]> git.pond.sub.org Git - empserver/commitdiff
Remove superflous casts and parenthesis.
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 21 May 2006 12:24:30 +0000 (12:24 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 21 May 2006 12:24:30 +0000 (12:24 +0000)
28 files changed:
src/client/serverio.c
src/lib/commands/buy.c
src/lib/commands/look.c
src/lib/commands/mfir.c
src/lib/commands/miss.c
src/lib/commands/rada.c
src/lib/commands/spy.c
src/lib/commands/torp.c
src/lib/common/move.c
src/lib/common/path.c
src/lib/gen/chance.c
src/lib/subs/landgun.c
src/lib/subs/lndsub.c
src/lib/subs/mission.c
src/lib/subs/move.c
src/lib/subs/plnsub.c
src/lib/subs/satmap.c
src/lib/subs/shpsub.c
src/lib/subs/supply.c
src/lib/update/human.c
src/lib/update/mobility.c
src/lib/update/nav_ship.c
src/lib/update/nav_util.c
src/lib/update/plague.c
src/lib/update/populace.c
src/lib/update/sect.c
src/lib/update/ship.c
src/server/shutdown.c

index 9741413b6525b58b922bb34ac55449414d27500e..93420c5baa1c9587b970ac0f91ff71dc8b0ec0ae 100644 (file)
@@ -76,7 +76,7 @@ serverio(int s, struct ioqueue *ioq)
        return 0;
     }
     if (n != ioq->bsize)
-       buf = (char *)realloc(buf, n);
+       buf = realloc(buf, n);
     ioq_write(ioq, buf, n);
     return 1;
 }
index d2962b6905f65e0a7cdba7162eccb96eb87d9d0a..2188239b8879900d47c00e86ade93ddc562d9fe6 100644 (file)
@@ -112,7 +112,7 @@ buy(void)
     bid = atof(p);
     if (bid <= 0)
        return RET_FAIL;
-    if (natp->nat_money < (bid * comm.com_amount * buytax)) {
+    if (natp->nat_money < bid * comm.com_amount * buytax) {
        pr("This purchase would cost %.2f, %.2f more than you have.\n",
           bid * comm.com_amount * buytax,
           bid * comm.com_amount * buytax - natp->nat_money);
@@ -131,12 +131,12 @@ buy(void)
     for (q = 0; getcomm(q, &comt); q++) {
        if (comt.com_maxbidder == player->cnum &&
            comt.com_owner != 0 && comt.com_owner != player->cnum) {
-           tally += (comt.com_price * comt.com_amount) * buytax;
+           tally += comt.com_price * comt.com_amount * buytax;
        }
     }
     canspend = natp->nat_money - tally;
     getcomm(o, &comm);
-    if ((bid * comm.com_amount * buytax) > canspend) {
+    if (bid * comm.com_amount * buytax > canspend) {
        pr("You have overextended yourself in the market\n");
        pr("You can not bid on the current items at that price.\n");
        return RET_OK;
@@ -165,7 +165,7 @@ buy(void)
           qty, ip->i_name, n);
        return RET_FAIL;
     }
-    if ((bid * comm.com_amount) > natp->nat_money) {
+    if (bid * comm.com_amount > natp->nat_money) {
        pr("You don't have that much to spend!\n");
        return RET_FAIL;
     }
index 137fb0c572ff6f6920eadb431649dfebc8055772..c0329de6cd5bfccc9c5ee3588024859042be80ce 100644 (file)
@@ -260,7 +260,7 @@ look_land(struct lndstr *lookland)
     int dist;
 
     drange = techfact(lookland->lnd_tech, lookland->lnd_spy);
-    drange = (drange * ((double)lookland->lnd_effic / 100.0));
+    drange *= lookland->lnd_effic / 100.0;
     range = ldround(drange, 1);
 
     if (range == 0)
index e645b79d40a2b9bea00314638cb845771eca44f0..fc362ef9034763a6a8792ecc21844377848cbf5b 100644 (file)
@@ -364,7 +364,7 @@ multifire(void)
            shots = gun;
            guneff = seagun(fship.shp_effic, shots);
            dam = (int)guneff;
-           shell -= ldround(((double)shots) / 2.0, 1);
+           shell -= ldround(shots / 2.0, 1);
            fship.shp_item[I_SHELL] = shell;
            if (opt_NOMOBCOST == 0)
                fship.shp_mobil = MAX(fship.shp_mobil - 15, -100);
@@ -414,8 +414,8 @@ multifire(void)
            dam = (int)landunitgun(fland.lnd_effic, fland.lnd_dam, gun,
                                   fland.lnd_ammo, shell);
            if (target == targ_ship) {
-               if (chance(((double)fland.lnd_acc) / 100.0))
-                   dam = ldround(((double)dam / 2.0), 1);
+               if (chance(fland.lnd_acc / 100.0))
+                   dam = ldround(dam / 2.0, 1);
            }
            use_supply(&fland);
            resupply_commod(&fland, I_SHELL);   /* Get more shells */
@@ -554,7 +554,7 @@ multifire(void)
            prb *= prb;
            if (chance(prb)) {
                pr("Wind deflects shell%s.\n", splur(shots));
-/*                     dam = (int)((double)dam / 2.0);*/
+/*                     dam = (int)(dam / 2.0);*/
                dam *= (90 - (random() % 11)) / 100.0;
                if (dam < 0)
                    dam = 0;
@@ -713,7 +713,7 @@ do_defdam(struct emp_qelem *list, double odds)
            pr("\nDefenders fire back!\n");
            first = 0;
        }
-       dam = (odds * (double)fp->defdam);
+       dam = odds * fp->defdam;
 
        if (fp->type == targ_ship) {
            vict = fp->victim;
index d0d3263c665755f313cc45e77815c7f5fcfbf753..8e896e4094c4c9f9a6c8d7b87d05753b48cdb521 100644 (file)
@@ -209,7 +209,7 @@ mission(void)
        return RET_FAIL;
     }
 
-    mobused = ldround((mission_mob_cost * (double)mobmax), 1);
+    mobused = ldround(mission_mob_cost * (double)mobmax, 1);
 
     while (nxtitem(&ni, &item)) {
        gp = (struct genitem *)&item;
index 3de1333f138fa1952301a42e8a4f4fe61fd63570..363246dd84d7f6eff9870dc5151ff2b24bbe5117 100644 (file)
@@ -75,10 +75,10 @@ rada(void)
        if (!snxtsct(&ns, cp))
            return RET_SYN;
        tech = tfact(player->cnum, 8.0);
-       if (tech > ((double)WORLD_Y / 4.0))
-           tech = ((double)WORLD_Y / 4.0);
-       if (tech > ((double)WORLD_X / 8.0))
-           tech = ((double)WORLD_X / 8.0);
+       if (tech > WORLD_Y / 4.0)
+           tech = WORLD_Y / 4.0;
+       if (tech > WORLD_X / 8.0)
+           tech = WORLD_X / 8.0;
        while (nxtsct(&ns, &sect)) {
            if (sect.sct_type != SCT_RADAR)
                continue;
@@ -105,11 +105,11 @@ rada(void)
                    tf = 0.0;
                pr("%s at ", prship(&ship));
                tech = techfact(ship.shp_tech,
-                               (double)mchr[(int)ship.shp_type].m_vrnge);
-               if (tech > ((double)WORLD_Y / 2.0))
-                   tech = ((double)WORLD_Y / 2.0);
-               if (tech > ((double)WORLD_X / 4.0))
-                   tech = ((double)WORLD_X / 4.0);
+                               mchr[(int)ship.shp_type].m_vrnge);
+               if (tech > WORLD_Y / 2.0)
+                   tech = WORLD_Y / 2.0;
+               if (tech > WORLD_X / 4.0)
+                   tech = WORLD_X / 4.0;
                radmap(ship.shp_x, ship.shp_y, ship.shp_effic,
                       (int)tech, tf);
            }
@@ -133,10 +133,10 @@ rada(void)
                tf = 0.0;
                pr("%s at ", prland(&land));
                tech = techfact(land.lnd_tech, land.lnd_spy);
-               if (tech > ((double)WORLD_Y / 2.0))
-                   tech = ((double)WORLD_Y / 2.0);
-               if (tech > ((double)WORLD_X / 4.0))
-                   tech = ((double)WORLD_X / 4.0);
+               if (tech > WORLD_Y / 2.0)
+                   tech = WORLD_Y / 2.0;
+               if (tech > WORLD_X / 4.0)
+                   tech = WORLD_X / 4.0;
                radmap(land.lnd_x, land.lnd_y, land.lnd_effic,
                       (int)tech, tf);
            }
index 640fd94af9aa9a2a5d2f29ee40ec283c51be2a73..fd550bc0ced6ddd61ff0106a9748c591315f9aaf 100644 (file)
@@ -152,7 +152,7 @@ spy(void)
                continue;
            }
            /* catch spy N/200 chance, N = # military */
-           caught = chance((double)dsect.sct_item[I_MILIT] / 200.0);
+           caught = chance(dsect.sct_item[I_MILIT] / 200.0);
            own = dsect.sct_own;
            /* determine spyee relations with spyer */
            relat = getrel(getnatp(own), player->cnum);
index 747faabf359504b3ff67a6d80189b768d5f53daa..2a8e22ca07455e6e906d1ce2455f395f4d9cb4ba 100644 (file)
@@ -346,7 +346,7 @@ fire_dchrg(struct shpstr *sp, struct shpstr *targ, int ntargets)
        return;
 
     /* ok, all set.. now, we shoot */
-    shells -= ldround(((double)gun) / 2.0, 1);
+    shells -= ldround(gun / 2.0, 1);
     sp->shp_item[I_SHELL] = shells;
     putship(sp->shp_uid, sp);
 
index 83faddf883e57ffe0b3b2c44c80f5bc843584a2c..34df9b95a14325a6f3d077de40904acd6e2026a6 100644 (file)
@@ -51,9 +51,9 @@ sector_mcost(struct sctstr *sp, int do_bonus)
 /* Note, the best you can get is a 1.0 here. */
 
     if (do_bonus == MOB_ROAD) {
-       d = d / (1.0 + ((double)sp->sct_road / 122.0));
+       d = d / (1.0 + sp->sct_road / 122.0);
     } else if (do_bonus == MOB_RAIL) {
-       d = d / (1.0 + ((double)sp->sct_rail / 100.0));
+       d = d / (1.0 + sp->sct_rail / 100.0);
     } else {
        if (d < 2.0)
            d = 2.0;
@@ -61,10 +61,10 @@ sector_mcost(struct sctstr *sp, int do_bonus)
     if (d < 1.0)
        d = 1.0;
     if (dchr[sp->sct_type].d_mcst < 25)
-       d = (d * 100.0 - (double)sp->sct_effic) / 500.0;
-/*     d = (200.0 + (d - 3.0) * (double)sp->sct_effic) / 500.0;*/
+       d = (d * 100.0 - sp->sct_effic) / 500.0;
+/*     d = (200.0 + (d - 3.0) * sp->sct_effic) / 500.0;*/
     else
-       d = (d * 10.0 - (double)sp->sct_effic) / 115;
+       d = (d * 10.0 - sp->sct_effic) / 115;
 
     if (d <= 0.0 || d < MIN_MOBCOST)
        return MIN_MOBCOST;
index 7a3fcc059f5880d09f97e4b34435aee19dfba441..aa335dbbe0e58c95482956bdd05e3b822ece352c 100644 (file)
@@ -265,8 +265,8 @@ bp_realcost(struct as_coord from, struct as_coord to, void *pp)
 static double
 bp_seccost(struct as_coord from, struct as_coord to, void *pp)
 {
-    return (double)mapdist((coord)from.x, (coord)from.y,
-                          (coord)to.x, (coord)to.y);
+    return mapdist((coord)from.x, (coord)from.y,
+                  (coord)to.x, (coord)to.y);
 }
 
 /*
index 61a5982930b10c1de00db3a9c75d5e984ab1a36f..1898d01165af0565432755362e791c67e064ff7b 100644 (file)
@@ -40,7 +40,7 @@ chance(double d)
 {
     double roll;
 
-    roll = (random() & 0x7fff);
+    roll = random() & 0x7fff;
 
     if (d > roll / 32768.0)
        return 1;
@@ -50,7 +50,7 @@ chance(double d)
 int
 roll(int n)
 {
-    return (random() % n) + 1;
+    return 1 + random() % n;
 }
 
 /*
index 6f743e5b83de8e93a6fa322ae77b0f6b784c7154..ecf68df31b9c4e4c25bf85603d3a2300a7fb3879 100644 (file)
@@ -43,11 +43,10 @@ double
 landgun(int effic, int guns)
 {
     double d;
-    double g = (double)MIN(guns, 7);
+    double g = MIN(guns, 7);
 
-    d = ((double)(random() % 30) + 20.0) * ((double)g / 7.0);
-    d *= (double)effic;
-    d /= 100.0;
+    d = (random() % 30 + 20.0) * (g / 7.0);
+    d *= effic / 100.0;
     return d;
 }
 
@@ -58,8 +57,8 @@ seagun(int effic, int guns)
 
     d = 0.0;
     while (guns--)
-       d += 10.0 + (double)(random() % 6);
-    d *= (double)effic * 0.01;
+       d += 10.0 + random() % 6;
+    d *= effic * 0.01;
     return d;
 }
 
@@ -70,8 +69,8 @@ landunitgun(int effic, int shots, int guns, int ammo, int shells)
 
     shots = MIN(shots, guns);
     while (shots-- > 0)
-       d += 5.0 + (double)(random() % 6);
-    d *= (double)effic * 0.01;
+       d += 5.0 + random() % 6;
+    d *= effic * 0.01;
     if (shells < ammo && ammo != 0)
        d *= (double)shells / (double)ammo;
     return d;
index 4a911577e93407a17714cf0d9e206c5e3d981050..c89e9b66784db5e4068e83c50fe4230f4d4a77db 100644 (file)
@@ -176,8 +176,7 @@ lnd_take_casualty(int combat_mode, struct llist *llp, int cas)
        eff_eq = 100;
        llp->land.lnd_effic = 0;
     } else {
-       eff_eq =
-           ldround((((double)cas * 100.0) / (double)llp->lcp->l_mil), 1);
+       eff_eq = ldround(cas * 100.0 / llp->lcp->l_mil, 1);
        llp->land.lnd_effic -= eff_eq;
        lnd_submil(&llp->land, cas);
     }
@@ -345,7 +344,7 @@ intelligence_report(int destination, struct lndstr *lp, int spy,
     memset(buf1, 0, sizeof(buf1));
     memset(buf2, 0, sizeof(buf2));
     memset(buf3, 0, sizeof(buf3));
-    if (chance((double)(spy + lp->lnd_vis) / 10.0)) {
+    if (chance((spy + lp->lnd_vis) / 10.0)) {
        if (destination == player->cnum)
            pr("%s %s", mess, prland(lp));
        else
@@ -353,8 +352,7 @@ intelligence_report(int destination, struct lndstr *lp, int spy,
 
        estimate = lp->lnd_item[I_MILIT];
 
-       if (chance((double)(spy + lp->lnd_vis) / 20.0)) {
-
+       if (chance((spy + lp->lnd_vis) / 20.0)) {
            if (destination == player->cnum)
                pr(" (eff %d, mil %d",
                   roundintby(lp->lnd_effic, 5),
@@ -365,7 +363,7 @@ intelligence_report(int destination, struct lndstr *lp, int spy,
                        roundintby(lp->lnd_item[I_MILIT], 10));
            estimate = lp->lnd_item[I_MILIT] * lp->lnd_effic / 100.0;
 
-           if (chance((double)(spy + lp->lnd_vis) / 20.0)) {
+           if (chance((spy + lp->lnd_vis) / 20.0)) {
                int t;
                t = lp->lnd_tech - 20 + roll(40);
                t = MAX(t, 0);
@@ -524,7 +522,7 @@ lnd_sel(struct nstr_item *ni, struct emp_qelem *list)
        llp = malloc(sizeof(struct llist));
        llp->lcp = lcp;
        llp->land = land;
-       llp->mobil = (double)land.lnd_mobil;
+       llp->mobil = land.lnd_mobil;
        emp_insque(&llp->queue, list);
     }
 }
@@ -593,7 +591,7 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp,
        if (land.lnd_x != allx || land.lnd_y != ally)
            *togetherp = 0;
        if (land.lnd_mobil + 1 < (int)llp->mobil) {
-           llp->mobil = (double)land.lnd_mobil;
+           llp->mobil = land.lnd_mobil;
        }
        if (llp->mobil < *minmobp)
            *minmobp = llp->mobil;
@@ -821,7 +819,7 @@ lnd_damage(struct emp_qelem *list, int totdam)
 
     if (!totdam || !(count = lnd_count(list)))
        return 0;
-    dam = ldround(((double)totdam / (double)count), 1);
+    dam = ldround((double)totdam / count, 1);
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
        llp = (struct llist *)qp;
@@ -975,9 +973,9 @@ lnd_hardtarget(struct lndstr *lp)
     struct sctstr sect;
 
     getsect(lp->lnd_x, lp->lnd_y, &sect);
-    return (int)(((double)lp->lnd_effic / 100.0) *
-                (10 + dchr[sect.sct_type].d_dstr * 2 +
-                 (double)lp->lnd_spd / 2.0 - lp->lnd_vis));
+    return (int)((lp->lnd_effic / 100.0) *
+                (10 + dchr[sect.sct_type].d_dstr * 2 + lp->lnd_spd / 2.0
+                 - lp->lnd_vis));
 }
 
 static int
@@ -1019,7 +1017,7 @@ lnd_mobcost(struct lndstr *lp, struct sctstr *sp, int mobtype)
    bridge heads, bridges and highways have built-in highways bonus
    because they are a 1, and this will discount that. */
 
-    smobcost = (double)sector_mcost(sp, mobtype);
+    smobcost = sector_mcost(sp, mobtype);
     if (smobcost < 0.01)
        smobcost = 0.01;
 
index 74c568f6cb40de64ea0e79584ee856eca4ceea8e..f13912252fb7b5a36e0210dfaf324cf70db9c8b9 100644 (file)
@@ -486,9 +486,8 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
                dam2 = ldround(landunitgun(lp->lnd_effic, lp->lnd_dam, gun,
                                           lp->lnd_ammo, shell), 1);
                if (sect.sct_type == SCT_WATER) {
-                   double dam3 = (double)dam2;
-                   if (chance(((double)lp->lnd_acc) / 100.0))
-                       dam2 = ldround((dam3 / 2.0), 1);
+                   if (chance(lp->lnd_acc / 100.0))
+                       dam2 = ldround(dam2 / 2.0, 1);
                }
                dam += dam2;
                if (sect.sct_type == SCT_WATER)
@@ -527,7 +526,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
                if (!(mcp->m_flags & M_DCH) && !(mcp->m_flags & M_SUBT))
                    continue;
                vrange = techfact(sp->shp_tech, mcp->m_vrnge);
-               vrange *= (double)sp->shp_effic / 200.0;
+               vrange *= sp->shp_effic / 200.0;
                if (md > vrange)
                    continue;
                /* can't look all the time */
@@ -900,7 +899,7 @@ show_mission(int type, struct nstr_item *np)
            pr("  %4d", plus);
        } else if (gp->mission == MI_ESCORT) {
            pr("        ");
-           pr("  %4d", (int)(item.plane.pln_range / 2.0));
+           pr("  %4d", item.plane.pln_range / 2);
        } else
            pr("              ");
        if (gp->mission)
@@ -1536,7 +1535,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
        for (qp = interceptors.q_forw; qp != (&interceptors);
             qp = qp->q_forw)
            tcount++;
-       tcount -= (count * 2);
+       tcount -= count * 2;
        /* Just in case there are more incoming than we have */
        if (tcount < 0)
            tcount = 0;
index 5fdd967df13e9b4b7f6a94484dca6cc43fc70cf6..2f893a1a81fd191d119efab983ae922ed88c6ac6 100644 (file)
@@ -63,7 +63,7 @@ move_ground(struct sctstr *start, struct sctstr *end,
     double sect_mcost;
     double total_mcost;
     double mv_cost;
-    double mobility = (double)start->sct_mobil;
+    double mobility = start->sct_mobil;
     int dir;
     int intcost;
     int takedam = *dam;
@@ -230,7 +230,7 @@ move_ground(struct sctstr *start, struct sctstr *end,
        if (takedam && chance(weight / 100.0) &&
            ((curx != oldx) || (cury != oldy)))
            *dam += ground_interdict(curx, cury, player->cnum,
-                                      "commodities");
+                                    "commodities");
        if (*dam >= 100)
            break;
     }
index e1df61520d467f8c25ba553513a044f2ccd3bdcb..9229b6c0a61f3fb41d77a1a6f3af8e912a4b689b 100644 (file)
@@ -1005,7 +1005,7 @@ plane_sweep(struct emp_qelem *plane_list, coord x, coord y)
        if (!(pcp->pl_flags & P_SWEEP)) /* if it isn't an sweep plane */
            continue;
 
-       if (chance(((double)(100 - pp->pln_acc)) / 100.0)) {
+       if (chance((100.0 - pp->pln_acc) / 100.0)) {
            pr("Sweep! in %s\n",
               xyas(sect.sct_x, sect.sct_y, pp->pln_own));
            mines_there--;
index 06bfde29c1c0f1c5dd95e30c0ef7ce422c74a568..c9660042ebe36b1db2adf6d5ecc6d2f8a0817267 100644 (file)
@@ -208,7 +208,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
        while (nxtitem(&ni, &land)) {
            if (land.lnd_own == 0)
                continue;
-           if (!chance((double)land.lnd_effic / 20.0))
+           if (!chance(land.lnd_effic / 20.0))
                continue;
            if (++crackle == 100)
                crackle = 0;
@@ -326,7 +326,7 @@ satdisp(struct sctstr *sp, int acc, int showstuff)
     while (nxtitem(&ni, &land)) {
        if (land.lnd_own == 0)
            continue;
-       if (!chance((double)land.lnd_effic / 20.0))
+       if (!chance(land.lnd_effic / 20.0))
            continue;
 
        if (first) {
index eb2a4ec66503fdc7aa38f0f8e5f6e85e9e681440..bafa098a14a4712073f328b0863490462fd5be83 100644 (file)
@@ -107,7 +107,7 @@ shp_sel(struct nstr_item *ni, struct emp_qelem *list)
        mlp = malloc(sizeof(struct mlist));
        mlp->mcp = mcp;
        mlp->ship = ship;
-       mlp->mobil = (double)ship.shp_mobil;
+       mlp->mobil = ship.shp_mobil;
        emp_insque(&mlp->queue, list);
     }
 }
@@ -178,7 +178,7 @@ shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp,
        if (ship.shp_x != allx || ship.shp_y != ally)
            *togetherp = 0;
        if (ship.shp_mobil + 1 < (int)mlp->mobil) {
-           mlp->mobil = (double)ship.shp_mobil;
+           mlp->mobil = ship.shp_mobil;
        }
        if (mlp->mobil < *minmobp)
            *minmobp = mlp->mobil;
@@ -446,7 +446,7 @@ shp_damage(struct emp_qelem *list, int totdam, int wantflags,
     if (!totdam
        || !(count = shp_count(list, wantflags, nowantflags, x, y)))
        return 0;
-    dam = ldround(((double)totdam / (double)count), 1);
+    dam = ldround((double)totdam / count, 1);
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
        mlp = (struct mlist *)qp;
@@ -749,11 +749,11 @@ shp_hardtarget(struct shpstr *sp)
 
     vis = sp->shp_visib;
     getsect(sp->shp_x, sp->shp_y, &sect);
-    onsea = (sect.sct_type == SCT_WATER);
+    onsea = sect.sct_type == SCT_WATER;
     if (mcp->m_flags & M_SUB)
        vis *= 4;
-    return (int)(((double)sp->shp_effic / 100.0) *
-                (20 + (double)sp->shp_speed * onsea / 2.0 - vis));
+    return (int)((sp->shp_effic / 100.0) *
+                (20 + sp->shp_speed * onsea / 2.0 - vis));
 }
 
 static int
@@ -955,9 +955,8 @@ shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget)
 
        /* now calculate the odds */
        gun = MIN(ship.shp_item[I_GUN], ship.shp_glim);
-       eff = (double)ship.shp_effic / 100.0;
-       teff =
-           (((double)ship.shp_tech) / (((double)ship.shp_tech) + 200.0));
+       eff = ship.shp_effic / 100.0;
+       teff = ship.shp_tech / (ship.shp_tech + 200.0);
        /* raise 4.5 for better interception -KHS */
        hitchance = (int)(gun * eff * teff * 4.5) - hardtarget;
        if (hitchance < 0)
@@ -1032,7 +1031,7 @@ shp_missdef(struct shpstr *sp, natid victim)
     mlp = malloc(sizeof(struct mlist));
     mlp->mcp = &mchr[(int)sp->shp_type];
     mlp->ship = *sp;
-    mlp->mobil = (double)sp->shp_mobil;
+    mlp->mobil = sp->shp_mobil;
     emp_insque(&mlp->queue, &list);
     sprintf(buf, "%s", prship(&mlp->ship));
 
index f1fce1e2b4324612875f38dd1108d496149a242f..6d417f36cea810f54343cd04de1ca87faa07e265 100644 (file)
@@ -111,8 +111,8 @@ resupply_commod(struct lndstr *lp, i_type type)
     }
 
     if (opt_FUEL && type == I_PETROL) {
-       int fuel_needed = (lp->lnd_fuelu * (((float)etu_per_update
-                                            * land_mob_scale)) / 10.0);
+       int fuel_needed = lp->lnd_fuelu
+           * ((float)etu_per_update * land_mob_scale) / 10.0;
 
        while ((lp->lnd_fuel < fuel_needed) && lp->lnd_item[I_PETROL]) {
            lp->lnd_fuel += 10;
@@ -216,10 +216,10 @@ s_commod(int own, int x, int y, i_type type, int total_wanted,
        packing = ip->i_pkg[dp->d_pkg];
        if (packing > 1 && sect.sct_effic < 60)
            packing = 1;
-       weight = ((double)ip->i_lbs / (double)packing);
+       weight = (double)ip->i_lbs / packing;
        mobcost = move_cost * weight;
        if (mobcost > 0)
-           can_move = ((double)sect.sct_mobil / mobcost);
+           can_move = (double)sect.sct_mobil / mobcost;
        else
            can_move = sect.sct_item[type] - minimum;
        if (can_move > sect.sct_item[type] - minimum)
@@ -290,10 +290,10 @@ s_commod(int own, int x, int y, i_type type, int total_wanted,
        packing = ip->i_pkg[dp->d_pkg];
        if (packing > 1 && sect.sct_effic < 60)
            packing = 1;
-       weight = ((double)ip->i_lbs / (double)packing);
+       weight = (double)ip->i_lbs / packing;
        mobcost = move_cost * weight;
        if (mobcost > 0)
-           can_move = ((double)sect.sct_mobil / mobcost);
+           can_move = (double)sect.sct_mobil / mobcost;
        else
            can_move = ship.shp_item[type] - minimum;
        if (can_move > ship.shp_item[type] - minimum)
@@ -381,10 +381,10 @@ s_commod(int own, int x, int y, i_type type, int total_wanted,
 
        min = get_minimum(&land, type);
        ip = &ichr[type];
-       weight = ((double)ip->i_lbs);
+       weight = ip->i_lbs;
        mobcost = move_cost * weight;
        if (mobcost > 0)
-           can_move = ((double)land.lnd_mobil / mobcost);
+           can_move = (double)land.lnd_mobil / mobcost;
        else
            can_move = land.lnd_item[type] - min;
        if (can_move > land.lnd_item[type] - min)
@@ -438,8 +438,7 @@ get_minimum(struct lndstr *lp, i_type type)
     case I_FOOD:
        if (opt_NOFOOD)
            return 0;           /* no food reqd, get out */
-       want = (((double)etu_per_update * eatrate) *
-               (double)lp->lnd_item[I_MILIT]) + 1;
+       want = (double)etu_per_update * eatrate * lp->lnd_item[I_MILIT] + 1;
        break;
     case I_SHELL:
        want = lp->lnd_ammo;
@@ -448,18 +447,15 @@ get_minimum(struct lndstr *lp, i_type type)
        /*
         * return the amount of pet we'd need to get to 
         * enough fuel for 1 update
-        *
         */
     case I_PETROL:
        if (opt_FUEL == 0)
            return 0;
-       want = (lp->lnd_fuelu * (((float)etu_per_update *
-                                 land_mob_scale)) / 10.0);
+       want = lp->lnd_fuelu * ((float)etu_per_update * land_mob_scale)
+           / 10.0;
        want -= lp->lnd_fuel;
        if (want > 0) {
-           double d;
-           d = (double)want / 10.0;
-           want = (int)d;
+           want = want / 10;
            if (want == 0)
                want++;
        }
@@ -518,7 +514,7 @@ has_supply(struct lndstr *lp)
        fuel = lp->lnd_fuel;
        if (fuel < fuel_needed) {
            petrol_needed =
-               ldround(((double)(fuel_needed - fuel) / 10.0), 1);
+               ldround((fuel_needed - fuel) / 10.0, 1);
            petrol = keeppetrol = lp->lnd_item[I_PETROL];
            if (petrol < petrol_needed) {
                lp->lnd_item[I_PETROL] = 0;
@@ -582,7 +578,7 @@ use_supply(struct lndstr *lp)
 
        if (fuel < fuel_needed) {
            petrol_needed =
-               ldround(((double)(fuel_needed - fuel) / 10.0), 1);
+               ldround((fuel_needed - fuel) / 10.0, 1);
            petrol = lp->lnd_item[I_PETROL];
        }
 
index 27a6c21fc4c09610e751397686d6f985aad03413..0efa96f5af79aa10f5ca5da82d397538a01c57ab 100644 (file)
@@ -99,7 +99,7 @@ do_feed(struct sctstr *sp, struct natstr *np, short *vec,
                   supply ships in port, or supply units */
                int needed;
 
-               needed = ldround((double)(1 + etu * people * eatrate), 1);
+               needed = ldround(1.0 + etu * people * eatrate, 1);
 
                /* Now, find some food */
                vec[I_FOOD] = supply_commod(sp->sct_own,
index cce9bb9106f7782db4175f037efb958b8dab5895..fbacfd9f6320a07e728994807a238ba9bb3b46fe 100644 (file)
@@ -306,26 +306,26 @@ do_mob_ship(struct shpstr *sp, int etus)
 
     /* opt_FUEL in force */
     if (mchr[(int)sp->shp_type].m_fuelu == 0) {
-       value = sp->shp_mobil + ((float)etus * ship_mob_scale);
+       value = sp->shp_mobil + (float)etus * ship_mob_scale;
        if (value > ship_mob_max)
            value = ship_mob_max;
        sp->shp_mobil = (signed char)value;
     } else {
        can_add = ship_mob_max - sp->shp_mobil;
-       if (can_add > ((float)etus * ship_mob_scale))
-           can_add = ((float)etus * ship_mob_scale);
-       have_fuel_for = ldround((((double)sp->shp_fuel /
-                                 (double)mchr[(int)sp->shp_type].m_fuelu)
-                                * (double)fuel_mult), 1);
+       if (can_add > (float)etus * ship_mob_scale)
+           can_add = (float)etus * ship_mob_scale;
+       have_fuel_for = ldround(((double)sp->shp_fuel /
+                                (double)mchr[(int)sp->shp_type].m_fuelu)
+                               * (double)fuel_mult, 1);
 
        if (can_add > have_fuel_for) {
            int need;
            need = can_add - have_fuel_for;
-           d = (double)need;
-           d *= (double)mchr[(int)sp->shp_type].m_fuelu;
-           d /= (double)fuel_mult;
+           d = need;
+           d *= mchr[(int)sp->shp_type].m_fuelu;
+           d /= fuel_mult;
            d /= 5.0;
-           if ((d - (int)d) > 0.0)
+           if (d - (int)d > 0.0)
                d++;
            need = (int)d;
            newfuel = supply_commod(sp->shp_own, sp->shp_x, sp->shp_y,
@@ -333,18 +333,18 @@ do_mob_ship(struct shpstr *sp, int etus)
            sp->shp_fuel += newfuel * 5;
        }
 
-       have_fuel_for = ldround((((double)sp->shp_fuel /
-                                 (double)mchr[(int)sp->shp_type].m_fuelu)
-                                * (double)fuel_mult), 1);
+       have_fuel_for = ldround(((double)sp->shp_fuel /
+                                (double)mchr[(int)sp->shp_type].m_fuelu)
+                               * (double)fuel_mult, 1);
 
        if (can_add > have_fuel_for) {
            int need;
            need = can_add - have_fuel_for;
-           d = (double)need;
-           d *= (double)mchr[(int)sp->shp_type].m_fuelu;
-           d /= (double)fuel_mult;
+           d = need;
+           d *= mchr[(int)sp->shp_type].m_fuelu;
+           d /= fuel_mult;
            d /= 50.0;
-           if ((d - (int)d) > 0.0)
+           if (d - (int)d > 0.0)
                d++;
            need = (int)d;
            newfuel = supply_commod(sp->shp_own, sp->shp_x, sp->shp_y,
@@ -352,17 +352,17 @@ do_mob_ship(struct shpstr *sp, int etus)
            sp->shp_fuel += newfuel * 50;
        }
 
-       have_fuel_for = ldround((((double)sp->shp_fuel /
-                                 (double)mchr[(int)sp->shp_type].m_fuelu)
-                                * (double)fuel_mult), 1);
+       have_fuel_for = ldround(((double)sp->shp_fuel /
+                                (double)mchr[(int)sp->shp_type].m_fuelu)
+                               * (double)fuel_mult, 1);
 
        if (can_add > have_fuel_for)
            total_add = have_fuel_for;
        else
            total_add = can_add;
-       d = (double)total_add;
-       d *= (double)mchr[(int)sp->shp_type].m_fuelu;
-       d /= (double)fuel_mult;
+       d = total_add;
+       d *= mchr[(int)sp->shp_type].m_fuelu;
+       d /= fuel_mult;
        sp->shp_fuel -= ldround(d, 1);
        sp->shp_fuel = MIN(sp->shp_fuel, mchr[(int)sp->shp_type].m_fuelc);
        sp->shp_mobil += total_add;
@@ -429,19 +429,19 @@ do_mob_land(struct lndstr *lp, int etus)
 
        can_add = land_mob_max - lp->lnd_mobil;
 
-       if (can_add > ((float)etus * land_mob_scale))
-           can_add = ((float)etus * land_mob_scale);
+       if (can_add > (float)etus * land_mob_scale)
+           can_add = (float)etus * land_mob_scale;
 
        have_fuel_for = (lp->lnd_fuel / lp->lnd_fuelu) * fuel_mult;
 
        if (can_add > have_fuel_for) {
            int need;
            need = can_add - have_fuel_for;
-           d = (double)need;
-           d *= (double)lp->lnd_fuelu;
-           d /= (double)fuel_mult;
+           d = need;
+           d *= lp->lnd_fuelu;
+           d /= fuel_mult;
            d /= 5.0;
-           if ((d - (int)d) > 0.0)
+           if (d - (int)d > 0.0)
                d++;
            need = (int)d;
            newfuel = supply_commod(lp->lnd_own, lp->lnd_x, lp->lnd_y,
@@ -454,11 +454,11 @@ do_mob_land(struct lndstr *lp, int etus)
        if (can_add > have_fuel_for) {
            int need;
            need = can_add - have_fuel_for;
-           d = (double)need;
-           d *= (double)lp->lnd_fuelu;
-           d /= (double)fuel_mult;
+           d = need;
+           d *= lp->lnd_fuelu;
+           d /= fuel_mult;
            d /= 50.0;
-           if ((d - (int)d) > 0.0)
+           if (d - (int)d > 0.0)
                d++;
            need = (int)d;
            newfuel = supply_commod(lp->lnd_own, lp->lnd_x, lp->lnd_y,
@@ -472,9 +472,9 @@ do_mob_land(struct lndstr *lp, int etus)
            total_add = have_fuel_for;
        } else
            total_add = can_add;
-       d = (double)total_add;
-       d *= (double)lp->lnd_fuelu;
-       d /= (double)fuel_mult;
+       d = total_add;
+       d *= lp->lnd_fuelu;
+       d /= fuel_mult;
        lp->lnd_fuel -= ldround(d, 1);
        lp->lnd_fuel = MIN(lp->lnd_fuel, lp->lnd_fuelc);
        lp->lnd_mobil += total_add;
index 9c8e501895c9d3d511447c58d03c43113e7139e4..13e6ff9ddf6c0f6efd8213da47407ac82e972987 100644 (file)
@@ -262,7 +262,7 @@ nav_ship(struct shpstr *sp)
     mlp = malloc(sizeof(struct mlist));
     mlp->mcp = mchr + sp->shp_type;
     mlp->ship = *sp;
-    mlp->mobil = (double)sp->shp_mobil;
+    mlp->mobil = sp->shp_mobil;
     emp_insque(&mlp->queue, &ship_list);
 
     quit = 1;                  /* setup loop, we want to check it 1 time. */
index 8c3933ffc4fea803c41bafa6d614e355b3709441..3171e83a44fbb15fa79889f0d836c3053d688fe7 100644 (file)
@@ -212,10 +212,10 @@ auto_fuel_ship(struct shpstr *sp)
     if (opt_FUEL == 0)
        return;
     getship(sp->shp_uid, sp);  /* refresh */
-    /* fill with petro */
+    /* fill with petrol */
     maxfuel = mchr[(int)sp->shp_type].m_fuelc;
-    d = (double)maxfuel / 5.0;
-    if ((d - (int)d > 0.0))
+    d = maxfuel / 5.0;
+    if (d - (int)d > 0.0)
        d++;
     need = (int)d;
 
@@ -233,8 +233,8 @@ auto_fuel_ship(struct shpstr *sp)
     }
     add_fuel = 0;
     /* fill with oil */
-    d = (double)(maxfuel - totalfuel) / 50.0;
-    if ((d - (int)d > 0.0))
+    d = (maxfuel - totalfuel) / 50.0;
+    if (d - (int)d > 0.0)
        d++;
     need = (int)d;
 
index 1915a553e802ccf9c8f7decc859bfb1d2a169734..f117588a3acaae25f406607c80d617a8159aef17 100644 (file)
@@ -170,7 +170,7 @@ plague_people(struct natstr *np, short *vec,
        plg_num = 100.0 * etus;
        plg_denom = (np->nat_level[NAT_RLEV] + 100.0) *
            (*ptime + etus + 1.0);
-       pct_left = 1.0 - (double)(plg_num / plg_denom);
+       pct_left = 1.0 - plg_num / plg_denom;
        if (pct_left < 0.2)
            pct_left = 0.2;
        vec[I_CIVIL] = vec[I_CIVIL] * pct_left;
index 2bb5349a91032da2486d9d16acdb1c3f19ac6690..1058a929e994555dc5bc06b8ca102eee2c7d922d 100644 (file)
@@ -95,7 +95,7 @@ populace(struct natstr *np, struct sctstr *sp, int etu)
        if (n < 0)
            n = 0;
        sp->sct_work = n;
-       if (chance((double)work_red / 1000.0)) {
+       if (chance(work_red / 1000.0)) {
            /*
             * small chance of rebellion...
             * if work_red is (max) 67,
index 887f1811250e7be35879a2d7b592998e55818730..e2dd1cffb8eca6f2e84ca396931bb4a3b1e2abf8 100644 (file)
@@ -258,7 +258,7 @@ decay_fallout(struct sctstr *sp, int etus)
 
     if (etus > 24)
        etus = 24;
-    decay = roundavg(((decay_per_etu + 6.0) * fallout_spread) *
+    decay = roundavg((decay_per_etu + 6.0) * fallout_spread *
                     (double)etus * (double)sp->sct_fallout);
 
     sp->sct_fallout = decay < sp->sct_fallout ? sp->sct_fallout - decay : 0;
index 07e2dce48ceaa7cf4b907dbf62e35d4cad62a21e..51c8ffa18657cc01f99623cea66ff8a62421614f 100644 (file)
@@ -171,8 +171,8 @@ upd_ship(struct shpstr *sp, int etus,
                                                 sp->shp_item[I_MILIT],
                                                 sp->shp_item[I_UW],
                                                 ITEM_MAX)
-                                     * (double)sp->shp_effic / 100.0
-                                     * (double)sectp->sct_oil / 100.0
+                                     * sp->shp_effic / 100.0
+                                     * sectp->sct_oil / 100.0
                                      * prod_eff(product, sp->shp_tech));
                max_oil = mp->m_item[I_OIL];
                if (sp->shp_item[I_OIL] + oil_gained > max_oil)
index 081dc2811bb1a41f3b7520ffdfe51226b74db282..a40200d3887146af81239c1485514e12781a7583 100644 (file)
@@ -87,7 +87,7 @@ shutdown_sequence(void *unused)
                        header, shutdown_pending);
            } else if (shutdown_pending % 60 == 0) {
                pr_wall("%sThe server will be shutting down %d hours from now.\n",
-                       header, (int)(shutdown_pending / 60));
+                       header, shutdown_pending / 60);
            }
        }
        empth_sleep(now + 60);