aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <martin.dev.446@gmail.com>2019-12-28 16:58:18 -0500
committerGiacomo Pozzoni <giacomopoz@gmail.com>2019-12-28 22:58:18 +0100
commit6b19f4a0ab1f77ea969a080a6eea0379baf9f8df (patch)
tree29eb01729a985948375d8c02bf6f4d83f08080a7
parent53fe736087341ae056713768562e0cc27de2ac19 (diff)
additional output for additem command (#24006)
* additional output for additem command when removing items with additem: if the user provides an amount too large of a negative amount, the command will now output the amount of items that could not be destroyed. * renamed sql file to hopefully avoid conflicts * added clarification to failure string * changed unneeded else if condition to else * code style; braces * Update and rename 9999_99_99_99_world.sql to 2019_12_28_01_world.sql
-rw-r--r--sql/updates/world/3.3.5/2019_12_28_01_world.sql4
-rw-r--r--src/server/game/Entities/Player/Player.cpp27
-rw-r--r--src/server/game/Entities/Player/Player.h2
-rw-r--r--src/server/game/Miscellaneous/Language.h4
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp23
5 files changed, 43 insertions, 17 deletions
diff --git a/sql/updates/world/3.3.5/2019_12_28_01_world.sql b/sql/updates/world/3.3.5/2019_12_28_01_world.sql
new file mode 100644
index 00000000000..68519239a7e
--- /dev/null
+++ b/sql/updates/world/3.3.5/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 d0570fd0884..846b987c583 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -12462,7 +12462,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);
@@ -12482,7 +12482,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
{
@@ -12491,7 +12491,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;
}
}
}
@@ -12510,7 +12510,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
{
@@ -12519,7 +12519,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;
}
}
}
@@ -12543,7 +12543,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool
DestroyItem(i, j, update);
if (remcount >= count)
- return;
+ return remcount;
}
else
{
@@ -12552,7 +12552,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;
}
}
}
@@ -12575,7 +12575,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
@@ -12585,7 +12585,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;
}
}
}
@@ -12603,7 +12603,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
{
@@ -12612,7 +12612,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;
}
}
}
@@ -12636,7 +12636,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool
DestroyItem(i, j, update);
if (remcount >= count)
- return;
+ return remcount;
}
else
{
@@ -12645,13 +12645,14 @@ 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 5aa9069f91a..66bf4c0cc1d 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1122,7 +1122,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 e7e15b88b61..3873ba427e4 100644
--- a/src/server/game/Miscellaneous/Language.h
+++ b/src/server/game/Miscellaneous/Language.h
@@ -642,9 +642,11 @@ enum TrinityStrings
LANG_GMLIST_HEADER = 598,
LANG_GMLIST_EMPTY = 599,
+ LANG_REMOVEITEM_FAILURE = 600,
+
// End Level 3 list, continued at 1100
- // 600-704 - free
+ // 601-704 - free
LANG_WAIT_BEFORE_SPEAKING = 705,
LANG_NOT_EQUIPPED_ITEM = 706,
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 81f01513035..af30a25abef 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -1263,8 +1263,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;
}