mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-23 19:02:04 -05:00
Fix plugin crash when nested scope occurs (#13556)
This commit is contained in:
parent
22063ec8b9
commit
5a849ededf
1 changed files with 8 additions and 2 deletions
|
@ -63,19 +63,25 @@ namespace OpenRCT2::Scripting
|
|||
ScriptExecutionInfo& _execInfo;
|
||||
std::shared_ptr<Plugin> _plugin;
|
||||
|
||||
std::shared_ptr<Plugin> _backupPlugin;
|
||||
bool _backupIsGameStateMutable;
|
||||
|
||||
public:
|
||||
PluginScope(ScriptExecutionInfo& execInfo, std::shared_ptr<Plugin> plugin, bool isGameStateMutable)
|
||||
: _execInfo(execInfo)
|
||||
, _plugin(plugin)
|
||||
{
|
||||
_backupPlugin = _execInfo._plugin;
|
||||
_backupIsGameStateMutable = _execInfo._isGameStateMutable;
|
||||
|
||||
_execInfo._plugin = plugin;
|
||||
_execInfo._isGameStateMutable = isGameStateMutable;
|
||||
}
|
||||
PluginScope(const PluginScope&) = delete;
|
||||
~PluginScope()
|
||||
{
|
||||
_execInfo._plugin = nullptr;
|
||||
_execInfo._isGameStateMutable = false;
|
||||
_execInfo._plugin = _backupPlugin;
|
||||
_execInfo._isGameStateMutable = _backupIsGameStateMutable;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue