diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-09-19 12:28:42 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-09-19 12:28:42 +0000 |
commit | 2c4d4ecc19fc8308b2772e4ffe6570ca362264d1 (patch) | |
tree | a4b6d78a89bfd12b3667129bd0bae63a805682cd /src/net | |
parent | cf0f74488b0f2057bc535774dc6a2c871311932f (diff) | |
download | mana-2c4d4ecc19fc8308b2772e4ffe6570ca362264d1.tar.gz mana-2c4d4ecc19fc8308b2772e4ffe6570ca362264d1.tar.bz2 mana-2c4d4ecc19fc8308b2772e4ffe6570ca362264d1.tar.xz mana-2c4d4ecc19fc8308b2772e4ffe6570ca362264d1.zip |
Got rid of writeSet() calls.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/messageout.cpp | 7 | ||||
-rw-r--r-- | src/net/network.cpp | 10 | ||||
-rw-r--r-- | src/net/network.h | 1 | ||||
-rw-r--r-- | src/net/protocol.cpp | 4 |
4 files changed, 5 insertions, 17 deletions
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index daf5ebf4..e7928a4d 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -36,8 +36,6 @@ MessageOut::MessageOut(): mDataSize(0), mPos(0) { - // TODO: data not to be already allocated, keep it this way unitl full - // conversion mData = out + out_size; } @@ -64,6 +62,7 @@ void MessageOut::writeByte(char value) expand(mPos + sizeof(char)); mData[mPos] = value; mPos += sizeof(char); + out_size += sizeof(char); } void MessageOut::writeShort(short value) @@ -76,6 +75,7 @@ void MessageOut::writeShort(short value) #endif //SDLNet_Write16(value, &mData[mPos]); mPos += sizeof(short); + out_size += sizeof(short); } void MessageOut::writeLong(long value) @@ -88,6 +88,7 @@ void MessageOut::writeLong(long value) #endif //SDLNet_Write32(value, &mData[mPos]); mPos += sizeof(long); + out_size += sizeof(long); } void MessageOut::writeString(const std::string &string, int length) @@ -110,12 +111,14 @@ void MessageOut::writeString(const std::string &string, int length) // Write the actual string memcpy(&mData[mPos], (void*)toWrite.c_str(), toWrite.length()); mPos += toWrite.length(); + out_size += toWrite.length(); // Pad remaining space with zeros if (length > (int)toWrite.length()) { memset(&mData[mPos], '\0', length - toWrite.length()); mPos += length - toWrite.length(); + out_size += length - toWrite.length(); } } diff --git a/src/net/network.cpp b/src/net/network.cpp index 570b31bb..7a3ecc09 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -279,16 +279,6 @@ get_next_message() return MessageIn(in, length); } -void writeSet(unsigned int value) -{ - if (out_size + value >= buffer_size) { - logger->log("Warning: Output buffer full"); - } - else { - out_size += value; - } -} - void skip(int len) { memcpy(in, in + len, in_size - len); diff --git a/src/net/network.h b/src/net/network.h index c6a4380b..47e71190 100644 --- a/src/net/network.h +++ b/src/net/network.h @@ -44,7 +44,6 @@ void flush(); MessageIn get_next_message(); extern char *out; -void writeSet(unsigned int value); void skip(int len); extern unsigned int in_size; /**< Amount of data in input buffer. */ diff --git a/src/net/protocol.cpp b/src/net/protocol.cpp index 318c446d..b56745fa 100644 --- a/src/net/protocol.cpp +++ b/src/net/protocol.cpp @@ -86,7 +86,6 @@ void map_start() outMsg.writeLong(session_ID1); outMsg.writeLong(session_ID2); outMsg.writeByte(sex); - writeSet(19); // Skip a mysterious 4 bytes while ((in_size < 4)|| (out_size > 0)) flush(); @@ -118,7 +117,6 @@ void map_start() // TODO: be able to reuse the same msg MessageOut newMsg; newMsg.writeShort(0x007d); - writeSet(2); } void walk(unsigned short x, unsigned short y, unsigned char direction) @@ -128,7 +126,6 @@ void walk(unsigned short x, unsigned short y, unsigned char direction) set_coordinates(temp, x, y, direction); outMsg.writeShort(0x0085); outMsg.writeString(temp, 3); - writeSet(5); } void action(char type, int id) @@ -137,7 +134,6 @@ void action(char type, int id) outMsg.writeShort(0x0089); outMsg.writeLong(id); outMsg.writeByte(type); - writeSet(7); } Being* attack(unsigned short x, unsigned short y, unsigned char direction) |