From: Eric S. Raymond Date: Sun, 12 Mar 2023 10:39:57 +0000 (-0400) Subject: Add message and bailout on invalid save. X-Git-Tag: 1.15~63 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=04df0ce64c3d7413daaa19e19f476430768cccac;p=open-adventure.git Add message and bailout on invalid save. Note: save/resume still fails at saveresume.4 at this revision. --- diff --git a/adventure.yaml b/adventure.yaml index 76e6b1c..b246498 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -3189,13 +3189,13 @@ arbitrary_messages: !!omap save file format, and this program uses Version %d.%d. You must find an instance using that other version in order to resume that Adventure. # This message is not currently used -#- SAVE_TAMPERING: |- -# 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. +- SAVE_TAMPERING: |- + 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. - TWIST_TURN: |- Sorry, but the path twisted and turned so much that I can't figure out which way to go to get back. diff --git a/saveresume.c b/saveresume.c index 05e12b7..c9278a4 100644 --- a/saveresume.c +++ b/saveresume.c @@ -137,7 +137,10 @@ int restore(FILE* fp) fclose(fp); if (save.version != VRSION) { rspeak(VERSION_SKEW, save.version / 10, MOD(save.version, 10), VRSION / 10, MOD(VRSION, 10)); - } else if (is_valid(save.game)) { + } else if (!is_valid(save.game)) { + rspeak(SAVE_TAMPERING); + exit(EXIT_SUCCESS); + } else { game = save.game; } return GO_TOP; diff --git a/tests/saveresume.4.chk b/tests/saveresume.4.chk index 1643c43..1280b2b 100644 --- a/tests/saveresume.4.chk +++ b/tests/saveresume.4.chk @@ -10,15 +10,9 @@ down a gully. > resume Can't open file y, try again. -You're in front of building. - -> blast - -Blasting requires dynamite. - - -You scored 32 out of a possible 430, using 2 turns. - -You are obviously a rank amateur. Better luck next time. - -To achieve the next higher rating, you need 14 more points. +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.