(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

@ -744,7 +744,7 @@ ac_planedamage(struct plist *plp, natid from, int dam, natid other,
}
pp->pln_effic = eff;
pp->pln_mobil -= min(32 + pp->pln_mobil, dam / 2);
pp->pln_mobil -= MIN(32 + pp->pln_mobil, dam / 2);
if (disp == 1) {
if (from != 0 && (plp->pcp->pl_flags & P_M) == 0)
nreport(from, N_DOWN_PLANE, pp->pln_own, 1);
@ -839,7 +839,7 @@ ac_shipflak(struct emp_qelem *list, coord x, coord y)
if (rel > HOSTILE)
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) {
shell = ship.shp_item[I_SHELL];
if (shell <= 0) {

View file

@ -262,7 +262,7 @@ att_get_combat(struct combat *com, int isdef)
else if (mil == 1)
pr("Only 1 mil %s\n", prcom(1, com));
/* don't abandon attacking sectors or ships */
com->troops = max(0, mil - 1);
com->troops = MAX(0, mil - 1);
}
com->plague = pstage == PLG_INFECT;
} else { /* not first time */
@ -297,8 +297,8 @@ att_get_combat(struct combat *com, int isdef)
}
if (com->troops && com->troops + 1 > mil) {
if (com->own == owner && player->cnum == owner) /* not a takeover */
pr("WARNING: Your mil %s has been reduced from %d to %d!\n", prcom(1, com), com->troops, max(0, mil - 1));
com->troops = max(0, mil - 1);
pr("WARNING: Your mil %s has been reduced from %d to %d!\n", prcom(1, com), com->troops, MAX(0, mil - 1));
com->troops = MAX(0, mil - 1);
}
}
}
@ -847,17 +847,17 @@ calc_mobcost(int combat_mode, struct combat *off, struct combat *def,
switch (combat_mode) {
case A_ATTACK:
off->mobcost +=
max(1,
MAX(1,
(int)(attacking_mil *
sector_mcost(getsectp(def->x, def->y), MOB_ROAD)));
break;
case A_LBOARD:
off->mobcost += max(1, attacking_mil / 5);
off->mobcost += MAX(1, attacking_mil / 5);
break;
case A_BOARD:
switch (off->type) {
case EF_SECTOR:
off->mobcost += max(1, attacking_mil / 5);
off->mobcost += MAX(1, attacking_mil / 5);
break;
case EF_SHIP:
/* the 2 in the formula below is a fudge factor */
@ -899,7 +899,7 @@ ask_off(int combat_mode, struct combat *off, struct combat *def)
if (att_get_combat(off, 0) <= 0)
return 0;
if ((attacking_mil =
min(attacking_mil, min(mob_support, off->troops))) <= 0)
MIN(attacking_mil, MIN(mob_support, off->troops))) <= 0)
return 0;
calc_mobcost(combat_mode, off, def, attacking_mil);
@ -1680,7 +1680,7 @@ get_mine_dsupport(struct combat *def, int a_engineer)
getsect(def->x, def->y, &sect);
if (sect.sct_oldown != player->cnum) {
mines = min(sect.sct_mines, 20);
mines = MIN(sect.sct_mines, 20);
if (a_engineer)
mines = ldround(((double)mines / 2.0), 1);
if (mines > 0) {
@ -1906,7 +1906,7 @@ att_fight(int combat_mode, struct combat *off, struct emp_qelem *olist,
/* Make sure we use a positive mobility here */
tmob = ((def->mob < 0) ? -(def->mob) : (def->mob));
def->mobcost =
min(20, min(1, tmob - damage(tmob, 100 * d_cas / d_mil)));
MIN(20, MIN(1, tmob - damage(tmob, 100 * d_cas / d_mil)));
}
def->mil = def->troops;
}
@ -1916,7 +1916,7 @@ att_fight(int combat_mode, struct combat *off, struct emp_qelem *olist,
if (off[n].type != EF_BAD && off[n].troops < a_troops[n]) {
if (off[n].type == EF_SECTOR && off[n].mil)
off[n].mobcost +=
min(20,
MIN(20,
off[n].mob - damage(off[n].mob,
100 * (a_troops[n] - off[n].troops)
/ off[n].mil));
@ -2455,7 +2455,7 @@ ask_move_in_off(struct combat *off, struct combat *def)
if (off->own != player->cnum)
return;
d = sector_mcost(getsectp(def->x, def->y), MOB_ROAD);
if ((mob_support = min(off->troops, (int)(off->mob / d))) <= 0)
if ((mob_support = MIN(off->troops, (int)(off->mob / d))) <= 0)
return;
sprintf(prompt, "How many mil to move in from %s (%d max)? ",
xyas(off->x, off->y, player->cnum), mob_support);
@ -2470,13 +2470,13 @@ ask_move_in_off(struct combat *off, struct combat *def)
return;
if (att_get_combat(def, 0) < 0)
return;
if ((num_mil = min(off->troops, num_mil)) <= 0) {
if ((num_mil = MIN(off->troops, num_mil)) <= 0) {
pr("No mil moved in from %s\n",
xyas(off->x, off->y, player->cnum));
return;
}
mob_support = max(1, (int)(num_mil * d));
off->mob -= min(off->mob, mob_support);
mob_support = MAX(1, (int)(num_mil * d));
off->mob -= MIN(off->mob, mob_support);
off->mil -= num_mil;
off->troops -= num_mil;
put_combat(off);

View file

@ -113,7 +113,7 @@ detonate(struct plnstr *pp, int x, int y)
fallout += damage * 30;
else
fallout += damage * 3;
sect.sct_fallout = min(fallout, FALLOUT_MAX);
sect.sct_fallout = MIN(fallout, FALLOUT_MAX);
}
if (damage > 100) {
makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x, sect.sct_y);

View file

@ -107,8 +107,8 @@ sd(natid att, natid own, coord x, coord y, int noisy, int defending,
if (shell < ship.shp_glim)
shell += supply_commod(ship.shp_own, ship.shp_x, ship.shp_y,
I_SHELL, shell - ship.shp_glim);
nshot = min(min(ship.shp_item[I_GUN], shell), ship.shp_item[I_MILIT]);
nshot = min(nshot, ship.shp_glim);
nshot = MIN(MIN(ship.shp_item[I_GUN], shell), ship.shp_item[I_MILIT]);
nshot = MIN(nshot, ship.shp_glim);
if (nshot <= 0)
continue;
ship.shp_item[I_SHELL] = shell - nshot;

View file

@ -40,7 +40,7 @@ double
landgun(int effic, int guns)
{
double d;
double g = (double)min(guns, 7);
double g = (double)MIN(guns, 7);
d = ((double)(random() % 30) + 20.0) * ((double)g / 7.0);
d *= (double)effic;
@ -65,7 +65,7 @@ landunitgun(int effic, int shots, int guns, int ammo, int shells)
{
double d = 0.0;
shots = min(shots, guns);
shots = MIN(shots, guns);
while (shots-- > 0)
d += 5.0 + (double)(random() % 6);
d *= (double)effic * 0.01;

View file

@ -392,7 +392,7 @@ intelligence_report(int destination, struct lndstr *lp, int spy,
if (chance((double)(spy + lp->lnd_vis) / 20.0)) {
int t;
t = lp->lnd_tech - 20 + roll(40);
t = max(t, 0);
t = MAX(t, 0);
if (destination == player->cnum)
pr(", tech %d)\n", t);
else
@ -938,7 +938,7 @@ lnd_fort_interdiction(struct emp_qelem *list,
gun = fsect.sct_item[I_GUN];
if (gun < 1)
continue;
range = tfactfire(fsect.sct_own, (double)min(gun, 7));
range = tfactfire(fsect.sct_own, (double)MIN(gun, 7));
if (fsect.sct_effic > 59)
range++;
range2 = roundrange(range);
@ -1378,7 +1378,7 @@ lnd_fortify (struct lndstr *lp, int hard_amt)
if ((lp->lnd_ship >= 0) || lp->lnd_land >= 0)
return 0;
hard_amt = min(lp->lnd_mobil, hard_amt);
hard_amt = MIN(lp->lnd_mobil, hard_amt);
if ((lp->lnd_harden + hard_amt) > land_mob_max)
hard_amt = land_mob_max - lp->lnd_harden;
@ -1409,7 +1409,7 @@ lnd_fortify (struct lndstr *lp, int hard_amt)
lp->lnd_mobil = 0;
lp->lnd_harden += hard_amt;
lp->lnd_harden = min(lp->lnd_harden, land_mob_max);
lp->lnd_harden = MIN(lp->lnd_harden, land_mob_max);
return hard_amt;
}

View file

@ -308,8 +308,8 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
struct sctstr sect;
/*
size = max(sizeof(struct shpstr),sizeof(struct lndstr));
size = max(size,sizeof(struct plnstr));
size = MAX(sizeof(struct shpstr),sizeof(struct lndstr));
size = MAX(size,sizeof(struct plnstr));
block = malloc(size);
*/
size = sizeof(u_block);
@ -615,17 +615,17 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
if (md > range2)
continue;
gun = sp->shp_item[I_GUN];
gun = min(gun, sp->shp_glim);
gun = MIN(gun, sp->shp_glim);
shell = sp->shp_item[I_SHELL];
if (shell < gun)
shell += supply_commod(sp->shp_own,
sp->shp_x, sp->shp_y, I_SHELL,
gun - shell);
gun = min(gun, shell);
gun = min(gun, sp->shp_item[I_MILIT] / 2.0);
gun = MIN(gun, shell);
gun = MIN(gun, sp->shp_item[I_MILIT] / 2.0);
if (gun == 0)
continue;
gun = max(gun, 1);
gun = MAX(gun, 1);
dam2 = seagun(sp->shp_effic, gun);
if (range2 == 0.0)
prb = 1.0;
@ -880,8 +880,8 @@ show_mission(int type, struct nstr_item *np)
s_char *block;
struct genitem *gp;
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);
while (nxtitem(np, block)) {

View file

@ -361,7 +361,7 @@ pln_mine(struct emp_qelem *list, struct sctstr *sectp)
pr("Your seamines have no effect here.\n");
return;
}
sectp->sct_mines = min(sectp->sct_mines + amt, MINES_MAX);
sectp->sct_mines = MIN(sectp->sct_mines + amt, MINES_MAX);
pr("%d mines laid in %s.\n", amt,
xyas(sectp->sct_x, sectp->sct_y, player->cnum));
if (map_set(player->cnum, sectp->sct_x, sectp->sct_y, 'X', 0))
@ -1245,7 +1245,7 @@ pln_mobcost(int dist, struct plnstr *pp, int flags)
cost = ldround((double)cost * dist / pp->pln_range_max, 1);
return min(32 + pp->pln_mobil, cost + 5);
return MIN(32 + pp->pln_mobil, cost + 5);
}
/*

View file

@ -286,7 +286,7 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig)
for (m = 0; mines > 0 && m < 5; m++) {
if (chance(0.66)) {
mines--;
shells = min(max, shells + 1);
shells = MIN(max, shells + 1);
changed |= map_set(sp->shp_own, sp->shp_x, sp->shp_y,
'X', 0);
}
@ -514,7 +514,7 @@ retreat_land1(struct lndstr *lp, s_char code, int orig)
for (m = 0; mines > 0 && m < 5; m++) {
if (chance(0.66)) {
mines--;
shells = min(max, shells + 1);
shells = MIN(max, shells + 1);
}
}
sect.sct_mines = mines;

View file

@ -257,7 +257,7 @@ shp_sweep(struct emp_qelem *ship_list, int verbose, natid actor)
if (chance(0.66)) {
mpr(actor, "Sweep...\n");
mines--;
shells = min(max, shells + 1);
shells = MIN(max, shells + 1);
changed |= map_set(actor, sect.sct_x, sect.sct_y, 'X', 0);
}
}
@ -661,7 +661,7 @@ shp_fort_interdiction(struct emp_qelem *list, coord newx, coord newy,
gun = fsect.sct_item[I_GUN];
if (gun < 1)
continue;
range = tfactfire(fsect.sct_own, (double)min(gun, 7));
range = tfactfire(fsect.sct_own, (double)MIN(gun, 7));
if (fsect.sct_effic > 59)
range++;
range2 = roundrange(range);
@ -950,7 +950,7 @@ shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget)
continue;
/* 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;
teff =
(((double)ship.shp_tech) / (((double)ship.shp_tech) + 200.0));

View file

@ -558,7 +558,7 @@ use_supply(struct lndstr *lp)
lp->lnd_item[I_SHELL] = shells;
}
lp->lnd_item[I_SHELL] = max(lp->lnd_item[I_SHELL] - shells_needed, 0);
lp->lnd_item[I_SHELL] = MAX(lp->lnd_item[I_SHELL] - shells_needed, 0);
if (lp->lnd_frg) /* artillery */
goto done;
@ -574,7 +574,7 @@ use_supply(struct lndstr *lp)
lp->lnd_item[I_FOOD] = food;
}
lp->lnd_item[I_FOOD] = max(lp->lnd_item[I_FOOD] - food_needed, 0);
lp->lnd_item[I_FOOD] = MAX(lp->lnd_item[I_FOOD] - food_needed, 0);
if (opt_FUEL) {
fuel_needed = lp->lnd_fuelu;
@ -600,7 +600,7 @@ use_supply(struct lndstr *lp)
if (petrol_needed) {
if (petrol >= petrol_needed) {
lp->lnd_item[I_PETROL]
= max(lp->lnd_item[I_PETROL] - petrol_needed, 0);
= MAX(lp->lnd_item[I_PETROL] - petrol_needed, 0);
lp->lnd_fuel += petrol_needed * 10;
} else {
lp->lnd_fuel += lp->lnd_item[I_PETROL] * 10;
@ -608,7 +608,7 @@ use_supply(struct lndstr *lp)
}
}
lp->lnd_fuel = max(lp->lnd_fuel - fuel_needed, 0);
lp->lnd_fuel = MAX(lp->lnd_fuel - fuel_needed, 0);
}
/* end opt_FUEL */
done: