update: Treat sanctuaries more consistently

Land unit maintenance and building ignore land units in sanctuary
sectors.  Leftovers from undocumented compile-time option START_UNITS,
which is gone since commit dab1f0b, v4.3.0.  Feeding, paying military
and fallout don't ignore them.  Change maintenance and building to
match.

Sector preparation (except for the fallout part) and production ignore
even non-sanctuary sectors owned by nations in sanctuary.  Fallout,
delivery, distribution and mobility growth don't check the sector
owner's status.  Change preparation and production to ignore just
sanctuary sectors, without checking the sector owner's status.  Except
don't bother for most of fallout, as we already avoid spreading
fallout into sanctuaries; still ignore sanctuaries when doing fallout
damage mostly for completeness.

Delivery and distribution ignore unowned sectors.  Ignore sanctuaries,
too.

Feeding and mobility growth ignore sanctuaries.  Ignore sea, too.

None of this should matter in sane game states.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-06-24 19:18:21 +02:00
parent e15e7f6bf8
commit a97ac7a401
7 changed files with 11 additions and 23 deletions

View file

@ -67,9 +67,7 @@ finish_sects(int etu)
logerror("delivering...\n"); logerror("delivering...\n");
/* Do deliveries */ /* Do deliveries */
for (n = 0; NULL != (sp = getsectid(n)); n++) { for (n = 0; NULL != (sp = getsectid(n)); n++) {
if (sp->sct_type == SCT_WATER) if (!sp->sct_own || sp->sct_type == SCT_SANCT)
continue;
if (sp->sct_own == 0)
continue; continue;
if (nat_budget[sp->sct_own].money < 0) if (nat_budget[sp->sct_own].money < 0)
continue; continue;
@ -89,7 +87,7 @@ finish_sects(int etu)
logerror("exporting..."); logerror("exporting...");
for (n = 0; NULL != (sp = getsectid(n)); n++) { for (n = 0; NULL != (sp = getsectid(n)); n++) {
if (!sp->sct_own) if (!sp->sct_own || sp->sct_type == SCT_SANCT)
continue; continue;
if (nat_budget[sp->sct_own].money < 0) if (nat_budget[sp->sct_own].money < 0)
continue; continue;
@ -100,7 +98,7 @@ finish_sects(int etu)
logerror("importing..."); logerror("importing...");
for (n = 0; NULL != (sp = getsectid(n)); n++) { for (n = 0; NULL != (sp = getsectid(n)); n++) {
sp->sct_off = 0; sp->sct_off = 0;
if (!sp->sct_own) if (!sp->sct_own || sp->sct_type == SCT_SANCT)
continue; continue;
if (nat_budget[sp->sct_own].money < 0) if (nat_budget[sp->sct_own].money < 0)
continue; continue;

View file

@ -73,7 +73,8 @@ do_feed(struct sctstr *sp, struct natstr *np, int etu,
sp->sct_item[I_MILIT], sp->sct_item[I_MILIT],
sp->sct_item[I_UW], sp->sct_item[I_UW],
maxworkers)); maxworkers));
if (sp->sct_type != SCT_SANCT) {
if (sp->sct_type != SCT_WATER && sp->sct_type != SCT_SANCT) {
manna = 0; manna = 0;
if (opt_NOFOOD == 0) { if (opt_NOFOOD == 0) {
needed = (int)ceil(food_needed(sp->sct_item, etu)); needed = (int)ceil(food_needed(sp->sct_item, etu));

View file

@ -85,7 +85,6 @@ prod_land(int etus, int natnum, struct bp *bp, int build)
/* build = 1, maintain = 0 */ /* build = 1, maintain = 0 */
{ {
struct lndstr *lp; struct lndstr *lp;
struct sctstr *sp;
int i; int i;
for (i = 0; (lp = getlandp(i)); i++) { for (i = 0; (lp = getlandp(i)); i++) {
@ -93,9 +92,6 @@ prod_land(int etus, int natnum, struct bp *bp, int build)
continue; continue;
if (lp->lnd_own != natnum) if (lp->lnd_own != natnum)
continue; continue;
sp = getsectp(lp->lnd_x, lp->lnd_y);
if (sp->sct_type == SCT_SANCT)
continue;
upd_land(lp, etus, bp, build); upd_land(lp, etus, bp, build);
} }
} }

View file

@ -103,19 +103,13 @@ update_main(void)
logerror("producing for countries..."); logerror("producing for countries...");
for (i = 0; i < MAXNOC; i++) { for (i = 0; i < MAXNOC; i++) {
if (!(np = getnatp(i)))
continue;
if (np->nat_stat == STAT_SANCT) {
continue;
}
/* maintain units */ /* maintain units */
prod_ship(etu, i, NULL, 0); prod_ship(etu, i, NULL, 0);
prod_plane(etu, i, NULL, 0); prod_plane(etu, i, NULL, 0);
prod_land(etu, i, NULL, 0); prod_land(etu, i, NULL, 0);
/* produce all sects */ /* produce all sects */
produce_sect(np, etu, NULL); produce_sect(getnatp(i), etu, NULL);
/* build units */ /* build units */
prod_ship(etu, i, NULL, 1); prod_ship(etu, i, NULL, 1);

View file

@ -92,7 +92,7 @@ mob_inc_sect(struct sctstr *sp, int etus)
if (sp->sct_own == 0) if (sp->sct_own == 0)
return; return;
if (sp->sct_type == SCT_SANCT) if (sp->sct_type == SCT_WATER || sp->sct_type == SCT_SANCT)
return; return;
value = sp->sct_mobil + ((float)etus * sect_mob_scale); value = sp->sct_mobil + ((float)etus * sect_mob_scale);

View file

@ -58,7 +58,7 @@ prepare_sects(int etu)
sp->sct_updated = sp->sct_fallout != 0; sp->sct_updated = sp->sct_fallout != 0;
/* Next, we process the fallout there */ /* Next, we process the fallout there */
for (n = 0; NULL != (sp = getsectid(n)); n++) for (n = 0; NULL != (sp = getsectid(n)); n++)
if (sp->sct_updated) if (sp->sct_updated && sp->sct_type != SCT_SANCT)
do_fallout(sp, etu); do_fallout(sp, etu);
/* Next, we spread the fallout */ /* Next, we spread the fallout */
for (n = 0; NULL != (sp = getsectid(n)); n++) for (n = 0; NULL != (sp = getsectid(n)); n++)
@ -70,12 +70,11 @@ prepare_sects(int etu)
decay_fallout(sp, etu); decay_fallout(sp, etu);
} }
} }
for (n = 0; NULL != (sp = getsectid(n)); n++) { for (n = 0; NULL != (sp = getsectid(n)); n++) {
sp->sct_updated = 0; sp->sct_updated = 0;
if (sp->sct_type == SCT_WATER) if (sp->sct_type == SCT_WATER || sp->sct_type == SCT_SANCT)
continue;
if (getnatp(sp->sct_own)->nat_stat == STAT_SANCT)
continue; continue;
/* /*

View file

@ -233,7 +233,7 @@ produce_sect(struct natstr *np, int etu, struct bp *bp)
double cost; double cost;
for (n = 0; NULL != (sp = getsectid(n)); n++) { for (n = 0; NULL != (sp = getsectid(n)); n++) {
if (sp->sct_type == SCT_WATER) if (sp->sct_type == SCT_WATER || sp->sct_type == SCT_SANCT)
continue; continue;
if (sp->sct_own != np->nat_cnum) if (sp->sct_own != np->nat_cnum)
continue; continue;