summaryrefslogtreecommitdiff
path: root/src/net/messagein.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-11 14:48:19 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-11 15:24:57 +0300
commitf1b82c1b06604c2c1eed750a6c980aa0b5355560 (patch)
tree3e524583691af0e5a17e5ee974439b4c6ea07ef4 /src/net/messagein.cpp
parent452f2489bf3225235797ea08ea0d466f80409a87 (diff)
downloadmanaverse-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.gz
manaverse-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.bz2
manaverse-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.xz
manaverse-f1b82c1b06604c2c1eed750a6c980aa0b5355560.zip
First part of checks from Parasoft C++ Test.
Diffstat (limited to 'src/net/messagein.cpp')
-rw-r--r--src/net/messagein.cpp35
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);
}