From 2c731273c1c8071ddbfc56ff857d8285cea6f4bc Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 27 Apr 2020 22:02:38 +0100 Subject: [PATCH] Fix #11494: Old console commands don't work at headless console since plugin system (#11508) --- distribution/openrct2.d.ts | 10 ++++++++++ src/openrct2/scripting/ScConsole.hpp | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index a3a9b858b2..8e30a850b6 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -91,6 +91,16 @@ declare global { interface Console { clear(): void; log(message?: any, ...optionalParams: any[]): void; + + /** + * Executes a command using the legacy console REPL. This should not be used + * by plugins, and exists only for servers to continue using old commands until + * all functionality can be accomplished with this scripting API. + * + * @deprecated + * @param command The command and arguments to execute. + */ + executeLegacy(command: string): void; } /** diff --git a/src/openrct2/scripting/ScConsole.hpp b/src/openrct2/scripting/ScConsole.hpp index 0b8e90e6aa..6d15102512 100644 --- a/src/openrct2/scripting/ScConsole.hpp +++ b/src/openrct2/scripting/ScConsole.hpp @@ -51,10 +51,16 @@ namespace OpenRCT2::Scripting return 0; } + void executeLegacy(const std::string& command) + { + _console.Execute(command); + } + static void Register(duk_context* ctx) { dukglue_register_method(ctx, &ScConsole::clear, "clear"); dukglue_register_method_varargs(ctx, &ScConsole::log, "log"); + dukglue_register_method(ctx, &ScConsole::executeLegacy, "executeLegacy"); } }; } // namespace OpenRCT2::Scripting