Simplify SPDX copyright lines to the shortest canonical form...
[open-adventure.git] / saveresume.c
index 4cac0343a2a41f7c7a59a573ba61caa44414cf30..34404c69f548b591f2e8abddf967b3ca5c5e9faf 100644 (file)
@@ -4,8 +4,7 @@
  * (ESR) This replaces  a bunch of particularly nasty FORTRAN-derived code;
  * see the history.adoc file in the source distribution for discussion.
  *
- * SPDX-FileCopyrightText: 1977, 2005 by Will Crowther and Don Woods
- * SPDX-FileCopyrightText: 2017 by Eric S. Raymond
+ * SPDX-FileCopyrightText: (C) 1977, 2005 by Will Crowther and Don Woods
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
@@ -16,7 +15,6 @@
 #include <inttypes.h>
 
 #include "advent.h"
-#include "dungeon.h"
 
 /*
  * Use this to detect endianness mismatch.  Can't be unchanged by byte-swapping.
@@ -137,7 +135,7 @@ int restore(FILE* fp)
      *  sane initial state.
      *  If ADVENT_NOSAVE is defined, gripe instead. */
 #ifdef ADVENT_NOSAVE
-    rspeak(SAVERESUME_DISABLED)
+    rspeak(SAVERESUME_DISABLED);
     return GO_TOP;
 #endif
 
@@ -218,7 +216,7 @@ bool is_valid(struct game_t valgame)
     int temp_tally = 0;
     for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
         if (objects[treasure].is_treasure) {
-            if (valgame.objects[treasure].prop == STATE_NOTFOUND) {
+            if (PROP_IS_NOTFOUND2(valgame, treasure)) {
                 ++temp_tally;
             }
         }
@@ -229,30 +227,8 @@ bool is_valid(struct game_t valgame)
 
     /* Check that properties of objects aren't beyond expected */
     for (obj_t obj = 0; obj <= NOBJECTS; obj++) {
-       /* Magic number -2 allows a STASHED version of state 1 */
-        if (valgame.objects[obj].prop < -2 || valgame.objects[obj].prop > 1) {
-            switch (obj) {
-            case RUG:
-            case DRAGON:
-            case BIRD:
-            case BOTTLE:
-            case PLANT:
-            case PLANT2:
-            case TROLL:
-            case URN:
-            case EGGS:
-            case VASE:
-            case CHAIN:
-                if (valgame.objects[obj].prop == 2) // There are multiple different states, but it's convenient to clump them together
-                    continue;  // LCOV_EXCL_LINE
-            /* FALLTHRU */
-            case BEAR:
-                if (valgame.objects[BEAR].prop == CONTENTED_BEAR || valgame.objects[BEAR].prop == BEAR_DEAD)
-                    continue;
-            /* FALLTHRU */
-            default:
-                return false;  // LCOV_EXCL_LINE
-            }
+        if (PROP_IS_INVALID(valgame.objects[obj].prop)) {
+           return false;       // LCOV_EXCL_LINE
         }
     }