(take_casualties): Remove superflous casts and parenthesis. Cast to

double rather than float where result usual arithmetic conversions
obviously convert the cast's result to double.  No functional changes;
code is still ugly and incomprehensible.
This commit is contained in:
Markus Armbruster 2006-05-20 16:24:15 +00:00
parent 092a52f2c6
commit 3a38e91a5c

View file

@ -477,26 +477,20 @@ take_casualties(struct sctstr *sp, int mc)
if (!(lchr[(int)lp->lnd_type].l_flags & L_SECURITY)) if (!(lchr[(int)lp->lnd_type].l_flags & L_SECURITY))
continue; continue;
cantake = (((float)(lp->lnd_effic - 40) / 100.0) * cantake = ((lp->lnd_effic - 40) / 100.0) * lnd_getmil(lp) * 2.0;
(float)lnd_getmil(lp)) * 2;
/* (float)lchr[lp->lnd_type].l_mil)*2; */
if (cantake >= each) { if (cantake >= each) {
/* deq = (((float)each/(float)(lchr[lp->lnd_type].l_mil*2)) */ deq = ((double)each / (lnd_getmil(lp) * 2.0)) * 100.0;
deq = (((float)each / (float)(lnd_getmil(lp) * 2))
* 100.0);
mc -= each; mc -= each;
} else if (cantake > 0) { } else if (cantake > 0) {
deq = (((float)cantake / (float)(lnd_getmil(lp) * 2)) * 100.0); deq = ((double)cantake / (lnd_getmil(lp) * 2.0)) * 100.0;
/* (float)(lchr[lp->lnd_type].l_mil*2)) * 100.0); */ mc -= (deq / 100.0) * lnd_getmil(lp) * 2.0;
mc -= (((float)deq / 100.0) * (float)lnd_getmil(lp)) * 2;
/* (float)lchr[lp->lnd_type].l_mil)*2; */
} else } else
deq = 0; deq = 0;
lp->lnd_effic -= deq; lp->lnd_effic -= deq;
lp->lnd_mobil -= deq / 2; lp->lnd_mobil -= deq / 2;
deq = (double)lchr[(int)lp->lnd_type].l_mil * (deq / 100.0); deq = lchr[(int)lp->lnd_type].l_mil * (deq / 100.0);
lnd_submil(lp, deq); lnd_submil(lp, deq);
if (mc <= 0) if (mc <= 0)
return; return;
@ -508,22 +502,20 @@ take_casualties(struct sctstr *sp, int mc)
if (lchr[(int)lp->lnd_type].l_flags & L_SECURITY) if (lchr[(int)lp->lnd_type].l_flags & L_SECURITY)
continue; continue;
cantake = (((float)(lp->lnd_effic - 40) / 100.0) * cantake = ((lp->lnd_effic - 40) / 100.0) * lnd_getmil(lp);
(float)lnd_getmil(lp));
if (cantake >= each) { if (cantake >= each) {
deq = (((float)each / (float)(lnd_getmil(lp) * 2)) deq = ((double)each / (lnd_getmil(lp) * 2.0)) * 100.0;
* 100.0);
mc -= each; mc -= each;
} else if (cantake > 0) { } else if (cantake > 0) {
deq = (((float)cantake / (float)lnd_getmil(lp)) deq = ((double)cantake / lnd_getmil(lp)) * 100.0;
* 100.0); mc -= (deq / 100.0) * lnd_getmil(lp);
mc -= (((float)deq / 100.0) * (float)lnd_getmil(lp));
} else } else
deq = 0; deq = 0;
lp->lnd_effic -= deq; lp->lnd_effic -= deq;
lp->lnd_mobil -= deq / 2; lp->lnd_mobil -= deq / 2;
deq = (double)lchr[(int)lp->lnd_type].l_mil * (deq / 100.0); deq = lchr[(int)lp->lnd_type].l_mil * (deq / 100.0);
lnd_submil(lp, deq); lnd_submil(lp, deq);
if (mc <= 0) if (mc <= 0)
return; return;
@ -536,7 +528,7 @@ take_casualties(struct sctstr *sp, int mc)
if (lchr[(int)lp->lnd_type].l_flags & L_SECURITY) if (lchr[(int)lp->lnd_type].l_flags & L_SECURITY)
continue; continue;
mc -= (((float)lp->lnd_effic / 100.0) * (float)lnd_getmil(lp)); mc -= (lp->lnd_effic / 100.0) * lnd_getmil(lp);
lp->lnd_effic = 0; lp->lnd_effic = 0;
lnd_submil(lp, 1000); /* Remove 'em all */ lnd_submil(lp, 1000); /* Remove 'em all */
wu(0, lp->lnd_own, "%s dies fighting guerrillas in %s\n", wu(0, lp->lnd_own, "%s dies fighting guerrillas in %s\n",
@ -554,7 +546,7 @@ take_casualties(struct sctstr *sp, int mc)
if (!(lchr[(int)lp->lnd_type].l_flags & L_SECURITY)) if (!(lchr[(int)lp->lnd_type].l_flags & L_SECURITY))
continue; continue;
mc -= (((float)lp->lnd_effic / 100.0) * (float)lnd_getmil(lp)) * 2; mc -= (lp->lnd_effic / 100.0) * lnd_getmil(lp) * 2.0;
lp->lnd_effic = 0; lp->lnd_effic = 0;
lnd_submil(lp, 1000); /* Kill 'em all */ lnd_submil(lp, 1000); /* Kill 'em all */
wu(0, lp->lnd_own, "%s dies fighting guerrillas in %s\n", wu(0, lp->lnd_own, "%s dies fighting guerrillas in %s\n",