From d153833b2cea7dadadcac091df279ed1af6dd4aa Mon Sep 17 00:00:00 2001 From: NRGJobro <85864573+NRGJobro@users.noreply.github.com> Date: Thu, 19 Aug 2021 13:56:43 -0400 Subject: [PATCH] Fixed The Dupe Command Again (#4434) Fixed the offhand option in dupe. (didn't do anything before) --- Horion/Command/Commands/DupeCommand.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/Horion/Command/Commands/DupeCommand.cpp b/Horion/Command/Commands/DupeCommand.cpp index f13b9336..9e040451 100644 --- a/Horion/Command/Commands/DupeCommand.cpp +++ b/Horion/Command/Commands/DupeCommand.cpp @@ -1,6 +1,7 @@ #include "DupeCommand.h" DupeCommand::DupeCommand() : IMCCommand("dupe", "Duplicates the item in hand", " ") { + registerAlias("d"); } DupeCommand::~DupeCommand() { @@ -8,37 +9,30 @@ DupeCommand::~DupeCommand() { bool DupeCommand::execute(std::vector* args) { C_PlayerInventoryProxy* supplies = g_Data.getLocalPlayer()->getSupplies(); - C_Inventory* inv = supplies->inventory; auto transactionManager = g_Data.getLocalPlayer()->getTransactionManager(); - + C_Inventory* inv = supplies->inventory; int selectedSlot = supplies->selectedHotbarSlot; C_ItemStack* item = inv->getItemStack(selectedSlot); - int count = item->count; bool isGive = true; - if (args->size() > 1) item->count = assertInt(args->at(1)); if (args->size() > 2) isGive = static_cast(assertInt(args->at(2))); - if (isGive) { - int slot = inv->getFirstEmptySlot(); - C_InventoryAction* firstAction = nullptr; C_InventoryAction* secondAction = nullptr; - firstAction = new C_InventoryAction(0, item, nullptr, 507, 99999); - transactionManager->addInventoryAction(*firstAction); - inv->addItemToFirstEmptySlot(item); - } else + } else { + C_InventoryAction* pp = nullptr; + pp = new C_InventoryAction(0, item, nullptr, 507, 99999); + transactionManager->addInventoryAction(*pp); g_Data.getLocalPlayer()->setOffhandSlot(item); - + } if (args->size() > 1) item->count = count; - - clientMessageF("%sSuccessfully duplicated the item!", GREEN); + clientMessageF("%sSuccessfully duplicated the item!", GREEN); return true; }