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

Add support to record and replay game commands/actions. #8374

Merged
merged 44 commits into from
Jan 2, 2019

Conversation

ZehMatt
Copy link
Member

@ZehMatt ZehMatt commented Dec 6, 2018

This is something I wanted to do for a longer time now. Basically this records all game actions and game commands and replays it back.

Small preview: https://share.epic-domain.com/2018-12-06_06-30-281437ce2a04a2d1077.webm

@ZehMatt ZehMatt force-pushed the replay-feature branch 2 times, most recently from 4a601cf to a42cc8c Compare December 6, 2018 06:31
@janisozaur janisozaur added Xcode Fix Required feature Add something new to the game. labels Dec 6, 2018
@ZehMatt
Copy link
Member Author

ZehMatt commented Dec 6, 2018

Ok a few things that we need to discuss:

  1. What should the file extension be for replays?
  2. What should the output filename look like?
  3. Is the current path acceptable?
  4. Should user interaction stay locked while the replay is active?

And I think it would be better if we save the cheats and in replays as we can use them to do regression tests on hacked parts.

@AaronVanGeffen
Copy link
Member

This is a really neat idea. Sounds like this would make a really neat way of making time-lapses as well, e.g. for NE design parks.

@ZehMatt
Copy link
Member Author

ZehMatt commented Dec 7, 2018

My current goal is to use this system to generate regression tests. Lets say something would crash by placing a scenery in a specific way. So we fix it, we create a replay and put it to the regression tests, that assures that the exact situation will not ever crash again. But yeah I think this system could be used for more like macro recording. Right now its currently bound to park snapshot and specific ticks but it could in theory save some optimized output to simply replay actions.

@ZehMatt
Copy link
Member Author

ZehMatt commented Dec 11, 2018

Okay I think this should do, the WIP label can be removed. However we need to decide where what goes still.

@fromthere
Copy link

fromthere commented Dec 11, 2018

I think this can be used to create tutorial(there should be popup function though)

or speedrun recording? (with early completion feature)

@ZehMatt ZehMatt force-pushed the replay-feature branch 2 times, most recently from e207851 to 2863899 Compare December 11, 2018 09:22
@ZehMatt
Copy link
Member Author

ZehMatt commented Dec 11, 2018

I might look into that afterwards, my focus currently sits more on stability and such tests can easily detect if something fundamentally changed in the game logic or rendering.

@ZehMatt ZehMatt force-pushed the replay-feature branch 6 times, most recently from 226e0d3 to 8046a40 Compare December 13, 2018 09:41
@Gymnasiast
Copy link
Member

I ran into difficulties fixing the Xcode project on this. It complained about not being able to find gtest.h after I added the ReplayTests.cpp file to it. On closer inspection, it appears the Xcode project does not do testing at all, which might explain this.

@janisozaur
Copy link
Member

Perhaps it's finally time to move macOS builds to cmake, given how problematic updating the xcode project is on account of both technical term as well as social – there's nobody using it.

@Gymnasiast
Copy link
Member

I think Xcode is needed to make an .app package on Mac. Cmake just makes a Unix-style binary.

@ZehMatt
Copy link
Member Author

ZehMatt commented Dec 14, 2018

Perhaps skip ReplayTests.cpp for the time being?

@Gymnasiast
Copy link
Member

The problem is that it can't compile due to it not finding symbols. The regular code should not need test sources (the other way round is fine, and inevitable).

@IntelOrca
Copy link
Contributor

I think there are cmake extensions for creating a .app, a .app at the end of the day is just a directory so we can always create it ourselves manually. Someone with more experience would need to investigate this.

OpenLoco has proved to be much more convenient regarding macOS (e.g. no xcode and filesystem via boost).

@IntelOrca
Copy link
Contributor

IntelOrca commented Dec 14, 2018

The problem is that it can't compile due to it not finding symbols. The regular code should not need test sources.

What src/ source file are you referring to? I don't see any that require test headers.

@ZehMatt
Copy link
Member Author

ZehMatt commented Dec 14, 2018

Only ReplayTests.cpp includes gtests.h, so the idea was to leave ReplayTests.cpp out of the Xcode project/build.

@Gymnasiast
Copy link
Member

Oh, wait, I now see what I did wrong. I added ReplayTest.cpp instead of ReplayManager.{cpp,h}. Taking another stab tonight.

@janisozaur
Copy link
Member

I'm pretty much done with reviewing this and most of my requests have already been taken care of.

Other than the remaining comments I also have one more request: at the very beginning of record data add recording version id ("1") and network stream version string. I know it's not expected to change in format but if it does it will make it easier for us. In case of recording version reject replays in different version, for network stream print a warning stating the current and expected version as well as hint to perform normalisation.

I still haven't tested it, I'd like to do so tomorrow.

@ZehMatt
Copy link
Member Author

ZehMatt commented Dec 29, 2018

Fair enough, will refactor it slightly to support other versions if required.

Copy link
Member

@janisozaur janisozaur left a comment

Choose a reason for hiding this comment

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

Last minor comments and a suggestion: it would be nice to have some indication the playback has finished (other than the status text missing) like a pop-up (think: network desync) and the client getting paused.

Other than that it's fine to get merged.

@ZehMatt
Copy link
Member Author

ZehMatt commented Jan 2, 2019

I left out the pausing of the game as that felt really off. Also instead of a window popup I have used the news queue which seems to do the notification job well enough, also when pausing the game it would stop updating the news queue and only half way renders the text, hope this approach is fine too.

@janisozaur
Copy link
Member

The news ticker approach sounds fine. There's some failing CI job now.

@ZehMatt
Copy link
Member Author

ZehMatt commented Jan 2, 2019

Yea GCC would need a macro but I rather wen't the C++ approach using stringstream now which at least adds type safety.

@ZehMatt ZehMatt merged commit a065806 into OpenRCT2:develop Jan 2, 2019
@ZehMatt ZehMatt deleted the replay-feature branch January 29, 2019 23:09
janisozaur added a commit that referenced this pull request Mar 13, 2019
- Feature: [#4418] Allow steep slopes on the side-friction roller coaster.
- Feature: [#7726] Add shortcut to advance one tick.
- Feature: [#7956, #7964] Add sprite font glyphs for Hungarian and some Czech letters.
- Feature: [#7971] Toolbox option to open custom content folder.
- Feature: [#7980] Allow data path for RCT1 to be specified by a command line argument.
- Feature: [#8073] Auto-upload minidumps to backtrace.io (optional, MSVC/Windows only)
- Feature: [#8078] Add save_park command to in-game console.
- Feature: [#8080] New console variable "current_rotation" to get or set view rotation.
- Feature: [#8098] Glyph for Russian rouble sign.
- Feature: [#8099] Add Powered Launch mode to Inverted RC (for RCT1 parity).
- Feature: [#8190] Allow building footpaths on 'corner down' terrain.
- Feature: [#8191] Allow building on-ride photos and water S-bends on the Water Coaster.
- Feature: [#8259] Add say command to in-game console.
- Feature: [#8374] Add replay system.
- Feature: [#8377] Add option to adjust amount of autosaves to keep.
- Feature: [#8458] Add sprite sorting benchmark.
- Feature: [#8583] Add boosters to water coaster.
- Feature: [#8648] Add optional chat button to top toolbar in multiplayer games.
- Feature: [#8652] Add network window including a graph for data usage visualisation.
- Feature: [#8670] Add ability to download missing objects when loading a park.
- Change: [#7961] Add new object types: station, terrain surface, and terrain edge.
- Change: [#8222] The climate setting has been moved from objective options to scenario options.
- Change: [#8718] Allow TARMAC object to be removed when running the `remove_unused_objects` command.
- Change: [#8718] No longer require the generic scenery groups and tarmac footpath to be checked when creating a scenario.
- Change: [#8734] Disable kick button in multiplayer window when unable to use it.
- Fix: [#3832] Changing the colour scheme of track pieces does not work in multiplayer.
- Fix: [#4094] Coasters with long flat-to-steep pieces offer them in diagonal mode (original bug).
- Fix: [#5684] Player list can desync between clients and server and can crash.
- Fix: [#6191] OpenRCT2 fails to run when the path has an emoji in it.
- Fix: [#7439] Placement messages have mixed strings
- Fix: [#7473] Disabling sound effects also disables "Disable audio on focus loss".
- Fix: [#7536] Android builds fail to start.
- Fix: [#7689] Deleting 0-tile maze gives a MONEY32_UNDEFINED (negative) refund.
- Fix: [#7828] Copied entrances and exits stay when demolishing ride.
- Fix: [#7945] Client IP address is logged as `(null)` in server logs.
- Fix: [#7952] Performance drop caused by code refactor.
- Fix: [#7954] Key validation fails on Windows due to non-ASCII user / player name.
- Fix: [#7975] Inspection flag not cleared for rides which are set to never be inspected (original bug).
- Fix: [#7985] Giant Screenshot ignores 'Map rendering' settings.
- Fix: [#7987] Broken track designs increase money by MONEY32_UNDEFINED.
- Fix: [#7991] Scenery and footpaths on Construction Rights tiles can be deleted using Clear Scenery.
- Fix: [#8034] Vanilla sprites are broken when making screenshots from command line.
- Fix: [#8045] Crash when switching between languages.
- Fix: [#8062] In multiplayer warnings for unstable cheats are shown when disabling them.
- Fix: [#8090] Maze designs saved incorrectly.
- Fix: [#8101] Title sequences window flashes after opening.
- Fix: [#8120] Crash trying to place peep spawn outside of map.
- Fix: [#8121] Crash Renaming park with server logging enabled.
- Fix: [#8139] Buying land costs money when the game is in "no money" mode.
- Fix: [#8141] Attempting to build entrance/exit on station 2 does not work.
- Fix: [#8142] Reliability of mazes and crooked houses can go below 100%.
- Fix: [#8187] Cannot set land ownership over ride entrances or exits in sandbox mode.
- Fix: [#8200] Incorrect behaviour when removing entrances and exits that are on the same tile.
- Fix: [#8204] Crash when tile element has no surface elements.
- Fix: [#8264] Rides and scenery placeable outside of map with ZC and Sandbox mode enabled.
- Fix: [#8335] Rides with arbitrary ride types can crash the game when they break down.
- Fix: [#8358] Infinite loop when changing vehicle count on stopped ride.
- Fix: [#8402] Crash closing a window in some cases.
- Fix: [#8431] Crash when game action logging is enabled.
- Fix: [#8433] Crash if master server response is not valid JSON.
- Fix: [#8434] Crash if curl_easy_init fails.
- Fix: [#8443] Crash when selecting the current vehicle for ride that has none available.
- Fix: [#8456] Junior booster track piece doesn't connect properly.
- Fix: [#8464] Crash on game shutdown.
- Fix: [#8469] Crash modifying colour on hacked rides.
- Fix: [#8508] Underground roto-drop is not going up.
- Fix: [#8555] Multiplayer window text limits are not computed properly.
- Fix: [#8572] Steel Twister track pieces ID 64 and 65 drawn incorrectly.
- Fix: [#8585] Part of track missing on air powered vertical coaster.
- Fix: [#8588] Guest list scrolling breaks above ~2000 guests.
- Fix: [#8591] Game loop does not run at a consistent tick rate of 40 Hz.
- Fix: [#8647] Marketing campaigns check for entry fees below £1 (original bug).
- Fix: [#8653] Crash when peeps attempt to enter a ride with no vehicles.
- Fix: [#8720] Desync due to boats colliding with ghost pieces.
- Fix: [#8739] Savegame from original game crashes when cruising through map.
- Fix: [#8742] Access violation in vehicle_update_sound_params.
- Fix: [#8804] Raising water shows money effect at the bottom rather than new height.
- Fix: [#8811] Some fields in the sv6 save file not being copied correctly.
- Fix: [#8824] Invalid read in footpath_chain_ride_queue.
- Improved: [#2940] Allow mouse-dragging to set patrol area (Singleplayer only).
- Improved: [#7730] Draw extreme vertical and lateral Gs red in the ride window's graph tab.
- Improved: [#7930] Automatically create folders for custom content.
- Improved: [#7980] Show the full path of the scenario in the scenario select window.
- Improved: [#7993] Allow assigning a keyboard shortcut for opening the tile inspector.
- Improved: [#8107] Support Discord release of RCT2.
- Improved: [#8491] Highlight entrance and exit with different colours in track design previews.
- Improved: Almost completely new Hungarian translation.
- Removed: [#7929] Support for scenario text objects.
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. feature Add something new to the game. 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

6 participants