diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-10-11 14:48:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-10-11 15:24:57 +0300 |
commit | f1b82c1b06604c2c1eed750a6c980aa0b5355560 (patch) | |
tree | 3e524583691af0e5a17e5ee974439b4c6ea07ef4 /src/net/messagein.cpp | |
parent | 452f2489bf3225235797ea08ea0d466f80409a87 (diff) | |
download | manaplus-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.gz manaplus-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.bz2 manaplus-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.xz manaplus-f1b82c1b06604c2c1eed750a6c980aa0b5355560.zip |
First part of checks from Parasoft C++ Test.
Diffstat (limited to 'src/net/messagein.cpp')
-rw-r--r-- | src/net/messagein.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 219ef8a2f..28a16cfbd 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -121,13 +121,21 @@ void MessageIn::readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction) serverDir = static_cast<uint8_t>(data[2] & 0x000f); direction = fromServerDirection(serverDir); + + DEBUGLOG(std::string("readCoordinates: ").append(toString( + static_cast<int>(x))).append(",").append(toString( + static_cast<int>(y))).append(",").append(toString( + static_cast<int>(serverDir)))); + } + else + { + x = 0; + y = 0; + direction = 0; + logger->log("error: wrong readCoordinates packet"); } mPos += 3; PacketCounters::incInBytes(3); - DEBUGLOG(std::string("readCoordinates: ").append(toString( - static_cast<int>(x))).append(",").append(toString( - static_cast<int>(y))).append(",").append(toString( - static_cast<int>(serverDir)))); } void MessageIn::readCoordinatePair(uint16_t &srcX, uint16_t &srcY, @@ -146,13 +154,22 @@ void MessageIn::readCoordinatePair(uint16_t &srcX, uint16_t &srcY, temp = MAKEWORD(data[2], data[1] & 0x003f); srcY = static_cast<uint16_t>(temp >> 4); + + DEBUGLOG(std::string("readCoordinatePair: ").append(toString( + static_cast<int>(srcX))).append(",").append(toString( + static_cast<int>(srcY))).append(" ").append(toString( + static_cast<int>(dstX))).append(",").append(toString( + static_cast<int>(dstY)))); + } + else + { + srcX = 0; + srcY = 0; + dstX = 0; + dstY = 0; + logger->log("error: wrong readCoordinatePair packet"); } mPos += 5; - DEBUGLOG(std::string("readCoordinatePair: ").append(toString( - static_cast<int>(srcX))).append(",").append(toString( - static_cast<int>(srcY))).append(" ").append(toString( - static_cast<int>(dstX))).append(",").append(toString( - static_cast<int>(dstY)))); PacketCounters::incInBytes(5); } |