Replace magic MINTRS/MAXTRS with a treasure attribute in YAML.
[open-adventure.git] / init.c
diff --git a/init.c b/init.c
index 03c93f12a2a0c68eb5f2ca05a6eecfe8287b6f2b..b19e422fd5a9dc7dd5033ba985ec8048d32b957f 100644 (file)
--- a/init.c
+++ b/init.c
  *     12600 words of message text (LINES, LINSIZ).
  *     885 travel options (TRAVEL, TRVSIZ).
  *     330 vocabulary words (KTAB, ATAB, TABSIZ).
- *     185 locations (LTEXT, STEXT, KEY, COND, game.abbrev, game.atloc,
- *                   LOCSND, LOCSIZ).
- *     100 objects (PLAC, game.place, FIXD, game.fixed, game.link (twice),
- *                   PTEXT, game.prop, OBJSND, OBJTXT).
  *      35 "action" verbs (ACTSPK, VRBSIZ).
- *     277 random messages (RTEXT, RTXSIZ).
- *      12 different player classifications (CTEXT, CVAL, CLSMAX).
- *      20 hints (game.hintlc, game.hinted, HINTS, HNTSIZ).
- *        5 "# of turns" threshholds (TTEXT, TRNVAL, TRNSIZ).
  *  There are also limits which cannot be exceeded due to the structure of
  *  the database.  (E.G., The vocabulary uses n/1000 to determine word type,
  *  so there can't be more than 1000 words.)  These upper limits are:
  *     1000 non-synonymous vocabulary words
  *     300 locations
  *     100 objects
- *  Note:
- *   - the object count limit has been abstracted as NOBJECTS
- *   - the random message limit has been abstracted as RTXSIZ
- *   - maximum locations limit has been abstracted as LOCSIZ
  */
 
 /*  Description of the database format
  *     bit; see section 9), the number of turns he must be at the right loc(s)
  *     before triggering the hint, the points deducted for taking the hint,
  *     the message number (section 6) of the question, and the message number
- *     of the hint.  These values are stashed in the "hints" array.  HNTMAX is
- *     set to the max hint number (<= HNTSIZ).
+ *     of the hint.  These values are stashed in the "hints" array.
  *  Section 12: Unused in this version.
  *  Section 13: Sounds and text.  Each line contains either 2 or 3 numbers.  If
  *     2 (call them N and S), N is a location and message ABS(S) from section
@@ -180,7 +167,7 @@ void initialise(void)
         game.link[i + NOBJECTS] = game.link[i] = 0;
     }
 
-    for (int i = 1; i <= LOCSIZ; i++) {
+    for (int i = 1; i <= NLOCATIONS; i++) {
         game.abbrev[i] = 0;
         if (!(locations[i].description.big == 0 || KEY[i] == 0)) {
             int k = KEY[i];
@@ -212,21 +199,22 @@ void initialise(void)
             DROP(k, PLAC[k]);
     }
 
-    /*  Treasures, as noted earlier, are objects MINTRS through MAXTRS
-     *  Their props are initially -1, and are set to 0 the first time
+    /*  Treasure props are initially -1, and are set to 0 the first time
      *  they are described.  game.tally keeps track of how many are
      *  not yet found, so we know when to close the cave. */
     game.tally = 0;
-    for (int treasure = MINTRS; treasure <= MAXTRS; treasure++) {
-        if (object_descriptions[treasure].inventory != 0)
-            game.prop[treasure] = -1;
-        game.tally = game.tally - game.prop[treasure];
+    for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
+       if (object_descriptions[treasure].is_treasure) {
+           if (object_descriptions[treasure].inventory != 0)
+               game.prop[treasure] = -1;
+           game.tally = game.tally - game.prop[treasure];
+       }
     }
 
     /*  Clear the hint stuff.  game.hintlc[i] is how long he's been at LOC
      *  with cond bit i.  game.hinted[i] is true iff hint i has been
      *  used. */
-    for (int i = 0; i < HINT_COUNT; i++) {
+    for (int i = 0; i < NHINTS; i++) {
         game.hinted[i] = false;
         game.hintlc[i] = 0;
     }
@@ -273,7 +261,7 @@ void initialise(void)
     VOLCANO = VOCWRD(WORD_VOLCANO, 1);
     WATER = VOCWRD(WORD_WATER, 1);
 
-    /* Objects from MINTRS through MAXTRS are treasures.  Here are a few. */
+    /* Vocabulary for treasures */
     AMBER = VOCWRD(WORD_AMBER, 1);
     CHAIN = VOCWRD(WORD_CHAIN, 1);
     CHEST = VOCWRD(WORD_CHEST, 1);
@@ -350,11 +338,10 @@ void initialise(void)
      * game.iwest      How many times he's said "west" instead of "w"
      * game.knfloc     0 if no knife here, loc if knife here, -1 after caveat
      * game.limit      Lifetime of lamp (not set here)
-     * maximum_deaths          Number of reincarnation messages available (up to 5)
      * game.numdie     Number of times killed so far
      * game.trnluz     # points lost so far due to number of turns used
      * game.turns      Tallies how many commands he's given (ignores yes/no)
-     * Logicals were explained earlier */
+     */
     game.turns = 0;
     game.trnluz = 0;
     game.lmwarn = false;