diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/net/inventoryhandler.cpp | 6 | ||||
-rw-r--r-- | src/net/messagein.cpp | 20 | ||||
-rw-r--r-- | src/net/messagein.h | 15 |
4 files changed, 26 insertions, 22 deletions
@@ -1,4 +1,11 @@ +2007-08-14 Guillaume Melquiond <guillaume.melquiond@gmail.com> + + * src/net/messagein.h, src/net/messagein.cpp: Fixed error-prone + interface. + * src/net/inventoryhandler.cpp: Handled money as an inventory part. + 2007-08-14 Josh Langley <joshlangley[at]optusnet.com.au> + * gui/button.cpp, gui/inventorywindow.cpp, gui/inventorywindow.h, gui/item_amount.cpp, gui/item_amount.h, gui/itemcontainer.cpp, gui/itemcontainer.h, gui/popupmenu.cpp, gui/trade.cpp, inventory.cpp, diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp index ce01c3dc..354dd685 100644 --- a/src/net/inventoryhandler.cpp +++ b/src/net/inventoryhandler.cpp @@ -58,6 +58,12 @@ void InventoryHandler::handleMessage(MessageIn &msg) while (msg.getUnreadLength()) { int slot = msg.readByte(); + if (slot == 255) + { + player_node->setMoney(msg.readLong()); + continue; + } + int id = msg.readShort(); if (slot < EQUIPMENT_SIZE) { diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index a1707e06..e90084ff 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -36,37 +36,33 @@ MessageIn::MessageIn(const char *data, unsigned int length): mId = readShort(); } -MessageIn::~MessageIn() +int MessageIn::readByte() { -} - -char MessageIn::readByte() -{ - char value = -1; + int value = -1; if (mPos < mLength) { - value = mData[mPos]; + value = (unsigned char) mData[mPos]; } mPos += 1; return value; } -short MessageIn::readShort() +int MessageIn::readShort() { - short value = -1; + int value = -1; if (mPos + 2 <= mLength) { uint16_t t; memcpy(&t, mData + mPos, 2); - value = ENET_NET_TO_HOST_16(t); + value = (unsigned short) ENET_NET_TO_HOST_16(t); } mPos += 2; return value; } -long MessageIn::readLong() +int MessageIn::readLong() { - long value = -1; + int value = -1; if (mPos + 4 <= mLength) { uint32_t t; diff --git a/src/net/messagein.h b/src/net/messagein.h index cb8e44cd..37103f2c 100644 --- a/src/net/messagein.h +++ b/src/net/messagein.h @@ -41,16 +41,11 @@ class MessageIn */ MessageIn(const char *data, unsigned int length); - /** - * Destructor. - */ - ~MessageIn(); - - short getId() { return mId; } /**< Returns the message ID. */ + int getId() { return mId; } /**< Returns the message ID. */ - char readByte(); /**< Reads a byte. */ - short readShort(); /**< Reads a short. */ - long readLong(); /**< Reads a long. */ + int readByte(); /**< Reads a byte. */ + int readShort(); /**< Reads a short. */ + int readLong(); /**< Reads a long. */ /** * Reads a 3-byte block containing tile-based coordinates. @@ -79,7 +74,7 @@ class MessageIn private: const char* mData; /**< The message data. */ unsigned int mLength; /**< The length of the data. */ - short mId; /**< The message ID. */ + unsigned short mId; /**< The message ID. */ /** * Actual position in the packet. From 0 to packet->length. |