From 3fb968387deba0cbfd59d029aa6cf4789d68d09c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 23 May 2016 20:53:16 +0300 Subject: Dont show asserts in pickup special packets. --- src/net/eathena/inventoryrecv.cpp | 43 +++++++++++++++++++++++++++++---------- src/net/tmwa/inventoryrecv.cpp | 43 +++++++++++++++++++++++++++++---------- src/resources/db/itemdb.cpp | 5 +++++ src/resources/db/itemdb.h | 2 ++ 4 files changed, 71 insertions(+), 22 deletions(-) diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp index dea3a411f..4ca2f042e 100644 --- a/src/net/eathena/inventoryrecv.cpp +++ b/src/net/eathena/inventoryrecv.cpp @@ -243,7 +243,6 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) } const ItemColor color = ItemColorManager::getColorFromCards(&cards[0]); - const ItemInfo &itemInfo = ItemDB::get(itemId); BeingId floorId; if (Ea::InventoryRecv::mSentPickups.empty()) { @@ -285,22 +284,44 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) } if (localPlayer) { - localPlayer->pickedUp(itemInfo, - 0, - color, - floorId, - pickup); + if (itemId == 0) + { + localPlayer->pickedUp(ItemDB::getEmpty(), + 0, + color, + floorId, + pickup); + } + else + { + localPlayer->pickedUp(ItemDB::get(itemId), + 0, + color, + floorId, + pickup); + } } } else { if (localPlayer) { - localPlayer->pickedUp(itemInfo, - amount, - color, - floorId, - Pickup::OKAY); + if (itemId == 0) + { + localPlayer->pickedUp(ItemDB::getEmpty(), + amount, + color, + floorId, + Pickup::OKAY); + } + else + { + localPlayer->pickedUp(ItemDB::get(itemId), + amount, + color, + floorId, + Pickup::OKAY); + } } if (inventory) diff --git a/src/net/tmwa/inventoryrecv.cpp b/src/net/tmwa/inventoryrecv.cpp index 878a03538..9d753efe2 100644 --- a/src/net/tmwa/inventoryrecv.cpp +++ b/src/net/tmwa/inventoryrecv.cpp @@ -159,7 +159,6 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) cards[f] = msg.readUInt16("card"); const int equipType = msg.readInt16("equip type"); const ItemTypeT type = static_cast(msg.readUInt8("item type")); - const ItemInfo &itemInfo = ItemDB::get(itemId); const unsigned char err = msg.readUInt8("status"); BeingId floorId; if (Ea::InventoryRecv::mSentPickups.empty()) @@ -202,22 +201,44 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) } if (localPlayer) { - localPlayer->pickedUp(itemInfo, - 0, - ItemColor_one, - floorId, - pickup); + if (itemId == 0) + { + localPlayer->pickedUp(ItemDB::getEmpty(), + 0, + ItemColor_one, + floorId, + pickup); + } + else + { + localPlayer->pickedUp(ItemDB::get(itemId), + 0, + ItemColor_one, + floorId, + pickup); + } } } else { if (localPlayer) { - localPlayer->pickedUp(itemInfo, - amount, - ItemColor_one, - floorId, - Pickup::OKAY); + if (itemId == 0) + { + localPlayer->pickedUp(ItemDB::getEmpty(), + amount, + ItemColor_one, + floorId, + Pickup::OKAY); + } + else + { + localPlayer->pickedUp(ItemDB::get(itemId), + amount, + ItemColor_one, + floorId, + Pickup::OKAY); + } } if (inventory) diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index 6c79c12e8..3438c59ad 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -780,6 +780,11 @@ const ItemDB::ItemInfos &ItemDB::getItemInfos() return mItemInfos; } +const ItemInfo &ItemDB::getEmpty() +{ + return *mUnknown; +} + static int parseSpriteName(const std::string &name) { int id = -1; diff --git a/src/resources/db/itemdb.h b/src/resources/db/itemdb.h index d8706ef31..b0aceef32 100644 --- a/src/resources/db/itemdb.h +++ b/src/resources/db/itemdb.h @@ -58,6 +58,8 @@ namespace ItemDB const ItemInfo &get(const int id) A_WARN_UNUSED; const ItemInfo &get(const std::string &name) A_WARN_UNUSED; + const ItemInfo &getEmpty() A_WARN_UNUSED; + int getNumOfHairstyles() A_WARN_UNUSED; // Items database -- cgit v1.2.3-60-g2f50