diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-12 21:29:10 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-12 22:22:59 +0300 |
commit | 03889098f030471b88b007e03a1c5a5630434521 (patch) | |
tree | 4b60ab4f26e44908bf240254029976eb078fdaa0 /src/net | |
parent | c565936b3ac5b6e1ab0d5ca30963619c7b725bb6 (diff) | |
download | manaverse-03889098f030471b88b007e03a1c5a5630434521.tar.gz manaverse-03889098f030471b88b007e03a1c5a5630434521.tar.bz2 manaverse-03889098f030471b88b007e03a1c5a5630434521.tar.xz manaverse-03889098f030471b88b007e03a1c5a5630434521.zip |
Fix code style and other small issues.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/network.cpp | 4 | ||||
-rw-r--r-- | src/net/eathena/gamehandler.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/gamehandler.h | 2 | ||||
-rw-r--r-- | src/net/sdltcpnet.cpp | 26 | ||||
-rw-r--r-- | src/net/sdltcpnet.h | 11 |
5 files changed, 25 insertions, 20 deletions
diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index 112e16891..679447a50 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -145,7 +145,7 @@ void Network::flush() return; SDL_mutexP(mMutex); - int ret = TcpNet::send(mSocket, mOutBuffer, mOutSize); + const int ret = TcpNet::send(mSocket, mOutBuffer, mOutSize); DEBUGLOG(std::string("Send ").append(toString(mOutSize)).append(" bytes")); if (ret < static_cast<int>(mOutSize)) { @@ -254,7 +254,7 @@ void Network::receive() continue; } - int ret = TcpNet::recv(mSocket, mInBuffer + mInSize, + const int ret = TcpNet::recv(mSocket, mInBuffer + mInSize, BUFFER_SIZE - mInSize); if (!ret) diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp index 74f2a89ea..2ec9899c2 100644 --- a/src/net/eathena/gamehandler.cpp +++ b/src/net/eathena/gamehandler.cpp @@ -169,7 +169,7 @@ void GameHandler::disconnect2() const MessageOut outMsg(CMSG_CLIENT_DISCONNECT); } -void GameHandler::processMapCharId(Net::MessageIn &msg) +void GameHandler::processMapCharId(Net::MessageIn &msg) const { msg.readInt32(); // char id } diff --git a/src/net/eathena/gamehandler.h b/src/net/eathena/gamehandler.h index 4e3ef861b..2de3ccaac 100644 --- a/src/net/eathena/gamehandler.h +++ b/src/net/eathena/gamehandler.h @@ -56,7 +56,7 @@ class GameHandler final : public MessageHandler, public Ea::GameHandler void mapLoadedEvent() const override; - void processMapCharId(Net::MessageIn &msg); + void processMapCharId(Net::MessageIn &msg) const; bool mustPing() const override A_WARN_UNUSED { return true; } diff --git a/src/net/sdltcpnet.cpp b/src/net/sdltcpnet.cpp index b38bc8a67..97ed59443 100644 --- a/src/net/sdltcpnet.cpp +++ b/src/net/sdltcpnet.cpp @@ -24,14 +24,15 @@ #include "logger.h" #include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/tcp.h> -#include <netdb.h> #if defined(M_TCPOK) && !defined(ANDROID) +#include <netinet/in.h> +#include <netdb.h> #include <linux/tcp.h> #else -// using manual hack, because in this mode linux/tcp.h compiled with errors +#include <netinet/in.h> +#include <netinet/tcp.h> +#include <netdb.h> #include <netinet/tcp.h> // Use linear timeouts for thin streams #define TCP_THIN_LINEAR_TIMEOUTS 16 @@ -44,7 +45,8 @@ #include "debug.h" // because actual struct is hidden in SDL_net we reinroducing it here -struct TCPsocketHack { +struct TCPsocketHack +{ int ready; int channel; IPaddress remoteAddress; @@ -67,7 +69,7 @@ void TcpNet::closeSocket(TcpNet::Socket socket) SDLNet_TCP_Close(socket); } -int TcpNet::send(TcpNet::Socket sock, const void *data, int len) +int TcpNet::send(TcpNet::Socket sock, const void *const data, const int len) { return SDLNet_TCP_Send(sock, data, len); } @@ -77,17 +79,19 @@ char *TcpNet::getError() return SDLNet_GetError(); } -int TcpNet::resolveHost(IPaddress *address, const char *host, Uint16 port) +int TcpNet::resolveHost(IPaddress *const address, const char *host, + const Uint16 port) { return SDLNet_ResolveHost(address, host, port); } -TcpNet::Socket TcpNet::open(IPaddress *ip) +TcpNet::Socket TcpNet::open(IPaddress *const ip) { TcpNet::Socket sock = SDLNet_TCP_Open(ip); if (sock && ip) { - TCPsocketHack *hack = reinterpret_cast<TCPsocketHack *>(sock); + const TCPsocketHack *const hack + = reinterpret_cast<const TCPsocketHack *const>(sock); // here we using some magic to compare TCPsocket and own padding // because actual struct TCPsocket not in headers if (hack) @@ -116,7 +120,7 @@ TcpNet::Socket TcpNet::open(IPaddress *ip) return sock; } -TcpNet::SocketSet TcpNet::allocSocketSet(int maxsockets) +TcpNet::SocketSet TcpNet::allocSocketSet(const int maxsockets) { return SDLNet_AllocSocketSet(maxsockets); } @@ -126,7 +130,7 @@ int TcpNet::addSocket(TcpNet::SocketSet set, TcpNet::Socket sock) return SDLNet_TCP_AddSocket(set, sock); } -int TcpNet::checkSockets(TcpNet::SocketSet set, Uint32 timeout) +int TcpNet::checkSockets(const TcpNet::SocketSet set, const Uint32 timeout) { return SDLNet_CheckSockets(set, timeout); } diff --git a/src/net/sdltcpnet.h b/src/net/sdltcpnet.h index c13b84063..18cb1338c 100644 --- a/src/net/sdltcpnet.h +++ b/src/net/sdltcpnet.h @@ -38,19 +38,20 @@ namespace TcpNet void closeSocket(TcpNet::Socket socket); - int send(TcpNet::Socket sock, const void *data, int len); + int send(TcpNet::Socket sock, const void *const data, const int len); char *getError(); - int resolveHost(IPaddress *address, const char *host, Uint16 port); + int resolveHost(IPaddress *const address, const char *host, + const Uint16 port); - TcpNet::Socket open(IPaddress *ip); + TcpNet::Socket open(IPaddress *const ip); - SocketSet allocSocketSet(int maxsockets); + SocketSet allocSocketSet(const int maxsockets); int addSocket(TcpNet::SocketSet set, TcpNet::Socket sock); - int checkSockets(TcpNet::SocketSet set, Uint32 timeout); + int checkSockets(const TcpNet::SocketSet set, const Uint32 timeout); int recv(TcpNet::Socket sock, void *data, int maxlen); |