(ship_bomb, deli, do_demo, fuel, grin, look_ship)

(ltend, multifire, quite_bigdef, mine, landmine)
(do_loan, prod, printdiff, sell, sona, stre)
(tend, fire_dchrg, vers, work, ac_planedamage)
(ac_shipflak, ask_off, get_mine_dsupport, att_fight)
(ask_move_in_off, detonate, sd, land_gun)
(land_unitgun, lnd_fort_interdiction, lnd_fortify)
(perform_mission, pln_mine, pln_mobcost)
(retreat_ship1, retreat_land1, shp_sweep)
(shp_fort_interdiction, shp_missle_defense)
(new_work, growfood, upd_land, land_repair)
(get_materials, do_mob_ship, do_mob_land)
(load_it, unload_it, prod_plane, produce)
(guerrilla, upd_buildeff, spread_fallout)
(upd_ship, ship_repair, min, dmin, MIN):
Remove min() and dmin() functions and replace
with a MIN macro in misc.h.  Remove local MIN
macros and use the new one in misc.h.  This
change removes the need for the special
case for _WIN32.

(fuel, look_ship, multifire, mission, sona)
(plane_sona, ef_open, player_accept, player_main)
(ac_dog, att_get_combat, calc_mobcost)
(ask_move_in_off, intelligence_report)
(build_mission_list_type, perform_mission)
(show_mission, use_supply, dodistribute)
(allocate_memory, max, dmax, MAX):
Remove max() and dmax() functions and replace
with a MAX macro in misc.h.  Remove local MAX
macros and use the new one in misc.h.  This
change removes the need for the special
case for _WIN32.
This commit is contained in:
Ron Koenderink 2006-01-12 14:23:55 +00:00
parent b89de57d51
commit 04a8b84592
48 changed files with 152 additions and 251 deletions

View file

@ -542,7 +542,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
continue;
shell = gun = 0;
gun = min(ship.shp_item[I_GUN], ship.shp_glim);
gun = MIN(ship.shp_item[I_GUN], ship.shp_glim);
if (gun > 0) {
shell = ship.shp_item[I_SHELL];
if (shell <= 0)

View file

@ -105,7 +105,7 @@ deli(void)
if (!check_sect_ok(&sect))
continue;
thresh = min(thresh, ITEM_MAX) & ~7;
thresh = MIN(thresh, ITEM_MAX) & ~7;
del = thresh | dir;
sect.sct_del[ich->i_vtype] = del;
putsect(&sect);

View file

@ -101,7 +101,7 @@ do_demo(struct natstr *natp, struct nstr_sect nstr, int number, s_char *p,
if (sect.sct_own != sect.sct_oldown)
continue;
civ = sect.sct_item[I_CIVIL];
deltamil = number < 0 ? mil + number : min(mil, number);
deltamil = number < 0 ? mil + number : MIN(mil, number);
if (deltamil <= 0)
continue;
if (deltamil > ITEM_MAX - civ)

View file

@ -174,8 +174,8 @@ fuel(void)
xyas(sect.sct_x, sect.sct_y, player->cnum));
continue;
}
move_amt = min(tot_fuel, fuel_amt);
move_amt = min(move_amt, max_amt);
move_amt = MIN(tot_fuel, fuel_amt);
move_amt = MIN(move_amt, max_amt);
if (move_amt == 0)
continue;
@ -187,21 +187,21 @@ fuel(void)
extra = ((float)move_amt / 5.0) - (move_amt / 5);
if (extra > 0.0)
sect.sct_item[I_PETROL]
= max((pet_amt - move_amt / 5) - 1, 0);
= MAX((pet_amt - move_amt / 5) - 1, 0);
else
sect.sct_item[I_PETROL]
= max((pet_amt - move_amt / 5), 0);
= MAX((pet_amt - move_amt / 5), 0);
} else {
sect.sct_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = ((float)move_amt / 50.0) - (move_amt / 50);
sect.sct_item[I_OIL] = max(oil_amt - move_amt / 50, 0);
sect.sct_item[I_OIL] = MAX(oil_amt - move_amt / 50, 0);
if (extra > 0.0)
sect.sct_item[I_OIL]
= max((oil_amt - move_amt / 50) - 1, 0);
= MAX((oil_amt - move_amt / 50) - 1, 0);
else
sect.sct_item[I_OIL]
= max((oil_amt - move_amt / 50), 0);
= MAX((oil_amt - move_amt / 50), 0);
}
/* load plague */
@ -250,8 +250,8 @@ fuel(void)
continue;
}
tot_fuel = oil_amt * 50 + pet_amt * 5;
move_amt = min(tot_fuel, fuel_amt);
move_amt = min(move_amt, max_amt);
move_amt = MIN(tot_fuel, fuel_amt);
move_amt = MIN(move_amt, max_amt);
if (move_amt == 0)
continue;
@ -263,22 +263,22 @@ fuel(void)
extra = ((float)move_amt / 5.0) - (move_amt / 5);
if (extra > 0.0)
item2.ship.shp_item[I_PETROL]
= max((pet_amt - move_amt / 5) - 1, 0);
= MAX((pet_amt - move_amt / 5) - 1, 0);
else
item2.ship.shp_item[I_PETROL]
= max((pet_amt - move_amt / 5), 0);
= MAX((pet_amt - move_amt / 5), 0);
} else {
item2.ship.shp_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = ((float)move_amt / 50.0) - (move_amt / 50);
item2.ship.shp_item[I_OIL]
= max(oil_amt - (move_amt / 50), 0);
= MAX(oil_amt - (move_amt / 50), 0);
if (extra > 0.0)
item2.ship.shp_item[I_OIL]
= max((oil_amt - move_amt / 50) - 1, 0);
= MAX((oil_amt - move_amt / 50) - 1, 0);
else
item2.ship.shp_item[I_OIL]
= max((oil_amt - move_amt / 50), 0);
= MAX((oil_amt - move_amt / 50), 0);
}
/* load plague */
@ -335,8 +335,8 @@ fuel(void)
xyas(sect.sct_x, sect.sct_y, player->cnum));
continue;
}
move_amt = min(tot_fuel, fuel_amt);
move_amt = min(move_amt, max_amt);
move_amt = MIN(tot_fuel, fuel_amt);
move_amt = MIN(move_amt, max_amt);
if (move_amt == 0)
continue;
@ -348,21 +348,21 @@ fuel(void)
extra = ((float)move_amt / 5.0) - (move_amt / 5);
if (extra > 0.0)
sect.sct_item[I_PETROL]
= max((pet_amt - move_amt / 5) - 1, 0);
= MAX((pet_amt - move_amt / 5) - 1, 0);
else
sect.sct_item[I_PETROL]
= max((pet_amt - move_amt / 5), 0);
= MAX((pet_amt - move_amt / 5), 0);
} else {
sect.sct_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = ((float)move_amt / 50.0) - (move_amt / 50);
sect.sct_item[I_OIL] = max(oil_amt - move_amt / 50, 0);
sect.sct_item[I_OIL] = MAX(oil_amt - move_amt / 50, 0);
if (extra > 0.0)
sect.sct_item[I_OIL]
= max((oil_amt - move_amt / 50) - 1, 0);
= MAX((oil_amt - move_amt / 50) - 1, 0);
else
sect.sct_item[I_OIL]
= max((oil_amt - move_amt / 50), 0);
= MAX((oil_amt - move_amt / 50), 0);
}
/* load plague */
@ -412,8 +412,8 @@ fuel(void)
continue;
}
tot_fuel = oil_amt * 50 + pet_amt * 5;
move_amt = min(tot_fuel, fuel_amt);
move_amt = min(move_amt, max_amt);
move_amt = MIN(tot_fuel, fuel_amt);
move_amt = MIN(move_amt, max_amt);
if (move_amt == 0)
continue;
@ -425,22 +425,22 @@ fuel(void)
extra = ((float)move_amt / 5.0) - (move_amt / 5);
if (extra > 0.0)
item2.land.lnd_item[I_PETROL]
= max((pet_amt - move_amt / 5) - 1, 0);
= MAX((pet_amt - move_amt / 5) - 1, 0);
else
item2.land.lnd_item[I_PETROL]
= max((pet_amt - move_amt / 5), 0);
= MAX((pet_amt - move_amt / 5), 0);
} else {
item2.land.lnd_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = ((float)move_amt / 50.0) - (move_amt / 50);
item2.land.lnd_item[I_OIL]
= max(oil_amt - move_amt / 50, 0);
= MAX(oil_amt - move_amt / 50, 0);
if (extra > 0.0)
item2.land.lnd_item[I_OIL]
= max((oil_amt - move_amt / 50) - 1, 0);
= MAX((oil_amt - move_amt / 50) - 1, 0);
else
item2.land.lnd_item[I_OIL]
= max((oil_amt - move_amt / 50), 0);
= MAX((oil_amt - move_amt / 50), 0);
}
/* load plague */

View file

@ -82,7 +82,7 @@ grin(void)
if (CANT_HAPPEN(pchr[P_BAR].p_ctype[i] <= I_NONE ||
pchr[P_BAR].p_ctype[i] > I_MAX))
continue;
n = min(n,
n = MIN(n,
(double)(ITEM_MAX - sect.sct_item[pchr[P_BAR].p_ctype[i]])
/ (pchr[P_BAR].p_camt[i] * grind_eff));
}

View file

@ -131,7 +131,7 @@ look_ship(struct shpstr *lookship)
range = range * (lookship->shp_effic / 100.0);
smcp = &mchr[(int)lookship->shp_type];
if (smcp->m_flags & M_SUB)
range = min(range, 1);
range = MIN(range, 1);
for (i = 0; NULL != (sp = getshipp(i)); i++) {
if (sp->shp_own == player->cnum || sp->shp_own == 0)
continue;
@ -146,7 +146,7 @@ look_ship(struct shpstr *lookship)
vrange = (int)(sp->shp_visib * range / 20.0);
getsect(sp->shp_x, sp->shp_y, &sect);
if (sect.sct_type != SCT_WATER)
vrange = max(1, vrange);
vrange = MAX(1, vrange);
if (dist > vrange)
continue;
if (smcp->m_flags & M_SUB) {

View file

@ -124,8 +124,8 @@ ltend(void)
amt = 0;
/* take from target and give to tender */
transfer = min(ontarget, -amt);
transfer = min(maxtender - ontender, transfer);
transfer = MIN(ontarget, -amt);
transfer = MIN(maxtender - ontender, transfer);
if (transfer == 0)
continue;
target.lnd_item[ip->i_vtype] = ontarget - transfer;
@ -133,8 +133,8 @@ ltend(void)
total += transfer;
} else {
/* give to target from tender */
transfer = min(ontender, amt);
transfer = min(transfer, maxtarget - ontarget);
transfer = MIN(ontender, amt);
transfer = MIN(transfer, maxtarget - ontarget);
if (transfer == 0)
continue;
target.lnd_item[ip->i_vtype] = ontarget + transfer;

View file

@ -208,7 +208,7 @@ multifire(void)
continue;
}
gun = item.ship.shp_item[I_GUN];
gun = min(gun, item.ship.shp_glim);
gun = MIN(gun, item.ship.shp_glim);
if (item.ship.shp_frnge == 0) {
pr("Ships %d cannot fire guns!\n", item.ship.shp_uid);
continue;
@ -327,7 +327,7 @@ multifire(void)
continue;
}
gun = fship.shp_item[I_GUN];
gun = min(gun, fship.shp_glim);
gun = MIN(gun, fship.shp_glim);
if (fship.shp_frnge == 0 || gun == 0) {
pr("Insufficient arms.\n");
continue;
@ -358,16 +358,16 @@ multifire(void)
continue;
}
}
gun = min(gun, shell * 2);
gun = min(gun, mil / 2);
gun = max(gun, 1);
gun = MIN(gun, shell * 2);
gun = MIN(gun, mil / 2);
gun = MAX(gun, 1);
shots = gun;
guneff = seagun(fship.shp_effic, shots);
dam = (int)guneff;
shell -= ldround(((double)shots) / 2.0, 1);
fship.shp_item[I_SHELL] = shell;
if (opt_NOMOBCOST == 0)
fship.shp_mobil = max(fship.shp_mobil - 15, -100);
fship.shp_mobil = MAX(fship.shp_mobil - 15, -100);
putship(fship.shp_uid, &fship);
} else if (attacker == targ_unit) {
if (fland.lnd_own != player->cnum) {
@ -840,8 +840,8 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown,
/* only need 1 shell, so don't check that */
if (shell < 1)
continue;
nshot = min(gun, ship.shp_item[I_MILIT]);
nshot = min(nshot, ship.shp_glim);
nshot = MIN(gun, ship.shp_item[I_MILIT]);
nshot = MIN(nshot, ship.shp_glim);
if (nshot == 0)
continue;
(*nfiring)++;

View file

@ -72,13 +72,13 @@ mine(void)
continue;
if ((shells = ship.shp_item[I_SHELL]) == 0)
continue;
mines_avail = min(shells, mines);
mines_avail = MIN(shells, mines);
if (getsect(ship.shp_x, ship.shp_y, &sect) == 0 ||
(sect.sct_type != SCT_WATER && sect.sct_type != SCT_BSPAN)) {
pr("You can't lay mines there!!\n");
continue;
}
sect.sct_mines = min(sect.sct_mines + mines_avail, MINES_MAX);
sect.sct_mines = MIN(sect.sct_mines + mines_avail, MINES_MAX);
ship.shp_item[I_SHELL] = shells - mines_avail;
putsect(&sect);
ship.shp_mission = 0;
@ -123,7 +123,7 @@ landmine(void)
putland(land.lnd_uid, &land);
if (!(shells = land.lnd_item[I_SHELL]))
continue;
shells = min(shells, land.lnd_mobil);
shells = MIN(shells, land.lnd_mobil);
if (!getsect(land.lnd_x, land.lnd_y, &sect) ||
sect.sct_type == SCT_WATER || sect.sct_type == SCT_BSPAN) {
pr("You can't lay mines there!!\n");
@ -141,7 +141,7 @@ landmine(void)
land.lnd_mission = 0;
total_mines_laid = 0;
while (shells > 0 && total_mines_laid < mines_wanted) {
mines_laid = min(shells, mines_wanted - total_mines_laid);
mines_laid = MIN(shells, mines_wanted - total_mines_laid);
land.lnd_item[I_SHELL] = shells - mines_laid;
land.lnd_mobil -= mines_laid;
putland(land.lnd_uid, &land);
@ -149,10 +149,10 @@ landmine(void)
putland(land.lnd_uid, &land);
total_mines_laid += mines_laid;
shells = land.lnd_item[I_SHELL];
shells = min(shells, land.lnd_mobil);
shells = MIN(shells, land.lnd_mobil);
}
getsect(sect.sct_x, sect.sct_y, &sect);
sect.sct_mines = min(sect.sct_mines + total_mines_laid, MINES_MAX);
sect.sct_mines = MIN(sect.sct_mines + total_mines_laid, MINES_MAX);
putsect(&sect);
if (total_mines_laid == mines_wanted) {
pr("%s laid a total of %d mines in %s",

View file

@ -188,8 +188,8 @@ mission(void)
desired_radius = 9999;
}
size = max(sizeof(struct lndstr), sizeof(struct plnstr));
size = max(size, sizeof(struct shpstr));
size = MAX(sizeof(struct lndstr), sizeof(struct plnstr));
size = MAX(size, sizeof(struct shpstr));
block = malloc(size);
switch (type) {
case EF_SHIP:

View file

@ -231,8 +231,8 @@ do_loan(void)
loan.l_loner = player->cnum;
loan.l_lonee = recipient;
loan.l_status = LS_PROPOSED;
loan.l_irate = min(irate, 127);
loan.l_ldur = min(dur, 127);
loan.l_irate = MIN(irate, 127);
loan.l_ldur = MIN(dur, 127);
loan.l_amtpaid = 0;
loan.l_amtdue = amt;
(void)time(&loan.l_lastpay);

View file

@ -147,7 +147,7 @@ prod(void)
total_work(sect.sct_work, etu_per_update,
civs, sect.sct_item[I_MILIT],
uws, maxpop));
bwork = min(work / 2, bwork);
bwork = MIN(work / 2, bwork);
}
twork = 100 - eff;
if (twork > bwork) {
@ -215,7 +215,7 @@ prod(void)
continue;
if (CANT_HAPPEN(it <= I_NONE || I_MAX < it))
continue;
used = min(used, sect.sct_item[it] / pp->p_camt[j]);
used = MIN(used, sect.sct_item[it] / pp->p_camt[j]);
unit_work += pp->p_camt[j];
}
if (unit_work == 0)
@ -229,17 +229,17 @@ prod(void)
if (*resource * 100 < pp->p_nrdep * max)
max = *resource * 100 / pp->p_nrdep;
}
act = min(used, max);
act = MIN(used, max);
real = dmin(999.0, (double)act * prodeff);
maxr = dmin(999.0, (double)max * prodeff);
real = MIN(999.0, (double)act * prodeff);
maxr = MIN(999.0, (double)max * prodeff);
if (vtype != I_NONE) {
if (real < 0.0)
real = 0.0;
/* production backlog? */
there = min(ITEM_MAX, sect.sct_item[vtype]);
real = dmin(real, ITEM_MAX - there);
there = MIN(ITEM_MAX, sect.sct_item[vtype]);
real = MIN(real, ITEM_MAX - there);
}
if (prodeff != 0) {
@ -315,7 +315,7 @@ prod(void)
civs = (1.0 + obrate * etu_per_update) * sect.sct_item[I_CIVIL];
natp = getnatp(sect.sct_own);
maxpop = max_pop(natp->nat_level[NAT_RLEV], &sect);
civs = min(civs, maxpop);
civs = MIN(civs, maxpop);
/* This isn't quite right, since research might
rise/fall during the update, but it's the best
we can really do */
@ -354,7 +354,7 @@ prod(void)
}
if (vtype != I_NONE || pp->p_level == NAT_ELEV
|| pp->p_level == NAT_HLEV)
pr(" %5d\n", min(999, (int)(max * prodeff + 0.5)));
pr(" %5d\n", MIN(999, (int)(max * prodeff + 0.5)));
else
pr(" %5.2f\n", maxr);
}

View file

@ -119,7 +119,7 @@ printdiff(struct natstr *plnatp, struct natstr *natp, int what)
if (ours
&& plnatp->nat_stat >= STAT_ACTIVE && natp->nat_stat >= STAT_ACTIVE) {
theirs = natp->nat_level[what];
if ((shift = min((int)theirs, (int)ours) - 100) > 0) {
if ((shift = MIN((int)theirs, (int)ours) - 100) > 0) {
ours -= shift;
theirs -= shift;
} else

View file

@ -136,7 +136,7 @@ sell(void)
return RET_FAIL;
}
if (number_set >= 0)
com = min(number_set, amt);
com = MIN(number_set, amt);
else
com = amt + number_set;
if (com <= 0)

View file

@ -122,7 +122,7 @@ sona(void)
if (sect.sct_type != SCT_WATER)
continue;
range = (int)techfact(ship.shp_tech, (double)mcp->m_vrnge);
srange = min(7, 7 * range * ship.shp_effic / 200);
srange = MIN(7, 7 * range * ship.shp_effic / 200);
pr("%s at %s efficiency %d%%, max range %d\n",
prship(&ship),
xyas(ship.shp_x, ship.shp_y, player->cnum),
@ -162,10 +162,10 @@ sona(void)
if (targ.shp_own == player->cnum || targ.shp_own == 0)
continue;
tmcp = &mchr[(int)targ.shp_type];
pingrange = min(7, max(targ.shp_visib, 10) * range / 10);
pingrange = MIN(7, MAX(targ.shp_visib, 10) * range / 10);
vrange = pingrange * ship.shp_effic / 200;
dist = mapdist(targ.shp_x, targ.shp_y, ship.shp_x, ship.shp_y);
pingrange = (max(pingrange, 2) * targ.shp_effic) / 100;
pingrange = (MAX(pingrange, 2) * targ.shp_effic) / 100;
if (dist > pingrange)
continue;
if (tmcp->m_flags & M_SONAR && targ.shp_own) {
@ -272,10 +272,10 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
if (roll(100) >
pln_identchance(pp, shp_hardtarget(targ), EF_SHIP))
continue;
pingrange = max(targ->shp_visib, 10) * range / 10;
pingrange = MAX(targ->shp_visib, 10) * range / 10;
vrange = ((float)pingrange) * ((float)pp->pln_effic / 200.0);
dist = mapdist(targ->shp_x, targ->shp_y, x, y);
pingrange = (max(pingrange, 2) * targ->shp_effic);
pingrange = (MAX(pingrange, 2) * targ->shp_effic);
pingrange = roundavg(pingrange / 100.0);
if (dist > pingrange)
continue;

View file

@ -99,7 +99,7 @@ stre(void)
pr("%7d", sect.sct_mines);
else
pr("%7s", "");
eff *= (1.0 + min(sect.sct_mines, 20) * 0.02);
eff *= (1.0 + MIN(sect.sct_mines, 20) * 0.02);
} else {
pr("%7s", "?");
}

View file

@ -156,8 +156,8 @@ tend(void)
amt = 0;
/* take from target and give to tender */
transfer = min(ontarget, -amt);
transfer = min(maxtender - ontender, transfer);
transfer = MIN(ontarget, -amt);
transfer = MIN(maxtender - ontender, transfer);
if (transfer == 0)
continue;
target.shp_item[ip->i_vtype] = ontarget - transfer;
@ -165,8 +165,8 @@ tend(void)
total += transfer;
} else {
/* give to target from tender */
transfer = min(ontender, amt);
transfer = min(transfer, maxtarget - ontarget);
transfer = MIN(ontender, amt);
transfer = MIN(transfer, maxtarget - ontarget);
if (transfer == 0)
continue;
target.shp_item[ip->i_vtype] = ontarget + transfer;

View file

@ -349,14 +349,14 @@ fire_dchrg(struct shpstr *sp, struct shpstr *targ, int ntargets)
shells = sp->shp_item[I_SHELL];
gun = sp->shp_item[I_GUN];
gun = min(gun, sp->shp_glim);
gun = min(gun, sp->shp_item[I_MILIT] / 2);
gun = MIN(gun, sp->shp_glim);
gun = MIN(gun, sp->shp_item[I_MILIT] / 2);
shells +=
supply_commod(sp->shp_own, sp->shp_x, sp->shp_y, I_SHELL,
(gun + 1) / 2 - shells);
gun = min(gun, shells * 2);
gun = MIN(gun, shells * 2);
if (gun == 0)
return;

View file

@ -134,9 +134,9 @@ vers(void)
(int)(plane_mob_scale * (float)etu_per_update),
(int)(land_mob_scale * (float)etu_per_update));
pr("Max eff gain per update\t\t--\t%d\t%d\t%d\n",
min((int)(ship_grow_scale * (float)etu_per_update), 100),
min((int)(plane_grow_scale * (float)etu_per_update), 100),
min((int)(land_grow_scale * (float)etu_per_update), 100));
MIN((int)(ship_grow_scale * (float)etu_per_update), 100),
MIN((int)(plane_grow_scale * (float)etu_per_update), 100),
MIN((int)(land_grow_scale * (float)etu_per_update), 100));
pr("\n");
pr("Ships on autonavigation may use %i cargo holds per ship.\n", TMAX);
if (opt_TRADESHIPS) {

View file

@ -89,7 +89,7 @@ work(void)
doney = sect.sct_y;
continue;
}
eff_amt = min(land.lnd_mobil, work_amt);
eff_amt = MIN(land.lnd_mobil, work_amt);
w = ldround(((double)eff_amt * land.lnd_effic / 600.0), 1);
if (w < 1) {
pr("%s doesn't work enough to change efficiency (try increasing amount)\n", prland(&land));