Skip to content

Commit

Permalink
Add: execute "game_exit.scr" on closing the game
Browse files Browse the repository at this point in the history
This is especially useful for automated-testing, to make a save
when the game quits while using "-vnull:ticks=N".

Additionally, it is useful for dedicated servers that automatically
want to save a game before the server (gracefully) shuts down.
  • Loading branch information
TrueBrain committed Jun 9, 2021
1 parent 12de256 commit dbb782d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/scripts/game_exit.scr.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save on_exit
2 changes: 2 additions & 0 deletions src/openttd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,8 @@ int openttd_main(int argc, char *argv[])

VideoDriver::GetInstance()->MainLoop();

IConsoleCmdExec("exec scripts/game_exit.scr 0");

WaitTillSaved();

/* only save config if we have to */
Expand Down

0 comments on commit dbb782d

Please sign in to comment.