From dfff80faa8b5cf4cd286fee2d1ef5eebcdb49829 Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Debian Linux)" Date: Thu, 2 Mar 2023 19:44:47 -0800 Subject: [PATCH] Add optional auto-save/restore feature using -a option To enable use with online Bulletin Board Systems (BBSes) where users may be disconnected unexpectedly, but would naturally want to resume playing their same game, added support for an optional save game path/filename to be specified on the command-line (very similar to "-r "), except this save/restore file is: 1. automatically loaded/restored if it exists 2. automatically created when starting a new game 3. automatically updated when exiting a game for any reason 4. cannot be changed to a different path/filename by the user Since a BBS server program can be expected to send a SIGHUP or SIGTERM to the game process upon user disconnection (or timeout), those signals are caught and a graceful termination will occur which saves the current game state. Build with ADVENT_AUTOSAVE defined to enable this option. BUG: The 'info' command still reports the save/suspend/pause commands as valid, though they are not when this build option is used (same is true of ADVENT_NOSAVE, and that doesn't apparently bother anyone). --- Makefile | 1 + advent.h | 3 +++ main.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- saveresume.c | 4 ++-- score.c | 3 +++ 5 files changed, 57 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 4e5f331..38139de 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ # Makefile for the open-source release of adventure 2.5 # To build with save/resume disabled, pass CFLAGS="-DADVENT_NOSAVE" +# To build with auto-save/resume enabled, pass CFLAGS="-D ADVENT_AUTOSAVE" VERS=$(shell sed -n = mxscor && game.trnluz != 0) rspeak(TOOK_LONG); -- 2.31.1