mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-16 12:32:29 +01:00
Always allow game state to be mutated in single player
This commit is contained in:
@@ -380,19 +380,31 @@ static std::string Stringify(duk_context* ctx, duk_idx_t idx)
|
|||||||
|
|
||||||
bool OpenRCT2::Scripting::IsGameStateMutable()
|
bool OpenRCT2::Scripting::IsGameStateMutable()
|
||||||
{
|
{
|
||||||
auto& scriptEngine = GetContext()->GetScriptEngine();
|
// Allow single player to alter game state anywhere
|
||||||
auto& execInfo = scriptEngine.GetExecInfo();
|
if (network_get_mode() == NETWORK_MODE_NONE)
|
||||||
return execInfo.IsGameStateMutable();
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
||||||
|
auto& execInfo = scriptEngine.GetExecInfo();
|
||||||
|
return execInfo.IsGameStateMutable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenRCT2::Scripting::ThrowIfGameStateNotMutable()
|
void OpenRCT2::Scripting::ThrowIfGameStateNotMutable()
|
||||||
{
|
{
|
||||||
auto& scriptEngine = GetContext()->GetScriptEngine();
|
// Allow single player to alter game state anywhere
|
||||||
auto& execInfo = scriptEngine.GetExecInfo();
|
if (network_get_mode() != NETWORK_MODE_NONE)
|
||||||
if (!execInfo.IsGameStateMutable())
|
|
||||||
{
|
{
|
||||||
auto ctx = scriptEngine.GetContext();
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
||||||
duk_error(ctx, DUK_ERR_ERROR, "Game state is not mutable in this context.");
|
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.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user