aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am22
-rw-r--r--src/game/ItemHandler.cpp26
-rw-r--r--src/game/Player.cpp58
-rw-r--r--src/game/Player.h2
4 files changed, 68 insertions, 40 deletions
diff --git a/Makefile.am b/Makefile.am
index eb58ac488f2..4edbad5947c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
+
diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp
index cf762dd0cb2..d886cda742b 100644
--- a/src/game/ItemHandler.cpp
+++ b/src/game/ItemHandler.cpp
@@ -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 )
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 29cf24a4318..280dd60c8f6 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -17854,20 +17854,20 @@ 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;
+ if (count < 1) count = 1;
// cheating attempt
if(slot > MAX_BAG_SIZE && slot !=NULL_SLOT)
return false;
- if(!isAlive())
+ if (!isAlive())
return false;
ItemPrototype const *pProto = objmgr.GetItemPrototype( item );
- if( !pProto )
+ if (!pProto)
{
SendBuyError( BUY_ERR_CANT_FIND_ITEM, NULL, item, 0);
return false;
@@ -17889,7 +17889,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
}
size_t vendor_slot = vItems->FindItemSlot(item);
- if(vendor_slot >= vItems->GetItemCount())
+ if (vendor_slot >= vItems->GetItemCount())
{
SendBuyError( BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0);
return false;
@@ -17898,39 +17898,39 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
VendorItem const* crItem = vItems->m_items[vendor_slot];
// check current item amount if it limited
- if( crItem->maxcount != 0 )
+ if (crItem->maxcount != 0)
{
- if(pCreature->GetVendorItemCurrentCount(crItem) < pProto->BuyCount * count )
+ if (pCreature->GetVendorItemCurrentCount(crItem) < pProto->BuyCount * count )
{
SendBuyError( BUY_ERR_ITEM_ALREADY_SOLD, pCreature, item, 0);
return false;
}
}
- if( uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank)
+ if (uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank)
{
SendBuyError( BUY_ERR_REPUTATION_REQUIRE, pCreature, item, 0);
return false;
}
- if(crItem->ExtendedCost)
+ if (crItem->ExtendedCost)
{
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
- if(!iece)
+ if (!iece)
{
sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, crItem->ExtendedCost);
return false;
}
// honor points price
- if(GetHonorPoints() < (iece->reqhonorpoints * count))
+ if (GetHonorPoints() < (iece->reqhonorpoints * count))
{
SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL);
return false;
}
// arena points price
- if(GetArenaPoints() < (iece->reqarenapoints * count))
+ if (GetArenaPoints() < (iece->reqarenapoints * count))
{
SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, NULL, NULL);
return false;
@@ -17960,12 +17960,13 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
// reputation discount
price = uint32(floor(price * GetReputationPriceDiscount(pCreature)));
- if( GetMoney() < price )
+ if (GetMoney() < price)
{
SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, item, 0);
return false;
}
+<<<<<<< HEAD:src/game/Player.cpp
uint8 bag = 0; // init for case invalid bagGUID
if (bagguid != NULL_BAG && slot != NULL_SLOT)
@@ -17998,31 +17999,34 @@ 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 );
- if( msg != EQUIP_ERR_OK )
+ if (msg != EQUIP_ERR_OK)
{
SendEquipError( msg, NULL, NULL );
return false;
}
ModifyMoney( -(int32)price );
- if(crItem->ExtendedCost) // case for new honor system
+ if (crItem->ExtendedCost) // case for new honor system
{
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
- if(iece->reqhonorpoints)
+ if (iece->reqhonorpoints)
ModifyHonorPoints( - int32(iece->reqhonorpoints * count));
- if(iece->reqarenapoints)
+ if (iece->reqarenapoints)
ModifyArenaPoints( - int32(iece->reqarenapoints * count));
for (uint8 i = 0; i < 5; ++i)
{
- if(iece->reqitem[i])
+ if (iece->reqitem[i])
DestroyItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count), true);
}
}
- if(Item *it = StoreNewItem( dest, item, true ))
+ if (Item *it = StoreNewItem( dest, item, true ))
{
uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count);
@@ -18036,9 +18040,9 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
SendNewItem(it, pProto->BuyCount*count, true, false, false);
}
}
- else if( IsEquipmentPos( bag, slot ) )
+ else if (IsEquipmentPos(bag, slot))
{
- if(pProto->BuyCount * count != 1)
+ if (pProto->BuyCount * count != 1)
{
SendEquipError( EQUIP_ERR_ITEM_CANT_BE_EQUIPPED, NULL, NULL );
return false;
@@ -18046,19 +18050,19 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
uint16 dest;
uint8 msg = CanEquipNewItem( slot, dest, item, false );
- if( msg != EQUIP_ERR_OK )
+ if (msg != EQUIP_ERR_OK)
{
SendEquipError( msg, NULL, NULL );
return false;
}
ModifyMoney( -(int32)price );
- if(crItem->ExtendedCost) // case for new honor system
+ if (crItem->ExtendedCost) // case for new honor system
{
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
- if(iece->reqhonorpoints)
+ if (iece->reqhonorpoints)
ModifyHonorPoints( - int32(iece->reqhonorpoints));
- if(iece->reqarenapoints)
+ if (iece->reqarenapoints)
ModifyArenaPoints( - int32(iece->reqarenapoints));
for (uint8 i = 0; i < 5; ++i)
{
@@ -18067,7 +18071,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
}
}
- if(Item *it = EquipNewItem( dest, item, true ))
+ if (Item *it = EquipNewItem( dest, item, true ))
{
uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count);
@@ -18089,7 +18093,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
return false;
}
- return crItem->maxcount!=0;
+ return crItem->maxcount != 0;
}
uint32 Player::GetMaxPersonalArenaRatingRequirement()
diff --git a/src/game/Player.h b/src/game/Player.h
index 863473bcb0b..4c100e592c8 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -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; }