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

Fix quickloading #60587

Merged
merged 4 commits into from
Sep 1, 2022
Merged

Fix quickloading #60587

merged 4 commits into from
Sep 1, 2022

Conversation

angleKH
Copy link
Contributor

@angleKH angleKH commented Aug 30, 2022

Summary

Bugfixes "Restored quickload to working order"

Purpose of change

This PR fixes the quickload function (currently crashes) and enables it in release builds under the debug menu, and adds the same warning as the "Quit without saving" option. This would also be especially helpful for development.

This also happens to fix #38557.

Describe the solution

Rather than attempting to call the functions to load the game directly, as the current implementation does, this simply loads the world as if the user exited to the menu and immediately loaded the world again. This means the cleanup code from exiting will also run, unlike the current implementation which is missing some.

For this PR, on quickloading, the current world and player save is queued to load the next time the main menu is entered. Then the game exits to the main menu but loads the world immediately. Because of this the data files still need to go through the loading/validating process, but this is also the case for the current implementation.

The cli option --world has also been changed to use this queue rather than being part of the main loop as an if statement.

Describe alternatives you've considered

Loading the world again without simulating exiting and loading the world from nothing would be best, but is infeasible. I could not get it to work. This would also likely add a lot of duplicated code from the necessary cleanup.

Before using the main menu, I also tried using the current implementation of the cli --world option's method to load the world (g->load in the main loop before menu) after running cleanup code. This worked, but segfaulted after a couple of quickloads. This also implies that there may be some problem with the current implementation of the cli --world option.

Testing

Tested only on Linux.

  • Tested quickloading several times.
  • Tested with the same world.
  • Tested after switching between different worlds.
  • Tested with worlds containing multiple characters to ensure the correct character was quickloaded.
  • Tested quickloading after loading a world with the cli --world option.

Additional context

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Aug 30, 2022
src/debug_menu.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Aug 30, 2022
@angleKH angleKH marked this pull request as draft August 30, 2022 19:15
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Aug 30, 2022
@angleKH angleKH marked this pull request as ready for review August 30, 2022 22:07
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Aug 31, 2022
src/game.cpp Outdated Show resolved Hide resolved
@dseguin dseguin merged commit 72e6972 into CleverRaven:master Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unnecessary autosave after quickloading an autosave
4 participants