From 8c30aafe9a54e4548d3b0817a9f46a536562f3a7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 13 Jan 2011 20:50:58 +0200 Subject: Fix again equipment window (F4) issue and adding checks. Now equipment window now worked if was empty inventory in connection movinf to other map. --- src/net/tmwa/inventoryhandler.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/net/tmwa/inventoryhandler.cpp') diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 23a1e78b1..186f9ceb3 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -166,9 +166,12 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) case SMSG_PLAYER_STORAGE_ITEMS: if (msg.getId() == SMSG_PLAYER_INVENTORY) { - // Clear inventory - this will be a complete refresh - mEquips.clear(); - PlayerInfo::getEquipment()->setBackend(&mEquips); + if (PlayerInfo::getEquipment()) + { + // Clear inventory - this will be a complete refresh + mEquips.clear(); + PlayerInfo::getEquipment()->setBackend(&mEquips); + } if (inventory) inventory->clear(); @@ -255,6 +258,12 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) break; case SMSG_PLAYER_INVENTORY_ADD: + if (PlayerInfo::getEquipment() + && !PlayerInfo::getEquipment()->getBackend()) + { // look like SMSG_PLAYER_INVENTORY was not received + mEquips.clear(); + PlayerInfo::getEquipment()->setBackend(&mEquips); + } index = msg.readInt16() - INVENTORY_OFFSET; amount = msg.readInt16(); itemId = msg.readInt16(); @@ -426,7 +435,8 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) case SMSG_PLAYER_EQUIPMENT: msg.readInt16(); // length - if (!PlayerInfo::getEquipment()->getBackend()) + if (PlayerInfo::getEquipment() + && !PlayerInfo::getEquipment()->getBackend()) { // look like SMSG_PLAYER_INVENTORY was not received mEquips.clear(); PlayerInfo::getEquipment()->setBackend(&mEquips); -- cgit v1.2.3-60-g2f50