1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-26 08:14:38 +01:00

Fix #21145, #21158: Keep handles for intervals stable and resolve crash

This commit is contained in:
ζeh Matt
2024-01-06 09:38:25 +02:00
parent 296e8cdb16
commit 8bcd409fb0
2 changed files with 55 additions and 51 deletions

View File

@@ -126,20 +126,14 @@ namespace OpenRCT2::Scripting
}
};
using IntervalHandle = int32_t;
using IntervalHandle = uint32_t;
struct ScriptInterval
{
std::shared_ptr<Plugin> Owner;
IntervalHandle Handle{};
uint32_t Delay{};
int64_t LastTimestamp{};
DukValue Callback;
bool Repeat{};
bool IsValid() const
{
return Handle != 0;
}
};
class ScriptEngine
@@ -162,7 +156,8 @@ namespace OpenRCT2::Scripting
DukValue _parkStorage;
uint32_t _lastIntervalTimestamp{};
std::vector<ScriptInterval> _intervals;
std::map<IntervalHandle, ScriptInterval> _intervals;
IntervalHandle _nextIntervalHandle = 1;
std::unique_ptr<FileWatcher> _pluginFileWatcher;
std::unordered_set<std::string> _changedPluginFiles;