From a97ac7a40150d9bb839dbc343bad58cfbc5b4b68 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 24 Jun 2016 19:18:21 +0200 Subject: [PATCH] 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 --- src/lib/update/finish.c | 8 +++----- src/lib/update/human.c | 3 ++- src/lib/update/land.c | 4 ---- src/lib/update/main.c | 8 +------- src/lib/update/mobility.c | 2 +- src/lib/update/prepare.c | 7 +++---- src/lib/update/sect.c | 2 +- 7 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/lib/update/finish.c b/src/lib/update/finish.c index 76d9bebb..6cba5501 100644 --- a/src/lib/update/finish.c +++ b/src/lib/update/finish.c @@ -67,9 +67,7 @@ finish_sects(int etu) logerror("delivering...\n"); /* Do deliveries */ for (n = 0; NULL != (sp = getsectid(n)); n++) { - if (sp->sct_type == SCT_WATER) - continue; - if (sp->sct_own == 0) + if (!sp->sct_own || sp->sct_type == SCT_SANCT) continue; if (nat_budget[sp->sct_own].money < 0) continue; @@ -89,7 +87,7 @@ finish_sects(int etu) logerror("exporting..."); for (n = 0; NULL != (sp = getsectid(n)); n++) { - if (!sp->sct_own) + if (!sp->sct_own || sp->sct_type == SCT_SANCT) continue; if (nat_budget[sp->sct_own].money < 0) continue; @@ -100,7 +98,7 @@ finish_sects(int etu) logerror("importing..."); for (n = 0; NULL != (sp = getsectid(n)); n++) { sp->sct_off = 0; - if (!sp->sct_own) + if (!sp->sct_own || sp->sct_type == SCT_SANCT) continue; if (nat_budget[sp->sct_own].money < 0) continue; diff --git a/src/lib/update/human.c b/src/lib/update/human.c index f5469e01..308df1b2 100644 --- a/src/lib/update/human.c +++ b/src/lib/update/human.c @@ -73,7 +73,8 @@ do_feed(struct sctstr *sp, struct natstr *np, int etu, sp->sct_item[I_MILIT], sp->sct_item[I_UW], maxworkers)); - if (sp->sct_type != SCT_SANCT) { + + if (sp->sct_type != SCT_WATER && sp->sct_type != SCT_SANCT) { manna = 0; if (opt_NOFOOD == 0) { needed = (int)ceil(food_needed(sp->sct_item, etu)); diff --git a/src/lib/update/land.c b/src/lib/update/land.c index 6be2c142..860330bc 100644 --- a/src/lib/update/land.c +++ b/src/lib/update/land.c @@ -85,7 +85,6 @@ prod_land(int etus, int natnum, struct bp *bp, int build) /* build = 1, maintain = 0 */ { struct lndstr *lp; - struct sctstr *sp; int i; for (i = 0; (lp = getlandp(i)); i++) { @@ -93,9 +92,6 @@ prod_land(int etus, int natnum, struct bp *bp, int build) continue; if (lp->lnd_own != natnum) continue; - sp = getsectp(lp->lnd_x, lp->lnd_y); - if (sp->sct_type == SCT_SANCT) - continue; upd_land(lp, etus, bp, build); } } diff --git a/src/lib/update/main.c b/src/lib/update/main.c index 7ece6dab..1c50d1a8 100644 --- a/src/lib/update/main.c +++ b/src/lib/update/main.c @@ -103,19 +103,13 @@ update_main(void) logerror("producing for countries..."); for (i = 0; i < MAXNOC; i++) { - if (!(np = getnatp(i))) - continue; - if (np->nat_stat == STAT_SANCT) { - continue; - } - /* maintain units */ prod_ship(etu, i, NULL, 0); prod_plane(etu, i, NULL, 0); prod_land(etu, i, NULL, 0); /* produce all sects */ - produce_sect(np, etu, NULL); + produce_sect(getnatp(i), etu, NULL); /* build units */ prod_ship(etu, i, NULL, 1); diff --git a/src/lib/update/mobility.c b/src/lib/update/mobility.c index e77fe4b4..6dc9ea07 100644 --- a/src/lib/update/mobility.c +++ b/src/lib/update/mobility.c @@ -92,7 +92,7 @@ mob_inc_sect(struct sctstr *sp, int etus) if (sp->sct_own == 0) return; - if (sp->sct_type == SCT_SANCT) + if (sp->sct_type == SCT_WATER || sp->sct_type == SCT_SANCT) return; value = sp->sct_mobil + ((float)etus * sect_mob_scale); diff --git a/src/lib/update/prepare.c b/src/lib/update/prepare.c index e7c6603e..23fe66ad 100644 --- a/src/lib/update/prepare.c +++ b/src/lib/update/prepare.c @@ -58,7 +58,7 @@ prepare_sects(int etu) sp->sct_updated = sp->sct_fallout != 0; /* Next, we process the fallout there */ 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); /* Next, we spread the fallout */ for (n = 0; NULL != (sp = getsectid(n)); n++) @@ -70,12 +70,11 @@ prepare_sects(int etu) decay_fallout(sp, etu); } } + for (n = 0; NULL != (sp = getsectid(n)); n++) { sp->sct_updated = 0; - if (sp->sct_type == SCT_WATER) - continue; - if (getnatp(sp->sct_own)->nat_stat == STAT_SANCT) + if (sp->sct_type == SCT_WATER || sp->sct_type == SCT_SANCT) continue; /* diff --git a/src/lib/update/sect.c b/src/lib/update/sect.c index 26a14e56..0fed6ca5 100644 --- a/src/lib/update/sect.c +++ b/src/lib/update/sect.c @@ -233,7 +233,7 @@ produce_sect(struct natstr *np, int etu, struct bp *bp) double cost; 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; if (sp->sct_own != np->nat_cnum) continue;