Fix #15298: Crash on map.getAllEntities from in-game console (#15301)

This commit is contained in:
Hielke Morsink 2021-08-28 17:43:11 +02:00 committed by GitHub
parent 97ded2d7c4
commit e0751d707f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -1433,7 +1433,16 @@ int32_t OpenRCT2::Scripting::GetTargetAPIVersion()
{
auto& scriptEngine = GetContext()->GetScriptEngine();
auto& execInfo = scriptEngine.GetExecInfo();
return execInfo.GetCurrentPlugin()->GetTargetAPIVersion();
// Commands from the in-game console do not have a plug-in set
auto plugin = execInfo.GetCurrentPlugin();
if (plugin == nullptr)
{
// For in-game console, default to the current API version
return OPENRCT2_PLUGIN_API_VERSION;
}
return plugin->GetTargetAPIVersion();
}
#endif