]> git.pond.sub.org Git - empserver/commitdiff
(take_casualties): Code for distributing casualties among units did
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 8 Oct 2006 09:32:49 +0000 (09:32 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 8 Oct 2006 09:32:49 +0000 (09:32 +0000)
not make sense, and in its confusion destroyed land land units when it
shouldn't.  Minimally invasive fix; code is still ugly and
incomprehensible.

src/lib/update/revolt.c

index 68cc9007ff82d4921b5570fb91d16fe9775bef6b..5148ad3196b3ffbf27e67b642c4368b393be1cfb 100644 (file)
@@ -465,15 +465,14 @@ take_casualties(struct sctstr *sp, int mc)
        if (!(lchr[(int)lp->lnd_type].l_flags & L_SECURITY))
            continue;
 
-       cantake = ((lp->lnd_effic - 40) / 100.0)
-           * lp->lnd_item[I_MILIT] * 2.0;
+       cantake = ((lp->lnd_effic - 40) / 100.0) * lp->lnd_item[I_MILIT];
 
        if (cantake >= each) {
-           deq = (each / (lp->lnd_item[I_MILIT] * 2.0)) * 100.0;
-           mc -= each;
+           deq = ((double)each / lp->lnd_item[I_MILIT]) * 100.0;
+           mc -= 2 * each;
        } else if (cantake > 0) {
-           deq = (cantake / (lp->lnd_item[I_MILIT] * 2.0)) * 100.0;
-           mc -= (deq / 100.0) * lp->lnd_item[I_MILIT] * 2.0;
+           deq = ((double)cantake / lp->lnd_item[I_MILIT]) * 100.0;
+           mc -= 2 * cantake;
        } else
            deq = 0;
 
@@ -494,11 +493,11 @@ take_casualties(struct sctstr *sp, int mc)
        cantake = ((lp->lnd_effic - 40) / 100.0) * lp->lnd_item[I_MILIT];
 
        if (cantake >= each) {
-           deq = ((double)each / (lp->lnd_item[I_MILIT] * 2.0)) * 100.0;
+           deq = ((double)each / lp->lnd_item[I_MILIT]) * 100.0;
            mc -= each;
        } else if (cantake > 0) {
            deq = ((double)cantake / lp->lnd_item[I_MILIT]) * 100.0;
-           mc -= (deq / 100.0) * lp->lnd_item[I_MILIT];
+           mc -= cantake;
        } else
            deq = 0;