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

Improvements for replays #92

Merged
merged 5 commits into from
Oct 2, 2016
Merged

Improvements for replays #92

merged 5 commits into from
Oct 2, 2016

Conversation

Falcury
Copy link
Contributor

@Falcury Falcury commented Sep 18, 2016

This adds some new functions for replays.

  • Added a way for the game to loop through and remember all of the files in the replays/ directory; added struct replay_info_type to keep track of all the files. The replay files do not need to have a specific naming pattern anymore.
  • Added a procedure that reads the "header" of the replay file (version strings + levelset name)
  • Replays can be played back in reverse creation order.
  • Replays get saved to a replays/ directory with format YYYY-mm-dd Mod Name L<level> - <incrementing number>
  • The game can now switch between different mod folders on the fly (i.e. you can cycle through replays that were created with different mods). Added a procedure reload_non_music_sounds() that frees and reloads all of the sounds that are not music sounds (i.e. everything that is not an OGG file). Added a procedure reload_resources(); this calls reload_non_music_sounds() and also reloads the data from PRINCE.DAT and KID.DAT (chtabs 0-2).
  • Fixed opening replay files (directly, e.g. by double-clicking) from other working directories than the SDLPoP root directory. (The game would look for the data files in the folder of the replay file itself, but this is not necessarily the desired behavior... Added procedure change_working_directory_to_sdlpop_root() to makes sure that the SDLPoP root folder will be the working directory in this situation).
  • Refactor: Split the code from load_options() into multiple pieces: load_global_options(), check_mod_param() and load_mod_options() (which needs to be called AFTER checking whether a replay file is being opened as the first command line parameter, because a replay file from a specific mod may be loaded, so the initial levelset name is not definitive until then).
  • Other minor changes

Known issues / discussion points:

  • Still using the old version strings quick_version and replay_version, I don't really know if this should be changed or not.
  • The replay format is still unwieldy... Should there be other changes? And should memory of moves[] be dynamic instead of static, and/or encapsulated somehow in a 'memory buffer' type?
  • Do we need a warning message if the replay's mod folder is not installed?

EDIT 1 Oct 2016: The issue with Cuspop options has been fixed. options_type has been removed altogether now. I also added an option in SDLPoP.ini to change the folder where replays are saved / read from.

* Added a way for the game to loop through and remember all of the files in the replays/ directory; added `struct replay_info_type` to keep track of all the files.
* Added a procedure that reads the "header" of the replay file (version strings + levelset name)
* Replays can be played back in reverse creation order.
* Replays get saved to a `replays/` directory
* Added a procedure `reload_non_music_sounds()` that frees and reloads all of the sounds that are not music sounds (i.e. everything that is not an OGG file)
* The game can now switch between different mod folders on the fly (i.e. you can cycle through replays that were created with different mods), added a procedure `reload_resources()`; this calls `reload_non_music_sounds()` and also reloads the data from PRINCE.DAT and KID.DAT (chtabs 0-2).
* Fixed opening replay files (directly, e.g. by double-clicking) from other working directories than the SDLPoP root directory. (The game would look for the data files in the folder of the replay file itself, but this is not necessarily the desired behavior... Added procedure `change_working_directory_to_sdlpop_root()` which makes sure that the SDLPoP root folder will be the working directory in this situation).
* Refactor: Split the code from `load_options()` into multiple pieces: `load_global_options()`, `check_mod_param()` and `load_mod_options()` (which needs to be called AFTER checking whether a replay file is being opened as the first command line parameter, because a replay file from a specific mod may be loaded, so the initial levelset name is not definitive until then).

Known issues:
* CusPop options used by replays do not get cleared properly. Will have to find a way to set all of the CusPop modified variables back to their original state, when unloading a replay... The old `options_type` provides some 'encapsulation' for the replay config... in that line of thinking, should we simply store all of the (SDLPoP.ini / mod.ini) configuration state along with the replay file? I'm not sure...
* Still using the old version strings `quick_version` and `replay_version`, I don't really know if this should be changed or not.
* The replay format is still unwieldy... Should there be other changes? And should memory now stored in `moves[]` be dynamic instead of static, and/or encapsulated somehow in a 'memory buffer' type?
* Should it be possible to change the location of the `replays/` folder? Or should there be some other solution?
* Do we need a warning message if the replay's mod folder is not installed?
Plus small changes to SDLPoP.ini:
* Added some spacing to make the different sections stand out more
* `;start_in_blind_mode = false` was set to `true` accidentally (fixed)
(For instance, if there is no `mod.ini`, the default settings can just be used)
Now makes use of the SDL_RWops functions, for file-like memory streams.
Instead of using the fixed `options_type` struct to read/write the options in bulk, now it uses a method similar to `quick_process()`.
The `options_type` itself is phased out.
* The function use_default_options() is no longer necessary
* Ignore some bytes in options_process(): enable_mixer, enable_fade, enable_flash, enable_text, enable_replay and use_correct_aspect_ratio should not be changeable by replays (although these options were included in the old replay files)
* Refactored the procedures for saving/loading the options using SDL_RWops streams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants