]> git.pond.sub.org Git - empserver/commitdiff
Don't execute pre-write checks from sct_postread()
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 6 Sep 2008 12:03:08 +0000 (08:03 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 9 Sep 2008 01:25:12 +0000 (21:25 -0400)
Chainsaw 3 factored out most checks from sct_prewrite() into
checksect(), and called that from sct_postread() as well.  Revert
this, because it was a bad idea: whenever checksect() called from
ef_read() found something to change, it was actually a bug, and
changing it just hid the bug from whatever called ef_read().  But it
couldn't hide it from code going through ef_ptr().  So, instead of
having bugs visible everywhere, including census and such, they were
hidden in hard to observe places.  For instance, the previous commit
fixed one that was visible to the path finder, but not the actual path
user, which led to the path user choking on an incorrect path in a
rather obscure manner.

Things no longer "corrected" on read: excessive mobility, low work
despite no civilians present, sector owned despite neither civilians,
military nor land units.  The latter had a scary-looking caploss(),
but NF_SACKED should have rendered that harmless.

src/lib/subs/sect.c

index 1aef5baa5eae7785593f1db123f4c29ea0027e83..70f93d1856e2a0fa70d2ccd7178f19579e9f4e69 100644 (file)
 #include "sect.h"
 #include "xy.h"
 
-static int checksect(struct sctstr *);
-
 void
 sct_postread(int id, void *ptr)
 {
     struct sctstr *sp = ptr;
 
-    checksect(sp);
     player->owner = (player->god || sp->sct_own == player->cnum);
     if (opt_MOB_ACCESS)
        sct_do_upd_mob(sp);
@@ -65,30 +62,10 @@ void
 sct_prewrite(int id, void *ptr)
 {
     struct sctstr *sp = ptr;
-
-    bridge_damaged(sp);
-    checksect(sp);
-}
-
-void
-item_prewrite(short *item)
-{
-    i_type i;
-
-    for (i = I_NONE + 1; i <= I_MAX; ++i) {
-       if (CANT_HAPPEN(item[i] < 0))
-           item[i] = 0;
-       else if (CANT_HAPPEN(item[i] > ITEM_MAX))
-           item[i] = ITEM_MAX;
-    }
-}
-
-static int
-checksect(struct sctstr *sp)
-{
     int mil, civs;
     natid own;
 
+    bridge_damaged(sp);
     item_prewrite(sp->sct_item);
 
     /* shouldn't happen, but... */
@@ -114,7 +91,19 @@ checksect(struct sctstr *sp)
        if (sp->sct_type == SCT_CAPIT || sp->sct_type == SCT_MOUNT)
            caploss(sp, own, "");
     }
-    return 1;
+}
+
+void
+item_prewrite(short *item)
+{
+    i_type i;
+
+    for (i = I_NONE + 1; i <= I_MAX; ++i) {
+       if (CANT_HAPPEN(item[i] < 0))
+           item[i] = 0;
+       else if (CANT_HAPPEN(item[i] > ITEM_MAX))
+           item[i] = ITEM_MAX;
+    }
 }
 
 int