diff --git a/src/items/weapons.c b/src/items/weapons.c index 6c764b123..040fa0293 100644 --- a/src/items/weapons.c +++ b/src/items/weapons.c @@ -16,7 +16,10 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ -#include +#ifdef _MSC_VER +# include +#endif + #include "weapons.h" #include "battle.h" @@ -106,7 +109,7 @@ int *casualties) } enemies = count_enemies(b, af, FIGHT_ROW, FIGHT_ROW, SELECT_ADVANCE); - enemies = MIN(enemies, CATAPULT_ATTACKS); + if (enemies > CATAPULT_ATTACKS) enemies = CATAPULT_ATTACKS; if (enemies == 0) { return true; /* allow further attacks */ } diff --git a/src/kernel/region.c b/src/kernel/region.c index 4614f22bc..99e82d659 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -16,7 +16,10 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ -#include +#ifdef _MSC_VER +# include +#endif + #include "region.h" /* kernel includes */ @@ -141,8 +144,11 @@ const char *regionname(const region * r, const faction * f) int region_maxworkers(const region *r) { int size = max_production(r); - int treespace = (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE; - return MAX(size - treespace, MIN(size / 10, 200)); + int treespace = size - (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE; + size /=10; + if (size > 200) size = 200; + if (treespace < size) treespace = size; + return treespace; } int deathcount(const region * r) @@ -400,7 +406,7 @@ koor_distance_wrap_xy(int x1, int y1, int x2, int y2, int width, int height) int dx = x1 - x2; int dy = y1 - y2; int result, dist; - int mindist = MIN(width, height) >> 1; + int mindist = ((width > height) ? height : width) / 2; /* Bei negativem dy am Ursprung spiegeln, das veraendert * den Abstand nicht @@ -423,13 +429,15 @@ koor_distance_wrap_xy(int x1, int y1, int x2, int y2, int width, int height) if (result <= mindist) return result; } - dist = MAX(dx, height - dy); + dist = height - dy; + if (dist < dx) dist = dx; if (dist >= 0 && dist < result) { result = dist; if (result <= mindist) return result; } - dist = MAX(width - dx, dy); + dist = width - dx; + if (dist < dy) dist = dy; if (dist >= 0 && dist < result) result = dist; return result; @@ -1097,7 +1105,8 @@ void init_region(region *r) if (!fval(r, RF_CHAOTIC)) { int peasants; peasants = (region_maxworkers(r) * (20 + dice(6, 10))) / 100; - rsetpeasants(r, MAX(100, peasants)); + if (peasants < 100) peasants = 100; + rsetpeasants(r, peasants); rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL, INT_MAX) + 1) + rng_int() % 5)); } @@ -1419,7 +1428,8 @@ faction *update_owners(region * r) else if (f || new_owner->faction != region_get_last_owner(r)) { alliance *al = region_get_alliance(r); if (al && new_owner->faction->alliance == al) { - int morale = MAX(0, region_get_morale(r) - MORALE_TRANSFER); + int morale = region_get_morale(r) - MORALE_TRANSFER; + if (morale < 0) morale = 0; region_set_morale(r, morale, turn); } else { diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 552b831fd..a12c7cc1c 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -16,7 +16,9 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ -#include +#ifdef _MSC_VER +# include +#endif #include #include "ship.h" @@ -359,8 +361,9 @@ int shipspeed(const ship * sh, const unit * u) int crew = crew_skill(sh); int crew_bonus = (crew / sh->type->sumskill / 2) - 1; if (crew_bonus > 0) { - bonus = MIN(bonus, crew_bonus); - bonus = MIN(bonus, sh->type->range_max - sh->type->range); + int sbonus = sh->type->range_max - sh->type->range; + if (bonus > sbonus) bonus = sbonus; + if (bonus > crew_bonus) bonus = crew_bonus; } else { bonus = 0; diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 0778fc48e..c1e9264b9 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -16,7 +16,9 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ -#include +#ifdef _MSC_VER +# include +#endif #include #include "unit.h" @@ -1229,7 +1231,7 @@ int invisible(const unit * target, const unit * viewer) else { int hidden = item_invis(target); if (hidden) { - hidden = MIN(hidden, target->number); + if (hidden > target->number) hidden = target->number; if (viewer) { const resource_type *rtype = get_resourcetype(R_AMULET_OF_TRUE_SEEING); hidden -= i_get(viewer->items, rtype->itype); diff --git a/src/spells.c b/src/spells.c index a5c8383a1..cd349759f 100644 --- a/src/spells.c +++ b/src/spells.c @@ -4089,7 +4089,7 @@ static int sp_pump(castorder * co) * Betoert eine Einheit, so das sie ihm den groe�ten Teil ihres Bargelds * und 50% ihres Besitzes schenkt. Sie behaelt jedoch immer soviel, wie * sie zum ueberleben braucht. Wirkt gegen Magieresistenz. - * MIN(Stufe*1000$, u->money - maintenance) + * min(Stufe*1000$, u->money - maintenance) * Von jedem Item wird 50% abgerundet ermittelt und uebergeben. Dazu * kommt Itemzahl%2 mit 50% chance * diff --git a/src/triggers/shock.c b/src/triggers/shock.c index 0d0177025..205439b46 100644 --- a/src/triggers/shock.c +++ b/src/triggers/shock.c @@ -16,7 +16,10 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ -#include +#ifdef _MSC_VER +# include +#endif + #include "shock.h" #include @@ -61,8 +64,8 @@ static void do_shock(unit * u, const char *reason) if (u->number > 0) { /* HP - Verlust */ int hp = (unit_max_hp(u) * u->number) / 10; - hp = MIN(u->hp, hp); - u->hp = MAX(1, hp); + if (hp > u->hp) hp = u->hp; + u->hp = (hp > 1) ? hp : 1; } /* Aura - Verlust */