diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-06-26 21:32:52 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-06-26 21:32:52 +0000 |
commit | 5cfc34ebc292c82f7ec7ce19e36bf0774986b270 (patch) | |
tree | f329fd18eeab2ffa2563b09e8512d7a5ba909f2b | |
parent | 579ccd64cc098f4caa4ba1ebc6918488788b2a57 (diff) | |
download | mana-5cfc34ebc292c82f7ec7ce19e36bf0774986b270.tar.gz mana-5cfc34ebc292c82f7ec7ce19e36bf0774986b270.tar.bz2 mana-5cfc34ebc292c82f7ec7ce19e36bf0774986b270.tar.xz mana-5cfc34ebc292c82f7ec7ce19e36bf0774986b270.zip |
Fixed the readString method (synchronized with the server version by Guillaume
Melquiond).
-rw-r--r-- | ChangeLog | 30 | ||||
-rw-r--r-- | src/net/messagein.cpp | 28 |
2 files changed, 30 insertions, 28 deletions
@@ -1,3 +1,8 @@ +2006-06-26 Bjørn Lindeijer <bjorn@lindeijer.nl> + + * src/net/messagein.cpp: Fixed the readString method (synchronized + with the server version by Guillaume Melquiond). + 2006-06-21 Eugenio Favalli <elvenprogrammer@gmail.com> * data/graphics/sprites/Makefile.am, @@ -93,21 +98,22 @@ 2006-04-28 Philipp Sehmisch <tmw@crushnet.org> * data/graphics/tiles/Woodland_ground.png: Graphical update of the - woodland tileset. Paths improved, and tiles that were redunant replaced - by new dirt tiles. - * data/maps/new_9.1.tmx.gz: modified because of changes in the tileset - layout (no new server sided walkmap required) - * data/graphics/sprites/monster11.png: improved the shading of the mushroom - monster - * data/graphics/sprites/monster15.png: added dropshadow to the bat monster - (note that the version 0.0.19 live update overrides the changed file) + woodland tileset. Paths improved, and tiles that were redunant + replaced by new dirt tiles. + * data/maps/new_9.1.tmx.gz: Modified because of changes in the tileset + layout (no new server sided walkmap required). + * data/graphics/sprites/monster11.png: Improved the shading of the + mushroom monster. + * data/graphics/sprites/monster15.png: Added dropshadow to the bat + monster (note that the version 0.0.19 live update overrides the + changed file). 2006-04-04 Bjørn Lindeijer <bjorn@lindeijer.nl> * ChangeLog: Converted to UTF-8. * NEWS: Spelling correction. - * docs/INSTALL/debian.txt, docs/INSTALL/win32.txt: Updated with respect - to the move from CVS to Subversion. + * docs/INSTALL/debian.txt, docs/INSTALL/win32.txt: Updated with + respect to the move from CVS to Subversion. 2006-03-25 Eugenio Favalli <elvenprogrammer@gmail.com> @@ -177,7 +183,7 @@ 2006-03-13 Philipp Sehmisch <tmw@crushnet.org> - * data/maps/new_7.1.tmx.gz: fixed some map bugs (update of server sided + * data/maps/new_7.1.tmx.gz: Fixed some map bugs (update of server sided walkmap required!) 2006-03-11 Eugenio Favalli <elvenprogrammer@gmail.com> @@ -2199,4 +2205,4 @@ restore some doxygen comments, improved size adaption and made the window a shorter. * data/graphics/images/login_wallpaper.png: New login wallpaper by - Momotaro.
\ No newline at end of file + Momotaro. diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 9abe4a2d..bbc0a44c 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -155,28 +155,24 @@ MessageIn::skip(unsigned int length) std::string MessageIn::readString(int length) { - int stringLength = 0; - // Get string length if (length < 0) { - stringLength = readInt16(); - } else { - stringLength = length; + length = readInt16(); } - // Make sure there is enough data available - assert(mPos + length <= mLength); + // Make sure the string isn't erroneous + if (length < 0 || mPos + length > mLength) { + mPos = mLength + 1; + return ""; + } // Read the string - char *tmpString = new char[stringLength + 1]; - memcpy(tmpString, (void*)&mData[mPos], stringLength); - tmpString[stringLength] = 0; - mPos += stringLength; - - std::string read = tmpString; - delete[] tmpString; - - return read; + char const *stringBeg = mData + mPos; + char const *stringEnd = (char const *)memchr(stringBeg, '\0', length); + std::string readString(stringBeg, + stringEnd ? stringEnd - stringBeg : length); + mPos += length; + return readString; } Sint8& operator<<(Sint8 &lhs, MessageIn &msg) |