]> git.pond.sub.org Git - empserver/commitdiff
(ship_bomb, deli, do_demo, fuel, grin, look_ship)
authorRon Koenderink <rkoenderink@yahoo.ca>
Thu, 12 Jan 2006 14:23:55 +0000 (14:23 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Thu, 12 Jan 2006 14:23:55 +0000 (14:23 +0000)
(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.

48 files changed:
include/misc.h
include/prototypes.h
src/lib/commands/bomb.c
src/lib/commands/deli.c
src/lib/commands/demo.c
src/lib/commands/fuel.c
src/lib/commands/grin.c
src/lib/commands/look.c
src/lib/commands/lten.c
src/lib/commands/mfir.c
src/lib/commands/mine.c
src/lib/commands/miss.c
src/lib/commands/offe.c
src/lib/commands/prod.c
src/lib/commands/repo.c
src/lib/commands/sell.c
src/lib/commands/sona.c
src/lib/commands/stre.c
src/lib/commands/tend.c
src/lib/commands/torp.c
src/lib/commands/vers.c
src/lib/commands/work.c
src/lib/common/file.c
src/lib/gen/minmax.c [deleted file]
src/lib/player/accept.c
src/lib/player/player.c
src/lib/subs/aircombat.c
src/lib/subs/attsub.c
src/lib/subs/detonate.c
src/lib/subs/fortdef.c
src/lib/subs/landgun.c
src/lib/subs/lndsub.c
src/lib/subs/mission.c
src/lib/subs/plnsub.c
src/lib/subs/retreat.c
src/lib/subs/shpsub.c
src/lib/subs/supply.c
src/lib/update/human.c
src/lib/update/land.c
src/lib/update/material.c
src/lib/update/mobility.c
src/lib/update/nav_util.c
src/lib/update/plane.c
src/lib/update/produce.c
src/lib/update/revolt.c
src/lib/update/sect.c
src/lib/update/ship.c
src/util/fairland.c

index c82df470d567356ae39b3e860a045042541c18f0..67458d754cfd3983e972ab964f7a73cbb1debd10 100644 (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[]);
index 64005120a49e70b6bb219a967313be22e33c7d15..3d1c8421f5f7ff8da7df422e34067bb2f9e100b8 100644 (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 **);
index c8f3ffaa61299cca0f26492d37474a14ae48a6b0..17b7b6f288dd4d2cd62dd4a160f88313dc11d698 100644 (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)
index dbb7a54bff29ee83248731779a9786c15ca854e2..30b0a20c7f0094ed1e17da98cfab96188b5e5596 100644 (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);
index ef1940a4d92ffef2a8c84ac7f2c60ff3af4336cd..c170e22bce3802f839728a5edcc7cdde94b7a7d0 100644 (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)
index 36097043866d7cdf9bba4393e88cead7eb3d674c..9e64d66b5af9c6e6d6a931cf138b4bf94d7e617c 100644 (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 */
index f983aedca007d3d0914666f26bf172d7a9118aa6..ed7f32e2e44474c0d8c7242f831c402260a7f886 100644 (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));
        }
index fa850f842c8b5474bb19e2eb27a1cdacc5ac2fc2..d85c558a6469891d3a3cdee467418f4aef964f5f 100644 (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) {
index e7d5d37354b5a87a476872f51362e8abe28584d5..482cee871c991c7c0098c351822307ad1d18e6b2 100644 (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;
index 7322b8d762840b2dfb04a66a4cdff9b8cbe5df0d..c6bc7df8ab904f04d6caded8a5db484d799e6744 100644 (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)++;
index ab3b1d03171f86b124d2f99386c749508ff4b63f..ec3f459ff2293ad346bb0a7ab81bf2a3a65ed737 100644 (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",
index cda7fe5cd7f7e0bab9ddf44aada9f84e1c13d3ba..902fa3e51825e2ca7e4ee2815d12e19fc34b45e5 100644 (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:
index 51f7a723d5047d2702a295a8104a52fe980fa06a..c3ab9cfa560c93dbfaf5639f72cf182c31e4a055 100644 (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);
index 76b309638cae061861d281d9a941373b5d9ea59b..7795417928176949f834d5421ca0d3e4a1ae549d 100644 (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);
     }
index 58c285de4f58661915bb26510665b21a6c2d2687..1ce3ecb40460d026c5f48e428abf2e62f7cf7c45 100644 (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
index 0eb2fb7768c5b65899b7fdfdbaa658379c54111e..6eacd98adb8b462e6afd54425b0d4a1198f1eb19 100644 (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)
index 6ecbd7889c4364b82db4f7638cf9bac49be20399..f3558912beb6844c9b22fd0b9c461b99432a5156 100644 (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;
index 88cb4d45fd0df5aff1024490bf25d8fbc36566a5..f5f6b022c131f39179391829e66179d78fcdf183 100644 (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", "?");
        }
index cf542c773aae6e264f78976ca9dc5cb8ec481823..bc3d10719d10d262a490876712667f31d50cbe19 100644 (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;
index 6c156dec95a6fd9f227b8b8785bab8071aa77032..03ba91d89ee354bcf08bdaf3a05e4d7096699d1d 100644 (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;
 
index 71666bf9839cbe0c49d260bc913761d676388b7c..b27fe13e769c148dc6fe3e3c7d09ca06f26d18f2 100644 (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) {
index 2d7bd8ab1a1ce1fb0568e93911fc7f224c122cd6..a04d2731009d09843c14de5d67d03d92ef4898a3 100644 (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));
index 103c2e1876d55751b19917abd94b5d8386052b77..5f8f94ebb227e6b6613e818282e093343e06c498 100644 (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);
diff --git a/src/lib/gen/minmax.c b/src/lib/gen/minmax.c
deleted file mode 100644 (file)
index 03f92b2..0000000
+++ /dev/null
@@ -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
index 56d0a558d181b7eef0be1fcc952f2847cc9bafc7..05b40b40cf4eae78020ddd6a5722cef608341f5c 100644 (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,
index a19c79343bcb0532cfba054fedfbb507fcac17c8..e0c45ec6f08f655609208d1f864a4cccf834a0e0 100644 (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))
index 7d87320d901ebb0eda395fd909fc6a30f44b5915..3fa7f8f0451ac8e6c3f531e1c9e7ab992beba059 100644 (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) {
index fad0a3c5aebd50063fb467fcd93abffdc918dc47..29a9490fe1929e34ecc27d9f131d3ec85f7e1da2 100644 (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);
index e281b2681740272be496c87f007247c83f4780aa..c0ea76c9a243318fea929ad83a893e6eb389fc6b 100644 (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);
index 81b88d03bcf1091fad6619d5f9516cb880d1d057..408722f9558acdbb27b6c1862e95c402f95cdbc0 100644 (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;
index 2c789420e3a81a69b893b0deca7698beef234578..ee8008f95973a5159e95a6b820150c4ec1ce7658 100644 (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;
index 2f0f024f20427b42a759b5ec97cf02834f45e1db..8137d376299abd553dc70e2f635e5715f20e79bb 100644 (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;
 }
index d184f88734ac1150bae531888dd16a40772ddeea..bf63b85652fe9e4c0052813af61ac233b2f3a077 100644 (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)) {
index c1932494dddc3ffba00b854391e9f0159e57661f..bbba669a9686c4e13ee69f95b60d357d0c673f8e 100644 (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);
 }
 
 /*
index 4335c3d230174cc1acfc90df336e73db02e00843..c61da1e0ee37bdd5efaae17fb2c14e7e5439d096 100644 (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;
index 1fa6b66090a33c040b9e2ab5bbb35b9900c98cab..c00f2a1ce9d9a9e7c418200f891e80922ab714cd 100644 (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));
index b73bc0432cc3ba179200f4e67c7ef2fa3f3a4302..8c9ded5164a71c16d306db171488425ac41133e2 100644 (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:
index 7db1d78769160801ffa4960701c8fddd6615f63e..3e6796e9ec20e9c5dc94b8c2223d5ab2f6d8997c 100644 (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];
     /*
index b37261aa305a8e9a7d036d3a2f945ad2f1c17124..fd8b869899e5907cf669f044668f366fd193383a 100644 (file)
 
 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) {
index 42d8970bf1f4885668edcf844029b370ee394611..e5db8cf4fa38c6d576227c159681a37409e002dd 100644 (file)
 #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 */
index 4c4dcc8110cf7d65e4d20479cc83abbea7adbfaf..f1675558dafc02facd6fa58f35f41f260cc1c0b6 100644 (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;
        }
index 9c07bfca0b78ee8a056930150b1883725f8e2eae..2051ab85e509b8cab039cea724e8407dcdce6cbc 100644 (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;
 
index 9dff2a8e88c1abad51dbe71f169911eed0ab9efd..a3cf3960ec5f0206e595a22cfd751455469e2fd4 100644 (file)
 #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) {
index de9151e66b16943a1ee8c81094caf672cd6f5b39..423bb28eb73d5e9e18c534b4dde1c3bb0ac342d0 100644 (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;
 }
index 50a725eff88dd7af81a86fba9cb8f050bb5a943d..257979896f8a15a31943a9c5e9278d6443a23745 100644 (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;
     }
 
index c7ce2b4c34804a25ca8b9faf63fb7d93a504308e..67178674479e4dca69dd33bd183ccf20a3a2105f 100644 (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);
     }
 }
 
index 8f4ce632ea567212532101abb9bafe119b4f2aef..2fe01d0503f537fb2662a24b60a4e9e3c687b085 100644 (file)
 #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) {
index d11ac43bf431048bb439e95de059c5ddd71d3991..0d07a3bdfb32e2fadd054f0dc1da78dfabdbd5f9 100644 (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));