Magic-number and state-arithmetic removal.
[open-adventure.git] / main.c
diff --git a/main.c b/main.c
index a6027f8136e06637db534a1a3df691a0e8384e3e..3c4d448ab56009f5f505b6aeb5510fe211e7ee5e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -19,7 +19,6 @@
 #include <stdbool.h>
 #include <getopt.h>
 #include <signal.h>
-#include <time.h>
 #include <string.h>
 #include "advent.h"
 #include "linenoise/linenoise.h"
@@ -138,17 +137,8 @@ int main(int argc, char *argv[])
 
     linenoiseHistorySetMaxLen(350);
 
-    /* Initialize our LCG PRNG with parameters tested against
-     * Knuth vol. 2. by the original authors */
-    game.lcg_a = 1093;
-    game.lcg_c = 221587;
-    game.lcg_m = 1048576;
-    srand(time(NULL));
-    long seedval = (long)rand();
-    set_seed(seedval);
-
     /*  Initialize game variables */
-    initialise();
+    long seedval = initialise();
 
     /*  Start-up, dwarf stuff */
     make_zzword(game.zzword);
@@ -1123,12 +1113,12 @@ L2607:
             wordclear(&command.wd2);
         } else {
             /* FIXME: Magic numbers related to vocabulary */
-            if (!((V1 != 1000 + WATER && V1 != 1000 + OIL) ||
-                  (V2 != 1000 + PLANT && V2 != 1000 + DOOR))) {
+           if (!((V1 != PROMOTE_WORD(WATER) && V1 != PROMOTE_WORD(OIL)) ||
+                 (V2 != PROMOTE_WORD(PLANT) && V2 != PROMOTE_WORD(DOOR)))) {
                 if (AT(V2 - 1000))
                     command.wd2 = token_to_packed("POUR");
             }
-            if (V1 == 1000 + CAGE && V2 == 1000 + BIRD && HERE(CAGE) && HERE(BIRD))
+           if (V1 == PROMOTE_WORD(CAGE) && V2 == PROMOTE_WORD(BIRD) && HERE(CAGE) && HERE(BIRD))
                 command.wd1 = token_to_packed("CATCH");
         }
 L2620: