Don't execute pre-write checks from sct_postread()

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.
This commit is contained in:
Markus Armbruster 2008-09-06 08:03:08 -04:00
parent f84d25378b
commit 85eb288f97

View file

@ -48,14 +48,11 @@
#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