]> git.pond.sub.org Git - empserver/commitdiff
update: Treat sanctuaries more consistently
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 24 Jun 2016 17:18:21 +0000 (19:18 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:08:30 +0000 (20:08 +0200)
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>
src/lib/update/finish.c
src/lib/update/human.c
src/lib/update/land.c
src/lib/update/main.c
src/lib/update/mobility.c
src/lib/update/prepare.c
src/lib/update/sect.c

index 76d9bebbad8cd6ad7cb7ac32ba059cc3992209dc..6cba55015b9cb6f92f57465b73df15242193c703 100644 (file)
@@ -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;
index f5469e01632f83d1faa51b6991ca3891617d3e7c..308df1b244de6912d40d18b222bce90d54d926e1 100644 (file)
@@ -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));
index 6be2c14264ab364bc90694e1ab91bbca4dc42338..860330bcb02324d4fcdd99c97401caa189beda6d 100644 (file)
@@ -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);
     }
 }
index 7ece6dab19f534dacf52efbd314179e7cd98189a..1c50d1a8554d6e22770086182ff0782f6313ac7c 100644 (file)
@@ -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);
index e77fe4b4a46eea2b20241c3dcb5c6e51516e0036..6dc9ea07c4606ca43fa7d4babd864dd33e3ff45f 100644 (file)
@@ -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);
index e7c6603e68f850cc2da55b2d70537f959acab5f4..23fe66ad37a71a7ba89b3c3d916fda9d9f2461f0 100644 (file)
@@ -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;
 
        /*
index 26a14e5623dda147cd23dfe7fd763bc1cefcd645..0fed6ca5222a2372eb873aa995c5f75c8b09ce49 100644 (file)
@@ -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;