Replace magic MINTRS/MAXTRS with a treasure attribute in YAML.
[open-adventure.git] / main.c
diff --git a/main.c b/main.c
index 6fa2ddcbc7c954f53fd111b5ce4bfbd386208586..069c8651c808ea312a150a4b9246713226a7a52a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -289,7 +289,9 @@ static bool spotted_by_pirate(int i)
         return true;
     int snarfed = 0;
     bool movechest = false, robplayer = false;
-    for (int treasure = MINTRS; treasure <= MAXTRS; treasure++) {
+    for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
+       if (!object_descriptions[treasure].is_treasure)
+           continue;
         /*  Pirate won't take pyramid from plover room or dark
          *  room (too easy!). */
         if (treasure == PYRAMID && (game.loc == PLAC[PYRAMID] || game.loc == PLAC[EMERALD])) {
@@ -323,7 +325,9 @@ static bool spotted_by_pirate(int i)
     }
     if (robplayer) {
         rspeak(PIRATE_POUNCES);
-        for (int treasure = MINTRS; treasure <= MAXTRS; treasure++) {
+       for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
+           if (!object_descriptions[treasure].is_treasure)
+               continue;
             if (!(treasure == PYRAMID && (game.loc == PLAC[PYRAMID] || game.loc == PLAC[EMERALD]))) {
                 if (AT(treasure) && game.fixed[treasure] == 0)
                     CARRY(treasure, game.loc);