diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-18 17:48:29 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-18 17:49:00 +0200 |
commit | f98d003e354a1792117b7cbc771d1dd91475a156 (patch) | |
tree | dc2a297f7c4026394c9954ae4bfd4abd22ef9612 /src/net | |
parent | bb0a6cb25b2985fd1f74c9d27d5a46f6863e2dee (diff) | |
download | manaplus-f98d003e354a1792117b7cbc771d1dd91475a156.tar.gz manaplus-f98d003e354a1792117b7cbc771d1dd91475a156.tar.bz2 manaplus-f98d003e354a1792117b7cbc771d1dd91475a156.tar.xz manaplus-f98d003e354a1792117b7cbc771d1dd91475a156.zip |
Fix most old style cast except manaserv and libxml2 defines.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/download.cpp | 3 | ||||
-rw-r--r-- | src/net/messagein.cpp | 19 | ||||
-rw-r--r-- | src/net/messageout.cpp | 2 | ||||
-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 |
8 files changed, 34 insertions, 28 deletions
diff --git a/src/net/download.cpp b/src/net/download.cpp index 40d7c872a..aa2793ddb 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -92,7 +92,8 @@ unsigned long Download::fadler32(FILE *file) char *buffer = static_cast<char*>(malloc(fileSize)); const size_t read = fread(buffer, 1, fileSize, file); unsigned long adler = adler32(0L, Z_NULL, 0); - adler = adler32(static_cast<uInt>(adler), (Bytef*)buffer, read); + adler = adler32(static_cast<uInt>(adler), + reinterpret_cast<Bytef*>(buffer), read); free(buffer); return adler; diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index e39a443f1..9ffc052f6 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -30,8 +30,8 @@ #include "utils/stringutils.h" #define MAKEWORD(low, high) \ - ((unsigned short)(((unsigned char)(low)) | \ - ((unsigned short)((unsigned char)(high))) << 8)) + (static_cast<unsigned short>((static_cast<unsigned char>(low)) | \ + (static_cast<unsigned short>(static_cast<unsigned char>(high))) << 8)) namespace Net { @@ -121,14 +121,16 @@ void MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) break; } default: - logger->log("incorrect direction: %d", (int)direction); + logger->log("incorrect direction: %d", + static_cast<int>(direction)); // OOPSIE! Impossible or unknown direction = 0; } } mPos += 3; PacketCounters::incInBytes(3); - DEBUGLOG("readCoordinates: " + toString((int)x) + "," + toString((int)y)); + DEBUGLOG("readCoordinates: " + toString(static_cast<int>(x)) + + "," + toString(static_cast<int>(y))); } void MessageIn::readCoordinatePair(Uint16 &srcX, Uint16 &srcY, @@ -151,9 +153,10 @@ void MessageIn::readCoordinatePair(Uint16 &srcX, Uint16 &srcY, srcY = static_cast<unsigned short>(temp >> 4); } mPos += 5; - DEBUGLOG("readCoordinatePair: " + toString((int)srcX) + "," - + toString((int)srcY) + " " + toString((int)dstX) + "," - + toString((int)dstY)); + DEBUGLOG("readCoordinatePair: " + toString(static_cast<int>(srcX)) + "," + + toString(static_cast<int>(srcY)) + " " + + toString(static_cast<int>(dstX)) + "," + + toString(static_cast<int>(dstY))); PacketCounters::incInBytes(5); } @@ -161,7 +164,7 @@ void MessageIn::skip(unsigned int length) { mPos += length; PacketCounters::incInBytes(length); - DEBUGLOG("skip: " + toString((int)length)); + DEBUGLOG("skip: " + toString(static_cast<int>(length))); } std::string MessageIn::readString(int length) diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index 82123a2df..db7f4842e 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -45,7 +45,7 @@ MessageOut::MessageOut(short id _UNUSED_): void MessageOut::writeInt8(Sint8 value) { - DEBUGLOG("writeInt8: " + toString((int)value)); + DEBUGLOG("writeInt8: " + toString(static_cast<int>(value))); expand(1); mData[mPos] = value; mPos += 1; 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); |