Commit graph

71 commits

Author SHA1 Message Date
Eric S. Raymond
643656fcc3 Complain to user on save/resume.restore when it's disabled. 2023-03-04 19:48:17 -05:00
Rob Swindell (on Debian Linux)
dfff80faa8 Add optional auto-save/restore feature using -a <filename> 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 <filename>"), 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).
2023-03-02 19:44:47 -08:00
Eric S. Raymond
94e7cc6505 Address Gitlab isse #62: Comment typos. 2023-03-01 13:04:53 -05:00
Eric S. Raymond
d320212622 Indent cleanup. 2022-04-18 10:31:13 -04:00
Eric S. Raymond
4069bf210b cppcheck cleanup. 2022-04-13 20:55:57 -04:00
Eric S. Raymond
49e2479efa Improve test coverage. 2022-04-07 06:42:20 -04:00
Eric S. Raymond
bb2b8e0fca Support execution of command script arguments. 2022-04-05 14:33:29 -04:00
Eric S. Raymond
0799bc2f79 Address Gitlib issu #57: Resume can't open save file...
...when auto-completed filename is followed by a space character.
2022-04-04 17:51:06 -04:00
Eric S. Raymond
989bdad3ee Add a warning to avoid CI breakage. 2019-02-28 22:42:59 -05:00
Eric S. Raymond
b2b4377f71 Bump the save format number, just in case. 2019-02-28 06:04:57 -05:00
Eric S. Raymond
81af59974b The FORTRAN-derived longs were semantically ints. Make it so.
Note. because we used fixed-length declrations in the right places, this
shouldn't break saves.

(Besides being right, this will someday make a port to Go a touch easier,
if we decide to do that.)
2019-02-28 05:58:16 -05:00
Eric S. Raymond
3ca9613bcd More coverage tweaks. 2018-11-15 13:33:16 -05:00
Eric S. Raymond
5ce427b62b Another coverage tweak. 2018-11-15 12:40:04 -05:00
Eric S. Raymond
79875c8088 Tweak code-coverage exclusions. 2018-11-15 12:18:27 -05:00
Eric S. Raymond
876fbb2f78 Prepare for sync with the issue #37 bugfix branch. 2018-11-14 11:52:55 -05:00
Eric S. Raymond
87452af448 Sync patch. 2018-11-14 11:43:38 -05:00
Eric S. Raymond
782c5c3f29 SPDXify the code. 2018-03-08 20:56:21 -05:00
NHOrus
5ff7592a51 Unlike objects, player doesn't go to -1 when destroyed.
Tighten bounds check.
2017-09-13 19:34:35 +03:00
NHOrus
076bb8908b If divident negative, then remainder is negative too.
RNG values need to be always positive.
Solution: Transposing positively by divisor. In all the two places it may happen.
2017-09-11 21:27:57 +03:00
NHOrus
9e2cb3c191 Put some of important parameters into fixed width signed integers
Massaged test files. Fixes issue #41
2017-09-11 00:58:13 +03:00
NHOrus
43f0cb232b Silenced fallthrough warning 2017-09-05 18:32:56 +03:00
NHOrus
96ead306b5 Prevent RNG overflow.
Pass save under validation by pointer, so we could mess with underlying
values a little. Only thing I feel we can safely and sanely modify.
2017-09-05 18:20:21 +03:00
NHOrus
0dd40bba32 Removed old copy-paste error
Put numdie bounds check in croak to prevent OOB access on negative
numdie while preserving tests
2017-09-05 17:46:38 +03:00
NHOrus
e5a0c6e2b7 Prevent tampering with PRNG parameters in save 2017-08-24 14:48:02 +03:00
NHOrus
917af2e744 Fixed copy-paste errors 2017-08-24 14:41:21 +03:00
NHOrus
17d94c46cd Prevent division by zero 2017-08-24 14:25:29 +03:00
NHOrus
25424a01db Verify bounds for linked lists 2017-08-24 13:47:57 +03:00
NHOrus
5e39abf730 Corrected limit for atloc, see init.c for filling double-linked list 2017-08-24 13:40:10 +03:00
NHOrus
aeaa0400cb Fix value, add check for linked locations 2017-08-24 13:02:51 +03:00
NHOrus
98b21323a6 Bounds check for properties; it is not violated in normal game 2017-08-24 11:21:10 +03:00
NHOrus
f496bff945 Syntax error 2017-08-13 15:58:35 +01:00
NHOrus
ad9c53abdb Validate dwarves and tally 2017-08-13 15:56:37 +01:00
NHOrus
f0dc3d3b7c Verify sanity of location arrays 2017-08-13 15:16:09 +01:00
NHOrus
36f72f1902 Validating sanity of locations in restored game 2017-08-13 15:13:20 +01:00
Jason S. Ninneman
26bf324e07 Use the '=' operator (not memcpy()) to shallow-copy structs. 2017-08-03 12:41:35 -07:00
NHOrus
63152e6714 Broke all logical or into multiline statement to show lcov's lies
Results are weird, some things that need to be checked aren't and
at least my local lcov doesn't show them as unchecked
2017-07-03 07:20:37 +03:00
Jason S. Ninneman
73278b1a3c Bump save file version number.
Also add missing space in the version mesage.
2017-07-02 09:55:53 -07:00
Jason S. Ninneman
d23111daba Replace datime() with just time().
Also make the 'savetime' value meaningful.

This removes a separate library dependency on some systems.
2017-07-02 09:46:01 -07:00
Aaron Traas
85f8334e17 centralize calls to make_zzword()
make_zzword() now called in set_seed(), because the only times it was
called in the entire application is after every invocation of set_seed().
2017-07-02 02:02:09 -04:00
Jason S. Ninneman
ad3b097c9e Replace linenoise with libedit in code and build. 2017-07-01 07:22:53 -07:00
Eric S. Raymond
58b44313d3 Without IGNORE, -Wunused-result throws a warning on fread(2).
I've seen it happen on fwrite(2) as well; wrapping that as well in
case some compiler decides to be finicky.
2017-07-01 08:35:05 -04:00
Jason S. Ninneman
8bc08773fa Various cleanups.
* Remove disused macro.
* GCC doesn't seem to mind if IGNORE() is left off.
* Enumify phase codes.
* Use EXIT_* macros in all exit() calls.
* How did this even work without extern?
* Give advent.h a much-needed makeover.
* Use the chomp indicator in YAML string blocks to avoid code ugliness.
2017-07-01 03:19:33 +00:00
NHOrus
0f15c9e0f3 Breaking one-line conditionals 2017-06-29 22:51:30 +03:00
NHOrus
bf2fa227f0 Unshadowed k2 into k3 in main.c
Reindented everything
2017-06-29 20:11:53 +03:00
Jason S. Ninneman
1ee0e5c7b0 Finish newdb -> dungeon renaming. 2017-06-29 08:54:55 -07:00
Jason S. Ninneman
83fb64b5a8 Jettison MAKEWD(), GETTXT(), vocab(), GETIN(), and the old db compiler. 2017-06-29 08:54:35 -07:00
Jason S. Ninneman
50435465a6 Completely wire vocab words in YAML to the code.
This massive patch:
* Finishes working all the vocab words into YAML structures.
* Adds vocab ID generator functions.
* Redoes the input-getting system, removing the need for GETIN(),
  GETTXT(), etc.
* Changes advent<->ascii mapping to avoid the special 'shift'
  character.
* Works around some bad behavior in the dragon attack logic.
* Handles the reservoir magic word without changing the database
  contents.
2017-06-29 01:59:37 -07:00
Aaron Traas
0a30176a8c Allow cheat to generate save files with bogus numbers.
Also remove pre-built save file for resumefail.log
2017-06-27 16:13:49 -04:00
Eric S. Raymond
d6cb6f0d8d Create a cheater to test strange save/resume cases.
Patch due to Aaron Traas, but needed modification because of code
drift since submission.
2017-06-26 15:07:09 -04:00
Eric S. Raymond
59243cf8bc Take FORTRANish upper-case function names to C-style lowercase...
...except for a few we're planning to get rid of.  This will avoid some
upcoming collisions with macros defined from YAML.
2017-06-26 10:19:33 -04:00