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 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
Copy link
Member Author

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 :)

This is especially useful for automated-testing, to make a save
when the game quits while using "-vnull:ticks=N".
@TrueBrain TrueBrain merged commit 37ae6b8 into OpenTTD:master Jun 10, 2021
@TrueBrain TrueBrain deleted the script-game-exit branch June 10, 2021 17:34
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.

None yet

3 participants