]> git.pond.sub.org Git - empserver/commit
sect: Fix revert to deity and "no civilians" corner cases
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 4 Jun 2016 15:14:25 +0000 (17:14 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 17:59:57 +0000 (19:59 +0200)
commit5e54219606569a10da388c30577e9c7362bb204e
treef91fe13488b28f3eedeeb7e0b0755b4d9e19995f
parent0bdcb5ee19fa2946cdb7dbe4d41855aaef559385
sect: Fix revert to deity and "no civilians" corner cases

We maintain a few sector invariants in sct_prewrite().  Since the
update bypasses sct_prewrite(), it needs to maintain them itself.  The
two should be consistent.

When a deserted sector reverts to the deity, sct_prewrite() clears
owner and mobility.  It neglects to clear the old owner, unlike
populace().  Harmless, but fix it anyway for consistency.  Visible in
tests/navi-march/final.xdump.

Work percentage, loyalty and old owner apply to civilians.  When there
are none, sct_prewrite() sets work percentage to 100 and old owner to
owner.  It neglects to clear loyalty, unlike populace().  Loyalty
persists until populace() clears it.  Most of the time, this doesn't
matter, as moving civilians into a sector without civilians ignores
the sector's loyalty.  However, airlifted and unloaded civilians adopt
the sector's loyalty (bug#49 and bug#255).

Fix sct_prewrite() to clear loyalty for consistency, and to mitigate
these bugs.

Note that populace() may not always clear loyalty right away.  This
will be fixed in the next commit.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/subs/sect.c
tests/navi-march/final.xdump