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 | |
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.
-rw-r--r-- | src/being.h | 2 | ||||
-rw-r--r-- | src/map.cpp | 2 | ||||
-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 | ||||
-rw-r--r-- | src/particleemitter.cpp | 3 | ||||
-rw-r--r-- | src/resources/resource.h | 2 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 2 | ||||
-rw-r--r-- | src/utils/process.cpp | 4 |
11 files changed, 33 insertions, 27 deletions
diff --git a/src/being.h b/src/being.h index 02d3db68e..40f29a58d 100644 --- a/src/being.h +++ b/src/being.h @@ -276,7 +276,7 @@ class Being : public ActorSprite, public ConfigListener * @param type the attack type */ void handleAttack(Being *const victim, const int damage, - const int attackId = 1); + const int attackId = 1); virtual void handleSkill(Being *const victim, const int damage, const int skillId, const int skillLevel); diff --git a/src/map.cpp b/src/map.cpp index 94b797d43..8e2bca209 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -566,7 +566,7 @@ void Map::drawCollision(Graphics *const graphics, void Map::updateAmbientLayers(const float scrollX, const float scrollY) { BLOCK_START("Map::updateAmbientLayers") - static int lastTick = tick_time; // static = only initialized at first call + static int lastTick = tick_time; if (mLastAScrollX == 0.0f && mLastAScrollY == 0.0f) { 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); diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index 1ae439e97..5e7fcb2c6 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -140,7 +140,8 @@ ParticleEmitter::ParticleEmitter(const XmlNodePtr emitterNode, { mParticleGravity = readParticleEmitterProp(propertyNode, 0.0f); } - else if (name == "randomnes" || name == "randomness") // legacy bug + else if (name == "randomnes" + || name == "randomness") // legacy bug { mParticleRandomness = readParticleEmitterProp(propertyNode, 0); } diff --git a/src/resources/resource.h b/src/resources/resource.h index 0577a3569..bfb93a700 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -87,7 +87,7 @@ class Resource std::string getSource() const A_WARN_UNUSED { return mSource; } - void setProtected(bool b) + void setProtected(const bool b) { mProtected = b; } bool isProtected() const diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 2baf09340..0cff31f0a 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -783,7 +783,7 @@ struct WalkLayerLoader }; WalkLayer *ResourceManager::getWalkLayer(const std::string &name, - Map *const map) + Map *const map) { WalkLayerLoader rl = {name, map}; return static_cast<WalkLayer*>(get("map_" + name, diff --git a/src/utils/process.cpp b/src/utils/process.cpp index ec9eea548..39f4a5813 100644 --- a/src/utils/process.cpp +++ b/src/utils/process.cpp @@ -55,7 +55,7 @@ int execFileWait(std::string pathName, std::string name A_UNUSED, if (!arg2.empty()) args.append(" ").append(arg2); - if (CreateProcess(pathName.c_str(), static_cast<char*>(args.c_str()), + if (CreateProcess(pathName.c_str(), const_cast<char*>(args.c_str()), nullptr, nullptr, false, CREATE_DEFAULT_ERROR_MODE, nullptr, nullptr, &siStartupInfo, &piProcessInfo) != false) { @@ -231,7 +231,7 @@ bool execFile(std::string pathName, std::string name, #ifdef WIN32 bool openBrowser(std::string url) { - return static_cast<int>(ShellExecute(nullptr, "open", + return reinterpret_cast<int>(ShellExecute(nullptr, "open", replaceAll(url, " ", "").c_str(), nullptr, nullptr, SW_SHOWNORMAL)) > 32; } |