Remove superflous casts and parenthesis.

This commit is contained in:
Markus Armbruster 2006-05-21 12:24:30 +00:00
parent f883710417
commit cd73a47dfa
28 changed files with 136 additions and 145 deletions

View file

@ -76,7 +76,7 @@ serverio(int s, struct ioqueue *ioq)
return 0; return 0;
} }
if (n != ioq->bsize) if (n != ioq->bsize)
buf = (char *)realloc(buf, n); buf = realloc(buf, n);
ioq_write(ioq, buf, n); ioq_write(ioq, buf, n);
return 1; return 1;
} }

View file

@ -112,7 +112,7 @@ buy(void)
bid = atof(p); bid = atof(p);
if (bid <= 0) if (bid <= 0)
return RET_FAIL; 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", pr("This purchase would cost %.2f, %.2f more than you have.\n",
bid * comm.com_amount * buytax, bid * comm.com_amount * buytax,
bid * comm.com_amount * buytax - natp->nat_money); bid * comm.com_amount * buytax - natp->nat_money);
@ -131,12 +131,12 @@ buy(void)
for (q = 0; getcomm(q, &comt); q++) { for (q = 0; getcomm(q, &comt); q++) {
if (comt.com_maxbidder == player->cnum && if (comt.com_maxbidder == player->cnum &&
comt.com_owner != 0 && comt.com_owner != 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; canspend = natp->nat_money - tally;
getcomm(o, &comm); 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 have overextended yourself in the market\n");
pr("You can not bid on the current items at that price.\n"); pr("You can not bid on the current items at that price.\n");
return RET_OK; return RET_OK;
@ -165,7 +165,7 @@ buy(void)
qty, ip->i_name, n); qty, ip->i_name, n);
return RET_FAIL; 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"); pr("You don't have that much to spend!\n");
return RET_FAIL; return RET_FAIL;
} }

View file

@ -260,7 +260,7 @@ look_land(struct lndstr *lookland)
int dist; int dist;
drange = techfact(lookland->lnd_tech, lookland->lnd_spy); 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); range = ldround(drange, 1);
if (range == 0) if (range == 0)

View file

@ -364,7 +364,7 @@ multifire(void)
shots = gun; shots = gun;
guneff = seagun(fship.shp_effic, shots); guneff = seagun(fship.shp_effic, shots);
dam = (int)guneff; dam = (int)guneff;
shell -= ldround(((double)shots) / 2.0, 1); shell -= ldround(shots / 2.0, 1);
fship.shp_item[I_SHELL] = shell; fship.shp_item[I_SHELL] = shell;
if (opt_NOMOBCOST == 0) if (opt_NOMOBCOST == 0)
fship.shp_mobil = MAX(fship.shp_mobil - 15, -100); 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, dam = (int)landunitgun(fland.lnd_effic, fland.lnd_dam, gun,
fland.lnd_ammo, shell); fland.lnd_ammo, shell);
if (target == targ_ship) { if (target == targ_ship) {
if (chance(((double)fland.lnd_acc) / 100.0)) if (chance(fland.lnd_acc / 100.0))
dam = ldround(((double)dam / 2.0), 1); dam = ldround(dam / 2.0, 1);
} }
use_supply(&fland); use_supply(&fland);
resupply_commod(&fland, I_SHELL); /* Get more shells */ resupply_commod(&fland, I_SHELL); /* Get more shells */
@ -554,7 +554,7 @@ multifire(void)
prb *= prb; prb *= prb;
if (chance(prb)) { if (chance(prb)) {
pr("Wind deflects shell%s.\n", splur(shots)); 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; dam *= (90 - (random() % 11)) / 100.0;
if (dam < 0) if (dam < 0)
dam = 0; dam = 0;
@ -713,7 +713,7 @@ do_defdam(struct emp_qelem *list, double odds)
pr("\nDefenders fire back!\n"); pr("\nDefenders fire back!\n");
first = 0; first = 0;
} }
dam = (odds * (double)fp->defdam); dam = odds * fp->defdam;
if (fp->type == targ_ship) { if (fp->type == targ_ship) {
vict = fp->victim; vict = fp->victim;

View file

@ -209,7 +209,7 @@ mission(void)
return RET_FAIL; return RET_FAIL;
} }
mobused = ldround((mission_mob_cost * (double)mobmax), 1); mobused = ldround(mission_mob_cost * (double)mobmax, 1);
while (nxtitem(&ni, &item)) { while (nxtitem(&ni, &item)) {
gp = (struct genitem *)&item; gp = (struct genitem *)&item;

View file

@ -75,10 +75,10 @@ rada(void)
if (!snxtsct(&ns, cp)) if (!snxtsct(&ns, cp))
return RET_SYN; return RET_SYN;
tech = tfact(player->cnum, 8.0); tech = tfact(player->cnum, 8.0);
if (tech > ((double)WORLD_Y / 4.0)) if (tech > WORLD_Y / 4.0)
tech = ((double)WORLD_Y / 4.0); tech = WORLD_Y / 4.0;
if (tech > ((double)WORLD_X / 8.0)) if (tech > WORLD_X / 8.0)
tech = ((double)WORLD_X / 8.0); tech = WORLD_X / 8.0;
while (nxtsct(&ns, &sect)) { while (nxtsct(&ns, &sect)) {
if (sect.sct_type != SCT_RADAR) if (sect.sct_type != SCT_RADAR)
continue; continue;
@ -105,11 +105,11 @@ rada(void)
tf = 0.0; tf = 0.0;
pr("%s at ", prship(&ship)); pr("%s at ", prship(&ship));
tech = techfact(ship.shp_tech, tech = techfact(ship.shp_tech,
(double)mchr[(int)ship.shp_type].m_vrnge); mchr[(int)ship.shp_type].m_vrnge);
if (tech > ((double)WORLD_Y / 2.0)) if (tech > WORLD_Y / 2.0)
tech = ((double)WORLD_Y / 2.0); tech = WORLD_Y / 2.0;
if (tech > ((double)WORLD_X / 4.0)) if (tech > WORLD_X / 4.0)
tech = ((double)WORLD_X / 4.0); tech = WORLD_X / 4.0;
radmap(ship.shp_x, ship.shp_y, ship.shp_effic, radmap(ship.shp_x, ship.shp_y, ship.shp_effic,
(int)tech, tf); (int)tech, tf);
} }
@ -133,10 +133,10 @@ rada(void)
tf = 0.0; tf = 0.0;
pr("%s at ", prland(&land)); pr("%s at ", prland(&land));
tech = techfact(land.lnd_tech, land.lnd_spy); tech = techfact(land.lnd_tech, land.lnd_spy);
if (tech > ((double)WORLD_Y / 2.0)) if (tech > WORLD_Y / 2.0)
tech = ((double)WORLD_Y / 2.0); tech = WORLD_Y / 2.0;
if (tech > ((double)WORLD_X / 4.0)) if (tech > WORLD_X / 4.0)
tech = ((double)WORLD_X / 4.0); tech = WORLD_X / 4.0;
radmap(land.lnd_x, land.lnd_y, land.lnd_effic, radmap(land.lnd_x, land.lnd_y, land.lnd_effic,
(int)tech, tf); (int)tech, tf);
} }

View file

@ -152,7 +152,7 @@ spy(void)
continue; continue;
} }
/* catch spy N/200 chance, N = # military */ /* 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; own = dsect.sct_own;
/* determine spyee relations with spyer */ /* determine spyee relations with spyer */
relat = getrel(getnatp(own), player->cnum); relat = getrel(getnatp(own), player->cnum);

View file

@ -346,7 +346,7 @@ fire_dchrg(struct shpstr *sp, struct shpstr *targ, int ntargets)
return; return;
/* ok, all set.. now, we shoot */ /* 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; sp->shp_item[I_SHELL] = shells;
putship(sp->shp_uid, sp); putship(sp->shp_uid, sp);

View file

@ -51,9 +51,9 @@ sector_mcost(struct sctstr *sp, int do_bonus)
/* Note, the best you can get is a 1.0 here. */ /* Note, the best you can get is a 1.0 here. */
if (do_bonus == MOB_ROAD) { 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) { } 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 { } else {
if (d < 2.0) if (d < 2.0)
d = 2.0; d = 2.0;
@ -61,10 +61,10 @@ sector_mcost(struct sctstr *sp, int do_bonus)
if (d < 1.0) if (d < 1.0)
d = 1.0; d = 1.0;
if (dchr[sp->sct_type].d_mcst < 25) if (dchr[sp->sct_type].d_mcst < 25)
d = (d * 100.0 - (double)sp->sct_effic) / 500.0; d = (d * 100.0 - sp->sct_effic) / 500.0;
/* d = (200.0 + (d - 3.0) * (double)sp->sct_effic) / 500.0;*/ /* d = (200.0 + (d - 3.0) * sp->sct_effic) / 500.0;*/
else 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) if (d <= 0.0 || d < MIN_MOBCOST)
return MIN_MOBCOST; return MIN_MOBCOST;

View file

@ -265,7 +265,7 @@ bp_realcost(struct as_coord from, struct as_coord to, void *pp)
static double static double
bp_seccost(struct as_coord from, struct as_coord to, void *pp) bp_seccost(struct as_coord from, struct as_coord to, void *pp)
{ {
return (double)mapdist((coord)from.x, (coord)from.y, return mapdist((coord)from.x, (coord)from.y,
(coord)to.x, (coord)to.y); (coord)to.x, (coord)to.y);
} }

View file

@ -40,7 +40,7 @@ chance(double d)
{ {
double roll; double roll;
roll = (random() & 0x7fff); roll = random() & 0x7fff;
if (d > roll / 32768.0) if (d > roll / 32768.0)
return 1; return 1;
@ -50,7 +50,7 @@ chance(double d)
int int
roll(int n) roll(int n)
{ {
return (random() % n) + 1; return 1 + random() % n;
} }
/* /*

View file

@ -43,11 +43,10 @@ double
landgun(int effic, int guns) landgun(int effic, int guns)
{ {
double d; double d;
double g = (double)MIN(guns, 7); double g = MIN(guns, 7);
d = ((double)(random() % 30) + 20.0) * ((double)g / 7.0); d = (random() % 30 + 20.0) * (g / 7.0);
d *= (double)effic; d *= effic / 100.0;
d /= 100.0;
return d; return d;
} }
@ -58,8 +57,8 @@ seagun(int effic, int guns)
d = 0.0; d = 0.0;
while (guns--) while (guns--)
d += 10.0 + (double)(random() % 6); d += 10.0 + random() % 6;
d *= (double)effic * 0.01; d *= effic * 0.01;
return d; return d;
} }
@ -70,8 +69,8 @@ landunitgun(int effic, int shots, int guns, int ammo, int shells)
shots = MIN(shots, guns); shots = MIN(shots, guns);
while (shots-- > 0) while (shots-- > 0)
d += 5.0 + (double)(random() % 6); d += 5.0 + random() % 6;
d *= (double)effic * 0.01; d *= effic * 0.01;
if (shells < ammo && ammo != 0) if (shells < ammo && ammo != 0)
d *= (double)shells / (double)ammo; d *= (double)shells / (double)ammo;
return d; return d;

View file

@ -176,8 +176,7 @@ lnd_take_casualty(int combat_mode, struct llist *llp, int cas)
eff_eq = 100; eff_eq = 100;
llp->land.lnd_effic = 0; llp->land.lnd_effic = 0;
} else { } else {
eff_eq = eff_eq = ldround(cas * 100.0 / llp->lcp->l_mil, 1);
ldround((((double)cas * 100.0) / (double)llp->lcp->l_mil), 1);
llp->land.lnd_effic -= eff_eq; llp->land.lnd_effic -= eff_eq;
lnd_submil(&llp->land, cas); lnd_submil(&llp->land, cas);
} }
@ -345,7 +344,7 @@ intelligence_report(int destination, struct lndstr *lp, int spy,
memset(buf1, 0, sizeof(buf1)); memset(buf1, 0, sizeof(buf1));
memset(buf2, 0, sizeof(buf2)); memset(buf2, 0, sizeof(buf2));
memset(buf3, 0, sizeof(buf3)); 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) if (destination == player->cnum)
pr("%s %s", mess, prland(lp)); pr("%s %s", mess, prland(lp));
else else
@ -353,8 +352,7 @@ intelligence_report(int destination, struct lndstr *lp, int spy,
estimate = lp->lnd_item[I_MILIT]; 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) if (destination == player->cnum)
pr(" (eff %d, mil %d", pr(" (eff %d, mil %d",
roundintby(lp->lnd_effic, 5), 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)); roundintby(lp->lnd_item[I_MILIT], 10));
estimate = lp->lnd_item[I_MILIT] * lp->lnd_effic / 100.0; 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; int t;
t = lp->lnd_tech - 20 + roll(40); t = lp->lnd_tech - 20 + roll(40);
t = MAX(t, 0); t = MAX(t, 0);
@ -524,7 +522,7 @@ lnd_sel(struct nstr_item *ni, struct emp_qelem *list)
llp = malloc(sizeof(struct llist)); llp = malloc(sizeof(struct llist));
llp->lcp = lcp; llp->lcp = lcp;
llp->land = land; llp->land = land;
llp->mobil = (double)land.lnd_mobil; llp->mobil = land.lnd_mobil;
emp_insque(&llp->queue, list); 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) if (land.lnd_x != allx || land.lnd_y != ally)
*togetherp = 0; *togetherp = 0;
if (land.lnd_mobil + 1 < (int)llp->mobil) { if (land.lnd_mobil + 1 < (int)llp->mobil) {
llp->mobil = (double)land.lnd_mobil; llp->mobil = land.lnd_mobil;
} }
if (llp->mobil < *minmobp) if (llp->mobil < *minmobp)
*minmobp = llp->mobil; *minmobp = llp->mobil;
@ -821,7 +819,7 @@ lnd_damage(struct emp_qelem *list, int totdam)
if (!totdam || !(count = lnd_count(list))) if (!totdam || !(count = lnd_count(list)))
return 0; return 0;
dam = ldround(((double)totdam / (double)count), 1); dam = ldround((double)totdam / count, 1);
for (qp = list->q_back; qp != list; qp = next) { for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back; next = qp->q_back;
llp = (struct llist *)qp; llp = (struct llist *)qp;
@ -975,9 +973,9 @@ lnd_hardtarget(struct lndstr *lp)
struct sctstr sect; struct sctstr sect;
getsect(lp->lnd_x, lp->lnd_y, &sect); getsect(lp->lnd_x, lp->lnd_y, &sect);
return (int)(((double)lp->lnd_effic / 100.0) * return (int)((lp->lnd_effic / 100.0) *
(10 + dchr[sect.sct_type].d_dstr * 2 + (10 + dchr[sect.sct_type].d_dstr * 2 + lp->lnd_spd / 2.0
(double)lp->lnd_spd / 2.0 - lp->lnd_vis)); - lp->lnd_vis));
} }
static int 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 bridge heads, bridges and highways have built-in highways bonus
because they are a 1, and this will discount that. */ 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) if (smobcost < 0.01)
smobcost = 0.01; smobcost = 0.01;

View 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, dam2 = ldround(landunitgun(lp->lnd_effic, lp->lnd_dam, gun,
lp->lnd_ammo, shell), 1); lp->lnd_ammo, shell), 1);
if (sect.sct_type == SCT_WATER) { if (sect.sct_type == SCT_WATER) {
double dam3 = (double)dam2; if (chance(lp->lnd_acc / 100.0))
if (chance(((double)lp->lnd_acc) / 100.0)) dam2 = ldround(dam2 / 2.0, 1);
dam2 = ldround((dam3 / 2.0), 1);
} }
dam += dam2; dam += dam2;
if (sect.sct_type == SCT_WATER) 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)) if (!(mcp->m_flags & M_DCH) && !(mcp->m_flags & M_SUBT))
continue; continue;
vrange = techfact(sp->shp_tech, mcp->m_vrnge); vrange = techfact(sp->shp_tech, mcp->m_vrnge);
vrange *= (double)sp->shp_effic / 200.0; vrange *= sp->shp_effic / 200.0;
if (md > vrange) if (md > vrange)
continue; continue;
/* can't look all the time */ /* can't look all the time */
@ -900,7 +899,7 @@ show_mission(int type, struct nstr_item *np)
pr(" %4d", plus); pr(" %4d", plus);
} else if (gp->mission == MI_ESCORT) { } else if (gp->mission == MI_ESCORT) {
pr(" "); pr(" ");
pr(" %4d", (int)(item.plane.pln_range / 2.0)); pr(" %4d", item.plane.pln_range / 2);
} else } else
pr(" "); pr(" ");
if (gp->mission) 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); for (qp = interceptors.q_forw; qp != (&interceptors);
qp = qp->q_forw) qp = qp->q_forw)
tcount++; tcount++;
tcount -= (count * 2); tcount -= count * 2;
/* Just in case there are more incoming than we have */ /* Just in case there are more incoming than we have */
if (tcount < 0) if (tcount < 0)
tcount = 0; tcount = 0;

View file

@ -63,7 +63,7 @@ move_ground(struct sctstr *start, struct sctstr *end,
double sect_mcost; double sect_mcost;
double total_mcost; double total_mcost;
double mv_cost; double mv_cost;
double mobility = (double)start->sct_mobil; double mobility = start->sct_mobil;
int dir; int dir;
int intcost; int intcost;
int takedam = *dam; int takedam = *dam;

View 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 */ if (!(pcp->pl_flags & P_SWEEP)) /* if it isn't an sweep plane */
continue; continue;
if (chance(((double)(100 - pp->pln_acc)) / 100.0)) { if (chance((100.0 - pp->pln_acc) / 100.0)) {
pr("Sweep! in %s\n", pr("Sweep! in %s\n",
xyas(sect.sct_x, sect.sct_y, pp->pln_own)); xyas(sect.sct_x, sect.sct_y, pp->pln_own));
mines_there--; mines_there--;

View file

@ -208,7 +208,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
while (nxtitem(&ni, &land)) { while (nxtitem(&ni, &land)) {
if (land.lnd_own == 0) if (land.lnd_own == 0)
continue; continue;
if (!chance((double)land.lnd_effic / 20.0)) if (!chance(land.lnd_effic / 20.0))
continue; continue;
if (++crackle == 100) if (++crackle == 100)
crackle = 0; crackle = 0;
@ -326,7 +326,7 @@ satdisp(struct sctstr *sp, int acc, int showstuff)
while (nxtitem(&ni, &land)) { while (nxtitem(&ni, &land)) {
if (land.lnd_own == 0) if (land.lnd_own == 0)
continue; continue;
if (!chance((double)land.lnd_effic / 20.0)) if (!chance(land.lnd_effic / 20.0))
continue; continue;
if (first) { if (first) {

View file

@ -107,7 +107,7 @@ shp_sel(struct nstr_item *ni, struct emp_qelem *list)
mlp = malloc(sizeof(struct mlist)); mlp = malloc(sizeof(struct mlist));
mlp->mcp = mcp; mlp->mcp = mcp;
mlp->ship = ship; mlp->ship = ship;
mlp->mobil = (double)ship.shp_mobil; mlp->mobil = ship.shp_mobil;
emp_insque(&mlp->queue, list); 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) if (ship.shp_x != allx || ship.shp_y != ally)
*togetherp = 0; *togetherp = 0;
if (ship.shp_mobil + 1 < (int)mlp->mobil) { if (ship.shp_mobil + 1 < (int)mlp->mobil) {
mlp->mobil = (double)ship.shp_mobil; mlp->mobil = ship.shp_mobil;
} }
if (mlp->mobil < *minmobp) if (mlp->mobil < *minmobp)
*minmobp = mlp->mobil; *minmobp = mlp->mobil;
@ -446,7 +446,7 @@ shp_damage(struct emp_qelem *list, int totdam, int wantflags,
if (!totdam if (!totdam
|| !(count = shp_count(list, wantflags, nowantflags, x, y))) || !(count = shp_count(list, wantflags, nowantflags, x, y)))
return 0; return 0;
dam = ldround(((double)totdam / (double)count), 1); dam = ldround((double)totdam / count, 1);
for (qp = list->q_back; qp != list; qp = next) { for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back; next = qp->q_back;
mlp = (struct mlist *)qp; mlp = (struct mlist *)qp;
@ -749,11 +749,11 @@ shp_hardtarget(struct shpstr *sp)
vis = sp->shp_visib; vis = sp->shp_visib;
getsect(sp->shp_x, sp->shp_y, &sect); 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) if (mcp->m_flags & M_SUB)
vis *= 4; vis *= 4;
return (int)(((double)sp->shp_effic / 100.0) * return (int)((sp->shp_effic / 100.0) *
(20 + (double)sp->shp_speed * onsea / 2.0 - vis)); (20 + sp->shp_speed * onsea / 2.0 - vis));
} }
static int static int
@ -955,9 +955,8 @@ shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget)
/* now calculate the odds */ /* now calculate the odds */
gun = MIN(ship.shp_item[I_GUN], ship.shp_glim); gun = MIN(ship.shp_item[I_GUN], ship.shp_glim);
eff = (double)ship.shp_effic / 100.0; eff = ship.shp_effic / 100.0;
teff = teff = ship.shp_tech / (ship.shp_tech + 200.0);
(((double)ship.shp_tech) / (((double)ship.shp_tech) + 200.0));
/* raise 4.5 for better interception -KHS */ /* raise 4.5 for better interception -KHS */
hitchance = (int)(gun * eff * teff * 4.5) - hardtarget; hitchance = (int)(gun * eff * teff * 4.5) - hardtarget;
if (hitchance < 0) if (hitchance < 0)
@ -1032,7 +1031,7 @@ shp_missdef(struct shpstr *sp, natid victim)
mlp = malloc(sizeof(struct mlist)); mlp = malloc(sizeof(struct mlist));
mlp->mcp = &mchr[(int)sp->shp_type]; mlp->mcp = &mchr[(int)sp->shp_type];
mlp->ship = *sp; mlp->ship = *sp;
mlp->mobil = (double)sp->shp_mobil; mlp->mobil = sp->shp_mobil;
emp_insque(&mlp->queue, &list); emp_insque(&mlp->queue, &list);
sprintf(buf, "%s", prship(&mlp->ship)); sprintf(buf, "%s", prship(&mlp->ship));

View file

@ -111,8 +111,8 @@ resupply_commod(struct lndstr *lp, i_type type)
} }
if (opt_FUEL && type == I_PETROL) { if (opt_FUEL && type == I_PETROL) {
int fuel_needed = (lp->lnd_fuelu * (((float)etu_per_update int fuel_needed = lp->lnd_fuelu
* land_mob_scale)) / 10.0); * ((float)etu_per_update * land_mob_scale) / 10.0;
while ((lp->lnd_fuel < fuel_needed) && lp->lnd_item[I_PETROL]) { while ((lp->lnd_fuel < fuel_needed) && lp->lnd_item[I_PETROL]) {
lp->lnd_fuel += 10; 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]; packing = ip->i_pkg[dp->d_pkg];
if (packing > 1 && sect.sct_effic < 60) if (packing > 1 && sect.sct_effic < 60)
packing = 1; packing = 1;
weight = ((double)ip->i_lbs / (double)packing); weight = (double)ip->i_lbs / packing;
mobcost = move_cost * weight; mobcost = move_cost * weight;
if (mobcost > 0) if (mobcost > 0)
can_move = ((double)sect.sct_mobil / mobcost); can_move = (double)sect.sct_mobil / mobcost;
else else
can_move = sect.sct_item[type] - minimum; can_move = sect.sct_item[type] - minimum;
if (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]; packing = ip->i_pkg[dp->d_pkg];
if (packing > 1 && sect.sct_effic < 60) if (packing > 1 && sect.sct_effic < 60)
packing = 1; packing = 1;
weight = ((double)ip->i_lbs / (double)packing); weight = (double)ip->i_lbs / packing;
mobcost = move_cost * weight; mobcost = move_cost * weight;
if (mobcost > 0) if (mobcost > 0)
can_move = ((double)sect.sct_mobil / mobcost); can_move = (double)sect.sct_mobil / mobcost;
else else
can_move = ship.shp_item[type] - minimum; can_move = ship.shp_item[type] - minimum;
if (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); min = get_minimum(&land, type);
ip = &ichr[type]; ip = &ichr[type];
weight = ((double)ip->i_lbs); weight = ip->i_lbs;
mobcost = move_cost * weight; mobcost = move_cost * weight;
if (mobcost > 0) if (mobcost > 0)
can_move = ((double)land.lnd_mobil / mobcost); can_move = (double)land.lnd_mobil / mobcost;
else else
can_move = land.lnd_item[type] - min; can_move = land.lnd_item[type] - min;
if (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: case I_FOOD:
if (opt_NOFOOD) if (opt_NOFOOD)
return 0; /* no food reqd, get out */ return 0; /* no food reqd, get out */
want = (((double)etu_per_update * eatrate) * want = (double)etu_per_update * eatrate * lp->lnd_item[I_MILIT] + 1;
(double)lp->lnd_item[I_MILIT]) + 1;
break; break;
case I_SHELL: case I_SHELL:
want = lp->lnd_ammo; 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 * return the amount of pet we'd need to get to
* enough fuel for 1 update * enough fuel for 1 update
*
*/ */
case I_PETROL: case I_PETROL:
if (opt_FUEL == 0) if (opt_FUEL == 0)
return 0; return 0;
want = (lp->lnd_fuelu * (((float)etu_per_update * want = lp->lnd_fuelu * ((float)etu_per_update * land_mob_scale)
land_mob_scale)) / 10.0); / 10.0;
want -= lp->lnd_fuel; want -= lp->lnd_fuel;
if (want > 0) { if (want > 0) {
double d; want = want / 10;
d = (double)want / 10.0;
want = (int)d;
if (want == 0) if (want == 0)
want++; want++;
} }
@ -518,7 +514,7 @@ has_supply(struct lndstr *lp)
fuel = lp->lnd_fuel; fuel = lp->lnd_fuel;
if (fuel < fuel_needed) { if (fuel < fuel_needed) {
petrol_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]; petrol = keeppetrol = lp->lnd_item[I_PETROL];
if (petrol < petrol_needed) { if (petrol < petrol_needed) {
lp->lnd_item[I_PETROL] = 0; lp->lnd_item[I_PETROL] = 0;
@ -582,7 +578,7 @@ use_supply(struct lndstr *lp)
if (fuel < fuel_needed) { if (fuel < fuel_needed) {
petrol_needed = petrol_needed =
ldround(((double)(fuel_needed - fuel) / 10.0), 1); ldround((fuel_needed - fuel) / 10.0, 1);
petrol = lp->lnd_item[I_PETROL]; petrol = lp->lnd_item[I_PETROL];
} }

View file

@ -99,7 +99,7 @@ do_feed(struct sctstr *sp, struct natstr *np, short *vec,
supply ships in port, or supply units */ supply ships in port, or supply units */
int needed; int needed;
needed = ldround((double)(1 + etu * people * eatrate), 1); needed = ldround(1.0 + etu * people * eatrate, 1);
/* Now, find some food */ /* Now, find some food */
vec[I_FOOD] = supply_commod(sp->sct_own, vec[I_FOOD] = supply_commod(sp->sct_own,

View file

@ -306,26 +306,26 @@ do_mob_ship(struct shpstr *sp, int etus)
/* opt_FUEL in force */ /* opt_FUEL in force */
if (mchr[(int)sp->shp_type].m_fuelu == 0) { 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) if (value > ship_mob_max)
value = ship_mob_max; value = ship_mob_max;
sp->shp_mobil = (signed char)value; sp->shp_mobil = (signed char)value;
} else { } else {
can_add = ship_mob_max - sp->shp_mobil; can_add = ship_mob_max - sp->shp_mobil;
if (can_add > ((float)etus * ship_mob_scale)) if (can_add > (float)etus * ship_mob_scale)
can_add = ((float)etus * ship_mob_scale); can_add = (float)etus * ship_mob_scale;
have_fuel_for = ldround((((double)sp->shp_fuel / have_fuel_for = ldround(((double)sp->shp_fuel /
(double)mchr[(int)sp->shp_type].m_fuelu) (double)mchr[(int)sp->shp_type].m_fuelu)
* (double)fuel_mult), 1); * (double)fuel_mult, 1);
if (can_add > have_fuel_for) { if (can_add > have_fuel_for) {
int need; int need;
need = can_add - have_fuel_for; need = can_add - have_fuel_for;
d = (double)need; d = need;
d *= (double)mchr[(int)sp->shp_type].m_fuelu; d *= mchr[(int)sp->shp_type].m_fuelu;
d /= (double)fuel_mult; d /= fuel_mult;
d /= 5.0; d /= 5.0;
if ((d - (int)d) > 0.0) if (d - (int)d > 0.0)
d++; d++;
need = (int)d; need = (int)d;
newfuel = supply_commod(sp->shp_own, sp->shp_x, sp->shp_y, 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; sp->shp_fuel += newfuel * 5;
} }
have_fuel_for = ldround((((double)sp->shp_fuel / have_fuel_for = ldround(((double)sp->shp_fuel /
(double)mchr[(int)sp->shp_type].m_fuelu) (double)mchr[(int)sp->shp_type].m_fuelu)
* (double)fuel_mult), 1); * (double)fuel_mult, 1);
if (can_add > have_fuel_for) { if (can_add > have_fuel_for) {
int need; int need;
need = can_add - have_fuel_for; need = can_add - have_fuel_for;
d = (double)need; d = need;
d *= (double)mchr[(int)sp->shp_type].m_fuelu; d *= mchr[(int)sp->shp_type].m_fuelu;
d /= (double)fuel_mult; d /= fuel_mult;
d /= 50.0; d /= 50.0;
if ((d - (int)d) > 0.0) if (d - (int)d > 0.0)
d++; d++;
need = (int)d; need = (int)d;
newfuel = supply_commod(sp->shp_own, sp->shp_x, sp->shp_y, 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; sp->shp_fuel += newfuel * 50;
} }
have_fuel_for = ldround((((double)sp->shp_fuel / have_fuel_for = ldround(((double)sp->shp_fuel /
(double)mchr[(int)sp->shp_type].m_fuelu) (double)mchr[(int)sp->shp_type].m_fuelu)
* (double)fuel_mult), 1); * (double)fuel_mult, 1);
if (can_add > have_fuel_for) if (can_add > have_fuel_for)
total_add = have_fuel_for; total_add = have_fuel_for;
else else
total_add = can_add; total_add = can_add;
d = (double)total_add; d = total_add;
d *= (double)mchr[(int)sp->shp_type].m_fuelu; d *= mchr[(int)sp->shp_type].m_fuelu;
d /= (double)fuel_mult; d /= fuel_mult;
sp->shp_fuel -= ldround(d, 1); sp->shp_fuel -= ldround(d, 1);
sp->shp_fuel = MIN(sp->shp_fuel, mchr[(int)sp->shp_type].m_fuelc); sp->shp_fuel = MIN(sp->shp_fuel, mchr[(int)sp->shp_type].m_fuelc);
sp->shp_mobil += total_add; 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; can_add = land_mob_max - lp->lnd_mobil;
if (can_add > ((float)etus * land_mob_scale)) if (can_add > (float)etus * land_mob_scale)
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; have_fuel_for = (lp->lnd_fuel / lp->lnd_fuelu) * fuel_mult;
if (can_add > have_fuel_for) { if (can_add > have_fuel_for) {
int need; int need;
need = can_add - have_fuel_for; need = can_add - have_fuel_for;
d = (double)need; d = need;
d *= (double)lp->lnd_fuelu; d *= lp->lnd_fuelu;
d /= (double)fuel_mult; d /= fuel_mult;
d /= 5.0; d /= 5.0;
if ((d - (int)d) > 0.0) if (d - (int)d > 0.0)
d++; d++;
need = (int)d; need = (int)d;
newfuel = supply_commod(lp->lnd_own, lp->lnd_x, lp->lnd_y, 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) { if (can_add > have_fuel_for) {
int need; int need;
need = can_add - have_fuel_for; need = can_add - have_fuel_for;
d = (double)need; d = need;
d *= (double)lp->lnd_fuelu; d *= lp->lnd_fuelu;
d /= (double)fuel_mult; d /= fuel_mult;
d /= 50.0; d /= 50.0;
if ((d - (int)d) > 0.0) if (d - (int)d > 0.0)
d++; d++;
need = (int)d; need = (int)d;
newfuel = supply_commod(lp->lnd_own, lp->lnd_x, lp->lnd_y, 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; total_add = have_fuel_for;
} else } else
total_add = can_add; total_add = can_add;
d = (double)total_add; d = total_add;
d *= (double)lp->lnd_fuelu; d *= lp->lnd_fuelu;
d /= (double)fuel_mult; d /= fuel_mult;
lp->lnd_fuel -= ldround(d, 1); lp->lnd_fuel -= ldround(d, 1);
lp->lnd_fuel = MIN(lp->lnd_fuel, lp->lnd_fuelc); lp->lnd_fuel = MIN(lp->lnd_fuel, lp->lnd_fuelc);
lp->lnd_mobil += total_add; lp->lnd_mobil += total_add;

View file

@ -262,7 +262,7 @@ nav_ship(struct shpstr *sp)
mlp = malloc(sizeof(struct mlist)); mlp = malloc(sizeof(struct mlist));
mlp->mcp = mchr + sp->shp_type; mlp->mcp = mchr + sp->shp_type;
mlp->ship = *sp; mlp->ship = *sp;
mlp->mobil = (double)sp->shp_mobil; mlp->mobil = sp->shp_mobil;
emp_insque(&mlp->queue, &ship_list); emp_insque(&mlp->queue, &ship_list);
quit = 1; /* setup loop, we want to check it 1 time. */ quit = 1; /* setup loop, we want to check it 1 time. */

View file

@ -212,10 +212,10 @@ auto_fuel_ship(struct shpstr *sp)
if (opt_FUEL == 0) if (opt_FUEL == 0)
return; return;
getship(sp->shp_uid, sp); /* refresh */ getship(sp->shp_uid, sp); /* refresh */
/* fill with petro */ /* fill with petrol */
maxfuel = mchr[(int)sp->shp_type].m_fuelc; maxfuel = mchr[(int)sp->shp_type].m_fuelc;
d = (double)maxfuel / 5.0; d = maxfuel / 5.0;
if ((d - (int)d > 0.0)) if (d - (int)d > 0.0)
d++; d++;
need = (int)d; need = (int)d;
@ -233,8 +233,8 @@ auto_fuel_ship(struct shpstr *sp)
} }
add_fuel = 0; add_fuel = 0;
/* fill with oil */ /* fill with oil */
d = (double)(maxfuel - totalfuel) / 50.0; d = (maxfuel - totalfuel) / 50.0;
if ((d - (int)d > 0.0)) if (d - (int)d > 0.0)
d++; d++;
need = (int)d; need = (int)d;

View file

@ -170,7 +170,7 @@ plague_people(struct natstr *np, short *vec,
plg_num = 100.0 * etus; plg_num = 100.0 * etus;
plg_denom = (np->nat_level[NAT_RLEV] + 100.0) * plg_denom = (np->nat_level[NAT_RLEV] + 100.0) *
(*ptime + etus + 1.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) if (pct_left < 0.2)
pct_left = 0.2; pct_left = 0.2;
vec[I_CIVIL] = vec[I_CIVIL] * pct_left; vec[I_CIVIL] = vec[I_CIVIL] * pct_left;

View file

@ -95,7 +95,7 @@ populace(struct natstr *np, struct sctstr *sp, int etu)
if (n < 0) if (n < 0)
n = 0; n = 0;
sp->sct_work = n; sp->sct_work = n;
if (chance((double)work_red / 1000.0)) { if (chance(work_red / 1000.0)) {
/* /*
* small chance of rebellion... * small chance of rebellion...
* if work_red is (max) 67, * if work_red is (max) 67,

View file

@ -258,7 +258,7 @@ decay_fallout(struct sctstr *sp, int etus)
if (etus > 24) if (etus > 24)
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); (double)etus * (double)sp->sct_fallout);
sp->sct_fallout = decay < sp->sct_fallout ? sp->sct_fallout - decay : 0; sp->sct_fallout = decay < sp->sct_fallout ? sp->sct_fallout - decay : 0;

View file

@ -171,8 +171,8 @@ upd_ship(struct shpstr *sp, int etus,
sp->shp_item[I_MILIT], sp->shp_item[I_MILIT],
sp->shp_item[I_UW], sp->shp_item[I_UW],
ITEM_MAX) ITEM_MAX)
* (double)sp->shp_effic / 100.0 * sp->shp_effic / 100.0
* (double)sectp->sct_oil / 100.0 * sectp->sct_oil / 100.0
* prod_eff(product, sp->shp_tech)); * prod_eff(product, sp->shp_tech));
max_oil = mp->m_item[I_OIL]; max_oil = mp->m_item[I_OIL];
if (sp->shp_item[I_OIL] + oil_gained > max_oil) if (sp->shp_item[I_OIL] + oil_gained > max_oil)

View file

@ -87,7 +87,7 @@ shutdown_sequence(void *unused)
header, shutdown_pending); header, shutdown_pending);
} else if (shutdown_pending % 60 == 0) { } else if (shutdown_pending % 60 == 0) {
pr_wall("%sThe server will be shutting down %d hours from now.\n", 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); empth_sleep(now + 60);