mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
Better check client inventory pos data received in some client packets to skip invalid cases.
This commit is contained in:
parent
6f6ec21b72
commit
d54e53c709
4 changed files with 122 additions and 0 deletions
|
|
@ -8258,6 +8258,78 @@ bool Player::IsBagPos( uint16 pos )
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Player::IsValidPos( uint8 bag, uint8 slot )
|
||||
{
|
||||
// post selected
|
||||
if(bag == NULL_BAG)
|
||||
return true;
|
||||
|
||||
if (bag == INVENTORY_SLOT_BAG_0)
|
||||
{
|
||||
// any post selected
|
||||
if (slot == NULL_SLOT)
|
||||
return true;
|
||||
|
||||
// equipment
|
||||
if (slot < EQUIPMENT_SLOT_END)
|
||||
return true;
|
||||
|
||||
// bag equip slots
|
||||
if (slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END)
|
||||
return true;
|
||||
|
||||
// backpack slots
|
||||
if (slot >= INVENTORY_SLOT_ITEM_START && slot < INVENTORY_SLOT_ITEM_END)
|
||||
return true;
|
||||
|
||||
// keyring slots
|
||||
if (slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_END)
|
||||
return true;
|
||||
|
||||
// bank main slots
|
||||
if (slot >= BANK_SLOT_ITEM_START && slot < BANK_SLOT_ITEM_END)
|
||||
return true;
|
||||
|
||||
// bank bag slots
|
||||
if (slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// bag content slots
|
||||
if (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END)
|
||||
{
|
||||
Bag* pBag = (Bag*)GetItemByPos (INVENTORY_SLOT_BAG_0, bag);
|
||||
if(!pBag)
|
||||
return false;
|
||||
|
||||
// any post selected
|
||||
if (slot == NULL_SLOT)
|
||||
return true;
|
||||
|
||||
return slot < pBag->GetBagSize();
|
||||
}
|
||||
|
||||
// bank bag content slots
|
||||
if( bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END )
|
||||
{
|
||||
Bag* pBag = (Bag*)GetItemByPos (INVENTORY_SLOT_BAG_0, bag);
|
||||
if(!pBag)
|
||||
return false;
|
||||
|
||||
// any post selected
|
||||
if (slot == NULL_SLOT)
|
||||
return true;
|
||||
|
||||
return slot < pBag->GetBagSize();
|
||||
}
|
||||
|
||||
// where this?
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const
|
||||
{
|
||||
uint32 tempcount = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue