From 311ad32a8869c4c2bb2a9f7460ded9226bd85804 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 19 Sep 2004 07:16:44 +0000 Subject: [PATCH] (shoo): Code to enfore the mobility limit assumed double m were 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 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lib/commands/shoo.c b/src/lib/commands/shoo.c index 780d35ca0..076cd5c4c 100644 --- a/src/lib/commands/shoo.c +++ b/src/lib/commands/shoo.c @@ -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) -- 2.43.0