centralize calls to make_zzword()
authorAaron Traas <aaron@traas.org>
Sun, 2 Jul 2017 06:02:09 +0000 (02:02 -0400)
committerAaron Traas <aaron@traas.org>
Sun, 2 Jul 2017 06:02:09 +0000 (02:02 -0400)
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().

init.c
main.c
misc.c
saveresume.c

diff --git a/init.c b/init.c
index 0f81fe15cb52e79fdc2692a9e8d9d005f19c9af9..812e943e6dc69589758c19739a388f7903aa0fd1 100644 (file)
--- a/init.c
+++ b/init.c
@@ -92,8 +92,5 @@ long initialise(void)
     }
     game.conds = setbit(11);
 
     }
     game.conds = setbit(11);
 
-    /*  Start-up, dwarf stuff */
-    make_zzword(game.zzword);
-
     return seedval;
 }
     return seedval;
 }
diff --git a/main.c b/main.c
index 9d466b41f5176ff042ade81676bcdd90c0462e97..1cff0d1648db7fb827b29fb6f3859ada02bcf16e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -141,8 +141,6 @@ static bool fallback_handler(char *buf)
         printf("Seed set to %ld\n", sv);
         // autogenerated, so don't charge user time for it.
         --game.turns;
         printf("Seed set to %ld\n", sv);
         // autogenerated, so don't charge user time for it.
         --game.turns;
-        // here we reconfigure any global game state that uses random numbers
-        make_zzword(game.zzword);
         return true;
     }
     return false;
         return true;
     }
     return false;
diff --git a/misc.c b/misc.c
index ac22ae039dde7a15f739a6d9c67ff9be60eee518..b71969e2918dcd32f7f695753b33bdb2d889d921 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -633,8 +633,8 @@ long atdwrf(long where)
     return (at);
 }
 
     return (at);
 }
 
-/*  Utility routines (SETBIT, TSTBIT, set_seed, get_next_lcg_value,
- *  randrange, RNDVOC) */
+/*  Utility routines (setbit, tstbit, set_seed, get_next_lcg_value,
+ *  randrange) */
 
 long setbit(long bit)
 /*  Returns 2**bit for use in constructing bit-masks. */
 
 long setbit(long bit)
 /*  Returns 2**bit for use in constructing bit-masks. */
@@ -652,6 +652,9 @@ void set_seed(long seedval)
 /* Set the LCG seed */
 {
     game.lcg_x = (unsigned long) seedval % game.lcg_m;
 /* Set the LCG seed */
 {
     game.lcg_x = (unsigned long) seedval % game.lcg_m;
+    
+    // once seed is set, we need to generate the Z`ZZZ word
+    make_zzword(game.zzword);
 }
 
 unsigned long get_next_lcg_value(void)
 }
 
 unsigned long get_next_lcg_value(void)
index c275986f4e85bf0d2358d17581391c449fcd110b..49e0021b91c55f4434935774ca29d12884357f8e 100644 (file)
@@ -122,8 +122,6 @@ 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));
         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);
-        make_zzword(game.zzword);
     }
     return GO_TOP;
 }
     }
     return GO_TOP;
 }