]> git.pond.sub.org Git - empserver/commitdiff
(shoo): Code to enfore the mobility limit assumed double m were
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 19 Sep 2004 07:16:44 +0000 (07:16 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 19 Sep 2004 07:16:44 +0000 (07:16 +0000)
integer.  When 5 * sect.sct_mobil - 4 < nshot < 5 * sect.sct_mobil,
nshot was rounded up to the next multiple of 5.  This could shoot more
people than present, resulting in negative population.  Before
rev. 1.3, putvar() swept this error under the rug.

src/lib/commands/shoo.c

index 780d35ca0a18a65366f38455942e2da2ae649445..076cd5c4c5e575ceb8355288de9a0034e9f3ab46 100644 (file)
@@ -93,12 +93,9 @@ shoo(void)
        if (sect.sct_item[item] == 0 || sect.sct_item[I_CIVIL] > mil * 10)
            continue;
        nshot = sect.sct_item[item] > targets ? targets : sect.sct_item[item];
-       m = ((double)nshot + 4.0) / 5.0;
-
-       if (m > sect.sct_mobil) {
+       if (nshot > sect.sct_mobil * 5)
            nshot = sect.sct_mobil * 5;
-           m = sect.sct_mobil;
-       }
+       m = nshot / 5.0;
        /*
         * Each security unit lowers the cost of
         * shooting a person by 10%. However, you
@@ -106,7 +103,7 @@ shoo(void)
         */
        if (nsec > 5)
            nsec = 5;
-       m = ((float)m * (1.0 - ((float)nsec * 0.1)));
+       m *= 1.0 - nsec * 0.1;
        if (nshot <= 0)
            continue;
        if (m < 0)