From 0ae87370621b9e42d3aa13b781421dc53074c609 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 16 Mar 2014 05:03:17 +0100 Subject: [PATCH] rename MIN/MAX to _min/_max --- autoconf.h.in | 8 +-- src/bind_gmtool.c | 2 +- src/economy.c | 62 +++++++++++------------ src/give.c | 2 +- src/items/weapons.c | 2 +- src/items/xerewards.c | 2 +- src/kernel/alchemy.c | 8 +-- src/kernel/battle.c | 64 ++++++++++++------------ src/kernel/build.c | 36 +++++++------- src/kernel/building.c | 2 +- src/kernel/config.c | 10 ++-- src/kernel/connection.c | 4 +- src/kernel/curse.c | 12 ++--- src/kernel/group.c | 2 +- src/kernel/item.c | 2 +- src/kernel/magic.c | 32 ++++++------ src/kernel/move.c | 18 +++---- src/kernel/names.c | 4 +- src/kernel/pool.c | 10 ++-- src/kernel/region.c | 10 ++-- src/kernel/reports.c | 6 +-- src/kernel/unit.c | 2 +- src/laws.c | 66 ++++++++++++------------ src/modules/arena.c | 18 ++++--- src/modules/autoseed.c | 8 +-- src/modules/dungeon.c | 4 +- src/monster.c | 10 ++-- src/monsters.c | 6 +-- src/platform.h | 12 ----- src/races/dragons.c | 2 +- src/races/zombies.c | 8 +-- src/randenc.c | 6 +-- src/spells/borders.c | 2 +- src/spells/combatspells.c | 30 +++++------ src/spells/spells.c | 102 +++++++++++++++++++------------------- src/spy.c | 6 +-- src/study.c | 20 ++++---- src/triggers/shock.c | 2 +- 38 files changed, 297 insertions(+), 305 deletions(-) diff --git a/autoconf.h.in b/autoconf.h.in index c10746006..dec869aec 100644 --- a/autoconf.h.in +++ b/autoconf.h.in @@ -116,11 +116,11 @@ #endif #endif -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#ifndef _min +#define _min(a,b) ((a) < (b) ? (a) : (b)) #endif -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#ifndef _max +#define _max(a,b) ((a) > (b) ? (a) : (b)) #endif #if !defined(DBG_UNREFERENCED_PARAMETER) diff --git a/src/bind_gmtool.c b/src/bind_gmtool.c index b3e027a58..f381318cf 100644 --- a/src/bind_gmtool.c +++ b/src/bind_gmtool.c @@ -186,7 +186,7 @@ static void lua_paint_info(struct window *wnd, const struct state *st) break; else { size_t len = end - str; - int bytes = MIN((int)len, size); + int bytes = _min((int)len, size); mvwaddnstr(win, line++, 1, str, bytes); wclrtoeol(win); str = end + 1; diff --git a/src/economy.c b/src/economy.c index 7b679367a..3751e7012 100644 --- a/src/economy.c +++ b/src/economy.c @@ -369,11 +369,11 @@ static int do_recruiting(recruitment * recruits, int available) int number, dec; float multi = 2.0F * rc->recruit_multi; - number = MIN(req->qty, (int)(get / multi)); + number = _min(req->qty, (int)(get / multi)); if (rc->recruitcost) { int afford = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, number * rc->recruitcost) / rc->recruitcost; - number = MIN(number, afford); + number = _min(number, afford); } if (u->number + number > UNIT_MAXSIZE) { ADDMSG(&u->faction->msgs, msg_feedback(u, req->ord, "error_unit_size", @@ -615,7 +615,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders) if (recruitcost > 0) { int pooled = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, recruitcost * n); - n = MIN(n, pooled / recruitcost); + n = _min(n, pooled / recruitcost); } u->wants = n; @@ -637,7 +637,7 @@ static void friendly_takeover(region * r, faction * f) int morale = region_get_morale(r); region_set_owner(r, f, turn); if (morale > 0) { - morale = MAX(0, morale - MORALE_TRANSFER); + morale = _max(0, morale - MORALE_TRANSFER); region_set_morale(r, morale, turn); } } @@ -1229,7 +1229,7 @@ static int recruit_archetype(unit * u, order * ord) if (a != NULL) { maxsize -= a->data.i; } - n = MIN(maxsize / arch->size, n); + n = _min(maxsize / arch->size, n); if (n <= 0) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "recruit_capacity_exhausted", "building", u->building)); @@ -1560,12 +1560,12 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) /* mit Flinkfingerring verzehnfacht sich die Produktion */ amount += - skill * MIN(u->number, get_item(u, + skill * _min(u->number, get_item(u, I_RING_OF_NIMBLEFINGER)) * (roqf_factor() - 1); /* Schaffenstrunk: */ if ((dm = get_effect(u, oldpotiontype[P_DOMORE])) != 0) { - dm = MIN(dm, u->number); + dm = _min(dm, u->number); change_effect(u, oldpotiontype[P_DOMORE], -dm); amount += dm * skill; /* dm Personen produzieren doppelt */ } @@ -1659,7 +1659,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) } need = norders; - avail = MIN(avail, norders); + avail = _min(avail, norders); if (need > 0) { int use = 0; for (al = alist; al; al = al->next) @@ -1674,7 +1674,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) use += x; norders -= want; need -= x; - al->get = MIN(al->want, al->get + (int)(x / al->save)); + al->get = _min(al->want, al->get + (int)(x / al->save)); } } if (use) { @@ -1707,7 +1707,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) avail = 0; } - avail = MIN(avail, norders); + avail = _min(avail, norders); for (al = alist; al; al = al->next) { if (avail > 0) { int want = required(al->want, al->save); @@ -1717,7 +1717,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) ++x; avail -= x; norders -= want; - al->get = MIN(al->want, (int)(x / al->save)); + al->get = _min(al->want, (int)(x / al->save)); if (rdata->produce) { int use = required(al->get, al->save); if (use) @@ -2159,7 +2159,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord) k -= a->data.i; } - n = MIN(n, k); + n = _min(n, k); if (!n) { cmistake(u, ord, 102, MSG_COMMERCE); @@ -2453,7 +2453,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) /* Ein Händler kann nur 10 Güter pro Talentpunkt verkaufen. */ - n = MIN(n, u->number * 10 * eff_skill(u, SK_TRADE, r)); + n = _min(n, u->number * 10 * eff_skill(u, SK_TRADE, r)); if (!n) { cmistake(u, ord, 54, MSG_COMMERCE); @@ -2483,11 +2483,11 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) if (o->type.ltype == ltype && o->unit->faction == u->faction) { int fpool = o->qty - get_pooled(o->unit, itype->rtype, GET_RESERVE, INT_MAX); - available -= MAX(0, fpool); + available -= _max(0, fpool); } } - n = MIN(n, available); + n = _min(n, available); if (n <= 0) { cmistake(u, ord, 264, MSG_COMMERCE); @@ -2511,7 +2511,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) k -= a->data.i; } - n = MIN(n, k); + n = _min(n, k); assert(n >= 0); /* die Menge der verkauften Güter merken */ a->data.i += n; @@ -2566,7 +2566,7 @@ static void expandstealing(region * r, request * stealorders) n = 10; } if (n > 0) { - n = MIN(n, oa[i].unit->wants); + n = _min(n, oa[i].unit->wants); use_pooled(u, r_silver, GET_ALL, n); oa[i].unit->n = n; change_money(oa[i].unit, n); @@ -2621,8 +2621,8 @@ static void plant(region * r, unit * u, int raw) return; } - n = MIN(skill * u->number, n); - n = MIN(raw, n); + n = _min(skill * u->number, n); + n = _min(raw, n); /* Für jedes Kraut Talent*10% Erfolgschance. */ for (i = n; i > 0; i--) { if (rng_int() % 10 < skill) @@ -2670,14 +2670,14 @@ static void planttrees(region * r, unit * u, int raw) } /* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */ - raw = MIN(raw, skill * u->number); + raw = _min(raw, skill * u->number); n = get_pooled(u, rtype, GET_DEFAULT, raw); if (n == 0) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype)); return; } - n = MIN(raw, n); + n = _min(raw, n); /* Für jeden Samen Talent*10% Erfolgschance. */ for (i = n; i > 0; i--) { @@ -2734,7 +2734,7 @@ static void breedtrees(region * r, unit * u, int raw) } /* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */ - raw = MIN(skill * u->number, raw); + raw = _min(skill * u->number, raw); n = get_pooled(u, rtype, GET_DEFAULT, raw); /* Samen prüfen */ if (n == 0) { @@ -2742,7 +2742,7 @@ static void breedtrees(region * r, unit * u, int raw) msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype)); return; } - n = MIN(raw, n); + n = _min(raw, n); /* Für jeden Samen Talent*5% Erfolgschance. */ for (i = n; i > 0; i--) { @@ -2775,7 +2775,7 @@ static void breedhorses(region * r, unit * u) cmistake(u, u->thisorder, 107, MSG_PRODUCE); return; } - n = MIN(u->number * eff_skill(u, SK_HORSE_TRAINING, r), get_item(u, I_HORSE)); + n = _min(u->number * eff_skill(u, SK_HORSE_TRAINING, r), get_item(u, I_HORSE)); for (c = 0; c < n; c++) { if (rng_int() % 100 < eff_skill(u, SK_HORSE_TRAINING, r)) { @@ -3003,7 +3003,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders) } } - i = MIN(u->number, get_item(u, I_RING_OF_NIMBLEFINGER)); + i = _min(u->number, get_item(u, I_RING_OF_NIMBLEFINGER)); if (i > 0) { n *= STEALINCOME * (u->number + i * (roqf_factor() - 1)); } else { @@ -3024,7 +3024,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders) /* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */ - produceexp(u, SK_STEALTH, MIN(n, u->number)); + produceexp(u, SK_STEALTH, _min(n, u->number)); } /* ------------------------------------------------------------- */ @@ -3048,7 +3048,7 @@ static void expandentertainment(region * r) entertaining -= o->qty; /* Nur soviel PRODUCEEXP wie auch tatsächlich gemacht wurde */ - produceexp(u, SK_ENTERTAINMENT, MIN(u->n, u->number)); + produceexp(u, SK_ENTERTAINMENT, _min(u->n, u->number)); add_income(u, IC_ENTERTAIN, o->qty, u->n); fset(u, UFL_LONGACTION | UFL_NOTMOVING); } @@ -3098,7 +3098,7 @@ void entertain_cmd(unit * u, struct order *ord) skip_token(); max_e = getuint(); if (max_e != 0) { - u->wants = MIN(u->wants, max_e); + u->wants = _min(u->wants, max_e); } o = nextentertainer++; o->unit = u; @@ -3161,7 +3161,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork) if (blessedharvest_ct && r->attribs) { int happy = (int)curse_geteffect(get_curse(r->attribs, blessedharvest_ct)); - happy = MIN(happy, jobs); + happy = _min(happy, jobs); earnings += happy; } } @@ -3263,9 +3263,9 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders) if (max == 0) max = INT_MAX; if (!playerrace(u_race(u))) { - u->wants = MIN(income(u), max); + u->wants = _min(income(u), max); } else { - u->wants = MIN(n * eff_skill(u, SK_TAXING, r) * 20, max); + u->wants = _min(n * eff_skill(u, SK_TAXING, r) * 20, max); } u2 = is_guarded(r, u, GUARD_TAX); diff --git a/src/give.c b/src/give.c index a2d0a83b3..c6760f671 100644 --- a/src/give.c +++ b/src/give.c @@ -124,7 +124,7 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, assert(itype != NULL); n = get_pooled(src, item2resource(itype), GET_DEFAULT, want); - n = MIN(want, n); + n = _min(want, n); r = n; if (dest && src->faction != dest->faction && src->faction->age < GiveRestriction()) { diff --git a/src/items/weapons.c b/src/items/weapons.c index 9eb3d8d72..e80e850e5 100644 --- a/src/items/weapons.c +++ b/src/items/weapons.c @@ -111,7 +111,7 @@ attack_catapult(const troop * at, const struct weapon_type *wtype, } enemies = count_enemies(b, af, FIGHT_ROW, FIGHT_ROW, SELECT_ADVANCE); - enemies = MIN(enemies, CATAPULT_ATTACKS); + enemies = _min(enemies, CATAPULT_ATTACKS); if (enemies == 0) { return true; /* allow further attacks */ } diff --git a/src/items/xerewards.c b/src/items/xerewards.c index 26cd621bb..08a92c92e 100644 --- a/src/items/xerewards.c +++ b/src/items/xerewards.c @@ -76,7 +76,7 @@ use_manacrystal(struct unit *u, const struct item_type *itype, int amount, } for (i = 0; i != amount; ++i) { - sp += MAX(25, max_spellpoints(u->region, u) / 2); + sp += _max(25, max_spellpoints(u->region, u) / 2); change_spellpoints(u, sp); } diff --git a/src/kernel/alchemy.c b/src/kernel/alchemy.c index c7e4d2979..07501b215 100644 --- a/src/kernel/alchemy.c +++ b/src/kernel/alchemy.c @@ -70,12 +70,12 @@ void herbsearch(region * r, unit * u, int max) } if (max) - max = MIN(max, rherbs(r)); + max = _min(max, rherbs(r)); else max = rherbs(r); herbsfound = ntimespprob(eff_skill(u, SK_HERBALISM, r) * u->number, (double)rherbs(r) / 100.0F, -0.01F); - herbsfound = MIN(herbsfound, max); + herbsfound = _min(herbsfound, max); rsetherbs(r, rherbs(r) - herbsfound); if (herbsfound) { @@ -153,7 +153,7 @@ static int do_potion(unit * u, region *r, const potion_type * ptype, int amount) ADDMSG(&u->faction->msgs, msg_message("growtree_effect", "mage amount", u, holz)); } else if (ptype == oldpotiontype[P_HEILWASSER]) { - u->hp = MIN(unit_max_hp(u) * u->number, u->hp + 400 * amount); + u->hp = _min(unit_max_hp(u) * u->number, u->hp + 400 * amount); } else if (ptype == oldpotiontype[P_PEOPLE]) { attrib *a = (attrib *) a_find(r->attribs, &at_peasantluck); if (!a) @@ -169,7 +169,7 @@ static int do_potion(unit * u, region *r, const potion_type * ptype, int amount) amount = 1; } else if (ptype == oldpotiontype[P_MACHT]) { /* Verfünffacht die HP von max. 10 Personen in der Einheit */ - u->hp += MIN(u->number, 10 * amount) * unit_max_hp(u) * 4; + u->hp += _min(u->number, 10 * amount) * unit_max_hp(u) * 4; } else { change_effect(u, ptype, 10 * amount); } diff --git a/src/kernel/battle.c b/src/kernel/battle.c index 22ac2c6e0..7561ce1cc 100644 --- a/src/kernel/battle.c +++ b/src/kernel/battle.c @@ -235,7 +235,7 @@ int armedmen(const unit * u, bool siege_weapons) if (n > u->number) break; } - n = MIN(n, u->number); + n = _min(n, u->number); } } return n; @@ -464,7 +464,7 @@ static int get_row(const side * s, int row, const side * vs) /* every entry in the size[] array means someone trying to defend us. * 'retreat' is the number of rows falling. */ - result = MAX(FIRST_ROW, row - retreat); + result = _max(FIRST_ROW, row - retreat); return result; } @@ -627,11 +627,11 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking) if (u_race(u) == new_race[RC_ORC]) { int sword = effskill(u, SK_MELEE); int spear = effskill(u, SK_SPEAR); - skill = MAX(sword, spear) - 3; + skill = _max(sword, spear) - 3; if (attacking) { - skill = MAX(skill, u_race(u)->at_default); + skill = _max(skill, u_race(u)->at_default); } else { - skill = MAX(skill, u_race(u)->df_default); + skill = _max(skill, u_race(u)->df_default); } } else { if (attacking) { @@ -712,7 +712,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type) /* only half against trolls */ if (skl > 0) { if (type == BONUS_DAMAGE) { - int dmg = MIN(skl, 8); + int dmg = _min(skl, 8); if (u_race(enemy.fighter->unit) == new_race[RC_TROLL]) { dmg = dmg / 4; } else { @@ -721,7 +721,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type) return dmg; } else { skl = skl / 2; - return MIN(skl, 4); + return _min(skl, 4); } } } @@ -849,7 +849,7 @@ int select_magicarmor(troop t) int geschuetzt = 0; int ma = 0; - geschuetzt = MIN(get_item(u, I_TROLLBELT), u->number); + geschuetzt = _min(get_item(u, I_TROLLBELT), u->number); if (geschuetzt > t.index) /* unser Kandidat wird geschuetzt */ ma += 1; @@ -1025,7 +1025,7 @@ static void vampirism(troop at, int damage) if (gain > 0) { int maxhp = unit_max_hp(at.fighter->unit); at.fighter->person[at.index].hp = - MIN(gain + at.fighter->person[at.index].hp, maxhp); + _min(gain + at.fighter->person[at.index].hp, maxhp); } } } @@ -1159,8 +1159,8 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) if (damage_rules & DAMAGE_CRITICAL) { double kritchance = (sk * 3 - sd) / 200.0; - kritchance = MAX(kritchance, 0.005); - kritchance = MIN(0.9, kritchance); + kritchance = _max(kritchance, 0.005); + kritchance = _min(0.9, kritchance); while (chance(kritchance)) { if (bdebug) { @@ -1191,7 +1191,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) /* Skilldifferenzbonus */ if (damage_rules & DAMAGE_SKILL_BONUS) { - da += MAX(0, (sk - sd) / DAMAGE_QUOTIENT); + da += _max(0, (sk - sd) / DAMAGE_QUOTIENT); } } @@ -1218,13 +1218,13 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) } if (res > 0) { - da = (int)(MAX(da * res, 0)); + da = (int)(_max(da * res, 0)); } /* gegen Magie wirkt nur natürliche und magische Rüstung */ ar = an + am; } - rda = MAX(da - ar, 0); + rda = _max(da - ar, 0); if ((u_race(du)->battle_flags & BF_INV_NONMAGIC) && !magic) rda = 0; @@ -1257,7 +1257,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) } /* gibt Rüstung +effect für duration Treffer */ if (me->typ == SHIELD_ARMOR) { - rda = MAX(rda - me->effect, 0); + rda = _max(rda - me->effect, 0); me->duration--; } } @@ -1470,7 +1470,7 @@ troop select_enemy(fighter * af, int minrow, int maxrow, int select) minrow = FIGHT_ROW; maxrow = BEHIND_ROW; } - minrow = MAX(minrow, FIGHT_ROW); + minrow = _max(minrow, FIGHT_ROW); enemies = count_enemies(b, af, minrow, maxrow, select); @@ -1569,7 +1569,7 @@ static troop select_opponent(battle * b, troop at, int mindist, int maxdist) * them */ dt = select_enemy(at.fighter, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); } else { - mindist = MAX(mindist, FIGHT_ROW); + mindist = _max(mindist, FIGHT_ROW); dt = select_enemy(at.fighter, mindist, maxdist, SELECT_ADVANCE); } @@ -1691,7 +1691,7 @@ void do_combatmagic(battle * b, combatmagic_t was) level = eff_spelllevel(mage, sp, level, 1); if (sl > 0) - level = MIN(sl, level); + level = _min(sl, level); if (level < 0) { report_failed_spell(b, mage, sp); free_order(ord); @@ -1777,7 +1777,7 @@ static void do_combatspell(troop at) level = eff_spelllevel(caster, sp, fi->magic, 1); if ((sl = get_combatspelllevel(caster, 1)) > 0) - level = MIN(level, sl); + level = _min(level, sl); if (fumble(r, caster, sp, level)) { report_failed_spell(b, caster, sp); @@ -2024,7 +2024,7 @@ void dazzle(battle * b, troop * td) void damage_building(battle * b, building * bldg, int damage_abs) { - bldg->size = MAX(1, bldg->size - damage_abs); + bldg->size = _max(1, bldg->size - damage_abs); /* Wenn Burg, dann gucken, ob die Leute alle noch in das Gebäude passen. */ @@ -2297,7 +2297,7 @@ void do_regenerate(fighter * af) while (ta.index--) { af->person[ta.index].hp += effskill(au, SK_STAMINA); - af->person[ta.index].hp = MIN(unit_max_hp(au), af->person[ta.index].hp); + af->person[ta.index].hp = _min(unit_max_hp(au), af->person[ta.index].hp); } } @@ -2364,9 +2364,9 @@ double fleechance(unit * u) if (u_race(u) == new_race[RC_HALFLING]) { c += 0.20; - c = MIN(c, 0.90); + c = _min(c, 0.90); } else { - c = MIN(c, 0.75); + c = _min(c, 0.75); } if (a != NULL) @@ -2492,7 +2492,7 @@ static void loot_items(fighter * corpse) float lootfactor = dead / (float)u->number; /* only loot the dead! */ int maxloot = (int)(itm->number * lootfactor); if (maxloot > 0) { - int i = MIN(10, maxloot); + int i = _min(10, maxloot); for (; i != 0; --i) { int loot = maxloot / i; @@ -2585,7 +2585,7 @@ static void battle_effects(battle * b, int dead_players) { region *r = b->region; int dead_peasants = - MIN(rpeasants(r), (int)(dead_players * PopulationDamage())); + _min(rpeasants(r), (int)(dead_players * PopulationDamage())); if (dead_peasants) { deathcounts(r, dead_peasants + dead_players); chaoscounts(r, dead_peasants / 2); @@ -3102,7 +3102,7 @@ static void print_stats(battle * b) for (s = b->sides; s != b->sides + b->nsides; ++s) { if (!ql_empty(s->leader.fighters)) { - b->max_tactics = MAX(b->max_tactics, s->leader.value); + b->max_tactics = _max(b->max_tactics, s->leader.value); } } @@ -3271,7 +3271,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) /* change_effect wird in ageing gemacht */ /* Effekte von Artefakten */ - strongmen = MIN(fig->unit->number, get_item(u, I_TROLLBELT)); + strongmen = _min(fig->unit->number, get_item(u, I_TROLLBELT)); /* Hitpoints, Attack- und Defence-Boni für alle Personen */ for (i = 0; i < fig->alive; i++) { @@ -3467,7 +3467,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) else p_bonus += 3; } while (rnd >= 97); - bonus = MAX(p_bonus, bonus); + bonus = _max(p_bonus, bonus); } tactics += bonus; } @@ -3607,7 +3607,7 @@ battle *make_battle(region * r) for (bf = b->factions; bf; bf = bf->next) { faction *f = bf->faction; - max_fac_no = MAX(max_fac_no, f->no); + max_fac_no = _max(max_fac_no, f->no); freset(f, FFL_MARK); } return b; @@ -3645,7 +3645,7 @@ static void free_battle(battle * b) bfaction *bf = b->factions; faction *f = bf->faction; b->factions = bf->next; - max_fac_no = MAX(max_fac_no, f->no); + max_fac_no = _max(max_fac_no, f->no); free(bf); } @@ -4203,7 +4203,7 @@ static void battle_flee(battle * b) troop dt; int runners = 0; /* Flucht nicht bei mehr als 600 HP. Damit Wyrme tötbar bleiben. */ - int runhp = MIN(600, (int)(0.9 + unit_max_hp(u) * hpflee(u->status))); + int runhp = _min(600, (int)(0.9 + unit_max_hp(u) * hpflee(u->status))); if (u->ship && fval(u->region->terrain, SEA_REGION)) { /* keine Flucht von Schiffen auf hoher See */ @@ -4248,7 +4248,7 @@ static void battle_flee(battle * b) if (fig->person[dt.index].flags & FL_PANICED) { ispaniced = EFFECT_PANIC_SPELL; } - if (chance(MIN(fleechance(u) + ispaniced, 0.90))) { + if (chance(_min(fleechance(u) + ispaniced, 0.90))) { ++runners; flee(dt); } diff --git a/src/kernel/build.c b/src/kernel/build.c index 1a6f52a11..79963d2cc 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -117,11 +117,11 @@ static void destroy_road(unit * u, int nmax, struct order *ord) cmistake(u, ord, 71, MSG_PRODUCE); } else { short road = rroad(r, d); - n = MIN(n, road); + n = _min(n, road); if (n != 0) { region *r2 = rconnect(r, d); int willdo = eff_skill(u, SK_ROAD_BUILDING, r) * u->number; - willdo = MIN(willdo, n); + willdo = _min(willdo, n); if (willdo == 0) { /* TODO: error message */ } @@ -318,7 +318,7 @@ void build_road(region * r, unit * u, int size, direction_t d) } if (size > 0) - left = MIN(size, left); + left = _min(size, left); /* baumaximum anhand der rohstoffe */ if (u_race(u) == new_race[RC_STONEGOLEM]) { n = u->number * GOLEM_STONE; @@ -329,14 +329,14 @@ void build_road(region * r, unit * u, int size, direction_t d) return; } } - left = MIN(n, left); + left = _min(n, left); /* n = maximum by skill. try to maximize it */ n = u->number * eff_skill(u, SK_ROAD_BUILDING, r); if (n < left) { item *itm = *i_find(&u->items, olditemtype[I_RING_OF_NIMBLEFINGER]); if (itm != NULL && itm->number > 0) { - int rings = MIN(u->number, itm->number); + int rings = _min(u->number, itm->number); n = n * ((roqf_factor() - 1) * rings + u->number) / u->number; } } @@ -345,15 +345,15 @@ void build_road(region * r, unit * u, int size, direction_t d) if (dm != 0) { int sk = eff_skill(u, SK_ROAD_BUILDING, r); int todo = (left - n + sk - 1) / sk; - todo = MIN(todo, u->number); - dm = MIN(dm, todo); + todo = _min(todo, u->number); + dm = _min(dm, todo); change_effect(u, oldpotiontype[P_DOMORE], -dm); n += dm * sk; } /* Auswirkung Schaffenstrunk */ } /* make minimum of possible and available: */ - n = MIN(left, n); + n = _min(left, n); /* n is now modified by several special effects, so we have to * minimize it again to make sure the road will not grow beyond @@ -369,7 +369,7 @@ void build_road(region * r, unit * u, int size, direction_t d) } else { use_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT, n); /* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */ - produceexp(u, SK_ROAD_BUILDING, MIN(n, u->number)); + produceexp(u, SK_ROAD_BUILDING, _min(n, u->number)); } ADDMSG(&u->faction->msgs, msg_message("buildroad", "region unit size", r, u, n)); @@ -473,7 +473,7 @@ int build(unit * u, const construction * ctype, int completed, int want) if (dm != 0) { /* Auswirkung Schaffenstrunk */ - dm = MIN(dm, u->number); + dm = _min(dm, u->number); change_effect(u, oldpotiontype[P_DOMORE], -dm); skills += dm * effsk; } @@ -529,17 +529,17 @@ int build(unit * u, const construction * ctype, int completed, int want) if (itm != NULL) i = itm->number; if (i > 0) { - int rings = MIN(u->number, i); + int rings = _min(u->number, i); n = n * ((roqf_factor() - 1) * rings + u->number) / u->number; } } if (want > 0) { - n = MIN(want, n); + n = _min(want, n); } if (type->maxsize > 0) { - n = MIN(type->maxsize - completed, n); + n = _min(type->maxsize - completed, n); if (type->improvement == NULL) { want = n; } @@ -610,7 +610,7 @@ int build(unit * u, const construction * ctype, int completed, int want) completed = completed + n; } /* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */ - produceexp(u, ctype->skill, MIN(made, u->number)); + produceexp(u, ctype->skill, _min(made, u->number)); return made; } @@ -647,7 +647,7 @@ int maxbuild(const unit * u, const construction * cons) if (have < need) { return 0; } else - maximum = MIN(maximum, have / need); + maximum = _min(maximum, have / need); } return maximum; } @@ -853,7 +853,7 @@ static void build_ship(unit * u, ship * sh, int want) } if (sh->damage && can) { - int repair = MIN(sh->damage, can * DAMAGE_SCALE); + int repair = _min(sh->damage, can * DAMAGE_SCALE); n += repair / DAMAGE_SCALE; if (repair % DAMAGE_SCALE) ++n; @@ -897,7 +897,7 @@ create_ship(region * r, unit * u, const struct ship_type *newtype, int want, return; } if (want > 0) - want = MIN(want, msize); + want = _min(want, msize); else want = msize; @@ -956,7 +956,7 @@ void continue_ship(region * r, unit * u, int want) return; } if (want > 0) - want = MIN(want, msize); + want = _min(want, msize); else want = msize; diff --git a/src/kernel/building.c b/src/kernel/building.c index f8a749187..4cb556e3e 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -158,7 +158,7 @@ int buildingcapacity(const building * b) { if (b->type->capacity >= 0) { if (b->type->maxcapacity >= 0) { - return MIN(b->type->maxcapacity, b->size * b->type->capacity); + return _min(b->type->maxcapacity, b->size * b->type->capacity); } return b->size * b->type->capacity; } diff --git a/src/kernel/config.c b/src/kernel/config.c index e4478bc12..e1647d7e4 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -1723,7 +1723,7 @@ int maxworkingpeasants(const struct region *r) { int i = production(r) * MAXPEASANTS_PER_AREA - ((rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE); - return MAX(i, 0); + return _max(i, 0); } int lighthouse_range(const building * b, const faction * f) @@ -1743,8 +1743,8 @@ int lighthouse_range(const building * b, const faction * f) break; if (f == NULL || u->faction == f) { int sk = eff_skill(u, SK_PERCEPTION, r) / 3; - d = MAX(d, sk); - d = MIN(maxd, d); + d = _max(d, sk); + d = _min(maxd, d); if (d == maxd) break; } @@ -2528,7 +2528,7 @@ void plagues(region * r, bool ismagic) /* Seuchenwahrscheinlichkeit in % */ if (!ismagic) { - double mwp = MAX(maxworkingpeasants(r), 1); + double mwp = _max(maxworkingpeasants(r), 1); double prob = pow(rpeasants(r) / (mwp * wage(r, NULL, NULL, turn) * 0.13), 4.0) * PLAGUE_CHANCE; @@ -2797,7 +2797,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn) /* Godcurse: Income -10 */ if (curse_active(get_curse(r->attribs, ct_find("godcursezone")))) { - wage = MAX(0, wage - 10); + wage = _max(0, wage - 10); } /* Bei einer Dürre verdient man nur noch ein Viertel */ diff --git a/src/kernel/connection.c b/src/kernel/connection.c index 7bfd0c6e6..9d72a6502 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -105,7 +105,7 @@ static connection **get_borders_i(const region * r1, const region * r2) int key = reg_hashkey(r1); int k2 = reg_hashkey(r2); - key = MIN(k2, key) % BORDER_MAXHASH; + key = _min(k2, key) % BORDER_MAXHASH; bp = &borders[key]; while (*bp) { connection *b = *bp; @@ -535,7 +535,7 @@ static const char *b_nameroad(const connection * b, const region * r, return LOC(f->locale, mkname("border", "an_incomplete_road")); } } else { - int percent = MAX(1, 100 * local / r->terrain->max_road); + int percent = _max(1, 100 * local / r->terrain->max_road); if (local) { slprintf(buffer, sizeof(buffer), LOC(f->locale, mkname("border", "a_road_percent")), percent); diff --git a/src/kernel/curse.c b/src/kernel/curse.c index 46d7aad43..dd722b828 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -129,7 +129,7 @@ int curse_age(attrib * a) if (result != 0) { c->duration = 0; } else if (c->duration != INT_MAX) { - c->duration = MAX(0, c->duration - 1); + c->duration = _max(0, c->duration - 1); } return c->duration; } @@ -315,7 +315,7 @@ const curse_type *ct_find(const char *c) if (strcmp(c, type->cname) == 0) { return type; } else { - size_t k = MIN(strlen(c), strlen(type->cname)); + size_t k = _min(strlen(c), strlen(type->cname)); if (!_memicmp(c, type->cname, k)) { return type; } @@ -478,7 +478,7 @@ int get_cursedmen(unit * u, const curse * c) cursedmen = c->data.i; } - return MIN(u->number, cursedmen); + return _min(u->number, cursedmen); } /* setzt die Anzahl der betroffenen Personen auf cursedmen */ @@ -552,7 +552,7 @@ curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct, /* es gibt schon eins diese Typs */ if (c && ct->mergeflags != NO_MERGE) { if (ct->mergeflags & M_DURATION) { - c->duration = MAX(c->duration, duration); + c->duration = _max(c->duration, duration); } if (ct->mergeflags & M_SUMDURATION) { c->duration += duration; @@ -561,10 +561,10 @@ curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct, c->effect += effect; } if (ct->mergeflags & M_MAXEFFECT) { - c->effect = MAX(c->effect, effect); + c->effect = _max(c->effect, effect); } if (ct->mergeflags & M_VIGOUR) { - c->vigour = MAX(vigour, c->vigour); + c->vigour = _max(vigour, c->vigour); } if (ct->mergeflags & M_VIGOUR_ADD) { c->vigour = vigour + c->vigour; diff --git a/src/kernel/group.c b/src/kernel/group.c index 2a5098490..99e2a1a61 100755 --- a/src/kernel/group.c +++ b/src/kernel/group.c @@ -58,7 +58,7 @@ static group *new_group(faction * f, const char *name, int gid) gp = &(*gp)->next; *gp = g; - maxgid = MAX(gid, maxgid); + maxgid = _max(gid, maxgid); g->name = _strdup(name); g->gid = gid; diff --git a/src/kernel/item.c b/src/kernel/item.c index c7ed8304b..ef7d3eb8f 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -746,7 +746,7 @@ static int heal(unit * user, int effect) { int req = unit_max_hp(user) * user->number - user->hp; if (req > 0) { - req = MIN(req, effect); + req = _min(req, effect); effect -= req; user->hp += req; } diff --git a/src/kernel/magic.c b/src/kernel/magic.c index 95b5ec0ff..c3970bed4 100644 --- a/src/kernel/magic.c +++ b/src/kernel/magic.c @@ -540,7 +540,7 @@ int get_combatspelllevel(const unit * u, int nr) assert(nr < MAXCOMBATSPELLS); if (m) { int level = eff_skill(u, SK_MAGIC, u->region); - return MIN(m->combatspells[nr].level, level); + return _min(m->combatspells[nr].level, level); } return -1; } @@ -672,7 +672,7 @@ int change_spellpoints(unit * u, int mp) } /* verhindere negative Magiepunkte */ - sp = MAX(m->spellpoints + mp, 0); + sp = _max(m->spellpoints + mp, 0); m->spellpoints = sp; return sp; @@ -730,7 +730,7 @@ int max_spellpoints(const region * r, const unit * u) if (n > 0) msp = (msp * n) / 100; - return MAX((int)msp, 0); + return _max((int)msp, 0); } int change_maxspellpoints(unit * u, int csp) @@ -765,7 +765,7 @@ int countspells(unit * u, int step) count = m->spellcount + step; /* negative Werte abfangen. */ - m->spellcount = MAX(0, count); + m->spellcount = _max(0, count); return m->spellcount; } @@ -854,7 +854,7 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range) * gewünschten gebildet */ } else if (sp->components[k].cost == SPC_LEVEL) { costtyp = SPC_LEVEL; - cast_level = MIN(cast_level, maxlevel); + cast_level = _min(cast_level, maxlevel); /* bei Typ Linear müssen die Kosten in Höhe der Stufe vorhanden * sein, ansonsten schlägt der Spruch fehl */ } else if (sp->components[k].cost == SPC_LINEAR) { @@ -871,7 +871,7 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range) if (spells) { spellbook_entry * sbe = spellbook_get(spells, sp); if (sbe) { - return MIN(cast_level, sbe->level); + return _min(cast_level, sbe->level); } } log_error("spell %s is not in the spellbook for %s\n", sp->sname, unitname(u)); @@ -1069,7 +1069,7 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, force = force * MagicPower(); - return MAX(force, 0); + return _max(force, 0); } /* ------------------------------------------------------------- */ @@ -1235,8 +1235,8 @@ target_resists_magic(unit * magician, void *obj, int objtyp, int t_bonus) break; } - probability = MAX(0.02, probability + t_bonus * 0.01); - probability = MIN(0.98, probability); + probability = _max(0.02, probability + t_bonus * 0.01); + probability = _min(0.98, probability); /* gibt true, wenn die Zufallszahl kleiner als die chance ist und * false, wenn sie gleich oder größer ist, dh je größer die @@ -1376,7 +1376,7 @@ static void do_fumble(castorder * co) case 2: /* temporärer Stufenverlust */ - duration = MAX(rng_int() % level / 2, 2); + duration = _max(rng_int() % level / 2, 2); effect = -(float)level/2; c = create_curse(u, &u->attribs, ct_find("skillmod"), (float)level, @@ -1487,14 +1487,14 @@ void regenerate_aura(void) reg_aura -= regen; if (chance(reg_aura)) ++regen; - regen = MAX(1, regen); - regen = MIN((auramax - aura), regen); + regen = _max(1, regen); + regen = _min((auramax - aura), regen); aura += regen; ADDMSG(&u->faction->msgs, msg_message("regenaura", "unit region amount", u, r, regen)); } - set_spellpoints(u, MIN(aura, auramax)); + set_spellpoints(u, _min(aura, auramax)); } } } @@ -2508,7 +2508,7 @@ static castorder *cast_cmd(unit * u, order * ord) /* für Syntax ' STUFE x REGION y z ' */ if (param == P_LEVEL) { int p = getint(); - level = MIN(p, level); + level = _min(p, level); if (level < 1) { /* Fehler "Das macht wenig Sinn" */ cmistake(u, ord, 10, MSG_MAGIC); @@ -2538,7 +2538,7 @@ static castorder *cast_cmd(unit * u, order * ord) * hier nach REGION nochmal auf STUFE prüfen */ if (param == P_LEVEL) { int p = getint(); - level = MIN(p, level); + level = _min(p, level); if (level < 1) { /* Fehler "Das macht wenig Sinn" */ cmistake(u, ord, 10, MSG_MAGIC); @@ -2667,7 +2667,7 @@ static castorder *cast_cmd(unit * u, order * ord) * löschen, zaubern kann er noch */ range *= 2; set_order(&caster->thisorder, NULL); - level = MIN(level, eff_skill(caster, SK_MAGIC, caster->region) / 2); + level = _min(level, eff_skill(caster, SK_MAGIC, caster->region) / 2); } } /* Weitere Argumente zusammenbasteln */ diff --git a/src/kernel/move.c b/src/kernel/move.c index 72bacb310..fb975adb8 100644 --- a/src/kernel/move.c +++ b/src/kernel/move.c @@ -257,12 +257,12 @@ static int ridingcapacity(unit * u) ** tragen nichts (siehe walkingcapacity). Ein Wagen zählt nur, wenn er ** von zwei Pferden gezogen wird */ - animals = MIN(animals, effskill(u, SK_RIDING) * u->number * 2); + animals = _min(animals, effskill(u, SK_RIDING) * u->number * 2); if (fval(u_race(u), RCF_HORSE)) animals += u->number; /* maximal diese Pferde können zum Ziehen benutzt werden */ - vehicles = MIN(animals / HORSESNEEDED, vehicles); + vehicles = _min(animals / HORSESNEEDED, vehicles); return vehicles * vcap + animals * acap; } @@ -279,7 +279,7 @@ int walkingcapacity(const struct unit *u) /* Das Gewicht, welches die Pferde tragen, plus das Gewicht, welches * die Leute tragen */ - pferde_fuer_wagen = MIN(animals, effskill(u, SK_RIDING) * u->number * 4); + pferde_fuer_wagen = _min(animals, effskill(u, SK_RIDING) * u->number * 4); if (fval(u_race(u), RCF_HORSE)) { animals += u->number; people = 0; @@ -288,7 +288,7 @@ int walkingcapacity(const struct unit *u) } /* maximal diese Pferde können zum Ziehen benutzt werden */ - wagen_mit_pferden = MIN(vehicles, pferde_fuer_wagen / HORSESNEEDED); + wagen_mit_pferden = _min(vehicles, pferde_fuer_wagen / HORSESNEEDED); n = wagen_mit_pferden * vcap; @@ -298,7 +298,7 @@ int walkingcapacity(const struct unit *u) wagen_ohne_pferde = vehicles - wagen_mit_pferden; /* Genug Trolle, um die Restwagen zu ziehen? */ - wagen_mit_trollen = MIN(u->number / 4, wagen_ohne_pferde); + wagen_mit_trollen = _min(u->number / 4, wagen_ohne_pferde); /* Wagenkapazität hinzuzählen */ n += wagen_mit_trollen * vcap; @@ -317,7 +317,7 @@ int walkingcapacity(const struct unit *u) } /* change_effect wird in ageing gemacht */ tmp = get_item(u, I_TROLLBELT); - n += MIN(people, tmp) * (STRENGTHMULTIPLIER - 1) * personcapacity(u); + n += _min(people, tmp) * (STRENGTHMULTIPLIER - 1) * personcapacity(u); return n; } @@ -345,7 +345,7 @@ static int canwalk(unit * u) maxwagen = effskill(u, SK_RIDING) * u->number * 2; if (u_race(u) == new_race[RC_TROLL]) { - maxwagen = MAX(maxwagen, u->number / 4); + maxwagen = _max(maxwagen, u->number / 4); } maxpferde = effskill(u, SK_RIDING) * u->number * 4 + u->number; @@ -854,7 +854,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r) if (!contact && guard) { double prob = 0.3; /* 30% base chance */ prob += 0.1 * (perception - eff_stealth(reisender, r)); - prob += 0.1 * MIN(guard->number, get_item(guard, I_AMULET_OF_TRUE_SEEING)); + prob += 0.1 * _min(guard->number, get_item(guard, I_AMULET_OF_TRUE_SEEING)); if (chance(prob)) { return guard; @@ -1927,7 +1927,7 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep) const luxury_type *ltype = resource2luxury(itm->type->rtype); if (ltype != NULL && itm->number > 0) { int st = itm->number * effskill(hafenmeister, SK_TRADE) / 50; - st = MIN(itm->number, st); + st = _min(itm->number, st); if (st > 0) { i_change(&u2->items, itm->type, -st); diff --git a/src/kernel/names.c b/src/kernel/names.c index 3a26c7b22..706d53c33 100644 --- a/src/kernel/names.c +++ b/src/kernel/names.c @@ -417,9 +417,9 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) } } - /* Buchstaben pro Teilkürzel = MAX(1,max/AnzWort) */ + /* Buchstaben pro Teilkürzel = _max(1,max/AnzWort) */ - bpt = MAX(1, maxchars / c); + bpt = _max(1, maxchars / c); /* Einzelne Wörter anspringen und jeweils die ersten BpT kopieren */ diff --git a/src/kernel/pool.c b/src/kernel/pool.c index 954cdb164..72234142f 100644 --- a/src/kernel/pool.c +++ b/src/kernel/pool.c @@ -174,7 +174,7 @@ get_pooled(const unit * u, const resource_type * rtype, unsigned int mode, use = have; else { int reserve = get_reservation(u, rtype); - int slack = MAX(0, have - reserve); + int slack = _max(0, have - reserve); if (mode & GET_RESERVE) use = have - slack; else if (mode & GET_SLACK) @@ -216,16 +216,16 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count) } if ((mode & GET_SLACK) && (mode & GET_RESERVE)) { - n = MIN(use, have); + n = _min(use, have); } else { int reserve = get_reservation(u, rtype); - int slack = MAX(0, have - reserve); + int slack = _max(0, have - reserve); if (mode & GET_RESERVE) { n = have - slack; - n = MIN(use, n); + n = _min(use, n); change_reservation(u, rtype, -n); } else if (mode & GET_SLACK) { - n = MIN(use, slack); + n = _min(use, slack); } } if (n > 0) { diff --git a/src/kernel/region.c b/src/kernel/region.c index 4da863036..c177d8acf 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -573,7 +573,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 = _min(width, height) >> 1; /* Bei negativem dy am Ursprung spiegeln, das veraendert * den Abstand nicht @@ -596,13 +596,13 @@ 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 = _max(dx, height - dy); if (dist >= 0 && dist < result) { result = dist; if (result <= mindist) return result; } - dist = MAX(width - dx, dy); + dist = _max(width - dx, dy); if (dist >= 0 && dist < result) result = dist; return result; @@ -1371,7 +1371,7 @@ void terraform_region(region * r, const terrain_type * terrain) if (!fval(r, RF_CHAOTIC)) { int peasants; peasants = (maxworkingpeasants(r) * (20 + dice_rand("6d10"))) / 100; - rsetpeasants(r, MAX(100, peasants)); + rsetpeasants(r, _max(100, peasants)); rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL, INT_MAX) + 1) + rng_int() % 5)); } @@ -1540,7 +1540,7 @@ faction *update_owners(region * r) } else { alliance *al = region_get_alliance(r); if (al && u->faction->alliance == al) { - int morale = MAX(0, r->land->morale - MORALE_TRANSFER); + int morale = _max(0, r->land->morale - MORALE_TRANSFER); region_set_morale(r, morale, turn); } else { region_set_morale(r, MORALE_TAKEOVER, turn); diff --git a/src/kernel/reports.c b/src/kernel/reports.c index cb3fa52e4..9282ee091 100644 --- a/src/kernel/reports.c +++ b/src/kernel/reports.c @@ -215,8 +215,8 @@ int update_nmrs(void) int nmr = turn - f->lastorders + 1; if (nmr < 0 || nmr > NMRTimeout()) { log_error("faction %s has %d NMRS\n", factionid(f), nmr); - nmr = MAX(0, nmr); - nmr = MIN(nmr, NMRTimeout()); + nmr = _max(0, nmr); + nmr = _min(nmr, NMRTimeout()); } ++nmrs[nmr]; } @@ -935,7 +935,7 @@ spskill(char *buffer, size_t size, const struct locale * lang, oldeff = sv->old + get_modifier(u, sv->id, sv->old, u->region, false); } - oldeff = MAX(0, oldeff); + oldeff = _max(0, oldeff); diff = effsk - oldeff; if (diff != 0) { diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 7f2aa226f..30220f70d 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1361,7 +1361,7 @@ int invisible(const unit * target, const unit * viewer) get_item(target, I_RING_OF_INVISIBILITY) + 100 * get_item(target, I_SPHERE_OF_INVISIBILITY); if (hidden) { - hidden = MIN(hidden, target->number); + hidden = _min(hidden, target->number); if (viewer) hidden -= get_item(viewer, I_AMULET_OF_TRUE_SEEING); } diff --git a/src/laws.c b/src/laws.c index e237d983e..c600346f4 100755 --- a/src/laws.c +++ b/src/laws.c @@ -154,7 +154,7 @@ static void help_feed(unit * donor, unit * u, int *need_p) { int need = *need_p; int give = get_money(donor) - lifestyle(donor); - give = MIN(need, give); + give = _min(need, give); if (give > 0) { change_money(donor, -give); @@ -223,7 +223,7 @@ void get_food(region * r) * food from the peasants - should not be used with WORK */ if (owner != NULL && (get_alliance(owner, u->faction) & HELP_MONEY)) { int rm = rmoney(r); - int use = MIN(rm, need); + int use = _min(rm, need); rsetmoney(r, rm - use); need -= use; } @@ -236,7 +236,7 @@ void get_food(region * r) for (v = r->units; need && v; v = v->next) { if (v->faction == u->faction && help_money(v)) { int give = get_money(v) - lifestyle(v); - give = MIN(need, give); + give = _min(need, give); if (give > 0) { change_money(v, -give); change_money(u, give); @@ -253,7 +253,7 @@ void get_food(region * r) int need = lifestyle(u); faction *f = u->faction; - need -= MAX(0, get_money(u)); + need -= _max(0, get_money(u)); if (need > 0) { unit *v; @@ -310,7 +310,7 @@ void get_food(region * r) unit *donor = u; while (donor != NULL && hungry > 0) { int blut = get_effect(donor, pt_blood); - blut = MIN(blut, hungry); + blut = _min(blut, hungry); change_effect(donor, pt_blood, -blut); hungry -= blut; if (donor == u) @@ -357,7 +357,7 @@ void get_food(region * r) /* 3. Von den überlebenden das Geld abziehen: */ for (u = r->units; u; u = u->next) { - int need = MIN(get_money(u), lifestyle(u)); + int need = _min(get_money(u), lifestyle(u)); change_money(u, -need); } } @@ -417,7 +417,7 @@ static void live(region * r) } /* bestes Talent raussuchen */ if (sb != NULL) { - int weeks = MIN(effect, u->number); + int weeks = _min(effect, u->number); reduce_skill(u, sb, weeks); ADDMSG(&u->faction->msgs, msg_message("dumbeffect", "unit weeks skill", u, weeks, (skill_t) sb->id)); @@ -475,7 +475,7 @@ static void calculate_emigration(region * r) int max_emigration = MAX_EMIGRATION(rp2 - maxp2); if (max_emigration > 0) { - max_emigration = MIN(max_emigration, max_immigrants); + max_emigration = _min(max_emigration, max_immigrants); r->land->newpeasants += max_emigration; rc->land->newpeasants -= max_emigration; max_immigrants -= max_emigration; @@ -534,7 +534,7 @@ static void peasants(region * r) /* Alle werden satt, oder halt soviele für die es auch Geld gibt */ - satiated = MIN(peasants, money / maintenance_cost(NULL)); + satiated = _min(peasants, money / maintenance_cost(NULL)); rsetmoney(r, money - satiated * maintenance_cost(NULL)); /* Von denjenigen, die nicht satt geworden sind, verhungert der @@ -543,7 +543,7 @@ static void peasants(region * r) /* Es verhungert maximal die unterernährten Bevölkerung. */ - n = MIN(peasants - satiated, rpeasants(r)); + n = _min(peasants - satiated, rpeasants(r)); dead += (int)(0.5F + n * PEASANT_STARVATION_CHANCE); if (dead > 0) { @@ -624,7 +624,7 @@ static void horses(region * r) /* Logistisches Wachstum, Optimum bei halbem Maximalbesatz. */ maxhorses = maxworkingpeasants(r) / 10; - maxhorses = MAX(0, maxhorses); + maxhorses = _max(0, maxhorses); horses = rhorses(r); if (horses > 0) { if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) { @@ -657,7 +657,7 @@ static void horses(region * r) if (r2 && fval(r2->terrain, WALK_INTO)) { int pt = (rhorses(r) * HORSEMOVE) / 100; pt = (int)normalvariate(pt, pt / 4.0); - pt = MAX(0, pt); + pt = _max(0, pt); if (fval(r2, RF_MIGRATION)) rsethorses(r2, rhorses(r2) + pt); else { @@ -760,7 +760,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season) a = a_find(r->attribs, &at_germs); if (a && last_weeks_season == SEASON_SPRING) { /* ungekeimte Samen bleiben erhalten, Sprößlinge wachsen */ - sprout = MIN(a->data.sa[1], rtrees(r, 1)); + sprout = _min(a->data.sa[1], rtrees(r, 1)); /* aus dem gesamt Sprößlingepool abziehen */ rsettrees(r, 1, rtrees(r, 1) - sprout); /* zu den Bäumen hinzufügen */ @@ -780,7 +780,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season) /* Grundchance 1.0% */ /* Jeder Elf in der Region erhöht die Chance marginal */ - elves = MIN(elves, (production(r) * MAXPEASANTS_PER_AREA) / 8); + elves = _min(elves, (production(r) * MAXPEASANTS_PER_AREA) / 8); if (elves) { seedchance += 1.0 - pow(0.99999, elves * RESOURCE_QUANTITY); } @@ -845,7 +845,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season) /* Raubbau abfangen, es dürfen nie mehr Samen wachsen, als aktuell * in der Region sind */ - seeds = MIN(a->data.sa[0], rtrees(r, 0)); + seeds = _min(a->data.sa[0], rtrees(r, 0)); sprout = 0; for (i = 0; i < seeds; i++) { @@ -865,7 +865,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season) * der Region entfernt werden können, da Jungbäume in der gleichen * Runde nachwachsen, wir also nicht mehr zwischen diesjährigen und * 'alten' Jungbäumen unterscheiden könnten */ - sprout = MIN(a->data.sa[1], rtrees(r, 1)); + sprout = _min(a->data.sa[1], rtrees(r, 1)); grownup_trees = 0; for (i = 0; i < sprout; i++) { @@ -973,7 +973,7 @@ void demographics(void) for (r = regions; r; r = r->next) { if (r->land && r->land->newpeasants) { int rp = rpeasants(r) + r->land->newpeasants; - rsetpeasants(r, MAX(0, rp)); + rsetpeasants(r, _max(0, rp)); } } @@ -1473,7 +1473,7 @@ static void remove_idle_players(void) } log_info(" - beseitige Spieler, die sich nach der Anmeldung nicht gemeldet haben..."); - age = calloc(MAX(4, turn + 1), sizeof(int)); + age = calloc(_max(4, turn + 1), sizeof(int)); for (f = factions; f; f = f->next) if (!is_monsters(f)) { if (RemoveNMRNewbie() && !fval(f, FFL_NOIDLEOUT)) { @@ -2866,7 +2866,7 @@ int combatspell_cmd(unit * u, struct order *ord) if (findparam(s, u->faction->locale) == P_LEVEL) { /* Merken, setzen kommt erst später */ level = getint(); - level = MAX(0, level); + level = _max(0, level); s = getstrtoken(); } @@ -3328,14 +3328,14 @@ static building *age_building(building * b) float effect = 100; /* the mage reactivates the circle */ c = create_curse(mage, &rt->attribs, ct_astralblock, - (float)MAX(1, sk), MAX(1, sk / 2), effect, 0); + (float)_max(1, sk), _max(1, sk / 2), effect, 0); ADDMSG(&r->msgs, msg_message("astralshield_activate", "region unit", r, mage)); } } else if (mage != NULL) { int sk = effskill(mage, SK_MAGIC); - c->duration = MAX(c->duration, sk / 2); - c->vigour = MAX(c->vigour, sk); + c->duration = _max(c->duration, sk / 2); + c->vigour = _max(c->vigour, sk); } } } @@ -3404,12 +3404,12 @@ static void ageing(void) /* Goliathwasser */ int i = get_effect(u, oldpotiontype[P_STRONG]); if (i > 0) { - change_effect(u, oldpotiontype[P_STRONG], -1 * MIN(u->number, i)); + change_effect(u, oldpotiontype[P_STRONG], -1 * _min(u->number, i)); } /* Berserkerblut */ i = get_effect(u, oldpotiontype[P_BERSERK]); if (i > 0) { - change_effect(u, oldpotiontype[P_BERSERK], -1 * MIN(u->number, i)); + change_effect(u, oldpotiontype[P_BERSERK], -1 * _min(u->number, i)); } if (is_cursed(u->attribs, C_OLDRACE, 0)) { @@ -3483,7 +3483,7 @@ static int maxunits(const faction * f) if (flimit == 0) { return alimit; } - return MIN(alimit, flimit); + return _min(alimit, flimit); } int checkunitnumber(const faction * f, int add) @@ -3823,9 +3823,9 @@ void monthly_healing(void) p *= heal_factor(u); if (u->hp < umhp) { #ifdef NEW_DAEMONHUNGER_RULE - double maxheal = MAX(u->number, umhp / 20.0); + double maxheal = _max(u->number, umhp / 20.0); #else - double maxheal = MAX(u->number, umhp / 10.0); + double maxheal = _max(u->number, umhp / 10.0); #endif int addhp; struct building *b = inside_building(u); @@ -3843,7 +3843,7 @@ void monthly_healing(void) ++addhp; /* Aufaddieren der geheilten HP. */ - u->hp = MIN(u->hp + addhp, umhp); + u->hp = _min(u->hp + addhp, umhp); /* soll man an negativer regeneration sterben können? */ assert(u->hp > 0); @@ -4108,7 +4108,7 @@ int claim_cmd(unit * u, struct order *ord) if (itype != NULL) { item **iclaim = i_find(&u->faction->items, itype); if (iclaim != NULL && *iclaim != NULL) { - n = MIN(n, (*iclaim)->number); + n = _min(n, (*iclaim)->number); i_change(iclaim, itype, -n); i_change(&u->items, itype, n); } @@ -4378,9 +4378,9 @@ int siege_cmd(unit * u, order * ord) /* schaden durch katapulte */ d = i_get(u->items, it_catapult); - d = MIN(u->number, d); + d = _min(u->number, d); pooled = get_pooled(u, it_catapultammo->rtype, GET_DEFAULT, d); - d = MIN(pooled, d); + d = _min(pooled, d); if (eff_skill(u, SK_CATAPULT, r) >= 1) { katapultiere = d; d *= eff_skill(u, SK_CATAPULT, r); @@ -4406,11 +4406,11 @@ int siege_cmd(unit * u, order * ord) * einheiten wieder abgesucht werden muessen! */ usetsiege(u, b); - b->besieged += MAX(bewaffnete, katapultiere); + b->besieged += _max(bewaffnete, katapultiere); /* definitiver schaden eingeschraenkt */ - d = MIN(d, b->size - 1); + d = _min(d, b->size - 1); /* meldung, schaden anrichten */ if (d && !curse_active(get_curse(b->attribs, magicwalls_ct))) { diff --git a/src/modules/arena.c b/src/modules/arena.c index 1cc3333e9..407ee89e0 100644 --- a/src/modules/arena.c +++ b/src/modules/arena.c @@ -101,13 +101,17 @@ static int leave_arena(struct unit *u, const struct item_type *itype, int amount, order * ord) { - if (!u->building && leave_fail(u)) - return -1; - if (u->building != arena_tower(u->faction->magiegebiet) && leave_fail(u)) - return -1; - unused(amount, ord, itype); - assert(!"not implemented"); - return 0; + if (!u->building && leave_fail(u)) { + return -1; + } + if (u->building != arena_tower(u->faction->magiegebiet) && leave_fail(u)) { + return -1; + } + unused(amount); + unused(ord); + unused(itype); + assert(!"not implemented"); + return 0; } static int enter_fail(unit * u) diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 92b94ae3e..9343ab0d4 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -1021,8 +1021,8 @@ int build_island_e3(int x, int y, int numfactions, int minsize) q = region_quality(r, rn); if (q >= MIN_QUALITY && nfactions < numfactions) { starting_region(r, rn); - minq = MIN(minq, q); - maxq = MAX(maxq, q); + minq = _min(minq, q); + maxq = _max(maxq, q); ++nfactions; } } @@ -1036,8 +1036,8 @@ int build_island_e3(int x, int y, int numfactions, int minsize) q = region_quality(r, rn); if (q >= MIN_QUALITY * 4 / 3 && nfactions < numfactions) { starting_region(r, rn); - minq = MIN(minq, q); - maxq = MAX(maxq, q); + minq = _min(minq, q); + maxq = _max(maxq, q); ++nfactions; } } diff --git a/src/modules/dungeon.c b/src/modules/dungeon.c index 657b20837..4a8b384cd 100644 --- a/src/modules/dungeon.c +++ b/src/modules/dungeon.c @@ -225,8 +225,8 @@ static int tagbegin(xml_stack * stack) monster *m = calloc(sizeof(monster), 1); m->race = rc_find(xml_value(tag, "race")); m->chance = xml_fvalue(tag, "chance"); - m->avgsize = MAX(1, xml_ivalue(tag, "size")); - m->maxunits = MIN(1, xml_ivalue(tag, "maxunits")); + m->avgsize = _max(1, xml_ivalue(tag, "size")); + m->maxunits = _min(1, xml_ivalue(tag, "maxunits")); if (m->race) { if (xml_bvalue(tag, "boss")) { diff --git a/src/monster.c b/src/monster.c index ab016e5a5..3d643b75f 100644 --- a/src/monster.c +++ b/src/monster.c @@ -108,7 +108,7 @@ static void eaten_by_monster(unit * u) n = (int)(n * multi); if (n > 0) { n = lovar(n); - n = MIN(rpeasants(u->region), n); + n = _min(rpeasants(u->region), n); if (n > 0) { deathcounts(u->region, n); @@ -133,7 +133,7 @@ static void absorbed_by_monster(unit * u) if (n > 0) { n = lovar(n); - n = MIN(rpeasants(u->region), n); + n = _min(rpeasants(u->region), n); if (n > 0) { rsetpeasants(u->region, rpeasants(u->region) - n); scale_number(u, u->number + n); @@ -148,7 +148,7 @@ static int scareaway(region * r, int anzahl) int n, p, diff = 0, emigrants[MAXDIRECTIONS]; direction_t d; - anzahl = MIN(MAX(1, anzahl), rpeasants(r)); + anzahl = _min(_max(1, anzahl), rpeasants(r)); /* Wandern am Ende der Woche (normal) oder wegen Monster. Die * Wanderung wird erst am Ende von demographics () ausgefuehrt. @@ -160,7 +160,7 @@ static int scareaway(region * r, int anzahl) p = rpeasants(r); assert(p >= 0 && anzahl >= 0); - for (n = MIN(p, anzahl); n; n--) { + for (n = _min(p, anzahl); n; n--) { direction_t dir = (direction_t) (rng_int() % MAXDIRECTIONS); region *rc = rconnect(r, dir); @@ -195,7 +195,7 @@ static void scared_by_monster(unit * u) if (n > 0) { n = lovar(n); - n = MIN(rpeasants(u->region), n); + n = _min(rpeasants(u->region), n); if (n > 0) { n = scareaway(u->region, n); if (n > 0) { diff --git a/src/monsters.c b/src/monsters.c index 9aa534b9b..f8c6ddd5d 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -82,7 +82,7 @@ static void reduce_weight(unit * u) int horses = get_resource(u, oldresourcetype[R_HORSE]); if (horses > 0) { - horses = MIN(horses, (u->number * 2)); + horses = _min(horses, (u->number * 2)); change_resource(u, oldresourcetype[R_HORSE], -horses); } @@ -109,7 +109,7 @@ static void reduce_weight(unit * u) if (itype->weight >= 10 && itype->rtype->wtype == 0 && itype->rtype->atype == 0) { if (itype->capacity < itype->weight) { - int reduce = MIN(itm->number, -((capacity - weight) / itype->weight)); + int reduce = _min(itm->number, -((capacity - weight) / itype->weight)); give_item(reduce, itm->type, u, NULL, NULL); weight -= reduce * itype->weight; } @@ -124,7 +124,7 @@ static void reduce_weight(unit * u) const item_type *itype = itm->type; weight += itm->number * itype->weight; if (itype->capacity < itype->weight) { - int reduce = MIN(itm->number, -((capacity - weight) / itype->weight)); + int reduce = _min(itm->number, -((capacity - weight) / itype->weight)); give_item(reduce, itm->type, u, NULL, NULL); weight -= reduce * itype->weight; } diff --git a/src/platform.h b/src/platform.h index 9aeee4293..4d9875c61 100644 --- a/src/platform.h +++ b/src/platform.h @@ -78,18 +78,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # define _XOPEN_SOURCE #endif -/**** **** - ** min/max macros ** - **** ****/ -#ifndef NOMINMAX -#ifndef MIN -# define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef MAX -# define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif -#endif - #define unused (void) #include "util/bool.h" diff --git a/src/races/dragons.c b/src/races/dragons.c index cee2709f7..410400490 100644 --- a/src/races/dragons.c +++ b/src/races/dragons.c @@ -22,7 +22,7 @@ /* util includes */ #include -#define age_chance(a,b,p) (MAX(0,a-b)*p) +#define age_chance(a,b,p) (_max(0,a-b)*p) #define DRAGONAGE 27 #define WYRMAGE 68 diff --git a/src/races/zombies.c b/src/races/zombies.c index 1aa3936be..8cf53c06c 100644 --- a/src/races/zombies.c +++ b/src/races/zombies.c @@ -30,7 +30,7 @@ #define UNDEAD_BREAKUP 25 /* chance dafuer */ #define UNDEAD_BREAKUP_FRACTION (25+rng_int()%70) /* anteil der weg geht */ -#define age_chance(a,b,p) (MAX(0,a-b)*p) +#define age_chance(a,b,p) (_max(0,a-b)*p) void age_undead(unit * u) { @@ -60,7 +60,7 @@ void age_undead(unit * u) void age_skeleton(unit * u) { if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) { - int n = MAX(1, u->number / 2); + int n = _max(1, u->number / 2); double q = (double)u->hp / (double)(unit_max_hp(u) * u->number); u_setrace(u, new_race[RC_SKELETON_LORD]); u->irace = NULL; @@ -72,7 +72,7 @@ void age_skeleton(unit * u) void age_zombie(unit * u) { if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) { - int n = MAX(1, u->number / 2); + int n = _max(1, u->number / 2); double q = (double)u->hp / (double)(unit_max_hp(u) * u->number); u_setrace(u, new_race[RC_ZOMBIE_LORD]); u->irace = NULL; @@ -84,7 +84,7 @@ void age_zombie(unit * u) void age_ghoul(unit * u) { if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) { - int n = MAX(1, u->number / 2); + int n = _max(1, u->number / 2); double q = (double)u->hp / (double)(unit_max_hp(u) * u->number); u_setrace(u, new_race[RC_GHOUL_LORD]); u->irace = NULL; diff --git a/src/randenc.c b/src/randenc.c index f1e577477..8340f1f78 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -1194,7 +1194,7 @@ static void rotting_herbs(void) if (fval(itm->type, ITF_HERB)) { double nv = normalvariate(k, k / 4); int inv = (int)nv; - int delta = MIN(n, inv); + int delta = _min(n, inv); if (i_change(itmp, itm->type, -delta) == NULL) { continue; } @@ -1242,7 +1242,7 @@ void randomevents(void) a_remove(&r->attribs, a); ADDMSG(&r->msgs, msg_message("orcified", "region", r)); } else { - a->data.i -= MAX(10, a->data.i / 10); + a->data.i -= _max(10, a->data.i / 10); if (a->data.i <= 0) a_remove(&r->attribs, a); } @@ -1279,7 +1279,7 @@ void randomevents(void) while (*blist) { building *b = *blist; if (fval(b->type, BTF_DECAY) && !building_owner(b)) { - b->size -= MAX(1, (b->size * 20) / 100); + b->size -= _max(1, (b->size * 20) / 100); if (b->size == 0) { remove_building(blist, r->buildings); } diff --git a/src/spells/borders.c b/src/spells/borders.c index bc6802a33..833dab38d 100644 --- a/src/spells/borders.c +++ b/src/spells/borders.c @@ -214,7 +214,7 @@ static region *wall_move(const connection * b, struct unit *u, wall_data *fd = (wall_data *) b->data.v; if (!routing && fd->active) { int hp = dice(3, fd->force) * u->number; - hp = MIN(u->hp, hp); + hp = _min(u->hp, hp); u->hp -= hp; if (u->hp) { ADDMSG(&u->faction->msgs, msg_message("firewall_damage", diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index cc168dbd1..2176336c5 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -315,14 +315,14 @@ int sp_combatrosthauch(struct castorder * co) if (force <= 0) break; - /* da n MIN(force, x), sollte force maximal auf 0 sinken */ + /* da n _min(force, x), sollte force maximal auf 0 sinken */ assert(force >= 0); if (df->weapons) { int w; for (w = 0; df->weapons[w].type != NULL; ++w) { weapon *wp = df->weapons; - int n = MIN(force, wp->used); + int n = _min(force, wp->used); if (n) { requirement *mat = wp->type->itype->construction->materials; bool iron = false; @@ -873,7 +873,7 @@ int sp_shadowknights(struct castorder * co) region *r = b->region; unit *mage = fi->unit; attrib *a; - int force = MAX(1, (int)get_force(power, 3)); + int force = _max(1, (int)get_force(power, 3)); message *msg; u = @@ -973,7 +973,7 @@ int sp_chaosrow(struct castorder * co) continue; if (power <= 0.0) break; - /* force sollte wegen des MAX(0,x) nicht unter 0 fallen können */ + /* force sollte wegen des _max(0,x) nicht unter 0 fallen können */ if (is_magic_resistant(mage, df->unit, 0)) continue; @@ -1008,7 +1008,7 @@ int sp_chaosrow(struct castorder * co) } k += df->alive; } - power = MAX(0, power - n); + power = _max(0, power - n); } ql_free(fgs); @@ -1110,12 +1110,12 @@ int sp_hero(struct castorder * co) switch (sp->id) { case SPL_HERO: df_bonus = (int)(power / 5); - force = MAX(1, lovar(get_force(power, 4))); + force = _max(1, lovar(get_force(power, 4))); break; default: df_bonus = 1; - force = MAX(1, (int)power); + force = _max(1, (int)power); } allies = @@ -1164,7 +1164,7 @@ int sp_berserk(struct castorder * co) switch (sp->id) { case SPL_BERSERK: case SPL_BLOODTHIRST: - at_bonus = MAX(1, level / 3); + at_bonus = _max(1, level / 3); df_malus = 2; force = (int)get_force(power, 2); break; @@ -1220,7 +1220,7 @@ int sp_frighten(struct castorder * co) int targets = 0; message *m; - at_malus = MAX(1, level - 4); + at_malus = _max(1, level - 4); df_malus = 2; force = (int)get_force(power, 2); @@ -1502,7 +1502,7 @@ int sp_fumbleshield(struct castorder * co) case SPL_CERRDOR_FUMBLESHIELD: case SPL_TYBIED_FUMBLESHIELD: duration = 100; - effect = MAX(1, 25 - level); + effect = _max(1, 25 - level); break; default: @@ -1549,7 +1549,7 @@ int sp_reanimate(struct castorder * co) } healable = count_healable(b, fi); - healable = (int)MIN(k, healable); + healable = (int)_min(k, healable); while (healable--) { fighter *tf = select_corpse(b, fi); if (tf != NULL && tf->side->casualties > 0 @@ -1601,7 +1601,7 @@ int sp_keeploot(struct castorder * co) message_all(b, m); msg_release(m); - b->keeploot = (int)MAX(25, b->keeploot + 5 * power); + b->keeploot = (int)_max(25, b->keeploot + 5 * power); return level; } @@ -1632,10 +1632,10 @@ static int heal_fighters(quicklist * fgs, int *power, bool heal_monsters) ++wound; if (wound > 0 && wound < hp) { - int heal = MIN(healhp, wound); + int heal = _min(healhp, wound); assert(heal >= 0); df->person[n].hp += heal; - healhp = MAX(0, healhp - heal); + healhp = _max(0, healhp - heal); ++healed; if (healhp <= 0) break; @@ -1768,7 +1768,7 @@ int sp_undeadhero(struct castorder * co) } ql_free(fgs); - level = MIN(level, undead); + level = _min(level, undead); if (undead == 0) { msg = msg_message("summonundead_effect_0", "mage region", mage, mage->region); diff --git a/src/spells/spells.c b/src/spells/spells.c index a5d56823a..504d31d58 100644 --- a/src/spells/spells.c +++ b/src/spells/spells.c @@ -149,7 +149,7 @@ static void magicanalyse_region(region * r, unit * mage, double force) * mehr als 100% probability und damit immer ein Erfolg. */ probability = curse_chance(c, force); mon = c->duration + (rng_int() % 10) - 5; - mon = MAX(1, mon); + mon = _max(1, mon); found = true; if (chance(probability)) { /* Analyse geglueckt */ @@ -188,7 +188,7 @@ static void magicanalyse_unit(unit * u, unit * mage, double force) * mehr als 100% probability und damit immer ein Erfolg. */ probability = curse_chance(c, force); mon = c->duration + (rng_int() % 10) - 5; - mon = MAX(1, mon); + mon = _max(1, mon); if (chance(probability)) { /* Analyse geglueckt */ if (c_flags(c) & CURSE_NOAGE) { @@ -227,7 +227,7 @@ static void magicanalyse_building(building * b, unit * mage, double force) * mehr als 100% probability und damit immer ein Erfolg. */ probability = curse_chance(c, force); mon = c->duration + (rng_int() % 10) - 5; - mon = MAX(1, mon); + mon = _max(1, mon); if (chance(probability)) { /* Analyse geglueckt */ if (c_flags(c) & CURSE_NOAGE) { @@ -266,7 +266,7 @@ static void magicanalyse_ship(ship * sh, unit * mage, double force) * mehr als 100% probability und damit immer ein Erfolg. */ probability = curse_chance(c, force); mon = c->duration + (rng_int() % 10) - 5; - mon = MAX(1, mon); + mon = _max(1, mon); if (chance(probability)) { /* Analyse geglueckt */ if (c_flags(c) & CURSE_NOAGE) { @@ -674,7 +674,7 @@ static int sp_destroy_magic(castorder * co) "unit region command", mage, mage->region, co->order)); } - return MAX(succ, 1); + return _max(succ, 1); } /* ------------------------------------------------------------- */ @@ -740,7 +740,7 @@ static int sp_transferaura(castorder * co) return 0; } - gain = MIN(aura, scm_src->spellpoints) / multi; + gain = _min(aura, scm_src->spellpoints) / multi; scm_src->spellpoints -= gain * multi; scm_dst->spellpoints += gain; @@ -879,7 +879,7 @@ static int sp_summonent(castorder * co) return 0; } - ents = (int)MIN(power * power, rtrees(r, 2)); + ents = (int)_min(power * power, rtrees(r, 2)); u = create_unit(r, mage->faction, ents, new_race[RC_TREEMAN], 0, NULL, mage); @@ -1270,7 +1270,7 @@ static int sp_rosthauch(castorder * co) for (; iweapon != NULL; iweapon = iweapon->next) { item **ip = i_find(&u->items, iweapon->type); if (*ip) { - int i = MIN((*ip)->number, force); + int i = _min((*ip)->number, force); if (iweapon->chance < 1.0) { i = (int)(i * iweapon->chance); } @@ -1307,7 +1307,7 @@ static int sp_rosthauch(castorder * co) * unguenstigsten Fall kann pro Stufe nur eine Waffe verzaubert werden, * darum wird hier nur fuer alle Faelle in denen noch weniger Waffen * betroffen wurden ein Kostennachlass gegeben */ - return MIN(success, cast_level); + return _min(success, cast_level); } /* ------------------------------------------------------------- */ @@ -1337,7 +1337,7 @@ static int sp_kaelteschutz(castorder * co) unit *mage = co->magician.u; int cast_level = co->level; float force = co->force; - int duration = MAX(cast_level, (int)force) + 1; + int duration = _max(cast_level, (int)force) + 1; spellparameter *pa = co->par; float effect; @@ -2081,8 +2081,8 @@ static int sp_drought(castorder * co) */ c = get_curse(r->attribs, ct_find("drought")); if (c) { - c->vigour = MAX(c->vigour, power); - c->duration = MAX(c->duration, (int)power); + c->vigour = _max(c->vigour, power); + c->duration = _max(c->duration, (int)power); } else { float effect = 4.0; /* Baeume und Pferde sterben */ @@ -2278,8 +2278,8 @@ static int sp_earthquake(castorder * co) if (burg->size != 0 && !is_cursed(burg->attribs, C_MAGICWALLS, 0)) { /* Magieresistenz */ if (!target_resists_magic(mage, burg, TYP_BUILDING, 0)) { - kaputt = MIN(10 * cast_level, burg->size / 4); - kaputt = MAX(kaputt, 1); + kaputt = _min(10 * cast_level, burg->size / 4); + kaputt = _max(kaputt, 1); burg->size -= kaputt; if (burg->size == 0) { /* TODO: sollten die Insassen nicht Schaden nehmen? */ @@ -2444,7 +2444,7 @@ static int sp_forest_fire(castorder * co) * das Zaubern. Patzer werden warscheinlicher. * Jeder Zauber muss erst gegen den Wiederstand des Fluchs gezaubert * werden und schwaecht dessen Antimagiewiederstand um 1. - * Wirkt MAX(Stufe(Magier) - Stufe(Ziel), rand(3)) Wochen + * Wirkt _max(Stufe(Magier) - Stufe(Ziel), rand(3)) Wochen * Patzer: * Magier wird selbst betroffen * @@ -2472,7 +2472,7 @@ static int sp_fumblecurse(castorder * co) rx = rng_int() % 3; sx = cast_level - effskill(target, SK_MAGIC); - duration = MAX(sx, rx) + 1; + duration = _max(sx, rx) + 1; effect = force/2; c = create_curse(mage, &target->attribs, ct_find("fumble"), @@ -2635,8 +2635,8 @@ static int sp_firewall(castorder * co) fd->countdown = cast_level + 1; } else { fd = (wall_data *) b->data.v; - fd->force = (int)MAX(fd->force, force / 2 + 0.5); - fd->countdown = MAX(fd->countdown, cast_level + 1); + fd->force = (int)_max(fd->force, force / 2 + 0.5); + fd->countdown = _max(fd->countdown, cast_level + 1); } /* melden, 1x pro Partei */ @@ -2847,7 +2847,7 @@ attrib_type at_deathcloud_compat = { * Ruestung wirkt nicht * Patzer: * Magier geraet in den Staub und verliert zufaellige Zahl von HP bis -* auf MAX(hp,2) +* auf _max(hp,2) * Besonderheiten: * Nicht als curse implementiert, was schlecht ist - man kann dadurch * kein dispell machen. Wegen fix unter Zeitdruck erstmal nicht zu @@ -3265,7 +3265,7 @@ static int sp_summonundead(castorder * co) return 0; } - undead = MIN(deathcount(r), 2 + lovar(force)); + undead = _min(deathcount(r), 2 + lovar(force)); if (cast_level <= 8) { race = new_race[RC_SKELETON]; @@ -3311,7 +3311,7 @@ static int sp_auraleak(castorder * co) int cast_level = co->level; message *msg; - lost = MIN(0.95, cast_level * 0.05); + lost = _min(0.95, cast_level * 0.05); for (u = r->units; u; u = u->next) { if (is_mage(u)) { @@ -3697,8 +3697,8 @@ static int sp_raisepeasantmob(castorder * co) anteil = 6 + (rng_int() % 4); n = rpeasants(r) * anteil / 10; - n = MAX(0, n); - n = MIN(n, rpeasants(r)); + n = _max(0, n); + n = _min(n, rpeasants(r)); if (n <= 0) { report_failure(mage, co->order); @@ -3935,12 +3935,12 @@ static int sp_recruit(castorder * co) n = (pow(force, 1.6) * 100) / f->race->recruitcost; if (rc->recruit_multi != 0) { double multp = maxp / rc->recruit_multi; - n = MIN(multp, n); - n = MAX(n, 1); + n = _min(multp, n); + n = _max(n, 1); rsetpeasants(r, maxp - (int)(n * rc->recruit_multi)); } else { - n = MIN(maxp, n); - n = MAX(n, 1); + n = _min(maxp, n); + n = _max(n, 1); rsetpeasants(r, maxp - (int)n); } @@ -3985,12 +3985,12 @@ static int sp_bigrecruit(castorder * co) n = (int)force + lovar((force * force * 1000) / f->race->recruitcost); if (f->race == new_race[RC_ORC]) { - n = MIN(2 * maxp, n); - n = MAX(n, 1); + n = _min(2 * maxp, n); + n = _max(n, 1); rsetpeasants(r, maxp - (n + 1) / 2); } else { - n = MIN(maxp, n); - n = MAX(n, 1); + n = _min(maxp, n); + n = _max(n, 1); rsetpeasants(r, maxp - n); } @@ -4078,7 +4078,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 - maintenace) + * _min(Stufe*1000$, u->money - maintenace) * Von jedem Item wird 50% abgerundet ermittelt und uebergeben. Dazu * kommt Itemzahl%2 mit 50% chance * @@ -4115,15 +4115,15 @@ static int sp_seduce(castorder * co) int loot; if (itm->type == i_silver) { loot = - MIN(cast_level * 1000, get_money(target) - (maintenance_cost(target))); - loot = MAX(loot, 0); + _min(cast_level * 1000, get_money(target) - (maintenance_cost(target))); + loot = _max(loot, 0); } else { loot = itm->number / 2; if (itm->number % 2) { loot += rng_int() % 2; } if (loot > 0) { - loot = (int)MIN(loot, force * 5); + loot = (int)_min(loot, force * 5); } } if (loot > 0) { @@ -4240,7 +4240,7 @@ static int sp_headache(castorder * co) } if (smax != NULL) { /* wirkt auf maximal 10 Personen */ - int change = MIN(10, target->number) * (rng_int() % 2 + 1) / target->number; + int change = _min(10, target->number) * (rng_int() % 2 + 1) / target->number; reduce_skill(target, smax, change); } set_order(&target->thisorder, NULL); @@ -4284,7 +4284,7 @@ static int sp_raisepeasants(castorder * co) "error_nopeasants", "")); return 0; } - bauern = (int)MIN(rpeasants(r), power * 250); + bauern = (int)_min(rpeasants(r), power * 250); rsetpeasants(r, rpeasants(r) - bauern); u2 = @@ -4367,7 +4367,7 @@ int sp_puttorest(castorder * co) message *seen = msg_message("puttorest", "mage", mage); message *unseen = msg_message("puttorest", "mage", NULL); - laid_to_rest = MAX(laid_to_rest, dead); + laid_to_rest = _max(laid_to_rest, dead); deathcounts(r, -laid_to_rest); @@ -4595,7 +4595,7 @@ int sp_baddreams(castorder * co) /* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken, * also duration+2 */ - duration = (int)MAX(1, power / 2); /* Stufe 1 macht sonst mist */ + duration = (int)_max(1, power / 2); /* Stufe 1 macht sonst mist */ duration = 2 + rng_int() % duration; /* Nichts machen als ein entsprechendes Attribut in die Region legen. */ @@ -4633,7 +4633,7 @@ int sp_gooddreams(castorder * co) /* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken, * also duration+2 */ - duration = (int)MAX(1, power / 2); /* Stufe 1 macht sonst mist */ + duration = (int)_max(1, power / 2); /* Stufe 1 macht sonst mist */ duration = 2 + rng_int() % duration; effect = 1; c = create_curse(mage, &r->attribs, ct_find("gbdream"), power, duration, effect, 0); @@ -4774,7 +4774,7 @@ int sp_sweetdreams(castorder * co) cmistake(mage, co->order, 40, MSG_EVENT); continue; } - men = MIN(opfer, u->number); + men = _min(opfer, u->number); opfer -= men; /* Nichts machen als ein entsprechendes Attribut an die Einheit legen. */ @@ -4888,7 +4888,7 @@ int sp_itemcloak(castorder * co) spellparameter *pa = co->par; int cast_level = co->level; float power = co->force; - int duration = (int)MAX(2.0, power + 1); /* works in the report, and ageing this round would kill it if it's <=1 */ + int duration = (int)_max(2.0, power + 1); /* works in the report, and ageing this round would kill it if it's <=1 */ /* wenn kein Ziel gefunden, Zauber abbrechen */ if (pa->param[0]->flag == TARGET_NOTFOUND) @@ -4952,7 +4952,7 @@ int sp_resist_magic_bonus(castorder * co) continue; */ - m = MIN(u->number, victims); + m = _min(u->number, victims); victims -= m; create_curse(mage, &u->attribs, ct_find("magicresistance"), @@ -4968,8 +4968,8 @@ int sp_resist_magic_bonus(castorder * co) msg_release(msg); } - cast_level = MIN(cast_level, (int)(cast_level * (victims + 4) / maxvictims)); - return MAX(cast_level, 1); + cast_level = _min(cast_level, (int)(cast_level * (victims + 4) / maxvictims)); + return _max(cast_level, 1); } /** spell 'Astraler Weg'. @@ -5819,7 +5819,7 @@ int sp_permtransfer(castorder * co) return 0; } - aura = MIN(get_spellpoints(mage) - spellcost(mage, sp), aura); + aura = _min(get_spellpoints(mage) - spellcost(mage, sp), aura); change_maxspellpoints(mage, -aura); change_spellpoints(mage, -aura); @@ -6191,7 +6191,7 @@ int sp_speed2(castorder * co) spellparameter *pa = co->par; maxmen = 2 * cast_level * cast_level; - dur = MAX(1, cast_level / 2); + dur = _max(1, cast_level / 2); for (n = 0; n < pa->length; n++) { float effect; @@ -6205,7 +6205,7 @@ int sp_speed2(castorder * co) u = pa->param[n]->data.u; - men = MIN(maxmen, u->number); + men = _min(maxmen, u->number); effect = 2; create_curse(mage, &u->attribs, ct_find("speed"), force, dur, effect, men); maxmen -= men; @@ -6216,7 +6216,7 @@ int sp_speed2(castorder * co) "unit region amount", mage, mage->region, used)); /* Effektiv benoetigten cast_level (mindestens 1) zurueckgeben */ used = (int)sqrt(used / 2); - return MAX(1, used); + return _max(1, used); } /* ------------------------------------------------------------- */ @@ -6298,7 +6298,7 @@ int sp_q_antimagie(castorder * co) ADDMSG(&mage->faction->msgs, msg_message("destroy_magic_noeffect", "unit region command", mage, mage->region, co->order)); } - return MAX(succ, 1); + return _max(succ, 1); } /* ------------------------------------------------------------- */ @@ -6453,7 +6453,7 @@ static int sp_wdwpyramid(castorder * co) ADDMSG(&mage->faction->msgs, msg_message("wdw_pyramidspell_notfound", "unit region command mindist maxdist", mage, r, co->order, - MAX(1, minshowdist), maxshowdist)); + _max(1, minshowdist), maxshowdist)); } return cast_level; diff --git a/src/spy.c b/src/spy.c index 2a277484a..4c794939a 100644 --- a/src/spy.c +++ b/src/spy.c @@ -142,7 +142,7 @@ int spy_cmd(unit * u, struct order *ord) * Fuer jeden Talentpunkt, den das Spionagetalent das Tarnungstalent * des Opfers uebersteigt, erhoeht sich dieses um 5%*/ spy = eff_skill(u, SK_SPY, r) - eff_skill(target, SK_STEALTH, r); - spychance = 0.1 + MAX(spy * 0.05, 0.0); + spychance = 0.1 + _max(spy * 0.05, 0.0); if (chance(spychance)) { produceexp(u, SK_SPY, u->number); @@ -157,7 +157,7 @@ int spy_cmd(unit * u, struct order *ord) - (effskill(u, SK_STEALTH) + eff_skill(u, SK_SPY, r) / 2); if (invisible(u, target) >= u->number) { - observe = MIN(observe, 0); + observe = _min(observe, 0); } /* Anschliessend wird - unabhaengig vom Erfolg - gewuerfelt, ob der @@ -345,7 +345,7 @@ static int crew_skill(region * r, faction * f, ship * sh, skill_t sk) for (u = r->units; u; u = u->next) { if (u->ship == sh && u->faction == f) { int s = eff_skill(u, sk, r); - value = MAX(s, value); + value = _max(s, value); } } return value; diff --git a/src/study.c b/src/study.c index fffde25bf..d3d9ee10a 100644 --- a/src/study.c +++ b/src/study.c @@ -185,7 +185,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk, * steigen. * * n ist die Anzahl zusaetzlich gelernter Tage. n darf max. die Differenz - * von schon gelernten Tagen zum MAX(30 Tage pro Mann) betragen. */ + * von schon gelernten Tagen zum _max(30 Tage pro Mann) betragen. */ if (magic_lowskill(student)) { cmistake(teacher, teacher->thisorder, 292, MSG_EVENT); @@ -199,7 +199,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk, n -= teach->value; } - n = MIN(n, nteaching); + n = _min(n, nteaching); if (n != 0) { struct building *b = inside_building(teacher); @@ -224,7 +224,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk, if (btype == bt_find("academy") && student->building && student->building->type == bt_find("academy")) { int j = study_cost(student, sk); - j = MAX(50, j * 2); + j = _max(50, j * 2); /* kann Einheit das zahlen? */ if (get_pooled(student, oldresourcetype[R_SILVER], GET_DEFAULT, j) >= j) { /* Jeder Schueler zusaetzlich +10 Tage wenn in Uni. */ @@ -265,7 +265,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk, * die Talentaenderung (enno). */ - nteaching = MAX(0, nteaching - student->number * 30); + nteaching = _max(0, nteaching - student->number * 30); } return n; @@ -302,7 +302,7 @@ int teach_cmd(unit * u, struct order *ord) teaching = u->number * 30 * TEACHNUMBER; if ((i = get_effect(u, oldpotiontype[P_FOOL])) > 0) { /* Trank "Dumpfbackenbrot" */ - i = MIN(i, u->number * TEACHNUMBER); + i = _min(i, u->number * TEACHNUMBER); /* Trank wirkt pro Schueler, nicht pro Lehrer */ teaching -= i * 30; change_effect(u, oldpotiontype[P_FOOL], -i); @@ -602,7 +602,7 @@ int learn_cmd(unit * u, order * ord) const struct building_type *btype = b ? b->type : NULL; if (btype && btype == bt_find("academy")) { - studycost = MAX(50, studycost * 2); + studycost = _max(50, studycost * 2); } } @@ -686,11 +686,11 @@ int learn_cmd(unit * u, order * ord) if (studycost) { int cost = studycost * u->number; money = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, cost); - money = MIN(money, cost); + money = _min(money, cost); } if (money < studycost * u->number) { studycost = p; /* Ohne Univertreurung */ - money = MIN(money, studycost); + money = _min(money, studycost); if (p > 0 && money < studycost * u->number) { cmistake(u, ord, 65, MSG_EVENT); multi = money / (double)(studycost * u->number); @@ -709,12 +709,12 @@ int learn_cmd(unit * u, order * ord) } if (get_effect(u, oldpotiontype[P_WISE])) { - l = MIN(u->number, get_effect(u, oldpotiontype[P_WISE])); + l = _min(u->number, get_effect(u, oldpotiontype[P_WISE])); teach->value += l * 10; change_effect(u, oldpotiontype[P_WISE], -l); } if (get_effect(u, oldpotiontype[P_FOOL])) { - l = MIN(u->number, get_effect(u, oldpotiontype[P_FOOL])); + l = _min(u->number, get_effect(u, oldpotiontype[P_FOOL])); teach->value -= l * 30; change_effect(u, oldpotiontype[P_FOOL], -l); } diff --git a/src/triggers/shock.c b/src/triggers/shock.c index ef0dab03e..550d9a79b 100644 --- a/src/triggers/shock.c +++ b/src/triggers/shock.c @@ -60,7 +60,7 @@ static void do_shock(unit * u, const char *reason) if (u->number > 0) { /* HP - Verlust */ u->hp = (unit_max_hp(u) * u->number) / 10; - u->hp = MAX(1, u->hp); + u->hp = _max(1, u->hp); } /* Aura - Verlust */