diff options
Diffstat (limited to 'src/net/tmwa')
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 13 | ||||
-rw-r--r-- | src/net/tmwa/messagein.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/messageout.cpp | 10 | ||||
-rw-r--r-- | src/net/tmwa/network.cpp | 8 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 5 |
5 files changed, 20 insertions, 18 deletions
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 74a620ce3..f066db0bd 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -179,7 +179,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) speed = msg.readInt16(); stunMode = msg.readInt16(); // opt1 statusEffects = msg.readInt16(); // opt2 - statusEffects |= ((Uint32)msg.readInt16()) << 16; // option + statusEffects |= (static_cast<Uint32>( + msg.readInt16())) << 16; // option job = msg.readInt16(); // class dstBeing = actorSpriteManager->findBeing(id); @@ -500,12 +501,12 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) if (dstBeing) { dstBeing->takeDamage(srcBeing, param1, - (Being::AttackType)type); + static_cast<Being::AttackType>(type)); } if (srcBeing) { srcBeing->handleAttack(dstBeing, param1, - (Being::AttackType)type); + static_cast<Being::AttackType>(type)); if (srcBeing->getType() == Being::PLAYER) srcBeing->setAttackTime(); } @@ -560,7 +561,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) if (!effectManager) return; - id = (Uint32)msg.readInt32(); + id = static_cast<Uint32>(msg.readInt32()); Being* being = actorSpriteManager->findBeing(id); if (!being) break; @@ -843,7 +844,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) speed = msg.readInt16(); stunMode = msg.readInt16(); // opt1; Aethyra use this as cape statusEffects = msg.readInt16(); // opt2; Aethyra use this as misc1 - statusEffects |= ((Uint32) msg.readInt16()) + statusEffects |= (static_cast<Uint32>(msg.readInt16())) << 16; // status.options; Aethyra uses this as misc2 job = msg.readInt16(); @@ -1100,7 +1101,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) stunMode = msg.readInt16(); statusEffects = msg.readInt16(); - statusEffects |= ((Uint32) msg.readInt16()) << 16; + statusEffects |= (static_cast<Uint32>(msg.readInt16())) << 16; msg.readInt8(); // Unused? dstBeing->setStunMode(stunMode); diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp index 3e079ed75..ca32b1df4 100644 --- a/src/net/tmwa/messagein.cpp +++ b/src/net/tmwa/messagein.cpp @@ -60,7 +60,7 @@ Sint16 MessageIn::readInt16() } mPos += 2; PacketCounters::incInBytes(2); - DEBUGLOG("readInt16: " + toString((int)value)); + DEBUGLOG("readInt16: " + toString(static_cast<int>(value))); return value; } diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp index c12105581..17314937d 100644 --- a/src/net/tmwa/messageout.cpp +++ b/src/net/tmwa/messageout.cpp @@ -55,7 +55,7 @@ void MessageOut::expand(size_t bytes) void MessageOut::writeInt16(Sint16 value) { - DEBUGLOG("writeInt16: " + toString((int)value)); + DEBUGLOG("writeInt16: " + toString(static_cast<int>(value))); expand(2); #if SDL_BYTEORDER == SDL_BIG_ENDIAN Sint16 swap = SDL_Swap16(value); @@ -81,8 +81,8 @@ void MessageOut::writeInt32(Sint32 value) PacketCounters::incOutBytes(4); } -#define LOBYTE(w) ((unsigned char)(w)) -#define HIBYTE(w) ((unsigned char)(((unsigned short)(w)) >> 8)) +#define LOBYTE(w) (static_cast<unsigned char>(w)) +#define HIBYTE(w) (static_cast<unsigned char>((static_cast<unsigned short>(w)) >> 8)) void MessageOut::writeCoordinates(unsigned short x, unsigned short y, unsigned char direction) @@ -99,7 +99,7 @@ void MessageOut::writeCoordinates(unsigned short x, unsigned short y, data[1] = 1; data[2] = 2; data[0] = HIBYTE(temp); - data[1] = (unsigned char) temp; + data[1] = static_cast<unsigned char>(temp); temp = y; temp <<= 4; data[1] |= HIBYTE(temp); @@ -134,7 +134,7 @@ void MessageOut::writeCoordinates(unsigned short x, unsigned short y, break; default: // OOPSIE! Impossible or unknown - direction = (unsigned char) -1; + direction = static_cast<unsigned char>(-1); } data[2] |= direction; PacketCounters::incOutBytes(3); diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index ad8be300c..5beb05c20 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -257,7 +257,7 @@ void Network::flush() SDL_mutexP(mMutex); ret = SDLNet_TCP_Send(mSocket, mOutBuffer, mOutSize); - if (ret < (int)mOutSize) + if (ret < static_cast<int>(mOutSize)) { setError("Error in SDLNet_TCP_Send(): " + std::string(SDLNet_GetError())); @@ -396,7 +396,7 @@ void Network::receive() { // TODO Try to get this to block all the time while still being able // to escape the loop - int numReady = SDLNet_CheckSockets(set, ((Uint32)500)); + int numReady = SDLNet_CheckSockets(set, (static_cast<Uint32>(500))); int ret; switch (numReady) { @@ -476,9 +476,9 @@ void Network::setError(const std::string &error) Uint16 Network::readWord(int pos) { #if SDL_BYTEORDER == SDL_BIG_ENDIAN - return SDL_Swap16((*(Uint16*)(mInBuffer + (pos)))); + return SDL_Swap16((*static_cast<Uint16*>(mInBuffer + (pos)))); #else - return (*(Uint16*)(mInBuffer + (pos))); + return (*reinterpret_cast<Uint16*>(mInBuffer + (pos))); #endif } diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 8ba323268..55908093f 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -241,8 +241,9 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) // player_node->updateNavigateList(); } - logger->log("Adjust scrolling by %d:%d", (int) scrollOffsetX, - (int) scrollOffsetY); + logger->log("Adjust scrolling by %d:%d", + static_cast<int>(scrollOffsetX), + static_cast<int>(scrollOffsetY)); if (viewport) viewport->scrollBy(scrollOffsetX, scrollOffsetY); |