1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 21:13:05 +01:00

Add game mutable protection

This commit is contained in:
Ted John
2020-02-23 02:00:22 +00:00
parent dc64d3541d
commit a5c8ff920f
14 changed files with 77 additions and 24 deletions

View File

@@ -39,6 +39,7 @@ namespace OpenRCT2::Scripting
{
private:
std::shared_ptr<Plugin> _plugin;
bool _isGameStateMutable{};
public:
class PluginScope
@@ -48,16 +49,18 @@ namespace OpenRCT2::Scripting
std::shared_ptr<Plugin> _plugin;
public:
PluginScope(ScriptExecutionInfo& execInfo, std::shared_ptr<Plugin> plugin)
PluginScope(ScriptExecutionInfo& execInfo, std::shared_ptr<Plugin> plugin, bool isGameStateMutable)
: _execInfo(execInfo)
, _plugin(plugin)
{
_execInfo._plugin = plugin;
_execInfo._isGameStateMutable = isGameStateMutable;
}
PluginScope(const PluginScope&) = delete;
~PluginScope()
{
_execInfo._plugin = nullptr;
_execInfo._isGameStateMutable = false;
}
};
@@ -65,6 +68,11 @@ namespace OpenRCT2::Scripting
{
return _plugin;
}
bool IsGameStateMutable()
{
return _isGameStateMutable;
}
};
class DukContext
@@ -150,9 +158,13 @@ namespace OpenRCT2::Scripting
void LoadPlugin(std::shared_ptr<Plugin>& plugin);
void StopPlugin(std::shared_ptr<Plugin> plugin);
bool ShouldLoadScript(const std::string& path);
bool ShouldStartPlugin(const std::shared_ptr<Plugin> &plugin);
bool ShouldStartPlugin(const std::shared_ptr<Plugin>& plugin);
void SetupHotReloading();
void AutoReloadPlugins();
void ProcessREPL();
};
bool IsGameStateMutable();
void ThrowIfGameStateNotMutable();
} // namespace OpenRCT2::Scripting