sect: Catch clobbered sector coordinates in sct_prewrite()
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 27 Jan 2013 09:31:49 +0000 (10:31 +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/subs/sect.c

index ba6655fd82d8b1f0de1980da9c1fc95415f151c5..b300b05d1eb3598644d170b488e9ddbfbb54737d 100644 (file)
@@ -29,7 +29,7 @@
  *  Known contributors to this file:
  *     Dave Pare, 1989
  *     Steve McClure, 1996
- *     Markus Armbruster, 2004-2010
+ *     Markus Armbruster, 2004-2013
  */
 
 #include <config.h>
@@ -60,9 +60,16 @@ sct_prewrite(int id, void *old, void *new)
 {
     struct sctstr *oldsp = old;
     struct sctstr *sp = new;
+    coord x, y;
     int mil, civs;
     natid own, prev_own;
 
+    sctoff2xy(&x, &y, sp->sct_uid);
+    if (CANT_HAPPEN(sp->sct_x != x || sp->sct_y != y)) {
+       sp->sct_x = x;
+       sp->sct_y = y;
+    }
+
     bridge_damaged(sp);
     item_prewrite(sp->sct_item);