From b04348c56be6b19dbf4503b29919e913c95f7c04 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Fri, 23 May 2025 10:44:16 -0300 Subject: [PATCH] Make error message on console set command more descriptive Previously when using `set variable something` you would always get the non-helpful message: "set variable command failed, likely due to permissions." Since all of these are going through game actions, we can use the GameActionResult to return something more meaningful. For example, trying to do `set game_speed 5`: Before: ![image](https://github.com/user-attachments/assets/7e52143b-ca5d-461c-8475-408ba6346350) After: ![image](https://github.com/user-attachments/assets/44160ceb-954b-41f6-80e3-fe581403b404) --- distribution/changelog.txt | 1 + src/openrct2/interface/InteractiveConsole.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 8880623194..4dec6a7191 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -10,6 +10,7 @@ - Improved: [#24417] Improve the fallback vehicle sprites for Dive Loops. - Improved: [#24433] The ride, new ride, scenery, path, viewport, park and tool windows no longer redraw every frame if they have not changed. - Improved: [#24467] Apply tweening only to on-screen entities when not zoomed out for better performance with uncapped FPS. +- Improved: [#24479] More descriptive error messages for `set` commands in the in-game console. - Change: [#24342] g2.dat is now split into g2.dat and fonts.dat. - Change: [#24362] The Windows installer now prevents installing to the same folder as RollerCoaster Tycoon 2 or Classic. - Change: [#24418] Small & Large Zero G Rolls can now be built on the LIM Launched RC without cheats if vehicle sprites are available. diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 56962e45ad..958e0fa6cd 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -741,7 +741,8 @@ static void ConsoleSetVariableAction(InteractiveConsole& console, std::string va auto action = TAction(std::forward(args)...); action.SetCallback([&console, var](const GameAction*, const GameActions::Result* res) { if (res->Error != GameActions::Status::Ok) - console.WriteLineError(String::stdFormat("set %s command failed, likely due to permissions.", var.c_str())); + console.WriteLineError(String::stdFormat( + "set %s command failed: %s - %s.", var.c_str(), res->GetErrorTitle().c_str(), res->GetErrorMessage().c_str())); else console.Execute(String::stdFormat("get %s", var.c_str())); console.EndAsyncExecution();