From 391133cb8fa98d43b2068b06f4c2d1e371607837 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 24 Dec 2009 01:23:40 +0300 Subject: [PATCH] [9052] Fixed possible crash at fake items swap packet. --- src/game/Player.cpp | 19 +++++++++++++------ src/shared/revision_nr.h | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 968299f28..fdc8e9adf 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -11221,12 +11221,12 @@ void Player::SwapItem( uint16 src, uint16 dst ) Item *pSrcItem = GetItemByPos( srcbag, srcslot ); Item *pDstItem = GetItemByPos( dstbag, dstslot ); - if( !pSrcItem ) + if (!pSrcItem) return; sLog.outDebug( "STORAGE: SwapItem bag = %u, slot = %u, item = %u", dstbag, dstslot, pSrcItem->GetEntry()); - if(!isAlive() ) + if (!isAlive()) { SendEquipError( EQUIP_ERR_YOU_ARE_DEAD, pSrcItem, pDstItem ); return; @@ -11234,7 +11234,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) // SRC checks - if(pSrcItem->m_lootGenerated) // prevent swap looting item + if (pSrcItem->m_lootGenerated) // prevent swap looting item { //best error message found for attempting to swap while looting SendEquipError( EQUIP_ERR_CANT_DO_RIGHT_NOW, pSrcItem, NULL ); @@ -11242,11 +11242,11 @@ void Player::SwapItem( uint16 src, uint16 dst ) } // check unequip potability for equipped items and bank bags - if(IsEquipmentPos ( src ) || IsBagPos ( src )) + if (IsEquipmentPos(src) || IsBagPos(src)) { // bags can be swapped with empty bag slots, or with empty bag (items move possibility checked later) uint8 msg = CanUnequipItem( src, !IsBagPos ( src ) || IsBagPos ( dst ) || (pDstItem && pDstItem->IsBag() && ((Bag*)pDstItem)->IsEmpty())); - if(msg != EQUIP_ERR_OK) + if (msg != EQUIP_ERR_OK) { SendEquipError( msg, pSrcItem, pDstItem ); return; @@ -11254,12 +11254,19 @@ void Player::SwapItem( uint16 src, uint16 dst ) } // prevent put equipped/bank bag in self - if( IsBagPos ( src ) && srcslot == dstbag) + if (IsBagPos(src) && srcslot == dstbag) { SendEquipError( EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pSrcItem, pDstItem ); return; } + // prevent put equipped/bank bag in self + if (IsBagPos(dst) && dstslot == srcbag) + { + SendEquipError( EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pDstItem, pSrcItem ); + return; + } + // DST checks if (pDstItem) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 17ef69ea5..a0819017f 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9051" + #define REVISION_NR "9052" #endif // __REVISION_NR_H__