Fix #21171: Crash creating entities with no slots available

This commit is contained in:
ζeh Matt 2024-01-12 17:51:41 +02:00
parent 3dc2a25121
commit 7d3c273594
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
1 changed files with 5 additions and 0 deletions

View File

@ -233,6 +233,11 @@ namespace OpenRCT2::Scripting
DukValue createEntityType(duk_context* ctx, const DukValue& initializer)
{
TEntityType* entity = CreateEntity<TEntityType>();
if (entity == nullptr)
{
// Probably no more space for entities for this specified entity type.
return ToDuk(ctx, undefined);
}
auto entityPos = CoordsXYZ{ AsOrDefault(initializer["x"], 0), AsOrDefault(initializer["y"], 0),
AsOrDefault(initializer["z"], 0) };