Clean up remnant magic labels.
[open-adventure.git] / misc.c
diff --git a/misc.c b/misc.c
index 71f1214230304c1bda962c2bf109b216a38bd808..7a86b9f2a1682d104d64819d9e62dd899b51b953 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -27,7 +27,7 @@ void packed_to_token(long packed, char token[6])
   for (int i = 0; i < 5; ++i)
     {
       char advent = (packed >> i * 6) & 63;
-      token[4 - i] = advent_to_ascii[advent];
+      token[4 - i] = advent_to_ascii[(int) advent];
     }
 
   // Ensure the last character is \0.
@@ -196,7 +196,7 @@ bool GETIN(FILE *input,
            (junk > 0);
        if (GETTXT(true,true,true) <= 0)
            return true;
-       RSPEAK(53);
+       RSPEAK(ARB_53);
     }
 }
 
@@ -217,7 +217,7 @@ long YES(FILE *input, vocab_t x, vocab_t y, vocab_t z)
            RSPEAK(z);
            return false;
        }
-       RSPEAK(185);
+       RSPEAK(ARB_185);
     }
 }
 
@@ -367,7 +367,7 @@ void MOVE(long object, long where)
        from=game.fixed[object-NOBJECTS];
     else
        from=game.place[object];
-    if (from > 0 && from <= 300)
+    if (from > 0 && !SPECIAL(from))
        CARRY(object,from);
     DROP(object,where);
 }
@@ -460,21 +460,21 @@ bool TSTBIT(long mask, int bit)
 void set_seed(long seedval)
 /* Set the LCG seed */
 {
-    lcgstate.x = (unsigned long) seedval % lcgstate.m;
+    game.lcg_x = (unsigned long) seedval % game.lcg_m;
 }
 
 unsigned long get_next_lcg_value(void)
 /* Return the LCG's current value, and then iterate it. */
 {
-    unsigned long old_x = lcgstate.x;
-    lcgstate.x = (lcgstate.a * lcgstate.x + lcgstate.c) % lcgstate.m;
+    unsigned long old_x = game.lcg_x;
+    game.lcg_x = (game.lcg_a * game.lcg_x + game.lcg_c) % game.lcg_m;
     return old_x;
 }
 
 long randrange(long range)
 /* Return a random integer from [0, range). */
 {
-    return range * get_next_lcg_value() / lcgstate.m;
+    return range * get_next_lcg_value() / game.lcg_m;
 }
 
 long RNDVOC(long second, long force)
@@ -541,7 +541,6 @@ void BUG(long num)
 
 bool MAPLIN(FILE *fp)
 {
-    long i, val;
     bool eof;
 
     /* Read a line of input, from the specified input source.
@@ -561,9 +560,9 @@ bool MAPLIN(FILE *fp)
      * in which you want to echo commands.  One is when shipping them to 
      * a log under the -l option, in which case you want to suppress
      * prompt generation (so test logs are unadorned command sequences).
-     * On the other hand, if you redireceted stdin and are feeding the program 
+     * On the other hand, if you redirected stdin and are feeding the program 
      * a logfile, you *do* want prompt generation - it makes checkfiles
-     * easier to read when the commands are maked by a preceding prompt.
+     * easier to read when the commands are marked by a preceding prompt.
      */
     do {
        if (!editline) {
@@ -577,7 +576,7 @@ bool MAPLIN(FILE *fp)
            if (!eof) {
                strncpy(rawbuf, cp, sizeof(rawbuf)-1);
                linenoiseHistoryAdd(rawbuf);
-               strncat(rawbuf, "\n", sizeof(rawbuf)-1);
+               strncat(rawbuf, "\n", sizeof(rawbuf) - strlen(rawbuf) - 1);
                linenoiseFree(cp);
            }
        }
@@ -624,8 +623,8 @@ bool MAPLIN(FILE *fp)
      *  and is not changed thereafter unless the routines on this page choose
      *  to do so. */
        LNLENG=0;
-       for (i=1; i<=(long)sizeof(INLINE) && INLINE[i]!=0; i++) {
-           val=INLINE[i];
+       for (long i=1; i<=(long)sizeof(INLINE) && INLINE[i]!=0; i++) {
+           long val=INLINE[i];
            INLINE[i]=ascii_to_advent[val];
            if (INLINE[i] != 0)
                LNLENG=i;
@@ -648,7 +647,7 @@ void TYPE(void)
     }
 
     for (i=1; i<=LNLENG; i++) {
-       INLINE[i]=advent_to_ascii[INLINE[i]];
+      INLINE[i]=advent_to_ascii[(int) INLINE[i]];
     }
     INLINE[LNLENG+1]=0;
     printf("%s\n", INLINE+1);