(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

@ -39,6 +39,9 @@
#include <string.h>
#include <sys/types.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
#if defined(_WIN32)
typedef unsigned char u_char;
typedef unsigned short u_short;
@ -48,9 +51,6 @@ typedef long ssize_t;
/* integral mismatch, due to misuse of sector short */
#ifndef __GNUC__
#pragma warning (disable : 4761 )
#else
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#endif
#include <io.h>
@ -136,9 +136,6 @@ extern int oops(char *, char *, int);
#define RET_SYN 2 /* syntax error in command */
#define RET_SYS 3 /* system error (missing file, etc) */
double dmax(double n1, double n2);
double dmin(double n1, double n2);
extern char *getstarg(char *input, char *prompt, char buf[]);
extern char *getstring(char *prompt, char buf[]);
extern char *ugetstring(char *prompt, char buf[]);

View file

@ -382,10 +382,6 @@ extern int diffy(int, int);
extern int deltax(int, int);
extern int deltay(int, int);
extern int mapdist(int, int, int, int);
#if !defined(_WIN32)
extern int max(int, int);
extern int min(int, int);
#endif
extern s_char *effadv(int);
extern int onearg(s_char *, s_char *);
extern int parse(char *, char **, char **, char *, char **);

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));

View file

@ -114,7 +114,7 @@ ef_open(int type, int how)
if (how & EFF_MEM)
ep->csize = ep->fids;
else
ep->csize = max(1, blksize(fd) / ep->size);
ep->csize = MAX(1, blksize(fd) / ep->size);
size = ep->csize * ep->size;
if (CANT_HAPPEN(ep->cache))
free(ep->cache);

View file

@ -1,73 +0,0 @@
/*
* Empire - A multi-player, client/server Internet based war game.
* Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* ---
*
* See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
* related information and legal notices. It is expected that any future
* projects/authors will amend these files as needed.
*
* ---
*
* minmax.c: Misc min and max routines
*
* Known contributors to this file:
* Doug Hay, 1998
* Steve McClure, 1998
*/
#include <config.h>
#include "gen.h"
double
dmax(double n1, double n2)
{
if (n1 > n2)
return n1;
return n2;
}
double
dmin(double n1, double n2)
{
if (n1 < n2)
return n1;
return n2;
}
#if !defined(_WIN32)
int
max(int n1, int n2)
{
if (n1 > n2)
return n1;
return n2;
}
int
min(int n1, int n2)
{
if (n1 < n2)
return n1;
return n2;
}
#endif

View file

@ -240,7 +240,7 @@ player_accept(void *unused)
#endif /* RESOLVE_IPADDRESS */
/* XXX may not be big enough */
stacksize = 100000
/* budget */ + max(WORLD_X * WORLD_Y / 2 * sizeof(int) * 7,
/* budget */ + MAX(WORLD_X * WORLD_Y / 2 * sizeof(int) * 7,
/* power */ MAXNOC * sizeof(struct powstr));
sprintf(buf, "Player (fd #%d)", ns);
empth_create(PP_PLAYER, player_login, stacksize,

View file

@ -134,7 +134,7 @@ player_main(struct player *p)
* charging at least 15 seconds.
*/
time(&natp->nat_last_logout);
secs = max(natp->nat_last_logout - player->lasttime, 15);
secs = MAX(natp->nat_last_logout - player->lasttime, 15);
natp->nat_minused += secs / 60;
secs = secs % 60;
if (chance(secs / 60.0))

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:

View file

@ -146,7 +146,7 @@ int
new_work(struct sctstr *sp, int delta)
{
if (sp->sct_type == sp->sct_newtype)
return min(rollover_avail_max, sp->sct_avail) + delta;
return MIN(rollover_avail_max, sp->sct_avail) + delta;
return delta;
}
@ -161,7 +161,7 @@ growfood(struct sctstr *sp, short *vec, int work, int etu)
food_workers = work * fcrate;
food_fertil = etu * sp->sct_fertil * fgrate;
food = min(food_workers, food_fertil);
food = MIN(food_workers, food_fertil);
if (food > ITEM_MAX - vec[I_FOOD])
food = ITEM_MAX - vec[I_FOOD];
/*

View file

@ -55,10 +55,6 @@
int mil_dbl_pay;
#ifndef MIN
#define MIN(x,y) ((x) > (y) ? (y) : (x))
#endif
static int landrepair(struct lndstr *, struct natstr *,
int *, int);
static void upd_land(struct lndstr *lp, int etus,
@ -144,8 +140,8 @@ upd_land(struct lndstr *lp, int etus,
mult = 2;
if (lcp->l_flags & L_ENGINEER)
mult *= 3;
/* cost = -(mult * etus * dmin(0.0, money_land * LND_COST(lcp->l_cost, lp->lnd_tech - lcp->l_tech)));*/
cost = -(mult * etus * dmin(0.0, money_land * lcp->l_cost));
/* cost = -(mult * etus * MIN(0.0, money_land * LND_COST(lcp->l_cost, lp->lnd_tech - lcp->l_tech)));*/
cost = -(mult * etus * MIN(0.0, money_land * lcp->l_cost));
if ((np->nat_priorities[PRI_LMAINT] == 0 || np->nat_money < cost)
&& !player->simulation) {
if ((eff = lp->lnd_effic - etus / 5) < LAND_MINEFF) {

View file

@ -41,10 +41,6 @@
#include "common.h"
#include "subs.h"
#ifndef MIN
#define MIN(x,y) ((x) > (y) ? (y) : (x))
#endif
void
get_materials(struct sctstr *sp, int *bp, int *mvec, int check)
/* only check if found=0, remove them=1 */

View file

@ -365,7 +365,7 @@ do_mob_ship(struct shpstr *sp, int etus)
d *= (double)mchr[(int)sp->shp_type].m_fuelu;
d /= (double)fuel_mult;
sp->shp_fuel -= (u_char)ldround(d, 1);
sp->shp_fuel = (u_char)min(sp->shp_fuel,
sp->shp_fuel = (u_char)MIN(sp->shp_fuel,
mchr[(int)sp->shp_type].m_fuelc);
sp->shp_mobil += (s_char)total_add;
}
@ -478,7 +478,7 @@ do_mob_land(struct lndstr *lp, int etus)
d *= (double)lp->lnd_fuelu;
d /= (double)fuel_mult;
lp->lnd_fuel -= (u_char)ldround(d, 1);
lp->lnd_fuel = (u_char)min(lp->lnd_fuel, lp->lnd_fuelc);
lp->lnd_fuel = (u_char)MIN(lp->lnd_fuel, lp->lnd_fuelc);
if (total_add + lp->lnd_mobil > land_mob_max) {
total_add = land_mob_max - lp->lnd_mobil;
}

View file

@ -113,7 +113,7 @@ load_it(struct shpstr *sp, struct sctstr *psect, int i)
if (!abs_max)
return 0; /* can't load the ship, skip to the end. */
max_amt = min(sect_amt, max_amt - ship_amt);
max_amt = MIN(sect_amt, max_amt - ship_amt);
if (max_amt <= 0 && (ship_amt != abs_max)) {
sp->shp_autonav |= AN_LOADING;
return 0;
@ -199,7 +199,7 @@ unload_it(struct shpstr *sp)
if (comm == I_CIVIL)
ship_amt--; /* This leaves 1 civs on board the ship */
max_amt = min(ship_amt, ITEM_MAX - sect_amt);
max_amt = MIN(ship_amt, ITEM_MAX - sect_amt);
if (max_amt <= 0)
continue;

View file

@ -49,10 +49,6 @@
#include "common.h"
#include "gen.h"
#ifndef MIN
#define MIN(x,y) ((x) > (y) ? (y) : (x))
#endif
int
prod_plane(int etus, int natnum, int *bp, int buildem)
@ -133,7 +129,7 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
if (buildem == 0) {
/* flight pay is 5x the pay received by other military */
start_money = np->nat_money;
cost = -(mult * etus * dmin(0.0, desc->pl_cost * money_plane));
cost = -(mult * etus * MIN(0.0, desc->pl_cost * money_plane));
if ((np->nat_priorities[PRI_PMAINT] == 0 ||
np->nat_money < cost) && !player->simulation) {
if ((eff = pp->pln_effic - etus / 5) < PLANE_MINEFF) {

View file

@ -169,9 +169,9 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
}
}
/* The min() here is to take care of integer rounding errors */
/* The MIN() here is to take care of integer rounding errors */
if (p_e > 0.0) {
return min(work, (int)(unit_work * material_consume / p_e));
return MIN(work, (int)(unit_work * material_consume / p_e));
}
return 0;
}

View file

@ -218,7 +218,7 @@ guerrilla(struct sctstr *sp)
logerror("%d Che targeted at country %d retiring", che, target);
sp->sct_che = 0;
sp->sct_che_target = 0;
sp->sct_item[I_CIVIL] = min(civ + che, ITEM_MAX);
sp->sct_item[I_CIVIL] = MIN(civ + che, ITEM_MAX);
return;
}

View file

@ -97,7 +97,7 @@ upd_buildeff(struct natstr *np, struct sctstr *sp, int *workp,
+ (vec[I_MILIT] * 2 / 5.0) + vec[I_UW];
*workp = roundavg((etu * (*workp)) / 100.0);
buildeff_work = min((int)(*workp / 2), buildeff_work);
buildeff_work = MIN((int)(*workp / 2), buildeff_work);
}
}
if (np->nat_priorities[*desig]) {
@ -247,7 +247,7 @@ spread_fallout(struct sctstr *sp, int etus)
inc = roundavg(etus * fallout_spread * (sp->sct_fallout)) - 1;
if (inc < 0)
inc = 0;
ap->sct_fallout = min(ap->sct_fallout + inc, FALLOUT_MAX);
ap->sct_fallout = MIN(ap->sct_fallout + inc, FALLOUT_MAX);
}
}

View file

@ -54,10 +54,6 @@
#include "lost.h"
#include "budg.h"
#ifndef MIN
#define MIN(x,y) ((x) > (y) ? (y) : (x))
#endif
static int shiprepair(struct shpstr *, struct natstr *,
int *, int);
static void upd_ship(struct shpstr *, int,
@ -144,7 +140,7 @@ upd_ship(struct shpstr *sp, int etus,
mult = 1;
if (np->nat_level[NAT_TLEV] < sp->shp_tech * 0.85)
mult = 2;
cost = -(mult * etus * dmin(0.0, money_ship * mp->m_cost));
cost = -(mult * etus * MIN(0.0, money_ship * mp->m_cost));
if ((np->nat_priorities[PRI_SMAINT] == 0 || np->nat_money < cost)
&& !player->simulation) {
if ((eff = sp->shp_effic - etus / 5) < SHIP_MINEFF) {

View file

@ -124,9 +124,6 @@ static char *program_name;
#define new_x(newx) (((newx) + WORLD_X) % WORLD_X)
#define new_y(newy) (((newy) + WORLD_Y) % WORLD_Y)
#if !defined(_WIN32)
#define max(a,b) (a>b?a:b)
#endif
#define rnd(x) (random() % (x))
int secs; /* number of sectors grown */
@ -459,9 +456,9 @@ allocate_memory(void)
secty = calloc(nc + ni, sizeof(int *));
sectc = calloc(nc + ni, sizeof(int *));
isecs = calloc(nc + ni, sizeof(int));
weight = calloc(max(sc, is * 2), sizeof(int));
dsea = calloc(max(sc, is * 2), sizeof(int));
dmoun = calloc(max(sc, is * 2), sizeof(int));
weight = calloc(MAX(sc, is * 2), sizeof(int));
dsea = calloc(MAX(sc, is * 2), sizeof(int));
dmoun = calloc(MAX(sc, is * 2), sizeof(int));
for (i = 0; i < nc; ++i) {
sectx[i] = calloc(sc, sizeof(int));
secty[i] = calloc(sc, sizeof(int));