1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 07:14:31 +01:00

Load temporary map animations from S4 files

This commit is contained in:
mix
2025-05-21 07:57:26 +01:00
parent 43b0ed6dc8
commit 57148e137a
7 changed files with 28 additions and 2 deletions

View File

@@ -820,6 +820,7 @@ namespace OpenRCT2
_objectManager->LoadObjects(result.RequiredObjects, true);
SetProgress(90, 100, STR_STRING_M_PERCENT);
MapAnimation::ClearAll();
// TODO: Have a separate GameState and exchange once loaded.
auto& gameState = ::getGameState();
parkImporter->Import(gameState);

View File

@@ -2848,6 +2848,7 @@ bool NetworkBase::LoadMap(IStream* stream)
auto loadResult = importer->LoadFromStream(stream, false);
objManager.LoadObjects(loadResult.RequiredObjects);
MapAnimation::ClearAll();
// TODO: Have a separate GameState and exchange once loaded.
auto& gameState = getGameState();
importer->Import(gameState);

View File

@@ -194,6 +194,7 @@ namespace OpenRCT2::RCT1
ImportRideMeasurements();
ImportEntities();
ImportTileElements(gameState);
ImportMapAnimations();
ImportPeepSpawns(gameState);
ImportFinance(gameState);
ImportResearch(gameState);
@@ -1460,6 +1461,26 @@ namespace OpenRCT2::RCT1
dst->z = src->z;
}
void ImportMapAnimations()
{
for (const auto& mapAnimation : std::span(_s4.MapAnimations, _s4.NumMapAnimations))
{
switch (mapAnimation.Type)
{
case kRCT12MapAnimationTypeOnRidePhoto:
MapAnimation::CreateTemporary(
{ mapAnimation.x, mapAnimation.y, (mapAnimation.BaseZ / 2) * kCoordsZStep },
MapAnimation::TemporaryType::onRidePhoto);
break;
case kRCT12MapAnimationTypeLandEdgeDoor:
MapAnimation::CreateTemporary(
{ mapAnimation.x, mapAnimation.y, (mapAnimation.BaseZ / 2) * kCoordsZStep },
MapAnimation::TemporaryType::landEdgeDoor);
break;
}
}
}
void ImportPeepSpawns(GameState_t& gameState)
{
gameState.peepSpawns.clear();

View File

@@ -1165,6 +1165,9 @@ struct RCT12MapAnimation
};
static_assert(sizeof(RCT12MapAnimation) == 6);
static constexpr uint8_t kRCT12MapAnimationTypeOnRidePhoto = 6;
static constexpr uint8_t kRCT12MapAnimationTypeLandEdgeDoor = 9;
struct RCT12ResearchItem
{
// Bit 16 (0: scenery entry, 1: ride entry)

View File

@@ -472,8 +472,6 @@ void MapAnimation::CreateTemporary(const CoordsXYZ& coords, const TemporaryType
void MapAnimation::CreateAll()
{
ClearAll();
TileElementIterator it;
TileElementIteratorBegin(&it);
while (TileElementIteratorNext(&it))

View File

@@ -51,6 +51,7 @@ static std::unique_ptr<IContext> localStartGame(const std::string& parkPath)
auto loadResult = importer->LoadSavedGame(parkPath.c_str(), false);
context->GetObjectManager().LoadObjects(loadResult.RequiredObjects);
MapAnimation::ClearAll();
// TODO: Have a separate GameState and exchange once loaded.
auto& gameState = getGameState();
importer->Import(gameState);

View File

@@ -83,6 +83,7 @@ static bool ImportS6(MemoryStream& stream, std::unique_ptr<IContext>& context, b
auto loadResult = importer->LoadFromStream(&stream, false);
objManager.LoadObjects(loadResult.RequiredObjects);
MapAnimation::ClearAll();
// TODO: Have a separate GameState and exchange once loaded.
auto& gameState = getGameState();
importer->Import(gameState);