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

This commit is contained in:
Hielke Morsink authored and GitHub committed 2021-08-28 17:43:11 +02:00
1 parent 97ded2d7c4
commit e0751d707f
1 file changed
+10 -1
+10 -1
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