diff --git a/distribution/changelog.txt b/distribution/changelog.txt index d716c6293c6f..e1ef5dd06d0b 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -2,6 +2,7 @@ ------------------------------------------------------------------------ - Feature: [#622] Add option to align the top toolbar buttons horizontally centred (off by default). - Feature: [#20263] Ability to increase the size of the map in the (0, 0) direction. +- Feature: [#21656] Save the currently following entity into the save file. - Feature: [#21714] [Plugin] Costume assignment is now tailored to each staff type. - Feature: [#21853] Enlarged UI mode. - Feature: [#21893, #22065] On launch, the game now indicates what system is being initialised. diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 1ec5b86167ee..f549c720ca72 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -362,6 +362,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 bcf3db304e67..2145397481c3 100644 --- a/src/openrct2/GameState.h +++ b/src/openrct2/GameState.h @@ -127,6 +127,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 cf5aa65f3f9d..c5bd151b1b33 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -1758,6 +1758,7 @@ void WindowFollowSprite(WindowBase& w, EntityId spriteIndex) if (spriteIndex.ToUnderlying() < MAX_ENTITIES || spriteIndex.IsNull()) { w.viewport_smart_follow_sprite = spriteIndex; + GetGameState().CurrentlyFollowingEntity = spriteIndex; } } @@ -1765,6 +1766,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 7d2a8a69faa7..5571ff8f930f 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 3aef7d103bcd..271c6de496f8 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!