[8121] Cleanup and more safe code in Player::BuyItemFromVendor use. Author: VladimirMangos
* Move bag search by bag guid code to WorldSession::HandleBuyItemInSlotOpcode
* Really reject unexisted bag cases.
--HG--
branch : trunk
This commit is contained in:
+11
-11
@@ -22,17 +22,6 @@
|
||||
SUBDIRS = dep doc src
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
# Win32 project workspace for Visual Studio .NET 2003
|
||||
EXTRA_DIST = \
|
||||
win/mangosdVC71.sln \
|
||||
win/VC71/framework.vcproj \
|
||||
win/VC71/game.vcproj \
|
||||
win/VC71/mangosd.vcproj \
|
||||
win/VC71/realmd.vcproj \
|
||||
win/VC71/shared.vcproj \
|
||||
win/VC71/zlib.vcproj \
|
||||
win/VC71/g3dlite.vcproj
|
||||
|
||||
# Win32 project workspace for Visual Studio .NET 2005
|
||||
EXTRA_DIST += \
|
||||
win/mangosdVC80.sln \
|
||||
@@ -55,3 +44,14 @@ EXTRA_DIST += \
|
||||
win/VC90/zlib.vcproj \
|
||||
win/VC90/g3dlite.vcproj
|
||||
|
||||
# Win32 project workspace for Visual Studio .NET 2010
|
||||
EXTRA_DIST = \
|
||||
win/mangosdVC100.sln \
|
||||
win/VC100/framework.vcxproj \
|
||||
win/VC100/game.vcxproj \
|
||||
win/VC100/mangosd.vcxproj \
|
||||
win/VC100/realmd.vcxproj \
|
||||
win/VC100/shared.vcxproj \
|
||||
win/VC100/zlib.vcxproj \
|
||||
win/VC100/g3dlite.vcxproj
|
||||
|
||||
|
||||
@@ -674,7 +674,31 @@ void WorldSession::HandleBuyItemInSlotOpcode( WorldPacket & recv_data )
|
||||
|
||||
recv_data >> vendorguid >> item >> slot >> bagguid >> bagslot >> count;
|
||||
|
||||
GetPlayer()->BuyItemFromVendor(vendorguid,item,count,bagguid,bagslot);
|
||||
uint8 bag = NULL_BAG; // init for case invalid bagGUID
|
||||
|
||||
// find bag slot by bag guid
|
||||
if (bagguid == _player->GetGUID())
|
||||
bag = INVENTORY_SLOT_BAG_0;
|
||||
else
|
||||
{
|
||||
for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END;++i)
|
||||
{
|
||||
if (Bag *pBag = (Bag*)_player->GetItemByPos(INVENTORY_SLOT_BAG_0,i))
|
||||
{
|
||||
if (bagguid == pBag->GetGUID())
|
||||
{
|
||||
bag = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bag not found, cheating?
|
||||
if (bag == NULL_BAG)
|
||||
return;
|
||||
|
||||
GetPlayer()->BuyItemFromVendor(vendorguid,item,count,bag,bagslot);
|
||||
}
|
||||
|
||||
void WorldSession::HandleBuyItemOpcode( WorldPacket & recv_data )
|
||||
|
||||
+5
-1
@@ -17854,7 +17854,7 @@ void Player::InitDataForForm(bool reapplyMods)
|
||||
}
|
||||
|
||||
// Return true is the bought item has a max count to force refresh of window by caller
|
||||
bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot)
|
||||
bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint8 bag, uint8 slot)
|
||||
{
|
||||
// cheating attempt
|
||||
if (count < 1) count = 1;
|
||||
@@ -17966,6 +17966,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
|
||||
return false;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD:src/game/Player.cpp
|
||||
uint8 bag = 0; // init for case invalid bagGUID
|
||||
|
||||
if (bagguid != NULL_BAG && slot != NULL_SLOT)
|
||||
@@ -17998,6 +17999,9 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
|
||||
}
|
||||
|
||||
if( IsInventoryPos( bag, slot ) || (bagguid == NULL_BAG && slot == NULL_SLOT) )
|
||||
=======
|
||||
if ((bag == NULL_BAG && slot == NULL_SLOT) || IsInventoryPos(bag, slot))
|
||||
>>>>>>> 03c14bd3ebd8da13b803d18cf147d3ea8b8b5620:src/game/Player.cpp
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = CanStoreNewItem( bag, slot, dest, item, pProto->BuyCount * count );
|
||||
|
||||
+1
-1
@@ -1126,7 +1126,7 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
return mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip();
|
||||
}
|
||||
void SendNewItem( Item *item, uint32 count, bool received, bool created, bool broadcast = false );
|
||||
bool BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot);
|
||||
bool BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint8 bag, uint8 slot);
|
||||
|
||||
float GetReputationPriceDiscount( Creature const* pCreature ) const;
|
||||
Player* GetTrader() const { return pTrader; }
|
||||
|
||||
Reference in New Issue
Block a user