diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 1bb633bf3f..210ad4c758 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,6 +1,7 @@ 0.4.11 (in development) ------------------------------------------------------------------------ - Feature: [#11512] Coloured usernames by group on multiplayer servers. +- Feature: [#21656] Save the currently following entity into the save file. - Feature: [#21734] Park admittance price can now be set via text input. - Improved: [#21769] Expose “animation is backwards” wall property in Tile Inspector. - Change: [#21715] [Plugin] Remove access to the internal `owner` property. Note: `ownership` is still accessible. diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index bc2e86661b..0652d0b4ac 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -531,6 +531,12 @@ void GameLoadInit() auto& gameState = GetGameState(); windowManager->SetMainView(gameState.SavedView, gameState.SavedViewZoom, gameState.SavedViewRotation); + if (gameState.CurrentlyFollowingEntity != EntityId::GetNull()) + { + auto* mainWindow = WindowGetMain(); + WindowFollowSprite(*mainWindow, gameState.CurrentlyFollowingEntity); + } + if (NetworkGetMode() != NETWORK_MODE_CLIENT) { GameActions::ClearQueue(); diff --git a/src/openrct2/GameState.h b/src/openrct2/GameState.h index 564166c58a..68950d95a6 100644 --- a/src/openrct2/GameState.h +++ b/src/openrct2/GameState.h @@ -126,6 +126,7 @@ namespace OpenRCT2 ScreenCoordsXY SavedView; uint8_t SavedViewRotation; ZoomLevel SavedViewZoom; + EntityId CurrentlyFollowingEntity{ EntityId::GetNull() }; ObjectEntryIndex LastEntranceStyle; diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index b8184d0a0c..76423ce2e8 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -1822,6 +1822,7 @@ void WindowFollowSprite(WindowBase& w, EntityId spriteIndex) if (spriteIndex.ToUnderlying() < MAX_ENTITIES || spriteIndex.IsNull()) { w.viewport_smart_follow_sprite = spriteIndex; + GetGameState().CurrentlyFollowingEntity = spriteIndex; } } @@ -1829,6 +1830,7 @@ void WindowUnfollowSprite(WindowBase& w) { w.viewport_smart_follow_sprite = EntityId::GetNull(); w.viewport_target_sprite = EntityId::GetNull(); + GetGameState().CurrentlyFollowingEntity = EntityId::GetNull(); } Viewport* WindowGetViewport(WindowBase* w) diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index 7de94e29f9..61a9de6104 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -599,7 +599,7 @@ namespace OpenRCT2 void ReadWriteInterfaceChunk(GameState_t& gameState, OrcaStream& os) { - os.ReadWriteChunk(ParkFileChunkType::INTERFACE, [&gameState](OrcaStream::ChunkStream& cs) { + os.ReadWriteChunk(ParkFileChunkType::INTERFACE, [&gameState, &os](OrcaStream::ChunkStream& cs) { cs.ReadWrite(gameState.SavedView.x); cs.ReadWrite(gameState.SavedView.y); if (cs.GetMode() == OrcaStream::Mode::READING) @@ -612,6 +612,12 @@ namespace OpenRCT2 cs.Write(static_cast(gameState.SavedViewZoom)); } cs.ReadWrite(gameState.SavedViewRotation); + + if (os.GetHeader().TargetVersion >= PARK_FILE_CURRENT_VERSION) + cs.ReadWrite(gameState.CurrentlyFollowingEntity); + else + gameState.CurrentlyFollowingEntity = EntityId::GetNull(); + cs.ReadWrite(gameState.LastEntranceStyle); cs.ReadWrite(gameState.EditorStep); }); diff --git a/src/openrct2/park/ParkFile.h b/src/openrct2/park/ParkFile.h index 3aef7d103b..271c6de496 100644 --- a/src/openrct2/park/ParkFile.h +++ b/src/openrct2/park/ParkFile.h @@ -11,10 +11,10 @@ namespace OpenRCT2 struct GameState_t; // Current version that is saved. - constexpr uint32_t PARK_FILE_CURRENT_VERSION = 33; + constexpr uint32_t PARK_FILE_CURRENT_VERSION = 34; // The minimum version that is forwards compatible with the current version. - constexpr uint32_t PARK_FILE_MIN_VERSION = 33; + constexpr uint32_t PARK_FILE_MIN_VERSION = 34; // The minimum version that is backwards compatible with the current version. // If this is increased beyond 0, uncomment the checks in ParkFile.cpp and Context.cpp!