diff --git a/src/client/serverio.c b/src/client/serverio.c index 9741413b..93420c5b 100644 --- a/src/client/serverio.c +++ b/src/client/serverio.c @@ -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; } diff --git a/src/lib/commands/buy.c b/src/lib/commands/buy.c index d2962b69..2188239b 100644 --- a/src/lib/commands/buy.c +++ b/src/lib/commands/buy.c @@ -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; } diff --git a/src/lib/commands/look.c b/src/lib/commands/look.c index 137fb0c5..c0329de6 100644 --- a/src/lib/commands/look.c +++ b/src/lib/commands/look.c @@ -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) diff --git a/src/lib/commands/mfir.c b/src/lib/commands/mfir.c index e645b79d..fc362ef9 100644 --- a/src/lib/commands/mfir.c +++ b/src/lib/commands/mfir.c @@ -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; diff --git a/src/lib/commands/miss.c b/src/lib/commands/miss.c index d0d3263c..8e896e40 100644 --- a/src/lib/commands/miss.c +++ b/src/lib/commands/miss.c @@ -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; diff --git a/src/lib/commands/rada.c b/src/lib/commands/rada.c index 3de1333f..363246dd 100644 --- a/src/lib/commands/rada.c +++ b/src/lib/commands/rada.c @@ -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, §)) { 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); } diff --git a/src/lib/commands/spy.c b/src/lib/commands/spy.c index 640fd94a..fd550bc0 100644 --- a/src/lib/commands/spy.c +++ b/src/lib/commands/spy.c @@ -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); diff --git a/src/lib/commands/torp.c b/src/lib/commands/torp.c index 747faabf..2a8e22ca 100644 --- a/src/lib/commands/torp.c +++ b/src/lib/commands/torp.c @@ -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); diff --git a/src/lib/common/move.c b/src/lib/common/move.c index 83faddf8..34df9b95 100644 --- a/src/lib/common/move.c +++ b/src/lib/common/move.c @@ -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; diff --git a/src/lib/common/path.c b/src/lib/common/path.c index 7a3fcc05..aa335dbb 100644 --- a/src/lib/common/path.c +++ b/src/lib/common/path.c @@ -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); } /* diff --git a/src/lib/gen/chance.c b/src/lib/gen/chance.c index 61a59829..1898d011 100644 --- a/src/lib/gen/chance.c +++ b/src/lib/gen/chance.c @@ -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; } /* diff --git a/src/lib/subs/landgun.c b/src/lib/subs/landgun.c index 6f743e5b..ecf68df3 100644 --- a/src/lib/subs/landgun.c +++ b/src/lib/subs/landgun.c @@ -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; diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index 4a911577..c89e9b66 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -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, §); - 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; diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index 74c568f6..f1391225 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -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; diff --git a/src/lib/subs/move.c b/src/lib/subs/move.c index 5fdd967d..2f893a1a 100644 --- a/src/lib/subs/move.c +++ b/src/lib/subs/move.c @@ -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; } diff --git a/src/lib/subs/plnsub.c b/src/lib/subs/plnsub.c index e1df6152..9229b6c0 100644 --- a/src/lib/subs/plnsub.c +++ b/src/lib/subs/plnsub.c @@ -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--; diff --git a/src/lib/subs/satmap.c b/src/lib/subs/satmap.c index 06bfde29..c9660042 100644 --- a/src/lib/subs/satmap.c +++ b/src/lib/subs/satmap.c @@ -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) { diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index eb2a4ec6..bafa098a 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -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, §); - 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)); diff --git a/src/lib/subs/supply.c b/src/lib/subs/supply.c index f1fce1e2..6d417f36 100644 --- a/src/lib/subs/supply.c +++ b/src/lib/subs/supply.c @@ -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]; } diff --git a/src/lib/update/human.c b/src/lib/update/human.c index 27a6c21f..0efa96f5 100644 --- a/src/lib/update/human.c +++ b/src/lib/update/human.c @@ -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, diff --git a/src/lib/update/mobility.c b/src/lib/update/mobility.c index cce9bb91..fbacfd9f 100644 --- a/src/lib/update/mobility.c +++ b/src/lib/update/mobility.c @@ -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; diff --git a/src/lib/update/nav_ship.c b/src/lib/update/nav_ship.c index 9c8e5018..13e6ff9d 100644 --- a/src/lib/update/nav_ship.c +++ b/src/lib/update/nav_ship.c @@ -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. */ diff --git a/src/lib/update/nav_util.c b/src/lib/update/nav_util.c index 8c3933ff..3171e83a 100644 --- a/src/lib/update/nav_util.c +++ b/src/lib/update/nav_util.c @@ -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; diff --git a/src/lib/update/plague.c b/src/lib/update/plague.c index 1915a553..f117588a 100644 --- a/src/lib/update/plague.c +++ b/src/lib/update/plague.c @@ -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; diff --git a/src/lib/update/populace.c b/src/lib/update/populace.c index 2bb5349a..1058a929 100644 --- a/src/lib/update/populace.c +++ b/src/lib/update/populace.c @@ -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, diff --git a/src/lib/update/sect.c b/src/lib/update/sect.c index 887f1811..e2dd1cff 100644 --- a/src/lib/update/sect.c +++ b/src/lib/update/sect.c @@ -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; diff --git a/src/lib/update/ship.c b/src/lib/update/ship.c index 07e2dce4..51c8ffa1 100644 --- a/src/lib/update/ship.c +++ b/src/lib/update/ship.c @@ -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) diff --git a/src/server/shutdown.c b/src/server/shutdown.c index 081dc281..a40200d3 100644 --- a/src/server/shutdown.c +++ b/src/server/shutdown.c @@ -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);