Merge branch 'master' of github.com:eressea/server

This commit is contained in:
Enno Rehling 2014-03-16 22:19:06 +01:00
commit 5647905db3
56 changed files with 476 additions and 386 deletions

View File

@ -1,6 +1,13 @@
cmake_minimum_required(VERSION 2.6)
if (WIN32)
FILE(TO_CMAKE_PATH "${CMAKE_MODULE_PATH}" CMAKE_MODULE_PATH )
FILE(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH )
message(status "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
endif(WIN32)
project (eressea-server C)
enable_testing()
INCLUDE (CheckIncludeFiles)

View File

@ -30,21 +30,41 @@
#cmakedefine HAVE_DIRECT_MKDIR 1
#cmakedefine HAVE_DIRECT__MKDIR 1
#include <stddef.h>
#if defined(HAVE_STRINGS_H)
#include <strings.h>
#endif
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#if defined(HAVE_IO_H)
#include <io.h>
#endif
#if defined(HAVE_WINDOWS_H)
#include <windows.h>
#endif
#if defined(HAVE_STDBOOL_H)
# include <stdbool.h>
#else
# if ! HAVE__BOOL
# ifdef __cplusplus
typedef bool _Bool;
# else
typedef unsigned char _Bool;
# endif
# endif
# define bool _Bool
# define false 0
# define true 1
# define __bool_true_false_are_defined 1
#endif
#ifndef HAVE__ACCESS
#ifdef HAVE_ACCESS
#define _access(path, mode) access(path, mode)
#ifndef _A_RDONLY
#define _A_RDONLY R_OK
#endif
#ifndef _A_WRONLY
#define _A_WRONLY W_OK
#endif
#endif
#endif
@ -122,11 +142,11 @@
#endif
#endif
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#ifndef _min
#define _min(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#ifndef _max
#define _max(a,b) ((a) > (b) ? (a) : (b))
#endif
#if !defined(DBG_UNREFERENCED_PARAMETER)

8
s/git-reset Executable file
View File

@ -0,0 +1,8 @@
#/bin/sh
if [ ! -d .git ] ; then
echo "please run this script from the repository's top-level directory"
exit 1
fi
git submodule sync
git submodule update --init

View File

@ -240,7 +240,7 @@ function test_taxes()
assert_equal(25, u:get_item("money"))
end
function test_leave()
function test_region_owner_cannot_leave_castle()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
f.id = 42

View File

@ -42,3 +42,17 @@ int eressea_export_json(const char * filename, unsigned int flags) {
perror(filename);
return -1;
}
int eressea_import_json(const char * filename) {
FILE *F = fopen(filename, "rt");
if (F) {
stream out = { 0 };
int err;
fstream_init(&out, F);
err = json_import(&out);
fstream_done(&out);
return err;
}
perror(filename);
return -1;
}

View File

@ -8,7 +8,9 @@ void eressea_free_game(void);
int eressea_read_game(const char * filename);
int eressea_write_game(const char * filename);
int eressea_read_orders(const char * filename);
int eressea_export_json(const char * filename, unsigned int flags);
int eressea_import_json(const char * filename);
#ifdef __cplusplus
}
#endif

View File

@ -186,7 +186,7 @@ static void lua_paint_info(struct window *wnd, const struct state *st)
break;
else {
size_t len = end - str;
int bytes = MIN((int)len, size);
int bytes = _min((int)len, size);
mvwaddnstr(win, line++, 1, str, bytes);
wclrtoeol(win);
str = end + 1;

View File

@ -369,11 +369,11 @@ static int do_recruiting(recruitment * recruits, int available)
int number, dec;
float multi = 2.0F * rc->recruit_multi;
number = MIN(req->qty, (int)(get / multi));
number = _min(req->qty, (int)(get / multi));
if (rc->recruitcost) {
int afford = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT,
number * rc->recruitcost) / rc->recruitcost;
number = MIN(number, afford);
number = _min(number, afford);
}
if (u->number + number > UNIT_MAXSIZE) {
ADDMSG(&u->faction->msgs, msg_feedback(u, req->ord, "error_unit_size",
@ -615,7 +615,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders)
if (recruitcost > 0) {
int pooled =
get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, recruitcost * n);
n = MIN(n, pooled / recruitcost);
n = _min(n, pooled / recruitcost);
}
u->wants = n;
@ -637,7 +637,7 @@ static void friendly_takeover(region * r, faction * f)
int morale = region_get_morale(r);
region_set_owner(r, f, turn);
if (morale > 0) {
morale = MAX(0, morale - MORALE_TRANSFER);
morale = _max(0, morale - MORALE_TRANSFER);
region_set_morale(r, morale, turn);
}
}
@ -1229,7 +1229,7 @@ static int recruit_archetype(unit * u, order * ord)
if (a != NULL) {
maxsize -= a->data.i;
}
n = MIN(maxsize / arch->size, n);
n = _min(maxsize / arch->size, n);
if (n <= 0) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
"recruit_capacity_exhausted", "building", u->building));
@ -1560,12 +1560,12 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
/* mit Flinkfingerring verzehnfacht sich die Produktion */
amount +=
skill * MIN(u->number, get_item(u,
skill * _min(u->number, get_item(u,
I_RING_OF_NIMBLEFINGER)) * (roqf_factor() - 1);
/* Schaffenstrunk: */
if ((dm = get_effect(u, oldpotiontype[P_DOMORE])) != 0) {
dm = MIN(dm, u->number);
dm = _min(dm, u->number);
change_effect(u, oldpotiontype[P_DOMORE], -dm);
amount += dm * skill; /* dm Personen produzieren doppelt */
}
@ -1659,7 +1659,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
}
need = norders;
avail = MIN(avail, norders);
avail = _min(avail, norders);
if (need > 0) {
int use = 0;
for (al = alist; al; al = al->next)
@ -1674,7 +1674,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
use += x;
norders -= want;
need -= x;
al->get = MIN(al->want, al->get + (int)(x / al->save));
al->get = _min(al->want, al->get + (int)(x / al->save));
}
}
if (use) {
@ -1707,7 +1707,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
avail = 0;
}
avail = MIN(avail, norders);
avail = _min(avail, norders);
for (al = alist; al; al = al->next) {
if (avail > 0) {
int want = required(al->want, al->save);
@ -1717,7 +1717,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
++x;
avail -= x;
norders -= want;
al->get = MIN(al->want, (int)(x / al->save));
al->get = _min(al->want, (int)(x / al->save));
if (rdata->produce) {
int use = required(al->get, al->save);
if (use)
@ -2159,7 +2159,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord)
k -= a->data.i;
}
n = MIN(n, k);
n = _min(n, k);
if (!n) {
cmistake(u, ord, 102, MSG_COMMERCE);
@ -2453,7 +2453,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
/* Ein Händler kann nur 10 Güter pro Talentpunkt verkaufen. */
n = MIN(n, u->number * 10 * eff_skill(u, SK_TRADE, r));
n = _min(n, u->number * 10 * eff_skill(u, SK_TRADE, r));
if (!n) {
cmistake(u, ord, 54, MSG_COMMERCE);
@ -2483,11 +2483,11 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
if (o->type.ltype == ltype && o->unit->faction == u->faction) {
int fpool =
o->qty - get_pooled(o->unit, itype->rtype, GET_RESERVE, INT_MAX);
available -= MAX(0, fpool);
available -= _max(0, fpool);
}
}
n = MIN(n, available);
n = _min(n, available);
if (n <= 0) {
cmistake(u, ord, 264, MSG_COMMERCE);
@ -2511,7 +2511,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
k -= a->data.i;
}
n = MIN(n, k);
n = _min(n, k);
assert(n >= 0);
/* die Menge der verkauften Güter merken */
a->data.i += n;
@ -2566,7 +2566,7 @@ static void expandstealing(region * r, request * stealorders)
n = 10;
}
if (n > 0) {
n = MIN(n, oa[i].unit->wants);
n = _min(n, oa[i].unit->wants);
use_pooled(u, r_silver, GET_ALL, n);
oa[i].unit->n = n;
change_money(oa[i].unit, n);
@ -2621,8 +2621,8 @@ static void plant(region * r, unit * u, int raw)
return;
}
n = MIN(skill * u->number, n);
n = MIN(raw, n);
n = _min(skill * u->number, n);
n = _min(raw, n);
/* Für jedes Kraut Talent*10% Erfolgschance. */
for (i = n; i > 0; i--) {
if (rng_int() % 10 < skill)
@ -2670,14 +2670,14 @@ static void planttrees(region * r, unit * u, int raw)
}
/* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */
raw = MIN(raw, skill * u->number);
raw = _min(raw, skill * u->number);
n = get_pooled(u, rtype, GET_DEFAULT, raw);
if (n == 0) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
return;
}
n = MIN(raw, n);
n = _min(raw, n);
/* Für jeden Samen Talent*10% Erfolgschance. */
for (i = n; i > 0; i--) {
@ -2734,7 +2734,7 @@ static void breedtrees(region * r, unit * u, int raw)
}
/* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */
raw = MIN(skill * u->number, raw);
raw = _min(skill * u->number, raw);
n = get_pooled(u, rtype, GET_DEFAULT, raw);
/* Samen prüfen */
if (n == 0) {
@ -2742,7 +2742,7 @@ static void breedtrees(region * r, unit * u, int raw)
msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
return;
}
n = MIN(raw, n);
n = _min(raw, n);
/* Für jeden Samen Talent*5% Erfolgschance. */
for (i = n; i > 0; i--) {
@ -2775,7 +2775,7 @@ static void breedhorses(region * r, unit * u)
cmistake(u, u->thisorder, 107, MSG_PRODUCE);
return;
}
n = MIN(u->number * eff_skill(u, SK_HORSE_TRAINING, r), get_item(u, I_HORSE));
n = _min(u->number * eff_skill(u, SK_HORSE_TRAINING, r), get_item(u, I_HORSE));
for (c = 0; c < n; c++) {
if (rng_int() % 100 < eff_skill(u, SK_HORSE_TRAINING, r)) {
@ -3003,7 +3003,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
}
}
i = MIN(u->number, get_item(u, I_RING_OF_NIMBLEFINGER));
i = _min(u->number, get_item(u, I_RING_OF_NIMBLEFINGER));
if (i > 0) {
n *= STEALINCOME * (u->number + i * (roqf_factor() - 1));
} else {
@ -3024,7 +3024,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
/* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */
produceexp(u, SK_STEALTH, MIN(n, u->number));
produceexp(u, SK_STEALTH, _min(n, u->number));
}
/* ------------------------------------------------------------- */
@ -3048,7 +3048,7 @@ static void expandentertainment(region * r)
entertaining -= o->qty;
/* Nur soviel PRODUCEEXP wie auch tatsächlich gemacht wurde */
produceexp(u, SK_ENTERTAINMENT, MIN(u->n, u->number));
produceexp(u, SK_ENTERTAINMENT, _min(u->n, u->number));
add_income(u, IC_ENTERTAIN, o->qty, u->n);
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
}
@ -3098,7 +3098,7 @@ void entertain_cmd(unit * u, struct order *ord)
skip_token();
max_e = getuint();
if (max_e != 0) {
u->wants = MIN(u->wants, max_e);
u->wants = _min(u->wants, max_e);
}
o = nextentertainer++;
o->unit = u;
@ -3161,7 +3161,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
if (blessedharvest_ct && r->attribs) {
int happy =
(int)curse_geteffect(get_curse(r->attribs, blessedharvest_ct));
happy = MIN(happy, jobs);
happy = _min(happy, jobs);
earnings += happy;
}
}
@ -3263,9 +3263,9 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
if (max == 0)
max = INT_MAX;
if (!playerrace(u_race(u))) {
u->wants = MIN(income(u), max);
u->wants = _min(income(u), max);
} else {
u->wants = MIN(n * eff_skill(u, SK_TAXING, r) * 20, max);
u->wants = _min(n * eff_skill(u, SK_TAXING, r) * 20, max);
}
u2 = is_guarded(r, u, GUARD_TAX);

View File

@ -1,9 +1,10 @@
$#include "bind_eressea.h"
module eressea {
void eressea_free_game @ free_game(void);
int eressea_read_game @ read_game(const char * filename);
int eressea_write_game @ write_game(const char * filename);
int eressea_read_orders @ read_orders(const char * filename);
int eressea_export_json @ export(const char * filename, unsigned int flags);
void eressea_free_game @ free_game(void);
int eressea_read_game @ read_game(const char * filename);
int eressea_write_game @ write_game(const char * filename);
int eressea_read_orders @ read_orders(const char * filename);
int eressea_export_json @ export(const char * filename, unsigned int flags);
int eressea_import_json @ import(const char * filename);
}

View File

@ -1,6 +1,5 @@
/*
** Lua binding: eressea
** Generated automatically by tolua 5.1.3 on Sat Mar 15 19:26:36 2014.
*/
#include "tolua.h"
@ -160,6 +159,33 @@ static int tolua_eressea_eressea_export00(lua_State* tolua_S)
#endif
}
/* function: eressea_import_json */
static int tolua_eressea_eressea_import00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isstring(tolua_S,1,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
const char* filename = ((const char*) tolua_tostring(tolua_S,1,0));
{
int tolua_ret = (int) eressea_import_json(filename);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'import'.",&tolua_err);
return 0;
#endif
}
/* Open lib function */
LUALIB_API int luaopen_eressea (lua_State* tolua_S)
{
@ -174,6 +200,7 @@ LUALIB_API int luaopen_eressea (lua_State* tolua_S)
tolua_function(tolua_S,"write_game",tolua_eressea_eressea_write_game00);
tolua_function(tolua_S,"read_orders",tolua_eressea_eressea_read_orders00);
tolua_function(tolua_S,"export",tolua_eressea_eressea_export00);
tolua_function(tolua_S,"import",tolua_eressea_eressea_import00);
tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
return 1;

View File

@ -124,7 +124,7 @@ give_item(int want, const item_type * itype, unit * src, unit * dest,
assert(itype != NULL);
n = get_pooled(src, item2resource(itype), GET_DEFAULT, want);
n = MIN(want, n);
n = _min(want, n);
r = n;
if (dest && src->faction != dest->faction
&& src->faction->age < GiveRestriction()) {

View File

@ -9,7 +9,6 @@
*/
#include <platform.h>
#include <util/bool.h>
#include <curses.h>
#include <kernel/config.h>

View File

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

View File

@ -76,7 +76,7 @@ use_manacrystal(struct unit *u, const struct item_type *itype, int amount,
}
for (i = 0; i != amount; ++i) {
sp += MAX(25, max_spellpoints(u->region, u) / 2);
sp += _max(25, max_spellpoints(u->region, u) / 2);
change_spellpoints(u, sp);
}

View File

@ -16,13 +16,48 @@
#include <assert.h>
int json_import(struct stream * out) {
cJSON *json, *child;
char buffer[1024], *data = 0;
size_t sz = 0;
assert(out && out->api);
while (!out->api->readln(out->handle, buffer, sizeof(buffer))) {
size_t len = strlen(buffer);
data = (char *)realloc(data, sz + len + 1);
memcpy(data + sz, buffer, len);
sz += len;
data[sz] = 0;
}
json = cJSON_Parse(data);
child = cJSON_GetObjectItem(json, "regions");
if (child && child->type==cJSON_Object) {
cJSON *j;
for (j = child->child; j; j = j->next) {
cJSON *attr;
unsigned int id = 0;
int x = 0, y = 0;
region * r;
id = (unsigned int)atol(j->string);
if ((attr = cJSON_GetObjectItem(j, "x")) != 0 && attr->type == cJSON_Number) x = attr->valueint;
if ((attr = cJSON_GetObjectItem(j, "y")) != 0 && attr->type == cJSON_Number) y = attr->valueint;
r = new_region(x, y, 0, id);
if ((attr = cJSON_GetObjectItem(j, "type")) != 0 && attr->type == cJSON_String) {
const terrain_type *terrain = get_terrain(attr->valuestring);
terraform_region(r, terrain);
}
if ((attr = cJSON_GetObjectItem(j, "name")) != 0 && attr->type == cJSON_String) {
region_setname(r, attr->valuestring);
}
}
}
cJSON_Delete(json);
return 0;
}
int json_export(stream * out, unsigned int flags) {
cJSON *json, *root = cJSON_CreateObject();
assert(out && out->api);
if (flags & EXPORT_REGIONS) {
if (regions && (flags & EXPORT_REGIONS)) {
region * r;
cJSON_AddItemToObject(root, "regions", json = cJSON_CreateObject());
for (r = regions; r; r = r->next) {
@ -35,7 +70,7 @@ int json_export(stream * out, unsigned int flags) {
cJSON_AddStringToObject(data, "type", r->terrain->_name);
}
}
if (flags & EXPORT_FACTIONS) {
if (factions && (flags & EXPORT_FACTIONS)) {
faction *f;
cJSON_AddItemToObject(root, "factions", json = cJSON_CreateObject());
for (f = factions; f; f = f->next) {
@ -48,7 +83,7 @@ int json_export(stream * out, unsigned int flags) {
}
if (flags) {
char *tok, *output;
output = cJSON_Print(json);
output = cJSON_Print(root);
tok = strtok(output, "\n\r");
while (tok) {
if (tok[0]) {

View File

@ -5,7 +5,7 @@
#include "json.h"
#include "bind_eressea.h"
static void test_export(CuTest * tc) {
static void test_export_no_regions(CuTest * tc) {
char buf[1024];
stream out = { 0 };
int err;
@ -19,8 +19,23 @@ static void test_export(CuTest * tc) {
mstream_done(&out);
}
static void test_export_no_factions(CuTest * tc) {
char buf[1024];
stream out = { 0 };
int err;
mstream_init(&out);
err = json_export(&out, EXPORT_FACTIONS);
CuAssertIntEquals(tc, 0, err);
out.api->rewind(out.handle);
out.api->read(out.handle, buf, sizeof(buf));
CuAssertStrEquals(tc, "{\n}\n", buf);
mstream_done(&out);
}
CuSuite *get_json_suite(void) {
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_export);
SUITE_ADD_TEST(suite, test_export_no_regions);
SUITE_ADD_TEST(suite, test_export_no_factions);
return suite;
}

View File

@ -70,12 +70,12 @@ void herbsearch(region * r, unit * u, int max)
}
if (max)
max = MIN(max, rherbs(r));
max = _min(max, rherbs(r));
else
max = rherbs(r);
herbsfound = ntimespprob(eff_skill(u, SK_HERBALISM, r) * u->number,
(double)rherbs(r) / 100.0F, -0.01F);
herbsfound = MIN(herbsfound, max);
herbsfound = _min(herbsfound, max);
rsetherbs(r, rherbs(r) - herbsfound);
if (herbsfound) {
@ -153,7 +153,7 @@ static int do_potion(unit * u, region *r, const potion_type * ptype, int amount)
ADDMSG(&u->faction->msgs, msg_message("growtree_effect",
"mage amount", u, holz));
} else if (ptype == oldpotiontype[P_HEILWASSER]) {
u->hp = MIN(unit_max_hp(u) * u->number, u->hp + 400 * amount);
u->hp = _min(unit_max_hp(u) * u->number, u->hp + 400 * amount);
} else if (ptype == oldpotiontype[P_PEOPLE]) {
attrib *a = (attrib *) a_find(r->attribs, &at_peasantluck);
if (!a)
@ -169,7 +169,7 @@ static int do_potion(unit * u, region *r, const potion_type * ptype, int amount)
amount = 1;
} else if (ptype == oldpotiontype[P_MACHT]) {
/* Verfünffacht die HP von max. 10 Personen in der Einheit */
u->hp += MIN(u->number, 10 * amount) * unit_max_hp(u) * 4;
u->hp += _min(u->number, 10 * amount) * unit_max_hp(u) * 4;
} else {
change_effect(u, ptype, 10 * amount);
}

View File

@ -235,7 +235,7 @@ int armedmen(const unit * u, bool siege_weapons)
if (n > u->number)
break;
}
n = MIN(n, u->number);
n = _min(n, u->number);
}
}
return n;
@ -464,7 +464,7 @@ static int get_row(const side * s, int row, const side * vs)
/* every entry in the size[] array means someone trying to defend us.
* 'retreat' is the number of rows falling.
*/
result = MAX(FIRST_ROW, row - retreat);
result = _max(FIRST_ROW, row - retreat);
return result;
}
@ -627,11 +627,11 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking)
if (u_race(u) == new_race[RC_ORC]) {
int sword = effskill(u, SK_MELEE);
int spear = effskill(u, SK_SPEAR);
skill = MAX(sword, spear) - 3;
skill = _max(sword, spear) - 3;
if (attacking) {
skill = MAX(skill, u_race(u)->at_default);
skill = _max(skill, u_race(u)->at_default);
} else {
skill = MAX(skill, u_race(u)->df_default);
skill = _max(skill, u_race(u)->df_default);
}
} else {
if (attacking) {
@ -712,7 +712,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type)
/* only half against trolls */
if (skl > 0) {
if (type == BONUS_DAMAGE) {
int dmg = MIN(skl, 8);
int dmg = _min(skl, 8);
if (u_race(enemy.fighter->unit) == new_race[RC_TROLL]) {
dmg = dmg / 4;
} else {
@ -721,7 +721,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type)
return dmg;
} else {
skl = skl / 2;
return MIN(skl, 4);
return _min(skl, 4);
}
}
}
@ -849,7 +849,7 @@ int select_magicarmor(troop t)
int geschuetzt = 0;
int ma = 0;
geschuetzt = MIN(get_item(u, I_TROLLBELT), u->number);
geschuetzt = _min(get_item(u, I_TROLLBELT), u->number);
if (geschuetzt > t.index) /* unser Kandidat wird geschuetzt */
ma += 1;
@ -1025,7 +1025,7 @@ static void vampirism(troop at, int damage)
if (gain > 0) {
int maxhp = unit_max_hp(at.fighter->unit);
at.fighter->person[at.index].hp =
MIN(gain + at.fighter->person[at.index].hp, maxhp);
_min(gain + at.fighter->person[at.index].hp, maxhp);
}
}
}
@ -1159,8 +1159,8 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
if (damage_rules & DAMAGE_CRITICAL) {
double kritchance = (sk * 3 - sd) / 200.0;
kritchance = MAX(kritchance, 0.005);
kritchance = MIN(0.9, kritchance);
kritchance = _max(kritchance, 0.005);
kritchance = _min(0.9, kritchance);
while (chance(kritchance)) {
if (bdebug) {
@ -1191,7 +1191,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
/* Skilldifferenzbonus */
if (damage_rules & DAMAGE_SKILL_BONUS) {
da += MAX(0, (sk - sd) / DAMAGE_QUOTIENT);
da += _max(0, (sk - sd) / DAMAGE_QUOTIENT);
}
}
@ -1218,13 +1218,13 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
}
if (res > 0) {
da = (int)(MAX(da * res, 0));
da = (int)(_max(da * res, 0));
}
/* gegen Magie wirkt nur natürliche und magische Rüstung */
ar = an + am;
}
rda = MAX(da - ar, 0);
rda = _max(da - ar, 0);
if ((u_race(du)->battle_flags & BF_INV_NONMAGIC) && !magic)
rda = 0;
@ -1257,7 +1257,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
}
/* gibt Rüstung +effect für duration Treffer */
if (me->typ == SHIELD_ARMOR) {
rda = MAX(rda - me->effect, 0);
rda = _max(rda - me->effect, 0);
me->duration--;
}
}
@ -1470,7 +1470,7 @@ troop select_enemy(fighter * af, int minrow, int maxrow, int select)
minrow = FIGHT_ROW;
maxrow = BEHIND_ROW;
}
minrow = MAX(minrow, FIGHT_ROW);
minrow = _max(minrow, FIGHT_ROW);
enemies = count_enemies(b, af, minrow, maxrow, select);
@ -1569,7 +1569,7 @@ static troop select_opponent(battle * b, troop at, int mindist, int maxdist)
* them */
dt = select_enemy(at.fighter, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
} else {
mindist = MAX(mindist, FIGHT_ROW);
mindist = _max(mindist, FIGHT_ROW);
dt = select_enemy(at.fighter, mindist, maxdist, SELECT_ADVANCE);
}
@ -1691,7 +1691,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
level = eff_spelllevel(mage, sp, level, 1);
if (sl > 0)
level = MIN(sl, level);
level = _min(sl, level);
if (level < 0) {
report_failed_spell(b, mage, sp);
free_order(ord);
@ -1777,7 +1777,7 @@ static void do_combatspell(troop at)
level = eff_spelllevel(caster, sp, fi->magic, 1);
if ((sl = get_combatspelllevel(caster, 1)) > 0)
level = MIN(level, sl);
level = _min(level, sl);
if (fumble(r, caster, sp, level)) {
report_failed_spell(b, caster, sp);
@ -2024,7 +2024,7 @@ void dazzle(battle * b, troop * td)
void damage_building(battle * b, building * bldg, int damage_abs)
{
bldg->size = MAX(1, bldg->size - damage_abs);
bldg->size = _max(1, bldg->size - damage_abs);
/* Wenn Burg, dann gucken, ob die Leute alle noch in das Gebäude passen. */
@ -2297,7 +2297,7 @@ void do_regenerate(fighter * af)
while (ta.index--) {
af->person[ta.index].hp += effskill(au, SK_STAMINA);
af->person[ta.index].hp = MIN(unit_max_hp(au), af->person[ta.index].hp);
af->person[ta.index].hp = _min(unit_max_hp(au), af->person[ta.index].hp);
}
}
@ -2364,9 +2364,9 @@ double fleechance(unit * u)
if (u_race(u) == new_race[RC_HALFLING]) {
c += 0.20;
c = MIN(c, 0.90);
c = _min(c, 0.90);
} else {
c = MIN(c, 0.75);
c = _min(c, 0.75);
}
if (a != NULL)
@ -2492,7 +2492,7 @@ static void loot_items(fighter * corpse)
float lootfactor = dead / (float)u->number; /* only loot the dead! */
int maxloot = (int)(itm->number * lootfactor);
if (maxloot > 0) {
int i = MIN(10, maxloot);
int i = _min(10, maxloot);
for (; i != 0; --i) {
int loot = maxloot / i;
@ -2585,7 +2585,7 @@ static void battle_effects(battle * b, int dead_players)
{
region *r = b->region;
int dead_peasants =
MIN(rpeasants(r), (int)(dead_players * PopulationDamage()));
_min(rpeasants(r), (int)(dead_players * PopulationDamage()));
if (dead_peasants) {
deathcounts(r, dead_peasants + dead_players);
chaoscounts(r, dead_peasants / 2);
@ -3102,7 +3102,7 @@ static void print_stats(battle * b)
for (s = b->sides; s != b->sides + b->nsides; ++s) {
if (!ql_empty(s->leader.fighters)) {
b->max_tactics = MAX(b->max_tactics, s->leader.value);
b->max_tactics = _max(b->max_tactics, s->leader.value);
}
}
@ -3271,7 +3271,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
/* change_effect wird in ageing gemacht */
/* Effekte von Artefakten */
strongmen = MIN(fig->unit->number, get_item(u, I_TROLLBELT));
strongmen = _min(fig->unit->number, get_item(u, I_TROLLBELT));
/* Hitpoints, Attack- und Defence-Boni für alle Personen */
for (i = 0; i < fig->alive; i++) {
@ -3467,7 +3467,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
else
p_bonus += 3;
} while (rnd >= 97);
bonus = MAX(p_bonus, bonus);
bonus = _max(p_bonus, bonus);
}
tactics += bonus;
}
@ -3607,7 +3607,7 @@ battle *make_battle(region * r)
for (bf = b->factions; bf; bf = bf->next) {
faction *f = bf->faction;
max_fac_no = MAX(max_fac_no, f->no);
max_fac_no = _max(max_fac_no, f->no);
freset(f, FFL_MARK);
}
return b;
@ -3645,7 +3645,7 @@ static void free_battle(battle * b)
bfaction *bf = b->factions;
faction *f = bf->faction;
b->factions = bf->next;
max_fac_no = MAX(max_fac_no, f->no);
max_fac_no = _max(max_fac_no, f->no);
free(bf);
}
@ -4203,7 +4203,7 @@ static void battle_flee(battle * b)
troop dt;
int runners = 0;
/* Flucht nicht bei mehr als 600 HP. Damit Wyrme tötbar bleiben. */
int runhp = MIN(600, (int)(0.9 + unit_max_hp(u) * hpflee(u->status)));
int runhp = _min(600, (int)(0.9 + unit_max_hp(u) * hpflee(u->status)));
if (u->ship && fval(u->region->terrain, SEA_REGION)) {
/* keine Flucht von Schiffen auf hoher See */
@ -4248,7 +4248,7 @@ static void battle_flee(battle * b)
if (fig->person[dt.index].flags & FL_PANICED) {
ispaniced = EFFECT_PANIC_SPELL;
}
if (chance(MIN(fleechance(u) + ispaniced, 0.90))) {
if (chance(_min(fleechance(u) + ispaniced, 0.90))) {
++runners;
flee(dt);
}

View File

@ -117,11 +117,11 @@ static void destroy_road(unit * u, int nmax, struct order *ord)
cmistake(u, ord, 71, MSG_PRODUCE);
} else {
short road = rroad(r, d);
n = MIN(n, road);
n = _min(n, road);
if (n != 0) {
region *r2 = rconnect(r, d);
int willdo = eff_skill(u, SK_ROAD_BUILDING, r) * u->number;
willdo = MIN(willdo, n);
willdo = _min(willdo, n);
if (willdo == 0) {
/* TODO: error message */
}
@ -318,7 +318,7 @@ void build_road(region * r, unit * u, int size, direction_t d)
}
if (size > 0)
left = MIN(size, left);
left = _min(size, left);
/* baumaximum anhand der rohstoffe */
if (u_race(u) == new_race[RC_STONEGOLEM]) {
n = u->number * GOLEM_STONE;
@ -329,14 +329,14 @@ void build_road(region * r, unit * u, int size, direction_t d)
return;
}
}
left = MIN(n, left);
left = _min(n, left);
/* n = maximum by skill. try to maximize it */
n = u->number * eff_skill(u, SK_ROAD_BUILDING, r);
if (n < left) {
item *itm = *i_find(&u->items, olditemtype[I_RING_OF_NIMBLEFINGER]);
if (itm != NULL && itm->number > 0) {
int rings = MIN(u->number, itm->number);
int rings = _min(u->number, itm->number);
n = n * ((roqf_factor() - 1) * rings + u->number) / u->number;
}
}
@ -345,15 +345,15 @@ void build_road(region * r, unit * u, int size, direction_t d)
if (dm != 0) {
int sk = eff_skill(u, SK_ROAD_BUILDING, r);
int todo = (left - n + sk - 1) / sk;
todo = MIN(todo, u->number);
dm = MIN(dm, todo);
todo = _min(todo, u->number);
dm = _min(dm, todo);
change_effect(u, oldpotiontype[P_DOMORE], -dm);
n += dm * sk;
} /* Auswirkung Schaffenstrunk */
}
/* make minimum of possible and available: */
n = MIN(left, n);
n = _min(left, n);
/* n is now modified by several special effects, so we have to
* minimize it again to make sure the road will not grow beyond
@ -369,7 +369,7 @@ void build_road(region * r, unit * u, int size, direction_t d)
} else {
use_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT, n);
/* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */
produceexp(u, SK_ROAD_BUILDING, MIN(n, u->number));
produceexp(u, SK_ROAD_BUILDING, _min(n, u->number));
}
ADDMSG(&u->faction->msgs, msg_message("buildroad",
"region unit size", r, u, n));
@ -473,7 +473,7 @@ int build(unit * u, const construction * ctype, int completed, int want)
if (dm != 0) {
/* Auswirkung Schaffenstrunk */
dm = MIN(dm, u->number);
dm = _min(dm, u->number);
change_effect(u, oldpotiontype[P_DOMORE], -dm);
skills += dm * effsk;
}
@ -529,17 +529,17 @@ int build(unit * u, const construction * ctype, int completed, int want)
if (itm != NULL)
i = itm->number;
if (i > 0) {
int rings = MIN(u->number, i);
int rings = _min(u->number, i);
n = n * ((roqf_factor() - 1) * rings + u->number) / u->number;
}
}
if (want > 0) {
n = MIN(want, n);
n = _min(want, n);
}
if (type->maxsize > 0) {
n = MIN(type->maxsize - completed, n);
n = _min(type->maxsize - completed, n);
if (type->improvement == NULL) {
want = n;
}
@ -610,7 +610,7 @@ int build(unit * u, const construction * ctype, int completed, int want)
completed = completed + n;
}
/* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */
produceexp(u, ctype->skill, MIN(made, u->number));
produceexp(u, ctype->skill, _min(made, u->number));
return made;
}
@ -647,7 +647,7 @@ int maxbuild(const unit * u, const construction * cons)
if (have < need) {
return 0;
} else
maximum = MIN(maximum, have / need);
maximum = _min(maximum, have / need);
}
return maximum;
}
@ -853,7 +853,7 @@ static void build_ship(unit * u, ship * sh, int want)
}
if (sh->damage && can) {
int repair = MIN(sh->damage, can * DAMAGE_SCALE);
int repair = _min(sh->damage, can * DAMAGE_SCALE);
n += repair / DAMAGE_SCALE;
if (repair % DAMAGE_SCALE)
++n;
@ -897,7 +897,7 @@ create_ship(region * r, unit * u, const struct ship_type *newtype, int want,
return;
}
if (want > 0)
want = MIN(want, msize);
want = _min(want, msize);
else
want = msize;
@ -956,7 +956,7 @@ void continue_ship(region * r, unit * u, int want)
return;
}
if (want > 0)
want = MIN(want, msize);
want = _min(want, msize);
else
want = msize;

View File

@ -158,7 +158,7 @@ int buildingcapacity(const building * b)
{
if (b->type->capacity >= 0) {
if (b->type->maxcapacity >= 0) {
return MIN(b->type->maxcapacity, b->size * b->type->capacity);
return _min(b->type->maxcapacity, b->size * b->type->capacity);
}
return b->size * b->type->capacity;
}

View File

@ -1723,7 +1723,7 @@ int maxworkingpeasants(const struct region *r)
{
int i = production(r) * MAXPEASANTS_PER_AREA
- ((rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE);
return MAX(i, 0);
return _max(i, 0);
}
int lighthouse_range(const building * b, const faction * f)
@ -1743,8 +1743,8 @@ int lighthouse_range(const building * b, const faction * f)
break;
if (f == NULL || u->faction == f) {
int sk = eff_skill(u, SK_PERCEPTION, r) / 3;
d = MAX(d, sk);
d = MIN(maxd, d);
d = _max(d, sk);
d = _min(maxd, d);
if (d == maxd)
break;
}
@ -2528,7 +2528,7 @@ void plagues(region * r, bool ismagic)
/* Seuchenwahrscheinlichkeit in % */
if (!ismagic) {
double mwp = MAX(maxworkingpeasants(r), 1);
double mwp = _max(maxworkingpeasants(r), 1);
double prob =
pow(rpeasants(r) / (mwp * wage(r, NULL, NULL, turn) * 0.13), 4.0)
* PLAGUE_CHANCE;
@ -2797,7 +2797,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
/* Godcurse: Income -10 */
if (curse_active(get_curse(r->attribs, ct_find("godcursezone")))) {
wage = MAX(0, wage - 10);
wage = _max(0, wage - 10);
}
/* Bei einer Dürre verdient man nur noch ein Viertel */

View File

@ -105,7 +105,7 @@ static connection **get_borders_i(const region * r1, const region * r2)
int key = reg_hashkey(r1);
int k2 = reg_hashkey(r2);
key = MIN(k2, key) % BORDER_MAXHASH;
key = _min(k2, key) % BORDER_MAXHASH;
bp = &borders[key];
while (*bp) {
connection *b = *bp;
@ -535,7 +535,7 @@ static const char *b_nameroad(const connection * b, const region * r,
return LOC(f->locale, mkname("border", "an_incomplete_road"));
}
} else {
int percent = MAX(1, 100 * local / r->terrain->max_road);
int percent = _max(1, 100 * local / r->terrain->max_road);
if (local) {
slprintf(buffer, sizeof(buffer), LOC(f->locale, mkname("border",
"a_road_percent")), percent);

View File

@ -129,7 +129,7 @@ int curse_age(attrib * a)
if (result != 0) {
c->duration = 0;
} else if (c->duration != INT_MAX) {
c->duration = MAX(0, c->duration - 1);
c->duration = _max(0, c->duration - 1);
}
return c->duration;
}
@ -315,7 +315,7 @@ const curse_type *ct_find(const char *c)
if (strcmp(c, type->cname) == 0) {
return type;
} else {
size_t k = MIN(strlen(c), strlen(type->cname));
size_t k = _min(strlen(c), strlen(type->cname));
if (!_memicmp(c, type->cname, k)) {
return type;
}
@ -478,7 +478,7 @@ int get_cursedmen(unit * u, const curse * c)
cursedmen = c->data.i;
}
return MIN(u->number, cursedmen);
return _min(u->number, cursedmen);
}
/* setzt die Anzahl der betroffenen Personen auf cursedmen */
@ -552,7 +552,7 @@ curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct,
/* es gibt schon eins diese Typs */
if (c && ct->mergeflags != NO_MERGE) {
if (ct->mergeflags & M_DURATION) {
c->duration = MAX(c->duration, duration);
c->duration = _max(c->duration, duration);
}
if (ct->mergeflags & M_SUMDURATION) {
c->duration += duration;
@ -561,10 +561,10 @@ curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct,
c->effect += effect;
}
if (ct->mergeflags & M_MAXEFFECT) {
c->effect = MAX(c->effect, effect);
c->effect = _max(c->effect, effect);
}
if (ct->mergeflags & M_VIGOUR) {
c->vigour = MAX(vigour, c->vigour);
c->vigour = _max(vigour, c->vigour);
}
if (ct->mergeflags & M_VIGOUR_ADD) {
c->vigour = vigour + c->vigour;

View File

@ -58,7 +58,7 @@ static group *new_group(faction * f, const char *name, int gid)
gp = &(*gp)->next;
*gp = g;
maxgid = MAX(gid, maxgid);
maxgid = _max(gid, maxgid);
g->name = _strdup(name);
g->gid = gid;

View File

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

View File

@ -540,7 +540,7 @@ int get_combatspelllevel(const unit * u, int nr)
assert(nr < MAXCOMBATSPELLS);
if (m) {
int level = eff_skill(u, SK_MAGIC, u->region);
return MIN(m->combatspells[nr].level, level);
return _min(m->combatspells[nr].level, level);
}
return -1;
}
@ -672,7 +672,7 @@ int change_spellpoints(unit * u, int mp)
}
/* verhindere negative Magiepunkte */
sp = MAX(m->spellpoints + mp, 0);
sp = _max(m->spellpoints + mp, 0);
m->spellpoints = sp;
return sp;
@ -730,7 +730,7 @@ int max_spellpoints(const region * r, const unit * u)
if (n > 0)
msp = (msp * n) / 100;
return MAX((int)msp, 0);
return _max((int)msp, 0);
}
int change_maxspellpoints(unit * u, int csp)
@ -765,7 +765,7 @@ int countspells(unit * u, int step)
count = m->spellcount + step;
/* negative Werte abfangen. */
m->spellcount = MAX(0, count);
m->spellcount = _max(0, count);
return m->spellcount;
}
@ -854,7 +854,7 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range)
* gewünschten gebildet */
} else if (sp->components[k].cost == SPC_LEVEL) {
costtyp = SPC_LEVEL;
cast_level = MIN(cast_level, maxlevel);
cast_level = _min(cast_level, maxlevel);
/* bei Typ Linear müssen die Kosten in Höhe der Stufe vorhanden
* sein, ansonsten schlägt der Spruch fehl */
} else if (sp->components[k].cost == SPC_LINEAR) {
@ -871,7 +871,7 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range)
if (spells) {
spellbook_entry * sbe = spellbook_get(spells, sp);
if (sbe) {
return MIN(cast_level, sbe->level);
return _min(cast_level, sbe->level);
}
}
log_error("spell %s is not in the spellbook for %s\n", sp->sname, unitname(u));
@ -1069,7 +1069,7 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level,
force = force * MagicPower();
return MAX(force, 0);
return _max(force, 0);
}
/* ------------------------------------------------------------- */
@ -1235,8 +1235,8 @@ target_resists_magic(unit * magician, void *obj, int objtyp, int t_bonus)
break;
}
probability = MAX(0.02, probability + t_bonus * 0.01);
probability = MIN(0.98, probability);
probability = _max(0.02, probability + t_bonus * 0.01);
probability = _min(0.98, probability);
/* gibt true, wenn die Zufallszahl kleiner als die chance ist und
* false, wenn sie gleich oder größer ist, dh je größer die
@ -1376,7 +1376,7 @@ static void do_fumble(castorder * co)
case 2:
/* temporärer Stufenverlust */
duration = MAX(rng_int() % level / 2, 2);
duration = _max(rng_int() % level / 2, 2);
effect = -(float)level/2;
c =
create_curse(u, &u->attribs, ct_find("skillmod"), (float)level,
@ -1487,14 +1487,14 @@ void regenerate_aura(void)
reg_aura -= regen;
if (chance(reg_aura))
++regen;
regen = MAX(1, regen);
regen = MIN((auramax - aura), regen);
regen = _max(1, regen);
regen = _min((auramax - aura), regen);
aura += regen;
ADDMSG(&u->faction->msgs, msg_message("regenaura",
"unit region amount", u, r, regen));
}
set_spellpoints(u, MIN(aura, auramax));
set_spellpoints(u, _min(aura, auramax));
}
}
}
@ -2508,7 +2508,7 @@ static castorder *cast_cmd(unit * u, order * ord)
/* für Syntax ' STUFE x REGION y z ' */
if (param == P_LEVEL) {
int p = getint();
level = MIN(p, level);
level = _min(p, level);
if (level < 1) {
/* Fehler "Das macht wenig Sinn" */
cmistake(u, ord, 10, MSG_MAGIC);
@ -2538,7 +2538,7 @@ static castorder *cast_cmd(unit * u, order * ord)
* hier nach REGION nochmal auf STUFE prüfen */
if (param == P_LEVEL) {
int p = getint();
level = MIN(p, level);
level = _min(p, level);
if (level < 1) {
/* Fehler "Das macht wenig Sinn" */
cmistake(u, ord, 10, MSG_MAGIC);
@ -2667,7 +2667,7 @@ static castorder *cast_cmd(unit * u, order * ord)
* löschen, zaubern kann er noch */
range *= 2;
set_order(&caster->thisorder, NULL);
level = MIN(level, eff_skill(caster, SK_MAGIC, caster->region) / 2);
level = _min(level, eff_skill(caster, SK_MAGIC, caster->region) / 2);
}
}
/* Weitere Argumente zusammenbasteln */

View File

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

View File

@ -417,9 +417,9 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars)
}
}
/* Buchstaben pro Teilkürzel = MAX(1,max/AnzWort) */
/* Buchstaben pro Teilkürzel = _max(1,max/AnzWort) */
bpt = MAX(1, maxchars / c);
bpt = _max(1, maxchars / c);
/* Einzelne Wörter anspringen und jeweils die ersten BpT kopieren */

View File

@ -174,7 +174,7 @@ get_pooled(const unit * u, const resource_type * rtype, unsigned int mode,
use = have;
else {
int reserve = get_reservation(u, rtype);
int slack = MAX(0, have - reserve);
int slack = _max(0, have - reserve);
if (mode & GET_RESERVE)
use = have - slack;
else if (mode & GET_SLACK)
@ -216,16 +216,16 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
}
if ((mode & GET_SLACK) && (mode & GET_RESERVE)) {
n = MIN(use, have);
n = _min(use, have);
} else {
int reserve = get_reservation(u, rtype);
int slack = MAX(0, have - reserve);
int slack = _max(0, have - reserve);
if (mode & GET_RESERVE) {
n = have - slack;
n = MIN(use, n);
n = _min(use, n);
change_reservation(u, rtype, -n);
} else if (mode & GET_SLACK) {
n = MIN(use, slack);
n = _min(use, slack);
}
}
if (n > 0) {

View File

@ -573,7 +573,7 @@ koor_distance_wrap_xy(int x1, int y1, int x2, int y2, int width, int height)
int dx = x1 - x2;
int dy = y1 - y2;
int result, dist;
int mindist = MIN(width, height) >> 1;
int mindist = _min(width, height) >> 1;
/* Bei negativem dy am Ursprung spiegeln, das veraendert
* den Abstand nicht
@ -596,13 +596,13 @@ koor_distance_wrap_xy(int x1, int y1, int x2, int y2, int width, int height)
if (result <= mindist)
return result;
}
dist = MAX(dx, height - dy);
dist = _max(dx, height - dy);
if (dist >= 0 && dist < result) {
result = dist;
if (result <= mindist)
return result;
}
dist = MAX(width - dx, dy);
dist = _max(width - dx, dy);
if (dist >= 0 && dist < result)
result = dist;
return result;
@ -1371,7 +1371,7 @@ void terraform_region(region * r, const terrain_type * terrain)
if (!fval(r, RF_CHAOTIC)) {
int peasants;
peasants = (maxworkingpeasants(r) * (20 + dice_rand("6d10"))) / 100;
rsetpeasants(r, MAX(100, peasants));
rsetpeasants(r, _max(100, peasants));
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
INT_MAX) + 1) + rng_int() % 5));
}
@ -1540,7 +1540,7 @@ faction *update_owners(region * r)
} else {
alliance *al = region_get_alliance(r);
if (al && u->faction->alliance == al) {
int morale = MAX(0, r->land->morale - MORALE_TRANSFER);
int morale = _max(0, r->land->morale - MORALE_TRANSFER);
region_set_morale(r, morale, turn);
} else {
region_set_morale(r, MORALE_TAKEOVER, turn);

View File

@ -55,7 +55,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <quicklist.h>
/* libc includes */
#include <sys/stat.h>
#include <assert.h>
#include <errno.h>
#include <limits.h>
@ -216,8 +215,8 @@ int update_nmrs(void)
int nmr = turn - f->lastorders + 1;
if (nmr < 0 || nmr > NMRTimeout()) {
log_error("faction %s has %d NMRS\n", factionid(f), nmr);
nmr = MAX(0, nmr);
nmr = MIN(nmr, NMRTimeout());
nmr = _max(0, nmr);
nmr = _min(nmr, NMRTimeout());
}
++nmrs[nmr];
}
@ -936,7 +935,7 @@ spskill(char *buffer, size_t size, const struct locale * lang,
oldeff = sv->old + get_modifier(u, sv->id, sv->old, u->region, false);
}
oldeff = MAX(0, oldeff);
oldeff = _max(0, oldeff);
diff = effsk - oldeff;
if (diff != 0) {
@ -1726,13 +1725,11 @@ static void write_script(FILE * F, const faction * f)
int init_reports(void)
{
prepare_reports();
#ifdef HAVE_STAT
{
stat_type st;
if (stat(reportpath(), &st) == 0)
if (_access(reportpath(), 0)!=0) {
return 0;
}
}
#endif
if (_mkdir(reportpath()) != 0) {
if (errno != EEXIST) {
perror("could not create reportpath");

View File

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

View File

@ -154,7 +154,7 @@ static void help_feed(unit * donor, unit * u, int *need_p)
{
int need = *need_p;
int give = get_money(donor) - lifestyle(donor);
give = MIN(need, give);
give = _min(need, give);
if (give > 0) {
change_money(donor, -give);
@ -223,7 +223,7 @@ void get_food(region * r)
* food from the peasants - should not be used with WORK */
if (owner != NULL && (get_alliance(owner, u->faction) & HELP_MONEY)) {
int rm = rmoney(r);
int use = MIN(rm, need);
int use = _min(rm, need);
rsetmoney(r, rm - use);
need -= use;
}
@ -236,7 +236,7 @@ void get_food(region * r)
for (v = r->units; need && v; v = v->next) {
if (v->faction == u->faction && help_money(v)) {
int give = get_money(v) - lifestyle(v);
give = MIN(need, give);
give = _min(need, give);
if (give > 0) {
change_money(v, -give);
change_money(u, give);
@ -253,7 +253,7 @@ void get_food(region * r)
int need = lifestyle(u);
faction *f = u->faction;
need -= MAX(0, get_money(u));
need -= _max(0, get_money(u));
if (need > 0) {
unit *v;
@ -310,7 +310,7 @@ void get_food(region * r)
unit *donor = u;
while (donor != NULL && hungry > 0) {
int blut = get_effect(donor, pt_blood);
blut = MIN(blut, hungry);
blut = _min(blut, hungry);
change_effect(donor, pt_blood, -blut);
hungry -= blut;
if (donor == u)
@ -357,7 +357,7 @@ void get_food(region * r)
/* 3. Von den überlebenden das Geld abziehen: */
for (u = r->units; u; u = u->next) {
int need = MIN(get_money(u), lifestyle(u));
int need = _min(get_money(u), lifestyle(u));
change_money(u, -need);
}
}
@ -417,7 +417,7 @@ static void live(region * r)
}
/* bestes Talent raussuchen */
if (sb != NULL) {
int weeks = MIN(effect, u->number);
int weeks = _min(effect, u->number);
reduce_skill(u, sb, weeks);
ADDMSG(&u->faction->msgs, msg_message("dumbeffect",
"unit weeks skill", u, weeks, (skill_t) sb->id));
@ -475,7 +475,7 @@ static void calculate_emigration(region * r)
int max_emigration = MAX_EMIGRATION(rp2 - maxp2);
if (max_emigration > 0) {
max_emigration = MIN(max_emigration, max_immigrants);
max_emigration = _min(max_emigration, max_immigrants);
r->land->newpeasants += max_emigration;
rc->land->newpeasants -= max_emigration;
max_immigrants -= max_emigration;
@ -534,7 +534,7 @@ static void peasants(region * r)
/* Alle werden satt, oder halt soviele für die es auch Geld gibt */
satiated = MIN(peasants, money / maintenance_cost(NULL));
satiated = _min(peasants, money / maintenance_cost(NULL));
rsetmoney(r, money - satiated * maintenance_cost(NULL));
/* Von denjenigen, die nicht satt geworden sind, verhungert der
@ -543,7 +543,7 @@ static void peasants(region * r)
/* Es verhungert maximal die unterernährten Bevölkerung. */
n = MIN(peasants - satiated, rpeasants(r));
n = _min(peasants - satiated, rpeasants(r));
dead += (int)(0.5F + n * PEASANT_STARVATION_CHANCE);
if (dead > 0) {
@ -624,7 +624,7 @@ static void horses(region * r)
/* Logistisches Wachstum, Optimum bei halbem Maximalbesatz. */
maxhorses = maxworkingpeasants(r) / 10;
maxhorses = MAX(0, maxhorses);
maxhorses = _max(0, maxhorses);
horses = rhorses(r);
if (horses > 0) {
if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) {
@ -657,7 +657,7 @@ static void horses(region * r)
if (r2 && fval(r2->terrain, WALK_INTO)) {
int pt = (rhorses(r) * HORSEMOVE) / 100;
pt = (int)normalvariate(pt, pt / 4.0);
pt = MAX(0, pt);
pt = _max(0, pt);
if (fval(r2, RF_MIGRATION))
rsethorses(r2, rhorses(r2) + pt);
else {
@ -760,7 +760,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
a = a_find(r->attribs, &at_germs);
if (a && last_weeks_season == SEASON_SPRING) {
/* ungekeimte Samen bleiben erhalten, Sprößlinge wachsen */
sprout = MIN(a->data.sa[1], rtrees(r, 1));
sprout = _min(a->data.sa[1], rtrees(r, 1));
/* aus dem gesamt Sprößlingepool abziehen */
rsettrees(r, 1, rtrees(r, 1) - sprout);
/* zu den Bäumen hinzufügen */
@ -780,7 +780,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
/* Grundchance 1.0% */
/* Jeder Elf in der Region erhöht die Chance marginal */
elves = MIN(elves, (production(r) * MAXPEASANTS_PER_AREA) / 8);
elves = _min(elves, (production(r) * MAXPEASANTS_PER_AREA) / 8);
if (elves) {
seedchance += 1.0 - pow(0.99999, elves * RESOURCE_QUANTITY);
}
@ -845,7 +845,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
/* Raubbau abfangen, es dürfen nie mehr Samen wachsen, als aktuell
* in der Region sind */
seeds = MIN(a->data.sa[0], rtrees(r, 0));
seeds = _min(a->data.sa[0], rtrees(r, 0));
sprout = 0;
for (i = 0; i < seeds; i++) {
@ -865,7 +865,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
* der Region entfernt werden können, da Jungbäume in der gleichen
* Runde nachwachsen, wir also nicht mehr zwischen diesjährigen und
* 'alten' Jungbäumen unterscheiden könnten */
sprout = MIN(a->data.sa[1], rtrees(r, 1));
sprout = _min(a->data.sa[1], rtrees(r, 1));
grownup_trees = 0;
for (i = 0; i < sprout; i++) {
@ -973,7 +973,7 @@ void demographics(void)
for (r = regions; r; r = r->next) {
if (r->land && r->land->newpeasants) {
int rp = rpeasants(r) + r->land->newpeasants;
rsetpeasants(r, MAX(0, rp));
rsetpeasants(r, _max(0, rp));
}
}
@ -1473,7 +1473,7 @@ static void remove_idle_players(void)
}
log_info(" - beseitige Spieler, die sich nach der Anmeldung nicht gemeldet haben...");
age = calloc(MAX(4, turn + 1), sizeof(int));
age = calloc(_max(4, turn + 1), sizeof(int));
for (f = factions; f; f = f->next)
if (!is_monsters(f)) {
if (RemoveNMRNewbie() && !fval(f, FFL_NOIDLEOUT)) {
@ -2866,7 +2866,7 @@ int combatspell_cmd(unit * u, struct order *ord)
if (findparam(s, u->faction->locale) == P_LEVEL) {
/* Merken, setzen kommt erst später */
level = getint();
level = MAX(0, level);
level = _max(0, level);
s = getstrtoken();
}
@ -3328,14 +3328,14 @@ static building *age_building(building * b)
float effect = 100;
/* the mage reactivates the circle */
c = create_curse(mage, &rt->attribs, ct_astralblock,
(float)MAX(1, sk), MAX(1, sk / 2), effect, 0);
(float)_max(1, sk), _max(1, sk / 2), effect, 0);
ADDMSG(&r->msgs,
msg_message("astralshield_activate", "region unit", r, mage));
}
} else if (mage != NULL) {
int sk = effskill(mage, SK_MAGIC);
c->duration = MAX(c->duration, sk / 2);
c->vigour = MAX(c->vigour, sk);
c->duration = _max(c->duration, sk / 2);
c->vigour = _max(c->vigour, sk);
}
}
}
@ -3404,12 +3404,12 @@ static void ageing(void)
/* Goliathwasser */
int i = get_effect(u, oldpotiontype[P_STRONG]);
if (i > 0) {
change_effect(u, oldpotiontype[P_STRONG], -1 * MIN(u->number, i));
change_effect(u, oldpotiontype[P_STRONG], -1 * _min(u->number, i));
}
/* Berserkerblut */
i = get_effect(u, oldpotiontype[P_BERSERK]);
if (i > 0) {
change_effect(u, oldpotiontype[P_BERSERK], -1 * MIN(u->number, i));
change_effect(u, oldpotiontype[P_BERSERK], -1 * _min(u->number, i));
}
if (is_cursed(u->attribs, C_OLDRACE, 0)) {
@ -3483,7 +3483,7 @@ static int maxunits(const faction * f)
if (flimit == 0) {
return alimit;
}
return MIN(alimit, flimit);
return _min(alimit, flimit);
}
int checkunitnumber(const faction * f, int add)
@ -3823,9 +3823,9 @@ void monthly_healing(void)
p *= heal_factor(u);
if (u->hp < umhp) {
#ifdef NEW_DAEMONHUNGER_RULE
double maxheal = MAX(u->number, umhp / 20.0);
double maxheal = _max(u->number, umhp / 20.0);
#else
double maxheal = MAX(u->number, umhp / 10.0);
double maxheal = _max(u->number, umhp / 10.0);
#endif
int addhp;
struct building *b = inside_building(u);
@ -3843,7 +3843,7 @@ void monthly_healing(void)
++addhp;
/* Aufaddieren der geheilten HP. */
u->hp = MIN(u->hp + addhp, umhp);
u->hp = _min(u->hp + addhp, umhp);
/* soll man an negativer regeneration sterben können? */
assert(u->hp > 0);
@ -4108,7 +4108,7 @@ int claim_cmd(unit * u, struct order *ord)
if (itype != NULL) {
item **iclaim = i_find(&u->faction->items, itype);
if (iclaim != NULL && *iclaim != NULL) {
n = MIN(n, (*iclaim)->number);
n = _min(n, (*iclaim)->number);
i_change(iclaim, itype, -n);
i_change(&u->items, itype, n);
}
@ -4378,9 +4378,9 @@ int siege_cmd(unit * u, order * ord)
/* schaden durch katapulte */
d = i_get(u->items, it_catapult);
d = MIN(u->number, d);
d = _min(u->number, d);
pooled = get_pooled(u, it_catapultammo->rtype, GET_DEFAULT, d);
d = MIN(pooled, d);
d = _min(pooled, d);
if (eff_skill(u, SK_CATAPULT, r) >= 1) {
katapultiere = d;
d *= eff_skill(u, SK_CATAPULT, r);
@ -4406,11 +4406,11 @@ int siege_cmd(unit * u, order * ord)
* einheiten wieder abgesucht werden muessen! */
usetsiege(u, b);
b->besieged += MAX(bewaffnete, katapultiere);
b->besieged += _max(bewaffnete, katapultiere);
/* definitiver schaden eingeschraenkt */
d = MIN(d, b->size - 1);
d = _min(d, b->size - 1);
/* meldung, schaden anrichten */
if (d && !curse_active(get_curse(b->attribs, magicwalls_ct))) {

View File

@ -101,15 +101,17 @@ static int
leave_arena(struct unit *u, const struct item_type *itype, int amount,
order * ord)
{
if (!u->building && leave_fail(u))
return -1;
if (u->building != arena_tower(u->faction->magiegebiet) && leave_fail(u))
return -1;
unused(amount);
unused(ord);
unused(itype);
assert(!"not implemented");
return 0;
if (!u->building && leave_fail(u)) {
return -1;
}
if (u->building != arena_tower(u->faction->magiegebiet) && leave_fail(u)) {
return -1;
}
unused(amount);
unused(ord);
unused(itype);
assert(!"not implemented");
return 0;
}
static int enter_fail(unit * u)

View File

@ -1021,8 +1021,8 @@ int build_island_e3(int x, int y, int numfactions, int minsize)
q = region_quality(r, rn);
if (q >= MIN_QUALITY && nfactions < numfactions) {
starting_region(r, rn);
minq = MIN(minq, q);
maxq = MAX(maxq, q);
minq = _min(minq, q);
maxq = _max(maxq, q);
++nfactions;
}
}
@ -1036,8 +1036,8 @@ int build_island_e3(int x, int y, int numfactions, int minsize)
q = region_quality(r, rn);
if (q >= MIN_QUALITY * 4 / 3 && nfactions < numfactions) {
starting_region(r, rn);
minq = MIN(minq, q);
maxq = MAX(maxq, q);
minq = _min(minq, q);
maxq = _max(maxq, q);
++nfactions;
}
}

View File

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

View File

@ -108,7 +108,7 @@ static void eaten_by_monster(unit * u)
n = (int)(n * multi);
if (n > 0) {
n = lovar(n);
n = MIN(rpeasants(u->region), n);
n = _min(rpeasants(u->region), n);
if (n > 0) {
deathcounts(u->region, n);
@ -133,7 +133,7 @@ static void absorbed_by_monster(unit * u)
if (n > 0) {
n = lovar(n);
n = MIN(rpeasants(u->region), n);
n = _min(rpeasants(u->region), n);
if (n > 0) {
rsetpeasants(u->region, rpeasants(u->region) - n);
scale_number(u, u->number + n);
@ -148,7 +148,7 @@ static int scareaway(region * r, int anzahl)
int n, p, diff = 0, emigrants[MAXDIRECTIONS];
direction_t d;
anzahl = MIN(MAX(1, anzahl), rpeasants(r));
anzahl = _min(_max(1, anzahl), rpeasants(r));
/* Wandern am Ende der Woche (normal) oder wegen Monster. Die
* Wanderung wird erst am Ende von demographics () ausgefuehrt.
@ -160,7 +160,7 @@ static int scareaway(region * r, int anzahl)
p = rpeasants(r);
assert(p >= 0 && anzahl >= 0);
for (n = MIN(p, anzahl); n; n--) {
for (n = _min(p, anzahl); n; n--) {
direction_t dir = (direction_t) (rng_int() % MAXDIRECTIONS);
region *rc = rconnect(r, dir);
@ -195,7 +195,7 @@ static void scared_by_monster(unit * u)
if (n > 0) {
n = lovar(n);
n = MIN(rpeasants(u->region), n);
n = _min(rpeasants(u->region), n);
if (n > 0) {
n = scareaway(u->region, n);
if (n > 0) {

View File

@ -82,7 +82,7 @@ static void reduce_weight(unit * u)
int horses = get_resource(u, oldresourcetype[R_HORSE]);
if (horses > 0) {
horses = MIN(horses, (u->number * 2));
horses = _min(horses, (u->number * 2));
change_resource(u, oldresourcetype[R_HORSE], -horses);
}
@ -109,7 +109,7 @@ static void reduce_weight(unit * u)
if (itype->weight >= 10 && itype->rtype->wtype == 0
&& itype->rtype->atype == 0) {
if (itype->capacity < itype->weight) {
int reduce = MIN(itm->number, -((capacity - weight) / itype->weight));
int reduce = _min(itm->number, -((capacity - weight) / itype->weight));
give_item(reduce, itm->type, u, NULL, NULL);
weight -= reduce * itype->weight;
}
@ -124,7 +124,7 @@ static void reduce_weight(unit * u)
const item_type *itype = itm->type;
weight += itm->number * itype->weight;
if (itype->capacity < itype->weight) {
int reduce = MIN(itm->number, -((capacity - weight) / itype->weight));
int reduce = _min(itm->number, -((capacity - weight) / itype->weight));
give_item(reduce, itm->type, u, NULL, NULL);
weight -= reduce * itype->weight;
}

View File

@ -58,13 +58,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# define _CRTDBG_MAP_ALLOC
#endif
# define HAVE_INLINE
# define INLINE_FUNCTION __inline
#endif /* _MSC_VER_ */
#if defined __GNUC__
# define HAVE_INLINE
# define INLINE_FUNCTION static __inline
# undef _BSD_SOURCE
# define _BSD_SOURCE
# undef __USE_BSD
@ -82,34 +78,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# define _XOPEN_SOURCE
#endif
/* TinyCC */
#ifdef TINYCC
# undef HAVE_INLINE
# define INLINE_FUNCTION
#endif
#define unused (void)
/**** ****
** min/max macros **
**** ****/
#ifndef NOMINMAX
#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
# define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
#endif
#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)
#else /* ghs || __GNUC__ || ..... */
# define unused(a) (a)
#endif /* ghs || __GNUC__ || ..... */
#include "util/bool.h"
#ifndef INLINE_FUNCTION
# define INLINE_FUNCTION
#endif

View File

@ -22,7 +22,7 @@
/* util includes */
#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 WYRMAGE 68

View File

@ -30,7 +30,7 @@
#define UNDEAD_BREAKUP 25 /* chance dafuer */
#define UNDEAD_BREAKUP_FRACTION (25+rng_int()%70) /* anteil der weg geht */
#define age_chance(a,b,p) (MAX(0,a-b)*p)
#define age_chance(a,b,p) (_max(0,a-b)*p)
void age_undead(unit * u)
{
@ -60,7 +60,7 @@ void age_undead(unit * u)
void age_skeleton(unit * u)
{
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
int n = MAX(1, u->number / 2);
int n = _max(1, u->number / 2);
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
u_setrace(u, new_race[RC_SKELETON_LORD]);
u->irace = NULL;
@ -72,7 +72,7 @@ void age_skeleton(unit * u)
void age_zombie(unit * u)
{
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
int n = MAX(1, u->number / 2);
int n = _max(1, u->number / 2);
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
u_setrace(u, new_race[RC_ZOMBIE_LORD]);
u->irace = NULL;
@ -84,7 +84,7 @@ void age_zombie(unit * u)
void age_ghoul(unit * u)
{
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
int n = MAX(1, u->number / 2);
int n = _max(1, u->number / 2);
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
u_setrace(u, new_race[RC_GHOUL_LORD]);
u->irace = NULL;

View File

@ -1194,7 +1194,7 @@ static void rotting_herbs(void)
if (fval(itm->type, ITF_HERB)) {
double nv = normalvariate(k, k / 4);
int inv = (int)nv;
int delta = MIN(n, inv);
int delta = _min(n, inv);
if (i_change(itmp, itm->type, -delta) == NULL) {
continue;
}
@ -1242,7 +1242,7 @@ void randomevents(void)
a_remove(&r->attribs, a);
ADDMSG(&r->msgs, msg_message("orcified", "region", r));
} else {
a->data.i -= MAX(10, a->data.i / 10);
a->data.i -= _max(10, a->data.i / 10);
if (a->data.i <= 0)
a_remove(&r->attribs, a);
}
@ -1279,7 +1279,7 @@ void randomevents(void)
while (*blist) {
building *b = *blist;
if (fval(b->type, BTF_DECAY) && !building_owner(b)) {
b->size -= MAX(1, (b->size * 20) / 100);
b->size -= _max(1, (b->size * 20) / 100);
if (b->size == 0) {
remove_building(blist, r->buildings);
}

View File

@ -96,11 +96,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <limits.h>
#include <stdlib.h>
#ifdef HAVE_STAT
#include <sys/types.h>
#include <sys/stat.h>
#endif
extern int verbosity;
extern int *storms;
extern int weeks_per_month;

View File

@ -214,7 +214,7 @@ static region *wall_move(const connection * b, struct unit *u,
wall_data *fd = (wall_data *) b->data.v;
if (!routing && fd->active) {
int hp = dice(3, fd->force) * u->number;
hp = MIN(u->hp, hp);
hp = _min(u->hp, hp);
u->hp -= hp;
if (u->hp) {
ADDMSG(&u->faction->msgs, msg_message("firewall_damage",

View File

@ -315,14 +315,14 @@ int sp_combatrosthauch(struct castorder * co)
if (force <= 0)
break;
/* da n MIN(force, x), sollte force maximal auf 0 sinken */
/* da n _min(force, x), sollte force maximal auf 0 sinken */
assert(force >= 0);
if (df->weapons) {
int w;
for (w = 0; df->weapons[w].type != NULL; ++w) {
weapon *wp = df->weapons;
int n = MIN(force, wp->used);
int n = _min(force, wp->used);
if (n) {
requirement *mat = wp->type->itype->construction->materials;
bool iron = false;
@ -873,7 +873,7 @@ int sp_shadowknights(struct castorder * co)
region *r = b->region;
unit *mage = fi->unit;
attrib *a;
int force = MAX(1, (int)get_force(power, 3));
int force = _max(1, (int)get_force(power, 3));
message *msg;
u =
@ -973,7 +973,7 @@ int sp_chaosrow(struct castorder * co)
continue;
if (power <= 0.0)
break;
/* force sollte wegen des MAX(0,x) nicht unter 0 fallen können */
/* force sollte wegen des _max(0,x) nicht unter 0 fallen können */
if (is_magic_resistant(mage, df->unit, 0))
continue;
@ -1008,7 +1008,7 @@ int sp_chaosrow(struct castorder * co)
}
k += df->alive;
}
power = MAX(0, power - n);
power = _max(0, power - n);
}
ql_free(fgs);
@ -1110,12 +1110,12 @@ int sp_hero(struct castorder * co)
switch (sp->id) {
case SPL_HERO:
df_bonus = (int)(power / 5);
force = MAX(1, lovar(get_force(power, 4)));
force = _max(1, lovar(get_force(power, 4)));
break;
default:
df_bonus = 1;
force = MAX(1, (int)power);
force = _max(1, (int)power);
}
allies =
@ -1164,7 +1164,7 @@ int sp_berserk(struct castorder * co)
switch (sp->id) {
case SPL_BERSERK:
case SPL_BLOODTHIRST:
at_bonus = MAX(1, level / 3);
at_bonus = _max(1, level / 3);
df_malus = 2;
force = (int)get_force(power, 2);
break;
@ -1220,7 +1220,7 @@ int sp_frighten(struct castorder * co)
int targets = 0;
message *m;
at_malus = MAX(1, level - 4);
at_malus = _max(1, level - 4);
df_malus = 2;
force = (int)get_force(power, 2);
@ -1502,7 +1502,7 @@ int sp_fumbleshield(struct castorder * co)
case SPL_CERRDOR_FUMBLESHIELD:
case SPL_TYBIED_FUMBLESHIELD:
duration = 100;
effect = MAX(1, 25 - level);
effect = _max(1, 25 - level);
break;
default:
@ -1549,7 +1549,7 @@ int sp_reanimate(struct castorder * co)
}
healable = count_healable(b, fi);
healable = (int)MIN(k, healable);
healable = (int)_min(k, healable);
while (healable--) {
fighter *tf = select_corpse(b, fi);
if (tf != NULL && tf->side->casualties > 0
@ -1601,7 +1601,7 @@ int sp_keeploot(struct castorder * co)
message_all(b, m);
msg_release(m);
b->keeploot = (int)MAX(25, b->keeploot + 5 * power);
b->keeploot = (int)_max(25, b->keeploot + 5 * power);
return level;
}
@ -1632,10 +1632,10 @@ static int heal_fighters(quicklist * fgs, int *power, bool heal_monsters)
++wound;
if (wound > 0 && wound < hp) {
int heal = MIN(healhp, wound);
int heal = _min(healhp, wound);
assert(heal >= 0);
df->person[n].hp += heal;
healhp = MAX(0, healhp - heal);
healhp = _max(0, healhp - heal);
++healed;
if (healhp <= 0)
break;
@ -1768,7 +1768,7 @@ int sp_undeadhero(struct castorder * co)
}
ql_free(fgs);
level = MIN(level, undead);
level = _min(level, undead);
if (undead == 0) {
msg =
msg_message("summonundead_effect_0", "mage region", mage, mage->region);

View File

@ -149,7 +149,7 @@ static void magicanalyse_region(region * r, unit * mage, double force)
* mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force);
mon = c->duration + (rng_int() % 10) - 5;
mon = MAX(1, mon);
mon = _max(1, mon);
found = true;
if (chance(probability)) { /* Analyse geglueckt */
@ -188,7 +188,7 @@ static void magicanalyse_unit(unit * u, unit * mage, double force)
* mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force);
mon = c->duration + (rng_int() % 10) - 5;
mon = MAX(1, mon);
mon = _max(1, mon);
if (chance(probability)) { /* Analyse geglueckt */
if (c_flags(c) & CURSE_NOAGE) {
@ -227,7 +227,7 @@ static void magicanalyse_building(building * b, unit * mage, double force)
* mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force);
mon = c->duration + (rng_int() % 10) - 5;
mon = MAX(1, mon);
mon = _max(1, mon);
if (chance(probability)) { /* Analyse geglueckt */
if (c_flags(c) & CURSE_NOAGE) {
@ -266,7 +266,7 @@ static void magicanalyse_ship(ship * sh, unit * mage, double force)
* mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force);
mon = c->duration + (rng_int() % 10) - 5;
mon = MAX(1, mon);
mon = _max(1, mon);
if (chance(probability)) { /* Analyse geglueckt */
if (c_flags(c) & CURSE_NOAGE) {
@ -674,7 +674,7 @@ static int sp_destroy_magic(castorder * co)
"unit region command", mage, mage->region, co->order));
}
return MAX(succ, 1);
return _max(succ, 1);
}
/* ------------------------------------------------------------- */
@ -740,7 +740,7 @@ static int sp_transferaura(castorder * co)
return 0;
}
gain = MIN(aura, scm_src->spellpoints) / multi;
gain = _min(aura, scm_src->spellpoints) / multi;
scm_src->spellpoints -= gain * multi;
scm_dst->spellpoints += gain;
@ -879,7 +879,7 @@ static int sp_summonent(castorder * co)
return 0;
}
ents = (int)MIN(power * power, rtrees(r, 2));
ents = (int)_min(power * power, rtrees(r, 2));
u = create_unit(r, mage->faction, ents, new_race[RC_TREEMAN], 0, NULL, mage);
@ -1270,7 +1270,7 @@ static int sp_rosthauch(castorder * co)
for (; iweapon != NULL; iweapon = iweapon->next) {
item **ip = i_find(&u->items, iweapon->type);
if (*ip) {
int i = MIN((*ip)->number, force);
int i = _min((*ip)->number, force);
if (iweapon->chance < 1.0) {
i = (int)(i * iweapon->chance);
}
@ -1307,7 +1307,7 @@ static int sp_rosthauch(castorder * co)
* unguenstigsten Fall kann pro Stufe nur eine Waffe verzaubert werden,
* darum wird hier nur fuer alle Faelle in denen noch weniger Waffen
* betroffen wurden ein Kostennachlass gegeben */
return MIN(success, cast_level);
return _min(success, cast_level);
}
/* ------------------------------------------------------------- */
@ -1337,7 +1337,7 @@ static int sp_kaelteschutz(castorder * co)
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
int duration = MAX(cast_level, (int)force) + 1;
int duration = _max(cast_level, (int)force) + 1;
spellparameter *pa = co->par;
float effect;
@ -2081,8 +2081,8 @@ static int sp_drought(castorder * co)
*/
c = get_curse(r->attribs, ct_find("drought"));
if (c) {
c->vigour = MAX(c->vigour, power);
c->duration = MAX(c->duration, (int)power);
c->vigour = _max(c->vigour, power);
c->duration = _max(c->duration, (int)power);
} else {
float effect = 4.0;
/* Baeume und Pferde sterben */
@ -2278,8 +2278,8 @@ static int sp_earthquake(castorder * co)
if (burg->size != 0 && !is_cursed(burg->attribs, C_MAGICWALLS, 0)) {
/* Magieresistenz */
if (!target_resists_magic(mage, burg, TYP_BUILDING, 0)) {
kaputt = MIN(10 * cast_level, burg->size / 4);
kaputt = MAX(kaputt, 1);
kaputt = _min(10 * cast_level, burg->size / 4);
kaputt = _max(kaputt, 1);
burg->size -= kaputt;
if (burg->size == 0) {
/* TODO: sollten die Insassen nicht Schaden nehmen? */
@ -2444,7 +2444,7 @@ static int sp_forest_fire(castorder * co)
* das Zaubern. Patzer werden warscheinlicher.
* Jeder Zauber muss erst gegen den Wiederstand des Fluchs gezaubert
* werden und schwaecht dessen Antimagiewiederstand um 1.
* Wirkt MAX(Stufe(Magier) - Stufe(Ziel), rand(3)) Wochen
* Wirkt _max(Stufe(Magier) - Stufe(Ziel), rand(3)) Wochen
* Patzer:
* Magier wird selbst betroffen
*
@ -2472,7 +2472,7 @@ static int sp_fumblecurse(castorder * co)
rx = rng_int() % 3;
sx = cast_level - effskill(target, SK_MAGIC);
duration = MAX(sx, rx) + 1;
duration = _max(sx, rx) + 1;
effect = force/2;
c = create_curse(mage, &target->attribs, ct_find("fumble"),
@ -2635,8 +2635,8 @@ static int sp_firewall(castorder * co)
fd->countdown = cast_level + 1;
} else {
fd = (wall_data *) b->data.v;
fd->force = (int)MAX(fd->force, force / 2 + 0.5);
fd->countdown = MAX(fd->countdown, cast_level + 1);
fd->force = (int)_max(fd->force, force / 2 + 0.5);
fd->countdown = _max(fd->countdown, cast_level + 1);
}
/* melden, 1x pro Partei */
@ -2847,7 +2847,7 @@ attrib_type at_deathcloud_compat = {
* Ruestung wirkt nicht
* Patzer:
* Magier geraet in den Staub und verliert zufaellige Zahl von HP bis
* auf MAX(hp,2)
* auf _max(hp,2)
* Besonderheiten:
* Nicht als curse implementiert, was schlecht ist - man kann dadurch
* kein dispell machen. Wegen fix unter Zeitdruck erstmal nicht zu
@ -3265,7 +3265,7 @@ static int sp_summonundead(castorder * co)
return 0;
}
undead = MIN(deathcount(r), 2 + lovar(force));
undead = _min(deathcount(r), 2 + lovar(force));
if (cast_level <= 8) {
race = new_race[RC_SKELETON];
@ -3311,7 +3311,7 @@ static int sp_auraleak(castorder * co)
int cast_level = co->level;
message *msg;
lost = MIN(0.95, cast_level * 0.05);
lost = _min(0.95, cast_level * 0.05);
for (u = r->units; u; u = u->next) {
if (is_mage(u)) {
@ -3697,8 +3697,8 @@ static int sp_raisepeasantmob(castorder * co)
anteil = 6 + (rng_int() % 4);
n = rpeasants(r) * anteil / 10;
n = MAX(0, n);
n = MIN(n, rpeasants(r));
n = _max(0, n);
n = _min(n, rpeasants(r));
if (n <= 0) {
report_failure(mage, co->order);
@ -3935,12 +3935,12 @@ static int sp_recruit(castorder * co)
n = (pow(force, 1.6) * 100) / f->race->recruitcost;
if (rc->recruit_multi != 0) {
double multp = maxp / rc->recruit_multi;
n = MIN(multp, n);
n = MAX(n, 1);
n = _min(multp, n);
n = _max(n, 1);
rsetpeasants(r, maxp - (int)(n * rc->recruit_multi));
} else {
n = MIN(maxp, n);
n = MAX(n, 1);
n = _min(maxp, n);
n = _max(n, 1);
rsetpeasants(r, maxp - (int)n);
}
@ -3985,12 +3985,12 @@ static int sp_bigrecruit(castorder * co)
n = (int)force + lovar((force * force * 1000) / f->race->recruitcost);
if (f->race == new_race[RC_ORC]) {
n = MIN(2 * maxp, n);
n = MAX(n, 1);
n = _min(2 * maxp, n);
n = _max(n, 1);
rsetpeasants(r, maxp - (n + 1) / 2);
} else {
n = MIN(maxp, n);
n = MAX(n, 1);
n = _min(maxp, n);
n = _max(n, 1);
rsetpeasants(r, maxp - n);
}
@ -4078,7 +4078,7 @@ static int sp_pump(castorder * co)
* Betoert eine Einheit, so das sie ihm den groeßten Teil ihres Bargelds
* und 50% ihres Besitzes schenkt. Sie behaelt jedoch immer soviel, wie
* sie zum ueberleben braucht. Wirkt gegen Magieresistenz.
* MIN(Stufe*1000$, u->money - maintenace)
* _min(Stufe*1000$, u->money - maintenace)
* Von jedem Item wird 50% abgerundet ermittelt und uebergeben. Dazu
* kommt Itemzahl%2 mit 50% chance
*
@ -4115,15 +4115,15 @@ static int sp_seduce(castorder * co)
int loot;
if (itm->type == i_silver) {
loot =
MIN(cast_level * 1000, get_money(target) - (maintenance_cost(target)));
loot = MAX(loot, 0);
_min(cast_level * 1000, get_money(target) - (maintenance_cost(target)));
loot = _max(loot, 0);
} else {
loot = itm->number / 2;
if (itm->number % 2) {
loot += rng_int() % 2;
}
if (loot > 0) {
loot = (int)MIN(loot, force * 5);
loot = (int)_min(loot, force * 5);
}
}
if (loot > 0) {
@ -4240,7 +4240,7 @@ static int sp_headache(castorder * co)
}
if (smax != NULL) {
/* wirkt auf maximal 10 Personen */
int change = MIN(10, target->number) * (rng_int() % 2 + 1) / target->number;
int change = _min(10, target->number) * (rng_int() % 2 + 1) / target->number;
reduce_skill(target, smax, change);
}
set_order(&target->thisorder, NULL);
@ -4284,7 +4284,7 @@ static int sp_raisepeasants(castorder * co)
"error_nopeasants", ""));
return 0;
}
bauern = (int)MIN(rpeasants(r), power * 250);
bauern = (int)_min(rpeasants(r), power * 250);
rsetpeasants(r, rpeasants(r) - bauern);
u2 =
@ -4367,7 +4367,7 @@ int sp_puttorest(castorder * co)
message *seen = msg_message("puttorest", "mage", mage);
message *unseen = msg_message("puttorest", "mage", NULL);
laid_to_rest = MAX(laid_to_rest, dead);
laid_to_rest = _max(laid_to_rest, dead);
deathcounts(r, -laid_to_rest);
@ -4595,7 +4595,7 @@ int sp_baddreams(castorder * co)
/* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken,
* also duration+2 */
duration = (int)MAX(1, power / 2); /* Stufe 1 macht sonst mist */
duration = (int)_max(1, power / 2); /* Stufe 1 macht sonst mist */
duration = 2 + rng_int() % duration;
/* Nichts machen als ein entsprechendes Attribut in die Region legen. */
@ -4633,7 +4633,7 @@ int sp_gooddreams(castorder * co)
/* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken,
* also duration+2 */
duration = (int)MAX(1, power / 2); /* Stufe 1 macht sonst mist */
duration = (int)_max(1, power / 2); /* Stufe 1 macht sonst mist */
duration = 2 + rng_int() % duration;
effect = 1;
c = create_curse(mage, &r->attribs, ct_find("gbdream"), power, duration, effect, 0);
@ -4774,7 +4774,7 @@ int sp_sweetdreams(castorder * co)
cmistake(mage, co->order, 40, MSG_EVENT);
continue;
}
men = MIN(opfer, u->number);
men = _min(opfer, u->number);
opfer -= men;
/* Nichts machen als ein entsprechendes Attribut an die Einheit legen. */
@ -4888,7 +4888,7 @@ int sp_itemcloak(castorder * co)
spellparameter *pa = co->par;
int cast_level = co->level;
float power = co->force;
int duration = (int)MAX(2.0, power + 1); /* works in the report, and ageing this round would kill it if it's <=1 */
int duration = (int)_max(2.0, power + 1); /* works in the report, and ageing this round would kill it if it's <=1 */
/* wenn kein Ziel gefunden, Zauber abbrechen */
if (pa->param[0]->flag == TARGET_NOTFOUND)
@ -4952,7 +4952,7 @@ int sp_resist_magic_bonus(castorder * co)
continue;
*/
m = MIN(u->number, victims);
m = _min(u->number, victims);
victims -= m;
create_curse(mage, &u->attribs, ct_find("magicresistance"),
@ -4968,8 +4968,8 @@ int sp_resist_magic_bonus(castorder * co)
msg_release(msg);
}
cast_level = MIN(cast_level, (int)(cast_level * (victims + 4) / maxvictims));
return MAX(cast_level, 1);
cast_level = _min(cast_level, (int)(cast_level * (victims + 4) / maxvictims));
return _max(cast_level, 1);
}
/** spell 'Astraler Weg'.
@ -5819,7 +5819,7 @@ int sp_permtransfer(castorder * co)
return 0;
}
aura = MIN(get_spellpoints(mage) - spellcost(mage, sp), aura);
aura = _min(get_spellpoints(mage) - spellcost(mage, sp), aura);
change_maxspellpoints(mage, -aura);
change_spellpoints(mage, -aura);
@ -6191,7 +6191,7 @@ int sp_speed2(castorder * co)
spellparameter *pa = co->par;
maxmen = 2 * cast_level * cast_level;
dur = MAX(1, cast_level / 2);
dur = _max(1, cast_level / 2);
for (n = 0; n < pa->length; n++) {
float effect;
@ -6205,7 +6205,7 @@ int sp_speed2(castorder * co)
u = pa->param[n]->data.u;
men = MIN(maxmen, u->number);
men = _min(maxmen, u->number);
effect = 2;
create_curse(mage, &u->attribs, ct_find("speed"), force, dur, effect, men);
maxmen -= men;
@ -6216,7 +6216,7 @@ int sp_speed2(castorder * co)
"unit region amount", mage, mage->region, used));
/* Effektiv benoetigten cast_level (mindestens 1) zurueckgeben */
used = (int)sqrt(used / 2);
return MAX(1, used);
return _max(1, used);
}
/* ------------------------------------------------------------- */
@ -6298,7 +6298,7 @@ int sp_q_antimagie(castorder * co)
ADDMSG(&mage->faction->msgs, msg_message("destroy_magic_noeffect",
"unit region command", mage, mage->region, co->order));
}
return MAX(succ, 1);
return _max(succ, 1);
}
/* ------------------------------------------------------------- */
@ -6453,7 +6453,7 @@ static int sp_wdwpyramid(castorder * co)
ADDMSG(&mage->faction->msgs, msg_message("wdw_pyramidspell_notfound",
"unit region command mindist maxdist", mage, r, co->order,
MAX(1, minshowdist), maxshowdist));
_max(1, minshowdist), maxshowdist));
}
return cast_level;

View File

@ -142,7 +142,7 @@ int spy_cmd(unit * u, struct order *ord)
* Fuer jeden Talentpunkt, den das Spionagetalent das Tarnungstalent
* des Opfers uebersteigt, erhoeht sich dieses um 5%*/
spy = eff_skill(u, SK_SPY, r) - eff_skill(target, SK_STEALTH, r);
spychance = 0.1 + MAX(spy * 0.05, 0.0);
spychance = 0.1 + _max(spy * 0.05, 0.0);
if (chance(spychance)) {
produceexp(u, SK_SPY, u->number);
@ -157,7 +157,7 @@ int spy_cmd(unit * u, struct order *ord)
- (effskill(u, SK_STEALTH) + eff_skill(u, SK_SPY, r) / 2);
if (invisible(u, target) >= u->number) {
observe = MIN(observe, 0);
observe = _min(observe, 0);
}
/* Anschliessend wird - unabhaengig vom Erfolg - gewuerfelt, ob der
@ -345,7 +345,7 @@ static int crew_skill(region * r, faction * f, ship * sh, skill_t sk)
for (u = r->units; u; u = u->next) {
if (u->ship == sh && u->faction == f) {
int s = eff_skill(u, sk, r);
value = MAX(s, value);
value = _max(s, value);
}
}
return value;

View File

@ -185,7 +185,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
* steigen.
*
* n ist die Anzahl zusaetzlich gelernter Tage. n darf max. die Differenz
* von schon gelernten Tagen zum MAX(30 Tage pro Mann) betragen. */
* von schon gelernten Tagen zum _max(30 Tage pro Mann) betragen. */
if (magic_lowskill(student)) {
cmistake(teacher, teacher->thisorder, 292, MSG_EVENT);
@ -199,7 +199,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
n -= teach->value;
}
n = MIN(n, nteaching);
n = _min(n, nteaching);
if (n != 0) {
struct building *b = inside_building(teacher);
@ -224,7 +224,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
if (btype == bt_find("academy")
&& student->building && student->building->type == bt_find("academy")) {
int j = study_cost(student, sk);
j = MAX(50, j * 2);
j = _max(50, j * 2);
/* kann Einheit das zahlen? */
if (get_pooled(student, oldresourcetype[R_SILVER], GET_DEFAULT, j) >= j) {
/* Jeder Schueler zusaetzlich +10 Tage wenn in Uni. */
@ -265,7 +265,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
* die Talentaenderung (enno).
*/
nteaching = MAX(0, nteaching - student->number * 30);
nteaching = _max(0, nteaching - student->number * 30);
}
return n;
@ -302,7 +302,7 @@ int teach_cmd(unit * u, struct order *ord)
teaching = u->number * 30 * TEACHNUMBER;
if ((i = get_effect(u, oldpotiontype[P_FOOL])) > 0) { /* Trank "Dumpfbackenbrot" */
i = MIN(i, u->number * TEACHNUMBER);
i = _min(i, u->number * TEACHNUMBER);
/* Trank wirkt pro Schueler, nicht pro Lehrer */
teaching -= i * 30;
change_effect(u, oldpotiontype[P_FOOL], -i);
@ -602,7 +602,7 @@ int learn_cmd(unit * u, order * ord)
const struct building_type *btype = b ? b->type : NULL;
if (btype && btype == bt_find("academy")) {
studycost = MAX(50, studycost * 2);
studycost = _max(50, studycost * 2);
}
}
@ -686,11 +686,11 @@ int learn_cmd(unit * u, order * ord)
if (studycost) {
int cost = studycost * u->number;
money = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, cost);
money = MIN(money, cost);
money = _min(money, cost);
}
if (money < studycost * u->number) {
studycost = p; /* Ohne Univertreurung */
money = MIN(money, studycost);
money = _min(money, studycost);
if (p > 0 && money < studycost * u->number) {
cmistake(u, ord, 65, MSG_EVENT);
multi = money / (double)(studycost * u->number);
@ -709,12 +709,12 @@ int learn_cmd(unit * u, order * ord)
}
if (get_effect(u, oldpotiontype[P_WISE])) {
l = MIN(u->number, get_effect(u, oldpotiontype[P_WISE]));
l = _min(u->number, get_effect(u, oldpotiontype[P_WISE]));
teach->value += l * 10;
change_effect(u, oldpotiontype[P_WISE], -l);
}
if (get_effect(u, oldpotiontype[P_FOOL])) {
l = MIN(u->number, get_effect(u, oldpotiontype[P_FOOL]));
l = _min(u->number, get_effect(u, oldpotiontype[P_FOOL]));
teach->value -= l * 30;
change_effect(u, oldpotiontype[P_FOOL], -l);
}

View File

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

View File

@ -1,15 +0,0 @@
#if HAVE_STDBOOL_H
# include <stdbool.h>
#else
# if ! HAVE__BOOL
# ifdef __cplusplus
typedef bool _Bool;
# else
typedef unsigned char _Bool;
# endif
# endif
# define bool _Bool
# define false 0
# define true 1
# define __bool_true_false_are_defined 1
#endif

View File

@ -29,15 +29,11 @@ extern "C" {
extern int *intlist_add(int *i_p, int i);
extern int *intlist_find(int *i_p, int i);
#ifdef HAVE_INLINE
# include "strings.c"
#else
extern unsigned int hashstring(const char *s);
extern const char *escape_string(const char *str, char *buffer,
unsigned int len);
extern unsigned int jenkins_hash(unsigned int a);
extern unsigned int wang_hash(unsigned int a);
#endif
/* benchmark for units:
* JENKINS_HASH: 5.25 misses/hit (with good cache behavior)

View File

@ -75,17 +75,17 @@ cp_convert(const char *format, char *buffer, size_t length, int codepage)
void log_rotate(const char *filename, int maxindex)
{
int n;
if (_access(filename, _A_RDONLY)==0) {
if (_access(filename, 4)==0) {
char buffer[2][MAX_PATH];
int src = 1;
assert(strlen(filename)<sizeof(buffer[0])-4);
for(n=0;n<maxindex;++n) {
sprintf(buffer[0], "%s.%d", filename, n);
if (_access(filename, _A_RDONLY)!=0) {
if (_access(filename, 0)!=0) {
break;
}
}
if (_access(buffer[0], _A_RDONLY)==0) {
if (_access(buffer[0], 0)==0) {
unlink(buffer[0]);
}
while(n--) {

View File

@ -21,7 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* libc includes */
#include <string.h>
INLINE_FUNCTION unsigned int hashstring(const char *s)
unsigned int hashstring(const char *s)
{
unsigned int key = 0;
while (*s) {
@ -30,7 +30,7 @@ INLINE_FUNCTION unsigned int hashstring(const char *s)
return key & 0x7FFFFFFF;
}
INLINE_FUNCTION const char *escape_string(const char *str, char *buffer,
const char *escape_string(const char *str, char *buffer,
unsigned int len)
{
const char *start = strchr(str, '\"');
@ -69,7 +69,7 @@ INLINE_FUNCTION const char *escape_string(const char *str, char *buffer,
return str;
}
INLINE_FUNCTION unsigned int jenkins_hash(unsigned int a)
unsigned int jenkins_hash(unsigned int a)
{
a = (a + 0x7ed55d16) + (a << 12);
a = (a ^ 0xc761c23c) ^ (a >> 19);
@ -80,7 +80,7 @@ INLINE_FUNCTION unsigned int jenkins_hash(unsigned int a)
return a;
}
INLINE_FUNCTION unsigned int wang_hash(unsigned int a)
unsigned int wang_hash(unsigned int a)
{
a = ~a + (a << 15); /* a = (a << 15) - a - 1; */
a = a ^ (a >> 12);

7
vs2010-build.bat Normal file
View File

@ -0,0 +1,7 @@
@ECHO OFF
SET VSVERSION=10
SET ERESSEA=%Userprofile%/Documents/Eressea
mkdir build-vs%VSVERSION%
cd build-vs%VSVERSION%
"%ProgramFiles(x86)%\CMake 2.8\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%ERESSEA%/server/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..

View File

@ -1,4 +1,7 @@
@ECHO OFF
mkdir build-vs11
cd build-vs11
"c:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -G "Visual Studio 11" -DCMAKE_PREFIX_PATH="C:/Program Files (x86)/Lua/5.1;C:/Users/Enno/Documents/Eressea/dependencies-win32" -DCMAKE_MODULE_PATH="C:/Users/Enno/Documents/Eressea/server/cmake/Modules" ..
SET VSVERSION=11
SET ERESSEA=%Userprofile%/Documents/Eressea
mkdir build-vs%VSVERSION%
cd build-vs%VSVERSION%
"%ProgramFiles(x86)%\CMake 2.8\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%ERESSEA%/server/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..

7
vs2013-build.bat Normal file
View File

@ -0,0 +1,7 @@
@ECHO OFF
SET VSVERSION=12
SET ERESSEA=%Userprofile%/Documents/Eressea
mkdir build-vs%VSVERSION%
cd build-vs%VSVERSION%
"%ProgramFiles(x86)%\CMake 2.8\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%ERESSEA%/server/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..