games: Fix real bugs on three games (found by gcc 5.0)
authorJohn Marino <draco@marino.st>
Wed, 11 Feb 2015 08:03:31 +0000 (09:03 +0100)
committerJohn Marino <draco@marino.st>
Wed, 11 Feb 2015 08:03:31 +0000 (09:03 +0100)
I had NO_GAMES set so I missed these bugs yesterday.  Adventure, Fortune,
and Mille all had bugs in them  (the latter had two).

Now gcc-5.0 can build the entire world and kernel.
I still need to verify that a gcc-5.0 built world and kernel is bootable
and works though.

games/adventure/init.c
games/fortune/fortune/fortune.c
games/mille/move.c

index 122b90d..beb3631 100644 (file)
@@ -81,7 +81,7 @@ linkdata(void)
        int i, j;
 
        /* array linkages */
-       for (i = 1; i <= LOCSIZ; i++)
+       for (i = 1; i < LOCSIZ; i++)
                if (ltext[i].seekadr != 0 && travel[i] != 0)
                        if ((travel[i]->tverb) == 1)
                                cond[i] = 2;
index 175ab53..9606aa0 100644 (file)
@@ -97,7 +97,7 @@ bool All_forts        = false;        /* any fortune allowed */
 bool Equal_probs= false;       /* scatter un-allocted prob equally */
 bool Match     = false;        /* dump fortunes matching a pattern */
 #ifdef DEBUG
-bool Debug = false;            /* print debug messages */
+int Debug = 0;                 /* print debug messages */
 #endif
 
 char *Fortbuf = NULL;          /* fortune buffer for -m */
index 7581cc0..8a0da41 100644 (file)
@@ -140,7 +140,7 @@ acc:
                for (i = 1; i < HAND_SZ; i++)
                        if (pp->hand[i] == C_INIT) {
                                for (j = 0; pp->hand[j] == C_INIT; j++)
-                                       if (j >= HAND_SZ) {
+                                       if (j == HAND_SZ - 1) {
                                                j = 0;
                                                break;
                                        }
@@ -193,6 +193,7 @@ playcard(PLAY *pp)
 {
        int     v;
        CARD    card;
+       bool    blockNext;
 
        /*
         * check and see if player has picked
@@ -212,7 +213,7 @@ mustpick:
        if (Debug)
                fprintf(outf, "PLAYCARD: Card = %s\n", C_name[card]);
 #endif
-       Next = FALSE;
+       blockNext = FALSE;
        switch (card) {
          case C_200:
                if (pp->nummiles[C_200] == 2)
@@ -322,18 +323,18 @@ protected:
                        if (!pp->can_go && isrepair(pp->battle))
                                pp->can_go = TRUE;
                }
-               Next = -1;
+               blockNext = TRUE;
                break;
 
          case C_INIT:
                error("no card there");
-               Next = -1;
+               blockNext = TRUE;
                break;
        }
        if (pp == &Player[PLAYER])
                account(card);
        pp->hand[Card_no] = C_INIT;
-       Next = (Next == -1 ? FALSE : TRUE);
+       Next = !blockNext;
        return TRUE;
 }