]> git.pond.sub.org Git - empserver/commitdiff
ef_verify: Cover sector coordinates in game state verification
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 27 Jan 2013 09:27:36 +0000 (10:27 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 6 Jun 2013 17:55:01 +0000 (19:55 +0200)
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/common/ef_verify.c

index 1443e52471e002e5ab05fa3c0eeeda42038e716b..5c9bbf070dbf375163c6a9285990b54f40e9ca74 100644 (file)
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Ron Koenderink, 2005
- *     Markus Armbruster, 2006-2011
+ *     Markus Armbruster, 2006-2013
  */
 
 #include <config.h>
@@ -209,6 +209,27 @@ verify_table(int type)
     return retval;
 }
 
+static int
+verify_sectors(int may_put)
+{
+    int i;
+    struct sctstr *sp;
+    coord x, y;
+
+    /* laziness: assumes sector file is EFF_MEM */
+    for (i = 0; (sp = getsectid(i)); i++) {
+       sctoff2xy(&x, &y, sp->sct_uid);
+       if (sp->sct_x != x || sp->sct_y != y) {
+           sp->sct_x = x;
+           sp->sct_y = y;
+           if (may_put)
+               putsect(sp);
+           verify_fail(EF_SECTOR, i, NULL, 0, "bogus coordinates (fixed)");
+       }
+    }
+    return 0;
+}
+
 static int
 verify_planes(int may_put)
 {
@@ -351,6 +372,7 @@ ef_verify_state(int may_put)
     }
 
     /* Special checks */
+    retval |= verify_sectors(may_put);
     retval |= verify_planes(may_put);
     retval |= verify_lands(may_put);
     retval |= verify_nukes(may_put);