From 177c1a16a7b5dc319e1e8f7b2aa0333a85b685a5 Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 24 Feb 2020 17:43:03 +0000 Subject: [PATCH] Always allow game state to be mutated in single player --- src/openrct2/scripting/ScriptEngine.cpp | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index e40ed99f93..ae6273bd78 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -380,19 +380,31 @@ static std::string Stringify(duk_context* ctx, duk_idx_t idx) bool OpenRCT2::Scripting::IsGameStateMutable() { - auto& scriptEngine = GetContext()->GetScriptEngine(); - auto& execInfo = scriptEngine.GetExecInfo(); - return execInfo.IsGameStateMutable(); + // Allow single player to alter game state anywhere + if (network_get_mode() == NETWORK_MODE_NONE) + { + return true; + } + else + { + auto& scriptEngine = GetContext()->GetScriptEngine(); + auto& execInfo = scriptEngine.GetExecInfo(); + return execInfo.IsGameStateMutable(); + } } void OpenRCT2::Scripting::ThrowIfGameStateNotMutable() { - auto& scriptEngine = GetContext()->GetScriptEngine(); - auto& execInfo = scriptEngine.GetExecInfo(); - if (!execInfo.IsGameStateMutable()) + // Allow single player to alter game state anywhere + if (network_get_mode() != NETWORK_MODE_NONE) { - auto ctx = scriptEngine.GetContext(); - duk_error(ctx, DUK_ERR_ERROR, "Game state is not mutable in this context."); + auto& scriptEngine = GetContext()->GetScriptEngine(); + auto& execInfo = scriptEngine.GetExecInfo(); + if (!execInfo.IsGameStateMutable()) + { + auto ctx = scriptEngine.GetContext(); + duk_error(ctx, DUK_ERR_ERROR, "Game state is not mutable in this context."); + } } }