Save following entity into save file

This commit is contained in:
Harry Hopkinson 2024-03-22 20:23:33 +00:00
parent 08fdf386a5
commit 51d1a5985f
6 changed files with 19 additions and 3 deletions

View File

@ -1,6 +1,7 @@
0.4.11 (in development) 0.4.11 (in development)
------------------------------------------------------------------------ ------------------------------------------------------------------------
- Feature: [#11512] Coloured usernames by group on multiplayer servers. - 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. - Feature: [#21734] Park admittance price can now be set via text input.
- Improved: [#21769] Expose “animation is backwards” wall property in Tile Inspector. - 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. - Change: [#21715] [Plugin] Remove access to the internal `owner` property. Note: `ownership` is still accessible.

View File

@ -531,6 +531,12 @@ void GameLoadInit()
auto& gameState = GetGameState(); auto& gameState = GetGameState();
windowManager->SetMainView(gameState.SavedView, gameState.SavedViewZoom, gameState.SavedViewRotation); 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) if (NetworkGetMode() != NETWORK_MODE_CLIENT)
{ {
GameActions::ClearQueue(); GameActions::ClearQueue();

View File

@ -126,6 +126,7 @@ namespace OpenRCT2
ScreenCoordsXY SavedView; ScreenCoordsXY SavedView;
uint8_t SavedViewRotation; uint8_t SavedViewRotation;
ZoomLevel SavedViewZoom; ZoomLevel SavedViewZoom;
EntityId CurrentlyFollowingEntity{ EntityId::GetNull() };
ObjectEntryIndex LastEntranceStyle; ObjectEntryIndex LastEntranceStyle;

View File

@ -1822,6 +1822,7 @@ void WindowFollowSprite(WindowBase& w, EntityId spriteIndex)
if (spriteIndex.ToUnderlying() < MAX_ENTITIES || spriteIndex.IsNull()) if (spriteIndex.ToUnderlying() < MAX_ENTITIES || spriteIndex.IsNull())
{ {
w.viewport_smart_follow_sprite = spriteIndex; 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_smart_follow_sprite = EntityId::GetNull();
w.viewport_target_sprite = EntityId::GetNull(); w.viewport_target_sprite = EntityId::GetNull();
GetGameState().CurrentlyFollowingEntity = EntityId::GetNull();
} }
Viewport* WindowGetViewport(WindowBase* w) Viewport* WindowGetViewport(WindowBase* w)

View File

@ -599,7 +599,7 @@ namespace OpenRCT2
void ReadWriteInterfaceChunk(GameState_t& gameState, OrcaStream& os) 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.x);
cs.ReadWrite(gameState.SavedView.y); cs.ReadWrite(gameState.SavedView.y);
if (cs.GetMode() == OrcaStream::Mode::READING) if (cs.GetMode() == OrcaStream::Mode::READING)
@ -612,6 +612,12 @@ namespace OpenRCT2
cs.Write(static_cast<int8_t>(gameState.SavedViewZoom)); cs.Write(static_cast<int8_t>(gameState.SavedViewZoom));
} }
cs.ReadWrite(gameState.SavedViewRotation); 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.LastEntranceStyle);
cs.ReadWrite(gameState.EditorStep); cs.ReadWrite(gameState.EditorStep);
}); });

View File

@ -11,10 +11,10 @@ namespace OpenRCT2
struct GameState_t; struct GameState_t;
// Current version that is saved. // 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. // 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. // 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! // If this is increased beyond 0, uncomment the checks in ParkFile.cpp and Context.cpp!