diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-25 19:47:33 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-25 19:47:33 +0000 |
commit | 1221231dc656368bf1595b7827ad3a48f38b33b7 (patch) | |
tree | d0b5691a3a027d46d57364f86727baaecce5f4e0 /src/messageout.h | |
parent | 87eecbfc7c7ac72cb1a57ba83e967c655213d116 (diff) | |
download | manaserv-1221231dc656368bf1595b7827ad3a48f38b33b7.tar.gz manaserv-1221231dc656368bf1595b7827ad3a48f38b33b7.tar.bz2 manaserv-1221231dc656368bf1595b7827ad3a48f38b33b7.tar.xz manaserv-1221231dc656368bf1595b7827ad3a48f38b33b7.zip |
Applied patch by Rogier, addressing TODOs in MessageOut and NetComputer.
Diffstat (limited to 'src/messageout.h')
-rw-r--r-- | src/messageout.h | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/messageout.h b/src/messageout.h index dac20f71..19997a0b 100644 --- a/src/messageout.h +++ b/src/messageout.h @@ -47,15 +47,21 @@ class MessageOut */ ~MessageOut(); - void writeByte(char value); /**< Writes a byte. */ - void writeShort(short value); /**< Writes a short. */ - void writeLong(long value); /**< Writes a long. */ + void + writeByte(char value); /**< Writes a byte. */ + + void + writeShort(short value); /**< Writes a short. */ + + void + writeLong(long value); /**< Writes a long. */ /** * Writes a string. If a fixed length is not given (-1), it is stored * as a short at the start of the string. */ - void writeString(const std::string &string, int length = -1); + void + writeString(const std::string &string, int length = -1); /** * Returns the content of the message. @@ -67,21 +73,19 @@ class MessageOut * Returns the length of the data. */ unsigned int - getDataSize() const { return mDataSize; } + getLength() const { return mPos; } private: /** - * Expand the packet data to be able to hold more data. - * - * NOTE: For performance enhancements this method could allocate extra - * memory in advance instead of expanding size every time more data is - * added. + * Ensures the capacity of the data buffer is large enough to hold the + * given amount of bytes. */ - void expand(size_t size); + void + expand(size_t size); char *mData; /**< Data building up. */ - unsigned int mDataSize; /**< Size of data. */ unsigned int mPos; /**< Position in the data. */ + unsigned int mDataSize; /**< Allocated datasize. */ }; -#endif +#endif //_TMWSERV_MESSAGEOUT_H_ |