diff options
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 42 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 2 |
2 files changed, 27 insertions, 17 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 978078e5b85..9d088b5be49 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -6853,26 +6853,11 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, int32 honor, bool pvpt || (MapType == 3 && !InBattleground())) return true; - uint32 noSpaceForCount = 0; uint32 itemId = sWorld.getIntConfig(CONFIG_PVP_TOKEN_ID); int32 count = sWorld.getIntConfig(CONFIG_PVP_TOKEN_COUNT); - // check space and find places - ItemPosCountVec dest; - uint8 msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount); - if (msg != EQUIP_ERR_OK) // convert to possible store amount - count = noSpaceForCount; - - if (count == 0 || dest.empty()) // can't add any - { - // -- TODO: Send to mailbox if no space - ChatHandler(this).PSendSysMessage("You don't have any space in your bags for a token."); - return true; - } - - Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); - SendNewItem(item,count,true,false); - ChatHandler(this).PSendSysMessage("You have been awarded a token for slaying another player."); + if(AddItem(itemId, count)) + ChatHandler(this).PSendSysMessage("You have been awarded a token for slaying another player."); } } @@ -23997,6 +23982,29 @@ void Player::SendRefundInfo(Item *item) GetSession()->SendPacket(&data); } +bool Player::AddItem(uint32 itemId, uint32 count) +{ + uint32 noSpaceForCount = 0; + ItemPosCountVec dest;
+ uint8 msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
+ if (msg != EQUIP_ERR_OK)
+ count = noSpaceForCount;
+
+ if (count == 0 || dest.empty())
+ {
+ // -- TODO: Send to mailbox if no space
+ ChatHandler(this).PSendSysMessage("You don't have any space in your bags.");
+ return false;
+ }
+
+ Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
+ if(item)
+ SendNewItem(item,count,true,false); + else + return false; + return true; +} + void Player::RefundItem(Item *item) { if (!item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE)) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 1f35aed6799..90d5b4494b3 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1272,6 +1272,8 @@ class Player : public Unit, public GridObject<Player> void LoadCorpse(); void LoadPet(); + bool AddItem(uint32 itemId, uint32 count); + uint32 m_stableSlots; /*********************************************************/ |