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: adhere the autosave_on_exit setting for Null videodriver #9343

Merged
merged 1 commit into from Jun 10, 2021

Conversation

@TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Jun 9, 2021

Motivation / Problem

Our scripting stuff is rarely useful, but I now had a use, it wasn't supplying.

For automated testing, I want to load an (old) savegame, run for a few ticks, and save&exit, so I could compare it with later results.

But .. there is no way to do this "run for a few ticks, and save&exit" currently. I could see two possible solutions:

  1. have a console command that "delayed executes" a command, so I can say: "execute in 200 ticks: save & exit".
  2. have a script that is called just after the game is stopping but before anything is shut down.
  3. (tnx to @glx22) make sure autosave_on_exit also works for the null driver.

Description

I went with 3), as 2) felt weird and dirty. 1) would be ideal, but is a lot more work.

This is especially useful for automated-testing, to make a save
when the game quits while using "-vnull:ticks=N".

Limitations

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')
@glx22
Copy link
Contributor

@glx22 glx22 commented Jun 9, 2021

Can't use the save at exit setting

} else if (_settings_client.gui.autosave_on_exit) {
?

@TrueBrain TrueBrain changed the title Add: execute "game_exit.scr" on closing the game Add: adhere the autosave_on_exit setting for Null videodriver Jun 9, 2021
@TrueBrain TrueBrain force-pushed the TrueBrain:script-game-exit branch from dbb782d to 1d32a18 Jun 9, 2021
@TrueBrain
Copy link
Member Author

@TrueBrain TrueBrain commented Jun 9, 2021

Can't use the save at exit setting

} else if (_settings_client.gui.autosave_on_exit) {

?

Completely forgot about that setting, yes, that works too :) Still needs a minor change ;)

Nice, tnx :)

@TrueBrain TrueBrain force-pushed the TrueBrain:script-game-exit branch from 1d32a18 to b50f864 Jun 9, 2021
bin/scripts/game_exit.scr.example Outdated Show resolved Hide resolved
This is especially useful for automated-testing, to make a save
when the game quits while using "-vnull:ticks=N".
@TrueBrain TrueBrain force-pushed the TrueBrain:script-game-exit branch from b50f864 to 326650f Jun 9, 2021
@TrueBrain TrueBrain merged commit 37ae6b8 into OpenTTD:master Jun 10, 2021
13 checks passed
13 checks passed
@github-actions
Emscripten
Details
@github-actions
Commit checker
Details
@github-actions
Check preview needs update Check preview needs update
Details
@github-actions
Linux (clang, clang++, libsdl2-dev)
Details
@github-actions
Linux (gcc, g++, libsdl2-dev)
Details
@github-actions
Linux (gcc, g++, libsdl1.2-dev)
Details
@github-actions
Linux (gcc, g++, -DOPTION_DEDICATED=ON)
Details
@github-actions
Mac OS (x64, x86_64)
Details
@github-actions
Windows (windows-latest, x86)
Details
@github-actions
Windows (windows-latest, x64)
Details
@github-actions
Windows (windows-2016, x86)
Details
@github-actions
Windows (windows-2016, x64)
Details
@github-actions
Check Annotations
Details
@TrueBrain TrueBrain deleted the TrueBrain:script-game-exit branch Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants