]> git.pond.sub.org Git - empserver/commitdiff
Do not cast to float where usual arithmetic conversions obviously
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 6 May 2006 08:26:31 +0000 (08:26 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 6 May 2006 08:26:31 +0000 (08:26 +0000)
convert the cast's result to double.  Such casts are ugly and may lose
precision.

14 files changed:
src/lib/commands/coll.c
src/lib/commands/enli.c
src/lib/commands/fuel.c
src/lib/commands/payo.c
src/lib/commands/scra.c
src/lib/commands/scut.c
src/lib/commands/sona.c
src/lib/subs/aircombat.c
src/lib/subs/attsub.c
src/lib/subs/lndsub.c
src/lib/subs/plnsub.c
src/lib/update/land.c
src/lib/update/plane.c
src/lib/update/ship.c

index 854eb7d78f6ab119424972ae1652959204f86a23..e6439d762a7ee37f56c74c14f550cbae53cbde9c 100644 (file)
@@ -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;
index ca3a73a4162c82251b774f14539f70a84264236b..2f38c6352de376cf0f71c49771812314de6af222 100644 (file)
@@ -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;
 }
index 1917e1dc1d7924900a4931a8b56754c612b5c308..43c22698aed454638da960786473af83ae24498c 100644 (file)
@@ -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)
index bf735bfa029d0422e81d584772dd4adcdf7bbeac..c8ee9225a3d0ae0618133ed2cad23520be099c9d 100644 (file)
@@ -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);
index 9cdba96d4224722fb5206d5fb6ded9600791b403..ca0aed71de39a302288c1dc54088c4b6eb6a6ce6 100644 (file)
@@ -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;
index f84d97034442e4fd7489271e497690f5d13184da..6e1bc780ef68f30401a4f63019d30dfe23b0aa83 100644 (file)
@@ -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;
index e4648b474c22d08942f768bb0b14b6ad12d86b9e..8691ad5b866b99795d1d0f46a5259cfdeae6156a 100644 (file)
@@ -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);
index e8235201c847aae582749891a1baebdc0b29c9b1..8b3f8e2e616debf91e1018c2fb129d9e5b02e149 100644 (file)
@@ -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))
index b2c0034033b51bc9a50c0ee755f1bc05cdb1c8a2..5432c4291b0f6c44b1820235416ee52414424994 100644 (file)
@@ -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)
index 60fa0dfd971ed3ceab51c6fbda2551d6284b86d5..c55943ce9d5be45eec8d9be0e175b4d343e692bc 100644 (file)
@@ -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. */
index d6a6cb248f3e0e54264aae7d24d36c29d02d4a26..c6423ac177951a1109af5af93d87339c7af1b303 100644 (file)
@@ -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)
index fe2b2ef97f571c28dc1eb9199e063fc54b264509..194e7462fe0f7b8914ac757a0ae2937eafd74026 100644 (file)
@@ -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);
index 8aa20f13732ff2ab80ad2fc953b2e3796ee1c27c..3b9360032d5db5ef7c39a2f2b86beb806bc5593a 100644 (file)
@@ -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);
index 80cb5aab95b5c9205a291dba6a3b45a0ba77bb55..7de8ed8acb5a7f95ab89c59f40fb811df0792928 100644 (file)
@@ -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);