Do not base endgame bonus on arbitrary messages
authorNHOrus <jy6x2b32pie9@yahoo.com>
Fri, 14 Jul 2017 12:40:59 +0000 (15:40 +0300)
committerNHOrus <jy6x2b32pie9@yahoo.com>
Fri, 14 Jul 2017 13:38:25 +0000 (16:38 +0300)
This may break save files, but doesn't, due to padding

actions.c
advent.h
score.c

index 40a1928f62d99299970e9a07fef2775cd59196f1..cb034d16605a98205aec8ce92c9b781a3bb62833 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -236,13 +236,16 @@ static void blast(void)
         !game.closed)
         rspeak(REQUIRES_DYNAMITE);
     else {
-        if (HERE(ROD2))
-            game.bonus = SPLATTER_MESSAGE;
-        else if (game.loc == LOC_NE)
-            game.bonus = DEFEAT_MESSAGE;
-        else
-            game.bonus = VICTORY_MESSAGE;
-        rspeak(game.bonus);
+        if (HERE(ROD2)) {
+            game.bonus = splatter;
+            rspeak(SPLATTER_MESSAGE);
+        } else if (game.loc == LOC_NE) {
+            game.bonus = defeat;
+            rspeak(DEFEAT_MESSAGE);
+        } else {
+            game.bonus = victory;
+            rspeak(VICTORY_MESSAGE);
+        }
         terminate(endgame);
     }
 }
index 6efe5efbddea9ec0fd498717717e93ebe1d7f5c2..7eb54dc744d3e694edf5055b252b0a55e843047a 100644 (file)
--- a/advent.h
+++ b/advent.h
@@ -89,6 +89,8 @@ enum speechpart {unknown, intransitive, transitive};
 
 enum wordtype {NO_WORD_TYPE, MOTION, OBJECT, ACTION, SPECIAL};
 
+typedef enum scorebonus {none, splatter, defeat, victory} score_t;
+
 /* Phase codes for action returns.
  * These were at one time FORTRAN line numbers.
  * The values don't matter, but perturb their order at your peril.
@@ -118,7 +120,7 @@ typedef long loc_t;    // index into the locations array */
 struct game_t {
     unsigned long lcg_a, lcg_c, lcg_m, lcg_x;
     long abbnum;                 // How often to print non-abbreviated descriptions
-    long bonus;
+    score_t bonus;                  // What kind of bonus we are getting for finishing the game
     long chloc;
     long chloc2;
     long clock1;                 // # turns from finding last treasure till closing
diff --git a/score.c b/score.c
index c31ee6a88dc2ec7bcc0d0c856869b0f4d585c5cf..8bd3cce1793af69a20c7b186a99ba58f7c27de1b 100644 (file)
--- a/score.c
+++ b/score.c
@@ -71,13 +71,13 @@ long score(enum termination mode)
         score += 25;
     mxscor += 25;
     if (game.closed) {
-        if (game.bonus == 0)
+        if (game.bonus == none)
             score += 10;
-        if (game.bonus == SPLATTER_MESSAGE)
+        if (game.bonus == splatter)
             score += 25;
-        if (game.bonus == DEFEAT_MESSAGE)
+        if (game.bonus == defeat)
             score += 30;
-        if (game.bonus == VICTORY_MESSAGE)
+        if (game.bonus == victory)
             score += 45;
     }
     mxscor += 45;