Relax the savefile validity check a little.

There was a very old bug, probably predating the OpenAdventure port,
that would poke a stashed value of -1 into the snake object if you did
a save in endgame, and then fail the savefile validation on resume.
This was masked for a long time by a bug in put() just fixed a couple
of revisions ago.
This commit is contained in:
Eric S. Raymond 2023-03-12 10:03:43 -04:00
parent 04df0ce64c
commit 0ffb297801
3 changed files with 20 additions and 9 deletions

View file

@ -32,7 +32,7 @@
#define WRITE_MODE "wb" // b is not needed for POSIX but harmless
/* Special object-state values - integers > 0 are object-specific */
#define STATE_NOTFOUND -1 // 'Not found" state of treasures */
#define STATE_NOTFOUND -1 // 'Not found" state of treasures
#define STATE_FOUND 0 // After discovered, before messed with
#define STATE_IN_CAVITY 1 // State value common to all gemstones
@ -42,7 +42,7 @@
/* Map a state property value to a negative range, where the object cannot be
* picked up but the value can be recovered later. Avoid colliding with -1,
* which has its own meaning. */
* which has its own meaning as STATE_NOTFOUND. */
#define STASHED(obj) (-1 - game.prop[obj])
#define PROMPT "> "

View file

@ -219,7 +219,8 @@ bool is_valid(struct game_t valgame)
/* Check that properties of objects aren't beyond expected */
for (obj_t obj = 0; obj <= NOBJECTS; obj++) {
if (valgame.prop[obj] < STATE_NOTFOUND || valgame.prop[obj] > 1) {
/* Magic number -2 allows a STASHED version of state 1 */
if (valgame.prop[obj] < -2 || valgame.prop[obj] > 1) {
switch (obj) {
case RUG:
case DRAGON:

View file

@ -10,9 +10,19 @@ down a gully.
> resume
Can't open file y, try again.
A dark fog creeps in to surround you. From somewhere in the fog you
hear a stern voice. "This Adventure has been tampered with! You have
been dabbling in magic, knowing not the havoc you might cause thereby.
Leave at once, before you do irrevocable harm!" The fog thickens,
until at last you can see nothing at all. Your vision then clears,
and you find yourself back in The Real World.
You're at sw end.
The grate is locked.
> blast
There is a loud explosion, and a twenty-foot hole appears in the far
wall, burying the dwarves in the rubble. You march through the hole
and find yourself in the main office, where a cheering band of
friendly elves carry the conquering adventurer off into the sunset.
You scored 423 out of a possible 430, using 468 turns.
Your score puts you in Master Adventurer Class A.
To achieve the next higher rating, you need 4 more points.