Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #21426: Save currently following entity into save file. #21656

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions distribution/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions src/openrct2/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/openrct2/GameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ namespace OpenRCT2
ScreenCoordsXY SavedView;
uint8_t SavedViewRotation;
ZoomLevel SavedViewZoom;
EntityId CurrentlyFollowingEntity{ EntityId::GetNull() };
Harry-Hopkinson marked this conversation as resolved.
Show resolved Hide resolved

ObjectEntryIndex LastEntranceStyle;

Expand Down
2 changes: 2 additions & 0 deletions src/openrct2/interface/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,13 +1758,15 @@ void WindowFollowSprite(WindowBase& w, EntityId spriteIndex)
if (spriteIndex.ToUnderlying() < MAX_ENTITIES || spriteIndex.IsNull())
{
w.viewport_smart_follow_sprite = spriteIndex;
GetGameState().CurrentlyFollowingEntity = spriteIndex;
}
}

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)
Expand Down
8 changes: 7 additions & 1 deletion src/openrct2/park/ParkFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -612,6 +612,12 @@ namespace OpenRCT2
cs.Write(static_cast<int8_t>(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);
});
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/park/ParkFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down