X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=blobdiff_plain;f=saveresume.c;h=4ce219af323e7e7ebff1cea80fbfa43f524b0b07;hp=3546378a5ae6d4e7e6ae44db7fb18b7e91beeb46;hb=d0a868bd4ac2bf4d3258f4fcdac328cef077eff5;hpb=d6cb6f0d8d258f4125fd3a0cc3899541ea2efd5b diff --git a/saveresume.c b/saveresume.c index 3546378..4ce219a 100644 --- a/saveresume.c +++ b/saveresume.c @@ -2,8 +2,7 @@ #include #include "advent.h" -#include "database.h" -#include "newdb.h" +#include "dungeon.h" #include "linenoise/linenoise.h" /* @@ -27,18 +26,20 @@ struct save_t { }; struct save_t save; -int savefile(FILE *fp) - /* Save game to file. No input or output from user. */ +int savefile(FILE *fp, long version) +/* Save game to file. No input or output from user. */ { long i, k; datime(&i, &k); k = i + 650 * k; save.savetime = k; save.mode = -1; - save.version = VRSION; + + save.version = (version == 0) ? VRSION : version; + memcpy(&save.game, &game, sizeof(struct game_t)); IGNORE(fwrite(&save, sizeof(struct save_t), 1, fp)); - return(0); + return (0); } /* Suspend and resume */ @@ -55,7 +56,8 @@ int suspend(void) FILE *fp = NULL; rspeak(SUSPEND_WARNING); - if (!yes(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) return GO_CLEAROBJ; + if (!yes(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) + return GO_CLEAROBJ; game.saved = game.saved + 5; while (fp == NULL) { @@ -68,8 +70,7 @@ int suspend(void) linenoiseFree(name); } - savefile(fp); - IGNORE(fwrite(&save, sizeof(struct save_t), 1, fp)); + savefile(fp, VRSION); fclose(fp); rspeak(RESUME_HELP); exit(0); @@ -87,7 +88,8 @@ int resume(void) if (game.loc != 1 || game.abbrev[1] != 1) { rspeak(RESUME_ABANDON); - if (!yes(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) return GO_CLEAROBJ; + if (!yes(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) + return GO_CLEAROBJ; } while (fp == NULL) { @@ -118,7 +120,8 @@ int restore(FILE* fp) rspeak(VERSION_SKEW, save.version / 10, MOD(save.version, 10), VRSION / 10, MOD(VRSION, 10)); } else { memcpy(&game, &save.game, sizeof(struct game_t)); - game.zzword = rndvoc(3, game.zzword); + //game.zzword = rndvoc(3, game.zzword); + make_zzword(game.zzword); } return GO_TOP; }