1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-27 00:34:46 +01:00

Fix #21274: Collision of PeepId when importing SV4

This commit is contained in:
ζeh Matt
2024-01-25 16:34:00 +02:00
parent 6e14f6540a
commit e5a10c1514

View File

@@ -177,7 +177,7 @@ namespace RCT1
ImportRides();
ImportRideMeasurements();
ImportSprites();
ImportEntities();
ImportTileElements();
ImportPeepSpawns();
ImportFinance(gameState);
@@ -190,6 +190,7 @@ namespace RCT1
ImportSavedView();
FixLandOwnership();
FixUrbanPark();
FixNextGuestNumber(gameState);
CountBlockSections();
SetDefaultNames();
DetermineRideEntranceAndExitLocations();
@@ -1199,7 +1200,7 @@ namespace RCT1
void ImportEntity(const RCT12EntityBase& src);
template<typename T> void ImportEntity(const RCT12EntityBase& src);
void ImportSprites()
void ImportEntities()
{
for (int i = 0; i < Limits::MaxEntities; i++)
{
@@ -2601,6 +2602,22 @@ namespace RCT1
}
}
void FixNextGuestNumber(GameState_t& gameState)
{
// In RCT1, the next guest number is not saved, so we have to calculate it.
// This is done by finding the highest guest number in the park, and adding 1.
uint32_t nextGuestNumber = 0;
// TODO: Entities are currently read from the global state, change this once entities are stored
// in the passed gameState.
for (auto peep : EntityList<Guest>())
{
nextGuestNumber = std::max(nextGuestNumber, peep->PeepId);
}
gameState.NextGuestNumber = nextGuestNumber + 1;
}
/**
* Counts the block sections. The reason this iterates over the map is to avoid getting into infinite loops,
* which can happen with hacked parks.