Do not cast to float where usual arithmetic conversions obviously
convert the cast's result to double. Such casts are ugly and may lose precision.
This commit is contained in:
parent
802f69b039
commit
7a99405942
14 changed files with 35 additions and 35 deletions
|
@ -99,7 +99,7 @@ coll(void)
|
|||
xyas(x, y, player->cnum), cname(loan.l_lonee));
|
||||
return RET_FAIL;
|
||||
}
|
||||
pay = dchr[sect.sct_type].d_value * ((float)sect.sct_effic + 100.0);
|
||||
pay = dchr[sect.sct_type].d_value * (sect.sct_effic + 100.0);
|
||||
for (i = 0; ichr[i].i_name; i++) {
|
||||
if (ichr[i].i_value == 0 || ichr[i].i_uid == I_NONE)
|
||||
continue;
|
||||
|
|
|
@ -135,7 +135,7 @@ enli(void)
|
|||
natp->nat_reserve -= totalmil;
|
||||
putnat(natp);
|
||||
}
|
||||
if ((player->btused += roundavg((float)totalmil * 0.02)) > 0)
|
||||
if ((player->btused += roundavg(totalmil * 0.02)) > 0)
|
||||
pr("Paperwork at recruiting stations ... %d\n", player->btused);
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ fuel(void)
|
|||
|
||||
fueled = 1;
|
||||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
extra = move_amt / 5.0 - move_amt / 5;
|
||||
if (extra > 0.0)
|
||||
sect.sct_item[I_PETROL]
|
||||
= MAX((pet_amt - move_amt / 5) - 1, 0);
|
||||
|
@ -189,7 +189,7 @@ fuel(void)
|
|||
} else {
|
||||
sect.sct_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
extra = move_amt / 50.0 - move_amt / 50;
|
||||
sect.sct_item[I_OIL] = MAX(oil_amt - move_amt / 50, 0);
|
||||
if (extra > 0.0)
|
||||
sect.sct_item[I_OIL]
|
||||
|
@ -255,7 +255,7 @@ fuel(void)
|
|||
|
||||
fueled = 1;
|
||||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
extra = move_amt / 5.0 - move_amt / 5;
|
||||
if (extra > 0.0)
|
||||
item2.ship.shp_item[I_PETROL]
|
||||
= MAX((pet_amt - move_amt / 5) - 1, 0);
|
||||
|
@ -265,7 +265,7 @@ fuel(void)
|
|||
} else {
|
||||
item2.ship.shp_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
extra = move_amt / 50.0 - move_amt / 50;
|
||||
item2.ship.shp_item[I_OIL]
|
||||
= MAX(oil_amt - (move_amt / 50), 0);
|
||||
if (extra > 0.0)
|
||||
|
@ -340,7 +340,7 @@ fuel(void)
|
|||
|
||||
fueled = 1;
|
||||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
extra = move_amt / 5.0 - move_amt / 5;
|
||||
if (extra > 0.0)
|
||||
sect.sct_item[I_PETROL]
|
||||
= MAX((pet_amt - move_amt / 5) - 1, 0);
|
||||
|
@ -350,7 +350,7 @@ fuel(void)
|
|||
} else {
|
||||
sect.sct_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
extra = move_amt / 50.0 - move_amt / 50;
|
||||
sect.sct_item[I_OIL] = MAX(oil_amt - move_amt / 50, 0);
|
||||
if (extra > 0.0)
|
||||
sect.sct_item[I_OIL]
|
||||
|
@ -417,7 +417,7 @@ fuel(void)
|
|||
|
||||
fueled = 1;
|
||||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
extra = move_amt / 5.0 - move_amt / 5;
|
||||
if (extra > 0.0)
|
||||
item2.land.lnd_item[I_PETROL]
|
||||
= MAX((pet_amt - move_amt / 5) - 1, 0);
|
||||
|
@ -427,7 +427,7 @@ fuel(void)
|
|||
} else {
|
||||
item2.land.lnd_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
extra = move_amt / 50.0 - move_amt / 50;
|
||||
item2.land.lnd_item[I_OIL]
|
||||
= MAX(oil_amt - move_amt / 50, 0);
|
||||
if (extra > 0.0)
|
||||
|
|
|
@ -99,14 +99,14 @@ payo(void)
|
|||
if (dist < trade_1_dist)
|
||||
cash = 0;
|
||||
else if (dist < trade_2_dist)
|
||||
cash = (1.0 + trade_1 * ((float)dist));
|
||||
cash = 1.0 + trade_1 * dist;
|
||||
else if (dist < trade_3_dist)
|
||||
cash = (1.0 + trade_2 * ((float)dist));
|
||||
cash = 1.0 + trade_2 * dist;
|
||||
else
|
||||
cash = (1.0 + trade_3 * ((float)dist));
|
||||
cash = 1.0 + trade_3 * dist;
|
||||
|
||||
cash *= mp->m_cost;
|
||||
cash *= (((float)ship.shp_effic) / 100.0);
|
||||
cash *= ship.shp_effic / 100.0;
|
||||
|
||||
if (sect.sct_own && (sect.sct_own != ship.shp_own))
|
||||
cash *= (1.0 + trade_ally_bonus);
|
||||
|
|
|
@ -171,7 +171,7 @@ scra(void)
|
|||
continue;
|
||||
}
|
||||
if (type == EF_SHIP) {
|
||||
eff = ((float)item.ship.shp_effic / 100.0);
|
||||
eff = item.ship.shp_effic / 100.0;
|
||||
mp = &mchr[(int)item.ship.shp_type];
|
||||
if (opt_TRADESHIPS) {
|
||||
if (mp->m_flags & M_TRADE) {
|
||||
|
@ -249,7 +249,7 @@ scra(void)
|
|||
item.ship.shp_own = 0;
|
||||
putship(item.ship.shp_uid, &item.ship);
|
||||
} else if (type == EF_LAND) {
|
||||
eff = ((float)item.land.lnd_effic / 100.0);
|
||||
eff = item.land.lnd_effic / 100.0;
|
||||
lp = &lchr[(int)item.land.lnd_type];
|
||||
pr("%s", prland(&item.land));
|
||||
for (i = I_NONE + 1; i <= I_MAX; i++) {
|
||||
|
@ -317,7 +317,7 @@ scra(void)
|
|||
item.land.lnd_own = 0;
|
||||
putland(item.land.lnd_uid, &item.land);
|
||||
} else {
|
||||
eff = ((float)item.land.lnd_effic / 100.0);
|
||||
eff = item.land.lnd_effic / 100.0;
|
||||
pp = &plchr[(int)item.plane.pln_type];
|
||||
pr("%s", prplane(&item.plane));
|
||||
sect.sct_item[I_LCM] += pp->pl_lcm * 2 / 3 * eff;
|
||||
|
|
|
@ -204,13 +204,13 @@ scuttle_tradeship(struct shpstr *sp, int interactive)
|
|||
if (dist < trade_1_dist)
|
||||
cash = 0;
|
||||
else if (dist < trade_2_dist)
|
||||
cash = (1.0 + trade_1 * ((float)dist));
|
||||
cash = 1.0 + trade_1 * dist;
|
||||
else if (dist < trade_3_dist)
|
||||
cash = (1.0 + trade_2 * ((float)dist));
|
||||
cash = 1.0 + trade_2 * dist;
|
||||
else
|
||||
cash = (1.0 + trade_3 * ((float)dist));
|
||||
cash = 1.0 + trade_3 * dist;
|
||||
cash *= mp->m_cost;
|
||||
cash *= (((float)sp->shp_effic) / 100.0);
|
||||
cash *= sp->shp_effic / 100.0;
|
||||
|
||||
if (sect.sct_own != sp->shp_own) {
|
||||
ally_cash = cash * trade_ally_cut;
|
||||
|
|
|
@ -265,7 +265,7 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
|
|||
pln_identchance(pp, shp_hardtarget(targ), EF_SHIP))
|
||||
continue;
|
||||
pingrange = MAX(targ->shp_visib, 10) * range / 10;
|
||||
vrange = ((float)pingrange) * ((float)pp->pln_effic / 200.0);
|
||||
vrange = pingrange * (pp->pln_effic / 200.0);
|
||||
dist = mapdist(targ->shp_x, targ->shp_y, x, y);
|
||||
pingrange = (MAX(pingrange, 2) * targ->shp_effic);
|
||||
pingrange = roundavg(pingrange / 100.0);
|
||||
|
|
|
@ -625,8 +625,8 @@ ac_dog(struct plist *ap, struct plist *dp)
|
|||
att -= 2;
|
||||
if ((dp->pcp->pl_flags & P_F) && dp->bombs != 0)
|
||||
def -= 2;
|
||||
att += ((float)ap->pcp->pl_stealth / 25.0);
|
||||
def += ((float)dp->pcp->pl_stealth / 25.0);
|
||||
att += ap->pcp->pl_stealth / 25.0;
|
||||
def += dp->pcp->pl_stealth / 25.0;
|
||||
if (att < 1) {
|
||||
def += 1 - att;
|
||||
att = 1;
|
||||
|
@ -1073,7 +1073,7 @@ getilist(struct emp_qelem *list, natid own, struct emp_qelem *a,
|
|||
&& (pcp->pl_flags & P_V) == 0)
|
||||
continue;
|
||||
}
|
||||
if ((float)petrol < (float)pcp->pl_fuel / 2.0)
|
||||
if (petrol <= pcp->pl_fuel / 2)
|
||||
continue;
|
||||
/* Finally, is it in the list of planes already in
|
||||
flight? */
|
||||
|
@ -1160,13 +1160,13 @@ do_evade(struct emp_qelem *bomb_list, struct emp_qelem *esc_list)
|
|||
evade = 100.0;
|
||||
for (qp = bomb_list->q_forw; qp != bomb_list; qp = qp->q_forw) {
|
||||
plp = (struct plist *)qp;
|
||||
if (evade > ((float)plp->pcp->pl_stealth / 100.0))
|
||||
evade = (plp->pcp->pl_stealth / 100.0);
|
||||
if (evade > plp->pcp->pl_stealth / 100.0)
|
||||
evade = plp->pcp->pl_stealth / 100.0;
|
||||
}
|
||||
for (qp = esc_list->q_forw; qp != esc_list; qp = qp->q_forw) {
|
||||
plp = (struct plist *)qp;
|
||||
if (evade > plp->pcp->pl_stealth / 100.0)
|
||||
evade = (plp->pcp->pl_stealth / 100.0);
|
||||
evade = plp->pcp->pl_stealth / 100.0;
|
||||
}
|
||||
|
||||
if (chance(evade))
|
||||
|
|
|
@ -1493,7 +1493,7 @@ att_reacting_units(struct combat *def, struct emp_qelem *list, int a_spy,
|
|||
dtotal = 0;
|
||||
snxtitem_all(&ni, EF_LAND);
|
||||
while (nxtitem(&ni, &land) &&
|
||||
(dtotal + new_land * eff < (int)(1.2 * (float)ototal))) {
|
||||
(dtotal + new_land * eff < (int)(1.2 * ototal))) {
|
||||
if (!land.lnd_own)
|
||||
continue;
|
||||
if (!land.lnd_rad_max)
|
||||
|
|
|
@ -1383,7 +1383,7 @@ lnd_fortify (struct lndstr *lp, int hard_amt)
|
|||
eng = has_helpful_engineer(lp->lnd_x, lp->lnd_y, lp->lnd_own);
|
||||
|
||||
if (eng)
|
||||
hard_amt = ((float)hard_amt * 1.5);
|
||||
hard_amt *= 1.5;
|
||||
|
||||
if ((lp->lnd_harden + hard_amt) > land_mob_max)
|
||||
hard_amt = land_mob_max - lp->lnd_harden;
|
||||
|
@ -1394,7 +1394,7 @@ lnd_fortify (struct lndstr *lp, int hard_amt)
|
|||
/* Now, if an engineer helped, it's really only 2/3rds of
|
||||
that */
|
||||
if (eng)
|
||||
mob_used = (int)((float)mob_used / 1.5);
|
||||
mob_used /= 1.5;
|
||||
|
||||
/* If we increased it, but not much, we gotta take at least 1
|
||||
mob point. */
|
||||
|
|
|
@ -1146,7 +1146,7 @@ pln_hitchance(struct plnstr *pp, int hardtarget, int type)
|
|||
acc += 35;
|
||||
}
|
||||
hitchance = (int)(pp->pln_effic * (1.0 - 0.1 * tfact) *
|
||||
(1.0 - (float)acc / 100.0)) - hardtarget;
|
||||
(1.0 - acc / 100.0)) - hardtarget;
|
||||
|
||||
/* smooth out the bottom of the graph with asymtote at 5 -KHS */
|
||||
if (hitchance < 20)
|
||||
|
|
|
@ -276,7 +276,7 @@ landrepair(struct lndstr *land, struct natstr *np,
|
|||
if (left > delta)
|
||||
left = delta;
|
||||
|
||||
leftp = ((float)left / 100.0);
|
||||
leftp = left / 100.0;
|
||||
|
||||
memset(mvec, 0, sizeof(mvec));
|
||||
mvec[I_LCM] = lcm_needed = ldround(lp->l_lcm * leftp, 1);
|
||||
|
|
|
@ -191,7 +191,7 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
|
|||
if (left > delta)
|
||||
left = delta;
|
||||
|
||||
leftp = ((float)left / 100.0);
|
||||
leftp = left / 100.0;
|
||||
memset(mvec, 0, sizeof(mvec));
|
||||
mvec[I_MILIT] = mil_needed = ldround(plp->pl_crew * leftp, 1);
|
||||
mvec[I_LCM] = lcm_needed = ldround(plp->pl_lcm * leftp, 1);
|
||||
|
|
|
@ -345,7 +345,7 @@ shiprepair(struct shpstr *ship, struct natstr *np,
|
|||
if (left > delta)
|
||||
left = delta;
|
||||
|
||||
leftp = ((float)left / 100.0);
|
||||
leftp = left / 100.0;
|
||||
memset(mvec, 0, sizeof(mvec));
|
||||
mvec[I_LCM] = lcm_needed = ldround(mp->m_lcm * leftp, 1);
|
||||
mvec[I_HCM] = hcm_needed = ldround(mp->m_hcm * leftp, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue