From 82e5e3d5f0a135e4e910ee1f7130dff3a23872a8 Mon Sep 17 00:00:00 2001 From: David Chavez Date: Sat, 13 Aug 2022 00:38:26 +0200 Subject: [PATCH] Add rupee modification --- soh/soh/Enhancements/debugconsole.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 204028e41..b9a0aa935 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -606,13 +606,20 @@ static bool ReverseControlsHandler(std::shared_ptr Console, const // TODO: Implement } -static bool AddRemoveRupeesHandler(std::shared_ptr Console, const std::vector& args) { +static bool UpdateRupeesHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() != 2) { SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } - // TODO: Implement + try { + int value = std::stoi(args[1], nullptr, 10); + gSaveContext.rupees += value; + return CMD_SUCCESS; + } catch (std::invalid_argument const& ex) { + SohImGui::console->SendErrorMessage("[SOH] Rupee value must be a number."); + return CMD_FAILED; + } } static bool SpeedModifierHandler(std::shared_ptr Console, const std::vector& args) { @@ -927,11 +934,7 @@ void DebugConsole_Init(void) { { "value", Ship::ArgumentType::NUMBER } }}); - CMD_REGISTER("add_rupees", { AddRemoveRupeesHandler, "Adds rupees.", { - { "value", Ship::ArgumentType::NUMBER } - }}); - - CMD_REGISTER("subtract_rupees", { AddRemoveRupeesHandler, "Subtracts rupees.", { + CMD_REGISTER("update_rupees", { UpdateRupeesHandler, "Adds rupees.", { { "value", Ship::ArgumentType::NUMBER } }});