Fix for issue . Added check to prevent sale of bags with items in them

This commit is contained in:
Devn00b 2022-10-27 21:01:19 -07:00
parent 63b2c7d54c
commit d28af745d8
3 changed files with 21 additions and 1 deletions
EQ2/source/WorldServer

View file

@ -3754,7 +3754,16 @@ vector<Item*>* PlayerItemList::GetItemsFromBagID(sint32 bag_id){
}
return ret;
}
int32 PlayerItemList::GetItemCountInBag(Item* bag){
MPlayerItems.readlock(__FUNCTION__, __LINE__);
if(bag && bag->IsBag() && items.count(bag->details.bag_id) > 0){
int32 bagitems = items.count(bag->details.bag_id);
MPlayerItems.releasereadlock(__FUNCTION__, __LINE__);
return bagitems;
}
MPlayerItems.releasereadlock(__FUNCTION__, __LINE__);
return 0;
}
vector<Item*>* PlayerItemList::GetItemsInBag(Item* bag){
vector<Item*>* ret_items = new vector<Item*>;
MPlayerItems.readlock(__FUNCTION__, __LINE__);

View file

@ -1133,6 +1133,8 @@ public:
int32 CheckSlotConflict(Item* tmp, bool check_lore_only = false, bool lock_mutex = true, int16* lore_stack_count = 0);
int32 GetItemCountInBag(Item* bag);
Mutex MPlayerItems;
private:
void AddItemToPacket(PacketStruct* packet, Player* player, Item* item, int16 i, bool overflow = false);

View file

@ -6968,6 +6968,15 @@ void Client::SellItem(int32 item_id, int16 quantity, int32 unique_id) {
SimpleMessage(CHANNEL_COLOR_RED, "This item has no value.");
return;
}
else if (item->IsBag())
{
int32 bagitemcount = player->GetPlayerItemList()->GetItemCountInBag(item);
if (bagitemcount > 0) {
SimpleMessage(CHANNEL_COLOR_RED, "You cannot sell a bag with items inside it.");
return;
}
}
int32 sell_price = (int32)(master_item->sell_price * multiplier);
if (sell_price > item->sell_price)
sell_price = item->sell_price;