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

Made setting the game speed a game action #20825

Merged
merged 8 commits into from
Oct 4, 2023

Conversation

fidwell
Copy link
Contributor

@fidwell fidwell commented Sep 28, 2023

This change adds a new game action called GameSetSpeedAction (for C++) gamesetspeed (for plugins) for changing the game speed (normal, fast, turbo, etc.).

@@ -425,6 +425,12 @@ namespace OpenRCT2::Scripting
return GetIconByName(iconName);
}

void setGameSpeed(int32_t speed)
{
gGameSpeed = std::max(1, (speed > 4 ? (gConfigGeneral.DebuggingTools ? 8 : 4) : speed));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be dangerous to run from a networked game. I think thats the main reason why we haven't implemented it. @ZehMatt any thoughts on this?

Copy link
Member

@ZehMatt ZehMatt Oct 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory its safe as clients can't progress past the server tick, however if the game speed is not properly synchronized then clients will only fast-forward if they are too far behind the server tick. Ideally this is a game action so clients will progress at the same pace as the server.

@fidwell fidwell changed the title Allowed setting the game speed from a plugin Made setting the game speed a game action Oct 2, 2023
@fidwell
Copy link
Contributor Author

fidwell commented Oct 2, 2023

Updated the branch to make it a game action. I think I hit all the right places, and it seems to work both in-game and from a plugin. As usual, apologies for missing anything obvious; I'm not a C++ developer... I just know how to copy patterns...

There are two places I didn't touch yet: the title screen, and the legacy console commands. I can update those too if needed.

@ZehMatt ZehMatt added network version Network version needs updating - double check before merging! changelog This issue/PR deserves a changelog entry. labels Oct 2, 2023
@ZehMatt ZehMatt added this to the v0.4.7 milestone Oct 2, 2023
Copy link
Member

@ZehMatt ZehMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thing, also this needs a network version bump.

src/openrct2/actions/GameSetSpeedAction.cpp Outdated Show resolved Hide resolved
Copy link
Member

@ZehMatt ZehMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine, I haven't tested it but I assume you did some basic testing also with multiplayer in mind?

@fidwell
Copy link
Contributor Author

fidwell commented Oct 4, 2023

I tested with a plugin and it seems to work fine.

I tried starting a server and got an immediate crash with the message: Unable to find player 4294967295 for game action 83. From what I can figure, this was because it was using a game action to set the speed in the GameLoadInit function, where player_id hasn't been set yet (so it just had garbage in it). So I had to roll that line back. Seems to be okay now.

Copy link
Member

@ZehMatt ZehMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, no objections from me.

@duncanspumpkin duncanspumpkin merged commit e17bca3 into OpenRCT2:develop Oct 4, 2023
21 checks passed
@fidwell fidwell deleted the game-speed-action branch October 7, 2023 23:33
Realsteel89 pushed a commit to Realsteel89/OpenRCT2 that referenced this pull request Oct 10, 2023
* Bare minimum for a game action

* Changelog entry

* Fixed formatting

* Consistent capitalization

* Committed wrong file

* Removing redundant toolbar invalidations

* Bump network version; remove redundant qualifier

* Fixed crash on starting server
if (!IsValidSpeed(_speed))
{
LOG_WARNING("Invalid game command for speed %u", _speed);
return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we offer better error message than just invalid? I know it's weird to explain because it needs to be between 1-4 or 8...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that this error message could have been worded better. Since this PR was already merged, I'll have to make a new PR to clean it up.

int32_t _speed{ 1 };

public:
GameSetSpeedAction() = default;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this to compile somewhere? Otherwise I would remove it, as we never use the default ctor and would technically always want to use the action with a given speed.

Copy link
Contributor Author

@fidwell fidwell Oct 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a C++ expert by any means... I only made the .h file because the other game actions did. If it's not needed, then yeah let's remove it.

@deurklink
Copy link
Contributor

Awww damn this no longer allows me to play back replays at a higher game speed

Realsteel89 pushed a commit to Realsteel89/OpenRCT2 that referenced this pull request Oct 15, 2023
* Bare minimum for a game action

* Changelog entry

* Fixed formatting

* Consistent capitalization

* Committed wrong file

* Removing redundant toolbar invalidations

* Bump network version; remove redundant qualifier

* Fixed crash on starting server
AT41 pushed a commit to AT41/OpenRCT2 that referenced this pull request Dec 24, 2023
* Bare minimum for a game action

* Changelog entry

* Fixed formatting

* Consistent capitalization

* Committed wrong file

* Removing redundant toolbar invalidations

* Bump network version; remove redundant qualifier

* Fixed crash on starting server
janisozaur added a commit that referenced this pull request Dec 31, 2023
- Feature: [#12078] Add shortcut key for toggling wall slope.
- Feature: [#19919] Add diagonal brakes and diagonal block brakes to most coaster types.
- Feature: [#20141] Add additional track pieces to the Giga Coaster.
- Feature: [#20825] Made setting the game speed a game action.
- Feature: [#20830] Display author field on scenery window.
- Feature: [#20853] [Plugin] Add “BaseTileElement.owner” which is saved in the park file.
- Feature: [objects#257] Re-introduce the RCT1 road, which does not have handrails.
- Feature: [OpenMusic#46] Added Mystic ride music style.
- Feature: [OpenMusic#50] Added Rock style 4 ride music.
- Improved: [objects#261] Add composer credits on all RCT2 music objects.
- Change: [#20790] Default ride price set to free if park charges for entry.
- Change: [#20880] Restore removed default coaster colours.
- Change: [#21102] The money effect will now update even when the game is paused.
- Change: [objects#244] Update sort priorities for expansion scenery groups.
- Change: [objects#256] Use recoloured RCT2 artwork on the Fruity Ices Stall, rather than the (slightly different) RCT1 artwork.
- Fix: [#5677] Balloons pass through the ground and objects.
- Fix: [#12299] Placing ride entrances/exits ignores the Disable Clearance Checks cheat.
- Fix: [#13473] Guests complain that the default Circus price is too high.
- Fix: [#15293] TTF fonts don’t format correctly with OpenGL.
- Fix: [#16453] Tile inspector invisibility shortcut does not use a game action.
- Fix: [#16926] When multiple vehicles are grouped in research, only one of them is unlocked.
- Fix: [#17774] Misplaced/missing land and construction rights tiles in RCT1 & RCT2 scenarios.
- Fix: [#18199] Dots in the game save’s name no longer get truncated.
- Fix: [#19722] “Forbid tree removal” restriction doesn’t forbid removal of large scenery tree items.
- Fix: [#20253] Crash when displaying a Lay-Down RC’s half loop.
- Fix: [#20356] Cannot set tertiary colour on small scenery.
- Fix: [#20624] Scrolling text glitches after language is changed.
- Fix: [#20679] Android: game crashes at launch.
- Fix: [#20737] Spent money in player window underflows when getting refunds.
- Fix: [#20747] Staff speed cheat not applying to newly hired staff, UI not showing the current applied speed.
- Fix: [#20778] [Plugin] Incorrect target api when executing custom actions.
- Fix: [#20807] Tertiary colour not copied with small scenery.
- Fix: [#20964] Crash when player connects to server with a group assigned that no longer exists.
- Fix: [#20995] TTF fonts don’t support hinting, outlines, or insets with OpenGL.
- Fix: [#21042] Peeps don’t render properly in S4 parks.
- Fix: [objects#246, objects#248] Some objects are incorrectly marked as originating from RCT1.
- Fix: [objects#260] Submarine Ride has its capacity listed incorrectly.
KatieZeldaKat pushed a commit to KatieZeldaKat/OpenRCT2 that referenced this pull request Jan 2, 2024
- Feature: [OpenRCT2#12078] Add shortcut key for toggling wall slope.
- Feature: [OpenRCT2#19919] Add diagonal brakes and diagonal block brakes to most coaster types.
- Feature: [OpenRCT2#20141] Add additional track pieces to the Giga Coaster.
- Feature: [OpenRCT2#20825] Made setting the game speed a game action.
- Feature: [OpenRCT2#20830] Display author field on scenery window.
- Feature: [OpenRCT2#20853] [Plugin] Add “BaseTileElement.owner” which is saved in the park file.
- Feature: [objects#257] Re-introduce the RCT1 road, which does not have handrails.
- Feature: [OpenMusic#46] Added Mystic ride music style.
- Feature: [OpenMusic#50] Added Rock style 4 ride music.
- Improved: [objects#261] Add composer credits on all RCT2 music objects.
- Change: [OpenRCT2#20790] Default ride price set to free if park charges for entry.
- Change: [OpenRCT2#20880] Restore removed default coaster colours.
- Change: [OpenRCT2#21102] The money effect will now update even when the game is paused.
- Change: [objects#244] Update sort priorities for expansion scenery groups.
- Change: [objects#256] Use recoloured RCT2 artwork on the Fruity Ices Stall, rather than the (slightly different) RCT1 artwork.
- Fix: [OpenRCT2#5677] Balloons pass through the ground and objects.
- Fix: [OpenRCT2#12299] Placing ride entrances/exits ignores the Disable Clearance Checks cheat.
- Fix: [OpenRCT2#13473] Guests complain that the default Circus price is too high.
- Fix: [OpenRCT2#15293] TTF fonts don’t format correctly with OpenGL.
- Fix: [OpenRCT2#16453] Tile inspector invisibility shortcut does not use a game action.
- Fix: [OpenRCT2#16926] When multiple vehicles are grouped in research, only one of them is unlocked.
- Fix: [OpenRCT2#17774] Misplaced/missing land and construction rights tiles in RCT1 & RCT2 scenarios.
- Fix: [OpenRCT2#18199] Dots in the game save’s name no longer get truncated.
- Fix: [OpenRCT2#19722] “Forbid tree removal” restriction doesn’t forbid removal of large scenery tree items.
- Fix: [OpenRCT2#20253] Crash when displaying a Lay-Down RC’s half loop.
- Fix: [OpenRCT2#20356] Cannot set tertiary colour on small scenery.
- Fix: [OpenRCT2#20624] Scrolling text glitches after language is changed.
- Fix: [OpenRCT2#20679] Android: game crashes at launch.
- Fix: [OpenRCT2#20737] Spent money in player window underflows when getting refunds.
- Fix: [OpenRCT2#20747] Staff speed cheat not applying to newly hired staff, UI not showing the current applied speed.
- Fix: [OpenRCT2#20778] [Plugin] Incorrect target api when executing custom actions.
- Fix: [OpenRCT2#20807] Tertiary colour not copied with small scenery.
- Fix: [OpenRCT2#20964] Crash when player connects to server with a group assigned that no longer exists.
- Fix: [OpenRCT2#20995] TTF fonts don’t support hinting, outlines, or insets with OpenGL.
- Fix: [OpenRCT2#21042] Peeps don’t render properly in S4 parks.
- Fix: [objects#246, objects#248] Some objects are incorrectly marked as originating from RCT1.
- Fix: [objects#260] Submarine Ride has its capacity listed incorrectly.
CorySanin added a commit to CorySanin/OpenRCT2 that referenced this pull request Feb 4, 2024
Release v0.4.7

- Feature: [OpenRCT2#12078] Add shortcut key for toggling wall slope.
- Feature: [OpenRCT2#19919] Add diagonal brakes and diagonal block brakes to most coaster types.
- Feature: [OpenRCT2#20141] Add additional track pieces to the Giga Coaster.
- Feature: [OpenRCT2#20825] Made setting the game speed a game action.
- Feature: [OpenRCT2#20830] Display author field on scenery window.
- Feature: [OpenRCT2#20853] [Plugin] Add “BaseTileElement.owner” which is saved in the park file.
- Feature: [objects#257] Re-introduce the RCT1 road, which does not have handrails.
- Feature: [OpenMusic#46] Added Mystic ride music style.
- Feature: [OpenMusic#50] Added Rock style 4 ride music.
- Improved: [objects#261] Add composer credits on all RCT2 music objects.
- Change: [OpenRCT2#20790] Default ride price set to free if park charges for entry.
- Change: [OpenRCT2#20880] Restore removed default coaster colours.
- Change: [OpenRCT2#21102] The money effect will now update even when the game is paused.
- Change: [objects#244] Update sort priorities for expansion scenery groups.
- Change: [objects#256] Use recoloured RCT2 artwork on the Fruity Ices Stall, rather than the (slightly different) RCT1 artwork.
- Fix: [OpenRCT2#5677] Balloons pass through the ground and objects.
- Fix: [OpenRCT2#12299] Placing ride entrances/exits ignores the Disable Clearance Checks cheat.
- Fix: [OpenRCT2#13473] Guests complain that the default Circus price is too high.
- Fix: [OpenRCT2#15293] TTF fonts don’t format correctly with OpenGL.
- Fix: [OpenRCT2#16453] Tile inspector invisibility shortcut does not use a game action.
- Fix: [OpenRCT2#16926] When multiple vehicles are grouped in research, only one of them is unlocked.
- Fix: [OpenRCT2#17774] Misplaced/missing land and construction rights tiles in RCT1 & RCT2 scenarios.
- Fix: [OpenRCT2#18199] Dots in the game save’s name no longer get truncated.
- Fix: [OpenRCT2#19722] “Forbid tree removal” restriction doesn’t forbid removal of large scenery tree items.
- Fix: [OpenRCT2#20253] Crash when displaying a Lay-Down RC’s half loop.
- Fix: [OpenRCT2#20356] Cannot set tertiary colour on small scenery.
- Fix: [OpenRCT2#20624] Scrolling text glitches after language is changed.
- Fix: [OpenRCT2#20679] Android: game crashes at launch.
- Fix: [OpenRCT2#20737] Spent money in player window underflows when getting refunds.
- Fix: [OpenRCT2#20747] Staff speed cheat not applying to newly hired staff, UI not showing the current applied speed.
- Fix: [OpenRCT2#20778] [Plugin] Incorrect target api when executing custom actions.
- Fix: [OpenRCT2#20807] Tertiary colour not copied with small scenery.
- Fix: [OpenRCT2#20964] Crash when player connects to server with a group assigned that no longer exists.
- Fix: [OpenRCT2#20995] TTF fonts don’t support hinting, outlines, or insets with OpenGL.
- Fix: [OpenRCT2#21042] Peeps don’t render properly in S4 parks.
- Fix: [objects#246, objects#248] Some objects are incorrectly marked as originating from RCT1.
- Fix: [objects#260] Submarine Ride has its capacity listed incorrectly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog This issue/PR deserves a changelog entry. network version Network version needs updating - double check before merging!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants