new mail addresses

gcc-4.2: MAX() and MIN()
This commit is contained in:
Enno Rehling 2008-08-18 10:11:51 +00:00
parent 8a2fe52291
commit 9e529a50ae
43 changed files with 323 additions and 334 deletions

View file

@ -13,8 +13,9 @@ if ! $(HAVE_LUA) {
} }
if ! $(CPU) { if ! $(CPU) {
CPU = pentium2 ; CPU = prescott ;
ARCH = -march=$(CPU) -mtune=$(CPU) -mmmx -mieee-fp ; ARCH = -march=$(CPU) -mmmx -mieee-fp ;
ARCH += -mtune=$(CPU) ;
} }
if $(DISTCC_HOSTS) { if $(DISTCC_HOSTS) {

View file

@ -276,40 +276,32 @@ cr_output_curses(FILE * F, const faction * viewer, const void * obj, typ_t typ)
static int static int
cr_unit(variant var, char * buffer, const void * userdata) cr_unit(variant var, char * buffer, const void * userdata)
{ {
const faction * report = (const faction*)userdata;
unit * u = (unit *)var.v; unit * u = (unit *)var.v;
sprintf(buffer, "%d", u?u->no:-1); sprintf(buffer, "%d", u?u->no:-1);
unused(report);
return 0; return 0;
} }
static int static int
cr_ship(variant var, char * buffer, const void * userdata) cr_ship(variant var, char * buffer, const void * userdata)
{ {
const faction * report = (const faction*)userdata;
ship * u = (ship *)var.v; ship * u = (ship *)var.v;
sprintf(buffer, "%d", u?u->no:-1); sprintf(buffer, "%d", u?u->no:-1);
unused(report);
return 0; return 0;
} }
static int static int
cr_building(variant var, char * buffer, const void * userdata) cr_building(variant var, char * buffer, const void * userdata)
{ {
const faction * report = (const faction*)userdata;
building * u = (building *)var.v; building * u = (building *)var.v;
sprintf(buffer, "%d", u?u->no:-1); sprintf(buffer, "%d", u?u->no:-1);
unused(report);
return 0; return 0;
} }
static int static int
cr_faction(variant var, char * buffer, const void * userdata) cr_faction(variant var, char * buffer, const void * userdata)
{ {
const faction * report = (const faction*)userdata;
faction * f = (faction *)var.v; faction * f = (faction *)var.v;
sprintf(buffer, "%d", f?f->no:-1); sprintf(buffer, "%d", f?f->no:-1);
unused(report);
return 0; return 0;
} }

View file

@ -353,10 +353,10 @@ do_recruiting(recruitment * recruits, int available)
if (rc==new_race[RC_URUK]) multi = 1; if (rc==new_race[RC_URUK]) multi = 1;
number = min(req->qty, get / multi); number = MIN(req->qty, get / multi);
if (rc->recruitcost) { if (rc->recruitcost) {
int afford = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, number*rc->recruitcost) / 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);
use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, rc->recruitcost*number); use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, rc->recruitcost*number);
} }
if (u->number+number>UNIT_MAXSIZE) { if (u->number+number>UNIT_MAXSIZE) {
@ -548,7 +548,7 @@ recruit(unit * u, struct order * ord, request ** recruitorders)
} }
if (recruitcost>0) { if (recruitcost>0) {
int pooled = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, recruitcost * n); 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; u->wants = n;
@ -1120,7 +1120,7 @@ recruit_archetype(unit * u, order * ord)
if (a!=NULL) { if (a!=NULL) {
maxsize -= a->data.i; maxsize -= a->data.i;
} }
n = min(maxsize/arch->size, n); n = MIN(maxsize/arch->size, n);
if (n<=0) { if (n<=0) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "recruit_capacity_exhausted", "building", u->building)); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "recruit_capacity_exhausted", "building", u->building));
/* TODO: error message */ /* TODO: error message */
@ -1427,11 +1427,11 @@ allocate_resource(unit * u, const resource_type * rtype, int want)
/* nun ist amount die Gesamtproduktion der Einheit (in punkten) */ /* nun ist amount die Gesamtproduktion der Einheit (in punkten) */
/* mit Flinkfingerring verzehnfacht sich die Produktion */ /* mit Flinkfingerring verzehnfacht sich die Produktion */
amount += skill * min(u->number, get_item(u,I_RING_OF_NIMBLEFINGER)) * 9; amount += skill * MIN(u->number, get_item(u,I_RING_OF_NIMBLEFINGER)) * 9;
/* Schaffenstrunk: */ /* Schaffenstrunk: */
if ((dm = get_effect(u, oldpotiontype[P_DOMORE])) != 0) { 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); change_effect(u, oldpotiontype[P_DOMORE], -dm);
amount += dm * skill; /* dm Personen produzieren doppelt */ amount += dm * skill; /* dm Personen produzieren doppelt */
} }
@ -1538,7 +1538,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
} }
need = norders; need = norders;
avail = min(avail, norders); avail = MIN(avail, norders);
if (need>0) { if (need>0) {
int use = 0; int use = 0;
for (al=alist;al;al=al->next) if (!fval(al, AFL_DONE)) { for (al=alist;al;al=al->next) if (!fval(al, AFL_DONE)) {
@ -1552,7 +1552,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
use += x; use += x;
norders -= want; norders -= want;
need -= x; 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) { if (use) {
@ -1584,7 +1584,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
if (avail < 0) avail = 0; if (avail < 0) avail = 0;
} }
avail = min(avail, norders); avail = MIN(avail, norders);
for (al=alist;al;al=al->next) { for (al=alist;al;al=al->next) {
if (avail > 0) { if (avail > 0) {
int want = required(al->want, al->save); int want = required(al->want, al->save);
@ -1594,7 +1594,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
++x; ++x;
avail -= x; avail -= x;
norders -= want; norders -= want;
al->get = min(al->want, (int)(x/al->save)); al->get = MIN(al->want, (int)(x/al->save));
if (rdata->produce) { if (rdata->produce) {
int use = required(al->get, al->save); int use = required(al->get, al->save);
if (use) rdata->produce(r, rtype, use); if (use) rdata->produce(r, rtype, use);
@ -2021,7 +2021,7 @@ buy(unit * u, request ** buyorders, struct order * ord)
k -= a->data.i; k -= a->data.i;
} }
n = min(n, k); n = MIN(n, k);
if (!n) { if (!n) {
cmistake(u, ord, 102, MSG_COMMERCE); cmistake(u, ord, 102, MSG_COMMERCE);
@ -2305,7 +2305,7 @@ static boolean
/* Ein Händler kann nur 10 Güter pro Talentpunkt verkaufen. */ /* 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) { if (!n) {
cmistake(u, ord, 54, MSG_COMMERCE); cmistake(u, ord, 54, MSG_COMMERCE);
@ -2334,11 +2334,11 @@ static boolean
for (o=*sellorders;o;o=o->next) { for (o=*sellorders;o;o=o->next) {
if (o->type.ltype==ltype && o->unit->faction == u->faction) { if (o->type.ltype==ltype && o->unit->faction == u->faction) {
int fpool = o->qty - get_pooled(o->unit, itype->rtype, GET_RESERVE, INT_MAX); 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) { if (n <= 0) {
cmistake(u, ord, 264, MSG_COMMERCE); cmistake(u, ord, 264, MSG_COMMERCE);
@ -2362,7 +2362,7 @@ static boolean
k -= a->data.i; k -= a->data.i;
} }
n = min(n, k); n = MIN(n, k);
assert(n>=0); assert(n>=0);
/* die Menge der verkauften Güter merken */ /* die Menge der verkauften Güter merken */
a->data.i += n; a->data.i += n;
@ -2415,7 +2415,7 @@ expandstealing(region * r, request * stealorders)
n = 10; n = 10;
} }
if (n > 0) { 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); use_pooled(u, r_silver, GET_ALL, n);
oa[i].unit->n = n; oa[i].unit->n = n;
change_money(oa[i].unit, n); change_money(oa[i].unit, n);
@ -2469,8 +2469,8 @@ plant(region *r, unit *u, int raw)
return; return;
} }
n = min(skill*u->number, n); n = MIN(skill*u->number, n);
n = min(raw, n); n = MIN(raw, n);
/* Für jedes Kraut Talent*10% Erfolgschance. */ /* Für jedes Kraut Talent*10% Erfolgschance. */
for(i = n; i>0; i--) { for(i = n; i>0; i--) {
if (rng_int()%10 < skill) planted++; if (rng_int()%10 < skill) planted++;
@ -2518,14 +2518,14 @@ planttrees(region *r, unit *u, int raw)
} }
/* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */ /* 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); n = get_pooled(u, rtype, GET_DEFAULT, raw);
if (n==0) { if (n==0) {
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs,
msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype)); msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
return; return;
} }
n = min(raw, n); n = MIN(raw, n);
/* Für jeden Samen Talent*10% Erfolgschance. */ /* Für jeden Samen Talent*10% Erfolgschance. */
for(i = n; i>0; i--) { for(i = n; i>0; i--) {
@ -2582,7 +2582,7 @@ breedtrees(region *r, unit *u, int raw)
} }
/* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */ /* 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); n = get_pooled(u, rtype, GET_DEFAULT, raw);
/* Samen prüfen */ /* Samen prüfen */
if (n==0) { if (n==0) {
@ -2590,7 +2590,7 @@ breedtrees(region *r, unit *u, int raw)
msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype)); msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
return; return;
} }
n = min(raw, n); n = MIN(raw, n);
/* Für jeden Samen Talent*5% Erfolgschance. */ /* Für jeden Samen Talent*5% Erfolgschance. */
for(i = n; i>0; i--) { for(i = n; i>0; i--) {
@ -2623,7 +2623,7 @@ breedhorses(region *r, unit *u)
cmistake(u, u->thisorder, 107, MSG_PRODUCE); cmistake(u, u->thisorder, 107, MSG_PRODUCE);
return; 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++) { for (c = 0; c < n; c++) {
if (rng_int() % 100 < eff_skill(u, SK_HORSE_TRAINING, r)) { if (rng_int() % 100 < eff_skill(u, SK_HORSE_TRAINING, r)) {
@ -2848,7 +2848,7 @@ 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) { if (i > 0) {
n *= STEALINCOME * (u->number + i * 9); n *= STEALINCOME * (u->number + i * 9);
} else { } else {
@ -2869,7 +2869,7 @@ steal_cmd(unit * u, struct order * ord, request ** stealorders)
/* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */ /* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */
produceexp(u, SK_STEALTH, min(n, u->number)); produceexp(u, SK_STEALTH, MIN(n, u->number));
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -2894,7 +2894,7 @@ expandentertainment(region * r)
entertaining -= o->qty; entertaining -= o->qty;
/* Nur soviel PRODUCEEXP wie auch tatsächlich gemacht wurde */ /* 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); add_income(u, IC_ENTERTAIN, o->qty, u->n);
fset(u, UFL_LONGACTION|UFL_NOTMOVING); fset(u, UFL_LONGACTION|UFL_NOTMOVING);
} }
@ -2945,7 +2945,7 @@ entertain_cmd(unit * u, struct order * ord)
skip_token(); skip_token();
max_e = getuint(); max_e = getuint();
if (max_e != 0) { if (max_e != 0) {
u->wants = min(u->wants,max_e); u->wants = MIN(u->wants,max_e);
} }
o = nextentertainer++; o = nextentertainer++;
o->unit = u; o->unit = u;
@ -2997,7 +2997,7 @@ expandwork(region * r, request * work_begin, request * work_end)
/* Der Rest wird von den Bauern verdient. n ist das uebriggebliebene /* Der Rest wird von den Bauern verdient. n ist das uebriggebliebene
* Geld. */ * Geld. */
earnings = min(n, rpeasants(r) * p_wage) + verdienst; earnings = MIN(n, rpeasants(r) * p_wage) + verdienst;
/* Mehr oder weniger durch Trank "Riesengrass" oder "Faulobstschnaps" */ /* Mehr oder weniger durch Trank "Riesengrass" oder "Faulobstschnaps" */
rsetmoney(r, rmoney(r) + earnings); rsetmoney(r, rmoney(r) + earnings);
@ -3097,9 +3097,9 @@ tax_cmd(unit * u, struct order * ord, request ** taxorders)
if (max == 0) max = INT_MAX; if (max == 0) max = INT_MAX;
if (!playerrace(u->race)) { if (!playerrace(u->race)) {
u->wants = min(income(u), max); u->wants = MIN(income(u), max);
} else { } 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); u2 = is_guarded(r, u, GUARD_TAX);

View file

@ -87,7 +87,7 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, struct ord
assert(itype!=NULL); assert(itype!=NULL);
n = get_pooled(src, item2resource(itype), GET_DEFAULT, want); n = get_pooled(src, item2resource(itype), GET_DEFAULT, want);
n = min(want, n); n = MIN(want, n);
if (dest && src->faction != dest->faction && src->faction->age < GiveRestriction()) { if (dest && src->faction != dest->faction && src->faction->age < GiveRestriction()) {
if (ord!=NULL) { if (ord!=NULL) {
ADDMSG(&src->faction->msgs, msg_feedback(src, ord, "giverestriction", ADDMSG(&src->faction->msgs, msg_feedback(src, ord, "giverestriction",

View file

@ -202,7 +202,7 @@ get_food(region *r)
* food from the peasants */ * food from the peasants */
if (owner!=NULL && (get_alliance(owner, u->faction) & HELP_MONEY)) { if (owner!=NULL && (get_alliance(owner, u->faction) & HELP_MONEY)) {
int rm = rmoney(r); int rm = rmoney(r);
int use = min(rm, need); int use = MIN(rm, need);
rsetmoney(r, rm-use); rsetmoney(r, rm-use);
need -= use; need -= use;
} }
@ -214,7 +214,7 @@ get_food(region *r)
for (v = r->units; need && v; v = v->next) { for (v = r->units; need && v; v = v->next) {
if (v->faction == u->faction && help_money(v)) { if (v->faction == u->faction && help_money(v)) {
int give = get_money(v) - lifestyle(v); int give = get_money(v) - lifestyle(v);
give = min(need, give); give = MIN(need, give);
if (give>0) { if (give>0) {
change_money(v, -give); change_money(v, -give);
change_money(u, give); change_money(u, give);
@ -231,7 +231,7 @@ get_food(region *r)
int need = lifestyle(u); int need = lifestyle(u);
faction * f = u->faction; faction * f = u->faction;
need -= max(0, get_money(u)); need -= MAX(0, get_money(u));
if (need > 0) { if (need > 0) {
unit *v; unit *v;
@ -239,7 +239,7 @@ get_food(region *r)
for (v = r->units; need && v; v = v->next) { for (v = r->units; need && v; v = v->next) {
if (v->faction != f && alliedunit(v, f, HELP_MONEY) && help_money(v)) { if (v->faction != f && alliedunit(v, f, HELP_MONEY) && help_money(v)) {
int give = get_money(v) - lifestyle(v); int give = get_money(v) - lifestyle(v);
give = min(need, give); give = MIN(need, give);
if (give>0) { if (give>0) {
change_money(v, -give); change_money(v, -give);
@ -289,7 +289,7 @@ get_food(region *r)
} }
if (donor != NULL) { if (donor != NULL) {
int blut = get_effect(donor, pt_blood); int blut = get_effect(donor, pt_blood);
blut = min(blut, hungry); blut = MIN(blut, hungry);
change_effect(donor, pt_blood, -blut); change_effect(donor, pt_blood, -blut);
hungry -= blut; hungry -= blut;
} }
@ -320,7 +320,7 @@ get_food(region *r)
/* 3. Von den überlebenden das Geld abziehen: */ /* 3. Von den überlebenden das Geld abziehen: */
for (u = r->units; u; u = u->next) { 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); change_money(u, -need);
} }
} }
@ -382,7 +382,7 @@ live(region * r)
} }
/* bestes Talent raussuchen */ /* bestes Talent raussuchen */
if (sb!=NULL) { if (sb!=NULL) {
int weeks = min(effect, u->number); int weeks = MIN(effect, u->number);
reduce_skill(u, sb, weeks); reduce_skill(u, sb, weeks);
ADDMSG(&u->faction->msgs, msg_message("dumbeffect", ADDMSG(&u->faction->msgs, msg_message("dumbeffect",
"unit weeks skill", u, weeks, (skill_t)sb->id)); "unit weeks skill", u, weeks, (skill_t)sb->id));
@ -439,7 +439,7 @@ calculate_emigration(region *r)
int max_emigration = MAX_EMIGRATION(rp2-maxp2); int max_emigration = MAX_EMIGRATION(rp2-maxp2);
if (max_emigration>0) { if (max_emigration>0) {
max_emigration = min(max_emigration, max_immigrants); max_emigration = MIN(max_emigration, max_immigrants);
r->land->newpeasants += max_emigration; r->land->newpeasants += max_emigration;
rc->land->newpeasants -= max_emigration; rc->land->newpeasants -= max_emigration;
max_immigrants -= max_emigration; max_immigrants -= max_emigration;
@ -499,7 +499,7 @@ peasants(region * r)
/* Alle werden satt, oder halt soviele für die es auch Geld gibt */ /* 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)); rsetmoney(r, money - satiated * maintenance_cost(NULL));
/* Von denjenigen, die nicht satt geworden sind, verhungert der /* Von denjenigen, die nicht satt geworden sind, verhungert der
@ -508,7 +508,7 @@ peasants(region * r)
/* Es verhungert maximal die unterernährten Bevölkerung. */ /* 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); dead += (int)(0.5F + n * PEASANT_STARVATION_CHANCE);
if (dead > 0) { if (dead > 0) {
@ -590,7 +590,7 @@ horses(region * r)
/* Logistisches Wachstum, Optimum bei halbem Maximalbesatz. */ /* Logistisches Wachstum, Optimum bei halbem Maximalbesatz. */
maxhorses = maxworkingpeasants(r)/10; maxhorses = maxworkingpeasants(r)/10;
maxhorses = max(0, maxhorses); maxhorses = MAX(0, maxhorses);
horses = rhorses(r); horses = rhorses(r);
if (horses > 0) { if (horses > 0) {
if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) { if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) {
@ -620,7 +620,7 @@ horses(region * r)
if (r2 && fval(r2->terrain, WALK_INTO)) { if (r2 && fval(r2->terrain, WALK_INTO)) {
int pt = (rhorses(r) * HORSEMOVE)/100; int pt = (rhorses(r) * HORSEMOVE)/100;
pt = (int)normalvariate(pt, pt/4.0); pt = (int)normalvariate(pt, pt/4.0);
pt = max(0, pt); pt = MAX(0, pt);
if (fval(r2, RF_MIGRATION)) if (fval(r2, RF_MIGRATION))
rsethorses(r2, rhorses(r2) + pt); rsethorses(r2, rhorses(r2) + pt);
else { else {
@ -666,7 +666,7 @@ trees(region * r, const int current_season, const int last_weeks_season)
a = a_find(r->attribs, &at_germs); a = a_find(r->attribs, &at_germs);
if(a && last_weeks_season == SEASON_SPRING) { if(a && last_weeks_season == SEASON_SPRING) {
/* ungekeimte Samen bleiben erhalten, Sprößlinge wachsen */ /* 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 */ /* aus dem gesamt Sprößlingepool abziehen */
rsettrees(r, 1, rtrees(r, 1) - sprout); rsettrees(r, 1, rtrees(r, 1) - sprout);
/* zu den Bäumen hinzufügen */ /* zu den Bäumen hinzufügen */
@ -686,7 +686,7 @@ trees(region * r, const int current_season, const int last_weeks_season)
/* Grundchance 1.0% */ /* Grundchance 1.0% */
seedchance = (int)(FORESTGROWTH * RESOURCE_QUANTITY); seedchance = (int)(FORESTGROWTH * RESOURCE_QUANTITY);
/* Jeder Elf in der Region erhöht die Chance um 0.0008%. */ /* Jeder Elf in der Region erhöht die Chance um 0.0008%. */
seedchance += (min(elves, (production(r)*MAXPEASANTS_PER_AREA)/8)) * 8; seedchance += (MIN(elves, (production(r)*MAXPEASANTS_PER_AREA)/8)) * 8;
grownup_trees = rtrees(r, 2); grownup_trees = rtrees(r, 2);
seeds = 0; seeds = 0;
@ -738,7 +738,7 @@ trees(region * r, const int current_season, const int last_weeks_season)
/* Raubbau abfangen, es dürfen nie mehr Samen wachsen, als aktuell /* Raubbau abfangen, es dürfen nie mehr Samen wachsen, als aktuell
* in der Region sind */ * in der Region sind */
seeds = min(a->data.sa[0], rtrees(r, 0)); seeds = MIN(a->data.sa[0], rtrees(r, 0));
sprout = 0; sprout = 0;
for(i=0;i<seeds;i++) { for(i=0;i<seeds;i++) {
@ -757,7 +757,7 @@ trees(region * r, const int current_season, const int last_weeks_season)
* der Region entfernt werden können, da Jungbäume in der gleichen * der Region entfernt werden können, da Jungbäume in der gleichen
* Runde nachwachsen, wir also nicht mehr zwischen diesjährigen und * Runde nachwachsen, wir also nicht mehr zwischen diesjährigen und
* 'alten' Jungbäumen unterscheiden könnten */ * '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; grownup_trees = 0;
for(i=0;i<sprout;i++) { for(i=0;i<sprout;i++) {
@ -844,7 +844,7 @@ demographics(void)
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
if (r->land && r->land->newpeasants) { if (r->land && r->land->newpeasants) {
int rp = rpeasants(r) + r->land->newpeasants; int rp = rpeasants(r) + r->land->newpeasants;
rsetpeasants(r, max(0, rp)); rsetpeasants(r, MAX(0, rp));
} }
} }
@ -1089,7 +1089,7 @@ parse_restart(void)
puts(" - beseitige Spieler, die sich nach der Anmeldung nicht " puts(" - beseitige Spieler, die sich nach der Anmeldung nicht "
"gemeldet haben..."); "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)) { for (f = factions; f; f = f->next) if (!is_monsters(f)) {
if (RemoveNMRNewbie() && !fval(f, FFL_NOIDLEOUT)) { if (RemoveNMRNewbie() && !fval(f, FFL_NOIDLEOUT)) {
if (f->age>=0 && f->age <= turn) ++age[f->age]; if (f->age>=0 && f->age <= turn) ++age[f->age];
@ -2386,7 +2386,7 @@ combatspell_cmd(unit * u, struct order * ord)
if (findparam(s, u->faction->locale) == P_LEVEL) { if (findparam(s, u->faction->locale) == P_LEVEL) {
/* Merken, setzen kommt erst später */ /* Merken, setzen kommt erst später */
level = getint(); level = getint();
level = max(0, level); level = MAX(0, level);
s = getstrtoken(); s = getstrtoken();
} }
@ -2943,8 +2943,8 @@ age_building(building * b)
} }
} else if (mage!=NULL) { } else if (mage!=NULL) {
int sk = effskill(mage, SK_MAGIC); int sk = effskill(mage, SK_MAGIC);
c->duration = max(c->duration, sk/2); c->duration = MAX(c->duration, sk/2);
c->vigour = max(c->vigour, sk); c->vigour = MAX(c->vigour, sk);
} }
} }
} }
@ -2969,12 +2969,12 @@ ageing(void)
/* Goliathwasser */ /* Goliathwasser */
int i = get_effect(u, oldpotiontype[P_STRONG]); int i = get_effect(u, oldpotiontype[P_STRONG]);
if (i > 0){ 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*/ /* Berserkerblut*/
i = get_effect(u, oldpotiontype[P_BERSERK]); i = get_effect(u, oldpotiontype[P_BERSERK]);
if (i > 0){ 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)){ if (is_cursed(u->attribs, C_OLDRACE, 0)){
@ -3325,9 +3325,9 @@ monthly_healing(void)
p *= heal_factor(u->race); p *= heal_factor(u->race);
if (u->hp < umhp) { if (u->hp < umhp) {
#ifdef NEW_DAEMONHUNGER_RULE #ifdef NEW_DAEMONHUNGER_RULE
double maxheal = max(u->number, umhp/20.0); double maxheal = MAX(u->number, umhp/20.0);
#else #else
double maxheal = max(u->number, umhp/10.0); double maxheal = MAX(u->number, umhp/10.0);
#endif #endif
int addhp; int addhp;
struct building * b = inside_building(u); struct building * b = inside_building(u);
@ -3344,7 +3344,7 @@ monthly_healing(void)
if (maxheal>0.0 && chance(maxheal)) ++addhp; if (maxheal>0.0 && chance(maxheal)) ++addhp;
/* Aufaddieren der geheilten HP. */ /* 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? */ /* soll man an negativer regeneration sterben können? */
assert(u->hp > 0); assert(u->hp > 0);
@ -3502,7 +3502,7 @@ claim_cmd(unit * u, struct order * ord)
if (itype!=NULL) { if (itype!=NULL) {
item ** iclaim = i_find(&u->faction->items, itype); item ** iclaim = i_find(&u->faction->items, itype);
if (iclaim!=NULL && *iclaim!=NULL) { if (iclaim!=NULL && *iclaim!=NULL) {
n = min(n, (*iclaim)->number); n = MIN(n, (*iclaim)->number);
i_change(iclaim, itype, -n); i_change(iclaim, itype, -n);
i_change(&u->items, itype, n); i_change(&u->items, itype, n);
} }

View file

@ -84,7 +84,7 @@ reduce_weight(unit * u)
int weight = 0; int weight = 0;
if (horses > 0) { if (horses > 0) {
horses = min(horses, (u->number*2)); horses = MIN(horses, (u->number*2));
change_resource(u, oldresourcetype[R_HORSE], - horses); change_resource(u, oldresourcetype[R_HORSE], - horses);
} }
@ -96,7 +96,7 @@ reduce_weight(unit * u)
if (weight>capacity) { if (weight>capacity) {
if (itype->weight>=10 && itype->rtype->wtype==0 && itype->rtype->atype==0) { if (itype->weight>=10 && itype->rtype->wtype==0 && itype->rtype->atype==0) {
if (itype->capacity < 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); give_item(reduce, itm->type, u, NULL, NULL);
weight -= reduce * itype->weight; weight -= reduce * itype->weight;
} }
@ -110,7 +110,7 @@ reduce_weight(unit * u)
const item_type * itype = itm->type; const item_type * itype = itm->type;
weight += itm->number*itype->weight; weight += itm->number*itype->weight;
if (itype->capacity < 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); give_item(reduce, itm->type, u, NULL, NULL);
weight -= reduce * itype->weight; weight -= reduce * itype->weight;
} }
@ -608,7 +608,7 @@ eaten_by_monster(unit * u)
if (n > 0) { if (n > 0) {
n = lovar(n); n = lovar(n);
n = min(rpeasants(u->region), n); n = MIN(rpeasants(u->region), n);
if (n > 0) { if (n > 0) {
deathcounts(u->region, n); deathcounts(u->region, n);
@ -634,7 +634,7 @@ absorbed_by_monster(unit * u)
if(n > 0) { if(n > 0) {
n = lovar(n); n = lovar(n);
n = min(rpeasants(u->region), n); n = MIN(rpeasants(u->region), n);
if (n > 0){ if (n > 0){
rsetpeasants(u->region, rpeasants(u->region) - n); rsetpeasants(u->region, rpeasants(u->region) - n);
scale_number(u, u->number + n); scale_number(u, u->number + n);
@ -650,7 +650,7 @@ scareaway(region * r, int anzahl)
int n, p, diff = 0, emigrants[MAXDIRECTIONS]; int n, p, diff = 0, emigrants[MAXDIRECTIONS];
direction_t d; 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 /* Wandern am Ende der Woche (normal) oder wegen Monster. Die
* Wanderung wird erst am Ende von demographics () ausgefuehrt. * Wanderung wird erst am Ende von demographics () ausgefuehrt.
@ -662,7 +662,7 @@ scareaway(region * r, int anzahl)
p = rpeasants(r); p = rpeasants(r);
assert(p >= 0 && anzahl >= 0); 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); direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS);
region * rc = rconnect(r, dir); region * rc = rconnect(r, dir);
@ -698,7 +698,7 @@ scared_by_monster(unit * u)
if(n > 0) { if(n > 0) {
n = lovar(n); n = lovar(n);
n = min(rpeasants(u->region), n); n = MIN(rpeasants(u->region), n);
if(n > 0) { if(n > 0) {
n = scareaway(u->region, n); n = scareaway(u->region, n);
if(n > 0) { if(n > 0) {

View file

@ -1160,7 +1160,7 @@ rotting_herbs(void)
if (fval(itm->type, ITF_HERB)) { if (fval(itm->type, ITF_HERB)) {
double nv = normalvariate(k, k/4); double nv = normalvariate(k, k/4);
int inv = (int)nv; int inv = (int)nv;
int delta = min(n, inv); int delta = MIN(n, inv);
if (i_change(itmp, itm->type, -delta)==NULL) { if (i_change(itmp, itm->type, -delta)==NULL) {
continue; continue;
} }
@ -1207,7 +1207,7 @@ randomevents(void)
a_remove(&r->attribs, a); a_remove(&r->attribs, a);
ADDMSG(&r->msgs, msg_message("orcified", "region", r)); ADDMSG(&r->msgs, msg_message("orcified", "region", r));
} else { } 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); if (a->data.i <= 0) a_remove(&r->attribs, a);
} }
} }
@ -1244,7 +1244,7 @@ randomevents(void)
while (*blist) { while (*blist) {
building * b = *blist; building * b = *blist;
if (fval(b->type, BTF_DECAY) && !buildingowner(r, b)) { if (fval(b->type, BTF_DECAY) && !buildingowner(r, b)) {
b->size -= max(1, (b->size * 20) / 100); b->size -= MAX(1, (b->size * 20) / 100);
if (b->size == 0) { if (b->size == 0) {
remove_building(blist, r->buildings); remove_building(blist, r->buildings);
} }

View file

@ -139,7 +139,7 @@ spy_cmd(unit * u, struct order * ord)
* Für jeden Talentpunkt, den das Spionagetalent das Tarnungstalent * Für jeden Talentpunkt, den das Spionagetalent das Tarnungstalent
* des Opfers übersteigt, erhöht sich dieses um 5%*/ * des Opfers übersteigt, erhöht sich dieses um 5%*/
spy = eff_skill(u, SK_SPY, r) - eff_skill(target, SK_STEALTH, r); 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)) { if (chance(spychance)) {
produceexp(u, SK_SPY, u->number); produceexp(u, SK_SPY, u->number);
@ -154,7 +154,7 @@ spy_cmd(unit * u, struct order * ord)
- (effskill(u, SK_STEALTH) + eff_skill(u, SK_SPY, r)/2); - (effskill(u, SK_STEALTH) + eff_skill(u, SK_SPY, r)/2);
if (invisible(u, target) >= u->number) { if (invisible(u, target) >= u->number) {
observe = min(observe, 0); observe = MIN(observe, 0);
} }
/* Anschließend wird - unabhängig vom Erfolg - gewürfelt, ob der /* Anschließend wird - unabhängig vom Erfolg - gewürfelt, ob der
@ -392,7 +392,7 @@ crew_skill(region * r, faction * f, ship * sh, skill_t sk)
for (u=r->units;u;u=u->next) { for (u=r->units;u;u=u->next) {
if (u->ship == sh && u->faction == f) { if (u->ship == sh && u->faction == f) {
int s = eff_skill(u, sk, r); int s = eff_skill(u, sk, r);
value = max(s, value); value = MAX(s, value);
} }
} }
return value; return value;

View file

@ -159,7 +159,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
* steigen. * steigen.
* *
* n ist die Anzahl zusätzlich gelernter Tage. n darf max. die Differenz * n ist die Anzahl zusätzlich 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)){ if (magic_lowskill(student)){
cmistake(teacher, teacher->thisorder, 292, MSG_EVENT); cmistake(teacher, teacher->thisorder, 292, MSG_EVENT);
@ -173,7 +173,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
n -= teach->value; n -= teach->value;
} }
n = min(n, nteaching); n = MIN(n, nteaching);
if (n != 0) { if (n != 0) {
struct building * b = inside_building(teacher); struct building * b = inside_building(teacher);
@ -196,7 +196,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
&& student->building && student->building->type == bt_find("academy")) && student->building && student->building->type == bt_find("academy"))
{ {
int j = study_cost(student, sk); int j = study_cost(student, sk);
j = max(50, j * 2); j = MAX(50, j * 2);
/* kann Einheit das zahlen? */ /* kann Einheit das zahlen? */
if (get_pooled(student, oldresourcetype[R_SILVER], GET_DEFAULT, j) >= j) { if (get_pooled(student, oldresourcetype[R_SILVER], GET_DEFAULT, j) >= j) {
/* Jeder Schüler zusätzlich +10 Tage wenn in Uni. */ /* Jeder Schüler zusätzlich +10 Tage wenn in Uni. */
@ -236,7 +236,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
* die Talentänderung (enno). * die Talentänderung (enno).
*/ */
nteaching = max(0, nteaching - student->number * 30); nteaching = MAX(0, nteaching - student->number * 30);
} }
return n; return n;
@ -274,7 +274,7 @@ teach_cmd(unit * u, struct order * ord)
teaching = u->number * 30 * TEACHNUMBER; teaching = u->number * 30 * TEACHNUMBER;
if ((i = get_effect(u, oldpotiontype[P_FOOL])) > 0) { /* Trank "Dumpfbackenbrot" */ 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 Schüler, nicht pro Lehrer */ /* Trank wirkt pro Schüler, nicht pro Lehrer */
teaching -= i * 30; teaching -= i * 30;
change_effect(u, oldpotiontype[P_FOOL], -i); change_effect(u, oldpotiontype[P_FOOL], -i);
@ -532,7 +532,7 @@ learn_cmd(unit * u, order * ord)
const struct building_type * btype = b?b->type:NULL; const struct building_type * btype = b?b->type:NULL;
if (btype == bt_find("academy")) { if (btype == bt_find("academy")) {
studycost = max(50, studycost * 2); studycost = MAX(50, studycost * 2);
} }
} }
@ -608,11 +608,11 @@ learn_cmd(unit * u, order * ord)
if (studycost) { if (studycost) {
int cost = studycost * u->number; int cost = studycost * u->number;
money = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, cost); money = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, cost);
money = min(money, cost); money = MIN(money, cost);
} }
if (money < studycost * u->number) { if (money < studycost * u->number) {
studycost = p; /* Ohne Univertreurung */ studycost = p; /* Ohne Univertreurung */
money = min(money, studycost); money = MIN(money, studycost);
if (p>0 && money < studycost * u->number) { if (p>0 && money < studycost * u->number) {
cmistake(u, ord, 65, MSG_EVENT); cmistake(u, ord, 65, MSG_EVENT);
multi = money / (double)(studycost * u->number); multi = money / (double)(studycost * u->number);
@ -631,12 +631,12 @@ learn_cmd(unit * u, order * ord)
} }
if (get_effect(u, oldpotiontype[P_WISE])) { 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; teach->value += l * 10;
change_effect(u, oldpotiontype[P_WISE], -l); change_effect(u, oldpotiontype[P_WISE], -l);
} }
if (get_effect(u, oldpotiontype[P_FOOL])) { 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; teach->value -= l * 30;
change_effect(u, oldpotiontype[P_FOOL], -l); change_effect(u, oldpotiontype[P_FOOL], -l);
} }
@ -651,7 +651,7 @@ learn_cmd(unit * u, order * ord)
teach->value += u->number * 5 * (l+1); teach->value += u->number * 5 * (l+1);
} else { } else {
teach->value -= u->number * 5 * (l+1); teach->value -= u->number * 5 * (l+1);
teach->value = max(0, teach->value); teach->value = MAX(0, teach->value);
} }
} }
#endif /* KARMA_MODULE */ #endif /* KARMA_MODULE */

View file

@ -99,7 +99,7 @@ attack_catapult(const troop * at, const struct weapon_type * wtype, int * casual
} }
enemies = count_enemies(b, af, FIGHT_ROW, FIGHT_ROW, SELECT_ADVANCE); enemies = count_enemies(b, af, FIGHT_ROW, FIGHT_ROW, SELECT_ADVANCE);
enemies = min(enemies, CATAPULT_ATTACKS); enemies = MIN(enemies, CATAPULT_ATTACKS);
if (enemies==0) { if (enemies==0) {
return true; /* allow further attacks */ return true; /* allow further attacks */
} }

View file

@ -67,7 +67,7 @@ use_manacrystal(struct unit * u, const struct item_type * itype, int amount, str
} }
for (i=0;i!=amount;++i) { 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); change_spellpoints(u, sp);
} }

View file

@ -72,11 +72,11 @@ herbsearch(region * r, unit * u, int max)
return; return;
} }
if (max) max = min(max, rherbs(r)); if (max) max = MIN(max, rherbs(r));
else max = rherbs(r); else max = rherbs(r);
herbsfound = ntimespprob(eff_skill(u, SK_HERBALISM, r) * u->number, herbsfound = ntimespprob(eff_skill(u, SK_HERBALISM, r) * u->number,
(double)rherbs(r)/100.0F, -0.01F); (double)rherbs(r)/100.0F, -0.01F);
herbsfound = min(herbsfound, max); herbsfound = MIN(herbsfound, max);
rsetherbs(r, rherbs(r)-herbsfound); rsetherbs(r, rherbs(r)-herbsfound);
if (herbsfound) { if (herbsfound) {
@ -128,7 +128,7 @@ use_potion(unit * u, const item_type * itype, int amount, struct order *ord)
} else if (ptype==oldpotiontype[P_HEAL]) { } else if (ptype==oldpotiontype[P_HEAL]) {
return EUNUSABLE; return EUNUSABLE;
} else if (ptype==oldpotiontype[P_HEILWASSER]) { } 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]) { } else if (ptype==oldpotiontype[P_PEOPLE]) {
region * r = u->region; region * r = u->region;
attrib * a = (attrib*)a_find(r->attribs, &at_peasantluck); attrib * a = (attrib*)a_find(r->attribs, &at_peasantluck);
@ -144,7 +144,7 @@ use_potion(unit * u, const item_type * itype, int amount, struct order *ord)
amount=1; amount=1;
} else if (ptype==oldpotiontype[P_MACHT]) { } else if (ptype==oldpotiontype[P_MACHT]) {
/* Verfünffacht die HP von max. 10 Personen in der Einheit */ /* 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 { } else {
change_effect(u, ptype, 10*amount); change_effect(u, ptype, 10*amount);
} }

View file

@ -94,7 +94,6 @@ alliance_kick(const tnode * tnext, void * data, struct order * ord)
unit * u = (unit*)data; unit * u = (unit*)data;
faction * f = findfaction(getid()); faction * f = findfaction(getid());
attrib * a; attrib * a;
unused(tnext);
if (f==NULL || f->alliance!=u->faction->alliance) { if (f==NULL || f->alliance!=u->faction->alliance) {
/* does not belong to our alliance */ /* does not belong to our alliance */

View file

@ -216,7 +216,7 @@ armedmen(const unit * u, boolean siege_weapons)
/* if (effskill(u, wtype->skill) >= wtype->minskill) n += itm->number; */ /* if (effskill(u, wtype->skill) >= wtype->minskill) n += itm->number; */
if (n>u->number) break; if (n>u->number) break;
} }
n = min(n, u->number); n = MIN(n, u->number);
} }
} }
return n; return n;
@ -442,7 +442,7 @@ get_row(const side * s, int row, const side * vs)
/* every entry in the size[] array means someone trying to defend us. /* every entry in the size[] array means someone trying to defend us.
* 'retreat' is the number of rows falling. * 'retreat' is the number of rows falling.
*/ */
result = max(FIRST_ROW, row - retreat); result = MAX(FIRST_ROW, row - retreat);
return result; return result;
} }
@ -576,11 +576,11 @@ weapon_skill(const weapon_type * wtype, const unit * u, boolean attacking)
if(u->race == new_race[RC_URUK]) { if(u->race == new_race[RC_URUK]) {
int sword = effskill(u, SK_MELEE); int sword = effskill(u, SK_MELEE);
int spear = effskill(u, SK_SPEAR); int spear = effskill(u, SK_SPEAR);
skill = max(sword, spear) - 3; skill = MAX(sword, spear) - 3;
if (attacking) { if (attacking) {
skill = max(skill, u->race->at_default); skill = MAX(skill, u->race->at_default);
} else { } else {
skill = max(skill, u->race->df_default); skill = MAX(skill, u->race->df_default);
} }
} else { } else {
if (attacking) { if (attacking) {
@ -734,7 +734,7 @@ select_magicarmor(troop t)
int geschuetzt = 0; int geschuetzt = 0;
int ma = 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 */ if (geschuetzt > t.index) /* unser Kandidat wird geschuetzt */
ma += 1; ma += 1;
@ -1016,8 +1016,8 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
} }
#endif /* KARMA_MODULE */ #endif /* KARMA_MODULE */
kritchance = max(kritchance, 0.005); kritchance = MAX(kritchance, 0.005);
kritchance = min(0.9, kritchance); kritchance = MIN(0.9, kritchance);
while (chance(kritchance)) { while (chance(kritchance)) {
if (bdebug) { if (bdebug) {
@ -1040,7 +1040,7 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
} }
/* Skilldifferenzbonus */ /* Skilldifferenzbonus */
da += max(0, (sk-sd)/DAMAGE_QUOTIENT); da += MAX(0, (sk-sd)/DAMAGE_QUOTIENT);
} }
@ -1063,13 +1063,13 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
} }
if (res > 0) { 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 */ /* gegen Magie wirkt nur natürliche und magische Rüstung */
ar = an+am; ar = an+am;
} }
rda = max(da - ar,0); rda = MAX(da - ar,0);
if ((du->race->battle_flags & BF_INV_NONMAGIC) && !magic) rda = 0; if ((du->race->battle_flags & BF_INV_NONMAGIC) && !magic) rda = 0;
else { else {
@ -1094,7 +1094,7 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
} }
/* gibt Rüstung +effect für duration Treffer */ /* gibt Rüstung +effect für duration Treffer */
if (meffect->typ == SHIELD_ARMOR) { if (meffect->typ == SHIELD_ARMOR) {
rda = max(rda - meffect->effect, 0); rda = MAX(rda - meffect->effect, 0);
meffect->duration--; meffect->duration--;
} }
} }
@ -1294,7 +1294,7 @@ select_enemy(fighter * af, int minrow, int maxrow, int select)
minrow = FIGHT_ROW; minrow = FIGHT_ROW;
maxrow = BEHIND_ROW; maxrow = BEHIND_ROW;
} }
minrow = max(minrow, FIGHT_ROW); minrow = MAX(minrow, FIGHT_ROW);
enemies = count_enemies(b, af, minrow, maxrow, select); enemies = count_enemies(b, af, minrow, maxrow, select);
@ -1367,7 +1367,7 @@ select_opponent(battle * b, troop at, int mindist, int maxdist)
* them */ * them */
dt = select_enemy(at.fighter, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); dt = select_enemy(at.fighter, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
} else { } else {
mindist = max(mindist, FIGHT_ROW); mindist = MAX(mindist, FIGHT_ROW);
dt = select_enemy(at.fighter, mindist, maxdist, SELECT_ADVANCE); dt = select_enemy(at.fighter, mindist, maxdist, SELECT_ADVANCE);
} }
@ -1479,7 +1479,7 @@ do_combatmagic(battle *b, combatmagic_t was)
} }
level = eff_spelllevel(mage, sp, level, 1); level = eff_spelllevel(mage, sp, level, 1);
if (sl > 0) level = min(sl, level); if (sl > 0) level = MIN(sl, level);
if (level < 0) { if (level < 0) {
report_failed_spell(b, mage, sp); report_failed_spell(b, mage, sp);
free_order(ord); free_order(ord);
@ -1561,7 +1561,7 @@ do_combatspell(troop at)
} }
level = eff_spelllevel(mage, sp, fi->magic, 1); level = eff_spelllevel(mage, sp, fi->magic, 1);
if ((sl = get_combatspelllevel(mage, 1)) > 0) level = min(level, sl); if ((sl = get_combatspelllevel(mage, 1)) > 0) level = MIN(level, sl);
if (fumble(r, mage, sp, sp->level) == true) { if (fumble(r, mage, sp, sp->level) == true) {
report_failed_spell(b, mage, sp); report_failed_spell(b, mage, sp);
@ -1825,7 +1825,7 @@ dazzle(battle *b, troop *td)
void void
damage_building(battle *b, building *bldg, int damage_abs) 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. */ /* Wenn Burg, dann gucken, ob die Leute alle noch in das Gebäude passen. */
@ -2085,7 +2085,7 @@ do_regenerate(fighter *af)
while(ta.index--) { while(ta.index--) {
af->person[ta.index].hp += effskill(au, SK_STAMINA); 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);
} }
} }
@ -2118,9 +2118,9 @@ fleechance(unit * u)
if (u->race == new_race[RC_HALFLING]) { if (u->race == new_race[RC_HALFLING]) {
c += 0.20; c += 0.20;
c = min(c, 0.90); c = MIN(c, 0.90);
} else { } else {
c = min(c, 0.75); c = MIN(c, 0.75);
} }
if (a!=NULL) c += a->data.flt; if (a!=NULL) c += a->data.flt;
@ -2189,7 +2189,7 @@ loot_items(fighter * corpse)
float lootfactor = dead/(float)u->number; /* only loot the dead! */ float lootfactor = dead/(float)u->number; /* only loot the dead! */
int maxloot = (int)(itm->number*lootfactor); int maxloot = (int)(itm->number*lootfactor);
if (maxloot>0) { if (maxloot>0) {
int i = min(10, maxloot); int i = MIN(10, maxloot);
for (; i != 0; --i) { for (; i != 0; --i) {
int loot = maxloot/i; int loot = maxloot/i;
@ -2264,7 +2264,7 @@ static void
battle_effects(battle * b, int dead_players) battle_effects(battle * b, int dead_players)
{ {
region * r = b->region; region * r = b->region;
int dead_peasants = min(rpeasants(r), (int)(dead_players*PopulationDamage())); int dead_peasants = MIN(rpeasants(r), (int)(dead_players*PopulationDamage()));
deathcounts(r, dead_peasants + dead_players); deathcounts(r, dead_peasants + dead_players);
chaoscounts(r, dead_peasants / 2); chaoscounts(r, dead_peasants / 2);
rsetpeasants(r, rpeasants(r) - dead_peasants); rsetpeasants(r, rpeasants(r) - dead_peasants);
@ -2805,7 +2805,7 @@ print_stats(battle * b)
for (s=b->sides;s!=b->sides+b->nsides;++s) { for (s=b->sides;s!=b->sides+b->nsides;++s) {
if (cv_size(&s->leader.fighters)) { if (cv_size(&s->leader.fighters)) {
b->max_tactics = max(b->max_tactics, s->leader.value); b->max_tactics = MAX(b->max_tactics, s->leader.value);
} }
} }
@ -2948,7 +2948,7 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
/* change_effect wird in ageing gemacht */ /* change_effect wird in ageing gemacht */
/* Effekte von Artefakten */ /* Effekte von Artefakten */
strongmen = min(fig->unit->number, get_item(u, I_TROLLBELT)); strongmen = MIN(fig->unit->number, get_item(u, I_TROLLBELT));
#if KARMA_MODULE #if KARMA_MODULE
for (a = a_find(u->attribs, &at_prayer_effect); a && a->type==&at_prayer_effect; a = a->next) { for (a = a_find(u->attribs, &at_prayer_effect); a && a->type==&at_prayer_effect; a = a->next) {
@ -3125,7 +3125,7 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
else else
p_bonus += 3; p_bonus += 3;
} while(rnd >= 97); } while(rnd >= 97);
bonus = max(p_bonus, bonus); bonus = MAX(p_bonus, bonus);
} }
t += bonus; t += bonus;
} }
@ -3241,7 +3241,7 @@ make_battle(region * r)
for (bf=b->factions;bf;bf=bf->next) { for (bf=b->factions;bf;bf=bf->next) {
faction * f = bf->faction; 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); freset(f, FFL_MARK);
} }
return b; return b;
@ -3284,7 +3284,7 @@ free_battle(battle * b)
bfaction * bf = b->factions; bfaction * bf = b->factions;
faction * f = bf->faction; faction * f = bf->faction;
b->factions = bf->next; b->factions = bf->next;
max_fac_no = max(max_fac_no, f->no); max_fac_no = MAX(max_fac_no, f->no);
free(bf); free(bf);
} }
@ -3542,7 +3542,7 @@ flee(const troop dt)
/* Regeländerung: Man muß das Tier nicht reiten können, /* Regeländerung: Man muß das Tier nicht reiten können,
* um es vom Schlachtfeld mitzunehmen, ist ja nur * um es vom Schlachtfeld mitzunehmen, ist ja nur
* eine Region weit. * */ * eine Region weit. * */
keep = min(1, itm->number); keep = MIN(1, itm->number);
/* da ist das weight des tiers mit drin */ /* da ist das weight des tiers mit drin */
carry += itype->capacity - itype->weight; carry += itype->capacity - itype->weight;
} else if (itm->type->weight <= 0) { } else if (itm->type->weight <= 0) {
@ -3881,7 +3881,7 @@ battle_flee(battle * b)
troop dt; troop dt;
int runners = 0; int runners = 0;
/* Flucht nicht bei mehr als 600 HP. Damit Wyrme tötbar bleiben. */ /* 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 (fval(u->race, RCF_UNDEAD) || u->race == new_race[RC_SHADOWKNIGHT]) continue; if (fval(u->race, RCF_UNDEAD) || u->race == new_race[RC_SHADOWKNIGHT]) continue;
dt.fighter = fig; dt.fighter = fig;
@ -3918,7 +3918,7 @@ battle_flee(battle * b)
if (fig->person[dt.index].flags & FL_PANICED) { if (fig->person[dt.index].flags & FL_PANICED) {
ispaniced = EFFECT_PANIC_SPELL; ispaniced = EFFECT_PANIC_SPELL;
} }
if (chance(min(fleechance(u)+ispaniced, 0.90))) { if (chance(MIN(fleechance(u)+ispaniced, 0.90))) {
++runners; ++runners;
flee(dt); flee(dt);
} }

View file

@ -190,7 +190,7 @@ bin_r_str_buf(struct storage * store, char * result, size_t size)
result[0] = 0; result[0] = 0;
} else { } else {
len = (size_t)i; len = (size_t)i;
rd = min(len, size); rd = MIN(len, size);
fread(result, sizeof(char), rd, file(store)); fread(result, sizeof(char), rd, file(store));
if (rd<len) { if (rd<len) {
fseek(file(store), (long)(len-rd), SEEK_CUR); fseek(file(store), (long)(len-rd), SEEK_CUR);

View file

@ -99,7 +99,7 @@ get_borders_i(const region * r1, const region * r2)
int key = reg_hashkey(r1); int key = reg_hashkey(r1);
int k2 = reg_hashkey(r2); int k2 = reg_hashkey(r2);
key = min(k2, key) % BORDER_MAXHASH; key = MIN(k2, key) % BORDER_MAXHASH;
bp = &borders[key]; bp = &borders[key];
while (*bp) { while (*bp) {
border * b = *bp; border * b = *bp;
@ -452,7 +452,7 @@ b_nameroad(const border * b, const region * r, const struct faction * f, int gfl
return LOC(f->locale, mkname("border", "an_incomplete_road")); return LOC(f->locale, mkname("border", "an_incomplete_road"));
} }
} else { } else {
int percent = max(1, 100*local/r->terrain->max_road); int percent = MAX(1, 100*local/r->terrain->max_road);
if (local) { if (local) {
snprintf(buffer, sizeof(buffer), LOC(f->locale, mkname("border", "a_road_percent")), percent); snprintf(buffer, sizeof(buffer), LOC(f->locale, mkname("border", "a_road_percent")), percent);
} else { } else {

View file

@ -223,9 +223,9 @@ siege_cmd(unit * u, order * ord)
/* schaden durch katapulte */ /* schaden durch katapulte */
d = i_get(u->items, it_catapult); 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); 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) { if (eff_skill(u, SK_CATAPULT, r) >= 1) {
katapultiere = d; katapultiere = d;
d *= eff_skill(u, SK_CATAPULT, r); d *= eff_skill(u, SK_CATAPULT, r);
@ -251,11 +251,11 @@ siege_cmd(unit * u, order * ord)
* einheiten wieder abgesucht werden muessen! */ * einheiten wieder abgesucht werden muessen! */
usetsiege(u, b); usetsiege(u, b);
b->besieged += max(bewaffnete, katapultiere); b->besieged += MAX(bewaffnete, katapultiere);
/* definitiver schaden eingeschraenkt */ /* definitiver schaden eingeschraenkt */
d = min(d, b->size - 1); d = MIN(d, b->size - 1);
/* meldung, schaden anrichten */ /* meldung, schaden anrichten */
if (d && !curse_active(get_curse(b->attribs, magicwalls_ct))) { if (d && !curse_active(get_curse(b->attribs, magicwalls_ct))) {
@ -311,11 +311,11 @@ destroy_road(unit *u, int nmax, struct order * ord)
cmistake(u, ord, 71, MSG_PRODUCE); cmistake(u, ord, 71, MSG_PRODUCE);
} else { } else {
short road = rroad(r, d); short road = rroad(r, d);
n = min(n, road); n = MIN(n, road);
if (n!=0) { if (n!=0) {
region * r2 = rconnect(r,d); region * r2 = rconnect(r,d);
int willdo = eff_skill(u, SK_ROAD_BUILDING, r)*u->number; int willdo = eff_skill(u, SK_ROAD_BUILDING, r)*u->number;
willdo = min(willdo, n); willdo = MIN(willdo, n);
if (willdo==0) { if (willdo==0) {
/* TODO: error message */ /* TODO: error message */
} }
@ -502,7 +502,7 @@ build_road(region * r, unit * u, int size, direction_t d)
return; return;
} }
if (size>0) left = min(size, left); if (size>0) left = MIN(size, left);
/* baumaximum anhand der rohstoffe */ /* baumaximum anhand der rohstoffe */
if (u->race == new_race[RC_STONEGOLEM]){ if (u->race == new_race[RC_STONEGOLEM]){
n = u->number * GOLEM_STONE; n = u->number * GOLEM_STONE;
@ -513,14 +513,14 @@ build_road(region * r, unit * u, int size, direction_t d)
return; return;
} }
} }
left = min(n, left); left = MIN(n, left);
/* n = maximum by skill. try to maximize it */ /* n = maximum by skill. try to maximize it */
n = u->number * eff_skill(u, SK_ROAD_BUILDING, r); n = u->number * eff_skill(u, SK_ROAD_BUILDING, r);
if (n < left) { if (n < left) {
item * itm = *i_find(&u->items, olditemtype[I_RING_OF_NIMBLEFINGER]); item * itm = *i_find(&u->items, olditemtype[I_RING_OF_NIMBLEFINGER]);
if (itm!=NULL && itm->number>0) { if (itm!=NULL && itm->number>0) {
int rings = min(u->number, itm->number); int rings = MIN(u->number, itm->number);
n = n * (9*rings+u->number) / u->number; n = n * (9*rings+u->number) / u->number;
} }
} }
@ -529,15 +529,15 @@ build_road(region * r, unit * u, int size, direction_t d)
if (dm != 0) { if (dm != 0) {
int sk = eff_skill(u, SK_ROAD_BUILDING, r); int sk = eff_skill(u, SK_ROAD_BUILDING, r);
int todo = (left - n + sk - 1) / sk; int todo = (left - n + sk - 1) / sk;
todo = min(todo, u->number); todo = MIN(todo, u->number);
dm = min(dm, todo); dm = MIN(dm, todo);
change_effect(u, oldpotiontype[P_DOMORE], -dm); change_effect(u, oldpotiontype[P_DOMORE], -dm);
n += dm * sk; n += dm * sk;
} /* Auswirkung Schaffenstrunk */ } /* Auswirkung Schaffenstrunk */
} }
/* make minimum of possible and available: */ /* 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 /* n is now modified by several special effects, so we have to
* minimize it again to make sure the road will not grow beyond * minimize it again to make sure the road will not grow beyond
@ -553,7 +553,7 @@ build_road(region * r, unit * u, int size, direction_t d)
} else { } else {
use_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT, n); use_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT, n);
/* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */ /* 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", ADDMSG(&u->faction->msgs, msg_message("buildroad",
"region unit size", r, u, n)); "region unit size", r, u, n));
@ -632,7 +632,7 @@ build(unit * u, const construction * ctype, int completed, int want)
if (dm != 0) { if (dm != 0) {
/* Auswirkung Schaffenstrunk */ /* Auswirkung Schaffenstrunk */
dm = min(dm, u->number); dm = MIN(dm, u->number);
change_effect(u, oldpotiontype[P_DOMORE], -dm); change_effect(u, oldpotiontype[P_DOMORE], -dm);
skills += dm * effsk; skills += dm * effsk;
} }
@ -687,17 +687,17 @@ build(unit * u, const construction * ctype, int completed, int want)
item * itm = *i_find(&u->items, olditemtype[I_RING_OF_NIMBLEFINGER]); item * itm = *i_find(&u->items, olditemtype[I_RING_OF_NIMBLEFINGER]);
if (itm!=NULL) i = itm->number; if (itm!=NULL) i = itm->number;
if (i>0) { if (i>0) {
int rings = min(u->number, i); int rings = MIN(u->number, i);
n = n * (9*rings+u->number) / u->number; n = n * (9*rings+u->number) / u->number;
} }
} }
if (want>0) { if (want>0) {
n = min(want, n); n = MIN(want, n);
} }
if (type->maxsize>0) { if (type->maxsize>0) {
n = min(type->maxsize-completed, n); n = MIN(type->maxsize-completed, n);
if (type->improvement==NULL) { if (type->improvement==NULL) {
want = n; want = n;
} }
@ -752,7 +752,7 @@ build(unit * u, const construction * ctype, int completed, int want)
completed = completed + n; completed = completed + n;
} }
/* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */ /* 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; return made;
} }
@ -789,7 +789,7 @@ maxbuild(const unit * u, const construction * cons)
if (have<need) { if (have<need) {
return 0; return 0;
} }
else maximum = min(maximum, have/need); else maximum = MIN(maximum, have/need);
} }
return maximum; return maximum;
} }
@ -977,7 +977,7 @@ build_ship(unit * u, ship * sh, int want)
} }
if (sh->damage && can) { if (sh->damage && can) {
int repair = min(sh->damage, can * DAMAGE_SCALE); int repair = MIN(sh->damage, can * DAMAGE_SCALE);
n += repair / DAMAGE_SCALE; n += repair / DAMAGE_SCALE;
if (repair % DAMAGE_SCALE) ++n; if (repair % DAMAGE_SCALE) ++n;
sh->damage = sh->damage - repair; sh->damage = sh->damage - repair;
@ -1016,7 +1016,7 @@ create_ship(region * r, unit * u, const struct ship_type * newtype, int want, or
cmistake(u, ord, 88, MSG_PRODUCE); cmistake(u, ord, 88, MSG_PRODUCE);
return; return;
} }
if (want>0) want = min(want, msize); if (want>0) want = MIN(want, msize);
else want = msize; else want = msize;
sh = new_ship(newtype, u->faction->locale, r); sh = new_ship(newtype, u->faction->locale, r);
@ -1070,7 +1070,7 @@ continue_ship(region * r, unit * u, int want)
cmistake(u, u->thisorder, 88, MSG_PRODUCE); cmistake(u, u->thisorder, 88, MSG_PRODUCE);
return; return;
} }
if (want > 0) want = min(want, msize); if (want > 0) want = MIN(want, msize);
else want = msize; else want = msize;
build_ship(u, sh, want); build_ship(u, sh, want);

View file

@ -146,7 +146,7 @@ buildingcapacity(const building * b)
{ {
if (b->type->capacity>=0) { if (b->type->capacity>=0) {
if (b->type->maxcapacity>=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; return b->size * b->type->capacity;
} }

View file

@ -134,7 +134,7 @@ curse_age(attrib * a)
} else if (c_flags(c) & CURSE_NOAGE) { } else if (c_flags(c) & CURSE_NOAGE) {
c->duration = 1; c->duration = 1;
} else if (c->duration!=INT_MAX) { } else if (c->duration!=INT_MAX) {
c->duration = max(0, c->duration-1); c->duration = MAX(0, c->duration-1);
} }
return c->duration; return c->duration;
} }
@ -314,7 +314,7 @@ ct_find(const char *c)
if (strcmp(c, ctl->type->cname)==0) { if (strcmp(c, ctl->type->cname)==0) {
return ctl->type; return ctl->type;
} else { } else {
size_t k = min(strlen(c), strlen(ctl->type->cname)); size_t k = MIN(strlen(c), strlen(ctl->type->cname));
if (!strncasecmp(c, ctl->type->cname, k)) { if (!strncasecmp(c, ctl->type->cname, k)) {
return ctl->type; return ctl->type;
} }
@ -468,7 +468,7 @@ get_cursedmen(unit *u, curse *c)
cursedmen = cc->cursedmen; cursedmen = cc->cursedmen;
} }
return min(u->number, cursedmen); return MIN(u->number, cursedmen);
} }
/* setzt die Anzahl der betroffenen Personen auf cursedmen */ /* setzt die Anzahl der betroffenen Personen auf cursedmen */
@ -548,7 +548,7 @@ create_curse(unit *magician, attrib **ap, const curse_type *ct, double vigour,
/* es gibt schon eins diese Typs */ /* es gibt schon eins diese Typs */
if (c && ct->mergeflags != NO_MERGE) { if (c && ct->mergeflags != NO_MERGE) {
if(ct->mergeflags & M_DURATION){ if(ct->mergeflags & M_DURATION){
c->duration = max(c->duration, duration); c->duration = MAX(c->duration, duration);
} }
if(ct->mergeflags & M_SUMDURATION){ if(ct->mergeflags & M_SUMDURATION){
c->duration += duration; c->duration += duration;
@ -557,10 +557,10 @@ create_curse(unit *magician, attrib **ap, const curse_type *ct, double vigour,
c->effect.i += effect.i; c->effect.i += effect.i;
} }
if(ct->mergeflags & M_MAXEFFECT){ if(ct->mergeflags & M_MAXEFFECT){
c->effect.i = max(c->effect.i, effect.i); c->effect.i = MAX(c->effect.i, effect.i);
} }
if(ct->mergeflags & M_VIGOUR){ if(ct->mergeflags & M_VIGOUR){
c->vigour = max(vigour, c->vigour); c->vigour = MAX(vigour, c->vigour);
} }
if(ct->mergeflags & M_VIGOUR_ADD){ if(ct->mergeflags & M_VIGOUR_ADD){
c->vigour = vigour + c->vigour; c->vigour = vigour + c->vigour;

View file

@ -1833,7 +1833,7 @@ maxworkingpeasants(const struct region * r)
{ {
int i = production(r) * MAXPEASANTS_PER_AREA int i = production(r) * MAXPEASANTS_PER_AREA
- ((rtrees(r,2)+rtrees(r,1)/2) * TREESIZE); - ((rtrees(r,2)+rtrees(r,1)/2) * TREESIZE);
return max(i, 0); return MAX(i, 0);
} }
unit_list * unit_list *
@ -1886,8 +1886,8 @@ lighthouse_range(const building * b, const faction * f)
if (c > buildingcapacity(b)) break; if (c > buildingcapacity(b)) break;
if (f==NULL || u->faction == f) { if (f==NULL || u->faction == f) {
int sk = eff_skill(u, SK_PERCEPTION, r) / 3; int sk = eff_skill(u, SK_PERCEPTION, r) / 3;
d = max(d, sk); d = MAX(d, sk);
d = min(maxd, d); d = MIN(maxd, d);
if (d==maxd) break; if (d==maxd) break;
} }
} else if (c) break; /* first unit that's no longer in the house ends the search */ } else if (c) break; /* first unit that's no longer in the house ends the search */
@ -2578,7 +2578,7 @@ plagues(region * r, boolean ismagic)
/* Seuchenwahrscheinlichkeit in % */ /* Seuchenwahrscheinlichkeit in % */
if (!ismagic) { if (!ismagic) {
double mwp = max(maxworkingpeasants(r), 1); double mwp = MAX(maxworkingpeasants(r), 1);
double prob = pow(rpeasants(r) / (mwp * wage(r, NULL, NULL) * 0.13), 4.0) double prob = pow(rpeasants(r) / (mwp * wage(r, NULL, NULL) * 0.13), 4.0)
* PLAGUE_CHANCE; * PLAGUE_CHANCE;
@ -2670,7 +2670,7 @@ default_wage(const region *r, const faction * f, const race * rc)
/* Godcurse: Income -10 */ /* Godcurse: Income -10 */
if (curse_active(get_curse(r->attribs, ct_find("godcursezone")))) { 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 */ /* Bei einer Dürre verdient man nur noch ein Viertel */

View file

@ -52,7 +52,7 @@ new_group(faction * f, const char * name, int gid)
while (*gp) gp = &(*gp)->next; while (*gp) gp = &(*gp)->next;
*gp = g; *gp = g;
maxgid = max(gid, maxgid); maxgid = MAX(gid, maxgid);
g->name = strdup(name); g->name = strdup(name);
g->gid = gid; g->gid = gid;

View file

@ -751,7 +751,7 @@ heal(unit * user, int effect)
{ {
int req = unit_max_hp(user) * user->number - user->hp; int req = unit_max_hp(user) * user->number - user->hp;
if (req>0) { if (req>0) {
req = min(req, effect); req = MIN(req, effect);
effect -= req; effect -= req;
user->hp += req; user->hp += req;
} }

View file

@ -401,7 +401,7 @@ sacrifice_cmd(unit * u, struct order * ord)
cmistake(u, ord, 253, MSG_EVENT); cmistake(u, ord, 253, MSG_EVENT);
return 0; return 0;
} }
n = min(get_spellpoints(u), min(max_spellpoints(u->region, u), n)); n = MIN(get_spellpoints(u), min(max_spellpoints(u->region, u), n));
if(n <= 0) { if(n <= 0) {
cmistake(u, ord, 254, MSG_EVENT); cmistake(u, ord, 254, MSG_EVENT);
return 0; return 0;

View file

@ -534,7 +534,7 @@ get_combatspelllevel(const unit *u, int nr)
assert(nr < MAXCOMBATSPELLS); assert(nr < MAXCOMBATSPELLS);
if (m) { if (m) {
int level = eff_skill(u, SK_MAGIC, u->region); 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; return -1;
} }
@ -664,7 +664,7 @@ change_spellpoints(unit * u, int mp)
if (!m) return 0; if (!m) return 0;
/* verhindere negative Magiepunkte */ /* verhindere negative Magiepunkte */
sp = max(m->spellpoints + mp, 0); sp = MAX(m->spellpoints + mp, 0);
m->spellpoints = sp; m->spellpoints = sp;
return sp; return sp;
@ -723,7 +723,7 @@ max_spellpoints(const region * r, const unit * u)
n = get_curseeffect(u->attribs, C_AURA, 0); n = get_curseeffect(u->attribs, C_AURA, 0);
if (n>0) msp = (msp*n)/100; if (n>0) msp = (msp*n)/100;
return max((int)msp, 0); return MAX((int)msp, 0);
} }
int int
@ -759,7 +759,7 @@ countspells(unit *u, int step)
count = m->spellcount + step; count = m->spellcount + step;
/* negative Werte abfangen. */ /* negative Werte abfangen. */
m->spellcount = max(0,count); m->spellcount = MAX(0,count);
return m->spellcount; return m->spellcount;
} }
@ -847,7 +847,7 @@ eff_spelllevel(unit *u, const spell * sp, int cast_level, int range)
* gewünschten gebildet */ * gewünschten gebildet */
} else if (sp->components[k].cost == SPC_LEVEL) { } else if (sp->components[k].cost == SPC_LEVEL) {
costtyp = 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 /* bei Typ Linear müssen die Kosten in Höhe der Stufe vorhanden
* sein, ansonsten schlägt der Spruch fehl */ * sein, ansonsten schlägt der Spruch fehl */
} else if (sp->components[k].cost == SPC_LINEAR) { } else if (sp->components[k].cost == SPC_LINEAR) {
@ -859,7 +859,7 @@ eff_spelllevel(unit *u, const spell * sp, int cast_level, int range)
/* Ein Spruch mit Fixkosten wird immer mit der Stufe des Spruchs und /* Ein Spruch mit Fixkosten wird immer mit der Stufe des Spruchs und
* nicht auf der Stufe des Magiers gezaubert */ * nicht auf der Stufe des Magiers gezaubert */
if (costtyp == SPC_FIX) { if (costtyp == SPC_FIX) {
cast_level = min(cast_level, sp->level); cast_level = MIN(cast_level, sp->level);
} }
return cast_level; return cast_level;
@ -1061,7 +1061,7 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order
force = force * MagicPower(); force = force * MagicPower();
return max(force, 0); return MAX(force, 0);
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -1220,8 +1220,8 @@ target_resists_magic(unit *magician, void *obj, int objtyp, int t_bonus)
break; break;
} }
probability = max(0.02, probability + t_bonus*0.01); probability = MAX(0.02, probability + t_bonus*0.01);
probability = min(0.98, probability); probability = MIN(0.98, probability);
/* gibt true, wenn die Zufallszahl kleiner als die chance ist und /* gibt true, wenn die Zufallszahl kleiner als die chance ist und
* false, wenn sie gleich oder größer ist, dh je größer die * false, wenn sie gleich oder größer ist, dh je größer die
@ -1355,7 +1355,7 @@ do_fumble(castorder *co)
case 2: case 2:
/* temporärer Stufenverlust */ /* temporärer Stufenverlust */
duration = max(rng_int()%level/2, 2); duration = MAX(rng_int()%level/2, 2);
effect.i = -(level/2); effect.i = -(level/2);
c = create_curse(u, &u->attribs, ct_find("skillmod"), (float)level, duration, c = create_curse(u, &u->attribs, ct_find("skillmod"), (float)level, duration,
effect, 1); effect, 1);
@ -1469,15 +1469,15 @@ regeneration_magiepunkte(void)
/* maximal Differenz bis Maximale-Aura regenerieren /* maximal Differenz bis Maximale-Aura regenerieren
* mindestens 1 Aura pro Monat */ * mindestens 1 Aura pro Monat */
reg_aura = max(1,reg_aura); reg_aura = MAX(1,reg_aura);
reg_aura = min((auramax - aura), reg_aura); reg_aura = MIN((auramax - aura), reg_aura);
aura += (int)reg_aura; aura += (int)reg_aura;
ADDMSG(&u->faction->msgs, msg_message( ADDMSG(&u->faction->msgs, msg_message(
"regenaura", "unit region amount", "regenaura", "unit region amount",
u, r, (int)reg_aura)); u, r, (int)reg_aura));
} }
set_spellpoints(u, min(aura, auramax)); set_spellpoints(u, MIN(aura, auramax));
/* Zum letzten Mal Spruchliste aktualisieren */ /* Zum letzten Mal Spruchliste aktualisieren */
updatespelllist(u); updatespelllist(u);
@ -2473,7 +2473,7 @@ cast_cmd(unit * u, order * ord)
/* für Syntax ' STUFE x REGION y z ' */ /* für Syntax ' STUFE x REGION y z ' */
if (findparam(s, u->faction->locale) == P_LEVEL) { if (findparam(s, u->faction->locale) == P_LEVEL) {
int p = getint(); int p = getint();
level = min(p, level); level = MIN(p, level);
if (level < 1) { if (level < 1) {
/* Fehler "Das macht wenig Sinn" */ /* Fehler "Das macht wenig Sinn" */
cmistake(u, ord, 10, MSG_MAGIC); cmistake(u, ord, 10, MSG_MAGIC);
@ -2499,7 +2499,7 @@ cast_cmd(unit * u, order * ord)
* hier nach REGION nochmal auf STUFE prüfen */ * hier nach REGION nochmal auf STUFE prüfen */
if (findparam(s, u->faction->locale) == P_LEVEL) { if (findparam(s, u->faction->locale) == P_LEVEL) {
int p = getint(); int p = getint();
level = min(p, level); level = MIN(p, level);
if (level < 1) { if (level < 1) {
/* Fehler "Das macht wenig Sinn" */ /* Fehler "Das macht wenig Sinn" */
cmistake(u, ord, 10, MSG_MAGIC); cmistake(u, ord, 10, MSG_MAGIC);
@ -2622,7 +2622,7 @@ cast_cmd(unit * u, order * ord)
* löschen, zaubern kann er noch */ * löschen, zaubern kann er noch */
range *= 2; range *= 2;
set_order(&mage->thisorder, NULL); set_order(&mage->thisorder, NULL);
level = min(level, eff_skill(mage, SK_MAGIC, mage->region)/2); level = MIN(level, eff_skill(mage, SK_MAGIC, mage->region)/2);
familiar = u; familiar = u;
} }
} }

View file

@ -272,11 +272,11 @@ ridingcapacity(unit * u)
* tragen nichts (siehe walkingcapacity). Ein Wagen zählt nur, wenn er * tragen nichts (siehe walkingcapacity). Ein Wagen zählt nur, wenn er
* von zwei Pferden gezogen wird */ * 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, RCF_HORSE)) animals += u->number; if (fval(u->race, RCF_HORSE)) animals += u->number;
/* maximal diese Pferde können zum Ziehen benutzt werden */ /* maximal diese Pferde können zum Ziehen benutzt werden */
vehicles = min(animals / HORSESNEEDED, vehicles); vehicles = MIN(animals / HORSESNEEDED, vehicles);
return vehicles * vcap + animals * acap; return vehicles * vcap + animals * acap;
} }
@ -294,7 +294,7 @@ walkingcapacity(const struct unit * u)
/* Das Gewicht, welches die Pferde tragen, plus das Gewicht, welches /* Das Gewicht, welches die Pferde tragen, plus das Gewicht, welches
* die Leute tragen */ * 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, RCF_HORSE)) { if (fval(u->race, RCF_HORSE)) {
animals += u->number; animals += u->number;
people = 0; people = 0;
@ -303,7 +303,7 @@ walkingcapacity(const struct unit * u)
} }
/* maximal diese Pferde können zum Ziehen benutzt werden */ /* 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; n = wagen_mit_pferden * vcap;
@ -313,7 +313,7 @@ walkingcapacity(const struct unit * u)
wagen_ohne_pferde = vehicles - wagen_mit_pferden; wagen_ohne_pferde = vehicles - wagen_mit_pferden;
/* Genug Trolle, um die Restwagen zu ziehen? */ /* 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 */ /* Wagenkapazität hinzuzählen */
n += wagen_mit_trollen * vcap; n += wagen_mit_trollen * vcap;
@ -331,7 +331,7 @@ walkingcapacity(const struct unit * u)
} }
/* change_effect wird in ageing gemacht */ /* change_effect wird in ageing gemacht */
tmp = get_item(u, I_TROLLBELT); tmp = get_item(u, I_TROLLBELT);
n += min(people, tmp) * (STRENGTHMULTIPLIER-1) * personcapacity(u); n += MIN(people, tmp) * (STRENGTHMULTIPLIER-1) * personcapacity(u);
return n; return n;
} }
@ -359,7 +359,7 @@ canwalk(unit * u)
maxwagen = effskill(u, SK_RIDING) * u->number * 2; maxwagen = effskill(u, SK_RIDING) * u->number * 2;
if (u->race == new_race[RC_TROLL]) { if (u->race == 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; maxpferde = effskill(u, SK_RIDING) * u->number * 4 + u->number;
@ -843,7 +843,7 @@ bewegung_blockiert_von(unit * reisender, region * r)
if (!contact && guard) { if (!contact && guard) {
double prob = 0.3; /* 30% base chance */ double prob = 0.3; /* 30% base chance */
prob += 0.1 * (perception - eff_stealth(reisender, r)); 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)) { if (chance(prob)) {
return guard; return guard;
@ -1836,7 +1836,7 @@ sail(unit * u, order * ord, boolean move_on_land, region_list **routep)
const luxury_type * ltype = resource2luxury(itm->type->rtype); const luxury_type * ltype = resource2luxury(itm->type->rtype);
if (ltype!=NULL && itm->number>0) { if (ltype!=NULL && itm->number>0) {
int st = itm->number * effskill(hafenmeister, SK_TRADE) / 50; int st = itm->number * effskill(hafenmeister, SK_TRADE) / 50;
st = min(itm->number, st); st = MIN(itm->number, st);
if (st > 0) { if (st > 0) {
i_change(&u2->items, itm->type, -st); i_change(&u2->items, itm->type, -st);

View file

@ -418,9 +418,9 @@ 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 */ /* Einzelne Wörter anspringen und jeweils die ersten BpT kopieren */

View file

@ -180,7 +180,7 @@ get_pooled(const unit * u, const resource_type * rtype, unsigned int mode, int c
if ((mode & GET_SLACK) && (mode & GET_RESERVE)) use = have; if ((mode & GET_SLACK) && (mode & GET_RESERVE)) use = have;
else { else {
int reserve = get_reservation(u, rtype); 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; if (mode & GET_RESERVE) use = have-slack;
else if (mode & GET_SLACK) use = slack; else if (mode & GET_SLACK) use = slack;
} }
@ -216,17 +216,17 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
} }
if ((mode & GET_SLACK) && (mode & GET_RESERVE)) { if ((mode & GET_SLACK) && (mode & GET_RESERVE)) {
n = min(use, have); n = MIN(use, have);
} else { } else {
int reserve = get_reservation(u, rtype); int reserve = get_reservation(u, rtype);
int slack = max(0, have-reserve); int slack = MAX(0, have-reserve);
if (mode & GET_RESERVE) { if (mode & GET_RESERVE) {
n = have-slack; n = have-slack;
n = min(use, n); n = MIN(use, n);
change_reservation(u, rtype, -n); change_reservation(u, rtype, -n);
} }
else if (mode & GET_SLACK) { else if (mode & GET_SLACK) {
n = min(use, slack); n = MIN(use, slack);
} }
} }
if (n>0) { if (n>0) {

View file

@ -1202,7 +1202,7 @@ terraform_region(region * r, const terrain_type * terrain)
if (!fval(r, RF_CHAOTIC)) { if (!fval(r, RF_CHAOTIC)) {
int peasants; int peasants;
peasants = (maxworkingpeasants(r) * (20+dice_rand("6d10")))/100; 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)+1) + rng_int() % 5)); rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL)+1) + rng_int() % 5));
} }
} }

View file

@ -61,6 +61,7 @@ struct message;
struct message_list; struct message_list;
struct rawmaterial; struct rawmaterial;
struct donation; struct donation;
struct item;
typedef struct land_region { typedef struct land_region {
char *name; char *name;

View file

@ -203,8 +203,8 @@ update_nmrs(void)
int nmr = turn-f->lastorders+1; int nmr = turn-f->lastorders+1;
if (nmr<0 || nmr>NMRTimeout()) { if (nmr<0 || nmr>NMRTimeout()) {
log_error(("faction %s has %d NMRS\n", factionid(f), nmr)); log_error(("faction %s has %d NMRS\n", factionid(f), nmr));
nmr = max(0, nmr); nmr = MAX(0, nmr);
nmr = min(nmr, NMRTimeout()); nmr = MIN(nmr, NMRTimeout());
} }
++nmrs[nmr]; ++nmrs[nmr];
} }
@ -833,7 +833,7 @@ spskill(char * buffer, size_t size, const struct locale * lang, const struct uni
oldeff = sv->old + get_modifier(u, sv->id, sv->old, u->region, false); oldeff = sv->old + get_modifier(u, sv->id, sv->old, u->region, false);
} }
oldeff = max(0, oldeff); oldeff = MAX(0, oldeff);
diff = effsk - oldeff; diff = effsk - oldeff;
if (diff != 0) { if (diff != 0) {

View file

@ -1303,7 +1303,7 @@ invisible(const unit *target, const unit * viewer)
else { else {
int hidden = get_item(target, I_RING_OF_INVISIBILITY) + 100 * get_item(target, I_SPHERE_OF_INVISIBILITY); int hidden = get_item(target, I_RING_OF_INVISIBILITY) + 100 * get_item(target, I_SPHERE_OF_INVISIBILITY);
if (hidden) { if (hidden) {
hidden = min(hidden, target->number); hidden = MIN(hidden, target->number);
if (viewer) hidden -= get_item(viewer, I_AMULET_OF_TRUE_SEEING); if (viewer) hidden -= get_item(viewer, I_AMULET_OF_TRUE_SEEING);
} }
return hidden; return hidden;

View file

@ -218,8 +218,8 @@ tagbegin(xml_stack *stack)
monster * m = calloc(sizeof(monster), 1); monster * m = calloc(sizeof(monster), 1);
m->race = rc_find(xml_value(tag, "race")); m->race = rc_find(xml_value(tag, "race"));
m->chance = xml_fvalue(tag, "chance"); m->chance = xml_fvalue(tag, "chance");
m->avgsize = max(1, xml_ivalue(tag, "size")); m->avgsize = MAX(1, xml_ivalue(tag, "size"));
m->maxunits = min(1, xml_ivalue(tag, "maxunits")); m->maxunits = MIN(1, xml_ivalue(tag, "maxunits"));
if (m->race) { if (m->race) {
if (xml_bvalue(tag, "boss")) { if (xml_bvalue(tag, "boss")) {

View file

@ -23,7 +23,7 @@
/* util includes */ /* util includes */
#include <util/rng.h> #include <util/rng.h>
#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 DRAGONAGE 27
#define WYRMAGE 68 #define WYRMAGE 68

View file

@ -31,7 +31,7 @@
#define UNDEAD_BREAKUP 25 /* chance dafuer */ #define UNDEAD_BREAKUP 25 /* chance dafuer */
#define UNDEAD_BREAKUP_FRACTION (25+rng_int()%70) /* anteil der weg geht */ #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 void
age_undead(unit *u) age_undead(unit *u)
@ -61,7 +61,7 @@ void
age_skeleton(unit *u) age_skeleton(unit *u)
{ {
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) { 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); double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
u->race = new_race[RC_SKELETON_LORD]; u->race = new_race[RC_SKELETON_LORD];
u->irace = new_race[RC_SKELETON_LORD]; u->irace = new_race[RC_SKELETON_LORD];
@ -74,7 +74,7 @@ void
age_zombie(unit *u) age_zombie(unit *u)
{ {
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) { 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); double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
u->race = new_race[RC_ZOMBIE_LORD]; u->race = new_race[RC_ZOMBIE_LORD];
u->irace = new_race[RC_ZOMBIE_LORD]; u->irace = new_race[RC_ZOMBIE_LORD];
@ -87,7 +87,7 @@ void
age_ghoul(unit *u) age_ghoul(unit *u)
{ {
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) { 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); double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
u->race = new_race[RC_GHOUL_LORD]; u->race = new_race[RC_GHOUL_LORD];
u->irace = new_race[RC_GHOUL_LORD]; u->irace = new_race[RC_GHOUL_LORD];

View file

@ -286,14 +286,14 @@ sp_combatrosthauch(fighter * fi, int level, double power, spell * sp)
if (df->alive==0) continue; if (df->alive==0) continue;
if (force<=0) break; 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); assert(force >= 0);
if (df->weapons) { if (df->weapons) {
int w; int w;
for (w=0;df->weapons[w].type!=NULL;++w) { for (w=0;df->weapons[w].type!=NULL;++w) {
weapon * wp = df->weapons; weapon * wp = df->weapons;
int n = min(force, wp->used); int n = MIN(force, wp->used);
if (n) { if (n) {
requirement * mat = wp->type->itype->construction->materials; requirement * mat = wp->type->itype->construction->materials;
boolean iron = false; boolean iron = false;
@ -841,7 +841,7 @@ sp_shadowknights(fighter * fi, int level, double power, spell * sp)
region *r = b->region; region *r = b->region;
unit *mage = fi->unit; unit *mage = fi->unit;
attrib *a; attrib *a;
int force = max(1, (int)get_force(power, 3)); int force = MAX(1, (int)get_force(power, 3));
message * msg; message * msg;
unused(sp); unused(sp);
@ -933,7 +933,7 @@ sp_chaosrow(fighter * fi, int level, double power, spell * sp)
if (df->alive==0) continue; if (df->alive==0) continue;
if (power<=0.0) break; 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; if (is_magic_resistant(mage, df->unit, 0)) continue;
@ -967,7 +967,7 @@ sp_chaosrow(fighter * fi, int level, double power, spell * sp)
} }
k+=df->alive; k+=df->alive;
} }
power = max(0, power-n); power = MAX(0, power-n);
} }
cv_kill(fgs); cv_kill(fgs);
free(fgs); free(fgs);
@ -1066,12 +1066,12 @@ sp_hero(fighter * fi, int level, double power, spell * sp)
switch(sp->id) { switch(sp->id) {
case SPL_HERO: case SPL_HERO:
df_bonus = (int)(power/5); df_bonus = (int)(power/5);
force = max(1, lovar(get_force(power, 4))); force = MAX(1, lovar(get_force(power, 4)));
break; break;
default: default:
df_bonus = 1; df_bonus = 1;
force = max(1, (int)power); force = MAX(1, (int)power);
} }
allies = count_allies(fi->side, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); allies = count_allies(fi->side, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
@ -1115,7 +1115,7 @@ sp_berserk(fighter * fi, int level, double power, spell * sp)
switch(sp->id) { switch(sp->id) {
case SPL_BERSERK: case SPL_BERSERK:
case SPL_BLOODTHIRST: case SPL_BLOODTHIRST:
at_bonus = max(1,level/3); at_bonus = MAX(1,level/3);
df_malus = 2; df_malus = 2;
force = (int)get_force(power,2); force = (int)get_force(power,2);
break; break;
@ -1165,7 +1165,7 @@ sp_frighten(fighter * fi, int level, double power, spell * sp)
int targets = 0; int targets = 0;
message * m; message * m;
at_malus = max(1,level - 4); at_malus = MAX(1,level - 4);
df_malus = 2; df_malus = 2;
force = (int)get_force(power, 2); force = (int)get_force(power, 2);
@ -1427,7 +1427,7 @@ sp_fumbleshield(fighter * fi, int level, double power, spell * sp)
case SPL_CERRDOR_FUMBLESHIELD: case SPL_CERRDOR_FUMBLESHIELD:
case SPL_TYBIED_FUMBLESHIELD: case SPL_TYBIED_FUMBLESHIELD:
duration = 100; duration = 100;
effect = max(1, 25-level); effect = MAX(1, 25-level);
break; break;
default: default:
@ -1473,7 +1473,7 @@ sp_reanimate(fighter * fi, int level, double power, spell * sp)
} }
healable = count_healable(b, fi); healable = count_healable(b, fi);
healable = (int)min(k, healable); healable = (int)MIN(k, healable);
while (healable--) { while (healable--) {
fighter * tf = select_corpse(b, fi); fighter * tf = select_corpse(b, fi);
if (tf!=NULL && tf->side->casualties > 0 if (tf!=NULL && tf->side->casualties > 0
@ -1521,7 +1521,7 @@ sp_keeploot(fighter * fi, int level, double power, spell * sp)
message_all(b, m); message_all(b, m);
msg_release(m); msg_release(m);
b->keeploot = (int)max(25, b->keeploot + 5*power); b->keeploot = (int)MAX(25, b->keeploot + 5*power);
return level; return level;
} }
@ -1551,10 +1551,10 @@ heal_fighters(cvector *fgs, int * power, boolean heal_monsters)
if (rest>n) ++wound; if (rest>n) ++wound;
if (wound > 0 && wound < hp) { if (wound > 0 && wound < hp) {
int heal = min(healhp, wound); int heal = MIN(healhp, wound);
assert(heal>=0); assert(heal>=0);
df->person[n].hp += heal; df->person[n].hp += heal;
healhp = max(0, healhp - heal); healhp = MAX(0, healhp - heal);
++healed; ++healed;
if (healhp<=0) break; if (healhp<=0) break;
} }
@ -1678,7 +1678,7 @@ sp_undeadhero(fighter * fi, int level, double power, spell * sp)
cv_kill(fgs); cv_kill(fgs);
free(fgs); free(fgs);
level = min(level, undead); level = MIN(level, undead);
if (undead == 0) { if (undead == 0) {
msg = msg_message("summonundead_effect_0", "mage region", mage, mage->region); msg = msg_message("summonundead_effect_0", "mage region", mage, mage->region);
} else { } else {

View file

@ -149,7 +149,7 @@ magicanalyse_region(region *r, unit *mage, double force)
* mehr als 100% probability und damit immer ein Erfolg. */ * mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force); probability = curse_chance(c, force);
mon = c->duration + (rng_int()%10) - 5; mon = c->duration + (rng_int()%10) - 5;
mon = max(1, mon); mon = MAX(1, mon);
found = true; found = true;
if (chance(probability)) { /* Analyse geglückt */ if (chance(probability)) { /* Analyse geglückt */
@ -190,7 +190,7 @@ magicanalyse_unit(unit *u, unit *mage, double force)
* mehr als 100% probability und damit immer ein Erfolg. */ * mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force); probability = curse_chance(c, force);
mon = c->duration + (rng_int()%10) - 5; mon = c->duration + (rng_int()%10) - 5;
mon = max(1,mon); mon = MAX(1,mon);
if (chance(probability)) { /* Analyse geglückt */ if (chance(probability)) { /* Analyse geglückt */
if (c_flags(c) & CURSE_NOAGE) { if (c_flags(c) & CURSE_NOAGE) {
@ -231,7 +231,7 @@ magicanalyse_building(building *b, unit *mage, double force)
* mehr als 100% probability und damit immer ein Erfolg. */ * mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force); probability = curse_chance(c, force);
mon = c->duration + (rng_int()%10) - 5; mon = c->duration + (rng_int()%10) - 5;
mon = max(1,mon); mon = MAX(1,mon);
if (chance(probability)) { /* Analyse geglückt */ if (chance(probability)) { /* Analyse geglückt */
if (c_flags(c) & CURSE_NOAGE) { if (c_flags(c) & CURSE_NOAGE) {
@ -272,7 +272,7 @@ magicanalyse_ship(ship *sh, unit *mage, double force)
* mehr als 100% probability und damit immer ein Erfolg. */ * mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force); probability = curse_chance(c, force);
mon = c->duration + (rng_int()%10) - 5; mon = c->duration + (rng_int()%10) - 5;
mon = max(1,mon); mon = MAX(1,mon);
if (chance(probability)) { /* Analyse geglückt */ if (chance(probability)) { /* Analyse geglückt */
if (c_flags(c) & CURSE_NOAGE) { if (c_flags(c) & CURSE_NOAGE) {
@ -701,7 +701,7 @@ sp_destroy_magic(castorder *co)
mage, mage->region, co->order)); mage, mage->region, co->order));
} }
return max(succ, 1); return MAX(succ, 1);
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -764,7 +764,7 @@ sp_transferaura(castorder *co)
return 0; return 0;
} }
gain = min(aura, scm_src->spellpoints) / multi; gain = MIN(aura, scm_src->spellpoints) / multi;
scm_src->spellpoints -= gain*multi; scm_src->spellpoints -= gain*multi;
scm_dst->spellpoints += gain; scm_dst->spellpoints += gain;
@ -902,7 +902,7 @@ sp_summonent(castorder *co)
return 0; 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); u = create_unit(r, mage->faction, ents, new_race[RC_TREEMAN], 0, NULL, mage);
@ -1296,7 +1296,7 @@ sp_rosthauch(castorder *co)
for (;iweapon!=NULL;iweapon=iweapon->next) { for (;iweapon!=NULL;iweapon=iweapon->next) {
item ** ip = i_find(&u->items, iweapon->type); item ** ip = i_find(&u->items, iweapon->type);
if (*ip) { if (*ip) {
int i = min((*ip)->number, force); int i = MIN((*ip)->number, force);
if (iweapon->chance<1.0) { if (iweapon->chance<1.0) {
i = (int)(i*iweapon->chance); i = (int)(i*iweapon->chance);
} }
@ -1332,7 +1332,7 @@ sp_rosthauch(castorder *co)
* ungünstigsten Fall kann pro Stufe nur eine Waffe verzaubert werden, * ungünstigsten Fall kann pro Stufe nur eine Waffe verzaubert werden,
* darum wird hier nur für alle Fälle in denen noch weniger Waffen * darum wird hier nur für alle Fälle in denen noch weniger Waffen
* betroffen wurden ein Kostennachlass gegeben */ * betroffen wurden ein Kostennachlass gegeben */
return min(success, cast_level); return MIN(success, cast_level);
} }
@ -1364,7 +1364,7 @@ sp_kaelteschutz(castorder *co)
unit *mage = co->magician.u; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = max(cast_level, (int)force) + 1; int duration = MAX(cast_level, (int)force) + 1;
spellparameter *pa = co->par; spellparameter *pa = co->par;
variant effect; variant effect;
@ -2091,8 +2091,8 @@ sp_drought(castorder *co)
*/ */
c = get_curse(r->attribs, ct_find("drought")); c = get_curse(r->attribs, ct_find("drought"));
if (c) { if (c) {
c->vigour = max(c->vigour, power); c->vigour = MAX(c->vigour, power);
c->duration = max(c->duration, (int)power); c->duration = MAX(c->duration, (int)power);
} else { } else {
variant effect; variant effect;
/* Baeume und Pferde sterben */ /* Baeume und Pferde sterben */
@ -2280,8 +2280,8 @@ sp_earthquake(castorder *co)
if (burg->size != 0 && !is_cursed(burg->attribs, C_MAGICWALLS, 0)) { if (burg->size != 0 && !is_cursed(burg->attribs, C_MAGICWALLS, 0)) {
/* Magieresistenz */ /* Magieresistenz */
if (!target_resists_magic(mage, burg, TYP_BUILDING, 0)) { if (!target_resists_magic(mage, burg, TYP_BUILDING, 0)) {
kaputt = min(10 * cast_level, burg->size / 4); kaputt = MIN(10 * cast_level, burg->size / 4);
kaputt = max(kaputt, 1); kaputt = MAX(kaputt, 1);
burg->size -= kaputt; burg->size -= kaputt;
if (burg->size == 0) { if (burg->size == 0) {
/* TODO: sollten die Insassen nicht Schaden nehmen? */ /* TODO: sollten die Insassen nicht Schaden nehmen? */
@ -2448,7 +2448,7 @@ sp_forest_fire(castorder *co)
* das Zaubern. Patzer werden warscheinlicher. * das Zaubern. Patzer werden warscheinlicher.
* Jeder Zauber muss erst gegen den Wiederstand des Fluchs gezaubert * Jeder Zauber muss erst gegen den Wiederstand des Fluchs gezaubert
* werden und schwächt dessen Antimagiewiederstand um 1. * werden und schwächt dessen Antimagiewiederstand um 1.
* Wirkt max(Stufe(Magier) - Stufe(Ziel), rand(3)) Wochen * Wirkt MAX(Stufe(Magier) - Stufe(Ziel), rand(3)) Wochen
* Patzer: * Patzer:
* Magier wird selbst betroffen * Magier wird selbst betroffen
* *
@ -2476,7 +2476,7 @@ sp_fumblecurse(castorder *co)
rx = rng_int()%3; rx = rng_int()%3;
sx = cast_level - effskill(target, SK_MAGIC); sx = cast_level - effskill(target, SK_MAGIC);
duration = max(sx, rx) + 1; duration = MAX(sx, rx) + 1;
effect.i = (int)(force/2); effect.i = (int)(force/2);
c = create_curse(mage, &target->attribs, ct_find("fumble"), c = create_curse(mage, &target->attribs, ct_find("fumble"),
@ -2815,7 +2815,7 @@ wall_move(const border * b, struct unit * u, struct region * from, struct region
wall_data * fd = (wall_data*)b->data.v; wall_data * fd = (wall_data*)b->data.v;
if (!routing && fd->active) { if (!routing && fd->active) {
int hp = dice(3, fd->force) * u->number; int hp = dice(3, fd->force) * u->number;
hp = min (u->hp, hp); hp = MIN(u->hp, hp);
u->hp -= hp; u->hp -= hp;
if (u->hp) { if (u->hp) {
ADDMSG(&u->faction->msgs, msg_message("firewall_damage", ADDMSG(&u->faction->msgs, msg_message("firewall_damage",
@ -2887,8 +2887,8 @@ sp_firewall(castorder *co)
fd->countdown = cast_level+1; fd->countdown = cast_level+1;
} else { } else {
fd = (wall_data*)b->data.v; fd = (wall_data*)b->data.v;
fd->force = (int)max(fd->force, force/2+0.5); fd->force = (int)MAX(fd->force, force/2+0.5);
fd->countdown = max(fd->countdown, cast_level+1); fd->countdown = MAX(fd->countdown, cast_level+1);
} }
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
@ -3113,7 +3113,7 @@ sp_unholypower(castorder *co)
* Rüstung wirkt nicht * Rüstung wirkt nicht
* Patzer: * Patzer:
* Magier gerät in den Staub und verliert zufällige Zahl von HP bis * Magier gerät in den Staub und verliert zufällige Zahl von HP bis
* auf max(hp,2) * auf MAX(hp,2)
* Besonderheiten: * Besonderheiten:
* Nicht als curse implementiert, was schlecht ist - man kann dadurch * Nicht als curse implementiert, was schlecht ist - man kann dadurch
* kein dispell machen. Wegen fix unter Zeitdruck erstmal nicht zu * kein dispell machen. Wegen fix unter Zeitdruck erstmal nicht zu
@ -3588,7 +3588,7 @@ sp_summonundead(castorder *co)
return 0; return 0;
} }
undead = min(deathcount(r), 2 + lovar(force)); undead = MIN(deathcount(r), 2 + lovar(force));
if (cast_level <= 8) { if (cast_level <= 8) {
race = new_race[RC_SKELETON]; race = new_race[RC_SKELETON];
@ -3633,7 +3633,7 @@ sp_auraleak(castorder *co)
int cast_level = co->level; int cast_level = co->level;
message * msg; 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) { for(u = r->units; u; u = u->next) {
if (is_mage(u)) { if (is_mage(u)) {
@ -3993,8 +3993,8 @@ sp_raisepeasantmob(castorder *co)
anteil.i = 6 + (rng_int()%4); anteil.i = 6 + (rng_int()%4);
n = rpeasants(r) * anteil.i / 10; n = rpeasants(r) * anteil.i / 10;
n = max(0, n); n = MAX(0, n);
n = min(n, rpeasants(r)); n = MIN(n, rpeasants(r));
if (n <= 0) { if (n <= 0) {
report_failure(mage, co->order); report_failure(mage, co->order);
@ -4218,12 +4218,12 @@ sp_recruit(castorder *co)
* Bauer, nur die Kosten steigen. */ * Bauer, nur die Kosten steigen. */
n = (int)((pow(force, 1.6) * 100)/f->race->recruitcost); n = (int)((pow(force, 1.6) * 100)/f->race->recruitcost);
if (f->race==new_race[RC_URUK]) { if (f->race==new_race[RC_URUK]) {
n = min(2*maxp, n); n = MIN(2*maxp, n);
n = max(n, 1); n = MAX(n, 1);
rsetpeasants(r, maxp - (n+1) / 2); rsetpeasants(r, maxp - (n+1) / 2);
} else { } else {
n = min(maxp, n); n = MIN(maxp, n);
n = max(n, 1); n = MAX(n, 1);
rsetpeasants(r, maxp - n); rsetpeasants(r, maxp - n);
} }
@ -4265,12 +4265,12 @@ sp_bigrecruit(castorder *co)
n = (int)force + lovar((force * force * 1000)/f->race->recruitcost); n = (int)force + lovar((force * force * 1000)/f->race->recruitcost);
if (f->race==new_race[RC_URUK]) { if (f->race==new_race[RC_URUK]) {
n = min(2*maxp, n); n = MIN(2*maxp, n);
n = max(n, 1); n = MAX(n, 1);
rsetpeasants(r, maxp - (n+1) / 2); rsetpeasants(r, maxp - (n+1) / 2);
} else { } else {
n = min(maxp, n); n = MIN(maxp, n);
n = max(n, 1); n = MAX(n, 1);
rsetpeasants(r, maxp - n); rsetpeasants(r, maxp - n);
} }
@ -4351,7 +4351,7 @@ sp_pump(castorder *co)
* Betört eine Einheit, so das sie ihm den größten Teil ihres Bargelds * Betört eine Einheit, so das sie ihm den größten Teil ihres Bargelds
* und 50% ihres Besitzes schenkt. Sie behält jedoch immer soviel, wie * und 50% ihres Besitzes schenkt. Sie behält jedoch immer soviel, wie
* sie zum überleben braucht. Wirkt gegen Magieresistenz. * sie zum überleben braucht. Wirkt gegen Magieresistenz.
* min(Stufe*1000$, u->money - maintenace) * MIN(Stufe*1000$, u->money - maintenace)
* Von jedem Item wird 50% abgerundet ermittelt und übergeben. Dazu * Von jedem Item wird 50% abgerundet ermittelt und übergeben. Dazu
* kommt Itemzahl%2 mit 50% chance * kommt Itemzahl%2 mit 50% chance
* *
@ -4387,15 +4387,15 @@ sp_seduce(castorder *co)
item * itm = *itmp; item * itm = *itmp;
int loot; int loot;
if (itm->type==i_silver) { if (itm->type==i_silver) {
loot = min(cast_level * 1000, get_money(target) - (maintenance_cost(target))); loot = MIN(cast_level * 1000, get_money(target) - (maintenance_cost(target)));
loot = max(loot, 0); loot = MAX(loot, 0);
} else { } else {
loot = itm->number/2; loot = itm->number/2;
if (itm->number % 2) { if (itm->number % 2) {
loot += rng_int() % 2; loot += rng_int() % 2;
} }
if (loot > 0) { if (loot > 0) {
loot = (int)min(loot, force * 5); loot = (int)MIN(loot, force * 5);
} }
} }
if (loot>0) { if (loot>0) {
@ -4508,7 +4508,7 @@ sp_headache(castorder *co)
} }
if (smax!=NULL) { if (smax!=NULL) {
/* wirkt auf maximal 10 Personen */ /* 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); reduce_skill(target, smax, change);
} }
set_order(&target->thisorder, NULL); set_order(&target->thisorder, NULL);
@ -4553,7 +4553,7 @@ sp_raisepeasants(castorder *co)
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, "error_nopeasants", "")); ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, "error_nopeasants", ""));
return 0; return 0;
} }
bauern = (int)min(rpeasants(r), power*250); bauern = (int)MIN(rpeasants(r), power*250);
rsetpeasants(r, rpeasants(r) - bauern); rsetpeasants(r, rpeasants(r) - bauern);
u2 = create_unit(r, mage->faction, bauern, new_race[RC_PEASANT], 0, LOC(mage->faction->locale, "furious_mob"), mage); u2 = create_unit(r, mage->faction, bauern, new_race[RC_PEASANT], 0, LOC(mage->faction->locale, "furious_mob"), mage);
@ -4720,7 +4720,7 @@ sp_puttorest(castorder *co)
message * seen = msg_message("puttorest", "mage", mage); message * seen = msg_message("puttorest", "mage", mage);
message * unseen = msg_message("puttorest", "mage", NULL); 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); deathcounts(r, -laid_to_rest);
@ -4943,7 +4943,7 @@ sp_baddreams(castorder *co)
/* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken, /* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken,
* also duration+2 */ * 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; duration = 2 + rng_int()%duration;
/* Nichts machen als ein entsprechendes Attribut in die Region legen. */ /* Nichts machen als ein entsprechendes Attribut in die Region legen. */
@ -4983,7 +4983,7 @@ sp_gooddreams(castorder *co)
/* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken, /* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken,
* also duration+2 */ * 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; duration = 2 + rng_int()%duration;
effect.i = 1; effect.i = 1;
c = create_curse(mage, &r->attribs, ct_find("gbdream"), power, duration, effect, 0); c = create_curse(mage, &r->attribs, ct_find("gbdream"), power, duration, effect, 0);
@ -5116,7 +5116,7 @@ sp_sweetdreams(castorder *co)
cmistake(mage, co->order, 40, MSG_EVENT); cmistake(mage, co->order, 40, MSG_EVENT);
continue; continue;
} }
men = min(opfer, u->number); men = MIN(opfer, u->number);
opfer -= men; opfer -= men;
/* Nichts machen als ein entsprechendes Attribut an die Einheit legen. */ /* Nichts machen als ein entsprechendes Attribut an die Einheit legen. */
@ -5293,7 +5293,7 @@ sp_resist_magic_bonus(castorder *co)
continue; continue;
*/ */
m = min(u->number,victims); m = MIN(u->number,victims);
victims -= m; victims -= m;
resistbonus.i = 20; resistbonus.i = 20;
@ -5310,8 +5310,8 @@ sp_resist_magic_bonus(castorder *co)
msg_release(msg); msg_release(msg);
} }
cast_level = min(cast_level, (int)(cast_level*(victims+4)/maxvictims)); cast_level = MIN(cast_level, (int)(cast_level*(victims+4)/maxvictims));
return max(cast_level, 1); return MAX(cast_level, 1);
} }
/** spell 'Astraler Weg'. /** spell 'Astraler Weg'.
@ -6094,7 +6094,7 @@ sp_permtransfer(castorder *co)
return 0; 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_maxspellpoints(mage,-aura);
change_spellpoints(mage,-aura); change_spellpoints(mage,-aura);
@ -6484,7 +6484,7 @@ sp_speed2(castorder *co)
spellparameter *pa = co->par; spellparameter *pa = co->par;
maxmen = 2 * cast_level * cast_level; 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++) { for (n = 0; n < pa->length; n++) {
variant effect; variant effect;
@ -6498,7 +6498,7 @@ sp_speed2(castorder *co)
u = pa->param[n]->data.u; u = pa->param[n]->data.u;
men = min(maxmen,u->number); men = MIN(maxmen,u->number);
effect.i = 2; effect.i = 2;
create_curse(mage, &u->attribs, ct_find("speed"), force, dur, effect, men); create_curse(mage, &u->attribs, ct_find("speed"), force, dur, effect, men);
maxmen -= men; maxmen -= men;
@ -6508,7 +6508,7 @@ sp_speed2(castorder *co)
ADDMSG(&mage->faction->msgs, msg_message("speed_time_effect", "unit region amount", mage, mage->region, used)); ADDMSG(&mage->faction->msgs, msg_message("speed_time_effect", "unit region amount", mage, mage->region, used));
/* Effektiv benötigten cast_level (mindestens 1) zurückgeben */ /* Effektiv benötigten cast_level (mindestens 1) zurückgeben */
used = (int)sqrt(used/2); used = (int)sqrt(used/2);
return max(1, used); return MAX(1, used);
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -6592,7 +6592,7 @@ sp_q_antimagie(castorder *co)
"destroy_magic_noeffect", "unit region command", "destroy_magic_noeffect", "unit region command",
mage, mage->region, co->order)); mage, mage->region, co->order));
} }
return max(succ, 1); return MAX(succ, 1);
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -6783,7 +6783,7 @@ sp_wdwpyramid(castorder *co)
ADDMSG(&mage->faction->msgs, msg_message("wdw_pyramidspell_notfound", ADDMSG(&mage->faction->msgs, msg_message("wdw_pyramidspell_notfound",
"unit region command mindist maxdist", mage, r, co->order, "unit region command mindist maxdist", mage, r, co->order,
max(1, minshowdist), maxshowdist)); MAX(1, minshowdist), maxshowdist));
} }
return cast_level; return cast_level;

View file

@ -56,7 +56,7 @@ do_shock(unit *u, const char *reason)
if (u->number > 0) { if (u->number > 0) {
/* HP - Verlust */ /* HP - Verlust */
u->hp = (unit_max_hp(u) * u->number)/10; u->hp = (unit_max_hp(u) * u->number)/10;
u->hp = max(1, u->hp); u->hp = MAX(1, u->hp);
} }
/* Aura - Verlust */ /* Aura - Verlust */

View file

@ -238,17 +238,18 @@ extern char * strdup(const char *s);
/**** **** /**** ****
** min/max macros ** ** min/max macros **
**** ****/ **** ****/
#ifndef NOMINMAX #ifndef NOMINMAX
#ifndef min #ifndef MIN
# define min(a,b) ((a) < (b) ? (a) : (b)) # define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif #endif
#ifndef max #ifndef MAX
# define max(a,b) ((a) > (b) ? (a) : (b)) # define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif #endif
#endif #endif
#if defined (ghs) || defined (__GNUC__) || defined (__hpux) || defined (__sgi) || defined (__DECCXX) || defined (__KCC) || defined (__rational__) || defined (__USLC__) || defined (ACE_RM544) #if defined (__GNUC__)
# define unused(a) /* unused: a */
#elif defined (ghs) || || defined (__hpux) || defined (__sgi) || defined (__DECCXX) || defined (__KCC) || defined (__rational__) || defined (__USLC__) || defined (ACE_RM544)
# define unused(a) do {/* null */} while (&a == 0) # define unused(a) do {/* null */} while (&a == 0)
#else /* ghs || __GNUC__ || ..... */ #else /* ghs || __GNUC__ || ..... */
# define unused(a) (a) # define unused(a) (a)

View file

@ -90,14 +90,14 @@
<xi:include href="eressea/temple.xml"/> <xi:include href="eressea/temple.xml"/>
<strings> <strings>
<string name="mailto"> <string name="mailto">
<text locale="de">eressea-server@eressea.kn-bremen.de</text> <text locale="de">eressea-server@eressea.de</text>
<text locale="en">eressea-server@eressea.kn-bremen.de</text> <text locale="en">eressea-server@eressea.de</text>
</string> </string>
<string name="newbie_info_1"> <string name="newbie_info_1">
<text locale="de">Bitte denke daran, deine Befehle mit dem Betreff <text locale="de">Bitte denke daran, deine Befehle mit dem Betreff
ERESSEA BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden.</text> ERESSEA BEFEHLE an eressea-server@eressea.de zu senden.</text>
<text locale="en">Remember to send your orders to <text locale="en">Remember to send your orders to
eressea-server@eressea.kn-bremen.de with the subject ERESSEA ORDERS.</text> eressea-server@eressea.de with the subject ERESSEA ORDERS.</text>
</string> </string>
<string name="mailcmd"> <string name="mailcmd">
<text locale="de">ERESSEA BEFEHLE</text> <text locale="de">ERESSEA BEFEHLE</text>

View file

@ -1,57 +1,52 @@
Willkommen beim Eressea-Testspiel. Willkommen beim Eressea-Testspiel.
Vorweg: Dieses ist NICHT deine zukünftige Eressea-Partei. Es ist ein Vorweg: Dieses ist NICHT deine zukünftige Eressea-Partei. Es ist ein
Tutorial. Um sicherzustellen, das neue Spieler in Eressea ein gewisses Tutorial. Um sicherzustellen, das neue Spieler in Eressea ein gewisses
Grundverständnis der Anleitung mitbringen, und nicht nach wochenlanger Grundverständnis der Anleitung mitbringen, und nicht nach wochenlanger
Wartezeit über einen einfachen Fehler stolpern, schicken wir jeden neuen Wartezeit über einen einfachen Fehler stolpern, schicken wir jeden neuen
Spieler in eine Probepartie, die 5 Runden dauert. Du kannst also mit dieser Spieler in eine Probepartie, die 5 Runden dauert. Du kannst also mit dieser
Partei tun was Du möchtest, und etwas herumexperimentieren, ohne das das auf Partei tun was Du möchtest, und etwas herumexperimentieren, ohne das das auf
Deine spätere Partei Auswirkungen hat. Einzig, das Du die 5 Runden Deine spätere Partei Auswirkungen hat. Einzig, das Du die 5 Runden
überlebst, verlangen wir von Dir. überlebst, verlangen wir von Dir.
Folgende Unterschiede gibt es zwischen diesem Testspiel und dem richtigen Folgende Unterschiede gibt es zwischen diesem Testspiel und dem richtigen
Eressea: Eressea:
* Email-Adresse für Züge * Email-Adresse für Züge
Testspiel: tutorial@eressea.upb.de Testspiel: tutorial@eressea.de
Eressea: eressea-server@eressea.upb.de Eressea: eressea-server@eressea.de
* Zugabgaberhytmus: * Zugabgaberhytmus:
Testspiel: 3x die Woche, Montag, Mittwoch und Samstag um 09:00 Uhr morgens Testspiel: 3x die Woche, Montag, Mittwoch und Samstag um 09:00 Uhr morgens
Eressea: 1x die Woche, Sonntags um 9:00 Uhr Eressea: 1x die Woche, Sonntags um 9:00 Uhr
* Spieldauer: * Spieldauer:
Testspiel: 5 Züge Minimum, Partei wird nach 10 Zügen gelöscht. Testspiel: 5 Züge Minimum, Partei wird nach 10 Zügen gelöscht.
Eressea: unbegrenzt Eressea: unbegrenzt
Ein paar Tipps für den Anfang: Ein paar Tipps für den Anfang:
Eressea ist ein komplexes Spiel mit einer Menge Regeln. Je besser Du sie Eressea ist ein komplexes Spiel mit einer Menge Regeln. Je besser Du sie
verstehst, desto besser wirst Du das Spiel spielen können. Nimm Dir die verstehst, desto besser wirst Du das Spiel spielen können. Nimm Dir die
Zeit, die Anleitung ausführlich zu lesen. Du findest sie unter Zeit, die Anleitung ausführlich zu lesen. Du findest sie unter
http://eressea.upb.de/rules/. Wenn Du allgemeine Fragen hast, kannst Du auch http://wiki.eressea.de/de/. Wenn Du allgemeine Fragen hast, kannst Du auch
auf unserem Forum vorbeischauen, das du unter http://eressea.upb.de/forum/ auf unserem Forum vorbeischauen, das du auf
findest. http://www.pbem-spiele.de/forum/viewforum.php?f=16 findest.
Eressea ist ein textuelles Spiel. Laß Dich nicht davon einschüchtern, das Du Eressea ist ein textuelles Spiel. Laß Dich nicht davon einschüchtern, das Du
Befehle lernen mußt - so viele sind es nicht, und die meisten sind sehr Befehle lernen mußt - so viele sind es nicht, und die meisten sind sehr
intuitiv. Vieles in Eressea passiert in deiner Phantasie, und das intuitiv. Vieles in Eressea passiert in deiner Phantasie, und das
spannendste am Spiel sind die anderen Spieler und die Diplomatie mit ihnen. spannendste am Spiel sind die anderen Spieler und die Diplomatie mit ihnen.
Die beiden anderen Dateien in dieser Mail enthalten den Report in zwei Die beiden anderen Dateien in dieser Mail enthalten den Report in zwei
verschiedenen Formaten. Die Datei mit der Endung .nr ist eine normale verschiedenen Formaten. Die Datei mit der Endung .nr ist eine normale
Textdatei, und sie enthält deinen ersten Report in menschenlesbarer Form. Du Textdatei, und sie enthält deinen ersten Report in menschenlesbarer Form. Du
kannst sie mit jedem Texteditor (zum Beispiel Notepad) lesen. Die zweite kannst sie mit jedem Texteditor (zum Beispiel Notepad) lesen. Die zweite
Datei mit der Endung .cr enthält den Report in einer Form, die von Datei mit der Endung .cr enthält den Report in einer Form, die von
Eressea-Software gelesen werden kann, wie zum Beispiel Magellan, das Du Eressea-Software gelesen werden kann, wie zum Beispiel Magellan, das Du
unter http://eressea.upb.de/magellan/ findest. Ob Du lieber mit der unter http://magellan.log-out.net/ findest. Ob Du lieber mit der
Textversion oder mit einem Programm spielst, ist Dir überlassen. Textversion oder mit einem Programm spielst, ist Dir überlassen.
Solltest Du Fragen haben, die du mit der Anleitung nicht beantworten kannst, Viel Spaß mit Eressea wünscht Dir auf jeden Fall
kannst du eine Mail an die Adresse eressea-help@eressea.kn-bremen.de
schicken. Dort hilft man Dir gerne mit Fragen aller Art. Oder Du siehst Dir
mal die Beispielzüge unter http://www.webfeed.de/eressea/ an.
Viel Spaß mit Eressea wünscht Dir auf jeden Fall
das Eressea-Team. das Eressea-Team.

View file

@ -10,8 +10,8 @@ game shortly.
The tutorial differs from Eressea in a few very important points: The tutorial differs from Eressea in a few very important points:
* Email-Address to send your turns to: * Email-Address to send your turns to:
Tutorial: tutorial@eressea.upb.de Tutorial: tutorial@eressea.de
Eressea: eressea-server@eressea.upb.de Eressea: eressea-server@eressea.de
* Frequency: * Frequency:
Tutorial: 3x per Week, Monday, Wednesday and Saturday before 9 am CET. Tutorial: 3x per Week, Monday, Wednesday and Saturday before 9 am CET.
@ -40,7 +40,7 @@ because the translation of the human-readable report is currently a work in
progress. That's why we recommend using the file with the .cr extension progress. That's why we recommend using the file with the .cr extension
instead. It is a format that is understood by most Eressea-tools, notably instead. It is a format that is understood by most Eressea-tools, notably
the very good Magellan client. It is available at the very good Magellan client. It is available at
http://eressea.upb.de/magellan/. http://magellan.log-out.net/.
If you have any questions that the documentation does not answer, you can If you have any questions that the documentation does not answer, you can
send them to eressea-help@eressea.kn-bremen.de, and get an answer from a send them to eressea-help@eressea.kn-bremen.de, and get an answer from a

View file

@ -13,7 +13,7 @@ loadscript("default.lua")
function change_locales() function change_locales()
-- local localechange = { } -- local localechange = { }
local localechange = { en = { "won" } } local localechange = { de = { "bb" } }
for loc, flist in pairs(localechange) do for loc, flist in pairs(localechange) do
for index, name in pairs(flist) do for index, name in pairs(flist) do

View file

@ -96,8 +96,8 @@ convert_resources(void)
rawmaterial * rmstone = rm_get(r, rm_stones.rtype); rawmaterial * rmstone = rm_get(r, rm_stones.rtype);
int oldiron; int oldiron;
int oldlaen = MAXLAENPERTURN * min(r->age, 100) / 2; int oldlaen = MAXLAENPERTURN * MIN(r->age, 100) / 2;
int oldstone = terrain[rterrain(r)].quarries * max(0, r->age - INIT_STONE); int oldstone = terrain[rterrain(r)].quarries * MAX(0, r->age - INIT_STONE);
int iron = a->data.sa[0]; int iron = a->data.sa[0];
int laen = a->data.sa[1]; int laen = a->data.sa[1];
int stone, level; int stone, level;
@ -127,7 +127,7 @@ convert_resources(void)
/** IRON **/ /** IRON **/
if (r_isglacier(r) || r->terrain==T_ICEBERG) { if (r_isglacier(r) || r->terrain==T_ICEBERG) {
oldiron = GLIRONPERTURN * min(r->age, 100) / 2; oldiron = GLIRONPERTURN * MIN(r->age, 100) / 2;
} else { } else {
oldiron = IRONPERTURN * r->age; oldiron = IRONPERTURN * r->age;
} }
@ -136,7 +136,7 @@ convert_resources(void)
} }
if (terrain[r->terrain].rawmaterials[i].type) { if (terrain[r->terrain].rawmaterials[i].type) {
base = terrain[r->terrain].rawmaterials[i].base; base = terrain[r->terrain].rawmaterials[i].base;
iron = max(0, (int)(oldiron * ironmulti - iron )); iron = MAX(0, (int)(oldiron * ironmulti - iron ));
level = 1; level = 1;
base = (int)(terrain[r->terrain].rawmaterials[i].base*(1+level*terrain[r->terrain].rawmaterials[i].divisor)); base = (int)(terrain[r->terrain].rawmaterials[i].base*(1+level*terrain[r->terrain].rawmaterials[i].divisor));
while (iron >= base) { while (iron >= base) {
@ -163,7 +163,7 @@ convert_resources(void)
if (terrain[r->terrain].rawmaterials[i].type == &rm_laen) break; if (terrain[r->terrain].rawmaterials[i].type == &rm_laen) break;
} }
if (terrain[r->terrain].rawmaterials[i].type) { if (terrain[r->terrain].rawmaterials[i].type) {
laen = max(0, (int)(oldlaen * laenmulti - laen)); laen = MAX(0, (int)(oldlaen * laenmulti - laen));
level = 1; level = 1;
base = (int)(terrain[r->terrain].rawmaterials[i].base*(1+level*terrain[r->terrain].rawmaterials[i].divisor)); base = (int)(terrain[r->terrain].rawmaterials[i].base*(1+level*terrain[r->terrain].rawmaterials[i].divisor));
while (laen >= base) { while (laen >= base) {