mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
[8897] More stricted checks for store operations.
* Use stricted definition valid pos for expected explicit pos cases * Prevent attempts add bag to self at autostore.
This commit is contained in:
parent
d48ce8b717
commit
5186046c5e
5 changed files with 20 additions and 18 deletions
|
|
@ -44,13 +44,13 @@ void WorldSession::HandleSplitItemOpcode( WorldPacket & recv_data )
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return; //check count - if zero it's fake packet
|
return; //check count - if zero it's fake packet
|
||||||
|
|
||||||
if(!_player->IsValidPos(srcbag, srcslot))
|
if(!_player->IsValidPos(srcbag, srcslot, true))
|
||||||
{
|
{
|
||||||
_player->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
|
_player->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_player->IsValidPos(dstbag, dstslot))
|
if(!_player->IsValidPos(dstbag, dstslot, false)) // can be autostore pos
|
||||||
{
|
{
|
||||||
_player->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL );
|
_player->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL );
|
||||||
return;
|
return;
|
||||||
|
|
@ -71,13 +71,13 @@ void WorldSession::HandleSwapInvItemOpcode( WorldPacket & recv_data )
|
||||||
if(srcslot == dstslot)
|
if(srcslot == dstslot)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!_player->IsValidPos(INVENTORY_SLOT_BAG_0, srcslot))
|
if(!_player->IsValidPos(INVENTORY_SLOT_BAG_0, srcslot, true))
|
||||||
{
|
{
|
||||||
_player->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
|
_player->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_player->IsValidPos(INVENTORY_SLOT_BAG_0,dstslot))
|
if(!_player->IsValidPos(INVENTORY_SLOT_BAG_0, dstslot, true))
|
||||||
{
|
{
|
||||||
_player->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL );
|
_player->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL );
|
||||||
return;
|
return;
|
||||||
|
|
@ -123,13 +123,13 @@ void WorldSession::HandleSwapItem( WorldPacket & recv_data )
|
||||||
if(src == dst)
|
if(src == dst)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!_player->IsValidPos(srcbag, srcslot))
|
if(!_player->IsValidPos(srcbag, srcslot, true))
|
||||||
{
|
{
|
||||||
_player->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
|
_player->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_player->IsValidPos(dstbag, dstslot))
|
if(!_player->IsValidPos(dstbag, dstslot, true))
|
||||||
{
|
{
|
||||||
_player->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL );
|
_player->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL );
|
||||||
return;
|
return;
|
||||||
|
|
@ -783,7 +783,7 @@ void WorldSession::HandleAutoStoreBagItemOpcode( WorldPacket & recv_data )
|
||||||
if( !pItem )
|
if( !pItem )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!_player->IsValidPos(dstbag, NULL_SLOT))
|
if(!_player->IsValidPos(dstbag, NULL_SLOT, false)) // can be autostore pos
|
||||||
{
|
{
|
||||||
_player->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL );
|
_player->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL );
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -2011,10 +2011,11 @@ bool ChatHandler::HandleItemMoveCommand(const char* args)
|
||||||
if(srcslot==dstslot)
|
if(srcslot==dstslot)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(!m_session->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0,srcslot))
|
if(!m_session->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, srcslot, true))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!m_session->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0,dstslot))
|
// can be autostore pos
|
||||||
|
if(!m_session->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0,dstslot, false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot);
|
uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot);
|
||||||
|
|
|
||||||
|
|
@ -8646,16 +8646,16 @@ bool Player::IsBagPos( uint16 pos )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::IsValidPos( uint8 bag, uint8 slot )
|
bool Player::IsValidPos( uint8 bag, uint8 slot, bool explicit_pos )
|
||||||
{
|
{
|
||||||
// post selected
|
// post selected
|
||||||
if(bag == NULL_BAG)
|
if(bag == NULL_BAG && !explicit_pos)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (bag == INVENTORY_SLOT_BAG_0)
|
if (bag == INVENTORY_SLOT_BAG_0)
|
||||||
{
|
{
|
||||||
// any post selected
|
// any post selected
|
||||||
if (slot == NULL_SLOT)
|
if (slot == NULL_SLOT && !explicit_pos)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// equipment
|
// equipment
|
||||||
|
|
@ -8693,7 +8693,7 @@ bool Player::IsValidPos( uint8 bag, uint8 slot )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// any post selected
|
// any post selected
|
||||||
if (slot == NULL_SLOT)
|
if (slot == NULL_SLOT && !explicit_pos)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return slot < pBag->GetBagSize();
|
return slot < pBag->GetBagSize();
|
||||||
|
|
@ -8707,7 +8707,7 @@ bool Player::IsValidPos( uint8 bag, uint8 slot )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// any post selected
|
// any post selected
|
||||||
if (slot == NULL_SLOT)
|
if (slot == NULL_SLOT && !explicit_pos)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return slot < pBag->GetBagSize();
|
return slot < pBag->GetBagSize();
|
||||||
|
|
@ -8999,8 +8999,9 @@ uint8 Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, ItemPrototy
|
||||||
if (bag==skip_bag)
|
if (bag==skip_bag)
|
||||||
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
|
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
|
||||||
|
|
||||||
|
// skip not existed bag or self targeted bag
|
||||||
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag );
|
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag );
|
||||||
if (!pBag)
|
if (!pBag || pBag==pSrcItem)
|
||||||
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
|
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
|
||||||
|
|
||||||
ItemPrototype const* pBagProto = pBag->GetProto();
|
ItemPrototype const* pBagProto = pBag->GetProto();
|
||||||
|
|
|
||||||
|
|
@ -1173,8 +1173,8 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
static bool IsBagPos( uint16 pos );
|
static bool IsBagPos( uint16 pos );
|
||||||
static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8, pos & 255); }
|
static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8, pos & 255); }
|
||||||
static bool IsBankPos( uint8 bag, uint8 slot );
|
static bool IsBankPos( uint8 bag, uint8 slot );
|
||||||
bool IsValidPos( uint16 pos ) { return IsBankPos(pos >> 8, pos & 255); }
|
bool IsValidPos( uint16 pos, bool explicit_pos ) { return IsValidPos(pos >> 8, pos & 255, explicit_pos); }
|
||||||
bool IsValidPos( uint8 bag, uint8 slot );
|
bool IsValidPos( uint8 bag, uint8 slot, bool explicit_pos );
|
||||||
uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, 2); }
|
uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, 2); }
|
||||||
void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, 2, count); }
|
void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, 2, count); }
|
||||||
bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false ) const;
|
bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false ) const;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8896"
|
#define REVISION_NR "8897"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue