diff options
-rw-r--r-- | sql/updates/world/master/2021_12_19_24_world_2019_12_28_01_world.sql | 4 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 36 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 2 | ||||
-rw-r--r-- | src/server/game/Miscellaneous/Language.h | 2 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 23 |
5 files changed, 45 insertions, 22 deletions
diff --git a/sql/updates/world/master/2021_12_19_24_world_2019_12_28_01_world.sql b/sql/updates/world/master/2021_12_19_24_world_2019_12_28_01_world.sql new file mode 100644 index 00000000000..68519239a7e --- /dev/null +++ b/sql/updates/world/master/2021_12_19_24_world_2019_12_28_01_world.sql @@ -0,0 +1,4 @@ +-- +delete from `trinity_string` where `entry`=600; +insert into `trinity_string` (entry,content_default,content_loc1,content_loc2,content_loc3,content_loc4,content_loc5,content_loc6,content_loc7,content_loc8) values +(600, "Failed to remove itemID = %i, amount = %i, from %s (No such item exists in target's inventory)", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index a1cb2059172..db6cfdb97e8 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -12795,7 +12795,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) } } -void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool unequip_check) +uint32 Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool unequip_check) { TC_LOG_DEBUG("entities.player.items", "Player::DestroyItemCount: Player '%s' (%s), Item: %u, Count: %u", GetName().c_str(), GetGUID().ToString().c_str(), itemEntry, count); @@ -12816,7 +12816,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool DestroyItem(INVENTORY_SLOT_BAG_0, i, update); if (remcount >= count) - return; + return remcount; } else { @@ -12825,7 +12825,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool if (IsInWorld() && update) item->SendUpdateToPlayer(this); item->SetState(ITEM_CHANGED, this); - return; + return remcount; } } } @@ -12849,7 +12849,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool DestroyItem(i, j, update); if (remcount >= count) - return; + return remcount; } else { @@ -12858,7 +12858,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool if (IsInWorld() && update) item->SendUpdateToPlayer(this); item->SetState(ITEM_CHANGED, this); - return; + return remcount; } } } @@ -12881,7 +12881,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool DestroyItem(INVENTORY_SLOT_BAG_0, i, update); if (remcount >= count) - return; + return remcount; } } else @@ -12891,7 +12891,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool if (IsInWorld() && update) item->SendUpdateToPlayer(this); item->SetState(ITEM_CHANGED, this); - return; + return remcount; } } } @@ -12909,7 +12909,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool remcount += item->GetCount(); DestroyItem(INVENTORY_SLOT_BAG_0, i, update); if (remcount >= count) - return; + return remcount; } else { @@ -12918,7 +12918,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool if (IsInWorld() && update) item->SendUpdateToPlayer(this); item->SetState(ITEM_CHANGED, this); - return; + return remcount; } } } @@ -12942,7 +12942,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool DestroyItem(i, j, update); if (remcount >= count) - return; + return remcount; } else { @@ -12951,7 +12951,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool if (IsInWorld() && update) item->SendUpdateToPlayer(this); item->SetState(ITEM_CHANGED, this); - return; + return remcount; } } } @@ -12973,7 +12973,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool remcount += item->GetCount(); DestroyItem(INVENTORY_SLOT_BAG_0, i, update); if (remcount >= count) - return; + return remcount; } } else @@ -12983,7 +12983,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool if (IsInWorld() && update) item->SendUpdateToPlayer(this); item->SetState(ITEM_CHANGED, this); - return; + return remcount; } } } @@ -13002,7 +13002,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool DestroyItem(INVENTORY_SLOT_BAG_0, i, update); if (remcount >= count) - return; + return remcount; } else { @@ -13011,7 +13011,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool if (IsInWorld() && update) item->SendUpdateToPlayer(this); item->SetState(ITEM_CHANGED, this); - return; + return remcount; } } } @@ -13030,7 +13030,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool DestroyItem(INVENTORY_SLOT_BAG_0, i, update); if (remcount >= count) - return; + return remcount; } else { @@ -13039,12 +13039,12 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool if (IsInWorld() && update) item->SendUpdateToPlayer(this); item->SetState(ITEM_CHANGED, this); - return; + return remcount; } } } } - + return remcount; } void Player::DestroyZoneLimitedItem(bool update, uint32 new_zone) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 85578cd1ff6..ce2e681a4c8 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1431,7 +1431,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> // in trade, guild bank, mail.... void RemoveItemDependentAurasAndCasts(Item* pItem); void DestroyItem(uint8 bag, uint8 slot, bool update); - void DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check = false); + uint32 DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check = false); void DestroyItemCount(Item* item, uint32& count, bool update); void DestroyConjuredItems(bool update); void DestroyZoneLimitedItem(bool update, uint32 new_zone); diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index a1f167ba02d..fcd094ddd97 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -685,7 +685,7 @@ enum TrinityStrings LANG_GMLIST_HEADER = 598, LANG_GMLIST_EMPTY = 599, - LANG_REMOVEITEM_FAILURE = 600, // 3.3.5 RESERVED + LANG_REMOVEITEM_FAILURE = 600, // End Level 3 list, continued at 1100 diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 7b74a54774f..af77c7466d2 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1333,8 +1333,27 @@ public: // Subtract if (count < 0) { - playerTarget->DestroyItemCount(itemId, -count, true, false); - handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget).c_str()); + uint32 destroyedItemCount = playerTarget->DestroyItemCount(itemId, -count, true, false); + + if (destroyedItemCount > 0) + { + // output the amount of items successfully destroyed + handler->PSendSysMessage(LANG_REMOVEITEM, itemId, destroyedItemCount, handler->GetNameLink(playerTarget).c_str()); + + // check to see if we were unable to destroy all of the amount requested. + uint32 unableToDestroyItemCount = -count - destroyedItemCount; + if (unableToDestroyItemCount > 0) + { + // output message for the amount of items we couldn't destroy + handler->PSendSysMessage(LANG_REMOVEITEM_FAILURE, itemId, unableToDestroyItemCount, handler->GetNameLink(playerTarget).c_str()); + } + } + else + { + // failed to destroy items of the amount requested + handler->PSendSysMessage(LANG_REMOVEITEM_FAILURE, itemId, -count, handler->GetNameLink(playerTarget).c_str()); + } + return true; } |