Skip to content

Commit

Permalink
Fix: [OpenRCT2#23297] Peeps disappear when closing the game.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmbernardi committed Dec 10, 2024
1 parent e201ccf commit f439f0e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions distribution/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
------------------------------------------------------------------------
- Improved: [#23260] Add diagonal (block) brakes to LSM Launched Roller Coaster.
- Fix: [#23286] Currency formatted incorrectly in the in game console.
- Fix: [#23297] Peeps disappear when closing the game.

0.4.17 (2024-12-08)
------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ void GameLoadOrQuitNoSavePrompt()
}
default:
GameUnloadScripts();
ResetAllEntities();
FreeAllEntities();
OpenRCT2Finish();
break;
}
Expand Down
15 changes: 11 additions & 4 deletions src/openrct2/entity/EntityRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,10 @@ const std::list<EntityId>& GetEntityList(const EntityType id)
}

/**
*
* rct2: 0x0069EB13
* Frees any dynamically attached memory for all entities
*/
void ResetAllEntities()
void FreeAllEntities()
{
// Free all associated Entity pointers prior to zeroing memory
for (int32_t i = 0; i < MAX_ENTITIES; ++i)
{
auto* spr = GetEntity(EntityId::FromUnderlying(i));
Expand All @@ -174,6 +172,15 @@ void ResetAllEntities()
}
FreeEntity(*spr);
}
}

/**
*
* rct2: 0x0069EB13
*/
void ResetAllEntities()
{
FreeAllEntities();

auto& gameState = GetGameState();
std::fill(std::begin(gameState.Entities), std::end(gameState.Entities), Entity_t());
Expand Down
1 change: 1 addition & 0 deletions src/openrct2/entity/EntityRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ T* CreateEntityAt(const EntityId index)
return static_cast<T*>(CreateEntityAt(index, T::cEntityType));
}

void FreeAllEntities();
void ResetAllEntities();
void ResetEntitySpatialIndices();
void UpdateAllMiscEntities();
Expand Down

0 comments on commit f439f0e

Please sign in to comment.