diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-01-22 02:20:43 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-01-22 02:20:43 +0300 |
commit | e71376322cbe85d59ca7d1a9d7f2a3db9ae9b914 (patch) | |
tree | 4e9f65c3ef67e6e06e1e1dca140e2d7ef6a22ff7 /src/net/messagein.cpp | |
parent | b6eb53b9abdf48b88cb1978b9af97f2a879d2717 (diff) | |
parent | acc25a7dffefb8b8b4e8022af918794d26048453 (diff) | |
download | plus-e71376322cbe85d59ca7d1a9d7f2a3db9ae9b914.tar.gz plus-e71376322cbe85d59ca7d1a9d7f2a3db9ae9b914.tar.bz2 plus-e71376322cbe85d59ca7d1a9d7f2a3db9ae9b914.tar.xz plus-e71376322cbe85d59ca7d1a9d7f2a3db9ae9b914.zip |
Merge commit 'v1.2.1.22' into stripped
Conflicts:
data/fonts/mplus-1p-bold.ttf
data/fonts/mplus-1p-regular.ttf
src/CMakeLists.txt
src/Makefile.am
src/guichan/gui.cpp
Diffstat (limited to 'src/net/messagein.cpp')
-rw-r--r-- | src/net/messagein.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 0fbf7162b..4fb61dc6a 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -241,4 +241,29 @@ std::string MessageIn::readRawString(int length) return str; } +char *MessageIn::readBytes(int length) +{ + // Get string length + if (length < 0) + length = readInt16(); + + // Make sure the string isn't erroneous + if (length < 0 || mPos + length > mLength) + { + mPos = mLength + 1; + DEBUGLOG("readBytesString error"); + return nullptr; + } + + char *buf = new char[length + 2]; + + memcpy (buf, mData + mPos, length); + buf[length] = 0; + buf[length + 1] = 0; + mPos += length; + + PacketCounters::incInBytes(length); + return buf; +} + } |