From 5dcbb8a3f423a07b4ed600b0e52328ea5853fdc8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 7 Aug 2016 10:28:09 +0200 Subject: [PATCH 001/675] add a very simple tst for unicode comparisons --- src/util/unicode.test.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index 958b695e2..3aff3a3a3 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -16,9 +16,17 @@ static void test_unicode_tolower(CuTest * tc) CuAssertStrEquals(tc, "helloX", buffer); } +static void test_unicode_compare(CuTest *tc) +{ + CuAssertIntEquals(tc, 0, unicode_utf8_strcasecmp("ABCDEFG", "abcdefg")); + CuAssertIntEquals(tc, 0, unicode_utf8_strcasecmp("abcdefg123", "ABCDEFG123")); + CuAssertIntEquals(tc, 1, unicode_utf8_strcasecmp("bacdefg123", "ABCDEFG123")); +} + CuSuite *get_unicode_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_unicode_tolower); + SUITE_ADD_TEST(suite, test_unicode_compare); return suite; } From 98d1fb935cae99ef3822d2323c06524543d92e31 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 4 Sep 2016 22:00:37 +0100 Subject: [PATCH 002/675] Feature: ships that FOLLOW or use PIRACY are not affected by storms. --- src/move.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/move.c b/src/move.c index c95775b5a..3e49d2dd3 100644 --- a/src/move.c +++ b/src/move.c @@ -1791,7 +1791,7 @@ bool can_takeoff(const ship * sh, const region * from, const region * to) return true; } -static void sail(unit * u, order * ord, region_list ** routep) +static void sail(unit * u, order * ord, region_list ** routep, bool drifting) { region *starting_point = u->region; region *current_point, *last_point; @@ -1801,8 +1801,8 @@ static void sail(unit * u, order * ord, region_list ** routep) faction *f = u->faction; region *next_point = NULL; int error; - double damage_storm = config_get_flt("rules.ship.damage_storm", 0.02); - bool storms_enabled = config_get_int("rules.ship.storms", 1) != 0; + bool storms_enabled = drifting && (config_get_int("rules.ship.storms", 1) != 0); + double damage_storm = storms_enabled ? config_get_flt("rules.ship.damage_storm", 0.02) : 0.0; int lighthouse_div = config_get_int("rules.storm.lighthouse.divisor", 0); const char *token = getstrtoken(); @@ -2278,7 +2278,8 @@ void move_cmd(unit * u, order * ord) assert(u->number); if (u->ship && u == ship_owner(u->ship)) { - sail(u, ord, &route); + bool drifting = (getkeyword(ord) == K_MOVE); + sail(u, ord, &route, drifting); } else { travel(u, &route); From a4498f8b433532170214cc76a24ee97a05d70b96 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 11 Sep 2016 21:27:46 +0200 Subject: [PATCH 003/675] require at least 2K peasants in starting regions --- scripts/eressea/autoseed.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/eressea/autoseed.lua b/scripts/eressea/autoseed.lua index d0f83b6d3..2441c7079 100644 --- a/scripts/eressea/autoseed.lua +++ b/scripts/eressea/autoseed.lua @@ -3,6 +3,8 @@ local autoseed = {} -- minimum required resources in the 7-hex neighborhood: local peasants = 10000 local trees = 800 +-- minimum resources in the region itself: +local min_peasants = 2000 -- number of starters per region: local per_region = 2 @@ -23,11 +25,13 @@ local function select_regions(regions, peasants, trees) local sel = {} for r in regions do if not r.plane and r.terrain~="ocean" and not r.units() then - sp = score(r, "peasant") - st = score(r, "tree") - if sp >= peasants then - if st >= trees then - table.insert(sel, r) + if r:get_resource("peasant") >= min_peasants then + sp = score(r, "peasant") + st = score(r, "tree") + if sp >= peasants then + if st >= trees then + table.insert(sel, r) + end end end end From 84bc6c58a83b393f6c6d170f8aaa3217fdbfad5d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 12 Sep 2016 15:59:22 +0200 Subject: [PATCH 004/675] prepare_reports gone prepare_seen is something else now unit tests are crashing --- src/reports.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/reports.c b/src/reports.c index 06408d96e..07657e757 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1367,17 +1367,14 @@ static void cb_add_seen(region *r, unit *u, void *cbdata) { } } -static void prepare_reports(void) +void prepare_seen(faction *f) { region *r; - faction *f; building *b; const struct building_type *bt_lighthouse = bt_find("lighthouse"); - for (f = factions; f; f = f->next) { - if (f->seen) seen_done(f->seen); - f->seen = seen_init(); - } + if (f->seen) seen_done(f->seen); + f->seen = seen_init(); for (r = regions; r; r = r->next) { unit *u; @@ -1498,20 +1495,6 @@ static void cb_view_neighbours(seen_region *sr, void *cbdata) { } } -void prepare_seen(faction *f) -{ - region *r; - struct seen_region *sr; - - for (r = f->first, sr = NULL; sr == NULL && r != f->last; r = r->next) { - sr = find_seen(f->seen, r); - } - - seenhash_map(f->seen, cb_view_neighbours, f); - get_seen_interval(f->seen, &f->first, &f->last); - link_seen(f->seen, f->first, f->last); -} - static void prepare_report(struct report_context *ctx, faction *f) { prepare_seen(f); @@ -1609,7 +1592,6 @@ int init_reports(void) { check_messages_exist(); create_directories(); - prepare_reports(); return 0; } From a67950433d6eb75622810a35d88da315e22237e2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 12 Sep 2016 22:03:16 +0200 Subject: [PATCH 005/675] WIP: prepare_seen vs lastregion/firstregion. lighthouses and travelthru are handled by both, should only be in prepare_seen? --- src/creport.c | 4 +- src/kernel/faction.h | 1 - src/kernel/region.h | 3 + src/kernel/types.h | 11 +++ src/kernel/unit.h | 1 - src/reports.c | 190 +++++++++++++++++++++---------------------- src/reports.h | 12 ++- src/seen.c | 29 ------- src/seen.h | 10 --- src/seen.test.c | 16 ++-- 10 files changed, 124 insertions(+), 153 deletions(-) diff --git a/src/creport.c b/src/creport.c index 4cf778f23..0cb69af43 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1165,13 +1165,13 @@ int seemode, FILE * F) } static void -cr_output_resources(FILE * F, report_context * ctx, seen_region * sr) +cr_output_resources(FILE * F, report_context * ctx, seen_region * sr, bool see_unit) { char cbuf[BUFFERSIZE], *pos = cbuf; const region *r = sr->r; faction *f = ctx->f; resource_report result[MAX_RAWMATERIALS]; - int n, size = report_resources(sr, result, MAX_RAWMATERIALS, f); + int n, size = report_resources(sr, result, MAX_RAWMATERIALS, f, see_unit); #ifdef RESOURCECOMPAT int trees = rtrees(r, 2); diff --git a/src/kernel/faction.h b/src/kernel/faction.h index 5a1ca893b..80a71da48 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -100,7 +100,6 @@ extern "C" { struct message_list *msgs; } *battles; struct item *items; /* items this faction can claim */ - struct seen_region **seen; struct quicklist *seen_factions; bool _alive; /* enno: sollte ein flag werden */ } faction; diff --git a/src/kernel/region.h b/src/kernel/region.h index bbc5282b0..01f1c0ae9 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -137,6 +137,9 @@ extern "C" { #ifdef FAST_CONNECT struct region *connect[MAXDIRECTIONS]; /* use rconnect(r, dir) to access */ #endif + struct { + seen_mode mode; + } seen; } region; extern struct region *regions; diff --git a/src/kernel/types.h b/src/kernel/types.h index 632dad425..e0521635e 100644 --- a/src/kernel/types.h +++ b/src/kernel/types.h @@ -73,6 +73,17 @@ typedef struct ursprung { int x, y; } ursprung; +/* seen_mode: visibility in the report */ +typedef enum { + seen_none, + seen_neighbour, + seen_lighthouse, + seen_travel, + seen_far, + seen_unit, + seen_battle +} seen_mode; + /* ------------------ Status von Einheiten --------------------- */ typedef unsigned char status_t; diff --git a/src/kernel/unit.h b/src/kernel/unit.h index 459d0b656..32e48a950 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -36,7 +36,6 @@ extern "C" { #define UFL_LONGACTION (1<<2) /* 4 */ #define UFL_OWNER (1<<3) /* 8 */ #define UFL_ANON_FACTION (1<<4) /* 16 */ -#define UFL_DISBELIEVES (1<<5) /* 32 */ #define UFL_WARMTH (1<<6) /* 64 */ #define UFL_HERO (1<<7) #define UFL_MOVED (1<<8) diff --git a/src/reports.c b/src/reports.c index 07657e757..053ad3e2b 100644 --- a/src/reports.c +++ b/src/reports.c @@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "reports.h" #include "laws.h" -#include "seen.h" #include "travelthru.h" #include "lighthouse.h" #include "donations.h" @@ -368,10 +367,9 @@ const char **illusion) } int -report_resources(const seen_region * sr, resource_report * result, int size, -const faction * viewer) +report_resources(const region * r, resource_report * result, int size, +const faction * viewer, bool see_unit) { - const region *r = sr->r; int n = 0; if (r->land) { @@ -416,7 +414,7 @@ const faction * viewer) } } - if (sr->mode >= see_unit) { + if (see_unit) { rawmaterial *res = r->resources; while (res) { int maxskill = 0; @@ -452,14 +450,14 @@ const faction * viewer) } int -bufunit(const faction * f, const unit * u, unsigned int indent, int mode, char *buf, +bufunit(const faction * f, const unit * u, unsigned int indent, seen_mode mode, char *buf, size_t size) { int i, dh; int getarnt = fval(u, UFL_ANON_FACTION); const char *pzTmp, *str; building *b; - bool isbattle = (bool)(mode == see_battle); + bool isbattle = (bool)(mode == seen_battle); item *itm, *show = NULL; faction *fv = visible_faction(f, u); char *bufp = buf; @@ -596,7 +594,7 @@ size_t size) if (f == u->faction || omniscient(f)) { show = u->items; } - else if (mode >= see_unit) { + else if (mode >= seen_unit) { int n = report_items(u, results, MAX_INVENTORY, u, f); assert(n >= 0); if (n > 0) { @@ -890,7 +888,7 @@ void lparagraph(struct strlist **SP, char *s, unsigned int indent, char mark) void spunit(struct strlist **SP, const struct faction *f, const unit * u, unsigned int indent, -int mode) +seen_mode mode) { char buf[DISPLAYSIZE]; int dh = bufunit(f, u, indent, mode, buf, sizeof(buf)); @@ -929,15 +927,15 @@ const struct unit *ucansee(const struct faction *f, const struct unit *u, return x; } -int stealth_modifier(int seen_mode) +int stealth_modifier(seen_mode mode) { - switch (seen_mode) { - case see_unit: + switch (mode) { + case seen_unit: return 0; - case see_far: - case see_lighthouse: + case seen_far: + case seen_lighthouse: return -2; - case see_travel: + case seen_travel: return -1; default: return INT_MIN; @@ -1003,7 +1001,6 @@ static void add_travelthru_addresses(region *r, faction *f, quicklist **flist, i static void get_addresses(report_context * ctx) { /* "TODO: travelthru" */ - seen_region *sr = NULL; region *r; const faction *lastf = NULL; quicklist *flist = 0; @@ -1022,14 +1019,13 @@ static void get_addresses(report_context * ctx) } /* find the first region that this faction can see */ - for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) { - sr = find_seen(ctx->f->seen, r); + for (r = ctx->first; r != ctx->last; r = r->next) { + if (r->seen.mode > seen_none) break; } - for (; sr != NULL; sr = sr->next) { - int stealthmod = stealth_modifier(sr->mode); - r = sr->r; - if (sr->mode == see_lighthouse) { + for (; r != NULL; r = r->next) { + int stealthmod = stealth_modifier(r->seen.mode); + if (r->seen.mode == seen_lighthouse) { unit *u = r->units; for (; u; u = u->next) { faction *sf = visible_faction(ctx->f, u); @@ -1042,12 +1038,12 @@ static void get_addresses(report_context * ctx) } } } - else if (sr->mode == see_travel) { + else if (r->seen.mode == seen_travel) { /* when we travel through a region, then we must add * the factions of any units we saw */ add_travelthru_addresses(r, ctx->f, &flist, stealthmod); } - else if (sr->mode > see_travel) { + else if (r->seen.mode > seen_travel) { const unit *u = r->units; while (u != NULL) { if (u->faction != ctx->f) { @@ -1133,7 +1129,20 @@ static quicklist *get_regions_distance(region * root, int radius) return rlist; } -void view_default(struct seen_region **seen, region * r, faction * f) +static void add_seen(region *r, seen_mode mode) { + if (r->seen.mode < mode) { + r->seen.mode = mode; + } +} + +static void faction_add_seen(faction *f, region *r, seen_mode mode) { + add_seen(r, mode); +#ifdef SMART_INTERVALS + update_interval(f, r); +#endif +} + +static void view_default(region * r, faction * f) { int dir; for (dir = 0; dir != MAXDIRECTIONS; ++dir) { @@ -1145,8 +1154,9 @@ void view_default(struct seen_region **seen, region * r, faction * f) break; b = b->next; } - if (!b) - add_seen(seen, r2, see_neighbour, false); + if (!b) { + add_seen(r2, seen_neighbour); + } } } } @@ -1167,20 +1177,20 @@ void view_neighbours(struct seen_region **seen, region * r, faction * f) b = b->next; } if (!b) { - if (add_seen(seen, r2, see_far, false)) { - if (!(fval(r2->terrain, FORBIDDEN_REGION))) { - int dir; - for (dir = 0; dir != MAXDIRECTIONS; ++dir) { - region *r3 = rconnect(r2, dir); - if (r3) { - connection *b = get_borders(r2, r3); - while (b) { - if (!b->type->transparent(b, f)) - break; - b = b->next; - } - if (!b) - add_seen(seen, r3, see_neighbour, false); + add_seen(r2, seen_far); + if (!(fval(r2->terrain, FORBIDDEN_REGION))) { + int dir; + for (dir = 0; dir != MAXDIRECTIONS; ++dir) { + region *r3 = rconnect(r2, dir); + if (r3) { + connection *b = get_borders(r2, r3); + while (b) { + if (!b->type->transparent(b, f)) + break; + b = b->next; + } + if (!b) { + add_seen(r3, seen_neighbour); } } } @@ -1191,8 +1201,7 @@ void view_neighbours(struct seen_region **seen, region * r, faction * f) } static void -recurse_regatta(struct seen_region **seen, region * center, region * r, -faction * f, int maxdist) +recurse_regatta(region * center, region * r, faction * f, int maxdist) { int d; int dist = distance(center, r); @@ -1212,19 +1221,19 @@ faction * f, int maxdist) } if (!b) { if (ndist < maxdist) { - if (add_seen(seen, r2, see_far, false)) { - recurse_regatta(seen, center, r2, f, maxdist); - } + add_seen(r2, seen_far); + recurse_regatta(center, r2, f, maxdist); + } + else { + add_seen(r2, seen_neighbour); } - else - add_seen(seen, r2, see_neighbour, false); } } } } } -static void view_regatta(struct seen_region **seen, region * r, faction * f) +static void view_regatta(region * r, faction * f) { unit *u; int skill = 0; @@ -1235,10 +1244,12 @@ static void view_regatta(struct seen_region **seen, region * r, faction * f) skill = es; } } - recurse_regatta(seen, r, r, f, skill / 2); + recurse_regatta(r, r, f, skill / 2); } -static void prepare_lighthouse(building * b, faction * f) +/** mark all regions seen by the lighthouse. + */ +static void prepare_lighthouse(building * b, faction *f) { int range = lighthouse_range(b, f); quicklist *ql, *rlist = get_regions_distance(b->region, range); @@ -1251,10 +1262,10 @@ static void prepare_lighthouse(building * b, faction * f) int d; get_neighbours(rl, next); - faction_add_seen(f, rl, see_lighthouse); + faction_add_seen(f, rl, seen_lighthouse); for (d = 0; d != MAXDIRECTIONS; ++d) { if (next[d]) { - faction_add_seen(f, next[d], see_neighbour); + faction_add_seen(f, next[d], seen_neighbour); } } } @@ -1362,37 +1373,40 @@ void reorder_units(region * r) static void cb_add_seen(region *r, unit *u, void *cbdata) { unused_arg(cbdata); - if (u->faction) { - faction_add_seen(u->faction, r, see_travel); - } + faction_add_seen(u->faction, r, seen_travel); } -void prepare_seen(faction *f) +/** set region.seen based on visibility by one faction. + * + * this function may also update f->last and f->first for potential + * lighthouses and travelthru reports + */ +void prepare_seen(report_context *ctx) { + faction *f = ctx->f; region *r; building *b; + static int config; + static bool rule_region_owners; const struct building_type *bt_lighthouse = bt_find("lighthouse"); - if (f->seen) seen_done(f->seen); - f->seen = seen_init(); - - for (r = regions; r; r = r->next) { + if (config_changed(&config)) { + rule_region_owners = config_token("rules.region_owner_pay_building", bt_lighthouse->_name); + } + for (r = ctx->first; r!=ctx->last; r = r->next) { unit *u; reorder_units(r); - /* Region owner get always the Lighthouse report */ - if (bt_lighthouse && config_token("rules.region_owner_pay_building", bt_lighthouse->_name)) { + /* region owner get the report from lighthouses */ + if (fval(r, RF_LIGHTHOUSE) && rule_region_owners && bt_lighthouse) { for (b = rbuildings(r); b; b = b->next) { if (b && b->type == bt_lighthouse) { u = building_owner(b); - if (u) { - prepare_lighthouse(b, u->faction); + if (u && u->faction==f) { + prepare_lighthouse(b, f); if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { - seen_region *sr = faction_add_seen(u->faction, r, see_unit); - if (fval(u, UFL_DISBELIEVES)) { - sr->disbelieves = true; - } + faction_add_seen(f, r, seen_unit); } } } @@ -1406,10 +1420,7 @@ void prepare_seen(faction *f) } if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { - seen_region *sr = faction_add_seen(u->faction, r, see_unit); - if (fval(u, UFL_DISBELIEVES)) { - sr->disbelieves = true; - } + faction_add_seen(f, r, seen_unit); } } @@ -1480,30 +1491,23 @@ static region *firstregion(faction * f) #endif } -static void cb_view_neighbours(seen_region *sr, void *cbdata) { - faction *f = (faction *)cbdata; - if (sr->mode > see_neighbour) { - region *r = sr->r; - plane *p = rplane(r); - void(*view) (struct seen_region **, region *, faction *) = view_default; - - if (p && fval(p, PFL_SEESPECIAL)) { - /* TODO: this is not very customizable */ - view = (strcmp(p->name, "Regatta") == 0) ? view_regatta : view_neighbours; - } - view(f->seen, r, f); - } -} - -static void prepare_report(struct report_context *ctx, faction *f) +static void prepare_report(report_context *ctx, faction *f) { - prepare_seen(f); ctx->f = f; ctx->report_time = time(NULL); ctx->addresses = NULL; ctx->userdata = NULL; ctx->first = firstregion(f); ctx->last = lastregion(f); + prepare_seen(&ctx); +} + +static void finish_reports(report_context *ctx) { + region *r; + ql_free(ctx->addresses); + for (r = ctx->first; r != ctx->last; r = r->next) { + r->seen.mode = seen_none; + } } int write_reports(faction * f, time_t ltime) @@ -1551,10 +1555,7 @@ int write_reports(faction * f, time_t ltime) if (!gotit) { log_warning("No report for faction %s!", factionid(f)); } - ql_free(ctx.addresses); - if (ctx.f->seen) { - seen_done(ctx.f->seen); - } + finish_reports(&ctx); return 0; } @@ -1623,7 +1624,6 @@ int reports(void) } if (mailit) fclose(mailit); - free_seen(); return retval; } diff --git a/src/reports.h b/src/reports.h index 584fe7d4a..11ec4b580 100644 --- a/src/reports.h +++ b/src/reports.h @@ -54,7 +54,7 @@ extern "C" { const char *hp_status(const struct unit *u); size_t spskill(char *pbuf, size_t siz, const struct locale *lang, const struct unit *u, struct skill *sv, int *dh, int days); /* mapper */ void spunit(struct strlist **SP, const struct faction *f, - const struct unit *u, unsigned int indent, int mode); + const struct unit *u, unsigned int indent, seen_mode mode); void prepare_seen(struct faction *f); int reports(void); @@ -65,7 +65,7 @@ extern "C" { const struct unit *ucansee(const struct faction *f, const struct unit *u, const struct unit *x); - int stealth_modifier(int seen_mode); + int stealth_modifier(seen_mode seen_mode); typedef struct report_context { struct faction *f; @@ -81,7 +81,7 @@ extern "C" { int flag); int bufunit(const struct faction *f, const struct unit *u, unsigned int indent, - int mode, char *buf, size_t size); + seen_mode mode, char *buf, size_t size); const char *trailinto(const struct region *r, const struct locale *lang); @@ -103,10 +103,8 @@ extern "C" { int number; int level; } resource_report; - void view_default(struct seen_region **seen, struct region * r, struct faction * f); - void view_neighbours(struct seen_region **seen, struct region * r, struct faction * f); - int report_resources(const struct seen_region *sr, - struct resource_report *result, int size, const struct faction *viewer); + int report_resources(const struct region *r, struct resource_report *res, + int size, const struct faction *viewer, bool see_unit); int report_items(const struct unit *u, struct item *result, int size, const struct unit *owner, const struct faction *viewer); void report_item(const struct unit *owner, const struct item *i, diff --git a/src/seen.c b/src/seen.c index 928b3f55e..dcafa425e 100644 --- a/src/seen.c +++ b/src/seen.c @@ -137,32 +137,3 @@ void get_seen_interval(struct seen_region *seen[], struct region **firstp, struc *firstp = interval.first; *lastp = interval.last; } - -seen_region *add_seen(struct seen_region *seehash[], struct region *r, seen_t mode, bool dis) -{ - seen_region *find = find_seen(seehash, r); - if (find == NULL) { - unsigned int index = reg_hashkey(r) & (MAXSEEHASH - 1); - if (!reuse) - reuse = (seen_region *)calloc(1, sizeof(struct seen_region)); - find = reuse; - reuse = reuse->nextHash; - find->nextHash = seehash[index]; - find->mode = mode; - seehash[index] = find; - find->r = r; - } - else if (find->mode < mode) { - find->mode = mode; - } - find->disbelieves |= dis; - return find; -} - -seen_region *faction_add_seen(faction *f, region *r, seen_t mode) { - assert(f->seen); -#ifdef SMART_INTERVALS - update_interval(f, r); -#endif - return add_seen(f->seen, r, mode, false); -} diff --git a/src/seen.h b/src/seen.h index 1f0197cc7..abf062c2e 100644 --- a/src/seen.h +++ b/src/seen.h @@ -28,16 +28,6 @@ struct seen_region; extern "C" { #endif - typedef enum { - see_none, - see_neighbour, - see_lighthouse, - see_travel, - see_far, - see_unit, - see_battle - } seen_t; - typedef struct seen_region { struct seen_region *nextHash; struct seen_region *next; diff --git a/src/seen.test.c b/src/seen.test.c index e3e1265bd..287ee00fe 100644 --- a/src/seen.test.c +++ b/src/seen.test.c @@ -190,13 +190,13 @@ static void test_seenhash_map(CuTest *tc) { CuSuite *get_seen_suite(void) { CuSuite *suite = CuSuiteNew(); - SUITE_ADD_TEST(suite, test_prepare_seen); - SUITE_ADD_TEST(suite, test_seen_travelthru); - SUITE_ADD_TEST(suite, test_add_seen); - SUITE_ADD_TEST(suite, test_faction_add_seen); - SUITE_ADD_TEST(suite, test_seen_region); - SUITE_ADD_TEST(suite, test_seen_interval_backward); - SUITE_ADD_TEST(suite, test_seen_interval_forward); - SUITE_ADD_TEST(suite, test_seenhash_map); + DISABLE_TEST(suite, test_prepare_seen); + DISABLE_TEST(suite, test_seen_travelthru); + DISABLE_TEST(suite, test_add_seen); + DISABLE_TEST(suite, test_faction_add_seen); + DISABLE_TEST(suite, test_seen_region); + DISABLE_TEST(suite, test_seen_interval_backward); + DISABLE_TEST(suite, test_seen_interval_forward); + DISABLE_TEST(suite, test_seenhash_map); return suite; } From 652ead4f60226c6aebb158c656c348a0e4225e68 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Sep 2016 07:46:08 +0200 Subject: [PATCH 006/675] prepare_seen has to check for ctx->f. we are no longer preparing everyone at once --- src/reports.c | 82 +++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 52 deletions(-) diff --git a/src/reports.c b/src/reports.c index 053ad3e2b..c895d98ed 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1249,8 +1249,9 @@ static void view_regatta(region * r, faction * f) /** mark all regions seen by the lighthouse. */ -static void prepare_lighthouse(building * b, faction *f) +static void prepare_lighthouse(building * b, report_context *ctx) { + faction *f = ctx->f; int range = lighthouse_range(b, f); quicklist *ql, *rlist = get_regions_distance(b->region, range); int qi; @@ -1378,7 +1379,7 @@ static void cb_add_seen(region *r, unit *u, void *cbdata) { /** set region.seen based on visibility by one faction. * - * this function may also update f->last and f->first for potential + * this function may also update ctx->last and ctx->first for potential * lighthouses and travelthru reports */ void prepare_seen(report_context *ctx) @@ -1398,35 +1399,40 @@ void prepare_seen(report_context *ctx) reorder_units(r); - /* region owner get the report from lighthouses */ - if (fval(r, RF_LIGHTHOUSE) && rule_region_owners && bt_lighthouse) { - for (b = rbuildings(r); b; b = b->next) { - if (b && b->type == bt_lighthouse) { - u = building_owner(b); - if (u && u->faction==f) { - prepare_lighthouse(b, f); - if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { - faction_add_seen(f, r, seen_unit); + if (fval(r, RF_LIGHTHOUSE)) { + /* region owners get the report from lighthouses */ + if (rule_region_owners && bt_lighthouse) { + for (b = rbuildings(r); b; b = b->next) { + if (b && b->type == bt_lighthouse) { + u = building_owner(b); + if (u && u->faction==f) { + prepare_lighthouse(b, ctx); + if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { + faction_add_seen(f, r, seen_unit); + } } } } } + + } + for (u = r->units; u; u = u->next) { + if (u->faction==f) { + if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { + faction_add_seen(f, r, seen_unit); + } + if (fval(r, RF_LIGHTHOUSE) { + // TODO: is the building big enough for the unit? + if (u->building && u->building->type == bt_lighthouse) { + /* we are in a lighthouse. add the regions we can see from here! */ + prepare_lighthouse(u->building, ctx); + } + } + } } - for (u = r->units; u; u = u->next) { - if (u->building && u->building->type == bt_lighthouse) { - /* we are in a lighthouse. add the regions we can see from here! */ - prepare_lighthouse(u->building, u->faction); - } - - if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { - faction_add_seen(f, r, seen_unit); - } - } - - if (fval(r, RF_TRAVELUNIT)) { - travelthru_map(r, cb_add_seen, r); + travelthru_map(r, cb_add_seen, ctx); } } } @@ -1441,34 +1447,6 @@ static void cb_set_last(region *r, unit *u, void *cbdata) { static region *lastregion(faction * f) { #ifdef SMART_INTERVALS - unit *u = f->units; - region *r = f->last; - - if (u == NULL) - return NULL; - if (r != NULL) - return r->next; - - /* it is safe to start in the region of the first unit. */ - f->last = u->region; - /* if regions have indices, we can skip ahead: */ - for (u = u->nextF; u != NULL; u = u->nextF) { - r = u->region; - if (r->index > f->last->index) - f->last = r; - } - - /* we continue from the best region and look for travelthru etc. */ - for (r = f->last->next; r; r = r->next) { - /* search the region for travelthru-attributes: */ - if (fval(r, RF_TRAVELUNIT)) { - travelthru_map(r, cb_set_last, f); - } - if (f->last == r) - continue; - if (check_leuchtturm(r, f)) - f->last = r; - } return f->last->next; #else return NULL; From 71fa3600f77f6e275f7576fe146268711e4eef63 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Sep 2016 09:09:35 +0200 Subject: [PATCH 007/675] recalculate [first,last) after lighthouses aand trvelthru --- src/CMakeLists.txt | 2 -- src/alchemy.c | 3 ++- src/battle.c | 3 +-- src/creport.c | 1 - src/reports.c | 64 +++++++++++++++++++++++++--------------------- src/reports.h | 3 ++- 6 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f1414c851..31a434ad5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,7 +96,6 @@ set (ERESSEA_SRC guard.c prefix.c donations.c - seen.c eressea.c callback.c direction.c @@ -197,7 +196,6 @@ set(TESTS_SRC tests.test.c volcano.test.c reports.test.c - seen.test.c summary.test.c travelthru.test.c callback.test.c diff --git a/src/alchemy.c b/src/alchemy.c index cf4dc6f73..89b00c5f0 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -170,7 +170,8 @@ static int potion_luck(unit *u, region *r, attrib_type *atype, int amount) { } static int potion_truth(unit *u) { - fset(u, UFL_DISBELIEVES); + // TODO: this potion does nothing! + // fset(u, UFL_DISBELIEVES); return 1; } diff --git a/src/battle.c b/src/battle.c index 392b24441..e3e74ab82 100644 --- a/src/battle.c +++ b/src/battle.c @@ -23,7 +23,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "chaos.h" #include "move.h" #include "laws.h" -#include "seen.h" #include "skill.h" #include "monster.h" @@ -2884,7 +2883,7 @@ static void battle_punit(unit * u, battle * b) faction *f = bf->faction; strlist *S = 0, *x; - spunit(&S, f, u, 4, see_battle); + spunit(&S, f, u, 4, seen_battle); for (x = S; x; x = x->next) { fbattlerecord(b, f, x->s); if (bdebug && u->faction == f) { diff --git a/src/creport.c b/src/creport.c index 0cb69af43..f0d545de1 100644 --- a/src/creport.c +++ b/src/creport.c @@ -11,7 +11,6 @@ without prior permission by the authors of Eressea. #include #include #include "creport.h" -#include "seen.h" #include "travelthru.h" /* tweakable features */ diff --git a/src/reports.c b/src/reports.c index c895d98ed..8637586bc 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1372,6 +1372,31 @@ void reorder_units(region * r) } } +static region *lastregion(faction * f) +{ +#ifdef SMART_INTERVALS + return f->last->next; +#else + return NULL; +#endif +} + +static region *firstregion(faction * f) +{ +#ifdef SMART_INTERVALS + region *r = f->first; + + if (f->units == NULL) + return NULL; + if (r != NULL) + return r; + + return f->first = regions; +#else + return regions; +#endif +} + static void cb_add_seen(region *r, unit *u, void *cbdata) { unused_arg(cbdata); faction_add_seen(u->faction, r, seen_travel); @@ -1391,6 +1416,9 @@ void prepare_seen(report_context *ctx) static bool rule_region_owners; const struct building_type *bt_lighthouse = bt_find("lighthouse"); + // [fast,last) interval of regions with a unit in it + ctx->first = firstregion(f); + ctx->last = lastregion(f); if (config_changed(&config)) { rule_region_owners = config_token("rules.region_owner_pay_building", bt_lighthouse->_name); } @@ -1421,7 +1449,7 @@ void prepare_seen(report_context *ctx) if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { faction_add_seen(f, r, seen_unit); } - if (fval(r, RF_LIGHTHOUSE) { + if (fval(r, RF_LIGHTHOUSE)) { // TODO: is the building big enough for the unit? if (u->building && u->building->type == bt_lighthouse) { /* we are in a lighthouse. add the regions we can see from here! */ @@ -1435,6 +1463,11 @@ void prepare_seen(report_context *ctx) travelthru_map(r, cb_add_seen, ctx); } } + // [fast,last) interval of seen regions (with lighthouses and travel) + // TODO: what about neighbours? when are they included? do we need + // them outside of the CR? + ctx->first = firstregion(f); + ctx->last = lastregion(f); } static void cb_set_last(region *r, unit *u, void *cbdata) { @@ -1444,40 +1477,13 @@ static void cb_set_last(region *r, unit *u, void *cbdata) { } } -static region *lastregion(faction * f) -{ -#ifdef SMART_INTERVALS - return f->last->next; -#else - return NULL; -#endif -} - -static region *firstregion(faction * f) -{ -#ifdef SMART_INTERVALS - region *r = f->first; - - if (f->units == NULL) - return NULL; - if (r != NULL) - return r; - - return f->first = regions; -#else - return regions; -#endif -} - static void prepare_report(report_context *ctx, faction *f) { ctx->f = f; ctx->report_time = time(NULL); ctx->addresses = NULL; ctx->userdata = NULL; - ctx->first = firstregion(f); - ctx->last = lastregion(f); - prepare_seen(&ctx); + prepare_seen(ctx); } static void finish_reports(report_context *ctx) { diff --git a/src/reports.h b/src/reports.h index 11ec4b580..7e35d26f4 100644 --- a/src/reports.h +++ b/src/reports.h @@ -56,7 +56,6 @@ extern "C" { void spunit(struct strlist **SP, const struct faction *f, const struct unit *u, unsigned int indent, seen_mode mode); - void prepare_seen(struct faction *f); int reports(void); int write_reports(struct faction *f, time_t ltime); int init_reports(void); @@ -75,6 +74,8 @@ extern "C" { time_t report_time; } report_context; + void prepare_seen(struct report_context *ctx); + typedef int(*report_fun) (const char *filename, report_context * ctx, const char *charset); void register_reporttype(const char *extension, report_fun write, From f520d8396dbacc5f1348dec861f0c75dd9937e31 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Sep 2016 15:30:09 +0200 Subject: [PATCH 008/675] make creport not use seen_region. remove jsreport from build --- src/CMakeLists.txt | 1 - src/creport.c | 52 ++++++++++++++++++++-------------------------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 31a434ad5..4eaf3ca51 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,7 +103,6 @@ set (ERESSEA_SRC skill.c json.c creport.c - jsreport.c economy.c give.c items.c diff --git a/src/creport.c b/src/creport.c index f0d545de1..5d508612f 100644 --- a/src/creport.c +++ b/src/creport.c @@ -958,7 +958,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f, show = u->items; } else { - if (mode >= see_unit) { + if (mode >= seen_unit) { int n = report_items(u, result, MAX_INVENTORY, u, f); assert(n >= 0); if (n > 0) { @@ -1111,8 +1111,7 @@ static char *cr_output_resource(char *buf, const char *name, } static void -cr_borders(seen_region ** seen, const region * r, const faction * f, -int seemode, FILE * F) +cr_borders(const region * r, const faction * f, seen_mode mode, FILE * F) { direction_t d; int g = 0; @@ -1121,9 +1120,8 @@ int seemode, FILE * F) const connection *b; if (!r2) continue; - if (seemode == see_neighbour) { - seen_region *sr = find_seen(seen, r2); - if (sr == NULL || sr->mode <= see_neighbour) + if (mode == seen_neighbour) { + if (r2->seen.mode <= seen_neighbour) continue; } b = get_borders(r, r2); @@ -1164,13 +1162,12 @@ int seemode, FILE * F) } static void -cr_output_resources(FILE * F, report_context * ctx, seen_region * sr, bool see_unit) +cr_output_resources(FILE * F, report_context * ctx, region *r, bool see_unit) { char cbuf[BUFFERSIZE], *pos = cbuf; - const region *r = sr->r; faction *f = ctx->f; resource_report result[MAX_RAWMATERIALS]; - int n, size = report_resources(sr, result, MAX_RAWMATERIALS, f, see_unit); + int n, size = report_resources(r, result, MAX_RAWMATERIALS, f, see_unit); #ifdef RESOURCECOMPAT int trees = rtrees(r, 2); @@ -1256,10 +1253,9 @@ static void cr_output_travelthru(FILE *F, region *r, const faction *f) { travelthru_map(r, cb_cr_travelthru_unit, &cbdata); } -static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr) +static void cr_output_region(FILE * F, report_context * ctx, region * r) { faction *f = ctx->f; - region *r = sr->r; plane *pl = rplane(r); int plid = plane_id(pl), nx, ny; const char *tname; @@ -1267,7 +1263,7 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr) int uid = r->uid; #ifdef OCEAN_NEIGHBORS_GET_NO_ID - if (sr->mode <= see_neighbour && !r->land) { + if (r->seen.mode <= seen_neighbour && !r->land) { uid = 0; } #endif @@ -1316,16 +1312,16 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr) tname = terrain_name(r); fprintf(F, "\"%s\";Terrain\n", translate(tname, LOC(f->locale, tname))); - if (sr->mode != see_unit) - fprintf(F, "\"%s\";visibility\n", visibility[sr->mode]); - if (sr->mode == see_neighbour) { - cr_borders(ctx->f->seen, r, f, sr->mode, F); + if (r->seen.mode != seen_unit) + fprintf(F, "\"%s\";visibility\n", visibility[r->seen.mode]); + if (r->seen.mode == seen_neighbour) { + cr_borders(r, f, r->seen.mode, F); } else { building *b; ship *sh; unit *u; - int stealthmod = stealth_modifier(sr->mode); + int stealthmod = stealth_modifier(r->seen.mode); if (r->display && r->display[0]) fprintf(F, "\"%s\";Beschr\n", r->display); @@ -1337,7 +1333,7 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr) } fprintf(F, "%d;Pferde\n", rhorses(r)); - if (sr->mode >= see_unit) { + if (r->seen.mode >= seen_unit) { if (rule_region_owners()) { faction *owner = region_get_owner(r); if (owner) { @@ -1368,9 +1364,9 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr) /* this writes both some tags (RESOURCECOMPAT) and a block. * must not write any blocks before it */ - cr_output_resources(F, ctx, sr); + cr_output_resources(F, ctx, r, r->seen.mode >= seen_unit); - if (sr->mode >= see_unit) { + if (r->seen.mode >= seen_unit) { /* trade */ if (markets_module() && r->land) { const item_type *lux = r_luxury(r); @@ -1407,8 +1403,8 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr) print_items(F, r->land->items, f->locale); } cr_output_curses_compat(F, f, r, TYP_REGION); - cr_borders(ctx->f->seen, r, f, sr->mode, F); - if (sr->mode == see_unit && is_astral(r) + cr_borders(r, f, r->seen.mode, F); + if (r->seen.mode == seen_unit && is_astral(r) && !is_cursed(r->attribs, C_ASTRALBLOCK, 0)) { /* Sonderbehandlung Teleport-Ebene */ region_list *rl = astralregions(r, inhabitable); @@ -1431,7 +1427,7 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr) } cr_output_travelthru(F, r, f); - if (sr->mode == see_unit || sr->mode == see_travel) { + if (r->seen.mode == seen_unit || r->seen.mode == seen_travel) { message_list *mlist = r_getmessages(r, f); cr_output_messages(F, r->msgs, f); if (mlist) { @@ -1466,7 +1462,7 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr) if (u->building || u->ship || (stealthmod > INT_MIN && cansee(f, r, u, stealthmod))) { - cr_output_unit_compat(F, r, f, u, sr->mode); + cr_output_unit_compat(F, r, f, u, r->seen.mode); } } } @@ -1483,7 +1479,6 @@ report_computer(const char *filename, report_context * ctx, const char *charset) region *r; const char *mailto = LOC(f->locale, "mailto"); const attrib *a; - seen_region *sr = NULL; FILE *F = fopen(filename, "w"); if (era < 0) { @@ -1661,11 +1656,8 @@ report_computer(const char *filename, report_context * ctx, const char *charset) } /* traverse all regions */ - for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) { - sr = find_seen(ctx->f->seen, r); - } - for (; sr != NULL; sr = sr->next) { - cr_output_region(F, ctx, sr); + for (r = ctx->first; r != ctx->last; r = r->next) { + cr_output_region(F, ctx, r); } report_crtypes(F, f->locale); write_translations(F); From 20578da0e9daefea4fefe9501135fb4dfd261ce3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Sep 2016 16:58:48 +0200 Subject: [PATCH 009/675] delete the old seen.* files remove includes for seen.h remove unused functions --- src/bind_unit.c | 1 - src/bindings.c | 1 - src/jsreport.c | 1 - src/report.c | 1 - src/reports.c | 26 ------ src/reports.test.c | 1 - src/seen.c | 139 ------------------------------- src/seen.h | 52 ------------ src/seen.test.c | 202 --------------------------------------------- src/tests.c | 1 - 10 files changed, 425 deletions(-) delete mode 100644 src/seen.c delete mode 100644 src/seen.h delete mode 100644 src/seen.test.c diff --git a/src/bind_unit.c b/src/bind_unit.c index a7ba3fe96..c8d5557f0 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -18,7 +18,6 @@ without prior permission by the authors of Eressea. #include "bindings.h" #include "move.h" #include "reports.h" -#include "seen.h" #include "guard.h" /* attributes includes */ diff --git a/src/bindings.c b/src/bindings.c index 9d74719f7..d9dadbb79 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -26,7 +26,6 @@ without prior permission by the authors of Eressea. #include "helpers.h" #include "console.h" #include "reports.h" -#include "seen.h" #include "study.h" #include "calendar.h" diff --git a/src/jsreport.c b/src/jsreport.c index 4450d0165..d75b7919d 100644 --- a/src/jsreport.c +++ b/src/jsreport.c @@ -1,6 +1,5 @@ #include "reports.h" #include "jsreport.h" -#include "seen.h" #include #include #include diff --git a/src/report.c b/src/report.c index 2c79209b9..22dba29d8 100644 --- a/src/report.c +++ b/src/report.c @@ -22,7 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "reports.h" -#include "seen.h" #include "laws.h" #include "travelthru.h" #include "monster.h" diff --git a/src/reports.c b/src/reports.c index 8637586bc..81abb408a 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1142,25 +1142,6 @@ static void faction_add_seen(faction *f, region *r, seen_mode mode) { #endif } -static void view_default(region * r, faction * f) -{ - int dir; - for (dir = 0; dir != MAXDIRECTIONS; ++dir) { - region *r2 = rconnect(r, dir); - if (r2) { - connection *b = get_borders(r, r2); - while (b) { - if (!b->type->transparent(b, f)) - break; - b = b->next; - } - if (!b) { - add_seen(r2, seen_neighbour); - } - } - } -} - void view_neighbours(struct seen_region **seen, region * r, faction * f) { int d; @@ -1470,13 +1451,6 @@ void prepare_seen(report_context *ctx) ctx->last = lastregion(f); } -static void cb_set_last(region *r, unit *u, void *cbdata) { - faction *f = (faction *)cbdata; - if (u->faction == f) { - f->last = r; - } -} - static void prepare_report(report_context *ctx, faction *f) { ctx->f = f; diff --git a/src/reports.test.c b/src/reports.test.c index c27a0f6f9..887e04f0d 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -4,7 +4,6 @@ #include "report.h" #include "creport.h" #include "move.h" -#include "seen.h" #include "travelthru.h" #include "keyword.h" diff --git a/src/seen.c b/src/seen.c deleted file mode 100644 index dcafa425e..000000000 --- a/src/seen.c +++ /dev/null @@ -1,139 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#include -#include -#include "seen.h" - -#include -#include - -#include -#include - -#define MAXSEEHASH 0x1000 -seen_region *reuse; - -seen_region **seen_init(void) -{ - return (seen_region **)calloc(MAXSEEHASH, sizeof(seen_region *)); -} - -void seen_done(seen_region * seehash[]) -{ - int i; - for (i = 0; i != MAXSEEHASH; ++i) { - seen_region *sd = seehash[i]; - if (sd == NULL) - continue; - while (sd->nextHash != NULL) - sd = sd->nextHash; - sd->nextHash = reuse; - reuse = seehash[i]; - seehash[i] = NULL; - } - free(seehash); -} - -void free_seen(void) -{ - while (reuse) { - seen_region *r = reuse; - reuse = reuse->nextHash; - free(r); - } -} - -void -link_seen(seen_region * seehash[], const region * first, const region * last) -{ - const region *r = first; - seen_region *sr = NULL; - - if (first == last) - return; - - do { - sr = find_seen(seehash, r); - r = r->next; - } while (sr == NULL && r != last); - - while (r != last) { - seen_region *sn = find_seen(seehash, r); - if (sn != NULL) { - sr->next = sn; - sr = sn; - } - r = r->next; - } - if (sr) sr->next = 0; -} - -seen_region *find_seen(struct seen_region *seehash[], const region * r) -{ - unsigned int index = reg_hashkey(r) & (MAXSEEHASH - 1); - seen_region *find = seehash[index]; - while (find) { - if (find->r == r) { - return find; - } - find = find->nextHash; - } - return NULL; -} - -void seenhash_map(struct seen_region *seen[], void(*cb)(seen_region *, void *), void *cbdata) { - int i; - for (i = 0; i != MAXSEEHASH; ++i) { - seen_region *sr = seen[i]; - while (sr != NULL) { - cb(sr, cbdata); - sr = sr->nextHash; - } - } -} - -typedef struct cb_interval { - region *first; - region *last; -} cb_interval; - -static void cb_get_interval(seen_region *sr, void *cbdata) { - cb_interval *iv = (cb_interval *)cbdata; - region *r = sr->r; - if (iv->first == NULL || r->index < iv->first->index) { - iv->first = r; - } - if (iv->last != NULL && r->index >= iv->last->index) { - iv->last = r->next; - } -} - -/* this function adds the neighbour regions of the ones we have seen - * to the interval, which may be outside of [faction.first, faction.last) - */ -void get_seen_interval(struct seen_region *seen[], struct region **firstp, struct region **lastp) -{ - cb_interval interval; - - interval.first = *firstp; - interval.last = *lastp; - seenhash_map(seen, cb_get_interval, &interval); - *firstp = interval.first; - *lastp = interval.last; -} diff --git a/src/seen.h b/src/seen.h deleted file mode 100644 index abf062c2e..000000000 --- a/src/seen.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef H_SEEN_REGION -#define H_SEEN_REGION - -struct region; -struct faction; -struct seen_region; - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct seen_region { - struct seen_region *nextHash; - struct seen_region *next; - struct region *r; - seen_t mode; - bool disbelieves; /* potion of truth */ - } seen_region; - -struct seen_region **seen_init(void); -void seen_done(struct seen_region *seehash[]); -void free_seen(void); -void link_seen(struct seen_region *seehash[], const struct region * first, const struct region * last); -struct seen_region *find_seen(struct seen_region *seehash[], const struct region * r); -void get_seen_interval(struct seen_region *seen[], struct region **firstp, struct region **lastp); -seen_region *add_seen(struct seen_region *seehash[], struct region *r, seen_t mode, bool dis); -void link_seen(struct seen_region *seehash[], const struct region *first, const struct region *last); -void seenhash_map(struct seen_region *seen[], void(*cb)(struct seen_region *, void *), void *cbdata); -struct seen_region *faction_add_seen(struct faction *f, struct region *r, seen_t mode); -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/seen.test.c b/src/seen.test.c deleted file mode 100644 index 287ee00fe..000000000 --- a/src/seen.test.c +++ /dev/null @@ -1,202 +0,0 @@ -#include -#include -#include "seen.h" -#include "reports.h" -#include "travelthru.h" - -#include -#include -#include - -#include -#include - -static void setup_seen(int x, int y) { - int dir; - - for (dir = 0; dir != MAXDIRECTIONS; ++dir) { - test_create_region(x+delta_x[dir], y+delta_y[dir], 0); - } -} - -static void test_add_seen(CuTest *tc) { - region *r; - seen_region **seen, *sr; - - test_setup(); - seen = seen_init(); - r = test_create_region(0, 0, 0); - sr = add_seen(seen, r, see_travel, false); - CuAssertPtrEquals(tc, r, sr->r); - CuAssertIntEquals(tc, see_travel, sr->mode); - CuAssertIntEquals(tc, false, sr->disbelieves); - CuAssertPtrEquals(tc, 0, sr->next); - CuAssertPtrEquals(tc, 0, sr->nextHash); - CuAssertPtrEquals(tc, sr, find_seen(seen, r)); - sr = add_seen(seen, r, see_neighbour, true); - CuAssertIntEquals(tc, true, sr->disbelieves); - CuAssertIntEquals(tc, see_travel, sr->mode); - sr = add_seen(seen, r, see_unit, false); - CuAssertIntEquals(tc, true, sr->disbelieves); - CuAssertIntEquals(tc, see_unit, sr->mode); - seen_done(seen); - test_cleanup(); -} - -static void test_faction_add_seen(CuTest *tc) { - faction *f; - seen_region *sr; - - test_setup(); - f = test_create_faction(0); - f->seen = seen_init(); - test_create_region(0, 0, 0); - test_create_region(0, 1, 0); - sr = faction_add_seen(f, regions, see_unit); - CuAssertIntEquals(tc, false, sr->disbelieves); - CuAssertPtrEquals(tc, regions, f->first); - CuAssertPtrEquals(tc, regions, f->last); - seen_done(f->seen); - test_cleanup(); -} - -static void test_prepare_seen(CuTest *tc) { - region *r; - faction *f; - unit *u; - - test_setup(); - f = test_create_faction(0); - r = test_create_region(0, 0, 0); - u = test_create_unit(f, r); - f->seen = seen_init(); - faction_add_seen(f, r, see_unit); - setup_seen(0, 0); - r = test_create_region(2, 2, 0); - setup_seen(2, 2); - travelthru_add(r, u); - - init_reports(); - prepare_seen(f); - CuAssertPtrEquals(tc, regions, f->first); - CuAssertPtrEquals(tc, 0, f->last); - seen_done(f->seen); - test_cleanup(); -} - -static void test_seen_travelthru(CuTest *tc) { - seen_region *sr; - region *r; - faction *f; - unit *u; - - test_setup(); - setup_seen(0, 0); - f = test_create_faction(0); - u = test_create_unit(f, test_create_region(0, 0, 0)); - r = test_create_region(0, 1, 0); - travelthru_add(r, u); - init_reports(); - view_default(f->seen, r, f); - get_seen_interval(f->seen, &f->first, &f->last); - link_seen(f->seen, f->first, f->last); - CuAssertPtrEquals(tc, regions, f->first); - CuAssertPtrEquals(tc, 0, f->last); - sr = find_seen(f->seen, regions); - CuAssertPtrEquals(tc, regions, sr->r); - CuAssertIntEquals(tc, see_neighbour, sr->mode); - sr = find_seen(f->seen, r); - CuAssertPtrEquals(tc, r, sr->r); - CuAssertIntEquals(tc, see_travel, sr->mode); - seen_done(f->seen); - test_cleanup(); -} - -static void test_seen_region(CuTest *tc) { - seen_region **seen, *sr; - region *r; - - test_setup(); - setup_seen(0, 0); - r = test_create_region(0, 0, 0); - seen = seen_init(); - add_seen(seen, r, see_unit, false); - sr = find_seen(seen, r); - CuAssertPtrEquals(tc, r, sr->r); - seen_done(seen); - test_cleanup(); -} - -static void test_seen_interval_backward(CuTest *tc) { - region *r, *first, *last; - seen_region **seen; - - test_setup(); - r = test_create_region(0, 0, 0); - setup_seen(0, 0); - seen = seen_init(); - add_seen(seen, r, see_unit, false); - view_default(seen, r, 0); - first = r; - last = 0; - get_seen_interval(seen, &first, &last); - CuAssertPtrEquals(tc, regions, first); - CuAssertPtrEquals(tc, 0, last); - seen_done(seen); - test_cleanup(); -} - -static void test_seen_interval_forward(CuTest *tc) { - region *r, *first, *last; - seen_region **seen; - - test_setup(); - setup_seen(0, 0); - r = test_create_region(0, 0, 0); - seen = seen_init(); - add_seen(seen, r, see_unit, true); - view_default(seen, r, 0); - first = r; - last = 0; - get_seen_interval(seen, &first, &last); - CuAssertPtrEquals(tc, regions, first); - CuAssertPtrEquals(tc, 0, last); - seen_done(seen); - test_cleanup(); -} - -static void cb_testmap(seen_region *sr, void *cbdata) { - int *ip = (int *)cbdata; - *ip += sr->r->y; -} - -static void test_seenhash_map(CuTest *tc) { - region *r; - seen_region **seen; - int i = 0; - - test_setup(); - seen = seen_init(); - r = test_create_region(1, 1, 0); - add_seen(seen, r, see_unit, false); - r = test_create_region(2, 2, 0); - add_seen(seen, r, see_unit, false); - seenhash_map(seen, cb_testmap, &i); - CuAssertIntEquals(tc, 3, i); - seen_done(seen); - test_cleanup(); -} - -CuSuite *get_seen_suite(void) -{ - CuSuite *suite = CuSuiteNew(); - DISABLE_TEST(suite, test_prepare_seen); - DISABLE_TEST(suite, test_seen_travelthru); - DISABLE_TEST(suite, test_add_seen); - DISABLE_TEST(suite, test_faction_add_seen); - DISABLE_TEST(suite, test_seen_region); - DISABLE_TEST(suite, test_seen_interval_backward); - DISABLE_TEST(suite, test_seen_interval_forward); - DISABLE_TEST(suite, test_seenhash_map); - return suite; -} diff --git a/src/tests.c b/src/tests.c index 85aafd211..5673acea1 100644 --- a/src/tests.c +++ b/src/tests.c @@ -1,7 +1,6 @@ #include #include "tests.h" #include "keyword.h" -#include "seen.h" #include "prefix.h" #include "reports.h" From acfb06392a7731feac5a5388153960b1d0a3e80e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Sep 2016 17:02:51 +0200 Subject: [PATCH 010/675] Everything except report.c compiles. Not that I'm not claiming that it works. --- src/bind_unit.c | 2 +- src/bindings.c | 2 +- src/creport.c | 2 +- src/creport.h | 3 ++- src/reports.test.c | 2 +- src/test_eressea.c | 1 - src/tests.c | 1 - 7 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/bind_unit.c b/src/bind_unit.c index c8d5557f0..3f3848e78 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -59,7 +59,7 @@ without prior permission by the authors of Eressea. static int tolua_bufunit(lua_State * L) { char buf[8192]; unit *self = (unit *)tolua_tousertype(L, 1, 0); - int mode = (int)tolua_tonumber(L, 2, see_unit); + int mode = (int)tolua_tonumber(L, 2, (int)seen_unit); if (!self) return 0; bufunit(self->faction, self, 0, mode, buf, sizeof(buf)); diff --git a/src/bindings.c b/src/bindings.c index d9dadbb79..40d444710 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -974,7 +974,7 @@ static int tolua_report_unit(lua_State * L) char buffer[512]; unit *u = (unit *)tolua_tousertype(L, 1, 0); faction *f = (faction *)tolua_tousertype(L, 2, 0); - bufunit(f, u, 0, see_unit, buffer, sizeof(buffer)); + bufunit(f, u, 0, seen_unit, buffer, sizeof(buffer)); tolua_pushstring(L, buffer); return 1; } diff --git a/src/creport.c b/src/creport.c index 5d508612f..98ce770df 100644 --- a/src/creport.c +++ b/src/creport.c @@ -734,7 +734,7 @@ static void cr_output_spells(stream *out, const unit * u, int maxlevel) * @param u unit to report */ void cr_output_unit(stream *out, const region * r, const faction * f, - const unit * u, int mode) + const unit * u, seen_mode mode) { /* Race attributes are always plural and item attributes always * singular */ diff --git a/src/creport.h b/src/creport.h index c2c2ff385..6717cbf28 100644 --- a/src/creport.h +++ b/src/creport.h @@ -24,7 +24,8 @@ extern "C" { void register_cr(void); int crwritemap(const char *filename); - void cr_output_unit(struct stream *out, const struct region * r, const struct faction * f, const struct unit * u, int mode); + void cr_output_unit(struct stream *out, const struct region * r, + const struct faction * f, const struct unit * u, seen_mode mode); #ifdef __cplusplus } diff --git a/src/reports.test.c b/src/reports.test.c index 887e04f0d..c3cc012fe 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -194,7 +194,7 @@ static void test_cr_unit(CuTest *tc) { renumber_unit(u, 1234); mstream_init(&strm); - cr_output_unit(&strm, r, f, u, see_unit); + cr_output_unit(&strm, r, f, u, seen_unit); strm.api->rewind(strm.handle); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, line, "EINHEIT 1234"); diff --git a/src/test_eressea.c b/src/test_eressea.c index 0f6fc3522..f6bdc25b8 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -61,7 +61,6 @@ int RunAllTests(int argc, char *argv[]) /* self-test */ ADD_SUITE(tests); ADD_SUITE(callback); - ADD_SUITE(seen); ADD_SUITE(json); ADD_SUITE(jsonconf); ADD_SUITE(direction); diff --git a/src/tests.c b/src/tests.c index 5673acea1..53f5ea470 100644 --- a/src/tests.c +++ b/src/tests.c @@ -179,7 +179,6 @@ static void test_reset(void) { free_shiptypes(); free_races(); free_spellbooks(); - free_seen(); free_prefixes(); mt_clear(); for (i = 0; i != MAXSKILLS; ++i) { From 648857f52c95f4304e3d03039f5510a6ddf258cd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Sep 2016 18:52:35 +0200 Subject: [PATCH 011/675] disable report.c temporarily --- src/CMakeLists.txt | 2 +- src/eressea.c | 3 +-- src/reports.test.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4eaf3ca51..ffac8c76d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -114,7 +114,7 @@ set (ERESSEA_SRC randenc.c volcano.c chaos.c - report.c + # report.c spy.c study.c summary.c diff --git a/src/eressea.c b/src/eressea.c index 1fc69762b..bdb4dc712 100755 --- a/src/eressea.c +++ b/src/eressea.c @@ -65,9 +65,8 @@ void game_init(void) register_triggers(); register_xmas(); - register_nr(); +// register_nr(); register_cr(); - register_jsreport(); register_races(); register_spells(); diff --git a/src/reports.test.c b/src/reports.test.c index c3cc012fe..57f35f3ed 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -1,7 +1,7 @@ #include #include #include "reports.h" -#include "report.h" +//#include "report.h" #include "creport.h" #include "move.h" #include "travelthru.h" From 428f640ba6cb46d455e30db6a029869e42d88f4f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Sep 2016 19:09:53 +0200 Subject: [PATCH 012/675] disable reports tests. have to sort them by report.test and reports.test first --- src/CMakeLists.txt | 2 +- src/test_eressea.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ffac8c76d..1c0783dc5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -194,7 +194,7 @@ set(TESTS_SRC vortex.test.c tests.test.c volcano.test.c - reports.test.c +# reports.test.c summary.test.c travelthru.test.c callback.test.c diff --git a/src/test_eressea.c b/src/test_eressea.c index f6bdc25b8..ac8d55ee9 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -99,7 +99,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(item); ADD_SUITE(magic); ADD_SUITE(alchemy); - ADD_SUITE(reports); +// ADD_SUITE(reports); ADD_SUITE(save); ADD_SUITE(ship); ADD_SUITE(spellbook); From 4e4b4e482ef217964681d794412e88391206d099 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Sep 2016 20:13:26 +0200 Subject: [PATCH 013/675] split off report.test from reports.test move some tests around --- src/CMakeLists.txt | 5 +- src/creport.h | 3 + src/kernel/spell.test.c | 1 + src/report.c | 252 ++++++++++++++++++++-------------------- src/report.test.c | 242 ++++++++++++++++++++++++++++++++++++++ src/reports.test.c | 208 --------------------------------- 6 files changed, 373 insertions(+), 338 deletions(-) create mode 100644 src/report.test.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1c0783dc5..666f42e07 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -114,7 +114,7 @@ set (ERESSEA_SRC randenc.c volcano.c chaos.c - # report.c + report.c spy.c study.c summary.c @@ -194,7 +194,8 @@ set(TESTS_SRC vortex.test.c tests.test.c volcano.test.c -# reports.test.c + reports.test.c + report.test.c summary.test.c travelthru.test.c callback.test.c diff --git a/src/creport.h b/src/creport.h index 6717cbf28..fc2517859 100644 --- a/src/creport.h +++ b/src/creport.h @@ -11,6 +11,9 @@ */ #ifndef H_GC_CREPORT #define H_GC_CREPORT + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/spell.test.c b/src/kernel/spell.test.c index fa5e9527c..f61c0fffe 100644 --- a/src/kernel/spell.test.c +++ b/src/kernel/spell.test.c @@ -1,6 +1,7 @@ #include #include +#include #include #include diff --git a/src/report.c b/src/report.c index 22dba29d8..d1147ad71 100644 --- a/src/report.c +++ b/src/report.c @@ -144,7 +144,6 @@ void write_spaces(stream *out, size_t num) { } } - static void centre(stream *out, const char *s, bool breaking) { /* Bei Namen die genau 80 Zeichen lang sind, kann es hier Probleme @@ -247,125 +246,6 @@ static size_t write_spell_modifier(spell * sp, int flag, const char * str, bool return 0; } -void nr_spell_syntax(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang); - -void nr_spell(stream *out, spellbook_entry * sbe, const struct locale *lang) -{ - int bytes, k, itemanz, costtyp; - char buf[4096]; - char *startp, *bufp = buf; - size_t size = sizeof(buf) - 1; - spell * sp = sbe->sp; - - newline(out); - centre(out, spell_name(sp, lang), true); - newline(out); - paragraph(out, LOC(lang, "nr_spell_description"), 0, 0, 0); - paragraph(out, spell_info(sp, lang), 2, 0, 0); - - bytes = (int)strlcpy(bufp, LOC(lang, "nr_spell_type"), size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - - if (size) { - *bufp++ = ' '; - --size; - } - if (sp->sptyp & PRECOMBATSPELL) { - bytes = (int)strlcpy(bufp, LOC(lang, "sptype_precombat"), size); - } - else if (sp->sptyp & COMBATSPELL) { - bytes = (int)strlcpy(bufp, LOC(lang, "sptype_combat"), size); - } - else if (sp->sptyp & POSTCOMBATSPELL) { - bytes = (int)strlcpy(bufp, LOC(lang, "sptype_postcombat"), size); - } - else { - bytes = (int)strlcpy(bufp, LOC(lang, "sptype_normal"), size); - } - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - *bufp = 0; - paragraph(out, buf, 0, 0, 0); - - sprintf(buf, "%s %d", LOC(lang, "nr_spell_level"), sbe->level); - paragraph(out, buf, 0, 0, 0); - - sprintf(buf, "%s %d", LOC(lang, "nr_spell_rank"), sp->rank); - paragraph(out, buf, 0, 0, 0); - - paragraph(out, LOC(lang, "nr_spell_components"), 0, 0, 0); - for (k = 0; sp->components[k].type; ++k) { - const resource_type *rtype = sp->components[k].type; - itemanz = sp->components[k].amount; - costtyp = sp->components[k].cost; - if (itemanz > 0) { - size = sizeof(buf) - 1; - bufp = buf; - if (sp->sptyp & SPELLLEVEL) { - bytes = - _snprintf(bufp, size, " %d %s", itemanz, LOC(lang, resourcename(rtype, - itemanz != 1))); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR) { - bytes = _snprintf(bufp, size, " * %s", LOC(lang, "nr_level")); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - } - } - else { - bytes = _snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1))); - if (wrptr(&bufp, &size, bytes) != 0) { - WARN_STATIC_BUFFER(); - } - } - *bufp = 0; - paragraph(out, buf, 2, 2, '-'); - } - } - - size = sizeof(buf) - 1; - bufp = buf; - bytes = (int)strlcpy(buf, LOC(lang, "nr_spell_modifiers"), size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - - startp = bufp; - bytes = (int)write_spell_modifier(sp, FARCASTING, LOC(lang, "smod_far"), startp != bufp, bufp, size); - if (bytes && wrptr(&bufp, &size, bytes) != 0) { - WARN_STATIC_BUFFER(); - } - bytes = (int)write_spell_modifier(sp, OCEANCASTABLE, LOC(lang, "smod_sea"), startp != bufp, bufp, size); - if (bytes && wrptr(&bufp, &size, bytes) != 0) { - WARN_STATIC_BUFFER(); - } - bytes = (int)write_spell_modifier(sp, ONSHIPCAST, LOC(lang, "smod_ship"), startp != bufp, bufp, size); - if (bytes && wrptr(&bufp, &size, bytes) != 0) { - WARN_STATIC_BUFFER(); - } - bytes = (int)write_spell_modifier(sp, NOTFAMILIARCAST, LOC(lang, "smod_nofamiliar"), startp != bufp, bufp, size); - if (bytes && wrptr(&bufp, &size, bytes) != 0) { - WARN_STATIC_BUFFER(); - } - if (startp == bufp) { - bytes = (int)write_spell_modifier(sp, NOTFAMILIARCAST, LOC(lang, "smod_none"), startp != bufp, bufp, size); - if (bytes && wrptr(&bufp, &size, bytes) != 0) { - WARN_STATIC_BUFFER(); - } - } - *bufp = 0; - paragraph(out, buf, 0, 0, 0); - paragraph(out, LOC(lang, "nr_spell_syntax"), 0, 0, 0); - - bufp = buf; - size = sizeof(buf) - 1; - - nr_spell_syntax(out, sbe, lang); - - newline(out); -} - void nr_spell_syntax(stream *out, spellbook_entry * sbe, const struct locale *lang) { int bytes; @@ -544,8 +424,9 @@ void nr_spell_syntax(stream *out, spellbook_entry * sbe, const struct locale *la } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - } else { - log_error("unknown spell parameter %c for spell %s", cp, sp->sname); + } + else { + log_error("unknown spell parameter %c for spell %s", cp, sp->sname); } } *bufp = 0; @@ -553,6 +434,123 @@ void nr_spell_syntax(stream *out, spellbook_entry * sbe, const struct locale *la } +void nr_spell(stream *out, spellbook_entry * sbe, const struct locale *lang) +{ + int bytes, k, itemanz, costtyp; + char buf[4096]; + char *startp, *bufp = buf; + size_t size = sizeof(buf) - 1; + spell * sp = sbe->sp; + + newline(out); + centre(out, spell_name(sp, lang), true); + newline(out); + paragraph(out, LOC(lang, "nr_spell_description"), 0, 0, 0); + paragraph(out, spell_info(sp, lang), 2, 0, 0); + + bytes = (int)strlcpy(bufp, LOC(lang, "nr_spell_type"), size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + + if (size) { + *bufp++ = ' '; + --size; + } + if (sp->sptyp & PRECOMBATSPELL) { + bytes = (int)strlcpy(bufp, LOC(lang, "sptype_precombat"), size); + } + else if (sp->sptyp & COMBATSPELL) { + bytes = (int)strlcpy(bufp, LOC(lang, "sptype_combat"), size); + } + else if (sp->sptyp & POSTCOMBATSPELL) { + bytes = (int)strlcpy(bufp, LOC(lang, "sptype_postcombat"), size); + } + else { + bytes = (int)strlcpy(bufp, LOC(lang, "sptype_normal"), size); + } + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + *bufp = 0; + paragraph(out, buf, 0, 0, 0); + + sprintf(buf, "%s %d", LOC(lang, "nr_spell_level"), sbe->level); + paragraph(out, buf, 0, 0, 0); + + sprintf(buf, "%s %d", LOC(lang, "nr_spell_rank"), sp->rank); + paragraph(out, buf, 0, 0, 0); + + paragraph(out, LOC(lang, "nr_spell_components"), 0, 0, 0); + for (k = 0; sp->components[k].type; ++k) { + const resource_type *rtype = sp->components[k].type; + itemanz = sp->components[k].amount; + costtyp = sp->components[k].cost; + if (itemanz > 0) { + size = sizeof(buf) - 1; + bufp = buf; + if (sp->sptyp & SPELLLEVEL) { + bytes = + _snprintf(bufp, size, " %d %s", itemanz, LOC(lang, resourcename(rtype, + itemanz != 1))); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR) { + bytes = _snprintf(bufp, size, " * %s", LOC(lang, "nr_level")); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + } + } + else { + bytes = _snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1))); + if (wrptr(&bufp, &size, bytes) != 0) { + WARN_STATIC_BUFFER(); + } + } + *bufp = 0; + paragraph(out, buf, 2, 2, '-'); + } + } + + size = sizeof(buf) - 1; + bufp = buf; + bytes = (int)strlcpy(buf, LOC(lang, "nr_spell_modifiers"), size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + + startp = bufp; + bytes = (int)write_spell_modifier(sp, FARCASTING, LOC(lang, "smod_far"), startp != bufp, bufp, size); + if (bytes && wrptr(&bufp, &size, bytes) != 0) { + WARN_STATIC_BUFFER(); + } + bytes = (int)write_spell_modifier(sp, OCEANCASTABLE, LOC(lang, "smod_sea"), startp != bufp, bufp, size); + if (bytes && wrptr(&bufp, &size, bytes) != 0) { + WARN_STATIC_BUFFER(); + } + bytes = (int)write_spell_modifier(sp, ONSHIPCAST, LOC(lang, "smod_ship"), startp != bufp, bufp, size); + if (bytes && wrptr(&bufp, &size, bytes) != 0) { + WARN_STATIC_BUFFER(); + } + bytes = (int)write_spell_modifier(sp, NOTFAMILIARCAST, LOC(lang, "smod_nofamiliar"), startp != bufp, bufp, size); + if (bytes && wrptr(&bufp, &size, bytes) != 0) { + WARN_STATIC_BUFFER(); + } + if (startp == bufp) { + bytes = (int)write_spell_modifier(sp, NOTFAMILIARCAST, LOC(lang, "smod_none"), startp != bufp, bufp, size); + if (bytes && wrptr(&bufp, &size, bytes) != 0) { + WARN_STATIC_BUFFER(); + } + } + *bufp = 0; + paragraph(out, buf, 0, 0, 0); + paragraph(out, LOC(lang, "nr_spell_syntax"), 0, 0, 0); + + bufp = buf; + size = sizeof(buf) - 1; + + nr_spell_syntax(out, sbe, lang); + + newline(out); +} + static void nr_curses_i(stream *out, int indent, const faction *viewer, objtype_t typ, const void *obj, attrib *a, int self) { @@ -675,12 +673,12 @@ static void rps_nowrap(stream *out, const char *s) } static void -nr_unit(stream *out, const faction * f, const unit * u, int indent, int mode) +nr_unit(stream *out, const faction * f, const unit * u, int indent, seen_mode mode) { attrib *a_otherfaction; char marker; int dh; - bool isbattle = (bool)(mode == see_battle); + bool isbattle = (bool)(mode == seen_battle); char buf[8192]; if (fval(u_race(u), RCF_INVISIBLE)) @@ -875,9 +873,8 @@ bool see_border(const connection * b, const faction * f, const region * r) return cs; } -static void describe(stream *out, const seen_region * sr, faction * f) +static void describe(stream *out, const region * r, faction * f) { - const region *r; int n; bool dh; direction_t d; @@ -901,9 +898,8 @@ static void describe(stream *out, const seen_region * sr, faction * f) assert(out); assert(f); - assert(sr); + assert(r); - r = sr->r; for (d = 0; d != MAXDIRECTIONS; d++) { /* Nachbarregionen, die gesehen werden, ermitteln */ region *r2 = rconnect(r, d); diff --git a/src/report.test.c b/src/report.test.c new file mode 100644 index 000000000..cf074b284 --- /dev/null +++ b/src/report.test.c @@ -0,0 +1,242 @@ +#include +#include +#include "report.h" +#include "move.h" +#include "travelthru.h" +#include "keyword.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +static void test_write_spaces(CuTest *tc) { + stream out = { 0 }; + char buf[1024]; + size_t len; + + mstream_init(&out); + write_spaces(&out, 4); + out.api->rewind(out.handle); + len = out.api->read(out.handle, buf, sizeof(buf)); + buf[len] = '\0'; + CuAssertStrEquals(tc, " ", buf); + CuAssertIntEquals(tc, ' ', buf[3]); + mstream_done(&out); +} + +static void test_write_many_spaces(CuTest *tc) { + stream out = { 0 }; + char buf[1024]; + size_t len; + + mstream_init(&out); + write_spaces(&out, 100); + out.api->rewind(out.handle); + len = out.api->read(out.handle, buf, sizeof(buf)); + buf[len] = '\0'; + CuAssertIntEquals(tc, 100, (int)len); + CuAssertIntEquals(tc, ' ', buf[99]); + mstream_done(&out); +} + +static void test_write_travelthru(CuTest *tc) { + stream out = { 0 }; + char buf[1024]; + size_t len; + region *r; + faction *f; + unit *u; + struct locale *lang; + + test_cleanup(); + lang = get_or_create_locale("de"); + locale_setstring(lang, "travelthru_header", "Durchreise: "); + mstream_init(&out); + r = test_create_region(0, 0, 0); + r->flags |= RF_TRAVELUNIT; + f = test_create_faction(0); + f->locale = lang; + u = test_create_unit(f, test_create_region(0, 1, 0)); + unit_setname(u, "Hodor"); + unit_setid(u, 1); + + write_travelthru(&out, r, f); + out.api->rewind(out.handle); + len = out.api->read(out.handle, buf, sizeof(buf)); + CuAssertIntEquals_Msg(tc, "no travelers, no report", 0, (int)len); + mstream_done(&out); + + mstream_init(&out); + travelthru_add(r, u); + write_travelthru(&out, r, f); + out.api->rewind(out.handle); + len = out.api->read(out.handle, buf, sizeof(buf)); + buf[len] = '\0'; + CuAssertStrEquals_Msg(tc, "list one unit", "Durchreise: Hodor (1).\n", buf); + mstream_done(&out); + + mstream_init(&out); + move_unit(u, r, 0); + write_travelthru(&out, r, f); + out.api->rewind(out.handle); + len = out.api->read(out.handle, buf, sizeof(buf)); + CuAssertIntEquals_Msg(tc, "do not list units that stopped in the region", 0, (int)len); + + mstream_done(&out); + test_cleanup(); +} + +typedef struct { + struct locale *lang; + spell *sp; + spellbook *spb; + spellbook_entry * sbe; +} spell_fixture; + +static void setup_spell_fixture(spell_fixture * spf) { + spf->lang = test_create_locale(); + locale_setstring(spf->lang, mkname("spell", "testspell"), "Testzauber"); + locale_setstring(spf->lang, "nr_spell_type", "Typ:"); + locale_setstring(spf->lang, "sptype_normal", "Normal"); + locale_setstring(spf->lang, "nr_spell_modifiers", "Modifier:"); + locale_setstring(spf->lang, "smod_none", "Keine"); + locale_setstring(spf->lang, keyword(K_CAST), "ZAUBERE"); + locale_setstring(spf->lang, parameters[P_REGION], "REGION"); + locale_setstring(spf->lang, parameters[P_LEVEL], "STUFE"); + locale_setstring(spf->lang, "par_unit", "enr"); + locale_setstring(spf->lang, "par_ship", "snr"); + locale_setstring(spf->lang, "par_building", "bnr"); + locale_setstring(spf->lang, "spellpar::hodor", "Hodor"); + + spf->spb = create_spellbook("testbook"); + spf->sp = test_create_spell(); + spellbook_add(spf->spb, spf->sp, 1); + spf->sbe = spellbook_get(spf->spb, spf->sp); +} + +static void cleanup_spell_fixture(spell_fixture *spf) { + spellbook_clear(spf->spb); + free(spf->spb); + test_cleanup(); +} + +static void set_parameter(spell_fixture spell, char *value) { + free(spell.sp->parameter); + spell.sp->parameter = _strdup(value); +} + +static void check_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char *syntax) { + stream strm; + char buf[1024]; + char *linestart, *newline; + size_t len; + + mstream_init(&strm); + nr_spell_syntax(&strm, spell->sbe, spell->lang); + strm.api->rewind(strm.handle); + len = strm.api->read(strm.handle, buf, sizeof(buf)); + buf[len] = '\0'; + + linestart = strtok(buf, "\n"); + while (linestart && !strstr(linestart, "ZAUBERE")) + linestart = strtok(NULL, "\n"); + + CuAssertPtrNotNull(tc, linestart); + + newline = strtok(NULL, "\n"); + while (newline) { + *(newline - 1) = '\n'; + newline = strtok(NULL, "\n"); + } + + CuAssertStrEquals_Msg(tc, msg, syntax, linestart); + + mstream_done(&strm); +} + +static void test_write_spell_syntax(CuTest *tc) { + spell_fixture spell; + + test_cleanup(); + setup_spell_fixture(&spell); + + check_spell_syntax(tc, "vanilla", &spell, " ZAUBERE \"Testzauber\""); + + spell.sp->sptyp |= FARCASTING; + check_spell_syntax(tc, "far", &spell, " ZAUBERE [REGION x y] \"Testzauber\""); + + spell.sp->sptyp |= SPELLLEVEL; + check_spell_syntax(tc, "farlevel", &spell, " ZAUBERE [REGION x y] [STUFE n] \"Testzauber\""); + spell.sp->sptyp = 0; + + set_parameter(spell, "kc"); + check_spell_syntax(tc, "kc", &spell, " ZAUBERE \"Testzauber\" ( REGION | EINHEIT | SCHIFF | BURG )"); + + spell.sp->sptyp |= BUILDINGSPELL; + check_spell_syntax(tc, "kc typed", &spell, " ZAUBERE \"Testzauber\" BURG "); + spell.sp->sptyp = 0; + + set_parameter(spell, "b"); + check_spell_syntax(tc, "b", &spell, " ZAUBERE \"Testzauber\" "); + + set_parameter(spell, "s"); + check_spell_syntax(tc, "s", &spell, " ZAUBERE \"Testzauber\" "); + + set_parameter(spell, "s+"); + check_spell_syntax(tc, "s+", &spell, " ZAUBERE \"Testzauber\" [ ...]"); + + set_parameter(spell, "u"); + check_spell_syntax(tc, "u", &spell, " ZAUBERE \"Testzauber\" "); + + set_parameter(spell, "r"); + check_spell_syntax(tc, "r", &spell, " ZAUBERE \"Testzauber\" "); + + set_parameter(spell, "bc"); + free(spell.sp->syntax); + spell.sp->syntax = _strdup("hodor"); + check_spell_syntax(tc, "bc hodor", &spell, " ZAUBERE \"Testzauber\" "); + free(spell.sp->syntax); + spell.sp->syntax = 0; + + set_parameter(spell, "c?"); + free(spell.sp->syntax); + spell.sp->syntax = _strdup("hodor"); + check_spell_syntax(tc, "c?", &spell, " ZAUBERE \"Testzauber\" []"); + free(spell.sp->syntax); + spell.sp->syntax = 0; + + set_parameter(spell, "kc+"); + check_spell_syntax(tc, "kc+", &spell, + " ZAUBERE \"Testzauber\" ( REGION | EINHEIT [ ...] | SCHIFF \n [ ...] | BURG [ ...] )"); + + cleanup_spell_fixture(&spell); +} + +CuSuite *get_report_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_write_spaces); + SUITE_ADD_TEST(suite, test_write_many_spaces); + SUITE_ADD_TEST(suite, test_write_travelthru); + SUITE_ADD_TEST(suite, test_write_spell_syntax); + return suite; +} diff --git a/src/reports.test.c b/src/reports.test.c index 57f35f3ed..c8ea83e4c 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -1,7 +1,6 @@ #include #include #include "reports.h" -//#include "report.h" #include "creport.h" #include "move.h" #include "travelthru.h" @@ -118,36 +117,6 @@ static void test_seen_faction(CuTest *tc) { test_cleanup(); } -static void test_write_spaces(CuTest *tc) { - stream out = { 0 }; - char buf[1024]; - size_t len; - - mstream_init(&out); - write_spaces(&out, 4); - out.api->rewind(out.handle); - len = out.api->read(out.handle, buf, sizeof(buf)); - buf[len] = '\0'; - CuAssertStrEquals(tc, " ", buf); - CuAssertIntEquals(tc, ' ', buf[3]); - mstream_done(&out); -} - -static void test_write_many_spaces(CuTest *tc) { - stream out = { 0 }; - char buf[1024]; - size_t len; - - mstream_init(&out); - write_spaces(&out, 100); - out.api->rewind(out.handle); - len = out.api->read(out.handle, buf, sizeof(buf)); - buf[len] = '\0'; - CuAssertIntEquals(tc, 100, (int)len); - CuAssertIntEquals(tc, ' ', buf[99]); - mstream_done(&out); -} - static void test_sparagraph(CuTest *tc) { strlist *sp = 0; @@ -202,53 +171,6 @@ static void test_cr_unit(CuTest *tc) { test_cleanup(); } -static void test_write_travelthru(CuTest *tc) { - stream out = { 0 }; - char buf[1024]; - size_t len; - region *r; - faction *f; - unit *u; - struct locale *lang; - - test_cleanup(); - lang = get_or_create_locale("de"); - locale_setstring(lang, "travelthru_header", "Durchreise: "); - mstream_init(&out); - r = test_create_region(0, 0, 0); - r->flags |= RF_TRAVELUNIT; - f = test_create_faction(0); - f->locale = lang; - u = test_create_unit(f, test_create_region(0, 1, 0)); - unit_setname(u, "Hodor"); - unit_setid(u, 1); - - write_travelthru(&out, r, f); - out.api->rewind(out.handle); - len = out.api->read(out.handle, buf, sizeof(buf)); - CuAssertIntEquals_Msg(tc, "no travelers, no report", 0, (int)len); - mstream_done(&out); - - mstream_init(&out); - travelthru_add(r, u); - write_travelthru(&out, r, f); - out.api->rewind(out.handle); - len = out.api->read(out.handle, buf, sizeof(buf)); - buf[len] = '\0'; - CuAssertStrEquals_Msg(tc, "list one unit", "Durchreise: Hodor (1).\n", buf); - mstream_done(&out); - - mstream_init(&out); - move_unit(u, r, 0); - write_travelthru(&out, r, f); - out.api->rewind(out.handle); - len = out.api->read(out.handle, buf, sizeof(buf)); - CuAssertIntEquals_Msg(tc, "do not list units that stopped in the region", 0, (int)len); - - mstream_done(&out); - test_cleanup(); -} - static void test_write_unit(CuTest *tc) { unit *u; faction *f; @@ -290,132 +212,6 @@ static void test_write_unit(CuTest *tc) { test_cleanup(); } -typedef struct { - struct locale *lang; - spell *sp; - spellbook *spb; - spellbook_entry * sbe; -} spell_fixture; - -static void setup_spell_fixture(spell_fixture * spf) { - spf->lang = get_or_create_locale("de"); - locale_setstring(spf->lang, mkname("spell", "testspell"), "Testzauber"); - locale_setstring(spf->lang, "nr_spell_type", "Typ:"); - locale_setstring(spf->lang, "sptype_normal", "Normal"); - locale_setstring(spf->lang, "nr_spell_modifiers", "Modifier:"); - locale_setstring(spf->lang, "smod_none", "Keine"); - locale_setstring(spf->lang, keyword(K_CAST), "ZAUBERE"); - locale_setstring(spf->lang, parameters[P_REGION], "REGION"); - locale_setstring(spf->lang, parameters[P_LEVEL], "STUFE"); - locale_setstring(spf->lang, "par_unit", "enr"); - locale_setstring(spf->lang, "par_ship", "snr"); - locale_setstring(spf->lang, "par_building", "bnr"); - locale_setstring(spf->lang, "spellpar::hodor", "Hodor"); - - spf->spb = create_spellbook("testbook"); - spf->sp = test_create_spell(); - spellbook_add(spf->spb, spf->sp, 1); - spf->sbe = spellbook_get(spf->spb, spf->sp); -} - -static void cleanup_spell_fixture(spell_fixture *spf) { - spellbook_clear(spf->spb); - free(spf->spb); - test_cleanup(); -} - -static void check_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char *syntax) { - stream strm; - char buf[1024]; - char *linestart, *newline; - size_t len; - - mstream_init(&strm); - nr_spell_syntax(&strm, spell->sbe, spell->lang); - strm.api->rewind(strm.handle); - len = strm.api->read(strm.handle, buf, sizeof(buf)); - buf[len] = '\0'; - - linestart = strtok(buf, "\n"); - while (linestart && !strstr(linestart, "ZAUBERE")) - linestart = strtok(NULL, "\n") ; - - CuAssertPtrNotNull(tc, linestart); - - newline = strtok(NULL, "\n"); - while (newline) { - *(newline - 1) = '\n'; - newline = strtok(NULL, "\n"); - } - - CuAssertStrEquals_Msg(tc, msg, syntax, linestart); - - mstream_done(&strm); -} - -static void set_parameter(spell_fixture spell, char *value) { - free(spell.sp->parameter); - spell.sp->parameter = _strdup(value); -} - -static void test_write_spell_syntax(CuTest *tc) { - spell_fixture spell; - - test_cleanup(); - setup_spell_fixture(&spell); - - check_spell_syntax(tc, "vanilla", &spell, " ZAUBERE \"Testzauber\""); - - spell.sp->sptyp |= FARCASTING; - check_spell_syntax(tc, "far", &spell, " ZAUBERE [REGION x y] \"Testzauber\""); - - spell.sp->sptyp |= SPELLLEVEL; - check_spell_syntax(tc, "farlevel", &spell, " ZAUBERE [REGION x y] [STUFE n] \"Testzauber\""); - spell.sp->sptyp = 0; - - set_parameter(spell, "kc"); - check_spell_syntax(tc, "kc", &spell, " ZAUBERE \"Testzauber\" ( REGION | EINHEIT | SCHIFF | BURG )"); - - spell.sp->sptyp |= BUILDINGSPELL; - check_spell_syntax(tc, "kc typed", &spell, " ZAUBERE \"Testzauber\" BURG "); - spell.sp->sptyp = 0; - - set_parameter(spell, "b"); - check_spell_syntax(tc, "b", &spell, " ZAUBERE \"Testzauber\" "); - - set_parameter(spell, "s"); - check_spell_syntax(tc, "s", &spell, " ZAUBERE \"Testzauber\" "); - - set_parameter(spell, "s+"); - check_spell_syntax(tc, "s+", &spell, " ZAUBERE \"Testzauber\" [ ...]"); - - set_parameter(spell, "u"); - check_spell_syntax(tc, "u", &spell, " ZAUBERE \"Testzauber\" "); - - set_parameter(spell, "r"); - check_spell_syntax(tc, "r", &spell, " ZAUBERE \"Testzauber\" "); - - set_parameter(spell, "bc"); - free(spell.sp->syntax); - spell.sp->syntax = _strdup("hodor"); - check_spell_syntax(tc, "bc hodor", &spell, " ZAUBERE \"Testzauber\" "); - free(spell.sp->syntax); - spell.sp->syntax = 0; - - set_parameter(spell, "c?"); - free(spell.sp->syntax); - spell.sp->syntax = _strdup("hodor"); - check_spell_syntax(tc, "c?", &spell, " ZAUBERE \"Testzauber\" []"); - free(spell.sp->syntax); - spell.sp->syntax = 0; - - set_parameter(spell, "kc+"); - check_spell_syntax(tc, "kc+", &spell, - " ZAUBERE \"Testzauber\" ( REGION | EINHEIT [ ...] | SCHIFF \n [ ...] | BURG [ ...] )"); - - cleanup_spell_fixture(&spell); -} - static void test_arg_resources(CuTest *tc) { variant v1, v2; arg_type *atype; @@ -456,12 +252,8 @@ CuSuite *get_reports_suite(void) SUITE_ADD_TEST(suite, test_reorder_units); SUITE_ADD_TEST(suite, test_seen_faction); SUITE_ADD_TEST(suite, test_regionid); - SUITE_ADD_TEST(suite, test_write_spaces); - SUITE_ADD_TEST(suite, test_write_many_spaces); SUITE_ADD_TEST(suite, test_sparagraph); - SUITE_ADD_TEST(suite, test_write_travelthru); SUITE_ADD_TEST(suite, test_write_unit); - SUITE_ADD_TEST(suite, test_write_spell_syntax); SUITE_ADD_TEST(suite, test_arg_resources); return suite; } From 482e619969c9f0fd249f67aaa3c34476bf91d998 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Sep 2016 20:17:59 +0200 Subject: [PATCH 014/675] disable reports entirely. --- src/CMakeLists.txt | 7 +++--- src/bindings.c | 2 +- src/creport.test.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++ src/eressea.c | 7 +++--- src/reports.test.c | 24 ------------------- 5 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 src/creport.test.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 666f42e07..b8b2b4e40 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,7 +102,8 @@ set (ERESSEA_SRC keyword.c skill.c json.c - creport.c +# creport.c +# report.c economy.c give.c items.c @@ -114,7 +115,6 @@ set (ERESSEA_SRC randenc.c volcano.c chaos.c - report.c spy.c study.c summary.c @@ -195,7 +195,8 @@ set(TESTS_SRC tests.test.c volcano.test.c reports.test.c - report.test.c + creport.test.c +# report.test.c summary.test.c travelthru.test.c callback.test.c diff --git a/src/bindings.c b/src/bindings.c index 40d444710..cca725ca1 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -1090,7 +1090,7 @@ int tolua_bindings_open(lua_State * L) tolua_function(L, TOLUA_CAST "factions", tolua_get_factions); tolua_function(L, TOLUA_CAST "regions", tolua_get_regions); tolua_function(L, TOLUA_CAST "read_turn", tolua_read_turn); - tolua_function(L, TOLUA_CAST "write_map", &tolua_write_map); +// tolua_function(L, TOLUA_CAST "write_map", &tolua_write_map); tolua_function(L, TOLUA_CAST "read_orders", tolua_read_orders); tolua_function(L, TOLUA_CAST "process_orders", tolua_process_orders); tolua_function(L, TOLUA_CAST "init_reports", tolua_init_reports); diff --git a/src/creport.test.c b/src/creport.test.c new file mode 100644 index 000000000..3a84ea566 --- /dev/null +++ b/src/creport.test.c @@ -0,0 +1,58 @@ +#include +#include +#include "creport.h" +#include "move.h" +#include "travelthru.h" +#include "keyword.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +static void test_cr_unit(CuTest *tc) { + stream strm; + char line[1024]; + faction *f; + region *r; + unit *u; + + test_cleanup(); + f = test_create_faction(0); + r = test_create_region(0, 0, 0); + u = test_create_unit(f, r); + renumber_unit(u, 1234); + + mstream_init(&strm); + cr_output_unit(&strm, r, f, u, seen_unit); + strm.api->rewind(strm.handle); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, line, "EINHEIT 1234"); + mstream_done(&strm); + test_cleanup(); +} + +CuSuite *get_creport_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_cr_unit); + return suite; +} diff --git a/src/eressea.c b/src/eressea.c index bdb4dc712..13c4a15ae 100755 --- a/src/eressea.c +++ b/src/eressea.c @@ -28,11 +28,10 @@ #include "calendar.h" #include "chaos.h" -#include "creport.h" #include "items.h" -#include "jsreport.h" +//#include "creport.h" +//#include "report.h" #include "names.h" -#include "report.h" #include "reports.h" #include "spells.h" #include "wormhole.h" @@ -66,7 +65,7 @@ void game_init(void) register_xmas(); // register_nr(); - register_cr(); +// register_cr(); register_races(); register_spells(); diff --git a/src/reports.test.c b/src/reports.test.c index c8ea83e4c..5cd7eed6d 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -1,7 +1,6 @@ #include #include #include "reports.h" -#include "creport.h" #include "move.h" #include "travelthru.h" #include "keyword.h" @@ -149,28 +148,6 @@ static void test_sparagraph(CuTest *tc) { freestrlist(sp); } -static void test_cr_unit(CuTest *tc) { - stream strm; - char line[1024]; - faction *f; - region *r; - unit *u; - - test_cleanup(); - f = test_create_faction(0); - r = test_create_region(0, 0, 0); - u = test_create_unit(f, r); - renumber_unit(u, 1234); - - mstream_init(&strm); - cr_output_unit(&strm, r, f, u, seen_unit); - strm.api->rewind(strm.handle); - CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); - CuAssertStrEquals(tc, line, "EINHEIT 1234"); - mstream_done(&strm); - test_cleanup(); -} - static void test_write_unit(CuTest *tc) { unit *u; faction *f; @@ -248,7 +225,6 @@ static void test_arg_resources(CuTest *tc) { CuSuite *get_reports_suite(void) { CuSuite *suite = CuSuiteNew(); - SUITE_ADD_TEST(suite, test_cr_unit); SUITE_ADD_TEST(suite, test_reorder_units); SUITE_ADD_TEST(suite, test_seen_faction); SUITE_ADD_TEST(suite, test_regionid); From cd71a21bf5012db0db191f80d4b61570bd3133f9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Sep 2016 21:09:05 +0200 Subject: [PATCH 015/675] really disable reports --- src/CMakeLists.txt | 2 +- src/bindings.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b8b2b4e40..591aa122e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -195,7 +195,7 @@ set(TESTS_SRC tests.test.c volcano.test.c reports.test.c - creport.test.c +# creport.test.c # report.test.c summary.test.c travelthru.test.c diff --git a/src/bindings.c b/src/bindings.c index cca725ca1..aa2e177c1 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -50,7 +50,6 @@ without prior permission by the authors of Eressea. #include #include -#include "creport.h" #include "economy.h" #include "summary.h" #include "teleport.h" @@ -572,7 +571,7 @@ static int tolua_write_summary(lua_State * L) } return 0; } - +/* static int tolua_write_map(lua_State * L) { const char *filename = tolua_tostring(L, 1, 0); @@ -581,7 +580,7 @@ static int tolua_write_map(lua_State * L) } return 0; } - +*/ static int tolua_read_turn(lua_State * L) { int cturn = current_turn(); From 8ec37783e212866e345e5d49b653185871b84753 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Sep 2016 21:13:26 +0200 Subject: [PATCH 016/675] fix nul-pointer access --- src/reports.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reports.c b/src/reports.c index 81abb408a..c94b7e8ff 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1356,7 +1356,7 @@ void reorder_units(region * r) static region *lastregion(faction * f) { #ifdef SMART_INTERVALS - return f->last->next; + return f->last ? f->last->next : NULL; #else return NULL; #endif From 576f183afb673c8515263c5c541ad4e0c6b57d3a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 14 Sep 2016 17:04:23 +0200 Subject: [PATCH 017/675] separate tests.report module (lua) disable all report testing for now --- scripts/tests/common.lua | 116 ------------------------------------ scripts/tests/e2/init.lua | 1 + scripts/tests/e3/init.lua | 1 + scripts/tests/process.lua | 12 ++-- scripts/tests/report.lua | 122 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 130 insertions(+), 122 deletions(-) create mode 100644 scripts/tests/report.lua diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 446a7cf6d..75ab62cfc 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -673,8 +673,6 @@ function test_laen2() local laen = r:get_resource("laen") process_orders() - init_reports() --- write_report(u1.faction) assert_equal(laen - 2, r:get_resource("laen")) assert_equal(2, u1:get_item("laen")) end @@ -965,120 +963,6 @@ function test_bug_1795_demons() assert_equal(peasants, r:get_resource("peasant")) end -module("tests.report", package.seeall, lunit.testcase) - -function setup() - eressea.free_game() - eressea.settings.set("nmr.timeout", "0") - eressea.settings.set("rules.food.flags", "4") -end - -local function find_in_report(f, pattern, extension) - extension = extension or "nr" - local filename = config.reportpath .. "/" .. get_turn() .. "-" .. itoa36(f.id) .. "." .. extension - local report = io.open(filename, 'r'); - assert_not_nil(report) - t = report:read("*all") - report:close() - - local start, _ = string.find(t, pattern) - return start~=nil -end - -local function remove_report(faction) - local filetrunk = config.reportpath .. "/" .. get_turn() .. "-" .. itoa36(faction.id) - os.remove(filetrunk .. ".nr") - os.remove(filetrunk .. ".cr") - os.remove(filetrunk .. ".txt") -end - -function test_coordinates_no_plane() - local r = region.create(0, 0, "mountain") - local f = faction.create("noplane@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - init_reports() - write_report(f) - assert_true(find_in_report(f, r.name .. " %(0,0%), Berg")) - remove_report(f) -end - -function test_show_shadowmaster_attacks() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.race = "shadowmaster" - u:clear_orders() - u:add_order("ZEIGE Schattenmeister") - process_orders() - init_reports() - write_report(f) - assert_false(find_in_report(f, ", ,")) - remove_report(f) -end - -function test_coordinates_named_plane() - local p = plane.create(0, -3, -3, 7, 7, "Hell") - local r = region.create(0, 0, "mountain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - init_reports() - write_report(f) - assert_true(find_in_report(f, r.name .. " %(0,0,Hell%), Berg")) - remove_report(f) -end - -function test_coordinates_unnamed_plane() - local p = plane.create(0, -3, -3, 7, 7) - local r = region.create(0, 0, "mountain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - init_reports() - write_report(f) - assert_true(find_in_report(f, r.name .. " %(0,0%), Berg")) - remove_report(f) -end - -function test_coordinates_noname_plane() - local p = plane.create(0, -3, -3, 7, 7, "") - local r = region.create(0, 0, "mountain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - init_reports() - write_report(f) - assert_true(find_in_report(f, r.name .. " %(0,0%), Berg")) - remove_report(f) -end - -function test_lighthouse() - eressea.free_game() - local r = region.create(0, 0, "mountain") - local f = faction.create("noreply@eressea.de", "human", "de") - region.create(1, 0, "mountain") - region.create(2, 0, "ocean") - region.create(0, 1, "firewall") - region.create(3, 0, "mountain") - region.create(4, 0, "plain") - local u = unit.create(f, r, 1) - local b = building.create(r, "lighthouse") - b.size = 100 - b.working = true - u.building = b - u:set_skill("perception", 9) - u:add_item("money", 1000) - assert_not_nil(b) - - init_reports() - write_report(f) - assert_true(find_in_report(f, " %(1,0%) %(vom Turm erblickt%)")) - assert_true(find_in_report(f, " %(2,0%) %(vom Turm erblickt%)")) - assert_true(find_in_report(f, " %(3,0%) %(vom Turm erblickt%)")) - - assert_false(find_in_report(f, " %(0,0%) %(vom Turm erblickt%)")) - assert_false(find_in_report(f, " %(0,1%) %(vom Turm erblickt%)")) - assert_false(find_in_report(f, " %(4,0%) %(vom Turm erblickt%)")) - remove_report(f) -end - module("tests.parser", package.seeall, lunit.testcase) function setup() diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index cd6cf640a..1f325aa17 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -8,6 +8,7 @@ require 'tests.e2.spells' require 'tests.e2.stealth' require 'tests.orders' require 'tests.common' +-- require 'tests.report' require 'tests.storage' require 'tests.magicbag' require 'tests.process' diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua index 2e4096712..4655fdcef 100644 --- a/scripts/tests/e3/init.lua +++ b/scripts/tests/e3/init.lua @@ -6,5 +6,6 @@ require 'tests.e3.parser' require 'tests.e3.morale' require 'tests.orders' require 'tests.common' +-- require 'tests.report' require 'tests.magicbag' require 'tests.process' diff --git a/scripts/tests/process.lua b/scripts/tests/process.lua index 3256c73e6..bd5d45d65 100644 --- a/scripts/tests/process.lua +++ b/scripts/tests/process.lua @@ -30,12 +30,12 @@ function test_process_turn() assert_equal(0, write_reports()) assert_equal(0, eressea.write_game("test.dat")) assert_file("data/test.dat") - assert_file("reports/" .. get_turn() .. "-ii.nr") - assert_file("reports/" .. get_turn() .. "-ii.cr") - assert_file("reports/" .. get_turn() .. "-ii.txt") - assert_file("reports/" .. get_turn() .. "-777.nr") - assert_file("reports/" .. get_turn() .. "-777.cr") - assert_file("reports/" .. get_turn() .. "-777.txt") + -- assert_file("reports/" .. get_turn() .. "-ii.nr") + -- assert_file("reports/" .. get_turn() .. "-ii.cr") + -- assert_file("reports/" .. get_turn() .. "-ii.txt") + -- assert_file("reports/" .. get_turn() .. "-777.nr") + -- assert_file("reports/" .. get_turn() .. "-777.cr") + -- assert_file("reports/" .. get_turn() .. "-777.txt") assert_file("reports/reports.txt") os.remove("reports") os.remove("data") diff --git a/scripts/tests/report.lua b/scripts/tests/report.lua new file mode 100644 index 000000000..2a037c770 --- /dev/null +++ b/scripts/tests/report.lua @@ -0,0 +1,122 @@ +require "lunit" + +module("tests.report", package.seeall, lunit.testcase) + +function setup() + eressea.free_game() + eressea.settings.set("nmr.timeout", "0") + eressea.settings.set("rules.food.flags", "4") +end + +local function find_in_report(f, pattern, extension) + extension = extension or "nr" + local filename = config.reportpath .. "/" .. get_turn() .. "-" .. itoa36(f.id) .. "." .. extension + local report = io.open(filename, 'r'); + assert_not_nil(report) + t = report:read("*all") + report:close() + + local start, _ = string.find(t, pattern) + return start~=nil +end + +local function remove_report(faction) + local filetrunk = config.reportpath .. "/" .. get_turn() .. "-" .. itoa36(faction.id) + os.remove(filetrunk .. ".nr") + os.remove(filetrunk .. ".cr") + os.remove(filetrunk .. ".txt") +end + +function setup() + eressea.free_game() + eressea.settings.set("nmr.timeout", "0") + eressea.settings.set("rules.food.flags", "4") +end + +function test_coordinates_unnamed_plane() + local p = plane.create(0, -3, -3, 7, 7) + local r = region.create(0, 0, "mountain") + local f = faction.create("unnamed@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + init_reports() + write_report(f) + assert_true(find_in_report(f, r.name .. " %(0,0%), Berg")) + remove_report(f) +end + +function test_coordinates_no_plane() + local r = region.create(0, 0, "mountain") + local f = faction.create("noplane@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + init_reports() + write_report(f) + assert_true(find_in_report(f, r.name .. " %(0,0%), Berg")) + remove_report(f) +end + +function test_show_shadowmaster_attacks() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u.race = "shadowmaster" + u:clear_orders() + u:add_order("ZEIGE Schattenmeister") + process_orders() + init_reports() + write_report(f) + assert_false(find_in_report(f, ", ,")) + remove_report(f) +end + +function test_coordinates_named_plane() + local p = plane.create(0, -3, -3, 7, 7, "Hell") + local r = region.create(0, 0, "mountain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + init_reports() + write_report(f) + assert_true(find_in_report(f, r.name .. " %(0,0,Hell%), Berg")) + remove_report(f) +end + +function test_coordinates_noname_plane() + local p = plane.create(0, -3, -3, 7, 7, "") + local r = region.create(0, 0, "mountain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + init_reports() + write_report(f) + assert_true(find_in_report(f, r.name .. " %(0,0%), Berg")) + remove_report(f) +end + +function test_lighthouse() + eressea.free_game() + local r = region.create(0, 0, "mountain") + local f = faction.create("noreply@eressea.de", "human", "de") + region.create(1, 0, "mountain") + region.create(2, 0, "ocean") + region.create(0, 1, "firewall") + region.create(3, 0, "mountain") + region.create(4, 0, "plain") + local u = unit.create(f, r, 1) + local b = building.create(r, "lighthouse") + b.size = 100 + b.working = true + u.building = b + u:set_skill("perception", 9) + u:add_item("money", 1000) + assert_not_nil(b) + + init_reports() + write_report(f) + assert_true(find_in_report(f, " %(1,0%) %(vom Turm erblickt%)")) + assert_true(find_in_report(f, " %(2,0%) %(vom Turm erblickt%)")) + assert_true(find_in_report(f, " %(3,0%) %(vom Turm erblickt%)")) + + assert_false(find_in_report(f, " %(0,0%) %(vom Turm erblickt%)")) + assert_false(find_in_report(f, " %(0,1%) %(vom Turm erblickt%)")) + assert_false(find_in_report(f, " %(4,0%) %(vom Turm erblickt%)")) + remove_report(f) +end + From 929db73102b49ad4e028696f07a4af73dfcdde84 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 14 Sep 2016 17:14:04 +0200 Subject: [PATCH 018/675] disable integration tests combine prepare_ functions --- s/travis-build | 11 ++++++++--- scripts/tests/process.lua | 14 +++++++------- src/reports.c | 30 ++++++++++++++---------------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/s/travis-build b/s/travis-build index 414a70f80..41975bc99 100755 --- a/s/travis-build +++ b/s/travis-build @@ -10,6 +10,12 @@ $BUILD/iniparser/inifile eressea.ini add lua:paths lunit:scripts fi } +integraton_tests() { +cd tests +./write-reports.sh +./run-turn.sh +} + set -e [ -z $BUILD ] && BUILD=Debug ; export BUILD s/cmake-init @@ -17,6 +23,5 @@ s/build cd $ROOT inifile s/runtests -cd tests -./write-reports.sh -./run-turn.sh + +# integraton_tests diff --git a/scripts/tests/process.lua b/scripts/tests/process.lua index bd5d45d65..63b96ddcd 100644 --- a/scripts/tests/process.lua +++ b/scripts/tests/process.lua @@ -23,19 +23,19 @@ local function assert_file(filename) os.remove(filename) end -function test_process_turn() +function disable_test_process_turn() u:add_order("NUMMER PARTEI 777") process_orders() assert_equal(0, init_reports()) assert_equal(0, write_reports()) assert_equal(0, eressea.write_game("test.dat")) assert_file("data/test.dat") - -- assert_file("reports/" .. get_turn() .. "-ii.nr") - -- assert_file("reports/" .. get_turn() .. "-ii.cr") - -- assert_file("reports/" .. get_turn() .. "-ii.txt") - -- assert_file("reports/" .. get_turn() .. "-777.nr") - -- assert_file("reports/" .. get_turn() .. "-777.cr") - -- assert_file("reports/" .. get_turn() .. "-777.txt") + assert_file("reports/" .. get_turn() .. "-ii.nr") + assert_file("reports/" .. get_turn() .. "-ii.cr") + assert_file("reports/" .. get_turn() .. "-ii.txt") + assert_file("reports/" .. get_turn() .. "-777.nr") + assert_file("reports/" .. get_turn() .. "-777.cr") + assert_file("reports/" .. get_turn() .. "-777.txt") assert_file("reports/reports.txt") os.remove("reports") os.remove("data") diff --git a/src/reports.c b/src/reports.c index c94b7e8ff..589053b1b 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1388,26 +1388,29 @@ static void cb_add_seen(region *r, unit *u, void *cbdata) { * this function may also update ctx->last and ctx->first for potential * lighthouses and travelthru reports */ -void prepare_seen(report_context *ctx) +static void prepare_report(report_context *ctx, faction *f) { - faction *f = ctx->f; region *r; building *b; static int config; static bool rule_region_owners; const struct building_type *bt_lighthouse = bt_find("lighthouse"); - // [fast,last) interval of regions with a unit in it - ctx->first = firstregion(f); - ctx->last = lastregion(f); if (config_changed(&config)) { rule_region_owners = config_token("rules.region_owner_pay_building", bt_lighthouse->_name); } + + ctx->f = f; + ctx->report_time = time(NULL); + ctx->addresses = NULL; + ctx->userdata = NULL; + // [first,last) interval of regions with a unit in it: + ctx->first = firstregion(f); + ctx->last = lastregion(f); + for (r = ctx->first; r!=ctx->last; r = r->next) { unit *u; - reorder_units(r); - if (fval(r, RF_LIGHTHOUSE)) { /* region owners get the report from lighthouses */ if (rule_region_owners && bt_lighthouse) { @@ -1451,15 +1454,6 @@ void prepare_seen(report_context *ctx) ctx->last = lastregion(f); } -static void prepare_report(report_context *ctx, faction *f) -{ - ctx->f = f; - ctx->report_time = time(NULL); - ctx->addresses = NULL; - ctx->userdata = NULL; - prepare_seen(ctx); -} - static void finish_reports(report_context *ctx) { region *r; ql_free(ctx->addresses); @@ -1549,8 +1543,12 @@ static void check_messages_exist(void) { int init_reports(void) { + region *r; check_messages_exist(); create_directories(); + for (r = regions; r; r = r->next) { + reorder_units(r); + } return 0; } From dfbc52020327d5475ae1f48c5a95a3b271043047 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 14 Sep 2016 21:46:57 +0200 Subject: [PATCH 019/675] add a simple test for prepare_report. TODO: it is _too_ simple. --- src/reports.c | 4 ++-- src/reports.h | 3 ++- src/reports.test.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/reports.c b/src/reports.c index 589053b1b..8a91bee63 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1388,7 +1388,7 @@ static void cb_add_seen(region *r, unit *u, void *cbdata) { * this function may also update ctx->last and ctx->first for potential * lighthouses and travelthru reports */ -static void prepare_report(report_context *ctx, faction *f) +void prepare_report(report_context *ctx, faction *f) { region *r; building *b; @@ -1454,7 +1454,7 @@ static void prepare_report(report_context *ctx, faction *f) ctx->last = lastregion(f); } -static void finish_reports(report_context *ctx) { +void finish_reports(report_context *ctx) { region *r; ql_free(ctx->addresses); for (r = ctx->first; r != ctx->last; r = r->next) { diff --git a/src/reports.h b/src/reports.h index 7e35d26f4..fd0efb591 100644 --- a/src/reports.h +++ b/src/reports.h @@ -74,7 +74,8 @@ extern "C" { time_t report_time; } report_context; - void prepare_seen(struct report_context *ctx); + void prepare_report(report_context *ctx, struct faction *f); + void finish_reports(report_context *ctx); typedef int(*report_fun) (const char *filename, report_context * ctx, const char *charset); diff --git a/src/reports.test.c b/src/reports.test.c index 5cd7eed6d..dff9256d3 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -222,9 +222,37 @@ static void test_arg_resources(CuTest *tc) { test_cleanup(); } +static void test_prepare_report(CuTest *tc) { + report_context ctx; + faction *f; + region *r; + unit *u; + + test_setup(); + f = test_create_faction(0); + r = test_create_region(0, 0, 0); + + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, 0, ctx.first); + CuAssertPtrEquals(tc, 0, ctx.last); + CuAssertIntEquals(tc, seen_none, r->seen.mode); + finish_reports(&ctx); + + u = test_create_unit(f, r); + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, r, ctx.first); + CuAssertPtrEquals(tc, 0, ctx.last); + CuAssertIntEquals(tc, seen_unit, r->seen.mode); + finish_reports(&ctx); + CuAssertIntEquals(tc, seen_none, r->seen.mode); + + test_cleanup(); +} + CuSuite *get_reports_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_prepare_report); SUITE_ADD_TEST(suite, test_reorder_units); SUITE_ADD_TEST(suite, test_seen_faction); SUITE_ADD_TEST(suite, test_regionid); From 2b9e5ffff9c0158fda1f9e62f2bf54608bf74524 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 15 Sep 2016 10:02:49 +0200 Subject: [PATCH 020/675] check seen_neighbour --- src/reports.test.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/reports.test.c b/src/reports.test.c index dff9256d3..b8df6792c 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -226,7 +226,6 @@ static void test_prepare_report(CuTest *tc) { report_context ctx; faction *f; region *r; - unit *u; test_setup(); f = test_create_faction(0); @@ -238,14 +237,22 @@ static void test_prepare_report(CuTest *tc) { CuAssertIntEquals(tc, seen_none, r->seen.mode); finish_reports(&ctx); - u = test_create_unit(f, r); + test_create_unit(f, r); prepare_report(&ctx, f); CuAssertPtrEquals(tc, r, ctx.first); CuAssertPtrEquals(tc, 0, ctx.last); CuAssertIntEquals(tc, seen_unit, r->seen.mode); finish_reports(&ctx); CuAssertIntEquals(tc, seen_none, r->seen.mode); - + finish_reports(&ctx); + + r = test_create_region(1, 0, 0); + CuAssertPtrEquals(tc, r, regions->next); + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, regions, ctx.first); + CuAssertPtrEquals(tc, r, ctx.last); + CuAssertIntEquals(tc, seen_neighbour, r->seen.mode); + test_cleanup(); } From 42bfc43e4f51c7292c90a5e76f01371e1603b1d5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 15 Sep 2016 13:01:08 +0200 Subject: [PATCH 021/675] test lighthouse preparation --- src/reports.test.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/reports.test.c b/src/reports.test.c index b8df6792c..1a8b35190 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -2,6 +2,7 @@ #include #include "reports.h" #include "move.h" +#include "lighthouse.h" #include "travelthru.h" #include "keyword.h" @@ -222,6 +223,34 @@ static void test_arg_resources(CuTest *tc) { test_cleanup(); } +static void test_prepare_lighthouse(CuTest *tc) { + report_context ctx; + faction *f; + region *r1, *r2, *r3; + unit *u; + building *b; + building_type *btype; + + test_setup(); + f = test_create_faction(0); + r1 = test_create_region(0, 0, 0); + r2 = test_create_region(1, 0, 0); + r3 = test_create_region(2, 0, 0); + btype = test_create_buildingtype("lighthouse"); + b = test_create_building(r1, btype); + b->size = 10; + u = test_create_unit(f, r1); + u->building = b; + update_lighthouse(b); + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, r1, ctx.first); + CuAssertPtrEquals(tc, r3, ctx.last); + CuAssertIntEquals(tc, seen_unit, r1->seen.mode); + CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode); + CuAssertIntEquals(tc, seen_none, r3->seen.mode); + test_cleanup(); +} + static void test_prepare_report(CuTest *tc) { report_context ctx; faction *f; @@ -260,6 +289,7 @@ CuSuite *get_reports_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_prepare_report); + SUITE_ADD_TEST(suite, test_prepare_lighthouse); SUITE_ADD_TEST(suite, test_reorder_units); SUITE_ADD_TEST(suite, test_seen_faction); SUITE_ADD_TEST(suite, test_regionid); From d8d3cd4cc40d10a1bd4e49324933edfae60b0c9d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 15 Sep 2016 20:11:38 +0200 Subject: [PATCH 022/675] move version string into a single object file --- src/creport.c | 2 +- src/kernel/save.c | 2 +- src/kernel/version.c | 10 ++++++++++ src/kernel/version.h | 5 +---- src/main.c | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 src/kernel/version.c diff --git a/src/creport.c b/src/creport.c index 98ce770df..51169ef0c 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1509,7 +1509,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset) fprintf(F, "%d;Basis\n", 36); fprintf(F, "%d;Runde\n", turn); fprintf(F, "%d;Zeitalter\n", era); - fprintf(F, "\"%s\";Build\n", ERESSEA_VERSION); + fprintf(F, "\"%s\";Build\n", eressea_version()); if (mailto != NULL) { fprintf(F, "\"%s\";mailto\n", mailto); fprintf(F, "\"%s\";mailcmd\n", LOC(f->locale, "mailcmd")); diff --git a/src/kernel/save.c b/src/kernel/save.c index 5121e02ed..bffc339f9 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1898,7 +1898,7 @@ int writegame(const char *filename) fstream_init(&strm, F); binstore_init(&store, &strm); - WRITE_INT(&store, version_no(ERESSEA_VERSION)); + WRITE_INT(&store, version_no(eressea_version())); n = write_game(&gdata); binstore_done(&store); fstream_done(&strm); diff --git a/src/kernel/version.c b/src/kernel/version.c new file mode 100644 index 000000000..95d61f014 --- /dev/null +++ b/src/kernel/version.c @@ -0,0 +1,10 @@ +#include "version.h" + +#ifndef ERESSEA_VERSION +// the version number, if it was not passed to make with -D +#define ERESSEA_VERSION "3.10.0-devel" +#endif + +const char *eressea_version(void) { + return ERESSEA_VERSION; +} diff --git a/src/kernel/version.h b/src/kernel/version.h index 5b3bf0cf6..f71177f9f 100644 --- a/src/kernel/version.h +++ b/src/kernel/version.h @@ -10,7 +10,4 @@ without prior permission by the authors of Eressea. */ -#ifndef ERESSEA_VERSION -// the version number, if it was not passed to make with -D -#define ERESSEA_VERSION "3.10.0-devel" -#endif +const char *eressea_version(void); diff --git a/src/main.c b/src/main.c index d3d2cbe50..58a15edc0 100644 --- a/src/main.c +++ b/src/main.c @@ -166,7 +166,7 @@ static int parse_args(int argc, char **argv, int *exitcode) printf("\n%s PBEM host\n" "Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n" "Compilation: " __DATE__ " at " __TIME__ "\nVersion: %s\n\n", - game_name(), ERESSEA_VERSION); + game_name(), eressea_version()); #ifdef USE_CURSES } else if (strcmp(argi + 2, "color") == 0) { From 77e39fc64bb4e4fe3e661f132edaa9eef6c6e0c9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 15 Sep 2016 20:14:17 +0200 Subject: [PATCH 023/675] use add_definitions instead of CMAKE_C_FLAGS, define ERESSEA_VERSION only on version.c --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 12 +++++++----- src/kernel/CMakeLists.txt | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7edf32d4f..1ad7b3528 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ CONFIGURE_FILE ( ${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in ${CMAKE_BINARY_DIR}/include/autoconf.h) INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_AUTOCONF") +add_definitions(-DUSE_AUTOCONF) add_subdirectory (cutest) add_subdirectory (cJSON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 591aa122e..022e1b512 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,14 +13,16 @@ include_directories (${BSON_INCLUDE_DIR}) include_directories (${INIPARSER_INCLUDE_DIR}) IF(DEFINED ERESSEA_VERSION) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DERESSEA_VERSION=\\\"${ERESSEA_VERSION}\\\"") +set_source_files_properties(kernel/version.c PROPERTIES +COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}") ENDIF() IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DHAVE__BOOL") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") + add_definitions(-DHAVE__BOOL) ELSEIF(MSVC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP") set(CMAKE_EXE_LINKER_FLAGS_DEBUG @@ -250,18 +252,18 @@ install(TARGETS eressea DESTINATION "bin") if (SQLITE3_FOUND) target_link_libraries(eressea ${SQLITE3_LIBRARIES}) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SQLITE") +add_definitions(-DUSE_SQLITE) endif(SQLITE3_FOUND) if (CURSES_FOUND) include_directories (${CURSES_INCLUDE_DIR}) target_link_libraries(eressea ${CURSES_LIBRARIES}) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CURSES") +add_definitions(-DUSE_CURSES) endif(CURSES_FOUND) if (LIBXML2_FOUND) include_directories (${LIBXML2_INCLUDE_DIR}) target_link_libraries(eressea ${LIBXML2_LIBRARIES}) target_link_libraries(test_eressea ${LIBXML2_LIBRARIES}) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_LIBXML2") +add_definitions(-DUSE_LIBXML2) endif (LIBXML2_FOUND) diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 9e829d4f4..016c8fb18 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -33,6 +33,7 @@ jsonconf.test.c ) SET(_FILES +version.c alliance.c ally.c build.c From 3f86014e9d05d99aa0dce3e84519e6dfa37b43f7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 15 Sep 2016 21:16:37 +0200 Subject: [PATCH 024/675] delete files created by report_summary --- src/summary.test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/summary.test.c b/src/summary.test.c index 33dc874b3..93c4d4c84 100644 --- a/src/summary.test.c +++ b/src/summary.test.c @@ -17,6 +17,8 @@ static void test_summary(CuTest * tc) sum = make_summary(); report_summary(sum, sum, true); CuAssertIntEquals(tc, 0, remove("parteien.full")); + CuAssertIntEquals(tc, 0, remove("datum")); + CuAssertIntEquals(tc, 0, remove("turn")); free_summary(sum); test_cleanup(); } From dbde14fdff50e035a15565c605bc1938ec0e01b3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 09:39:59 +0200 Subject: [PATCH 025/675] smarter version.c build that avoids full rebuilds. --- src/CMakeLists.txt | 5 ++++- src/kernel/CMakeLists.txt | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 022e1b512..41ca5b49b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -171,7 +171,10 @@ set (SERVER_SRC ${SERVER_SRC} ) endif(CURSES_FOUND) -add_library(game ${ERESSEA_SRC}) +add_library(version OBJECT ${VERSION_SRC}) +add_library(game ${ERESSEA_SRC} + $ +) add_executable(eressea ${SERVER_SRC}) target_link_libraries(eressea game diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 016c8fb18..2c9da7dc0 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -33,7 +33,6 @@ jsonconf.test.c ) SET(_FILES -version.c alliance.c ally.c build.c @@ -65,6 +64,8 @@ xmlreader.c jsonconf.c ) +SET(VERSION_SRC ${PROJECT_NAME}/version.c PARENT_SCOPE) + FOREACH(_FILE ${_FILES}) LIST(APPEND _SOURCES ${PROJECT_NAME}/${_FILE}) ENDFOREACH(_FILE) From 00a3a934f5c5e501c28c26ad4b9119338cc829ab Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 09:49:53 +0200 Subject: [PATCH 026/675] require cmake version 2.8.8 (add_library OBJECT ...) --- s/travis-build | 1 + src/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/s/travis-build b/s/travis-build index 41975bc99..4c6dbcee8 100755 --- a/s/travis-build +++ b/s/travis-build @@ -18,6 +18,7 @@ cd tests set -e [ -z $BUILD ] && BUILD=Debug ; export BUILD +cmake --version s/cmake-init s/build cd $ROOT diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 41ca5b49b..8a7c6a46a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.8) project (server C) include_directories (${CMAKE_CURRENT_SOURCE_DIR}) From bf59b1adf9c226130c2374839bfe1cd67fbf6c71 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 10:55:38 +0200 Subject: [PATCH 027/675] fix travis build by not depending on CMake 2.8.8 --- src/CMakeLists.txt | 9 ++++----- src/kernel/CMakeLists.txt | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a7c6a46a..db95aa884 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.8) +cmake_minimum_required(VERSION 2.8) project (server C) include_directories (${CMAKE_CURRENT_SOURCE_DIR}) @@ -171,11 +171,10 @@ set (SERVER_SRC ${SERVER_SRC} ) endif(CURSES_FOUND) -add_library(version OBJECT ${VERSION_SRC}) -add_library(game ${ERESSEA_SRC} - $ -) +add_library(version STATIC ${VERSION_SRC}) +add_library(game ${ERESSEA_SRC}) add_executable(eressea ${SERVER_SRC}) +target_link_libraries(game version) target_link_libraries(eressea game ${TOLUA_LIBRARIES} diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 2c9da7dc0..6bb860ad7 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 2.6) project(kernel C) SET(_TEST_FILES From 318cf68e1b482c88add407a753e03668a4950298 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 15 Sep 2016 20:11:38 +0200 Subject: [PATCH 028/675] move version string into a single object file --- src/creport.c | 2 +- src/kernel/save.c | 2 +- src/kernel/version.c | 10 ++++++++++ src/kernel/version.h | 5 +---- src/main.c | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 src/kernel/version.c diff --git a/src/creport.c b/src/creport.c index 4cf778f23..2c49caf44 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1515,7 +1515,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset) fprintf(F, "%d;Basis\n", 36); fprintf(F, "%d;Runde\n", turn); fprintf(F, "%d;Zeitalter\n", era); - fprintf(F, "\"%s\";Build\n", ERESSEA_VERSION); + fprintf(F, "\"%s\";Build\n", eressea_version()); if (mailto != NULL) { fprintf(F, "\"%s\";mailto\n", mailto); fprintf(F, "\"%s\";mailcmd\n", LOC(f->locale, "mailcmd")); diff --git a/src/kernel/save.c b/src/kernel/save.c index 5121e02ed..bffc339f9 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1898,7 +1898,7 @@ int writegame(const char *filename) fstream_init(&strm, F); binstore_init(&store, &strm); - WRITE_INT(&store, version_no(ERESSEA_VERSION)); + WRITE_INT(&store, version_no(eressea_version())); n = write_game(&gdata); binstore_done(&store); fstream_done(&strm); diff --git a/src/kernel/version.c b/src/kernel/version.c new file mode 100644 index 000000000..95d61f014 --- /dev/null +++ b/src/kernel/version.c @@ -0,0 +1,10 @@ +#include "version.h" + +#ifndef ERESSEA_VERSION +// the version number, if it was not passed to make with -D +#define ERESSEA_VERSION "3.10.0-devel" +#endif + +const char *eressea_version(void) { + return ERESSEA_VERSION; +} diff --git a/src/kernel/version.h b/src/kernel/version.h index 5b3bf0cf6..f71177f9f 100644 --- a/src/kernel/version.h +++ b/src/kernel/version.h @@ -10,7 +10,4 @@ without prior permission by the authors of Eressea. */ -#ifndef ERESSEA_VERSION -// the version number, if it was not passed to make with -D -#define ERESSEA_VERSION "3.10.0-devel" -#endif +const char *eressea_version(void); diff --git a/src/main.c b/src/main.c index d3d2cbe50..58a15edc0 100644 --- a/src/main.c +++ b/src/main.c @@ -166,7 +166,7 @@ static int parse_args(int argc, char **argv, int *exitcode) printf("\n%s PBEM host\n" "Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n" "Compilation: " __DATE__ " at " __TIME__ "\nVersion: %s\n\n", - game_name(), ERESSEA_VERSION); + game_name(), eressea_version()); #ifdef USE_CURSES } else if (strcmp(argi + 2, "color") == 0) { From 10916bb0a15454ee140a63786623b0ebe5e10f92 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 15 Sep 2016 20:14:17 +0200 Subject: [PATCH 029/675] use add_definitions instead of CMAKE_C_FLAGS, define ERESSEA_VERSION only on version.c --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 12 +++++++----- src/kernel/CMakeLists.txt | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7edf32d4f..1ad7b3528 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ CONFIGURE_FILE ( ${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in ${CMAKE_BINARY_DIR}/include/autoconf.h) INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_AUTOCONF") +add_definitions(-DUSE_AUTOCONF) add_subdirectory (cutest) add_subdirectory (cJSON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f1414c851..4070dcbd6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,14 +13,16 @@ include_directories (${BSON_INCLUDE_DIR}) include_directories (${INIPARSER_INCLUDE_DIR}) IF(DEFINED ERESSEA_VERSION) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DERESSEA_VERSION=\\\"${ERESSEA_VERSION}\\\"") +set_source_files_properties(kernel/version.c PROPERTIES +COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}") ENDIF() IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DHAVE__BOOL") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") + add_definitions(-DHAVE__BOOL) ELSEIF(MSVC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP") set(CMAKE_EXE_LINKER_FLAGS_DEBUG @@ -251,18 +253,18 @@ install(TARGETS eressea DESTINATION "bin") if (SQLITE3_FOUND) target_link_libraries(eressea ${SQLITE3_LIBRARIES}) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SQLITE") +add_definitions(-DUSE_SQLITE) endif(SQLITE3_FOUND) if (CURSES_FOUND) include_directories (${CURSES_INCLUDE_DIR}) target_link_libraries(eressea ${CURSES_LIBRARIES}) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CURSES") +add_definitions(-DUSE_CURSES) endif(CURSES_FOUND) if (LIBXML2_FOUND) include_directories (${LIBXML2_INCLUDE_DIR}) target_link_libraries(eressea ${LIBXML2_LIBRARIES}) target_link_libraries(test_eressea ${LIBXML2_LIBRARIES}) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_LIBXML2") +add_definitions(-DUSE_LIBXML2) endif (LIBXML2_FOUND) diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 9e829d4f4..016c8fb18 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -33,6 +33,7 @@ jsonconf.test.c ) SET(_FILES +version.c alliance.c ally.c build.c From 47526dd36b83213665a88f8dd59c162afb4a205a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 09:39:59 +0200 Subject: [PATCH 030/675] smarter version.c build that avoids full rebuilds. --- src/CMakeLists.txt | 5 ++++- src/kernel/CMakeLists.txt | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4070dcbd6..ef3bc782f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -173,7 +173,10 @@ set (SERVER_SRC ${SERVER_SRC} ) endif(CURSES_FOUND) -add_library(game ${ERESSEA_SRC}) +add_library(version OBJECT ${VERSION_SRC}) +add_library(game ${ERESSEA_SRC} + $ +) add_executable(eressea ${SERVER_SRC}) target_link_libraries(eressea game diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 016c8fb18..2c9da7dc0 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -33,7 +33,6 @@ jsonconf.test.c ) SET(_FILES -version.c alliance.c ally.c build.c @@ -65,6 +64,8 @@ xmlreader.c jsonconf.c ) +SET(VERSION_SRC ${PROJECT_NAME}/version.c PARENT_SCOPE) + FOREACH(_FILE ${_FILES}) LIST(APPEND _SOURCES ${PROJECT_NAME}/${_FILE}) ENDFOREACH(_FILE) From dc004b2d7191485d65b88491f29b4ae8bcb185e4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 09:49:53 +0200 Subject: [PATCH 031/675] require cmake version 2.8.8 (add_library OBJECT ...) --- s/travis-build | 1 + src/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/s/travis-build b/s/travis-build index 414a70f80..f2ec7e487 100755 --- a/s/travis-build +++ b/s/travis-build @@ -12,6 +12,7 @@ fi set -e [ -z $BUILD ] && BUILD=Debug ; export BUILD +cmake --version s/cmake-init s/build cd $ROOT diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ef3bc782f..e12f8971f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.8) project (server C) include_directories (${CMAKE_CURRENT_SOURCE_DIR}) From b0799bd152a5654e33703673ef81658c997dc27b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 10:55:38 +0200 Subject: [PATCH 032/675] fix travis build by not depending on CMake 2.8.8 --- src/CMakeLists.txt | 9 ++++----- src/kernel/CMakeLists.txt | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e12f8971f..e4d90c069 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.8) +cmake_minimum_required(VERSION 2.8) project (server C) include_directories (${CMAKE_CURRENT_SOURCE_DIR}) @@ -173,11 +173,10 @@ set (SERVER_SRC ${SERVER_SRC} ) endif(CURSES_FOUND) -add_library(version OBJECT ${VERSION_SRC}) -add_library(game ${ERESSEA_SRC} - $ -) +add_library(version STATIC ${VERSION_SRC}) +add_library(game ${ERESSEA_SRC}) add_executable(eressea ${SERVER_SRC}) +target_link_libraries(game version) target_link_libraries(eressea game ${TOLUA_LIBRARIES} diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 2c9da7dc0..6bb860ad7 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 2.6) project(kernel C) SET(_TEST_FILES From 55df24ffb8e9970eefddb386b532712a8aae55d4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 16:54:41 +0200 Subject: [PATCH 033/675] all code review nitpicks fixed. --- s/runtests | 2 +- s/travis-build | 1 - src/CMakeLists.txt | 2 +- src/kernel/save.c | 6 ------ src/kernel/save.h | 1 - src/kernel/save.test.c | 1 + src/kernel/version.c | 7 +++++++ src/kernel/version.h | 14 +++++++++----- 8 files changed, 19 insertions(+), 15 deletions(-) diff --git a/s/runtests b/s/runtests index d0b3432e8..2f22402dc 100755 --- a/s/runtests +++ b/s/runtests @@ -20,6 +20,6 @@ $ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests.lua $ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e2.lua $ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e3.lua $ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e4.lua -rm -rf data reports orders.txt score score.alliances +rm -rf data reports orders.txt score score.alliances datum turn cd $OLDWPD diff --git a/s/travis-build b/s/travis-build index f2ec7e487..414a70f80 100755 --- a/s/travis-build +++ b/s/travis-build @@ -12,7 +12,6 @@ fi set -e [ -z $BUILD ] && BUILD=Debug ; export BUILD -cmake --version s/cmake-init s/build cd $ROOT diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e4d90c069..11bd860ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.6) project (server C) include_directories (${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/kernel/save.c b/src/kernel/save.c index bffc339f9..b9b522794 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1858,12 +1858,6 @@ static void clear_npc_orders(faction *f) } } -int version_no(const char *str) { - int maj = 0, min = 0, bld = 0; - sscanf(str, "%d.%d.%d", &maj, &min, &bld); - return (maj << 16) | (min << 8) | bld; -} - int writegame(const char *filename) { int n; diff --git a/src/kernel/save.h b/src/kernel/save.h index 27dd56661..3cd443926 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -79,7 +79,6 @@ extern "C" { int write_game(struct gamedata *data); int read_game(struct gamedata *data); - int version_no(const char *str); /* test-only functions that give access to internal implementation details (BAD) */ void _test_write_password(struct gamedata *data, const struct faction *f); diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index 95acbd4c0..00b5ff96c 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -5,6 +5,7 @@ #include #include "save.h" +#include "version.h" #include "unit.h" #include "group.h" #include "ally.h" diff --git a/src/kernel/version.c b/src/kernel/version.c index 95d61f014..220e113f7 100644 --- a/src/kernel/version.c +++ b/src/kernel/version.c @@ -1,5 +1,6 @@ #include "version.h" +#include #ifndef ERESSEA_VERSION // the version number, if it was not passed to make with -D #define ERESSEA_VERSION "3.10.0-devel" @@ -8,3 +9,9 @@ const char *eressea_version(void) { return ERESSEA_VERSION; } + +int version_no(const char *str) { + int maj = 0, min = 0, bld = 0; + sscanf(str, "%d.%d.%d", &maj, &min, &bld); + return (maj << 16) | (min << 8) | bld; +} diff --git a/src/kernel/version.h b/src/kernel/version.h index f71177f9f..c268e7bac 100644 --- a/src/kernel/version.h +++ b/src/kernel/version.h @@ -1,13 +1,17 @@ +#pragma once /* +-------------------+ | | Enno Rehling | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2007 | Christian Schlittchen - | | + | (c) 1998 - 2016 | Christian Schlittchen + | | https://github.com/eressea/server +-------------------+ - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. */ +#ifndef H_KERNEL_VERSION +#define H_KERNEL_VERSION + const char *eressea_version(void); +int version_no(const char *str); + +#endif From 1dac556d09f3d2fac03804f49267e9a7a3c3b903 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 17:11:33 +0200 Subject: [PATCH 034/675] Fix MSVC compilation (always include platform-specific hacks). --- src/kernel/version.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kernel/version.c b/src/kernel/version.c index 220e113f7..022b5087d 100644 --- a/src/kernel/version.c +++ b/src/kernel/version.c @@ -1,3 +1,4 @@ +#include #include "version.h" #include From 007f4d8b0dd8493951fd62a4859670d9e0bfd608 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 17:25:40 +0200 Subject: [PATCH 035/675] test that travelthru notifications will make it into the report. --- src/reports.test.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/reports.test.c b/src/reports.test.c index 1a8b35190..aed289972 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -223,6 +223,28 @@ static void test_arg_resources(CuTest *tc) { test_cleanup(); } +static void test_prepare_travelthru(CuTest *tc) { + report_context ctx; + faction *f; + region *r1, *r2, *r3; + unit *u; + + test_setup(); + f = test_create_faction(0); + r1 = test_create_region(0, 0, 0); + r2 = test_create_region(1, 0, 0); + r3 = test_create_region(2, 0, 0); + u = test_create_unit(f, r1); + travelthru_add(r2, u); + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, r1, ctx.first); + CuAssertPtrEquals(tc, r3, ctx.last); + CuAssertIntEquals(tc, seen_unit, r1->seen.mode); + CuAssertIntEquals(tc, seen_travel, r2->seen.mode); + CuAssertIntEquals(tc, seen_none, r3->seen.mode); + test_cleanup(); +} + static void test_prepare_lighthouse(CuTest *tc) { report_context ctx; faction *f; @@ -290,6 +312,7 @@ CuSuite *get_reports_suite(void) CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_prepare_report); SUITE_ADD_TEST(suite, test_prepare_lighthouse); + SUITE_ADD_TEST(suite, test_prepare_travelthru); SUITE_ADD_TEST(suite, test_reorder_units); SUITE_ADD_TEST(suite, test_seen_faction); SUITE_ADD_TEST(suite, test_regionid); From d449ce4a8c142491e68e29dafabc1976f4464061 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 18:03:28 +0200 Subject: [PATCH 036/675] re-enable report writing, fix report.c to work without seen_region --- src/CMakeLists.txt | 4 +- src/eressea.c | 4 +- src/kernel/region.c | 6 +-- src/kernel/region.h | 2 +- src/report.c | 118 +++++++++++++++++++----------------------- src/reports.c | 13 ++--- src/reports.h | 2 +- src/travelthru.c | 2 +- src/travelthru.h | 2 +- src/travelthru.test.c | 2 +- 10 files changed, 70 insertions(+), 85 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index db95aa884..aa13bc3a4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -105,7 +105,7 @@ set (ERESSEA_SRC skill.c json.c # creport.c -# report.c + report.c economy.c give.c items.c @@ -200,7 +200,7 @@ set(TESTS_SRC volcano.test.c reports.test.c # creport.test.c -# report.test.c + report.test.c summary.test.c travelthru.test.c callback.test.c diff --git a/src/eressea.c b/src/eressea.c index 13c4a15ae..409254aea 100755 --- a/src/eressea.c +++ b/src/eressea.c @@ -30,7 +30,7 @@ #include "chaos.h" #include "items.h" //#include "creport.h" -//#include "report.h" +#include "report.h" #include "names.h" #include "reports.h" #include "spells.h" @@ -64,7 +64,7 @@ void game_init(void) register_triggers(); register_xmas(); -// register_nr(); + register_nr(); // register_cr(); register_races(); diff --git a/src/kernel/region.c b/src/kernel/region.c index d6aa9ef27..4c66e04f8 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -697,13 +697,11 @@ void r_setdemand(region * r, const luxury_type * ltype, int value) d->value = value; } -const item_type *r_luxury(region * r) +const item_type *r_luxury(const region * r) { struct demand *dmd; if (r->land) { - if (!r->land->demands) { - fix_demand(r); - } + assert(r->land->demands || !"need to call fix_demands on a region"); for (dmd = r->land->demands; dmd; dmd = dmd->next) { if (dmd->value == 0) return dmd->type->itype; diff --git a/src/kernel/region.h b/src/kernel/region.h index 01f1c0ae9..163b6c22c 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -274,7 +274,7 @@ extern "C" { int value); int owner_change(const region * r); bool is_mourning(const region * r, int in_turn); - const struct item_type *r_luxury(struct region *r); + const struct item_type *r_luxury(const struct region *r); void get_neighbours(const struct region *r, struct region **list); struct faction *update_owners(struct region *r); diff --git a/src/report.c b/src/report.c index d1147ad71..345a76e10 100644 --- a/src/report.c +++ b/src/report.c @@ -21,6 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include "report.h" #include "reports.h" #include "laws.h" #include "travelthru.h" @@ -169,7 +170,7 @@ static void centre(stream *out, const char *s, bool breaking) static void paragraph(stream *out, const char *str, ptrdiff_t indent, int hanging_indent, -char marker) + char marker) { size_t length = REPORTWIDTH; const char *end, *begin, *mark = 0; @@ -716,7 +717,7 @@ nr_unit(stream *out, const faction * f, const unit * u, int indent, seen_mode mo static void rp_messages(stream *out, message_list * msgs, faction * viewer, int indent, -bool categorized) + bool categorized) { nrsection *section; @@ -809,7 +810,7 @@ static void prices(stream *out, const region * r, const faction * f) if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - for (dmd = r->land->demands; dmd; dmd = dmd->next){ + for (dmd = r->land->demands; dmd; dmd = dmd->next) { if (dmd->value > 0) { m = msg_message("nr_market_price", "product price", dmd->type->itype->rtype, dmd->value * dmd->type->price); @@ -937,14 +938,14 @@ static void describe(stream *out, const region * r, faction * f) if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - if (sr->mode == see_travel) { - bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel")); + if (r->seen.mode == seen_travel) { + bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "seen_travel")); } - else if (sr->mode == see_neighbour) { + else if (r->seen.mode == seen_neighbour) { bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour")); } - else if (sr->mode == see_lighthouse) { - bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse")); + else if (r->seen.mode == seen_lighthouse) { + bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "seen_lighthouse")); } else { bytes = 0; @@ -991,9 +992,9 @@ static void describe(stream *out, const region * r, faction * f) } /* iron & stone */ - if (sr->mode == see_unit) { + if (r->seen.mode == seen_unit) { resource_report result[MAX_RAWMATERIALS]; - int n, numresults = report_resources(sr, result, MAX_RAWMATERIALS, f); + int n, numresults = report_resources(r, result, MAX_RAWMATERIALS, f, true); for (n = 0; n < numresults; ++n) { if (result[n].number >= 0 && result[n].level >= 0) { @@ -1026,7 +1027,7 @@ static void describe(stream *out, const region * r, faction * f) bytes = (int)strlcpy(bufp, LOC(f->locale, n == 1 ? "rc_orc" : "rc_orc_p"), - size); + size); } else { bytes = (int)strlcpy(bufp, " ", size); @@ -1034,7 +1035,7 @@ static void describe(stream *out, const region * r, faction * f) WARN_STATIC_BUFFER(); bytes = (int)strlcpy(bufp, LOC(f->locale, n == 1 ? "peasant" : "peasant_p"), - size); + size); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1044,13 +1045,13 @@ static void describe(stream *out, const region * r, faction * f) WARN_STATIC_BUFFER(); } } - if (rmoney(r) && sr->mode >= see_travel) { + if (rmoney(r) && r->seen.mode >= seen_travel) { bytes = _snprintf(bufp, size, ", %d ", rmoney(r)); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); bytes = (int)strlcpy(bufp, LOC(f->locale, resourcename(get_resourcetype(R_SILVER), - rmoney(r) != 1)), size); + rmoney(r) != 1)), size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } @@ -1189,7 +1190,7 @@ static void describe(stream *out, const region * r, faction * f) *bufp = 0; paragraph(out, buf, 0, 0, 0); - if (sr->mode == see_unit && is_astral(r) && + if (r->seen.mode == seen_unit && is_astral(r) && !is_cursed(r->attribs, C_ASTRALBLOCK, 0)) { /* Sonderbehandlung Teleport-Ebene */ region_list *rl = astralregions(r, inhabitable); @@ -1392,7 +1393,6 @@ report_template(const char *filename, report_context * ctx, const char *charset) region *r; FILE *F = fopen(filename, "w"); stream strm = { 0 }, *out = &strm; - seen_region *sr = NULL; char buf[8192], *bufp; size_t size; int bytes; @@ -1424,16 +1424,11 @@ report_template(const char *filename, report_context * ctx, const char *charset) rps_nowrap(out, buf); newline(out); - for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) { - sr = find_seen(ctx->f->seen, r); - } - - for (; sr != NULL; sr = sr->next) { - region *r = sr->r; + for (r = ctx->first; r != ctx->last; r = r->next) { unit *u; int dh = 0; - if (sr->mode < see_unit) + if (r->seen.mode < seen_unit) continue; for (u = r->units; u; u = u->next) { @@ -1778,10 +1773,9 @@ static void list_address(stream *out, const faction * uf, quicklist * seenfactio } static void -nr_ship(stream *out, const seen_region * sr, const ship * sh, const faction * f, -const unit * captain) +nr_ship(stream *out, const region *r, const ship * sh, const faction * f, + const unit * captain) { - const region *r = sr->r; char buffer[8192], *bufp = buffer; size_t size = sizeof(buffer) - 1; int bytes; @@ -1800,7 +1794,7 @@ const unit * captain) else { bytes = _snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale, - sh->type->_name)); + sh->type->_name)); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1852,8 +1846,7 @@ const unit * captain) } static void -nr_building(stream *out, const seen_region * sr, const building * b, -const faction * f) +nr_building(stream *out, const region *r, const building *b, const faction *f) { int i, bytes; const char *name, *bname, *billusion = NULL; @@ -1867,7 +1860,7 @@ const faction * f) newline(out); bytes = _snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang, - "nr_size"), b->size); + "nr_size"), b->size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1893,7 +1886,7 @@ const faction * f) WARN_STATIC_BUFFER(); } - if (b->besieged > 0 && sr->mode >= see_lighthouse) { + if (b->besieged > 0 && r->seen.mode >= seen_lighthouse) { msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged, b->besieged - b->size * SIEGEFACTOR); bytes = (int)nr_render(msg, lang, bufp, size, f); @@ -1920,11 +1913,9 @@ const faction * f) *bufp = 0; paragraph(out, buffer, 2, 0, 0); - if (sr->mode < see_lighthouse) - return; - - i = 0; - nr_curses(out, 4, f, TYP_BUILDING, b); + if (r->seen.mode >= seen_lighthouse) { + nr_curses(out, 4, f, TYP_BUILDING, b); + } } static void nr_paragraph(stream *out, message * m, faction * f) @@ -1960,7 +1951,7 @@ static void init_cb(cb_data *data, stream *out, char *buffer, size_t size, const data->counter = 0; } -static void cb_write_travelthru(region *r, unit *u, void *cbdata) { +static void cb_write_travelthru(const region *r, unit *u, void *cbdata) { cb_data *data = (cb_data *)cbdata; const faction *f = data->f; @@ -2015,7 +2006,7 @@ static void cb_write_travelthru(region *r, unit *u, void *cbdata) { } } -void write_travelthru(stream *out, region * r, const faction * f) +void write_travelthru(stream *out, const region *r, const faction *f) { int maxtravel; char buf[8192]; @@ -2033,7 +2024,7 @@ void write_travelthru(stream *out, region * r, const faction * f) init_cb(&cbdata, out, buf, sizeof(buf), f); cbdata.maxtravel = maxtravel; - cbdata.writep += + cbdata.writep += strlcpy(buf, LOC(f->locale, "travelthru_header"), sizeof(buf)); travelthru_map(r, cb_write_travelthru, &cbdata); return; @@ -2042,7 +2033,7 @@ void write_travelthru(stream *out, region * r, const faction * f) int report_plaintext(const char *filename, report_context * ctx, -const char *charset) + const char *charset) { int flag = 0; char ch; @@ -2058,7 +2049,6 @@ const char *charset) int wants_stats = (f->options & ix); FILE *F = fopen(filename, "w"); stream strm = { 0 }, *out = &strm; - seen_region *sr = NULL; char buf[8192]; char *bufp; bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0; @@ -2066,7 +2056,7 @@ const char *charset) int thisseason; int nextseason; gamedate date; - + get_gamedate(turn + 1, &date); thisseason = date.season; get_gamedate(turn + 2, &date); @@ -2148,8 +2138,8 @@ const char *charset) if (f_get_alliance(f)) { m = msg_message("nr_alliance", "leader name id age", - alliance_get_leader(f->alliance), f->alliance->name, f->alliance->id, - turn - f->alliance_joindate); + alliance_get_leader(f->alliance), f->alliance->name, f->alliance->id, + turn - f->alliance_joindate); nr_render(m, f->locale, buf, sizeof(buf), f); msg_release(m); centre(out, buf, true); @@ -2286,22 +2276,18 @@ const char *charset) CHECK_ERRNO(); anyunits = 0; - for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) { - sr = find_seen(ctx->f->seen, r); - } - for (; sr != NULL; sr = sr->next) { - region *r = sr->r; - int stealthmod = stealth_modifier(sr->mode); + for (r = ctx->first; r != ctx->last; r = r->next) { + int stealthmod = stealth_modifier(r->seen.mode); building *b = r->buildings; ship *sh = r->ships; - if (sr->mode < see_lighthouse) + if (r->seen.mode < seen_lighthouse) continue; /* Beschreibung */ - if (sr->mode == see_unit) { + if (r->seen.mode == seen_unit) { anyunits = 1; - describe(out, sr, f); + describe(out, r, f); if (markets_module() && r->land) { const item_type *lux = r_luxury(r); const item_type *herb = r->land->herbtype; @@ -2331,27 +2317,27 @@ const char *charset) write_travelthru(out, r, f); } else { - if (sr->mode == see_far) { - describe(out, sr, f); + if (r->seen.mode == seen_far) { + describe(out, r, f); newline(out); guards(out, r, f); newline(out); write_travelthru(out, r, f); } else { - describe(out, sr, f); + describe(out, r, f); newline(out); write_travelthru(out, r, f); } } /* Statistik */ - if (wants_stats && sr->mode == see_unit) + if (wants_stats && r->seen.mode == seen_unit) statistics(out, r, f); /* Nachrichten an REGION in der Region */ - if (sr->mode == see_unit || sr->mode == see_travel) { + if (r->seen.mode == seen_unit || r->seen.mode == seen_travel) { // TODO: Bug 2073 message_list *mlist = r_getmessages(r, f); if (mlist) { @@ -2368,13 +2354,13 @@ const char *charset) u = r->units; while (b) { while (b && (!u || u->building != b)) { - nr_building(out, sr, b, f); + nr_building(out, r, b, f); b = b->next; } if (b) { - nr_building(out, sr, b, f); + nr_building(out, r, b, f); while (u && u->building == b) { - nr_unit(out, f, u, 6, sr->mode); + nr_unit(out, f, u, 6, r->seen.mode); u = u->next; } b = b->next; @@ -2383,7 +2369,7 @@ const char *charset) while (u && !u->ship) { if (stealthmod > INT_MIN) { if (u->faction == f || cansee(f, r, u, stealthmod)) { - nr_unit(out, f, u, 4, sr->mode); + nr_unit(out, f, u, 4, r->seen.mode); } } assert(!u->building); @@ -2391,13 +2377,13 @@ const char *charset) } while (sh) { while (sh && (!u || u->ship != sh)) { - nr_ship(out, sr, sh, f, NULL); + nr_ship(out, r, sh, f, NULL); sh = sh->next; } if (sh) { - nr_ship(out, sr, sh, f, u); + nr_ship(out, r, sh, f, u); while (u && u->ship == sh) { - nr_unit(out, f, u, 6, sr->mode); + nr_unit(out, f, u, 6, r->seen.mode); u = u->next; } sh = sh->next; @@ -2459,7 +2445,7 @@ unit *can_find(faction * f, faction * f2) if (ss) { /* bei TARNE PARTEI yxz muss die Partei von unit proof nicht * wirklich Partei f2 sein! */ - /* assert(ss->proof->faction==f2); */ + /* assert(ss->proof->faction==f2); */ return ss->proof; } return NULL; diff --git a/src/reports.c b/src/reports.c index 8a91bee63..52f5f1dfe 100644 --- a/src/reports.c +++ b/src/reports.c @@ -971,7 +971,7 @@ typedef struct address_data { int stealthmod; } address_data; -static void cb_add_address(region *r, unit *ut, void *cbdata) { +static void cb_add_address(const region *r, unit *ut, void *cbdata) { address_data *data = (address_data *)cbdata; faction *f = data->f; @@ -1378,8 +1378,9 @@ static region *firstregion(faction * f) #endif } -static void cb_add_seen(region *r, unit *u, void *cbdata) { - unused_arg(cbdata); +static void cb_add_seen(const region *rc, unit *u, void *cbdata) { + region *r = (region *)cbdata; + assert(rc == r); faction_add_seen(u->faction, r, seen_travel); } @@ -1444,7 +1445,7 @@ void prepare_report(report_context *ctx, faction *f) } if (fval(r, RF_TRAVELUNIT)) { - travelthru_map(r, cb_add_seen, ctx); + travelthru_map(r, cb_add_seen, r); } } // [fast,last) interval of seen regions (with lighthouses and travel) @@ -2147,7 +2148,7 @@ typedef struct count_data { const struct faction *f; } count_data; -static void count_cb(region *r, unit *u, void *cbdata) { +static void count_cb(const region *r, unit *u, void *cbdata) { count_data *data = (count_data *)cbdata; const struct faction *f = data->f; if (r != u->region && (!u->ship || ship_owner(u->ship) == u)) { @@ -2157,7 +2158,7 @@ static void count_cb(region *r, unit *u, void *cbdata) { } } -int count_travelthru(struct region *r, const struct faction *f) { +int count_travelthru(const struct region *r, const struct faction *f) { count_data data = { 0 }; data.f = f; travelthru_map(r, count_cb, &data); diff --git a/src/reports.h b/src/reports.h index fd0efb591..3c4a86707 100644 --- a/src/reports.h +++ b/src/reports.h @@ -125,7 +125,7 @@ extern "C" { int stream_printf(struct stream * out, const char *format, ...); - int count_travelthru(struct region *r, const struct faction *f); + int count_travelthru(const struct region *r, const struct faction *f); #define GR_PLURAL 0x01 /* grammar: plural */ #define MAX_INVENTORY 128 /* maimum number of different items in an inventory */ diff --git a/src/travelthru.c b/src/travelthru.c index 32607ae5c..deaa05f27 100644 --- a/src/travelthru.c +++ b/src/travelthru.c @@ -95,7 +95,7 @@ bool travelthru_cansee(const struct region *r, const struct faction *f, const st return false; } -void travelthru_map(region * r, void(*cb)(region *, struct unit *, void *), void *cbdata) +void travelthru_map(const region * r, void(*cb)(const region *, struct unit *, void *), void *cbdata) { attrib *a; assert(r); diff --git a/src/travelthru.h b/src/travelthru.h index 4e43dd25a..44c6e3978 100644 --- a/src/travelthru.h +++ b/src/travelthru.h @@ -11,7 +11,7 @@ extern "C" { struct region; struct faction; struct unit; - void travelthru_map(struct region * r, void(*cb)(struct region *r, struct unit *, void *), void *cbdata); + void travelthru_map(const struct region * r, void(*cb)(const struct region *r, struct unit *, void *), void *cbdata); bool travelthru_cansee(const struct region *r, const struct faction *f, const struct unit *u); void travelthru_add(struct region * r, struct unit * u); diff --git a/src/travelthru.test.c b/src/travelthru.test.c index 74ab29b7e..06a3633ab 100644 --- a/src/travelthru.test.c +++ b/src/travelthru.test.c @@ -13,7 +13,7 @@ struct attrib; -static void count_travelers(region *r, unit *u, void *cbdata) { +static void count_travelers(const region *r, unit *u, void *cbdata) { int *n = (int *)cbdata; unused_arg(r); *n += u->number; From acfa2cfbe5865c09468f1f38cbd1b443f52ae0d3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 18:59:24 +0200 Subject: [PATCH 037/675] remove view functions for special planes (Regatta). --- src/kernel/plane.h | 1 - src/reports.c | 100 +-------------------------------------------- 2 files changed, 1 insertion(+), 100 deletions(-) diff --git a/src/kernel/plane.h b/src/kernel/plane.h index 85c38cf9f..d06495f34 100644 --- a/src/kernel/plane.h +++ b/src/kernel/plane.h @@ -43,7 +43,6 @@ extern "C" { #define PFL_FRIENDLY 4096 /* everyone is your ally */ #define PFL_NOORCGROWTH 8192 /* orcs don't grow */ #define PFL_NOMONSTERS 16384 /* no monster randenc */ -#define PFL_SEESPECIAL 32768 /* far seeing */ typedef struct plane { struct plane *next; diff --git a/src/reports.c b/src/reports.c index 06408d96e..48aee609d 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1151,93 +1151,6 @@ void view_default(struct seen_region **seen, region * r, faction * f) } } -void view_neighbours(struct seen_region **seen, region * r, faction * f) -{ - int d; - region * nb[MAXDIRECTIONS]; - - get_neighbours(r, nb); - for (d = 0; d != MAXDIRECTIONS; ++d) { - region *r2 = nb[d]; - if (r2) { - connection *b = get_borders(r, r2); - while (b) { - if (!b->type->transparent(b, f)) - break; - b = b->next; - } - if (!b) { - if (add_seen(seen, r2, see_far, false)) { - if (!(fval(r2->terrain, FORBIDDEN_REGION))) { - int dir; - for (dir = 0; dir != MAXDIRECTIONS; ++dir) { - region *r3 = rconnect(r2, dir); - if (r3) { - connection *b = get_borders(r2, r3); - while (b) { - if (!b->type->transparent(b, f)) - break; - b = b->next; - } - if (!b) - add_seen(seen, r3, see_neighbour, false); - } - } - } - } - } - } - } -} - -static void -recurse_regatta(struct seen_region **seen, region * center, region * r, -faction * f, int maxdist) -{ - int d; - int dist = distance(center, r); - region * nb[MAXDIRECTIONS]; - - get_neighbours(r, nb); - for (d = 0; d != MAXDIRECTIONS; ++d) { - region *r2 = nb[d]; - if (r2) { - int ndist = distance(center, r2); - if (ndist > dist && fval(r2->terrain, SEA_REGION)) { - connection *b = get_borders(r, r2); - while (b) { - if (!b->type->transparent(b, f)) - break; - b = b->next; - } - if (!b) { - if (ndist < maxdist) { - if (add_seen(seen, r2, see_far, false)) { - recurse_regatta(seen, center, r2, f, maxdist); - } - } - else - add_seen(seen, r2, see_neighbour, false); - } - } - } - } -} - -static void view_regatta(struct seen_region **seen, region * r, faction * f) -{ - unit *u; - int skill = 0; - for (u = r->units; u; u = u->next) { - if (u->faction == f) { - int es = effskill(u, SK_PERCEPTION, 0); - if (es > skill) - skill = es; - } - } - recurse_regatta(seen, r, r, f, skill / 2); -} - static void prepare_lighthouse(building * b, faction * f) { int range = lighthouse_range(b, f); @@ -1487,14 +1400,7 @@ static void cb_view_neighbours(seen_region *sr, void *cbdata) { faction *f = (faction *)cbdata; if (sr->mode > see_neighbour) { region *r = sr->r; - plane *p = rplane(r); - void(*view) (struct seen_region **, region *, faction *) = view_default; - - if (p && fval(p, PFL_SEESPECIAL)) { - /* TODO: this is not very customizable */ - view = (strcmp(p->name, "Regatta") == 0) ? view_regatta : view_neighbours; - } - view(f->seen, r, f); + view_default(f->seen, r, f); } } @@ -2276,8 +2182,4 @@ void register_reports(void) add_function("resources", &eval_resources); add_function("regions", &eval_regions); add_function("trail", &eval_trail); - - /* register alternative visibility functions */ - register_function((pf_generic)view_neighbours, "view_neighbours"); - register_function((pf_generic)view_regatta, "view_regatta"); } From 9d60a0f96766a1450cf1c801b7abc198906a2e68 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 19:28:07 +0200 Subject: [PATCH 038/675] missing forward struct declaration --- src/report.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/report.h b/src/report.h index 66eb4a4b9..ec0ee903c 100644 --- a/src/report.h +++ b/src/report.h @@ -23,6 +23,7 @@ extern "C" { struct spellbook_entry; struct region; struct faction; + struct locale; void register_nr(void); void report_cleanup(void); void write_spaces(struct stream *out, size_t num); From 567083c9e85d1444485202d1455e8943abd0373a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 20:18:53 +0200 Subject: [PATCH 039/675] fix bad translation key --- src/report.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/report.c b/src/report.c index 345a76e10..64febfb44 100644 --- a/src/report.c +++ b/src/report.c @@ -939,13 +939,13 @@ static void describe(stream *out, const region * r, faction * f) WARN_STATIC_BUFFER(); if (r->seen.mode == seen_travel) { - bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "seen_travel")); + bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel")); } else if (r->seen.mode == seen_neighbour) { bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour")); } else if (r->seen.mode == seen_lighthouse) { - bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "seen_lighthouse")); + bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse")); } else { bytes = 0; From 74ff763b22f6b684c6751a1e268406b82030646d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 21:12:03 +0200 Subject: [PATCH 040/675] speeding up default_wage a little bit. --- src/kernel/config.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index d78362f3c..ccb6f3463 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -922,8 +922,6 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn) building *b = largestbuilding(r, &cmp_wage, false); int esize = 0; double wage; - attrib *a; - const struct curse_type *ctype; if (b != NULL) { /* TODO: this reveals imaginary castles */ @@ -963,23 +961,28 @@ 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); + if (r->attribs) { + attrib *a; + const struct curse_type *ctype; + /* Godcurse: Income -10 */ + ctype = ct_find("godcursezone"); + if (ctype && curse_active(get_curse(r->attribs, ctype))) { + wage = _max(0, wage - 10); + } + + /* Bei einer Drre verdient man nur noch ein Viertel */ + ctype = ct_find("drought"); + if (ctype) { + curse *c = get_curse(r->attribs, ctype); + if (curse_active(c)) + wage /= curse_geteffect(c); + } + + a = a_find(r->attribs, &at_reduceproduction); + if (a) { + wage = (wage * a->data.sa[0]) / 100; + } } - - /* Bei einer Drre verdient man nur noch ein Viertel */ - ctype = ct_find("drought"); - if (ctype) { - curse *c = get_curse(r->attribs, ctype); - if (curse_active(c)) - wage /= curse_geteffect(c); - } - - a = a_find(r->attribs, &at_reduceproduction); - if (a) - wage = (wage * a->data.sa[0]) / 100; - return (int)wage; } From a86e30d0149038e1d037552715256e12b56796c8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 21:17:54 +0200 Subject: [PATCH 041/675] re-enable report testing, find out that it fails. --- src/reports.c | 2 +- src/reports.test.c | 12 +++++++++++- src/test_eressea.c | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/reports.c b/src/reports.c index 975cbb3b9..cdf85d096 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1311,7 +1311,7 @@ void prepare_report(report_context *ctx, faction *f) static bool rule_region_owners; const struct building_type *bt_lighthouse = bt_find("lighthouse"); - if (config_changed(&config)) { + if (bt_lighthouse && config_changed(&config)) { rule_region_owners = config_token("rules.region_owner_pay_building", bt_lighthouse->_name); } diff --git a/src/reports.test.c b/src/reports.test.c index aed289972..6d96a9436 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -225,12 +225,13 @@ static void test_arg_resources(CuTest *tc) { static void test_prepare_travelthru(CuTest *tc) { report_context ctx; - faction *f; + faction *f, *f2; region *r1, *r2, *r3; unit *u; test_setup(); f = test_create_faction(0); + f2 = test_create_faction(0); r1 = test_create_region(0, 0, 0); r2 = test_create_region(1, 0, 0); r3 = test_create_region(2, 0, 0); @@ -239,9 +240,18 @@ static void test_prepare_travelthru(CuTest *tc) { prepare_report(&ctx, f); CuAssertPtrEquals(tc, r1, ctx.first); CuAssertPtrEquals(tc, r3, ctx.last); + CuAssertPtrEquals(tc, f, ctx.f); CuAssertIntEquals(tc, seen_unit, r1->seen.mode); CuAssertIntEquals(tc, seen_travel, r2->seen.mode); CuAssertIntEquals(tc, seen_none, r3->seen.mode); + finish_reports(&ctx); + CuAssertIntEquals(tc, seen_none, r2->seen.mode); + + prepare_report(&ctx, f2); + CuAssertIntEquals(tc, seen_none, r2->seen.mode); + CuAssertPtrEquals(tc, f2, ctx.f); + CuAssertPtrEquals(tc, NULL, ctx.first); + CuAssertPtrEquals(tc, NULL, ctx.last); test_cleanup(); } diff --git a/src/test_eressea.c b/src/test_eressea.c index ac8d55ee9..7089493f9 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -99,7 +99,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(item); ADD_SUITE(magic); ADD_SUITE(alchemy); -// ADD_SUITE(reports); + ADD_SUITE(reports); ADD_SUITE(save); ADD_SUITE(ship); ADD_SUITE(spellbook); @@ -110,6 +110,8 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(ally); ADD_SUITE(messages); /* gamecode */ + ADD_SUITE(report); +// ADD_SUITE(creport); ADD_SUITE(prefix); ADD_SUITE(summary); ADD_SUITE(names); From a2125fbb9a7d139e8667631096f955cedc4f9556 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Sep 2016 21:26:17 +0200 Subject: [PATCH 042/675] managed to reproduce the travelthru bug in a unit test. travel from other factions inside the [first, last) interval will poison the report. --- src/reports.test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/reports.test.c b/src/reports.test.c index 6d96a9436..503f8a1be 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -235,6 +235,8 @@ static void test_prepare_travelthru(CuTest *tc) { r1 = test_create_region(0, 0, 0); r2 = test_create_region(1, 0, 0); r3 = test_create_region(2, 0, 0); + test_create_unit(f2, r1); + test_create_unit(f2, r3); u = test_create_unit(f, r1); travelthru_add(r2, u); prepare_report(&ctx, f); @@ -250,7 +252,7 @@ static void test_prepare_travelthru(CuTest *tc) { prepare_report(&ctx, f2); CuAssertIntEquals(tc, seen_none, r2->seen.mode); CuAssertPtrEquals(tc, f2, ctx.f); - CuAssertPtrEquals(tc, NULL, ctx.first); + CuAssertPtrEquals(tc, r1, ctx.first); CuAssertPtrEquals(tc, NULL, ctx.last); test_cleanup(); } From 0753ea0174a181d76bb0be939967f766086d7001 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 08:28:33 +0200 Subject: [PATCH 043/675] fix travelthru reporting (passes unit test) --- src/report.c | 6 +++--- src/report.h | 2 +- src/reports.c | 17 +++++++++-------- src/reports.h | 2 +- src/travelthru.c | 2 +- src/travelthru.h | 2 +- src/travelthru.test.c | 2 +- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/report.c b/src/report.c index 64febfb44..c7093da73 100644 --- a/src/report.c +++ b/src/report.c @@ -1951,7 +1951,7 @@ static void init_cb(cb_data *data, stream *out, char *buffer, size_t size, const data->counter = 0; } -static void cb_write_travelthru(const region *r, unit *u, void *cbdata) { +static void cb_write_travelthru(region *r, unit *u, void *cbdata) { cb_data *data = (cb_data *)cbdata; const faction *f = data->f; @@ -2006,7 +2006,7 @@ static void cb_write_travelthru(const region *r, unit *u, void *cbdata) { } } -void write_travelthru(stream *out, const region *r, const faction *f) +void write_travelthru(stream *out, region *r, const faction *f) { int maxtravel; char buf[8192]; @@ -2038,7 +2038,7 @@ report_plaintext(const char *filename, report_context * ctx, int flag = 0; char ch; int anyunits, no_units, no_people; - const struct region *r; + region *r; faction *f = ctx->f; unit *u; char pzTime[64]; diff --git a/src/report.h b/src/report.h index ec0ee903c..84a6c66d4 100644 --- a/src/report.h +++ b/src/report.h @@ -27,7 +27,7 @@ extern "C" { void register_nr(void); void report_cleanup(void); void write_spaces(struct stream *out, size_t num); - void write_travelthru(struct stream *out, const struct region * r, const struct faction * f); + void write_travelthru(struct stream *out, struct region * r, const struct faction * f); void nr_spell_syntax(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang); void nr_spell(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang); diff --git a/src/reports.c b/src/reports.c index cdf85d096..50e220393 100644 --- a/src/reports.c +++ b/src/reports.c @@ -971,7 +971,7 @@ typedef struct address_data { int stealthmod; } address_data; -static void cb_add_address(const region *r, unit *ut, void *cbdata) { +static void cb_add_address(region *r, unit *ut, void *cbdata) { address_data *data = (address_data *)cbdata; faction *f = data->f; @@ -1292,10 +1292,11 @@ static region *firstregion(faction * f) #endif } -static void cb_add_seen(const region *rc, unit *u, void *cbdata) { - region *r = (region *)cbdata; - assert(rc == r); - faction_add_seen(u->faction, r, seen_travel); +static void cb_add_seen(region *r, unit *u, void *cbdata) { + faction *f = (faction *)cbdata; + if (u->faction==f) { + faction_add_seen(f, r, seen_travel); + } } /** set region.seen based on visibility by one faction. @@ -1359,7 +1360,7 @@ void prepare_report(report_context *ctx, faction *f) } if (fval(r, RF_TRAVELUNIT)) { - travelthru_map(r, cb_add_seen, r); + travelthru_map(r, cb_add_seen, f); } } // [fast,last) interval of seen regions (with lighthouses and travel) @@ -2062,7 +2063,7 @@ typedef struct count_data { const struct faction *f; } count_data; -static void count_cb(const region *r, unit *u, void *cbdata) { +static void count_cb(region *r, unit *u, void *cbdata) { count_data *data = (count_data *)cbdata; const struct faction *f = data->f; if (r != u->region && (!u->ship || ship_owner(u->ship) == u)) { @@ -2072,7 +2073,7 @@ static void count_cb(const region *r, unit *u, void *cbdata) { } } -int count_travelthru(const struct region *r, const struct faction *f) { +int count_travelthru(struct region *r, const struct faction *f) { count_data data = { 0 }; data.f = f; travelthru_map(r, count_cb, &data); diff --git a/src/reports.h b/src/reports.h index 3c4a86707..fd0efb591 100644 --- a/src/reports.h +++ b/src/reports.h @@ -125,7 +125,7 @@ extern "C" { int stream_printf(struct stream * out, const char *format, ...); - int count_travelthru(const struct region *r, const struct faction *f); + int count_travelthru(struct region *r, const struct faction *f); #define GR_PLURAL 0x01 /* grammar: plural */ #define MAX_INVENTORY 128 /* maimum number of different items in an inventory */ diff --git a/src/travelthru.c b/src/travelthru.c index deaa05f27..32607ae5c 100644 --- a/src/travelthru.c +++ b/src/travelthru.c @@ -95,7 +95,7 @@ bool travelthru_cansee(const struct region *r, const struct faction *f, const st return false; } -void travelthru_map(const region * r, void(*cb)(const region *, struct unit *, void *), void *cbdata) +void travelthru_map(region * r, void(*cb)(region *, struct unit *, void *), void *cbdata) { attrib *a; assert(r); diff --git a/src/travelthru.h b/src/travelthru.h index 44c6e3978..4e43dd25a 100644 --- a/src/travelthru.h +++ b/src/travelthru.h @@ -11,7 +11,7 @@ extern "C" { struct region; struct faction; struct unit; - void travelthru_map(const struct region * r, void(*cb)(const struct region *r, struct unit *, void *), void *cbdata); + void travelthru_map(struct region * r, void(*cb)(struct region *r, struct unit *, void *), void *cbdata); bool travelthru_cansee(const struct region *r, const struct faction *f, const struct unit *u); void travelthru_add(struct region * r, struct unit * u); diff --git a/src/travelthru.test.c b/src/travelthru.test.c index 06a3633ab..74ab29b7e 100644 --- a/src/travelthru.test.c +++ b/src/travelthru.test.c @@ -13,7 +13,7 @@ struct attrib; -static void count_travelers(const region *r, unit *u, void *cbdata) { +static void count_travelers(region *r, unit *u, void *cbdata) { int *n = (int *)cbdata; unused_arg(r); *n += u->number; From adfafd51a6e9e09fe2ea07339cd101ca11c7ed07 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 12:34:02 +0200 Subject: [PATCH 044/675] test lighthouses --- src/CMakeLists.txt | 1 + src/lighthouse.c | 2 +- src/lighthouse.h | 3 ++ src/lighthouse.test.c | 95 +++++++++++++++++++++++++++++++++++++++++++ src/test_eressea.c | 1 + 5 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/lighthouse.test.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 11bd860ba..40be63190 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -211,6 +211,7 @@ set(TESTS_SRC keyword.test.c give.test.c laws.test.c + lighthouse.test.c magic.test.c market.test.c monsters.test.c diff --git a/src/lighthouse.c b/src/lighthouse.c index 441eb0458..58d522807 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -14,7 +14,7 @@ #include #include -static attrib_type at_lighthouse = { +const attrib_type at_lighthouse = { "lighthouse" /* Rest ist NULL; temporres, nicht alterndes Attribut */ }; diff --git a/src/lighthouse.h b/src/lighthouse.h index b31c520cb..518b05b5a 100644 --- a/src/lighthouse.h +++ b/src/lighthouse.h @@ -27,6 +27,9 @@ extern "C" { struct faction; struct region; struct building; + struct attrib; + + extern const struct attrib_type at_lighthouse; /* leuchtturm */ bool check_leuchtturm(struct region *r, struct faction *f); void update_lighthouse(struct building *lh); diff --git a/src/lighthouse.test.c b/src/lighthouse.test.c new file mode 100644 index 000000000..193de58a6 --- /dev/null +++ b/src/lighthouse.test.c @@ -0,0 +1,95 @@ +#include + +#include "lighthouse.h" + +#include +#include +#include +#include +#include +#include +#include + + +#include +#include "tests.h" + +static void test_lighthouse_range(CuTest * tc) +{ + faction *f; + unit *u; + region *r1, *r2; + building *b; + + test_setup(); + r1 = test_create_region(0, 0, 0); + r2 = test_create_region(1, 0, 0); + f = test_create_faction(0); + u = test_create_unit(f, r1); + b = test_create_building(r1, test_create_buildingtype("lighthouse")); + CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL)); + CuAssertIntEquals(tc, 0, lighthouse_range(b, f)); + b->size = 10; + CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL)); + u->building = b; + set_level(u, SK_PERCEPTION, 3); + CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL)); + b->flags |= BLD_MAINTAINED; + CuAssertIntEquals(tc, 1, lighthouse_range(b, NULL)); + set_level(u, SK_PERCEPTION, 6); + CuAssertIntEquals(tc, 2, lighthouse_range(b, NULL)); + b->size = 100; + CuAssertIntEquals(tc, 2, lighthouse_range(b, NULL)); + set_level(u, SK_PERCEPTION, 9); + CuAssertIntEquals(tc, 3, lighthouse_range(b, NULL)); + CuAssertIntEquals(tc, 3, lighthouse_range(b, f)); + CuAssertIntEquals(tc, 0, lighthouse_range(b, test_create_faction(0))); + test_cleanup(); +} + +static void test_lighthouse_update(CuTest * tc) +{ + region *r1, *r2, *r3; + building *b; + const struct terrain_type *t_ocean, *t_plain; + + test_setup(); + t_ocean = test_create_terrain("ocean", SEA_REGION); + t_plain = test_create_terrain("plain", LAND_REGION); + r1 = test_create_region(0, 0, t_plain); + r2 = test_create_region(1, 0, t_ocean); + r3 = test_create_region(2, 0, t_ocean); + b = test_create_building(r1, test_create_buildingtype("lighthouse")); + CuAssertIntEquals(tc, 0, r1->flags&RF_LIGHTHOUSE); + CuAssertPtrEquals(tc, NULL, r1->attribs); + CuAssertPtrEquals(tc, NULL, r2->attribs); + CuAssertPtrEquals(tc, NULL, r3->attribs); + + r1->flags = 0; + b->size = 1; + update_lighthouse(b); + CuAssertIntEquals(tc, RF_LIGHTHOUSE, r1->flags&RF_LIGHTHOUSE); + CuAssertPtrNotNull(tc, r2->attribs); + CuAssertPtrEquals(tc, (void *)&at_lighthouse, (void *)r2->attribs->type); + CuAssertPtrEquals(tc, NULL, r1->attribs); + CuAssertPtrEquals(tc, NULL, r3->attribs); + + a_removeall(&r2->attribs, NULL); + r1->flags = 0; + b->size = 10; + update_lighthouse(b); + CuAssertIntEquals(tc, RF_LIGHTHOUSE, r1->flags&RF_LIGHTHOUSE); + CuAssertPtrNotNull(tc, r2->attribs); + CuAssertPtrEquals(tc, (void *)&at_lighthouse, (void *)r2->attribs->type); + CuAssertPtrNotNull(tc, r3->attribs); + CuAssertPtrEquals(tc, (void *)&at_lighthouse, (void *)r3->attribs->type); + test_cleanup(); +} + +CuSuite *get_lighthouse_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_lighthouse_range); + SUITE_ADD_TEST(suite, test_lighthouse_update); + return suite; +} diff --git a/src/test_eressea.c b/src/test_eressea.c index 0f6fc3522..2511c5727 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -122,6 +122,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(flyingship); ADD_SUITE(give); ADD_SUITE(laws); + ADD_SUITE(lighthouse); ADD_SUITE(market); ADD_SUITE(monsters); ADD_SUITE(move); From 7349ec0aa9d6a7c56ba04d225b532c0df9c4d271 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 13:20:02 +0200 Subject: [PATCH 045/675] improve lighthouse tests. you must be inside lighthouse to get a report from it. --- src/lighthouse.c | 7 +++++-- src/lighthouse.test.c | 27 ++++++++++++++++----------- src/reports.c | 3 +-- src/reports.test.c | 20 +++++++++++++------- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/lighthouse.c b/src/lighthouse.c index 58d522807..54591cd16 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -71,15 +71,18 @@ int lighthouse_range(const building * b, const faction * f) if (skill_enabled(SK_PERCEPTION)) { region *r = b->region; int c = 0; + int cap = buildingcapacity(b); unit *u; + for (u = r->units; u; u = u->next) { if (u->building == b || u == building_owner(b)) { if (u->building == b) { c += u->number; } - if (c > buildingcapacity(b)) + if (c > cap) { break; - if (f == NULL || u->faction == f) { + } + else if (f == NULL || u->faction == f) { int sk = effskill(u, SK_PERCEPTION, 0) / 3; d = _max(d, sk); d = _min(maxd, d); diff --git a/src/lighthouse.test.c b/src/lighthouse.test.c index 193de58a6..391146d61 100644 --- a/src/lighthouse.test.c +++ b/src/lighthouse.test.c @@ -16,33 +16,38 @@ static void test_lighthouse_range(CuTest * tc) { - faction *f; - unit *u; + unit *u1, *u2; region *r1, *r2; building *b; test_setup(); r1 = test_create_region(0, 0, 0); r2 = test_create_region(1, 0, 0); - f = test_create_faction(0); - u = test_create_unit(f, r1); + u1 = test_create_unit(test_create_faction(0), r1); + u2 = test_create_unit(test_create_faction(0), r1); b = test_create_building(r1, test_create_buildingtype("lighthouse")); CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL)); - CuAssertIntEquals(tc, 0, lighthouse_range(b, f)); + CuAssertIntEquals(tc, 0, lighthouse_range(b, u1->faction)); b->size = 10; CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL)); - u->building = b; - set_level(u, SK_PERCEPTION, 3); + u1->building = b; + u2->building = b; + u1->number = 10; + set_level(u1, SK_PERCEPTION, 3); + set_level(u2, SK_PERCEPTION, 3); CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL)); b->flags |= BLD_MAINTAINED; CuAssertIntEquals(tc, 1, lighthouse_range(b, NULL)); - set_level(u, SK_PERCEPTION, 6); - CuAssertIntEquals(tc, 2, lighthouse_range(b, NULL)); + set_level(u1, SK_PERCEPTION, 6); + CuAssertIntEquals(tc, 2, lighthouse_range(b, u1->faction)); + CuAssertIntEquals(tc, 0, lighthouse_range(b, u2->faction)); b->size = 100; + update_lighthouse(b); CuAssertIntEquals(tc, 2, lighthouse_range(b, NULL)); - set_level(u, SK_PERCEPTION, 9); + set_level(u1, SK_PERCEPTION, 9); CuAssertIntEquals(tc, 3, lighthouse_range(b, NULL)); - CuAssertIntEquals(tc, 3, lighthouse_range(b, f)); + CuAssertIntEquals(tc, 3, lighthouse_range(b, u1->faction)); + CuAssertIntEquals(tc, 1, lighthouse_range(b, u2->faction)); CuAssertIntEquals(tc, 0, lighthouse_range(b, test_create_faction(0))); test_cleanup(); } diff --git a/src/reports.c b/src/reports.c index 50e220393..915aa8a1b 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1350,8 +1350,7 @@ void prepare_report(report_context *ctx, faction *f) faction_add_seen(f, r, seen_unit); } if (fval(r, RF_LIGHTHOUSE)) { - // TODO: is the building big enough for the unit? - if (u->building && u->building->type == bt_lighthouse) { + if (u->building && u->building->type == bt_lighthouse && inside_building(u)) { /* we are in a lighthouse. add the regions we can see from here! */ prepare_lighthouse(u->building, ctx); } diff --git a/src/reports.test.c b/src/reports.test.c index 503f8a1be..1e3f800e4 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -264,24 +265,29 @@ static void test_prepare_lighthouse(CuTest *tc) { unit *u; building *b; building_type *btype; + const struct terrain_type *t_ocean, *t_plain; test_setup(); + t_ocean = test_create_terrain("ocean", SEA_REGION); + t_plain = test_create_terrain("plain", LAND_REGION); f = test_create_faction(0); - r1 = test_create_region(0, 0, 0); - r2 = test_create_region(1, 0, 0); - r3 = test_create_region(2, 0, 0); + r1 = test_create_region(0, 0, t_plain); + r2 = test_create_region(1, 0, t_ocean); + r3 = test_create_region(2, 0, t_ocean); btype = test_create_buildingtype("lighthouse"); b = test_create_building(r1, btype); + b->flags |= BLD_MAINTAINED; b->size = 10; + update_lighthouse(b); u = test_create_unit(f, r1); u->building = b; - update_lighthouse(b); + set_level(u, SK_PERCEPTION, 3); prepare_report(&ctx, f); CuAssertPtrEquals(tc, r1, ctx.first); - CuAssertPtrEquals(tc, r3, ctx.last); + CuAssertPtrEquals(tc, NULL, ctx.last); CuAssertIntEquals(tc, seen_unit, r1->seen.mode); CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode); - CuAssertIntEquals(tc, seen_none, r3->seen.mode); + CuAssertIntEquals(tc, seen_neighbour, r3->seen.mode); test_cleanup(); } @@ -314,7 +320,7 @@ static void test_prepare_report(CuTest *tc) { prepare_report(&ctx, f); CuAssertPtrEquals(tc, regions, ctx.first); CuAssertPtrEquals(tc, r, ctx.last); - CuAssertIntEquals(tc, seen_neighbour, r->seen.mode); + CuAssertIntEquals(tc, seen_none, r->seen.mode); test_cleanup(); } From 2a0bd3e7ca4c2af78499f3a1c3a428ed63819245 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 13:29:14 +0200 Subject: [PATCH 046/675] unused variable warning --- src/lighthouse.test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lighthouse.test.c b/src/lighthouse.test.c index 391146d61..d6c63bf9a 100644 --- a/src/lighthouse.test.c +++ b/src/lighthouse.test.c @@ -17,15 +17,15 @@ static void test_lighthouse_range(CuTest * tc) { unit *u1, *u2; - region *r1, *r2; + region *r; building *b; test_setup(); - r1 = test_create_region(0, 0, 0); - r2 = test_create_region(1, 0, 0); - u1 = test_create_unit(test_create_faction(0), r1); - u2 = test_create_unit(test_create_faction(0), r1); - b = test_create_building(r1, test_create_buildingtype("lighthouse")); + r = test_create_region(0, 0, 0); + test_create_region(1, 0, 0); + u1 = test_create_unit(test_create_faction(0), r); + u2 = test_create_unit(test_create_faction(0), r); + b = test_create_building(r, test_create_buildingtype("lighthouse")); CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL)); CuAssertIntEquals(tc, 0, lighthouse_range(b, u1->faction)); b->size = 10; From 1ca67a57d255ac9abde979f152f354998f4e9393 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 14:54:39 +0200 Subject: [PATCH 047/675] add a new test for lighthouse capacity. https://bugs.eressea.de/view.php?id=2237 --- src/reports.c | 3 ++- src/reports.h | 1 + src/reports.test.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/reports.c b/src/reports.c index 48aee609d..ec2e002f5 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1418,8 +1418,9 @@ void prepare_seen(faction *f) link_seen(f->seen, f->first, f->last); } -static void prepare_report(struct report_context *ctx, faction *f) +void prepare_report(struct report_context *ctx, faction *f) { + assert(f->seen); prepare_seen(f); ctx->f = f; ctx->report_time = time(NULL); diff --git a/src/reports.h b/src/reports.h index 584fe7d4a..f9bc9b495 100644 --- a/src/reports.h +++ b/src/reports.h @@ -57,6 +57,7 @@ extern "C" { const struct unit *u, unsigned int indent, int mode); void prepare_seen(struct faction *f); + void prepare_report(struct report_context *ctx, struct faction *f); int reports(void); int write_reports(struct faction *f, time_t ltime); int init_reports(void); diff --git a/src/reports.test.c b/src/reports.test.c index c27a0f6f9..71bd7dd80 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -3,6 +3,7 @@ #include "reports.h" #include "report.h" #include "creport.h" +#include "lighthouse.h" #include "move.h" #include "seen.h" #include "travelthru.h" @@ -17,6 +18,7 @@ #include #include #include +#include #include #include @@ -450,6 +452,41 @@ static void test_arg_resources(CuTest *tc) { test_cleanup(); } +void test_prepare_lighthouse(CuTest *tc) { + building *b; + building_type *btype; + unit *u; + region *r1, *r2; + faction *f; + report_context ctx; + const struct terrain_type *t_ocean, *t_plain; + + test_setup(); + f = test_create_faction(0); + t_ocean = test_create_terrain("ocean", SEA_REGION); + t_plain = test_create_terrain("plain", LAND_REGION); + btype = test_create_buildingtype("lighthouse"); + btype->maxcapacity = 4; + r1 = test_create_region(0, 0, 0); + r2 = test_create_region(0, 0, 0); + b = test_create_building(r1, btype); + b->size = 10; + update_lighthouse(b); + u = test_create_unit(test_create_faction(0), r1); + u->number = 4; + u->building = b; + CuAssertPtrEquals(tc, b, inside_building(u)); + u = test_create_unit(f, r1); + u->building = b; + CuAssertPtrEquals(tc, NULL, inside_building(u)); + u->faction->seen = seen_init(); + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, r1, ctx.first); + CuAssertPtrEquals(tc, r2, ctx.last); + seen_done(f->seen); + test_cleanup(); +} + CuSuite *get_reports_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -464,5 +501,6 @@ CuSuite *get_reports_suite(void) SUITE_ADD_TEST(suite, test_write_unit); SUITE_ADD_TEST(suite, test_write_spell_syntax); SUITE_ADD_TEST(suite, test_arg_resources); + SUITE_ADD_TEST(suite, test_prepare_lighthouse); return suite; } From c4dbb696814ab192f57ce624203f01150d09150f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 15:29:28 +0200 Subject: [PATCH 048/675] previous test was bad and did not actually exercise prepare_lighthouse. made a slighlty better test, which is failing for the right reasons. --- src/reports.c | 5 +++-- src/reports.test.c | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/reports.c b/src/reports.c index ec2e002f5..183d6ce6c 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1316,9 +1316,10 @@ static void prepare_reports(void) } for (u = r->units; u; u = u->next) { - if (u->building && u->building->type == bt_lighthouse) { + b = u->building; + if (b && b->type == bt_lighthouse) { /* we are in a lighthouse. add the regions we can see from here! */ - prepare_lighthouse(u->building, u->faction); + prepare_lighthouse(b, u->faction); } if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { diff --git a/src/reports.test.c b/src/reports.test.c index 71bd7dd80..14b3c7314 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -458,7 +458,6 @@ void test_prepare_lighthouse(CuTest *tc) { unit *u; region *r1, *r2; faction *f; - report_context ctx; const struct terrain_type *t_ocean, *t_plain; test_setup(); @@ -467,23 +466,26 @@ void test_prepare_lighthouse(CuTest *tc) { t_plain = test_create_terrain("plain", LAND_REGION); btype = test_create_buildingtype("lighthouse"); btype->maxcapacity = 4; - r1 = test_create_region(0, 0, 0); - r2 = test_create_region(0, 0, 0); + r1 = test_create_region(0, 0, t_plain); + r2 = test_create_region(1, 0, t_ocean); b = test_create_building(r1, btype); + b->flags |= BLD_MAINTAINED; b->size = 10; update_lighthouse(b); u = test_create_unit(test_create_faction(0), r1); u->number = 4; u->building = b; + set_level(u, SK_PERCEPTION, 3); + CuAssertIntEquals(tc, 1, lighthouse_range(b, u->faction)); CuAssertPtrEquals(tc, b, inside_building(u)); u = test_create_unit(f, r1); u->building = b; + set_level(u, SK_PERCEPTION, 3); + CuAssertIntEquals(tc, 0, lighthouse_range(b, u->faction)); CuAssertPtrEquals(tc, NULL, inside_building(u)); - u->faction->seen = seen_init(); - prepare_report(&ctx, f); - CuAssertPtrEquals(tc, r1, ctx.first); - CuAssertPtrEquals(tc, r2, ctx.last); - seen_done(f->seen); + init_reports(); + CuAssertPtrNotNull(tc, find_seen(f->seen, r1)); + CuAssertPtrEquals(tc, 0, find_seen(f->seen, r2)); test_cleanup(); } From eb7dd051f85b87355f6ea5214b3ff545a976dd55 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 15:31:04 +0200 Subject: [PATCH 049/675] fix bug 2237, respect lighthouse capacity. --- src/reports.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reports.c b/src/reports.c index 183d6ce6c..101eb75e8 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1317,7 +1317,7 @@ static void prepare_reports(void) for (u = r->units; u; u = u->next) { b = u->building; - if (b && b->type == bt_lighthouse) { + if (b && b->type == bt_lighthouse && inside_building(u)) { /* we are in a lighthouse. add the regions we can see from here! */ prepare_lighthouse(b, u->faction); } From 4c7d51990e095a1a3872188f4a10f90231a0ca28 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 15:37:11 +0200 Subject: [PATCH 050/675] prepare_report should stay static, remove that change. --- src/reports.c | 2 +- src/reports.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/reports.c b/src/reports.c index 101eb75e8..e0d4cff37 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1419,7 +1419,7 @@ void prepare_seen(faction *f) link_seen(f->seen, f->first, f->last); } -void prepare_report(struct report_context *ctx, faction *f) +static void prepare_report(struct report_context *ctx, faction *f) { assert(f->seen); prepare_seen(f); diff --git a/src/reports.h b/src/reports.h index f9bc9b495..584fe7d4a 100644 --- a/src/reports.h +++ b/src/reports.h @@ -57,7 +57,6 @@ extern "C" { const struct unit *u, unsigned int indent, int mode); void prepare_seen(struct faction *f); - void prepare_report(struct report_context *ctx, struct faction *f); int reports(void); int write_reports(struct faction *f, time_t ltime); int init_reports(void); From e97ebb04695819135ac4fdd02ab2085ada0d4cbe Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 19:52:13 +0200 Subject: [PATCH 051/675] RF_SAVEMASK needs to include RF_LIGHTHOUSE or the new report prep doesn't work. --- src/kernel/region.h | 2 +- src/kernel/save.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kernel/region.h b/src/kernel/region.h index 163b6c22c..6e231529d 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -58,7 +58,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define RF_ALL 0xFFFFFF -#define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_ENCOUNTER|RF_ORCIFIED|RF_GUARDED) +#define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_ENCOUNTER|RF_ORCIFIED|RF_GUARDED|RF_LIGHTHOUSE) struct message; struct message_list; struct rawmaterial; diff --git a/src/kernel/save.c b/src/kernel/save.c index b9b522794..34a408113 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1792,8 +1792,9 @@ int read_game(gamedata *data) { for (r = regions; r; r = r->next) { if (r->flags & RF_LIGHTHOUSE) { building *b; - for (b = r->buildings; b; b = b->next) + for (b = r->buildings; b; b = b->next) { update_lighthouse(b); + } } } log_debug("marking factions as alive."); From a425a78f7cfc0a4491ed52b15d2399073accd8aa Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 19:59:49 +0200 Subject: [PATCH 052/675] add a lighthouse to the sample data. --- .gitignore | 6 ------ src/lighthouse.test.c | 3 +-- tests/data/184.dat | Bin 7720 -> 7443 bytes 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index fd1a7c349..8e19d4018 100644 --- a/.gitignore +++ b/.gitignore @@ -26,12 +26,6 @@ ipch/ *.bak bin/ build*/ -game-e2/data -game-e2/*.log* -game-e2/reports/ -game-e3/data/ -game-e3/*.log* -game-e3/reports/ *.log *.log.* tags diff --git a/src/lighthouse.test.c b/src/lighthouse.test.c index 193de58a6..ded77649a 100644 --- a/src/lighthouse.test.c +++ b/src/lighthouse.test.c @@ -18,12 +18,11 @@ static void test_lighthouse_range(CuTest * tc) { faction *f; unit *u; - region *r1, *r2; + region *r1; building *b; test_setup(); r1 = test_create_region(0, 0, 0); - r2 = test_create_region(1, 0, 0); f = test_create_faction(0); u = test_create_unit(f, r1); b = test_create_building(r1, test_create_buildingtype("lighthouse")); diff --git a/tests/data/184.dat b/tests/data/184.dat index d219f92ddd96f5bdd7d9ee4c4e5276bbb1dee895..a1ee8802ae2c9c8ebc6ba5a1b04acfd9be5b559d 100644 GIT binary patch delta 1458 zcmZ9Mdq`7J9LLXnZSLV~)9IZ-@1m%%vSnt`?(SU)1(m%?dJZS(Mm38lusO9ow3@dU zlob_W1-&fD=tUSo*~=hHQ6n5I8gS$~h9!v@SlDv(In(~VQEr*V2VLF!kIxs3=`rYNx6&N;_ zUd_hR*9SD7%YobiZZGf?R{*rA76NNk(}53EGk|*aQed%q8t|k#FC9*R1iJF7|4$C$ z-0K``TnL=Lh;K=#hViY0IY6DJ2DndSHz10t3x5cWRK&k)HiKEF<$*!%Okk@PZ>iHw z0g5`j%tIY-M%1&**&4y^_6%{jaMg(){R-f)L_hFc z;%s1F;(Xw|Bqy*rX^sI|nYylUn@Ld#pNyv#Cgb>#b-Pf9HWKajdC;!|R&}SRtz1I3=Y+REM8%tq=J`K(yQnjb=cH}C|(zIeQ+tct_hNVv}Le%Fc z+1j~|@^wy+r+i}>(rQafik%*(yL^)aMS5G=m8q9XTuw(xw8IqQoaJS3sW26x1hsXc zAQdc<5YMnyuFUOnY(1L7I9%(~O#Ep*KCXhWKodDAwD2u|sjy zpwW!~?~7Iokz?rH4Sydc5gJQX_BC9{Bs9)eb^Z1?GRKL5ihH5+W5}QsIOhK^$Vyf3 zkGH21Ia;c2`_(*z&?u?0zWt8kML^LuYjq&}R!igro3H8eA>1x??E8H^$QbE`o!!;= z`GKO7u!O``_wG5%6HC|`Z~d8GvUG{^`S&!bCu#9W(d|9#(ZLK0Nnp^8g1 zq1m{a6Bn8k-zt=1Rqgb*y&X;F*j=}~f0LaMQRsQi4~EEbR&Vd#ujG21P}O$obpKp^ LQlrSEZRgJIckf^O?wrs0{?0j^jZJP&l^((| zjKDCABFKDwo-H7aa(=QWNTn@LhO2)ySvh4JR-*lzq@3k5 zDQDm#ONKf|mI^{A^ka5t1r1nzT#xVB<)?nyWb?vNh< z@U}eF4Kj@N`sB3;6#OkW09X*T%{7gdEFJj#D;1@l2PuGh7jz5+qk!SHxV5EkJPF0? z6-R-hg1O-{gA+y0FmuBIiDtUWy62FBl%%mS5h?;IBlZE;HL^Bz&CF7&|)a1e@0|)`!#6=4)A@+)H$Kgx*a zEbRn8s-epp+d9y;&pHoDbip({6D`20s-C$;!3wpQ<$d{2l26m>Vtefm)ZF1sGo`~# KEdmqg)%^#w4f?_W From d3d9b097bcdf2fa14a76f594551e2278a0d4356f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 20:34:06 +0200 Subject: [PATCH 053/675] add some lighthouse checks to integration tests. --- tests/run-turn.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/run-turn.sh b/tests/run-turn.sh index d47ac81a2..92eac8948 100755 --- a/tests/run-turn.sh +++ b/tests/run-turn.sh @@ -53,6 +53,9 @@ assert_grep_count reports/$CRFILE '^BURG' 1 assert_grep_count reports/$CRFILE '^EINHEIT' 2 assert_grep_count reports/$CRFILE '^GEGENSTAENDE' 2 +assert_grep_count reports/185-heg.nr 'vom Turm erblickt' 6 +assert_grep_count reports/185-heg.cr '"lighthouse";visibility' 6 +assert_grep_count reports/185-heg.cr '"neighbour";visibility' 11 assert_grep_count reports/185-6rLo.cr '^EINHEIT' 2 assert_grep_count reports/185-6rLo.cr '^REGION' 13 echo "integration tests: PASS" From 1fb061c6f0b01e872d561ab1e03b782ccec5d538 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 20:35:41 +0200 Subject: [PATCH 054/675] syntax error (bash functions are hard). --- tests/run-turn.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run-turn.sh b/tests/run-turn.sh index 92eac8948..519ed8bd8 100755 --- a/tests/run-turn.sh +++ b/tests/run-turn.sh @@ -53,7 +53,7 @@ assert_grep_count reports/$CRFILE '^BURG' 1 assert_grep_count reports/$CRFILE '^EINHEIT' 2 assert_grep_count reports/$CRFILE '^GEGENSTAENDE' 2 -assert_grep_count reports/185-heg.nr 'vom Turm erblickt' 6 +assert_grep_count reports/185-heg.nr 'erblickt' 6 assert_grep_count reports/185-heg.cr '"lighthouse";visibility' 6 assert_grep_count reports/185-heg.cr '"neighbour";visibility' 11 assert_grep_count reports/185-6rLo.cr '^EINHEIT' 2 From a5d44f963808397ed206f3bbd77fa4870b1ea343 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Sep 2016 22:57:22 +0200 Subject: [PATCH 055/675] re-enable creport --- src/CMakeLists.txt | 4 ++-- src/eressea.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7006e4d77..df92085db 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -104,7 +104,7 @@ set (ERESSEA_SRC keyword.c skill.c json.c -# creport.c + creport.c report.c economy.c give.c @@ -199,7 +199,7 @@ set(TESTS_SRC tests.test.c volcano.test.c reports.test.c -# creport.test.c + creport.test.c report.test.c summary.test.c travelthru.test.c diff --git a/src/eressea.c b/src/eressea.c index 409254aea..dead153cb 100755 --- a/src/eressea.c +++ b/src/eressea.c @@ -29,7 +29,7 @@ #include "calendar.h" #include "chaos.h" #include "items.h" -//#include "creport.h" +#include "creport.h" #include "report.h" #include "names.h" #include "reports.h" @@ -65,7 +65,7 @@ void game_init(void) register_xmas(); register_nr(); -// register_cr(); + register_cr(); register_races(); register_spells(); From ac8332c896dd34783c647e706a7c2c4dcc8e9a2e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Sep 2016 10:24:08 +0200 Subject: [PATCH 056/675] re-enable report tests. RF_LIGHTHOUSE also flags for lighthouses with size 0. --- s/travis-build | 2 +- scripts/tests/e2/init.lua | 2 +- scripts/tests/process.lua | 2 +- src/lighthouse.c | 53 ++++++++++++++++++++------------------- src/lighthouse.test.c | 2 +- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/s/travis-build b/s/travis-build index 4c6dbcee8..45db05c60 100755 --- a/s/travis-build +++ b/s/travis-build @@ -25,4 +25,4 @@ cd $ROOT inifile s/runtests -# integraton_tests +integraton_tests diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 1f325aa17..2fdad1898 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -8,7 +8,7 @@ require 'tests.e2.spells' require 'tests.e2.stealth' require 'tests.orders' require 'tests.common' --- require 'tests.report' +require 'tests.report' require 'tests.storage' require 'tests.magicbag' require 'tests.process' diff --git a/scripts/tests/process.lua b/scripts/tests/process.lua index 63b96ddcd..3256c73e6 100644 --- a/scripts/tests/process.lua +++ b/scripts/tests/process.lua @@ -23,7 +23,7 @@ local function assert_file(filename) os.remove(filename) end -function disable_test_process_turn() +function test_process_turn() u:add_order("NUMMER PARTEI 777") process_orders() assert_equal(0, init_reports()) diff --git a/src/lighthouse.c b/src/lighthouse.c index 54591cd16..96b42b333 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -26,36 +26,37 @@ const attrib_type at_lighthouse = { */ void update_lighthouse(building * lh) { - if (lh->size>0 && is_building_type(lh->type, "lighthouse")) { + if (is_building_type(lh->type, "lighthouse")) { region *r = lh->region; - int d = (int)log10(lh->size) + 1; - int x; r->flags |= RF_LIGHTHOUSE; + if (lh->size > 0) { + int d = (int)log10(lh->size) + 1; + int x; + for (x = -d; x <= d; ++x) { + int y; + for (y = -d; y <= d; ++y) { + attrib *a; + region *r2; + int px = r->x + x, py = r->y + y; - for (x = -d; x <= d; ++x) { - int y; - for (y = -d; y <= d; ++y) { - attrib *a; - region *r2; - int px = r->x + x, py = r->y + y; - - pnormalize(&px, &py, rplane(r)); - r2 = findregion(px, py); - if (!r2 || !fval(r2->terrain, SEA_REGION)) - continue; - if (distance(r, r2) > d) - continue; - a = a_find(r2->attribs, &at_lighthouse); - while (a && a->type == &at_lighthouse) { - building *b = (building *)a->data.v; - if (b == lh) - break; - a = a->next; - } - if (!a) { - a = a_add(&r2->attribs, a_new(&at_lighthouse)); - a->data.v = (void *)lh; + pnormalize(&px, &py, rplane(r)); + r2 = findregion(px, py); + if (!r2 || !fval(r2->terrain, SEA_REGION)) + continue; + if (distance(r, r2) > d) + continue; + a = a_find(r2->attribs, &at_lighthouse); + while (a && a->type == &at_lighthouse) { + building *b = (building *)a->data.v; + if (b == lh) + break; + a = a->next; + } + if (!a) { + a = a_add(&r2->attribs, a_new(&at_lighthouse)); + a->data.v = (void *)lh; + } } } } diff --git a/src/lighthouse.test.c b/src/lighthouse.test.c index d6c63bf9a..e06941bc1 100644 --- a/src/lighthouse.test.c +++ b/src/lighthouse.test.c @@ -65,7 +65,7 @@ static void test_lighthouse_update(CuTest * tc) r2 = test_create_region(1, 0, t_ocean); r3 = test_create_region(2, 0, t_ocean); b = test_create_building(r1, test_create_buildingtype("lighthouse")); - CuAssertIntEquals(tc, 0, r1->flags&RF_LIGHTHOUSE); + CuAssertIntEquals(tc, RF_LIGHTHOUSE, r1->flags&RF_LIGHTHOUSE); CuAssertPtrEquals(tc, NULL, r1->attribs); CuAssertPtrEquals(tc, NULL, r2->attribs); CuAssertPtrEquals(tc, NULL, r3->attribs); From 18fcba3ed6af034c8d47e9cbb639b84fbdbf9eb6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Sep 2016 11:14:00 +0200 Subject: [PATCH 057/675] failing test for a new bug: empty dummy units get stuck in faction.units after recruiting. --- scripts/tests/common.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 446a7cf6d..187f78920 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -1139,3 +1139,16 @@ function test_prefix() u1.faction.locale = "en" assert_not_nil(u1:show():find("archelf")) end + +function test_recruit() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + + u:add_item("money", 1000) + set_order(u, "REKRUTIERE 5") + process_orders() + for u in f.units do + assert_equal(6, u.number) + end +end From b3c31856aaaaf74c4463cee7554912cca54ec6c1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Sep 2016 11:34:54 +0200 Subject: [PATCH 058/675] add (failing) test for recruiting into existing units. --- src/economy.c | 2 +- src/economy.h | 2 +- src/economy.test.c | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/economy.c b/src/economy.c index 8d4939d4a..1eda7bf61 100644 --- a/src/economy.c +++ b/src/economy.c @@ -244,7 +244,7 @@ static recruitment *select_recruitment(request ** rop, return recruits; } -static void add_recruits(unit * u, int number, int wanted) +void add_recruits(unit * u, int number, int wanted) { region *r = u->region; assert(number <= wanted); diff --git a/src/economy.h b/src/economy.h index b6c8002c9..4bce314a9 100644 --- a/src/economy.h +++ b/src/economy.h @@ -61,7 +61,7 @@ extern "C" { void give_control(struct unit * u, struct unit * u2); void tax_cmd(struct unit * u, struct order *ord, struct request ** taxorders); void expandtax(struct region * r, struct request * taxorders); - + void add_recruits(struct unit * u, int number, int wanted); struct message * check_steal(const struct unit * u, struct order *ord); #ifdef __cplusplus diff --git a/src/economy.test.c b/src/economy.test.c index ce09aae43..9c4311c70 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -290,6 +290,22 @@ static void test_maintain_buildings(CuTest *tc) { test_cleanup(); } +static void test_recruit(CuTest *tc) { + unit *u; + faction *f; + + test_setup(); + f = test_create_faction(0); + u = test_create_unit(f, test_create_region(0, 0, 0)); + CuAssertIntEquals(tc, 1, u->number); + add_recruits(u, 1, 1); + CuAssertIntEquals(tc, 2, u->number); + CuAssertPtrEquals(tc, u, f->units); + CuAssertPtrEquals(tc, NULL, u->nextF); + CuAssertPtrEquals(tc, NULL, u->prevF); + test_cleanup(); +} + CuSuite *get_economy_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -302,5 +318,6 @@ CuSuite *get_economy_suite(void) SUITE_ADD_TEST(suite, test_heroes_dont_recruit); SUITE_ADD_TEST(suite, test_tax_cmd); SUITE_ADD_TEST(suite, test_maintain_buildings); + SUITE_ADD_TEST(suite, test_recruit); return suite; } From bb689aa7b61d590288d8f447dd5e62965b4aa2c7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Sep 2016 11:39:04 +0200 Subject: [PATCH 059/675] assert that f->units list is correct after remove_unit (fails) --- src/kernel/unit.test.c | 45 +++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index 162bf1570..bf0284b58 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -405,7 +405,7 @@ static void test_unit_description(CuTest *tc) { static void test_remove_unit(CuTest *tc) { region *r; - unit *u; + unit *u1, *u2; faction *f; int uno; const resource_type *rtype; @@ -415,19 +415,42 @@ static void test_remove_unit(CuTest *tc) { rtype = get_resourcetype(R_SILVER); r = test_create_region(0, 0, 0); f = test_create_faction(0); - u = test_create_unit(f, r); - uno = u->no; + u2 = test_create_unit(f, r); + u1 = test_create_unit(f, r); + CuAssertPtrEquals(tc, u1, f->units); + CuAssertPtrEquals(tc, u2, u1->nextF); + CuAssertPtrEquals(tc, u1, u2->prevF); + CuAssertPtrEquals(tc, 0, u2->nextF); + uno = u1->no; region_setresource(r, rtype, 0); - i_change(&u->items, rtype->itype, 100); - remove_unit(&r->units, u); - CuAssertIntEquals(tc, 100, region_getresource(r, rtype)); - CuAssertIntEquals(tc, 0, u->number); - CuAssertPtrEquals(tc, 0, u->region); - CuAssertPtrEquals(tc, 0, u->items); - CuAssertPtrEquals(tc, 0, u->nextF); - CuAssertPtrEquals(tc, 0, r->units); + i_change(&u1->items, rtype->itype, 100); + remove_unit(&r->units, u1); + CuAssertIntEquals(tc, 0, u1->number); + CuAssertPtrEquals(tc, 0, u1->region); + // money is given to a survivor: + CuAssertPtrEquals(tc, 0, u1->items); + CuAssertIntEquals(tc, 0, region_getresource(r, rtype)); + CuAssertIntEquals(tc, 100, i_get(u2->items, rtype->itype)); + + // unit is removed from f->units: + CuAssertPtrEquals(tc, 0, u1->nextF); + CuAssertPtrEquals(tc, u2, f->units); + CuAssertPtrEquals(tc, 0, u2->nextF); + CuAssertPtrEquals(tc, 0, u2->prevF); + // unit is no longer in r->units: + CuAssertPtrEquals(tc, u2, r->units); + CuAssertPtrEquals(tc, 0, u2->next); + + // unit is in deleted_units: CuAssertPtrEquals(tc, 0, findunit(uno)); CuAssertPtrEquals(tc, f, dfindhash(uno)); + + remove_unit(&r->units, u2); + // no survivor, give money to peasants: + CuAssertIntEquals(tc, 100, region_getresource(r, rtype)); + // there are now no more units: + CuAssertPtrEquals(tc, 0, r->units); + CuAssertPtrEquals(tc, 0, f->units); test_cleanup(); } From 6c9c460815f2cb3ffc40fa18dc537f9d1e0ec4e3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Sep 2016 11:46:54 +0200 Subject: [PATCH 060/675] fix failing unit tests, remove deleted unit from f->units list. --- src/kernel/unit.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/kernel/unit.c b/src/kernel/unit.c index fb4723f29..f0636b681 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -439,6 +439,9 @@ int remove_unit(unit ** ulist, unit * u) *ulist = u->next; } + if (u->faction && u->faction->units == u) { + u->faction->units = u->nextF; + } if (u->prevF) { u->prevF->nextF = u->nextF; } From 651ce11741c81f63d00c25e9984477cb9e402a4f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Sep 2016 12:44:03 +0200 Subject: [PATCH 061/675] do not report seen_none in CR --- src/creport.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/creport.c b/src/creport.c index 51169ef0c..a3b2cbea8 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1657,7 +1657,9 @@ report_computer(const char *filename, report_context * ctx, const char *charset) /* traverse all regions */ for (r = ctx->first; r != ctx->last; r = r->next) { - cr_output_region(F, ctx, r); + if (r->seen.mode > seen_none) { + cr_output_region(F, ctx, r); + } } report_crtypes(F, f->locale); write_translations(F); From 63a97d6bc0635cb63e479bf1b950459bd1270c41 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Sep 2016 13:08:53 +0200 Subject: [PATCH 062/675] check that regions are flagged with seen_neighbour where needed. --- src/reports.test.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/reports.test.c b/src/reports.test.c index c7414e4c4..582f4372a 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -369,10 +369,56 @@ static void test_prepare_report(CuTest *tc) { test_cleanup(); } +static void test_seen_neighbours(CuTest *tc) { + report_context ctx; + faction *f; + region *r1, *r2; + + test_setup(); + f = test_create_faction(0); + r1 = test_create_region(0, 0, 0); + r2 = test_create_region(1, 0, 0); + + test_create_unit(f, r1); + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, r1, ctx.first); + CuAssertPtrEquals(tc, 0, ctx.last); + CuAssertIntEquals(tc, seen_unit, r1->seen.mode); + CuAssertIntEquals(tc, seen_neighbour, r2->seen.mode); + finish_reports(&ctx); + test_cleanup(); +} + +static void test_seen_travelthru(CuTest *tc) { + report_context ctx; + faction *f; + unit *u; + region *r1, *r2, *r3; + + test_setup(); + f = test_create_faction(0); + r1 = test_create_region(0, 0, 0); + r2 = test_create_region(1, 0, 0); + r3 = test_create_region(2, 0, 0); + + u = test_create_unit(f, r1); + travelthru_add(r2, u); + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, r1, ctx.first); + CuAssertPtrEquals(tc, 0, ctx.last); + CuAssertIntEquals(tc, seen_unit, r1->seen.mode); + CuAssertIntEquals(tc, seen_travel, r2->seen.mode); + CuAssertIntEquals(tc, seen_neighbour, r3->seen.mode); + finish_reports(&ctx); + test_cleanup(); +} + CuSuite *get_reports_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_prepare_report); + SUITE_ADD_TEST(suite, test_seen_neighbours); + SUITE_ADD_TEST(suite, test_seen_travelthru); SUITE_ADD_TEST(suite, test_prepare_lighthouse); SUITE_ADD_TEST(suite, test_prepare_lighthouse_capacity); SUITE_ADD_TEST(suite, test_prepare_travelthru); From ec9d8eab1c8cb1c9590e111ffa54306701b4adcf Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Sep 2016 13:27:25 +0200 Subject: [PATCH 063/675] fix marking seen_neighbour regions. fix reports-tests that didn't think about them. --- src/reports.c | 19 ++++++++++--------- src/reports.test.c | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/reports.c b/src/reports.c index 915aa8a1b..420cdb752 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1137,6 +1137,16 @@ static void add_seen(region *r, seen_mode mode) { static void faction_add_seen(faction *f, region *r, seen_mode mode) { add_seen(r, mode); + if (mode > seen_neighbour) { + region *next[MAXDIRECTIONS]; + int d; + get_neighbours(r, next); + for (d = 0; d != MAXDIRECTIONS; ++d) { + if (next[d] && next[d]->seen.modeterrain, FORBIDDEN_REGION)) { - region * next[MAXDIRECTIONS]; - int d; - - get_neighbours(rl, next); faction_add_seen(f, rl, seen_lighthouse); - for (d = 0; d != MAXDIRECTIONS; ++d) { - if (next[d]) { - faction_add_seen(f, next[d], seen_neighbour); - } - } } } ql_free(rlist); diff --git a/src/reports.test.c b/src/reports.test.c index 582f4372a..1cf5b023b 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -237,7 +237,7 @@ static void test_prepare_travelthru(CuTest *tc) { f2 = test_create_faction(0); r1 = test_create_region(0, 0, 0); r2 = test_create_region(1, 0, 0); - r3 = test_create_region(2, 0, 0); + r3 = test_create_region(3, 0, 0); test_create_unit(f2, r1); test_create_unit(f2, r3); u = test_create_unit(f, r1); @@ -253,7 +253,9 @@ static void test_prepare_travelthru(CuTest *tc) { CuAssertIntEquals(tc, seen_none, r2->seen.mode); prepare_report(&ctx, f2); - CuAssertIntEquals(tc, seen_none, r2->seen.mode); + CuAssertIntEquals(tc, seen_unit, r1->seen.mode); + CuAssertIntEquals(tc, seen_neighbour, r2->seen.mode); + CuAssertIntEquals(tc, seen_unit, r3->seen.mode); CuAssertPtrEquals(tc, f2, ctx.f); CuAssertPtrEquals(tc, r1, ctx.first); CuAssertPtrEquals(tc, NULL, ctx.last); @@ -295,11 +297,17 @@ void test_prepare_lighthouse_capacity(CuTest *tc) { prepare_report(&ctx, u1->faction); CuAssertPtrEquals(tc, r1, ctx.first); CuAssertPtrEquals(tc, NULL, ctx.last); + CuAssertIntEquals(tc, seen_unit, r1->seen.mode); + CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode); finish_reports(&ctx); + prepare_report(&ctx, u2->faction); CuAssertPtrEquals(tc, r1, ctx.first); - CuAssertPtrEquals(tc, r2, ctx.last); + CuAssertPtrEquals(tc, 0, ctx.last); + CuAssertIntEquals(tc, seen_unit, r1->seen.mode); + CuAssertIntEquals(tc, seen_neighbour, r2->seen.mode); finish_reports(&ctx); + test_cleanup(); } @@ -360,7 +368,7 @@ static void test_prepare_report(CuTest *tc) { CuAssertIntEquals(tc, seen_none, r->seen.mode); finish_reports(&ctx); - r = test_create_region(1, 0, 0); + r = test_create_region(2, 0, 0); CuAssertPtrEquals(tc, r, regions->next); prepare_report(&ctx, f); CuAssertPtrEquals(tc, regions, ctx.first); From dc5fe4a0eb40535eb9201d0662a7af9398f3e43b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Sep 2016 13:49:34 +0200 Subject: [PATCH 064/675] recruiting fewer units than expected creates a message. --- src/economy.test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/economy.test.c b/src/economy.test.c index 9c4311c70..fbcc720bc 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -303,6 +303,10 @@ static void test_recruit(CuTest *tc) { CuAssertPtrEquals(tc, u, f->units); CuAssertPtrEquals(tc, NULL, u->nextF); CuAssertPtrEquals(tc, NULL, u->prevF); + CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "recruit")); + add_recruits(u, 1, 2); + CuAssertIntEquals(tc, 3, u->number); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "recruit")); test_cleanup(); } From eb8376ef7084bd6f33ef5311647da0d4d44d2e02 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 03:52:10 +0200 Subject: [PATCH 065/675] allow caching of ct_find results --- src/kernel/curse.c | 34 ++++++++++++++++++++++++++++++++++ src/kernel/curse.h | 2 ++ src/kernel/curse.test.c | 19 +++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/src/kernel/curse.c b/src/kernel/curse.c index 646c99687..ac2e917a7 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -291,6 +291,17 @@ attrib_type at_curse = { #define MAXCTHASH 128 static quicklist *cursetypes[MAXCTHASH]; +static int ct_changes = 1; + +bool ct_changed(int *cache) +{ + assert(cache); + if (*cache != ct_changes) { + *cache = ct_changes; + return true; + } + return false; +} void ct_register(const curse_type * ct) { @@ -298,6 +309,27 @@ void ct_register(const curse_type * ct) quicklist **ctlp = cursetypes + hash; ql_set_insert(ctlp, (void *)ct); + ++ct_changes; +} + +void ct_remove(const char *c) +{ + unsigned int hash = tolower(c[0]); + quicklist *ctl = cursetypes[hash]; + + if (ctl) { + int qi; + + for (qi = 0; ctl; ql_advance(&ctl, &qi, 1)) { + curse_type *type = (curse_type *)ql_get(ctl, qi); + + if (strcmp(c, type->cname) == 0) { + ql_delete(&ctl, qi); + ++ct_changes; + break; + } + } + } } const curse_type *ct_find(const char *c) @@ -798,5 +830,7 @@ void curses_done(void) { int i; for (i = 0; i != MAXCTHASH; ++i) { ql_free(cursetypes[i]); + cursetypes[i] = 0; } + ++ct_changes; } diff --git a/src/kernel/curse.h b/src/kernel/curse.h index 9013a1df5..a1518bbdd 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -282,7 +282,9 @@ extern "C" { int find_cursebyname(const char *c); const curse_type *ct_find(const char *c); + bool ct_changed(int *cache); void ct_register(const curse_type *); + void ct_remove(const char *c); void ct_checknames(void); curse *findcurse(int curseid); diff --git a/src/kernel/curse.test.c b/src/kernel/curse.test.c index 6514b2f3e..d7c86b9b0 100644 --- a/src/kernel/curse.test.c +++ b/src/kernel/curse.test.c @@ -157,10 +157,29 @@ static void test_write_flag(CuTest *tc) { cleanup_curse(&fix); } +static void test_curse_cache(CuTest *tc) +{ + int cache = 0; + const curse_type ct_dummy = { "dummy", CURSETYP_NORM, 0, M_SUMEFFECT, NULL }; + test_setup(); + CuAssertIntEquals(tc, true, ct_changed(&cache)); + CuAssertIntEquals(tc, false, ct_changed(&cache)); + CuAssertPtrEquals(tc, NULL, (void *)ct_find(ct_dummy.cname)); + ct_register(&ct_dummy); + CuAssertIntEquals(tc, true, ct_changed(&cache)); + CuAssertPtrEquals(tc, (void *)&ct_dummy, (void *)ct_find(ct_dummy.cname)); + ct_remove(ct_dummy.cname); + CuAssertIntEquals(tc, true, ct_changed(&cache)); + CuAssertIntEquals(tc, false, ct_changed(&cache)); + CuAssertPtrEquals(tc, NULL, (void *)ct_find(ct_dummy.cname)); + test_cleanup(); +} + CuSuite *get_curse_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_curse); + SUITE_ADD_TEST(suite, test_curse_cache); SUITE_ADD_TEST(suite, test_magicstreet); SUITE_ADD_TEST(suite, test_magicstreet_warning); SUITE_ADD_TEST(suite, test_good_dreams); From e7739867df82c8c598d6d66b632a51e33364b2fa Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 03:55:12 +0200 Subject: [PATCH 066/675] use curse_type caching in att_modification --- src/kernel/unit.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/kernel/unit.c b/src/kernel/unit.c index f0636b681..08f9314f3 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1279,8 +1279,12 @@ static int att_modification(const unit * u, skill_t sk) if (u->attribs) { curse *c; - const curse_type *skillmod_ct = ct_find("skillmod"); - const curse_type *worse_ct = ct_find("worse"); + static int cache; + static const curse_type *skillmod_ct, *worse_ct; + if (ct_changed(&cache)) { + skillmod_ct = ct_find("skillmod"); + worse_ct = ct_find("worse"); + } c = get_curse(u->attribs, worse_ct); if (c != NULL) result += curse_geteffect(c); From 640ba05876b44ca5fbe566c58538376ce815acef Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 04:04:02 +0200 Subject: [PATCH 067/675] allow local caching of bt_find results --- src/kernel/building.c | 16 +++++++++++++++- src/kernel/building.h | 1 + src/kernel/building.test.c | 8 ++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/kernel/building.c b/src/kernel/building.c index 60b588912..0056fba1e 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -83,15 +83,28 @@ const building_type *bt_find(const char *name) return bt_find_i(name); } +static int bt_changes = 1; + +bool bt_changed(int *cache) +{ + assert(cache); + if (*cache != bt_changes) { + *cache = bt_changes; + return true; + } + return false; +} + void bt_register(building_type * type) { if (type->init) { type->init(type); } ql_push(&buildingtypes, (void *)type); + ++bt_changes; } -void free_buildingtype(void *ptr) { +static void free_buildingtype(void *ptr) { building_type *btype = (building_type *)ptr; free_construction(btype->construction); free(btype->maintenance); @@ -103,6 +116,7 @@ void free_buildingtypes(void) { ql_foreach(buildingtypes, free_buildingtype); ql_free(buildingtypes); buildingtypes = 0; + ++bt_changes; } building_type *bt_get_or_create(const char *name) diff --git a/src/kernel/building.h b/src/kernel/building.h index 587197276..dad9ffdde 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -84,6 +84,7 @@ extern "C" { extern struct attrib_type at_building_action; building_type *bt_get_or_create(const char *name); + bool bt_changed(int *cache); const building_type *bt_find(const char *name); void free_buildingtypes(void); void register_buildings(void); diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index 2f6fa6e34..755e9319f 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -17,16 +17,20 @@ static void test_register_building(CuTest * tc) { building_type *btype; + int cache = 0; test_cleanup(); btype = (building_type *)calloc(sizeof(building_type), 1); btype->_name = _strdup("herp"); + CuAssertIntEquals(tc, true, bt_changed(&cache)); + CuAssertIntEquals(tc, false, bt_changed(&cache)); bt_register(btype); + CuAssertIntEquals(tc, true, bt_changed(&cache)); CuAssertPtrNotNull(tc, bt_find("herp")); - // free(btype->_name); - // free(btype); + free_buildingtypes(); + CuAssertIntEquals(tc, true, bt_changed(&cache)); test_cleanup(); } From d139ee08d1012044531996d6f364a29cd382ff30 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 04:15:12 +0200 Subject: [PATCH 068/675] caching building_type in economy code --- src/economy.c | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/src/economy.c b/src/economy.c index 1eda7bf61..75071b608 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1709,7 +1709,11 @@ static void buy(unit * u, request ** buyorders, struct order *ord) /* ...oder in der Region mu es eine Burg geben. */ building *b = 0; if (r->buildings) { - const struct building_type *bt_castle = bt_find("castle"); + static int cache; + static const struct building_type *bt_castle; + if (bt_changed(&cache)) { + bt_castle = bt_find("castle"); + } for (b = r->buildings; b; b = b->next) { if (b->type == bt_castle && b->size >= 2) { @@ -1795,8 +1799,14 @@ static void expandselling(region * r, request * sellorders, int limit) unit *hafenowner; static int counter[MAXLUXURIES]; static int ncounter = 0; - const struct building_type *castle_bt; + static int bt_cache; + static const struct building_type *castle_bt, *harbour_bt, *caravan_bt; + if (bt_changed(&bt_cache)) { + castle_bt = bt_find("castle"); + harbour_bt = bt_find("harbour"); + caravan_bt = bt_find("caravan"); + } if (ncounter == 0) { const luxury_type *ltype; for (ltype = luxurytypes; ltype; ltype = ltype->next) { @@ -1811,7 +1821,6 @@ static void expandselling(region * r, request * sellorders, int limit) } /* Stelle Eigentmer der grten Burg fest. Bekommt Steuern aus jedem * Verkauf. Wenn zwei Burgen gleicher Gre bekommt gar keiner etwas. */ - castle_bt = bt_find("castle"); for (b = rbuildings(r); b; b = b->next) { if (b->size > maxsize && building_owner(b) != NULL && b->type == castle_bt) { @@ -1825,7 +1834,7 @@ static void expandselling(region * r, request * sellorders, int limit) } } - hafenowner = owner_buildingtyp(r, bt_find("harbour")); + hafenowner = owner_buildingtyp(r, harbour_bt); if (maxb != (building *)NULL && maxowner != (unit *)NULL) { maxeffsize = buildingeffsize(maxb, false); @@ -1847,7 +1856,7 @@ static void expandselling(region * r, request * sellorders, int limit) return; if (r->terrain == newterrain(T_DESERT) - && buildingtype_exists(r, bt_find("caravan"), true)) { + && buildingtype_exists(r, caravan_bt, true)) { max_products = rpeasants(r) * 2 / TRADE_FRACTION; } /* Verkauf: so programmiert, dass er leicht auf mehrere Gueter pro @@ -1974,6 +1983,13 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) region *r = u->region; const char *s; keyword_t kwd; + static int bt_cache; + static const struct building_type *castle_bt, *caravan_bt; + + if (bt_changed(&bt_cache)) { + castle_bt = bt_find("castle"); + caravan_bt = bt_find("caravan"); + } if (u->ship && is_guarded(r, u, GUARD_CREWS)) { cmistake(u, ord, 69, MSG_INCOME); @@ -1990,7 +2006,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) unlimited = false; n = rpeasants(r) / TRADE_FRACTION; if (r->terrain == newterrain(T_DESERT) - && buildingtype_exists(r, bt_find("caravan"), true)) + && buildingtype_exists(r, caravan_bt, true)) n *= 2; if (n == 0) { cmistake(u, ord, 303, MSG_COMMERCE); @@ -2023,9 +2039,8 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) /* ...oder in der Region mu es eine Burg geben. */ building *b = 0; if (r->buildings) { - const struct building_type *bt_castle = bt_find("castle"); for (b = r->buildings; b; b = b->next) { - if (b->type == bt_castle && b->size >= 2) break; + if (b->type == castle_bt && b->size >= 2) break; } } if (!b) { @@ -2340,9 +2355,15 @@ static void breedhorses(unit * u) int n, c, breed = 0; const struct resource_type *rhorse = get_resourcetype(R_HORSE); int horses, effsk; + static int bt_cache; + static const struct building_type *stables_bt; + + if (bt_changed(&bt_cache)) { + stables_bt = bt_find("stables"); + } assert(rhorse && rhorse->itype); - if (!active_building(u, bt_find("stables"))) { + if (!active_building(u, stables_bt)) { cmistake(u, u->thisorder, 122, MSG_PRODUCE); return; } @@ -3079,6 +3100,13 @@ void produce(struct region *r) unit *u; bool limited = true; request *nextworker = workers; + static int bt_cache; + static const struct building_type *caravan_bt; + + if (bt_changed(&bt_cache)) { + caravan_bt = bt_find("caravan"); + } + assert(r); /* das sind alles befehle, die 30 tage brauchen, und die in thisorder @@ -3228,7 +3256,7 @@ void produce(struct region *r) if (sellorders) { int limit = rpeasants(r) / TRADE_FRACTION; if (r->terrain == newterrain(T_DESERT) - && buildingtype_exists(r, bt_find("caravan"), true)) + && buildingtype_exists(r, caravan_bt, true)) limit *= 2; expandselling(r, sellorders, limited ? limit : INT_MAX); } From 9af5fb032674790449f42118d979ea7bae72c8c4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 04:23:49 +0200 Subject: [PATCH 069/675] cache some of the highest-ranking ct_find callers --- src/kernel/config.c | 11 +++++++---- src/kernel/unit.c | 6 +++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index d78362f3c..5b51950e0 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -923,8 +923,12 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn) int esize = 0; double wage; attrib *a; - const struct curse_type *ctype; + static int ct_cache; + static const struct curse_type *drought_ct; + if (ct_changed(&ct_cache)) { + drought_ct = ct_find("drought"); + } if (b != NULL) { /* TODO: this reveals imaginary castles */ esize = buildingeffsize(b, false); @@ -969,9 +973,8 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn) } /* Bei einer Drre verdient man nur noch ein Viertel */ - ctype = ct_find("drought"); - if (ctype) { - curse *c = get_curse(r->attribs, ctype); + if (drought_ct) { + curse *c = get_curse(r->attribs, drought_ct); if (curse_active(c)) wage /= curse_geteffect(c); } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 08f9314f3..246f59cb7 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1733,7 +1733,11 @@ int unit_max_hp(const unit * u) /* der healing curse veraendert die maximalen hp */ if (u->region && u->region->attribs) { - const curse_type *heal_ct = ct_find("healingzone"); + static int cache; + static const curse_type *heal_ct; + if (ct_changed(&cache)) { + heal_ct = ct_find("healingzone"); + } if (heal_ct) { curse *c = get_curse(u->region->attribs, heal_ct); if (c) { From fbd596fbfa068bc9d66fedc8685b663cafc5ac6a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 06:43:56 +0200 Subject: [PATCH 070/675] remove bad caching in get_race --- src/kernel/race.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/kernel/race.c b/src/kernel/race.c index 57f443ea5..bb91898db 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -75,30 +75,15 @@ static const char *racenames[MAXRACES] = { "clone" }; -static race * race_cache[MAXRACES]; - struct race *get_race(race_t rt) { - static int cache = -1; const char * name; - race * result = 0; assert(rt < MAXRACES); name = racenames[rt]; if (!name) { - return 0; + return NULL; } - if (cache_breaker != cache) { - cache = cache_breaker; - memset(race_cache, 0, sizeof(race_cache)); - return race_cache[rt] = rc_get_or_create(name); - } - else { - result = race_cache[rt]; - if (!result) { - result = race_cache[rt] = rc_get_or_create(name); - } - } - return result; + return rc_get_or_create(name); } race_list *get_familiarraces(void) From f8167ed62caab84b93c523982800f429e85b339b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 06:47:46 +0200 Subject: [PATCH 071/675] test get_race and others --- src/kernel/race.test.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index e8bbfcf29..25bd3e912 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -9,7 +9,7 @@ static void test_rc_name(CuTest *tc) { struct race *rc; - test_cleanup(); + test_setup(); rc = test_create_race("human"); CuAssertStrEquals(tc, "race::human", rc_name_s(rc, NAME_SINGULAR)); CuAssertStrEquals(tc, "race::human_p", rc_name_s(rc, NAME_PLURAL)); @@ -20,7 +20,7 @@ static void test_rc_name(CuTest *tc) { static void test_rc_defaults(CuTest *tc) { struct race *rc; - test_cleanup(); + test_setup(); rc = rc_get_or_create("human"); CuAssertStrEquals(tc, "human", rc->_name); CuAssertDblEquals(tc, 0.0, rc->magres, 0.0); @@ -43,15 +43,25 @@ static void test_rc_defaults(CuTest *tc) { static void test_rc_find(CuTest *tc) { race *rc; - test_cleanup(); + test_setup(); rc = test_create_race("hungryhippos"); CuAssertPtrEquals(tc, rc, (void *)rc_find("hungryhippos")); test_cleanup(); } +static void test_race_get(CuTest *tc) { + race *rc; + test_setup(); + rc = get_race(RC_ELF); + CuAssertPtrEquals(tc, rc, (void *)rc_find("elf")); + CuAssertPtrEquals(tc, rc, (void *)rc_get_or_create("elf")); + test_cleanup(); +} + CuSuite *get_race_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_race_get); SUITE_ADD_TEST(suite, test_rc_name); SUITE_ADD_TEST(suite, test_rc_defaults); SUITE_ADD_TEST(suite, test_rc_find); From 96d6abdc5a802e335fadd15e2a06c991249be4d0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 06:55:32 +0200 Subject: [PATCH 072/675] add caching API for rc_find --- src/kernel/race.c | 14 ++++++++++++-- src/kernel/race.h | 1 + src/kernel/race.test.c | 9 ++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/kernel/race.c b/src/kernel/race.c index bb91898db..1088681d2 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -59,7 +59,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /** external variables **/ race *races; int num_races = 0; -static int cache_breaker; +static int rc_changes = 1; static const char *racenames[MAXRACES] = { "dwarf", "elf", NULL, "goblin", "human", "troll", "demon", "insect", @@ -132,6 +132,7 @@ void free_races(void) { races = rc; } num_races = 0; + ++rc_changes; } static race *rc_find_i(const char *name) @@ -153,6 +154,15 @@ const race * rc_find(const char *name) { return rc_find_i(name); } +bool rc_changed(int *cache) { + assert(cache); + if (*cache != rc_changes) { + *cache = rc_changes; + return true; + } + return false; +} + race *rc_get_or_create(const char *zName) { race *rc; @@ -180,7 +190,7 @@ race *rc_get_or_create(const char *zName) for (i = 1; i < RACE_ATTACKS; ++i) rc->attack[i].type = AT_NONE; rc->index = num_races++; - ++cache_breaker; + ++rc_changes; rc->next = races; return races = rc; } diff --git a/src/kernel/race.h b/src/kernel/race.h index b1632f62d..6e8e4bd36 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -180,6 +180,7 @@ extern "C" { race_t old_race(const struct race *); race *rc_get_or_create(const char *name); + bool rc_changed(int *cache); const race *rc_find(const char *); void free_races(void); diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index 25bd3e912..0a14c3ca6 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -50,11 +50,18 @@ static void test_rc_find(CuTest *tc) { } static void test_race_get(CuTest *tc) { + int cache; race *rc; test_setup(); + CuAssertTrue(tc, rc_changed(&cache)); + CuAssertTrue(tc, !rc_changed(&cache)); rc = get_race(RC_ELF); - CuAssertPtrEquals(tc, rc, (void *)rc_find("elf")); CuAssertPtrEquals(tc, rc, (void *)rc_get_or_create("elf")); + CuAssertTrue(tc, rc_changed(&cache)); + CuAssertTrue(tc, !rc_changed(&cache)); + CuAssertPtrEquals(tc, rc, (void *)rc_find("elf")); + free_races(); + CuAssertTrue(tc, rc_changed(&cache)); test_cleanup(); } From fe383af5f2cb032fc31d1e82bccf9f38c4f3b9f6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 06:58:24 +0200 Subject: [PATCH 073/675] sample usage of race caching --- src/spells.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/spells.c b/src/spells.c index ab4d6dd6d..015d56067 100644 --- a/src/spells.c +++ b/src/spells.c @@ -1501,16 +1501,23 @@ static int sp_create_irongolem(castorder * co) int cast_level = co->level; double force = co->force; int number = lovar(force * 8 * RESOURCE_QUANTITY); - if (number < 1) + static int cache; + race * golem_rc; + + if (rc_changed(&cache)) { + golem_rc = rc_find("irongolem"); + } + + if (number < 1) { number = 1; + } if (r->terrain == newterrain(T_SWAMP)) { cmistake(mage, co->order, 188, MSG_MAGIC); return 0; } - u2 = - create_unit(r, mage->faction, number, rc_find("irongolem"), 0, NULL, mage); + u2 = create_unit(r, mage->faction, number, golem_rc, 0, NULL, mage); set_level(u2, SK_ARMORER, 1); set_level(u2, SK_WEAPONSMITH, 1); @@ -1523,7 +1530,7 @@ static int sp_create_irongolem(castorder * co) ADDMSG(&mage->faction->msgs, msg_message("magiccreate_effect", "region command unit amount object", mage->region, co->order, mage, number, - LOC(mage->faction->locale, rc_name_s(rc_find("irongolem"), (u2->number == 1) ? NAME_SINGULAR : NAME_PLURAL)))); + LOC(mage->faction->locale, rc_name_s(golem_rc, (u2->number == 1) ? NAME_SINGULAR : NAME_PLURAL)))); return cast_level; } From 025c0b91d9110911695f204ef08ce0e024b76ca7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 07:02:45 +0200 Subject: [PATCH 074/675] cache the toad race --- src/study.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/study.c b/src/study.c index 58cbde94a..70c016dfc 100644 --- a/src/study.c +++ b/src/study.c @@ -94,6 +94,9 @@ magic_t getmagicskill(const struct locale * lang) /* familiars and toads are not migrants */ bool is_migrant(unit * u) { + static int cache; + static race *toad_rc; + if (u_race(u) == u->faction->race) return false; @@ -101,16 +104,21 @@ bool is_migrant(unit * u) return false; if (is_familiar(u)) return false; - if (u_race(u) == get_race(RC_TOAD)) - return false; - - return true; + if (rc_changed(&cache)) { + toad_rc = get_race(RC_TOAD); + } + return u_race(u) != toad_rc; } /* ------------------------------------------------------------- */ bool magic_lowskill(unit * u) { - return (u_race(u) == get_race(RC_TOAD)) ? true : false; + static race *toad_rc; + static int cache; + if (rc_changed(&cache)) { + toad_rc = get_race(RC_TOAD); + } + return u_race(u) == toad_rc; } /* ------------------------------------------------------------- */ From ee77075cb6fd777079e0cc4fea6d6bb6f08b6e77 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 08:25:39 +0200 Subject: [PATCH 075/675] cache get_race calls --- src/kernel/config.c | 1 + src/kernel/skills.c | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index d78362f3c..dc61e643b 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -140,6 +140,7 @@ int NMRTimeout(void) race_t old_race(const struct race * rc) { race_t i; + // TODO: this sucks so bad! for (i = 0; i != MAXRACES; ++i) { if (get_race(i) == rc) return i; } diff --git a/src/kernel/skills.c b/src/kernel/skills.c index caae7b836..e773424ab 100644 --- a/src/kernel/skills.c +++ b/src/kernel/skills.c @@ -104,16 +104,22 @@ int value, int flags) int skill_mod(const race * rc, skill_t sk, const struct terrain_type *terrain) { int result = 0; + static int rc_cache; + static race *rc_dwarf, *rc_insect; + if (rc_changed(&rc_cache)) { + rc_dwarf = get_race(RC_DWARF); + rc_insect = get_race(RC_INSECT); + } result = rc->bonus[sk]; - if (rc == get_race(RC_DWARF)) { + if (rc == rc_dwarf) { if (sk == SK_TACTICS) { if (terrain == newterrain(T_MOUNTAIN) || fval(terrain, ARCTIC_REGION)) ++result; } } - else if (rc == get_race(RC_INSECT)) { + else if (rc == rc_insect) { if (terrain == newterrain(T_MOUNTAIN) || fval(terrain, ARCTIC_REGION)) --result; else if (terrain == newterrain(T_DESERT) || terrain == newterrain(T_SWAMP)) @@ -126,19 +132,25 @@ int skill_mod(const race * rc, skill_t sk, const struct terrain_type *terrain) int rc_skillmod(const struct race *rc, const region * r, skill_t sk) { int mods = 0; - if (!skill_enabled(sk)) { return 0; } if (r) { mods = skill_mod(rc, sk, r->terrain); } - if (rc == get_race(RC_ELF) && r && r_isforest(r)) { - if (sk == SK_PERCEPTION || sk == SK_STEALTH) { - ++mods; + if (r && r_isforest(r)) { + static int rc_cache; + static race * rc_elf; + if (rc_changed(&rc_cache)) { + rc_elf = get_race(RC_ELF); } - else if (sk == SK_TACTICS) { - mods += 2; + if (rc == rc_elf) { + if (sk == SK_PERCEPTION || sk == SK_STEALTH) { + ++mods; + } + else if (sk == SK_TACTICS) { + mods += 2; + } } } return mods; From be5f15e18a58b36c8bcd4bb9f82a024e38c4ed48 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 08:32:09 +0200 Subject: [PATCH 076/675] fix const-conversion warning --- src/spells.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/spells.c b/src/spells.c index 015d56067..63f3af6a3 100644 --- a/src/spells.c +++ b/src/spells.c @@ -1502,7 +1502,7 @@ static int sp_create_irongolem(castorder * co) double force = co->force; int number = lovar(force * 8 * RESOURCE_QUANTITY); static int cache; - race * golem_rc; + const race * golem_rc; if (rc_changed(&cache)) { golem_rc = rc_find("irongolem"); @@ -1570,6 +1570,11 @@ static int sp_create_stonegolem(castorder * co) unit *mage = co->magician.u; int cast_level = co->level; int number = lovar(co->force * 5 * RESOURCE_QUANTITY); + const race * golem_rc; + + if (rc_changed(&cache)) { + golem_rc = rc_find("stonegolem"); + } if (number < 1) number = 1; @@ -1579,7 +1584,7 @@ static int sp_create_stonegolem(castorder * co) } u2 = - create_unit(r, mage->faction, number, rc_find("stonegolem"), 0, NULL, mage); + create_unit(r, mage->faction, number, golem_rc, 0, NULL, mage); set_level(u2, SK_ROAD_BUILDING, 1); set_level(u2, SK_BUILDING, 1); @@ -1591,7 +1596,7 @@ static int sp_create_stonegolem(castorder * co) ADDMSG(&mage->faction->msgs, msg_message("magiccreate_effect", "region command unit amount object", mage->region, co->order, mage, number, - LOC(mage->faction->locale, rc_name_s(rc_find("stonegolem"), (u2->number == 1) ? NAME_SINGULAR : NAME_PLURAL)))); + LOC(mage->faction->locale, rc_name_s(golem_rc, (u2->number == 1) ? NAME_SINGULAR : NAME_PLURAL)))); return cast_level; } From 6964267c3764ba6d74e2d186926ccc03e65a3016 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 08:35:54 +0200 Subject: [PATCH 077/675] static variables, duh --- src/spells.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/spells.c b/src/spells.c index 63f3af6a3..380d41b54 100644 --- a/src/spells.c +++ b/src/spells.c @@ -1502,7 +1502,7 @@ static int sp_create_irongolem(castorder * co) double force = co->force; int number = lovar(force * 8 * RESOURCE_QUANTITY); static int cache; - const race * golem_rc; + static const race * golem_rc; if (rc_changed(&cache)) { golem_rc = rc_find("irongolem"); @@ -1570,7 +1570,8 @@ static int sp_create_stonegolem(castorder * co) unit *mage = co->magician.u; int cast_level = co->level; int number = lovar(co->force * 5 * RESOURCE_QUANTITY); - const race * golem_rc; + static int cache; + static const race * golem_rc; if (rc_changed(&cache)) { golem_rc = rc_find("stonegolem"); From 115e13d513d6fd93e04cf14c58e81a0f01faf262 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 08:42:07 +0200 Subject: [PATCH 078/675] initialize variable --- src/kernel/race.test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index 0a14c3ca6..7c464e4da 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -50,7 +50,7 @@ static void test_rc_find(CuTest *tc) { } static void test_race_get(CuTest *tc) { - int cache; + int cache = 0; race *rc; test_setup(); CuAssertTrue(tc, rc_changed(&cache)); From b958fa1c2e724de73db5d04d4746752487eac718 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 08:56:33 +0200 Subject: [PATCH 079/675] get_race is better than old_race --- src/volcano.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/volcano.c b/src/volcano.c index 910bd8775..bd8c56b30 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -118,7 +118,7 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic) heiltrank = 0; /* Sieben Leben */ - if (old_race(u_race(u)) == RC_CAT && (chance(1.0 / 7))) { + if (u_race(u) == get_race(RC_CAT) && (chance(1.0 / 7))) { hp[i] = u->hp / u->number; hp_rem += hp[i]; continue; From 6ec99af4d6d84276f437dc3b6a11ace1bac3dec7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 15:53:31 +0200 Subject: [PATCH 080/675] mark all three major dragon types as RCF_DRAGON. use RCF_DRGON flag to detemine BP_DRAGON speed. --- res/eressea/races.xml | 2 +- res/races/dragon.xml | 2 +- res/races/wyrm.xml | 2 +- res/races/youngdragon.xml | 2 +- src/move.c | 11 +++++------ 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 201a6a797..b29b84ede 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -742,7 +742,7 @@ - + diff --git a/res/races/dragon.xml b/res/races/dragon.xml index 7a6dee3a7..a1f347105 100644 --- a/res/races/dragon.xml +++ b/res/races/dragon.xml @@ -1,5 +1,5 @@ +"6" damage="2d30" unarmedattack="0" unarmeddefense="0" attackmodifier="7" defensemodifier="7" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes"> diff --git a/res/races/wyrm.xml b/res/races/wyrm.xml index 8569f4c19..5c63b0fb6 100644 --- a/res/races/wyrm.xml +++ b/res/races/wyrm.xml @@ -1,4 +1,4 @@ - + diff --git a/res/races/youngdragon.xml b/res/races/youngdragon.xml index 541f68142..fe29bbfde 100644 --- a/res/races/youngdragon.xml +++ b/res/races/youngdragon.xml @@ -1,4 +1,4 @@ - + diff --git a/src/move.c b/src/move.c index c95775b5a..a97bc5425 100644 --- a/src/move.c +++ b/src/move.c @@ -1465,15 +1465,14 @@ static void make_route(unit * u, order * ord, region_list ** routep) static int movement_speed(unit * u) { int mp = BP_WALKING; - double dk = u_race(u)->speed; - + const race *rc = u_race(u); + double dk = rc->speed; assert(u->number); /* dragons have a fixed speed, and no other effects work on them: */ - switch (old_race(u_race(u))) { - case RC_DRAGON: - case RC_WYRM: - case RC_FIREDRAGON: + if (fval(rc, RCF_DRAGON)) { return BP_DRAGON; + } + switch (old_race(u_race(u))) { case RC_BIRTHDAYDRAGON: case RC_SONGDRAGON: mp = BP_DRAGON; From e6677806b615d9b65d26a273853c2f576f56f353 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 16:03:02 +0200 Subject: [PATCH 081/675] refactor unholy power, extract function --- src/spells.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/spells.c b/src/spells.c index 380d41b54..589b062da 100644 --- a/src/spells.c +++ b/src/spells.c @@ -2730,6 +2730,22 @@ static int sp_firewall(castorder * co) * (SPELLLEVEL | TESTCANSEE) */ +static race *unholy_race(const race *rc) { + race *target_race = NULL; + switch (old_race(rc)) { + case RC_SKELETON: + target_race = get_race(RC_SKELETON_LORD); + break; + case RC_ZOMBIE: + target_race = get_race(RC_ZOMBIE_LORD); + break; + case RC_GHOUL: + target_race = get_race(RC_GHOUL_LORD); + break; + } + return target_race; +} + static int sp_unholypower(castorder * co) { region * r = co_get_region(co); @@ -2752,17 +2768,8 @@ static int sp_unholypower(castorder * co) u = pa->param[i]->data.u; - switch (old_race(u_race(u))) { - case RC_SKELETON: - target_race = get_race(RC_SKELETON_LORD); - break; - case RC_ZOMBIE: - target_race = get_race(RC_ZOMBIE_LORD); - break; - case RC_GHOUL: - target_race = get_race(RC_GHOUL_LORD); - break; - default: + target_race = unholy_race(u_race(u)); + if (!target_race) { cmistake(mage, co->order, 284, MSG_MAGIC); continue; } From 1f100a1b6ceea63f5a1eaac15bbee7bf2f54fe8f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 16:10:10 +0200 Subject: [PATCH 082/675] replace old_race calls with get_race. --- src/monsters.c | 19 +++++++------------ src/spells.c | 2 ++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/monsters.c b/src/monsters.c index 0da4947f2..f5d38a446 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -380,20 +380,15 @@ static order *monster_move(region * r, unit * u) if (monster_is_waiting(u)) { return NULL; } - switch (old_race(u_race(u))) { - case RC_FIREDRAGON: - case RC_DRAGON: - case RC_WYRM: + if (fval(u_race(u), RCF_DRAGON)) { d = richest_neighbour(r, u->faction, 1); - break; - case RC_TREEMAN: - d = treeman_neighbour(r); - break; - default: - d = random_neighbour(r, u); - break; } - + else if (get_race(RC_TREEMAN)==u_race(u)) { + d = treeman_neighbour(r); + } + else { + d = random_neighbour(r, u); + } /* falls kein geld gefunden wird, zufaellig verreisen, aber nicht in * den ozean */ diff --git a/src/spells.c b/src/spells.c index 589b062da..37fa9af55 100644 --- a/src/spells.c +++ b/src/spells.c @@ -2742,6 +2742,8 @@ static race *unholy_race(const race *rc) { case RC_GHOUL: target_race = get_race(RC_GHOUL_LORD); break; + default: + target_race = NULL; } return target_race; } From 043ff40d0255c680b504afb37c602fbaad24816b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 18:28:44 +0200 Subject: [PATCH 083/675] eliminate another call to old_race. --- src/spells.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/spells.c b/src/spells.c index 37fa9af55..a860abe3c 100644 --- a/src/spells.c +++ b/src/spells.c @@ -2731,21 +2731,23 @@ static int sp_firewall(castorder * co) */ static race *unholy_race(const race *rc) { - race *target_race = NULL; - switch (old_race(rc)) { - case RC_SKELETON: - target_race = get_race(RC_SKELETON_LORD); - break; - case RC_ZOMBIE: - target_race = get_race(RC_ZOMBIE_LORD); - break; - case RC_GHOUL: - target_race = get_race(RC_GHOUL_LORD); - break; - default: - target_race = NULL; + static int cache; + static race * rc_skeleton, *rc_zombie, *rc_ghoul; + if (rc_changed(&cache)) { + rc_skeleton = get_race(RC_SKELETON); + rc_zombie = get_race(RC_ZOMBIE); + rc_ghoul = get_race(RC_GHOUL); } - return target_race; + if (rc == rc_skeleton) { + return get_race(RC_SKELETON_LORD); + } + if (rc == rc_zombie) { + return get_race(RC_ZOMBIE_LORD); + } + if (rc == rc_ghoul) { + return get_race(RC_GHOUL_LORD); + } + return NULL; } static int sp_unholypower(castorder * co) From a7fbe4901b920ffda74558fafeaef66ffb7b2c74 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 18:42:14 +0200 Subject: [PATCH 084/675] eliminate old_race. make the catdragon act like a dragon. --- res/eressea/races.xml | 2 +- src/battle.c | 46 ++++++++++++++++++---------------- src/economy.c | 58 +++++++++++++++++++++++-------------------- src/guard.c | 30 +++++++++++++--------- src/kernel/race.h | 2 +- 5 files changed, 75 insertions(+), 63 deletions(-) diff --git a/res/eressea/races.xml b/res/eressea/races.xml index b29b84ede..513797d8d 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -717,7 +717,7 @@ - + diff --git a/src/battle.c b/src/battle.c index 392b24441..534984fb1 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1037,31 +1037,33 @@ static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_ { const race *ar = u_race(au); int m, modifier = 0; - - switch (old_race(ar)) { - case RC_HALFLING: - if (wtype != NULL && dragonrace(u_race(du))) { - modifier += 5; + if (wtype != NULL) { + if (fval(u_race(du), RCF_DRAGON)) { + static int cache; + static race *rc_halfling; + if (rc_changed(&cache)) { + rc_halfling = get_race(RC_HALFLING); + } + if (ar == rc_halfling) { + modifier += 5; + } } - break; - default: - break; - } - if (wtype != NULL && wtype->modifiers != NULL) { - for (m = 0; wtype->modifiers[m].value; ++m) { - /* weapon damage for this weapon, possibly by race */ - if (wtype->modifiers[m].flags & WMF_DAMAGE) { - race_list *rlist = wtype->modifiers[m].races; - if (rlist != NULL) { - while (rlist) { - if (rlist->data == ar) - break; - rlist = rlist->next; + if (wtype->modifiers != NULL) { + for (m = 0; wtype->modifiers[m].value; ++m) { + /* weapon damage for this weapon, possibly by race */ + if (wtype->modifiers[m].flags & WMF_DAMAGE) { + race_list *rlist = wtype->modifiers[m].races; + if (rlist != NULL) { + while (rlist) { + if (rlist->data == ar) + break; + rlist = rlist->next; + } + if (rlist == NULL) + continue; } - if (rlist == NULL) - continue; + modifier += wtype->modifiers[m].value; } - modifier += wtype->modifiers[m].value; } } } diff --git a/src/economy.c b/src/economy.c index 1eda7bf61..ae13d5ecc 100644 --- a/src/economy.c +++ b/src/economy.c @@ -114,16 +114,20 @@ static void recruit_init(void) int income(const unit * u) { - switch (old_race(u_race(u))) { - case RC_FIREDRAGON: - return 150 * u->number; - case RC_DRAGON: - return 1000 * u->number; - case RC_WYRM: - return 5000 * u->number; - default: - return 20 * u->number; + // TODO: make this a property, like race.income, no hard-coding of values + if (fval(u_race(u), RCF_DRAGON)) { + switch (old_race(u_race(u))) { + case RC_FIREDRAGON: + return 150 * u->number; + case RC_DRAGON: + return 1000 * u->number; + case RC_WYRM: + return 5000 * u->number; + default: + break; + } } + return 20 * u->number; } static void scramble(void *data, unsigned int n, size_t width) @@ -478,7 +482,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders) init_order(ord); n = getint(); - if (n<=0) { + if (n <= 0) { syntax_error(u, ord); return; } @@ -796,7 +800,7 @@ static int maintain(building * b) cost -= use_pooled(u, m->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, - cost); + cost); assert(cost == 0); } if (work) { @@ -815,7 +819,7 @@ void maintain_buildings(region * r) while (*bp) { building *b = *bp; int flags = BLD_MAINTAINED; - + if (!curse_active(get_curse(b->attribs, nocost_ct))) { flags = maintain(b); } @@ -929,12 +933,12 @@ static void manufacture(unit * u, const item_type * itype, int want) case EBUILDINGREQ: ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "building_needed", "building", - itype->construction->btype->_name)); + itype->construction->btype->_name)); return; case ELOWSKILL: ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "manufacture_skills", - "skill minskill product", sk, minskill, itype->rtype, 1)); + "skill minskill product", sk, minskill, itype->rtype, 1)); return; case ENOMATERIALS: ADDMSG(&u->faction->msgs, msg_materials_required(u, u->thisorder, @@ -1077,8 +1081,8 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) skill_t sk = itype->construction->skill; add_message(&u->faction->msgs, msg_feedback(u, u->thisorder, "manufacture_skills", - "skill minskill product", sk, itype->construction->minskill, - itype->rtype)); + "skill minskill product", sk, itype->construction->minskill, + itype->rtype)); return; } else { @@ -1276,7 +1280,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) } typedef void(*allocate_function) (const resource_type *, struct region *, -struct allocation *); + struct allocation *); static allocate_function get_allocator(const struct resource_type *rtype) { @@ -1345,7 +1349,7 @@ static void create_potion(unit * u, const potion_type * ptype, int want) case EBUILDINGREQ: ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "building_needed", "building", - ptype->itype->construction->btype->_name)); + ptype->itype->construction->btype->_name)); break; case ECOMPLETE: assert(0); @@ -1687,7 +1691,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord) kwd = init_order(ord); assert(kwd == K_BUY); n = getint(); - if (n<=0) { + if (n <= 0) { cmistake(u, ord, 26, MSG_COMMERCE); return; } @@ -2082,7 +2086,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) * produktion, wo fr jedes produkt einzeln eine obere limite * existiert, so dass man arrays von orders machen kann. */ - /* Ein Hndler kann nur 10 Gter pro Talentpunkt handeln. */ + /* Ein Hndler kann nur 10 Gter pro Talentpunkt handeln. */ k = u->number * 10 * effskill(u, SK_TRADE, 0); /* hat der Hndler bereits gehandelt, muss die Menge der bereits @@ -2188,7 +2192,7 @@ static void plant(unit * u, int raw) if (skill < 6) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "plant_skills", - "skill minskill product", SK_HERBALISM, 6, itype->rtype, 1)); + "skill minskill product", SK_HERBALISM, 6, itype->rtype, 1)); return; } /* Wasser des Lebens prfen */ @@ -2202,7 +2206,7 @@ static void plant(unit * u, int raw) if (n == 0) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "resource_missing", "missing", - itype->rtype)); + itype->rtype)); return; } @@ -2218,7 +2222,7 @@ static void plant(unit * u, int raw) /* Alles ok. Abziehen. */ use_pooled(u, rt_water, GET_DEFAULT, 1); use_pooled(u, itype->rtype, GET_DEFAULT, n); - rsetherbs(r, (short) (rherbs(r) + planted)); + rsetherbs(r, (short)(rherbs(r) + planted)); ADDMSG(&u->faction->msgs, msg_message("plant", "unit region amount herb", u, r, planted, itype->rtype)); } @@ -2241,13 +2245,13 @@ static void planttrees(unit * u, int raw) if (skill < 6) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "plant_skills", - "skill minskill product", SK_HERBALISM, 6, rtype, 1)); + "skill minskill product", SK_HERBALISM, 6, rtype, 1)); return; } if (fval(r, RF_MALLORN) && skill < 7) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "plant_skills", - "skill minskill product", SK_HERBALISM, 7, rtype, 1)); + "skill minskill product", SK_HERBALISM, 7, rtype, 1)); return; } @@ -2284,7 +2288,7 @@ static void breedtrees(unit * u, int raw) int current_season; region *r = u->region; gamedate date; - + get_gamedate(turn, &date); current_season = date.season; @@ -2536,7 +2540,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders) return; } id = read_unitid(u->faction, r); - if (id>0) { + if (id > 0) { u2 = findunitr(r, id); } if (u2 && u2->region == u->region) { diff --git a/src/guard.c b/src/guard.c index f779e7e2e..326b89bee 100644 --- a/src/guard.c +++ b/src/guard.c @@ -67,28 +67,34 @@ void update_guards(void) unsigned int guard_flags(const unit * u) { + // TODO: this should be a property of the race, like race.guard_flags + static int rc_cache; + static race *rc_elf, *rc_ent, *rc_ironkeeper; + const race *rc = u_race(u); unsigned int flags = GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX; + // TODO: configuration, not define #if GUARD_DISABLES_PRODUCTION == 1 flags |= GUARD_PRODUCE; #endif #if GUARD_DISABLES_RECRUIT == 1 flags |= GUARD_RECRUIT; #endif - switch (old_race(u_race(u))) { - case RC_ELF: - if (u->faction->race != u_race(u)) - break; - /* else fallthrough */ - case RC_TREEMAN: + if (rc_changed(&rc_cache)) { + rc_elf = get_race(RC_ELF); + rc_ent = get_race(RC_TREEMAN); + rc_ironkeeper = get_race(RC_IRONKEEPER); + } + if (rc == rc_elf) { + if (u->faction->race == u_race(u)) { + flags |= GUARD_TREES; + } + } + else if (rc == rc_ent) { flags |= GUARD_TREES; - break; - case RC_IRONKEEPER: + } + else if (rc == rc_ironkeeper) { flags = GUARD_MINING; - break; - default: - /* TODO: This should be configuration variables, all of it */ - break; } return flags; } diff --git a/src/kernel/race.h b/src/kernel/race.h index 6e8e4bd36..d11dc5fd1 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -244,7 +244,7 @@ extern "C" { #define omniscient(f) ((f)->race==get_race(RC_ILLUSION) || (f)->race==get_race(RC_TEMPLATE)) #define playerrace(rc) (!fval((rc), RCF_NPC)) -#define dragonrace(rc) ((rc) == get_race(RC_FIREDRAGON) || (rc) == get_race(RC_DRAGON) || (rc) == get_race(RC_WYRM) || (rc) == get_race(RC_BIRTHDAYDRAGON)) +#define dragonrace(rc) (fval(rc, RCF_DRAGON)) #define humanoidrace(rc) (fval((rc), RCF_UNDEAD) || (rc)==get_race(RC_DRACOID) || playerrace(rc)) #define illusionaryrace(rc) (fval(rc, RCF_ILLUSIONARY)) From aceb8808268611c6445a3896778c51b455089819 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 18:45:16 +0200 Subject: [PATCH 085/675] add some TODO and reduce old_race usage. --- src/laws.c | 2 +- src/monster.c | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/laws.c b/src/laws.c index 19078353e..199d9e0a0 100755 --- a/src/laws.c +++ b/src/laws.c @@ -3464,7 +3464,7 @@ static int use_item(unit * u, const item_type * itype, int amount, struct order static double heal_factor(const unit * u) { double elf_regen; - + // TODO: do not hard-code, make this a property, race.healing switch (old_race(u_race(u))) { case RC_TROLL: case RC_DAEMON: diff --git a/src/monster.c b/src/monster.c index 5eafba1ea..37c48f8b5 100644 --- a/src/monster.c +++ b/src/monster.c @@ -83,6 +83,7 @@ static void eaten_by_monster(unit * u) multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0; } + // TODO: do not hard-code, make it a race property or callback? it's already RCF_KILLPEASANTS switch (old_race(u_race(u))) { case RC_FIREDRAGON: n = rng_int() % 80 * u->number; @@ -118,12 +119,7 @@ static void eaten_by_monster(unit * u) static void absorbed_by_monster(unit * u) { - int n; - - switch (old_race(u_race(u))) { - default: - n = rng_int() % (u->number / 20 + 1); - } + int n = rng_int() % (u->number / 20 + 1); if (n > 0) { n = lovar(n); From 12239178c6b567fa291e18725bc84568836117e1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 20:10:01 +0200 Subject: [PATCH 086/675] rc_find optimizations in monster AI. remove dead alp code. --- src/monsters.c | 125 +++++++++++++------------------------------- src/monsters.test.c | 3 +- src/move.c | 2 +- 3 files changed, 37 insertions(+), 93 deletions(-) diff --git a/src/monsters.c b/src/monsters.c index f5d38a446..78999e015 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -485,65 +485,6 @@ static order *make_movement_order(unit * u, const region * target, int moves, return parse_order(zOrder, u->faction->locale); } -#ifdef TODO_ALP -static order *monster_seeks_target(region * r, unit * u) -{ - direction_t d; - unit *target = NULL; - int dist, dist2; - direction_t i; - region *nr; - - /* Das Monster sucht ein bestimmtes Opfer. Welches, steht - * in einer Referenz/attribut - * derzeit gibt es nur den alp - */ - - switch (old_race(u_race(u))) { - case RC_ALP: - target = alp_target(u); - break; - default: - assert(!"Seeker-Monster gibt kein Ziel an"); - } - - /* TODO: prfen, ob target berhaupt noch existiert... */ - if (!target) { - log_error("Monster '%s' hat kein Ziel!\n", unitname(u)); - return NULL; /* this is a bug workaround! remove!! */ - } - - if (r == target->region) { /* Wir haben ihn! */ - if (u_race(u) == get_race(RC_ALP)) { - alp_findet_opfer(u, r); - } else { - assert(!"Seeker-Monster hat keine Aktion fuer Ziel"); - } - return NULL; - } - - /* Simpler Ansatz: Nachbarregion mit gerinster Distanz suchen. - * Sinnvoll momentan nur bei Monstern, die sich nicht um das - * Terrain kmmern. Nebelwnde & Co machen derzeit auch nix... - */ - dist2 = distance(r, target->region); - d = NODIRECTION; - for (i = 0; i < MAXDIRECTIONS; i++) { - nr = rconnect(r, i); - assert(nr); - dist = distance(nr, target->region); - if (dist < dist2) { - dist2 = dist; - d = i; - } - } - assert(d != NODIRECTION); - - return create_order(K_MOVE, u->faction->locale, "%s", - LOC(u->faction->locale, directions[d])); -} -#endif - void random_growl(const unit *u, region *target, int rand) { const struct locale *lang = u->faction->locale; @@ -652,6 +593,13 @@ static order *plan_dragon(unit * u) region *tr = NULL; bool move = false; order *long_order = NULL; + static int rc_cache; + static const race *rc_wyrm; + const race * rc = u_race(u); + + if (rc_changed(&rc_cache)) { + rc_wyrm = get_race(RC_WYRM); + } if (ta == NULL) { move |= (rpeasants(r) == 0); /* when no peasants, move */ @@ -659,7 +607,7 @@ static order *plan_dragon(unit * u) } move |= chance(0.04); /* 4% chance to change your mind */ - if (u_race(u) == get_race(RC_WYRM) && !move) { + if (rc == rc_wyrm && !move) { unit *u2; for (u2 = r->units; u2; u2 = u2->next) { /* wyrme sind einzelgnger */ @@ -689,18 +637,21 @@ static order *plan_dragon(unit * u) } if (tr != NULL) { assert(long_order == NULL); - switch (old_race(u_race(u))) { - case RC_FIREDRAGON: - long_order = make_movement_order(u, tr, 4, allowed_dragon); - break; - case RC_DRAGON: - long_order = make_movement_order(u, tr, 3, allowed_dragon); - break; - case RC_WYRM: + // TODO: per-race planning functions? + if (rc == rc_wyrm) { long_order = make_movement_order(u, tr, 1, allowed_dragon); - break; - default: - break; + } + else { + switch (old_race(rc)) { + case RC_FIREDRAGON: + long_order = make_movement_order(u, tr, 4, allowed_dragon); + break; + case RC_DRAGON: + long_order = make_movement_order(u, tr, 3, allowed_dragon); + break; + default: + break; + } } if (long_order) { reduce_weight(u); @@ -752,6 +703,7 @@ void plan_monsters(faction * f) bool attacking = chance(attack_chance); for (u = r->units; u; u = u->next) { + const race *rc = u_race(u); attrib *ta; order *long_order = NULL; @@ -807,7 +759,7 @@ void plan_monsters(faction * f) a_remove(&u->attribs, ta); } } - else if (u_race(u)->flags & RCF_MOVERANDOM) { + else if (rc->flags & RCF_MOVERANDOM) { if (chance(random_move_chance()) || check_overpopulated(u)) { long_order = monster_move(r, u); } @@ -821,31 +773,24 @@ void plan_monsters(faction * f) handle_event(u->attribs, "ai_move", u); } - switch (old_race(u_race(u))) { - case RC_SEASERPENT: - long_order = create_order(K_PIRACY, f->locale, NULL); - break; -#ifdef TODO_ALP - case RC_ALP: - long_order = monster_seeks_target(r, u); - break; -#endif - case RC_FIREDRAGON: - case RC_DRAGON: - case RC_WYRM: + if (fval(rc, RCF_DRAGON)) { long_order = plan_dragon(u); - break; - default: - if (u_race(u)->flags & RCF_LEARN) { - long_order = monster_learn(u); + } + else { + if (rc == get_race(RC_SEASERPENT)) { + long_order = create_order(K_PIRACY, f->locale, NULL); + } + else { + if (rc->flags & RCF_LEARN) { + long_order = monster_learn(u); + } } - break; } } if (long_order == NULL && unit_can_study(u)) { /* Einheiten, die Waffenlosen Kampf lernen knnten, lernen es um * zu bewachen: */ - if (u_race(u)->bonus[SK_WEAPONLESS] != -99) { + if (rc->bonus[SK_WEAPONLESS] != -99) { if (effskill(u, SK_WEAPONLESS, 0) < 1) { long_order = create_order(K_STUDY, f->locale, "'%s'", diff --git a/src/monsters.test.c b/src/monsters.test.c index a44a354d9..6797a9ce0 100644 --- a/src/monsters.test.c +++ b/src/monsters.test.c @@ -54,8 +54,7 @@ static void create_monsters(faction **player, faction **monsters, unit **u, unit *monsters = get_or_create_monsters(); assert(rc_find((*monsters)->race->_name)); rc = rc_get_or_create((*monsters)->race->_name); - fset(rc, RCF_UNARMEDGUARD); - fset(rc, RCF_NPC); + fset(rc, RCF_UNARMEDGUARD|RCF_NPC|RCF_DRAGON); fset(*monsters, FFL_NOIDLEOUT); assert(fval(*monsters, FFL_NPC) && fval((*monsters)->race, RCF_UNARMEDGUARD) && fval((*monsters)->race, RCF_NPC) && fval(*monsters, FFL_NOIDLEOUT)); diff --git a/src/move.c b/src/move.c index a97bc5425..63c79dd6b 100644 --- a/src/move.c +++ b/src/move.c @@ -1473,7 +1473,7 @@ static int movement_speed(unit * u) return BP_DRAGON; } switch (old_race(u_race(u))) { - case RC_BIRTHDAYDRAGON: + case RC_BIRTHDAYDRAGON: // FIXME: catdragon has RCF_DRAGON, so this cannot happen case RC_SONGDRAGON: mp = BP_DRAGON; break; From f8ac5c390dfda248edbaabdcdee77858b01d68c0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 20 Sep 2016 09:39:21 +0200 Subject: [PATCH 087/675] SAMRT_INTERVALS is no longer an option, but regular --- src/kernel/faction.c | 2 -- src/kernel/faction.h | 7 ------- src/kernel/unit.c | 2 -- src/reports.c | 10 ---------- src/travelthru.c | 2 -- 5 files changed, 23 deletions(-) diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 794554cec..d9c9d4e15 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -509,7 +509,6 @@ void renumber_faction(faction * f, int no) fset(f, FFL_NEWID); } -#ifdef SMART_INTERVALS void update_interval(struct faction *f, struct region *r) { if (r == NULL || f == NULL) @@ -521,7 +520,6 @@ void update_interval(struct faction *f, struct region *r) f->last = r; } } -#endif const char *faction_getname(const faction * self) { diff --git a/src/kernel/faction.h b/src/kernel/faction.h index 80a71da48..de5524294 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -33,9 +33,6 @@ extern "C" { struct gamedata; extern struct attrib_type at_maxmagicians; - /* SMART_INTERVALS: define to speed up finding the interval of regions that a - faction is in. defining this speeds up the turn by 30-40% */ -#define SMART_INTERVALS /* faction flags */ #define FFL_NEWID (1<<0) /* Die Partei hat bereits einmal ihre no gewechselt */ @@ -57,10 +54,8 @@ extern "C" { struct faction *next; struct faction *nexthash; -#ifdef SMART_INTERVALS struct region *first; struct region *last; -#endif int no; int subscription; int flags; @@ -138,9 +133,7 @@ extern "C" { void free_factions(void); void remove_empty_factions(void); -#ifdef SMART_INTERVALS void update_interval(struct faction *f, struct region *r); -#endif const char *faction_getbanner(const struct faction *self); void faction_setbanner(struct faction *self, const char *name); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 246f59cb7..4623e895e 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -964,9 +964,7 @@ void move_unit(unit * u, region * r, unit ** ulist) addlist(ulist, u); } -#ifdef SMART_INTERVALS update_interval(u->faction, r); -#endif u->region = r; } diff --git a/src/reports.c b/src/reports.c index 420cdb752..11d913ef5 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1147,9 +1147,7 @@ static void faction_add_seen(faction *f, region *r, seen_mode mode) { } } } -#ifdef SMART_INTERVALS update_interval(f, r); -#endif } /** mark all regions seen by the lighthouse. @@ -1270,16 +1268,11 @@ void reorder_units(region * r) static region *lastregion(faction * f) { -#ifdef SMART_INTERVALS return f->last ? f->last->next : NULL; -#else - return NULL; -#endif } static region *firstregion(faction * f) { -#ifdef SMART_INTERVALS region *r = f->first; if (f->units == NULL) @@ -1288,9 +1281,6 @@ static region *firstregion(faction * f) return r; return f->first = regions; -#else - return regions; -#endif } static void cb_add_seen(region *r, unit *u, void *cbdata) { diff --git a/src/travelthru.c b/src/travelthru.c index 32607ae5c..8e1fc946b 100644 --- a/src/travelthru.c +++ b/src/travelthru.c @@ -80,12 +80,10 @@ void travelthru_add(region * r, unit * u) ql_push(&ql, u); a->data.v = ql; -#ifdef SMART_INTERVALS /* the first and last region of the faction gets reset, because travelthrough * could be in regions that are located before the [first, last] interval, * and recalculation is needed */ update_interval(u->faction, r); -#endif } bool travelthru_cansee(const struct region *r, const struct faction *f, const struct unit *u) { From 69b420ae2ff94ab5294eb5c9bf9a077d54bbcd5d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 20 Sep 2016 15:53:55 +0200 Subject: [PATCH 088/675] separate interval generation from seen-markup a bit more. --- src/reports.c | 23 ++++++++++++++--------- src/reports.test.c | 4 ++++ src/travelthru.c | 6 ++++++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/reports.c b/src/reports.c index 11d913ef5..c38fdeae0 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1135,19 +1135,24 @@ static void add_seen(region *r, seen_mode mode) { } } -static void faction_add_seen(faction *f, region *r, seen_mode mode) { +static void add_seen_nb(faction *f, region *r, seen_mode mode) { + region *first = r, *last = r; add_seen(r, mode); if (mode > seen_neighbour) { region *next[MAXDIRECTIONS]; int d; get_neighbours(r, next); for (d = 0; d != MAXDIRECTIONS; ++d) { - if (next[d] && next[d]->seen.modeseen.modeindex>rn->index) first = rn; + if (last->indexindex) last = rn; } } } - update_interval(f, r); + update_interval(f, first); + update_interval(f, last); } /** mark all regions seen by the lighthouse. @@ -1162,7 +1167,7 @@ static void prepare_lighthouse(building * b, report_context *ctx) for (ql = rlist, qi = 0; ql; ql_advance(&ql, &qi, 1)) { region *rl = (region *)ql_get(ql, qi); if (!fval(rl->terrain, FORBIDDEN_REGION)) { - faction_add_seen(f, rl, seen_lighthouse); + add_seen_nb(f, rl, seen_lighthouse); } } ql_free(rlist); @@ -1286,7 +1291,7 @@ static region *firstregion(faction * f) static void cb_add_seen(region *r, unit *u, void *cbdata) { faction *f = (faction *)cbdata; if (u->faction==f) { - faction_add_seen(f, r, seen_travel); + add_seen_nb(f, r, seen_travel); } } @@ -1327,7 +1332,7 @@ void prepare_report(report_context *ctx, faction *f) if (u && u->faction==f) { prepare_lighthouse(b, ctx); if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { - faction_add_seen(f, r, seen_unit); + add_seen_nb(f, r, seen_unit); } } } @@ -1338,7 +1343,7 @@ void prepare_report(report_context *ctx, faction *f) for (u = r->units; u; u = u->next) { if (u->faction==f) { if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { - faction_add_seen(f, r, seen_unit); + add_seen_nb(f, r, seen_unit); } if (fval(r, RF_LIGHTHOUSE)) { if (u->building && u->building->type == bt_lighthouse && inside_building(u)) { @@ -1349,7 +1354,7 @@ void prepare_report(report_context *ctx, faction *f) } } - if (fval(r, RF_TRAVELUNIT)) { + if (fval(r, RF_TRAVELUNIT) && r->seen.modefirst); + CuAssertPtrEquals(tc, r1, f->last); travelthru_add(r2, u); + CuAssertPtrEquals(tc, r1, f->first); + CuAssertPtrEquals(tc, r3, f->last); prepare_report(&ctx, f); CuAssertPtrEquals(tc, r1, ctx.first); CuAssertPtrEquals(tc, 0, ctx.last); diff --git a/src/travelthru.c b/src/travelthru.c index 8e1fc946b..e55cacaa0 100644 --- a/src/travelthru.c +++ b/src/travelthru.c @@ -64,6 +64,8 @@ attrib_type at_travelunit = { */ void travelthru_add(region * r, unit * u) { + region *next[MAXDIRECTIONS]; + int d; attrib *a; quicklist *ql; @@ -84,6 +86,10 @@ void travelthru_add(region * r, unit * u) * could be in regions that are located before the [first, last] interval, * and recalculation is needed */ update_interval(u->faction, r); + get_neighbours(r, next); + for (d=0;d!=MAXDIRECTIONS;++d) { + update_interval(u->faction, next[d]); + } } bool travelthru_cansee(const struct region *r, const struct faction *f, const struct unit *u) { From a3ad9a022274f06e562b8691430badc290bcd81f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 20 Sep 2016 20:27:41 +0200 Subject: [PATCH 089/675] I am now calling get_race far too often. Fix this a bit. --- src/battle.c | 2 +- src/creport.c | 7 ++++- src/guard.c | 2 +- src/kernel/faction.c | 2 +- src/kernel/race.c | 61 +++++++++++++++++++++++------------------- src/kernel/race.h | 5 ++-- src/kernel/race.test.c | 8 +++--- src/kernel/skills.c | 4 +-- src/kernel/unit.test.c | 2 +- src/laws.c | 1 + src/reports.c | 13 +++++++++ src/reports.h | 2 ++ src/spells.c | 4 +-- src/study.c | 4 +-- src/study.test.c | 4 +-- 15 files changed, 73 insertions(+), 48 deletions(-) diff --git a/src/battle.c b/src/battle.c index b78753fe1..1bbaaadfe 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1039,7 +1039,7 @@ static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_ if (wtype != NULL) { if (fval(u_race(du), RCF_DRAGON)) { static int cache; - static race *rc_halfling; + static const race *rc_halfling; if (rc_changed(&cache)) { rc_halfling = get_race(RC_HALFLING); } diff --git a/src/creport.c b/src/creport.c index a3b2cbea8..5e7442030 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1480,6 +1480,8 @@ report_computer(const char *filename, report_context * ctx, const char *charset) const char *mailto = LOC(f->locale, "mailto"); const attrib *a; FILE *F = fopen(filename, "w"); + static const race *rc_human; + static int rc_cache; if (era < 0) { era = config_get_int("world.era", 1); @@ -1546,7 +1548,10 @@ report_computer(const char *filename, report_context * ctx, const char *charset) fprintf(F, "%d;Anzahl Personen\n", count_all(f)); fprintf(F, "\"%s\";Magiegebiet\n", magic_school[f->magiegebiet]); - if (f->race == get_race(RC_HUMAN)) { + if (rc_changed(&rc_cache)) { + rc_human = rc_find("human"); + } + if (f->race == rc_human) { fprintf(F, "%d;Anzahl Immigranten\n", count_migrants(f)); fprintf(F, "%d;Max. Immigranten\n", count_maxmigrants(f)); } diff --git a/src/guard.c b/src/guard.c index 326b89bee..da879fa53 100644 --- a/src/guard.c +++ b/src/guard.c @@ -69,7 +69,7 @@ unsigned int guard_flags(const unit * u) { // TODO: this should be a property of the race, like race.guard_flags static int rc_cache; - static race *rc_elf, *rc_ent, *rc_ironkeeper; + static const race *rc_elf, *rc_ent, *rc_ironkeeper; const race *rc = u_race(u); unsigned int flags = GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX; diff --git a/src/kernel/faction.c b/src/kernel/faction.c index d9c9d4e15..823932f88 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -301,7 +301,7 @@ unit *addplayer(region * r, faction * f) fset(u, UFL_ISNEW); if (f->race == get_race(RC_DAEMON)) { race_t urc; - race *rc; + const race *rc; do { urc = (race_t)(rng_int() % MAXRACES); rc = get_race(urc); diff --git a/src/kernel/race.c b/src/kernel/race.c index 1088681d2..b7b466cc8 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -75,7 +75,7 @@ static const char *racenames[MAXRACES] = { "clone" }; -struct race *get_race(race_t rt) { +const struct race *get_race(race_t rt) { const char * name; assert(rt < MAXRACES); @@ -83,7 +83,7 @@ struct race *get_race(race_t rt) { if (!name) { return NULL; } - return rc_get_or_create(name); + return rc_find(name); } race_list *get_familiarraces(void) @@ -163,38 +163,43 @@ bool rc_changed(int *cache) { return false; } -race *rc_get_or_create(const char *zName) +race *rc_create(const char *zName) { race *rc; int i; assert(zName); - rc = rc_find_i(zName); - if (!rc) { - rc = (race *)calloc(sizeof(race), 1); - rc->hitpoints = 1; - rc->weight = PERSON_WEIGHT; - rc->capacity = 540; - rc->recruit_multi = 1.0F; - rc->regaura = 1.0F; - rc->speed = 1.0F; - rc->battle_flags = 0; - if (strchr(zName, ' ') != NULL) { - log_error("race '%s' has an invalid name. remove spaces\n", zName); - assert(strchr(zName, ' ') == NULL); - } - rc->_name = _strdup(zName); - rc->precombatspell = NULL; - - rc->attack[0].type = AT_COMBATSPELL; - for (i = 1; i < RACE_ATTACKS; ++i) - rc->attack[i].type = AT_NONE; - rc->index = num_races++; - ++rc_changes; - rc->next = races; - return races = rc; + rc = (race *)calloc(sizeof(race), 1); + rc->hitpoints = 1; + rc->weight = PERSON_WEIGHT; + rc->capacity = 540; + rc->recruit_multi = 1.0F; + rc->regaura = 1.0F; + rc->speed = 1.0F; + rc->battle_flags = 0; + if (strchr(zName, ' ') != NULL) { + log_error("race '%s' has an invalid name. remove spaces\n", zName); + assert(strchr(zName, ' ') == NULL); } - return rc; + rc->_name = _strdup(zName); + rc->precombatspell = NULL; + + rc->attack[0].type = AT_COMBATSPELL; + for (i = 1; i < RACE_ATTACKS; ++i) + rc->attack[i].type = AT_NONE; + rc->index = num_races++; + ++rc_changes; + rc->next = races; + return races = rc; +} + +race *rc_get_or_create(const char *zName) +{ + race *rc; + + assert(zName); + rc = rc_find_i(zName); + return rc ? rc : rc_create(zName); } /** dragon movement **/ diff --git a/src/kernel/race.h b/src/kernel/race.h index d11dc5fd1..2edb0a542 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -175,10 +175,11 @@ extern "C" { struct race_list *get_familiarraces(void); struct race *races; - struct race *get_race(race_t rt); + const struct race *get_race(race_t rt); /** TODO: compatibility hacks: **/ race_t old_race(const struct race *); + race *rc_create(const char *zName); race *rc_get_or_create(const char *name); bool rc_changed(int *cache); const race *rc_find(const char *); @@ -241,8 +242,6 @@ extern "C" { const char *racename(const struct locale *lang, const struct unit *u, const race * rc); -#define omniscient(f) ((f)->race==get_race(RC_ILLUSION) || (f)->race==get_race(RC_TEMPLATE)) - #define playerrace(rc) (!fval((rc), RCF_NPC)) #define dragonrace(rc) (fval(rc, RCF_DRAGON)) #define humanoidrace(rc) (fval((rc), RCF_UNDEAD) || (rc)==get_race(RC_DRACOID) || playerrace(rc)) diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index 7c464e4da..ec4b40f92 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -51,15 +51,15 @@ static void test_rc_find(CuTest *tc) { static void test_race_get(CuTest *tc) { int cache = 0; - race *rc; + const race *rc; test_setup(); CuAssertTrue(tc, rc_changed(&cache)); CuAssertTrue(tc, !rc_changed(&cache)); - rc = get_race(RC_ELF); - CuAssertPtrEquals(tc, rc, (void *)rc_get_or_create("elf")); + rc = rc_get_or_create("elf"); + CuAssertPtrEquals(tc, (void *)rc, (void *)get_race(RC_ELF)); CuAssertTrue(tc, rc_changed(&cache)); CuAssertTrue(tc, !rc_changed(&cache)); - CuAssertPtrEquals(tc, rc, (void *)rc_find("elf")); + CuAssertPtrEquals(tc, (void *)rc, (void *)rc_find("elf")); free_races(); CuAssertTrue(tc, rc_changed(&cache)); test_cleanup(); diff --git a/src/kernel/skills.c b/src/kernel/skills.c index e773424ab..9a6c0f1d7 100644 --- a/src/kernel/skills.c +++ b/src/kernel/skills.c @@ -105,7 +105,7 @@ int skill_mod(const race * rc, skill_t sk, const struct terrain_type *terrain) { int result = 0; static int rc_cache; - static race *rc_dwarf, *rc_insect; + static const race *rc_dwarf, *rc_insect; if (rc_changed(&rc_cache)) { rc_dwarf = get_race(RC_DWARF); @@ -140,7 +140,7 @@ int rc_skillmod(const struct race *rc, const region * r, skill_t sk) } if (r && r_isforest(r)) { static int rc_cache; - static race * rc_elf; + static const race * rc_elf; if (rc_changed(&rc_cache)) { rc_elf = get_race(RC_ELF); } diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index bf0284b58..054a45652 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -102,7 +102,7 @@ static void test_remove_units_ignores_spells(CuTest *tc) { test_cleanup(); test_create_world(); - u = create_unit(findregion(0, 0), test_create_faction(test_create_race("human")), 1, get_race(RC_SPELL), 0, 0, 0); + u = create_unit(findregion(0, 0), test_create_faction(test_create_race("human")), 1, test_create_race("spell"), 0, 0, 0); uid = u->no; u->number = 0; u->age = 1; diff --git a/src/laws.c b/src/laws.c index 199d9e0a0..f1a2e531c 100755 --- a/src/laws.c +++ b/src/laws.c @@ -36,6 +36,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "study.h" #include "wormhole.h" #include "prefix.h" +#include "reports.h" #include "teleport.h" #include "calendar.h" #include "guard.h" diff --git a/src/reports.c b/src/reports.c index c38fdeae0..681802fd3 100644 --- a/src/reports.c +++ b/src/reports.c @@ -104,6 +104,19 @@ const char *coasts[MAXDIRECTIONS] = { "coast::w" }; +bool omniscient(const faction *f) +{ + static const race *rc_template, *rc_illusion; + static int cache; + if (rc_changed(&cache)) { + rc_illusion = get_race(RC_ILLUSION); + rc_template = get_race(RC_TEMPLATE); + } + return (f->race == rc_template || f->race == rc_illusion); +} + + + static char *groupid(const struct group *g, const struct faction *f) { typedef char name[OBJECTIDSIZE + 1]; diff --git a/src/reports.h b/src/reports.h index fd0efb591..8684dfa3f 100644 --- a/src/reports.h +++ b/src/reports.h @@ -48,6 +48,8 @@ extern "C" { struct unit *can_find(struct faction *, struct faction *); + bool omniscient(const struct faction *f); + /* funktionen zum schreiben eines reports */ void sparagraph(struct strlist **SP, const char *s, unsigned int indent, char mark); void lparagraph(struct strlist **SP, char *s, unsigned int indent, char mark); diff --git a/src/spells.c b/src/spells.c index a860abe3c..4f2d49d9d 100644 --- a/src/spells.c +++ b/src/spells.c @@ -2730,9 +2730,9 @@ static int sp_firewall(castorder * co) * (SPELLLEVEL | TESTCANSEE) */ -static race *unholy_race(const race *rc) { +static const race *unholy_race(const race *rc) { static int cache; - static race * rc_skeleton, *rc_zombie, *rc_ghoul; + static const race * rc_skeleton, *rc_zombie, *rc_ghoul; if (rc_changed(&cache)) { rc_skeleton = get_race(RC_SKELETON); rc_zombie = get_race(RC_ZOMBIE); diff --git a/src/study.c b/src/study.c index 70c016dfc..eb5cec12d 100644 --- a/src/study.c +++ b/src/study.c @@ -95,7 +95,7 @@ magic_t getmagicskill(const struct locale * lang) bool is_migrant(unit * u) { static int cache; - static race *toad_rc; + static const race *toad_rc; if (u_race(u) == u->faction->race) return false; @@ -113,7 +113,7 @@ bool is_migrant(unit * u) /* ------------------------------------------------------------- */ bool magic_lowskill(unit * u) { - static race *toad_rc; + static const race *toad_rc; static int cache; if (rc_changed(&cache)) { toad_rc = get_race(RC_TOAD); diff --git a/src/study.test.c b/src/study.test.c index 1bab404d8..47976930d 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -291,10 +291,10 @@ void test_learn_skill_multi(CuTest *tc) { static void test_demon_skillchanges(CuTest *tc) { unit * u; - race * rc; + const race * rc; test_setup(); rc = test_create_race("demon"); - CuAssertPtrEquals(tc, rc, get_race(RC_DAEMON)); + CuAssertPtrEquals(tc, (void *)rc, (void *)get_race(RC_DAEMON)); u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); CuAssertPtrNotNull(tc, u); set_level(u, SK_CROSSBOW, 1); From ff83d5108a1e9f5604c02e589306ad10c22b4031 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Sep 2016 09:08:02 +0200 Subject: [PATCH 090/675] remove old_race call form heal_factor --- res/races/demon.xml | 7 ++++++- res/races/goblin-2.xml | 6 +++++- res/races/goblin-3.xml | 6 +++++- res/races/goblin.xml | 7 ++++++- res/races/troll.xml | 7 ++++++- src/kernel/race.h | 1 + src/kernel/xmlreader.c | 1 + src/laws.c | 28 ++++++++++++++-------------- 8 files changed, 44 insertions(+), 19 deletions(-) diff --git a/res/races/demon.xml b/res/races/demon.xml index 9f97d4d8f..a350fef4a 100644 --- a/res/races/demon.xml +++ b/res/races/demon.xml @@ -1,5 +1,10 @@ - + diff --git a/res/races/goblin-2.xml b/res/races/goblin-2.xml index e91781aa6..9a9c265be 100644 --- a/res/races/goblin-2.xml +++ b/res/races/goblin-2.xml @@ -1,5 +1,9 @@ - + diff --git a/res/races/goblin-3.xml b/res/races/goblin-3.xml index a59ee6f77..e85b0c645 100644 --- a/res/races/goblin-3.xml +++ b/res/races/goblin-3.xml @@ -1,5 +1,9 @@ - + diff --git a/res/races/goblin.xml b/res/races/goblin.xml index af097396c..177c82ffe 100644 --- a/res/races/goblin.xml +++ b/res/races/goblin.xml @@ -1,5 +1,10 @@ - + diff --git a/res/races/troll.xml b/res/races/troll.xml index f151126fb..a2341851b 100644 --- a/res/races/troll.xml +++ b/res/races/troll.xml @@ -1,5 +1,10 @@ - + diff --git a/src/kernel/race.h b/src/kernel/race.h index 2edb0a542..f42e769a6 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -125,6 +125,7 @@ extern "C" { typedef struct race { char *_name; float magres; + float healing; double maxaura; /* Faktor auf Maximale Aura */ double regaura; /* Faktor auf Regeneration */ double recruit_multi; /* Faktor fr Bauernverbrauch */ diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index f3f866351..fd8596d1f 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1647,6 +1647,7 @@ static int parse_races(xmlDocPtr doc) xmlFree(propValue); rc->magres = (float)xml_fvalue(node, "magres", rc->magres); + rc->healing = (float)xml_fvalue(node, "healing", rc->healing); rc->maxaura = (float)xml_fvalue(node, "maxaura", rc->maxaura); rc->regaura = (float)xml_fvalue(node, "regaura", rc->regaura); rc->recruitcost = xml_ivalue(node, "recruitcost", rc->recruitcost); diff --git a/src/laws.c b/src/laws.c index f1a2e531c..1fab79558 100755 --- a/src/laws.c +++ b/src/laws.c @@ -3464,23 +3464,23 @@ static int use_item(unit * u, const item_type * itype, int amount, struct order static double heal_factor(const unit * u) { - double elf_regen; - // TODO: do not hard-code, make this a property, race.healing - switch (old_race(u_race(u))) { - case RC_TROLL: - case RC_DAEMON: - return 1.5; - case RC_GOBLIN: - return 2.0; - case RC_ELF: - elf_regen = get_param_flt(u_race(u)->parameters, "regen.forest", 1.0F); - if (elf_regen != 1.0 && r_isforest(u->region)) { + const race * rc = u_race(u); + if (rc->healing>0) { + return rc->healing; + } + if (r_isforest(u->region)) { + static int rc_cache; + static const race *rc_elf; + if (rc==rc_elf) { + static int config; + static double elf_regen = 1.0; + if (config_changed(&config)) { + elf_regen = get_param_flt(u_race(u)->parameters, "regen.forest", 1.0F); + } return elf_regen; } - return 1.0; - default: - return 1.0; } + return 1.0; } void monthly_healing(void) From ac4f8d6e7bfa98809c7361cf4de2aff5cef21fb3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Sep 2016 09:34:23 +0200 Subject: [PATCH 091/675] make monsters scaring peasants a per-race configuration. reduce the number of old_race calls that monster.c makes. --- res/races/dragon.xml | 6 +++-- res/races/wyrm.xml | 2 +- res/races/youngdragon.xml | 2 +- src/attributes/attributes.c | 5 ++++ src/attributes/attributes.h | 2 ++ src/kernel/xmlreader.c | 9 +++++++ src/monster.c | 53 +++++++++++++++++++------------------ 7 files changed, 49 insertions(+), 30 deletions(-) diff --git a/res/races/dragon.xml b/res/races/dragon.xml index a1f347105..907ff90a7 100644 --- a/res/races/dragon.xml +++ b/res/races/dragon.xml @@ -1,6 +1,8 @@ - +"6" damage="2d30" unarmedattack="0" unarmeddefense="0" +attackmodifier="7" defensemodifier="7" scarepeasants="yes" fly="yes" +walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes"> + diff --git a/res/races/wyrm.xml b/res/races/wyrm.xml index 5c63b0fb6..b5d3bd7a2 100644 --- a/res/races/wyrm.xml +++ b/res/races/wyrm.xml @@ -1,5 +1,5 @@ - + diff --git a/res/races/youngdragon.xml b/res/races/youngdragon.xml index fe29bbfde..d1b3a4752 100644 --- a/res/races/youngdragon.xml +++ b/res/races/youngdragon.xml @@ -1,5 +1,5 @@ - + diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index 770ba7524..a82e1941d 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -61,6 +61,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include +attrib_type at_scare = { // monster scares peasants + "scare", NULL, NULL, NULL, a_writeint, a_readint +}; + attrib_type at_unitdissolve = { "unitdissolve", NULL, NULL, NULL, a_writechars, a_readchars }; @@ -77,6 +81,7 @@ static int read_ext(attrib * a, void *owner, gamedata *data) void register_attributes(void) { /* Alle speicherbaren Attribute mssen hier registriert werden */ + at_register(&at_scare); at_register(&at_shiptrail); at_register(&at_familiar); at_register(&at_familiarmage); diff --git a/src/attributes/attributes.h b/src/attributes/attributes.h index b8974867e..91184ad98 100644 --- a/src/attributes/attributes.h +++ b/src/attributes/attributes.h @@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. extern "C" { #endif + struct attrib_type; + extern struct attrib_type at_scare; extern void register_attributes(void); #ifdef __cplusplus diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index fd8596d1f..1dd822130 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -33,6 +33,7 @@ without prior permission by the authors of Eressea. #include "vortex.h" #include +#include /* util includes */ #include @@ -1605,6 +1606,14 @@ static void parse_param(struct param **params, xmlNodePtr node) static void parse_ai(race * rc, xmlNodePtr node) { + int n; + + n = xml_ivalue(node, "scare", 0); + if (n>0) { + attrib *a = a_new(&at_scare); + a->data.i = n; + a_add(&rc->attribs, a); + } rc->splitsize = xml_ivalue(node, "splitsize", 0); rc->aggression = (float)xml_fvalue(node, "aggression", 0.04); if (xml_bvalue(node, "killpeasants", false)) diff --git a/src/monster.c b/src/monster.c index 37c48f8b5..afb0674c9 100644 --- a/src/monster.c +++ b/src/monster.c @@ -28,6 +28,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* attributes includes */ #include #include +#include /* kernel includes */ #include @@ -79,22 +80,17 @@ static void eaten_by_monster(unit * u) int n = 0; int horse = -1; const resource_type *rhorse = get_resourcetype(R_HORSE); + const race *rc = u_race(u); + attrib *a; + if (multi == 0.0) { multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0; } - // TODO: do not hard-code, make it a race property or callback? it's already RCF_KILLPEASANTS - switch (old_race(u_race(u))) { - case RC_FIREDRAGON: - n = rng_int() % 80 * u->number; - break; - case RC_DRAGON: - n = rng_int() % 200 * u->number; - break; - case RC_WYRM: - n = rng_int() % 500 * u->number; - break; - default: + a = a_find(rc->attribs, &at_scare); + if (a) { + n = rng_int() & a->data.i * u->number; + } else { n = rng_int() % (u->number / 20 + 1); horse = 0; } @@ -168,21 +164,26 @@ static int scareaway(region * r, int anzahl) static void scared_by_monster(unit * u) { int n; - - switch (old_race(u_race(u))) { - case RC_FIREDRAGON: - n = rng_int() % 160 * u->number; - break; - case RC_DRAGON: - n = rng_int() % 400 * u->number; - break; - case RC_WYRM: - n = rng_int() % 1000 * u->number; - break; - default: - n = rng_int() % (u->number / 4 + 1); + const race *rc = u_race(u); + attrib *a; + a = a_find(rc->attribs, &at_scare); + if (a) { + n = rng_int() & a->data.i * u->number; + } else { + switch (old_race(u_race(u))) { + case RC_FIREDRAGON: + n = rng_int() % 160 * u->number; + break; + case RC_DRAGON: + n = rng_int() % 400 * u->number; + break; + case RC_WYRM: + n = rng_int() % 1000 * u->number; + break; + default: + n = rng_int() % (u->number / 4 + 1); + } } - if (n > 0) { n = lovar(n); n = _min(rpeasants(u->region), n); From e45dc3d68a11846563a1e0f6b9e07042e2250a9e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Sep 2016 09:37:54 +0200 Subject: [PATCH 092/675] initizlize rc_elf --- src/laws.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/laws.c b/src/laws.c index 1fab79558..f854ed7ef 100755 --- a/src/laws.c +++ b/src/laws.c @@ -3471,6 +3471,9 @@ static double heal_factor(const unit * u) if (r_isforest(u->region)) { static int rc_cache; static const race *rc_elf; + if (rc_changed(&rc_cache)) { + rc_elf = get_race(RC_ELF); + } if (rc==rc_elf) { static int config; static double elf_regen = 1.0; From dfab45dc0cd4883b39eeb4247eb5e1af4dec9aaa Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Sep 2016 09:41:30 +0200 Subject: [PATCH 093/675] actually don't call old_race anymore --- src/monster.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/monster.c b/src/monster.c index afb0674c9..42e334fde 100644 --- a/src/monster.c +++ b/src/monster.c @@ -170,19 +170,7 @@ static void scared_by_monster(unit * u) if (a) { n = rng_int() & a->data.i * u->number; } else { - switch (old_race(u_race(u))) { - case RC_FIREDRAGON: - n = rng_int() % 160 * u->number; - break; - case RC_DRAGON: - n = rng_int() % 400 * u->number; - break; - case RC_WYRM: - n = rng_int() % 1000 * u->number; - break; - default: - n = rng_int() % (u->number / 4 + 1); - } + n = rng_int() % (u->number / 4 + 1); } if (n > 0) { n = lovar(n); From b985f9fa3ef0c949fd2e01342b07753a28cd2f9a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Sep 2016 10:11:37 +0200 Subject: [PATCH 094/675] adding gruenbaer gprof output for historical preservation --- doc/gprof-v3.10.0-163-gdfab45d.txt | 18335 +++++++++++++++++++++++++++ 1 file changed, 18335 insertions(+) create mode 100644 doc/gprof-v3.10.0-163-gdfab45d.txt diff --git a/doc/gprof-v3.10.0-163-gdfab45d.txt b/doc/gprof-v3.10.0-163-gdfab45d.txt new file mode 100644 index 000000000..aa148a1fd --- /dev/null +++ b/doc/gprof-v3.10.0-163-gdfab45d.txt @@ -0,0 +1,18335 @@ +# eressea -re2 -t961 run-turn.lua +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls s/call s/call name + 11.26 3.91 3.91 232 0.02 0.02 prepare_report + 6.94 6.32 2.41 cb_find_top_i + 6.28 8.50 2.18 68430271 0.00 0.00 rc_find_i + 3.43 9.69 1.19 2742237 0.00 0.00 paragraph + 2.76 10.65 0.96 230 0.00 0.02 report_computer + 2.76 11.61 0.96 232 0.00 0.01 get_addresses + 2.68 12.54 0.93 1437425 0.00 0.00 cansee + 2.53 13.42 0.88 232 0.00 0.00 finish_reports + 2.22 14.19 0.77 230 0.00 0.03 report_plaintext + 2.19 14.95 0.76 32337529 0.00 0.00 hashstring + 1.84 15.59 0.64 10375491 0.00 0.00 alliedgroup + 1.81 16.22 0.63 34611296 0.00 0.00 strlcpy + 1.76 16.83 0.61 24887945 0.00 0.00 locale_string + 1.64 17.40 0.57 1766225 0.00 0.00 nr_curses + 1.50 17.92 0.52 55492327 0.00 0.00 getkeyword + 1.35 18.39 0.47 1 0.47 5.47 process + 1.35 18.86 0.47 decode_pointer + 1.30 19.31 0.45 51974272 0.00 0.00 a_find + 1.15 19.71 0.40 1310373 0.00 0.00 cr_output_curses + 0.92 20.03 0.32 129167539 0.00 0.00 u_race + 0.89 20.34 0.31 71815034 0.00 0.00 get_race + 0.82 20.63 0.29 18856320 0.00 0.00 cb_add_seen + 0.81 20.91 0.28 cb_find_prefix_i + 0.81 21.19 0.28 from_external_node + 0.78 21.46 0.27 99 0.00 0.00 report_template + 0.72 21.71 0.25 10030400 0.00 0.00 effskill + 0.69 21.95 0.24 9544331 0.00 0.00 parse_symbol + 0.69 22.19 0.24 1158076 0.00 0.00 getbuf_utf8 + 0.66 22.42 0.23 5985780 0.00 0.00 itoab + 0.63 22.64 0.22 1118718 0.00 0.00 ufindhash + 0.63 22.86 0.22 ql_advance + 0.60 23.07 0.21 12246335 0.00 0.00 ct_find + 0.60 23.28 0.21 2725583 0.00 0.00 parse_string + 0.60 23.49 0.21 11241829 0.00 0.00 i_change + 0.55 23.68 0.19 2480226 0.00 0.00 old_race + 0.55 23.87 0.19 2248440 0.00 0.00 get_borders_i + 0.55 24.06 0.19 bin_r_int_pak + 0.52 24.24 0.18 fs_write + 0.49 24.41 0.17 6010308 0.00 0.00 i_find + 0.49 24.58 0.17 860263 0.00 0.00 use_pooled + 0.43 24.73 0.15 5168717 0.00 0.00 nrt_find + 0.43 24.88 0.15 178254 0.00 0.00 get_food + 0.40 25.02 0.14 4434556 0.00 0.00 translate + 0.40 25.16 0.14 fstream_done + 0.40 25.30 0.14 ql_get + 0.40 25.44 0.14 1375380 0.00 0.00 remove_empty_units_in_region + 0.37 25.57 0.13 10190660 0.00 0.00 get_curse + 0.37 25.70 0.13 5387327 0.00 0.00 parse_token + 0.35 25.82 0.12 11253756 0.00 0.00 genrand_int32 + 0.35 25.94 0.12 923671 0.00 0.00 cr_output_unit + 0.35 26.06 0.12 713016 0.00 0.00 do_enter + 0.35 26.18 0.12 596221 0.00 0.00 write_unit + 0.32 26.29 0.11 9953180 0.00 0.00 alliedunit + 0.32 26.40 0.11 1380398 0.00 0.00 translate + 0.32 26.51 0.11 10103290 0.00 0.00 stream_printf + 0.32 26.62 0.11 fs_writeln + 0.29 26.72 0.10 46391457 0.00 0.00 unicode_utf8_to_ucs4 + 0.29 26.82 0.10 36653945 0.00 0.00 wrptr + 0.29 26.92 0.10 13102790 0.00 0.00 opstack_pop + 0.26 27.01 0.09 50553492 0.00 0.00 stealth_modifier + 0.26 27.10 0.09 3398582 0.00 0.00 travelthru_map + 0.26 27.19 0.09 2624955 0.00 0.00 has_skill + 0.26 27.28 0.09 1390078 0.00 0.00 get_row + 0.26 27.37 0.09 1248014 0.00 0.00 listlen + 0.26 27.46 0.09 297222 0.00 0.00 fwritestr + 0.26 27.55 0.09 qli_more + 0.24 27.63 0.09 56052475 0.00 0.00 get_resourcetype + 0.23 27.71 0.08 20834979 0.00 0.00 autoalliance + 0.23 27.79 0.08 13102790 0.00 0.00 opstack_push + 0.23 27.87 0.08 12353561 0.00 0.00 report_item + 0.23 27.95 0.08 7252744 0.00 0.00 cmp_transfer + 0.23 28.03 0.08 7120688 0.00 0.00 get_money + 0.23 28.11 0.08 2 0.04 0.73 make_summary + 0.20 28.18 0.07 17451017 0.00 0.00 strlcpy_w + 0.20 28.25 0.07 47902 0.00 0.00 getshipweight + 0.20 28.32 0.07 bin_r_str_buf + 0.20 28.39 0.07 68430117 0.00 0.00 rc_find + 0.20 28.46 0.07 760673 0.00 0.00 addlist + 0.20 28.53 0.07 bin_w_int_pak + 0.17 28.59 0.06 26776263 0.00 0.00 get_param + 0.17 28.65 0.06 13259934 0.00 0.00 resourcename + 0.17 28.71 0.06 1826688 0.00 0.00 adjust_coordinates + 0.17 28.77 0.06 560965 0.00 0.00 bt_find_i + 0.17 28.83 0.06 209572 0.00 0.00 cr_borders + 0.17 28.89 0.06 108211 0.00 0.00 report_resources + 0.17 28.95 0.06 2 0.03 0.66 score + 0.17 29.01 0.06 2247 0.00 0.00 count_faction + 0.14 29.06 0.05 12560453 0.00 0.00 rc_changed + 0.14 29.11 0.05 7910500 0.00 0.00 r_isforest + 0.14 29.16 0.05 7179079 0.00 0.00 att_modification + 0.14 29.21 0.05 5329742 0.00 0.00 eatwhitespace_c + 0.14 29.26 0.05 2868601 0.00 0.00 u_irace + 0.14 29.31 0.05 2006524 0.00 0.00 get_command + 0.14 29.36 0.05 1929215 0.00 0.00 create_order_i + 0.14 29.41 0.05 1405457 0.00 0.00 report_items + 0.14 29.46 0.05 209572 0.00 0.00 building_owner_ex + 0.14 29.51 0.05 127676 0.00 0.00 describe + 0.14 29.56 0.05 96482 0.00 0.00 get_followers + 0.14 29.61 0.05 qli_init + 0.12 29.65 0.04 10053919 0.00 0.00 rtrees + 0.12 29.69 0.04 7851812 0.00 0.00 write_spaces + 0.12 29.73 0.04 6241702 0.00 0.00 eatwhite + 0.12 29.77 0.04 4625636 0.00 0.00 ffindhash + 0.12 29.81 0.04 4568249 0.00 0.00 find_variable + 0.12 29.85 0.04 4136059 0.00 0.00 mkname_buf + 0.12 29.89 0.04 3573165 0.00 0.00 cmp_faction + 0.12 29.93 0.04 2858912 0.00 0.00 get_effect + 0.12 29.97 0.04 1953682 0.00 0.00 spskill + 0.12 30.01 0.04 1644867 0.00 0.00 free_orders + 0.12 30.05 0.04 1010116 0.00 0.00 mt_find + 0.12 30.09 0.04 1006923 0.00 0.00 rfindhash + 0.12 30.13 0.04 841675 0.00 0.00 a_write + 0.12 30.17 0.04 178254 0.00 0.00 do_contact + 0.12 30.21 0.04 160206 0.00 0.00 monster_attacks + 0.12 30.25 0.04 3016 0.00 0.00 dfindhash + 0.12 30.29 0.04 1 0.04 0.09 ageing + 0.12 30.33 0.04 1 0.04 0.61 movement + 0.12 30.37 0.04 1 0.04 0.31 randomevents + 0.12 30.41 0.04 cb_find_prefix + 0.12 30.45 0.04 class_index_event + 0.12 30.49 0.04 fs_read + 0.12 30.53 0.04 pack_int + 0.12 30.57 0.04 ql_find + 0.12 30.61 0.04 tolua_unitlist_next + 0.12 30.65 0.04 unicode_ucs4_to_utf8 + 0.10 30.69 0.04 6907106 0.00 0.00 eff_skill + 0.10 30.72 0.04 7179154 0.00 0.00 get_modifier + 0.10 30.76 0.04 cb_get_kv + 0.09 30.79 0.03 21345834 0.00 0.00 skill_enabled + 0.09 30.82 0.03 13399069 0.00 0.00 balloc + 0.09 30.85 0.03 10375461 0.00 0.00 AllianceRestricted + 0.09 30.88 0.03 9232125 0.00 0.00 res_changeitem + 0.09 30.91 0.03 9170795 0.00 0.00 parse + 0.09 30.94 0.03 8302761 0.00 0.00 get_resource + 0.09 30.97 0.03 4851739 0.00 0.00 get_reservation + 0.09 31.00 0.03 4457785 0.00 0.00 transliterate + 0.09 31.03 0.03 2818494 0.00 0.00 rc_name + 0.09 31.06 0.03 2599554 0.00 0.00 change_money + 0.09 31.09 0.03 2277350 0.00 0.00 get_prefix + 0.09 31.12 0.03 1956810 0.00 0.00 add_skill + 0.09 31.15 0.03 1747682 0.00 0.00 cansee_durchgezogen + 0.09 31.18 0.03 1481616 0.00 0.00 get_keyword + 0.09 31.21 0.03 1348743 0.00 0.00 bufunit + 0.09 31.24 0.03 967784 0.00 0.00 msg_message + 0.09 31.27 0.03 779486 0.00 0.00 locale_getstring + 0.09 31.30 0.03 541982 0.00 0.00 get_pooled + 0.09 31.33 0.03 490896 0.00 0.00 default_wage + 0.09 31.36 0.03 417808 0.00 0.00 study_cmd + 0.09 31.39 0.03 372173 0.00 0.00 select_enemy + 0.09 31.42 0.03 301257 0.00 0.00 crt_find + 0.09 31.45 0.03 297010 0.00 0.00 bt_effsize + 0.09 31.48 0.03 195108 0.00 0.00 rps_nowrap + 0.09 31.51 0.03 130250 0.00 0.00 r_getmessages + 0.09 31.54 0.03 79180 0.00 0.00 rp_messages + 0.09 31.57 0.03 35287 0.00 0.00 prices + 0.09 31.60 0.03 13500 0.00 0.00 crew_skill + 0.09 31.63 0.03 10852 0.00 0.00 expandorders + 0.09 31.66 0.03 10846 0.00 0.00 scramble + 0.09 31.69 0.03 1 0.03 0.05 defaultorders + 0.09 31.72 0.03 1 0.03 0.05 demon_skillchanges + 0.09 31.75 0.03 1 0.03 0.06 dissolve_units + 0.09 31.78 0.03 1 0.03 0.03 move_hunters + 0.09 31.81 0.03 1 0.03 0.04 move_pirates + 0.09 31.84 0.03 1 0.03 0.03 reset_game + 0.09 31.87 0.03 a_select + 0.09 31.90 0.03 ql_foreachx + 0.06 31.92 0.02 24935046 0.00 0.00 faction_alive + 0.06 31.94 0.02 20836359 0.00 0.00 f_get_alliance + 0.06 31.96 0.02 20777534 0.00 0.00 config_get + 0.06 31.98 0.02 10375461 0.00 0.00 ally_mode + 0.06 32.00 0.02 9163148 0.00 0.00 golem_factor + 0.06 32.02 0.02 8452306 0.00 0.00 is_guardian_r + 0.06 32.04 0.02 7641081 0.00 0.00 genrand_int31 + 0.06 32.06 0.02 7417541 0.00 0.00 urace + 0.06 32.08 0.02 7179079 0.00 0.00 skill_mod + 0.06 32.10 0.02 4666665 0.00 0.00 rmoney + 0.06 32.12 0.02 4558423 0.00 0.00 get_translations + 0.06 32.14 0.02 3780355 0.00 0.00 nr_section + 0.06 32.16 0.02 3358315 0.00 0.00 ship_owner + 0.06 32.18 0.02 2903884 0.00 0.00 jenkins_hash + 0.06 32.20 0.02 2818494 0.00 0.00 rc_name_s + 0.06 32.22 0.02 2605004 0.00 0.00 rpeasants + 0.06 32.24 0.02 1996097 0.00 0.00 travelthru_cansee + 0.06 32.26 0.02 1929215 0.00 0.00 create_data + 0.06 32.28 0.02 1662377 0.00 0.00 get_unitrow + 0.06 32.30 0.02 1552289 0.00 0.00 rname + 0.06 32.32 0.02 1481407 0.00 0.00 parse_order + 0.06 32.34 0.02 1470505 0.00 0.00 write_order + 0.06 32.36 0.02 1344397 0.00 0.00 nr_unit + 0.06 32.38 0.02 1206547 0.00 0.00 findplane + 0.06 32.40 0.02 1188532 0.00 0.00 eff_stealth + 0.06 32.42 0.02 1177511 0.00 0.00 it_alias + 0.06 32.44 0.02 1121103 0.00 0.00 monster_is_waiting + 0.06 32.46 0.02 1054200 0.00 0.00 count_cb + 0.06 32.48 0.02 967902 0.00 0.00 cb_cr_travelthru_ship + 0.06 32.50 0.02 860166 0.00 0.00 weapon_effskill + 0.06 32.52 0.02 839202 0.00 0.00 a_age + 0.06 32.54 0.02 771861 0.00 0.00 armedmen + 0.06 32.56 0.02 742235 0.00 0.00 room_for_race_in_region + 0.06 32.58 0.02 688711 0.00 0.00 atoi36 + 0.06 32.60 0.02 635885 0.00 0.00 copy_order + 0.06 32.62 0.02 628037 0.00 0.00 read_items + 0.06 32.64 0.02 595898 0.00 0.00 follow_unit + 0.06 32.66 0.02 472366 0.00 0.00 produceexp_days + 0.06 32.68 0.02 418134 0.00 0.00 study_cost + 0.06 32.70 0.02 392959 0.00 0.00 add_message + 0.06 32.72 0.02 313244 0.00 0.00 check_overpopulated + 0.06 32.74 0.02 221802 0.00 0.00 unitorders + 0.06 32.76 0.02 178254 0.00 0.00 economics + 0.06 32.78 0.02 178254 0.00 0.00 hash_uid + 0.06 32.80 0.02 178254 0.00 0.00 reorder_units + 0.06 32.82 0.02 162996 0.00 0.00 inhabitable + 0.06 32.84 0.02 147217 0.00 0.00 normalvariate + 0.06 32.86 0.02 146997 0.00 0.00 term_eval + 0.06 32.88 0.02 62581 0.00 0.00 guards + 0.06 32.90 0.02 33139 0.00 0.00 statistics + 0.06 32.92 0.02 7964 0.00 0.00 nrt_string + 0.06 32.94 0.02 6963 0.00 0.00 move_ship + 0.06 32.96 0.02 3438 0.00 0.00 get_regions_distance + 0.06 32.98 0.02 388 0.00 0.00 internal_path_find + 0.06 33.00 0.02 231 0.00 0.00 faction_getmages + 0.06 33.02 0.02 30 0.00 0.00 config_set + 0.06 33.04 0.02 1 0.02 0.03 destroyfaction + 0.06 33.06 0.02 1 0.02 0.02 godcurse + 0.06 33.08 0.02 1 0.02 0.03 orc_growth + 0.06 33.10 0.02 1 0.02 0.03 restack_units + 0.06 33.12 0.02 1 0.02 0.02 spawn_dragons + 0.06 33.14 0.02 1 0.02 0.02 update_guards + 0.06 33.16 0.02 bin_w_brk + 0.06 33.18 0.02 bin_w_str + 0.06 33.20 0.02 fs_readln + 0.06 33.22 0.02 ql_push + 0.06 33.24 0.02 ql_set_insert_ex + 0.06 33.26 0.02 tolua_unit_get_faction + 0.06 33.28 0.02 wang_hash + 0.04 33.29 0.02 51003 0.00 0.00 give_money + 0.04 33.31 0.02 464 0.00 0.00 firstregion + 0.03 33.32 0.01 18647447 0.00 0.00 getplane + 0.03 33.33 0.01 10383360 0.00 0.00 HelpMask + 0.03 33.34 0.01 9298667 0.00 0.00 resource2item + 0.03 33.35 0.01 8506411 0.00 0.00 besieged + 0.03 33.36 0.01 7298034 0.00 0.00 skillmod + 0.03 33.37 0.01 5461936 0.00 0.00 slprintf + 0.03 33.38 0.01 5395063 0.00 0.00 i_get + 0.03 33.39 0.01 5152236 0.00 0.00 ct_changed + 0.03 33.40 0.01 5065285 0.00 0.00 get_param_int + 0.03 33.41 0.01 4984610 0.00 0.00 config_get_int + 0.03 33.42 0.01 4976082 0.00 0.00 find_function + 0.03 33.43 0.01 4835422 0.00 0.00 usiege + 0.03 33.44 0.01 4625636 0.00 0.00 findfaction + 0.03 33.45 0.01 4488684 0.00 0.00 crtag + 0.03 33.46 0.01 4374788 0.00 0.00 visible_faction + 0.03 33.47 0.01 4301501 0.00 0.00 statusrow + 0.03 33.48 0.01 4201030 0.00 0.00 curse_active + 0.03 33.49 0.01 4198692 0.00 0.00 lifestyle + 0.03 33.50 0.01 4133717 0.00 0.00 mkname + 0.03 33.51 0.01 3383689 0.00 0.00 update_interval + 0.03 33.52 0.01 2985733 0.00 0.00 is_repeated + 0.03 33.53 0.01 2934859 0.00 0.00 skillname + 0.03 33.54 0.01 2765718 0.00 0.00 maintenance_cost + 0.03 33.55 0.01 2494242 0.00 0.00 newline + 0.03 33.56 0.01 2481220 0.00 0.00 copy_arg + 0.03 33.57 0.01 2383101 0.00 0.00 unitname + 0.03 33.58 0.01 2281756 0.00 0.00 gettoken + 0.03 33.59 0.01 2275967 0.00 0.00 get_racename + 0.03 33.60 0.01 2275429 0.00 0.00 raceprefix + 0.03 33.61 0.01 2186159 0.00 0.00 rsetmoney + 0.03 33.62 0.01 2032164 0.00 0.00 rt_find + 0.03 33.63 0.01 1874928 0.00 0.00 terrain_name + 0.03 33.64 0.01 1751202 0.00 0.00 item_invis + 0.03 33.65 0.01 1629412 0.00 0.00 LongHunger + 0.03 33.66 0.01 1381157 0.00 0.00 unit_max_hp + 0.03 33.67 0.01 1351796 0.00 0.00 racename + 0.03 33.68 0.01 1336242 0.00 0.00 genrand_real2 + 0.03 33.69 0.01 1311302 0.00 0.00 init_tokens_str + 0.03 33.70 0.01 1205451 0.00 0.00 alliedfaction + 0.03 33.71 0.01 1106528 0.00 0.00 is_building_type + 0.03 33.72 0.01 1087065 0.00 0.00 get_neighbours + 0.03 33.73 0.01 1009159 0.00 0.00 log_orders + 0.03 33.74 0.01 996009 0.00 0.00 get_skill + 0.03 33.75 0.01 987612 0.00 0.00 getplanebyname + 0.03 33.76 0.01 967902 0.00 0.00 cb_cr_travelthru_unit + 0.03 33.77 0.01 950595 0.00 0.00 f_regionid + 0.03 33.78 0.01 923671 0.00 0.00 cr_output_unit_compat + 0.03 33.79 0.01 799427 0.00 0.00 eval_unit + 0.03 33.80 0.01 745269 0.00 0.00 add_seen_nb + 0.03 33.81 0.01 655564 0.00 0.00 eval_eq + 0.03 33.82 0.01 629123 0.00 0.00 write_items + 0.03 33.83 0.01 618305 0.00 0.00 escape_string + 0.03 33.84 0.01 610341 0.00 0.00 stream_order + 0.03 33.85 0.01 604861 0.00 0.00 write_unit_reference + 0.03 33.86 0.01 595896 0.00 0.00 update_long_order + 0.03 33.87 0.01 595125 0.00 0.00 read_unit + 0.03 33.88 0.01 593636 0.00 0.00 building_owner + 0.03 33.89 0.01 546579 0.00 0.00 weapon_skill + 0.03 33.90 0.01 454395 0.00 0.00 a_free + 0.03 33.91 0.01 451774 0.00 0.00 a_remove + 0.03 33.92 0.01 451774 0.00 0.00 a_unlink + 0.03 33.93 0.01 424669 0.00 0.00 active_building + 0.03 33.94 0.01 363135 0.00 0.00 select_opponent + 0.03 33.95 0.01 325825 0.00 0.00 scared_by_monster + 0.03 33.96 0.01 325282 0.00 0.00 eaten_by_monster + 0.03 33.97 0.01 302482 0.00 0.00 findtoken + 0.03 33.98 0.01 301257 0.00 0.00 cr_render + 0.03 33.99 0.01 300501 0.00 0.00 move_blocked + 0.03 34.00 0.01 283711 0.00 0.00 item2resource + 0.03 34.01 0.01 279395 0.00 0.00 weight + 0.03 34.02 0.01 264251 0.00 0.00 rsetpeasants + 0.03 34.03 0.01 263302 0.00 0.00 koor_reldirection + 0.03 34.04 0.01 251814 0.00 0.00 at_find + 0.03 34.05 0.01 218425 0.00 0.00 buildingtype + 0.03 34.06 0.01 209572 0.00 0.00 cr_output_region + 0.03 34.07 0.01 184870 0.00 0.00 buildingeffsize + 0.03 34.08 0.01 180598 0.00 0.00 nr_ship + 0.03 34.09 0.01 178263 0.00 0.00 drown + 0.03 34.10 0.01 178254 0.00 0.00 do_siege + 0.03 34.11 0.01 178254 0.00 0.00 maintain_buildings + 0.03 34.12 0.01 178254 0.00 0.00 sinkships + 0.03 34.13 0.01 178254 0.00 0.00 start_battle + 0.03 34.14 0.01 162862 0.00 0.00 allowed_dragon + 0.03 34.15 0.01 127676 0.00 0.00 write_travelthru + 0.03 34.16 0.01 116804 0.00 0.00 eval_isnull + 0.03 34.17 0.01 113845 0.00 0.00 choplist + 0.03 34.18 0.01 113592 0.00 0.00 nr_building + 0.03 34.19 0.01 105106 0.00 0.00 monster_move + 0.03 34.20 0.01 94420 0.00 0.00 add_give + 0.03 34.21 0.01 67213 0.00 0.00 eval_building + 0.03 34.22 0.01 65155 0.00 0.00 sm_familiar + 0.03 34.23 0.01 54530 0.00 0.00 a_insert + 0.03 34.24 0.01 47887 0.00 0.00 shipcapacity + 0.03 34.25 0.01 41095 0.00 0.00 cr_order + 0.03 34.26 0.01 40046 0.00 0.00 rule_stealth_other + 0.03 34.27 0.01 34486 0.00 0.00 effskill_study + 0.03 34.28 0.01 32727 0.00 0.00 rsetherbtype + 0.03 34.29 0.01 32670 0.00 0.00 horses + 0.03 34.30 0.01 27694 0.00 0.00 all_money + 0.03 34.31 0.01 25088 0.00 0.00 rmtroop + 0.03 34.32 0.01 20176 0.00 0.00 render_messages + 0.03 34.33 0.01 16132 0.00 0.00 teach_unit + 0.03 34.34 0.01 14326 0.00 0.00 replace_order + 0.03 34.35 0.01 11719 0.00 0.00 locale_name + 0.03 34.36 0.01 7255 0.00 0.00 sail + 0.03 34.37 0.01 5494 0.00 0.00 expandbuying + 0.03 34.38 0.01 3147 0.00 0.00 i_canuse + 0.03 34.39 0.01 2887 0.00 0.00 leave + 0.03 34.40 0.01 2838 0.00 0.00 do_attack + 0.03 34.41 0.01 1302 0.00 0.00 academy_can_teach + 0.03 34.42 0.01 1297 0.00 0.00 AllianceAuto + 0.03 34.43 0.01 1018 0.00 0.00 is_exclusive + 0.03 34.44 0.01 780 0.00 0.00 battle_report + 0.03 34.45 0.01 457 0.00 0.00 countheroes + 0.03 34.46 0.01 163 0.00 0.00 eval_lt + 0.03 34.47 0.01 150 0.00 0.00 set_factionstealth + 0.03 34.48 0.01 18 0.00 0.00 ship_update_owner + 0.03 34.49 0.01 6 0.00 0.02 remove_empty_units + 0.03 34.50 0.01 1 0.01 0.01 chaos_update + 0.03 34.51 0.01 1 0.01 0.01 create_icebergs + 0.03 34.52 0.01 1 0.01 0.01 free_params + 0.03 34.53 0.01 1 0.01 0.03 init_transportation + 0.03 34.54 0.01 1 0.01 0.11 magic + 0.03 34.55 0.01 1 0.01 0.01 move_icebergs + 0.03 34.56 0.01 1 0.01 0.03 regenerate_aura + 0.03 34.57 0.01 1 0.01 0.01 remove_empty_factions + 0.03 34.58 0.01 1 0.01 0.04 rotting_herbs + 0.03 34.59 0.01 1 0.01 0.35 write_game + 0.03 34.60 0.01 cb_insert + 0.03 34.61 0.01 cmp_curse + 0.03 34.62 0.01 create_backup + 0.03 34.63 0.01 ct_remove + 0.03 34.64 0.01 get_homeplane + 0.03 34.65 0.01 i10toi36 + 0.03 34.66 0.01 json_export + 0.03 34.67 0.01 make_external_node + 0.03 34.68 0.01 qli_next + 0.03 34.69 0.01 read_movement + 0.03 34.70 0.01 remove_plane + 0.03 34.71 0.01 set_string + 0.03 34.72 0.01 tolua_buildinglist_next + 0.03 34.73 0.01 tolua_regionlist_next + 0.03 34.74 0.01 tolua_tousertype + 0.01 34.74 0.01 cb_new_kv + 0.00 34.74 0.00 11194781 0.00 0.00 keyword_disabled + 0.00 34.74 0.00 7179079 0.00 0.00 rc_skillmod + 0.00 34.74 0.00 6656973 0.00 0.00 bfree + 0.00 34.74 0.00 6610983 0.00 0.00 is_guard + 0.00 34.74 0.00 5100840 0.00 0.00 itoa36 + 0.00 34.74 0.00 4503145 0.00 0.00 omniscient + 0.00 34.74 0.00 3902879 0.00 0.00 get_or_create_monsters + 0.00 34.74 0.00 3902878 0.00 0.00 get_monsters + 0.00 34.74 0.00 3656767 0.00 0.00 add_variable + 0.00 34.74 0.00 3587241 0.00 0.00 pnormalize + 0.00 34.74 0.00 3351853 0.00 0.00 unit_getname + 0.00 34.74 0.00 3166898 0.00 0.00 rherbs + 0.00 34.74 0.00 2426021 0.00 0.00 get_mage + 0.00 34.74 0.00 2386892 0.00 0.00 config_changed + 0.00 34.74 0.00 2383101 0.00 0.00 write_unitname + 0.00 34.74 0.00 2379316 0.00 0.00 resource2weapon + 0.00 34.74 0.00 2272376 0.00 0.00 u_description + 0.00 34.74 0.00 2225796 0.00 0.00 get_borders + 0.00 34.74 0.00 2155959 0.00 0.00 is_persistent + 0.00 34.74 0.00 2124526 0.00 0.00 locale_index + 0.00 34.74 0.00 2066777 0.00 0.00 parse_token_depr + 0.00 34.74 0.00 2009097 0.00 0.00 keyword + 0.00 34.74 0.00 1936876 0.00 0.00 free_order + 0.00 34.74 0.00 1787006 0.00 0.00 findparam + 0.00 34.74 0.00 1785077 0.00 0.00 faction_getorigin + 0.00 34.74 0.00 1771752 0.00 0.00 help_money + 0.00 34.74 0.00 1766225 0.00 0.00 nr_curses_i + 0.00 34.74 0.00 1753922 0.00 0.00 invisible + 0.00 34.74 0.00 1726748 0.00 0.00 is_riding + 0.00 34.74 0.00 1613387 0.00 0.00 rule_region_owners + 0.00 34.74 0.00 1523708 0.00 0.00 uprivate + 0.00 34.74 0.00 1511812 0.00 0.00 newterrain + 0.00 34.74 0.00 1474687 0.00 0.00 leftship + 0.00 34.74 0.00 1441945 0.00 0.00 is_mage + 0.00 34.74 0.00 1380398 0.00 0.00 brelease + 0.00 34.74 0.00 1380398 0.00 0.00 free_variables + 0.00 34.74 0.00 1380398 0.00 0.00 nr_render + 0.00 34.74 0.00 1380007 0.00 0.00 get_otherfaction + 0.00 34.74 0.00 1342832 0.00 0.00 handle_event + 0.00 34.74 0.00 1342381 0.00 0.00 release_data + 0.00 34.74 0.00 1336242 0.00 0.00 rng_injectable_double + 0.00 34.74 0.00 1295787 0.00 0.00 factionname + 0.00 34.74 0.00 1291427 0.00 0.00 set_order + 0.00 34.74 0.00 1252028 0.00 0.00 mkdata + 0.00 34.74 0.00 1218663 0.00 0.00 select_weapon + 0.00 34.74 0.00 1214628 0.00 0.00 is_allied + 0.00 34.74 0.00 1177511 0.00 0.00 it_find + 0.00 34.74 0.00 1160345 0.00 0.00 rhorses + 0.00 34.74 0.00 1158076 0.00 0.00 getbuf + 0.00 34.74 0.00 1132609 0.00 0.00 is_long + 0.00 34.74 0.00 1067195 0.00 0.00 free_arg + 0.00 34.74 0.00 1065211 0.00 0.00 shipname + 0.00 34.74 0.00 1065211 0.00 0.00 write_shipname + 0.00 34.74 0.00 1048274 0.00 0.00 cb_write_travelthru + 0.00 34.74 0.00 1027665 0.00 0.00 init_order + 0.00 34.74 0.00 1014205 0.00 0.00 add_seen + 0.00 34.74 0.00 1009159 0.00 0.00 msg_create + 0.00 34.74 0.00 1009028 0.00 0.00 msg_release + 0.00 34.74 0.00 987612 0.00 0.00 get_astralplane + 0.00 34.74 0.00 987488 0.00 0.00 is_astral + 0.00 34.74 0.00 987128 0.00 0.00 strlcat + 0.00 34.74 0.00 931076 0.00 0.00 change_resource + 0.00 34.74 0.00 892307 0.00 0.00 learn_skill + 0.00 34.74 0.00 888603 0.00 0.00 findunit + 0.00 34.74 0.00 884940 0.00 0.00 itoa10 + 0.00 34.74 0.00 883617 0.00 0.00 eval_int + 0.00 34.74 0.00 876979 0.00 0.00 count_enemies + 0.00 34.74 0.00 868104 0.00 0.00 select_armor + 0.00 34.74 0.00 843545 0.00 0.00 eval_if + 0.00 34.74 0.00 840577 0.00 0.00 a_read_orig + 0.00 34.74 0.00 840577 0.00 0.00 read_attribs + 0.00 34.74 0.00 839970 0.00 0.00 write_attribs + 0.00 34.74 0.00 832876 0.00 0.00 parse_int + 0.00 34.74 0.00 822780 0.00 0.00 i_new + 0.00 34.74 0.00 797288 0.00 0.00 can_survive + 0.00 34.74 0.00 785221 0.00 0.00 trailinto + 0.00 34.74 0.00 779868 0.00 0.00 a_new + 0.00 34.74 0.00 779419 0.00 0.00 a_add + 0.00 34.74 0.00 778818 0.00 0.00 describe_race + 0.00 34.74 0.00 773191 0.00 0.00 hp_status + 0.00 34.74 0.00 755575 0.00 0.00 cb_add_address + 0.00 34.74 0.00 754589 0.00 0.00 preferred_weapon + 0.00 34.74 0.00 752645 0.00 0.00 chance + 0.00 34.74 0.00 748527 0.00 0.00 unit_can_study + 0.00 34.74 0.00 744202 0.00 0.00 has_horses + 0.00 34.74 0.00 734392 0.00 0.00 plane_height + 0.00 34.74 0.00 734392 0.00 0.00 plane_width + 0.00 34.74 0.00 717287 0.00 0.00 get_param_flt + 0.00 34.74 0.00 717218 0.00 0.00 config_get_flt + 0.00 34.74 0.00 669051 0.00 0.00 production + 0.00 34.74 0.00 651711 0.00 0.00 oldcursename + 0.00 34.74 0.00 647569 0.00 0.00 write_faction_reference + 0.00 34.74 0.00 642406 0.00 0.00 write_building_reference + 0.00 34.74 0.00 633429 0.00 0.00 msg_free + 0.00 34.74 0.00 619425 0.00 0.00 getreload + 0.00 34.74 0.00 617313 0.00 0.00 attack + 0.00 34.74 0.00 615299 0.00 0.00 write_ship_reference + 0.00 34.74 0.00 607926 0.00 0.00 writeorder + 0.00 34.74 0.00 603524 0.00 0.00 set_number + 0.00 34.74 0.00 603246 0.00 0.00 level_days + 0.00 34.74 0.00 600145 0.00 0.00 u_setrace + 0.00 34.74 0.00 599650 0.00 0.00 setstatus + 0.00 34.74 0.00 598234 0.00 0.00 report_status + 0.00 34.74 0.00 598129 0.00 0.00 u_setfaction + 0.00 34.74 0.00 598069 0.00 0.00 uhash + 0.00 34.74 0.00 597806 0.00 0.00 unit_get_spellbook + 0.00 34.74 0.00 595705 0.00 0.00 unit_skill + 0.00 34.74 0.00 595478 0.00 0.00 monster_kills_peasants + 0.00 34.74 0.00 595472 0.00 0.00 age_unit + 0.00 34.74 0.00 578591 0.00 0.00 heal_factor + 0.00 34.74 0.00 560926 0.00 0.00 bt_find + 0.00 34.74 0.00 534930 0.00 0.00 isparam + 0.00 34.74 0.00 534762 0.00 0.00 enter_1 + 0.00 34.74 0.00 515911 0.00 0.00 write_regionname + 0.00 34.74 0.00 515550 0.00 0.00 eval_region + 0.00 34.74 0.00 515192 0.00 0.00 is_mourning + 0.00 34.74 0.00 515192 0.00 0.00 owner_change + 0.00 34.74 0.00 514146 0.00 0.00 koor_distance + 0.00 34.74 0.00 512663 0.00 0.00 koor_distance_orig + 0.00 34.74 0.00 508632 0.00 0.00 rule_blessed_harvest + 0.00 34.74 0.00 494960 0.00 0.00 buforder + 0.00 34.74 0.00 490901 0.00 0.00 largestbuilding + 0.00 34.74 0.00 490896 0.00 0.00 wage + 0.00 34.74 0.00 472418 0.00 0.00 produceexp + 0.00 34.74 0.00 472418 0.00 0.00 produceexp_ex + 0.00 34.74 0.00 470529 0.00 0.00 eval_resource + 0.00 34.74 0.00 459083 0.00 0.00 findregion + 0.00 34.74 0.00 447808 0.00 0.00 create_order + 0.00 34.74 0.00 438629 0.00 0.00 maxworkingpeasants + 0.00 34.74 0.00 435022 0.00 0.00 getskill + 0.00 34.74 0.00 432940 0.00 0.00 curse_geteffect + 0.00 34.74 0.00 417580 0.00 0.00 init_learning + 0.00 34.74 0.00 417577 0.00 0.00 done_learning + 0.00 34.74 0.00 417577 0.00 0.00 study_days + 0.00 34.74 0.00 417577 0.00 0.00 study_speedup + 0.00 34.74 0.00 417554 0.00 0.00 random_move_chance + 0.00 34.74 0.00 396305 0.00 0.00 cmp_wage + 0.00 34.74 0.00 392959 0.00 0.00 msg_addref + 0.00 34.74 0.00 386740 0.00 0.00 cr_output_curses_compat + 0.00 34.74 0.00 377253 0.00 0.00 guard_flags + 0.00 34.74 0.00 374425 0.00 0.00 i_free + 0.00 34.74 0.00 369586 0.00 0.00 r_connect + 0.00 34.74 0.00 363071 0.00 0.00 hits + 0.00 34.74 0.00 355423 0.00 0.00 deathcount + 0.00 34.74 0.00 353788 0.00 0.00 add_seen_faction_i + 0.00 34.74 0.00 353422 0.00 0.00 contest + 0.00 34.74 0.00 353422 0.00 0.00 contest_classic + 0.00 34.74 0.00 353422 0.00 0.00 skilldiff + 0.00 34.74 0.00 348444 0.00 0.00 report_resource + 0.00 34.74 0.00 337987 0.00 0.00 setguard + 0.00 34.74 0.00 330438 0.00 0.00 cr_unit + 0.00 34.74 0.00 329691 0.00 0.00 getguard + 0.00 34.74 0.00 317735 0.00 0.00 monster_learn + 0.00 34.74 0.00 317239 0.00 0.00 count_side + 0.00 34.74 0.00 308950 0.00 0.00 r_demand + 0.00 34.74 0.00 300810 0.00 0.00 count_enemies_i + 0.00 34.74 0.00 298951 0.00 0.00 distance + 0.00 34.74 0.00 297222 0.00 0.00 messagehash + 0.00 34.74 0.00 293362 0.00 0.00 get_direction + 0.00 34.74 0.00 285923 0.00 0.00 ualias + 0.00 34.74 0.00 284005 0.00 0.00 read_unitid + 0.00 34.74 0.00 282847 0.00 0.00 getunit + 0.00 34.74 0.00 279072 0.00 0.00 cr_int + 0.00 34.74 0.00 263302 0.00 0.00 reldirection + 0.00 34.74 0.00 257723 0.00 0.00 i_remove + 0.00 34.74 0.00 257693 0.00 0.00 rsethorses + 0.00 34.74 0.00 252446 0.00 0.00 movewhere + 0.00 34.74 0.00 251874 0.00 0.00 __at_hashkey + 0.00 34.74 0.00 251867 0.00 0.00 attacks_per_round + 0.00 34.74 0.00 251814 0.00 0.00 a_read_i + 0.00 34.74 0.00 229715 0.00 0.00 rsettrees + 0.00 34.74 0.00 228907 0.00 0.00 getid + 0.00 34.74 0.00 221899 0.00 0.00 findunitg + 0.00 34.74 0.00 221723 0.00 0.00 plane_center_x + 0.00 34.74 0.00 221723 0.00 0.00 plane_center_y + 0.00 34.74 0.00 218422 0.00 0.00 report_building + 0.00 34.74 0.00 217696 0.00 0.00 can_give + 0.00 34.74 0.00 217405 0.00 0.00 r_setdemand + 0.00 34.74 0.00 216069 0.00 0.00 check_param + 0.00 34.74 0.00 216069 0.00 0.00 config_token + 0.00 34.74 0.00 209572 0.00 0.00 cr_region_header + 0.00 34.74 0.00 204314 0.00 0.00 bt_changed + 0.00 34.74 0.00 203117 0.00 0.00 atoip + 0.00 34.74 0.00 201744 0.00 0.00 lovar + 0.00 34.74 0.00 196476 0.00 0.00 b_finvisible + 0.00 34.74 0.00 196476 0.00 0.00 b_rvisibleroad + 0.00 34.74 0.00 192815 0.00 0.00 add_regionlist + 0.00 34.74 0.00 192556 0.00 0.00 canride + 0.00 34.74 0.00 191379 0.00 0.00 finditemtype + 0.00 34.74 0.00 190469 0.00 0.00 border_name + 0.00 34.74 0.00 190467 0.00 0.00 b_nameroad + 0.00 34.74 0.00 190467 0.00 0.00 b_transparent + 0.00 34.74 0.00 189341 0.00 0.00 rule_autowork + 0.00 34.74 0.00 180818 0.00 0.00 buildingname + 0.00 34.74 0.00 180818 0.00 0.00 write_buildingname + 0.00 34.74 0.00 179761 0.00 0.00 cr_output_ship + 0.00 34.74 0.00 179235 0.00 0.00 get_chaoscount + 0.00 34.74 0.00 178429 0.00 0.00 a_removeall + 0.00 34.74 0.00 178322 0.00 0.00 terrain_find_i + 0.00 34.74 0.00 178311 0.00 0.00 region_setinfo + 0.00 34.74 0.00 178290 0.00 0.00 rhash + 0.00 34.74 0.00 178270 0.00 0.00 get_terrain + 0.00 34.74 0.00 178257 0.00 0.00 key_get + 0.00 34.74 0.00 178255 0.00 0.00 good_region + 0.00 34.74 0.00 178254 0.00 0.00 age_piracy + 0.00 34.74 0.00 178254 0.00 0.00 age_region + 0.00 34.74 0.00 178254 0.00 0.00 age_traveldir + 0.00 34.74 0.00 178254 0.00 0.00 do_battle + 0.00 34.74 0.00 178254 0.00 0.00 drifting_ships + 0.00 34.74 0.00 178254 0.00 0.00 enter_2 + 0.00 34.74 0.00 178254 0.00 0.00 expandwork + 0.00 34.74 0.00 178254 0.00 0.00 live + 0.00 34.74 0.00 178254 0.00 0.00 new_region + 0.00 34.74 0.00 178254 0.00 0.00 produce + 0.00 34.74 0.00 178254 0.00 0.00 readregion + 0.00 34.74 0.00 178254 0.00 0.00 region_getinfo + 0.00 34.74 0.00 178254 0.00 0.00 split_allocations + 0.00 34.74 0.00 178254 0.00 0.00 writeregion + 0.00 34.74 0.00 174968 0.00 0.00 get_familiar_mage + 0.00 34.74 0.00 174677 0.00 0.00 cr_output_resource + 0.00 34.74 0.00 169733 0.00 0.00 travelthru_add + 0.00 34.74 0.00 163027 0.00 0.00 markets_module + 0.00 34.74 0.00 157830 0.00 0.00 allowed_fly + 0.00 34.74 0.00 154110 0.00 0.00 rule_stealth_anon + 0.00 34.74 0.00 152803 0.00 0.00 free_node + 0.00 34.74 0.00 152803 0.00 0.00 new_node + 0.00 34.74 0.00 152504 0.00 0.00 plain_name + 0.00 34.74 0.00 147171 0.00 0.00 building_finished + 0.00 34.74 0.00 146997 0.00 0.00 dice_rand + 0.00 34.74 0.00 146950 0.00 0.00 f_regionid_s + 0.00 34.74 0.00 143730 0.00 0.00 rroad + 0.00 34.74 0.00 141675 0.00 0.00 mknode + 0.00 34.74 0.00 140305 0.00 0.00 set_resvalue + 0.00 34.74 0.00 137709 0.00 0.00 CavalryBonus + 0.00 34.74 0.00 133873 0.00 0.00 cr_region + 0.00 34.74 0.00 131765 0.00 0.00 give_control_cmd + 0.00 34.74 0.00 131722 0.00 0.00 give_cmd + 0.00 34.74 0.00 130867 0.00 0.00 get_transporters + 0.00 34.74 0.00 128596 0.00 0.00 check_errno + 0.00 34.74 0.00 128135 0.00 0.00 rpline + 0.00 34.74 0.00 127788 0.00 0.00 eval_direction + 0.00 34.74 0.00 127674 0.00 0.00 eval_trailto + 0.00 34.74 0.00 123744 0.00 0.00 arg_set + 0.00 34.74 0.00 123513 0.00 0.00 eval_order + 0.00 34.74 0.00 116914 0.00 0.00 fleechance + 0.00 34.74 0.00 116914 0.00 0.00 horse_fleeing_bonus + 0.00 34.74 0.00 116002 0.00 0.00 get_movement + 0.00 34.74 0.00 115276 0.00 0.00 can_move + 0.00 34.74 0.00 113844 0.00 0.00 translist + 0.00 34.74 0.00 113487 0.00 0.00 next_region + 0.00 34.74 0.00 112140 0.00 0.00 castle_name + 0.00 34.74 0.00 112140 0.00 0.00 castle_name_i + 0.00 34.74 0.00 110533 0.00 0.00 weapon_weight + 0.00 34.74 0.00 110167 0.00 0.00 cr_resource + 0.00 34.74 0.00 109785 0.00 0.00 move_unit + 0.00 34.74 0.00 109377 0.00 0.00 free_regionlist + 0.00 34.74 0.00 108560 0.00 0.00 eval_trail + 0.00 34.74 0.00 108335 0.00 0.00 roadto + 0.00 34.74 0.00 106919 0.00 0.00 mark_travelthru + 0.00 34.74 0.00 106798 0.00 0.00 help_feed + 0.00 34.74 0.00 105958 0.00 0.00 entrance_allowed + 0.00 34.74 0.00 104830 0.00 0.00 cr_output_building + 0.00 34.74 0.00 103784 0.00 0.00 move_cmd + 0.00 34.74 0.00 103187 0.00 0.00 cycle_route + 0.00 34.74 0.00 103079 0.00 0.00 rule_give + 0.00 34.74 0.00 102761 0.00 0.00 check_give + 0.00 34.74 0.00 102705 0.00 0.00 can_give_to + 0.00 34.74 0.00 102149 0.00 0.00 cr_output_travelthru + 0.00 34.74 0.00 101322 0.00 0.00 rsetherbs + 0.00 34.74 0.00 96637 0.00 0.00 personcapacity + 0.00 34.74 0.00 96637 0.00 0.00 walkingcapacity + 0.00 34.74 0.00 96555 0.00 0.00 canwalk + 0.00 34.74 0.00 96555 0.00 0.00 travel_i + 0.00 34.74 0.00 96529 0.00 0.00 travel + 0.00 34.74 0.00 96527 0.00 0.00 make_route + 0.00 34.74 0.00 96482 0.00 0.00 travel_route + 0.00 34.74 0.00 96450 0.00 0.00 cap_route + 0.00 34.74 0.00 96450 0.00 0.00 movement_speed + 0.00 34.74 0.00 96208 0.00 0.00 var_copy_regions + 0.00 34.74 0.00 95593 0.00 0.00 can_leave + 0.00 34.74 0.00 95533 0.00 0.00 give_item + 0.00 34.74 0.00 93452 0.00 0.00 see_border + 0.00 34.74 0.00 93120 0.00 0.00 change_reservation + 0.00 34.74 0.00 93119 0.00 0.00 give_quota + 0.00 34.74 0.00 93119 0.00 0.00 limited_give + 0.00 34.74 0.00 87004 0.00 0.00 i_add + 0.00 34.74 0.00 86400 0.00 0.00 spell_name + 0.00 34.74 0.00 84017 0.00 0.00 random_neighbour + 0.00 34.74 0.00 83859 0.00 0.00 reduce_weight + 0.00 34.74 0.00 83224 0.00 0.00 trollbelts + 0.00 34.74 0.00 80630 0.00 0.00 armor_bonus + 0.00 34.74 0.00 80630 0.00 0.00 calculate_armor + 0.00 34.74 0.00 80630 0.00 0.00 natural_armor + 0.00 34.74 0.00 80630 0.00 0.00 select_magicarmor + 0.00 34.74 0.00 80630 0.00 0.00 terminate + 0.00 34.74 0.00 79772 0.00 0.00 entertainmoney + 0.00 34.74 0.00 75797 0.00 0.00 buildingtype_exists + 0.00 34.74 0.00 72692 0.00 0.00 rc_specialdamage + 0.00 34.74 0.00 71416 0.00 0.00 reserve_i + 0.00 34.74 0.00 70836 0.00 0.00 is_guardian_u + 0.00 34.74 0.00 69432 0.00 0.00 getparam + 0.00 34.74 0.00 66134 0.00 0.00 shipspeed + 0.00 34.74 0.00 66058 0.00 0.00 ShipSpeedBonus + 0.00 34.74 0.00 65345 0.00 0.00 region_get_morale + 0.00 34.74 0.00 62267 0.00 0.00 get_migrants + 0.00 34.74 0.00 61961 0.00 0.00 cr_output_messages + 0.00 34.74 0.00 59694 0.00 0.00 r_insectstalled + 0.00 34.74 0.00 58524 0.00 0.00 a_writeint + 0.00 34.74 0.00 58518 0.00 0.00 a_readint + 0.00 34.74 0.00 57367 0.00 0.00 count_travelthru + 0.00 34.74 0.00 57138 0.00 0.00 getint + 0.00 34.74 0.00 56646 0.00 0.00 write_group + 0.00 34.74 0.00 56643 0.00 0.00 groupid + 0.00 34.74 0.00 56503 0.00 0.00 find_group + 0.00 34.74 0.00 56503 0.00 0.00 read_group + 0.00 34.74 0.00 55547 0.00 0.00 ally_add + 0.00 34.74 0.00 55350 0.00 0.00 can_start_guarding + 0.00 34.74 0.00 54735 0.00 0.00 init_cb + 0.00 34.74 0.00 54351 0.00 0.00 get_familiar + 0.00 34.74 0.00 54318 0.00 0.00 getstrtoken + 0.00 34.74 0.00 54163 0.00 0.00 var_copy_string + 0.00 34.74 0.00 51239 0.00 0.00 read_faction_reference + 0.00 34.74 0.00 51060 0.00 0.00 remove_skill + 0.00 34.74 0.00 50673 0.00 0.00 update_resources + 0.00 34.74 0.00 49331 0.00 0.00 _log_write + 0.00 34.74 0.00 49331 0.00 0.00 log_prefix + 0.00 34.74 0.00 49331 0.00 0.00 log_stdio + 0.00 34.74 0.00 49317 0.00 0.00 log_write + 0.00 34.74 0.00 49235 0.00 0.00 log_debug + 0.00 34.74 0.00 48565 0.00 0.00 u_set_building + 0.00 34.74 0.00 48457 0.00 0.00 bfindhash + 0.00 34.74 0.00 48455 0.00 0.00 findbuilding + 0.00 34.74 0.00 47562 0.00 0.00 rule_random_progress + 0.00 34.74 0.00 47562 0.00 0.00 skill_weeks + 0.00 34.74 0.00 47535 0.00 0.00 sk_set + 0.00 34.74 0.00 47287 0.00 0.00 canswim + 0.00 34.74 0.00 46742 0.00 0.00 findregionbyid + 0.00 34.74 0.00 46224 0.00 0.00 eval_faction + 0.00 34.74 0.00 46196 0.00 0.00 bhash + 0.00 34.74 0.00 46184 0.00 0.00 age_building + 0.00 34.74 0.00 45891 0.00 0.00 get_level + 0.00 34.74 0.00 45860 0.00 0.00 print_items + 0.00 34.74 0.00 45630 0.00 0.00 cr_output_resources + 0.00 34.74 0.00 44216 0.00 0.00 flying_ship + 0.00 34.74 0.00 44190 0.00 0.00 maintain + 0.00 34.74 0.00 41882 0.00 0.00 GiveRestriction + 0.00 34.74 0.00 41255 0.00 0.00 var_copy_order + 0.00 34.74 0.00 41248 0.00 0.00 msg_feedback + 0.00 34.74 0.00 40692 0.00 0.00 get_gamedate + 0.00 34.74 0.00 40099 0.00 0.00 eval_skill + 0.00 34.74 0.00 39955 0.00 0.00 write_of + 0.00 34.74 0.00 39926 0.00 0.00 check_leuchtturm + 0.00 34.74 0.00 39836 0.00 0.00 read_of + 0.00 34.74 0.00 39810 0.00 0.00 check_ship_allowed + 0.00 34.74 0.00 37974 0.00 0.00 deathcounts + 0.00 34.74 0.00 37931 0.00 0.00 centre + 0.00 34.74 0.00 37453 0.00 0.00 shiptrail_age + 0.00 34.74 0.00 37453 0.00 0.00 shiptrail_init + 0.00 34.74 0.00 37202 0.00 0.00 var_free_string + 0.00 34.74 0.00 37024 0.00 0.00 b_blocknone + 0.00 34.74 0.00 35708 0.00 0.00 reserve_cmd + 0.00 34.74 0.00 35708 0.00 0.00 reserve_self + 0.00 34.74 0.00 34565 0.00 0.00 ur_add + 0.00 34.74 0.00 34420 0.00 0.00 a_writeshorts + 0.00 34.74 0.00 34409 0.00 0.00 add_income + 0.00 34.74 0.00 34382 0.00 0.00 a_readshorts + 0.00 34.74 0.00 34221 0.00 0.00 eff_weight + 0.00 34.74 0.00 34220 0.00 0.00 shiptrail_read + 0.00 34.74 0.00 32727 0.00 0.00 region_set_morale + 0.00 34.74 0.00 32679 0.00 0.00 read_owner + 0.00 34.74 0.00 32679 0.00 0.00 rule_auto_taxation + 0.00 34.74 0.00 32670 0.00 0.00 calculate_emigration + 0.00 34.74 0.00 32670 0.00 0.00 growing_herbs + 0.00 34.74 0.00 32670 0.00 0.00 growing_trees + 0.00 34.74 0.00 32670 0.00 0.00 migrate + 0.00 34.74 0.00 32670 0.00 0.00 morale_update + 0.00 34.74 0.00 32670 0.00 0.00 peasants + 0.00 34.74 0.00 32670 0.00 0.00 write_owner + 0.00 34.74 0.00 31688 0.00 0.00 cr_building + 0.00 34.74 0.00 31214 0.00 0.00 message_faction + 0.00 34.74 0.00 30872 0.00 0.00 resolve_faction + 0.00 34.74 0.00 30634 0.00 0.00 guard_off_cmd + 0.00 34.74 0.00 30554 0.00 0.00 guard_on_cmd + 0.00 34.74 0.00 30308 0.00 0.00 peasant_growth_factor + 0.00 34.74 0.00 30250 0.00 0.00 peasant_luck_effect + 0.00 34.74 0.00 30150 0.00 0.00 ship_damage_percent + 0.00 34.74 0.00 28818 0.00 0.00 findship + 0.00 34.74 0.00 28818 0.00 0.00 sfindhash + 0.00 34.74 0.00 27694 0.00 0.00 dice + 0.00 34.74 0.00 27694 0.00 0.00 dragon_affinity_value + 0.00 34.74 0.00 27640 0.00 0.00 u_set_ship + 0.00 34.74 0.00 26995 0.00 0.00 inside_building + 0.00 34.74 0.00 26515 0.00 0.00 b_uinvisible + 0.00 34.74 0.00 26164 0.00 0.00 building_is_active + 0.00 34.74 0.00 26045 0.00 0.00 curse_cansee + 0.00 34.74 0.00 26045 0.00 0.00 msg_curse + 0.00 34.74 0.00 25857 0.00 0.00 eval_int36 + 0.00 34.74 0.00 25441 0.00 0.00 rmt_find + 0.00 34.74 0.00 25088 0.00 0.00 kill_troop + 0.00 34.74 0.00 25088 0.00 0.00 rmfighter + 0.00 34.74 0.00 24449 0.00 0.00 seematrix + 0.00 34.74 0.00 23781 0.00 0.00 guard + 0.00 34.74 0.00 23342 0.00 0.00 shiptrail_finalize + 0.00 34.74 0.00 23233 0.00 0.00 cr_faction + 0.00 34.74 0.00 22843 0.00 0.00 parser_end + 0.00 34.74 0.00 22644 0.00 0.00 new_border + 0.00 34.74 0.00 22643 0.00 0.00 b_validroad + 0.00 34.74 0.00 22643 0.00 0.00 b_writeroad + 0.00 34.74 0.00 22638 0.00 0.00 find_bordertype + 0.00 34.74 0.00 22637 0.00 0.00 b_readroad + 0.00 34.74 0.00 22301 0.00 0.00 army_index + 0.00 34.74 0.00 21517 0.00 0.00 chaosfactor + 0.00 34.74 0.00 21500 0.00 0.00 resource2luxury + 0.00 34.74 0.00 21443 0.00 0.00 ridingcapacity + 0.00 34.74 0.00 20072 0.00 0.00 cr_skill + 0.00 34.74 0.00 19671 0.00 0.00 buildingcapacity + 0.00 34.74 0.00 19545 0.00 0.00 eval_ship + 0.00 34.74 0.00 19089 0.00 0.00 st_find_i + 0.00 34.74 0.00 19085 0.00 0.00 shash + 0.00 34.74 0.00 19082 0.00 0.00 st_find + 0.00 34.74 0.00 18971 0.00 0.00 building_set_owner + 0.00 34.74 0.00 18963 0.00 0.00 ship_set_owner + 0.00 34.74 0.00 18788 0.00 0.00 sideabkz + 0.00 34.74 0.00 18059 0.00 0.00 add_chaoscount + 0.00 34.74 0.00 17289 0.00 0.00 parser_popstate + 0.00 34.74 0.00 17289 0.00 0.00 parser_pushstate + 0.00 34.74 0.00 16751 0.00 0.00 getuint + 0.00 34.74 0.00 16737 0.00 0.00 dir_invert + 0.00 34.74 0.00 16669 0.00 0.00 IsImmune + 0.00 34.74 0.00 16596 0.00 0.00 entertain_cmd + 0.00 34.74 0.00 16493 0.00 0.00 NewbieImmunity + 0.00 34.74 0.00 16191 0.00 0.00 add_donation + 0.00 34.74 0.00 16132 0.00 0.00 magic_lowskill + 0.00 34.74 0.00 15797 0.00 0.00 sell + 0.00 34.74 0.00 15708 0.00 0.00 add_travelthru_addresses + 0.00 34.74 0.00 15361 0.00 0.00 is_guarded + 0.00 34.74 0.00 15359 0.00 0.00 cinfo_building + 0.00 34.74 0.00 15240 0.00 0.00 msg_error + 0.00 34.74 0.00 15102 0.00 0.00 cmistake + 0.00 34.74 0.00 14994 0.00 0.00 cr_string + 0.00 34.74 0.00 14191 0.00 0.00 flee + 0.00 34.74 0.00 14111 0.00 0.00 shiptrail_write + 0.00 34.74 0.00 13500 0.00 0.00 enoughsailors + 0.00 34.74 0.00 12933 0.00 0.00 owner_buildingtyp + 0.00 34.74 0.00 12407 0.00 0.00 cr_regions + 0.00 34.74 0.00 12398 0.00 0.00 fbattlerecord + 0.00 34.74 0.00 12265 0.00 0.00 r_addmessage + 0.00 34.74 0.00 11989 0.00 0.00 resolve_unit + 0.00 34.74 0.00 11880 0.00 0.00 cansee_unit + 0.00 34.74 0.00 11599 0.00 0.00 building_protection + 0.00 34.74 0.00 11540 0.00 0.00 absorbed_by_monster + 0.00 34.74 0.00 11159 0.00 0.00 expandentertainment + 0.00 34.74 0.00 11087 0.00 0.00 do_work + 0.00 34.74 0.00 11052 0.00 0.00 find_spell + 0.00 34.74 0.00 11052 0.00 0.00 sp_alias + 0.00 34.74 0.00 10600 0.00 0.00 make_cmd + 0.00 34.74 0.00 10475 0.00 0.00 i_freeall + 0.00 34.74 0.00 10417 0.00 0.00 free_luxuries + 0.00 34.74 0.00 10344 0.00 0.00 cansail + 0.00 34.74 0.00 10232 0.00 0.00 update_lighthouse + 0.00 34.74 0.00 9763 0.00 0.00 read_reference + 0.00 34.74 0.00 9680 0.00 0.00 bewegung_blockiert_von + 0.00 34.74 0.00 9352 0.00 0.00 write_spell_modifier + 0.00 34.74 0.00 9147 0.00 0.00 merge_messages + 0.00 34.74 0.00 9147 0.00 0.00 split_messages + 0.00 34.74 0.00 8993 0.00 0.00 addtoken + 0.00 34.74 0.00 8962 0.00 0.00 hpflee + 0.00 34.74 0.00 8898 0.00 0.00 ucontact + 0.00 34.74 0.00 8892 0.00 0.00 astralregions + 0.00 34.74 0.00 8892 0.00 0.00 r_astral_to_standard + 0.00 34.74 0.00 8788 0.00 0.00 xml_cleanup_string + 0.00 34.74 0.00 8622 0.00 0.00 read_unit_reference + 0.00 34.74 0.00 8191 0.00 0.00 read_seenspell + 0.00 34.74 0.00 8187 0.00 0.00 write_seenspell + 0.00 34.74 0.00 8034 0.00 0.00 u_geteffstealth + 0.00 34.74 0.00 7964 0.00 0.00 nrt_section + 0.00 34.74 0.00 7957 0.00 0.00 magic_resistance + 0.00 34.74 0.00 7915 0.00 0.00 visible_default + 0.00 34.74 0.00 7889 0.00 0.00 special_resources + 0.00 34.74 0.00 7815 0.00 0.00 already_seen + 0.00 34.74 0.00 7630 0.00 0.00 addstrlist + 0.00 34.74 0.00 7493 0.00 0.00 required + 0.00 34.74 0.00 7336 0.00 0.00 get_alive + 0.00 34.74 0.00 7254 0.00 0.00 ship_ready + 0.00 34.74 0.00 7220 0.00 0.00 a_writestring + 0.00 34.74 0.00 7153 0.00 0.00 cr_ship + 0.00 34.74 0.00 7085 0.00 0.00 a_readprivate + 0.00 34.74 0.00 6962 0.00 0.00 leave_trail + 0.00 34.74 0.00 6962 0.00 0.00 set_coast + 0.00 34.74 0.00 6787 0.00 0.00 unicode_utf8_strcasecmp + 0.00 34.74 0.00 6576 0.00 0.00 xml_bvalue + 0.00 34.74 0.00 6530 0.00 0.00 findparam_ex + 0.00 34.74 0.00 5988 0.00 0.00 herbsearch + 0.00 34.74 0.00 5966 0.00 0.00 ntimespprob + 0.00 34.74 0.00 5925 0.00 0.00 addally + 0.00 34.74 0.00 5916 0.00 0.00 buy + 0.00 34.74 0.00 5907 0.00 0.00 cinfo_simple + 0.00 34.74 0.00 5810 0.00 0.00 report_transfer + 0.00 34.74 0.00 5596 0.00 0.00 drain_exp + 0.00 34.74 0.00 5588 0.00 0.00 get_locale + 0.00 34.74 0.00 5453 0.00 0.00 xml_ivalue + 0.00 34.74 0.00 5384 0.00 0.00 teach_cmd + 0.00 34.74 0.00 5358 0.00 0.00 get_spchange + 0.00 34.74 0.00 5358 0.00 0.00 max_spellpoints + 0.00 34.74 0.00 5354 0.00 0.00 xml_readtext + 0.00 34.74 0.00 5330 0.00 0.00 freestrlist + 0.00 34.74 0.00 5049 0.00 0.00 find_piracy_target + 0.00 34.74 0.00 5049 0.00 0.00 parse_ids + 0.00 34.74 0.00 5049 0.00 0.00 piracy_cmd + 0.00 34.74 0.00 5049 0.00 0.00 validate_pirate + 0.00 34.74 0.00 4915 0.00 0.00 get_spellpoints + 0.00 34.74 0.00 4875 0.00 0.00 get_combatspell + 0.00 34.74 0.00 4782 0.00 0.00 select_recruitment + 0.00 34.74 0.00 4629 0.00 0.00 expandselling + 0.00 34.74 0.00 4475 0.00 0.00 matmod + 0.00 34.74 0.00 4384 0.00 0.00 lparagraph + 0.00 34.74 0.00 4384 0.00 0.00 spunit + 0.00 34.74 0.00 4361 0.00 0.00 can_takeoff + 0.00 34.74 0.00 4261 0.00 0.00 findbuildingtype + 0.00 34.74 0.00 4259 0.00 0.00 findshiptype + 0.00 34.74 0.00 4162 0.00 0.00 spell_info + 0.00 34.74 0.00 4066 0.00 0.00 buildingmaintenance + 0.00 34.74 0.00 4052 0.00 0.00 c_clearflag + 0.00 34.74 0.00 4052 0.00 0.00 chash + 0.00 34.74 0.00 4052 0.00 0.00 curse_age + 0.00 34.74 0.00 4052 0.00 0.00 curse_init + 0.00 34.74 0.00 4024 0.00 0.00 curse_write + 0.00 34.74 0.00 4020 0.00 0.00 curse_read + 0.00 34.74 0.00 3862 0.00 0.00 unit_setname + 0.00 34.74 0.00 3717 0.00 0.00 free_castorders + 0.00 34.74 0.00 3659 0.00 0.00 ExpensiveMigrants + 0.00 34.74 0.00 3659 0.00 0.00 is_migrant + 0.00 34.74 0.00 3639 0.00 0.00 setreload + 0.00 34.74 0.00 3626 0.00 0.00 create_item + 0.00 34.74 0.00 3597 0.00 0.00 chaos + 0.00 34.74 0.00 3496 0.00 0.00 locale_setstring + 0.00 34.74 0.00 3438 0.00 0.00 lighthouse_range + 0.00 34.74 0.00 3438 0.00 0.00 prepare_lighthouse + 0.00 34.74 0.00 3355 0.00 0.00 region_getresource + 0.00 34.74 0.00 3203 0.00 0.00 faction_get_spellbook + 0.00 34.74 0.00 3203 0.00 0.00 join_battle + 0.00 34.74 0.00 3178 0.00 0.00 scale_number + 0.00 34.74 0.00 3171 0.00 0.00 get_spellbook + 0.00 34.74 0.00 3152 0.00 0.00 scareaway + 0.00 34.74 0.00 3123 0.00 0.00 limit_resource + 0.00 34.74 0.00 3117 0.00 0.00 name_cmd + 0.00 34.74 0.00 3114 0.00 0.00 rename_cmd + 0.00 34.74 0.00 3113 0.00 0.00 t_new + 0.00 34.74 0.00 3111 0.00 0.00 sidename + 0.00 34.74 0.00 3110 0.00 0.00 default_order + 0.00 34.74 0.00 3100 0.00 0.00 required + 0.00 34.74 0.00 3096 0.00 0.00 tt_find + 0.00 34.74 0.00 3078 0.00 0.00 allocate_resource + 0.00 34.74 0.00 3003 0.00 0.00 roqf_factor + 0.00 34.74 0.00 3002 0.00 0.00 forbiddenid + 0.00 34.74 0.00 2977 0.00 0.00 change_effect + 0.00 34.74 0.00 2931 0.00 0.00 name_unit + 0.00 34.74 0.00 2913 0.00 0.00 dead_fighters + 0.00 34.74 0.00 2889 0.00 0.00 create_unit + 0.00 34.74 0.00 2889 0.00 0.00 createunitid + 0.00 34.74 0.00 2854 0.00 0.00 is_attacker + 0.00 34.74 0.00 2831 0.00 0.00 countspells + 0.00 34.74 0.00 2818 0.00 0.00 newunitid + 0.00 34.74 0.00 2742 0.00 0.00 get_equipment + 0.00 34.74 0.00 2723 0.00 0.00 get_allocator + 0.00 34.74 0.00 2665 0.00 0.00 findnewunit + 0.00 34.74 0.00 2665 0.00 0.00 read_newunitid + 0.00 34.74 0.00 2650 0.00 0.00 a_initeffect + 0.00 34.74 0.00 2491 0.00 0.00 a_readeffect + 0.00 34.74 0.00 2468 0.00 0.00 find_argtype + 0.00 34.74 0.00 2468 0.00 0.00 tsf_find + 0.00 34.74 0.00 2457 0.00 0.00 set_level + 0.00 34.74 0.00 2421 0.00 0.00 set_racename + 0.00 34.74 0.00 2375 0.00 0.00 equip_unit + 0.00 34.74 0.00 2375 0.00 0.00 equip_unit_mask + 0.00 34.74 0.00 2324 0.00 0.00 read_spellbook + 0.00 34.74 0.00 2321 0.00 0.00 write_spellbook + 0.00 34.74 0.00 2304 0.00 0.00 killunit_write + 0.00 34.74 0.00 2299 0.00 0.00 killunit_read + 0.00 34.74 0.00 2274 0.00 0.00 cinfo_ship + 0.00 34.74 0.00 2148 0.00 0.00 demon_skillchange + 0.00 34.74 0.00 2112 0.00 0.00 spellbook_get + 0.00 34.74 0.00 2096 0.00 0.00 a_writeeffect + 0.00 34.74 0.00 2092 0.00 0.00 init_mage + 0.00 34.74 0.00 2091 0.00 0.00 read_mage + 0.00 34.74 0.00 2089 0.00 0.00 write_mage + 0.00 34.74 0.00 2081 0.00 0.00 a_init_reportspell + 0.00 34.74 0.00 2081 0.00 0.00 cr_reportspell + 0.00 34.74 0.00 2081 0.00 0.00 nr_spell + 0.00 34.74 0.00 2081 0.00 0.00 nr_spell_syntax + 0.00 34.74 0.00 2073 0.00 0.00 set_enemy + 0.00 34.74 0.00 2013 0.00 0.00 display_cmd + 0.00 34.74 0.00 2008 0.00 0.00 default_name + 0.00 34.74 0.00 1936 0.00 0.00 transfermen + 0.00 34.74 0.00 1921 0.00 0.00 show_allies_cr + 0.00 34.74 0.00 1911 0.00 0.00 cinfo_magicresistance + 0.00 34.74 0.00 1909 0.00 0.00 nrt_register + 0.00 34.74 0.00 1909 0.00 0.00 section_find + 0.00 34.74 0.00 1888 0.00 0.00 show_allies + 0.00 34.74 0.00 1873 0.00 0.00 set_spellpoints + 0.00 34.74 0.00 1848 0.00 0.00 uunhash + 0.00 34.74 0.00 1835 0.00 0.00 recruit + 0.00 34.74 0.00 1803 0.00 0.00 gift_items + 0.00 34.74 0.00 1794 0.00 0.00 remove_unit + 0.00 34.74 0.00 1761 0.00 0.00 give_horses + 0.00 34.74 0.00 1725 0.00 0.00 max_magicians + 0.00 34.74 0.00 1716 0.00 0.00 recruit_cost + 0.00 34.74 0.00 1711 0.00 0.00 cr_output_spells + 0.00 34.74 0.00 1700 0.00 0.00 status_cmd + 0.00 34.74 0.00 1697 0.00 0.00 new_group + 0.00 34.74 0.00 1670 0.00 0.00 any_recruiters + 0.00 34.74 0.00 1670 0.00 0.00 horse_recruiters + 0.00 34.74 0.00 1667 0.00 0.00 add_recruits + 0.00 34.74 0.00 1610 0.00 0.00 transfer_curse + 0.00 34.74 0.00 1594 0.00 0.00 do_recruiting + 0.00 34.74 0.00 1594 0.00 0.00 expandrecruit + 0.00 34.74 0.00 1594 0.00 0.00 free_recruitments + 0.00 34.74 0.00 1584 0.00 0.00 produce_resource + 0.00 34.74 0.00 1583 0.00 0.00 allied_skilllimit + 0.00 34.74 0.00 1583 0.00 0.00 reduce_skill + 0.00 34.74 0.00 1583 0.00 0.00 skill_limit + 0.00 34.74 0.00 1582 0.00 0.00 resource2potion + 0.00 34.74 0.00 1582 0.00 0.00 write_triggers + 0.00 34.74 0.00 1573 0.00 0.00 usetprivate + 0.00 34.74 0.00 1572 0.00 0.00 write_score + 0.00 34.74 0.00 1570 0.00 0.00 read_triggers + 0.00 34.74 0.00 1564 0.00 0.00 init_handler + 0.00 34.74 0.00 1564 0.00 0.00 write_handler + 0.00 34.74 0.00 1557 0.00 0.00 read_handler + 0.00 34.74 0.00 1529 0.00 0.00 ship_owner_ex + 0.00 34.74 0.00 1524 0.00 0.00 spellbook_add + 0.00 34.74 0.00 1522 0.00 0.00 a_write_unit + 0.00 34.74 0.00 1522 0.00 0.00 age_unit + 0.00 34.74 0.00 1520 0.00 0.00 eval_race + 0.00 34.74 0.00 1520 0.00 0.00 set_friendly + 0.00 34.74 0.00 1486 0.00 0.00 message_all + 0.00 34.74 0.00 1466 0.00 0.00 resolve_region_id + 0.00 34.74 0.00 1429 0.00 0.00 set_attacker + 0.00 34.74 0.00 1422 0.00 0.00 attrib_allocation + 0.00 34.74 0.00 1363 0.00 0.00 age_skeleton + 0.00 34.74 0.00 1361 0.00 0.00 unit_has_cursed_item + 0.00 34.74 0.00 1339 0.00 0.00 get_combatspelllevel + 0.00 34.74 0.00 1301 0.00 0.00 leveled_allocation + 0.00 34.74 0.00 1301 0.00 0.00 rm_get + 0.00 34.74 0.00 1297 0.00 0.00 add_tactics + 0.00 34.74 0.00 1297 0.00 0.00 battle_punit + 0.00 34.74 0.00 1297 0.00 0.00 free_fighter + 0.00 34.74 0.00 1297 0.00 0.00 hunted_dir + 0.00 34.74 0.00 1297 0.00 0.00 make_fighter + 0.00 34.74 0.00 1295 0.00 0.00 find_side + 0.00 34.74 0.00 1270 0.00 0.00 set_group + 0.00 34.74 0.00 1245 0.00 0.00 use_default + 0.00 34.74 0.00 1239 0.00 0.00 build + 0.00 34.74 0.00 1214 0.00 0.00 rule_faction_limit + 0.00 34.74 0.00 1202 0.00 0.00 resolve_familiar + 0.00 34.74 0.00 1201 0.00 0.00 change_spellpoints + 0.00 34.74 0.00 1199 0.00 0.00 res_changeaura + 0.00 34.74 0.00 1196 0.00 0.00 eval_localize + 0.00 34.74 0.00 1140 0.00 0.00 read_region_reference + 0.00 34.74 0.00 1139 0.00 0.00 region_setresource + 0.00 34.74 0.00 1138 0.00 0.00 read_targetregion + 0.00 34.74 0.00 1125 0.00 0.00 leave_building + 0.00 34.74 0.00 1119 0.00 0.00 write_region_reference + 0.00 34.74 0.00 1117 0.00 0.00 write_targetregion + 0.00 34.74 0.00 1091 0.00 0.00 loot_quota + 0.00 34.74 0.00 1078 0.00 0.00 resolve_mage + 0.00 34.74 0.00 1042 0.00 0.00 in_safe_building + 0.00 34.74 0.00 1041 0.00 0.00 findskill + 0.00 34.74 0.00 967 0.00 0.00 count_all + 0.00 34.74 0.00 960 0.00 0.00 tax_cmd + 0.00 34.74 0.00 957 0.00 0.00 crt_register + 0.00 34.74 0.00 957 0.00 0.00 mt_id + 0.00 34.74 0.00 957 0.00 0.00 mt_new + 0.00 34.74 0.00 957 0.00 0.00 mt_register + 0.00 34.74 0.00 955 0.00 0.00 movement_error + 0.00 34.74 0.00 946 0.00 0.00 sparagraph + 0.00 34.74 0.00 946 0.00 0.00 split_paragraph + 0.00 34.74 0.00 923 0.00 0.00 race_namegen + 0.00 34.74 0.00 894 0.00 0.00 make_follow + 0.00 34.74 0.00 834 0.00 0.00 eval_resources + 0.00 34.74 0.00 820 0.00 0.00 curse_geteffect_int + 0.00 34.74 0.00 799 0.00 0.00 setstealth_cmd + 0.00 34.74 0.00 793 0.00 0.00 is_familiar + 0.00 34.74 0.00 791 0.00 0.00 ally_cmd + 0.00 34.74 0.00 791 0.00 0.00 getfaction + 0.00 34.74 0.00 786 0.00 0.00 average_score_of_age + 0.00 34.74 0.00 785 0.00 0.00 lua_canuse_item + 0.00 34.74 0.00 769 0.00 0.00 shock_write + 0.00 34.74 0.00 768 0.00 0.00 shock_read + 0.00 34.74 0.00 767 0.00 0.00 spellcost + 0.00 34.74 0.00 763 0.00 0.00 init_skillmod + 0.00 34.74 0.00 760 0.00 0.00 read_familiar + 0.00 34.74 0.00 760 0.00 0.00 read_magician + 0.00 34.74 0.00 760 0.00 0.00 set_familiar + 0.00 34.74 0.00 754 0.00 0.00 checkunitnumber + 0.00 34.74 0.00 754 0.00 0.00 rule_alliance_limit + 0.00 34.74 0.00 752 0.00 0.00 monster_attack + 0.00 34.74 0.00 735 0.00 0.00 join_group + 0.00 34.74 0.00 708 0.00 0.00 age_ghoul + 0.00 34.74 0.00 702 0.00 0.00 max_transfers + 0.00 34.74 0.00 688 0.00 0.00 age_zombie + 0.00 34.74 0.00 677 0.00 0.00 slipthru + 0.00 34.74 0.00 666 0.00 0.00 generic_name + 0.00 34.74 0.00 663 0.00 0.00 expandtax + 0.00 34.74 0.00 659 0.00 0.00 can_give_men + 0.00 34.74 0.00 621 0.00 0.00 build_building + 0.00 34.74 0.00 621 0.00 0.00 group_cmd + 0.00 34.74 0.00 608 0.00 0.00 co_get_region + 0.00 34.74 0.00 604 0.00 0.00 eval_spell + 0.00 34.74 0.00 590 0.00 0.00 use_cmd + 0.00 34.74 0.00 590 0.00 0.00 use_item + 0.00 34.74 0.00 588 0.00 0.00 give_men + 0.00 34.74 0.00 574 0.00 0.00 battle_attacks + 0.00 34.74 0.00 574 0.00 0.00 battle_flee + 0.00 34.74 0.00 574 0.00 0.00 battle_update + 0.00 34.74 0.00 573 0.00 0.00 join_path + 0.00 34.74 0.00 569 0.00 0.00 relpath + 0.00 34.74 0.00 569 0.00 0.00 u_seteffstealth + 0.00 34.74 0.00 564 0.00 0.00 reportpath + 0.00 34.74 0.00 560 0.00 0.00 oldterrain + 0.00 34.74 0.00 554 0.00 0.00 a_finalizeeffect + 0.00 34.74 0.00 552 0.00 0.00 free_side + 0.00 34.74 0.00 552 0.00 0.00 make_side + 0.00 34.74 0.00 552 0.00 0.00 print_fighters + 0.00 34.74 0.00 524 0.00 0.00 remove_exclusive + 0.00 34.74 0.00 508 0.00 0.00 MagicRegeneration + 0.00 34.74 0.00 508 0.00 0.00 regeneration + 0.00 34.74 0.00 505 0.00 0.00 mm_smithy + 0.00 34.74 0.00 501 0.00 0.00 xml_fvalue + 0.00 34.74 0.00 499 0.00 0.00 MagicPower + 0.00 34.74 0.00 492 0.00 0.00 u_hasspell + 0.00 34.74 0.00 482 0.00 0.00 knowsspell + 0.00 34.74 0.00 481 0.00 0.00 count_units + 0.00 34.74 0.00 475 0.00 0.00 follow_ship + 0.00 34.74 0.00 465 0.00 0.00 get_function + 0.00 34.74 0.00 464 0.00 0.00 lastregion + 0.00 34.74 0.00 462 0.00 0.00 game_name + 0.00 34.74 0.00 461 0.00 0.00 maxheroes + 0.00 34.74 0.00 457 0.00 0.00 FactionSpells + 0.00 34.74 0.00 453 0.00 0.00 find_groupbyname + 0.00 34.74 0.00 451 0.00 0.00 mtype_get_param + 0.00 34.74 0.00 443 0.00 0.00 change_maxspellpoints + 0.00 34.74 0.00 443 0.00 0.00 res_changepermaura + 0.00 34.74 0.00 433 0.00 0.00 make_otherfaction + 0.00 34.74 0.00 432 0.00 0.00 helping + 0.00 34.74 0.00 428 0.00 0.00 free_nodes + 0.00 34.74 0.00 425 0.00 0.00 reportcasualties + 0.00 34.74 0.00 412 0.00 0.00 do_combatmagic + 0.00 34.74 0.00 406 0.00 0.00 PopulationDamage + 0.00 34.74 0.00 406 0.00 0.00 faction_setorigin + 0.00 34.74 0.00 405 0.00 0.00 enter_building + 0.00 34.74 0.00 404 0.00 0.00 usetpotionuse + 0.00 34.74 0.00 401 0.00 0.00 mayenter + 0.00 34.74 0.00 396 0.00 0.00 show_new_spells + 0.00 34.74 0.00 383 0.00 0.00 rt_get_or_create + 0.00 34.74 0.00 380 0.00 0.00 create_spellbook + 0.00 34.74 0.00 378 0.00 0.00 get_tactics + 0.00 34.74 0.00 377 0.00 0.00 manufacture + 0.00 34.74 0.00 371 0.00 0.00 add_translation + 0.00 34.74 0.00 365 0.00 0.00 unit_getspell + 0.00 34.74 0.00 361 0.00 0.00 regionname + 0.00 34.74 0.00 356 0.00 0.00 cr_race + 0.00 34.74 0.00 349 0.00 0.00 research_cmd + 0.00 34.74 0.00 348 0.00 0.00 begin_potion + 0.00 34.74 0.00 348 0.00 0.00 mail_cmd + 0.00 34.74 0.00 348 0.00 0.00 ugetpotionuse + 0.00 34.74 0.00 348 0.00 0.00 use_potion + 0.00 34.74 0.00 345 0.00 0.00 do_potion + 0.00 34.74 0.00 345 0.00 0.00 end_potion + 0.00 34.74 0.00 343 0.00 0.00 rough_amount + 0.00 34.74 0.00 338 0.00 0.00 findrace + 0.00 34.74 0.00 328 0.00 0.00 display_potion + 0.00 34.74 0.00 324 0.00 0.00 add_itemname_cb + 0.00 34.74 0.00 324 0.00 0.00 add_resourcename_cb + 0.00 34.74 0.00 324 0.00 0.00 caught_target + 0.00 34.74 0.00 319 0.00 0.00 loot_items + 0.00 34.74 0.00 314 0.00 0.00 CavalrySkill + 0.00 34.74 0.00 312 0.00 0.00 continue_ship + 0.00 34.74 0.00 307 0.00 0.00 getship + 0.00 34.74 0.00 303 0.00 0.00 create_castorder + 0.00 34.74 0.00 303 0.00 0.00 free_castorder + 0.00 34.74 0.00 298 0.00 0.00 plan_dragon + 0.00 34.74 0.00 295 0.00 0.00 age_dragon + 0.00 34.74 0.00 287 0.00 0.00 factionorders + 0.00 34.74 0.00 286 0.00 0.00 checkpasswd + 0.00 34.74 0.00 286 0.00 0.00 password_verify + 0.00 34.74 0.00 279 0.00 0.00 cr_spell + 0.00 34.74 0.00 273 0.00 0.00 pay_spell + 0.00 34.74 0.00 267 0.00 0.00 freetokens + 0.00 34.74 0.00 266 0.00 0.00 age_undead + 0.00 34.74 0.00 255 0.00 0.00 select_spellbook + 0.00 34.74 0.00 252 0.00 0.00 path_exists + 0.00 34.74 0.00 251 0.00 0.00 cancast + 0.00 34.74 0.00 251 0.00 0.00 eff_spelllevel + 0.00 34.74 0.00 251 0.00 0.00 out_faction + 0.00 34.74 0.00 250 0.00 0.00 real2tp + 0.00 34.74 0.00 249 0.00 0.00 make_movement_order + 0.00 34.74 0.00 248 0.00 0.00 sm_smithy + 0.00 34.74 0.00 242 0.00 0.00 canfly + 0.00 34.74 0.00 241 0.00 0.00 reshow + 0.00 34.74 0.00 241 0.00 0.00 reshow_cmd + 0.00 34.74 0.00 240 0.00 0.00 register_function + 0.00 34.74 0.00 236 0.00 0.00 leave_cmd + 0.00 34.74 0.00 234 0.00 0.00 make_leftship + 0.00 34.74 0.00 234 0.00 0.00 set_leftship + 0.00 34.74 0.00 233 0.00 0.00 faction_setpassword + 0.00 34.74 0.00 233 0.00 0.00 fhash + 0.00 34.74 0.00 233 0.00 0.00 password_encode + 0.00 34.74 0.00 233 0.00 0.00 read_groups + 0.00 34.74 0.00 233 0.00 0.00 read_password + 0.00 34.74 0.00 233 0.00 0.00 readfaction + 0.00 34.74 0.00 233 0.00 0.00 set_email + 0.00 34.74 0.00 232 0.00 0.00 spc_email_isvalid + 0.00 34.74 0.00 232 0.00 0.00 transfer_seen + 0.00 34.74 0.00 232 0.00 0.00 write_groups + 0.00 34.74 0.00 232 0.00 0.00 write_password + 0.00 34.74 0.00 232 0.00 0.08 write_reports + 0.00 34.74 0.00 232 0.00 0.00 write_script + 0.00 34.74 0.00 232 0.00 0.00 writefaction + 0.00 34.74 0.00 231 0.00 0.00 RemoveNMRNewbie + 0.00 34.74 0.00 231 0.00 0.00 eressea_version + 0.00 34.74 0.00 230 0.00 0.00 allies + 0.00 34.74 0.00 230 0.00 0.00 cr_find_address + 0.00 34.74 0.00 230 0.00 0.00 gamedate_season + 0.00 34.74 0.00 230 0.00 0.00 report_crtypes + 0.00 34.74 0.00 230 0.00 0.00 reset_translations + 0.00 34.74 0.00 230 0.00 0.00 rp_battles + 0.00 34.74 0.00 230 0.00 0.00 show_alliances_cr + 0.00 34.74 0.00 230 0.00 0.00 write_translations + 0.00 34.74 0.00 229 0.00 0.00 add_castorder + 0.00 34.74 0.00 229 0.00 0.00 list_address + 0.00 34.74 0.00 226 0.00 0.00 fumble + 0.00 34.74 0.00 225 0.00 0.00 spellpower + 0.00 34.74 0.00 224 0.00 0.00 leave_ship + 0.00 34.74 0.00 222 0.00 0.00 cast_cmd + 0.00 34.74 0.00 222 0.00 0.00 enter_ship + 0.00 34.74 0.00 220 0.00 0.00 farcasting + 0.00 34.74 0.00 214 0.00 0.00 var_copy_items + 0.00 34.74 0.00 210 0.00 0.00 cr_resources + 0.00 34.74 0.00 209 0.00 0.00 var_free_resources + 0.00 34.74 0.00 207 0.00 0.00 rule_force_leave + 0.00 34.74 0.00 206 0.00 0.00 aftermath + 0.00 34.74 0.00 206 0.00 0.00 battle_effects + 0.00 34.74 0.00 206 0.00 0.00 battle_free + 0.00 34.74 0.00 206 0.00 0.00 free_battle + 0.00 34.74 0.00 206 0.00 0.00 join_allies + 0.00 34.74 0.00 206 0.00 0.00 make_battle + 0.00 34.74 0.00 206 0.00 0.00 make_heroes + 0.00 34.74 0.00 206 0.00 0.00 print_header + 0.00 34.74 0.00 206 0.00 0.00 print_stats + 0.00 34.74 0.00 206 0.00 0.00 reorder_fleeing + 0.00 34.74 0.00 206 0.00 0.00 var_copy_resources + 0.00 34.74 0.00 203 0.00 0.00 msg_set_int + 0.00 34.74 0.00 196 0.00 0.00 make_name + 0.00 34.74 0.00 196 0.00 0.00 verify_targets + 0.00 34.74 0.00 195 0.00 0.00 mayboard + 0.00 34.74 0.00 192 0.00 0.00 can_contact + 0.00 34.74 0.00 191 0.00 0.00 CheckOverload + 0.00 34.74 0.00 191 0.00 0.00 xml_readconstruction + 0.00 34.74 0.00 188 0.00 0.00 is_freezing + 0.00 34.74 0.00 186 0.00 0.00 leftship_age + 0.00 34.74 0.00 185 0.00 0.00 it_get_or_create + 0.00 34.74 0.00 185 0.00 0.00 it_register + 0.00 34.74 0.00 183 0.00 0.00 cinfo_magicrunes + 0.00 34.74 0.00 182 0.00 0.00 age_firedragon + 0.00 34.74 0.00 182 0.00 0.00 msg_materials_required + 0.00 34.74 0.00 178 0.00 0.00 parse_function + 0.00 34.74 0.00 177 0.00 0.00 breed_cmd + 0.00 34.74 0.00 176 0.00 0.00 default_spoil + 0.00 34.74 0.00 174 0.00 0.00 breedhorses + 0.00 34.74 0.00 174 0.00 0.00 findresourcetype + 0.00 34.74 0.00 167 0.00 0.00 academy_teaching_bonus + 0.00 34.74 0.00 166 0.00 0.00 add_spell + 0.00 34.74 0.00 166 0.00 0.00 create_spell + 0.00 34.74 0.00 163 0.00 0.00 cinfo_shipnodrift + 0.00 34.74 0.00 162 0.00 0.00 rt_register + 0.00 34.74 0.00 160 0.00 0.00 damage_ship + 0.00 34.74 0.00 157 0.00 0.00 xml_readitem + 0.00 34.74 0.00 150 0.00 0.00 rc_get_or_create + 0.00 34.74 0.00 149 0.00 0.00 create_potion + 0.00 34.74 0.00 147 0.00 0.00 contact_cmd + 0.00 34.74 0.00 145 0.00 0.00 findunitr + 0.00 34.74 0.00 143 0.00 0.00 ResourceFactor + 0.00 34.74 0.00 143 0.00 0.00 update_resource + 0.00 34.74 0.00 138 0.00 0.00 renumber_cmd + 0.00 34.74 0.00 136 0.00 0.00 a_readstring + 0.00 34.74 0.00 136 0.00 0.00 path_find + 0.00 34.74 0.00 134 0.00 0.00 cinfo_slave + 0.00 34.74 0.00 133 0.00 0.00 income + 0.00 34.74 0.00 133 0.00 0.00 present + 0.00 34.74 0.00 133 0.00 0.00 reroute + 0.00 34.74 0.00 127 0.00 0.00 msg_create_message + 0.00 34.74 0.00 125 0.00 0.00 r_standard_to_astral + 0.00 34.74 0.00 125 0.00 0.00 random_unit + 0.00 34.74 0.00 125 0.00 0.00 tpregion + 0.00 34.74 0.00 124 0.00 0.00 age_stonecircle + 0.00 34.74 0.00 124 0.00 0.00 eval_unit_dative + 0.00 34.74 0.00 122 0.00 0.00 maxbuild + 0.00 34.74 0.00 121 0.00 0.00 co_get_caster + 0.00 34.74 0.00 121 0.00 0.00 lua_callspell + 0.00 34.74 0.00 121 0.00 0.00 msg_send_faction + 0.00 34.74 0.00 121 0.00 0.00 msg_set_unit + 0.00 34.74 0.00 120 0.00 0.00 plagues + 0.00 34.74 0.00 119 0.00 0.00 syntax_error + 0.00 34.74 0.00 118 0.00 0.00 keyword_key + 0.00 34.74 0.00 118 0.00 0.00 rule_transfermen + 0.00 34.74 0.00 115 0.00 0.00 build_ship + 0.00 34.74 0.00 115 0.00 0.00 usetcontact + 0.00 34.74 0.00 114 0.00 0.00 give_unit + 0.00 34.74 0.00 112 0.00 0.00 attack_firesword + 0.00 34.74 0.00 112 0.00 0.00 get_friends + 0.00 34.74 0.00 111 0.00 0.00 check_steal + 0.00 34.74 0.00 111 0.00 0.00 steal_cmd + 0.00 34.74 0.00 107 0.00 0.00 init_keyword + 0.00 34.74 0.00 106 0.00 0.00 a_readkey + 0.00 34.74 0.00 106 0.00 0.00 age_reduceproduction + 0.00 34.74 0.00 106 0.00 0.00 equipment_setskill + 0.00 34.74 0.00 105 0.00 0.00 terraform_region + 0.00 34.74 0.00 105 0.00 0.00 terraform_resources + 0.00 34.74 0.00 104 0.00 0.00 reshow_other + 0.00 34.74 0.00 99 0.00 0.00 spl_costtyp + 0.00 34.74 0.00 97 0.00 0.00 i_merge + 0.00 34.74 0.00 97 0.00 0.00 mk_piracy + 0.00 34.74 0.00 97 0.00 0.00 piracy_done + 0.00 34.74 0.00 97 0.00 0.00 piracy_init + 0.00 34.74 0.00 92 0.00 0.00 building_update_owner + 0.00 34.74 0.00 88 0.00 0.00 hunger + 0.00 34.74 0.00 88 0.00 0.00 hunger_damage + 0.00 34.74 0.00 88 0.00 0.00 parameter_key + 0.00 34.74 0.00 84 0.00 0.00 xml_readrequirements + 0.00 34.74 0.00 83 0.00 0.00 create_castorder_combat + 0.00 34.74 0.00 81 0.00 0.00 can_guard + 0.00 34.74 0.00 80 0.00 0.00 combatspell_cmd + 0.00 34.74 0.00 80 0.00 0.00 msg_set_resource + 0.00 34.74 0.00 78 0.00 0.00 eval_weight + 0.00 34.74 0.00 74 0.00 0.00 cast_combatspell + 0.00 34.74 0.00 74 0.00 0.00 get_force + 0.00 34.74 0.00 74 0.00 0.00 ghoul_name + 0.00 34.74 0.00 74 0.00 0.00 spell_damage + 0.00 34.74 0.00 73 0.00 0.00 create_equipment + 0.00 34.74 0.00 72 0.00 0.00 default_score + 0.00 34.74 0.00 71 0.00 0.00 disband_men + 0.00 34.74 0.00 70 0.00 0.00 skeleton_name + 0.00 34.74 0.00 68 0.00 0.00 a_readchars + 0.00 34.74 0.00 68 0.00 0.00 rc_create + 0.00 34.74 0.00 67 0.00 0.00 parse_ai + 0.00 34.74 0.00 66 0.00 0.00 a_writechars + 0.00 34.74 0.00 65 0.00 0.00 equipment_setitem + 0.00 34.74 0.00 65 0.00 0.00 findkeyword + 0.00 34.74 0.00 65 0.00 0.00 max_skill + 0.00 34.74 0.00 64 0.00 0.00 log_info + 0.00 34.74 0.00 62 0.00 0.00 cinfo_speed + 0.00 34.74 0.00 62 0.00 0.00 potion_luck + 0.00 34.74 0.00 61 0.00 0.00 add_callbacks + 0.00 34.74 0.00 61 0.00 0.00 add_items + 0.00 34.74 0.00 61 0.00 0.00 add_skills + 0.00 34.74 0.00 61 0.00 0.00 add_spells + 0.00 34.74 0.00 61 0.00 0.00 add_subsets + 0.00 34.74 0.00 60 0.00 0.00 equip_items + 0.00 34.74 0.00 60 0.00 0.00 nb_armor + 0.00 34.74 0.00 58 0.00 0.00 add_resource + 0.00 34.74 0.00 58 0.00 0.00 dict_get + 0.00 34.74 0.00 58 0.00 0.00 dict_name + 0.00 34.74 0.00 58 0.00 0.00 peasant_luck_factor + 0.00 34.74 0.00 58 0.00 0.00 rmt_get + 0.00 34.74 0.00 58 0.00 0.00 skill_key + 0.00 34.74 0.00 58 0.00 0.00 terraform_default + 0.00 34.74 0.00 57 0.00 0.00 free_land + 0.00 34.74 0.00 56 0.00 0.00 add_proc + 0.00 34.74 0.00 56 0.00 0.00 dict_init + 0.00 34.74 0.00 56 0.00 0.00 dict_read + 0.00 34.74 0.00 56 0.00 0.00 dict_write + 0.00 34.74 0.00 56 0.00 0.00 use_bloodpotion + 0.00 34.74 0.00 55 0.00 0.00 at_register + 0.00 34.74 0.00 55 0.00 0.00 renumber_unit + 0.00 34.74 0.00 54 0.00 0.00 eval_add + 0.00 34.74 0.00 54 0.00 0.00 it_set_appearance + 0.00 34.74 0.00 53 0.00 0.00 do_extra_spell + 0.00 34.74 0.00 53 0.00 0.00 lua_getresource + 0.00 34.74 0.00 53 0.00 0.00 sp_dragonodem + 0.00 34.74 0.00 52 0.00 0.00 cinfo_skillmod + 0.00 34.74 0.00 52 0.00 0.00 get_or_create_terrain + 0.00 34.74 0.00 52 0.00 0.00 zombie_name + 0.00 34.74 0.00 51 0.00 0.00 potion_water_of_life + 0.00 34.74 0.00 51 0.00 0.00 rcomp + 0.00 34.74 0.00 49 0.00 0.00 get_money_for_dragon + 0.00 34.74 0.00 48 0.00 0.00 addmessage + 0.00 34.74 0.00 48 0.00 0.00 allysfm + 0.00 34.74 0.00 48 0.00 0.00 caddmessage + 0.00 34.74 0.00 48 0.00 0.00 chaosterrain + 0.00 34.74 0.00 48 0.00 0.00 get_maxluxuries + 0.00 34.74 0.00 48 0.00 0.00 makename + 0.00 34.74 0.00 48 0.00 0.00 region_setname + 0.00 34.74 0.00 48 0.00 0.00 unit_addorder + 0.00 34.74 0.00 47 0.00 0.00 display_race + 0.00 34.74 0.00 47 0.00 0.00 give_peasants + 0.00 34.74 0.00 47 0.00 0.00 msg_set_region + 0.00 34.74 0.00 45 0.00 0.00 count_maxmigrants + 0.00 34.74 0.00 45 0.00 0.00 count_migrants + 0.00 34.74 0.00 45 0.00 0.00 create_curse + 0.00 34.74 0.00 44 0.00 0.00 ct_register + 0.00 34.74 0.00 44 0.00 0.00 curse_name + 0.00 34.74 0.00 43 0.00 0.00 unset_combatspell + 0.00 34.74 0.00 42 0.00 0.00 loot_cmd + 0.00 34.74 0.00 42 0.00 0.00 pcomp + 0.00 34.74 0.00 41 0.00 0.00 build_road + 0.00 34.74 0.00 41 0.00 0.00 expandstealing + 0.00 34.74 0.00 40 0.00 0.00 regions_in_range + 0.00 34.74 0.00 40 0.00 0.00 set_new_dragon_target + 0.00 34.74 0.00 39 0.00 0.00 bt_get_or_create + 0.00 34.74 0.00 39 0.00 0.00 deliverMail + 0.00 34.74 0.00 39 0.00 0.00 display_item + 0.00 34.74 0.00 39 0.00 0.00 random_growl + 0.00 34.74 0.00 38 0.00 0.00 count_allies + 0.00 34.74 0.00 38 0.00 0.00 do_combatspell + 0.00 34.74 0.00 38 0.00 0.00 report_action + 0.00 34.74 0.00 38 0.00 0.00 select_ally + 0.00 34.74 0.00 37 0.00 0.00 transport + 0.00 34.74 0.00 36 0.00 0.00 expandloot + 0.00 34.74 0.00 36 0.00 0.00 runhash + 0.00 34.74 0.00 35 0.00 0.00 mailunit + 0.00 34.74 0.00 34 0.00 0.00 dracoid_name + 0.00 34.74 0.00 33 0.00 0.00 pack_keyval + 0.00 34.74 0.00 33 0.00 0.00 set_param + 0.00 34.74 0.00 32 0.00 0.00 add_function + 0.00 34.74 0.00 32 0.00 0.00 make_curse + 0.00 34.74 0.00 30 0.00 0.00 limit_seeds + 0.00 34.74 0.00 30 0.00 0.00 overload_start + 0.00 34.74 0.00 30 0.00 0.00 treeman_neighbour + 0.00 34.74 0.00 29 0.00 0.00 add_proc_order + 0.00 34.74 0.00 29 0.00 0.00 add_raceprefix + 0.00 34.74 0.00 29 0.00 0.00 json_terrain_production + 0.00 34.74 0.00 28 0.00 0.00 cunhash + 0.00 34.74 0.00 28 0.00 0.00 curse_done + 0.00 34.74 0.00 28 0.00 0.00 destroy_curse + 0.00 34.74 0.00 28 0.00 0.00 report_effect + 0.00 34.74 0.00 27 0.00 0.00 NMRTimeout + 0.00 34.74 0.00 27 0.00 0.00 bt_register + 0.00 34.74 0.00 27 0.00 0.00 dragon_name + 0.00 34.74 0.00 27 0.00 0.00 move_iceberg + 0.00 34.74 0.00 27 0.00 0.00 register_item_use + 0.00 34.74 0.00 26 0.00 0.00 add_spellparameter + 0.00 34.74 0.00 26 0.00 0.00 free_spellparameter + 0.00 34.74 0.00 25 0.00 0.00 allysf + 0.00 34.74 0.00 25 0.00 0.00 make_targetregion + 0.00 34.74 0.00 24 0.00 0.00 equipment_addspell + 0.00 34.74 0.00 24 0.00 0.00 is_moving_ship + 0.00 34.74 0.00 23 0.00 0.00 destroy_cmd + 0.00 34.74 0.00 23 0.00 0.00 new_weapontype + 0.00 34.74 0.00 23 0.00 0.00 xml_readweapon + 0.00 34.74 0.00 22 0.00 0.00 addparam_ship + 0.00 34.74 0.00 22 0.00 0.00 rsetroad + 0.00 34.74 0.00 22 0.00 0.00 verify_ship + 0.00 34.74 0.00 21 0.00 0.00 sp_kampfzauber + 0.00 34.74 0.00 20 0.00 0.00 spawn_seaserpent + 0.00 34.74 0.00 19 0.00 0.00 tsf_register + 0.00 34.74 0.00 18 0.00 0.00 check_dupe + 0.00 34.74 0.00 18 0.00 0.00 handle_triggers + 0.00 34.74 0.00 18 0.00 0.00 json_flags + 0.00 34.74 0.00 18 0.00 0.00 json_terrain + 0.00 34.74 0.00 18 0.00 0.00 register_argtype + 0.00 34.74 0.00 18 0.00 0.00 timeout_handle + 0.00 34.74 0.00 18 0.00 0.00 timeout_init + 0.00 34.74 0.00 18 0.00 0.00 timeout_write + 0.00 34.74 0.00 17 0.00 0.00 recruit_dracoids + 0.00 34.74 0.00 16 0.00 0.00 addparam_unit + 0.00 34.74 0.00 16 0.00 0.00 damage_unit + 0.00 34.74 0.00 16 0.00 0.00 spy_cmd + 0.00 34.74 0.00 16 0.00 0.00 verify_unit + 0.00 34.74 0.00 15 0.00 0.00 drift_target + 0.00 34.74 0.00 15 0.00 0.00 new_potiontype + 0.00 34.74 0.00 15 0.00 0.00 overload + 0.00 34.74 0.00 15 0.00 0.00 pt_register + 0.00 34.74 0.00 15 0.00 0.00 res_changepeasants + 0.00 34.74 0.00 15 0.00 0.00 xml_readpotion + 0.00 34.74 0.00 14 0.00 0.00 heal_fighters + 0.00 34.74 0.00 14 0.00 0.00 tt_register + 0.00 34.74 0.00 13 0.00 0.00 add_proc_global + 0.00 34.74 0.00 13 0.00 0.00 getplanebyid + 0.00 34.74 0.00 13 0.00 0.00 log_error + 0.00 34.74 0.00 13 0.00 0.00 make_iceberg + 0.00 34.74 0.00 13 0.00 0.00 newcontainerid + 0.00 34.74 0.00 13 0.00 0.00 set_curseingmagician + 0.00 34.74 0.00 13 0.00 0.00 sp_blessedharvest + 0.00 34.74 0.00 13 0.00 0.00 timeout_read + 0.00 34.74 0.00 13 0.00 0.00 tolua_toid + 0.00 34.74 0.00 12 0.00 0.00 bunhash + 0.00 34.74 0.00 12 0.00 0.00 changefaction_init + 0.00 34.74 0.00 12 0.00 0.00 changefaction_write + 0.00 34.74 0.00 12 0.00 0.00 forget_cmd + 0.00 34.74 0.00 12 0.00 0.00 make_reduceproduction + 0.00 34.74 0.00 12 0.00 0.00 msg_to_ship_inmates + 0.00 34.74 0.00 12 0.00 0.00 volcano_destruction + 0.00 34.74 0.00 12 0.00 0.00 write_race_reference + 0.00 34.74 0.00 11 0.00 0.00 add_trigger + 0.00 34.74 0.00 11 0.00 0.00 koor_distance_wrap_xy + 0.00 34.74 0.00 11 0.00 0.00 new_building + 0.00 34.74 0.00 11 0.00 0.00 produce_seeds + 0.00 34.74 0.00 11 0.00 0.00 xml_register_callback + 0.00 34.74 0.00 11 0.00 0.00 xml_spell + 0.00 34.74 0.00 10 0.00 0.00 changefaction_read + 0.00 34.74 0.00 10 0.00 0.00 nrand + 0.00 34.74 0.00 10 0.00 0.00 rel_to_abs + 0.00 34.74 0.00 10 0.00 0.00 section_add + 0.00 34.74 0.00 10 0.00 0.00 set_combatspell + 0.00 34.74 0.00 10 0.00 0.00 sp_hain + 0.00 34.74 0.00 9 0.00 0.00 basepath + 0.00 34.74 0.00 9 0.00 0.00 init_resourcelimit + 0.00 34.74 0.00 9 0.00 0.00 melt_iceberg + 0.00 34.74 0.00 9 0.00 0.00 register_bordertype + 0.00 34.74 0.00 9 0.00 0.00 sp_stormwinds + 0.00 34.74 0.00 8 0.00 0.00 add_proc_region + 0.00 34.74 0.00 8 0.00 0.00 do_fumble + 0.00 34.74 0.00 8 0.00 0.00 mod_elves_only + 0.00 34.74 0.00 8 0.00 0.00 new_armortype + 0.00 34.74 0.00 8 0.00 0.00 spy_message + 0.00 34.74 0.00 8 0.00 0.00 unit_gethp + 0.00 34.74 0.00 8 0.00 0.00 xml_readarmor + 0.00 34.74 0.00 7 0.00 0.00 fighters + 0.00 34.74 0.00 7 0.00 0.00 has_ao_healing + 0.00 34.74 0.00 7 0.00 0.00 i_findc + 0.00 34.74 0.00 7 0.00 0.00 lt_register + 0.00 34.74 0.00 7 0.00 0.00 new_luxurytype + 0.00 34.74 0.00 7 0.00 0.00 register_race_name_function + 0.00 34.74 0.00 7 0.00 0.00 rmt_create + 0.00 34.74 0.00 7 0.00 0.00 scramble_fighters + 0.00 34.74 0.00 7 0.00 0.00 sp_healing + 0.00 34.74 0.00 7 0.00 0.00 spellbook_clear + 0.00 34.74 0.00 7 0.00 0.00 st_get_or_create + 0.00 34.74 0.00 7 0.00 0.00 sunhash + 0.00 34.74 0.00 7 0.00 0.00 xml_readluxury + 0.00 34.74 0.00 6 0.00 0.00 addparam_building + 0.00 34.74 0.00 6 0.00 0.00 changerace_init + 0.00 34.74 0.00 6 0.00 0.00 changerace_write + 0.00 34.74 0.00 6 0.00 0.00 equipment_setcallback + 0.00 34.74 0.00 6 0.00 0.00 findoption + 0.00 34.74 0.00 6 0.00 0.00 get_or_create_locale + 0.00 34.74 0.00 6 0.00 0.00 init_translations + 0.00 34.74 0.00 6 0.00 0.00 make_undead_unit + 0.00 34.74 0.00 6 0.00 0.00 msg_send_region + 0.00 34.74 0.00 6 0.00 0.00 read_race_reference + 0.00 34.74 0.00 6 0.00 0.00 remove_ship + 0.00 34.74 0.00 6 0.00 0.00 rrandneighbour + 0.00 34.74 0.00 6 0.00 0.00 send_cmd + 0.00 34.74 0.00 6 0.00 0.00 skill_summoned + 0.00 34.74 0.00 6 0.00 0.00 sp_mallornhain + 0.00 34.74 0.00 6 0.00 0.00 sp_summonundead + 0.00 34.74 0.00 6 0.00 0.00 volcano_outbreak + 0.00 34.74 0.00 5 0.00 0.00 at_deprecate + 0.00 34.74 0.00 5 0.00 0.00 datapath + 0.00 34.74 0.00 5 0.00 0.00 free_group + 0.00 34.74 0.00 5 0.00 0.00 get_cmp_region_owner + 0.00 34.74 0.00 5 0.00 0.00 log_warning + 0.00 34.74 0.00 5 0.00 0.00 reset_locales + 0.00 34.74 0.00 5 0.00 0.00 set_money + 0.00 34.74 0.00 5 0.00 0.00 trigger_killunit + 0.00 34.74 0.00 5 0.00 0.00 trigger_timeout + 0.00 34.74 0.00 5 0.00 0.00 ursprung_x + 0.00 34.74 0.00 5 0.00 0.00 ursprung_y + 0.00 34.74 0.00 4 0.00 0.00 count_skill + 0.00 34.74 0.00 4 0.00 0.00 heal + 0.00 34.74 0.00 4 0.00 0.00 intlist_add + 0.00 34.74 0.00 4 0.00 0.00 intlist_init + 0.00 34.74 0.00 4 0.00 0.00 json_config + 0.00 34.74 0.00 4 0.00 0.00 mailfaction + 0.00 34.74 0.00 4 0.00 0.00 nextlocale + 0.00 34.74 0.00 4 0.00 0.00 read_skill + 0.00 34.74 0.00 4 0.00 0.00 seefaction + 0.00 34.74 0.00 4 0.00 0.00 sp_goodwinds + 0.00 34.74 0.00 4 0.00 0.00 terrains + 0.00 34.74 0.00 4 0.00 0.00 try_rename + 0.00 34.74 0.00 4 0.00 0.00 verify_building + 0.00 34.74 0.00 3 0.00 0.00 add_proc_postregion + 0.00 34.74 0.00 3 0.00 0.00 add_proc_unit + 0.00 34.74 0.00 3 0.00 0.00 can_charm + 0.00 34.74 0.00 3 0.00 0.00 changerace_read + 0.00 34.74 0.00 3 0.00 0.00 count_particles + 0.00 34.74 0.00 3 0.00 0.00 gamedate2 + 0.00 34.74 0.00 3 0.00 0.00 getplaneid + 0.00 34.74 0.00 3 0.00 0.00 give_control + 0.00 34.74 0.00 3 0.00 0.00 init_group + 0.00 34.74 0.00 3 0.00 0.00 init_locales + 0.00 34.74 0.00 3 0.00 0.00 parse_param + 0.00 34.74 0.00 3 0.00 0.00 racelist_insert + 0.00 34.74 0.00 3 0.00 0.00 register_item_give + 0.00 34.74 0.00 3 0.00 0.00 register_reporttype + 0.00 34.74 0.00 3 0.00 0.00 report_failed_spell + 0.00 34.74 0.00 3 0.00 0.00 sp_charmingsong + 0.00 34.74 0.00 3 0.00 0.00 sp_eternizewall + 0.00 34.74 0.00 3 0.00 0.00 sp_song_of_peace + 0.00 34.74 0.00 3 0.00 0.00 target_resists_magic + 0.00 34.74 0.00 3 0.00 0.00 trigger_changerace + 0.00 34.74 0.00 3 0.00 0.00 update_nmrs + 0.00 34.74 0.00 3 0.00 0.00 use_healingpotion + 0.00 34.74 0.00 3 0.00 0.00 write_skill + 0.00 34.74 0.00 2 0.00 0.00 b_blockquestportal + 0.00 34.74 0.00 2 0.00 0.00 b_fvisible + 0.00 34.74 0.00 2 0.00 0.00 b_namequestportal + 0.00 34.74 0.00 2 0.00 0.00 b_opaque + 0.00 34.74 0.00 2 0.00 0.00 breedtrees + 0.00 34.74 0.00 2 0.00 0.00 claim_cmd + 0.00 34.74 0.00 2 0.00 0.00 create_directories + 0.00 34.74 0.00 2 0.00 0.00 create_ship + 0.00 34.74 0.00 2 0.00 0.00 disable_feature + 0.00 34.74 0.00 2 0.00 0.00 free_summary + 0.00 34.74 0.00 2 0.00 0.00 game_id + 0.00 34.74 0.00 2 0.00 0.00 giveitem_init + 0.00 34.74 0.00 2 0.00 0.00 giveitem_write + 0.00 34.74 0.00 2 0.00 0.00 init_directions + 0.00 34.74 0.00 2 0.00 0.00 init_keywords + 0.00 34.74 0.00 2 0.00 0.00 init_locale + 0.00 34.74 0.00 2 0.00 0.00 init_options_translation + 0.00 34.74 0.00 2 0.00 0.00 init_parameters + 0.00 34.74 0.00 2 0.00 0.00 init_skills + 0.00 34.74 0.00 2 0.00 0.00 init_terrains_translation + 0.00 34.74 0.00 2 0.00 0.00 json_keyword + 0.00 34.74 0.00 2 0.00 0.00 limit_mallornseeds + 0.00 34.74 0.00 2 0.00 0.00 log_create + 0.00 34.74 0.00 2 0.00 0.00 make_skillmod + 0.00 34.74 0.00 2 0.00 0.00 new_ship + 0.00 34.74 0.00 2 0.00 0.00 register_item_useonother + 0.00 34.74 0.00 2 0.00 0.00 register_special_direction + 0.00 34.74 0.00 2 0.00 0.00 remove_building + 0.00 34.74 0.00 2 0.00 0.00 report_summary + 0.00 34.74 0.00 2 0.00 0.00 res_changehp + 0.00 34.74 0.00 2 0.00 0.00 sp_bloodsacrifice + 0.00 34.74 0.00 2 0.00 0.00 sp_igjarjuk + 0.00 34.74 0.00 2 0.00 0.00 sp_summon_familiar + 0.00 34.74 0.00 2 0.00 0.00 sp_viewreality + 0.00 34.74 0.00 2 0.00 0.00 summon_allies + 0.00 34.74 0.00 2 0.00 0.00 tolua_eressea_open + 0.00 34.74 0.00 2 0.00 0.00 tolua_reg_types_eressea + 0.00 34.74 0.00 2 0.00 0.00 tolua_unit_open + 0.00 34.74 0.00 2 0.00 0.00 trigger_changefaction + 0.00 34.74 0.00 2 0.00 0.00 verbosity_to_flags + 0.00 34.74 0.00 2 0.00 0.00 wormhole_age + 0.00 34.74 0.00 2 0.00 0.00 wormhole_read + 0.00 34.74 0.00 2 0.00 0.00 wormhole_write + 0.00 34.74 0.00 2 0.00 0.00 xml_readstrings + 0.00 34.74 0.00 1 0.00 0.00 a_finalizestring + 0.00 34.74 0.00 1 0.00 0.00 a_upgradekeys + 0.00 34.74 0.00 1 0.00 0.00 a_writekeys + 0.00 34.74 0.00 1 0.00 0.00 add_seen_faction + 0.00 34.74 0.00 1 0.00 0.00 age_borders + 0.00 34.74 0.00 1 0.00 0.00 age_illusion + 0.00 34.74 0.00 1 0.00 0.00 attrib_done + 0.00 34.74 0.00 1 0.00 0.00 b_read + 0.00 34.74 0.00 1 0.00 0.00 b_write + 0.00 34.74 0.00 1 0.00 0.00 bind_monsters + 0.00 34.74 0.00 1 0.00 0.00 caldera_handle + 0.00 34.74 0.00 1 0.00 0.00 caldera_read + 0.00 34.74 0.00 1 0.00 0.00 caldera_write + 0.00 34.74 0.00 1 0.00 0.00 calendar_cleanup + 0.00 34.74 0.00 1 0.00 0.00 chaos_register + 0.00 34.74 0.00 1 0.00 0.00 check_messages_exist + 0.00 34.74 0.00 1 0.00 0.01 clear_npc_orders + 0.00 34.74 0.00 1 0.00 0.00 clonedied_read + 0.00 34.74 0.00 1 0.00 0.00 clonedied_write + 0.00 34.74 0.00 1 0.00 0.02 config_parse + 0.00 34.74 0.00 1 0.00 0.02 config_read + 0.00 34.74 0.00 1 0.00 0.00 create_mage + 0.00 34.74 0.00 1 0.00 0.00 create_newfamiliar + 0.00 34.74 0.00 1 0.00 0.00 crmessage_done + 0.00 34.74 0.00 1 0.00 0.00 ct_checknames + 0.00 34.74 0.00 1 0.00 0.00 curses_done + 0.00 34.74 0.00 1 0.00 0.00 dazzle + 0.00 34.74 0.00 1 0.00 0.54 demographics + 0.00 34.74 0.00 1 0.00 0.00 destroy_road + 0.00 34.74 0.00 1 0.00 0.45 do_battles + 0.00 34.74 0.00 1 0.00 0.00 enable_keyword + 0.00 34.74 0.00 1 0.00 0.00 equipment_done + 0.00 34.74 0.00 1 0.00 0.46 eressea_read_game + 0.00 34.74 0.00 1 0.00 0.00 eressea_run + 0.00 34.74 0.00 1 0.00 0.36 eressea_write_game + 0.00 34.74 0.00 1 0.00 0.00 flyingship_age + 0.00 34.74 0.00 1 0.00 0.01 free_config + 0.00 34.74 0.00 1 0.00 0.00 free_functions + 0.00 34.74 0.00 1 0.00 0.00 free_functions + 0.00 34.74 0.00 1 0.00 0.00 free_locales + 0.00 34.74 0.00 1 0.00 0.00 fumble_default + 0.00 34.74 0.00 1 0.00 0.00 funhash + 0.00 34.74 0.00 1 0.00 0.01 game_done + 0.00 34.74 0.00 1 0.00 0.00 game_init + 0.00 34.74 0.00 1 0.00 0.00 get_arg + 0.00 34.74 0.00 1 0.00 0.00 get_translation + 0.00 34.74 0.00 1 0.00 0.00 giveitem_read + 0.00 34.74 0.00 1 0.00 0.00 has_limited_skills + 0.00 34.74 0.00 1 0.00 0.04 icebergs + 0.00 34.74 0.00 1 0.00 0.04 immigration + 0.00 34.74 0.00 1 0.00 0.00 init_data + 0.00 34.74 0.00 1 0.00 0.00 init_genrand + 0.00 34.74 0.00 1 0.00 0.00 init_itemtypes + 0.00 34.74 0.00 1 0.00 0.00 init_mallornseed + 0.00 34.74 0.00 1 0.00 0.00 init_oldpotions + 0.00 34.74 0.00 1 0.00 0.00 init_processor + 0.00 34.74 0.00 1 0.00 0.02 init_reports + 0.00 34.74 0.00 1 0.00 0.00 init_resources + 0.00 34.74 0.00 1 0.00 0.00 init_rules + 0.00 34.74 0.00 1 0.00 0.00 init_seed + 0.00 34.74 0.00 1 0.00 0.00 init_smithy + 0.00 34.74 0.00 1 0.00 0.00 init_terrains + 0.00 34.74 0.00 1 0.00 0.00 item_done + 0.00 34.74 0.00 1 0.00 0.00 json_disable_features + 0.00 34.74 0.00 1 0.00 0.00 json_include + 0.00 34.74 0.00 1 0.00 0.00 json_keywords + 0.00 34.74 0.00 1 0.00 0.00 json_prefixes + 0.00 34.74 0.00 1 0.00 0.02 json_settings + 0.00 34.74 0.00 1 0.00 0.00 json_terrains + 0.00 34.74 0.00 1 0.00 0.00 kernel_done + 0.00 34.74 0.00 1 0.00 0.00 kernel_init + 0.00 34.74 0.00 1 0.00 0.00 levitate_ship + 0.00 34.74 0.00 1 0.00 0.00 load_inifile + 0.00 34.74 0.00 1 0.00 0.00 locale_init + 0.00 34.74 0.00 1 0.00 0.00 log_close + 0.00 34.74 0.00 1 0.00 0.00 log_open + 0.00 34.74 0.00 1 0.00 0.00 log_rotate + 0.00 34.74 0.00 1 0.00 0.00 log_to_file + 0.00 34.74 0.00 1 0.00 0.00 lua_done + 0.00 34.74 0.00 1 0.00 0.00 lua_init + 0.00 34.74 0.00 1 0.00 0.00 make_familiar + 0.00 34.74 0.00 1 0.00 0.00 make_locales + 0.00 34.74 0.00 1 0.00 0.00 make_matmod + 0.00 34.74 0.00 1 0.00 0.00 make_wormhole + 0.00 34.74 0.00 1 0.00 0.00 make_wormholes + 0.00 34.74 0.00 1 0.00 0.00 make_zombie + 0.00 34.74 0.00 1 0.00 0.00 message_done + 0.00 34.74 0.00 1 0.00 0.07 monthly_healing + 0.00 34.74 0.00 1 0.00 0.00 mt_clear + 0.00 34.74 0.00 1 0.00 0.04 new_units + 0.00 34.74 0.00 1 0.00 0.00 nmr_death + 0.00 34.74 0.00 1 0.00 0.00 nmr_warnings + 0.00 34.74 0.00 1 0.00 0.00 oldfamiliars + 0.00 34.74 0.00 1 0.00 0.00 openlibs + 0.00 34.74 0.00 1 0.00 0.00 parse_args + 0.00 34.74 0.00 1 0.00 0.00 parse_buildings + 0.00 34.74 0.00 1 0.00 0.00 parse_calendar + 0.00 34.74 0.00 1 0.00 0.00 parse_config + 0.00 34.74 0.00 1 0.00 0.00 parse_equipment + 0.00 34.74 0.00 1 0.00 0.00 parse_inifile + 0.00 34.74 0.00 1 0.00 0.00 parse_messages + 0.00 34.74 0.00 1 0.00 0.00 parse_races + 0.00 34.74 0.00 1 0.00 0.00 parse_resources + 0.00 34.74 0.00 1 0.00 0.00 parse_rules + 0.00 34.74 0.00 1 0.00 0.00 parse_ships + 0.00 34.74 0.00 1 0.00 0.00 parse_spellbooks + 0.00 34.74 0.00 1 0.00 0.00 parse_spells + 0.00 34.74 0.00 1 0.00 0.00 parse_strings + 0.00 34.74 0.00 1 0.00 0.00 pathfinder_cleanup + 0.00 34.74 0.00 1 0.00 0.53 plan_monsters + 0.00 34.74 0.00 1 0.00 0.00 plant + 0.00 34.74 0.00 1 0.00 0.00 planttrees + 0.00 34.74 0.00 1 0.00 5.61 processorders + 0.00 34.74 0.00 1 0.00 0.00 produce_mallornseeds + 0.00 34.74 0.00 1 0.00 0.00 promotion_cmd + 0.00 34.74 0.00 1 0.00 0.05 quit + 0.00 34.74 0.00 1 0.00 0.00 read_alliances + 0.00 34.74 0.00 1 0.00 0.00 read_borders + 0.00 34.74 0.00 1 0.00 0.00 read_building_reference + 0.00 34.74 0.00 1 0.00 0.46 read_game + 0.00 34.74 0.00 1 0.00 0.00 read_planes + 0.00 34.74 0.00 1 0.00 0.00 read_xml + 0.00 34.74 0.00 1 0.00 0.46 readgame + 0.00 34.74 0.00 1 0.00 0.65 readorders + 0.00 34.74 0.00 1 0.00 0.00 recruit_init + 0.00 34.74 0.00 1 0.00 0.00 register_arena + 0.00 34.74 0.00 1 0.00 0.00 register_artrewards + 0.00 34.74 0.00 1 0.00 0.00 register_attributes + 0.00 34.74 0.00 1 0.00 0.00 register_borders + 0.00 34.74 0.00 1 0.00 0.00 register_buildingcurse + 0.00 34.74 0.00 1 0.00 0.00 register_buildings + 0.00 34.74 0.00 1 0.00 0.00 register_cr + 0.00 34.74 0.00 1 0.00 0.00 register_demonseye + 0.00 34.74 0.00 1 0.00 0.00 register_flyingship + 0.00 34.74 0.00 1 0.00 0.00 register_gmcmd + 0.00 34.74 0.00 1 0.00 0.00 register_itemfunctions + 0.00 34.74 0.00 1 0.00 0.00 register_itemtypes + 0.00 34.74 0.00 1 0.00 0.00 register_magicresistance + 0.00 34.74 0.00 1 0.00 0.00 register_museum + 0.00 34.74 0.00 1 0.00 0.00 register_names + 0.00 34.74 0.00 1 0.00 0.00 register_nr + 0.00 34.74 0.00 1 0.00 0.00 register_race_description_function + 0.00 34.74 0.00 1 0.00 0.00 register_races + 0.00 34.74 0.00 1 0.00 0.00 register_regioncurse + 0.00 34.74 0.00 1 0.00 0.00 register_reports + 0.00 34.74 0.00 1 0.00 0.00 register_resources + 0.00 34.74 0.00 1 0.00 0.00 register_shipcurse + 0.00 34.74 0.00 1 0.00 0.00 register_spelldata + 0.00 34.74 0.00 1 0.00 0.00 register_spells + 0.00 34.74 0.00 1 0.00 0.00 register_tolua_helpers + 0.00 34.74 0.00 1 0.00 0.00 register_triggers + 0.00 34.74 0.00 1 0.00 0.00 register_unitcurse + 0.00 34.74 0.00 1 0.00 0.00 register_weapons + 0.00 34.74 0.00 1 0.00 0.00 register_xerewards + 0.00 34.74 0.00 1 0.00 0.00 register_xmas + 0.00 34.74 0.00 1 0.00 0.00 register_xmlreader + 0.00 34.74 0.00 1 0.00 0.03 remove_idle_players + 0.00 34.74 0.00 1 0.00 0.00 removelist + 0.00 34.74 0.00 1 0.00 0.00 renumber_factions + 0.00 34.74 0.00 1 0.00 0.00 report_donations + 0.00 34.74 0.00 1 0.00 0.00 report_failure + 0.00 34.74 0.00 1 0.00 0.00 report_spell + 0.00 34.74 0.00 1 0.00 18.69 reports + 0.00 34.74 0.00 1 0.00 0.00 reports_done + 0.00 34.74 0.00 1 0.00 0.00 resolve + 0.00 34.74 0.00 1 0.00 0.00 resolve_building + 0.00 34.74 0.00 1 0.00 0.00 select_familiar + 0.00 34.74 0.00 1 0.00 0.00 select_wormhole_regions + 0.00 34.74 0.00 1 0.00 0.00 setup_signal_handler + 0.00 34.74 0.00 1 0.00 0.00 shipcurse_flyingship + 0.00 34.74 0.00 1 0.00 0.00 sort_wormhole_regions + 0.00 34.74 0.00 1 0.00 0.00 sp_enterastral + 0.00 34.74 0.00 1 0.00 0.00 sp_flying_ship + 0.00 34.74 0.00 1 0.00 0.00 sp_generous + 0.00 34.74 0.00 1 0.00 0.00 sp_holyground + 0.00 34.74 0.00 1 0.00 0.00 sp_seduce + 0.00 34.74 0.00 1 0.00 0.00 sp_summonshadowlords + 0.00 34.74 0.00 1 0.00 0.01 spawn_braineaters + 0.00 34.74 0.00 1 0.00 0.01 spawn_undead + 0.00 34.74 0.00 1 0.00 0.00 t_add + 0.00 34.74 0.00 1 0.00 0.00 tolua_bind_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_bindings_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_building_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_config_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_dict_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_faction_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_game_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_gmtool_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_locale_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_log_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_message_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_order_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_process_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_reg_types_config + 0.00 34.74 0.00 1 0.00 0.00 tolua_reg_types_game + 0.00 34.74 0.00 1 0.00 0.00 tolua_reg_types_locale + 0.00 34.74 0.00 1 0.00 0.00 tolua_reg_types_log + 0.00 34.74 0.00 1 0.00 0.00 tolua_reg_types_process + 0.00 34.74 0.00 1 0.00 0.00 tolua_reg_types_settings + 0.00 34.74 0.00 1 0.00 0.00 tolua_region_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_settings_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_ship_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_sqlite_open + 0.00 34.74 0.00 1 0.00 0.00 tolua_storage_open + 0.00 34.74 0.00 1 0.00 0.00 translation_done + 0.00 34.74 0.00 1 0.00 0.00 translation_init + 0.00 34.74 0.00 1 0.00 0.00 trigger_giveitem + 0.00 34.74 0.00 1 0.00 0.00 trigger_shock + 0.00 34.74 0.00 1 0.00 0.03 update_spells + 0.00 34.74 0.00 1 0.00 0.00 use_skillpotion + 0.00 34.74 0.00 1 0.00 0.00 valid_race + 0.00 34.74 0.00 1 0.00 0.00 version_no + 0.00 34.74 0.00 1 0.00 0.00 volcano_update + 0.00 34.74 0.00 1 0.00 0.00 wormholes_register + 0.00 34.74 0.00 1 0.00 0.00 wormholes_update + 0.00 34.74 0.00 1 0.00 0.00 write_alliances + 0.00 34.74 0.00 1 0.00 0.00 write_borders + 0.00 34.74 0.00 1 0.00 0.00 write_planes + 0.00 34.74 0.00 1 0.00 0.35 writegame + 0.00 34.74 0.00 1 0.00 0.00 writepasswd + 0.00 34.74 0.00 1 0.00 0.00 writeturn + 0.00 34.74 0.00 1 0.00 0.00 xml_done + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + + Call graph (explanation follows) + + +granularity: each sample hit covers 2 byte(s) for 0.03% of 34.74 seconds + +index % time self children called name + +[1] 53.9 0.00 18.72 tolua_write_reports [1] + 0.00 18.69 1/1 reports [2] + 0.00 0.02 1/1 init_reports [399] +----------------------------------------------- + 0.00 18.69 1/1 tolua_write_reports [1] +[2] 53.8 0.00 18.69 1 reports [2] + 0.00 18.67 232/232 write_reports [3] + 0.00 0.02 1/6 remove_empty_units [146] + 0.00 0.00 1/1 report_donations [725] + 0.00 0.00 232/232 write_script [853] + 0.00 0.00 1/573 join_path [1016] + 0.00 0.00 1/564 reportpath [1063] + 0.00 0.00 1/64 log_info [1339] +----------------------------------------------- + 0.00 18.67 232/232 reports [2] +[3] 53.7 0.00 18.67 232 write_reports [3] + 0.77 6.37 230/230 report_plaintext [4] + 3.91 0.70 232/232 prepare_report [8] + 0.96 3.25 230/230 report_computer [9] + 0.96 0.53 232/232 get_addresses [20] + 0.88 0.00 232/232 finish_reports [33] + 0.27 0.06 99/99 report_template [87] + 0.00 0.00 559/5100840 itoa36 [116] + 0.00 0.00 559/573 join_path [1016] + 0.00 0.00 559/564 reportpath [1063] + 0.00 0.00 232/1295787 factionname [247] + 0.00 0.00 232/49235 log_debug [1245] +----------------------------------------------- + 0.77 6.37 230/230 write_reports [3] +[4] 20.6 0.77 6.37 230 report_plaintext [4] + 0.02 2.96 1344397/1344397 nr_unit [11] + 0.05 0.77 127676/127676 describe [35] + 0.03 0.77 78504/79180 rp_messages [36] + 0.29 0.13 453309/1437425 cansee [22] + 0.02 0.40 33139/33139 statistics [70] + 0.03 0.31 35287/35287 prices [85] + 0.01 0.21 180598/180598 nr_ship [111] + 0.01 0.12 113592/113592 nr_building [141] + 0.02 0.04 62581/62581 guards [229] + 0.04 0.00 21341107/50553492 stealth_modifier [188] + 0.01 0.03 127676/127676 write_travelthru [327] + 0.00 0.02 230/230 allies [419] + 0.02 0.00 78274/130250 r_getmessages [360] + 0.00 0.01 2081/2081 nr_spell [507] + 0.00 0.01 230/230 rp_battles [618] + 0.00 0.01 230/481 count_units [487] + 0.00 0.01 230/967 count_all [357] + 0.00 0.01 230/461 maxheroes [492] + 0.00 0.01 229/229 list_address [635] + 0.00 0.00 226/457 countheroes [572] + 0.00 0.00 293098/2494242 newline [594] + 0.00 0.00 1080/1380398 nr_render [25] + 0.00 0.00 23/45 count_maxmigrants [730] + 0.00 0.00 23/45 count_migrants [731] + 0.00 0.00 54055/2605004 rpeasants [435] + 0.00 0.00 62581/163027 markets_module [748] + 0.00 0.00 5009/24887945 locale_string [27] + 0.00 0.00 1080/967784 msg_message [132] + 0.00 0.00 162/786 average_score_of_age [777] + 0.00 0.00 4967/34611296 strlcpy [45] + 0.00 0.00 230/230 gamedate_season [944] + 0.00 0.00 3437/37931 centre [789] + 0.00 0.00 460/71815034 get_race [12] + 0.00 0.00 5871/36653945 wrptr [178] + 0.00 0.00 230/1295787 factionname [247] + 0.00 0.00 1539/13259934 resourcename [233] + 0.00 0.00 567/4133717 mkname [261] + 0.00 0.00 230/2818494 rc_name_s [260] + 0.00 0.00 460/51974272 a_find [65] + 0.00 0.00 230/462 game_name [1168] + 0.00 0.00 324/1572 write_score [1135] + 0.00 0.00 460/20836359 f_get_alliance [455] + 0.00 0.00 1/3902878 get_monsters [293] + 0.00 0.00 230/1214 rule_faction_limit [1331] + 0.00 0.00 128596/128596 check_errno [1432] + 0.00 0.00 127906/128135 rpline [1433] + 0.00 0.00 9147/9147 merge_messages [1517] + 0.00 0.00 9147/9147 split_messages [1518] + 0.00 0.00 1080/1009028 msg_release [1373] + 0.00 0.00 460/40692 get_gamedate [1466] + 0.00 0.00 337/1582 resource2potion [1569] +----------------------------------------------- + +[5] 16.2 0.00 5.64 tolua_process_orders [5] + 0.00 5.61 1/1 processorders [6] + 0.03 0.00 1/1 reset_game [356] +----------------------------------------------- + 0.00 5.61 1/1 tolua_process_orders [5] +[6] 16.2 0.00 5.61 1 processorders [6] + 0.47 5.00 1/1 process [7] + 0.04 0.05 1/1 ageing [185] + 0.00 0.03 1/1 update_spells [381] + 0.00 0.02 1/6 remove_empty_units [146] + 0.00 0.00 1/1 wormholes_update [906] + 0.00 0.00 1/1 init_processor [1310] + 0.00 0.00 2/4984610 config_get_int [348] + 0.00 0.00 1/64 log_info [1339] +----------------------------------------------- + 0.47 5.00 1/1 processorders [6] +[7] 15.7 0.47 5.00 1 process [7] + 0.00 1.07 178254/178254 produce [29] + 0.04 0.57 1/1 movement [47] + 0.00 0.54 1/1 demographics [50] + 0.00 0.45 1/1 do_battles [63] + 0.02 0.34 178254/178254 economics [78] + 0.04 0.27 1/1 randomevents [91] + 0.29 0.00 31172689/55492327 getkeyword [54] + 0.03 0.21 417808/417808 study_cmd [105] + 0.00 0.12 534762/534762 enter_1 [145] + 0.01 0.10 1/1 magic [157] + 0.00 0.09 799/799 setstealth_cmd [182] + 0.00 0.07 1/1 monthly_healing [215] + 0.00 0.06 595478/595478 monster_kills_peasants [230] + 0.03 0.02 1/1 defaultorders [249] + 0.04 0.01 178254/178254 do_contact [250] + 0.01 0.04 595896/595896 update_long_order [270] + 0.00 0.05 5384/5384 teach_cmd [272] + 0.00 0.05 1/1 quit [276] + 0.00 0.04 1/1 new_units [282] + 0.00 0.04 131765/131765 give_control_cmd [287] + 0.00 0.04 178254/178254 enter_2 [295] + 0.00 0.04 35708/35708 reserve_cmd [324] + 0.00 0.04 35708/35708 reserve_self [325] + 0.02 0.02 595898/595898 follow_unit [331] + 0.01 0.02 178254/178254 maintain_buildings [339] + 0.01 0.02 1/1 regenerate_aura [346] + 0.02 0.01 1/1 restack_units [353] + 0.00 0.03 10600/10600 make_cmd [383] + 0.01 0.01 178254/178254 sinkships [475] + 0.00 0.01 438223/71815034 get_race [12] + 0.01 0.00 178254/178254 do_siege [515] + 0.00 0.00 30554/30554 guard_on_cmd [656] + 0.00 0.00 435900/1629412 LongHunger [536] + 0.00 0.00 30634/30634 guard_off_cmd [711] + 0.00 0.00 236/236 leave_cmd [721] + 0.00 0.00 178254/178254 split_allocations [743] + 0.00 0.00 439954/129167539 u_race [89] + 0.00 0.00 590/590 use_cmd [763] + 0.00 0.00 138/138 renumber_cmd [780] + 0.00 0.00 241/241 reshow_cmd [818] + 0.00 0.00 3117/3117 name_cmd [835] + 0.00 0.00 348/348 mail_cmd [844] + 0.00 0.00 2013/2013 display_cmd [859] + 0.00 0.00 791/791 ally_cmd [877] + 0.00 0.00 1/1 nmr_warnings [878] + 0.00 0.00 80/80 combatspell_cmd [898] + 0.00 0.00 1700/1700 status_cmd [904] + 0.00 0.00 1/1 promotion_cmd [917] + 0.00 0.00 621/621 group_cmd [985] + 0.00 0.00 1/1 renumber_factions [1156] + 0.00 0.00 6/6 send_cmd [1202] + 0.00 0.00 17/12246335 ct_find [114] + 0.00 0.00 2/2 claim_cmd [1242] + 0.00 0.00 17/10190660 get_curse [143] + 0.00 0.00 17/4201030 curse_active [543] + 0.00 0.00 68/49235 log_debug [1245] + 0.00 0.00 5588/59694 r_insectstalled [1446] + 0.00 0.00 17/651711 oldcursename [1381] + 0.00 0.00 5/5 free_group [1750] +----------------------------------------------- + 3.91 0.70 232/232 write_reports [3] +[8] 13.3 3.91 0.70 232 prepare_report [8] + 0.08 0.53 3066474/3398582 travelthru_map [41] + 0.00 0.03 3438/3438 prepare_lighthouse [340] + 0.00 0.02 596221/71815034 get_race [12] + 0.01 0.01 596221/745269 add_seen_nb [386] + 0.02 0.00 464/464 firstregion [485] + 0.00 0.00 596221/129167539 u_race [89] + 0.00 0.00 232/560926 bt_find [237] + 0.00 0.00 1/216069 config_token [794] + 0.00 0.00 3563/26995 inside_building [1486] + 0.00 0.00 464/464 lastregion [1601] + 0.00 0.00 232/2386892 config_changed [1352] +----------------------------------------------- + 0.96 3.25 230/230 write_reports [3] +[9] 12.1 0.96 3.25 230 report_computer [9] + 0.01 3.18 209572/209572 cr_output_region [10] + 0.00 0.02 230/230 report_crtypes [428] + 0.00 0.01 230/230 cr_find_address [602] + 0.00 0.01 230/967 count_all [357] + 0.00 0.01 230/461 maxheroes [492] + 0.00 0.01 723/61961 cr_output_messages [57] + 0.01 0.00 230/457 countheroes [572] + 0.00 0.00 1921/1921 show_allies_cr [661] + 0.00 0.00 230/230 write_translations [689] + 0.00 0.00 2081/2081 cr_reportspell [756] + 0.00 0.00 22/45 count_maxmigrants [730] + 0.00 0.00 22/45 count_migrants [731] + 0.00 0.00 460/11719 locale_name [568] + 0.00 0.00 1896/4434556 translate [75] + 0.00 0.00 162/786 average_score_of_age [777] + 0.00 0.00 2693/24887945 locale_string [27] + 0.00 0.00 1921/2277350 get_prefix [263] + 0.00 0.00 493/1826688 adjust_coordinates [234] + 0.00 0.00 1876/13259934 resourcename [233] + 0.00 0.00 337/32337529 hashstring [37] + 0.00 0.00 464/4133717 mkname [261] + 0.00 0.00 230/2818494 rc_name_s [260] + 0.00 0.00 460/51974272 a_find [65] + 0.00 0.00 230/12560453 rc_changed [256] + 0.00 0.00 230/462 game_name [1168] + 0.00 0.00 324/1572 write_score [1135] + 0.00 0.00 230/45860 print_items [938] + 0.00 0.00 493/18647447 getplane [596] + 0.00 0.00 230/230 show_alliances_cr [1248] + 0.00 0.00 230/20836359 f_get_alliance [455] + 0.00 0.00 1/68430117 rc_find [15] + 0.00 0.00 1/4984610 config_get_int [348] + 0.00 0.00 230/1214 rule_faction_limit [1331] + 0.00 0.00 493/3587241 pnormalize [1350] + 0.00 0.00 337/1582 resource2potion [1569] + 0.00 0.00 230/231 eressea_version [1624] + 0.00 0.00 230/230 reset_translations [1625] +----------------------------------------------- + 0.01 3.18 209572/209572 report_computer [9] +[10] 9.2 0.01 3.18 209572 cr_output_region [10] + 0.01 1.60 923671/923671 cr_output_unit_compat [18] + 0.36 0.16 550775/1437425 cansee [22] + 0.00 0.46 61238/61961 cr_output_messages [57] + 0.06 0.09 209572/209572 cr_borders [135] + 0.00 0.12 179761/179761 cr_output_ship [152] + 0.00 0.06 45630/45630 cr_output_resources [238] + 0.00 0.06 104830/104830 cr_output_building [239] + 0.00 0.04 102149/102149 cr_output_travelthru [298] + 0.01 0.02 427650/4434556 translate [75] + 0.00 0.03 102149/386740 cr_output_curses_compat [144] + 0.00 0.02 249624/4374788 visible_faction [68] + 0.01 0.01 427650/24887945 locale_string [27] + 0.01 0.00 51976/130250 r_getmessages [360] + 0.00 0.01 104830/593636 building_owner [232] + 0.00 0.01 36929/490896 wage [174] + 0.00 0.01 209572/1874928 terrain_name [226] + 0.01 0.00 211668/1826688 adjust_coordinates [234] + 0.00 0.00 77909/1552289 rname [200] + 0.00 0.00 36937/79772 entertainmoney [643] + 0.00 0.00 365/8892 astralregions [329] + 0.00 0.00 36937/669051 production [417] + 0.00 0.00 179761/3358315 ship_owner [438] + 0.00 0.00 218078/13259934 resourcename [233] + 0.00 0.00 119504/2605004 rpeasants [435] + 0.00 0.00 38612/987488 is_astral [479] + 0.00 0.00 37300/12246335 ct_find [114] + 0.00 0.00 37300/10190660 get_curse [143] + 0.00 0.00 36937/163027 markets_module [748] + 0.00 0.00 102149/50553492 stealth_modifier [188] + 0.00 0.00 36937/4666665 rmoney [452] + 0.00 0.00 211668/18647447 getplane [596] + 0.00 0.00 37300/4201030 curse_active [543] + 0.00 0.00 45630/45860 print_items [938] + 0.00 0.00 36937/21345834 skill_enabled [365] + 0.00 0.00 36937/1613387 rule_region_owners [1323] + 0.00 0.00 211668/3587241 pnormalize [1350] + 0.00 0.00 209572/209572 cr_region_header [1414] + 0.00 0.00 45630/1160345 rhorses [1369] + 0.00 0.00 37300/651711 oldcursename [1381] + 0.00 0.00 36929/515192 is_mourning [1392] + 0.00 0.00 311/109377 free_regionlist [1436] +----------------------------------------------- + 0.02 2.96 1344397/1344397 report_plaintext [4] +[11] 8.6 0.02 2.96 1344397 nr_unit [11] + 0.03 1.85 1344359/1348743 bufunit [17] + 0.58 0.02 1344359/2742237 paragraph [26] + 0.43 0.03 1344359/1766225 nr_curses [48] + 0.01 0.00 1344359/51974272 a_find [65] + 0.01 0.00 1344359/2494242 newline [594] + 0.00 0.00 1344397/129167539 u_race [89] + 0.00 0.00 750517/1214628 is_allied [1368] + 0.00 0.00 373997/1380007 get_otherfaction [1362] +----------------------------------------------- + 0.00 0.00 1/71815034 sp_summonshadowlords [1034] + 0.00 0.00 1/71815034 rc_specialdamage [830] + 0.00 0.00 1/71815034 heal_factor [619] + 0.00 0.00 1/71815034 make_zombie [1267] + 0.00 0.00 1/71815034 is_migrant [1047] + 0.00 0.00 1/71815034 magic_lowskill [897] + 0.00 0.00 1/71815034 rc_skillmod [140] + 0.00 0.00 1/71815034 age_illusion [1308] + 0.00 0.00 2/71815034 omniscient [470] + 0.00 0.00 2/71815034 do_fumble [1062] + 0.00 0.00 2/71815034 sp_igjarjuk [923] + 0.00 0.00 2/71815034 skill_mod [264] + 0.00 0.00 3/71815034 guard_flags [690] + 0.00 0.00 3/71815034 cast_cmd [760] + 0.00 0.00 4/71815034 dissolve_units [241] + 0.00 0.00 4/71815034 age_firedragon [1123] + 0.00 0.00 5/71815034 age_dragon [1098] + 0.00 0.00 7/71815034 age_ghoul [1024] + 0.00 0.00 8/71815034 mod_elves_only [1239] + 0.00 0.00 10/71815034 chaos [848] + 0.00 0.00 10/71815034 spawn_dragons [411] + 0.00 0.00 12/71815034 sp_summonundead [896] + 0.00 0.00 15/71815034 steal_cmd [766] + 0.00 0.00 17/71815034 recruit_dracoids [837] + 0.00 0.00 17/71815034 age_zombie [1019] + 0.00 0.00 19/71815034 age_skeleton [1008] + 0.00 0.00 20/71815034 damage_unit [1044] + 0.00 0.00 20/71815034 spawn_seaserpent [831] + 0.00 0.00 31/71815034 random_unit [1174] + 0.00 0.00 38/71815034 sp_viewreality [784] + 0.00 0.00 42/71815034 loot_cmd [873] + 0.00 0.00 44/71815034 plan_dragon [273] + 0.00 0.00 44/71815034 build_road [950] + 0.00 0.00 56/71815034 use_bloodpotion [935] + 0.00 0.00 71/71815034 disband_men [999] + 0.00 0.00 93/71815034 report_summary [614] + 0.00 0.00 138/71815034 LongHunger [536] + 0.00 0.00 188/71815034 is_freezing [1088] + 0.00 0.00 247/71815034 spawn_undead [629] + 0.00 0.00 460/71815034 report_plaintext [4] + 0.00 0.00 489/71815034 make_fighter [424] + 0.00 0.00 639/71815034 spawn_braineaters [505] + 0.00 0.00 659/71815034 can_give_men [940] + 0.00 0.00 960/71815034 tax_cmd [697] + 0.00 0.00 1098/71815034 statistics [70] + 0.00 0.00 1689/71815034 recruit [650] + 0.00 0.00 1725/71815034 max_magicians [915] + 0.00 0.00 3743/71815034 battle_flee [352] + 0.00 0.00 5915/71815034 buy [707] + 0.00 0.00 7279/71815034 remove_empty_units_in_region [134] + 0.00 0.00 7560/71815034 drown [394] + 0.00 0.00 7957/71815034 magic_resistance [727] + 0.00 0.00 12787/71815034 canwalk [633] + 0.00 0.00 15763/71815034 sell [498] + 0.00 0.00 18304/71815034 average_score_of_age [777] + 0.00 0.00 23630/71815034 immigration [294] + 0.00 0.00 23993/71815034 guard_on_cmd [656] + 0.00 0.00 27694/71815034 dragon_affinity_value [516] + 0.00 0.00 84047/71815034 monster_move [129] + 0.00 0.00 96637/71815034 walkingcapacity [403] + 0.00 0.00 102606/71815034 give_cmd [102] + 0.00 0.00 105958/71815034 travel_route [147] + 0.00 0.00 116914/71815034 fleechance [408] + 0.00 0.00 120592/71815034 CavalryBonus [491] + 0.00 0.00 125515/71815034 default_wage [173] + 0.00 0.00 154155/71815034 terminate [242] + 0.00 0.01 221802/71815034 unitorders [46] + 0.00 0.01 236296/71815034 weapon_skill [221] + 0.00 0.01 335497/71815034 plan_monsters [52] + 0.00 0.01 417740/71815034 study_cmd [105] + 0.00 0.01 438223/71815034 process [7] + 0.00 0.01 463903/71815034 skilldiff [166] + 0.00 0.02 595472/71815034 age_unit [336] + 0.00 0.02 595476/71815034 demon_skillchanges [246] + 0.00 0.02 596221/71815034 prepare_report [8] + 0.00 0.02 783946/71815034 produce [29] + 0.00 0.03 1044674/71815034 get_food [88] + 0.01 0.04 1190864/71815034 magic [157] + 0.01 0.07 2383980/71815034 score [23] + 0.27 1.91 61440990/71815034 old_race [14] +[12] 7.3 0.31 2.23 71815034 get_race [12] + 0.07 2.16 67832617/68430117 rc_find [15] +----------------------------------------------- + +[13] 6.9 2.41 0.00 cb_find_top_i [13] +----------------------------------------------- + 0.00 0.00 133/2480226 income [885] + 0.00 0.00 249/2480226 plan_dragon [273] + 0.01 0.08 96316/2480226 movement_speed [155] + 0.09 1.04 1191719/2480226 score [23] + 0.09 1.04 1191809/2480226 make_summary [21] +[14] 6.8 0.19 2.17 2480226 old_race [14] + 0.27 1.91 61440990/71815034 get_race [12] +----------------------------------------------- + 0.00 0.00 1/68430117 report_computer [9] + 0.00 0.00 1/68430117 use_bloodpotion [935] + 0.00 0.00 2/68430117 parse_resources [1086] + 0.00 0.00 3/68430117 xml_readweapon [1266] + 0.00 0.00 6/68430117 tolua_unit_create [916] + 0.00 0.00 233/68430117 readfaction [767] + 0.00 0.02 597254/68430117 read_unit [74] + 0.07 2.16 67832617/68430117 get_race [12] +[15] 6.5 0.07 2.18 68430117 rc_find [15] + 2.18 0.00 68430117/68430271 rc_find_i [16] +----------------------------------------------- + 0.00 0.00 4/68430271 read_race_reference [1278] + 0.00 0.00 150/68430271 rc_get_or_create [1105] + 2.18 0.00 68430117/68430271 rc_find [15] +[16] 6.3 2.18 0.00 68430271 rc_find_i [16] +----------------------------------------------- + 0.00 0.01 4384/1348743 spunit [632] + 0.03 1.85 1344359/1348743 nr_unit [11] +[17] 5.4 0.03 1.85 1348743 bufunit [17] + 0.04 0.49 1953682/1953682 spskill [53] + 0.04 0.20 9318596/17451017 strlcpy_w [67] + 0.01 0.14 1350873/1351796 racename [133] + 0.00 0.13 1348743/4374788 visible_faction [68] + 0.03 0.10 704700/1405457 report_items [103] + 0.01 0.10 1187497/1205451 alliedfaction [162] + 0.00 0.08 494960/494960 buforder [201] + 0.01 0.07 1348743/2383101 unitname [142] + 0.00 0.06 598226/773191 hp_status [206] + 0.00 0.05 1145124/1295787 factionname [247] + 0.02 0.02 834439/24887945 locale_string [27] + 0.00 0.04 598226/598234 report_status [318] + 0.00 0.03 373172/9953180 alliedunit [31] + 0.01 0.02 1783118/12353561 report_item [106] + 0.02 0.00 1348743/2868601 u_irace [257] + 0.00 0.02 595139/597806 unit_get_spellbook [427] + 0.00 0.02 1348743/2272376 u_description [347] + 0.01 0.01 1348743/2275967 get_racename [368] + 0.02 0.00 6078454/36653945 wrptr [178] + 0.00 0.02 1348743/6610983 is_guard [211] + 0.01 0.00 1401002/51974272 a_find [65] + 0.00 0.01 1348743/1523708 uprivate [497] + 0.01 0.00 1045507/55492327 getkeyword [54] + 0.00 0.00 1045507/2985733 is_repeated [552] + 0.00 0.00 761036/4503145 omniscient [470] + 0.00 0.00 1348743/4835422 usiege [593] + 0.00 0.00 56643/56643 groupid [698] + 0.00 0.00 35516/86400 spell_name [646] + 0.00 0.00 597269/129167539 u_race [89] + 0.00 0.00 1187497/18647447 getplane [596] + 0.00 0.00 32943/34611296 strlcpy [45] + 0.00 0.00 1334/5358 max_spellpoints [755] + 0.00 0.00 4786/4875 get_combatspell [874] + 0.00 0.00 1265/1339 get_combatspelllevel [880] + 0.00 0.00 1334/12320804 effskill [100] + 0.00 0.00 1334/4915 get_spellpoints [872] + 0.00 0.00 401604/1380007 get_otherfaction [1362] +----------------------------------------------- + 0.01 1.60 923671/923671 cr_output_region [10] +[18] 4.6 0.01 1.60 923671 cr_output_unit_compat [18] + 0.12 1.48 923671/923671 cr_output_unit [19] +----------------------------------------------- + 0.12 1.48 923671/923671 cr_output_unit_compat [18] +[19] 4.6 0.12 1.48 923671 cr_output_unit [19] + 0.28 0.02 923633/1310373 cr_output_curses [69] + 0.11 0.17 3373083/4434556 translate [75] + 0.07 0.07 2768576/24887945 locale_string [27] + 0.02 0.10 700757/1405457 report_items [103] + 0.01 0.09 610341/610341 stream_order [167] + 0.10 0.00 9429681/10103290 stream_printf [158] + 0.00 0.09 923633/4374788 visible_faction [68] + 0.02 0.03 604957/12320804 effskill [100] + 0.00 0.04 603246/2934859 skillname [122] + 0.00 0.03 371101/9953180 alliedunit [31] + 0.01 0.02 1727391/12353561 report_item [106] + 0.00 0.02 923633/2275429 raceprefix [222] + 0.00 0.02 174965/773191 hp_status [206] + 0.01 0.01 925760/2818494 rc_name_s [260] + 0.02 0.00 923633/2868601 u_irace [257] + 0.00 0.01 923633/2272376 u_description [347] + 0.01 0.01 174965/279395 weight [459] + 0.00 0.01 923633/2275967 get_racename [368] + 0.00 0.01 923633/6610983 is_guard [211] + 0.00 0.01 923633/3351853 unit_getname [332] + 0.00 0.01 2246004/4503145 omniscient [470] + 0.00 0.01 716432/4133717 mkname [261] + 0.01 0.00 973220/51974272 a_find [65] + 0.01 0.00 695201/55492327 getkeyword [54] + 0.00 0.01 174965/1441945 is_mage [262] + 0.00 0.01 174965/2426021 get_mage [198] + 0.00 0.01 1711/1711 cr_output_spells [639] + 0.00 0.00 1100763/129167539 u_race [89] + 0.00 0.00 174965/7120688 get_money [187] + 0.00 0.00 923633/4835422 usiege [593] + 0.00 0.00 174965/174968 get_familiar_mage [722] + 0.00 0.00 174965/285923 ualias [692] + 0.00 0.00 174965/1523708 uprivate [497] + 0.00 0.00 705241/2155959 is_persistent [687] + 0.00 0.00 1711/5358 max_spellpoints [755] + 0.00 0.00 68497/2985733 is_repeated [552] + 0.00 0.00 1261/86400 spell_name [646] + 0.00 0.00 1711/4915 get_spellpoints [872] + 0.00 0.00 1637/8034 u_geteffstealth [919] + 0.00 0.00 2127/21345834 skill_enabled [365] + 0.00 0.00 603246/603246 level_days [1388] + 0.00 0.00 412396/1380007 get_otherfaction [1362] +----------------------------------------------- + 0.96 0.53 232/232 write_reports [3] +[20] 4.3 0.96 0.53 232 get_addresses [20] + 0.27 0.12 418124/1437425 cansee [22] + 0.00 0.08 854692/4374788 visible_faction [68] + 0.05 0.00 29110236/50553492 stealth_modifier [188] + 0.00 0.00 15708/15708 add_travelthru_addresses [673] + 0.00 0.00 464/20836359 f_get_alliance [455] + 0.00 0.00 453546/1214628 is_allied [1368] + 0.00 0.00 350020/353788 add_seen_faction_i [1401] + 0.00 0.00 232/232 transfer_seen [1622] +----------------------------------------------- + 0.04 0.69 1/2 tolua_init_summary [40] + 0.04 0.69 1/2 tolua_write_summary [38] +[21] 4.2 0.08 1.38 2 make_summary [21] + 0.09 1.04 1191809/2480226 old_race [14] + 0.03 0.05 1213526/12320804 effskill [100] + 0.01 0.04 351667/771861 armedmen [151] + 0.05 0.00 713016/1248014 listlen [190] + 0.00 0.02 703334/5395063 i_get [130] + 0.02 0.00 1543013/7120688 get_money [187] + 0.00 0.01 839681/3902878 get_monsters [293] + 0.00 0.00 454160/2605004 rpeasants [435] + 0.00 0.00 1191346/129167539 u_race [89] + 0.00 0.00 97652/4666665 rmoney [452] + 0.00 0.00 2/56052475 get_resourcetype [194] + 0.00 0.00 356508/1160345 rhorses [1369] + 0.00 0.00 201709/1511812 newterrain [1359] +----------------------------------------------- + 0.00 0.00 4/1437425 init_transportation [384] + 0.00 0.00 4/1437425 sp_generous [1040] + 0.00 0.00 4/1437425 seefaction [1117] + 0.00 0.00 8/1437425 caught_target [1003] + 0.00 0.00 12/1437425 sp_enterastral [1045] + 0.00 0.00 14/1437425 verify_unit [1028] + 0.00 0.00 30/1437425 sp_song_of_peace [939] + 0.00 0.00 35/1437425 mailunit [921] + 0.00 0.00 38/1437425 mail_cmd [844] + 0.00 0.00 39/1437425 deliverMail [966] + 0.00 0.00 70/1437425 can_give_to [600] + 0.00 0.00 81/1437425 can_guard [908] + 0.00 0.00 84/1437425 steal_cmd [766] + 0.00 0.00 109/1437425 set_factionstealth [183] + 0.00 0.00 197/1437425 report_action [860] + 0.00 0.00 397/1437425 is_guardian_u [626] + 0.00 0.00 752/1437425 monster_attack [764] + 0.00 0.00 816/1437425 follow_unit [331] + 0.00 0.00 1443/1437425 start_battle [297] + 0.01 0.00 11080/1437425 monster_attacks [248] + 0.27 0.12 418124/1437425 get_addresses [20] + 0.29 0.13 453309/1437425 report_plaintext [4] + 0.36 0.16 550775/1437425 cr_output_region [10] +[22] 3.9 0.93 0.42 1437425 cansee [22] + 0.07 0.10 2363341/12320804 effskill [100] + 0.00 0.12 1513189/1753922 invisible [139] + 0.02 0.07 960413/1188532 eff_stealth [163] + 0.00 0.01 1211531/6610983 is_guard [211] + 0.00 0.01 1335380/1474687 leftship [500] + 0.00 0.01 1335533/4503145 omniscient [470] + 0.00 0.00 2363341/21345834 skill_enabled [365] + 0.00 0.00 1335533/129167539 u_race [89] + 0.00 0.00 1156253/4835422 usiege [593] + 0.00 0.00 48/51974272 a_find [65] +----------------------------------------------- + 0.06 1.25 2/2 tolua_update_scores [24] +[23] 3.8 0.06 1.25 2 score [23] + 0.09 1.04 1191719/2480226 old_race [14] + 0.01 0.07 2383980/71815034 get_race [12] + 0.01 0.00 1191719/7120688 get_money [187] + 0.01 0.00 3903981/129167539 u_race [89] + 0.00 0.01 92368/593636 building_owner [232] + 0.00 0.00 462/786 average_score_of_age [777] + 0.00 0.00 38156/3358315 ship_owner [438] + 0.00 0.00 462/5100840 itoa36 [116] + 0.00 0.00 924/1572 write_score [1135] + 0.00 0.00 2/573 join_path [1016] + 0.00 0.00 356508/1613387 rule_region_owners [1323] + 0.00 0.00 2/9 basepath [1730] +----------------------------------------------- + +[24] 3.8 0.00 1.31 tolua_update_scores [24] + 0.06 1.25 2/2 score [23] +----------------------------------------------- + 0.00 0.00 1/1380398 sp_summon_familiar [1025] + 0.00 0.00 676/1380398 rp_battles [618] + 0.00 0.00 1080/1380398 report_plaintext [4] + 0.00 0.01 12729/1380398 cr_output_curses [69] + 0.00 0.01 15186/1380398 nr_curses_i [401] + 0.00 0.04 41255/1380398 log_orders [251] + 0.00 0.15 163573/1380398 describe [35] + 0.00 0.18 192618/1380398 statistics [70] + 0.00 0.23 247009/1380398 prices [85] + 0.00 0.28 301257/1380398 render_messages [58] + 0.00 0.38 405014/1380398 rp_messages [36] +[25] 3.7 0.00 1.28 1380398 nr_render [25] + 0.11 1.07 1380398/1380398 translate [28] + 0.04 0.03 1380398/5168717 nrt_find [98] + 0.03 0.00 1380398/34611296 strlcpy [45] +----------------------------------------------- + 0.00 0.00 1888/2742237 allies [419] + 0.00 0.00 2081/2742237 nr_spell_syntax [732] + 0.00 0.00 10794/2742237 list_address [635] + 0.01 0.00 15186/2742237 nr_curses_i [401] + 0.01 0.00 19851/2742237 nr_spell [507] + 0.01 0.00 27498/2742237 guards [229] + 0.02 0.00 35287/2742237 prices [85] + 0.02 0.00 55063/2742237 cb_write_travelthru [169] + 0.05 0.00 113592/2742237 nr_building [141] + 0.07 0.00 169255/2742237 describe [35] + 0.08 0.00 180598/2742237 nr_ship [111] + 0.16 0.01 361771/2742237 statistics [70] + 0.18 0.01 405014/2742237 rp_messages [36] + 0.58 0.02 1344359/2742237 nr_unit [11] +[26] 3.5 1.19 0.04 2742237 paragraph [26] + 0.04 0.00 7811581/7851812 write_spaces [303] +----------------------------------------------- + 0.00 0.00 1/24887945 sp_summon_familiar [1025] + 0.00 0.00 2/24887945 register_special_direction [1259] + 0.00 0.00 2/24887945 eval_unit [223] + 0.00 0.00 2/24887945 eval_unit_dative [1076] + 0.00 0.00 2/24887945 b_namequestportal [1279] + 0.00 0.00 2/24887945 create_ship [1014] + 0.00 0.00 2/24887945 new_ship [1229] + 0.00 0.00 8/24887945 display_item [1054] + 0.00 0.00 9/24887945 gamedate2 [1222] + 0.00 0.00 10/24887945 spawn_dragons [411] + 0.00 0.00 11/24887945 new_building [1059] + 0.00 0.00 14/24887945 findshiptype [869] + 0.00 0.00 22/24887945 init_options_translation [1157] + 0.00 0.00 26/24887945 init_directions [1143] + 0.00 0.00 36/24887945 init_terrains_translation [1129] + 0.00 0.00 44/24887945 curse_name [1140] + 0.00 0.00 54/24887945 findbuildingtype [866] + 0.00 0.00 78/24887945 eval_weight [1102] + 0.00 0.00 92/24887945 spawn_undead [629] + 0.00 0.00 93/24887945 report_summary [614] + 0.00 0.00 94/24887945 give_peasants [1060] + 0.00 0.00 99/24887945 piracy_cmd [660] + 0.00 0.00 133/24887945 travel [81] + 0.00 0.00 140/24887945 rp_battles [618] + 0.00 0.00 210/24887945 print_header [838] + 0.00 0.00 229/24887945 list_address [635] + 0.00 0.00 251/24887945 out_faction [615] + 0.00 0.00 264/24887945 init_translations [1033] + 0.00 0.00 282/24887945 init_locale [948] + 0.00 0.00 352/24887945 cr_resources [960] + 0.00 0.00 356/24887945 cr_race [949] + 0.00 0.00 446/24887945 print_items [938] + 0.00 0.00 490/24887945 build_building [696] + 0.00 0.00 495/24887945 display_race [963] + 0.00 0.00 527/24887945 make_movement_order [522] + 0.00 0.00 628/24887945 add_itemname_cb [980] + 0.00 0.00 648/24887945 add_resourcename_cb [977] + 0.00 0.00 666/24887945 generic_name [962] + 0.00 0.00 1150/24887945 gamedate_season [944] + 0.00 0.00 1188/24887945 follow_ship [749] + 0.00 0.00 1196/24887945 eval_localize [922] + 0.00 0.00 1490/24887945 eval_resources [907] + 0.00 0.00 1520/24887945 eval_race [882] + 0.00 0.00 1888/24887945 allies [419] + 0.00 0.00 2008/24887945 default_name [851] + 0.00 0.00 2073/24887945 cr_output_curses [69] + 0.00 0.00 2693/24887945 report_computer [9] + 0.00 0.00 3086/24887945 make_cmd [383] + 0.00 0.00 3203/24887945 cr_reportspell [756] + 0.00 0.00 4162/24887945 spell_info [841] + 0.00 0.00 4257/24887945 eval_trail [634] + 0.00 0.00 4762/24887945 nr_spell_syntax [732] + 0.00 0.00 5009/24887945 report_plaintext [4] + 0.00 0.00 5043/24887945 eval_ship [740] + 0.00 0.00 7336/24887945 battle_report [503] + 0.00 0.00 8758/24887945 print_stats [525] + 0.00 0.00 30518/24887945 nr_spell [507] + 0.00 0.00 31368/24887945 rp_messages [36] + 0.00 0.00 35368/24887945 cb_write_travelthru [169] + 0.00 0.00 54735/24887945 write_travelthru [327] + 0.00 0.00 55807/24887945 report_template [87] + 0.00 0.00 60360/24887945 guards [229] + 0.00 0.00 65837/24887945 show_allies [429] + 0.00 0.00 83723/24887945 monster_move [129] + 0.00 0.00 86400/24887945 spell_name [646] + 0.00 0.00 93450/24887945 b_nameroad [642] + 0.00 0.00 97017/24887945 cr_borders [135] + 0.00 0.00 104830/24887945 cr_output_building [239] + 0.00 0.00 110167/24887945 cr_resource [488] + 0.00 0.00 127788/24887945 eval_direction [608] + 0.00 0.00 133973/24887945 cycle_route [375] + 0.00 0.00 169153/24887945 statistics [70] + 0.00 0.00 174677/24887945 cr_output_resource [378] + 0.00 0.00 179761/24887945 cr_output_ship [152] + 0.01 0.01 227343/24887945 nr_building [141] + 0.01 0.01 247009/24887945 prices [85] + 0.01 0.01 373674/24887945 nr_ship [111] + 0.01 0.01 427650/24887945 cr_output_region [10] + 0.01 0.01 470529/24887945 eval_resource [328] + 0.01 0.01 537193/24887945 unit_getname [332] + 0.01 0.01 592664/24887945 spskill [53] + 0.01 0.01 598292/24887945 report_status [318] + 0.02 0.02 751188/24887945 rname [200] + 0.02 0.02 785221/24887945 trailinto [207] + 0.02 0.02 834439/24887945 bufunit [17] + 0.04 0.03 1460143/24887945 racename [133] + 0.04 0.04 1783118/24887945 report_item [106] + 0.05 0.04 1838265/24887945 describe [35] + 0.05 0.05 2006524/24887945 get_command [108] + 0.07 0.07 2768576/24887945 cr_output_unit [19] + 0.07 0.07 2934859/24887945 skillname [122] + 0.11 0.11 4488684/24887945 crtag [110] +[27] 3.4 0.61 0.58 24887945 locale_string [27] + 0.58 0.00 24887945/32337529 hashstring [37] +----------------------------------------------- + 0.11 1.07 1380398/1380398 nr_render [25] +[28] 3.4 0.11 1.07 1380398 translate [28] + 0.48 0.57 1379793/1380398 parse [333] + 0.01 0.00 1380398/13102790 opstack_pop [176] + 0.01 0.00 3656767/13399069 balloc [363] + 0.00 0.01 3656767/3656767 add_variable [607] + 0.00 0.00 605/1380398 parse_string [86] + 0.00 0.00 1380398/1380398 brelease [1360] + 0.00 0.00 1380398/1380398 free_variables [1361] +----------------------------------------------- + 0.00 1.07 178254/178254 process [7] +[29] 3.1 0.00 1.07 178254 produce [29] + 0.01 0.59 5494/5494 expandbuying [49] + 0.00 0.30 4629/4629 expandselling [93] + 0.00 0.05 178254/178254 expandwork [277] + 0.00 0.05 663/663 expandtax [278] + 0.00 0.02 783946/71815034 get_race [12] + 0.00 0.01 15797/15797 sell [498] + 0.00 0.01 11087/11087 do_work [612] + 0.00 0.01 178254/438629 maxworkingpeasants [473] + 0.00 0.01 11159/11159 expandentertainment [637] + 0.01 0.00 619614/55492327 getkeyword [54] + 0.00 0.00 16596/16596 entertain_cmd [665] + 0.00 0.00 361137/2605004 rpeasants [435] + 0.00 0.00 960/960 tax_cmd [697] + 0.00 0.00 793492/129167539 u_race [89] + 0.00 0.00 5916/5916 buy [707] + 0.00 0.00 356508/4666665 rmoney [452] + 0.00 0.00 189341/189341 rule_autowork [738] + 0.00 0.00 177/177 breed_cmd [741] + 0.00 0.00 111/111 steal_cmd [766] + 0.00 0.00 6133/472418 produceexp [322] + 0.00 0.00 41/41 expandstealing [807] + 0.00 0.00 36/36 expandloot [816] + 0.00 0.00 32679/32679 rule_auto_taxation [855] + 0.00 0.00 42/42 loot_cmd [873] + 0.00 0.00 349/349 research_cmd [886] + 0.00 0.00 6245/51974272 a_find [65] + 0.00 0.00 16/16 spy_cmd [990] + 0.00 0.00 17/12246335 ct_find [114] + 0.00 0.00 17/10190660 get_curse [143] + 0.00 0.00 1/560926 bt_find [237] + 0.00 0.00 17/4201030 curse_active [543] + 0.00 0.00 178254/204314 bt_changed [1415] + 0.00 0.00 4629/1511812 newterrain [1359] + 0.00 0.00 4139/59694 r_insectstalled [1446] + 0.00 0.00 344/75797 buildingtype_exists [1443] + 0.00 0.00 17/651711 oldcursename [1381] +----------------------------------------------- +[30] 3.0 0.48 0.57 1380398+20060311 [30] + 0.24 0.44 9544331 parse_symbol [42] + 0.21 0.12 2725583 parse_string [86] + 0.03 0.01 9170795 parse [333] +----------------------------------------------- + 0.00 0.00 2/9953180 find_piracy_target [967] + 0.00 0.00 79/9953180 can_guard [908] + 0.00 0.00 112/9953180 give_unit [952] + 0.00 0.00 112/9953180 mayboard [1046] + 0.00 0.00 131/9953180 caught_target [1003] + 0.00 0.00 215/9953180 mayenter [936] + 0.00 0.00 315/9953180 piracy_cmd [660] + 0.00 0.00 814/9953180 make_side [876] + 0.00 0.00 1104/9953180 get_friends [895] + 0.00 0.00 1198/9953180 check_ship_allowed [657] + 0.00 0.00 1432/9953180 start_battle [297] + 0.00 0.00 1613/9953180 sail [181] + 0.00 0.00 2033/9953180 join_allies [693] + 0.00 0.00 6140/9953180 bewegung_blockiert_von [631] + 0.00 0.00 6326/9953180 study_cmd [105] + 0.00 0.00 9353/9953180 teach_cmd [272] + 0.00 0.01 63046/9953180 is_guardian_u [626] + 0.00 0.01 102606/9953180 give_cmd [102] + 0.00 0.01 102705/9953180 can_give_to [600] + 0.00 0.01 111338/9953180 get_food [88] + 0.00 0.03 371101/9953180 cr_output_unit [19] + 0.00 0.03 373172/9953180 bufunit [17] + 0.01 0.11 1273750/9953180 get_pooled [104] + 0.03 0.26 3149695/9953180 use_pooled [39] + 0.05 0.36 4374788/9953180 visible_faction [68] +[31] 2.7 0.11 0.83 9953180 alliedunit [31] + 0.56 0.17 9004040/10375491 alliedgroup [34] + 0.05 0.00 5640296/51974272 a_find [65] + 0.03 0.01 9004040/20834979 autoalliance [179] + 0.00 0.00 9004040/18647447 getplane [596] +----------------------------------------------- +[32] 2.5 0.34 0.54 12320804+19159045 [32] + 0.04 0.46 7179154 get_modifier [55] + 0.25 0.01 10030400 effskill [100] + 0.01 0.06 7298034 skillmod [214] + 0.04 0.00 6907106 eff_skill [334] + 0.01 0.00 65155 sm_familiar [520] +----------------------------------------------- + 0.88 0.00 232/232 write_reports [3] +[33] 2.5 0.88 0.00 232 finish_reports [33] +----------------------------------------------- + 0.00 0.00 3/10375491 join_allies [693] + 0.00 0.00 27/10375491 allysfm [1122] + 0.00 0.00 55310/10375491 show_allies_cr [661] + 0.01 0.00 110660/10375491 show_allies [429] + 0.07 0.02 1205451/10375491 alliedfaction [162] + 0.56 0.17 9004040/10375491 alliedunit [31] +[34] 2.4 0.64 0.20 10375491 alliedgroup [34] + 0.03 0.08 10375461/10375461 AllianceRestricted [164] + 0.05 0.01 11830939/20834979 autoalliance [179] + 0.02 0.00 10375461/10375461 ally_mode [456] + 0.02 0.00 20750952/24935046 faction_alive [451] +----------------------------------------------- + 0.05 0.77 127676/127676 report_plaintext [4] +[35] 2.4 0.05 0.77 127676 describe [35] + 0.00 0.15 163573/1380398 nr_render [25] + 0.01 0.08 803645/950595 f_regionid [161] + 0.05 0.04 1838265/24887945 locale_string [27] + 0.07 0.00 169255/2742237 paragraph [26] + 0.00 0.06 765959/2225796 get_borders [120] + 0.00 0.06 638271/785221 trailinto [207] + 0.06 0.00 3045620/34611296 strlcpy [45] + 0.03 0.01 62581/108211 report_resources [210] + 0.04 0.00 127676/1766225 nr_curses [48] + 0.00 0.03 8525/8892 astralregions [329] + 0.01 0.02 163573/967784 msg_message [132] + 0.01 0.00 4194164/36653945 wrptr [178] + 0.00 0.00 127676/1874928 terrain_name [226] + 0.00 0.00 127676/669051 production [417] + 0.00 0.00 93452/190469 border_name [641] + 0.00 0.00 255350/51974272 a_find [65] + 0.00 0.00 179832/2605004 rpeasants [435] + 0.00 0.00 62581/987488 is_astral [479] + 0.00 0.00 255352/10053919 rtrees [302] + 0.00 0.00 222964/4666665 rmoney [452] + 0.00 0.00 164218/2494242 newline [594] + 0.00 0.00 96621/13259934 resourcename [233] + 0.00 0.00 96621/56052475 get_resourcetype [194] + 0.00 0.00 8515/12246335 ct_find [114] + 0.00 0.00 8515/10190660 get_curse [143] + 0.00 0.00 8515/4201030 curse_active [543] + 0.00 0.00 291/369586 r_connect [474] + 0.00 0.00 127676/1613387 rule_region_owners [1323] + 0.00 0.00 225630/1160345 rhorses [1369] + 0.00 0.00 163573/1009028 msg_release [1373] + 0.00 0.00 93452/93452 see_border [1440] + 0.00 0.00 93450/190467 b_transparent [1420] + 0.00 0.00 52156/515192 is_mourning [1392] + 0.00 0.00 8515/651711 oldcursename [1381] + 0.00 0.00 5680/109377 free_regionlist [1436] + 0.00 0.00 2/2 b_opaque [1772] +----------------------------------------------- + 0.00 0.01 676/79180 rp_battles [618] + 0.03 0.77 78504/79180 report_plaintext [4] +[36] 2.3 0.03 0.78 79180 rp_messages [36] + 0.00 0.38 405014/1380398 nr_render [25] + 0.02 0.20 3739100/3780355 nr_section [113] + 0.18 0.01 405014/2742237 paragraph [26] + 0.00 0.00 31368/24887945 locale_string [27] + 0.00 0.00 31368/37931 centre [789] + 0.00 0.00 62736/2494242 newline [594] +----------------------------------------------- + 0.00 0.00 6/32337529 get_or_create_locale [1275] + 0.00 0.00 337/32337529 report_computer [9] + 0.00 0.00 957/32337529 crt_register [1006] + 0.00 0.00 957/32337529 mt_register [1007] + 0.00 0.00 1909/32337529 nrt_register [883] + 0.00 0.00 2081/32337529 cr_reportspell [756] + 0.00 0.00 3496/32337529 locale_setstring [918] + 0.00 0.00 5588/32337529 get_locale [884] + 0.00 0.00 174677/32337529 cr_output_resource [378] + 0.01 0.00 301257/32337529 crt_find [321] + 0.02 0.00 779486/32337529 locale_getstring [266] + 0.02 0.00 1010116/32337529 mt_find [227] + 0.12 0.00 5168717/32337529 nrt_find [98] + 0.58 0.00 24887945/32337529 locale_string [27] +[37] 2.2 0.76 0.00 32337529 hashstring [37] +----------------------------------------------- + +[38] 2.1 0.00 0.74 tolua_write_summary [38] + 0.04 0.69 1/2 make_summary [21] + 0.00 0.01 2/2 report_summary [614] + 0.00 0.00 2/2 free_summary [1773] +----------------------------------------------- + 4060217 use_pooled [39] + 0.00 0.00 1/860263 breedtrees [1148] + 0.00 0.00 1/860263 promotion_cmd [917] + 0.00 0.00 1/860263 use_item [765] + 0.00 0.00 3/860263 use_healingpotion [1119] + 0.00 0.00 5/860263 give_horses [1108] + 0.00 0.00 21/860263 build_road [950] + 0.00 0.00 22/860263 give_money [484] + 0.00 0.00 38/860263 expandstealing [807] + 0.00 0.00 51/860263 potion_water_of_life [945] + 0.00 0.00 56/860263 use_bloodpotion [935] + 0.00 0.00 345/860263 end_potion [814] + 0.00 0.00 470/860263 pay_spell [805] + 0.00 0.00 1484/860263 build [691] + 0.00 0.00 1670/860263 do_recruiting [351] + 0.00 0.00 6386/860263 maintain [478] + 0.00 0.00 7475/860263 study_cmd [105] + 0.01 0.05 71328/860263 reserve_i [213] + 0.02 0.06 93824/860263 give_item [126] + 0.06 0.19 282676/860263 expandselling [93] + 0.08 0.26 394406/860263 expandbuying [49] +[39] 2.1 0.17 0.57 860263+4060217 use_pooled [39] + 0.03 0.26 3149695/9953180 alliedunit [31] + 0.02 0.14 4920480/8302761 get_resource [99] + 0.00 0.05 862087/931076 change_resource [240] + 0.03 0.01 4154050/4851739 get_reservation [281] + 0.01 0.00 4607888/7417541 urace [436] + 0.01 0.00 4920480/129167539 u_race [89] + 0.00 0.00 1/93120 change_reservation [1441] + 4060217 use_pooled [39] +----------------------------------------------- + +[40] 2.1 0.00 0.73 tolua_init_summary [40] + 0.04 0.69 1/2 make_summary [21] +----------------------------------------------- + 0.00 0.00 15708/3398582 add_travelthru_addresses [673] + 0.00 0.01 54735/3398582 write_travelthru [327] + 0.00 0.01 57367/3398582 count_travelthru [518] + 0.01 0.04 204298/3398582 cr_output_travelthru [298] + 0.08 0.53 3066474/3398582 prepare_report [8] +[41] 2.0 0.09 0.59 3398582 travelthru_map [41] + 0.29 0.00 18856320/18856320 cb_add_seen [94] + 0.00 0.10 1048274/1048274 cb_write_travelthru [169] + 0.02 0.06 967902/967902 cb_cr_travelthru_ship [204] + 0.02 0.04 1054200/1054200 count_cb [231] + 0.03 0.00 3398582/51974272 a_find [65] + 0.01 0.01 967902/967902 cb_cr_travelthru_unit [466] + 0.00 0.01 755575/755575 cb_add_address [598] +----------------------------------------------- + 3931390 parse_string [86] + 5612941 parse [333] +[42] 1.9 0.24 0.44 9544331 parse_symbol [42] + 0.01 0.06 799427/799427 eval_unit [223] + 0.00 0.05 515550/515550 eval_region [245] + 0.00 0.05 883617/883617 eval_int [268] + 0.04 0.00 4568249/4568249 find_variable [304] + 0.00 0.04 470529/470529 eval_resource [328] + 0.00 0.03 127674/127674 eval_trailto [369] + 0.03 0.00 4568249/13102790 opstack_push [202] + 0.00 0.02 843545/843545 eval_if [393] + 0.01 0.01 655564/655564 eval_eq [398] + 0.00 0.02 123513/123513 eval_order [472] + 0.01 0.00 67213/67213 eval_building [494] + 0.01 0.00 116804/116804 eval_isnull [517] + 0.01 0.00 163/163 eval_lt [539] + 0.01 0.00 4976082/4976082 find_function [549] + 0.00 0.01 127788/127788 eval_direction [608] + 0.00 0.01 108560/108560 eval_trail [634] + 0.00 0.00 40099/40099 eval_skill [671] + 0.00 0.00 46224/46224 eval_faction [685] + 0.00 0.00 25857/25857 eval_int36 [729] + 0.00 0.00 19545/19545 eval_ship [740] + 0.00 0.00 1520/1520 eval_race [882] + 0.00 0.00 834/834 eval_resources [907] + 0.00 0.00 1196/1196 eval_localize [922] + 0.00 0.00 604/604 eval_spell [961] + 0.00 0.00 124/124 eval_unit_dative [1076] + 0.00 0.00 78/78 eval_weight [1102] + 0.00 0.00 54/54 eval_add [1182] + 7791002 parse [333] +----------------------------------------------- + 0.00 0.65 1/1 tolua_read_orders [44] +[43] 1.9 0.00 0.65 1 readorders [43] + 0.02 0.59 221802/221802 unitorders [46] + 0.00 0.02 61643/1158076 getbuf [71] + 0.00 0.01 283446/2281756 gettoken [195] + 0.00 0.00 279151/1787006 findparam [458] + 0.00 0.00 283446/1311302 init_tokens_str [544] + 0.00 0.00 287/287 factionorders [983] + 0.00 0.00 2/64 log_info [1339] +----------------------------------------------- + +[44] 1.9 0.00 0.65 tolua_read_orders [44] + 0.00 0.65 1/1 readorders [43] +----------------------------------------------- + 0.00 0.00 12/34611296 register_spelldata [1250] + 0.00 0.00 15/34611296 check_dupe [1244] + 0.00 0.00 15/34611296 sp_summon_familiar [1025] + 0.00 0.00 22/34611296 dragon_name [1095] + 0.00 0.00 34/34611296 dracoid_name [1126] + 0.00 0.00 53/34611296 lua_getresource [1191] + 0.00 0.00 76/34611296 make_name [970] + 0.00 0.00 137/34611296 parse_spells [1120] + 0.00 0.00 527/34611296 make_movement_order [522] + 0.00 0.00 569/34611296 relpath [1061] + 0.00 0.00 1146/34611296 join_path [1016] + 0.00 0.00 1584/34611296 produce_resource [994] + 0.00 0.00 1667/34611296 add_recruits [371] + 0.00 0.00 2008/34611296 default_name [851] + 0.00 0.00 2478/34611296 write_spell_modifier [964] + 0.00 0.00 2622/34611296 nr_spell_syntax [732] + 0.00 0.00 2660/34611296 write_regionname [280] + 0.00 0.00 3111/34611296 sidename [867] + 0.00 0.00 3123/34611296 limit_resource [943] + 0.00 0.00 4921/34611296 nrt_register [883] + 0.00 0.00 4967/34611296 report_plaintext [4] + 0.00 0.00 6243/34611296 nr_spell [507] + 0.00 0.00 17417/34611296 teach_cmd [272] + 0.00 0.00 18788/34611296 sideabkz [745] + 0.00 0.00 32943/34611296 bufunit [17] + 0.00 0.00 54735/34611296 write_travelthru [327] + 0.00 0.00 62870/34611296 report_template [87] + 0.00 0.00 97114/34611296 guards [229] + 0.00 0.00 216694/34611296 racename [133] + 0.00 0.00 260073/34611296 nr_building [141] + 0.01 0.00 293954/34611296 show_allies [429] + 0.01 0.00 425391/34611296 create_order [341] + 0.01 0.00 529305/34611296 prices [85] + 0.01 0.00 532232/34611296 nr_ship [111] + 0.01 0.00 598234/34611296 report_status [318] + 0.01 0.00 785221/34611296 trailinto [207] + 0.02 0.00 950595/34611296 f_regionid [161] + 0.03 0.00 1380398/34611296 nr_render [25] + 0.06 0.00 3045620/34611296 describe [35] + 0.07 0.00 3889315/34611296 get_command [108] + 0.07 0.00 3931390/34611296 parse_string [86] + 0.32 0.00 17451017/34611296 strlcpy_w [67] +[45] 1.8 0.63 0.00 34611296 strlcpy [45] +----------------------------------------------- + 0.02 0.59 221802/221802 readorders [43] +[46] 1.8 0.02 0.59 221802 unitorders [46] + 0.00 0.36 1096433/1158076 getbuf [71] + 0.01 0.10 874634/1481407 parse_order [117] + 0.00 0.05 221802/221899 findunitg [279] + 0.02 0.01 984476/5387327 parse_token [125] + 0.00 0.01 221802/228907 getid [483] + 0.00 0.01 984476/1787006 findparam [458] + 0.00 0.01 221802/71815034 get_race [12] + 0.01 0.00 573389/55492327 getkeyword [54] + 0.00 0.00 573389/2985733 is_repeated [552] + 0.00 0.00 56948/1644867 free_orders [306] + 0.00 0.00 221802/129167539 u_race [89] + 0.00 0.00 395426/1936876 free_order [1356] +----------------------------------------------- + 0.04 0.57 1/1 process [7] +[47] 1.8 0.04 0.57 1 movement [47] + 0.00 0.44 103494/103784 move_cmd [66] + 0.03 0.01 1/1 move_pirates [326] + 0.03 0.00 1/1 move_hunters [342] + 0.01 0.02 1/1 init_transportation [384] + 0.02 0.00 1733187/55492327 getkeyword [54] + 0.00 0.01 178254/178254 drifting_ships [490] + 0.00 0.00 113702/115276 can_move [736] + 0.00 0.00 103494/1027665 init_order [613] + 0.00 0.00 17286/3358315 ship_owner [438] + 0.00 0.00 163/15102 cmistake [718] + 0.00 0.00 163/1291427 set_order [1365] +----------------------------------------------- + 0.04 0.00 113592/1766225 nr_building [141] + 0.04 0.00 127676/1766225 describe [35] + 0.06 0.00 180598/1766225 nr_ship [111] + 0.43 0.03 1344359/1766225 nr_unit [11] +[48] 1.7 0.57 0.04 1766225 nr_curses [48] + 0.00 0.02 1766225/1766225 nr_curses_i [401] + 0.00 0.01 113592/593636 building_owner [232] + 0.00 0.00 180598/3358315 ship_owner [438] +----------------------------------------------- + 0.01 0.59 5494/5494 produce [29] +[49] 1.7 0.01 0.59 5494 expandbuying [49] + 0.08 0.26 394406/860263 use_pooled [39] + 0.02 0.16 400300/541982 get_pooled [104] + 0.02 0.03 5484/10852 expandorders [197] + 0.01 0.00 788812/11241829 i_change [115] + 0.00 0.00 493465/51974272 a_find [65] + 0.00 0.00 394406/2186159 rsetmoney [553] + 0.00 0.00 11358/967784 msg_message [132] + 0.00 0.00 394406/4666665 rmoney [452] + 0.00 0.00 11358/392959 add_message [434] + 0.00 0.00 5679/451774 a_remove [366] + 0.00 0.00 5679/779419 a_add [555] + 0.00 0.00 5494/2605004 rpeasants [435] + 0.00 0.00 5494/56052475 get_resourcetype [194] + 0.00 0.00 11358/1009028 msg_release [1373] + 0.00 0.00 5679/779868 a_new [1376] +----------------------------------------------- + 0.00 0.54 1/1 process [7] +[50] 1.6 0.00 0.54 1 demographics [50] + 0.00 0.37 178254/178254 live [73] + 0.00 0.04 1/1 immigration [294] + 0.00 0.04 32670/32670 growing_herbs [300] + 0.01 0.03 32670/32670 horses [330] + 0.00 0.02 1/6 remove_empty_units [146] + 0.00 0.01 32670/32670 calculate_emigration [603] + 0.00 0.01 32670/32670 growing_trees [624] + 0.00 0.01 32670/490896 wage [174] + 0.00 0.00 32670/32670 peasants [658] + 0.00 0.00 65214/438629 maxworkingpeasants [473] + 0.00 0.00 32878/1336242 rng_injectable_double [396] + 0.00 0.00 120/120 plagues [781] + 0.00 0.00 32670/2605004 rpeasants [435] + 0.00 0.00 1/560926 bt_find [237] + 0.00 0.00 1/4984610 config_get_int [348] + 0.00 0.00 50673/50673 update_resources [1457] + 0.00 0.00 32670/32670 migrate [1478] + 0.00 0.00 208/75797 buildingtype_exists [1443] + 0.00 0.00 2/40692 get_gamedate [1466] +----------------------------------------------- + +[51] 1.5 0.00 0.53 tolua_planmonsters [51] + 0.00 0.53 1/1 plan_monsters [52] + 0.00 0.00 1/3902878 get_monsters [293] +----------------------------------------------- + 0.00 0.53 1/1 tolua_planmonsters [51] +[52] 1.5 0.00 0.53 1 plan_monsters [52] + 0.01 0.15 105106/105106 monster_move [129] + 0.02 0.07 313244/313244 check_overpopulated [184] + 0.04 0.01 160196/160206 monster_attacks [248] + 0.00 0.05 317735/317735 monster_learn [269] + 0.00 0.05 298/298 plan_dragon [273] + 0.04 0.00 432765/760673 addlist [217] + 0.00 0.03 419518/472418 produceexp [322] + 0.00 0.01 335497/71815034 get_race [12] + 0.00 0.01 595808/752645 chance [495] + 0.01 0.00 419518/1644867 free_orders [306] + 0.01 0.00 419518/1121103 monster_is_waiting [407] + 0.01 0.00 839036/51974272 a_find [65] + 0.00 0.00 419518/3902878 get_monsters [293] + 0.00 0.00 31277/447808 create_order [341] + 0.00 0.00 595142/129167539 u_race [89] + 0.00 0.00 417554/417554 random_move_chance [754] + 0.00 0.00 419518/21345834 skill_enabled [365] + 0.00 0.00 12762/6610983 is_guard [211] + 0.00 0.00 12984/748527 unit_can_study [709] + 0.00 0.00 44/12320804 effskill [100] + 0.00 0.00 44/2934859 skillname [122] + 0.00 0.00 40/451774 a_remove [366] + 0.00 0.00 1/717218 config_get_flt [714] + 0.00 0.00 315567/1342832 handle_event [1363] + 0.00 0.00 1/1 pathfinder_cleanup [1828] +----------------------------------------------- + 0.04 0.49 1953682/1953682 bufunit [17] +[53] 1.5 0.04 0.49 1953682 spskill [53] + 0.03 0.15 7046371/17451017 strlcpy_w [67] + 0.05 0.09 1953681/12320804 eff_skill [334] + 0.01 0.12 1953681/2934859 skillname [122] + 0.01 0.01 592664/24887945 locale_string [27] + 0.01 0.01 237880/12320804 get_modifier [55] + 0.01 0.00 1958340/36653945 wrptr [178] + 0.00 0.00 9493/2426021 get_mage [198] + 0.00 0.00 1551/8034 u_geteffstealth [919] + 0.00 0.00 1088/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 24/55492327 is_moving_ship [1231] + 0.00 0.00 148/55492327 transport [1011] + 0.00 0.00 17417/55492327 teach_cmd [272] + 0.00 0.00 30554/55492327 guard_on_cmd [656] + 0.00 0.00 30634/55492327 guard_off_cmd [711] + 0.00 0.00 38489/55492327 move_pirates [326] + 0.00 0.00 85384/55492327 move_hunters [342] + 0.00 0.00 103187/55492327 cycle_route [375] + 0.00 0.00 151532/55492327 report_template [87] + 0.00 0.00 162752/55492327 travel_i [92] + 0.00 0.00 204065/55492327 do_siege [515] + 0.01 0.00 573389/55492327 unitorders [46] + 0.01 0.00 619614/55492327 produce [29] + 0.01 0.00 692835/55492327 write_unit [97] + 0.01 0.00 695201/55492327 cr_output_unit [19] + 0.01 0.00 1045507/55492327 bufunit [17] + 0.01 0.00 1128316/55492327 magic [157] + 0.01 0.00 1129818/55492327 start_battle [297] + 0.01 0.00 1130203/55492327 restack_units [353] + 0.01 0.00 1131212/55492327 defaultorders [249] + 0.01 0.00 1132975/55492327 update_long_order [270] + 0.01 0.00 1133099/55492327 do_contact [250] + 0.01 0.00 1135305/55492327 follow_unit [331] + 0.01 0.00 1136686/55492327 new_units [282] + 0.02 0.00 1693146/55492327 init_transportation [384] + 0.02 0.00 1733187/55492327 movement [47] + 0.03 0.00 2855598/55492327 economics [78] + 0.04 0.00 4529361/55492327 do_enter [128] + 0.29 0.00 31172689/55492327 process [7] +[54] 1.5 0.52 0.00 55492327 getkeyword [54] +----------------------------------------------- + 6907105 eff_skill [334] + 0.00 0.00 34169/12320804 effskill_study [504] + 0.01 0.01 237880/12320804 spskill [53] +[55] 1.4 0.04 0.46 7179154 get_modifier [55] + 0.05 0.26 7179079/7179079 att_modification [90] + 0.00 0.14 7179079/7179079 rc_skillmod [140] + 0.02 0.00 7179079/129167539 u_race [89] + 0.00 0.00 1467202/18647447 getplane [596] + 7179079 skillmod [214] +----------------------------------------------- + +[56] 1.4 0.47 0.00 decode_pointer [56] +----------------------------------------------- + 0.00 0.01 723/61961 report_computer [9] + 0.00 0.46 61238/61961 cr_output_region [10] +[57] 1.3 0.00 0.46 61961 cr_output_messages [57] + 0.01 0.45 20176/20176 render_messages [58] +----------------------------------------------- + 0.01 0.45 20176/20176 cr_output_messages [57] +[58] 1.3 0.01 0.45 20176 render_messages [58] + 0.00 0.28 301257/1380398 nr_render [25] + 0.09 0.00 297222/297222 fwritestr [191] + 0.01 0.07 301257/301257 cr_render [196] + 0.00 0.00 297222/297222 messagehash [1405] +----------------------------------------------- + 0.00 0.46 1/1 tolua_eressea_eressea_read_game00 [61] +[59] 1.3 0.00 0.46 1 eressea_read_game [59] + 0.00 0.46 1/1 readgame [60] +----------------------------------------------- + 0.00 0.46 1/1 eressea_read_game [59] +[60] 1.3 0.00 0.46 1 readgame [60] + 0.00 0.46 1/1 read_game [62] + 0.00 0.00 1/3 init_locales [947] + 0.00 0.00 1/573 join_path [1016] + 0.00 0.00 1/5 datapath [1289] + 0.00 0.00 2/49235 log_debug [1245] +----------------------------------------------- + +[61] 1.3 0.00 0.46 tolua_eressea_eressea_read_game00 [61] + 0.00 0.46 1/1 eressea_read_game [59] +----------------------------------------------- + 0.00 0.46 1/1 readgame [60] +[62] 1.3 0.00 0.46 1 read_game [62] + 0.01 0.36 595125/595125 read_unit [74] + 0.00 0.08 178254/178254 readregion [209] + 0.00 0.01 9729/10232 update_lighthouse [605] + 0.00 0.00 46176/560926 bt_find [237] + 0.00 0.00 65258/840577 read_attribs [388] + 0.00 0.00 1/1 read_borders [706] + 0.00 0.00 595125/3383689 update_interval [551] + 0.00 0.00 1/1 resolve [757] + 0.00 0.00 233/233 readfaction [767] + 0.00 0.00 1/1 read_planes [1164] + 0.00 0.00 12/180818 buildingname [621] + 0.00 0.00 1/2 game_id [1324] + 0.00 0.00 182/49235 log_debug [1245] + 0.00 0.00 12/13 log_error [1340] + 0.00 0.00 46175/46196 bhash [1464] + 0.00 0.00 19082/19085 shash [1502] + 0.00 0.00 19082/19082 st_find [1503] + 0.00 0.00 233/233 fhash [1617] + 0.00 0.00 1/1 init_genrand [1809] + 0.00 0.00 1/1 read_alliances [1830] +----------------------------------------------- + 0.00 0.45 1/1 process [7] +[63] 1.3 0.00 0.45 1 do_battles [63] + 0.00 0.45 178254/178254 do_battle [64] + 0.00 0.00 1/1 init_rules [1272] +----------------------------------------------- + 0.00 0.45 178254/178254 do_battles [63] +[64] 1.3 0.00 0.45 178254 do_battle [64] + 0.00 0.35 574/574 battle_attacks [79] + 0.01 0.03 178254/178254 start_battle [297] + 0.00 0.03 574/574 battle_flee [352] + 0.01 0.00 780/780 battle_report [503] + 0.00 0.01 206/206 print_stats [525] + 0.00 0.00 206/206 join_allies [693] + 0.00 0.00 206/206 aftermath [701] + 0.00 0.00 206/206 print_header [838] + 0.00 0.00 206/412 do_combatmagic [825] + 0.00 0.00 206/361 regionname [987] + 0.00 0.00 206/207 rule_force_leave [1175] + 0.00 0.00 1/967784 msg_message [132] + 0.00 0.00 206/206 make_heroes [1298] + 0.00 0.00 206/49235 log_debug [1245] + 0.00 0.00 574/574 battle_update [1595] + 0.00 0.00 206/206 free_battle [1630] +----------------------------------------------- + 0.00 0.00 1/51974272 reshow_other [823] + 0.00 0.00 1/51974272 create_mage [1315] + 0.00 0.00 1/51974272 a_upgradekeys [1314] + 0.00 0.00 2/51974272 u_seteffstealth [1199] + 0.00 0.00 3/51974272 create_newfamiliar [1288] + 0.00 0.00 7/51974272 parse_resources [1086] + 0.00 0.00 9/51974272 melt_iceberg [1082] + 0.00 0.00 11/51974272 add_trigger [1260] + 0.00 0.00 12/51974272 volcano_destruction [1022] + 0.00 0.00 15/51974272 mail_cmd [844] + 0.00 0.00 26/51974272 set_new_dragon_target [486] + 0.00 0.00 27/51974272 move_iceberg [1094] + 0.00 0.00 48/51974272 cansee [22] + 0.00 0.00 58/51974272 tolua_dict_get [1218] + 0.00 0.00 62/51974272 potion_luck [1176] + 0.00 0.00 85/51974272 volcano_update [981] + 0.00 0.00 89/51974272 add_chaoscount [1198] + 0.00 0.00 104/51974272 set_factionstealth [183] + 0.00 0.00 115/51974272 usetcontact [1147] + 0.00 0.00 232/51974272 renumber_factions [1156] + 0.00 0.00 298/51974272 plan_dragon [273] + 0.00 0.00 324/51974272 caught_target [1003] + 0.00 0.00 328/51974272 display_potion [1090] + 0.00 0.00 348/51974272 ugetpotionuse [1133] + 0.00 0.00 380/51974272 set_group [1048] + 0.00 0.00 404/51974272 usetpotionuse [1078] + 0.00 0.00 460/51974272 report_computer [9] + 0.00 0.00 460/51974272 report_plaintext [4] + 0.00 0.00 631/51974272 follow_unit [331] + 0.00 0.00 664/51974272 ally_cmd [877] + 0.00 0.00 760/51974272 resolve_familiar [846] + 0.00 0.00 760/51974272 resolve_mage [856] + 0.00 0.00 793/51974272 is_familiar [1092] + 0.00 0.00 1297/51974272 hunted_dir [1055] + 0.00 0.00 1422/51974272 attrib_allocation [914] + 0.00 0.00 1429/51974272 start_battle [297] + 0.00 0.00 1573/51974272 usetprivate [1041] + 0.00 0.00 1593/51974272 make_fighter [424] + 0.00 0.00 1610/51974272 transfer_curse [1039] + 0.00 0.00 1725/51974272 max_magicians [915] + 0.00 0.00 1774/51974272 join_battle [425] + 0.00 0.00 2280/51974272 set_familiar [992] + 0.00 0.00 2421/51974272 set_racename [1015] + 0.00 0.00 2598/51974272 create_unit [296] + 0.00 0.00 2723/51974272 get_allocator [1001] + 0.00 0.00 2822/51974272 get_followers [254] + 0.00 0.00 2977/51974272 change_effect [982] + 0.00 0.00 3035/51974272 scale_number [969] + 0.00 0.00 3078/51974272 allocate_resource [752] + 0.00 0.00 3730/51974272 transfermen [899] + 0.00 0.00 4475/51974272 matmod [975] + 0.00 0.00 5049/51974272 find_piracy_target [967] + 0.00 0.00 5903/51974272 buy [707] + 0.00 0.00 5941/51974272 deathcounts [843] + 0.00 0.00 6245/51974272 produce [29] + 0.00 0.00 7815/51974272 already_seen [929] + 0.00 0.00 7957/51974272 magic_resistance [727] + 0.00 0.00 8034/51974272 u_geteffstealth [919] + 0.00 0.00 8144/51974272 ucontact [927] + 0.00 0.00 8246/51974272 horses [330] + 0.00 0.00 12520/51974272 sell [498] + 0.00 0.00 16132/51974272 teach_unit [426] + 0.00 0.00 23509/51974272 setguard [815] + 0.00 0.00 30250/51974272 peasants [658] + 0.00 0.00 31351/51974272 update_guards [415] + 0.00 0.00 32670/51974272 growing_trees [624] + 0.00 0.00 34221/51974272 eff_weight [683] + 0.00 0.00 35539/51974272 check_leuchtturm [786] + 0.00 0.00 39729/51974272 leave_trail [704] + 0.00 0.00 52551/51974272 update_lighthouse [605] + 0.00 0.00 54351/51974272 get_familiar [796] + 0.00 0.00 66058/51974272 shipspeed [669] + 0.00 0.00 71414/51974272 get_mage [198] + 0.00 0.00 116002/51974272 get_movement [750] + 0.00 0.00 116914/51974272 fleechance [408] + 0.00 0.00 169733/51974272 travelthru_add [609] + 0.00 0.00 172276/51974272 largestbuilding [651] + 0.00 0.00 174968/51974272 get_familiar_mage [722] + 0.00 0.00 178254/51974272 age_traveldir [720] + 0.00 0.00 178254/51974272 randomevents [91] + 0.00 0.00 178257/51974272 key_get [719] + 0.00 0.00 179235/51974272 get_chaoscount [717] + 0.00 0.00 255350/51974272 describe [35] + 0.00 0.00 285923/51974272 ualias [692] + 0.00 0.00 307833/51974272 default_wage [173] + 0.00 0.00 325282/51974272 eaten_by_monster [468] + 0.00 0.00 325825/51974272 scared_by_monster [380] + 0.00 0.00 329691/51974272 getguard [652] + 0.00 0.00 355423/51974272 deathcount [674] + 0.00 0.00 370844/51974272 expandselling [93] + 0.00 0.00 417739/51974272 study_cmd [105] + 0.00 0.00 493465/51974272 expandbuying [49] + 0.01 0.00 595441/51974272 destroyfaction [392] + 0.01 0.00 595476/51974272 dissolve_units [241] + 0.01 0.00 839036/51974272 plan_monsters [52] + 0.01 0.00 847828/51974272 raceprefix [222] + 0.01 0.00 973220/51974272 cr_output_unit [19] + 0.01 0.00 1115958/51974272 visible_faction [68] + 0.01 0.00 1344359/51974272 nr_unit [11] + 0.01 0.00 1401002/51974272 bufunit [17] + 0.01 0.00 1474687/51974272 leftship [500] + 0.01 0.00 1523708/51974272 uprivate [497] + 0.01 0.00 1646640/51974272 terrain_name [226] + 0.02 0.00 2275967/51974272 get_racename [368] + 0.02 0.00 2277350/51974272 get_prefix [263] + 0.02 0.00 2858912/51974272 get_effect [225] + 0.03 0.00 3398582/51974272 travelthru_map [41] + 0.05 0.00 5640296/51974272 alliedunit [31] + 0.06 0.00 7298034/51974272 skillmod [214] + 0.09 0.00 10322799/51974272 att_modification [90] +[65] 1.3 0.45 0.00 51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 99/103784 piracy_cmd [660] + 0.00 0.00 191/103784 follow_ship [749] + 0.00 0.44 103494/103784 movement [47] +[66] 1.3 0.00 0.45 103784 move_cmd [66] + 0.00 0.35 96529/96529 travel [81] + 0.01 0.09 7255/7255 sail [181] + 0.00 0.00 7269/3358315 ship_owner [438] + 0.00 0.00 103784/1291427 set_order [1365] + 0.00 0.00 103369/109377 free_regionlist [1436] +----------------------------------------------- + 0.00 0.00 211/17451017 display_race [963] + 0.00 0.00 1612/17451017 follow_ship [749] + 0.00 0.00 1799/17451017 print_header [838] + 0.00 0.00 4287/17451017 eval_trail [634] + 0.00 0.00 25201/17451017 battle_report [503] + 0.00 0.00 63020/17451017 cycle_route [375] + 0.00 0.02 989920/17451017 buforder [201] + 0.03 0.15 7046371/17451017 spskill [53] + 0.04 0.20 9318596/17451017 bufunit [17] +[67] 1.3 0.07 0.37 17451017 strlcpy_w [67] + 0.32 0.00 17451017/34611296 strlcpy [45] + 0.05 0.00 17451017/36653945 wrptr [178] +----------------------------------------------- + 0.00 0.00 8/4374788 spy_message [1038] + 0.00 0.00 315/4374788 piracy_cmd [660] + 0.00 0.01 67332/4374788 guards [229] + 0.00 0.01 74068/4374788 cb_add_address [598] + 0.00 0.02 249624/4374788 cr_output_region [10] + 0.00 0.08 854692/4374788 get_addresses [20] + 0.00 0.08 856373/4374788 set_factionstealth [183] + 0.00 0.09 923633/4374788 cr_output_unit [19] + 0.00 0.13 1348743/4374788 bufunit [17] +[68] 1.2 0.01 0.42 4374788 visible_faction [68] + 0.05 0.36 4374788/9953180 alliedunit [31] + 0.01 0.00 1115958/51974272 a_find [65] + 0.00 0.00 151469/1380007 get_otherfaction [1362] +----------------------------------------------- + 0.12 0.01 386740/1310373 cr_output_curses_compat [144] + 0.28 0.02 923633/1310373 cr_output_unit [19] +[69] 1.2 0.40 0.03 1310373 cr_output_curses [69] + 0.00 0.01 12729/1380398 nr_render [25] + 0.00 0.01 104830/593636 building_owner [232] + 0.00 0.00 12828/26045 msg_curse [664] + 0.00 0.00 179761/3358315 ship_owner [438] + 0.00 0.00 28167/10103290 stream_printf [158] + 0.00 0.00 2073/4434556 translate [75] + 0.00 0.00 2073/24887945 locale_string [27] + 0.00 0.00 2073/13259934 resourcename [233] + 0.00 0.00 12828/26045 curse_cansee [1489] + 0.00 0.00 12729/1009028 msg_release [1373] +----------------------------------------------- + 0.02 0.40 33139/33139 report_plaintext [4] +[70] 1.2 0.02 0.40 33139 statistics [70] + 0.00 0.18 192618/1380398 nr_render [25] + 0.16 0.01 361771/2742237 paragraph [26] + 0.01 0.02 192618/967784 msg_message [132] + 0.00 0.00 169153/24887945 locale_string [27] + 0.00 0.01 32354/490896 wage [174] + 0.01 0.00 347340/11241829 i_change [115] + 0.00 0.00 31155/560926 bt_find [237] + 0.00 0.00 31676/79772 entertainmoney [643] + 0.00 0.00 33139/669051 production [417] + 0.00 0.00 169153/13259934 resourcename [233] + 0.00 0.00 63509/163027 markets_module [748] + 0.00 0.00 144924/129167539 u_race [89] + 0.00 0.00 66278/2494242 newline [594] + 0.00 0.00 33139/2605004 rpeasants [435] + 0.00 0.00 31725/4666665 rmoney [452] + 0.00 0.00 33139/21345834 skill_enabled [365] + 0.00 0.00 1098/71815034 get_race [12] + 0.00 0.00 192618/1009028 msg_release [1373] + 0.00 0.00 169153/257723 i_remove [1407] + 0.00 0.00 169153/374425 i_free [1400] + 0.00 0.00 31155/75797 buildingtype_exists [1443] +----------------------------------------------- + 0.00 0.02 61643/1158076 readorders [43] + 0.00 0.36 1096433/1158076 unitorders [46] +[71] 1.1 0.00 0.38 1158076 getbuf [71] + 0.24 0.14 1158076/1158076 getbuf_utf8 [72] +----------------------------------------------- + 0.24 0.14 1158076/1158076 getbuf [71] +[72] 1.1 0.24 0.14 1158076 getbuf_utf8 [72] + 0.08 0.00 38195175/46391457 unicode_utf8_to_ucs4 [177] + 0.04 0.01 6241702/6241702 eatwhite [243] +----------------------------------------------- + 0.00 0.37 178254/178254 demographics [50] +[73] 1.1 0.00 0.37 178254 live [73] + 0.15 0.17 178254/178254 get_food [88] + 0.00 0.03 595472/595472 age_unit [336] + 0.01 0.01 595472/2858912 get_effect [225] +----------------------------------------------- + 0.01 0.36 595125/595125 read_game [62] +[74] 1.1 0.01 0.36 595125 read_unit [74] + 0.00 0.12 595125/888603 findunit [123] + 0.01 0.07 606357/1481407 parse_order [117] + 0.02 0.02 595125/628037 read_items [320] + 0.03 0.00 1951270/1956810 add_skill [355] + 0.00 0.02 379049/778818 describe_race [267] + 0.00 0.02 597254/68430117 rc_find [15] + 0.00 0.02 595125/840577 read_attribs [388] + 0.01 0.00 595125/1644867 free_orders [306] + 0.00 0.01 595125/4625636 findfaction [259] + 0.00 0.00 595125/598069 uhash [667] + 0.00 0.00 595125/129167539 u_race [89] + 0.00 0.00 606357/2155959 is_persistent [687] + 0.00 0.00 595125/598129 u_setfaction [1111] + 0.00 0.00 2129/21345834 skill_enabled [365] + 0.00 0.00 153878/154110 rule_stealth_anon [1325] + 0.00 0.00 595125/603524 set_number [1387] + 0.00 0.00 595125/600145 u_setrace [1389] + 0.00 0.00 595125/599650 setstatus [1390] + 0.00 0.00 595125/1291427 set_order [1365] + 0.00 0.00 47396/48455 findbuilding [1462] + 0.00 0.00 47396/48565 u_set_building [1460] + 0.00 0.00 27412/28818 findship [1483] + 0.00 0.00 27412/27640 u_set_ship [1485] +----------------------------------------------- + 0.00 0.00 352/4434556 cr_resources [960] + 0.00 0.00 356/4434556 cr_race [949] + 0.00 0.00 446/4434556 print_items [938] + 0.00 0.00 1896/4434556 report_computer [9] + 0.00 0.00 2073/4434556 cr_output_curses [69] + 0.00 0.00 5284/4434556 cr_reportspell [756] + 0.00 0.00 20072/4434556 cr_skill [672] + 0.00 0.00 33909/4434556 cr_output_spells [639] + 0.00 0.01 104830/4434556 cr_output_building [239] + 0.00 0.01 110167/4434556 cr_resource [488] + 0.01 0.01 174677/4434556 cr_output_resource [378] + 0.01 0.01 179761/4434556 cr_output_ship [152] + 0.01 0.02 427650/4434556 cr_output_region [10] + 0.11 0.17 3373083/4434556 cr_output_unit [19] +[75] 1.0 0.14 0.22 4434556 translate [75] + 0.01 0.21 4434556/4488684 crtag [110] +----------------------------------------------- + 0.00 0.36 1/1 tolua_eressea_eressea_write_game00 [77] +[76] 1.0 0.00 0.36 1 eressea_write_game [76] + 0.00 0.35 1/1 writegame [82] + 0.01 0.00 1/1 remove_empty_factions [576] +----------------------------------------------- + +[77] 1.0 0.00 0.36 tolua_eressea_eressea_write_game00 [77] + 0.00 0.36 1/1 eressea_write_game [76] +----------------------------------------------- + 0.02 0.34 178254/178254 process [7] +[78] 1.0 0.02 0.34 178254 economics [78] + 0.00 0.26 131722/131722 give_cmd [102] + 0.00 0.03 1594/1594 expandrecruit [349] + 0.03 0.00 2855598/55492327 getkeyword [54] + 0.02 0.00 178254/1375380 remove_empty_units_in_region [134] + 0.00 0.01 1835/1835 recruit [650] + 0.00 0.00 12/12 forget_cmd [1093] + 0.00 0.00 23/23 destroy_cmd [1113] + 0.00 0.00 1/1 recruit_init [1334] +----------------------------------------------- + 0.00 0.35 574/574 do_battle [64] +[79] 1.0 0.00 0.35 574 battle_attacks [79] + 0.01 0.34 2838/2838 do_attack [80] + 0.00 0.00 378/378 get_tactics [1178] +----------------------------------------------- + 0.01 0.34 2838/2838 battle_attacks [79] +[80] 1.0 0.01 0.34 2838 do_attack [80] + 0.00 0.34 617313/617313 attack [84] + 0.00 0.00 1501863/129167539 u_race [89] + 0.00 0.00 251867/876979 count_enemies [611] + 0.00 0.00 18/1486 message_all [834] + 0.00 0.00 18/967784 msg_message [132] + 0.00 0.00 251867/251867 attacks_per_round [1409] + 0.00 0.00 4005/754589 preferred_weapon [1377] + 0.00 0.00 18/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.35 96529/96529 move_cmd [66] +[81] 1.0 0.00 0.35 96529 travel [81] + 0.00 0.31 96555/96555 travel_i [92] + 0.00 0.04 96527/96527 make_route [289] + 0.00 0.00 94655/1474687 leftship [500] + 0.00 0.00 66/15361 is_guarded [377] + 0.00 0.00 133/133 reroute [1020] + 0.00 0.00 133/324 caught_target [1003] + 0.00 0.00 133/447808 create_order [341] + 0.00 0.00 133/24887945 locale_string [27] + 0.00 0.00 94660/95593 can_leave [1112] + 0.00 0.00 2/41248 msg_feedback [647] + 0.00 0.00 2/392959 add_message [434] + 0.00 0.00 5/129167539 u_race [89] + 0.00 0.00 133/1936876 free_order [1356] + 0.00 0.00 2/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.35 1/1 eressea_write_game [76] +[82] 1.0 0.00 0.35 1 writegame [82] + 0.01 0.34 1/1 write_game [83] + 0.00 0.00 1/2 create_directories [1294] + 0.00 0.00 1/573 join_path [1016] + 0.00 0.00 1/5 datapath [1289] + 0.00 0.00 1/1 version_no [1894] + 0.00 0.00 1/231 eressea_version [1624] +----------------------------------------------- + 0.01 0.34 1/1 writegame [82] +[83] 1.0 0.01 0.34 1 write_game [83] + 0.12 0.15 596221/596221 write_unit [97] + 0.04 0.00 534764/1248014 listlen [190] + 0.00 0.01 178254/178254 writeregion [519] + 0.00 0.01 1/1 clear_npc_orders [531] + 0.00 0.00 65263/839970 write_attribs [301] + 0.00 0.00 232/232 writefaction [762] + 0.00 0.00 1/1 write_planes [1207] + 0.00 0.00 1/2 game_id [1324] + 0.00 0.00 176/49235 log_debug [1245] + 0.00 0.00 46184/642406 write_building_reference [1383] + 0.00 0.00 19078/615299 write_ship_reference [1386] + 0.00 0.00 1/1 write_alliances [1896] + 0.00 0.00 1/1 write_borders [1897] +----------------------------------------------- + 0.00 0.34 617313/617313 do_attack [80] +[84] 1.0 0.00 0.34 617313 attack [84] + 0.00 0.16 363071/363071 hits [131] + 0.01 0.10 363135/363135 select_opponent [160] + 0.00 0.05 72692/80630 terminate [242] + 0.00 0.01 42157/146997 dice_rand [409] + 0.00 0.01 53/53 do_extra_spell [648] + 0.00 0.00 252753/876979 count_enemies [611] + 0.00 0.00 38/38 do_combatspell [702] + 0.00 0.00 47310/7641081 genrand_int31 [171] + 0.00 0.00 112/112 attack_firesword [785] + 0.00 0.00 5596/5596 drain_exp [850] + 0.00 0.00 23194/129167539 u_race [89] + 0.00 0.00 256354/619425 getreload [1385] + 0.00 0.00 234242/754589 preferred_weapon [1377] + 0.00 0.00 44924/1726748 is_riding [1358] + 0.00 0.00 3639/3639 setreload [1542] + 0.00 0.00 7/160 damage_ship [1641] + 0.00 0.00 1/1 dazzle [1800] +----------------------------------------------- + 0.03 0.31 35287/35287 report_plaintext [4] +[85] 1.0 0.03 0.31 35287 prices [85] + 0.00 0.23 247009/1380398 nr_render [25] + 0.01 0.03 247009/967784 msg_message [132] + 0.02 0.00 35287/2742237 paragraph [26] + 0.01 0.01 247009/24887945 locale_string [27] + 0.01 0.00 529305/34611296 strlcpy [45] + 0.00 0.00 776314/36653945 wrptr [178] + 0.00 0.00 247009/1009028 msg_release [1373] +----------------------------------------------- + 2724978 parse [333] + 0.00 0.00 605/1380398 translate [28] +[86] 1.0 0.21 0.12 2725583 parse_string [86] + 0.07 0.00 3931390/34611296 strlcpy [45] + 0.03 0.00 3931390/13102790 opstack_pop [176] + 0.02 0.00 2725583/13102790 opstack_push [202] + 0.01 0.00 2725583/13399069 balloc [363] + 0.00 0.00 6656973/6656973 bfree [1349] + 3931390 parse_symbol [42] +----------------------------------------------- + 0.27 0.06 99/99 write_reports [3] +[87] 1.0 0.27 0.06 99 report_template [87] + 0.03 0.00 195108/195108 rps_nowrap [359] + 0.00 0.01 128725/1470505 write_order [121] + 0.00 0.00 55807/24887945 locale_string [27] + 0.00 0.00 10477/490896 wage [174] + 0.00 0.00 52225/5100840 itoa36 [116] + 0.00 0.00 151532/55492327 getkeyword [54] + 0.00 0.00 12521/593636 building_owner [232] + 0.00 0.00 62870/34611296 strlcpy [45] + 0.00 0.00 216458/2494242 newline [594] + 0.00 0.00 45033/7120688 get_money [187] + 0.00 0.00 10477/1552289 rname [200] + 0.00 0.00 45033/4198692 lifestyle [286] + 0.00 0.00 45033/3351853 unit_getname [332] + 0.00 0.00 10477/1826688 adjust_coordinates [234] + 0.00 0.00 107804/36653945 wrptr [178] + 0.00 0.00 151532/2155959 is_persistent [687] + 0.00 0.00 45071/129167539 u_race [89] + 0.00 0.00 4309/10190660 get_curse [143] + 0.00 0.00 1258/884940 itoa10 [338] + 0.00 0.00 7093/3358315 ship_owner [438] + 0.00 0.00 12208/2985733 is_repeated [552] + 0.00 0.00 4309/4201030 curse_active [543] + 0.00 0.00 10477/18647447 getplane [596] + 0.00 0.00 99/12246335 ct_find [114] + 0.00 0.00 99/56052475 get_resourcetype [194] + 0.00 0.00 10477/3587241 pnormalize [1350] + 0.00 0.00 4066/4066 buildingmaintenance [1535] +----------------------------------------------- + 0.15 0.17 178254/178254 live [73] +[88] 0.9 0.15 0.17 178254 get_food [88] + 0.05 0.01 4046908/7120688 get_money [187] + 0.01 0.03 4046861/4198692 lifestyle [286] + 0.00 0.03 1044674/71815034 get_race [12] + 0.00 0.01 111338/9953180 alliedunit [31] + 0.01 0.00 726086/2599554 change_money [337] + 0.01 0.00 178254/264251 rsetpeasants [545] + 0.00 0.00 1771752/1771752 help_money [663] + 0.00 0.00 106798/106798 help_feed [678] + 0.00 0.00 1044674/129167539 u_race [89] + 0.00 0.00 178254/2605004 rpeasants [435] + 0.00 0.00 178257/4984610 config_get_int [348] + 0.00 0.00 43034/2858912 get_effect [225] + 0.00 0.00 88/88 hunger [808] + 0.00 0.00 178254/18647447 getplane [596] + 0.00 0.00 1461/2977 change_effect [982] + 0.00 0.00 2148/2032164 rt_find [597] +----------------------------------------------- + 0.00 0.00 1/129167539 sp_summonshadowlords [1034] + 0.00 0.00 1/129167539 sp_seduce [1336] + 0.00 0.00 1/129167539 promotion_cmd [917] + 0.00 0.00 1/129167539 oldfamiliars [1240] + 0.00 0.00 2/129167539 make_familiar [1219] + 0.00 0.00 2/129167539 do_fumble [1062] + 0.00 0.00 2/129167539 create_ship [1014] + 0.00 0.00 3/129167539 trigger_changerace [1297] + 0.00 0.00 4/129167539 cast_cmd [760] + 0.00 0.00 5/129167539 travel [81] + 0.00 0.00 5/129167539 leave_cmd [721] + 0.00 0.00 6/129167539 skill_summoned [1032] + 0.00 0.00 8/129167539 mod_elves_only [1239] + 0.00 0.00 9/129167539 chaos [848] + 0.00 0.00 15/129167539 steal_cmd [766] + 0.00 0.00 18/129167539 destroyfaction [392] + 0.00 0.00 20/129167539 spawn_dragons [411] + 0.00 0.00 24/129167539 make_heroes [1298] + 0.00 0.00 28/129167539 get_friends [895] + 0.00 0.00 31/129167539 random_unit [1174] + 0.00 0.00 36/129167539 damage_unit [1044] + 0.00 0.00 43/129167539 get_money_for_dragon [1087] + 0.00 0.00 44/129167539 build_road [950] + 0.00 0.00 45/129167539 dissolve_units [241] + 0.00 0.00 48/129167539 reshow_other [823] + 0.00 0.00 50/129167539 get_combatspell [874] + 0.00 0.00 58/129167539 use_bloodpotion [935] + 0.00 0.00 60/129167539 nb_armor [1273] + 0.00 0.00 71/129167539 disband_men [999] + 0.00 0.00 79/129167539 can_guard [908] + 0.00 0.00 88/129167539 hunger [808] + 0.00 0.00 92/129167539 spawn_undead [629] + 0.00 0.00 97/129167539 age_stonecircle [1021] + 0.00 0.00 111/129167539 check_steal [1234] + 0.00 0.00 112/129167539 give_unit [952] + 0.00 0.00 138/129167539 LongHunger [536] + 0.00 0.00 142/129167539 transfermen [899] + 0.00 0.00 168/129167539 loot_cmd [873] + 0.00 0.00 188/129167539 is_freezing [1088] + 0.00 0.00 222/129167539 enter_ship [733] + 0.00 0.00 242/129167539 canfly [1031] + 0.00 0.00 257/129167539 is_guardian_u [626] + 0.00 0.00 266/129167539 income [885] + 0.00 0.00 409/129167539 enter_building [695] + 0.00 0.00 460/129167539 plan_dragon [273] + 0.00 0.00 508/129167539 regeneration [942] + 0.00 0.00 578/129167539 gift_items [891] + 0.00 0.00 659/129167539 can_give_men [940] + 0.00 0.00 666/129167539 generic_name [962] + 0.00 0.00 681/129167539 absorbed_by_monster [804] + 0.00 0.00 783/129167539 give_men [857] + 0.00 0.00 802/129167539 heal_fighters [1158] + 0.00 0.00 990/129167539 kill_troop [532] + 0.00 0.00 1289/129167539 allocate_resource [752] + 0.00 0.00 1518/129167539 start_battle [297] + 0.00 0.00 1670/129167539 do_recruiting [351] + 0.00 0.00 1722/129167539 aftermath [701] + 0.00 0.00 2097/129167539 create_unit [296] + 0.00 0.00 3241/129167539 is_guardian_r [186] + 0.00 0.00 3340/129167539 select_recruitment [1079] + 0.00 0.00 3551/129167539 recruit [650] + 0.00 0.00 3836/129167539 tax_cmd [697] + 0.00 0.00 4069/129167539 is_migrant [1047] + 0.00 0.00 4632/129167539 add_recruits [371] + 0.00 0.00 4777/129167539 name_unit [803] + 0.00 0.00 5049/129167539 validate_pirate [1051] + 0.00 0.00 5358/129167539 max_spellpoints [755] + 0.00 0.00 5384/129167539 teach_cmd [272] + 0.00 0.00 5915/129167539 buy [707] + 0.00 0.00 7054/129167539 make_fighter [424] + 0.00 0.00 7279/129167539 remove_empty_units_in_region [134] + 0.00 0.00 7560/129167539 drown [394] + 0.00 0.00 7938/129167539 calculate_armor [645] + 0.00 0.00 7957/129167539 magic_resistance [727] + 0.00 0.00 8132/129167539 battle_flee [352] + 0.00 0.00 10979/129167539 expandwork [277] + 0.00 0.00 11880/129167539 cansee_unit [684] + 0.00 0.00 12787/129167539 canwalk [633] + 0.00 0.00 15347/129167539 can_start_guarding [679] + 0.00 0.00 15763/129167539 sell [498] + 0.00 0.00 16132/129167539 magic_lowskill [897] + 0.00 0.00 20370/129167539 get_reservation [281] + 0.00 0.00 21443/129167539 ridingcapacity [694] + 0.00 0.00 22150/129167539 do_work [612] + 0.00 0.00 23194/129167539 attack [84] + 0.00 0.00 25088/129167539 rmfighter [890] + 0.00 0.00 27379/129167539 bewegung_blockiert_von [631] + 0.00 0.00 27694/129167539 dragon_affinity_value [516] + 0.00 0.00 45071/129167539 report_template [87] + 0.00 0.00 45992/129167539 golem_factor [265] + 0.00 0.00 47987/129167539 guard_on_cmd [656] + 0.00 0.00 51382/129167539 immigration [294] + 0.00 0.00 52873/129167539 produceexp_ex [323] + 0.00 0.00 80630/129167539 natural_armor [788] + 0.00 0.00 92804/129167539 canswim [682] + 0.00 0.00 101492/129167539 report_item [106] + 0.00 0.00 115276/129167539 can_move [736] + 0.00 0.00 116914/129167539 fleechance [408] + 0.00 0.00 117616/129167539 rc_specialdamage [830] + 0.00 0.00 120592/129167539 CavalryBonus [491] + 0.00 0.00 132028/129167539 shipspeed [669] + 0.00 0.00 144924/129167539 statistics [70] + 0.00 0.00 168094/129167539 monster_move [129] + 0.00 0.00 176065/129167539 randomevents [91] + 0.00 0.00 192570/129167539 canride [465] + 0.00 0.00 193274/129167539 personcapacity [795] + 0.00 0.00 193321/129167539 walkingcapacity [403] + 0.00 0.00 221802/129167539 unitorders [46] + 0.00 0.00 278421/129167539 movement_speed [155] + 0.00 0.00 279395/129167539 weight [459] + 0.00 0.00 307120/129167539 give_cmd [102] + 0.00 0.00 325282/129167539 eaten_by_monster [468] + 0.00 0.00 325825/129167539 scared_by_monster [380] + 0.00 0.00 346411/129167539 travel_route [147] + 0.00 0.00 363135/129167539 select_opponent [160] + 0.00 0.00 372173/129167539 select_enemy [172] + 0.00 0.00 407896/129167539 guard_flags [690] + 0.00 0.00 417577/129167539 study_days [747] + 0.00 0.00 420172/129167539 tolua_unit_get_race [746] + 0.00 0.00 439954/129167539 process [7] + 0.00 0.00 464187/129167539 skilldiff [166] + 0.00 0.00 475770/129167539 terminate [242] + 0.00 0.00 578592/129167539 heal_factor [619] + 0.00 0.00 595125/129167539 read_unit [74] + 0.00 0.00 595142/129167539 plan_monsters [52] + 0.00 0.00 595144/129167539 monthly_healing [215] + 0.00 0.00 595476/129167539 demon_skillchanges [246] + 0.00 0.00 596221/129167539 prepare_report [8] + 0.00 0.00 597269/129167539 bufunit [17] + 0.00 0.00 742235/129167539 random_neighbour [153] + 0.00 0.00 748527/129167539 unit_can_study [709] + 0.00 0.00 793492/129167539 produce [29] + 0.00 0.00 835519/129167539 study_cmd [105] + 0.00 0.00 868104/129167539 select_armor [700] + 0.00 0.00 949946/129167539 can_survive [640] + 0.00 0.00 1044674/129167539 get_food [88] + 0.00 0.00 1100763/129167539 cr_output_unit [19] + 0.00 0.00 1121103/129167539 monster_is_waiting [407] + 0.00 0.00 1190864/129167539 magic [157] + 0.00 0.00 1191346/129167539 make_summary [21] + 0.00 0.00 1194391/129167539 age_unit [336] + 0.00 0.00 1335533/129167539 cansee [22] + 0.00 0.00 1344397/129167539 nr_unit [11] + 0.00 0.00 1381157/129167539 unit_max_hp [136] + 0.00 0.00 1469625/129167539 monster_kills_peasants [230] + 0.00 0.00 1501863/129167539 do_attack [80] + 0.00 0.00 1555209/129167539 weapon_skill [221] + 0.00 0.00 1747682/129167539 cansee_durchgezogen [170] + 0.00 0.00 1771752/129167539 help_money [663] + 0.00 0.00 1788663/129167539 write_unit [97] + 0.01 0.00 2367342/129167539 get_pooled [104] + 0.01 0.00 2521048/129167539 maintenance_cost [481] + 0.01 0.00 2554959/129167539 u_description [347] + 0.01 0.00 3891194/129167539 count_faction [219] + 0.01 0.00 3903981/129167539 score [23] + 0.01 0.00 4920480/129167539 use_pooled [39] + 0.02 0.00 7179079/129167539 get_modifier [55] + 0.07 0.00 29944440/129167539 check_overpopulated [184] + 0.08 0.00 34058224/129167539 room_for_race_in_region [165] +[89] 0.9 0.32 0.00 129167539 u_race [89] +----------------------------------------------- + 0.05 0.26 7179079/7179079 get_modifier [55] +[90] 0.9 0.05 0.26 7179079 att_modification [90] + 0.12 0.00 7027859/12246335 ct_find [114] + 0.09 0.00 10322799/51974272 a_find [65] + 0.04 0.00 3294942/10190660 get_curse [143] + 0.01 0.00 3294942/5152236 ct_changed [592] + 0.00 0.00 601859/4201030 curse_active [543] + 0.00 0.00 58/432940 curse_geteffect [1395] +----------------------------------------------- + 0.04 0.27 1/1 process [7] +[91] 0.9 0.04 0.27 1 randomevents [91] + 0.03 0.03 1/1 dissolve_units [241] + 0.03 0.02 1/1 demon_skillchanges [246] + 0.01 0.03 1/1 rotting_herbs [284] + 0.00 0.04 1/1 icebergs [285] + 0.02 0.01 1/1 orc_growth [370] + 0.02 0.00 1/1 godcurse [405] + 0.01 0.00 1/1 chaos_update [514] + 0.00 0.00 419410/3902878 get_monsters [293] + 0.00 0.00 178254/51974272 a_find [65] + 0.00 0.00 176065/129167539 u_race [89] + 0.00 0.00 1/1 volcano_update [981] + 0.00 0.00 172/2605004 rpeasants [435] + 0.00 0.00 6/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.31 96555/96555 travel [81] +[92] 0.9 0.00 0.31 96555 travel_i [92] + 0.00 0.12 96482/96482 travel_route [147] + 0.00 0.11 96450/96450 movement_speed [155] + 0.05 0.00 96482/96482 get_followers [254] + 0.00 0.01 96450/96450 cap_route [502] + 0.00 0.01 96555/96555 canwalk [633] + 0.00 0.00 162752/55492327 getkeyword [54] + 0.00 0.00 65/282847 getunit [205] + 0.00 0.00 105/15102 cmistake [718] + 0.00 0.00 32/967784 msg_message [132] + 0.00 0.00 33/392959 add_message [434] + 0.00 0.00 65/1027665 init_order [613] + 0.00 0.00 32/115276 can_move [736] + 0.00 0.00 32/1629412 LongHunger [536] + 0.00 0.00 1/41248 msg_feedback [647] + 0.00 0.00 199/95593 can_leave [1112] + 0.00 0.00 33/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.30 4629/4629 produce [29] +[93] 0.9 0.00 0.30 4629 expandselling [93] + 0.06 0.19 282676/860263 use_pooled [39] + 0.01 0.02 4628/10852 expandorders [197] + 0.01 0.00 282676/11241829 i_change [115] + 0.00 0.00 283759/2599554 change_money [337] + 0.00 0.00 370844/51974272 a_find [65] + 0.00 0.00 12448/967784 msg_message [132] + 0.00 0.00 5821/34409 add_income [625] + 0.00 0.00 4629/12933 owner_buildingtyp [676] + 0.00 0.00 9465/593636 building_owner [232] + 0.00 0.00 12448/392959 add_message [434] + 0.00 0.00 3778/184870 buildingeffsize [367] + 0.00 0.00 4738/451774 a_remove [366] + 0.00 0.00 4738/779419 a_add [555] + 0.00 0.00 4690/2605004 rpeasants [435] + 0.00 0.00 4629/4666665 rmoney [452] + 0.00 0.00 3/560926 bt_find [237] + 0.00 0.00 287458/308950 r_demand [1404] + 0.00 0.00 12448/1009028 msg_release [1373] + 0.00 0.00 4738/779868 a_new [1376] + 0.00 0.00 4629/204314 bt_changed [1415] + 0.00 0.00 4628/1511812 newterrain [1359] + 0.00 0.00 344/75797 buildingtype_exists [1443] + 0.00 0.00 13/217405 r_setdemand [1413] +----------------------------------------------- + 0.29 0.00 18856320/18856320 travelthru_map [41] +[94] 0.8 0.29 0.00 18856320 cb_add_seen [94] + 0.00 0.00 61444/745269 add_seen_nb [386] +----------------------------------------------- + +[95] 0.8 0.28 0.00 cb_find_prefix_i [95] +----------------------------------------------- + +[96] 0.8 0.28 0.00 from_external_node [96] +----------------------------------------------- + 0.12 0.15 596221/596221 write_game [83] +[97] 0.8 0.12 0.15 596221 write_unit [97] + 0.00 0.08 607926/607926 writeorder [208] + 0.00 0.03 596221/839970 write_attribs [301] + 0.01 0.00 596221/629123 write_items [511] + 0.01 0.00 596221/2868601 u_irace [257] + 0.01 0.00 596221/604861 write_unit_reference [557] + 0.01 0.00 692835/55492327 getkeyword [54] + 0.00 0.00 47440/593636 building_owner [232] + 0.00 0.00 1788663/129167539 u_race [89] + 0.00 0.00 692829/2155959 is_persistent [687] + 0.00 0.00 68016/2985733 is_repeated [552] + 0.00 0.00 27416/3358315 ship_owner [438] + 0.00 0.00 40/2383101 unitname [142] + 0.00 0.00 40/64 log_info [1339] + 0.00 0.00 596221/647569 write_faction_reference [1382] + 0.00 0.00 596221/642406 write_building_reference [1383] + 0.00 0.00 596221/615299 write_ship_reference [1386] +----------------------------------------------- + 0.00 0.00 7964/5168717 report_crtypes [428] + 0.04 0.03 1380398/5168717 nr_render [25] + 0.11 0.09 3780355/5168717 nr_section [113] +[98] 0.8 0.15 0.12 5168717 nrt_find [98] + 0.12 0.00 5168717/32337529 hashstring [37] +----------------------------------------------- + 0.00 0.00 4/8302761 reserve_i [213] + 0.00 0.00 83859/8302761 reduce_weight [404] + 0.00 0.03 931076/8302761 change_resource [240] + 0.01 0.07 2367342/8302761 get_pooled [104] + 0.02 0.14 4920480/8302761 use_pooled [39] +[99] 0.8 0.03 0.23 8302761 get_resource [99] + 0.03 0.21 8301368/9232125 res_changeitem [101] + 0.00 0.00 357/443 res_changepermaura [912] + 0.00 0.00 983/1199 res_changeaura [972] + 0.00 0.00 53/53 lua_getresource [1191] +----------------------------------------------- + 54349 sm_familiar [520] + 0.00 0.00 1/12320804 plant [1184] + 0.00 0.00 1/12320804 planttrees [1206] + 0.00 0.00 1/12320804 destroy_road [1230] + 0.00 0.00 2/12320804 sp_bloodsacrifice [1209] + 0.00 0.00 2/12320804 breedtrees [1148] + 0.00 0.00 2/12320804 setstealth_cmd [182] + 0.00 0.00 3/12320804 target_resists_magic [1154] + 0.00 0.00 4/12320804 sail [181] + 0.00 0.00 4/12320804 create_ship [1014] + 0.00 0.00 15/12320804 age_stonecircle [1021] + 0.00 0.00 22/12320804 reshow [822] + 0.00 0.00 41/12320804 build_road [950] + 0.00 0.00 44/12320804 plan_monsters [52] + 0.00 0.00 65/12320804 steal_cmd [766] + 0.00 0.00 90/12320804 sp_charmingsong [993] + 0.00 0.00 96/12320804 spy_cmd [990] + 0.00 0.00 165/12320804 update_spells [381] + 0.00 0.00 170/12320804 breedhorses [742] + 0.00 0.00 200/12320804 max_skill [1037] + 0.00 0.00 226/12320804 fumble [973] + 0.00 0.00 251/12320804 cancast [833] + 0.00 0.00 329/12320804 cast_cmd [760] + 0.00 0.00 349/12320804 research_cmd [886] + 0.00 0.00 377/12320804 manufacture [759] + 0.00 0.00 432/12320804 continue_ship [813] + 0.00 0.00 489/12320804 u_hasspell [951] + 0.00 0.00 508/12320804 regeneration [942] + 0.00 0.00 621/12320804 build_building [696] + 0.00 0.00 1230/12320804 build [691] + 0.00 0.00 1302/12320804 get_combatspelllevel [880] + 0.00 0.00 1334/12320804 bufunit [17] + 0.00 0.00 1423/12320804 leveled_allocation [888] + 0.00 0.00 1717/12320804 faction_getmages [382] + 0.00 0.00 2273/12320804 do_combatmagic [825] + 0.00 0.00 2659/12320804 tax_cmd [697] + 0.00 0.00 2909/12320804 make_fighter [424] + 0.00 0.00 2939/12320804 allocate_resource [752] + 0.00 0.00 3116/12320804 drifting_ships [490] + 0.00 0.00 3403/12320804 lighthouse_range [728] + 0.00 0.00 5358/12320804 max_spellpoints [755] + 0.00 0.00 5903/12320804 buy [707] + 0.00 0.00 5988/12320804 herbsearch [493] + 0.00 0.00 6428/12320804 cansee_unit [684] + 0.00 0.00 6580/12320804 study_cmd [105] + 0.00 0.00 7254/12320804 ship_ready [354] + 0.00 0.00 7957/12320804 magic_resistance [727] + 0.00 0.00 8873/12320804 bewegung_blockiert_von [631] + 0.00 0.00 10679/12320804 move_ship [374] + 0.00 0.00 12787/12320804 canwalk [633] + 0.00 0.00 20459/12320804 crew_skill [344] + 0.00 0.00 28293/12320804 sell [498] + 0.00 0.00 33015/12320804 ridingcapacity [694] + 0.00 0.00 33156/12320804 entertain_cmd [665] + 0.00 0.01 116914/12320804 horse_fleeing_bonus [604] + 0.00 0.01 116914/12320804 fleechance [408] + 0.00 0.01 137709/12320804 CavalryBonus [491] + 0.00 0.01 172836/12320804 cansee_durchgezogen [170] + 0.00 0.01 179414/12320804 walkingcapacity [403] + 0.01 0.01 192556/12320804 canride [465] + 0.01 0.01 207188/12320804 report_resources [210] + 0.02 0.02 551693/12320804 weapon_skill [221] + 0.02 0.03 604957/12320804 cr_output_unit [19] + 0.03 0.05 1188531/12320804 eff_stealth [163] + 0.03 0.05 1213526/12320804 make_summary [21] + 0.04 0.06 1327770/12320804 armedmen [151] + 0.04 0.06 1381157/12320804 unit_max_hp [136] + 0.07 0.10 2363341/12320804 cansee [22] +[100] 0.8 0.25 0.01 10030400 effskill [100] + 0.01 0.00 10030400/21345834 skill_enabled [365] + 4953357 eff_skill [334] +----------------------------------------------- + 0.00 0.02 930757/9232125 change_resource [240] + 0.03 0.21 8301368/9232125 get_resource [99] +[101] 0.8 0.03 0.23 9232125 res_changeitem [101] + 0.17 0.00 9232120/11241829 i_change [115] + 0.02 0.03 9163148/9163148 golem_factor [265] + 0.01 0.00 9232120/9298667 resource2item [546] + 0.00 0.00 1/3178 scale_number [969] +----------------------------------------------- + 0.00 0.26 131722/131722 economics [78] +[102] 0.7 0.00 0.26 131722 give_cmd [102] + 0.00 0.18 95533/95533 give_item [126] + 0.00 0.04 131722/282847 getunit [205] + 0.00 0.01 102699/102705 can_give_to [600] + 0.00 0.01 102606/9953180 alliedunit [31] + 0.00 0.01 231035/2281756 gettoken [195] + 0.00 0.00 102606/71815034 get_race [12] + 0.00 0.00 28910/41248 msg_feedback [647] + 0.00 0.00 29028/392959 add_message [434] + 0.00 0.00 131722/1027665 init_order [613] + 0.00 0.00 307120/129167539 u_race [89] + 0.00 0.00 94233/534930 isparam [668] + 0.00 0.00 93568/191379 finditemtype [735] + 0.00 0.00 18400/6010308 i_find [127] + 0.00 0.00 45456/1787006 findparam [458] + 0.00 0.00 24010/4851739 get_reservation [281] + 0.00 0.00 588/588 give_men [857] + 0.00 0.00 965/15102 cmistake [718] + 0.00 0.00 102739/18647447 getplane [596] + 0.00 0.00 114/114 give_unit [952] + 0.00 0.00 71/71 disband_men [999] + 0.00 0.00 102761/102761 check_give [1138] + 0.00 0.00 50/8898 ucontact [927] + 0.00 0.00 114935/217696 can_give [1335] + 0.00 0.00 131729/203117 atoip [1416] + 0.00 0.00 29028/1009028 msg_release [1373] +----------------------------------------------- + 0.02 0.10 700757/1405457 cr_output_unit [19] + 0.03 0.10 704700/1405457 bufunit [17] +[103] 0.7 0.05 0.20 1405457 report_items [103] + 0.06 0.11 8843052/12353561 report_item [106] + 0.02 0.00 1017568/12246335 ct_find [114] + 0.01 0.00 1017568/10190660 get_curse [143] +----------------------------------------------- + 1825360 get_pooled [104] + 0.00 0.00 1/541982 planttrees [1206] + 0.00 0.00 1/541982 breedtrees [1148] + 0.00 0.00 1/541982 promotion_cmd [917] + 0.00 0.00 2/541982 plant [1184] + 0.00 0.00 23/541982 build_road [950] + 0.00 0.00 59/541982 expandstealing [807] + 0.00 0.00 122/541982 maxbuild [946] + 0.00 0.00 404/541982 academy_can_teach [527] + 0.00 0.00 489/541982 eff_spelllevel [845] + 0.00 0.00 503/541982 cancast [833] + 0.00 0.00 590/541982 use_item [765] + 0.00 0.00 1670/541982 do_recruiting [351] + 0.00 0.00 1816/541982 build [691] + 0.00 0.00 3359/541982 recruit [650] + 0.00 0.00 7821/541982 study_cmd [105] + 0.00 0.01 13492/541982 maintain [478] + 0.00 0.01 15796/541982 sell [498] + 0.01 0.04 95533/541982 give_item [126] + 0.02 0.16 400300/541982 expandbuying [49] +[104] 0.7 0.03 0.21 541982+1825360 get_pooled [104] + 0.01 0.11 1273750/9953180 alliedunit [31] + 0.01 0.07 2367342/8302761 get_resource [99] + 0.00 0.00 671315/4851739 get_reservation [281] + 0.01 0.00 2367342/129167539 u_race [89] + 0.00 0.00 1849529/7417541 urace [436] + 1825360 get_pooled [104] +----------------------------------------------- + 0.03 0.21 417808/417808 process [7] +[105] 0.7 0.03 0.21 417808 study_cmd [105] + 0.00 0.04 420075/560926 bt_find [237] + 0.01 0.02 417577/451774 a_remove [366] + 0.00 0.02 417775/435022 getskill [387] + 0.02 0.00 417730/418134 study_cost [433] + 0.01 0.01 836342/2858912 get_effect [225] + 0.00 0.01 417740/71815034 get_race [12] + 0.01 0.00 417580/424669 active_building [560] + 0.00 0.01 417577/892307 learn_skill [471] + 0.00 0.00 7475/860263 use_pooled [39] + 0.00 0.01 405840/779419 a_add [555] + 0.00 0.00 835616/4984610 config_get_int [348] + 0.00 0.00 417739/51974272 a_find [65] + 0.00 0.00 7821/541982 get_pooled [104] + 0.00 0.00 417775/1027665 init_order [613] + 0.00 0.00 20072/967784 msg_message [132] + 0.00 0.00 169917/12246335 ct_find [114] + 0.00 0.00 169917/10190660 get_curse [143] + 0.00 0.00 835519/129167539 u_race [89] + 0.00 0.00 417808/748527 unit_can_study [709] + 0.00 0.00 417577/417577 study_days [747] + 0.00 0.00 20258/392959 add_message [434] + 0.00 0.00 6326/9953180 alliedunit [31] + 0.00 0.00 6580/12320804 effskill [100] + 0.00 0.00 169917/4201030 curse_active [543] + 0.00 0.00 4/4 count_skill [868] + 0.00 0.00 234/15102 cmistake [718] + 0.00 0.00 15296/56052475 get_resourcetype [194] + 0.00 0.00 186/41248 msg_feedback [647] + 0.00 0.00 3659/3659 ExpensiveMigrants [1004] + 0.00 0.00 589/2624955 has_skill [193] + 0.00 0.00 524/2426021 get_mage [198] + 0.00 0.00 1118/2977 change_effect [982] + 0.00 0.00 3659/3659 is_migrant [1047] + 0.00 0.00 524/793 is_familiar [1092] + 0.00 0.00 91/1441945 is_mage [262] + 0.00 0.00 17/45891 get_level [934] + 0.00 0.00 4/1583 skill_limit [1172] + 0.00 0.00 417577/417577 study_speedup [1398] + 0.00 0.00 405840/779868 a_new [1376] + 0.00 0.00 169917/651711 oldcursename [1381] + 0.00 0.00 20258/1009028 msg_release [1373] + 0.00 0.00 2495/75797 buildingtype_exists [1443] +----------------------------------------------- + 0.01 0.02 1727391/12353561 cr_output_unit [19] + 0.01 0.02 1783118/12353561 bufunit [17] + 0.06 0.11 8843052/12353561 report_items [103] +[106] 0.7 0.08 0.16 12353561 report_item [106] + 0.04 0.04 1783118/24887945 locale_string [27] + 0.05 0.00 11478488/13259934 resourcename [233] + 0.02 0.00 12353561/56052475 get_resourcetype [194] + 0.00 0.00 101492/129167539 u_race [89] +----------------------------------------------- + 0.03 0.00 884940/5985780 itoa10 [338] + 0.20 0.00 5100840/5985780 itoa36 [116] +[107] 0.7 0.23 0.00 5985780 itoab [107] +----------------------------------------------- + 0.00 0.00 41086/2006524 cr_order [489] + 0.01 0.04 494960/2006524 buforder [201] + 0.04 0.13 1470478/2006524 write_order [121] +[108] 0.7 0.05 0.18 2006524 get_command [108] + 0.05 0.05 2006524/24887945 locale_string [27] + 0.07 0.00 3889315/34611296 strlcpy [45] + 0.01 0.00 3889315/36653945 wrptr [178] + 0.00 0.00 2006524/2009097 keyword [1355] +----------------------------------------------- + 0.00 0.00 145/1118718 findunitr [991] + 0.00 0.00 754/1118718 createunitid [317] + 0.00 0.00 1794/1118718 remove_unit [499] + 0.00 0.00 5523/1118718 newunitid [319] + 0.04 0.00 221899/1118718 findunitg [279] + 0.17 0.01 888603/1118718 findunit [123] +[109] 0.7 0.22 0.01 1118718 ufindhash [109] + 0.01 0.00 1118718/2903884 jenkins_hash [439] +----------------------------------------------- + 0.00 0.00 3232/4488684 cr_output_resources [238] + 0.00 0.00 50896/4488684 write_translations [689] + 0.01 0.21 4434556/4488684 translate [75] +[110] 0.6 0.01 0.22 4488684 crtag [110] + 0.11 0.11 4488684/24887945 locale_string [27] + 0.00 0.00 1/5588 get_locale [884] +----------------------------------------------- + 0.01 0.21 180598/180598 report_plaintext [4] +[111] 0.6 0.01 0.21 180598 nr_ship [111] + 0.08 0.00 180598/2742237 paragraph [26] + 0.06 0.00 180598/1766225 nr_curses [48] + 0.03 0.00 18693/47902 getshipweight [212] + 0.01 0.01 373674/24887945 locale_string [27] + 0.01 0.00 532232/34611296 strlcpy [45] + 0.00 0.01 180598/1065211 shipname [290] + 0.00 0.00 18693/47887 shipcapacity [567] + 0.00 0.00 743981/36653945 wrptr [178] + 0.00 0.00 180598/2494242 newline [594] + 0.00 0.00 30150/30150 ship_damage_percent [1482] +----------------------------------------------- + +[112] 0.6 0.22 0.00 ql_advance [112] +----------------------------------------------- + 0.00 0.00 41255/3780355 log_orders [251] + 0.02 0.20 3739100/3780355 rp_messages [36] +[113] 0.6 0.02 0.20 3780355 nr_section [113] + 0.11 0.09 3780355/5168717 nrt_find [98] +----------------------------------------------- + 0.00 0.00 1/12246335 unit_max_hp [136] + 0.00 0.00 1/12246335 sp_holyground [1068] + 0.00 0.00 1/12246335 monthly_healing [215] + 0.00 0.00 1/12246335 spawn_undead [629] + 0.00 0.00 2/12246335 sp_charmingsong [993] + 0.00 0.00 2/12246335 sp_generous [1040] + 0.00 0.00 2/12246335 sp_enterastral [1045] + 0.00 0.00 2/12246335 shipcurse_flyingship [1072] + 0.00 0.00 3/12246335 sp_song_of_peace [939] + 0.00 0.00 3/12246335 sp_eternizewall [988] + 0.00 0.00 3/12246335 init_rules [1272] + 0.00 0.00 3/12246335 skilldiff [166] + 0.00 0.00 4/12246335 sp_goodwinds [974] + 0.00 0.00 6/12246335 forget_cmd [1093] + 0.00 0.00 9/12246335 is_freezing [1088] + 0.00 0.00 13/12246335 sp_blessedharvest [847] + 0.00 0.00 15/12246335 age_stonecircle [1021] + 0.00 0.00 17/12246335 produce [29] + 0.00 0.00 17/12246335 process [7] + 0.00 0.00 17/12246335 magic [157] + 0.00 0.00 22/12246335 drifting_ships [490] + 0.00 0.00 27/12246335 sp_stormwinds [871] + 0.00 0.00 34/12246335 sp_viewreality [784] + 0.00 0.00 99/12246335 report_template [87] + 0.00 0.00 349/12246335 can_give_men [940] + 0.00 0.00 406/12246335 make_fighter [424] + 0.00 0.00 450/12246335 spellpower [1000] + 0.00 0.00 452/12246335 fumble [973] + 0.00 0.00 488/12246335 give_men [857] + 0.00 0.00 508/12246335 regenerate_aura [346] + 0.00 0.00 1689/12246335 recruit [650] + 0.00 0.00 2815/12246335 count_faction [219] + 0.00 0.00 4020/12246335 curse_read [770] + 0.00 0.00 5358/12246335 max_spellpoints [755] + 0.00 0.00 5380/12246335 teach_cmd [272] + 0.00 0.00 5948/12246335 deathcounts [843] + 0.00 0.00 8515/12246335 describe [35] + 0.00 0.00 8573/12246335 magic_resistance [727] + 0.00 0.00 9250/12246335 movement_speed [155] + 0.00 0.00 16560/12246335 entertain_cmd [665] + 0.00 0.00 29173/12246335 horses [330] + 0.00 0.00 32649/12246335 growing_trees [624] + 0.00 0.00 37300/12246335 cr_output_region [10] + 0.00 0.00 39858/12246335 sail [181] + 0.00 0.00 67682/12246335 shipspeed [669] + 0.00 0.00 91155/12246335 godcurse [405] + 0.00 0.00 91483/12246335 orc_growth [370] + 0.00 0.00 94865/12246335 ageing [185] + 0.00 0.00 104368/12246335 roadto [606] + 0.00 0.00 159633/12246335 entertainmoney [643] + 0.00 0.00 169917/12246335 study_cmd [105] + 0.00 0.00 173175/12246335 can_survive [640] + 0.00 0.00 178254/12246335 maintain_buildings [339] + 0.00 0.00 282968/12246335 move_blocked [283] + 0.01 0.00 669051/12246335 production [417] + 0.01 0.00 733941/12246335 default_wage [173] + 0.02 0.00 1017568/12246335 report_items [103] + 0.02 0.00 1174371/12246335 terrain_name [226] + 0.12 0.00 7027859/12246335 att_modification [90] +[114] 0.6 0.21 0.00 12246335 ct_find [114] +----------------------------------------------- + 0.00 0.00 1/11241829 age_stonecircle [1021] + 0.00 0.00 4/11241829 claim_cmd [1242] + 0.00 0.00 26/11241829 gift_items [891] + 0.00 0.00 121/11241829 tolua_unit_add_item [1103] + 0.00 0.00 129/11241829 create_potion [821] + 0.00 0.00 306/11241829 manufacture [759] + 0.00 0.00 340/11241829 aftermath [701] + 0.00 0.00 1091/11241829 loot_items [810] + 0.00 0.00 2825/11241829 split_allocations [743] + 0.00 0.00 3221/11241829 terminate [242] + 0.00 0.00 5896/11241829 herbsearch [493] + 0.00 0.00 12859/11241829 breedhorses [742] + 0.00 0.00 22496/11241829 rotting_herbs [284] + 0.00 0.00 93119/11241829 give_item [126] + 0.01 0.00 282676/11241829 expandselling [93] + 0.01 0.00 347340/11241829 statistics [70] + 0.01 0.00 448447/11241829 read_items [320] + 0.01 0.00 788812/11241829 expandbuying [49] + 0.17 0.00 9232120/11241829 res_changeitem [101] +[115] 0.6 0.21 0.00 11241829 i_change [115] + 0.00 0.00 735776/822780 i_new [1375] + 0.00 0.00 98482/374425 i_free [1400] +----------------------------------------------- + 0.00 0.00 1/5100840 give_men [857] + 0.00 0.00 2/5100840 new_ship [1229] + 0.00 0.00 5/5100840 factionorders [983] + 0.00 0.00 11/5100840 new_building [1059] + 0.00 0.00 52/5100840 update_nmrs [1155] + 0.00 0.00 232/5100840 write_script [853] + 0.00 0.00 232/5100840 writepasswd [1074] + 0.00 0.00 233/5100840 readfaction [767] + 0.00 0.00 462/5100840 score [23] + 0.00 0.00 559/5100840 write_reports [3] + 0.00 0.00 1196/5100840 create_order [341] + 0.00 0.00 2008/5100840 default_name [851] + 0.00 0.00 17417/5100840 teach_cmd [272] + 0.00 0.00 18788/5100840 sideabkz [745] + 0.00 0.00 25857/5100840 eval_int36 [729] + 0.00 0.00 52225/5100840 report_template [87] + 0.00 0.00 56643/5100840 groupid [698] + 0.00 0.01 180818/5100840 write_buildingname [622] + 0.00 0.04 1065211/5100840 write_shipname [291] + 0.00 0.05 1295787/5100840 factionname [247] + 0.00 0.09 2383101/5100840 write_unitname [148] +[116] 0.6 0.00 0.20 5100840 itoa36 [116] + 0.20 0.00 5100840/5985780 itoab [107] +----------------------------------------------- + 0.00 0.00 1/1481407 tolua_unit_add_order [1276] + 0.00 0.00 47/1481407 give_peasants [1060] + 0.00 0.00 136/1481407 make_movement_order [522] + 0.00 0.00 232/1481407 defaultorders [249] + 0.01 0.07 606357/1481407 read_unit [74] + 0.01 0.10 874634/1481407 unitorders [46] +[117] 0.6 0.02 0.17 1481407 parse_order [117] + 0.04 0.04 1481407/1929215 create_order_i [175] + 0.00 0.05 1505792/2066777 parse_token_depr [220] + 0.03 0.02 1481407/1481616 get_keyword [274] + 0.00 0.00 24385/534930 isparam [668] +----------------------------------------------- + 0.00 0.00 22644/2248440 new_border [705] + 0.19 0.00 2225796/2248440 get_borders [120] +[118] 0.5 0.19 0.00 2248440 get_borders_i [118] +----------------------------------------------- + +[119] 0.5 0.19 0.00 bin_r_int_pak [119] +----------------------------------------------- + 0.00 0.00 22/2225796 rsetroad [1152] + 0.00 0.01 106203/2225796 travel_route [147] + 0.00 0.01 113487/2225796 next_region [601] + 0.00 0.01 143730/2225796 rroad [508] + 0.00 0.03 300501/2225796 move_blocked [283] + 0.00 0.06 765959/2225796 describe [35] + 0.00 0.07 795894/2225796 cr_borders [135] +[120] 0.5 0.00 0.19 2225796 get_borders [120] + 0.19 0.00 2225796/2248440 get_borders_i [118] +----------------------------------------------- + 0.00 0.01 123513/1470505 eval_order [472] + 0.00 0.01 128725/1470505 report_template [87] + 0.01 0.07 607926/1470505 writeorder [208] + 0.01 0.07 610341/1470505 stream_order [167] +[121] 0.5 0.02 0.17 1470505 write_order [121] + 0.04 0.13 1470478/2006524 get_command [108] +----------------------------------------------- + 0.00 0.00 8/2934859 sp_summon_familiar [1025] + 0.00 0.00 17/2934859 recruit_dracoids [837] + 0.00 0.00 44/2934859 plan_monsters [52] + 0.00 0.00 48/2934859 spy_message [1038] + 0.00 0.00 58/2934859 create_data [252] + 0.00 0.00 119/2934859 plan_dragon [273] + 0.00 0.00 20072/2934859 cr_skill [672] + 0.00 0.00 40099/2934859 eval_skill [671] + 0.00 0.02 317467/2934859 monster_learn [269] + 0.00 0.04 603246/2934859 cr_output_unit [19] + 0.01 0.12 1953681/2934859 spskill [53] +[122] 0.5 0.01 0.18 2934859 skillname [122] + 0.07 0.07 2934859/24887945 locale_string [27] + 0.01 0.03 2934859/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 1/888603 tolua_get_unit [1254] + 0.00 0.00 16/888603 verify_unit [1028] + 0.00 0.00 20/888603 restack_units [353] + 0.00 0.00 147/888603 contact_cmd [965] + 0.00 0.00 900/888603 follow_unit [331] + 0.00 0.00 9926/888603 resolve_unit [703] + 0.00 0.06 282468/888603 getunit [205] + 0.00 0.12 595125/888603 read_unit [74] +[123] 0.5 0.00 0.18 888603 findunit [123] + 0.17 0.01 888603/1118718 ufindhash [109] +----------------------------------------------- + +[124] 0.5 0.18 0.00 fs_write [124] +----------------------------------------------- + 0.00 0.00 54318/5387327 getstrtoken [710] + 0.02 0.01 984476/5387327 unitorders [46] + 0.05 0.02 2066777/5387327 parse_token_depr [220] + 0.06 0.02 2281756/5387327 gettoken [195] +[125] 0.5 0.13 0.05 5387327 parse_token [125] + 0.05 0.00 5306964/5329742 eatwhitespace_c [255] + 0.00 0.00 85158/46391457 unicode_utf8_to_ucs4 [177] +----------------------------------------------- + 0.00 0.18 95533/95533 give_cmd [102] +[126] 0.5 0.00 0.18 95533 give_item [126] + 0.02 0.06 93824/860263 use_pooled [39] + 0.01 0.04 95533/541982 get_pooled [104] + 0.01 0.02 94308/94420 add_give [379] + 0.02 0.00 51003/51003 give_money [484] + 0.01 0.00 283665/283711 item2resource [561] + 0.00 0.00 93119/11241829 i_change [115] + 0.00 0.00 41876/41882 GiveRestriction [836] + 0.00 0.00 93119/93119 give_quota [858] + 0.00 0.00 1225/41248 msg_feedback [647] + 0.00 0.00 1225/392959 add_message [434] + 0.00 0.00 2364/4851739 get_reservation [281] + 0.00 0.00 1761/1761 give_horses [1108] + 0.00 0.00 186260/1342832 handle_event [1363] + 0.00 0.00 93119/93120 change_reservation [1441] + 0.00 0.00 1225/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 2/6010308 claim_cmd [1242] + 0.00 0.00 11/6010308 build_road [950] + 0.00 0.00 1356/6010308 build [691] + 0.00 0.00 18400/6010308 give_cmd [102] + 0.02 0.00 595476/6010308 rotting_herbs [284] + 0.15 0.00 5395063/6010308 i_get [130] +[127] 0.5 0.17 0.00 6010308 i_find [127] +----------------------------------------------- + 0.03 0.01 178254/713016 enter_2 [295] + 0.09 0.03 534762/713016 enter_1 [145] +[128] 0.5 0.12 0.05 713016 do_enter [128] + 0.04 0.00 4529361/55492327 getkeyword [54] + 0.00 0.00 405/405 enter_building [695] + 0.00 0.00 222/222 enter_ship [733] + 0.00 0.00 639/228907 getid [483] + 0.00 0.00 639/2281756 gettoken [195] + 0.00 0.00 639/6530 findparam_ex [926] + 0.00 0.00 639/1027665 init_order [613] + 0.00 0.00 514/1936876 free_order [1356] +----------------------------------------------- + 0.01 0.15 105106/105106 plan_monsters [52] +[129] 0.5 0.01 0.15 105106 monster_move [129] + 0.00 0.11 84017/84017 random_neighbour [153] + 0.00 0.02 83723/83859 reduce_weight [404] + 0.00 0.01 83723/447808 create_order [341] + 0.00 0.00 83723/24887945 locale_string [27] + 0.00 0.00 84047/71815034 get_race [12] + 0.00 0.00 105106/1121103 monster_is_waiting [407] + 0.00 0.00 168094/129167539 u_race [89] + 0.00 0.00 30/30 treeman_neighbour [1201] +----------------------------------------------- + 0.00 0.00 4/5395063 damage_unit [1044] + 0.00 0.00 59/5395063 reshow_other [823] + 0.00 0.00 118/5395063 steal_cmd [766] + 0.00 0.00 170/5395063 breedhorses [742] + 0.00 0.00 225/5395063 spellpower [1000] + 0.00 0.00 242/5395063 canfly [1031] + 0.00 0.00 372/5395063 bewegung_blockiert_von [631] + 0.00 0.00 2594/5395063 make_fighter [424] + 0.00 0.00 2938/5395063 allocate_resource [752] + 0.00 0.00 5358/5395063 max_spellpoints [755] + 0.00 0.00 7957/5395063 magic_resistance [727] + 0.00 0.00 10900/5395063 terminate [242] + 0.00 0.00 47287/5395063 canswim [682] + 0.00 0.00 83224/5395063 trollbelts [677] + 0.00 0.00 85655/5395063 movement_speed [155] + 0.00 0.00 96637/5395063 walkingcapacity [403] + 0.00 0.01 279395/5395063 weight [459] + 0.00 0.02 566190/5395063 invisible [139] + 0.00 0.02 703334/5395063 make_summary [21] + 0.01 0.10 3502404/5395063 item_invis [149] +[130] 0.5 0.01 0.15 5395063 i_get [130] + 0.15 0.00 5395063/6010308 i_find [127] +----------------------------------------------- + 0.00 0.16 363071/363071 attack [84] +[131] 0.5 0.00 0.16 363071 hits [131] + 0.00 0.10 353422/353422 skilldiff [166] + 0.01 0.04 726142/1662377 get_unitrow [154] + 0.00 0.00 353422/353422 contest [654] + 0.00 0.00 706844/868104 select_armor [700] + 0.00 0.00 363071/1218663 select_weapon [1367] + 0.00 0.00 363071/619425 getreload [1385] +----------------------------------------------- + 0.00 0.00 1/967784 sp_holyground [1068] + 0.00 0.00 1/967784 sp_summonshadowlords [1034] + 0.00 0.00 1/967784 sp_generous [1040] + 0.00 0.00 1/967784 do_battle [64] + 0.00 0.00 1/967784 breedtrees [1148] + 0.00 0.00 1/967784 promotion_cmd [917] + 0.00 0.00 1/967784 age_stonecircle [1021] + 0.00 0.00 1/967784 verify_building [1255] + 0.00 0.00 1/967784 cast_cmd [760] + 0.00 0.00 1/967784 sp_flying_ship [1064] + 0.00 0.00 1/967784 use_skillpotion [1233] + 0.00 0.00 2/967784 sp_summon_familiar [1025] + 0.00 0.00 2/967784 sp_bloodsacrifice [1209] + 0.00 0.00 2/967784 sp_charmingsong [993] + 0.00 0.00 2/967784 sp_viewreality [784] + 0.00 0.00 2/967784 magic [157] + 0.00 0.00 2/967784 create_icebergs [538] + 0.00 0.00 2/967784 make_wormhole [1150] + 0.00 0.00 2/967784 summon_allies [925] + 0.00 0.00 3/967784 wormhole_age [1130] + 0.00 0.00 3/967784 sp_eternizewall [988] + 0.00 0.00 3/967784 report_failed_spell [1187] + 0.00 0.00 3/967784 begin_potion [1096] + 0.00 0.00 3/967784 give_control_cmd [287] + 0.00 0.00 3/967784 drown [394] + 0.00 0.00 3/967784 melt_iceberg [1082] + 0.00 0.00 3/967784 use_healingpotion [1119] + 0.00 0.00 4/967784 caught_target [1003] + 0.00 0.00 4/967784 movement_error [1193] + 0.00 0.00 4/967784 sp_goodwinds [974] + 0.00 0.00 4/967784 sp_enterastral [1045] + 0.00 0.00 4/967784 terminate [242] + 0.00 0.00 4/967784 give_men [857] + 0.00 0.00 4/967784 quit [276] + 0.00 0.00 4/967784 move_iceberg [1094] + 0.00 0.00 4/967784 factionorders [983] + 0.00 0.00 5/967784 sp_song_of_peace [939] + 0.00 0.00 6/967784 spy_cmd [990] + 0.00 0.00 6/967784 cinfo_skillmod [1192] + 0.00 0.00 7/967784 sp_healing [989] + 0.00 0.00 9/967784 sp_stormwinds [871] + 0.00 0.00 10/967784 spawn_dragons [411] + 0.00 0.00 12/967784 drifting_ships [490] + 0.00 0.00 12/967784 sp_mallornhain [968] + 0.00 0.00 12/967784 sp_summonundead [896] + 0.00 0.00 12/967784 forget_cmd [1093] + 0.00 0.00 13/967784 volcano_destruction [1022] + 0.00 0.00 15/967784 do_fumble [1062] + 0.00 0.00 18/967784 sp_hain [931] + 0.00 0.00 18/967784 do_attack [80] + 0.00 0.00 18/967784 attack_firesword [785] + 0.00 0.00 21/967784 sp_kampfzauber [957] + 0.00 0.00 21/967784 build_road [950] + 0.00 0.00 22/967784 spy_message [1038] + 0.00 0.00 24/967784 nmr_warnings [878] + 0.00 0.00 24/967784 cinfo_slave [1118] + 0.00 0.00 26/967784 sp_blessedharvest [847] + 0.00 0.00 28/967784 cinfo_speed [1110] + 0.00 0.00 30/967784 steal_cmd [766] + 0.00 0.00 32/967784 travel_i [92] + 0.00 0.00 37/967784 volcano_update [981] + 0.00 0.00 38/967784 expandstealing [807] + 0.00 0.00 39/967784 deliverMail [966] + 0.00 0.00 39/967784 display_item [1054] + 0.00 0.00 39/967784 random_growl [1065] + 0.00 0.00 41/967784 dissolve_units [241] + 0.00 0.00 48/967784 caddmessage [1070] + 0.00 0.00 51/967784 potion_water_of_life [945] + 0.00 0.00 51/967784 chaos [848] + 0.00 0.00 53/967784 sp_dragonodem [627] + 0.00 0.00 56/967784 use_bloodpotion [935] + 0.00 0.00 58/967784 add_recruits [371] + 0.00 0.00 71/967784 disband_men [999] + 0.00 0.00 88/967784 hunger [808] + 0.00 0.00 92/967784 spawn_undead [629] + 0.00 0.00 100/967784 age_reduceproduction [1017] + 0.00 0.00 110/967784 peasants [658] + 0.00 0.00 115/967784 build_ship [839] + 0.00 0.00 120/967784 plagues [781] + 0.00 0.00 129/967784 create_potion [821] + 0.00 0.00 163/967784 cinfo_shipnodrift [997] + 0.00 0.00 170/967784 breedhorses [742] + 0.00 0.00 174/967784 cinfo_magicrunes [996] + 0.00 0.00 306/967784 manufacture [759] + 0.00 0.00 325/967784 mail_cmd [844] + 0.00 0.00 345/967784 end_potion [814] + 0.00 0.00 349/967784 research_cmd [886] + 0.00 0.00 395/967784 reportcasualties [881] + 0.00 0.00 490/967784 build_building [696] + 0.00 0.00 508/967784 regenerate_aura [346] + 0.00 0.00 567/967784 eaten_by_monster [468] + 0.00 0.00 614/967784 print_fighters [616] + 0.00 0.00 676/967784 rp_battles [618] + 0.00 0.00 679/967784 print_header [838] + 0.00 0.00 681/967784 absorbed_by_monster [804] + 0.00 0.00 1080/967784 report_plaintext [4] + 0.00 0.00 1911/967784 cinfo_magicresistance [824] + 0.00 0.00 1992/967784 aftermath [701] + 0.00 0.00 2069/967784 nr_curses_i [401] + 0.00 0.00 2274/967784 cinfo_ship [812] + 0.00 0.00 2317/967784 print_stats [525] + 0.00 0.00 2594/967784 battle_report [503] + 0.00 0.00 2699/967784 scared_by_monster [380] + 0.00 0.00 2938/967784 split_allocations [743] + 0.00 0.00 5049/967784 piracy_cmd [660] + 0.00 0.00 5810/967784 report_transfer [724] + 0.00 0.00 5907/967784 cinfo_simple [751] + 0.00 0.00 5966/967784 herbsearch [493] + 0.00 0.00 7042/967784 sail [181] + 0.00 0.00 8710/967784 maintain_buildings [339] + 0.00 0.00 11358/967784 expandbuying [49] + 0.00 0.00 12398/967784 fbattlerecord [688] + 0.00 0.00 12448/967784 expandselling [93] + 0.00 0.00 14939/967784 maintain [478] + 0.00 0.00 15359/967784 cinfo_building [686] + 0.00 0.00 20072/967784 study_cmd [105] + 0.00 0.00 34409/967784 add_income [625] + 0.00 0.01 80478/967784 add_give [379] + 0.00 0.01 96460/967784 travel_route [147] + 0.01 0.02 163573/967784 describe [35] + 0.01 0.02 192618/967784 statistics [70] + 0.01 0.03 247009/967784 prices [85] +[132] 0.4 0.03 0.12 967784 msg_message [132] + 0.04 0.02 967784/1010116 mt_find [227] + 0.00 0.06 967784/1009159 msg_create [228] +----------------------------------------------- + 0.00 0.00 923/1351796 name_unit [803] + 0.01 0.14 1350873/1351796 bufunit [17] +[133] 0.4 0.01 0.14 1351796 racename [133] + 0.04 0.03 1460143/24887945 locale_string [27] + 0.01 0.03 1351796/2275429 raceprefix [222] + 0.01 0.01 1351796/2818494 rc_name_s [260] + 0.00 0.00 216694/34611296 strlcpy [45] + 0.00 0.00 108347/4133717 mkname [261] + 0.00 0.00 216694/36653945 wrptr [178] +----------------------------------------------- + 0.00 0.00 12/1375380 volcano_destruction [1022] + 0.01 0.00 127590/1375380 drown [394] + 0.02 0.00 178254/1375380 economics [78] + 0.11 0.01 1069524/1375380 remove_empty_units [146] +[134] 0.4 0.14 0.01 1375380 remove_empty_units_in_region [134] + 0.00 0.00 493/1794 remove_unit [499] + 0.00 0.00 4181205/24935046 faction_alive [451] + 0.00 0.00 7279/71815034 get_race [12] + 0.00 0.00 7279/129167539 u_race [89] +----------------------------------------------- + 0.06 0.09 209572/209572 cr_output_region [10] +[135] 0.4 0.06 0.09 209572 cr_borders [135] + 0.00 0.07 795894/2225796 get_borders [120] + 0.00 0.01 97014/143730 rroad [508] + 0.00 0.00 97017/24887945 locale_string [27] + 0.00 0.00 97017/190469 border_name [641] + 0.00 0.00 51044/369586 r_connect [474] + 0.00 0.00 97017/4133717 mkname [261] + 0.00 0.00 103026/196476 b_finvisible [1417] + 0.00 0.00 103026/196476 b_rvisibleroad [1418] + 0.00 0.00 97017/190467 b_transparent [1420] + 0.00 0.00 12323/26515 b_uinvisible [1487] +----------------------------------------------- + 0.00 0.00 1/1381157 make_familiar [1219] + 0.00 0.00 1/1381157 make_zombie [1267] + 0.00 0.00 2/1381157 summon_allies [925] + 0.00 0.00 4/1381157 heal [1224] + 0.00 0.00 6/1381157 skill_summoned [1032] + 0.00 0.00 8/1381157 age_firedragon [1123] + 0.00 0.00 10/1381157 age_dragon [1098] + 0.00 0.00 14/1381157 age_ghoul [1024] + 0.00 0.00 30/1381157 equip_unit_mask [776] + 0.00 0.00 34/1381157 age_zombie [1019] + 0.00 0.00 38/1381157 age_skeleton [1008] + 0.00 0.00 52/1381157 terminate [242] + 0.00 0.00 92/1381157 spawn_undead [629] + 0.00 0.00 369/1381157 add_recruits [371] + 0.00 0.00 2889/1381157 create_unit [296] + 0.00 0.00 8962/1381157 battle_flee [352] + 0.00 0.06 595454/1381157 monthly_healing [215] + 0.01 0.07 773191/1381157 hp_status [206] +[136] 0.4 0.01 0.13 1381157 unit_max_hp [136] + 0.04 0.06 1381157/12320804 effskill [100] + 0.02 0.00 1366398/10190660 get_curse [143] + 0.00 0.01 1381157/4984610 config_get_int [348] + 0.00 0.00 1381157/129167539 u_race [89] + 0.00 0.00 1366398/5152236 ct_changed [592] + 0.00 0.00 1/12246335 ct_find [114] +----------------------------------------------- + +[137] 0.4 0.14 0.00 fstream_done [137] +----------------------------------------------- + +[138] 0.4 0.14 0.00 ql_get [138] +----------------------------------------------- + 0.00 0.00 12/1753922 spy_cmd [990] + 0.00 0.00 8873/1753922 bewegung_blockiert_von [631] + 0.00 0.00 13580/1753922 cansee_unit [684] + 0.00 0.02 218268/1753922 cansee_durchgezogen [170] + 0.00 0.12 1513189/1753922 cansee [22] +[139] 0.4 0.00 0.14 1753922 invisible [139] + 0.01 0.11 1751202/1751202 item_invis [149] + 0.00 0.02 566190/5395063 i_get [130] + 0.00 0.00 566190/56052475 get_resourcetype [194] +----------------------------------------------- + 0.00 0.14 7179079/7179079 get_modifier [55] +[140] 0.4 0.00 0.14 7179079 rc_skillmod [140] + 0.05 0.03 7179079/7910500 r_isforest [199] + 0.02 0.03 7179079/7179079 skill_mod [264] + 0.01 0.00 7179079/21345834 skill_enabled [365] + 0.00 0.00 469309/12560453 rc_changed [256] + 0.00 0.00 1/71815034 get_race [12] +----------------------------------------------- + 0.01 0.12 113592/113592 report_plaintext [4] +[141] 0.4 0.01 0.12 113592 nr_building [141] + 0.05 0.00 113592/2742237 paragraph [26] + 0.04 0.00 113592/1766225 nr_curses [48] + 0.00 0.01 113592/218422 report_building [397] + 0.01 0.01 227343/24887945 locale_string [27] + 0.00 0.00 260073/34611296 strlcpy [45] + 0.00 0.00 113592/180818 buildingname [621] + 0.00 0.00 373665/36653945 wrptr [178] + 0.00 0.00 113592/2494242 newline [594] + 0.00 0.00 113592/147171 building_finished [1428] +----------------------------------------------- + 0.00 0.00 1/2383101 tolua_unit_tostring [1300] + 0.00 0.00 2/2383101 sp_igjarjuk [923] + 0.00 0.00 40/2383101 write_unit [97] + 0.00 0.00 122/2383101 eval_unit_dative [1076] + 0.00 0.00 75486/2383101 cb_cr_travelthru_unit [466] + 0.00 0.01 159282/2383101 cb_write_travelthru [169] + 0.00 0.04 799425/2383101 eval_unit [223] + 0.01 0.07 1348743/2383101 bufunit [17] +[142] 0.4 0.01 0.12 2383101 unitname [142] + 0.00 0.12 2383101/2383101 write_unitname [148] +----------------------------------------------- + 0.00 0.00 1/10190660 sp_generous [1040] + 0.00 0.00 2/10190660 sp_enterastral [1045] + 0.00 0.00 2/10190660 shipcurse_flyingship [1072] + 0.00 0.00 3/10190660 skilldiff [166] + 0.00 0.00 6/10190660 forget_cmd [1093] + 0.00 0.00 9/10190660 is_freezing [1088] + 0.00 0.00 10/10190660 sp_stormwinds [871] + 0.00 0.00 13/10190660 set_curseingmagician [1265] + 0.00 0.00 15/10190660 age_stonecircle [1021] + 0.00 0.00 17/10190660 produce [29] + 0.00 0.00 17/10190660 process [7] + 0.00 0.00 17/10190660 magic [157] + 0.00 0.00 22/10190660 drifting_ships [490] + 0.00 0.00 34/10190660 sp_viewreality [784] + 0.00 0.00 45/10190660 create_curse [800] + 0.00 0.00 349/10190660 can_give_men [940] + 0.00 0.00 406/10190660 make_fighter [424] + 0.00 0.00 450/10190660 spellpower [1000] + 0.00 0.00 452/10190660 fumble [973] + 0.00 0.00 488/10190660 give_men [857] + 0.00 0.00 508/10190660 regenerate_aura [346] + 0.00 0.00 1689/10190660 recruit [650] + 0.00 0.00 2815/10190660 count_faction [219] + 0.00 0.00 2974/10190660 start_battle [297] + 0.00 0.00 4309/10190660 report_template [87] + 0.00 0.00 5358/10190660 max_spellpoints [755] + 0.00 0.00 5380/10190660 teach_cmd [272] + 0.00 0.00 5948/10190660 deathcounts [843] + 0.00 0.00 7957/10190660 magic_resistance [727] + 0.00 0.00 8515/10190660 describe [35] + 0.00 0.00 9250/10190660 movement_speed [155] + 0.00 0.00 16560/10190660 entertain_cmd [665] + 0.00 0.00 19730/10190660 can_survive [640] + 0.00 0.00 29173/10190660 horses [330] + 0.00 0.00 32649/10190660 growing_trees [624] + 0.00 0.00 37300/10190660 cr_output_region [10] + 0.00 0.00 39858/10190660 sail [181] + 0.00 0.00 46175/10190660 maintain_buildings [339] + 0.00 0.00 67682/10190660 shipspeed [669] + 0.00 0.00 90436/10190660 spawn_undead [629] + 0.00 0.00 91155/10190660 godcurse [405] + 0.00 0.00 91176/10190660 monthly_healing [215] + 0.00 0.00 91483/10190660 orc_growth [370] + 0.00 0.00 94865/10190660 ageing [185] + 0.00 0.00 159633/10190660 entertainmoney [643] + 0.00 0.00 169917/10190660 study_cmd [105] + 0.00 0.00 208736/10190660 roadto [606] + 0.00 0.00 282968/10190660 move_blocked [283] + 0.01 0.00 669051/10190660 production [417] + 0.01 0.00 1017568/10190660 report_items [103] + 0.01 0.00 1041773/10190660 default_wage [173] + 0.01 0.00 1174371/10190660 terrain_name [226] + 0.02 0.00 1366398/10190660 unit_max_hp [136] + 0.04 0.00 3294942/10190660 att_modification [90] +[143] 0.4 0.13 0.00 10190660 get_curse [143] +----------------------------------------------- + 0.00 0.03 102149/386740 cr_output_region [10] + 0.00 0.03 104830/386740 cr_output_building [239] + 0.00 0.06 179761/386740 cr_output_ship [152] +[144] 0.4 0.00 0.13 386740 cr_output_curses_compat [144] + 0.12 0.01 386740/1310373 cr_output_curses [69] +----------------------------------------------- + 0.00 0.12 534762/534762 process [7] +[145] 0.4 0.00 0.12 534762 enter_1 [145] + 0.09 0.03 534762/713016 do_enter [128] +----------------------------------------------- + 0.00 0.02 1/6 reports [2] + 0.00 0.02 1/6 demographics [50] + 0.00 0.02 1/6 quit [276] + 0.00 0.02 1/6 processorders [6] + 0.00 0.02 1/6 magic [157] + 0.00 0.02 1/6 dissolve_units [241] +[146] 0.4 0.01 0.11 6 remove_empty_units [146] + 0.11 0.01 1069524/1375380 remove_empty_units_in_region [134] +----------------------------------------------- + 0.00 0.12 96482/96482 travel_i [92] +[147] 0.4 0.00 0.12 96482 travel_route [147] + 0.00 0.03 96240/103187 cycle_route [375] + 0.00 0.02 96240/109785 move_unit [421] + 0.00 0.01 105958/300501 move_blocked [283] + 0.00 0.01 96460/967784 msg_message [132] + 0.00 0.01 96240/192556 canride [465] + 0.00 0.01 106203/2225796 get_borders [120] + 0.00 0.01 96240/106919 mark_travelthru [610] + 0.00 0.01 9680/9680 bewegung_blockiert_von [631] + 0.00 0.00 96460/392959 add_message [434] + 0.00 0.00 106203/263302 reldirection [528] + 0.00 0.00 105958/71815034 get_race [12] + 0.00 0.00 346411/129167539 u_race [89] + 0.00 0.00 10581/472418 produceexp [322] + 0.00 0.00 192722/337987 setguard [815] + 0.00 0.00 1953/47287 canswim [682] + 0.00 0.00 234/242 canfly [1031] + 0.00 0.00 234/1874928 terrain_name [226] + 0.00 0.00 9/188 is_freezing [1088] + 0.00 0.00 2/15102 cmistake [718] + 0.00 0.00 105958/105958 entrance_allowed [1437] + 0.00 0.00 96460/1009028 msg_release [1373] + 0.00 0.00 96208/96208 var_copy_regions [1439] + 0.00 0.00 1727/744202 has_horses [1378] + 0.00 0.00 1567/59694 r_insectstalled [1446] +----------------------------------------------- + 0.00 0.12 2383101/2383101 unitname [142] +[148] 0.3 0.00 0.12 2383101 write_unitname [148] + 0.00 0.09 2383101/5100840 itoa36 [116] + 0.00 0.03 2383101/3351853 unit_getname [332] + 0.00 0.00 2383101/5461936 slprintf [548] +----------------------------------------------- + 0.01 0.11 1751202/1751202 invisible [139] +[149] 0.3 0.01 0.11 1751202 item_invis [149] + 0.01 0.10 3502404/5395063 i_get [130] + 0.01 0.00 3502404/56052475 get_resourcetype [194] +----------------------------------------------- + 0.01 0.00 1336242/11253756 genrand_real2 [395] + 0.02 0.00 2276433/11253756 scramble [244] + 0.08 0.00 7641081/11253756 genrand_int31 [171] +[150] 0.3 0.12 0.00 11253756 genrand_int32 [150] +----------------------------------------------- + 0.00 0.00 42/771861 loot_cmd [873] + 0.00 0.00 79/771861 can_guard [908] + 0.00 0.00 960/771861 tax_cmd [697] + 0.00 0.00 15347/771861 can_start_guarding [679] + 0.01 0.04 351667/771861 make_summary [21] + 0.01 0.05 403766/771861 is_guardian_r [186] +[151] 0.3 0.02 0.10 771861 armedmen [151] + 0.04 0.06 1327770/12320804 effskill [100] + 0.00 0.00 771861/7417541 urace [436] + 0.00 0.00 2375762/2379316 resource2weapon [1353] +----------------------------------------------- + 0.00 0.12 179761/179761 cr_output_region [10] +[152] 0.3 0.00 0.12 179761 cr_output_ship [152] + 0.00 0.06 179761/386740 cr_output_curses_compat [144] + 0.03 0.00 18850/47902 getshipweight [212] + 0.01 0.01 179761/4434556 translate [75] + 0.00 0.00 179761/24887945 locale_string [27] + 0.00 0.00 18850/47887 shipcapacity [567] + 0.00 0.00 18850/66134 shipspeed [669] + 0.00 0.00 160572/4503145 omniscient [470] +----------------------------------------------- + 0.00 0.11 84017/84017 monster_move [129] +[153] 0.3 0.00 0.11 84017 random_neighbour [153] + 0.02 0.08 742235/742235 room_for_race_in_region [165] + 0.00 0.01 797286/797288 can_survive [640] + 0.00 0.00 742235/129167539 u_race [89] + 0.00 0.00 84017/1087065 get_neighbours [480] + 0.00 0.00 83698/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 33/1662377 select_ally [1132] + 0.00 0.00 308/1662377 fighters [1012] + 0.00 0.00 25256/1662377 count_enemies_i [636] + 0.00 0.00 49445/1662377 count_side [666] + 0.01 0.04 726142/1662377 hits [131] + 0.01 0.05 861193/1662377 select_enemy [172] +[154] 0.3 0.02 0.09 1662377 get_unitrow [154] + 0.09 0.00 1390078/1390078 get_row [189] + 0.00 0.00 1662377/4301501 statusrow [550] +----------------------------------------------- + 0.00 0.11 96450/96450 travel_i [92] +[155] 0.3 0.00 0.11 96450 movement_speed [155] + 0.01 0.08 96316/2480226 old_race [14] + 0.00 0.01 96316/192556 canride [465] + 0.00 0.00 75870/1441945 is_mage [262] + 0.00 0.00 85655/5395063 i_get [130] + 0.00 0.00 85655/2858912 get_effect [225] + 0.00 0.00 85655/1177511 it_find [385] + 0.00 0.00 85643/987488 is_astral [479] + 0.00 0.00 278421/129167539 u_race [89] + 0.00 0.00 9250/12246335 ct_find [114] + 0.00 0.00 9250/10190660 get_curse [143] + 0.00 0.00 9/2977 change_effect [982] + 0.00 0.00 1/2426021 get_mage [198] +----------------------------------------------- + +[156] 0.3 0.02 0.09 ql_set_insert_ex [156] + 0.05 0.00 4746218/7252744 cmp_transfer [203] + 0.04 0.00 3573165/3573165 cmp_faction [305] +----------------------------------------------- + 0.01 0.10 1/1 process [7] +[157] 0.3 0.01 0.10 1 magic [157] + 0.01 0.04 1190864/71815034 get_race [12] + 0.00 0.02 1/6 remove_empty_units [146] + 0.00 0.02 595478/1441945 is_mage [262] + 0.01 0.00 1128316/55492327 getkeyword [54] + 0.00 0.00 1190864/129167539 u_race [89] + 0.00 0.00 222/222 cast_cmd [760] + 0.00 0.00 2/2 sp_viewreality [784] + 0.00 0.00 192/273 pay_spell [805] + 0.00 0.00 220/251 cancast [833] + 0.00 0.00 13/13 sp_blessedharvest [847] + 0.00 0.00 220/251 eff_spelllevel [845] + 0.00 0.00 9/9 sp_stormwinds [871] + 0.00 0.00 6/6 sp_summonundead [896] + 0.00 0.00 2062/2831 countspells [903] + 0.00 0.00 3/3 sp_song_of_peace [939] + 0.00 0.00 9/10 sp_hain [931] + 0.00 0.00 6/6 sp_mallornhain [968] + 0.00 0.00 4/4 sp_goodwinds [974] + 0.00 0.00 195/226 fumble [973] + 0.00 0.00 3/3 sp_eternizewall [988] + 0.00 0.00 3/3 sp_charmingsong [993] + 0.00 0.00 196/225 spellpower [1000] + 0.00 0.00 2/2 sp_summon_familiar [1025] + 0.00 0.00 196/196 verify_targets [1027] + 0.00 0.00 1/1 sp_summonshadowlords [1034] + 0.00 0.00 1/1 sp_generous [1040] + 0.00 0.00 1/1 sp_enterastral [1045] + 0.00 0.00 152/472418 produceexp [322] + 0.00 0.00 8/8 do_fumble [1062] + 0.00 0.00 1/1 sp_flying_ship [1064] + 0.00 0.00 1/1 sp_holyground [1068] + 0.00 0.00 2/2 sp_bloodsacrifice [1209] + 0.00 0.00 196/499 MagicPower [1195] + 0.00 0.00 2/967784 msg_message [132] + 0.00 0.00 17/12246335 ct_find [114] + 0.00 0.00 17/10190660 get_curse [143] + 0.00 0.00 2/392959 add_message [434] + 0.00 0.00 17/4201030 curse_active [543] + 0.00 0.00 1/1 sp_seduce [1336] + 0.00 0.00 8501/59694 r_insectstalled [1446] + 0.00 0.00 220/229 add_castorder [1626] + 0.00 0.00 220/608 co_get_region [1594] + 0.00 0.00 119/121 lua_callspell [1645] + 0.00 0.00 99/99 spl_costtyp [1650] + 0.00 0.00 17/651711 oldcursename [1381] + 0.00 0.00 9/3717 free_castorders [1541] + 0.00 0.00 2/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 28167/10103290 cr_output_curses [69] + 0.00 0.00 35101/10103290 cr_output_spells [639] + 0.01 0.00 610341/10103290 stream_order [167] + 0.10 0.00 9429681/10103290 cr_output_unit [19] +[158] 0.3 0.11 0.00 10103290 stream_printf [158] +----------------------------------------------- + +[159] 0.3 0.11 0.00 fs_writeln [159] +----------------------------------------------- + 0.01 0.10 363135/363135 attack [84] +[160] 0.3 0.01 0.10 363135 select_opponent [160] + 0.03 0.07 363135/372173 select_enemy [172] + 0.00 0.00 363135/129167539 u_race [89] +----------------------------------------------- + 0.00 0.02 146950/950595 f_regionid_s [477] + 0.01 0.08 803645/950595 describe [35] +[161] 0.3 0.01 0.10 950595 f_regionid [161] + 0.01 0.04 950595/1552289 rname [200] + 0.03 0.00 950595/1826688 adjust_coordinates [234] + 0.02 0.00 950595/34611296 strlcpy [45] + 0.00 0.00 950595/18647447 getplane [596] + 0.00 0.00 950595/3587241 pnormalize [1350] +----------------------------------------------- + 0.00 0.00 14/1205451 allysfm [1122] + 0.00 0.00 1449/1205451 nmr_warnings [878] + 0.00 0.00 5926/1205451 writefaction [762] + 0.00 0.00 10565/1205451 list_address [635] + 0.01 0.10 1187497/1205451 bufunit [17] +[162] 0.3 0.01 0.10 1205451 alliedfaction [162] + 0.07 0.02 1205451/10375491 alliedgroup [34] +----------------------------------------------- + 0.00 0.00 9680/1188532 bewegung_blockiert_von [631] + 0.00 0.00 9999/1188532 cansee_unit [684] + 0.00 0.02 208440/1188532 cansee_durchgezogen [170] + 0.02 0.07 960413/1188532 cansee [22] +[163] 0.3 0.02 0.09 1188532 eff_stealth [163] + 0.03 0.05 1188531/12320804 effskill [100] + 0.00 0.00 1188531/21345834 skill_enabled [365] + 0.00 0.00 4846/8034 u_geteffstealth [919] +----------------------------------------------- + 0.03 0.08 10375461/10375461 alliedgroup [34] +[164] 0.3 0.03 0.08 10375461 AllianceRestricted [164] + 0.01 0.03 10375461/10383360 HelpMask [288] + 0.01 0.02 10375461/20777534 config_get [224] +----------------------------------------------- + 0.02 0.08 742235/742235 random_neighbour [153] +[165] 0.3 0.02 0.08 742235 room_for_race_in_region [165] + 0.08 0.00 34058224/129167539 u_race [89] +----------------------------------------------- + 0.00 0.10 353422/353422 hits [131] +[166] 0.3 0.00 0.10 353422 skilldiff [166] + 0.02 0.07 706844/860166 weapon_effskill [168] + 0.00 0.01 463903/71815034 get_race [12] + 0.00 0.00 11599/11599 building_protection [708] + 0.00 0.00 464187/129167539 u_race [89] + 0.00 0.00 3/12246335 ct_find [114] + 0.00 0.00 3/10190660 get_curse [143] + 0.00 0.00 3/4201030 curse_active [543] + 0.00 0.00 706844/1218663 select_weapon [1367] +----------------------------------------------- + 0.01 0.09 610341/610341 cr_output_unit [19] +[167] 0.3 0.01 0.09 610341 stream_order [167] + 0.01 0.07 610341/1470505 write_order [121] + 0.01 0.00 610341/618305 escape_string [556] + 0.01 0.00 610341/10103290 stream_printf [158] +----------------------------------------------- + 0.00 0.01 153322/860166 terminate [242] + 0.02 0.07 706844/860166 skilldiff [166] +[168] 0.3 0.02 0.08 860166 weapon_effskill [168] + 0.01 0.05 489652/546579 weapon_skill [221] + 0.00 0.01 120592/137709 CavalryBonus [491] + 0.00 0.01 116873/12320804 skillmod [214] + 0.00 0.00 116873/7417541 urace [436] + 0.00 0.00 1601194/1726748 is_riding [1358] +----------------------------------------------- + 0.00 0.10 1048274/1048274 travelthru_map [41] +[169] 0.3 0.00 0.10 1048274 cb_write_travelthru [169] + 0.01 0.04 1028195/1996097 travelthru_cansee [180] + 0.02 0.00 55063/2742237 paragraph [26] + 0.00 0.02 435946/1065211 shipname [290] + 0.00 0.01 159282/2383101 unitname [142] + 0.00 0.00 35368/24887945 locale_string [27] +----------------------------------------------- + 0.01 0.03 613860/1747682 count_cb [231] + 0.02 0.05 1133822/1747682 travelthru_cansee [180] +[170] 0.3 0.03 0.07 1747682 cansee_durchgezogen [170] + 0.00 0.02 208440/1188532 eff_stealth [163] + 0.00 0.02 218268/1753922 invisible [139] + 0.00 0.02 1394913/6610983 is_guard [211] + 0.00 0.01 172836/12320804 effskill [100] + 0.00 0.00 1747682/129167539 u_race [89] + 0.00 0.00 1394913/4835422 usiege [593] +----------------------------------------------- + 0.00 0.00 1/7641081 select_familiar [1322] + 0.00 0.00 1/7641081 breedtrees [1148] + 0.00 0.00 1/7641081 use_bloodpotion [935] + 0.00 0.00 2/7641081 sp_charmingsong [993] + 0.00 0.00 3/7641081 select_wormhole_regions [909] + 0.00 0.00 6/7641081 randomevents [91] + 0.00 0.00 6/7641081 rrandneighbour [1221] + 0.00 0.00 10/7641081 do_fumble [1062] + 0.00 0.00 12/7641081 volcano_destruction [1022] + 0.00 0.00 13/7641081 newcontainerid [1263] + 0.00 0.00 15/7641081 drift_target [1053] + 0.00 0.00 15/7641081 random_unit [1174] + 0.00 0.00 21/7641081 do_combatspell [702] + 0.00 0.00 24/7641081 equip_unit_mask [776] + 0.00 0.00 25/7641081 treeman_neighbour [1201] + 0.00 0.00 27/7641081 nrand [1232] + 0.00 0.00 29/7641081 select_ally [1132] + 0.00 0.00 29/7641081 move_icebergs [534] + 0.00 0.00 36/7641081 expandloot [816] + 0.00 0.00 37/7641081 move_iceberg [1094] + 0.00 0.00 48/7641081 chaosterrain [1213] + 0.00 0.00 60/7641081 do_recruiting [351] + 0.00 0.00 83/7641081 fumble [973] + 0.00 0.00 92/7641081 dragon_name [1095] + 0.00 0.00 112/7641081 attack_firesword [785] + 0.00 0.00 116/7641081 terraform_default [1165] + 0.00 0.00 170/7641081 use_default [1149] + 0.00 0.00 176/7641081 default_spoil [1144] + 0.00 0.00 182/7641081 age_firedragon [1123] + 0.00 0.00 208/7641081 dracoid_name [1126] + 0.00 0.00 290/7641081 scramble_fighters [1116] + 0.00 0.00 295/7641081 age_dragon [1098] + 0.00 0.00 298/7641081 terraform_region [932] + 0.00 0.00 360/7641081 plan_dragon [273] + 0.00 0.00 412/7641081 piracy_cmd [660] + 0.00 0.00 503/7641081 expandwork [277] + 0.00 0.00 588/7641081 make_name [970] + 0.00 0.00 598/7641081 makename [1084] + 0.00 0.00 648/7641081 volcano_update [981] + 0.00 0.00 653/7641081 age_ghoul [1024] + 0.00 0.00 665/7641081 age_zombie [1019] + 0.00 0.00 725/7641081 age_skeleton [1008] + 0.00 0.00 1279/7641081 scale_number [969] + 0.00 0.00 1281/7641081 leveled_allocation [888] + 0.00 0.00 1596/7641081 attrib_allocation [914] + 0.00 0.00 1918/7641081 spawn_braineaters [505] + 0.00 0.00 2126/7641081 dissolve_units [241] + 0.00 0.00 2204/7641081 loot_items [810] + 0.00 0.00 2818/7641081 newunitid [319] + 0.00 0.00 3890/7641081 chaos [848] + 0.00 0.00 9552/7641081 spawn_undead [629] + 0.00 0.00 11021/7641081 drain_exp [850] + 0.00 0.00 11540/7641081 absorbed_by_monster [804] + 0.00 0.00 13338/7641081 terminate [242] + 0.00 0.00 17902/7641081 make_fighter [424] + 0.00 0.00 18025/7641081 chaos_update [514] + 0.00 0.00 18444/7641081 demon_skillchange [826] + 0.00 0.00 33436/7641081 scareaway [768] + 0.00 0.00 39919/7641081 sail [181] + 0.00 0.00 41004/7641081 dice [787] + 0.00 0.00 47310/7641081 attack [84] + 0.00 0.00 60896/7641081 breedhorses [742] + 0.00 0.00 83698/7641081 random_neighbour [153] + 0.00 0.00 139786/7641081 spawn_dragons [411] + 0.00 0.00 204245/7641081 term_eval [410] + 0.00 0.00 317467/7641081 monster_learn [269] + 0.00 0.00 325282/7641081 eaten_by_monster [468] + 0.00 0.00 325825/7641081 scared_by_monster [380] + 0.00 0.00 361320/7641081 growing_trees [624] + 0.00 0.00 372078/7641081 select_enemy [172] + 0.00 0.00 373896/7641081 contest_classic [655] + 0.00 0.00 403488/7641081 lovar [644] + 0.00 0.01 479588/7641081 learn_skill [471] + 0.00 0.01 889716/7641081 skill_weeks [509] + 0.01 0.03 3017598/7641081 growing_herbs [300] +[171] 0.3 0.02 0.08 7641081 genrand_int31 [171] + 0.08 0.00 7641081/11253756 genrand_int32 [150] +----------------------------------------------- + 0.00 0.00 45/372173 sp_kampfzauber [957] + 0.00 0.00 580/372173 attack_firesword [785] + 0.00 0.00 1100/372173 loot_items [810] + 0.00 0.00 7313/372173 sp_dragonodem [627] + 0.03 0.07 363135/372173 select_opponent [160] +[172] 0.3 0.03 0.07 372173 select_enemy [172] + 0.01 0.05 861193/1662377 get_unitrow [154] + 0.00 0.00 372078/7641081 genrand_int31 [171] + 0.00 0.00 372173/876979 count_enemies [611] + 0.00 0.00 1405349/4301501 statusrow [550] + 0.00 0.00 372173/129167539 u_race [89] +----------------------------------------------- + 0.03 0.07 490896/490896 wage [174] +[173] 0.3 0.03 0.07 490896 default_wage [173] + 0.01 0.02 169490/184870 buildingeffsize [367] + 0.01 0.00 1041773/10190660 get_curse [143] + 0.01 0.00 733941/12246335 ct_find [114] + 0.00 0.01 490896/490901 largestbuilding [651] + 0.00 0.00 125515/71815034 get_race [12] + 0.00 0.00 396300/1106528 is_building_type [554] + 0.00 0.00 307833/51974272 a_find [65] + 0.00 0.00 615666/4201030 curse_active [543] + 0.00 0.00 490896/5152236 ct_changed [592] + 0.00 0.00 426107/508632 rule_blessed_harvest [1327] + 0.00 0.00 426107/515192 is_mourning [1392] + 0.00 0.00 426107/432940 curse_geteffect [1395] +----------------------------------------------- + 0.00 0.00 10477/490896 report_template [87] + 0.00 0.00 10979/490896 do_work [612] + 0.00 0.01 32354/490896 statistics [70] + 0.00 0.01 32670/490896 demographics [50] + 0.00 0.01 36929/490896 cr_output_region [10] + 0.00 0.04 178254/490896 immigration [294] + 0.00 0.04 189233/490896 expandwork [277] +[174] 0.3 0.00 0.10 490896 wage [174] + 0.03 0.07 490896/490896 default_wage [173] +----------------------------------------------- + 0.01 0.01 447808/1929215 create_order [341] + 0.04 0.04 1481407/1929215 parse_order [117] +[175] 0.3 0.05 0.05 1929215 create_order_i [175] + 0.02 0.03 1929215/1929215 create_data [252] + 0.00 0.00 1929215/2124526 locale_index [1354] + 0.00 0.00 1207012/11194781 keyword_disabled [1348] +----------------------------------------------- + 0.00 0.00 78/13102790 eval_weight [1102] + 0.00 0.00 108/13102790 eval_add [1182] + 0.00 0.00 124/13102790 eval_unit_dative [1076] + 0.00 0.00 326/13102790 eval_lt [539] + 0.00 0.00 604/13102790 eval_spell [961] + 0.00 0.00 834/13102790 eval_resources [907] + 0.00 0.00 1196/13102790 eval_localize [922] + 0.00 0.00 3040/13102790 eval_race [882] + 0.00 0.00 19545/13102790 eval_ship [740] + 0.00 0.00 25857/13102790 eval_int36 [729] + 0.00 0.00 40099/13102790 eval_skill [671] + 0.00 0.00 46224/13102790 eval_faction [685] + 0.00 0.00 67213/13102790 eval_building [494] + 0.00 0.00 108560/13102790 eval_trail [634] + 0.00 0.00 116804/13102790 eval_isnull [517] + 0.00 0.00 123513/13102790 eval_order [472] + 0.00 0.00 127674/13102790 eval_trailto [369] + 0.00 0.00 127788/13102790 eval_direction [608] + 0.00 0.00 515550/13102790 eval_region [245] + 0.01 0.00 799427/13102790 eval_unit [223] + 0.01 0.00 883617/13102790 eval_int [268] + 0.01 0.00 941058/13102790 eval_resource [328] + 0.01 0.00 1311128/13102790 eval_eq [398] + 0.01 0.00 1380398/13102790 translate [28] + 0.02 0.00 2530635/13102790 eval_if [393] + 0.03 0.00 3931390/13102790 parse_string [86] +[176] 0.3 0.10 0.00 13102790 opstack_pop [176] +----------------------------------------------- + 0.00 0.00 130/46391457 transliterate [358] + 0.00 0.00 248/46391457 unicode_utf8_strcasecmp [1216] + 0.00 0.00 5132/46391457 eatwhitespace_c [255] + 0.00 0.00 85158/46391457 parse_token [125] + 0.00 0.00 176717/46391457 addtoken [811] + 0.00 0.00 1232688/46391457 findtoken [501] + 0.01 0.00 6696209/46391457 eatwhite [243] + 0.08 0.00 38195175/46391457 getbuf_utf8 [72] +[177] 0.3 0.10 0.00 46391457 unicode_utf8_to_ucs4 [177] +----------------------------------------------- + 0.00 0.00 15/36653945 sp_summon_familiar [1025] + 0.00 0.00 191/36653945 follow_ship [749] + 0.00 0.00 456/36653945 display_race [963] + 0.00 0.00 527/36653945 make_movement_order [522] + 0.00 0.00 1490/36653945 eval_resources [907] + 0.00 0.00 5871/36653945 report_plaintext [4] + 0.00 0.00 7912/36653945 nr_spell_syntax [732] + 0.00 0.00 12000/36653945 nr_spell [507] + 0.00 0.00 19276/36653945 eval_trail [634] + 0.00 0.00 97114/36653945 guards [229] + 0.00 0.00 107804/36653945 report_template [87] + 0.00 0.00 216694/36653945 racename [133] + 0.00 0.00 293954/36653945 show_allies [429] + 0.00 0.00 373665/36653945 nr_building [141] + 0.00 0.00 425391/36653945 create_order [341] + 0.00 0.00 743981/36653945 nr_ship [111] + 0.00 0.00 776314/36653945 prices [85] + 0.01 0.00 1958340/36653945 spskill [53] + 0.01 0.00 3889315/36653945 get_command [108] + 0.01 0.00 4194164/36653945 describe [35] + 0.02 0.00 6078454/36653945 bufunit [17] + 0.05 0.00 17451017/36653945 strlcpy_w [67] +[178] 0.3 0.10 0.00 36653945 wrptr [178] +----------------------------------------------- + 0.03 0.01 9004040/20834979 alliedunit [31] + 0.05 0.01 11830939/20834979 alliedgroup [34] +[179] 0.3 0.08 0.02 20834979 autoalliance [179] + 0.02 0.00 20834975/20836359 f_get_alliance [455] +----------------------------------------------- + 0.00 0.00 94066/1996097 cb_cr_travelthru_unit [466] + 0.01 0.03 873836/1996097 cb_cr_travelthru_ship [204] + 0.01 0.04 1028195/1996097 cb_write_travelthru [169] +[180] 0.3 0.02 0.08 1996097 travelthru_cansee [180] + 0.02 0.05 1133822/1747682 cansee_durchgezogen [170] + 0.01 0.00 1731771/3358315 ship_owner [438] +----------------------------------------------- + 0.01 0.09 7255/7255 move_cmd [66] +[181] 0.3 0.01 0.09 7255 sail [181] + 0.00 0.03 7254/7254 ship_ready [354] + 0.02 0.01 6947/6963 move_ship [374] + 0.00 0.00 39714/300501 move_blocked [283] + 0.00 0.01 42665/252446 movewhere [350] + 0.00 0.00 39731/39810 check_ship_allowed [657] + 0.00 0.00 47093/66134 shipspeed [669] + 0.00 0.00 6947/103187 cycle_route [375] + 0.00 0.00 6947/12933 owner_buildingtyp [676] + 0.00 0.00 42665/54318 getstrtoken [710] + 0.00 0.00 7042/967784 msg_message [132] + 0.00 0.00 6947/560926 bt_find [237] + 0.00 0.00 39858/12246335 ct_find [114] + 0.00 0.00 39926/39926 check_leuchtturm [786] + 0.00 0.00 39919/7641081 genrand_int31 [171] + 0.00 0.00 39858/10190660 get_curse [143] + 0.00 0.00 7043/392959 add_message [434] + 0.00 0.00 4325/4361 can_takeoff [854] + 0.00 0.00 6947/6962 set_coast [875] + 0.00 0.00 1613/9953180 alliedunit [31] + 0.00 0.00 39858/4201030 curse_active [543] + 0.00 0.00 14510/4984610 config_get_int [348] + 0.00 0.00 7273/717218 config_get_flt [714] + 0.00 0.00 191/324 caught_target [1003] + 0.00 0.00 112/15102 cmistake [718] + 0.00 0.00 951/955 movement_error [1193] + 0.00 0.00 8/369586 r_connect [474] + 0.00 0.00 4/12320804 effskill [100] + 0.00 0.00 39909/44216 flying_ship [1465] + 0.00 0.00 39904/40692 get_gamedate [1466] + 0.00 0.00 39714/192815 add_regionlist [1419] + 0.00 0.00 7043/1009028 msg_release [1373] + 0.00 0.00 6947/1291427 set_order [1365] + 0.00 0.00 149/651711 oldcursename [1381] + 0.00 0.00 29/160 damage_ship [1641] +----------------------------------------------- + 0.00 0.09 799/799 process [7] +[182] 0.3 0.00 0.09 799 setstealth_cmd [182] + 0.01 0.08 150/150 set_factionstealth [183] + 0.00 0.00 209/40046 rule_stealth_other [530] + 0.00 0.00 1238/2281756 gettoken [195] + 0.00 0.00 231/338 findrace [1030] + 0.00 0.00 209/1481616 get_keyword [274] + 0.00 0.00 799/1027665 init_order [613] + 0.00 0.00 209/688711 atoi36 [440] + 0.00 0.00 461/1787006 findparam [458] + 0.00 0.00 150/4625636 findfaction [259] + 0.00 0.00 569/569 u_seteffstealth [1199] + 0.00 0.00 231/21345834 skill_enabled [365] + 0.00 0.00 2/12320804 effskill [100] + 0.00 0.00 59/178429 a_removeall [958] + 0.00 0.00 230/154110 rule_stealth_anon [1325] +----------------------------------------------- + 0.01 0.08 150/150 setstealth_cmd [182] +[183] 0.3 0.01 0.08 150 set_factionstealth [183] + 0.00 0.08 856373/4374788 visible_faction [68] + 0.00 0.00 109/1437425 cansee [22] + 0.00 0.00 104/51974272 a_find [65] + 0.00 0.00 2/779419 a_add [555] + 0.00 0.00 2/433 make_otherfaction [1603] +----------------------------------------------- + 0.02 0.07 313244/313244 plan_monsters [52] +[184] 0.3 0.02 0.07 313244 check_overpopulated [184] + 0.07 0.00 29944440/129167539 u_race [89] +----------------------------------------------- + 0.04 0.05 1/1 processorders [6] +[185] 0.3 0.04 0.05 1 ageing [185] + 0.02 0.01 1190908/2858912 get_effect [225] + 0.01 0.00 614764/839202 a_age [418] + 0.00 0.00 178254/178254 age_region [659] + 0.00 0.00 94865/12246335 ct_find [114] + 0.00 0.00 46184/46184 age_building [712] + 0.00 0.00 94865/10190660 get_curse [143] + 0.00 0.00 94865/4201030 curse_active [543] + 0.00 0.00 178254/1613387 rule_region_owners [1323] + 0.00 0.00 614764/1342832 handle_event [1363] + 0.00 0.00 94865/651711 oldcursename [1381] + 0.00 0.00 1/1 age_borders [1789] +----------------------------------------------- + 0.00 0.02 1841323/8452306 is_guarded [377] + 0.02 0.06 6610983/8452306 is_guard [211] +[186] 0.3 0.02 0.07 8452306 is_guardian_r [186] + 0.01 0.05 403766/771861 armedmen [151] + 0.01 0.00 8451974/8506411 besieged [547] + 0.00 0.00 3241/129167539 u_race [89] + 0.00 0.00 913774/1613387 rule_region_owners [1323] +----------------------------------------------- + 0.00 0.00 9/7120688 destroyfaction [392] + 0.00 0.00 43/7120688 plan_dragon [273] + 0.00 0.00 752/7120688 monster_attacks [248] + 0.00 0.00 11448/7120688 all_money [529] + 0.00 0.00 45033/7120688 report_template [87] + 0.00 0.00 106798/7120688 help_feed [678] + 0.00 0.00 174965/7120688 cr_output_unit [19] + 0.01 0.00 1191719/7120688 score [23] + 0.02 0.00 1543013/7120688 make_summary [21] + 0.05 0.01 4046908/7120688 get_food [88] +[187] 0.3 0.08 0.01 7120688 get_money [187] + 0.01 0.00 7120688/56052475 get_resourcetype [194] +----------------------------------------------- + 0.00 0.00 102149/50553492 cr_output_region [10] + 0.04 0.00 21341107/50553492 report_plaintext [4] + 0.05 0.00 29110236/50553492 get_addresses [20] +[188] 0.3 0.09 0.00 50553492 stealth_modifier [188] +----------------------------------------------- + 0.09 0.00 1390078/1390078 get_unitrow [154] +[189] 0.3 0.09 0.00 1390078 get_row [189] +----------------------------------------------- + 0.00 0.00 1/1248014 report_summary [614] + 0.00 0.00 1/1248014 write_planes [1207] + 0.00 0.00 232/1248014 writefaction [762] + 0.04 0.00 534764/1248014 write_game [83] + 0.05 0.00 713016/1248014 make_summary [21] +[190] 0.3 0.09 0.00 1248014 listlen [190] +----------------------------------------------- + 0.09 0.00 297222/297222 render_messages [58] +[191] 0.3 0.09 0.00 297222 fwritestr [191] +----------------------------------------------- + +[192] 0.3 0.09 0.00 qli_more [192] +----------------------------------------------- + 0.00 0.00 224/2624955 give_unit [952] + 0.00 0.00 589/2624955 study_cmd [105] + 0.00 0.00 659/2624955 can_give_men [940] + 0.00 0.00 1758/2624955 give_men [857] + 0.00 0.00 3340/2624955 recruit [650] + 0.00 0.00 5253/2624955 count_skill [868] + 0.01 0.00 187111/2624955 orc_growth [370] + 0.08 0.00 2426021/2624955 get_mage [198] +[193] 0.3 0.09 0.00 2624955 has_skill [193] +----------------------------------------------- + 0.00 0.00 1/56052475 sp_seduce [1336] + 0.00 0.00 1/56052475 plant [1184] + 0.00 0.00 1/56052475 planttrees [1206] + 0.00 0.00 1/56052475 promotion_cmd [917] + 0.00 0.00 2/56052475 breedtrees [1148] + 0.00 0.00 2/56052475 make_summary [21] + 0.00 0.00 5/56052475 set_money [1326] + 0.00 0.00 41/56052475 expandstealing [807] + 0.00 0.00 55/56052475 build_road [950] + 0.00 0.00 99/56052475 report_template [87] + 0.00 0.00 111/56052475 steal_cmd [766] + 0.00 0.00 112/56052475 give_unit [952] + 0.00 0.00 124/56052475 age_stonecircle [1021] + 0.00 0.00 174/56052475 breedhorses [742] + 0.00 0.00 251/56052475 eff_spelllevel [845] + 0.00 0.00 251/56052475 cancast [833] + 0.00 0.00 273/56052475 pay_spell [805] + 0.00 0.00 404/56052475 academy_can_teach [527] + 0.00 0.00 505/56052475 mm_smithy [1203] + 0.00 0.00 521/56052475 breed_cmd [741] + 0.00 0.00 767/56052475 spellcost [995] + 0.00 0.00 1356/56052475 build [691] + 0.00 0.00 3335/56052475 region_setresource [1097] + 0.00 0.00 3340/56052475 do_recruiting [351] + 0.00 0.00 3359/56052475 recruit [650] + 0.00 0.00 3606/56052475 gift_items [891] + 0.00 0.00 3891/56052475 make_fighter [424] + 0.00 0.00 5494/56052475 expandbuying [49] + 0.00 0.00 5877/56052475 allocate_resource [752] + 0.00 0.00 6714/56052475 region_getresource [1058] + 0.00 0.00 7957/56052475 magic_resistance [727] + 0.00 0.00 9680/56052475 bewegung_blockiert_von [631] + 0.00 0.00 15296/56052475 study_cmd [105] + 0.00 0.00 83871/56052475 reduce_weight [404] + 0.00 0.00 93119/56052475 limited_give [879] + 0.00 0.00 96621/56052475 describe [35] + 0.00 0.00 279395/56052475 weight [459] + 0.00 0.00 325282/56052475 eaten_by_monster [468] + 0.00 0.00 350742/56052475 horse_fleeing_bonus [604] + 0.00 0.00 566190/56052475 invisible [139] + 0.00 0.00 577668/56052475 canride [465] + 0.00 0.00 2599554/56052475 change_money [337] + 0.01 0.00 3502404/56052475 item_invis [149] + 0.01 0.00 7120688/56052475 get_money [187] + 0.01 0.00 9703478/56052475 get_reservation [281] + 0.02 0.00 12353561/56052475 report_item [106] + 0.03 0.00 18326296/56052475 golem_factor [265] +[194] 0.2 0.09 0.00 56052475 get_resourcetype [194] + 0.00 0.00 310783/2032164 rt_find [597] +----------------------------------------------- + 0.00 0.00 1/2281756 destroy_road [1230] + 0.00 0.00 3/2281756 claim_cmd [1242] + 0.00 0.00 6/2281756 send_cmd [1202] + 0.00 0.00 12/2281756 forget_cmd [1093] + 0.00 0.00 20/2281756 restack_units [353] + 0.00 0.00 38/2281756 destroy_cmd [1113] + 0.00 0.00 100/2281756 combatspell_cmd [898] + 0.00 0.00 179/2281756 breed_cmd [741] + 0.00 0.00 241/2281756 reshow_cmd [818] + 0.00 0.00 250/2281756 renumber_cmd [780] + 0.00 0.00 262/2281756 defaultorders [249] + 0.00 0.00 286/2281756 factionorders [983] + 0.00 0.00 348/2281756 mail_cmd [844] + 0.00 0.00 378/2281756 recruit [650] + 0.00 0.00 395/2281756 cast_cmd [760] + 0.00 0.00 639/2281756 do_enter [128] + 0.00 0.00 677/2281756 ally_cmd [877] + 0.00 0.00 754/2281756 new_units [282] + 0.00 0.00 900/2281756 use_cmd [763] + 0.00 0.00 1238/2281756 setstealth_cmd [182] + 0.00 0.00 1700/2281756 status_cmd [904] + 0.00 0.00 2013/2281756 display_cmd [859] + 0.00 0.00 3117/2281756 name_cmd [835] + 0.00 0.00 5762/2281756 buy [707] + 0.00 0.00 15176/2281756 make_cmd [383] + 0.00 0.00 31531/2281756 sell [498] + 0.00 0.00 57138/2281756 getint [699] + 0.00 0.00 69432/2281756 getparam [681] + 0.00 0.00 131765/2281756 give_control_cmd [287] + 0.00 0.00 142423/2281756 cycle_route [375] + 0.00 0.00 142776/2281756 reserve_i [213] + 0.00 0.01 209781/2281756 make_route [289] + 0.00 0.01 228907/2281756 getid [483] + 0.00 0.01 231035/2281756 give_cmd [102] + 0.00 0.01 283446/2281756 readorders [43] + 0.00 0.01 284005/2281756 read_unitid [413] + 0.00 0.01 435022/2281756 getskill [387] +[195] 0.2 0.01 0.08 2281756 gettoken [195] + 0.06 0.02 2281756/5387327 parse_token [125] +----------------------------------------------- + 0.01 0.07 301257/301257 render_messages [58] +[196] 0.2 0.01 0.07 301257 cr_render [196] + 0.03 0.01 301257/301257 crt_find [321] + 0.00 0.01 110167/110167 cr_resource [488] + 0.01 0.00 41095/41095 cr_order [489] + 0.00 0.00 133873/133873 cr_region [662] + 0.00 0.00 20072/20072 cr_skill [672] + 0.00 0.00 12407/12407 cr_regions [840] + 0.00 0.00 356/356 cr_race [949] + 0.00 0.00 210/210 cr_resources [960] + 0.00 0.00 279/279 cr_spell [1026] + 0.00 0.00 330438/330438 cr_unit [1403] + 0.00 0.00 279072/279072 cr_int [1406] + 0.00 0.00 31688/31688 cr_building [1481] + 0.00 0.00 23233/23233 cr_faction [1493] + 0.00 0.00 14994/14994 cr_string [1510] + 0.00 0.00 7153/7153 cr_ship [1530] +----------------------------------------------- + 0.00 0.00 36/10852 expandloot [816] + 0.00 0.00 41/10852 expandstealing [807] + 0.00 0.00 663/10852 expandtax [278] + 0.01 0.02 4628/10852 expandselling [93] + 0.02 0.03 5484/10852 expandbuying [49] +[197] 0.2 0.03 0.05 10852 expandorders [197] + 0.03 0.02 10846/10846 scramble [244] + 0.00 0.00 19315/1936876 free_order [1356] +----------------------------------------------- + 0.00 0.00 1/2426021 movement_speed [155] + 0.00 0.00 1/2426021 spy_message [1038] + 0.00 0.00 10/2426021 set_combatspell [1146] + 0.00 0.00 43/2426021 unset_combatspell [1167] + 0.00 0.00 226/2426021 fumble [973] + 0.00 0.00 412/2426021 teach_cmd [272] + 0.00 0.00 443/2426021 change_maxspellpoints [911] + 0.00 0.00 524/2426021 study_cmd [105] + 0.00 0.00 1201/2426021 change_spellpoints [971] + 0.00 0.00 1339/2426021 get_combatspelllevel [880] + 0.00 0.00 1717/2426021 update_spells [381] + 0.00 0.00 1873/2426021 set_spellpoints [933] + 0.00 0.00 2831/2426021 countspells [903] + 0.00 0.00 4875/2426021 get_combatspell [874] + 0.00 0.00 4915/2426021 get_spellpoints [872] + 0.00 0.00 5358/2426021 get_spchange [862] + 0.00 0.00 9493/2426021 spskill [53] + 0.00 0.01 174965/2426021 cr_output_unit [19] + 0.00 0.01 176043/2426021 faction_getmages [382] + 0.00 0.02 597806/2426021 unit_get_spellbook [427] + 0.00 0.05 1441945/2426021 is_mage [262] +[198] 0.2 0.00 0.08 2426021 get_mage [198] + 0.08 0.00 2426021/2624955 has_skill [193] + 0.00 0.00 71414/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 326/7910500 make_fighter [424] + 0.00 0.00 152504/7910500 plain_name [715] + 0.00 0.00 578591/7910500 heal_factor [619] + 0.05 0.03 7179079/7910500 rc_skillmod [140] +[199] 0.2 0.05 0.03 7910500 r_isforest [199] + 0.03 0.00 8199466/10053919 rtrees [302] +----------------------------------------------- + 0.00 0.00 18/1552289 dragon_name [1095] + 0.00 0.00 39/1552289 random_growl [1065] + 0.00 0.00 10477/1552289 report_template [87] + 0.00 0.00 77909/1552289 cr_output_region [10] + 0.01 0.02 513251/1552289 write_regionname [280] + 0.01 0.04 950595/1552289 f_regionid [161] +[200] 0.2 0.02 0.06 1552289 rname [200] + 0.02 0.02 751188/24887945 locale_string [27] + 0.00 0.02 752225/1874928 terrain_name [226] +----------------------------------------------- + 0.00 0.08 494960/494960 bufunit [17] +[201] 0.2 0.00 0.08 494960 buforder [201] + 0.01 0.04 494960/2006524 get_command [108] + 0.00 0.02 989920/17451017 strlcpy_w [67] +----------------------------------------------- + 0.00 0.00 54/13102790 eval_add [1182] + 0.00 0.00 78/13102790 eval_weight [1102] + 0.00 0.00 124/13102790 eval_unit_dative [1076] + 0.00 0.00 163/13102790 eval_lt [539] + 0.00 0.00 604/13102790 eval_spell [961] + 0.00 0.00 834/13102790 eval_resources [907] + 0.00 0.00 1196/13102790 eval_localize [922] + 0.00 0.00 1520/13102790 eval_race [882] + 0.00 0.00 19545/13102790 eval_ship [740] + 0.00 0.00 25857/13102790 eval_int36 [729] + 0.00 0.00 40099/13102790 eval_skill [671] + 0.00 0.00 46224/13102790 eval_faction [685] + 0.00 0.00 67213/13102790 eval_building [494] + 0.00 0.00 108560/13102790 eval_trail [634] + 0.00 0.00 116804/13102790 eval_isnull [517] + 0.00 0.00 123513/13102790 eval_order [472] + 0.00 0.00 127674/13102790 eval_trailto [369] + 0.00 0.00 127788/13102790 eval_direction [608] + 0.00 0.00 470529/13102790 eval_resource [328] + 0.00 0.00 515550/13102790 eval_region [245] + 0.00 0.00 655564/13102790 eval_eq [398] + 0.00 0.00 799427/13102790 eval_unit [223] + 0.01 0.00 832876/13102790 parse_int [649] + 0.01 0.00 843545/13102790 eval_if [393] + 0.01 0.00 883617/13102790 eval_int [268] + 0.02 0.00 2725583/13102790 parse_string [86] + 0.03 0.00 4568249/13102790 parse_symbol [42] +[202] 0.2 0.08 0.00 13102790 opstack_push [202] +----------------------------------------------- + 0.03 0.00 2506526/7252744 ql_set_find_ex [373] + 0.05 0.00 4746218/7252744 ql_set_insert_ex [156] +[203] 0.2 0.08 0.00 7252744 cmp_transfer [203] +----------------------------------------------- + 0.02 0.06 967902/967902 travelthru_map [41] +[204] 0.2 0.02 0.06 967902 cb_cr_travelthru_ship [204] + 0.01 0.03 873836/1996097 travelthru_cansee [180] + 0.00 0.02 434165/1065211 shipname [290] +----------------------------------------------- + 0.00 0.00 16/282847 spy_cmd [990] + 0.00 0.00 65/282847 travel_i [92] + 0.00 0.00 70/282847 transport [1011] + 0.00 0.00 145/282847 init_transportation [384] + 0.00 0.00 1487/282847 start_battle [297] + 0.00 0.00 17577/282847 teach_cmd [272] + 0.00 0.04 131722/282847 give_cmd [102] + 0.00 0.04 131765/282847 give_control_cmd [287] +[205] 0.2 0.00 0.08 282847 getunit [205] + 0.00 0.06 282468/888603 findunit [123] + 0.00 0.02 282847/284005 read_unitid [413] +----------------------------------------------- + 0.00 0.02 174965/773191 cr_output_unit [19] + 0.00 0.06 598226/773191 bufunit [17] +[206] 0.2 0.00 0.08 773191 hp_status [206] + 0.01 0.07 773191/1381157 unit_max_hp [136] + 0.00 0.00 8974/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 19276/785221 eval_trail [634] + 0.00 0.01 127674/785221 eval_trailto [369] + 0.00 0.06 638271/785221 describe [35] +[207] 0.2 0.00 0.08 785221 trailinto [207] + 0.02 0.02 785221/24887945 locale_string [27] + 0.00 0.02 785221/1874928 terrain_name [226] + 0.01 0.00 785221/34611296 strlcpy [45] + 0.00 0.00 785221/987128 strlcat [1374] +----------------------------------------------- + 0.00 0.08 607926/607926 write_unit [97] +[208] 0.2 0.00 0.08 607926 writeorder [208] + 0.01 0.07 607926/1470505 write_order [121] +----------------------------------------------- + 0.00 0.08 178254/178254 read_game [62] +[209] 0.2 0.00 0.08 178254 readregion [209] + 0.00 0.05 178254/178254 new_region [275] + 0.01 0.00 32679/32727 rsetherbtype [537] + 0.00 0.01 178254/459083 findregion [420] + 0.00 0.01 178254/840577 read_attribs [388] + 0.00 0.00 178254/1206547 findplane [457] + 0.00 0.00 32679/628037 read_items [320] + 0.00 0.00 32679/264251 rsetpeasants [545] + 0.00 0.00 249361/2032164 rt_find [597] + 0.00 0.00 32679/2186159 rsetmoney [553] + 0.00 0.00 217392/217405 r_setdemand [1413] + 0.00 0.00 178254/178311 region_setinfo [1422] + 0.00 0.00 178254/178270 get_terrain [1423] + 0.00 0.00 98037/229715 rsettrees [1410] + 0.00 0.00 32679/257693 rsethorses [1408] + 0.00 0.00 32679/101322 rsetherbs [1438] + 0.00 0.00 32679/32727 region_set_morale [1476] + 0.00 0.00 32679/32679 read_owner [1477] + 0.00 0.00 25441/25441 rmt_find [1490] +----------------------------------------------- + 0.03 0.01 45630/108211 cr_output_resources [238] + 0.03 0.01 62581/108211 describe [35] +[210] 0.2 0.06 0.02 108211 report_resources [210] + 0.01 0.01 207188/12320804 effskill [100] + 0.00 0.00 182290/10053919 rtrees [302] + 0.00 0.00 91145/2605004 rpeasants [435] + 0.00 0.00 91145/4666665 rmoney [452] + 0.00 0.00 59445/9298667 resource2item [546] + 0.00 0.00 348444/348444 report_resource [1402] + 0.00 0.00 91145/1160345 rhorses [1369] + 0.00 0.00 7915/7915 visible_default [1525] +----------------------------------------------- + 0.00 0.00 3/6610983 destroy_road [1230] + 0.00 0.00 10/6610983 get_money_for_dragon [1087] + 0.00 0.00 6102/6610983 make_side [876] + 0.00 0.00 11880/6610983 cansee_unit [684] + 0.00 0.00 12762/6610983 plan_monsters [52] + 0.00 0.00 36821/6610983 allocate_resource [752] + 0.00 0.00 63046/6610983 is_guardian_u [626] + 0.00 0.00 216875/6610983 bewegung_blockiert_von [631] + 0.00 0.01 923633/6610983 cr_output_unit [19] + 0.00 0.01 1211531/6610983 cansee [22] + 0.00 0.02 1348743/6610983 bufunit [17] + 0.00 0.02 1384664/6610983 guards [229] + 0.00 0.02 1394913/6610983 cansee_durchgezogen [170] +[211] 0.2 0.00 0.08 6610983 is_guard [211] + 0.02 0.06 6610983/8452306 is_guardian_r [186] + 0.00 0.01 329691/329691 getguard [652] +----------------------------------------------- + 0.00 0.00 15/47902 overload [1002] + 0.02 0.00 10344/47902 cansail [469] + 0.03 0.00 18693/47902 nr_ship [111] + 0.03 0.00 18850/47902 cr_output_ship [152] +[212] 0.2 0.07 0.00 47902 getshipweight [212] + 0.00 0.00 70174/279395 weight [459] +----------------------------------------------- + 0.00 0.04 35708/71416 reserve_cmd [324] + 0.00 0.04 35708/71416 reserve_self [325] +[213] 0.2 0.00 0.07 71416 reserve_i [213] + 0.01 0.05 71328/860263 use_pooled [39] + 0.00 0.00 142776/2281756 gettoken [195] + 0.00 0.00 68977/931076 change_resource [240] + 0.00 0.00 31520/57138 getint [699] + 0.00 0.00 71388/1787006 findparam [458] + 0.00 0.00 71388/1027665 init_order [613] + 0.00 0.00 71364/191379 finditemtype [735] + 0.00 0.00 71390/7417541 urace [436] + 0.00 0.00 4/8302761 get_resource [99] + 0.00 0.00 140305/140305 set_resvalue [1430] + 0.00 0.00 71388/203117 atoip [1416] +----------------------------------------------- + 7179079 get_modifier [55] + 0.00 0.00 377/12320804 manufacture [759] + 0.00 0.00 1705/12320804 build [691] + 0.00 0.01 116873/12320804 weapon_effskill [168] +[214] 0.2 0.01 0.06 7298034 skillmod [214] + 0.06 0.00 7298034/51974272 a_find [65] + 0.00 0.00 8/8 mod_elves_only [1239] + 0.00 0.00 248/248 sm_smithy [1613] + 65155 sm_familiar [520] +----------------------------------------------- + 0.00 0.07 1/1 process [7] +[215] 0.2 0.00 0.07 1 monthly_healing [215] + 0.00 0.06 595454/1381157 unit_max_hp [136] + 0.00 0.01 578591/578591 heal_factor [619] + 0.00 0.00 595144/129167539 u_race [89] + 0.00 0.00 91176/10190660 get_curse [143] + 0.00 0.00 5206/560926 bt_find [237] + 0.00 0.00 7542/47287 canswim [682] + 0.00 0.00 5206/424669 active_building [560] + 0.00 0.00 2988/752645 chance [495] + 0.00 0.00 1/12246335 ct_find [114] +----------------------------------------------- + +[216] 0.2 0.07 0.00 bin_r_str_buf [216] +----------------------------------------------- + 0.00 0.00 2/760673 new_ship [1229] + 0.00 0.00 13/760673 read_planes [1164] + 0.00 0.00 17/760673 recruit_dracoids [837] + 0.00 0.00 42/760673 loot_cmd [873] + 0.00 0.00 59/760673 steal_cmd [766] + 0.00 0.00 232/760673 defaultorders [249] + 0.00 0.00 406/760673 faction_setorigin [979] + 0.00 0.00 736/760673 monster_attacks [248] + 0.00 0.00 948/760673 tax_cmd [697] + 0.00 0.00 1670/760673 recruit [650] + 0.00 0.00 2889/760673 move_unit [421] + 0.00 0.00 2889/760673 create_unit [296] + 0.00 0.00 5757/760673 buy [707] + 0.00 0.00 7630/760673 addstrlist [769] + 0.00 0.00 12520/760673 sell [498] + 0.01 0.00 113844/760673 translist [430] + 0.02 0.00 178254/760673 new_region [275] + 0.04 0.00 432765/760673 plan_monsters [52] +[217] 0.2 0.07 0.00 760673 addlist [217] +----------------------------------------------- + +[218] 0.2 0.07 0.00 bin_w_int_pak [218] +----------------------------------------------- + 0.00 0.00 45/2247 count_migrants [731] + 0.01 0.00 481/2247 count_units [487] + 0.02 0.00 754/2247 checkunitnumber [402] + 0.03 0.00 967/2247 count_all [357] +[219] 0.2 0.06 0.01 2247 count_faction [219] + 0.01 0.00 3891194/129167539 u_race [89] + 0.00 0.00 2815/12246335 ct_find [114] + 0.00 0.00 2815/10190660 get_curse [143] + 0.00 0.00 2815/4201030 curse_active [543] + 0.00 0.00 2815/651711 oldcursename [1381] +----------------------------------------------- + 0.00 0.02 560985/2066777 create_data [252] + 0.00 0.05 1505792/2066777 parse_order [117] +[220] 0.2 0.00 0.07 2066777 parse_token_depr [220] + 0.05 0.02 2066777/5387327 parse_token [125] +----------------------------------------------- + 0.00 0.01 56927/546579 make_fighter [424] + 0.01 0.05 489652/546579 weapon_effskill [168] +[221] 0.2 0.01 0.06 546579 weapon_skill [221] + 0.02 0.02 551693/12320804 effskill [100] + 0.00 0.01 236296/71815034 get_race [12] + 0.01 0.00 2284/3147 i_canuse [569] + 0.00 0.00 1555209/129167539 u_race [89] +----------------------------------------------- + 0.00 0.02 923633/2275429 cr_output_unit [19] + 0.01 0.03 1351796/2275429 racename [133] +[222] 0.2 0.01 0.06 2275429 raceprefix [222] + 0.03 0.02 2275429/2277350 get_prefix [263] + 0.01 0.00 847828/51974272 a_find [65] +----------------------------------------------- + 0.01 0.06 799427/799427 parse_symbol [42] +[223] 0.2 0.01 0.06 799427 eval_unit [223] + 0.00 0.04 799425/2383101 unitname [142] + 0.01 0.00 799427/13102790 opstack_pop [176] + 0.00 0.00 799427/13102790 opstack_push [202] + 0.00 0.00 799427/13399069 balloc [363] + 0.00 0.00 2/24887945 locale_string [27] +----------------------------------------------- + 0.00 0.00 1/20777534 parse_inifile [1317] + 0.00 0.00 2/20777534 init_locale [948] + 0.00 0.00 2/20777534 default_order [902] + 0.00 0.00 73/20777534 hunger_damage [1223] + 0.00 0.00 279/20777534 MagicPower [1195] + 0.00 0.00 462/20777534 game_name [1168] + 0.00 0.00 1297/20777534 AllianceAuto [535] + 0.00 0.00 16597/20777534 entertain_cmd [665] + 0.01 0.02 10375461/20777534 AllianceRestricted [164] + 0.01 0.02 10383360/20777534 HelpMask [288] +[224] 0.2 0.02 0.05 20777534 config_get [224] + 0.05 0.00 20777534/26776263 get_param [235] +----------------------------------------------- + 0.00 0.00 4/2858912 damage_unit [1044] + 0.00 0.00 11/2858912 build_road [950] + 0.00 0.00 1230/2858912 build [691] + 0.00 0.00 1297/2858912 make_fighter [424] + 0.00 0.00 2938/2858912 allocate_resource [752] + 0.00 0.00 5384/2858912 teach_cmd [272] + 0.00 0.00 43034/2858912 get_food [88] + 0.00 0.00 85655/2858912 movement_speed [155] + 0.00 0.00 96637/2858912 walkingcapacity [403] + 0.01 0.01 595472/2858912 live [73] + 0.01 0.01 836342/2858912 study_cmd [105] + 0.02 0.01 1190908/2858912 ageing [185] +[225] 0.2 0.04 0.02 2858912 get_effect [225] + 0.02 0.00 2858912/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 234/1874928 travel_route [147] + 0.00 0.00 127676/1874928 describe [35] + 0.00 0.01 209572/1874928 cr_output_region [10] + 0.00 0.02 752225/1874928 rname [200] + 0.00 0.02 785221/1874928 trailinto [207] +[226] 0.2 0.01 0.05 1874928 terrain_name [226] + 0.02 0.00 1174371/12246335 ct_find [114] + 0.01 0.00 1174371/10190660 get_curse [143] + 0.01 0.00 1646640/51974272 a_find [65] + 0.00 0.00 1174371/4201030 curse_active [543] + 0.00 0.00 152504/152504 plain_name [715] +----------------------------------------------- + 0.00 0.00 127/1010116 msg_create_message [1080] + 0.00 0.00 957/1010116 parse_messages [832] + 0.00 0.00 41248/1010116 msg_feedback [647] + 0.04 0.02 967784/1010116 msg_message [132] +[227] 0.2 0.04 0.02 1010116 mt_find [227] + 0.02 0.00 1010116/32337529 hashstring [37] +----------------------------------------------- + 0.00 0.00 6/1009159 msg_send_region [1210] + 0.00 0.00 121/1009159 msg_send_faction [1042] + 0.00 0.00 41248/1009159 msg_feedback [647] + 0.00 0.06 967784/1009159 msg_message [132] +[228] 0.2 0.00 0.06 1009159 msg_create [228] + 0.01 0.04 1009159/1009159 log_orders [251] + 0.01 0.00 2481220/2481220 copy_arg [521] +----------------------------------------------- + 0.02 0.04 62581/62581 report_plaintext [4] +[229] 0.2 0.02 0.04 62581 guards [229] + 0.00 0.02 1384664/6610983 is_guard [211] + 0.01 0.00 27498/2742237 paragraph [26] + 0.00 0.01 67332/4374788 visible_faction [68] + 0.00 0.00 60360/24887945 locale_string [27] + 0.00 0.00 97114/34611296 strlcpy [45] + 0.00 0.00 34482/1295787 factionname [247] + 0.00 0.00 97114/36653945 wrptr [178] + 0.00 0.00 27498/2494242 newline [594] +----------------------------------------------- + 0.00 0.06 595478/595478 process [7] +[230] 0.2 0.00 0.06 595478 monster_kills_peasants [230] + 0.01 0.02 325825/325825 scared_by_monster [380] + 0.01 0.01 325282/325282 eaten_by_monster [468] + 0.01 0.00 595478/1121103 monster_is_waiting [407] + 0.00 0.00 1469625/129167539 u_race [89] + 0.00 0.00 11540/11540 absorbed_by_monster [804] +----------------------------------------------- + 0.02 0.04 1054200/1054200 travelthru_map [41] +[231] 0.2 0.02 0.04 1054200 count_cb [231] + 0.01 0.03 613860/1747682 cansee_durchgezogen [170] + 0.01 0.00 875741/3358315 ship_owner [438] +----------------------------------------------- + 0.00 0.00 1/593636 give_control_cmd [287] + 0.00 0.00 1/593636 display_cmd [859] + 0.00 0.00 3/593636 try_rename [1225] + 0.00 0.00 5/593636 name_cmd [835] + 0.00 0.00 6/593636 bewegung_blockiert_von [631] + 0.00 0.00 6/593636 restack_units [353] + 0.00 0.00 26/593636 renumber_cmd [780] + 0.00 0.00 401/593636 mayenter [936] + 0.00 0.00 8710/593636 maintain_buildings [339] + 0.00 0.00 9465/593636 expandselling [93] + 0.00 0.00 11409/593636 lighthouse_range [728] + 0.00 0.00 12521/593636 report_template [87] + 0.00 0.00 21463/593636 maintain [478] + 0.00 0.00 28665/593636 owner_buildingtyp [676] + 0.00 0.00 37894/593636 reorder_units [400] + 0.00 0.00 47440/593636 write_unit [97] + 0.00 0.01 92368/593636 score [23] + 0.00 0.01 104830/593636 cr_output_curses [69] + 0.00 0.01 104830/593636 cr_output_region [10] + 0.00 0.01 113592/593636 nr_curses [48] +[232] 0.2 0.01 0.05 593636 building_owner [232] + 0.05 0.00 209480/209572 building_owner_ex [253] +----------------------------------------------- + 0.00 0.00 39/13259934 display_item [1054] + 0.00 0.00 352/13259934 cr_resources [960] + 0.00 0.00 446/13259934 print_items [938] + 0.00 0.00 628/13259934 add_itemname_cb [980] + 0.00 0.00 648/13259934 add_resourcename_cb [977] + 0.00 0.00 1490/13259934 eval_resources [907] + 0.00 0.00 1539/13259934 report_plaintext [4] + 0.00 0.00 1543/13259934 make_cmd [383] + 0.00 0.00 1876/13259934 report_computer [9] + 0.00 0.00 2073/13259934 cr_output_curses [69] + 0.00 0.00 2096/13259934 a_writeeffect [1073] + 0.00 0.00 3203/13259934 cr_reportspell [756] + 0.00 0.00 3203/13259934 nr_spell [507] + 0.00 0.00 96621/13259934 describe [35] + 0.00 0.00 110167/13259934 cr_resource [488] + 0.00 0.00 169153/13259934 statistics [70] + 0.00 0.00 218078/13259934 cr_output_region [10] + 0.00 0.00 249352/13259934 writeregion [519] + 0.00 0.00 448410/13259934 write_items [511] + 0.00 0.00 470529/13259934 eval_resource [328] + 0.05 0.00 11478488/13259934 report_item [106] +[233] 0.2 0.06 0.00 13259934 resourcename [233] +----------------------------------------------- + 0.00 0.00 493/1826688 report_computer [9] + 0.00 0.00 7499/1826688 cr_regions [840] + 0.00 0.00 10477/1826688 report_template [87] + 0.00 0.00 132705/1826688 cr_region [662] + 0.01 0.00 211668/1826688 cr_output_region [10] + 0.02 0.00 513251/1826688 write_regionname [280] + 0.03 0.00 950595/1826688 f_regionid [161] +[234] 0.2 0.06 0.00 1826688 adjust_coordinates [234] + 0.00 0.00 1785077/1785077 faction_getorigin [1357] + 0.00 0.00 221718/221723 plane_center_x [1411] + 0.00 0.00 221718/221723 plane_center_y [1412] + 0.00 0.00 221718/734392 plane_width [1380] + 0.00 0.00 221718/734392 plane_height [1379] +----------------------------------------------- + 0.00 0.00 88/26776263 hunger_damage [1223] + 0.00 0.00 216069/26776263 check_param [793] + 0.00 0.00 717287/26776263 get_param_flt [713] + 0.01 0.00 5065285/26776263 get_param_int [422] + 0.05 0.00 20777534/26776263 config_get [224] +[235] 0.2 0.06 0.00 26776263 get_param [235] +----------------------------------------------- + 0.00 0.00 39/560965 bt_get_or_create [1114] + 0.06 0.00 560926/560965 bt_find [237] +[236] 0.2 0.06 0.00 560965 bt_find_i [236] +----------------------------------------------- + 0.00 0.00 1/560926 buy [707] + 0.00 0.00 1/560926 breedhorses [742] + 0.00 0.00 1/560926 produce [29] + 0.00 0.00 1/560926 demographics [50] + 0.00 0.00 1/560926 wormholes_update [906] + 0.00 0.00 2/560926 sell [498] + 0.00 0.00 3/560926 expandselling [93] + 0.00 0.00 5/560926 build_road [950] + 0.00 0.00 6/560926 remove_building [1153] + 0.00 0.00 232/560926 prepare_report [8] + 0.00 0.00 322/560926 can_takeoff [854] + 0.00 0.00 1302/560926 academy_can_teach [527] + 0.00 0.00 5206/560926 monthly_healing [215] + 0.00 0.00 6947/560926 sail [181] + 0.00 0.00 9680/560926 bewegung_blockiert_von [631] + 0.00 0.00 31155/560926 statistics [70] + 0.00 0.00 39810/560926 check_ship_allowed [657] + 0.00 0.00 46176/560926 read_game [62] + 0.00 0.04 420075/560926 study_cmd [105] +[237] 0.2 0.00 0.06 560926 bt_find [237] + 0.06 0.00 560926/560965 bt_find_i [236] +----------------------------------------------- + 0.00 0.06 45630/45630 cr_output_region [10] +[238] 0.2 0.00 0.06 45630 cr_output_resources [238] + 0.03 0.01 45630/108211 report_resources [210] + 0.00 0.03 174677/174677 cr_output_resource [378] + 0.00 0.00 91260/10053919 rtrees [302] + 0.00 0.00 3232/4488684 crtag [110] +----------------------------------------------- + 0.00 0.06 104830/104830 cr_output_region [10] +[239] 0.2 0.00 0.06 104830 cr_output_building [239] + 0.00 0.03 104830/386740 cr_output_curses_compat [144] + 0.00 0.01 104830/218422 report_building [397] + 0.00 0.01 104830/4434556 translate [75] + 0.00 0.00 104830/24887945 locale_string [27] +----------------------------------------------- + 0.00 0.00 12/931076 reduce_weight [404] + 0.00 0.00 68977/931076 reserve_i [213] + 0.00 0.05 862087/931076 use_pooled [39] +[240] 0.2 0.00 0.06 931076 change_resource [240] + 0.00 0.03 931076/8302761 get_resource [99] + 0.00 0.02 930757/9232125 res_changeitem [101] + 0.00 0.00 86/443 res_changepermaura [912] + 0.00 0.00 216/1199 res_changeaura [972] + 0.00 0.00 15/15 res_changepeasants [1200] + 0.00 0.00 2/2 res_changehp [1779] +----------------------------------------------- + 0.03 0.03 1/1 randomevents [91] +[241] 0.2 0.03 0.03 1 dissolve_units [241] + 0.00 0.02 1/6 remove_empty_units [146] + 0.01 0.00 595476/51974272 a_find [65] + 0.00 0.00 2126/7641081 genrand_int31 [171] + 0.00 0.00 41/967784 msg_message [132] + 0.00 0.00 41/392959 add_message [434] + 0.00 0.00 19/264251 rsetpeasants [545] + 0.00 0.00 41/3178 scale_number [969] + 0.00 0.00 19/2605004 rpeasants [435] + 0.00 0.00 4/71815034 get_race [12] + 0.00 0.00 45/129167539 u_race [89] + 0.00 0.00 20/10053919 rtrees [302] + 0.00 0.00 41/1009028 msg_release [1373] + 0.00 0.00 20/229715 rsettrees [1410] +----------------------------------------------- + 0.00 0.00 45/80630 sp_kampfzauber [957] + 0.00 0.00 580/80630 attack_firesword [785] + 0.00 0.00 7313/80630 sp_dragonodem [627] + 0.00 0.05 72692/80630 attack [84] +[242] 0.2 0.00 0.05 80630 terminate [242] + 0.00 0.01 153322/860166 weapon_effskill [168] + 0.00 0.02 100532/146997 dice_rand [409] + 0.00 0.00 154155/71815034 get_race [12] + 0.00 0.01 80630/80630 calculate_armor [645] + 0.00 0.00 10897/25088 kill_troop [532] + 0.00 0.00 17117/137709 CavalryBonus [491] + 0.00 0.00 92981/752645 chance [495] + 0.00 0.00 475770/129167539 u_race [89] + 0.00 0.00 39357/1474687 leftship [500] + 0.00 0.00 10900/5395063 i_get [130] + 0.00 0.00 72692/72692 rc_specialdamage [830] + 0.00 0.00 13338/7641081 genrand_int31 [171] + 0.00 0.00 3221/11241829 i_change [115] + 0.00 0.00 52/1381157 unit_max_hp [136] + 0.00 0.00 4/967784 msg_message [132] + 0.00 0.00 4/31214 message_faction [716] + 0.00 0.00 148748/1218663 select_weapon [1367] + 0.00 0.00 80630/1726748 is_riding [1358] + 0.00 0.00 4/1009028 msg_release [1373] +----------------------------------------------- + 0.04 0.01 6241702/6241702 getbuf_utf8 [72] +[243] 0.2 0.04 0.01 6241702 eatwhite [243] + 0.01 0.00 6696209/46391457 unicode_utf8_to_ucs4 [177] +----------------------------------------------- + 0.03 0.02 10846/10846 expandorders [197] +[244] 0.2 0.03 0.02 10846 scramble [244] + 0.02 0.00 2276433/11253756 genrand_int32 [150] +----------------------------------------------- + 0.00 0.05 515550/515550 parse_symbol [42] +[245] 0.2 0.00 0.05 515550 eval_region [245] + 0.00 0.05 515550/515911 write_regionname [280] + 0.00 0.00 515550/13102790 opstack_pop [176] + 0.00 0.00 515550/13102790 opstack_push [202] + 0.00 0.00 515550/13399069 balloc [363] +----------------------------------------------- + 0.03 0.02 1/1 randomevents [91] +[246] 0.2 0.03 0.02 1 demon_skillchanges [246] + 0.00 0.02 595476/71815034 get_race [12] + 0.00 0.00 595476/129167539 u_race [89] + 0.00 0.00 2148/2148 demon_skillchange [826] +----------------------------------------------- + 0.00 0.00 4/1295787 checkpasswd [1268] + 0.00 0.00 5/1295787 tolua_faction_tostring [1257] + 0.00 0.00 230/1295787 report_plaintext [4] + 0.00 0.00 232/1295787 write_reports [3] + 0.00 0.00 251/1295787 out_faction [615] + 0.00 0.00 3111/1295787 sidename [867] + 0.00 0.00 10794/1295787 list_address [635] + 0.00 0.00 34482/1295787 guards [229] + 0.00 0.00 46224/1295787 eval_faction [685] + 0.00 0.00 55330/1295787 show_allies [429] + 0.00 0.05 1145124/1295787 bufunit [17] +[247] 0.2 0.00 0.05 1295787 factionname [247] + 0.00 0.05 1295787/5100840 itoa36 [116] + 0.00 0.00 1295787/5461936 slprintf [548] +----------------------------------------------- + 0.00 0.00 10/160206 get_money_for_dragon [1087] + 0.04 0.01 160196/160206 plan_monsters [52] +[248] 0.1 0.04 0.01 160206 monster_attacks [248] + 0.01 0.00 11080/1437425 cansee [22] + 0.00 0.00 752/752 monster_attack [764] + 0.00 0.00 736/760673 addlist [217] + 0.00 0.00 752/7120688 get_money [187] + 0.00 0.00 1042/1042 in_safe_building [1585] +----------------------------------------------- + 0.03 0.02 1/1 process [7] +[249] 0.1 0.03 0.02 1 defaultorders [249] + 0.01 0.00 1131212/55492327 getkeyword [54] + 0.00 0.01 524/524 remove_exclusive [571] + 0.00 0.00 232/1481407 parse_order [117] + 0.00 0.00 232/760673 addlist [217] + 0.00 0.00 262/2281756 gettoken [195] + 0.00 0.00 262/1027665 init_order [613] + 0.00 0.00 262/1936876 free_order [1356] + 0.00 0.00 1/11194781 keyword_disabled [1348] +----------------------------------------------- + 0.04 0.01 178254/178254 process [7] +[250] 0.1 0.04 0.01 178254 do_contact [250] + 0.01 0.00 1133099/55492327 getkeyword [54] + 0.00 0.00 147/147 contact_cmd [965] +----------------------------------------------- + 0.01 0.04 1009159/1009159 msg_create [228] +[251] 0.1 0.01 0.04 1009159 log_orders [251] + 0.00 0.04 41255/1380398 nr_render [25] + 0.00 0.00 41255/3780355 nr_section [113] + 0.00 0.00 41255/49235 log_debug [1245] +----------------------------------------------- + 0.02 0.03 1929215/1929215 create_order_i [175] +[252] 0.1 0.02 0.03 1929215 create_data [252] + 0.00 0.02 560985/2066777 parse_token_depr [220] + 0.01 0.01 560985/996009 get_skill [423] + 0.00 0.00 58/2934859 skillname [122] + 0.00 0.00 1252028/1252028 mkdata [1366] +----------------------------------------------- + 0.00 0.00 92/209572 building_update_owner [1010] + 0.05 0.00 209480/209572 building_owner [232] +[253] 0.1 0.05 0.00 209572 building_owner_ex [253] + 0.00 0.00 209544/216069 config_token [794] +----------------------------------------------- + 0.05 0.00 96482/96482 travel_i [92] +[254] 0.1 0.05 0.00 96482 get_followers [254] + 0.00 0.00 2822/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 22778/5329742 parser_end [849] + 0.05 0.00 5306964/5329742 parse_token [125] +[255] 0.1 0.05 0.00 5329742 eatwhitespace_c [255] + 0.00 0.00 5132/46391457 unicode_utf8_to_ucs4 [177] +----------------------------------------------- + 0.00 0.00 150/12560453 is_migrant [1047] + 0.00 0.00 230/12560453 report_computer [9] + 0.00 0.00 298/12560453 plan_dragon [273] + 0.00 0.00 410/12560453 rc_specialdamage [830] + 0.00 0.00 14447/12560453 heal_factor [619] + 0.00 0.00 16132/12560453 magic_lowskill [897] + 0.00 0.00 377253/12560453 guard_flags [690] + 0.00 0.00 469309/12560453 rc_skillmod [140] + 0.02 0.00 4503145/12560453 omniscient [470] + 0.03 0.00 7179079/12560453 skill_mod [264] +[256] 0.1 0.05 0.00 12560453 rc_changed [256] +----------------------------------------------- + 0.00 0.00 1/2868601 use_bloodpotion [935] + 0.00 0.00 3/2868601 trigger_changerace [1297] + 0.01 0.00 596221/2868601 write_unit [97] + 0.02 0.00 923633/2868601 cr_output_unit [19] + 0.02 0.00 1348743/2868601 bufunit [17] +[257] 0.1 0.05 0.00 2868601 u_irace [257] +----------------------------------------------- + +[258] 0.1 0.05 0.00 qli_init [258] +----------------------------------------------- + 0.00 0.00 4/4625636 mailfaction [1106] + 0.00 0.00 12/4625636 tolua_faction_get [1246] + 0.00 0.00 150/4625636 setstealth_cmd [182] + 0.00 0.00 233/4625636 readfaction [767] + 0.00 0.00 287/4625636 factionorders [983] + 0.00 0.00 791/4625636 getfaction [937] + 0.00 0.00 5925/4625636 addally [913] + 0.00 0.00 30872/4625636 resolve_faction [820] + 0.00 0.00 39836/4625636 read_of [524] + 0.00 0.00 49522/4625636 read_groups [782] + 0.00 0.01 595125/4625636 read_unit [74] + 0.01 0.03 3902879/4625636 get_or_create_monsters [292] +[259] 0.1 0.01 0.04 4625636 findfaction [259] + 0.04 0.00 4625636/4625636 ffindhash [315] +----------------------------------------------- + 0.00 0.00 10/2818494 spawn_dragons [411] + 0.00 0.00 47/2818494 display_race [963] + 0.00 0.00 71/2818494 report_summary [614] + 0.00 0.00 92/2818494 spawn_undead [629] + 0.00 0.00 230/2818494 report_computer [9] + 0.00 0.00 230/2818494 report_plaintext [4] + 0.00 0.00 251/2818494 out_faction [615] + 0.00 0.00 272/2818494 init_locale [948] + 0.00 0.00 356/2818494 cr_race [949] + 0.00 0.00 666/2818494 generic_name [962] + 0.00 0.00 1520/2818494 eval_race [882] + 0.00 0.01 537193/2818494 unit_getname [332] + 0.01 0.01 925760/2818494 cr_output_unit [19] + 0.01 0.01 1351796/2818494 racename [133] +[260] 0.1 0.02 0.03 2818494 rc_name_s [260] + 0.03 0.00 2818494/2818494 rc_name [364] +----------------------------------------------- + 0.00 0.00 2/4133717 b_namequestportal [1279] + 0.00 0.00 10/4133717 init_locale [948] + 0.00 0.00 18/4133717 parse_calendar [1252] + 0.00 0.00 44/4133717 curse_name [1140] + 0.00 0.00 47/4133717 display_item [1054] + 0.00 0.00 58/4133717 skill_key [1205] + 0.00 0.00 61/4133717 json_keyword [1127] + 0.00 0.00 86/4133717 display_race [963] + 0.00 0.00 140/4133717 nr_spell_syntax [732] + 0.00 0.00 464/4133717 report_computer [9] + 0.00 0.00 567/4133717 report_plaintext [4] + 0.00 0.00 1088/4133717 spskill [53] + 0.00 0.00 1911/4133717 cinfo_magicresistance [824] + 0.00 0.00 2081/4133717 cr_reportspell [756] + 0.00 0.00 2252/4133717 cinfo_ship [812] + 0.00 0.00 4162/4133717 spell_info [841] + 0.00 0.00 5907/4133717 cinfo_simple [751] + 0.00 0.00 8974/4133717 hp_status [206] + 0.00 0.00 15359/4133717 cinfo_building [686] + 0.00 0.00 20072/4133717 cr_skill [672] + 0.00 0.00 33909/4133717 cr_output_spells [639] + 0.00 0.00 86400/4133717 spell_name [646] + 0.00 0.00 93450/4133717 b_nameroad [642] + 0.00 0.00 97017/4133717 cr_borders [135] + 0.00 0.00 108347/4133717 racename [133] + 0.00 0.01 716432/4133717 cr_output_unit [19] + 0.01 0.03 2934859/4133717 skillname [122] +[261] 0.1 0.01 0.04 4133717 mkname [261] + 0.04 0.00 4133717/4136059 mkname_buf [316] +----------------------------------------------- + 0.00 0.00 87/1441945 age_stonecircle [1021] + 0.00 0.00 91/1441945 study_cmd [105] + 0.00 0.00 75870/1441945 movement_speed [155] + 0.00 0.01 174965/1441945 cr_output_unit [19] + 0.00 0.02 595454/1441945 regenerate_aura [346] + 0.00 0.02 595478/1441945 magic [157] +[262] 0.1 0.00 0.05 1441945 is_mage [262] + 0.00 0.05 1441945/2426021 get_mage [198] +----------------------------------------------- + 0.00 0.00 1921/2277350 report_computer [9] + 0.03 0.02 2275429/2277350 raceprefix [222] +[263] 0.1 0.03 0.02 2277350 get_prefix [263] + 0.02 0.00 2277350/51974272 a_find [65] +----------------------------------------------- + 0.02 0.03 7179079/7179079 rc_skillmod [140] +[264] 0.1 0.02 0.03 7179079 skill_mod [264] + 0.03 0.00 7179079/12560453 rc_changed [256] + 0.00 0.00 2/71815034 get_race [12] + 0.00 0.00 722366/1511812 newterrain [1359] +----------------------------------------------- + 0.02 0.03 9163148/9163148 res_changeitem [101] +[265] 0.1 0.02 0.03 9163148 golem_factor [265] + 0.03 0.00 18326296/56052475 get_resourcetype [194] + 0.00 0.00 45992/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 39/779486 display_item [1054] + 0.00 0.00 47/779486 display_race [963] + 0.00 0.00 58/779486 dragon_name [1095] + 0.00 0.00 117/779486 count_particles [1089] + 0.00 0.00 407/779486 make_name [970] + 0.03 0.02 778818/779486 describe_race [267] +[266] 0.1 0.03 0.02 779486 locale_getstring [266] + 0.02 0.00 779486/32337529 hashstring [37] +----------------------------------------------- + 0.00 0.02 379049/778818 read_unit [74] + 0.00 0.02 399769/778818 u_description [347] +[267] 0.1 0.00 0.05 778818 describe_race [267] + 0.03 0.02 778818/779486 locale_getstring [266] +----------------------------------------------- + 0.00 0.05 883617/883617 parse_symbol [42] +[268] 0.1 0.00 0.05 883617 eval_int [268] + 0.00 0.03 883617/884940 itoa10 [338] + 0.01 0.00 883617/13102790 opstack_pop [176] + 0.01 0.00 883617/13102790 opstack_push [202] + 0.00 0.00 883617/13399069 balloc [363] +----------------------------------------------- + 0.00 0.05 317735/317735 plan_monsters [52] +[269] 0.1 0.00 0.05 317735 monster_learn [269] + 0.00 0.02 317467/447808 create_order [341] + 0.00 0.02 317467/2934859 skillname [122] + 0.00 0.00 317467/7641081 genrand_int31 [171] + 0.00 0.00 317735/748527 unit_can_study [709] +----------------------------------------------- + 0.01 0.04 595896/595896 process [7] +[270] 0.1 0.01 0.04 595896 update_long_order [270] + 0.02 0.00 575221/635885 copy_order [441] + 0.01 0.00 1132975/55492327 getkeyword [54] + 0.00 0.00 152977/1644867 free_orders [306] + 0.00 0.00 595896/1629412 LongHunger [536] + 0.00 0.00 451283/2985733 is_repeated [552] + 0.00 0.00 1178/15102 cmistake [718] + 0.00 0.00 56/3110 default_order [902] + 0.00 0.00 1132609/1132609 is_long [1370] + 0.00 0.00 581697/1291427 set_order [1365] +----------------------------------------------- + 0.01 0.00 178254/1006923 new_region [275] + 0.01 0.00 369586/1006923 r_connect [474] + 0.02 0.00 459083/1006923 findregion [420] +[271] 0.1 0.04 0.01 1006923 rfindhash [271] + 0.01 0.00 1006923/2903884 jenkins_hash [439] +----------------------------------------------- + 0.00 0.05 5384/5384 process [7] +[272] 0.1 0.00 0.05 5384 teach_cmd [272] + 0.01 0.01 16132/16132 teach_unit [426] + 0.01 0.00 34486/34486 effskill_study [504] + 0.00 0.00 17577/282847 getunit [205] + 0.00 0.00 5384/14326 replace_order [526] + 0.00 0.00 17247/435022 getskill [387] + 0.00 0.00 9353/9953180 alliedunit [31] + 0.00 0.00 17417/5100840 itoa36 [116] + 0.00 0.00 5384/447808 create_order [341] + 0.00 0.00 17417/34611296 strlcpy [45] + 0.00 0.00 28057/1027665 init_order [613] + 0.00 0.00 22843/22843 parser_end [849] + 0.00 0.00 5384/69432 getparam [681] + 0.00 0.00 1323/41248 msg_feedback [647] + 0.00 0.00 17417/55492327 getkeyword [54] + 0.00 0.00 5384/2858912 get_effect [225] + 0.00 0.00 5380/12246335 ct_find [114] + 0.00 0.00 5380/10190660 get_curse [143] + 0.00 0.00 1323/392959 add_message [434] + 0.00 0.00 412/2426021 get_mage [198] + 0.00 0.00 5384/129167539 u_race [89] + 0.00 0.00 167/167 academy_teaching_bonus [1128] + 0.00 0.00 5384/18647447 getplane [596] + 0.00 0.00 42/54318 getstrtoken [710] + 0.00 0.00 42/534930 isparam [668] + 0.00 0.00 17289/17289 parser_pushstate [1507] + 0.00 0.00 17289/17289 parser_popstate [1506] + 0.00 0.00 5384/1936876 free_order [1356] + 0.00 0.00 1323/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.05 298/298 plan_monsters [52] +[273] 0.1 0.00 0.05 298 plan_dragon [273] + 0.00 0.02 249/252 path_exists [431] + 0.00 0.01 40/40 set_new_dragon_target [486] + 0.00 0.01 249/249 make_movement_order [522] + 0.00 0.00 17/17 recruit_dracoids [837] + 0.00 0.00 249/2480226 old_race [14] + 0.00 0.00 49/133 income [885] + 0.00 0.00 136/83859 reduce_weight [404] + 0.00 0.00 39/39 random_growl [1065] + 0.00 0.00 119/447808 create_order [341] + 0.00 0.00 119/2934859 skillname [122] + 0.00 0.00 49/49 get_money_for_dragon [1087] + 0.00 0.00 306/752645 chance [495] + 0.00 0.00 360/7641081 genrand_int31 [171] + 0.00 0.00 298/51974272 a_find [65] + 0.00 0.00 44/71815034 get_race [12] + 0.00 0.00 298/12560453 rc_changed [256] + 0.00 0.00 460/129167539 u_race [89] + 0.00 0.00 74/2605004 rpeasants [435] + 0.00 0.00 43/7120688 get_money [187] + 0.00 0.00 74/4666665 rmoney [452] + 0.00 0.00 119/21345834 skill_enabled [365] +----------------------------------------------- + 0.00 0.00 209/1481616 setstealth_cmd [182] + 0.03 0.02 1481407/1481616 parse_order [117] +[274] 0.1 0.03 0.02 1481616 get_keyword [274] + 0.01 0.00 1481616/4457785 transliterate [358] + 0.01 0.00 1481616/4558423 get_translations [437] + 0.00 0.00 1481322/11194781 keyword_disabled [1348] +----------------------------------------------- + 0.00 0.05 178254/178254 readregion [209] +[275] 0.1 0.00 0.05 178254 new_region [275] + 0.02 0.00 178254/178254 hash_uid [442] + 0.02 0.00 178254/760673 addlist [217] + 0.01 0.00 178254/1006923 rfindhash [271] + 0.00 0.00 178254/178290 rhash [737] + 0.00 0.00 178254/3587241 pnormalize [1350] +----------------------------------------------- + 0.00 0.05 1/1 process [7] +[276] 0.1 0.00 0.05 1 quit [276] + 0.00 0.03 1/1 remove_idle_players [391] + 0.00 0.02 1/6 remove_empty_units [146] + 0.00 0.00 237/16493 NewbieImmunity [900] + 0.00 0.00 4/967784 msg_message [132] + 0.00 0.00 4/392959 add_message [434] + 0.00 0.00 4/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.05 178254/178254 produce [29] +[277] 0.1 0.00 0.05 178254 expandwork [277] + 0.00 0.04 189233/490896 wage [174] + 0.00 0.00 342640/2605004 rpeasants [435] + 0.00 0.00 10979/34409 add_income [625] + 0.00 0.00 178254/2186159 rsetmoney [553] + 0.00 0.00 178254/4666665 rmoney [452] + 0.00 0.00 10979/2599554 change_money [337] + 0.00 0.00 10979/129167539 u_race [89] + 0.00 0.00 503/7641081 genrand_int31 [171] + 0.00 0.00 82525/508632 rule_blessed_harvest [1327] +----------------------------------------------- + 0.00 0.05 663/663 produce [29] +[278] 0.1 0.00 0.05 663 expandtax [278] + 0.02 0.00 1524933/2599554 change_money [337] + 0.01 0.00 3049883/4666665 rmoney [452] + 0.01 0.00 1524933/2186159 rsetmoney [553] + 0.00 0.00 663/10852 expandorders [197] + 0.00 0.00 948/34409 add_income [625] +----------------------------------------------- + 0.00 0.00 38/221899 renumber_cmd [780] + 0.00 0.00 59/221899 expandstealing [807] + 0.00 0.05 221802/221899 unitorders [46] +[279] 0.1 0.00 0.05 221899 findunitg [279] + 0.04 0.00 221899/1118718 ufindhash [109] +----------------------------------------------- + 0.00 0.00 361/515911 regionname [987] + 0.00 0.05 515550/515911 eval_region [245] +[280] 0.1 0.00 0.05 515911 write_regionname [280] + 0.01 0.02 513251/1552289 rname [200] + 0.02 0.00 513251/1826688 adjust_coordinates [234] + 0.00 0.00 513251/5461936 slprintf [548] + 0.00 0.00 513251/18647447 getplane [596] + 0.00 0.00 2660/34611296 strlcpy [45] + 0.00 0.00 513251/3587241 pnormalize [1350] +----------------------------------------------- + 0.00 0.00 2364/4851739 give_item [126] + 0.00 0.00 24010/4851739 give_cmd [102] + 0.00 0.00 671315/4851739 get_pooled [104] + 0.03 0.01 4154050/4851739 use_pooled [39] +[281] 0.1 0.03 0.02 4851739 get_reservation [281] + 0.01 0.00 9703478/56052475 get_resourcetype [194] + 0.00 0.00 20370/129167539 u_race [89] +----------------------------------------------- + 0.00 0.04 1/1 process [7] +[282] 0.1 0.00 0.04 1 new_units [282] + 0.00 0.02 754/754 checkunitnumber [402] + 0.00 0.01 754/2889 create_unit [296] + 0.01 0.00 1136686/55492327 getkeyword [54] + 0.00 0.00 754/228907 getid [483] + 0.00 0.00 754/2281756 gettoken [195] + 0.00 0.00 754/779419 a_add [555] + 0.00 0.00 754/1474687 leftship [500] + 0.00 0.00 754/1027665 init_order [613] + 0.00 0.00 754/779868 a_new [1376] + 0.00 0.00 754/599650 setstatus [1390] +----------------------------------------------- + 0.00 0.00 39714/300501 sail [181] + 0.00 0.01 105958/300501 travel_route [147] + 0.01 0.02 154829/300501 movewhere [350] +[283] 0.1 0.01 0.03 300501 move_blocked [283] + 0.00 0.03 300501/2225796 get_borders [120] + 0.00 0.00 282968/12246335 ct_find [114] + 0.00 0.00 282968/10190660 get_curse [143] + 0.00 0.00 282968/4201030 curse_active [543] + 0.00 0.00 37024/37024 b_blocknone [1471] + 0.00 0.00 2/2 b_blockquestportal [1770] +----------------------------------------------- + 0.01 0.03 1/1 randomevents [91] +[284] 0.1 0.01 0.03 1 rotting_herbs [284] + 0.02 0.00 595476/6010308 i_find [127] + 0.00 0.01 595476/1177511 it_find [385] + 0.00 0.00 22496/147217 normalvariate [376] + 0.00 0.00 22496/11241829 i_change [115] + 0.00 0.00 1/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.04 1/1 randomevents [91] +[285] 0.1 0.00 0.04 1 icebergs [285] + 0.01 0.01 178254/178263 drown [394] + 0.01 0.00 1/1 move_icebergs [534] + 0.01 0.00 1/1 create_icebergs [538] +----------------------------------------------- + 0.00 0.00 45033/4198692 report_template [87] + 0.00 0.00 106798/4198692 help_feed [678] + 0.01 0.03 4046861/4198692 get_food [88] +[286] 0.1 0.01 0.03 4198692 lifestyle [286] + 0.00 0.02 1677644/3902878 get_monsters [293] + 0.01 0.01 2521048/2765718 maintenance_cost [481] + 0.00 0.00 2521048/18647447 getplane [596] +----------------------------------------------- + 0.00 0.04 131765/131765 process [7] +[287] 0.1 0.00 0.04 131765 give_control_cmd [287] + 0.00 0.04 131765/282847 getunit [205] + 0.00 0.00 131765/2281756 gettoken [195] + 0.00 0.00 131765/1027665 init_order [613] + 0.00 0.00 131764/534930 isparam [668] + 0.00 0.00 6/102705 can_give_to [600] + 0.00 0.00 3/967784 msg_message [132] + 0.00 0.00 3/15102 cmistake [718] + 0.00 0.00 3/392959 add_message [434] + 0.00 0.00 1/593636 building_owner [232] + 0.00 0.00 5/3358315 ship_owner [438] + 0.00 0.00 3/3 give_control [1763] + 0.00 0.00 3/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 677/10383360 ally_cmd [877] + 0.00 0.00 1297/10383360 AllianceAuto [535] + 0.00 0.00 5925/10383360 addally [913] + 0.01 0.03 10375461/10383360 AllianceRestricted [164] +[288] 0.1 0.01 0.03 10383360 HelpMask [288] + 0.01 0.02 10383360/20777534 config_get [224] +----------------------------------------------- + 0.00 0.04 96527/96527 travel [81] +[289] 0.1 0.00 0.04 96527 make_route [289] + 0.00 0.03 209781/252446 movewhere [350] + 0.00 0.01 113254/113487 next_region [601] + 0.00 0.01 209781/2281756 gettoken [195] + 0.00 0.00 4/392959 add_message [434] + 0.00 0.00 4/955 movement_error [1193] + 0.00 0.00 113254/192815 add_regionlist [1419] + 0.00 0.00 4/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 14502/1065211 eval_ship [740] + 0.00 0.01 180598/1065211 nr_ship [111] + 0.00 0.02 434165/1065211 cb_cr_travelthru_ship [204] + 0.00 0.02 435946/1065211 cb_write_travelthru [169] +[290] 0.1 0.00 0.04 1065211 shipname [290] + 0.00 0.04 1065211/1065211 write_shipname [291] +----------------------------------------------- + 0.00 0.04 1065211/1065211 shipname [290] +[291] 0.1 0.00 0.04 1065211 write_shipname [291] + 0.00 0.04 1065211/5100840 itoa36 [116] + 0.00 0.00 1065211/5461936 slprintf [548] +----------------------------------------------- + 0.00 0.00 1/3902879 spawn_dragons [411] + 0.00 0.04 3902878/3902879 get_monsters [293] +[292] 0.1 0.00 0.04 3902879 get_or_create_monsters [292] + 0.01 0.03 3902879/4625636 findfaction [259] +----------------------------------------------- + 0.00 0.00 1/3902878 tolua_planmonsters [51] + 0.00 0.00 1/3902878 spawn_braineaters [505] + 0.00 0.00 1/3902878 report_plaintext [4] + 0.00 0.00 1/3902878 remove_idle_players [391] + 0.00 0.00 1/3902878 update_spells [381] + 0.00 0.00 1/3902878 make_zombie [1267] + 0.00 0.00 1/3902878 spawn_undead [629] + 0.00 0.00 5/3902878 chaos [848] + 0.00 0.00 82/3902878 age_undead [1196] + 0.00 0.00 84/3902878 loot_cmd [873] + 0.00 0.00 176/3902878 list_address [635] + 0.00 0.00 653/3902878 age_ghoul [1024] + 0.00 0.00 665/3902878 age_zombie [1019] + 0.00 0.00 725/3902878 age_skeleton [1008] + 0.00 0.00 983/3902878 loot_items [810] + 0.00 0.00 39959/3902878 can_start_guarding [679] + 0.00 0.00 83768/3902878 canwalk [633] + 0.00 0.00 419410/3902878 randomevents [91] + 0.00 0.00 419518/3902878 produceexp_ex [323] + 0.00 0.00 419518/3902878 plan_monsters [52] + 0.00 0.01 839681/3902878 make_summary [21] + 0.00 0.02 1677644/3902878 lifestyle [286] +[293] 0.1 0.00 0.04 3902878 get_monsters [293] + 0.00 0.04 3902878/3902879 get_or_create_monsters [292] +----------------------------------------------- + 0.00 0.04 1/1 demographics [50] +[294] 0.1 0.00 0.04 1 immigration [294] + 0.00 0.04 178254/490896 wage [174] + 0.00 0.00 185509/2605004 rpeasants [435] + 0.00 0.00 178254/2765718 maintenance_cost [481] + 0.00 0.00 23630/71815034 get_race [12] + 0.00 0.00 17728/438629 maxworkingpeasants [473] + 0.00 0.00 14329/264251 rsetpeasants [545] + 0.00 0.00 7074/1336242 rng_injectable_double [396] + 0.00 0.00 51382/129167539 u_race [89] + 0.00 0.00 1/4984610 config_get_int [348] + 0.00 0.00 1/64 log_info [1339] +----------------------------------------------- + 0.00 0.04 178254/178254 process [7] +[295] 0.1 0.00 0.04 178254 enter_2 [295] + 0.03 0.01 178254/713016 do_enter [128] +----------------------------------------------- + 0.00 0.00 1/2889 sp_summon_familiar [1025] + 0.00 0.00 1/2889 sp_summonshadowlords [1034] + 0.00 0.00 2/2889 summon_allies [925] + 0.00 0.00 5/2889 chaos [848] + 0.00 0.00 6/2889 tolua_unit_create [916] + 0.00 0.00 6/2889 sp_summonundead [896] + 0.00 0.00 10/2889 spawn_dragons [411] + 0.00 0.00 17/2889 recruit_dracoids [837] + 0.00 0.00 20/2889 spawn_seaserpent [831] + 0.00 0.00 38/2889 sp_viewreality [784] + 0.00 0.00 92/2889 spawn_undead [629] + 0.00 0.01 639/2889 spawn_braineaters [505] + 0.00 0.01 754/2889 new_units [282] + 0.00 0.02 1298/2889 add_recruits [371] +[296] 0.1 0.00 0.04 2889 create_unit [296] + 0.00 0.04 2889/2889 createunitid [317] + 0.00 0.00 2889/109785 move_unit [421] + 0.00 0.00 2806/2931 name_unit [803] + 0.00 0.00 2889/1381157 unit_max_hp [136] + 0.00 0.00 2889/760673 addlist [217] + 0.00 0.00 2889/3110 default_order [902] + 0.00 0.00 2494/779419 a_add [555] + 0.00 0.00 2062/2275967 get_racename [368] + 0.00 0.00 2598/51974272 a_find [65] + 0.00 0.00 2062/2421 set_racename [1015] + 0.00 0.00 535/1270 set_group [1048] + 0.00 0.00 2097/129167539 u_race [89] + 0.00 0.00 2889/24935046 faction_alive [451] + 0.00 0.00 2889/598129 u_setfaction [1111] + 0.00 0.00 2889/1291427 set_order [1365] + 0.00 0.00 2889/600145 u_setrace [1389] + 0.00 0.00 2889/603524 set_number [1387] + 0.00 0.00 2063/779868 a_new [1376] + 0.00 0.00 2062/599650 setstatus [1390] + 0.00 0.00 837/48565 u_set_building [1460] + 0.00 0.00 431/433 make_otherfaction [1603] + 0.00 0.00 431/1380007 get_otherfaction [1362] + 0.00 0.00 35/27640 u_set_ship [1485] +----------------------------------------------- + 0.01 0.03 178254/178254 do_battle [64] +[297] 0.1 0.01 0.03 178254 start_battle [297] + 0.00 0.02 2858/3203 join_battle [425] + 0.01 0.00 1129818/55492327 getkeyword [54] + 0.00 0.00 1443/1437425 cansee [22] + 0.00 0.00 1487/282847 getunit [205] + 0.00 0.00 1432/9953180 alliedunit [31] + 0.00 0.00 2974/10190660 get_curse [143] + 0.00 0.00 1486/1474687 leftship [500] + 0.00 0.00 1429/51974272 a_find [65] + 0.00 0.00 7/15361 is_guarded [377] + 0.00 0.00 1487/1027665 init_order [613] + 0.00 0.00 1518/1629412 LongHunger [536] + 0.00 0.00 1431/16669 IsImmune [901] + 0.00 0.00 57/41248 msg_feedback [647] + 0.00 0.00 2974/4201030 curse_active [543] + 0.00 0.00 1518/129167539 u_race [89] + 0.00 0.00 32/15102 cmistake [718] + 0.00 0.00 57/392959 add_message [434] + 0.00 0.00 1518/18647447 getplane [596] + 0.00 0.00 206/206 make_battle [1282] + 0.00 0.00 2/16493 NewbieImmunity [900] + 0.00 0.00 1429/2073 set_enemy [1562] + 0.00 0.00 55/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.04 102149/102149 cr_output_region [10] +[298] 0.1 0.00 0.04 102149 cr_output_travelthru [298] + 0.01 0.04 204298/3398582 travelthru_map [41] +----------------------------------------------- + 0.00 0.00 13/841675 write_planes [1207] + 0.00 0.00 1692/841675 write_groups [920] + 0.04 0.00 839970/841675 write_attribs [301] +[299] 0.1 0.04 0.00 841675 a_write [299] + 0.00 0.00 4024/4024 curse_write [930] + 0.00 0.00 1564/1564 write_handler [955] + 0.00 0.00 1522/1522 a_write_unit [998] + 0.00 0.00 2096/2096 a_writeeffect [1073] + 0.00 0.00 58524/58524 a_writeint [1447] + 0.00 0.00 56646/56646 write_group [1449] + 0.00 0.00 39955/39955 write_of [1467] + 0.00 0.00 34420/34420 a_writeshorts [1473] + 0.00 0.00 14111/14111 shiptrail_write [1511] + 0.00 0.00 8187/8187 write_seenspell [1523] + 0.00 0.00 7220/7220 a_writestring [1529] + 0.00 0.00 2089/2089 write_mage [1560] + 0.00 0.00 1117/1117 write_targetregion [1584] + 0.00 0.00 66/66 a_writechars [1663] + 0.00 0.00 56/56 dict_write [1677] + 0.00 0.00 2/2 wormhole_write [1785] + 0.00 0.00 1/1 a_writekeys [1787] +----------------------------------------------- + 0.00 0.04 32670/32670 demographics [50] +[300] 0.1 0.00 0.04 32670 growing_herbs [300] + 0.01 0.03 3017598/7641081 genrand_int31 [171] + 0.00 0.00 3112897/3166898 rherbs [1351] + 0.00 0.00 62629/101322 rsetherbs [1438] +----------------------------------------------- + 0.00 0.00 232/839970 writefaction [762] + 0.00 0.00 65263/839970 write_game [83] + 0.00 0.01 178254/839970 writeregion [519] + 0.00 0.03 596221/839970 write_unit [97] +[301] 0.1 0.00 0.04 839970 write_attribs [301] + 0.04 0.00 839970/841675 a_write [299] +----------------------------------------------- + 0.00 0.00 1/10053919 breedtrees [1148] + 0.00 0.00 6/10053919 sp_mallornhain [968] + 0.00 0.00 9/10053919 sp_hain [931] + 0.00 0.00 20/10053919 dissolve_units [241] + 0.00 0.00 51/10053919 potion_water_of_life [945] + 0.00 0.00 58/10053919 terraform_region [932] + 0.00 0.00 2772/10053919 tolua_region_get_resource [976] + 0.00 0.00 91260/10053919 cr_output_resources [238] + 0.00 0.00 182290/10053919 report_resources [210] + 0.00 0.00 196020/10053919 writeregion [519] + 0.00 0.00 249356/10053919 growing_trees [624] + 0.00 0.00 255352/10053919 describe [35] + 0.00 0.00 877258/10053919 maxworkingpeasants [473] + 0.03 0.00 8199466/10053919 r_isforest [199] +[302] 0.1 0.04 0.00 10053919 rtrees [302] +----------------------------------------------- + 0.00 0.00 40231/7851812 centre [789] + 0.04 0.00 7811581/7851812 paragraph [26] +[303] 0.1 0.04 0.00 7851812 write_spaces [303] +----------------------------------------------- + 0.04 0.00 4568249/4568249 parse_symbol [42] +[304] 0.1 0.04 0.00 4568249 find_variable [304] +----------------------------------------------- + 0.04 0.00 3573165/3573165 ql_set_insert_ex [156] +[305] 0.1 0.04 0.00 3573165 cmp_faction [305] +----------------------------------------------- + 0.00 0.00 1/1644867 tolua_unit_clear_orders [1313] + 0.00 0.00 6/1644867 make_undead_unit [1188] + 0.00 0.00 114/1644867 u_setfaction [1111] + 0.00 0.00 56948/1644867 unitorders [46] + 0.00 0.00 152977/1644867 update_long_order [270] + 0.01 0.00 419518/1644867 plan_monsters [52] + 0.01 0.00 420178/1644867 clear_npc_orders [531] + 0.01 0.00 595125/1644867 read_unit [74] +[306] 0.1 0.04 0.00 1644867 free_orders [306] + 0.00 0.00 810550/1936876 free_order [1356] +----------------------------------------------- + 0.00 0.00 46/3016 steal_cmd [766] + 0.00 0.00 146/3016 createunitid [317] + 0.04 0.00 2824/3016 newunitid [319] +[307] 0.1 0.04 0.00 3016 dfindhash [307] +----------------------------------------------- + +[308] 0.1 0.04 0.00 cb_find_prefix [308] +----------------------------------------------- + +[309] 0.1 0.04 0.00 class_index_event [309] +----------------------------------------------- + +[310] 0.1 0.04 0.00 fs_read [310] +----------------------------------------------- + +[311] 0.1 0.04 0.00 pack_int [311] +----------------------------------------------- + +[312] 0.1 0.04 0.00 ql_find [312] +----------------------------------------------- + +[313] 0.1 0.04 0.00 tolua_unitlist_next [313] +----------------------------------------------- + +[314] 0.1 0.04 0.00 unicode_ucs4_to_utf8 [314] +----------------------------------------------- + 0.04 0.00 4625636/4625636 findfaction [259] +[315] 0.1 0.04 0.00 4625636 ffindhash [315] +----------------------------------------------- + 0.00 0.00 2342/4136059 xml_readstrings [863] + 0.04 0.00 4133717/4136059 mkname [261] +[316] 0.1 0.04 0.00 4136059 mkname_buf [316] +----------------------------------------------- + 0.00 0.04 2889/2889 create_unit [296] +[317] 0.1 0.00 0.04 2889 createunitid [317] + 0.00 0.04 2743/2818 newunitid [319] + 0.00 0.00 146/3016 dfindhash [307] + 0.00 0.00 754/1118718 ufindhash [109] + 0.00 0.00 2889/598069 uhash [667] + 0.00 0.00 146/3002 forbiddenid [1280] +----------------------------------------------- + 0.00 0.00 8/598234 spy_message [1038] + 0.00 0.04 598226/598234 bufunit [17] +[318] 0.1 0.00 0.04 598234 report_status [318] + 0.01 0.01 598292/24887945 locale_string [27] + 0.01 0.00 598234/34611296 strlcpy [45] + 0.00 0.00 116/987128 strlcat [1374] +----------------------------------------------- + 0.00 0.00 32/2818 make_curse [802] + 0.00 0.00 43/2818 renumber_cmd [780] + 0.00 0.04 2743/2818 createunitid [317] +[319] 0.1 0.00 0.04 2818 newunitid [319] + 0.04 0.00 2824/3016 dfindhash [307] + 0.00 0.00 5523/1118718 ufindhash [109] + 0.00 0.00 2818/7641081 genrand_int31 [171] + 0.00 0.00 2818/3002 forbiddenid [1280] +----------------------------------------------- + 0.00 0.00 233/628037 readfaction [767] + 0.00 0.00 32679/628037 readregion [209] + 0.02 0.02 595125/628037 read_unit [74] +[320] 0.1 0.02 0.02 628037 read_items [320] + 0.00 0.01 448447/1177511 it_find [385] + 0.01 0.00 448447/11241829 i_change [115] +----------------------------------------------- + 0.03 0.01 301257/301257 cr_render [196] +[321] 0.1 0.03 0.01 301257 crt_find [321] + 0.01 0.00 301257/32337529 hashstring [37] +----------------------------------------------- + 0.00 0.00 1/472418 breedtrees [1148] + 0.00 0.00 8/472418 spy_cmd [990] + 0.00 0.00 21/472418 build_road [950] + 0.00 0.00 59/472418 steal_cmd [766] + 0.00 0.00 152/472418 magic [157] + 0.00 0.00 170/472418 breedhorses [742] + 0.00 0.00 349/472418 research_cmd [886] + 0.00 0.00 1040/472418 build [691] + 0.00 0.00 2825/472418 split_allocations [743] + 0.00 0.00 5896/472418 herbsearch [493] + 0.00 0.00 6133/472418 produce [29] + 0.00 0.00 9105/472418 move_ship [374] + 0.00 0.00 10581/472418 travel_route [147] + 0.00 0.00 16560/472418 expandentertainment [637] + 0.00 0.03 419518/472418 plan_monsters [52] +[322] 0.1 0.00 0.04 472418 produceexp [322] + 0.00 0.04 472418/472418 produceexp_ex [323] +----------------------------------------------- + 0.00 0.04 472418/472418 produceexp [322] +[323] 0.1 0.00 0.04 472418 produceexp_ex [323] + 0.02 0.00 472366/472366 produceexp_days [406] + 0.00 0.01 472366/892307 learn_skill [471] + 0.00 0.00 419518/3902878 get_monsters [293] + 0.00 0.00 52873/129167539 u_race [89] +----------------------------------------------- + 0.00 0.04 35708/35708 process [7] +[324] 0.1 0.00 0.04 35708 reserve_cmd [324] + 0.00 0.04 35708/71416 reserve_i [213] +----------------------------------------------- + 0.00 0.04 35708/35708 process [7] +[325] 0.1 0.00 0.04 35708 reserve_self [325] + 0.00 0.04 35708/71416 reserve_i [213] +----------------------------------------------- + 0.03 0.01 1/1 movement [47] +[326] 0.1 0.03 0.01 1 move_pirates [326] + 0.00 0.00 5049/5049 piracy_cmd [660] + 0.00 0.00 178254/178254 age_traveldir [720] + 0.00 0.00 38489/55492327 getkeyword [54] + 0.00 0.00 178254/178254 age_piracy [959] +----------------------------------------------- + 0.01 0.03 127676/127676 report_plaintext [4] +[327] 0.1 0.01 0.03 127676 write_travelthru [327] + 0.00 0.01 57367/57367 count_travelthru [518] + 0.00 0.01 54735/3398582 travelthru_map [41] + 0.00 0.00 54735/24887945 locale_string [27] + 0.00 0.00 54735/34611296 strlcpy [45] + 0.00 0.00 54735/54735 init_cb [1453] +----------------------------------------------- + 0.00 0.04 470529/470529 parse_symbol [42] +[328] 0.1 0.00 0.04 470529 eval_resource [328] + 0.01 0.01 470529/24887945 locale_string [27] + 0.01 0.00 941058/13102790 opstack_pop [176] + 0.00 0.00 470529/13102790 opstack_push [202] + 0.00 0.00 470529/13259934 resourcename [233] + 0.00 0.00 470529/13399069 balloc [363] +----------------------------------------------- + 0.00 0.00 2/8892 sp_viewreality [784] + 0.00 0.00 365/8892 cr_output_region [10] + 0.00 0.03 8525/8892 describe [35] +[329] 0.1 0.00 0.04 8892 astralregions [329] + 0.02 0.00 162996/162996 inhabitable [454] + 0.00 0.01 163381/459083 findregion [420] + 0.00 0.01 214975/514146 koor_distance [476] + 0.00 0.00 8892/8892 r_astral_to_standard [783] + 0.00 0.00 17784/987488 is_astral [479] + 0.00 0.00 163381/18647447 getplane [596] + 0.00 0.00 163381/3587241 pnormalize [1350] + 0.00 0.00 39832/192815 add_regionlist [1419] +----------------------------------------------- + 0.01 0.03 32670/32670 demographics [50] +[330] 0.1 0.01 0.03 32670 horses [330] + 0.02 0.01 124547/147217 normalvariate [376] + 0.00 0.00 32670/438629 maxworkingpeasants [473] + 0.00 0.00 29173/12246335 ct_find [114] + 0.00 0.00 29173/10190660 get_curse [143] + 0.00 0.00 5134/369586 r_connect [474] + 0.00 0.00 8246/51974272 a_find [65] + 0.00 0.00 29173/4201030 curse_active [543] + 0.00 0.00 376714/1160345 rhorses [1369] + 0.00 0.00 195073/257693 rsethorses [1408] + 0.00 0.00 62267/62267 get_migrants [1445] + 0.00 0.00 29173/651711 oldcursename [1381] +----------------------------------------------- + 0.02 0.02 595898/595898 process [7] +[331] 0.1 0.02 0.02 595898 follow_unit [331] + 0.01 0.00 1135305/55492327 getkeyword [54] + 0.00 0.00 595258/1629412 LongHunger [536] + 0.00 0.00 816/1437425 cansee [22] + 0.00 0.00 900/888603 findunit [123] + 0.00 0.00 900/284005 read_unitid [413] + 0.00 0.00 1425/69432 getparam [681] + 0.00 0.00 525/228907 getid [483] + 0.00 0.00 894/779419 a_add [555] + 0.00 0.00 1425/1027665 init_order [613] + 0.00 0.00 1039/3358315 ship_owner [438] + 0.00 0.00 519/115276 can_move [736] + 0.00 0.00 631/51974272 a_find [65] + 0.00 0.00 5/15102 cmistake [718] + 0.00 0.00 13/1297 hunted_dir [1055] + 0.00 0.00 894/894 make_follow [1589] + 0.00 0.00 703/1291427 set_order [1365] + 0.00 0.00 525/28818 findship [1483] +----------------------------------------------- + 0.00 0.00 86/3351853 tolua_unit_get_name [1194] + 0.00 0.00 45033/3351853 report_template [87] + 0.00 0.01 923633/3351853 cr_output_unit [19] + 0.00 0.03 2383101/3351853 write_unitname [148] +[332] 0.1 0.00 0.04 3351853 unit_getname [332] + 0.01 0.01 537193/24887945 locale_string [27] + 0.00 0.01 537193/2818494 rc_name_s [260] +----------------------------------------------- + 7791002 parse_symbol [42] + 0.48 0.57 1379793/1380398 translate [28] +[333] 0.1 0.03 0.01 9170795 parse [333] + 0.00 0.01 832876/832876 parse_int [649] + 5612941 parse_symbol [42] + 2724978 parse_string [86] +----------------------------------------------- + 4953357 effskill [100] + 0.00 0.00 20/12320804 target_resists_magic [1154] + 0.00 0.00 48/12320804 spy_message [1038] + 0.05 0.09 1953681/12320804 spskill [53] +[334] 0.1 0.04 0.00 6907106 eff_skill [334] + 6907105 get_modifier [55] +----------------------------------------------- + +[335] 0.1 0.04 0.00 cb_get_kv [335] +----------------------------------------------- + 0.00 0.03 595472/595472 live [73] +[336] 0.1 0.00 0.03 595472 age_unit [336] + 0.00 0.02 595472/71815034 get_race [12] + 0.00 0.01 595472/987488 is_astral [479] + 0.00 0.00 1194391/129167539 u_race [89] + 0.00 0.00 1363/1363 age_skeleton [1008] + 0.00 0.00 688/688 age_zombie [1019] + 0.00 0.00 708/708 age_ghoul [1024] + 0.00 0.00 295/295 age_dragon [1098] + 0.00 0.00 182/182 age_firedragon [1123] + 0.00 0.00 266/266 age_undead [1196] + 0.00 0.00 1/1 age_illusion [1308] +----------------------------------------------- + 0.00 0.00 17/2599554 recruit_dracoids [837] + 0.00 0.00 38/2599554 expandstealing [807] + 0.00 0.00 4800/2599554 expandloot [816] + 0.00 0.00 10979/2599554 expandwork [277] + 0.00 0.00 16560/2599554 expandentertainment [637] + 0.00 0.00 32382/2599554 help_feed [678] + 0.00 0.00 283759/2599554 expandselling [93] + 0.01 0.00 726086/2599554 get_food [88] + 0.02 0.00 1524933/2599554 expandtax [278] +[337] 0.1 0.03 0.00 2599554 change_money [337] + 0.00 0.00 2599554/56052475 get_resourcetype [194] + 0.00 0.00 87928/257723 i_remove [1407] + 0.00 0.00 87928/374425 i_free [1400] + 0.00 0.00 86907/822780 i_new [1375] + 0.00 0.00 86907/87004 i_add [1442] +----------------------------------------------- + 0.00 0.00 17/884940 create_order [341] + 0.00 0.00 48/884940 spy_message [1038] + 0.00 0.00 1258/884940 report_template [87] + 0.00 0.03 883617/884940 eval_int [268] +[338] 0.1 0.00 0.03 884940 itoa10 [338] + 0.03 0.00 884940/5985780 itoab [107] +----------------------------------------------- + 0.01 0.02 178254/178254 process [7] +[339] 0.1 0.01 0.02 178254 maintain_buildings [339] + 0.00 0.02 44190/44190 maintain [478] + 0.00 0.00 178254/12246335 ct_find [114] + 0.00 0.00 8710/967784 msg_message [132] + 0.00 0.00 8710/593636 building_owner [232] + 0.00 0.00 46175/10190660 get_curse [143] + 0.00 0.00 8710/392959 add_message [434] + 0.00 0.00 46175/4201030 curse_active [543] + 0.00 0.00 295/12265 r_addmessage [779] + 0.00 0.00 8710/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.03 3438/3438 prepare_report [8] +[340] 0.1 0.00 0.03 3438 prepare_lighthouse [340] + 0.02 0.01 3438/3438 get_regions_distance [372] + 0.00 0.00 87604/745269 add_seen_nb [386] + 0.00 0.00 3438/3438 lighthouse_range [728] +----------------------------------------------- + 0.00 0.00 2/447808 create_ship [1014] + 0.00 0.00 2/447808 default_order [902] + 0.00 0.00 8/447808 do_combatmagic [825] + 0.00 0.00 17/447808 recruit_dracoids [837] + 0.00 0.00 23/447808 do_combatspell [702] + 0.00 0.00 43/447808 get_money_for_dragon [1087] + 0.00 0.00 99/447808 piracy_cmd [660] + 0.00 0.00 119/447808 plan_dragon [273] + 0.00 0.00 133/447808 travel [81] + 0.00 0.00 325/447808 build_building [696] + 0.00 0.00 736/447808 monster_attack [764] + 0.00 0.00 5384/447808 teach_cmd [272] + 0.00 0.00 8450/447808 cycle_route [375] + 0.00 0.00 31277/447808 plan_monsters [52] + 0.00 0.01 83723/447808 monster_move [129] + 0.00 0.02 317467/447808 monster_learn [269] +[341] 0.1 0.00 0.03 447808 create_order [341] + 0.01 0.01 447808/1929215 create_order_i [175] + 0.01 0.00 425391/34611296 strlcpy [45] + 0.00 0.00 425391/36653945 wrptr [178] + 0.00 0.00 1196/5100840 itoa36 [116] + 0.00 0.00 17/884940 itoa10 [338] +----------------------------------------------- + 0.03 0.00 1/1 movement [47] +[342] 0.1 0.03 0.00 1 move_hunters [342] + 0.00 0.00 475/475 follow_ship [749] + 0.00 0.00 85384/55492327 getkeyword [54] + 0.00 0.00 597/69432 getparam [681] + 0.00 0.00 475/115276 can_move [736] + 0.00 0.00 597/1027665 init_order [613] + 0.00 0.00 475/1629412 LongHunger [536] +----------------------------------------------- + 0.01 0.00 112140/297010 castle_name_i [513] + 0.02 0.00 184870/297010 buildingeffsize [367] +[343] 0.1 0.03 0.00 297010 bt_effsize [343] + 0.00 0.00 297010/4984610 config_get_int [348] +----------------------------------------------- + 0.01 0.00 3115/13500 drifting_ships [490] + 0.01 0.00 3135/13500 sinkships [475] + 0.02 0.00 7250/13500 ship_ready [354] +[344] 0.1 0.03 0.00 13500 crew_skill [344] + 0.00 0.00 20459/12320804 effskill [100] +----------------------------------------------- + 0.01 0.00 136/388 path_find [523] + 0.01 0.01 252/388 path_exists [431] +[345] 0.1 0.02 0.01 388 internal_path_find [345] + 0.01 0.00 132629/162862 allowed_dragon [564] + 0.00 0.00 67291/369586 r_connect [474] + 0.00 0.00 125069/152803 new_node [1427] + 0.00 0.00 388/428 free_nodes [1604] + 0.00 0.00 48/157830 allowed_fly [1425] +----------------------------------------------- + 0.01 0.02 1/1 process [7] +[346] 0.1 0.01 0.02 1 regenerate_aura [346] + 0.00 0.02 595454/1441945 is_mage [262] + 0.00 0.00 1870/5358 max_spellpoints [755] + 0.00 0.00 508/967784 msg_message [132] + 0.00 0.00 1870/1873 set_spellpoints [933] + 0.00 0.00 1870/4915 get_spellpoints [872] + 0.00 0.00 508/508 regeneration [942] + 0.00 0.00 508/392959 add_message [434] + 0.00 0.00 508/752645 chance [495] + 0.00 0.00 508/12246335 ct_find [114] + 0.00 0.00 508/10190660 get_curse [143] + 0.00 0.00 1/4984610 config_get_int [348] + 0.00 0.00 508/26995 inside_building [1486] + 0.00 0.00 508/26164 building_is_active [1488] + 0.00 0.00 508/651711 oldcursename [1381] + 0.00 0.00 508/432940 curse_geteffect [1395] + 0.00 0.00 508/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.01 923633/2272376 cr_output_unit [19] + 0.00 0.02 1348743/2272376 bufunit [17] +[347] 0.1 0.00 0.03 2272376 u_description [347] + 0.00 0.02 399769/778818 describe_race [267] + 0.01 0.00 2554959/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 1/4984610 report_computer [9] + 0.00 0.00 1/4984610 recruit_init [1334] + 0.00 0.00 1/4984610 tax_cmd [697] + 0.00 0.00 1/4984610 immigration [294] + 0.00 0.00 1/4984610 demographics [50] + 0.00 0.00 1/4984610 nmr_death [1333] + 0.00 0.00 1/4984610 regenerate_aura [346] + 0.00 0.00 1/4984610 rotting_herbs [284] + 0.00 0.00 1/4984610 roqf_factor [1329] + 0.00 0.00 1/4984610 rule_blessed_harvest [1327] + 0.00 0.00 1/4984610 rule_alliance_limit [1332] + 0.00 0.00 1/4984610 rule_faction_limit [1331] + 0.00 0.00 1/4984610 rule_give [1328] + 0.00 0.00 1/4984610 allied_skilllimit [1330] + 0.00 0.00 2/4984610 rule_stealth_anon [1325] + 0.00 0.00 2/4984610 potion_water_of_life [945] + 0.00 0.00 2/4984610 processorders [6] + 0.00 0.00 2/4984610 rule_region_owners [1323] + 0.00 0.00 2/4984610 game_id [1324] + 0.00 0.00 4/4984610 init_processor [1310] + 0.00 0.00 12/4984610 demon_skillchange [826] + 0.00 0.00 16/4984610 init_rules [1272] + 0.00 0.00 27/4984610 NMRTimeout [1264] + 0.00 0.00 29/4984610 study_cost [433] + 0.00 0.00 42/4984610 loot_cmd [873] + 0.00 0.00 47/4984610 walkingcapacity [403] + 0.00 0.00 105/4984610 terraform_resources [986] + 0.00 0.00 111/4984610 LongHunger [536] + 0.00 0.00 118/4984610 rule_transfermen [1204] + 0.00 0.00 191/4984610 CheckOverload [1180] + 0.00 0.00 207/4984610 rule_force_leave [1175] + 0.00 0.00 225/4984610 spellpower [1000] + 0.00 0.00 226/4984610 fumble [973] + 0.00 0.00 226/4984610 skill_limit [1172] + 0.00 0.00 231/4984610 RemoveNMRNewbie [1171] + 0.00 0.00 348/4984610 begin_potion [1096] + 0.00 0.00 457/4984610 FactionSpells [1136] + 0.00 0.00 587/4984610 build_building [696] + 0.00 0.00 688/4984610 can_leave [1112] + 0.00 0.00 702/4984610 max_transfers [1109] + 0.00 0.00 1085/4984610 get_friends [895] + 0.00 0.00 1398/4984610 nmr_warnings [878] + 0.00 0.00 1725/4984610 max_magicians [915] + 0.00 0.00 3659/4984610 ExpensiveMigrants [1004] + 0.00 0.00 14510/4984610 sail [181] + 0.00 0.00 16493/4984610 NewbieImmunity [900] + 0.00 0.00 30250/4984610 peasants [658] + 0.00 0.00 32679/4984610 rule_auto_taxation [855] + 0.00 0.00 40046/4984610 rule_stealth_other [530] + 0.00 0.00 41882/4984610 GiveRestriction [836] + 0.00 0.00 47562/4984610 rule_random_progress [829] + 0.00 0.00 66058/4984610 ShipSpeedBonus [806] + 0.00 0.00 163027/4984610 markets_module [748] + 0.00 0.00 178254/4984610 drifting_ships [490] + 0.00 0.00 178257/4984610 get_food [88] + 0.00 0.00 189341/4984610 rule_autowork [738] + 0.00 0.00 297010/4984610 bt_effsize [343] + 0.00 0.00 472366/4984610 produceexp_days [406] + 0.00 0.00 835616/4984610 study_cmd [105] + 0.00 0.00 987612/4984610 get_astralplane [482] + 0.00 0.01 1381157/4984610 unit_max_hp [136] +[348] 0.1 0.01 0.02 4984610 config_get_int [348] + 0.01 0.01 4984610/5065285 get_param_int [422] +----------------------------------------------- + 0.00 0.03 1594/1594 economics [78] +[349] 0.1 0.00 0.03 1594 expandrecruit [349] + 0.00 0.03 1594/1594 do_recruiting [351] + 0.00 0.00 1594/264251 rsetpeasants [545] + 0.00 0.00 1594/2605004 rpeasants [435] + 0.00 0.00 4782/4782 select_recruitment [1079] + 0.00 0.00 1594/1594 free_recruitments [1568] +----------------------------------------------- + 0.00 0.01 42665/252446 sail [181] + 0.00 0.03 209781/252446 make_route [289] +[350] 0.1 0.00 0.03 252446 movewhere [350] + 0.01 0.02 154829/300501 move_blocked [283] + 0.00 0.01 159343/293362 get_direction [496] + 0.00 0.00 10913/369586 r_connect [474] + 0.00 0.00 1/1 get_translation [1304] +----------------------------------------------- + 0.00 0.03 1594/1594 expandrecruit [349] +[351] 0.1 0.00 0.03 1594 do_recruiting [351] + 0.00 0.03 1667/1667 add_recruits [371] + 0.00 0.00 1670/860263 use_pooled [39] + 0.00 0.00 1670/541982 get_pooled [104] + 0.00 0.00 3340/56052475 get_resourcetype [194] + 0.00 0.00 1670/129167539 u_race [89] + 0.00 0.00 60/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.03 574/574 do_battle [64] +[352] 0.1 0.00 0.03 574 battle_flee [352] + 0.00 0.02 116914/116914 fleechance [408] + 0.00 0.01 14191/14191 flee [638] + 0.00 0.00 58461/752645 chance [495] + 0.00 0.00 8962/1381157 unit_max_hp [136] + 0.00 0.00 3743/71815034 get_race [12] + 0.00 0.00 8132/129167539 u_race [89] + 0.00 0.00 8962/8962 hpflee [1519] +----------------------------------------------- + 0.02 0.01 1/1 process [7] +[353] 0.1 0.02 0.01 1 restack_units [353] + 0.01 0.00 1130203/55492327 getkeyword [54] + 0.00 0.00 20/888603 findunit [123] + 0.00 0.00 20/228907 getid [483] + 0.00 0.00 20/2281756 gettoken [195] + 0.00 0.00 6/593636 building_owner [232] + 0.00 0.00 20/1787006 findparam [458] + 0.00 0.00 20/1027665 init_order [613] + 0.00 0.00 2/3358315 ship_owner [438] +----------------------------------------------- + 0.00 0.03 7254/7254 sail [181] +[354] 0.1 0.00 0.03 7254 ship_ready [354] + 0.02 0.00 7250/13500 crew_skill [344] + 0.00 0.01 7230/10344 cansail [469] + 0.00 0.00 7254/12320804 effskill [100] + 0.00 0.00 7254/3358315 ship_owner [438] + 0.00 0.00 61/15102 cmistake [718] + 0.00 0.00 4/41248 msg_feedback [647] + 0.00 0.00 4/392959 add_message [434] + 0.00 0.00 7250/13500 enoughsailors [1512] + 0.00 0.00 4/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 698/1956810 transfermen [899] + 0.00 0.00 2419/1956810 set_level [774] + 0.00 0.00 2423/1956810 learn_skill [471] + 0.03 0.00 1951270/1956810 read_unit [74] +[355] 0.1 0.03 0.00 1956810 add_skill [355] + 0.00 0.00 1725/1725 max_magicians [915] +----------------------------------------------- + 0.03 0.00 1/1 tolua_process_orders [5] +[356] 0.1 0.03 0.00 1 reset_game [356] + 0.00 0.00 1/3 init_locales [947] +----------------------------------------------- + 0.00 0.00 1/967 promotion_cmd [917] + 0.00 0.00 45/967 count_maxmigrants [730] + 0.00 0.01 230/967 report_computer [9] + 0.00 0.01 230/967 report_plaintext [4] + 0.00 0.01 461/967 maxheroes [492] +[357] 0.1 0.00 0.03 967 count_all [357] + 0.03 0.00 967/2247 count_faction [219] +----------------------------------------------- + 0.00 0.00 174/4457785 findresourcetype [1181] + 0.00 0.00 371/4457785 add_translation [1145] + 0.00 0.00 628/4457785 add_itemname_cb [980] + 0.00 0.00 648/4457785 add_resourcename_cb [977] + 0.00 0.00 191379/4457785 finditemtype [735] + 0.01 0.00 995991/4457785 get_skill [423] + 0.01 0.00 1481616/4457785 get_keyword [274] + 0.01 0.00 1786978/4457785 findparam [458] +[358] 0.1 0.03 0.00 4457785 transliterate [358] + 0.00 0.00 130/46391457 unicode_utf8_to_ucs4 [177] +----------------------------------------------- + 0.03 0.00 195108/195108 report_template [87] +[359] 0.1 0.03 0.00 195108 rps_nowrap [359] +----------------------------------------------- + 0.01 0.00 51976/130250 cr_output_region [10] + 0.02 0.00 78274/130250 report_plaintext [4] +[360] 0.1 0.03 0.00 130250 r_getmessages [360] +----------------------------------------------- + +[361] 0.1 0.03 0.00 a_select [361] +----------------------------------------------- + +[362] 0.1 0.03 0.00 ql_foreachx [362] +----------------------------------------------- + 0.00 0.00 78/13399069 eval_weight [1102] + 0.00 0.00 124/13399069 eval_unit_dative [1076] + 0.00 0.00 604/13399069 eval_spell [961] + 0.00 0.00 834/13399069 eval_resources [907] + 0.00 0.00 1196/13399069 eval_localize [922] + 0.00 0.00 1520/13399069 eval_race [882] + 0.00 0.00 19545/13399069 eval_ship [740] + 0.00 0.00 25857/13399069 eval_int36 [729] + 0.00 0.00 40099/13399069 eval_skill [671] + 0.00 0.00 46224/13399069 eval_faction [685] + 0.00 0.00 67213/13399069 eval_building [494] + 0.00 0.00 108560/13399069 eval_trail [634] + 0.00 0.00 123513/13399069 eval_order [472] + 0.00 0.00 127674/13399069 eval_trailto [369] + 0.00 0.00 127788/13399069 eval_direction [608] + 0.00 0.00 470529/13399069 eval_resource [328] + 0.00 0.00 515550/13399069 eval_region [245] + 0.00 0.00 799427/13399069 eval_unit [223] + 0.00 0.00 883617/13399069 eval_int [268] + 0.01 0.00 2725583/13399069 parse_string [86] + 0.01 0.00 3656767/13399069 add_variable [607] + 0.01 0.00 3656767/13399069 translate [28] +[363] 0.1 0.03 0.00 13399069 balloc [363] +----------------------------------------------- + 0.03 0.00 2818494/2818494 rc_name_s [260] +[364] 0.1 0.03 0.00 2818494 rc_name [364] +----------------------------------------------- + 0.00 0.00 58/21345834 sp_summon_familiar [1025] + 0.00 0.00 119/21345834 plan_dragon [273] + 0.00 0.00 222/21345834 steal_cmd [766] + 0.00 0.00 231/21345834 setstealth_cmd [182] + 0.00 0.00 569/21345834 u_seteffstealth [1199] + 0.00 0.00 2127/21345834 cr_output_unit [19] + 0.00 0.00 2129/21345834 read_unit [74] + 0.00 0.00 2457/21345834 set_level [774] + 0.00 0.00 3387/21345834 lighthouse_range [728] + 0.00 0.00 6428/21345834 cansee_unit [684] + 0.00 0.00 8034/21345834 u_geteffstealth [919] + 0.00 0.00 23237/21345834 check_leuchtturm [786] + 0.00 0.00 33139/21345834 statistics [70] + 0.00 0.00 36937/21345834 cr_output_region [10] + 0.00 0.00 45891/21345834 get_level [934] + 0.00 0.00 419518/21345834 plan_monsters [52] + 0.00 0.00 1188531/21345834 eff_stealth [163] + 0.00 0.00 2363341/21345834 cansee [22] + 0.01 0.00 7179079/21345834 rc_skillmod [140] + 0.01 0.00 10030400/21345834 effskill [100] +[365] 0.1 0.03 0.00 21345834 skill_enabled [365] +----------------------------------------------- + 0.00 0.00 1/451774 reshow_other [823] + 0.00 0.00 1/451774 usetprivate [1041] + 0.00 0.00 8/451774 melt_iceberg [1082] + 0.00 0.00 23/451774 set_group [1048] + 0.00 0.00 40/451774 plan_monsters [52] + 0.00 0.00 40/451774 deathcounts [843] + 0.00 0.00 105/451774 change_effect [982] + 0.00 0.00 4738/451774 expandselling [93] + 0.00 0.00 5679/451774 expandbuying [49] + 0.00 0.00 23562/451774 a_age [418] + 0.01 0.02 417577/451774 study_cmd [105] +[366] 0.1 0.01 0.02 451774 a_remove [366] + 0.01 0.00 451774/451774 a_unlink [559] + 0.01 0.00 451774/454395 a_free [558] +----------------------------------------------- + 0.00 0.00 3/184870 bewegung_blockiert_von [631] + 0.00 0.00 3778/184870 expandselling [93] + 0.00 0.00 11599/184870 building_protection [708] + 0.01 0.02 169490/184870 default_wage [173] +[367] 0.1 0.01 0.02 184870 buildingeffsize [367] + 0.02 0.00 184870/297010 bt_effsize [343] +----------------------------------------------- + 0.00 0.00 1529/2275967 give_men [857] + 0.00 0.00 2062/2275967 create_unit [296] + 0.00 0.01 923633/2275967 cr_output_unit [19] + 0.01 0.01 1348743/2275967 bufunit [17] +[368] 0.1 0.01 0.02 2275967 get_racename [368] + 0.02 0.00 2275967/51974272 a_find [65] +----------------------------------------------- + 0.00 0.03 127674/127674 parse_symbol [42] +[369] 0.1 0.00 0.03 127674 eval_trailto [369] + 0.00 0.01 127674/146950 f_regionid_s [477] + 0.00 0.01 127674/785221 trailinto [207] + 0.00 0.00 127674/13102790 opstack_pop [176] + 0.00 0.00 127674/13102790 opstack_push [202] + 0.00 0.00 127674/13399069 balloc [363] +----------------------------------------------- + 0.02 0.01 1/1 randomevents [91] +[370] 0.1 0.02 0.01 1 orc_growth [370] + 0.01 0.00 187111/2624955 has_skill [193] + 0.00 0.00 91483/12246335 ct_find [114] + 0.00 0.00 91483/10190660 get_curse [143] +----------------------------------------------- + 0.00 0.03 1667/1667 do_recruiting [351] +[371] 0.1 0.00 0.03 1667 add_recruits [371] + 0.00 0.02 1298/2889 create_unit [296] + 0.00 0.01 1298/1794 remove_unit [499] + 0.00 0.00 1667/2375 equip_unit [775] + 0.00 0.00 1298/1936 transfermen [899] + 0.00 0.00 369/1381157 unit_max_hp [136] + 0.00 0.00 1667/34611296 strlcpy [45] + 0.00 0.00 4632/129167539 u_race [89] + 0.00 0.00 58/967784 msg_message [132] + 0.00 0.00 58/392959 add_message [434] + 0.00 0.00 3334/987128 strlcat [1374] + 0.00 0.00 1667/2742 get_equipment [1551] + 0.00 0.00 369/603524 set_number [1387] + 0.00 0.00 58/1009028 msg_release [1373] +----------------------------------------------- + 0.02 0.01 3438/3438 prepare_lighthouse [340] +[372] 0.1 0.02 0.01 3438 get_regions_distance [372] + 0.00 0.01 200928/298951 distance [599] + 0.00 0.00 88016/1087065 get_neighbours [480] +----------------------------------------------- + +[373] 0.1 0.00 0.03 ql_set_find_ex [373] + 0.03 0.00 2506526/7252744 cmp_transfer [203] +----------------------------------------------- + 0.00 0.00 1/6963 move_iceberg [1094] + 0.00 0.00 15/6963 drifting_ships [490] + 0.02 0.01 6947/6963 sail [181] +[374] 0.1 0.02 0.01 6963 move_ship [374] + 0.00 0.00 10653/109785 move_unit [421] + 0.00 0.00 6962/6962 leave_trail [704] + 0.00 0.00 6952/113844 translist [430] + 0.00 0.00 10679/106919 mark_travelthru [610] + 0.00 0.00 10679/12320804 effskill [100] + 0.00 0.00 9105/472418 produceexp [322] +----------------------------------------------- + 0.00 0.00 6947/103187 sail [181] + 0.00 0.03 96240/103187 travel_route [147] +[375] 0.1 0.00 0.03 103187 cycle_route [375] + 0.00 0.00 133973/24887945 locale_string [27] + 0.00 0.01 133973/293362 get_direction [496] + 0.01 0.00 8450/14326 replace_order [526] + 0.00 0.00 142423/2281756 gettoken [195] + 0.00 0.00 63020/17451017 strlcpy_w [67] + 0.00 0.00 103187/55492327 getkeyword [54] + 0.00 0.00 8450/447808 create_order [341] + 0.00 0.00 8450/1027665 init_order [613] + 0.00 0.00 188092/987128 strlcat [1374] + 0.00 0.00 8450/1936876 free_order [1356] +----------------------------------------------- + 0.00 0.00 174/147217 peasant_luck_effect [984] + 0.00 0.00 22496/147217 rotting_herbs [284] + 0.02 0.01 124547/147217 horses [330] +[376] 0.1 0.02 0.01 147217 normalvariate [376] + 0.00 0.01 403284/1336242 rng_injectable_double [396] +----------------------------------------------- + 0.00 0.00 7/15361 start_battle [297] + 0.00 0.00 30/15361 buy [707] + 0.00 0.00 39/15361 sell [498] + 0.00 0.00 42/15361 loot_cmd [873] + 0.00 0.00 66/15361 travel [81] + 0.00 0.00 278/15361 entertain_cmd [665] + 0.00 0.00 956/15361 tax_cmd [697] + 0.00 0.00 1716/15361 recruit [650] + 0.00 0.01 3100/15361 create_item [617] + 0.00 0.01 3141/15361 do_work [612] + 0.00 0.01 5986/15361 herbsearch [493] +[377] 0.1 0.00 0.03 15361 is_guarded [377] + 0.00 0.02 1841323/8452306 is_guardian_r [186] + 0.00 0.01 70836/70836 is_guardian_u [626] +----------------------------------------------- + 0.00 0.03 174677/174677 cr_output_resources [238] +[378] 0.1 0.00 0.03 174677 cr_output_resource [378] + 0.01 0.01 174677/4434556 translate [75] + 0.00 0.00 174677/24887945 locale_string [27] + 0.00 0.00 174677/32337529 hashstring [37] +----------------------------------------------- + 0.00 0.00 112/94420 give_unit [952] + 0.01 0.02 94308/94420 give_item [126] +[379] 0.1 0.01 0.02 94420 add_give [379] + 0.00 0.01 80478/967784 msg_message [132] + 0.00 0.00 80478/392959 add_message [434] + 0.00 0.00 1141/15102 cmistake [718] + 0.00 0.00 80478/1009028 msg_release [1373] +----------------------------------------------- + 0.01 0.02 325825/325825 monster_kills_peasants [230] +[380] 0.1 0.01 0.02 325825 scared_by_monster [380] + 0.00 0.01 197727/201744 lovar [644] + 0.00 0.00 325825/7641081 genrand_int31 [171] + 0.00 0.00 325825/51974272 a_find [65] + 0.00 0.00 255939/2605004 rpeasants [435] + 0.00 0.00 325825/129167539 u_race [89] + 0.00 0.00 3152/3152 scareaway [768] + 0.00 0.00 2699/967784 msg_message [132] + 0.00 0.00 2699/392959 add_message [434] + 0.00 0.00 2699/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.03 1/1 processorders [6] +[381] 0.1 0.00 0.03 1 update_spells [381] + 0.02 0.01 231/231 faction_getmages [382] + 0.00 0.00 396/396 show_new_spells [889] + 0.00 0.00 1717/2426021 get_mage [198] + 0.00 0.00 165/12320804 effskill [100] + 0.00 0.00 224/457 FactionSpells [1136] + 0.00 0.00 1/3902878 get_monsters [293] + 0.00 0.00 231/3203 faction_get_spellbook [1543] +----------------------------------------------- + 0.02 0.01 231/231 update_spells [381] +[382] 0.1 0.02 0.01 231 faction_getmages [382] + 0.00 0.01 176043/2426021 get_mage [198] + 0.00 0.00 1717/12320804 effskill [100] +----------------------------------------------- + 0.00 0.03 10600/10600 process [7] +[383] 0.1 0.00 0.03 10600 make_cmd [383] + 0.00 0.01 5988/5988 herbsearch [493] + 0.00 0.01 3626/3626 create_item [617] + 0.00 0.00 621/621 build_building [696] + 0.00 0.00 15176/2281756 gettoken [195] + 0.00 0.00 312/312 continue_ship [813] + 0.00 0.00 4259/4261 findbuildingtype [866] + 0.00 0.00 4259/4259 findshiptype [869] + 0.00 0.00 3086/24887945 locale_string [27] + 0.00 0.00 10600/1787006 findparam [458] + 0.00 0.00 10600/1027665 init_order [613] + 0.00 0.00 41/41 build_road [950] + 0.00 0.00 621/228907 getid [483] + 0.00 0.00 4259/191379 finditemtype [735] + 0.00 0.00 2/2 create_ship [1014] + 0.00 0.00 1543/13259934 resourcename [233] + 0.00 0.00 41/293362 get_direction [496] + 0.00 0.00 10/41248 msg_feedback [647] + 0.00 0.00 976/18647447 getplane [596] + 0.00 0.00 10/392959 add_message [434] + 0.00 0.00 10/1009028 msg_release [1373] +----------------------------------------------- + 0.01 0.02 1/1 movement [47] +[384] 0.1 0.01 0.02 1 init_transportation [384] + 0.02 0.00 1693146/55492327 getkeyword [54] + 0.00 0.00 145/282847 getunit [205] + 0.00 0.00 37/37 transport [1011] + 0.00 0.00 4/1437425 cansee [22] + 0.00 0.00 33/279395 weight [459] + 0.00 0.00 111/1027665 init_order [613] + 0.00 0.00 74/115276 can_move [736] + 0.00 0.00 4/41248 msg_feedback [647] + 0.00 0.00 74/1629412 LongHunger [536] + 0.00 0.00 4/15102 cmistake [718] + 0.00 0.00 20/779419 a_add [555] + 0.00 0.00 4/392959 add_message [434] + 0.00 0.00 20/779868 a_new [1376] + 0.00 0.00 4/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1/1177511 giveitem_read [1262] + 0.00 0.00 7/1177511 has_ao_healing [1269] + 0.00 0.00 9/1177511 default_spoil [1144] + 0.00 0.00 15/1177511 init_oldpotions [1235] + 0.00 0.00 66/1177511 add_items [1169] + 0.00 0.00 121/1177511 tolua_unit_add_item [1103] + 0.00 0.00 185/1177511 it_get_or_create [1115] + 0.00 0.00 242/1177511 canfly [1031] + 0.00 0.00 47287/1177511 canswim [682] + 0.00 0.00 85655/1177511 movement_speed [155] + 0.00 0.01 448447/1177511 read_items [320] + 0.00 0.01 595476/1177511 rotting_herbs [284] +[385] 0.1 0.00 0.03 1177511 it_find [385] + 0.02 0.00 1177511/1177511 it_alias [453] + 0.01 0.00 1177511/2032164 rt_find [597] +----------------------------------------------- + 0.00 0.00 61444/745269 cb_add_seen [94] + 0.00 0.00 87604/745269 prepare_lighthouse [340] + 0.01 0.01 596221/745269 prepare_report [8] +[386] 0.1 0.01 0.02 745269 add_seen_nb [386] + 0.01 0.00 745269/1087065 get_neighbours [480] + 0.00 0.00 1490538/3383689 update_interval [551] + 0.00 0.00 1014205/1014205 add_seen [1372] +----------------------------------------------- + 0.00 0.00 17247/435022 teach_cmd [272] + 0.00 0.02 417775/435022 study_cmd [105] +[387] 0.1 0.00 0.03 435022 getskill [387] + 0.00 0.01 435022/2281756 gettoken [195] + 0.00 0.00 435012/996009 get_skill [423] +----------------------------------------------- + 0.00 0.00 13/840577 read_planes [1164] + 0.00 0.00 233/840577 readfaction [767] + 0.00 0.00 1694/840577 read_groups [782] + 0.00 0.00 65258/840577 read_game [62] + 0.00 0.01 178254/840577 readregion [209] + 0.00 0.02 595125/840577 read_unit [74] +[388] 0.1 0.00 0.03 840577 read_attribs [388] + 0.00 0.03 840577/840577 a_read_orig [389] + 0.00 0.00 1/1 a_upgradekeys [1314] +----------------------------------------------- + 0.00 0.03 840577/840577 read_attribs [388] +[389] 0.1 0.00 0.03 840577 a_read_orig [389] + 0.00 0.03 251814/251814 a_read_i [390] + 0.00 0.00 251814/251874 __at_hashkey [3279] +----------------------------------------------- + 0.00 0.03 251814/251814 a_read_orig [389] +[390] 0.1 0.00 0.03 251814 a_read_i [390] + 0.00 0.01 39836/39836 read_of [524] + 0.01 0.00 251814/251814 at_find [563] + 0.00 0.00 251365/779419 a_add [555] + 0.00 0.00 4020/4020 curse_read [770] + 0.00 0.00 1557/1557 read_handler [799] + 0.00 0.00 1138/1138 read_targetregion [870] + 0.00 0.00 760/760 read_familiar [893] + 0.00 0.00 760/760 read_magician [894] + 0.00 0.00 2491/2491 a_readeffect [1052] + 0.00 0.00 449/454395 a_free [558] + 0.00 0.00 2/2 wormhole_read [1238] + 0.00 0.00 251814/779868 a_new [1376] + 0.00 0.00 58412/58518 a_readint [1448] + 0.00 0.00 56503/56503 read_group [1451] + 0.00 0.00 34382/34382 a_readshorts [1474] + 0.00 0.00 34220/34220 shiptrail_read [1475] + 0.00 0.00 8191/8191 read_seenspell [1522] + 0.00 0.00 7085/7085 a_readprivate [1531] + 0.00 0.00 2091/2091 read_mage [1559] + 0.00 0.00 136/136 a_readstring [1642] + 0.00 0.00 106/106 a_readkey [1648] + 0.00 0.00 68/68 a_readchars [1660] + 0.00 0.00 56/56 dict_read [1676] +----------------------------------------------- + 0.00 0.03 1/1 quit [276] +[391] 0.1 0.00 0.03 1 remove_idle_players [391] + 0.02 0.01 1/1 destroyfaction [392] + 0.00 0.00 231/231 RemoveNMRNewbie [1171] + 0.00 0.00 1/3902878 get_monsters [293] + 0.00 0.00 1/27 NMRTimeout [1264] + 0.00 0.00 1/1 nmr_death [1333] + 0.00 0.00 2/64 log_info [1339] +----------------------------------------------- + 0.02 0.01 1/1 remove_idle_players [391] +[392] 0.1 0.02 0.01 1 destroyfaction [392] + 0.01 0.00 595441/51974272 a_find [65] + 0.00 0.00 9/1803 gift_items [891] + 0.00 0.00 9/264251 rsetpeasants [545] + 0.00 0.00 1/40046 rule_stealth_other [530] + 0.00 0.00 9/7120688 get_money [187] + 0.00 0.00 9/2605004 rpeasants [435] + 0.00 0.00 18/129167539 u_race [89] + 0.00 0.00 9/2186159 rsetmoney [553] + 0.00 0.00 9/4666665 rmoney [452] + 0.00 0.00 39954/1380007 get_otherfaction [1362] + 0.00 0.00 9/1160345 rhorses [1369] + 0.00 0.00 9/257693 rsethorses [1408] + 0.00 0.00 9/603524 set_number [1387] + 0.00 0.00 1/1342832 handle_event [1363] + 0.00 0.00 1/1 funhash [1806] +----------------------------------------------- + 0.00 0.02 843545/843545 parse_symbol [42] +[393] 0.1 0.00 0.02 843545 eval_if [393] + 0.02 0.00 2530635/13102790 opstack_pop [176] + 0.01 0.00 843545/13102790 opstack_push [202] +----------------------------------------------- + 0.00 0.00 9/178263 melt_iceberg [1082] + 0.01 0.01 178254/178263 icebergs [285] +[394] 0.1 0.01 0.01 178263 drown [394] + 0.01 0.00 127590/1375380 remove_empty_units_in_region [134] + 0.00 0.00 7544/47287 canswim [682] + 0.00 0.00 7560/71815034 get_race [12] + 0.00 0.00 7560/129167539 u_race [89] + 0.00 0.00 3/967784 msg_message [132] + 0.00 0.00 3/242 canfly [1031] + 0.00 0.00 3/392959 add_message [434] + 0.00 0.00 3/3178 scale_number [969] + 0.00 0.00 3/1009028 msg_release [1373] +----------------------------------------------- + 0.01 0.01 1336242/1336242 rng_injectable_double [396] +[395] 0.1 0.01 0.01 1336242 genrand_real2 [395] + 0.01 0.00 1336242/11253756 genrand_int32 [150] +----------------------------------------------- + 0.00 0.00 58/1336242 peasant_luck_effect [984] + 0.00 0.00 1016/1336242 regeneration [942] + 0.00 0.00 7074/1336242 immigration [294] + 0.00 0.00 25985/1336242 plagues [781] + 0.00 0.00 30250/1336242 peasants [658] + 0.00 0.00 32878/1336242 demographics [50] + 0.00 0.00 83094/1336242 ntimespprob [723] + 0.00 0.01 403284/1336242 normalvariate [376] + 0.00 0.01 752603/1336242 chance [495] +[396] 0.1 0.00 0.02 1336242 rng_injectable_double [396] + 0.01 0.01 1336242/1336242 genrand_real2 [395] +----------------------------------------------- + 0.00 0.01 104830/218422 cr_output_building [239] + 0.00 0.01 113592/218422 nr_building [141] +[397] 0.1 0.00 0.02 218422 report_building [397] + 0.01 0.01 218422/218425 buildingtype [414] + 0.00 0.00 218422/1106528 is_building_type [554] +----------------------------------------------- + 0.01 0.01 655564/655564 parse_symbol [42] +[398] 0.1 0.01 0.01 655564 eval_eq [398] + 0.01 0.00 1311128/13102790 opstack_pop [176] + 0.00 0.00 655564/13102790 opstack_push [202] +----------------------------------------------- + 0.00 0.02 1/1 tolua_write_reports [1] +[399] 0.1 0.00 0.02 1 init_reports [399] + 0.02 0.00 178254/178254 reorder_units [400] + 0.00 0.00 1/1 check_messages_exist [1141] + 0.00 0.00 1/2 create_directories [1294] +----------------------------------------------- + 0.02 0.00 178254/178254 init_reports [399] +[400] 0.1 0.02 0.00 178254 reorder_units [400] + 0.00 0.00 37894/593636 building_owner [232] + 0.00 0.00 18974/3358315 ship_owner [438] +----------------------------------------------- + 0.00 0.02 1766225/1766225 nr_curses [48] +[401] 0.1 0.00 0.02 1766225 nr_curses_i [401] + 0.00 0.01 15186/1380398 nr_render [25] + 0.01 0.00 15186/2742237 paragraph [26] + 0.00 0.00 13217/26045 msg_curse [664] + 0.00 0.00 2069/967784 msg_message [132] + 0.00 0.00 15186/2494242 newline [594] + 0.00 0.00 15186/1009028 msg_release [1373] + 0.00 0.00 13217/26045 curse_cansee [1489] +----------------------------------------------- + 0.00 0.02 754/754 new_units [282] +[402] 0.1 0.00 0.02 754 checkunitnumber [402] + 0.02 0.00 754/2247 count_faction [219] + 0.00 0.00 754/754 rule_alliance_limit [1332] + 0.00 0.00 754/1214 rule_faction_limit [1331] +----------------------------------------------- + 0.00 0.00 12778/96637 canwalk [633] + 0.00 0.02 83859/96637 reduce_weight [404] +[403] 0.1 0.00 0.02 96637 walkingcapacity [403] + 0.00 0.01 179414/12320804 effskill [100] + 0.00 0.00 96637/71815034 get_race [12] + 0.00 0.00 96637/5395063 i_get [130] + 0.00 0.00 96637/2858912 get_effect [225] + 0.00 0.00 193274/2032164 rt_find [597] + 0.00 0.00 193321/129167539 u_race [89] + 0.00 0.00 96637/96637 personcapacity [795] + 0.00 0.00 47/4984610 config_get_int [348] + 0.00 0.00 96637/130867 get_transporters [1431] +----------------------------------------------- + 0.00 0.00 136/83859 plan_dragon [273] + 0.00 0.02 83723/83859 monster_move [129] +[404] 0.1 0.00 0.02 83859 reduce_weight [404] + 0.00 0.02 83859/96637 walkingcapacity [403] + 0.00 0.00 83859/8302761 get_resource [99] + 0.00 0.00 83871/56052475 get_resourcetype [194] + 0.00 0.00 47/47 give_peasants [1060] + 0.00 0.00 12/931076 change_resource [240] +----------------------------------------------- + 0.02 0.00 1/1 randomevents [91] +[405] 0.1 0.02 0.00 1 godcurse [405] + 0.00 0.00 91155/12246335 ct_find [114] + 0.00 0.00 91155/10190660 get_curse [143] + 0.00 0.00 91155/4201030 curse_active [543] + 0.00 0.00 91155/651711 oldcursename [1381] +----------------------------------------------- + 0.02 0.00 472366/472366 produceexp_ex [323] +[406] 0.1 0.02 0.00 472366 produceexp_days [406] + 0.00 0.00 472366/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 249/1121103 make_movement_order [522] + 0.00 0.00 752/1121103 monster_attack [764] + 0.00 0.00 105106/1121103 monster_move [129] + 0.01 0.00 419518/1121103 plan_monsters [52] + 0.01 0.00 595478/1121103 monster_kills_peasants [230] +[407] 0.1 0.02 0.00 1121103 monster_is_waiting [407] + 0.00 0.00 1121103/129167539 u_race [89] +----------------------------------------------- + 0.00 0.02 116914/116914 battle_flee [352] +[408] 0.1 0.00 0.02 116914 fleechance [408] + 0.00 0.01 116914/116914 horse_fleeing_bonus [604] + 0.00 0.01 116914/12320804 effskill [100] + 0.00 0.00 116914/71815034 get_race [12] + 0.00 0.00 116914/51974272 a_find [65] + 0.00 0.00 116914/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 23/146997 equip_items [1121] + 0.00 0.00 60/146997 damage_unit [1044] + 0.00 0.00 174/146997 terraform_resources [986] + 0.00 0.00 1560/146997 equip_unit_mask [776] + 0.00 0.00 2491/146997 hunger [808] + 0.00 0.01 42157/146997 attack [84] + 0.00 0.02 100532/146997 terminate [242] +[409] 0.1 0.00 0.02 146997 dice_rand [409] + 0.02 0.00 146997/146997 term_eval [410] +----------------------------------------------- + 0.02 0.00 146997/146997 dice_rand [409] +[410] 0.1 0.02 0.00 146997 term_eval [410] + 0.00 0.00 204245/7641081 genrand_int31 [171] +----------------------------------------------- + 0.02 0.00 1/1 tolua_spawn_dragons [412] +[411] 0.1 0.02 0.00 1 spawn_dragons [411] + 0.00 0.00 139786/7641081 genrand_int31 [171] + 0.00 0.00 20/20 spawn_seaserpent [831] + 0.00 0.00 10/2889 create_unit [296] + 0.00 0.00 12205/21517 chaosfactor [1077] + 0.00 0.00 10/2375 equip_unit [775] + 0.00 0.00 10/967784 msg_message [132] + 0.00 0.00 10/2931 name_unit [803] + 0.00 0.00 10/361 regionname [987] + 0.00 0.00 10/392959 add_message [434] + 0.00 0.00 10/24887945 locale_string [27] + 0.00 0.00 10/10 nrand [1232] + 0.00 0.00 10/71815034 get_race [12] + 0.00 0.00 10/752645 chance [495] + 0.00 0.00 10/2818494 rc_name_s [260] + 0.00 0.00 20/129167539 u_race [89] + 0.00 0.00 1/3902879 get_or_create_monsters [292] + 0.00 0.00 10/49235 log_debug [1245] + 0.00 0.00 139323/1511812 newterrain [1359] + 0.00 0.00 10/2742 get_equipment [1551] + 0.00 0.00 10/1009028 msg_release [1373] +----------------------------------------------- + +[412] 0.1 0.00 0.02 tolua_spawn_dragons [412] + 0.02 0.00 1/1 spawn_dragons [411] +----------------------------------------------- + 0.00 0.00 111/284005 steal_cmd [766] + 0.00 0.00 147/284005 contact_cmd [965] + 0.00 0.00 900/284005 follow_unit [331] + 0.00 0.02 282847/284005 getunit [205] +[413] 0.1 0.00 0.02 284005 read_unitid [413] + 0.00 0.01 284005/2281756 gettoken [195] + 0.01 0.00 281303/688711 atoi36 [440] + 0.00 0.00 283968/534930 isparam [668] + 0.00 0.00 2665/2665 read_newunitid [739] +----------------------------------------------- + 0.00 0.00 3/218425 new_building [1059] + 0.01 0.01 218422/218425 report_building [397] +[414] 0.1 0.01 0.01 218425 buildingtype [414] + 0.00 0.01 112140/112140 castle_name [512] + 0.00 0.00 15060/1106528 is_building_type [554] +----------------------------------------------- + 0.02 0.00 1/1 tolua_update_guards [416] +[415] 0.1 0.02 0.00 1 update_guards [415] + 0.00 0.00 31357/55350 can_start_guarding [679] + 0.00 0.00 31351/51974272 a_find [65] + 0.00 0.00 6/337987 setguard [815] +----------------------------------------------- + +[416] 0.1 0.00 0.02 tolua_update_guards [416] + 0.02 0.00 1/1 update_guards [415] +----------------------------------------------- + 0.00 0.00 32670/669051 peasants [658] + 0.00 0.00 33139/669051 statistics [70] + 0.00 0.00 36937/669051 cr_output_region [10] + 0.00 0.00 127676/669051 describe [35] + 0.00 0.01 438629/669051 maxworkingpeasants [473] +[417] 0.1 0.00 0.02 669051 production [417] + 0.01 0.00 669051/12246335 ct_find [114] + 0.01 0.00 669051/10190660 get_curse [143] + 0.00 0.00 669051/4201030 curse_active [543] +----------------------------------------------- + 0.00 0.00 46184/839202 age_building [712] + 0.00 0.00 178254/839202 age_region [659] + 0.01 0.00 614764/839202 ageing [185] +[418] 0.1 0.02 0.00 839202 a_age [418] + 0.00 0.00 23562/451774 a_remove [366] + 0.00 0.00 106/106 age_reduceproduction [1017] + 0.00 0.00 2/2 wormhole_age [1130] + 0.00 0.00 37453/37453 shiptrail_age [1468] + 0.00 0.00 4052/4052 curse_age [1538] + 0.00 0.00 1522/1522 age_unit [1573] + 0.00 0.00 186/186 leftship_age [1635] +----------------------------------------------- + 0.00 0.02 230/230 report_plaintext [4] +[419] 0.1 0.00 0.02 230 allies [419] + 0.00 0.02 1888/1888 show_allies [429] + 0.00 0.00 1888/2742237 paragraph [26] + 0.00 0.00 1888/24887945 locale_string [27] + 0.00 0.00 1888/2494242 newline [594] +----------------------------------------------- + 0.00 0.00 1/459083 tolua_get_region [1296] + 0.00 0.00 5/459083 cast_cmd [760] + 0.00 0.00 125/459083 tpregion [1085] + 0.00 0.00 8892/459083 r_astral_to_standard [783] + 0.00 0.01 108425/459083 update_lighthouse [605] + 0.00 0.01 163381/459083 astralregions [329] + 0.00 0.01 178254/459083 readregion [209] +[420] 0.1 0.00 0.02 459083 findregion [420] + 0.02 0.00 459083/1006923 rfindhash [271] +----------------------------------------------- + 0.00 0.00 1/109785 wormhole_age [1130] + 0.00 0.00 2/109785 sp_enterastral [1045] + 0.00 0.00 2889/109785 create_unit [296] + 0.00 0.00 10653/109785 move_ship [374] + 0.00 0.02 96240/109785 travel_route [147] +[421] 0.1 0.00 0.02 109785 move_unit [421] + 0.00 0.02 106892/113844 translist [430] + 0.00 0.00 209/2887 leave [432] + 0.00 0.00 109781/3383689 update_interval [551] + 0.00 0.00 2889/760673 addlist [217] + 0.00 0.00 106892/337987 setguard [815] +----------------------------------------------- + 0.00 0.00 45/5065285 count_maxmigrants [730] + 0.00 0.00 80630/5065285 armor_bonus [819] + 0.01 0.01 4984610/5065285 config_get_int [348] +[422] 0.1 0.01 0.01 5065285 get_param_int [422] + 0.01 0.00 5065285/26776263 get_param [235] +----------------------------------------------- + 0.00 0.00 12/996009 forget_cmd [1093] + 0.00 0.00 435012/996009 getskill [387] + 0.01 0.01 560985/996009 create_data [252] +[423] 0.1 0.01 0.01 996009 get_skill [423] + 0.01 0.00 995991/4457785 transliterate [358] + 0.00 0.00 995991/4558423 get_translations [437] +----------------------------------------------- + 0.00 0.00 2/1297 summon_allies [925] + 0.00 0.02 1295/1297 join_battle [425] +[424] 0.1 0.00 0.02 1297 make_fighter [424] + 0.01 0.00 1297/1297 AllianceAuto [535] + 0.00 0.01 56927/546579 weapon_skill [221] + 0.00 0.00 863/3147 i_canuse [569] + 0.00 0.00 17902/7641081 genrand_int31 [171] + 0.00 0.00 2909/12320804 effskill [100] + 0.00 0.00 552/552 make_side [876] + 0.00 0.00 2594/83224 trollbelts [677] + 0.00 0.00 2594/5395063 i_get [130] + 0.00 0.00 1297/2858912 get_effect [225] + 0.00 0.00 7054/129167539 u_race [89] + 0.00 0.00 489/71815034 get_race [12] + 0.00 0.00 1593/51974272 a_find [65] + 0.00 0.00 406/12246335 ct_find [114] + 0.00 0.00 3891/56052475 get_resourcetype [194] + 0.00 0.00 406/10190660 get_curse [143] + 0.00 0.00 1729/4301501 statusrow [550] + 0.00 0.00 326/7910500 r_isforest [199] + 0.00 0.00 110533/110533 weapon_weight [1435] + 0.00 0.00 3531/2379316 resource2weapon [1353] + 0.00 0.00 1297/1297 add_tactics [1579] + 0.00 0.00 1295/1295 find_side [1581] + 0.00 0.00 768/1429 set_attacker [1576] + 0.00 0.00 314/314 CavalrySkill [1608] + 0.00 0.00 156/1380007 get_otherfaction [1362] +----------------------------------------------- + 0.00 0.00 345/3203 join_allies [693] + 0.00 0.02 2858/3203 start_battle [297] +[425] 0.1 0.00 0.02 3203 join_battle [425] + 0.00 0.02 1295/1297 make_fighter [424] + 0.00 0.00 1774/51974272 a_find [65] + 0.00 0.00 661/1429 set_attacker [1576] +----------------------------------------------- + 0.01 0.01 16132/16132 teach_cmd [272] +[426] 0.1 0.01 0.01 16132 teach_unit [426] + 0.01 0.00 1302/1302 academy_can_teach [527] + 0.00 0.00 11749/779419 a_add [555] + 0.00 0.00 16132/51974272 a_find [65] + 0.00 0.00 16132/16132 magic_lowskill [897] + 0.00 0.00 11749/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 99/597806 eff_spelllevel [845] + 0.00 0.00 365/597806 unit_getspell [758] + 0.00 0.00 492/597806 u_hasspell [951] + 0.00 0.00 1711/597806 cr_output_spells [639] + 0.00 0.02 595139/597806 bufunit [17] +[427] 0.1 0.00 0.02 597806 unit_get_spellbook [427] + 0.00 0.02 597806/2426021 get_mage [198] + 0.00 0.00 2972/3203 faction_get_spellbook [1543] +----------------------------------------------- + 0.00 0.02 230/230 report_computer [9] +[428] 0.1 0.00 0.02 230 report_crtypes [428] + 0.02 0.00 7964/7964 nrt_string [443] + 0.00 0.00 7964/5168717 nrt_find [98] + 0.00 0.00 7964/618305 escape_string [556] + 0.00 0.00 7964/7964 nrt_section [1524] +----------------------------------------------- + 0.00 0.02 1888/1888 allies [419] +[429] 0.1 0.00 0.02 1888 show_allies [429] + 0.01 0.00 110660/10375491 alliedgroup [34] + 0.01 0.00 293954/34611296 strlcpy [45] + 0.00 0.00 65837/24887945 locale_string [27] + 0.00 0.00 55330/1295787 factionname [247] + 0.00 0.00 293954/36653945 wrptr [178] +----------------------------------------------- + 0.00 0.00 6952/113844 move_ship [374] + 0.00 0.02 106892/113844 move_unit [421] +[430] 0.1 0.00 0.02 113844 translist [430] + 0.01 0.00 113844/760673 addlist [217] + 0.01 0.00 113844/113845 choplist [565] +----------------------------------------------- + 0.00 0.00 3/252 farcasting [842] + 0.00 0.02 249/252 plan_dragon [273] +[431] 0.1 0.00 0.02 252 path_exists [431] + 0.01 0.01 252/388 internal_path_find [345] +----------------------------------------------- + 0.00 0.00 2/2887 summon_allies [925] + 0.00 0.00 2/2887 create_ship [1014] + 0.00 0.00 9/2887 build_building [696] + 0.00 0.00 136/2887 aftermath [701] + 0.00 0.00 191/2887 enter_ship [733] + 0.00 0.00 209/2887 move_unit [421] + 0.00 0.00 222/2887 leave_cmd [721] + 0.00 0.00 323/2887 enter_building [695] + 0.01 0.01 1793/2887 remove_unit [499] +[432] 0.1 0.01 0.01 2887 leave [432] + 0.00 0.01 224/224 leave_ship [540] + 0.00 0.00 1125/1125 leave_building [1009] + 0.00 0.00 734/95593 can_leave [1112] +----------------------------------------------- + 0.00 0.00 404/418134 academy_can_teach [527] + 0.02 0.00 417730/418134 study_cmd [105] +[433] 0.1 0.02 0.00 418134 study_cost [433] + 0.00 0.00 724/45891 get_level [934] + 0.00 0.00 29/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 1/392959 report_action [860] + 0.00 0.00 1/392959 sp_summon_familiar [1025] + 0.00 0.00 1/392959 sp_summonshadowlords [1034] + 0.00 0.00 1/392959 allocate_resource [752] + 0.00 0.00 1/392959 plant [1184] + 0.00 0.00 1/392959 planttrees [1206] + 0.00 0.00 1/392959 breedtrees [1148] + 0.00 0.00 1/392959 promotion_cmd [917] + 0.00 0.00 1/392959 age_stonecircle [1021] + 0.00 0.00 1/392959 verify_building [1255] + 0.00 0.00 1/392959 cast_cmd [760] + 0.00 0.00 1/392959 use_skillpotion [1233] + 0.00 0.00 2/392959 msg_to_ship_inmates [1286] + 0.00 0.00 2/392959 travel [81] + 0.00 0.00 2/392959 sp_bloodsacrifice [1209] + 0.00 0.00 2/392959 sp_charmingsong [993] + 0.00 0.00 2/392959 magic [157] + 0.00 0.00 2/392959 create_icebergs [538] + 0.00 0.00 2/392959 make_wormhole [1150] + 0.00 0.00 3/392959 begin_potion [1096] + 0.00 0.00 3/392959 give_control_cmd [287] + 0.00 0.00 3/392959 drown [394] + 0.00 0.00 3/392959 melt_iceberg [1082] + 0.00 0.00 3/392959 use_healingpotion [1119] + 0.00 0.00 4/392959 wormhole_age [1130] + 0.00 0.00 4/392959 caught_target [1003] + 0.00 0.00 4/392959 init_transportation [384] + 0.00 0.00 4/392959 make_route [289] + 0.00 0.00 4/392959 ship_ready [354] + 0.00 0.00 4/392959 give_men [857] + 0.00 0.00 4/392959 quit [276] + 0.00 0.00 4/392959 move_iceberg [1094] + 0.00 0.00 4/392959 factionorders [983] + 0.00 0.00 5/392959 buy [707] + 0.00 0.00 5/392959 sp_flying_ship [1064] + 0.00 0.00 6/392959 msg_send_region [1210] + 0.00 0.00 10/392959 make_cmd [383] + 0.00 0.00 10/392959 tax_cmd [697] + 0.00 0.00 10/392959 spy_cmd [990] + 0.00 0.00 10/392959 spawn_dragons [411] + 0.00 0.00 12/392959 sp_summonundead [896] + 0.00 0.00 12/392959 forget_cmd [1093] + 0.00 0.00 13/392959 volcano_destruction [1022] + 0.00 0.00 15/392959 do_fumble [1062] + 0.00 0.00 19/392959 enter_building [695] + 0.00 0.00 22/392959 spy_message [1038] + 0.00 0.00 24/392959 cancast [833] + 0.00 0.00 33/392959 travel_i [92] + 0.00 0.00 37/392959 volcano_update [981] + 0.00 0.00 37/392959 build_road [950] + 0.00 0.00 38/392959 expandstealing [807] + 0.00 0.00 39/392959 deliverMail [966] + 0.00 0.00 39/392959 display_item [1054] + 0.00 0.00 39/392959 random_growl [1065] + 0.00 0.00 41/392959 dissolve_units [241] + 0.00 0.00 47/392959 caddmessage [1070] + 0.00 0.00 51/392959 potion_water_of_life [945] + 0.00 0.00 51/392959 chaos [848] + 0.00 0.00 55/392959 nmr_warnings [878] + 0.00 0.00 56/392959 use_bloodpotion [935] + 0.00 0.00 57/392959 start_battle [297] + 0.00 0.00 58/392959 add_recruits [371] + 0.00 0.00 76/392959 steal_cmd [766] + 0.00 0.00 84/392959 do_work [612] + 0.00 0.00 88/392959 hunger [808] + 0.00 0.00 100/392959 age_reduceproduction [1017] + 0.00 0.00 110/392959 peasants [658] + 0.00 0.00 115/392959 build_ship [839] + 0.00 0.00 119/392959 syntax_error [1036] + 0.00 0.00 120/392959 plagues [781] + 0.00 0.00 121/392959 msg_send_faction [1042] + 0.00 0.00 149/392959 create_potion [821] + 0.00 0.00 170/392959 breedhorses [742] + 0.00 0.00 170/392959 guard_on_cmd [656] + 0.00 0.00 266/392959 spawn_undead [629] + 0.00 0.00 328/392959 mail_cmd [844] + 0.00 0.00 345/392959 end_potion [814] + 0.00 0.00 349/392959 research_cmd [886] + 0.00 0.00 377/392959 manufacture [759] + 0.00 0.00 508/392959 regenerate_aura [346] + 0.00 0.00 567/392959 eaten_by_monster [468] + 0.00 0.00 581/392959 build_building [696] + 0.00 0.00 681/392959 absorbed_by_monster [804] + 0.00 0.00 1225/392959 give_item [126] + 0.00 0.00 1323/392959 teach_cmd [272] + 0.00 0.00 2699/392959 scared_by_monster [380] + 0.00 0.00 2938/392959 split_allocations [743] + 0.00 0.00 5049/392959 piracy_cmd [660] + 0.00 0.00 5966/392959 herbsearch [493] + 0.00 0.00 7043/392959 sail [181] + 0.00 0.00 8710/392959 maintain_buildings [339] + 0.00 0.00 8797/392959 cmistake [718] + 0.00 0.00 11358/392959 expandbuying [49] + 0.00 0.00 12265/392959 r_addmessage [779] + 0.00 0.00 12448/392959 expandselling [93] + 0.00 0.00 14939/392959 maintain [478] + 0.00 0.00 20258/392959 study_cmd [105] + 0.00 0.00 29028/392959 give_cmd [102] + 0.00 0.00 31214/392959 message_faction [716] + 0.00 0.00 34409/392959 add_income [625] + 0.00 0.00 80478/392959 add_give [379] + 0.00 0.00 96460/392959 travel_route [147] +[434] 0.1 0.02 0.00 392959 add_message [434] + 0.00 0.00 392959/392959 msg_addref [1399] +----------------------------------------------- + 0.00 0.00 9/2605004 destroyfaction [392] + 0.00 0.00 19/2605004 dissolve_units [241] + 0.00 0.00 30/2605004 res_changepeasants [1200] + 0.00 0.00 45/2605004 region_getresource [1058] + 0.00 0.00 71/2605004 transfermen [899] + 0.00 0.00 74/2605004 plan_dragon [273] + 0.00 0.00 120/2605004 plagues [781] + 0.00 0.00 172/2605004 randomevents [91] + 0.00 0.00 246/2605004 battle_effects [1125] + 0.00 0.00 1594/2605004 expandrecruit [349] + 0.00 0.00 2692/2605004 eaten_by_monster [468] + 0.00 0.00 3455/2605004 absorbed_by_monster [804] + 0.00 0.00 4690/2605004 expandselling [93] + 0.00 0.00 5494/2605004 expandbuying [49] + 0.00 0.00 6569/2605004 scareaway [768] + 0.00 0.00 14863/2605004 sell [498] + 0.00 0.00 31670/2605004 spawn_undead [629] + 0.00 0.00 32670/2605004 demographics [50] + 0.00 0.00 32670/2605004 writeregion [519] + 0.00 0.00 33139/2605004 statistics [70] + 0.00 0.00 54055/2605004 report_plaintext [4] + 0.00 0.00 67774/2605004 peasants [658] + 0.00 0.00 91145/2605004 report_resources [210] + 0.00 0.00 119504/2605004 cr_output_region [10] + 0.00 0.00 144763/2605004 calculate_emigration [603] + 0.00 0.00 178254/2605004 get_food [88] + 0.00 0.00 179832/2605004 describe [35] + 0.00 0.00 185509/2605004 immigration [294] + 0.00 0.00 255939/2605004 scared_by_monster [380] + 0.00 0.00 342640/2605004 expandwork [277] + 0.00 0.00 361137/2605004 produce [29] + 0.00 0.00 454160/2605004 make_summary [21] +[435] 0.1 0.02 0.00 2605004 rpeasants [435] +----------------------------------------------- + 0.00 0.00 71390/7417541 reserve_i [213] + 0.00 0.00 116873/7417541 weapon_effskill [168] + 0.00 0.00 771861/7417541 armedmen [151] + 0.00 0.00 1849529/7417541 get_pooled [104] + 0.01 0.00 4607888/7417541 use_pooled [39] +[436] 0.1 0.02 0.00 7417541 urace [436] +----------------------------------------------- + 0.00 0.00 1/4558423 get_translation [1304] + 0.00 0.00 2/4558423 register_special_direction [1259] + 0.00 0.00 2/4558423 init_directions [1143] + 0.00 0.00 2/4558423 init_terrains_translation [1129] + 0.00 0.00 2/4558423 init_options_translation [1157] + 0.00 0.00 4/4558423 init_locale [948] + 0.00 0.00 6/4558423 findoption [1241] + 0.00 0.00 6/4558423 init_translations [1033] + 0.00 0.00 6/4558423 free_locales [1311] + 0.00 0.00 107/4558423 init_keyword [1179] + 0.00 0.00 338/4558423 findrace [1030] + 0.00 0.00 293362/4558423 get_direction [496] + 0.00 0.00 995991/4558423 get_skill [423] + 0.01 0.00 1481616/4558423 get_keyword [274] + 0.01 0.00 1786978/4558423 findparam [458] +[437] 0.1 0.02 0.00 4558423 get_translations [437] +----------------------------------------------- + 0.00 0.00 1/3358315 move_iceberg [1094] + 0.00 0.00 2/3358315 restack_units [353] + 0.00 0.00 5/3358315 give_control_cmd [287] + 0.00 0.00 6/3358315 validate_pirate [1051] + 0.00 0.00 10/3358315 name_cmd [835] + 0.00 0.00 17/3358315 display_cmd [859] + 0.00 0.00 18/3358315 leave_ship [540] + 0.00 0.00 24/3358315 is_moving_ship [1231] + 0.00 0.00 31/3358315 renumber_cmd [780] + 0.00 0.00 195/3358315 mayboard [1046] + 0.00 0.00 322/3358315 piracy_cmd [660] + 0.00 0.00 475/3358315 follow_ship [749] + 0.00 0.00 1039/3358315 follow_unit [331] + 0.00 0.00 3128/3358315 drifting_ships [490] + 0.00 0.00 7093/3358315 report_template [87] + 0.00 0.00 7254/3358315 ship_ready [354] + 0.00 0.00 7269/3358315 move_cmd [66] + 0.00 0.00 15828/3358315 sinkships [475] + 0.00 0.00 17286/3358315 movement [47] + 0.00 0.00 18974/3358315 reorder_units [400] + 0.00 0.00 27416/3358315 write_unit [97] + 0.00 0.00 38156/3358315 score [23] + 0.00 0.00 66134/3358315 shipspeed [669] + 0.00 0.00 179761/3358315 cr_output_curses [69] + 0.00 0.00 179761/3358315 cr_output_region [10] + 0.00 0.00 180598/3358315 nr_curses [48] + 0.01 0.00 875741/3358315 count_cb [231] + 0.01 0.00 1731771/3358315 travelthru_cansee [180] +[438] 0.1 0.02 0.00 3358315 ship_owner [438] + 0.00 0.00 1511/1529 ship_owner_ex [1571] +----------------------------------------------- + 0.00 0.00 36/2903884 runhash [1247] + 0.00 0.00 1848/2903884 uunhash [1049] + 0.00 0.00 178290/2903884 rhash [737] + 0.00 0.00 598069/2903884 uhash [667] + 0.01 0.00 1006923/2903884 rfindhash [271] + 0.01 0.00 1118718/2903884 ufindhash [109] +[439] 0.1 0.02 0.00 2903884 jenkins_hash [439] +----------------------------------------------- + 0.00 0.00 2/688711 tolua_atoi36 [1299] + 0.00 0.00 3/688711 tolua_getkey [1281] + 0.00 0.00 4/688711 parse_ids [852] + 0.00 0.00 4/688711 forbiddenid [1280] + 0.00 0.00 5/688711 tolua_toid [1274] + 0.00 0.00 6/688711 addparam_building [1261] + 0.00 0.00 16/688711 addparam_unit [1214] + 0.00 0.00 22/688711 addparam_ship [1212] + 0.00 0.00 69/688711 renumber_cmd [780] + 0.00 0.00 209/688711 setstealth_cmd [182] + 0.01 0.00 178254/688711 tolua_region_getkey [628] + 0.01 0.00 228814/688711 getid [483] + 0.01 0.00 281303/688711 read_unitid [413] +[440] 0.1 0.02 0.00 688711 atoi36 [440] +----------------------------------------------- + 0.00 0.00 303/635885 create_castorder [1066] + 0.00 0.00 1670/635885 recruit [650] + 0.00 0.00 3110/635885 default_order [902] + 0.00 0.00 14326/635885 replace_order [526] + 0.00 0.00 41255/635885 var_copy_order [734] + 0.02 0.00 575221/635885 update_long_order [270] +[441] 0.1 0.02 0.00 635885 copy_order [441] +----------------------------------------------- + 0.02 0.00 178254/178254 new_region [275] +[442] 0.1 0.02 0.00 178254 hash_uid [442] +----------------------------------------------- + 0.02 0.00 7964/7964 report_crtypes [428] +[443] 0.1 0.02 0.00 7964 nrt_string [443] +----------------------------------------------- + 0.00 0.00 1/30 tolua_settings_eressea_settings_set00 [773] + 0.00 0.00 1/30 disable_feature [771] + 0.02 0.00 28/30 json_settings [467] +[444] 0.1 0.02 0.00 30 config_set [444] + 0.00 0.00 30/33 set_param [1689] +----------------------------------------------- + +[445] 0.1 0.02 0.00 bin_w_brk [445] +----------------------------------------------- + +[446] 0.1 0.02 0.00 bin_w_str [446] +----------------------------------------------- + +[447] 0.1 0.02 0.00 fs_readln [447] +----------------------------------------------- + +[448] 0.1 0.02 0.00 ql_push [448] +----------------------------------------------- + +[449] 0.1 0.02 0.00 tolua_unit_get_faction [449] +----------------------------------------------- + +[450] 0.1 0.02 0.00 wang_hash [450] +----------------------------------------------- + 0.00 0.00 2889/24935046 create_unit [296] + 0.00 0.00 4181205/24935046 remove_empty_units_in_region [134] + 0.02 0.00 20750952/24935046 alliedgroup [34] +[451] 0.1 0.02 0.00 24935046 faction_alive [451] +----------------------------------------------- + 0.00 0.00 9/4666665 destroyfaction [392] + 0.00 0.00 17/4666665 give_money [484] + 0.00 0.00 36/4666665 expandloot [816] + 0.00 0.00 38/4666665 gift_items [891] + 0.00 0.00 41/4666665 region_getresource [1058] + 0.00 0.00 59/4666665 get_money_for_dragon [1087] + 0.00 0.00 74/4666665 plan_dragon [273] + 0.00 0.00 4629/4666665 expandselling [93] + 0.00 0.00 12922/4666665 plagues [781] + 0.00 0.00 16560/4666665 expandentertainment [637] + 0.00 0.00 27694/4666665 all_money [529] + 0.00 0.00 31725/4666665 statistics [70] + 0.00 0.00 32670/4666665 peasants [658] + 0.00 0.00 32670/4666665 writeregion [519] + 0.00 0.00 36937/4666665 cr_output_region [10] + 0.00 0.00 79772/4666665 entertainmoney [643] + 0.00 0.00 91145/4666665 report_resources [210] + 0.00 0.00 97652/4666665 make_summary [21] + 0.00 0.00 178254/4666665 expandwork [277] + 0.00 0.00 222964/4666665 describe [35] + 0.00 0.00 356508/4666665 produce [29] + 0.00 0.00 394406/4666665 expandbuying [49] + 0.01 0.00 3049883/4666665 expandtax [278] +[452] 0.1 0.02 0.00 4666665 rmoney [452] +----------------------------------------------- + 0.02 0.00 1177511/1177511 it_find [385] +[453] 0.1 0.02 0.00 1177511 it_alias [453] +----------------------------------------------- + 0.02 0.00 162996/162996 astralregions [329] +[454] 0.1 0.02 0.00 162996 inhabitable [454] +----------------------------------------------- + 0.00 0.00 230/20836359 show_alliances_cr [1248] + 0.00 0.00 230/20836359 report_computer [9] + 0.00 0.00 460/20836359 report_plaintext [4] + 0.00 0.00 464/20836359 get_addresses [20] + 0.02 0.00 20834975/20836359 autoalliance [179] +[455] 0.1 0.02 0.00 20836359 f_get_alliance [455] +----------------------------------------------- + 0.02 0.00 10375461/10375461 alliedgroup [34] +[456] 0.1 0.02 0.00 10375461 ally_mode [456] +----------------------------------------------- + 0.00 0.00 1/1206547 tolua_get_region [1296] + 0.00 0.00 178254/1206547 readregion [209] + 0.02 0.00 1028292/1206547 koor_distance [476] +[457] 0.1 0.02 0.00 1206547 findplane [457] +----------------------------------------------- + 0.00 0.00 20/1787006 restack_units [353] + 0.00 0.00 115/1787006 combatspell_cmd [898] + 0.00 0.00 176/1787006 breed_cmd [741] + 0.00 0.00 322/1787006 cast_cmd [760] + 0.00 0.00 461/1787006 setstealth_cmd [182] + 0.00 0.00 677/1787006 ally_cmd [877] + 0.00 0.00 1700/1787006 status_cmd [904] + 0.00 0.00 6530/1787006 findparam_ex [926] + 0.00 0.00 7650/1787006 getparam [681] + 0.00 0.00 10600/1787006 make_cmd [383] + 0.00 0.00 15797/1787006 sell [498] + 0.00 0.00 45456/1787006 give_cmd [102] + 0.00 0.00 71388/1787006 reserve_i [213] + 0.00 0.00 279151/1787006 readorders [43] + 0.00 0.00 362487/1787006 isparam [668] + 0.00 0.01 984476/1787006 unitorders [46] +[458] 0.1 0.00 0.02 1787006 findparam [458] + 0.01 0.00 1786978/4457785 transliterate [358] + 0.01 0.00 1786978/4558423 get_translations [437] +----------------------------------------------- + 0.00 0.00 2/279395 sp_enterastral [1045] + 0.00 0.00 33/279395 init_transportation [384] + 0.00 0.00 34221/279395 eff_weight [683] + 0.00 0.00 70174/279395 getshipweight [212] + 0.01 0.01 174965/279395 cr_output_unit [19] +[459] 0.1 0.01 0.01 279395 weight [459] + 0.00 0.01 279395/5395063 i_get [130] + 0.00 0.00 279395/129167539 u_race [89] + 0.00 0.00 279395/56052475 get_resourcetype [194] +----------------------------------------------- + 0.00 0.02 1/1 tolua_config_eressea_config_read00 [461] +[460] 0.1 0.00 0.02 1 config_read [460] + 0.00 0.02 1/1 config_parse [462] + 0.00 0.00 1/573 join_path [1016] +----------------------------------------------- + +[461] 0.1 0.00 0.02 tolua_config_eressea_config_read00 [461] + 0.00 0.02 1/1 config_read [460] +----------------------------------------------- + 0.00 0.02 1/1 config_read [460] +[462] 0.1 0.00 0.02 1 config_parse [462] + 0.00 0.02 1/1 json_config [464] + 0.00 0.00 1/3 init_locales [947] +----------------------------------------------- +[463] 0.1 0.00 0.02 1+4 [463] + 0.00 0.02 4 json_config [464] + 0.00 0.00 1 json_include [1283] +----------------------------------------------- + 3 json_include [1283] + 0.00 0.02 1/1 config_parse [462] +[464] 0.1 0.00 0.02 4 json_config [464] + 0.00 0.02 1/1 json_settings [467] + 0.00 0.00 1/1 json_disable_features [772] + 0.00 0.00 1/1 json_keywords [1124] + 0.00 0.00 1/1 json_terrains [1190] + 0.00 0.00 4/5 reset_locales [1751] + 0.00 0.00 1/1 json_prefixes [1812] + 0.00 0.00 1/1 init_terrains [1810] + 1 json_include [1283] +----------------------------------------------- + 0.00 0.01 96240/192556 travel_route [147] + 0.00 0.01 96316/192556 movement_speed [155] +[465] 0.1 0.00 0.02 192556 canride [465] + 0.01 0.01 192556/12320804 effskill [100] + 0.00 0.00 21443/21443 ridingcapacity [694] + 0.00 0.00 21443/34221 eff_weight [683] + 0.00 0.00 577668/56052475 get_resourcetype [194] + 0.00 0.00 192570/129167539 u_race [89] +----------------------------------------------- + 0.01 0.01 967902/967902 travelthru_map [41] +[466] 0.1 0.01 0.01 967902 cb_cr_travelthru_unit [466] + 0.00 0.00 94066/1996097 travelthru_cansee [180] + 0.00 0.00 75486/2383101 unitname [142] +----------------------------------------------- + 0.00 0.02 1/1 json_config [464] +[467] 0.1 0.00 0.02 1 json_settings [467] + 0.02 0.00 28/30 config_set [444] +----------------------------------------------- + 0.01 0.01 325282/325282 monster_kills_peasants [230] +[468] 0.1 0.01 0.01 325282 eaten_by_monster [468] + 0.00 0.00 325282/7641081 genrand_int31 [171] + 0.00 0.00 325282/51974272 a_find [65] + 0.00 0.00 325282/129167539 u_race [89] + 0.00 0.00 325282/56052475 get_resourcetype [194] + 0.00 0.00 567/967784 msg_message [132] + 0.00 0.00 1714/201744 lovar [644] + 0.00 0.00 567/392959 add_message [434] + 0.00 0.00 567/264251 rsetpeasants [545] + 0.00 0.00 2692/2605004 rpeasants [435] + 0.00 0.00 567/37974 deathcounts [843] + 0.00 0.00 567/1009028 msg_release [1373] + 0.00 0.00 1/1511812 newterrain [1359] +----------------------------------------------- + 0.00 0.01 3114/10344 drifting_ships [490] + 0.00 0.01 7230/10344 ship_ready [354] +[469] 0.1 0.00 0.02 10344 cansail [469] + 0.02 0.00 10344/47902 getshipweight [212] + 0.00 0.00 10344/47887 shipcapacity [567] +----------------------------------------------- + 0.00 0.00 160572/4503145 cr_output_ship [152] + 0.00 0.00 761036/4503145 bufunit [17] + 0.00 0.01 1335533/4503145 cansee [22] + 0.00 0.01 2246004/4503145 cr_output_unit [19] +[470] 0.1 0.00 0.02 4503145 omniscient [470] + 0.02 0.00 4503145/12560453 rc_changed [256] + 0.00 0.00 2/71815034 get_race [12] +----------------------------------------------- + 0.00 0.00 7/892307 use_skillpotion [1233] + 0.00 0.00 167/892307 academy_teaching_bonus [1128] + 0.00 0.00 2190/892307 demon_skillchange [826] + 0.00 0.01 417577/892307 study_cmd [105] + 0.00 0.01 472366/892307 produceexp_ex [323] +[471] 0.1 0.00 0.02 892307 learn_skill [471] + 0.00 0.01 45090/47535 sk_set [510] + 0.00 0.01 479588/7641081 genrand_int31 [171] + 0.00 0.00 2423/1956810 add_skill [355] + 0.00 0.00 447624/595705 unit_skill [1391] +----------------------------------------------- + 0.00 0.02 123513/123513 parse_symbol [42] +[472] 0.1 0.00 0.02 123513 eval_order [472] + 0.00 0.01 123513/1470505 write_order [121] + 0.00 0.00 123513/13102790 opstack_pop [176] + 0.00 0.00 123513/13102790 opstack_push [202] + 0.00 0.00 123513/13399069 balloc [363] +----------------------------------------------- + 0.00 0.00 17728/438629 immigration [294] + 0.00 0.00 32670/438629 horses [330] + 0.00 0.00 65214/438629 demographics [50] + 0.00 0.01 144763/438629 calculate_emigration [603] + 0.00 0.01 178254/438629 produce [29] +[473] 0.1 0.00 0.02 438629 maxworkingpeasants [473] + 0.00 0.01 438629/669051 production [417] + 0.00 0.00 877258/10053919 rtrees [302] +----------------------------------------------- + 0.00 0.00 1/369586 tolua_region_get_next [1302] + 0.00 0.00 1/369586 move_iceberg [1094] + 0.00 0.00 1/369586 rroad [508] + 0.00 0.00 8/369586 sail [181] + 0.00 0.00 8/369586 rrandneighbour [1221] + 0.00 0.00 10/369586 terraform_region [932] + 0.00 0.00 15/369586 chaos [848] + 0.00 0.00 36/369586 build_road [950] + 0.00 0.00 58/369586 drift_target [1053] + 0.00 0.00 291/369586 describe [35] + 0.00 0.00 2656/369586 scareaway [768] + 0.00 0.00 5134/369586 horses [330] + 0.00 0.00 10913/369586 movewhere [350] + 0.00 0.00 21148/369586 piracy_cmd [660] + 0.00 0.00 25793/369586 regions_in_range [675] + 0.00 0.00 46456/369586 calculate_emigration [603] + 0.00 0.00 51044/369586 cr_borders [135] + 0.00 0.00 67291/369586 internal_path_find [345] + 0.00 0.01 138722/369586 get_neighbours [480] +[474] 0.1 0.00 0.02 369586 r_connect [474] + 0.01 0.00 369586/1006923 rfindhash [271] + 0.00 0.00 369586/18647447 getplane [596] + 0.00 0.00 369586/3587241 pnormalize [1350] +----------------------------------------------- + 0.01 0.01 178254/178254 process [7] +[475] 0.1 0.01 0.01 178254 sinkships [475] + 0.01 0.00 3135/13500 crew_skill [344] + 0.00 0.00 15828/3358315 ship_owner [438] + 0.00 0.00 96/717218 config_get_flt [714] + 0.00 0.00 3135/13500 enoughsailors [1512] + 0.00 0.00 96/160 damage_ship [1641] + 0.00 0.00 5/6 remove_ship [1748] +----------------------------------------------- + 0.00 0.00 220/514146 farcasting [842] + 0.00 0.01 214975/514146 astralregions [329] + 0.00 0.01 298951/514146 distance [599] +[476] 0.0 0.00 0.02 514146 koor_distance [476] + 0.02 0.00 1028292/1206547 findplane [457] + 0.00 0.00 512674/734392 plane_width [1380] + 0.00 0.00 512674/734392 plane_height [1379] + 0.00 0.00 512663/512663 koor_distance_orig [1394] + 0.00 0.00 11/11 koor_distance_wrap_xy [1724] +----------------------------------------------- + 0.00 0.00 19276/146950 eval_trail [634] + 0.00 0.01 127674/146950 eval_trailto [369] +[477] 0.0 0.00 0.02 146950 f_regionid_s [477] + 0.00 0.02 146950/950595 f_regionid [161] +----------------------------------------------- + 0.00 0.02 44190/44190 maintain_buildings [339] +[478] 0.0 0.00 0.02 44190 maintain [478] + 0.00 0.01 13492/541982 get_pooled [104] + 0.00 0.00 6386/860263 use_pooled [39] + 0.00 0.00 14939/967784 msg_message [132] + 0.00 0.00 21463/593636 building_owner [232] + 0.00 0.00 14939/392959 add_message [434] + 0.00 0.00 6524/216069 config_token [794] + 0.00 0.00 14939/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 125/987488 tpregion [1085] + 0.00 0.00 125/987488 r_standard_to_astral [1067] + 0.00 0.00 8892/987488 r_astral_to_standard [783] + 0.00 0.00 17784/987488 astralregions [329] + 0.00 0.00 38612/987488 cr_output_region [10] + 0.00 0.00 62581/987488 describe [35] + 0.00 0.00 85643/987488 movement_speed [155] + 0.00 0.00 178254/987488 spawn_braineaters [505] + 0.00 0.01 595472/987488 age_unit [336] +[479] 0.0 0.00 0.02 987488 is_astral [479] + 0.00 0.02 987488/987612 get_astralplane [482] + 0.00 0.00 987488/18647447 getplane [596] +----------------------------------------------- + 0.00 0.00 30/1087065 treeman_neighbour [1201] + 0.00 0.00 84017/1087065 random_neighbour [153] + 0.00 0.00 88016/1087065 get_regions_distance [372] + 0.00 0.00 169733/1087065 travelthru_add [609] + 0.01 0.00 745269/1087065 add_seen_nb [386] +[480] 0.0 0.01 0.01 1087065 get_neighbours [480] + 0.00 0.01 138722/369586 r_connect [474] +----------------------------------------------- + 0.00 0.00 66416/2765718 peasants [658] + 0.00 0.00 178254/2765718 immigration [294] + 0.01 0.01 2521048/2765718 lifestyle [286] +[481] 0.0 0.01 0.01 2765718 maintenance_cost [481] + 0.01 0.00 2521048/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 124/987612 age_stonecircle [1021] + 0.00 0.02 987488/987612 is_astral [479] +[482] 0.0 0.00 0.02 987612 get_astralplane [482] + 0.01 0.00 987612/987612 getplanebyname [595] + 0.00 0.00 987612/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 20/228907 restack_units [353] + 0.00 0.00 22/228907 mail_cmd [844] + 0.00 0.00 287/228907 factionorders [983] + 0.00 0.00 307/228907 getship [1018] + 0.00 0.00 474/228907 follow_ship [749] + 0.00 0.00 525/228907 follow_unit [331] + 0.00 0.00 621/228907 make_cmd [383] + 0.00 0.00 639/228907 do_enter [128] + 0.00 0.00 754/228907 new_units [282] + 0.00 0.00 791/228907 getfaction [937] + 0.00 0.00 2665/228907 read_newunitid [739] + 0.00 0.01 221802/228907 unitorders [46] +[483] 0.0 0.00 0.02 228907 getid [483] + 0.00 0.01 228907/2281756 gettoken [195] + 0.01 0.00 228814/688711 atoi36 [440] +----------------------------------------------- + 0.02 0.00 51003/51003 give_item [126] +[484] 0.0 0.02 0.00 51003 give_money [484] + 0.00 0.00 22/860263 use_pooled [39] + 0.00 0.00 22/283711 item2resource [561] + 0.00 0.00 17/2186159 rsetmoney [553] + 0.00 0.00 17/4666665 rmoney [452] +----------------------------------------------- + 0.02 0.00 464/464 prepare_report [8] +[485] 0.0 0.02 0.00 464 firstregion [485] +----------------------------------------------- + 0.00 0.01 40/40 plan_dragon [273] +[486] 0.0 0.00 0.01 40 set_new_dragon_target [486] + 0.00 0.01 27694/27694 dragon_affinity_value [516] + 0.00 0.00 40/40 regions_in_range [675] + 0.00 0.00 25/779419 a_add [555] + 0.00 0.00 26/51974272 a_find [65] + 0.00 0.00 25/25 make_targetregion [1701] +----------------------------------------------- + 0.00 0.01 230/481 report_plaintext [4] + 0.00 0.01 251/481 out_faction [615] +[487] 0.0 0.00 0.01 481 count_units [487] + 0.01 0.00 481/2247 count_faction [219] +----------------------------------------------- + 0.00 0.01 110167/110167 cr_render [196] +[488] 0.0 0.00 0.01 110167 cr_resource [488] + 0.00 0.01 110167/4434556 translate [75] + 0.00 0.00 110167/24887945 locale_string [27] + 0.00 0.00 110167/13259934 resourcename [233] +----------------------------------------------- + 0.01 0.00 41095/41095 cr_render [196] +[489] 0.0 0.01 0.00 41095 cr_order [489] + 0.00 0.00 41086/2006524 get_command [108] +----------------------------------------------- + 0.00 0.01 178254/178254 movement [47] +[490] 0.0 0.00 0.01 178254 drifting_ships [490] + 0.01 0.00 3115/13500 crew_skill [344] + 0.00 0.01 3114/10344 cansail [469] + 0.00 0.00 178254/4984610 config_get_int [348] + 0.00 0.00 178254/717218 config_get_flt [714] + 0.00 0.00 3116/12320804 effskill [100] + 0.00 0.00 15/6963 move_ship [374] + 0.00 0.00 15/15 overload [1002] + 0.00 0.00 3128/3358315 ship_owner [438] + 0.00 0.00 15/15 drift_target [1053] + 0.00 0.00 12/967784 msg_message [132] + 0.00 0.00 22/12246335 ct_find [114] + 0.00 0.00 15/6962 set_coast [875] + 0.00 0.00 22/10190660 get_curse [143] + 0.00 0.00 12/12 msg_to_ship_inmates [1286] + 0.00 0.00 30/30 overload_start [1295] + 0.00 0.00 22/4201030 curse_active [543] + 0.00 0.00 3115/13500 enoughsailors [1512] + 0.00 0.00 22/651711 oldcursename [1381] + 0.00 0.00 15/192815 add_regionlist [1419] + 0.00 0.00 15/109377 free_regionlist [1436] + 0.00 0.00 15/160 damage_ship [1641] + 0.00 0.00 1/6 remove_ship [1748] +----------------------------------------------- + 0.00 0.00 17117/137709 terminate [242] + 0.00 0.01 120592/137709 weapon_effskill [168] +[491] 0.0 0.00 0.01 137709 CavalryBonus [491] + 0.00 0.01 137709/12320804 effskill [100] + 0.00 0.00 120592/71815034 get_race [12] + 0.00 0.00 120592/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 1/461 promotion_cmd [917] + 0.00 0.01 230/461 report_computer [9] + 0.00 0.01 230/461 report_plaintext [4] +[492] 0.0 0.00 0.01 461 maxheroes [492] + 0.00 0.01 461/967 count_all [357] +----------------------------------------------- + 0.00 0.01 5988/5988 make_cmd [383] +[493] 0.0 0.00 0.01 5988 herbsearch [493] + 0.00 0.01 5986/15361 is_guarded [377] + 0.00 0.00 5966/5966 ntimespprob [723] + 0.00 0.00 5966/967784 msg_message [132] + 0.00 0.00 5896/472418 produceexp [322] + 0.00 0.00 5988/12320804 effskill [100] + 0.00 0.00 5966/392959 add_message [434] + 0.00 0.00 5896/11241829 i_change [115] + 0.00 0.00 22/15102 cmistake [718] + 0.00 0.00 20639/3166898 rherbs [1351] + 0.00 0.00 5966/101322 rsetherbs [1438] + 0.00 0.00 5966/1009028 msg_release [1373] +----------------------------------------------- + 0.01 0.00 67213/67213 parse_symbol [42] +[494] 0.0 0.01 0.00 67213 eval_building [494] + 0.00 0.00 67213/180818 buildingname [621] + 0.00 0.00 67213/13102790 opstack_pop [176] + 0.00 0.00 67213/13102790 opstack_push [202] + 0.00 0.00 67213/13399069 balloc [363] +----------------------------------------------- + 0.00 0.00 2/752645 do_fumble [1062] + 0.00 0.00 3/752645 target_resists_magic [1154] + 0.00 0.00 10/752645 spawn_dragons [411] + 0.00 0.00 20/752645 bewegung_blockiert_von [631] + 0.00 0.00 24/752645 spy_cmd [990] + 0.00 0.00 29/752645 terraform_region [932] + 0.00 0.00 38/752645 equip_unit_mask [776] + 0.00 0.00 43/752645 get_money_for_dragon [1087] + 0.00 0.00 98/752645 age_stonecircle [1021] + 0.00 0.00 126/752645 create_icebergs [538] + 0.00 0.00 138/752645 terraform_resources [986] + 0.00 0.00 306/752645 plan_dragon [273] + 0.00 0.00 508/752645 regenerate_aura [346] + 0.00 0.00 1062/752645 loot_quota [1013] + 0.00 0.00 2988/752645 monthly_healing [215] + 0.00 0.00 58461/752645 battle_flee [352] + 0.00 0.00 92981/752645 terminate [242] + 0.00 0.01 595808/752645 plan_monsters [52] +[495] 0.0 0.00 0.01 752645 chance [495] + 0.00 0.01 752603/1336242 rng_injectable_double [396] +----------------------------------------------- + 0.00 0.00 1/293362 destroy_road [1230] + 0.00 0.00 4/293362 movement_error [1193] + 0.00 0.00 41/293362 make_cmd [383] + 0.00 0.01 133973/293362 cycle_route [375] + 0.00 0.01 159343/293362 movewhere [350] +[496] 0.0 0.00 0.01 293362 get_direction [496] + 0.01 0.00 293362/302482 findtoken [501] + 0.00 0.00 293362/4558423 get_translations [437] +----------------------------------------------- + 0.00 0.00 174965/1523708 cr_output_unit [19] + 0.00 0.01 1348743/1523708 bufunit [17] +[497] 0.0 0.00 0.01 1523708 uprivate [497] + 0.01 0.00 1523708/51974272 a_find [65] +----------------------------------------------- + 0.00 0.01 15797/15797 produce [29] +[498] 0.0 0.00 0.01 15797 sell [498] + 0.00 0.01 15796/541982 get_pooled [104] + 0.00 0.00 28293/12320804 effskill [100] + 0.00 0.00 31531/2281756 gettoken [195] + 0.00 0.00 12520/760673 addlist [217] + 0.00 0.00 15763/71815034 get_race [12] + 0.00 0.00 3277/15102 cmistake [718] + 0.00 0.00 15797/1787006 findparam [458] + 0.00 0.00 15797/1027665 init_order [613] + 0.00 0.00 14863/2605004 rpeasants [435] + 0.00 0.00 12520/51974272 a_find [65] + 0.00 0.00 15731/191379 finditemtype [735] + 0.00 0.00 39/15361 is_guarded [377] + 0.00 0.00 15763/129167539 u_race [89] + 0.00 0.00 2503/779419 a_add [555] + 0.00 0.00 15763/8506411 besieged [547] + 0.00 0.00 2/560926 bt_find [237] + 0.00 0.00 16651/1511812 newterrain [1359] + 0.00 0.00 15797/204314 bt_changed [1415] + 0.00 0.00 15731/21500 resource2luxury [1499] + 0.00 0.00 15730/308950 r_demand [1404] + 0.00 0.00 2503/779868 a_new [1376] + 0.00 0.00 1112/75797 buildingtype_exists [1443] +----------------------------------------------- + 0.00 0.00 3/1794 chaos [848] + 0.00 0.00 493/1794 remove_empty_units_in_region [134] + 0.00 0.01 1298/1794 add_recruits [371] +[499] 0.0 0.00 0.01 1794 remove_unit [499] + 0.01 0.01 1793/2887 leave [432] + 0.00 0.00 1794/1118718 ufindhash [109] + 0.00 0.00 1794/1803 gift_items [891] + 0.00 0.00 1793/1848 uunhash [1049] + 0.00 0.00 1/1 make_zombie [1267] + 0.00 0.00 1794/1342832 handle_event [1363] + 0.00 0.00 3/603524 set_number [1387] +----------------------------------------------- + 0.00 0.00 567/1474687 give_men [857] + 0.00 0.00 623/1474687 aftermath [701] + 0.00 0.00 754/1474687 new_units [282] + 0.00 0.00 1486/1474687 start_battle [297] + 0.00 0.00 1865/1474687 transfermen [899] + 0.00 0.00 39357/1474687 terminate [242] + 0.00 0.00 94655/1474687 travel [81] + 0.00 0.01 1335380/1474687 cansee [22] +[500] 0.0 0.00 0.01 1474687 leftship [500] + 0.01 0.00 1474687/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 1/302482 get_translation [1304] + 0.00 0.00 6/302482 findoption [1241] + 0.00 0.00 255/302482 unit_getspell [758] + 0.00 0.00 338/302482 findrace [1030] + 0.00 0.00 4259/302482 findshiptype [869] + 0.00 0.00 4261/302482 findbuildingtype [866] + 0.01 0.00 293362/302482 get_direction [496] +[501] 0.0 0.01 0.00 302482 findtoken [501] + 0.00 0.00 1232688/46391457 unicode_utf8_to_ucs4 [177] + 0.00 0.00 6664/49235 log_debug [1245] +----------------------------------------------- + 0.00 0.01 96450/96450 travel_i [92] +[502] 0.0 0.00 0.01 96450 cap_route [502] + 0.00 0.01 108335/108335 roadto [606] + 0.00 0.00 108335/263302 reldirection [528] +----------------------------------------------- + 0.01 0.00 780/780 do_battle [64] +[503] 0.0 0.01 0.00 780 battle_report [503] + 0.00 0.00 25201/17451017 strlcpy_w [67] + 0.00 0.00 2594/12398 fbattlerecord [688] + 0.00 0.00 2594/967784 msg_message [132] + 0.00 0.00 7058/18788 sideabkz [745] + 0.00 0.00 7336/24887945 locale_string [27] + 0.00 0.00 5188/31214 message_faction [716] + 0.00 0.00 7336/5461936 slprintf [548] + 0.00 0.00 7336/7336 get_alive [1528] + 0.00 0.00 7336/24449 seematrix [1491] + 0.00 0.00 7336/22301 army_index [1498] + 0.00 0.00 2594/1009028 msg_release [1373] +----------------------------------------------- + 0.01 0.00 34486/34486 teach_cmd [272] +[504] 0.0 0.01 0.00 34486 effskill_study [504] + 0.00 0.00 34169/12320804 get_modifier [55] + 0.00 0.00 34486/595705 unit_skill [1391] +----------------------------------------------- + 0.00 0.01 1/1 tolua_spawn_braineaters [506] +[505] 0.0 0.00 0.01 1 spawn_braineaters [505] + 0.00 0.01 639/2889 create_unit [296] + 0.00 0.00 178254/987488 is_astral [479] + 0.00 0.00 639/2375 equip_unit [775] + 0.00 0.00 1918/7641081 genrand_int31 [171] + 0.00 0.00 639/71815034 get_race [12] + 0.00 0.00 1/3902878 get_monsters [293] + 0.00 0.00 639/2742 get_equipment [1551] +----------------------------------------------- + +[506] 0.0 0.00 0.01 tolua_spawn_braineaters [506] + 0.00 0.01 1/1 spawn_braineaters [505] +----------------------------------------------- + 0.00 0.01 2081/2081 report_plaintext [4] +[507] 0.0 0.00 0.01 2081 nr_spell [507] + 0.01 0.00 19851/2742237 paragraph [26] + 0.00 0.00 30518/24887945 locale_string [27] + 0.00 0.00 2081/2081 nr_spell_syntax [732] + 0.00 0.00 2081/86400 spell_name [646] + 0.00 0.00 2081/4162 spell_info [841] + 0.00 0.00 6243/34611296 strlcpy [45] + 0.00 0.00 9352/9352 write_spell_modifier [964] + 0.00 0.00 12000/36653945 wrptr [178] + 0.00 0.00 2081/37931 centre [789] + 0.00 0.00 6243/2494242 newline [594] + 0.00 0.00 3203/13259934 resourcename [233] +----------------------------------------------- + 0.00 0.00 1/143730 destroy_road [1230] + 0.00 0.00 60/143730 build_road [950] + 0.00 0.00 46655/143730 roadto [606] + 0.00 0.01 97014/143730 cr_borders [135] +[508] 0.0 0.00 0.01 143730 rroad [508] + 0.00 0.01 143730/2225796 get_borders [120] + 0.00 0.00 1/369586 r_connect [474] +----------------------------------------------- + 0.00 0.00 27/47562 reduce_skill [1091] + 0.00 0.01 47535/47562 sk_set [510] +[509] 0.0 0.00 0.01 47562 skill_weeks [509] + 0.00 0.01 889716/7641081 genrand_int31 [171] + 0.00 0.00 47562/47562 rule_random_progress [829] +----------------------------------------------- + 0.00 0.00 2445/47535 set_level [774] + 0.00 0.01 45090/47535 learn_skill [471] +[510] 0.0 0.00 0.01 47535 sk_set [510] + 0.00 0.01 47535/47562 skill_weeks [509] +----------------------------------------------- + 0.00 0.00 232/629123 writefaction [762] + 0.00 0.00 32670/629123 writeregion [519] + 0.01 0.00 596221/629123 write_unit [97] +[511] 0.0 0.01 0.00 629123 write_items [511] + 0.00 0.00 448410/13259934 resourcename [233] +----------------------------------------------- + 0.00 0.01 112140/112140 buildingtype [414] +[512] 0.0 0.00 0.01 112140 castle_name [512] + 0.00 0.01 112140/112140 castle_name_i [513] +----------------------------------------------- + 0.00 0.01 112140/112140 castle_name [512] +[513] 0.0 0.00 0.01 112140 castle_name_i [513] + 0.01 0.00 112140/297010 bt_effsize [343] +----------------------------------------------- + 0.01 0.00 1/1 randomevents [91] +[514] 0.0 0.01 0.00 1 chaos_update [514] + 0.00 0.00 178254/179235 get_chaoscount [717] + 0.00 0.00 18025/7641081 genrand_int31 [171] + 0.00 0.00 3597/3597 chaos [848] + 0.00 0.00 18025/18059 add_chaoscount [1198] +----------------------------------------------- + 0.01 0.00 178254/178254 process [7] +[515] 0.0 0.01 0.00 178254 do_siege [515] + 0.00 0.00 204065/55492327 getkeyword [54] +----------------------------------------------- + 0.00 0.01 27694/27694 set_new_dragon_target [486] +[516] 0.0 0.00 0.01 27694 dragon_affinity_value [516] + 0.01 0.00 27694/27694 all_money [529] + 0.00 0.00 27694/71815034 get_race [12] + 0.00 0.00 27694/27694 dice [787] + 0.00 0.00 27694/129167539 u_race [89] +----------------------------------------------- + 0.01 0.00 116804/116804 parse_symbol [42] +[517] 0.0 0.01 0.00 116804 eval_isnull [517] + 0.00 0.00 116804/13102790 opstack_pop [176] + 0.00 0.00 116804/13102790 opstack_push [202] +----------------------------------------------- + 0.00 0.01 57367/57367 write_travelthru [327] +[518] 0.0 0.00 0.01 57367 count_travelthru [518] + 0.00 0.01 57367/3398582 travelthru_map [41] +----------------------------------------------- + 0.00 0.01 178254/178254 write_game [83] +[519] 0.0 0.00 0.01 178254 writeregion [519] + 0.00 0.01 178254/839970 write_attribs [301] + 0.00 0.00 249352/13259934 resourcename [233] + 0.00 0.00 196020/10053919 rtrees [302] + 0.00 0.00 32670/629123 write_items [511] + 0.00 0.00 32670/2605004 rpeasants [435] + 0.00 0.00 32670/4666665 rmoney [452] + 0.00 0.00 178254/178254 region_getinfo [1424] + 0.00 0.00 32670/1160345 rhorses [1369] + 0.00 0.00 32670/3166898 rherbs [1351] + 0.00 0.00 32670/65345 region_get_morale [1444] + 0.00 0.00 32670/32670 write_owner [1480] +----------------------------------------------- + 65155 skillmod [214] +[520] 0.0 0.01 0.00 65155 sm_familiar [520] + 0.00 0.00 26823/298951 distance [599] + 0.00 0.00 54349/54351 get_familiar [796] + 54349 effskill [100] +----------------------------------------------- + 0.01 0.00 2481220/2481220 msg_create [228] +[521] 0.0 0.01 0.00 2481220 copy_arg [521] + 0.00 0.00 41255/41255 var_copy_order [734] + 0.00 0.00 54163/54163 var_copy_string [1454] + 0.00 0.00 214/214 var_copy_items [1627] + 0.00 0.00 206/206 var_copy_resources [1632] +----------------------------------------------- + 0.00 0.01 249/249 plan_dragon [273] +[522] 0.0 0.00 0.01 249 make_movement_order [522] + 0.00 0.01 136/136 path_find [523] + 0.00 0.00 527/24887945 locale_string [27] + 0.00 0.00 136/1481407 parse_order [117] + 0.00 0.00 391/263302 reldirection [528] + 0.00 0.00 527/34611296 strlcpy [45] + 0.00 0.00 249/1121103 monster_is_waiting [407] + 0.00 0.00 527/36653945 wrptr [178] + 0.00 0.00 136/2009097 keyword [1355] +----------------------------------------------- + 0.00 0.01 136/136 make_movement_order [522] +[523] 0.0 0.00 0.01 136 path_find [523] + 0.01 0.00 136/388 internal_path_find [345] +----------------------------------------------- + 0.00 0.01 39836/39836 a_read_i [390] +[524] 0.0 0.00 0.01 39836 read_of [524] + 0.01 0.00 39836/40046 rule_stealth_other [530] + 0.00 0.00 39836/4625636 findfaction [259] +----------------------------------------------- + 0.00 0.01 206/206 do_battle [64] +[525] 0.0 0.00 0.01 206 print_stats [525] + 0.00 0.01 552/552 print_fighters [616] + 0.00 0.00 5420/12398 fbattlerecord [688] + 0.00 0.00 11178/18788 sideabkz [745] + 0.00 0.00 8758/24887945 locale_string [27] + 0.00 0.00 2317/967784 msg_message [132] + 0.00 0.00 4336/31214 message_faction [716] + 0.00 0.00 2082/3111 sidename [867] + 0.00 0.00 355/1486 message_all [834] + 0.00 0.00 11693/5461936 slprintf [548] + 0.00 0.00 13861/24449 seematrix [1491] + 0.00 0.00 13861/22301 army_index [1498] + 0.00 0.00 2317/1009028 msg_release [1373] + 0.00 0.00 149/2854 is_attacker [1550] +----------------------------------------------- + 0.00 0.00 2/14326 create_ship [1014] + 0.00 0.00 490/14326 build_building [696] + 0.00 0.00 5384/14326 teach_cmd [272] + 0.01 0.00 8450/14326 cycle_route [375] +[526] 0.0 0.01 0.00 14326 replace_order [526] + 0.00 0.00 14326/635885 copy_order [441] + 0.00 0.00 14326/1936876 free_order [1356] +----------------------------------------------- + 0.01 0.00 1302/1302 teach_unit [426] +[527] 0.0 0.01 0.00 1302 academy_can_teach [527] + 0.00 0.00 404/541982 get_pooled [104] + 0.00 0.00 1302/560926 bt_find [237] + 0.00 0.00 1709/424669 active_building [560] + 0.00 0.00 404/418134 study_cost [433] + 0.00 0.00 404/56052475 get_resourcetype [194] +----------------------------------------------- + 0.00 0.00 391/263302 make_movement_order [522] + 0.00 0.00 4307/263302 set_coast [875] + 0.00 0.00 4337/263302 can_takeoff [854] + 0.00 0.00 39729/263302 leave_trail [704] + 0.00 0.00 106203/263302 travel_route [147] + 0.00 0.00 108335/263302 cap_route [502] +[528] 0.0 0.00 0.01 263302 reldirection [528] + 0.01 0.00 263302/263302 koor_reldirection [562] + 0.00 0.00 526604/18647447 getplane [596] +----------------------------------------------- + 0.01 0.00 27694/27694 dragon_affinity_value [516] +[529] 0.0 0.01 0.00 27694 all_money [529] + 0.00 0.00 11448/7120688 get_money [187] + 0.00 0.00 27694/4666665 rmoney [452] +----------------------------------------------- + 0.00 0.00 1/40046 destroyfaction [392] + 0.00 0.00 209/40046 setstealth_cmd [182] + 0.01 0.00 39836/40046 read_of [524] +[530] 0.0 0.01 0.00 40046 rule_stealth_other [530] + 0.00 0.00 40046/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.01 1/1 write_game [83] +[531] 0.0 0.00 0.01 1 clear_npc_orders [531] + 0.01 0.00 420178/1644867 free_orders [306] +----------------------------------------------- + 0.00 0.00 10897/25088 terminate [242] + 0.00 0.01 14191/25088 flee [638] +[532] 0.0 0.00 0.01 25088 kill_troop [532] + 0.01 0.00 25088/25088 rmtroop [533] + 0.00 0.00 176/176 default_spoil [1144] + 0.00 0.00 990/129167539 u_race [89] + 0.00 0.00 12/60 equip_items [1121] + 0.00 0.00 319/2742 get_equipment [1551] + 0.00 0.00 9/97 i_merge [1651] +----------------------------------------------- + 0.01 0.00 25088/25088 kill_troop [532] +[533] 0.0 0.01 0.00 25088 rmtroop [533] + 0.00 0.00 25088/25088 rmfighter [890] +----------------------------------------------- + 0.01 0.00 1/1 icebergs [285] +[534] 0.0 0.01 0.00 1 move_icebergs [534] + 0.00 0.00 9/9 melt_iceberg [1082] + 0.00 0.00 20/27 move_iceberg [1094] + 0.00 0.00 29/7641081 genrand_int31 [171] + 0.00 0.00 178254/1511812 newterrain [1359] +----------------------------------------------- + 0.01 0.00 1297/1297 make_fighter [424] +[535] 0.0 0.01 0.00 1297 AllianceAuto [535] + 0.00 0.00 1297/10383360 HelpMask [288] + 0.00 0.00 1297/20777534 config_get [224] +----------------------------------------------- + 0.00 0.00 32/1629412 travel_i [92] + 0.00 0.00 37/1629412 transport [1011] + 0.00 0.00 74/1629412 init_transportation [384] + 0.00 0.00 222/1629412 cast_cmd [760] + 0.00 0.00 475/1629412 move_hunters [342] + 0.00 0.00 1518/1629412 start_battle [297] + 0.00 0.00 435900/1629412 process [7] + 0.00 0.00 595258/1629412 follow_unit [331] + 0.00 0.00 595896/1629412 update_long_order [270] +[536] 0.0 0.01 0.00 1629412 LongHunger [536] + 0.00 0.00 138/71815034 get_race [12] + 0.00 0.00 111/4984610 config_get_int [348] + 0.00 0.00 138/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 48/32727 terraform_region [932] + 0.01 0.00 32679/32727 readregion [209] +[537] 0.0 0.01 0.00 32727 rsetherbtype [537] + 0.00 0.00 50/361 regionname [987] + 0.00 0.00 50/49235 log_debug [1245] +----------------------------------------------- + 0.01 0.00 1/1 icebergs [285] +[538] 0.0 0.01 0.00 1 create_icebergs [538] + 0.00 0.00 126/752645 chance [495] + 0.00 0.00 7/27 move_iceberg [1094] + 0.00 0.00 2/967784 msg_message [132] + 0.00 0.00 2/392959 add_message [434] + 0.00 0.00 178261/1511812 newterrain [1359] + 0.00 0.00 2/1009028 msg_release [1373] +----------------------------------------------- + 0.01 0.00 163/163 parse_symbol [42] +[539] 0.0 0.01 0.00 163 eval_lt [539] + 0.00 0.00 326/13102790 opstack_pop [176] + 0.00 0.00 163/13102790 opstack_push [202] +----------------------------------------------- + 0.00 0.01 224/224 leave [432] +[540] 0.0 0.00 0.01 224 leave_ship [540] + 0.01 0.00 18/18 ship_update_owner [573] + 0.00 0.00 224/234 set_leftship [1134] + 0.00 0.00 18/3358315 ship_owner [438] +----------------------------------------------- + +[541] 0.0 0.00 0.01 main [541] + 0.00 0.01 1/1 game_done [542] + 0.00 0.00 1/1 game_init [1249] + 0.00 0.00 1/1 parse_config [1292] + 0.00 0.00 1/1 lua_init [1316] + 0.00 0.00 1/1 eressea_run [1346] + 0.00 0.00 1/1 setup_signal_handler [1863] + 0.00 0.00 1/1 locale_init [1815] + 0.00 0.00 1/1 parse_args [1825] + 0.00 0.00 1/1 bind_monsters [1793] + 0.00 0.00 1/1 log_close [1816] + 0.00 0.00 1/1 lua_done [1820] +----------------------------------------------- + 0.00 0.01 1/1 main [541] +[542] 0.0 0.00 0.01 1 game_done [542] + 0.00 0.01 1/1 free_config [574] + 0.00 0.00 1/1 free_locales [1311] + 0.00 0.00 1/1 free_functions [1804] + 0.00 0.00 1/1 calendar_cleanup [1796] + 0.00 0.00 1/1 kernel_done [1813] +----------------------------------------------- + 0.00 0.00 1/4201030 sp_generous [1040] + 0.00 0.00 2/4201030 sp_enterastral [1045] + 0.00 0.00 2/4201030 shipcurse_flyingship [1072] + 0.00 0.00 3/4201030 skilldiff [166] + 0.00 0.00 6/4201030 forget_cmd [1093] + 0.00 0.00 9/4201030 is_freezing [1088] + 0.00 0.00 10/4201030 sp_stormwinds [871] + 0.00 0.00 17/4201030 produce [29] + 0.00 0.00 17/4201030 process [7] + 0.00 0.00 17/4201030 magic [157] + 0.00 0.00 22/4201030 drifting_ships [490] + 0.00 0.00 34/4201030 sp_viewreality [784] + 0.00 0.00 349/4201030 can_give_men [940] + 0.00 0.00 450/4201030 spellpower [1000] + 0.00 0.00 452/4201030 fumble [973] + 0.00 0.00 488/4201030 give_men [857] + 0.00 0.00 1624/4201030 shipspeed [669] + 0.00 0.00 1689/4201030 recruit [650] + 0.00 0.00 2815/4201030 count_faction [219] + 0.00 0.00 2974/4201030 start_battle [297] + 0.00 0.00 4309/4201030 report_template [87] + 0.00 0.00 5948/4201030 deathcounts [843] + 0.00 0.00 8515/4201030 describe [35] + 0.00 0.00 16560/4201030 entertain_cmd [665] + 0.00 0.00 19730/4201030 can_survive [640] + 0.00 0.00 29173/4201030 horses [330] + 0.00 0.00 32649/4201030 growing_trees [624] + 0.00 0.00 37300/4201030 cr_output_region [10] + 0.00 0.00 39858/4201030 sail [181] + 0.00 0.00 46175/4201030 maintain_buildings [339] + 0.00 0.00 90436/4201030 spawn_undead [629] + 0.00 0.00 91155/4201030 godcurse [405] + 0.00 0.00 94865/4201030 ageing [185] + 0.00 0.00 159544/4201030 entertainmoney [643] + 0.00 0.00 169917/4201030 study_cmd [105] + 0.00 0.00 282968/4201030 move_blocked [283] + 0.00 0.00 601859/4201030 att_modification [90] + 0.00 0.00 615666/4201030 default_wage [173] + 0.00 0.00 669051/4201030 production [417] + 0.00 0.00 1174371/4201030 terrain_name [226] +[543] 0.0 0.01 0.00 4201030 curse_active [543] +----------------------------------------------- + 0.00 0.00 191/1311302 follow_ship [749] + 0.00 0.00 283446/1311302 readorders [43] + 0.01 0.00 1027665/1311302 init_order [613] +[544] 0.0 0.01 0.00 1311302 init_tokens_str [544] +----------------------------------------------- + 0.00 0.00 9/264251 destroyfaction [392] + 0.00 0.00 15/264251 res_changepeasants [1200] + 0.00 0.00 19/264251 dissolve_units [241] + 0.00 0.00 34/264251 battle_effects [1125] + 0.00 0.00 57/264251 terraform_region [932] + 0.00 0.00 71/264251 transfermen [899] + 0.00 0.00 120/264251 plagues [781] + 0.00 0.00 567/264251 eaten_by_monster [468] + 0.00 0.00 681/264251 absorbed_by_monster [804] + 0.00 0.00 1594/264251 expandrecruit [349] + 0.00 0.00 3152/264251 scareaway [768] + 0.00 0.00 14329/264251 immigration [294] + 0.00 0.00 32670/264251 peasants [658] + 0.00 0.00 32679/264251 readregion [209] + 0.01 0.00 178254/264251 get_food [88] +[545] 0.0 0.01 0.00 264251 rsetpeasants [545] +----------------------------------------------- + 0.00 0.00 1301/9298667 leveled_allocation [888] + 0.00 0.00 2723/9298667 split_allocations [743] + 0.00 0.00 3078/9298667 allocate_resource [752] + 0.00 0.00 59445/9298667 report_resources [210] + 0.01 0.00 9232120/9298667 res_changeitem [101] +[546] 0.0 0.01 0.00 9298667 resource2item [546] +----------------------------------------------- + 0.00 0.00 2/8506411 create_ship [1014] + 0.00 0.00 41/8506411 build_road [950] + 0.00 0.00 42/8506411 loot_cmd [873] + 0.00 0.00 79/8506411 can_guard [908] + 0.00 0.00 498/8506411 join_allies [693] + 0.00 0.00 598/8506411 build_building [696] + 0.00 0.00 960/8506411 tax_cmd [697] + 0.00 0.00 2943/8506411 allocate_resource [752] + 0.00 0.00 5915/8506411 buy [707] + 0.00 0.00 11003/8506411 do_work [612] + 0.00 0.00 15763/8506411 sell [498] + 0.00 0.00 16593/8506411 entertain_cmd [665] + 0.01 0.00 8451974/8506411 is_guardian_r [186] +[547] 0.0 0.01 0.00 8506411 besieged [547] + 0.00 0.00 8506411/11194781 keyword_disabled [1348] +----------------------------------------------- + 0.00 0.00 2/5461936 new_ship [1229] + 0.00 0.00 11/5461936 new_building [1059] + 0.00 0.00 47/5461936 give_peasants [1060] + 0.00 0.00 191/5461936 follow_ship [749] + 0.00 0.00 211/5461936 display_race [963] + 0.00 0.00 1572/5461936 write_score [1135] + 0.00 0.00 2705/5461936 b_nameroad [642] + 0.00 0.00 7336/5461936 battle_report [503] + 0.00 0.00 11693/5461936 print_stats [525] + 0.00 0.00 180818/5461936 write_buildingname [622] + 0.00 0.00 513251/5461936 write_regionname [280] + 0.00 0.00 1065211/5461936 write_shipname [291] + 0.00 0.00 1295787/5461936 factionname [247] + 0.00 0.00 2383101/5461936 write_unitname [148] +[548] 0.0 0.01 0.00 5461936 slprintf [548] +----------------------------------------------- + 0.01 0.00 4976082/4976082 parse_symbol [42] +[549] 0.0 0.01 0.00 4976082 find_function [549] +----------------------------------------------- + 0.00 0.00 60/4301501 aftermath [701] + 0.00 0.00 1729/4301501 make_fighter [424] + 0.00 0.00 5188/4301501 print_fighters [616] + 0.00 0.00 25088/4301501 rmfighter [890] + 0.00 0.00 324731/4301501 count_side [666] + 0.00 0.00 876979/4301501 count_enemies [611] + 0.00 0.00 1405349/4301501 select_enemy [172] + 0.00 0.00 1662377/4301501 get_unitrow [154] +[550] 0.0 0.01 0.00 4301501 statusrow [550] +----------------------------------------------- + 0.00 0.00 114/3383689 u_setfaction [1111] + 0.00 0.00 109781/3383689 move_unit [421] + 0.00 0.00 595125/3383689 read_game [62] + 0.00 0.00 1188131/3383689 travelthru_add [609] + 0.00 0.00 1490538/3383689 add_seen_nb [386] +[551] 0.0 0.01 0.00 3383689 update_interval [551] +----------------------------------------------- + 0.00 0.00 12208/2985733 report_template [87] + 0.00 0.00 68016/2985733 write_unit [97] + 0.00 0.00 68497/2985733 cr_output_unit [19] + 0.00 0.00 451283/2985733 update_long_order [270] + 0.00 0.00 573389/2985733 unitorders [46] + 0.00 0.00 766833/2985733 is_persistent [687] + 0.00 0.00 1045507/2985733 bufunit [17] +[552] 0.0 0.01 0.00 2985733 is_repeated [552] +----------------------------------------------- + 0.00 0.00 9/2186159 destroyfaction [392] + 0.00 0.00 17/2186159 give_money [484] + 0.00 0.00 36/2186159 expandloot [816] + 0.00 0.00 38/2186159 gift_items [891] + 0.00 0.00 41/2186159 region_setresource [1097] + 0.00 0.00 57/2186159 terraform_region [932] + 0.00 0.00 6459/2186159 plagues [781] + 0.00 0.00 16560/2186159 expandentertainment [637] + 0.00 0.00 32670/2186159 peasants [658] + 0.00 0.00 32679/2186159 readregion [209] + 0.00 0.00 178254/2186159 expandwork [277] + 0.00 0.00 394406/2186159 expandbuying [49] + 0.01 0.00 1524933/2186159 expandtax [278] +[553] 0.0 0.01 0.00 2186159 rsetmoney [553] +----------------------------------------------- + 0.00 0.00 10232/1106528 update_lighthouse [605] + 0.00 0.00 15060/1106528 buildingtype [414] + 0.00 0.00 24025/1106528 check_leuchtturm [786] + 0.00 0.00 46184/1106528 age_building [712] + 0.00 0.00 218422/1106528 report_building [397] + 0.00 0.00 396300/1106528 default_wage [173] + 0.00 0.00 396305/1106528 cmp_wage [670] +[554] 0.0 0.01 0.00 1106528 is_building_type [554] +----------------------------------------------- + 0.00 0.00 1/779419 create_mage [1315] + 0.00 0.00 1/779419 init_seed [1320] + 0.00 0.00 1/779419 init_mallornseed [1319] + 0.00 0.00 1/779419 a_upgradekeys [1314] + 0.00 0.00 1/779419 xml_readconstruction [1183] + 0.00 0.00 2/779419 set_factionstealth [183] + 0.00 0.00 2/779419 make_wormhole [1150] + 0.00 0.00 2/779419 summon_allies [925] + 0.00 0.00 2/779419 init_smithy [1312] + 0.00 0.00 3/779419 create_newfamiliar [1288] + 0.00 0.00 3/779419 usetprivate [1041] + 0.00 0.00 6/779419 add_chaoscount [1198] + 0.00 0.00 7/779419 parse_resources [1086] + 0.00 0.00 7/779419 add_trigger [1260] + 0.00 0.00 12/779419 volcano_destruction [1022] + 0.00 0.00 13/779419 move_iceberg [1094] + 0.00 0.00 20/779419 init_transportation [384] + 0.00 0.00 25/779419 set_new_dragon_target [486] + 0.00 0.00 32/779419 growing_trees [624] + 0.00 0.00 32/779419 make_curse [802] + 0.00 0.00 35/779419 deathcounts [843] + 0.00 0.00 55/779419 renumber_unit [1159] + 0.00 0.00 58/779419 potion_luck [1176] + 0.00 0.00 97/779419 piracy_cmd [660] + 0.00 0.00 114/779419 usetcontact [1147] + 0.00 0.00 159/779419 change_effect [982] + 0.00 0.00 234/779419 set_leftship [1134] + 0.00 0.00 328/779419 display_potion [1090] + 0.00 0.00 389/779419 usetpotionuse [1078] + 0.00 0.00 631/779419 set_group [1048] + 0.00 0.00 754/779419 new_units [282] + 0.00 0.00 760/779419 set_familiar [992] + 0.00 0.00 894/779419 follow_unit [331] + 0.00 0.00 2494/779419 create_unit [296] + 0.00 0.00 2503/779419 sell [498] + 0.00 0.00 3233/779419 leave_trail [704] + 0.00 0.00 3642/779419 buy [707] + 0.00 0.00 4162/779419 show_new_spells [889] + 0.00 0.00 4738/779419 expandselling [93] + 0.00 0.00 5679/779419 expandbuying [49] + 0.00 0.00 11749/779419 teach_unit [426] + 0.00 0.00 27216/779419 travelthru_add [609] + 0.00 0.00 52117/779419 update_lighthouse [605] + 0.00 0.00 251365/779419 a_read_i [390] + 0.00 0.01 405840/779419 study_cmd [105] +[555] 0.0 0.00 0.01 779419 a_add [555] + 0.01 0.00 54530/54530 a_insert [566] +----------------------------------------------- + 0.00 0.00 7964/618305 report_crtypes [428] + 0.01 0.00 610341/618305 stream_order [167] +[556] 0.0 0.01 0.00 618305 escape_string [556] +----------------------------------------------- + 0.00 0.00 1/604861 clonedied_write [1321] + 0.00 0.00 2/604861 giveitem_write [1309] + 0.00 0.00 6/604861 changerace_write [1287] + 0.00 0.00 12/604861 changefaction_write [1258] + 0.00 0.00 769/604861 shock_write [1050] + 0.00 0.00 1522/604861 a_write_unit [998] + 0.00 0.00 2304/604861 killunit_write [978] + 0.00 0.00 4024/604861 curse_write [930] + 0.01 0.00 596221/604861 write_unit [97] +[557] 0.0 0.01 0.00 604861 write_unit_reference [557] +----------------------------------------------- + 0.00 0.00 449/454395 a_read_i [390] + 0.00 0.00 2172/454395 a_removeall [958] + 0.01 0.00 451774/454395 a_remove [366] +[558] 0.0 0.01 0.00 454395 a_free [558] + 0.00 0.00 417577/417577 done_learning [1397] + 0.00 0.00 23342/23342 shiptrail_finalize [1492] + 0.00 0.00 10417/10417 free_luxuries [1516] + 0.00 0.00 554/554 a_finalizeeffect [1597] + 0.00 0.00 97/97 piracy_done [1653] + 0.00 0.00 28/28 curse_done [1696] + 0.00 0.00 1/1 a_finalizestring [1786] +----------------------------------------------- + 0.01 0.00 451774/451774 a_remove [366] +[559] 0.0 0.01 0.00 451774 a_unlink [559] +----------------------------------------------- + 0.00 0.00 174/424669 breedhorses [742] + 0.00 0.00 1709/424669 academy_can_teach [527] + 0.00 0.00 5206/424669 monthly_healing [215] + 0.01 0.00 417580/424669 study_cmd [105] +[560] 0.0 0.01 0.00 424669 active_building [560] + 0.00 0.00 6798/26164 building_is_active [1488] + 0.00 0.00 6405/26995 inside_building [1486] +----------------------------------------------- + 0.00 0.00 5/283711 give_horses [1108] + 0.00 0.00 19/283711 reshow_other [823] + 0.00 0.00 22/283711 give_money [484] + 0.01 0.00 283665/283711 give_item [126] +[561] 0.0 0.01 0.00 283711 item2resource [561] +----------------------------------------------- + 0.01 0.00 263302/263302 reldirection [528] +[562] 0.0 0.01 0.00 263302 koor_reldirection [562] + 0.00 0.00 932009/3587241 pnormalize [1350] +----------------------------------------------- + 0.01 0.00 251814/251814 a_read_i [390] +[563] 0.0 0.01 0.00 251814 at_find [563] +----------------------------------------------- + 0.00 0.00 30233/162862 regions_in_range [675] + 0.01 0.00 132629/162862 internal_path_find [345] +[564] 0.0 0.01 0.00 162862 allowed_dragon [564] + 0.00 0.00 157782/157830 allowed_fly [1425] +----------------------------------------------- + 0.00 0.00 1/113845 removelist [1290] + 0.01 0.00 113844/113845 translist [430] +[565] 0.0 0.01 0.00 113845 choplist [565] +----------------------------------------------- + 0.01 0.00 54530/54530 a_add [555] +[566] 0.0 0.01 0.00 54530 a_insert [566] +----------------------------------------------- + 0.00 0.00 10344/47887 cansail [469] + 0.00 0.00 18693/47887 nr_ship [111] + 0.00 0.00 18850/47887 cr_output_ship [152] +[567] 0.0 0.01 0.00 47887 shipcapacity [567] +----------------------------------------------- + 0.00 0.00 1/11719 tolua_faction_get_locale [1197] + 0.00 0.00 2/11719 config_get_locales [1161] + 0.00 0.00 2/11719 report_summary [614] + 0.00 0.00 232/11719 write_script [853] + 0.00 0.00 232/11719 writefaction [762] + 0.00 0.00 460/11719 report_computer [9] + 0.01 0.00 10790/11719 cr_find_address [602] +[568] 0.0 0.01 0.00 11719 locale_name [568] +----------------------------------------------- + 0.00 0.00 863/3147 make_fighter [424] + 0.01 0.00 2284/3147 weapon_skill [221] +[569] 0.0 0.01 0.00 3147 i_canuse [569] + 0.00 0.00 785/785 lua_canuse_item [1591] +----------------------------------------------- + 0.01 0.00 1018/1018 remove_exclusive [571] +[570] 0.0 0.01 0.00 1018 is_exclusive [570] +----------------------------------------------- + 0.00 0.01 524/524 defaultorders [249] +[571] 0.0 0.00 0.01 524 remove_exclusive [571] + 0.01 0.00 1018/1018 is_exclusive [570] + 0.00 0.00 310/1936876 free_order [1356] +----------------------------------------------- + 0.00 0.00 1/457 promotion_cmd [917] + 0.00 0.00 226/457 report_plaintext [4] + 0.01 0.00 230/457 report_computer [9] +[572] 0.0 0.01 0.00 457 countheroes [572] +----------------------------------------------- + 0.01 0.00 18/18 leave_ship [540] +[573] 0.0 0.01 0.00 18 ship_update_owner [573] + 0.00 0.00 18/1529 ship_owner_ex [1571] +----------------------------------------------- + 0.00 0.01 1/1 game_done [542] +[574] 0.0 0.00 0.01 1 free_config [574] + 0.01 0.00 1/1 free_params [575] +----------------------------------------------- + 0.01 0.00 1/1 free_config [574] +[575] 0.0 0.01 0.00 1 free_params [575] +----------------------------------------------- + 0.01 0.00 1/1 eressea_write_game [76] +[576] 0.0 0.01 0.00 1 remove_empty_factions [576] +----------------------------------------------- + +[577] 0.0 0.01 0.00 cb_insert [577] +----------------------------------------------- + +[578] 0.0 0.01 0.00 cmp_curse [578] +----------------------------------------------- + +[579] 0.0 0.01 0.00 create_backup [579] +----------------------------------------------- + +[580] 0.0 0.01 0.00 ct_remove [580] +----------------------------------------------- + +[581] 0.0 0.01 0.00 get_homeplane [581] +----------------------------------------------- + +[582] 0.0 0.01 0.00 i10toi36 [582] +----------------------------------------------- + +[583] 0.0 0.01 0.00 json_export [583] +----------------------------------------------- + +[584] 0.0 0.01 0.00 make_external_node [584] +----------------------------------------------- + +[585] 0.0 0.01 0.00 qli_next [585] +----------------------------------------------- + +[586] 0.0 0.01 0.00 read_movement [586] +----------------------------------------------- + +[587] 0.0 0.01 0.00 remove_plane [587] +----------------------------------------------- + +[588] 0.0 0.01 0.00 set_string [588] +----------------------------------------------- + +[589] 0.0 0.01 0.00 tolua_buildinglist_next [589] +----------------------------------------------- + +[590] 0.0 0.01 0.00 tolua_regionlist_next [590] +----------------------------------------------- + +[591] 0.0 0.01 0.00 tolua_tousertype [591] +----------------------------------------------- + 0.00 0.00 490896/5152236 default_wage [173] + 0.00 0.00 1366398/5152236 unit_max_hp [136] + 0.01 0.00 3294942/5152236 att_modification [90] +[592] 0.0 0.01 0.00 5152236 ct_changed [592] +----------------------------------------------- + 0.00 0.00 11880/4835422 cansee_unit [684] + 0.00 0.00 923633/4835422 cr_output_unit [19] + 0.00 0.00 1156253/4835422 cansee [22] + 0.00 0.00 1348743/4835422 bufunit [17] + 0.00 0.00 1394913/4835422 cansee_durchgezogen [170] +[593] 0.0 0.01 0.00 4835422 usiege [593] +----------------------------------------------- + 0.00 0.00 458/2494242 list_address [635] + 0.00 0.00 1632/2494242 rp_battles [618] + 0.00 0.00 1888/2494242 allies [419] + 0.00 0.00 6243/2494242 nr_spell [507] + 0.00 0.00 15186/2494242 nr_curses_i [401] + 0.00 0.00 27498/2494242 guards [229] + 0.00 0.00 62736/2494242 rp_messages [36] + 0.00 0.00 66278/2494242 statistics [70] + 0.00 0.00 113592/2494242 nr_building [141] + 0.00 0.00 164218/2494242 describe [35] + 0.00 0.00 180598/2494242 nr_ship [111] + 0.00 0.00 216458/2494242 report_template [87] + 0.00 0.00 293098/2494242 report_plaintext [4] + 0.01 0.00 1344359/2494242 nr_unit [11] +[594] 0.0 0.01 0.00 2494242 newline [594] +----------------------------------------------- + 0.01 0.00 987612/987612 get_astralplane [482] +[595] 0.0 0.01 0.00 987612 getplanebyname [595] +----------------------------------------------- + 0.00 0.00 3/18647447 getplaneid [1337] + 0.00 0.00 40/18647447 expandstealing [807] + 0.00 0.00 111/18647447 check_steal [1234] + 0.00 0.00 206/18647447 make_battle [1282] + 0.00 0.00 227/18647447 cast_cmd [760] + 0.00 0.00 493/18647447 report_computer [9] + 0.00 0.00 719/18647447 join_allies [693] + 0.00 0.00 976/18647447 make_cmd [383] + 0.00 0.00 1518/18647447 start_battle [297] + 0.00 0.00 1689/18647447 recruit [650] + 0.00 0.00 5384/18647447 teach_cmd [272] + 0.00 0.00 7957/18647447 magic_resistance [727] + 0.00 0.00 8865/18647447 r_astral_to_standard [783] + 0.00 0.00 9641/18647447 cr_regions [840] + 0.00 0.00 10477/18647447 report_template [87] + 0.00 0.00 102739/18647447 give_cmd [102] + 0.00 0.00 108425/18647447 update_lighthouse [605] + 0.00 0.00 132705/18647447 cr_region [662] + 0.00 0.00 163381/18647447 astralregions [329] + 0.00 0.00 174658/18647447 good_region [910] + 0.00 0.00 178254/18647447 get_food [88] + 0.00 0.00 211668/18647447 cr_output_region [10] + 0.00 0.00 369586/18647447 r_connect [474] + 0.00 0.00 513251/18647447 write_regionname [280] + 0.00 0.00 526604/18647447 reldirection [528] + 0.00 0.00 950595/18647447 f_regionid [161] + 0.00 0.00 987488/18647447 is_astral [479] + 0.00 0.00 1187497/18647447 bufunit [17] + 0.00 0.00 1467202/18647447 get_modifier [55] + 0.00 0.00 2521048/18647447 lifestyle [286] + 0.00 0.00 9004040/18647447 alliedunit [31] +[596] 0.0 0.01 0.00 18647447 getplane [596] +----------------------------------------------- + 0.00 0.00 1/2032164 do_fumble [1062] + 0.00 0.00 1/2032164 init_seed [1320] + 0.00 0.00 1/2032164 init_mallornseed [1319] + 0.00 0.00 17/2032164 parse_buildings [1131] + 0.00 0.00 51/2032164 potion_water_of_life [945] + 0.00 0.00 80/2032164 msg_set_resource [1226] + 0.00 0.00 225/2032164 spellpower [1000] + 0.00 0.00 233/2032164 parse_spells [1120] + 0.00 0.00 545/2032164 rt_get_or_create [1139] + 0.00 0.00 1139/2032164 tolua_region_set_resource [1057] + 0.00 0.00 2148/2032164 get_food [88] + 0.00 0.00 2366/2032164 allocate_resource [752] + 0.00 0.00 2491/2032164 a_readeffect [1052] + 0.00 0.00 3355/2032164 tolua_region_get_resource [976] + 0.00 0.00 5358/2032164 max_spellpoints [755] + 0.00 0.00 83224/2032164 trollbelts [677] + 0.00 0.00 193274/2032164 walkingcapacity [403] + 0.00 0.00 249361/2032164 readregion [209] + 0.00 0.00 310783/2032164 get_resourcetype [194] + 0.01 0.00 1177511/2032164 it_find [385] +[597] 0.0 0.01 0.00 2032164 rt_find [597] +----------------------------------------------- + 0.00 0.01 755575/755575 travelthru_map [41] +[598] 0.0 0.00 0.01 755575 cb_add_address [598] + 0.00 0.01 74068/4374788 visible_faction [68] + 0.00 0.00 11880/11880 cansee_unit [684] + 0.00 0.00 3767/353788 add_seen_faction_i [1401] +----------------------------------------------- + 0.00 0.00 3/298951 cast_cmd [760] + 0.00 0.00 26823/298951 sm_familiar [520] + 0.00 0.00 71197/298951 update_lighthouse [605] + 0.00 0.01 200928/298951 get_regions_distance [372] +[599] 0.0 0.00 0.01 298951 distance [599] + 0.00 0.01 298951/514146 koor_distance [476] +----------------------------------------------- + 0.00 0.00 6/102705 give_control_cmd [287] + 0.00 0.01 102699/102705 give_cmd [102] +[600] 0.0 0.00 0.01 102705 can_give_to [600] + 0.00 0.01 102705/9953180 alliedunit [31] + 0.00 0.00 70/1437425 cansee [22] + 0.00 0.00 20/8898 ucontact [927] +----------------------------------------------- + 0.00 0.00 233/113487 reroute [1020] + 0.00 0.01 113254/113487 make_route [289] +[601] 0.0 0.00 0.01 113487 next_region [601] + 0.00 0.01 113487/2225796 get_borders [120] +----------------------------------------------- + 0.00 0.01 230/230 report_computer [9] +[602] 0.0 0.00 0.01 230 cr_find_address [602] + 0.01 0.00 10790/11719 locale_name [568] +----------------------------------------------- + 0.00 0.01 32670/32670 demographics [50] +[603] 0.0 0.00 0.01 32670 calculate_emigration [603] + 0.00 0.01 144763/438629 maxworkingpeasants [473] + 0.00 0.00 46456/369586 r_connect [474] + 0.00 0.00 144763/2605004 rpeasants [435] + 0.00 0.00 64838/1511812 newterrain [1359] +----------------------------------------------- + 0.00 0.01 116914/116914 fleechance [408] +[604] 0.0 0.00 0.01 116914 horse_fleeing_bonus [604] + 0.00 0.01 116914/12320804 effskill [100] + 0.00 0.00 350742/56052475 get_resourcetype [194] +----------------------------------------------- + 0.00 0.00 2/10232 remove_building [1153] + 0.00 0.00 11/10232 new_building [1059] + 0.00 0.00 490/10232 build_building [696] + 0.00 0.01 9729/10232 read_game [62] +[605] 0.0 0.00 0.01 10232 update_lighthouse [605] + 0.00 0.01 108425/459083 findregion [420] + 0.00 0.00 71197/298951 distance [599] + 0.00 0.00 52117/779419 a_add [555] + 0.00 0.00 52551/51974272 a_find [65] + 0.00 0.00 10232/1106528 is_building_type [554] + 0.00 0.00 108425/18647447 getplane [596] + 0.00 0.00 108425/3587241 pnormalize [1350] + 0.00 0.00 52117/779868 a_new [1376] +----------------------------------------------- + 0.00 0.01 108335/108335 cap_route [502] +[606] 0.0 0.00 0.01 108335 roadto [606] + 0.00 0.00 46655/143730 rroad [508] + 0.00 0.00 208736/10190660 get_curse [143] + 0.00 0.00 104368/12246335 ct_find [114] + 0.00 0.00 16737/16737 dir_invert [1508] +----------------------------------------------- + 0.00 0.01 3656767/3656767 translate [28] +[607] 0.0 0.00 0.01 3656767 add_variable [607] + 0.01 0.00 3656767/13399069 balloc [363] +----------------------------------------------- + 0.00 0.01 127788/127788 parse_symbol [42] +[608] 0.0 0.00 0.01 127788 eval_direction [608] + 0.00 0.00 127788/24887945 locale_string [27] + 0.00 0.00 127788/13102790 opstack_pop [176] + 0.00 0.00 127788/13102790 opstack_push [202] + 0.00 0.00 127788/13399069 balloc [363] +----------------------------------------------- + 0.00 0.01 169733/169733 mark_travelthru [610] +[609] 0.0 0.00 0.01 169733 travelthru_add [609] + 0.00 0.00 1188131/3383689 update_interval [551] + 0.00 0.00 169733/1087065 get_neighbours [480] + 0.00 0.00 169733/51974272 a_find [65] + 0.00 0.00 27216/779419 a_add [555] + 0.00 0.00 27216/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 10679/106919 move_ship [374] + 0.00 0.01 96240/106919 travel_route [147] +[610] 0.0 0.00 0.01 106919 mark_travelthru [610] + 0.00 0.01 169733/169733 travelthru_add [609] +----------------------------------------------- + 0.00 0.00 21/876979 sp_kampfzauber [957] + 0.00 0.00 53/876979 sp_dragonodem [627] + 0.00 0.00 112/876979 attack_firesword [785] + 0.00 0.00 251867/876979 do_attack [80] + 0.00 0.00 252753/876979 attack [84] + 0.00 0.00 372173/876979 select_enemy [172] +[611] 0.0 0.00 0.01 876979 count_enemies [611] + 0.00 0.01 300810/300810 count_enemies_i [636] + 0.00 0.00 876979/4301501 statusrow [550] +----------------------------------------------- + 0.00 0.01 11087/11087 produce [29] +[612] 0.0 0.00 0.01 11087 do_work [612] + 0.00 0.01 3141/15361 is_guarded [377] + 0.00 0.00 10979/490896 wage [174] + 0.00 0.00 22150/129167539 u_race [89] + 0.00 0.00 11003/8506411 besieged [547] + 0.00 0.00 84/41248 msg_feedback [647] + 0.00 0.00 84/392959 add_message [434] + 0.00 0.00 24/15102 cmistake [718] + 0.00 0.00 84/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 2/1027665 claim_cmd [1242] + 0.00 0.00 6/1027665 send_cmd [1202] + 0.00 0.00 12/1027665 forget_cmd [1093] + 0.00 0.00 16/1027665 spy_cmd [990] + 0.00 0.00 20/1027665 restack_units [353] + 0.00 0.00 22/1027665 destroy_cmd [1113] + 0.00 0.00 42/1027665 loot_cmd [873] + 0.00 0.00 65/1027665 travel_i [92] + 0.00 0.00 70/1027665 transport [1011] + 0.00 0.00 80/1027665 combatspell_cmd [898] + 0.00 0.00 99/1027665 piracy_cmd [660] + 0.00 0.00 111/1027665 init_transportation [384] + 0.00 0.00 111/1027665 steal_cmd [766] + 0.00 0.00 138/1027665 renumber_cmd [780] + 0.00 0.00 147/1027665 contact_cmd [965] + 0.00 0.00 177/1027665 breed_cmd [741] + 0.00 0.00 222/1027665 cast_cmd [760] + 0.00 0.00 241/1027665 reshow_cmd [818] + 0.00 0.00 262/1027665 defaultorders [249] + 0.00 0.00 348/1027665 mail_cmd [844] + 0.00 0.00 349/1027665 research_cmd [886] + 0.00 0.00 590/1027665 use_cmd [763] + 0.00 0.00 597/1027665 move_hunters [342] + 0.00 0.00 621/1027665 group_cmd [985] + 0.00 0.00 639/1027665 do_enter [128] + 0.00 0.00 754/1027665 new_units [282] + 0.00 0.00 791/1027665 ally_cmd [877] + 0.00 0.00 799/1027665 setstealth_cmd [182] + 0.00 0.00 960/1027665 tax_cmd [697] + 0.00 0.00 1425/1027665 follow_unit [331] + 0.00 0.00 1487/1027665 start_battle [297] + 0.00 0.00 1700/1027665 status_cmd [904] + 0.00 0.00 1835/1027665 recruit [650] + 0.00 0.00 2013/1027665 display_cmd [859] + 0.00 0.00 3117/1027665 name_cmd [835] + 0.00 0.00 5049/1027665 parse_ids [852] + 0.00 0.00 5916/1027665 buy [707] + 0.00 0.00 8450/1027665 cycle_route [375] + 0.00 0.00 10600/1027665 make_cmd [383] + 0.00 0.00 15797/1027665 sell [498] + 0.00 0.00 16596/1027665 entertain_cmd [665] + 0.00 0.00 28057/1027665 teach_cmd [272] + 0.00 0.00 30554/1027665 guard_on_cmd [656] + 0.00 0.00 30634/1027665 guard_off_cmd [711] + 0.00 0.00 71388/1027665 reserve_i [213] + 0.00 0.00 103494/1027665 movement [47] + 0.00 0.00 131722/1027665 give_cmd [102] + 0.00 0.00 131765/1027665 give_control_cmd [287] + 0.00 0.00 417775/1027665 study_cmd [105] +[613] 0.0 0.00 0.01 1027665 init_order [613] + 0.01 0.00 1027665/1311302 init_tokens_str [544] +----------------------------------------------- + 0.00 0.01 2/2 tolua_write_summary [38] +[614] 0.0 0.00 0.01 2 report_summary [614] + 0.00 0.01 251/251 out_faction [615] + 0.00 0.00 93/24887945 locale_string [27] + 0.00 0.00 93/71815034 get_race [12] + 0.00 0.00 2/11719 locale_name [568] + 0.00 0.00 2/3 update_nmrs [1155] + 0.00 0.00 71/2818494 rc_name_s [260] + 0.00 0.00 2/3 gamedate2 [1222] + 0.00 0.00 1/1 writeturn [1253] + 0.00 0.00 2/573 join_path [1016] + 0.00 0.00 1/1248014 listlen [190] + 0.00 0.00 2/27 NMRTimeout [1264] + 0.00 0.00 2/462 game_name [1168] + 0.00 0.00 3/64 log_info [1339] + 0.00 0.00 51/51 rcomp [1681] + 0.00 0.00 42/42 pcomp [1687] + 0.00 0.00 2/9 basepath [1730] +----------------------------------------------- + 0.00 0.01 251/251 report_summary [614] +[615] 0.0 0.00 0.01 251 out_faction [615] + 0.00 0.01 251/481 count_units [487] + 0.00 0.00 251/24887945 locale_string [27] + 0.00 0.00 251/1295787 factionname [247] + 0.00 0.00 251/2818494 rc_name_s [260] +----------------------------------------------- + 0.00 0.01 552/552 print_stats [525] +[616] 0.0 0.00 0.01 552 print_fighters [616] + 0.00 0.01 1297/1297 battle_punit [620] + 0.00 0.00 614/1486 message_all [834] + 0.00 0.00 614/967784 msg_message [132] + 0.00 0.00 5188/4301501 statusrow [550] + 0.00 0.00 614/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.01 3626/3626 make_cmd [383] +[617] 0.0 0.00 0.01 3626 create_item [617] + 0.00 0.01 3100/15361 is_guarded [377] + 0.00 0.00 3078/3078 allocate_resource [752] + 0.00 0.00 377/377 manufacture [759] + 0.00 0.00 149/149 create_potion [821] + 0.00 0.00 22/15102 cmistake [718] + 0.00 0.00 526/1582 resource2potion [1569] +----------------------------------------------- + 0.00 0.01 230/230 report_plaintext [4] +[618] 0.0 0.00 0.01 230 rp_battles [618] + 0.00 0.01 676/79180 rp_messages [36] + 0.00 0.00 676/1380398 nr_render [25] + 0.00 0.00 676/967784 msg_message [132] + 0.00 0.00 816/37931 centre [789] + 0.00 0.00 140/24887945 locale_string [27] + 0.00 0.00 1632/2494242 newline [594] + 0.00 0.00 676/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.01 578591/578591 monthly_healing [215] +[619] 0.0 0.00 0.01 578591 heal_factor [619] + 0.00 0.00 578591/7910500 r_isforest [199] + 0.00 0.00 578592/129167539 u_race [89] + 0.00 0.00 14447/12560453 rc_changed [256] + 0.00 0.00 1/71815034 get_race [12] + 0.00 0.00 1/717287 get_param_flt [713] + 0.00 0.00 2430/2386892 config_changed [1352] +----------------------------------------------- + 0.00 0.01 1297/1297 print_fighters [616] +[620] 0.0 0.00 0.01 1297 battle_punit [620] + 0.00 0.01 4384/4384 spunit [632] + 0.00 0.00 4384/12398 fbattlerecord [688] + 0.00 0.00 4384/5330 freestrlist [1534] +----------------------------------------------- + 0.00 0.00 1/180818 tolua_building_tostring [1306] + 0.00 0.00 12/180818 read_game [62] + 0.00 0.00 67213/180818 eval_building [494] + 0.00 0.00 113592/180818 nr_building [141] +[621] 0.0 0.00 0.01 180818 buildingname [621] + 0.00 0.01 180818/180818 write_buildingname [622] +----------------------------------------------- + 0.00 0.01 180818/180818 buildingname [621] +[622] 0.0 0.00 0.01 180818 write_buildingname [622] + 0.00 0.01 180818/5100840 itoa36 [116] + 0.00 0.00 180818/5461936 slprintf [548] +----------------------------------------------- + 0.00 0.00 21/74 do_combatspell [702] + 0.00 0.01 53/74 do_extra_spell [648] +[623] 0.0 0.00 0.01 74 cast_combatspell [623] + 0.00 0.01 53/53 sp_dragonodem [627] + 0.00 0.00 74/273 pay_spell [805] + 0.00 0.00 21/21 sp_kampfzauber [957] + 0.00 0.00 74/83 create_castorder_combat [1137] + 0.00 0.00 74/303 free_castorder [1609] +----------------------------------------------- + 0.00 0.01 32670/32670 demographics [50] +[624] 0.0 0.00 0.01 32670 growing_trees [624] + 0.00 0.00 361320/7641081 genrand_int31 [171] + 0.00 0.00 249356/10053919 rtrees [302] + 0.00 0.00 32649/12246335 ct_find [114] + 0.00 0.00 32649/10190660 get_curse [143] + 0.00 0.00 32670/51974272 a_find [65] + 0.00 0.00 32649/4201030 curse_active [543] + 0.00 0.00 32/779419 a_add [555] + 0.00 0.00 130680/229715 rsettrees [1410] + 0.00 0.00 32649/651711 oldcursename [1381] + 0.00 0.00 32/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 42/34409 expandloot [816] + 0.00 0.00 59/34409 expandstealing [807] + 0.00 0.00 948/34409 expandtax [278] + 0.00 0.00 5821/34409 expandselling [93] + 0.00 0.00 10979/34409 expandwork [277] + 0.00 0.00 16560/34409 expandentertainment [637] +[625] 0.0 0.00 0.01 34409 add_income [625] + 0.00 0.00 34409/967784 msg_message [132] + 0.00 0.00 34409/392959 add_message [434] + 0.00 0.00 34409/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.01 70836/70836 is_guarded [377] +[626] 0.0 0.00 0.01 70836 is_guardian_u [626] + 0.00 0.01 63046/9953180 alliedunit [31] + 0.00 0.00 63046/6610983 is_guard [211] + 0.00 0.00 397/1437425 cansee [22] + 0.00 0.00 397/8898 ucontact [927] + 0.00 0.00 257/129167539 u_race [89] +----------------------------------------------- + 0.00 0.01 53/53 cast_combatspell [623] +[627] 0.0 0.00 0.01 53 sp_dragonodem [627] + 0.00 0.00 7313/80630 terminate [242] + 0.00 0.00 7313/372173 select_enemy [172] + 0.00 0.00 53/1486 message_all [834] + 0.00 0.00 53/967784 msg_message [132] + 0.00 0.00 53/201744 lovar [644] + 0.00 0.00 53/876979 count_enemies [611] + 0.00 0.00 53/74 spell_damage [1657] + 0.00 0.00 53/74 get_force [1656] + 0.00 0.00 53/1009028 msg_release [1373] +----------------------------------------------- + +[628] 0.0 0.00 0.01 tolua_region_getkey [628] + 0.01 0.00 178254/688711 atoi36 [440] + 0.00 0.00 178254/178257 key_get [719] +----------------------------------------------- + 0.00 0.01 1/1 tolua_spawn_undead [630] +[629] 0.0 0.00 0.01 1 spawn_undead [629] + 0.00 0.00 355408/355423 deathcount [674] + 0.00 0.00 92/2889 create_unit [296] + 0.00 0.00 90436/10190660 get_curse [143] + 0.00 0.00 31670/2605004 rpeasants [435] + 0.00 0.00 37226/37974 deathcounts [843] + 0.00 0.00 828/2457 set_level [774] + 0.00 0.00 90436/4201030 curse_active [543] + 0.00 0.00 9552/7641081 genrand_int31 [171] + 0.00 0.00 92/967784 msg_message [132] + 0.00 0.00 266/392959 add_message [434] + 0.00 0.00 92/2931 name_unit [803] + 0.00 0.00 92/1381157 unit_max_hp [136] + 0.00 0.00 247/71815034 get_race [12] + 0.00 0.00 92/361 regionname [987] + 0.00 0.00 21/2375 equip_unit [775] + 0.00 0.00 92/24887945 locale_string [27] + 0.00 0.00 9312/21517 chaosfactor [1077] + 0.00 0.00 92/2818494 rc_name_s [260] + 0.00 0.00 92/129167539 u_race [89] + 0.00 0.00 1/12246335 ct_find [114] + 0.00 0.00 1/3902878 get_monsters [293] + 0.00 0.00 92/49235 log_debug [1245] + 0.00 0.00 92/1009028 msg_release [1373] + 0.00 0.00 21/2742 get_equipment [1551] +----------------------------------------------- + +[630] 0.0 0.00 0.01 tolua_spawn_undead [630] + 0.00 0.01 1/1 spawn_undead [629] +----------------------------------------------- + 0.00 0.01 9680/9680 travel_route [147] +[631] 0.0 0.00 0.01 9680 bewegung_blockiert_von [631] + 0.00 0.00 216875/6610983 is_guard [211] + 0.00 0.00 9680/560926 bt_find [237] + 0.00 0.00 9680/1188532 eff_stealth [163] + 0.00 0.00 8873/1753922 invisible [139] + 0.00 0.00 8873/12320804 effskill [100] + 0.00 0.00 6140/9953180 alliedunit [31] + 0.00 0.00 58080/717218 config_get_flt [714] + 0.00 0.00 27379/129167539 u_race [89] + 0.00 0.00 6140/8898 ucontact [927] + 0.00 0.00 9680/56052475 get_resourcetype [194] + 0.00 0.00 372/5395063 i_get [130] + 0.00 0.00 6/593636 building_owner [232] + 0.00 0.00 3/184870 buildingeffsize [367] + 0.00 0.00 20/752645 chance [495] + 0.00 0.00 105/1511812 newterrain [1359] +----------------------------------------------- + 0.00 0.01 4384/4384 battle_punit [620] +[632] 0.0 0.00 0.01 4384 spunit [632] + 0.00 0.01 4384/1348743 bufunit [17] + 0.00 0.00 4384/4384 lparagraph [809] +----------------------------------------------- + 0.00 0.01 96555/96555 travel_i [92] +[633] 0.0 0.00 0.01 96555 canwalk [633] + 0.00 0.00 12778/96637 walkingcapacity [403] + 0.00 0.00 12778/34221 eff_weight [683] + 0.00 0.00 12787/12320804 effskill [100] + 0.00 0.00 83768/3902878 get_monsters [293] + 0.00 0.00 12787/71815034 get_race [12] + 0.00 0.00 12787/129167539 u_race [89] + 0.00 0.00 12787/130867 get_transporters [1431] +----------------------------------------------- + 0.00 0.01 108560/108560 parse_symbol [42] +[634] 0.0 0.00 0.01 108560 eval_trail [634] + 0.00 0.00 19276/146950 f_regionid_s [477] + 0.00 0.00 19276/785221 trailinto [207] + 0.00 0.00 108560/13102790 opstack_pop [176] + 0.00 0.00 108560/13102790 opstack_push [202] + 0.00 0.00 108560/13399069 balloc [363] + 0.00 0.00 4257/24887945 locale_string [27] + 0.00 0.00 4287/17451017 strlcpy_w [67] + 0.00 0.00 19276/36653945 wrptr [178] +----------------------------------------------- + 0.00 0.01 229/229 report_plaintext [4] +[635] 0.0 0.00 0.01 229 list_address [635] + 0.00 0.00 10794/2742237 paragraph [26] + 0.00 0.00 10565/1205451 alliedfaction [162] + 0.00 0.00 10794/1295787 factionname [247] + 0.00 0.00 229/24887945 locale_string [27] + 0.00 0.00 229/37931 centre [789] + 0.00 0.00 176/3902878 get_monsters [293] + 0.00 0.00 458/2494242 newline [594] + 0.00 0.00 10565/1214628 is_allied [1368] + 0.00 0.00 229/128135 rpline [1433] +----------------------------------------------- + 0.00 0.01 300810/300810 count_enemies [611] +[636] 0.0 0.00 0.01 300810 count_enemies_i [636] + 0.00 0.00 317201/317239 count_side [666] + 0.00 0.00 25256/1662377 get_unitrow [154] +----------------------------------------------- + 0.00 0.01 11159/11159 produce [29] +[637] 0.0 0.00 0.01 11159 expandentertainment [637] + 0.00 0.00 16560/34409 add_income [625] + 0.00 0.00 16560/472418 produceexp [322] + 0.00 0.00 11159/79772 entertainmoney [643] + 0.00 0.00 16560/2599554 change_money [337] + 0.00 0.00 16560/2186159 rsetmoney [553] + 0.00 0.00 16560/4666665 rmoney [452] +----------------------------------------------- + 0.00 0.01 14191/14191 battle_flee [352] +[638] 0.0 0.00 0.01 14191 flee [638] + 0.00 0.01 14191/25088 kill_troop [532] + 0.00 0.00 14191/337987 setguard [815] +----------------------------------------------- + 0.00 0.01 1711/1711 cr_output_unit [19] +[639] 0.0 0.00 0.01 1711 cr_output_spells [639] + 0.00 0.00 33909/4434556 translate [75] + 0.00 0.00 33909/86400 spell_name [646] + 0.00 0.00 33909/4133717 mkname [261] + 0.00 0.00 35101/10103290 stream_printf [158] + 0.00 0.00 1711/597806 unit_get_spellbook [427] +----------------------------------------------- + 0.00 0.00 2/797288 sp_enterastral [1045] + 0.00 0.01 797286/797288 random_neighbour [153] +[640] 0.0 0.00 0.01 797288 can_survive [640] + 0.00 0.00 173175/12246335 ct_find [114] + 0.00 0.00 949946/129167539 u_race [89] + 0.00 0.00 19730/10190660 get_curse [143] + 0.00 0.00 19730/4201030 curse_active [543] + 0.00 0.00 742475/744202 has_horses [1378] +----------------------------------------------- + 0.00 0.00 93452/190469 describe [35] + 0.00 0.00 97017/190469 cr_borders [135] +[641] 0.0 0.00 0.01 190469 border_name [641] + 0.00 0.01 190467/190467 b_nameroad [642] + 0.00 0.00 2/2 b_namequestportal [1279] +----------------------------------------------- + 0.00 0.01 190467/190467 border_name [641] +[642] 0.0 0.00 0.01 190467 b_nameroad [642] + 0.00 0.00 93450/24887945 locale_string [27] + 0.00 0.00 93450/4133717 mkname [261] + 0.00 0.00 2705/5461936 slprintf [548] +----------------------------------------------- + 0.00 0.00 11159/79772 expandentertainment [637] + 0.00 0.00 31676/79772 statistics [70] + 0.00 0.00 36937/79772 cr_output_region [10] +[643] 0.0 0.00 0.01 79772 entertainmoney [643] + 0.00 0.00 159633/12246335 ct_find [114] + 0.00 0.00 159633/10190660 get_curse [143] + 0.00 0.00 159544/4201030 curse_active [543] + 0.00 0.00 79772/4666665 rmoney [452] + 0.00 0.00 159633/651711 oldcursename [1381] + 0.00 0.00 89/432940 curse_geteffect [1395] +----------------------------------------------- + 0.00 0.00 2/201744 sp_bloodsacrifice [1209] + 0.00 0.00 3/201744 sp_song_of_peace [939] + 0.00 0.00 6/201744 sp_mallornhain [968] + 0.00 0.00 9/201744 sp_hain [931] + 0.00 0.00 9/201744 sp_summonundead [896] + 0.00 0.00 21/201744 sp_kampfzauber [957] + 0.00 0.00 53/201744 sp_dragonodem [627] + 0.00 0.00 1714/201744 eaten_by_monster [468] + 0.00 0.00 2200/201744 absorbed_by_monster [804] + 0.00 0.01 197727/201744 scared_by_monster [380] +[644] 0.0 0.00 0.01 201744 lovar [644] + 0.00 0.00 403488/7641081 genrand_int31 [171] + 0.00 0.00 1/1 register_reports [1851] +----------------------------------------------- + 0.00 0.01 80630/80630 terminate [242] +[645] 0.0 0.00 0.01 80630 calculate_armor [645] + 0.00 0.00 80630/80630 select_magicarmor [680] + 0.00 0.00 7938/7957 magic_resistance [727] + 0.00 0.00 80630/80630 natural_armor [788] + 0.00 0.00 161260/868104 select_armor [700] + 0.00 0.00 7938/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 8/86400 do_combatmagic [825] + 0.00 0.00 23/86400 do_combatspell [702] + 0.00 0.00 279/86400 cr_spell [1026] + 0.00 0.00 604/86400 eval_spell [961] + 0.00 0.00 1261/86400 cr_output_unit [19] + 0.00 0.00 2081/86400 cr_reportspell [756] + 0.00 0.00 2081/86400 nr_spell_syntax [732] + 0.00 0.00 2081/86400 nr_spell [507] + 0.00 0.00 8557/86400 select_spellbook [761] + 0.00 0.00 33909/86400 cr_output_spells [639] + 0.00 0.00 35516/86400 bufunit [17] +[646] 0.0 0.00 0.01 86400 spell_name [646] + 0.00 0.00 86400/24887945 locale_string [27] + 0.00 0.00 86400/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 1/41248 movement_error [1193] + 0.00 0.00 1/41248 travel_i [92] + 0.00 0.00 1/41248 allocate_resource [752] + 0.00 0.00 1/41248 plant [1184] + 0.00 0.00 1/41248 planttrees [1206] + 0.00 0.00 2/41248 travel [81] + 0.00 0.00 2/41248 give_men [857] + 0.00 0.00 3/41248 mail_cmd [844] + 0.00 0.00 4/41248 init_transportation [384] + 0.00 0.00 4/41248 ship_ready [354] + 0.00 0.00 4/41248 spy_cmd [990] + 0.00 0.00 5/41248 buy [707] + 0.00 0.00 10/41248 make_cmd [383] + 0.00 0.00 10/41248 tax_cmd [697] + 0.00 0.00 16/41248 build_road [950] + 0.00 0.00 19/41248 enter_building [695] + 0.00 0.00 22/41248 check_give [1138] + 0.00 0.00 24/41248 cancast [833] + 0.00 0.00 46/41248 steal_cmd [766] + 0.00 0.00 57/41248 start_battle [297] + 0.00 0.00 84/41248 do_work [612] + 0.00 0.00 170/41248 guard_on_cmd [656] + 0.00 0.00 182/41248 msg_materials_required [1005] + 0.00 0.00 186/41248 study_cmd [105] + 0.00 0.00 1225/41248 give_item [126] + 0.00 0.00 1323/41248 teach_cmd [272] + 0.00 0.00 8935/41248 msg_error [744] + 0.00 0.00 28910/41248 give_cmd [102] +[647] 0.0 0.00 0.01 41248 msg_feedback [647] + 0.00 0.00 41248/1010116 mt_find [227] + 0.00 0.00 41248/1009159 msg_create [228] + 0.00 0.00 123744/123744 arg_set [1434] +----------------------------------------------- + 0.00 0.01 53/53 attack [84] +[648] 0.0 0.00 0.01 53 do_extra_spell [648] + 0.00 0.01 53/74 cast_combatspell [623] +----------------------------------------------- + 0.00 0.01 832876/832876 parse [333] +[649] 0.0 0.00 0.01 832876 parse_int [649] + 0.01 0.00 832876/13102790 opstack_push [202] +----------------------------------------------- + 0.00 0.01 1835/1835 economics [78] +[650] 0.0 0.00 0.01 1835 recruit [650] + 0.00 0.00 1716/15361 is_guarded [377] + 0.00 0.00 3359/541982 get_pooled [104] + 0.00 0.00 1670/760673 addlist [217] + 0.00 0.00 3340/2624955 has_skill [193] + 0.00 0.00 1835/57138 getint [699] + 0.00 0.00 1689/71815034 get_race [12] + 0.00 0.00 1670/635885 copy_order [441] + 0.00 0.00 1689/12246335 ct_find [114] + 0.00 0.00 1689/10190660 get_curse [143] + 0.00 0.00 119/119 syntax_error [1036] + 0.00 0.00 378/2281756 gettoken [195] + 0.00 0.00 1835/1027665 init_order [613] + 0.00 0.00 3551/129167539 u_race [89] + 0.00 0.00 3359/56052475 get_resourcetype [194] + 0.00 0.00 46/15102 cmistake [718] + 0.00 0.00 1689/4201030 curse_active [543] + 0.00 0.00 1689/18647447 getplane [596] + 0.00 0.00 4/338 findrace [1030] + 0.00 0.00 1716/1716 recruit_cost [1564] + 0.00 0.00 1716/600145 u_setrace [1389] + 0.00 0.00 1689/651711 oldcursename [1381] + 0.00 0.00 89/40692 get_gamedate [1466] + 0.00 0.00 89/59694 r_insectstalled [1446] +----------------------------------------------- + 0.00 0.00 5/490901 name_cmd [835] + 0.00 0.01 490896/490901 default_wage [173] +[651] 0.0 0.00 0.01 490901 largestbuilding [651] + 0.00 0.00 396305/396305 cmp_wage [670] + 0.00 0.00 172276/51974272 a_find [65] +----------------------------------------------- + 0.00 0.01 329691/329691 is_guard [211] +[652] 0.0 0.00 0.01 329691 getguard [652] + 0.00 0.00 329691/51974272 a_find [65] + 0.00 0.00 329691/377253 guard_flags [690] +----------------------------------------------- + +[653] 0.0 0.01 0.00 cb_new_kv [653] +----------------------------------------------- + 0.00 0.00 353422/353422 hits [131] +[654] 0.0 0.00 0.00 353422 contest [654] + 0.00 0.00 353422/353422 contest_classic [655] +----------------------------------------------- + 0.00 0.00 353422/353422 contest [654] +[655] 0.0 0.00 0.00 353422 contest_classic [655] + 0.00 0.00 373896/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 30554/30554 process [7] +[656] 0.0 0.00 0.00 30554 guard_on_cmd [656] + 0.00 0.00 23993/55350 can_start_guarding [679] + 0.00 0.00 30554/69432 getparam [681] + 0.00 0.00 23993/71815034 get_race [12] + 0.00 0.00 6527/15102 cmistake [718] + 0.00 0.00 30554/55492327 getkeyword [54] + 0.00 0.00 30554/1027665 init_order [613] + 0.00 0.00 23781/23781 guard [865] + 0.00 0.00 47987/129167539 u_race [89] + 0.00 0.00 170/41248 msg_feedback [647] + 0.00 0.00 170/392959 add_message [434] + 0.00 0.00 170/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 79/39810 drift_target [1053] + 0.00 0.00 39731/39810 sail [181] +[657] 0.0 0.00 0.00 39810 check_ship_allowed [657] + 0.00 0.00 39810/560926 bt_find [237] + 0.00 0.00 1357/12933 owner_buildingtyp [676] + 0.00 0.00 1198/9953180 alliedunit [31] + 0.00 0.00 1198/8898 ucontact [927] + 0.00 0.00 179/188 is_freezing [1088] + 0.00 0.00 39810/59694 r_insectstalled [1446] + 0.00 0.00 39810/75797 buildingtype_exists [1443] +----------------------------------------------- + 0.00 0.00 32670/32670 demographics [50] +[658] 0.0 0.00 0.00 32670 peasants [658] + 0.00 0.00 32670/264251 rsetpeasants [545] + 0.00 0.00 32670/669051 production [417] + 0.00 0.00 30250/1336242 rng_injectable_double [396] + 0.00 0.00 67774/2605004 rpeasants [435] + 0.00 0.00 66416/2765718 maintenance_cost [481] + 0.00 0.00 30250/51974272 a_find [65] + 0.00 0.00 30250/4984610 config_get_int [348] + 0.00 0.00 32670/2186159 rsetmoney [553] + 0.00 0.00 32670/4666665 rmoney [452] + 0.00 0.00 30250/30308 peasant_growth_factor [928] + 0.00 0.00 30250/30250 peasant_luck_effect [984] + 0.00 0.00 110/967784 msg_message [132] + 0.00 0.00 110/392959 add_message [434] + 0.00 0.00 110/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 178254/178254 ageing [185] +[659] 0.0 0.00 0.00 178254 age_region [659] + 0.00 0.00 178254/839202 a_age [418] + 0.00 0.00 178254/1342832 handle_event [1363] + 0.00 0.00 32670/32670 morale_update [1479] +----------------------------------------------- + 0.00 0.00 5049/5049 move_pirates [326] +[660] 0.0 0.00 0.00 5049 piracy_cmd [660] + 0.00 0.00 30248/47287 canswim [682] + 0.00 0.00 21148/369586 r_connect [474] + 0.00 0.00 5049/967784 msg_message [132] + 0.00 0.00 99/103784 move_cmd [66] + 0.00 0.00 5049/392959 add_message [434] + 0.00 0.00 5049/5049 parse_ids [852] + 0.00 0.00 5049/5049 find_piracy_target [967] + 0.00 0.00 315/4374788 visible_faction [68] + 0.00 0.00 315/9953180 alliedunit [31] + 0.00 0.00 5049/5049 validate_pirate [1051] + 0.00 0.00 99/447808 create_order [341] + 0.00 0.00 412/7641081 genrand_int31 [171] + 0.00 0.00 99/24887945 locale_string [27] + 0.00 0.00 322/3358315 ship_owner [438] + 0.00 0.00 36/4361 can_takeoff [854] + 0.00 0.00 97/779419 a_add [555] + 0.00 0.00 99/1027665 init_order [613] + 0.00 0.00 5049/1009028 msg_release [1373] + 0.00 0.00 99/1936876 free_order [1356] + 0.00 0.00 97/97 mk_piracy [1652] +----------------------------------------------- + 0.00 0.00 1921/1921 report_computer [9] +[661] 0.0 0.00 0.00 1921 show_allies_cr [661] + 0.00 0.00 55310/10375491 alliedgroup [34] +----------------------------------------------- + 0.00 0.00 133873/133873 cr_render [196] +[662] 0.0 0.00 0.00 133873 cr_region [662] + 0.00 0.00 132705/1826688 adjust_coordinates [234] + 0.00 0.00 132705/18647447 getplane [596] + 0.00 0.00 132705/3587241 pnormalize [1350] +----------------------------------------------- + 0.00 0.00 1771752/1771752 get_food [88] +[663] 0.0 0.00 0.00 1771752 help_money [663] + 0.00 0.00 1771752/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 12828/26045 cr_output_curses [69] + 0.00 0.00 13217/26045 nr_curses_i [401] +[664] 0.0 0.00 0.00 26045 msg_curse [664] + 0.00 0.00 15359/15359 cinfo_building [686] + 0.00 0.00 5907/5907 cinfo_simple [751] + 0.00 0.00 2274/2274 cinfo_ship [812] + 0.00 0.00 1911/1911 cinfo_magicresistance [824] + 0.00 0.00 183/183 cinfo_magicrunes [996] + 0.00 0.00 163/163 cinfo_shipnodrift [997] + 0.00 0.00 62/62 cinfo_speed [1110] + 0.00 0.00 134/134 cinfo_slave [1118] + 0.00 0.00 52/52 cinfo_skillmod [1192] +----------------------------------------------- + 0.00 0.00 16596/16596 produce [29] +[665] 0.0 0.00 0.00 16596 entertain_cmd [665] + 0.00 0.00 33156/12320804 effskill [100] + 0.00 0.00 16560/16751 getuint [778] + 0.00 0.00 278/15361 is_guarded [377] + 0.00 0.00 16560/12246335 ct_find [114] + 0.00 0.00 16560/10190660 get_curse [143] + 0.00 0.00 16596/1027665 init_order [613] + 0.00 0.00 16597/20777534 config_get [224] + 0.00 0.00 16560/4201030 curse_active [543] + 0.00 0.00 16593/8506411 besieged [547] + 0.00 0.00 36/15102 cmistake [718] + 0.00 0.00 16560/651711 oldcursename [1381] +----------------------------------------------- + 0.00 0.00 38/317239 count_allies [1220] + 0.00 0.00 317201/317239 count_enemies_i [636] +[666] 0.0 0.00 0.00 317239 count_side [666] + 0.00 0.00 49445/1662377 get_unitrow [154] + 0.00 0.00 324731/4301501 statusrow [550] +----------------------------------------------- + 0.00 0.00 55/598069 renumber_unit [1159] + 0.00 0.00 2889/598069 createunitid [317] + 0.00 0.00 595125/598069 read_unit [74] +[667] 0.0 0.00 0.00 598069 uhash [667] + 0.00 0.00 598069/2903884 jenkins_hash [439] +----------------------------------------------- + 0.00 0.00 1/534930 destroy_cmd [1113] + 0.00 0.00 16/534930 addparam_unit [1214] + 0.00 0.00 42/534930 teach_cmd [272] + 0.00 0.00 241/534930 reshow_cmd [818] + 0.00 0.00 280/534930 use_cmd [763] + 0.00 0.00 24385/534930 parse_order [117] + 0.00 0.00 94233/534930 give_cmd [102] + 0.00 0.00 131764/534930 give_control_cmd [287] + 0.00 0.00 283968/534930 read_unitid [413] +[668] 0.0 0.00 0.00 534930 isparam [668] + 0.00 0.00 362487/1787006 findparam [458] +----------------------------------------------- + 0.00 0.00 191/66134 follow_ship [749] + 0.00 0.00 18850/66134 cr_output_ship [152] + 0.00 0.00 47093/66134 sail [181] +[669] 0.0 0.00 0.00 66134 shipspeed [669] + 0.00 0.00 67682/12246335 ct_find [114] + 0.00 0.00 67682/10190660 get_curse [143] + 0.00 0.00 66058/51974272 a_find [65] + 0.00 0.00 66058/66058 ShipSpeedBonus [806] + 0.00 0.00 66134/3358315 ship_owner [438] + 0.00 0.00 132028/129167539 u_race [89] + 0.00 0.00 1624/4201030 curse_active [543] + 0.00 0.00 820/820 curse_geteffect_int [1590] +----------------------------------------------- + 0.00 0.00 396305/396305 largestbuilding [651] +[670] 0.0 0.00 0.00 396305 cmp_wage [670] + 0.00 0.00 396305/1106528 is_building_type [554] +----------------------------------------------- + 0.00 0.00 40099/40099 parse_symbol [42] +[671] 0.0 0.00 0.00 40099 eval_skill [671] + 0.00 0.00 40099/2934859 skillname [122] + 0.00 0.00 40099/13102790 opstack_pop [176] + 0.00 0.00 40099/13102790 opstack_push [202] + 0.00 0.00 40099/13399069 balloc [363] +----------------------------------------------- + 0.00 0.00 20072/20072 cr_render [196] +[672] 0.0 0.00 0.00 20072 cr_skill [672] + 0.00 0.00 20072/4434556 translate [75] + 0.00 0.00 20072/2934859 skillname [122] + 0.00 0.00 20072/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 15708/15708 get_addresses [20] +[673] 0.0 0.00 0.00 15708 add_travelthru_addresses [673] + 0.00 0.00 15708/3398582 travelthru_map [41] +----------------------------------------------- + 0.00 0.00 15/355423 sp_summonundead [896] + 0.00 0.00 355408/355423 spawn_undead [629] +[674] 0.0 0.00 0.00 355423 deathcount [674] + 0.00 0.00 355423/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 40/40 set_new_dragon_target [486] +[675] 0.0 0.00 0.00 40 regions_in_range [675] + 0.00 0.00 30233/162862 allowed_dragon [564] + 0.00 0.00 25793/369586 r_connect [474] + 0.00 0.00 27734/152803 new_node [1427] + 0.00 0.00 40/428 free_nodes [1604] +----------------------------------------------- + 0.00 0.00 1357/12933 check_ship_allowed [657] + 0.00 0.00 4629/12933 expandselling [93] + 0.00 0.00 6947/12933 sail [181] +[676] 0.0 0.00 0.00 12933 owner_buildingtyp [676] + 0.00 0.00 28665/593636 building_owner [232] + 0.00 0.00 2920/147171 building_finished [1428] +----------------------------------------------- + 0.00 0.00 2594/83224 make_fighter [424] + 0.00 0.00 80630/83224 select_magicarmor [680] +[677] 0.0 0.00 0.00 83224 trollbelts [677] + 0.00 0.00 83224/5395063 i_get [130] + 0.00 0.00 83224/2032164 rt_find [597] +----------------------------------------------- + 0.00 0.00 106798/106798 get_food [88] +[678] 0.0 0.00 0.00 106798 help_feed [678] + 0.00 0.00 106798/7120688 get_money [187] + 0.00 0.00 106798/4198692 lifestyle [286] + 0.00 0.00 32382/2599554 change_money [337] + 0.00 0.00 16191/16191 add_donation [1509] +----------------------------------------------- + 0.00 0.00 23993/55350 guard_on_cmd [656] + 0.00 0.00 31357/55350 update_guards [415] +[679] 0.0 0.00 0.00 55350 can_start_guarding [679] + 0.00 0.00 15347/771861 armedmen [151] + 0.00 0.00 39959/3902878 get_monsters [293] + 0.00 0.00 15173/16669 IsImmune [901] + 0.00 0.00 15347/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 80630/80630 calculate_armor [645] +[680] 0.0 0.00 0.00 80630 select_magicarmor [680] + 0.00 0.00 80630/83224 trollbelts [677] +----------------------------------------------- + 0.00 0.00 6/69432 send_cmd [1202] + 0.00 0.00 17/69432 status_cmd [904] + 0.00 0.00 138/69432 reshow_cmd [818] + 0.00 0.00 597/69432 move_hunters [342] + 0.00 0.00 677/69432 ally_cmd [877] + 0.00 0.00 1425/69432 follow_unit [331] + 0.00 0.00 5384/69432 teach_cmd [272] + 0.00 0.00 30554/69432 guard_on_cmd [656] + 0.00 0.00 30634/69432 guard_off_cmd [711] +[681] 0.0 0.00 0.00 69432 getparam [681] + 0.00 0.00 69432/2281756 gettoken [195] + 0.00 0.00 7650/1787006 findparam [458] +----------------------------------------------- + 0.00 0.00 1953/47287 travel_route [147] + 0.00 0.00 7542/47287 monthly_healing [215] + 0.00 0.00 7544/47287 drown [394] + 0.00 0.00 30248/47287 piracy_cmd [660] +[682] 0.0 0.00 0.00 47287 canswim [682] + 0.00 0.00 47287/5395063 i_get [130] + 0.00 0.00 47287/1177511 it_find [385] + 0.00 0.00 92804/129167539 u_race [89] + 0.00 0.00 486/116002 get_movement [750] +----------------------------------------------- + 0.00 0.00 12778/34221 canwalk [633] + 0.00 0.00 21443/34221 canride [465] +[683] 0.0 0.00 0.00 34221 eff_weight [683] + 0.00 0.00 34221/279395 weight [459] + 0.00 0.00 34221/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 11880/11880 cb_add_address [598] +[684] 0.0 0.00 0.00 11880 cansee_unit [684] + 0.00 0.00 13580/1753922 invisible [139] + 0.00 0.00 9999/1188532 eff_stealth [163] + 0.00 0.00 6428/12320804 effskill [100] + 0.00 0.00 11880/6610983 is_guard [211] + 0.00 0.00 11880/129167539 u_race [89] + 0.00 0.00 11880/4835422 usiege [593] + 0.00 0.00 6428/21345834 skill_enabled [365] +----------------------------------------------- + 0.00 0.00 46224/46224 parse_symbol [42] +[685] 0.0 0.00 0.00 46224 eval_faction [685] + 0.00 0.00 46224/1295787 factionname [247] + 0.00 0.00 46224/13102790 opstack_pop [176] + 0.00 0.00 46224/13102790 opstack_push [202] + 0.00 0.00 46224/13399069 balloc [363] +----------------------------------------------- + 0.00 0.00 15359/15359 msg_curse [664] +[686] 0.0 0.00 0.00 15359 cinfo_building [686] + 0.00 0.00 15359/967784 msg_message [132] + 0.00 0.00 15359/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 151532/2155959 report_template [87] + 0.00 0.00 606357/2155959 read_unit [74] + 0.00 0.00 692829/2155959 write_unit [97] + 0.00 0.00 705241/2155959 cr_output_unit [19] +[687] 0.0 0.00 0.00 2155959 is_persistent [687] + 0.00 0.00 766833/2985733 is_repeated [552] +----------------------------------------------- + 0.00 0.00 2594/12398 battle_report [503] + 0.00 0.00 4384/12398 battle_punit [620] + 0.00 0.00 5420/12398 print_stats [525] +[688] 0.0 0.00 0.00 12398 fbattlerecord [688] + 0.00 0.00 12398/967784 msg_message [132] + 0.00 0.00 12398/31214 message_faction [716] + 0.00 0.00 12398/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 230/230 report_computer [9] +[689] 0.0 0.00 0.00 230 write_translations [689] + 0.00 0.00 50896/4488684 crtag [110] +----------------------------------------------- + 0.00 0.00 23781/377253 setguard [815] + 0.00 0.00 23781/377253 guard [865] + 0.00 0.00 329691/377253 getguard [652] +[690] 0.0 0.00 0.00 377253 guard_flags [690] + 0.00 0.00 377253/12560453 rc_changed [256] + 0.00 0.00 407896/129167539 u_race [89] + 0.00 0.00 3/71815034 get_race [12] +----------------------------------------------- + 0.00 0.00 115/1239 build_ship [839] + 0.00 0.00 149/1239 create_potion [821] + 0.00 0.00 377/1239 manufacture [759] + 0.00 0.00 598/1239 build_building [696] +[691] 0.0 0.00 0.00 1239 build [691] + 0.00 0.00 1484/860263 use_pooled [39] + 0.00 0.00 1816/541982 get_pooled [104] + 0.00 0.00 1705/12320804 skillmod [214] + 0.00 0.00 1230/12320804 effskill [100] + 0.00 0.00 1040/472418 produceexp [322] + 0.00 0.00 4475/4475 matmod [975] + 0.00 0.00 1356/6010308 i_find [127] + 0.00 0.00 1230/2858912 get_effect [225] + 0.00 0.00 1356/56052475 get_resourcetype [194] + 0.00 0.00 1578/1583 skill_limit [1172] + 0.00 0.00 95/2977 change_effect [982] + 0.00 0.00 61/3003 roqf_factor [1329] + 0.00 0.00 4530/26164 building_is_active [1488] + 0.00 0.00 2978/3100 required [1547] + 0.00 0.00 1733/26995 inside_building [1486] +----------------------------------------------- + 0.00 0.00 55/285923 renumber_unit [1159] + 0.00 0.00 110903/285923 findnewunit [753] + 0.00 0.00 174965/285923 cr_output_unit [19] +[692] 0.0 0.00 0.00 285923 ualias [692] + 0.00 0.00 285923/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 206/206 do_battle [64] +[693] 0.0 0.00 0.00 206 join_allies [693] + 0.00 0.00 345/3203 join_battle [425] + 0.00 0.00 2033/9953180 alliedunit [31] + 0.00 0.00 23/48 allysfm [1122] + 0.00 0.00 498/8506411 besieged [547] + 0.00 0.00 719/18647447 getplane [596] + 0.00 0.00 3/10375491 alliedgroup [34] + 0.00 0.00 1520/1520 set_friendly [1574] + 0.00 0.00 644/2073 set_enemy [1562] +----------------------------------------------- + 0.00 0.00 21443/21443 canride [465] +[694] 0.0 0.00 0.00 21443 ridingcapacity [694] + 0.00 0.00 33015/12320804 effskill [100] + 0.00 0.00 21443/129167539 u_race [89] + 0.00 0.00 21443/130867 get_transporters [1431] +----------------------------------------------- + 0.00 0.00 405/405 do_enter [128] +[695] 0.0 0.00 0.00 405 enter_building [695] + 0.00 0.00 323/2887 leave [432] + 0.00 0.00 401/401 mayenter [936] + 0.00 0.00 19/41248 msg_feedback [647] + 0.00 0.00 409/129167539 u_race [89] + 0.00 0.00 19/392959 add_message [434] + 0.00 0.00 1/15102 cmistake [718] + 0.00 0.00 401/48455 findbuilding [1462] + 0.00 0.00 323/677 slipthru [1593] + 0.00 0.00 323/48565 u_set_building [1460] + 0.00 0.00 19/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 621/621 make_cmd [383] +[696] 0.0 0.00 0.00 621 build_building [696] + 0.00 0.00 598/1239 build [691] + 0.00 0.00 490/10232 update_lighthouse [605] + 0.00 0.00 490/14326 replace_order [526] + 0.00 0.00 490/967784 msg_message [132] + 0.00 0.00 9/2887 leave [432] + 0.00 0.00 621/12320804 effskill [100] + 0.00 0.00 581/392959 add_message [434] + 0.00 0.00 490/24887945 locale_string [27] + 0.00 0.00 325/447808 create_order [341] + 0.00 0.00 91/182 msg_materials_required [1005] + 0.00 0.00 9/11 new_building [1059] + 0.00 0.00 165/3110 default_order [902] + 0.00 0.00 587/4984610 config_get_int [348] + 0.00 0.00 31/15102 cmistake [718] + 0.00 0.00 598/8506411 besieged [547] + 0.00 0.00 610/48455 findbuilding [1462] + 0.00 0.00 581/1009028 msg_release [1373] + 0.00 0.00 490/1936876 free_order [1356] + 0.00 0.00 9/48565 u_set_building [1460] + 0.00 0.00 2/75797 buildingtype_exists [1443] +----------------------------------------------- + 0.00 0.00 960/960 produce [29] +[697] 0.0 0.00 0.00 960 tax_cmd [697] + 0.00 0.00 956/15361 is_guarded [377] + 0.00 0.00 2659/12320804 effskill [100] + 0.00 0.00 960/771861 armedmen [151] + 0.00 0.00 948/760673 addlist [217] + 0.00 0.00 956/57138 getint [699] + 0.00 0.00 960/71815034 get_race [12] + 0.00 0.00 3836/129167539 u_race [89] + 0.00 0.00 960/1027665 init_order [613] + 0.00 0.00 10/41248 msg_feedback [647] + 0.00 0.00 960/8506411 besieged [547] + 0.00 0.00 10/392959 add_message [434] + 0.00 0.00 2/15102 cmistake [718] + 0.00 0.00 1/4984610 config_get_int [348] + 0.00 0.00 10/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 56643/56643 bufunit [17] +[698] 0.0 0.00 0.00 56643 groupid [698] + 0.00 0.00 56643/5100840 itoa36 [116] +----------------------------------------------- + 0.00 0.00 10/57138 combatspell_cmd [898] + 0.00 0.00 42/57138 loot_cmd [873] + 0.00 0.00 108/57138 cast_cmd [760] + 0.00 0.00 956/57138 tax_cmd [697] + 0.00 0.00 1835/57138 recruit [650] + 0.00 0.00 5916/57138 buy [707] + 0.00 0.00 16751/57138 getuint [778] + 0.00 0.00 31520/57138 reserve_i [213] +[699] 0.0 0.00 0.00 57138 getint [699] + 0.00 0.00 57138/2281756 gettoken [195] +----------------------------------------------- + 0.00 0.00 161260/868104 calculate_armor [645] + 0.00 0.00 706844/868104 hits [131] +[700] 0.0 0.00 0.00 868104 select_armor [700] + 0.00 0.00 868104/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 206/206 do_battle [64] +[701] 0.0 0.00 0.00 206 aftermath [701] + 0.00 0.00 136/2887 leave [432] + 0.00 0.00 319/319 loot_items [810] + 0.00 0.00 1992/967784 msg_message [132] + 0.00 0.00 3056/31214 message_faction [716] + 0.00 0.00 206/412 do_combatmagic [825] + 0.00 0.00 425/425 reportcasualties [881] + 0.00 0.00 552/18788 sideabkz [745] + 0.00 0.00 340/11241829 i_change [115] + 0.00 0.00 425/3178 scale_number [969] + 0.00 0.00 623/1474687 leftship [500] + 0.00 0.00 1722/129167539 u_race [89] + 0.00 0.00 206/206 battle_effects [1125] + 0.00 0.00 319/337987 setguard [815] + 0.00 0.00 60/4301501 statusrow [550] + 0.00 0.00 12/717218 config_get_flt [714] + 0.00 0.00 2594/2913 dead_fighters [1549] + 0.00 0.00 2168/24449 seematrix [1491] + 0.00 0.00 1992/1009028 msg_release [1373] + 0.00 0.00 1104/22301 army_index [1498] + 0.00 0.00 206/206 reorder_fleeing [1631] + 0.00 0.00 12/160 damage_ship [1641] +----------------------------------------------- + 0.00 0.00 38/38 attack [84] +[702] 0.0 0.00 0.00 38 do_combatspell [702] + 0.00 0.00 21/74 cast_combatspell [623] + 0.00 0.00 23/251 cancast [833] + 0.00 0.00 23/251 eff_spelllevel [845] + 0.00 0.00 23/226 fumble [973] + 0.00 0.00 2/273 pay_spell [805] + 0.00 0.00 23/1339 get_combatspelllevel [880] + 0.00 0.00 21/225 spellpower [1000] + 0.00 0.00 23/447808 create_order [341] + 0.00 0.00 23/86400 spell_name [646] + 0.00 0.00 38/4875 get_combatspell [874] + 0.00 0.00 2/3 report_failed_spell [1187] + 0.00 0.00 21/7641081 genrand_int31 [171] + 0.00 0.00 21/1936876 free_order [1356] +----------------------------------------------- + 0.00 0.00 1078/11989 resolve_mage [856] + 0.00 0.00 1202/11989 resolve_familiar [846] + 0.00 0.00 2607/11989 resolve [757] + 0.00 0.00 7102/11989 read_reference [726] +[703] 0.0 0.00 0.00 11989 resolve_unit [703] + 0.00 0.00 9926/888603 findunit [123] +----------------------------------------------- + 0.00 0.00 6962/6962 move_ship [374] +[704] 0.0 0.00 0.00 6962 leave_trail [704] + 0.00 0.00 39729/263302 reldirection [528] + 0.00 0.00 39729/51974272 a_find [65] + 0.00 0.00 3233/779419 a_add [555] + 0.00 0.00 3233/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 6/22644 rsetroad [1152] + 0.00 0.00 22638/22644 read_borders [706] +[705] 0.0 0.00 0.00 22644 new_border [705] + 0.00 0.00 22644/2248440 get_borders_i [118] +----------------------------------------------- + 0.00 0.00 1/1 read_game [62] +[706] 0.0 0.00 0.00 1 read_borders [706] + 0.00 0.00 22638/22644 new_border [705] + 0.00 0.00 45276/46742 findregionbyid [1463] + 0.00 0.00 22638/22638 find_bordertype [1496] + 0.00 0.00 22637/22637 b_readroad [1497] + 0.00 0.00 1/1 b_read [1791] +----------------------------------------------- + 0.00 0.00 5916/5916 produce [29] +[707] 0.0 0.00 0.00 5916 buy [707] + 0.00 0.00 5757/760673 addlist [217] + 0.00 0.00 5903/12320804 effskill [100] + 0.00 0.00 5916/57138 getint [699] + 0.00 0.00 5762/2281756 gettoken [195] + 0.00 0.00 5915/71815034 get_race [12] + 0.00 0.00 30/15361 is_guarded [377] + 0.00 0.00 5903/51974272 a_find [65] + 0.00 0.00 3642/779419 a_add [555] + 0.00 0.00 5916/1027665 init_order [613] + 0.00 0.00 5762/191379 finditemtype [735] + 0.00 0.00 154/15102 cmistake [718] + 0.00 0.00 5915/129167539 u_race [89] + 0.00 0.00 5915/8506411 besieged [547] + 0.00 0.00 5/41248 msg_feedback [647] + 0.00 0.00 5/392959 add_message [434] + 0.00 0.00 1/560926 bt_find [237] + 0.00 0.00 5762/21500 resource2luxury [1499] + 0.00 0.00 5762/308950 r_demand [1404] + 0.00 0.00 5460/204314 bt_changed [1415] + 0.00 0.00 3642/779868 a_new [1376] + 0.00 0.00 847/1511812 newterrain [1359] + 0.00 0.00 5/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 11599/11599 skilldiff [166] +[708] 0.0 0.00 0.00 11599 building_protection [708] + 0.00 0.00 11599/184870 buildingeffsize [367] +----------------------------------------------- + 0.00 0.00 12984/748527 plan_monsters [52] + 0.00 0.00 317735/748527 monster_learn [269] + 0.00 0.00 417808/748527 study_cmd [105] +[709] 0.0 0.00 0.00 748527 unit_can_study [709] + 0.00 0.00 748527/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 42/54318 teach_cmd [272] + 0.00 0.00 191/54318 follow_ship [749] + 0.00 0.00 620/54318 mail_cmd [844] + 0.00 0.00 621/54318 group_cmd [985] + 0.00 0.00 2012/54318 display_cmd [859] + 0.00 0.00 3114/54318 name_cmd [835] + 0.00 0.00 5053/54318 parse_ids [852] + 0.00 0.00 42665/54318 sail [181] +[710] 0.0 0.00 0.00 54318 getstrtoken [710] + 0.00 0.00 54318/5387327 parse_token [125] +----------------------------------------------- + 0.00 0.00 30634/30634 process [7] +[711] 0.0 0.00 0.00 30634 guard_off_cmd [711] + 0.00 0.00 30634/69432 getparam [681] + 0.00 0.00 30634/55492327 getkeyword [54] + 0.00 0.00 30634/1027665 init_order [613] + 0.00 0.00 76/337987 setguard [815] +----------------------------------------------- + 0.00 0.00 46184/46184 ageing [185] +[712] 0.0 0.00 0.00 46184 age_building [712] + 0.00 0.00 46184/839202 a_age [418] + 0.00 0.00 46184/1106528 is_building_type [554] + 0.00 0.00 124/124 age_stonecircle [1021] + 0.00 0.00 46184/1342832 handle_event [1363] +----------------------------------------------- + 0.00 0.00 1/717287 heal_factor [619] + 0.00 0.00 68/717287 parse_races [1104] + 0.00 0.00 717218/717287 config_get_flt [714] +[713] 0.0 0.00 0.00 717287 get_param_flt [713] + 0.00 0.00 717287/26776263 get_param [235] +----------------------------------------------- + 0.00 0.00 1/717218 move_iceberg [1094] + 0.00 0.00 1/717218 plan_monsters [52] + 0.00 0.00 12/717218 aftermath [701] + 0.00 0.00 30/717218 overload_start [1295] + 0.00 0.00 58/717218 peasant_luck_factor [1277] + 0.00 0.00 96/717218 sinkships [475] + 0.00 0.00 143/717218 ResourceFactor [1236] + 0.00 0.00 508/717218 MagicRegeneration [1185] + 0.00 0.00 1062/717218 loot_quota [1013] + 0.00 0.00 7273/717218 sail [181] + 0.00 0.00 23838/717218 give_quota [858] + 0.00 0.00 30308/717218 peasant_growth_factor [928] + 0.00 0.00 58080/717218 bewegung_blockiert_von [631] + 0.00 0.00 178254/717218 drifting_ships [490] + 0.00 0.00 417554/717218 random_move_chance [754] +[714] 0.0 0.00 0.00 717218 config_get_flt [714] + 0.00 0.00 717218/717287 get_param_flt [713] +----------------------------------------------- + 0.00 0.00 152504/152504 terrain_name [226] +[715] 0.0 0.00 0.00 152504 plain_name [715] + 0.00 0.00 152504/7910500 r_isforest [199] +----------------------------------------------- + 0.00 0.00 4/31214 terminate [242] + 0.00 0.00 679/31214 print_header [838] + 0.00 0.00 3056/31214 aftermath [701] + 0.00 0.00 4336/31214 print_stats [525] + 0.00 0.00 5188/31214 battle_report [503] + 0.00 0.00 5553/31214 message_all [834] + 0.00 0.00 12398/31214 fbattlerecord [688] +[716] 0.0 0.00 0.00 31214 message_faction [716] + 0.00 0.00 31214/392959 add_message [434] +----------------------------------------------- + 0.00 0.00 981/179235 chaosfactor [1077] + 0.00 0.00 178254/179235 chaos_update [514] +[717] 0.0 0.00 0.00 179235 get_chaoscount [717] + 0.00 0.00 179235/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 1/15102 report_failure [1285] + 0.00 0.00 1/15102 sp_summon_familiar [1025] + 0.00 0.00 1/15102 sp_hain [931] + 0.00 0.00 1/15102 sp_charmingsong [993] + 0.00 0.00 1/15102 enter_building [695] + 0.00 0.00 1/15102 display_cmd [859] + 0.00 0.00 1/15102 try_rename [1225] + 0.00 0.00 1/15102 fumble_default [1284] + 0.00 0.00 1/15102 cast_cmd [760] + 0.00 0.00 2/15102 travel_route [147] + 0.00 0.00 2/15102 tax_cmd [697] + 0.00 0.00 2/15102 give_unit [952] + 0.00 0.00 2/15102 name_cmd [835] + 0.00 0.00 3/15102 give_control_cmd [287] + 0.00 0.00 4/15102 init_transportation [384] + 0.00 0.00 4/15102 breedhorses [742] + 0.00 0.00 4/15102 build_road [950] + 0.00 0.00 5/15102 follow_unit [331] + 0.00 0.00 5/15102 leave_cmd [721] + 0.00 0.00 6/15102 enter_ship [733] + 0.00 0.00 16/15102 reshow_other [823] + 0.00 0.00 22/15102 herbsearch [493] + 0.00 0.00 22/15102 create_item [617] + 0.00 0.00 22/15102 destroy_cmd [1113] + 0.00 0.00 24/15102 do_work [612] + 0.00 0.00 27/15102 combatspell_cmd [898] + 0.00 0.00 31/15102 build_building [696] + 0.00 0.00 32/15102 start_battle [297] + 0.00 0.00 36/15102 entertain_cmd [665] + 0.00 0.00 46/15102 recruit [650] + 0.00 0.00 61/15102 ship_ready [354] + 0.00 0.00 72/15102 renumber_cmd [780] + 0.00 0.00 105/15102 travel_i [92] + 0.00 0.00 107/15102 ally_cmd [877] + 0.00 0.00 112/15102 sail [181] + 0.00 0.00 139/15102 allocate_resource [752] + 0.00 0.00 154/15102 buy [707] + 0.00 0.00 160/15102 follow_ship [749] + 0.00 0.00 163/15102 movement [47] + 0.00 0.00 182/15102 use_cmd [763] + 0.00 0.00 199/15102 continue_ship [813] + 0.00 0.00 234/15102 study_cmd [105] + 0.00 0.00 965/15102 give_cmd [102] + 0.00 0.00 1141/15102 add_give [379] + 0.00 0.00 1178/15102 update_long_order [270] + 0.00 0.00 3277/15102 sell [498] + 0.00 0.00 6527/15102 guard_on_cmd [656] +[718] 0.0 0.00 0.00 15102 cmistake [718] + 0.00 0.00 15102/15240 msg_error [744] + 0.00 0.00 8797/392959 add_message [434] + 0.00 0.00 8797/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 3/178257 tolua_getkey [1281] + 0.00 0.00 178254/178257 tolua_region_getkey [628] +[719] 0.0 0.00 0.00 178257 key_get [719] + 0.00 0.00 178257/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 178254/178254 move_pirates [326] +[720] 0.0 0.00 0.00 178254 age_traveldir [720] + 0.00 0.00 178254/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 236/236 process [7] +[721] 0.0 0.00 0.00 236 leave_cmd [721] + 0.00 0.00 222/2887 leave [432] + 0.00 0.00 5/15102 cmistake [718] + 0.00 0.00 5/129167539 u_race [89] + 0.00 0.00 222/677 slipthru [1593] +----------------------------------------------- + 0.00 0.00 3/174968 cast_cmd [760] + 0.00 0.00 174965/174968 cr_output_unit [19] +[722] 0.0 0.00 0.00 174968 get_familiar_mage [722] + 0.00 0.00 174968/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 5966/5966 herbsearch [493] +[723] 0.0 0.00 0.00 5966 ntimespprob [723] + 0.00 0.00 83094/1336242 rng_injectable_double [396] +----------------------------------------------- + 0.00 0.00 5810/5810 report_donations [725] +[724] 0.0 0.00 0.00 5810 report_transfer [724] + 0.00 0.00 5810/967784 msg_message [132] + 0.00 0.00 11620/12265 r_addmessage [779] + 0.00 0.00 5810/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1/1 reports [2] +[725] 0.0 0.00 0.00 1 report_donations [725] + 0.00 0.00 5810/5810 report_transfer [724] +----------------------------------------------- + 0.00 0.00 1/9763 caldera_read [1270] + 0.00 0.00 1/9763 clonedied_read [1271] + 0.00 0.00 1/9763 giveitem_read [1262] + 0.00 0.00 2/9763 wormhole_read [1238] + 0.00 0.00 3/9763 changerace_read [1215] + 0.00 0.00 10/9763 changefaction_read [1166] + 0.00 0.00 760/9763 read_familiar [893] + 0.00 0.00 760/9763 read_magician [894] + 0.00 0.00 768/9763 shock_read [892] + 0.00 0.00 1138/9763 read_targetregion [870] + 0.00 0.00 2299/9763 killunit_read [817] + 0.00 0.00 4020/9763 curse_read [770] +[726] 0.0 0.00 0.00 9763 read_reference [726] + 0.00 0.00 7102/11989 resolve_unit [703] + 0.00 0.00 760/1202 resolve_familiar [846] + 0.00 0.00 760/1078 resolve_mage [856] + 0.00 0.00 8622/8622 read_unit_reference [1521] + 0.00 0.00 3693/34565 ur_add [1472] + 0.00 0.00 1140/1140 read_region_reference [1582] + 0.00 0.00 1140/1466 resolve_region_id [1575] + 0.00 0.00 1/1 read_building_reference [1831] + 0.00 0.00 1/1 resolve_building [1862] +----------------------------------------------- + 0.00 0.00 3/7957 target_resists_magic [1154] + 0.00 0.00 16/7957 damage_unit [1044] + 0.00 0.00 7938/7957 calculate_armor [645] +[727] 0.0 0.00 0.00 7957 magic_resistance [727] + 0.00 0.00 7957/12320804 effskill [100] + 0.00 0.00 7957/71815034 get_race [12] + 0.00 0.00 7957/5395063 i_get [130] + 0.00 0.00 8573/12246335 ct_find [114] + 0.00 0.00 7957/10190660 get_curse [143] + 0.00 0.00 7957/51974272 a_find [65] + 0.00 0.00 7957/129167539 u_race [89] + 0.00 0.00 7957/56052475 get_resourcetype [194] + 0.00 0.00 7957/18647447 getplane [596] + 0.00 0.00 7957/26995 inside_building [1486] + 0.00 0.00 7957/26164 building_is_active [1488] +----------------------------------------------- + 0.00 0.00 3438/3438 prepare_lighthouse [340] +[728] 0.0 0.00 0.00 3438 lighthouse_range [728] + 0.00 0.00 11409/593636 building_owner [232] + 0.00 0.00 3403/12320804 effskill [100] + 0.00 0.00 3387/21345834 skill_enabled [365] + 0.00 0.00 3387/19671 buildingcapacity [1500] +----------------------------------------------- + 0.00 0.00 25857/25857 parse_symbol [42] +[729] 0.0 0.00 0.00 25857 eval_int36 [729] + 0.00 0.00 25857/5100840 itoa36 [116] + 0.00 0.00 25857/13102790 opstack_pop [176] + 0.00 0.00 25857/13102790 opstack_push [202] + 0.00 0.00 25857/13399069 balloc [363] +----------------------------------------------- + 0.00 0.00 22/45 report_computer [9] + 0.00 0.00 23/45 report_plaintext [4] +[730] 0.0 0.00 0.00 45 count_maxmigrants [730] + 0.00 0.00 45/967 count_all [357] + 0.00 0.00 45/5065285 get_param_int [422] +----------------------------------------------- + 0.00 0.00 22/45 report_computer [9] + 0.00 0.00 23/45 report_plaintext [4] +[731] 0.0 0.00 0.00 45 count_migrants [731] + 0.00 0.00 45/2247 count_faction [219] +----------------------------------------------- + 0.00 0.00 2081/2081 nr_spell [507] +[732] 0.0 0.00 0.00 2081 nr_spell_syntax [732] + 0.00 0.00 2081/2742237 paragraph [26] + 0.00 0.00 4762/24887945 locale_string [27] + 0.00 0.00 2081/86400 spell_name [646] + 0.00 0.00 2622/34611296 strlcpy [45] + 0.00 0.00 7912/36653945 wrptr [178] + 0.00 0.00 140/4133717 mkname [261] + 0.00 0.00 2081/2009097 keyword [1355] +----------------------------------------------- + 0.00 0.00 222/222 do_enter [128] +[733] 0.0 0.00 0.00 222 enter_ship [733] + 0.00 0.00 191/2887 leave [432] + 0.00 0.00 195/195 mayboard [1046] + 0.00 0.00 191/191 CheckOverload [1180] + 0.00 0.00 6/15102 cmistake [718] + 0.00 0.00 222/129167539 u_race [89] + 0.00 0.00 222/28818 findship [1483] + 0.00 0.00 191/27640 u_set_ship [1485] +----------------------------------------------- + 0.00 0.00 41255/41255 copy_arg [521] +[734] 0.0 0.00 0.00 41255 var_copy_order [734] + 0.00 0.00 41255/635885 copy_order [441] +----------------------------------------------- + 0.00 0.00 2/191379 claim_cmd [1242] + 0.00 0.00 103/191379 reshow_other [823] + 0.00 0.00 590/191379 use_cmd [763] + 0.00 0.00 4259/191379 make_cmd [383] + 0.00 0.00 5762/191379 buy [707] + 0.00 0.00 15731/191379 sell [498] + 0.00 0.00 71364/191379 reserve_i [213] + 0.00 0.00 93568/191379 give_cmd [102] +[735] 0.0 0.00 0.00 191379 finditemtype [735] + 0.00 0.00 191379/4457785 transliterate [358] + 0.00 0.00 191379/2124526 locale_index [1354] +----------------------------------------------- + 0.00 0.00 32/115276 travel_i [92] + 0.00 0.00 74/115276 init_transportation [384] + 0.00 0.00 474/115276 follow_ship [749] + 0.00 0.00 475/115276 move_hunters [342] + 0.00 0.00 519/115276 follow_unit [331] + 0.00 0.00 113702/115276 movement [47] +[736] 0.0 0.00 0.00 115276 can_move [736] + 0.00 0.00 115276/116002 get_movement [750] + 0.00 0.00 115276/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 36/178290 move_iceberg [1094] + 0.00 0.00 178254/178290 new_region [275] +[737] 0.0 0.00 0.00 178290 rhash [737] + 0.00 0.00 178290/2903884 jenkins_hash [439] +----------------------------------------------- + 0.00 0.00 189341/189341 produce [29] +[738] 0.0 0.00 0.00 189341 rule_autowork [738] + 0.00 0.00 189341/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 2665/2665 read_unitid [413] +[739] 0.0 0.00 0.00 2665 read_newunitid [739] + 0.00 0.00 2665/2665 findnewunit [753] + 0.00 0.00 2665/228907 getid [483] +----------------------------------------------- + 0.00 0.00 19545/19545 parse_symbol [42] +[740] 0.0 0.00 0.00 19545 eval_ship [740] + 0.00 0.00 14502/1065211 shipname [290] + 0.00 0.00 5043/24887945 locale_string [27] + 0.00 0.00 19545/13102790 opstack_pop [176] + 0.00 0.00 19545/13102790 opstack_push [202] + 0.00 0.00 19545/13399069 balloc [363] +----------------------------------------------- + 0.00 0.00 177/177 produce [29] +[741] 0.0 0.00 0.00 177 breed_cmd [741] + 0.00 0.00 174/174 breedhorses [742] + 0.00 0.00 179/2281756 gettoken [195] + 0.00 0.00 2/2 breedtrees [1148] + 0.00 0.00 176/1787006 findparam [458] + 0.00 0.00 177/1027665 init_order [613] + 0.00 0.00 174/174 findresourcetype [1181] + 0.00 0.00 1/1 plant [1184] + 0.00 0.00 521/56052475 get_resourcetype [194] +----------------------------------------------- + 0.00 0.00 174/174 breed_cmd [741] +[742] 0.0 0.00 0.00 174 breedhorses [742] + 0.00 0.00 60896/7641081 genrand_int31 [171] + 0.00 0.00 12859/11241829 i_change [115] + 0.00 0.00 170/967784 msg_message [132] + 0.00 0.00 170/472418 produceexp [322] + 0.00 0.00 170/12320804 effskill [100] + 0.00 0.00 170/392959 add_message [434] + 0.00 0.00 170/5395063 i_get [130] + 0.00 0.00 174/424669 active_building [560] + 0.00 0.00 4/15102 cmistake [718] + 0.00 0.00 174/56052475 get_resourcetype [194] + 0.00 0.00 1/560926 bt_find [237] + 0.00 0.00 174/204314 bt_changed [1415] + 0.00 0.00 170/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 178254/178254 process [7] +[743] 0.0 0.00 0.00 178254 split_allocations [743] + 0.00 0.00 2938/967784 msg_message [132] + 0.00 0.00 2825/472418 produceexp [322] + 0.00 0.00 2938/392959 add_message [434] + 0.00 0.00 1301/1301 leveled_allocation [888] + 0.00 0.00 1422/1422 attrib_allocation [914] + 0.00 0.00 2825/11241829 i_change [115] + 0.00 0.00 2723/2723 get_allocator [1001] + 0.00 0.00 2723/9298667 resource2item [546] + 0.00 0.00 2938/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 19/15240 give_men [857] + 0.00 0.00 119/15240 syntax_error [1036] + 0.00 0.00 15102/15240 cmistake [718] +[744] 0.0 0.00 0.00 15240 msg_error [744] + 0.00 0.00 8935/41248 msg_feedback [647] +----------------------------------------------- + 0.00 0.00 552/18788 aftermath [701] + 0.00 0.00 7058/18788 battle_report [503] + 0.00 0.00 11178/18788 print_stats [525] +[745] 0.0 0.00 0.00 18788 sideabkz [745] + 0.00 0.00 18788/5100840 itoa36 [116] + 0.00 0.00 18788/34611296 strlcpy [45] +----------------------------------------------- + +[746] 0.0 0.00 0.00 tolua_unit_get_race [746] + 0.00 0.00 420172/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 417577/417577 study_cmd [105] +[747] 0.0 0.00 0.00 417577 study_days [747] + 0.00 0.00 417577/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 36937/163027 cr_output_region [10] + 0.00 0.00 62581/163027 report_plaintext [4] + 0.00 0.00 63509/163027 statistics [70] +[748] 0.0 0.00 0.00 163027 markets_module [748] + 0.00 0.00 163027/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 475/475 move_hunters [342] +[749] 0.0 0.00 0.00 475 follow_ship [749] + 0.00 0.00 191/103784 move_cmd [66] + 0.00 0.00 1188/24887945 locale_string [27] + 0.00 0.00 1612/17451017 strlcpy_w [67] + 0.00 0.00 474/228907 getid [483] + 0.00 0.00 160/15102 cmistake [718] + 0.00 0.00 1284/1297 hunted_dir [1055] + 0.00 0.00 191/66134 shipspeed [669] + 0.00 0.00 191/16751 getuint [778] + 0.00 0.00 191/54318 getstrtoken [710] + 0.00 0.00 474/115276 can_move [736] + 0.00 0.00 475/3358315 ship_owner [438] + 0.00 0.00 191/1311302 init_tokens_str [544] + 0.00 0.00 191/36653945 wrptr [178] + 0.00 0.00 191/5461936 slprintf [548] + 0.00 0.00 283/28818 findship [1483] + 0.00 0.00 191/2009097 keyword [1355] +----------------------------------------------- + 0.00 0.00 240/116002 canfly [1031] + 0.00 0.00 486/116002 canswim [682] + 0.00 0.00 115276/116002 can_move [736] +[750] 0.0 0.00 0.00 116002 get_movement [750] + 0.00 0.00 116002/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 5907/5907 msg_curse [664] +[751] 0.0 0.00 0.00 5907 cinfo_simple [751] + 0.00 0.00 5907/967784 msg_message [132] + 0.00 0.00 5907/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 3078/3078 create_item [617] +[752] 0.0 0.00 0.00 3078 allocate_resource [752] + 0.00 0.00 36821/6610983 is_guard [211] + 0.00 0.00 2939/12320804 effskill [100] + 0.00 0.00 81/81 can_guard [908] + 0.00 0.00 2938/5395063 i_get [130] + 0.00 0.00 2938/2858912 get_effect [225] + 0.00 0.00 1709/3123 limit_resource [943] + 0.00 0.00 3078/51974272 a_find [65] + 0.00 0.00 139/15102 cmistake [718] + 0.00 0.00 2366/2032164 rt_find [597] + 0.00 0.00 5877/56052475 get_resourcetype [194] + 0.00 0.00 2943/8506411 besieged [547] + 0.00 0.00 3078/9298667 resource2item [546] + 0.00 0.00 1289/129167539 u_race [89] + 0.00 0.00 1/41248 msg_feedback [647] + 0.00 0.00 7/2977 change_effect [982] + 0.00 0.00 1/392959 add_message [434] + 0.00 0.00 2938/3003 roqf_factor [1329] + 0.00 0.00 5920/26995 inside_building [1486] + 0.00 0.00 5920/26164 building_is_active [1488] + 0.00 0.00 23/30 limit_seeds [1691] + 0.00 0.00 1/2 limit_mallornseeds [1775] +----------------------------------------------- + 0.00 0.00 2665/2665 read_newunitid [739] +[753] 0.0 0.00 0.00 2665 findnewunit [753] + 0.00 0.00 110903/285923 ualias [692] +----------------------------------------------- + 0.00 0.00 417554/417554 plan_monsters [52] +[754] 0.0 0.00 0.00 417554 random_move_chance [754] + 0.00 0.00 417554/717218 config_get_flt [714] +----------------------------------------------- + 0.00 0.00 443/5358 change_maxspellpoints [911] + 0.00 0.00 1334/5358 bufunit [17] + 0.00 0.00 1711/5358 cr_output_unit [19] + 0.00 0.00 1870/5358 regenerate_aura [346] +[755] 0.0 0.00 0.00 5358 max_spellpoints [755] + 0.00 0.00 5358/12320804 effskill [100] + 0.00 0.00 5358/5358 get_spchange [862] + 0.00 0.00 5358/5395063 i_get [130] + 0.00 0.00 5358/12246335 ct_find [114] + 0.00 0.00 5358/10190660 get_curse [143] + 0.00 0.00 5358/2032164 rt_find [597] + 0.00 0.00 5358/129167539 u_race [89] + 0.00 0.00 5358/651711 oldcursename [1381] + 0.00 0.00 5358/432940 curse_geteffect [1395] +----------------------------------------------- + 0.00 0.00 2081/2081 report_computer [9] +[756] 0.0 0.00 0.00 2081 cr_reportspell [756] + 0.00 0.00 5284/4434556 translate [75] + 0.00 0.00 3203/24887945 locale_string [27] + 0.00 0.00 2081/86400 spell_name [646] + 0.00 0.00 2081/4162 spell_info [841] + 0.00 0.00 2081/32337529 hashstring [37] + 0.00 0.00 2081/4133717 mkname [261] + 0.00 0.00 3203/13259934 resourcename [233] +----------------------------------------------- + 0.00 0.00 1/1 read_game [62] +[757] 0.0 0.00 0.00 1 resolve [757] + 0.00 0.00 2607/11989 resolve_unit [703] + 0.00 0.00 30872/30872 resolve_faction [820] + 0.00 0.00 442/1202 resolve_familiar [846] + 0.00 0.00 318/1078 resolve_mage [856] + 0.00 0.00 326/1466 resolve_region_id [1575] +----------------------------------------------- + 0.00 0.00 37/365 combatspell_cmd [898] + 0.00 0.00 103/365 reshow_other [823] + 0.00 0.00 225/365 cast_cmd [760] +[758] 0.0 0.00 0.00 365 unit_getspell [758] + 0.00 0.00 255/255 select_spellbook [761] + 0.00 0.00 365/597806 unit_get_spellbook [427] + 0.00 0.00 255/302482 findtoken [501] + 0.00 0.00 255/267 freetokens [1611] +----------------------------------------------- + 0.00 0.00 377/377 create_item [617] +[759] 0.0 0.00 0.00 377 manufacture [759] + 0.00 0.00 377/1239 build [691] + 0.00 0.00 306/967784 msg_message [132] + 0.00 0.00 377/12320804 effskill [100] + 0.00 0.00 377/12320804 skillmod [214] + 0.00 0.00 377/392959 add_message [434] + 0.00 0.00 71/182 msg_materials_required [1005] + 0.00 0.00 306/11241829 i_change [115] + 0.00 0.00 377/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 222/222 magic [157] +[760] 0.0 0.00 0.00 222 cast_cmd [760] + 0.00 0.00 225/365 unit_getspell [758] + 0.00 0.00 220/220 farcasting [842] + 0.00 0.00 329/12320804 effskill [100] + 0.00 0.00 221/482 knowsspell [956] + 0.00 0.00 395/2281756 gettoken [195] + 0.00 0.00 220/303 create_castorder [1066] + 0.00 0.00 108/57138 getint [699] + 0.00 0.00 322/1787006 findparam [458] + 0.00 0.00 222/1027665 init_order [613] + 0.00 0.00 26/26 add_spellparameter [1173] + 0.00 0.00 222/1629412 LongHunger [536] + 0.00 0.00 24/24 is_moving_ship [1231] + 0.00 0.00 5/459083 findregion [420] + 0.00 0.00 1/967784 msg_message [132] + 0.00 0.00 227/18647447 getplane [596] + 0.00 0.00 3/71815034 get_race [12] + 0.00 0.00 1/15102 cmistake [718] + 0.00 0.00 3/298951 distance [599] + 0.00 0.00 1/392959 add_message [434] + 0.00 0.00 4/793 is_familiar [1092] + 0.00 0.00 3/174968 get_familiar_mage [722] + 0.00 0.00 4/129167539 u_race [89] + 0.00 0.00 10/10 rel_to_abs [1728] + 0.00 0.00 5/3587241 pnormalize [1350] + 0.00 0.00 3/1291427 set_order [1365] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 255/255 unit_getspell [758] +[761] 0.0 0.00 0.00 255 select_spellbook [761] + 0.00 0.00 8557/86400 spell_name [646] + 0.00 0.00 8557/8993 addtoken [811] +----------------------------------------------- + 0.00 0.00 232/232 write_game [83] +[762] 0.0 0.00 0.00 232 writefaction [762] + 0.00 0.00 5926/1205451 alliedfaction [162] + 0.00 0.00 232/11719 locale_name [568] + 0.00 0.00 232/232 write_groups [920] + 0.00 0.00 232/1248014 listlen [190] + 0.00 0.00 232/839970 write_attribs [301] + 0.00 0.00 232/629123 write_items [511] + 0.00 0.00 232/647569 write_faction_reference [1382] + 0.00 0.00 232/232 write_password [1623] + 0.00 0.00 232/2321 write_spellbook [1556] +----------------------------------------------- + 0.00 0.00 590/590 process [7] +[763] 0.0 0.00 0.00 590 use_cmd [763] + 0.00 0.00 590/590 use_item [765] + 0.00 0.00 900/2281756 gettoken [195] + 0.00 0.00 182/15102 cmistake [718] + 0.00 0.00 590/1027665 init_order [613] + 0.00 0.00 590/191379 finditemtype [735] + 0.00 0.00 280/534930 isparam [668] +----------------------------------------------- + 0.00 0.00 752/752 monster_attacks [248] +[764] 0.0 0.00 0.00 752 monster_attack [764] + 0.00 0.00 752/1437425 cansee [22] + 0.00 0.00 736/447808 create_order [341] + 0.00 0.00 752/1121103 monster_is_waiting [407] +----------------------------------------------- + 0.00 0.00 590/590 use_cmd [763] +[765] 0.0 0.00 0.00 590 use_item [765] + 0.00 0.00 348/348 use_potion [801] + 0.00 0.00 590/541982 get_pooled [104] + 0.00 0.00 56/56 use_bloodpotion [935] + 0.00 0.00 3/3 use_healingpotion [1119] + 0.00 0.00 1/860263 use_pooled [39] + 0.00 0.00 1/1 use_skillpotion [1233] +----------------------------------------------- + 0.00 0.00 111/111 produce [29] +[766] 0.0 0.00 0.00 111 steal_cmd [766] + 0.00 0.00 46/3016 dfindhash [307] + 0.00 0.00 84/1437425 cansee [22] + 0.00 0.00 110/145 findunitr [991] + 0.00 0.00 65/65 max_skill [1037] + 0.00 0.00 111/284005 read_unitid [413] + 0.00 0.00 46/41248 msg_feedback [647] + 0.00 0.00 59/760673 addlist [217] + 0.00 0.00 30/967784 msg_message [132] + 0.00 0.00 65/12320804 effskill [100] + 0.00 0.00 59/472418 produceexp [322] + 0.00 0.00 76/392959 add_message [434] + 0.00 0.00 118/5395063 i_get [130] + 0.00 0.00 111/1027665 init_order [613] + 0.00 0.00 15/71815034 get_race [12] + 0.00 0.00 65/16669 IsImmune [901] + 0.00 0.00 111/111 check_steal [1234] + 0.00 0.00 222/21345834 skill_enabled [365] + 0.00 0.00 111/56052475 get_resourcetype [194] + 0.00 0.00 15/129167539 u_race [89] + 0.00 0.00 4/3003 roqf_factor [1329] + 0.00 0.00 76/1009028 msg_release [1373] + 0.00 0.00 65/192 can_contact [1634] +----------------------------------------------- + 0.00 0.00 233/233 read_game [62] +[767] 0.0 0.00 0.00 233 readfaction [767] + 0.00 0.00 233/233 read_groups [782] + 0.00 0.00 5925/5925 addally [913] + 0.00 0.00 406/406 faction_setorigin [979] + 0.00 0.00 233/628037 read_items [320] + 0.00 0.00 233/5100840 itoa36 [116] + 0.00 0.00 233/68430117 rc_find [15] + 0.00 0.00 233/840577 read_attribs [388] + 0.00 0.00 233/5588 get_locale [884] + 0.00 0.00 233/4625636 findfaction [259] + 0.00 0.00 233/457 FactionSpells [1136] + 0.00 0.00 233/49235 log_debug [1245] + 0.00 0.00 233/1613387 rule_region_owners [1323] + 0.00 0.00 233/233 set_email [1620] + 0.00 0.00 233/233 read_password [1619] + 0.00 0.00 233/2324 read_spellbook [1555] +----------------------------------------------- + 0.00 0.00 3152/3152 scared_by_monster [380] +[768] 0.0 0.00 0.00 3152 scareaway [768] + 0.00 0.00 33436/7641081 genrand_int31 [171] + 0.00 0.00 2656/369586 r_connect [474] + 0.00 0.00 3152/264251 rsetpeasants [545] + 0.00 0.00 6569/2605004 rpeasants [435] +----------------------------------------------- + 0.00 0.00 3246/7630 split_paragraph [828] + 0.00 0.00 4384/7630 lparagraph [809] +[769] 0.0 0.00 0.00 7630 addstrlist [769] + 0.00 0.00 7630/760673 addlist [217] +----------------------------------------------- + 0.00 0.00 4020/4020 a_read_i [390] +[770] 0.0 0.00 0.00 4020 curse_read [770] + 0.00 0.00 4020/9763 read_reference [726] + 0.00 0.00 4020/12246335 ct_find [114] + 0.00 0.00 4020/4052 chash [1537] + 0.00 0.00 4/4 read_skill [1759] +----------------------------------------------- + 0.00 0.00 2/2 json_disable_features [772] +[771] 0.0 0.00 0.00 2 disable_feature [771] + 0.00 0.00 1/30 config_set [444] + 0.00 0.00 1/64 log_info [1339] + 0.00 0.00 1/49235 log_debug [1245] + 0.00 0.00 2/1041 findskill [1586] + 0.00 0.00 2/65 findkeyword [1665] + 0.00 0.00 1/1 enable_keyword [1801] +----------------------------------------------- + 0.00 0.00 1/1 json_config [464] +[772] 0.0 0.00 0.00 1 json_disable_features [772] + 0.00 0.00 2/2 disable_feature [771] +----------------------------------------------- + +[773] 0.0 0.00 0.00 tolua_settings_eressea_settings_set00 [773] + 0.00 0.00 1/30 config_set [444] +----------------------------------------------- + 0.00 0.00 2/2457 sp_summonshadowlords [1034] + 0.00 0.00 6/2457 tolua_unit_setskill [1163] + 0.00 0.00 12/2457 forget_cmd [1093] + 0.00 0.00 26/2457 demon_skillchange [826] + 0.00 0.00 38/2457 sp_viewreality [784] + 0.00 0.00 54/2457 skill_summoned [1032] + 0.00 0.00 828/2457 spawn_undead [629] + 0.00 0.00 1491/2457 equip_unit_mask [776] +[774] 0.0 0.00 0.00 2457 set_level [774] + 0.00 0.00 2445/47535 sk_set [510] + 0.00 0.00 2419/1956810 add_skill [355] + 0.00 0.00 2457/21345834 skill_enabled [365] + 0.00 0.00 12/51060 remove_skill [1456] +----------------------------------------------- + 0.00 0.00 1/2375 oldfamiliars [1240] + 0.00 0.00 10/2375 spawn_dragons [411] + 0.00 0.00 17/2375 recruit_dracoids [837] + 0.00 0.00 20/2375 spawn_seaserpent [831] + 0.00 0.00 21/2375 spawn_undead [629] + 0.00 0.00 639/2375 spawn_braineaters [505] + 0.00 0.00 1667/2375 add_recruits [371] +[775] 0.0 0.00 0.00 2375 equip_unit [775] + 0.00 0.00 2375/2375 equip_unit_mask [776] +----------------------------------------------- + 24 equip_unit_mask [776] + 0.00 0.00 2375/2375 equip_unit [775] +[776] 0.0 0.00 0.00 2375+24 equip_unit_mask [776] + 0.00 0.00 1491/2457 set_level [774] + 0.00 0.00 1560/146997 dice_rand [409] + 0.00 0.00 30/1381157 unit_max_hp [136] + 0.00 0.00 38/752645 chance [495] + 0.00 0.00 24/7641081 genrand_int31 [171] + 0.00 0.00 60/822780 i_new [1375] + 0.00 0.00 60/87004 i_add [1442] + 24 equip_unit_mask [776] +----------------------------------------------- + 0.00 0.00 162/786 report_computer [9] + 0.00 0.00 162/786 report_plaintext [4] + 0.00 0.00 462/786 score [23] +[777] 0.0 0.00 0.00 786 average_score_of_age [777] + 0.00 0.00 18304/71815034 get_race [12] +----------------------------------------------- + 0.00 0.00 191/16751 follow_ship [749] + 0.00 0.00 16560/16751 entertain_cmd [665] +[778] 0.0 0.00 0.00 16751 getuint [778] + 0.00 0.00 16751/57138 getint [699] +----------------------------------------------- + 0.00 0.00 1/12265 report_spell [1301] + 0.00 0.00 1/12265 caddmessage [1070] + 0.00 0.00 2/12265 sp_viewreality [784] + 0.00 0.00 4/12265 sp_generous [1040] + 0.00 0.00 5/12265 sp_eternizewall [988] + 0.00 0.00 12/12265 sp_enterastral [1045] + 0.00 0.00 13/12265 sp_goodwinds [974] + 0.00 0.00 30/12265 sp_song_of_peace [939] + 0.00 0.00 76/12265 sp_stormwinds [871] + 0.00 0.00 206/12265 report_action [860] + 0.00 0.00 295/12265 maintain_buildings [339] + 0.00 0.00 11620/12265 report_transfer [724] +[779] 0.0 0.00 0.00 12265 r_addmessage [779] + 0.00 0.00 12265/392959 add_message [434] +----------------------------------------------- + 0.00 0.00 138/138 process [7] +[780] 0.0 0.00 0.00 138 renumber_cmd [780] + 0.00 0.00 43/2818 newunitid [319] + 0.00 0.00 250/2281756 gettoken [195] + 0.00 0.00 38/221899 findunitg [279] + 0.00 0.00 72/15102 cmistake [718] + 0.00 0.00 26/593636 building_owner [232] + 0.00 0.00 69/688711 atoi36 [440] + 0.00 0.00 55/55 renumber_unit [1159] + 0.00 0.00 138/6530 findparam_ex [926] + 0.00 0.00 138/1027665 init_order [613] + 0.00 0.00 31/3358315 ship_owner [438] + 0.00 0.00 38/3002 forbiddenid [1280] + 0.00 0.00 31/28818 findship [1483] + 0.00 0.00 27/48455 findbuilding [1462] + 0.00 0.00 10/12 bunhash [1720] + 0.00 0.00 10/46196 bhash [1464] + 0.00 0.00 1/7 sunhash [1744] + 0.00 0.00 1/19085 shash [1502] +----------------------------------------------- + 0.00 0.00 120/120 demographics [50] +[781] 0.0 0.00 0.00 120 plagues [781] + 0.00 0.00 25985/1336242 rng_injectable_double [396] + 0.00 0.00 12922/4666665 rmoney [452] + 0.00 0.00 6459/2186159 rsetmoney [553] + 0.00 0.00 120/967784 msg_message [132] + 0.00 0.00 120/392959 add_message [434] + 0.00 0.00 120/264251 rsetpeasants [545] + 0.00 0.00 120/2605004 rpeasants [435] + 0.00 0.00 120/37974 deathcounts [843] + 0.00 0.00 120/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 233/233 readfaction [767] +[782] 0.0 0.00 0.00 233 read_groups [782] + 0.00 0.00 49522/4625636 findfaction [259] + 0.00 0.00 1694/840577 read_attribs [388] + 0.00 0.00 51216/51239 read_faction_reference [1455] + 0.00 0.00 49522/55547 ally_add [1452] + 0.00 0.00 27921/34565 ur_add [1472] + 0.00 0.00 1694/1697 new_group [1565] +----------------------------------------------- + 0.00 0.00 8892/8892 astralregions [329] +[783] 0.0 0.00 0.00 8892 r_astral_to_standard [783] + 0.00 0.00 8892/459083 findregion [420] + 0.00 0.00 8892/987488 is_astral [479] + 0.00 0.00 8865/18647447 getplane [596] + 0.00 0.00 8892/3587241 pnormalize [1350] +----------------------------------------------- + 0.00 0.00 2/2 magic [157] +[784] 0.0 0.00 0.00 2 sp_viewreality [784] + 0.00 0.00 38/2889 create_unit [296] + 0.00 0.00 38/2457 set_level [774] + 0.00 0.00 2/8892 astralregions [329] + 0.00 0.00 38/71815034 get_race [12] + 0.00 0.00 34/12246335 ct_find [114] + 0.00 0.00 34/10190660 get_curse [143] + 0.00 0.00 2/967784 msg_message [132] + 0.00 0.00 2/12265 r_addmessage [779] + 0.00 0.00 34/4201030 curse_active [543] + 0.00 0.00 2/3 getplaneid [1337] + 0.00 0.00 34/651711 oldcursename [1381] + 0.00 0.00 2/608 co_get_region [1594] + 0.00 0.00 2/109377 free_regionlist [1436] + 0.00 0.00 2/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 112/112 attack [84] +[785] 0.0 0.00 0.00 112 attack_firesword [785] + 0.00 0.00 580/80630 terminate [242] + 0.00 0.00 580/372173 select_enemy [172] + 0.00 0.00 18/1486 message_all [834] + 0.00 0.00 18/967784 msg_message [132] + 0.00 0.00 112/7641081 genrand_int31 [171] + 0.00 0.00 112/876979 count_enemies [611] + 0.00 0.00 18/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 39926/39926 sail [181] +[786] 0.0 0.00 0.00 39926 check_leuchtturm [786] + 0.00 0.00 35539/51974272 a_find [65] + 0.00 0.00 24025/1106528 is_building_type [554] + 0.00 0.00 23237/21345834 skill_enabled [365] +----------------------------------------------- + 0.00 0.00 27694/27694 dragon_affinity_value [516] +[787] 0.0 0.00 0.00 27694 dice [787] + 0.00 0.00 41004/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 80630/80630 calculate_armor [645] +[788] 0.0 0.00 0.00 80630 natural_armor [788] + 0.00 0.00 80630/80630 armor_bonus [819] + 0.00 0.00 80630/129167539 u_race [89] +----------------------------------------------- + 3246 centre [789] + 0.00 0.00 229/37931 list_address [635] + 0.00 0.00 816/37931 rp_battles [618] + 0.00 0.00 2081/37931 nr_spell [507] + 0.00 0.00 3437/37931 report_plaintext [4] + 0.00 0.00 31368/37931 rp_messages [36] +[789] 0.0 0.00 0.00 37931+3246 centre [789] + 0.00 0.00 946/946 sparagraph [827] + 0.00 0.00 40231/7851812 write_spaces [303] + 0.00 0.00 946/5330 freestrlist [1534] + 3246 centre [789] +----------------------------------------------- + 0.00 0.00 1/1 tolua_read_xml [792] +[790] 0.0 0.00 0.00 1 init_data [790] + 0.00 0.00 1/1 read_xml [791] + 0.00 0.00 1/5 reset_locales [1751] +----------------------------------------------- + 0.00 0.00 1/1 init_data [790] +[791] 0.0 0.00 0.00 1 read_xml [791] + 0.00 0.00 1/1 parse_messages [832] + 0.00 0.00 1/1 parse_strings [864] + 0.00 0.00 1/1 parse_resources [1086] + 0.00 0.00 1/1 parse_races [1104] + 0.00 0.00 1/1 parse_spells [1120] + 0.00 0.00 1/1 parse_buildings [1131] + 0.00 0.00 1/1 parse_equipment [1170] + 0.00 0.00 1/1 parse_calendar [1252] + 0.00 0.00 1/1 parse_ships [1305] + 0.00 0.00 1/1 parse_spellbooks [1827] + 0.00 0.00 1/1 parse_rules [1826] +----------------------------------------------- + +[792] 0.0 0.00 0.00 tolua_read_xml [792] + 0.00 0.00 1/1 init_data [790] +----------------------------------------------- + 0.00 0.00 216069/216069 config_token [794] +[793] 0.0 0.00 0.00 216069 check_param [793] + 0.00 0.00 216069/26776263 get_param [235] +----------------------------------------------- + 0.00 0.00 1/216069 prepare_report [8] + 0.00 0.00 6524/216069 maintain [478] + 0.00 0.00 209544/216069 building_owner_ex [253] +[794] 0.0 0.00 0.00 216069 config_token [794] + 0.00 0.00 216069/216069 check_param [793] +----------------------------------------------- + 0.00 0.00 96637/96637 walkingcapacity [403] +[795] 0.0 0.00 0.00 96637 personcapacity [795] + 0.00 0.00 193274/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 2/54351 sp_summon_familiar [1025] + 0.00 0.00 54349/54351 sm_familiar [520] +[796] 0.0 0.00 0.00 54351 get_familiar [796] + 0.00 0.00 54351/51974272 a_find [65] +----------------------------------------------- +[797] 0.0 0.00 0.00 1557+26 [797] + 0.00 0.00 1570 read_triggers [798] + 0.00 0.00 13 timeout_read [1719] +----------------------------------------------- + 13 timeout_read [1719] + 0.00 0.00 1557/1557 read_handler [799] +[798] 0.0 0.00 0.00 1570 read_triggers [798] + 0.00 0.00 2299/2299 killunit_read [817] + 0.00 0.00 768/768 shock_read [892] + 0.00 0.00 10/10 changefaction_read [1166] + 0.00 0.00 3/3 changerace_read [1215] + 0.00 0.00 1/1 giveitem_read [1262] + 0.00 0.00 1/1 caldera_read [1270] + 0.00 0.00 1/1 clonedied_read [1271] + 0.00 0.00 3096/3096 tt_find [1548] + 0.00 0.00 3096/3113 t_new [1546] + 13 timeout_read [1719] +----------------------------------------------- + 0.00 0.00 1557/1557 a_read_i [390] +[799] 0.0 0.00 0.00 1557 read_handler [799] + 0.00 0.00 1557/1557 read_triggers [798] +----------------------------------------------- + 0.00 0.00 1/45 sp_holyground [1068] + 0.00 0.00 1/45 sp_generous [1040] + 0.00 0.00 1/45 shipcurse_flyingship [1072] + 0.00 0.00 2/45 sp_charmingsong [993] + 0.00 0.00 3/45 sp_song_of_peace [939] + 0.00 0.00 3/45 sp_eternizewall [988] + 0.00 0.00 4/45 sp_goodwinds [974] + 0.00 0.00 13/45 sp_blessedharvest [847] + 0.00 0.00 17/45 sp_stormwinds [871] +[800] 0.0 0.00 0.00 45 create_curse [800] + 0.00 0.00 32/32 make_curse [802] + 0.00 0.00 45/10190660 get_curse [143] + 0.00 0.00 13/13 set_curseingmagician [1265] +----------------------------------------------- + 0.00 0.00 348/348 use_item [765] +[801] 0.0 0.00 0.00 348 use_potion [801] + 0.00 0.00 345/345 end_potion [814] + 0.00 0.00 345/345 do_potion [941] + 0.00 0.00 348/348 begin_potion [1096] + 0.00 0.00 348/1582 resource2potion [1569] +----------------------------------------------- + 0.00 0.00 32/32 create_curse [800] +[802] 0.0 0.00 0.00 32 make_curse [802] + 0.00 0.00 32/2818 newunitid [319] + 0.00 0.00 32/779419 a_add [555] + 0.00 0.00 32/779868 a_new [1376] + 0.00 0.00 32/4052 chash [1537] +----------------------------------------------- + 0.00 0.00 6/2931 make_undead_unit [1188] + 0.00 0.00 10/2931 spawn_dragons [411] + 0.00 0.00 17/2931 recruit_dracoids [837] + 0.00 0.00 92/2931 spawn_undead [629] + 0.00 0.00 2806/2931 create_unit [296] +[803] 0.0 0.00 0.00 2931 name_unit [803] + 0.00 0.00 2008/2008 default_name [851] + 0.00 0.00 923/1351796 racename [133] + 0.00 0.00 923/923 race_namegen [905] + 0.00 0.00 4777/129167539 u_race [89] + 0.00 0.00 2931/3862 unit_setname [1540] +----------------------------------------------- + 0.00 0.00 11540/11540 monster_kills_peasants [230] +[804] 0.0 0.00 0.00 11540 absorbed_by_monster [804] + 0.00 0.00 11540/7641081 genrand_int31 [171] + 0.00 0.00 681/967784 msg_message [132] + 0.00 0.00 2200/201744 lovar [644] + 0.00 0.00 681/392959 add_message [434] + 0.00 0.00 3455/2605004 rpeasants [435] + 0.00 0.00 681/264251 rsetpeasants [545] + 0.00 0.00 681/3178 scale_number [969] + 0.00 0.00 681/129167539 u_race [89] + 0.00 0.00 681/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 2/273 do_combatspell [702] + 0.00 0.00 5/273 do_combatmagic [825] + 0.00 0.00 74/273 cast_combatspell [623] + 0.00 0.00 192/273 magic [157] +[805] 0.0 0.00 0.00 273 pay_spell [805] + 0.00 0.00 470/860263 use_pooled [39] + 0.00 0.00 269/767 spellcost [995] + 0.00 0.00 273/56052475 get_resourcetype [194] +----------------------------------------------- + 0.00 0.00 66058/66058 shipspeed [669] +[806] 0.0 0.00 0.00 66058 ShipSpeedBonus [806] + 0.00 0.00 66058/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 41/41 produce [29] +[807] 0.0 0.00 0.00 41 expandstealing [807] + 0.00 0.00 41/10852 expandorders [197] + 0.00 0.00 38/860263 use_pooled [39] + 0.00 0.00 59/541982 get_pooled [104] + 0.00 0.00 59/34409 add_income [625] + 0.00 0.00 59/221899 findunitg [279] + 0.00 0.00 38/967784 msg_message [132] + 0.00 0.00 38/392959 add_message [434] + 0.00 0.00 38/2599554 change_money [337] + 0.00 0.00 41/56052475 get_resourcetype [194] + 0.00 0.00 40/18647447 getplane [596] + 0.00 0.00 38/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 88/88 get_food [88] +[808] 0.0 0.00 0.00 88 hunger [808] + 0.00 0.00 2491/146997 dice_rand [409] + 0.00 0.00 88/967784 msg_message [132] + 0.00 0.00 88/392959 add_message [434] + 0.00 0.00 88/88 hunger_damage [1223] + 0.00 0.00 27/3178 scale_number [969] + 0.00 0.00 88/129167539 u_race [89] + 0.00 0.00 27/37974 deathcounts [843] + 0.00 0.00 88/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 4384/4384 spunit [632] +[809] 0.0 0.00 0.00 4384 lparagraph [809] + 0.00 0.00 4384/7630 addstrlist [769] +----------------------------------------------- + 0.00 0.00 319/319 aftermath [701] +[810] 0.0 0.00 0.00 319 loot_items [810] + 0.00 0.00 1100/372173 select_enemy [172] + 0.00 0.00 2204/7641081 genrand_int31 [171] + 0.00 0.00 1091/1091 loot_quota [1013] + 0.00 0.00 1091/11241829 i_change [115] + 0.00 0.00 983/3902878 get_monsters [293] + 0.00 0.00 38/38 select_ally [1132] + 0.00 0.00 319/2913 dead_fighters [1549] +----------------------------------------------- + 178365 addtoken [811] + 0.00 0.00 2/8993 register_special_direction [1259] + 0.00 0.00 14/8993 findshiptype [869] + 0.00 0.00 22/8993 init_options_translation [1157] + 0.00 0.00 26/8993 init_directions [1143] + 0.00 0.00 36/8993 init_terrains_translation [1129] + 0.00 0.00 54/8993 findbuildingtype [866] + 0.00 0.00 282/8993 init_locale [948] + 0.00 0.00 8557/8993 select_spellbook [761] +[811] 0.0 0.00 0.00 8993+178365 addtoken [811] + 0.00 0.00 176717/46391457 unicode_utf8_to_ucs4 [177] + 0.00 0.00 141675/141675 mknode [1429] + 178365 addtoken [811] +----------------------------------------------- + 0.00 0.00 2274/2274 msg_curse [664] +[812] 0.0 0.00 0.00 2274 cinfo_ship [812] + 0.00 0.00 2274/967784 msg_message [132] + 0.00 0.00 2252/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 312/312 make_cmd [383] +[813] 0.0 0.00 0.00 312 continue_ship [813] + 0.00 0.00 113/115 build_ship [839] + 0.00 0.00 120/122 maxbuild [946] + 0.00 0.00 432/12320804 effskill [100] + 0.00 0.00 306/307 getship [1018] + 0.00 0.00 199/15102 cmistake [718] +----------------------------------------------- + 0.00 0.00 345/345 use_potion [801] +[814] 0.0 0.00 0.00 345 end_potion [814] + 0.00 0.00 345/860263 use_pooled [39] + 0.00 0.00 345/967784 msg_message [132] + 0.00 0.00 345/392959 add_message [434] + 0.00 0.00 345/404 usetpotionuse [1078] + 0.00 0.00 345/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 6/337987 update_guards [415] + 0.00 0.00 76/337987 guard_off_cmd [711] + 0.00 0.00 319/337987 aftermath [701] + 0.00 0.00 14191/337987 flee [638] + 0.00 0.00 23781/337987 guard [865] + 0.00 0.00 106892/337987 move_unit [421] + 0.00 0.00 192722/337987 travel_route [147] +[815] 0.0 0.00 0.00 337987 setguard [815] + 0.00 0.00 23509/51974272 a_find [65] + 0.00 0.00 23781/377253 guard_flags [690] +----------------------------------------------- + 0.00 0.00 36/36 produce [29] +[816] 0.0 0.00 0.00 36 expandloot [816] + 0.00 0.00 36/10852 expandorders [197] + 0.00 0.00 4800/2599554 change_money [337] + 0.00 0.00 42/34409 add_income [625] + 0.00 0.00 36/7641081 genrand_int31 [171] + 0.00 0.00 36/2186159 rsetmoney [553] + 0.00 0.00 36/4666665 rmoney [452] + 0.00 0.00 5/65345 region_get_morale [1444] +----------------------------------------------- + 0.00 0.00 2299/2299 read_triggers [798] +[817] 0.0 0.00 0.00 2299 killunit_read [817] + 0.00 0.00 2299/9763 read_reference [726] +----------------------------------------------- + 0.00 0.00 241/241 process [7] +[818] 0.0 0.00 0.00 241 reshow_cmd [818] + 0.00 0.00 241/241 reshow [822] + 0.00 0.00 241/2281756 gettoken [195] + 0.00 0.00 138/69432 getparam [681] + 0.00 0.00 241/1027665 init_order [613] + 0.00 0.00 241/534930 isparam [668] +----------------------------------------------- + 0.00 0.00 80630/80630 natural_armor [788] +[819] 0.0 0.00 0.00 80630 armor_bonus [819] + 0.00 0.00 80630/5065285 get_param_int [422] +----------------------------------------------- + 0.00 0.00 30872/30872 resolve [757] +[820] 0.0 0.00 0.00 30872 resolve_faction [820] + 0.00 0.00 30872/4625636 findfaction [259] +----------------------------------------------- + 0.00 0.00 149/149 create_item [617] +[821] 0.0 0.00 0.00 149 create_potion [821] + 0.00 0.00 149/1239 build [691] + 0.00 0.00 129/967784 msg_message [132] + 0.00 0.00 149/392959 add_message [434] + 0.00 0.00 20/182 msg_materials_required [1005] + 0.00 0.00 129/11241829 i_change [115] + 0.00 0.00 149/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 241/241 reshow_cmd [818] +[822] 0.0 0.00 0.00 241 reshow [822] + 0.00 0.00 104/104 reshow_other [823] + 0.00 0.00 327/328 display_potion [1090] + 0.00 0.00 22/12320804 effskill [100] + 0.00 0.00 115/178429 a_removeall [958] +----------------------------------------------- + 0.00 0.00 104/104 reshow [822] +[823] 0.0 0.00 0.00 104 reshow_other [823] + 0.00 0.00 103/365 unit_getspell [758] + 0.00 0.00 47/47 display_race [963] + 0.00 0.00 39/39 display_item [1054] + 0.00 0.00 103/338 findrace [1030] + 0.00 0.00 59/5395063 i_get [130] + 0.00 0.00 16/15102 cmistake [718] + 0.00 0.00 103/191379 finditemtype [735] + 0.00 0.00 19/283711 item2resource [561] + 0.00 0.00 48/129167539 u_race [89] + 0.00 0.00 1/451774 a_remove [366] + 0.00 0.00 1/328 display_potion [1090] + 0.00 0.00 1/51974272 a_find [65] + 0.00 0.00 19/1582 resource2potion [1569] +----------------------------------------------- + 0.00 0.00 1911/1911 msg_curse [664] +[824] 0.0 0.00 0.00 1911 cinfo_magicresistance [824] + 0.00 0.00 1911/967784 msg_message [132] + 0.00 0.00 1911/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 206/412 aftermath [701] + 0.00 0.00 206/412 do_battle [64] +[825] 0.0 0.00 0.00 412 do_combatmagic [825] + 0.00 0.00 2273/12320804 effskill [100] + 0.00 0.00 2/2 sp_igjarjuk [923] + 0.00 0.00 7/7 sp_healing [989] + 0.00 0.00 8/251 cancast [833] + 0.00 0.00 5/273 pay_spell [805] + 0.00 0.00 8/251 eff_spelllevel [845] + 0.00 0.00 51/1339 get_combatspelllevel [880] + 0.00 0.00 51/4875 get_combatspell [874] + 0.00 0.00 8/226 fumble [973] + 0.00 0.00 8/225 spellpower [1000] + 0.00 0.00 8/447808 create_order [341] + 0.00 0.00 8/86400 spell_name [646] + 0.00 0.00 1/3 report_failed_spell [1187] + 0.00 0.00 9/83 create_castorder_combat [1137] + 0.00 0.00 3708/3717 free_castorders [1541] + 0.00 0.00 16/11052 find_spell [1513] + 0.00 0.00 9/229 add_castorder [1626] + 0.00 0.00 8/1936876 free_order [1356] +----------------------------------------------- + 0.00 0.00 2148/2148 demon_skillchanges [246] +[826] 0.0 0.00 0.00 2148 demon_skillchange [826] + 0.00 0.00 18444/7641081 genrand_int31 [171] + 0.00 0.00 2190/892307 learn_skill [471] + 0.00 0.00 26/2457 set_level [774] + 0.00 0.00 1508/1583 reduce_skill [1091] + 0.00 0.00 12/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 946/946 centre [789] +[827] 0.0 0.00 0.00 946 sparagraph [827] + 0.00 0.00 946/946 split_paragraph [828] +----------------------------------------------- + 0.00 0.00 946/946 sparagraph [827] +[828] 0.0 0.00 0.00 946 split_paragraph [828] + 0.00 0.00 3246/7630 addstrlist [769] +----------------------------------------------- + 0.00 0.00 47562/47562 skill_weeks [509] +[829] 0.0 0.00 0.00 47562 rule_random_progress [829] + 0.00 0.00 47562/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 72692/72692 terminate [242] +[830] 0.0 0.00 0.00 72692 rc_specialdamage [830] + 0.00 0.00 117616/129167539 u_race [89] + 0.00 0.00 410/12560453 rc_changed [256] + 0.00 0.00 1/71815034 get_race [12] +----------------------------------------------- + 0.00 0.00 20/20 spawn_dragons [411] +[831] 0.0 0.00 0.00 20 spawn_seaserpent [831] + 0.00 0.00 20/2889 create_unit [296] + 0.00 0.00 20/2375 equip_unit [775] + 0.00 0.00 20/71815034 get_race [12] + 0.00 0.00 20/2742 get_equipment [1551] +----------------------------------------------- + 0.00 0.00 1/1 read_xml [791] +[832] 0.0 0.00 0.00 1 parse_messages [832] + 0.00 0.00 1909/1909 nrt_register [883] + 0.00 0.00 957/1010116 mt_find [227] + 0.00 0.00 1910/5354 xml_readtext [887] + 0.00 0.00 957/957 mt_register [1007] + 0.00 0.00 957/957 crt_register [1006] + 0.00 0.00 1909/8788 xml_cleanup_string [1520] + 0.00 0.00 957/957 mt_new [1588] +----------------------------------------------- + 0.00 0.00 8/251 do_combatmagic [825] + 0.00 0.00 23/251 do_combatspell [702] + 0.00 0.00 220/251 magic [157] +[833] 0.0 0.00 0.00 251 cancast [833] + 0.00 0.00 503/541982 get_pooled [104] + 0.00 0.00 251/482 knowsspell [956] + 0.00 0.00 251/12320804 effskill [100] + 0.00 0.00 249/767 spellcost [995] + 0.00 0.00 24/41248 msg_feedback [647] + 0.00 0.00 24/392959 add_message [434] + 0.00 0.00 251/56052475 get_resourcetype [194] + 0.00 0.00 24/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 2/1486 summon_allies [925] + 0.00 0.00 3/1486 report_failed_spell [1187] + 0.00 0.00 7/1486 sp_healing [989] + 0.00 0.00 18/1486 do_attack [80] + 0.00 0.00 18/1486 attack_firesword [785] + 0.00 0.00 21/1486 sp_kampfzauber [957] + 0.00 0.00 53/1486 sp_dragonodem [627] + 0.00 0.00 355/1486 print_stats [525] + 0.00 0.00 395/1486 reportcasualties [881] + 0.00 0.00 614/1486 print_fighters [616] +[834] 0.0 0.00 0.00 1486 message_all [834] + 0.00 0.00 5553/31214 message_faction [716] +----------------------------------------------- + 0.00 0.00 3117/3117 process [7] +[835] 0.0 0.00 0.00 3117 name_cmd [835] + 0.00 0.00 3117/2281756 gettoken [195] + 0.00 0.00 3114/54318 getstrtoken [710] + 0.00 0.00 3117/6530 findparam_ex [926] + 0.00 0.00 3117/1027665 init_order [613] + 0.00 0.00 5/593636 building_owner [232] + 0.00 0.00 4/4 try_rename [1225] + 0.00 0.00 2/15102 cmistake [718] + 0.00 0.00 10/3358315 ship_owner [438] + 0.00 0.00 5/490901 largestbuilding [651] + 0.00 0.00 5/5 get_cmp_region_owner [1347] + 0.00 0.00 3114/3114 rename_cmd [1545] +----------------------------------------------- + 0.00 0.00 6/41882 give_men [857] + 0.00 0.00 41876/41882 give_item [126] +[836] 0.0 0.00 0.00 41882 GiveRestriction [836] + 0.00 0.00 41882/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 17/17 plan_dragon [273] +[837] 0.0 0.00 0.00 17 recruit_dracoids [837] + 0.00 0.00 17/2889 create_unit [296] + 0.00 0.00 17/2375 equip_unit [775] + 0.00 0.00 17/2931 name_unit [803] + 0.00 0.00 17/760673 addlist [217] + 0.00 0.00 17/447808 create_order [341] + 0.00 0.00 17/2934859 skillname [122] + 0.00 0.00 17/71815034 get_race [12] + 0.00 0.00 17/2599554 change_money [337] + 0.00 0.00 23/599650 setstatus [1390] + 0.00 0.00 17/2742 get_equipment [1551] +----------------------------------------------- + 0.00 0.00 206/206 do_battle [64] +[838] 0.0 0.00 0.00 206 print_header [838] + 0.00 0.00 679/967784 msg_message [132] + 0.00 0.00 1029/3111 sidename [867] + 0.00 0.00 1799/17451017 strlcpy_w [67] + 0.00 0.00 679/31214 message_faction [716] + 0.00 0.00 210/24887945 locale_string [27] + 0.00 0.00 2703/2854 is_attacker [1550] + 0.00 0.00 1084/24449 seematrix [1491] + 0.00 0.00 679/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 2/115 create_ship [1014] + 0.00 0.00 113/115 continue_ship [813] +[839] 0.0 0.00 0.00 115 build_ship [839] + 0.00 0.00 115/1239 build [691] + 0.00 0.00 115/967784 msg_message [132] + 0.00 0.00 115/392959 add_message [434] + 0.00 0.00 115/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 12407/12407 cr_render [196] +[840] 0.0 0.00 0.00 12407 cr_regions [840] + 0.00 0.00 7499/1826688 adjust_coordinates [234] + 0.00 0.00 9641/18647447 getplane [596] + 0.00 0.00 7499/3587241 pnormalize [1350] +----------------------------------------------- + 0.00 0.00 2081/4162 cr_reportspell [756] + 0.00 0.00 2081/4162 nr_spell [507] +[841] 0.0 0.00 0.00 4162 spell_info [841] + 0.00 0.00 4162/24887945 locale_string [27] + 0.00 0.00 4162/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 220/220 cast_cmd [760] +[842] 0.0 0.00 0.00 220 farcasting [842] + 0.00 0.00 3/252 path_exists [431] + 0.00 0.00 220/514146 koor_distance [476] +----------------------------------------------- + 0.00 0.00 27/37974 hunger [808] + 0.00 0.00 34/37974 battle_effects [1125] + 0.00 0.00 120/37974 plagues [781] + 0.00 0.00 567/37974 eaten_by_monster [468] + 0.00 0.00 37226/37974 spawn_undead [629] +[843] 0.0 0.00 0.00 37974 deathcounts [843] + 0.00 0.00 5948/12246335 ct_find [114] + 0.00 0.00 5948/10190660 get_curse [143] + 0.00 0.00 5941/51974272 a_find [65] + 0.00 0.00 5948/4201030 curse_active [543] + 0.00 0.00 40/451774 a_remove [366] + 0.00 0.00 35/779419 a_add [555] + 0.00 0.00 35/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 348/348 process [7] +[844] 0.0 0.00 0.00 348 mail_cmd [844] + 0.00 0.00 35/35 mailunit [921] + 0.00 0.00 325/967784 msg_message [132] + 0.00 0.00 38/1437425 cansee [22] + 0.00 0.00 620/54318 getstrtoken [710] + 0.00 0.00 328/392959 add_message [434] + 0.00 0.00 348/2281756 gettoken [195] + 0.00 0.00 623/6530 findparam_ex [926] + 0.00 0.00 4/4 mailfaction [1106] + 0.00 0.00 4/4 seefaction [1117] + 0.00 0.00 348/1027665 init_order [613] + 0.00 0.00 22/228907 getid [483] + 0.00 0.00 3/41248 msg_feedback [647] + 0.00 0.00 15/51974272 a_find [65] + 0.00 0.00 1/307 getship [1018] + 0.00 0.00 328/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 8/251 do_combatmagic [825] + 0.00 0.00 23/251 do_combatspell [702] + 0.00 0.00 220/251 magic [157] +[845] 0.0 0.00 0.00 251 eff_spelllevel [845] + 0.00 0.00 489/541982 get_pooled [104] + 0.00 0.00 249/767 spellcost [995] + 0.00 0.00 99/597806 unit_get_spellbook [427] + 0.00 0.00 251/56052475 get_resourcetype [194] + 0.00 0.00 99/2112 spellbook_get [1557] +----------------------------------------------- + 0.00 0.00 442/1202 resolve [757] + 0.00 0.00 760/1202 read_reference [726] +[846] 0.0 0.00 0.00 1202 resolve_familiar [846] + 0.00 0.00 1202/11989 resolve_unit [703] + 0.00 0.00 442/760 set_familiar [992] + 0.00 0.00 760/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 13/13 magic [157] +[847] 0.0 0.00 0.00 13 sp_blessedharvest [847] + 0.00 0.00 13/45 create_curse [800] + 0.00 0.00 13/28 report_effect [861] + 0.00 0.00 26/967784 msg_message [132] + 0.00 0.00 13/12246335 ct_find [114] + 0.00 0.00 26/1009028 msg_release [1373] + 0.00 0.00 13/608 co_get_region [1594] +----------------------------------------------- + 0.00 0.00 3597/3597 chaos_update [514] +[848] 0.0 0.00 0.00 3597 chaos [848] + 0.00 0.00 5/2889 create_unit [296] + 0.00 0.00 96/105 terraform_region [932] + 0.00 0.00 3890/7641081 genrand_int31 [171] + 0.00 0.00 3/1794 remove_unit [499] + 0.00 0.00 51/967784 msg_message [132] + 0.00 0.00 51/392959 add_message [434] + 0.00 0.00 125/125 random_unit [1174] + 0.00 0.00 15/369586 r_connect [474] + 0.00 0.00 48/48 chaosterrain [1213] + 0.00 0.00 10/71815034 get_race [12] + 0.00 0.00 5/242 canfly [1031] + 0.00 0.00 5/3902878 get_monsters [293] + 0.00 0.00 9/129167539 u_race [89] + 0.00 0.00 5/5 set_money [1326] + 0.00 0.00 51/1009028 msg_release [1373] + 0.00 0.00 48/1511812 newterrain [1359] +----------------------------------------------- + 0.00 0.00 22843/22843 teach_cmd [272] +[849] 0.0 0.00 0.00 22843 parser_end [849] + 0.00 0.00 22778/5329742 eatwhitespace_c [255] +----------------------------------------------- + 0.00 0.00 5596/5596 attack [84] +[850] 0.0 0.00 0.00 5596 drain_exp [850] + 0.00 0.00 11021/7641081 genrand_int31 [171] + 0.00 0.00 45149/45891 get_level [934] + 0.00 0.00 75/1583 reduce_skill [1091] + 0.00 0.00 5425/595705 unit_skill [1391] +----------------------------------------------- + 0.00 0.00 2008/2008 name_unit [803] +[851] 0.0 0.00 0.00 2008 default_name [851] + 0.00 0.00 2008/24887945 locale_string [27] + 0.00 0.00 2008/5100840 itoa36 [116] + 0.00 0.00 2008/34611296 strlcpy [45] + 0.00 0.00 4016/987128 strlcat [1374] +----------------------------------------------- + 0.00 0.00 5049/5049 piracy_cmd [660] +[852] 0.0 0.00 0.00 5049 parse_ids [852] + 0.00 0.00 5053/54318 getstrtoken [710] + 0.00 0.00 5049/1027665 init_order [613] + 0.00 0.00 4/688711 atoi36 [440] + 0.00 0.00 4/4 intlist_init [1757] + 0.00 0.00 4/4 intlist_add [1756] +----------------------------------------------- + 0.00 0.00 232/232 reports [2] +[853] 0.0 0.00 0.00 232 write_script [853] + 0.00 0.00 232/11719 locale_name [568] + 0.00 0.00 232/5100840 itoa36 [116] + 0.00 0.00 886/987128 strlcat [1374] +----------------------------------------------- + 0.00 0.00 36/4361 piracy_cmd [660] + 0.00 0.00 4325/4361 sail [181] +[854] 0.0 0.00 0.00 4361 can_takeoff [854] + 0.00 0.00 4337/263302 reldirection [528] + 0.00 0.00 322/560926 bt_find [237] + 0.00 0.00 322/75797 buildingtype_exists [1443] +----------------------------------------------- + 0.00 0.00 32679/32679 produce [29] +[855] 0.0 0.00 0.00 32679 rule_auto_taxation [855] + 0.00 0.00 32679/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 318/1078 resolve [757] + 0.00 0.00 760/1078 read_reference [726] +[856] 0.0 0.00 0.00 1078 resolve_mage [856] + 0.00 0.00 1078/11989 resolve_unit [703] + 0.00 0.00 318/760 set_familiar [992] + 0.00 0.00 760/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 588/588 give_cmd [102] +[857] 0.0 0.00 0.00 588 give_men [857] + 0.00 0.00 1758/2624955 has_skill [193] + 0.00 0.00 588/659 can_give_men [940] + 0.00 0.00 567/1936 transfermen [899] + 0.00 0.00 1529/2275967 get_racename [368] + 0.00 0.00 488/12246335 ct_find [114] + 0.00 0.00 488/10190660 get_curse [143] + 0.00 0.00 567/1474687 leftship [500] + 0.00 0.00 588/8898 ucontact [927] + 0.00 0.00 588/702 max_transfers [1109] + 0.00 0.00 359/2421 set_racename [1015] + 0.00 0.00 783/129167539 u_race [89] + 0.00 0.00 19/15240 msg_error [744] + 0.00 0.00 488/4201030 curse_active [543] + 0.00 0.00 4/967784 msg_message [132] + 0.00 0.00 2/41248 msg_feedback [647] + 0.00 0.00 4/392959 add_message [434] + 0.00 0.00 5/234 set_leftship [1134] + 0.00 0.00 1/5100840 itoa36 [116] + 0.00 0.00 6/41882 GiveRestriction [836] + 0.00 0.00 4/118 rule_transfermen [1204] + 0.00 0.00 1/49235 log_debug [1245] + 0.00 0.00 588/1361 unit_has_cursed_item [1577] + 0.00 0.00 488/651711 oldcursename [1381] + 0.00 0.00 359/600145 u_setrace [1389] +----------------------------------------------- + 0.00 0.00 93119/93119 give_item [126] +[858] 0.0 0.00 0.00 93119 give_quota [858] + 0.00 0.00 93119/93119 limited_give [879] + 0.00 0.00 23838/717218 config_get_flt [714] +----------------------------------------------- + 0.00 0.00 2013/2013 process [7] +[859] 0.0 0.00 0.00 2013 display_cmd [859] + 0.00 0.00 2013/2281756 gettoken [195] + 0.00 0.00 2012/54318 getstrtoken [710] + 0.00 0.00 2013/6530 findparam_ex [926] + 0.00 0.00 2013/1027665 init_order [613] + 0.00 0.00 1573/1573 usetprivate [1041] + 0.00 0.00 1/15102 cmistake [718] + 0.00 0.00 1/593636 building_owner [232] + 0.00 0.00 17/3358315 ship_owner [438] +----------------------------------------------- + 0.00 0.00 38/38 report_effect [861] +[860] 0.0 0.00 0.00 38 report_action [860] + 0.00 0.00 197/1437425 cansee [22] + 0.00 0.00 206/12265 r_addmessage [779] + 0.00 0.00 1/392959 add_message [434] +----------------------------------------------- + 0.00 0.00 6/28 sp_mallornhain [968] + 0.00 0.00 9/28 sp_hain [931] + 0.00 0.00 13/28 sp_blessedharvest [847] +[861] 0.0 0.00 0.00 28 report_effect [861] + 0.00 0.00 38/38 report_action [860] +----------------------------------------------- + 0.00 0.00 5358/5358 max_spellpoints [755] +[862] 0.0 0.00 0.00 5358 get_spchange [862] + 0.00 0.00 5358/2426021 get_mage [198] +----------------------------------------------- + 0.00 0.00 2/2 parse_strings [864] +[863] 0.0 0.00 0.00 2 xml_readstrings [863] + 0.00 0.00 3444/5354 xml_readtext [887] + 0.00 0.00 3435/3496 locale_setstring [918] + 0.00 0.00 2342/4136059 mkname_buf [316] + 0.00 0.00 6879/8788 xml_cleanup_string [1520] +----------------------------------------------- + 0.00 0.00 1/1 read_xml [791] +[864] 0.0 0.00 0.00 1 parse_strings [864] + 0.00 0.00 2/2 xml_readstrings [863] +----------------------------------------------- + 0.00 0.00 23781/23781 guard_on_cmd [656] +[865] 0.0 0.00 0.00 23781 guard [865] + 0.00 0.00 23781/377253 guard_flags [690] + 0.00 0.00 23781/337987 setguard [815] +----------------------------------------------- + 0.00 0.00 2/4261 findparam_ex [926] + 0.00 0.00 4259/4261 make_cmd [383] +[866] 0.0 0.00 0.00 4261 findbuildingtype [866] + 0.00 0.00 4261/302482 findtoken [501] + 0.00 0.00 54/24887945 locale_string [27] + 0.00 0.00 54/8993 addtoken [811] +----------------------------------------------- + 0.00 0.00 1029/3111 print_header [838] + 0.00 0.00 2082/3111 print_stats [525] +[867] 0.0 0.00 0.00 3111 sidename [867] + 0.00 0.00 3111/1295787 factionname [247] + 0.00 0.00 3111/34611296 strlcpy [45] +----------------------------------------------- + 0.00 0.00 4/4 study_cmd [105] +[868] 0.0 0.00 0.00 4 count_skill [868] + 0.00 0.00 5253/2624955 has_skill [193] + 0.00 0.00 5/793 is_familiar [1092] +----------------------------------------------- + 0.00 0.00 4259/4259 make_cmd [383] +[869] 0.0 0.00 0.00 4259 findshiptype [869] + 0.00 0.00 4259/302482 findtoken [501] + 0.00 0.00 14/24887945 locale_string [27] + 0.00 0.00 14/8993 addtoken [811] +----------------------------------------------- + 0.00 0.00 1138/1138 a_read_i [390] +[870] 0.0 0.00 0.00 1138 read_targetregion [870] + 0.00 0.00 1138/9763 read_reference [726] +----------------------------------------------- + 0.00 0.00 9/9 magic [157] +[871] 0.0 0.00 0.00 9 sp_stormwinds [871] + 0.00 0.00 17/45 create_curse [800] + 0.00 0.00 76/12265 r_addmessage [779] + 0.00 0.00 9/967784 msg_message [132] + 0.00 0.00 27/12246335 ct_find [114] + 0.00 0.00 10/10190660 get_curse [143] + 0.00 0.00 10/4201030 curse_active [543] + 0.00 0.00 10/651711 oldcursename [1381] + 0.00 0.00 9/608 co_get_region [1594] + 0.00 0.00 9/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1334/4915 bufunit [17] + 0.00 0.00 1711/4915 cr_output_unit [19] + 0.00 0.00 1870/4915 regenerate_aura [346] +[872] 0.0 0.00 0.00 4915 get_spellpoints [872] + 0.00 0.00 4915/2426021 get_mage [198] +----------------------------------------------- + 0.00 0.00 42/42 produce [29] +[873] 0.0 0.00 0.00 42 loot_cmd [873] + 0.00 0.00 84/133 income [885] + 0.00 0.00 42/15361 is_guarded [377] + 0.00 0.00 42/771861 armedmen [151] + 0.00 0.00 42/760673 addlist [217] + 0.00 0.00 42/57138 getint [699] + 0.00 0.00 42/71815034 get_race [12] + 0.00 0.00 84/3902878 get_monsters [293] + 0.00 0.00 168/129167539 u_race [89] + 0.00 0.00 42/1027665 init_order [613] + 0.00 0.00 42/4984610 config_get_int [348] + 0.00 0.00 42/8506411 besieged [547] +----------------------------------------------- + 0.00 0.00 38/4875 do_combatspell [702] + 0.00 0.00 51/4875 do_combatmagic [825] + 0.00 0.00 4786/4875 bufunit [17] +[874] 0.0 0.00 0.00 4875 get_combatspell [874] + 0.00 0.00 4875/2426021 get_mage [198] + 0.00 0.00 50/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 15/6962 drifting_ships [490] + 0.00 0.00 6947/6962 sail [181] +[875] 0.0 0.00 0.00 6962 set_coast [875] + 0.00 0.00 4307/263302 reldirection [528] + 0.00 0.00 4307/44216 flying_ship [1465] +----------------------------------------------- + 0.00 0.00 552/552 make_fighter [424] +[876] 0.0 0.00 0.00 552 make_side [876] + 0.00 0.00 814/9953180 alliedunit [31] + 0.00 0.00 6102/6610983 is_guard [211] +----------------------------------------------- + 0.00 0.00 791/791 process [7] +[877] 0.0 0.00 0.00 791 ally_cmd [877] + 0.00 0.00 791/791 getfaction [937] + 0.00 0.00 677/69432 getparam [681] + 0.00 0.00 677/2281756 gettoken [195] + 0.00 0.00 107/15102 cmistake [718] + 0.00 0.00 677/1787006 findparam [458] + 0.00 0.00 791/1027665 init_order [613] + 0.00 0.00 664/51974272 a_find [65] + 0.00 0.00 677/10383360 HelpMask [288] + 0.00 0.00 1/1 removelist [1290] + 0.00 0.00 2/55547 ally_add [1452] +----------------------------------------------- + 0.00 0.00 1/1 process [7] +[878] 0.0 0.00 0.00 1 nmr_warnings [878] + 0.00 0.00 1449/1205451 alliedfaction [162] + 0.00 0.00 1398/4984610 config_get_int [348] + 0.00 0.00 24/967784 msg_message [132] + 0.00 0.00 55/392959 add_message [434] + 0.00 0.00 20/27 NMRTimeout [1264] + 0.00 0.00 24/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 93119/93119 give_quota [858] +[879] 0.0 0.00 0.00 93119 limited_give [879] + 0.00 0.00 93119/56052475 get_resourcetype [194] +----------------------------------------------- + 0.00 0.00 23/1339 do_combatspell [702] + 0.00 0.00 51/1339 do_combatmagic [825] + 0.00 0.00 1265/1339 bufunit [17] +[880] 0.0 0.00 0.00 1339 get_combatspelllevel [880] + 0.00 0.00 1302/12320804 effskill [100] + 0.00 0.00 1339/2426021 get_mage [198] +----------------------------------------------- + 0.00 0.00 425/425 aftermath [701] +[881] 0.0 0.00 0.00 425 reportcasualties [881] + 0.00 0.00 395/1486 message_all [834] + 0.00 0.00 395/967784 msg_message [132] + 0.00 0.00 395/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1520/1520 parse_symbol [42] +[882] 0.0 0.00 0.00 1520 eval_race [882] + 0.00 0.00 1520/24887945 locale_string [27] + 0.00 0.00 1520/2818494 rc_name_s [260] + 0.00 0.00 3040/13102790 opstack_pop [176] + 0.00 0.00 1520/13102790 opstack_push [202] + 0.00 0.00 1520/13399069 balloc [363] +----------------------------------------------- + 0.00 0.00 1909/1909 parse_messages [832] +[883] 0.0 0.00 0.00 1909 nrt_register [883] + 0.00 0.00 4921/34611296 strlcpy [45] + 0.00 0.00 1909/32337529 hashstring [37] + 0.00 0.00 1909/1909 section_find [1563] + 0.00 0.00 10/10 section_add [1729] +----------------------------------------------- + 0.00 0.00 1/5588 crtag [110] + 0.00 0.00 233/5588 readfaction [767] + 0.00 0.00 5354/5588 xml_readtext [887] +[884] 0.0 0.00 0.00 5588 get_locale [884] + 0.00 0.00 5588/32337529 hashstring [37] +----------------------------------------------- + 0.00 0.00 49/133 plan_dragon [273] + 0.00 0.00 84/133 loot_cmd [873] +[885] 0.0 0.00 0.00 133 income [885] + 0.00 0.00 133/2480226 old_race [14] + 0.00 0.00 266/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 349/349 produce [29] +[886] 0.0 0.00 0.00 349 research_cmd [886] + 0.00 0.00 349/967784 msg_message [132] + 0.00 0.00 349/472418 produceexp [322] + 0.00 0.00 349/12320804 effskill [100] + 0.00 0.00 349/392959 add_message [434] + 0.00 0.00 349/1027665 init_order [613] + 0.00 0.00 692/3166898 rherbs [1351] + 0.00 0.00 349/1009028 msg_release [1373] + 0.00 0.00 343/343 rough_amount [1607] +----------------------------------------------- + 0.00 0.00 1910/5354 parse_messages [832] + 0.00 0.00 3444/5354 xml_readstrings [863] +[887] 0.0 0.00 0.00 5354 xml_readtext [887] + 0.00 0.00 5354/5588 get_locale [884] +----------------------------------------------- + 0.00 0.00 1301/1301 split_allocations [743] +[888] 0.0 0.00 0.00 1301 leveled_allocation [888] + 0.00 0.00 1423/12320804 effskill [100] + 0.00 0.00 1281/7641081 genrand_int31 [171] + 0.00 0.00 1245/1245 use_default [1149] + 0.00 0.00 1301/9298667 resource2item [546] + 0.00 0.00 2704/7493 required [1527] + 0.00 0.00 1301/1301 rm_get [1578] +----------------------------------------------- + 0.00 0.00 396/396 update_spells [381] +[889] 0.0 0.00 0.00 396 show_new_spells [889] + 0.00 0.00 7815/7815 already_seen [929] + 0.00 0.00 4162/779419 a_add [555] + 0.00 0.00 4162/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 25088/25088 rmtroop [533] +[890] 0.0 0.00 0.00 25088 rmfighter [890] + 0.00 0.00 25088/129167539 u_race [89] + 0.00 0.00 25088/4301501 statusrow [550] +----------------------------------------------- + 0.00 0.00 9/1803 destroyfaction [392] + 0.00 0.00 1794/1803 remove_unit [499] +[891] 0.0 0.00 0.00 1803 gift_items [891] + 0.00 0.00 112/112 get_friends [895] + 0.00 0.00 3606/56052475 get_resourcetype [194] + 0.00 0.00 578/129167539 u_race [89] + 0.00 0.00 26/11241829 i_change [115] + 0.00 0.00 38/2186159 rsetmoney [553] + 0.00 0.00 38/4666665 rmoney [452] + 0.00 0.00 1803/103079 rule_give [1328] + 0.00 0.00 216/257723 i_remove [1407] + 0.00 0.00 216/374425 i_free [1400] + 0.00 0.00 88/97 i_merge [1651] + 0.00 0.00 5/1160345 rhorses [1369] + 0.00 0.00 5/257693 rsethorses [1408] +----------------------------------------------- + 0.00 0.00 768/768 read_triggers [798] +[892] 0.0 0.00 0.00 768 shock_read [892] + 0.00 0.00 768/9763 read_reference [726] +----------------------------------------------- + 0.00 0.00 760/760 a_read_i [390] +[893] 0.0 0.00 0.00 760 read_familiar [893] + 0.00 0.00 760/9763 read_reference [726] +----------------------------------------------- + 0.00 0.00 760/760 a_read_i [390] +[894] 0.0 0.00 0.00 760 read_magician [894] + 0.00 0.00 760/9763 read_reference [726] +----------------------------------------------- + 0.00 0.00 112/112 gift_items [891] +[895] 0.0 0.00 0.00 112 get_friends [895] + 0.00 0.00 1104/9953180 alliedunit [31] + 0.00 0.00 1085/4984610 config_get_int [348] + 0.00 0.00 28/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 6/6 magic [157] +[896] 0.0 0.00 0.00 6 sp_summonundead [896] + 0.00 0.00 6/2889 create_unit [296] + 0.00 0.00 6/6 skill_summoned [1032] + 0.00 0.00 12/967784 msg_message [132] + 0.00 0.00 6/6 make_undead_unit [1188] + 0.00 0.00 12/392959 add_message [434] + 0.00 0.00 12/71815034 get_race [12] + 0.00 0.00 9/201744 lovar [644] + 0.00 0.00 15/355423 deathcount [674] + 0.00 0.00 12/1009028 msg_release [1373] + 0.00 0.00 6/608 co_get_region [1594] +----------------------------------------------- + 0.00 0.00 16132/16132 teach_unit [426] +[897] 0.0 0.00 0.00 16132 magic_lowskill [897] + 0.00 0.00 16132/12560453 rc_changed [256] + 0.00 0.00 16132/129167539 u_race [89] + 0.00 0.00 1/71815034 get_race [12] +----------------------------------------------- + 0.00 0.00 80/80 process [7] +[898] 0.0 0.00 0.00 80 combatspell_cmd [898] + 0.00 0.00 37/365 unit_getspell [758] + 0.00 0.00 100/2281756 gettoken [195] + 0.00 0.00 27/15102 cmistake [718] + 0.00 0.00 10/10 set_combatspell [1146] + 0.00 0.00 43/43 unset_combatspell [1167] + 0.00 0.00 115/1787006 findparam [458] + 0.00 0.00 80/1027665 init_order [613] + 0.00 0.00 10/57138 getint [699] +----------------------------------------------- + 0.00 0.00 71/1936 disband_men [999] + 0.00 0.00 567/1936 give_men [857] + 0.00 0.00 1298/1936 add_recruits [371] +[899] 0.0 0.00 0.00 1936 transfermen [899] + 0.00 0.00 3730/51974272 a_find [65] + 0.00 0.00 1936/3178 scale_number [969] + 0.00 0.00 1865/1474687 leftship [500] + 0.00 0.00 1610/1610 transfer_curse [1039] + 0.00 0.00 698/1956810 add_skill [355] + 0.00 0.00 71/264251 rsetpeasants [545] + 0.00 0.00 71/2605004 rpeasants [435] + 0.00 0.00 142/129167539 u_race [89] + 0.00 0.00 5/234 set_leftship [1134] + 0.00 0.00 108170/595705 unit_skill [1391] + 0.00 0.00 1865/603524 set_number [1387] + 0.00 0.00 95/51060 remove_skill [1456] +----------------------------------------------- + 0.00 0.00 2/16493 start_battle [297] + 0.00 0.00 237/16493 quit [276] + 0.00 0.00 16254/16493 IsImmune [901] +[900] 0.0 0.00 0.00 16493 NewbieImmunity [900] + 0.00 0.00 16493/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 65/16669 steal_cmd [766] + 0.00 0.00 1431/16669 start_battle [297] + 0.00 0.00 15173/16669 can_start_guarding [679] +[901] 0.0 0.00 0.00 16669 IsImmune [901] + 0.00 0.00 16254/16493 NewbieImmunity [900] +----------------------------------------------- + 0.00 0.00 56/3110 update_long_order [270] + 0.00 0.00 165/3110 build_building [696] + 0.00 0.00 2889/3110 create_unit [296] +[902] 0.0 0.00 0.00 3110 default_order [902] + 0.00 0.00 3110/635885 copy_order [441] + 0.00 0.00 2/447808 create_order [341] + 0.00 0.00 2/20777534 config_get [224] + 0.00 0.00 3110/2124526 locale_index [1354] + 0.00 0.00 2/65 findkeyword [1665] +----------------------------------------------- + 0.00 0.00 2/2831 do_fumble [1062] + 0.00 0.00 767/2831 spellcost [995] + 0.00 0.00 2062/2831 magic [157] +[903] 0.0 0.00 0.00 2831 countspells [903] + 0.00 0.00 2831/2426021 get_mage [198] +----------------------------------------------- + 0.00 0.00 1700/1700 process [7] +[904] 0.0 0.00 0.00 1700 status_cmd [904] + 0.00 0.00 1700/2281756 gettoken [195] + 0.00 0.00 1700/1787006 findparam [458] + 0.00 0.00 1700/1027665 init_order [613] + 0.00 0.00 17/69432 getparam [681] + 0.00 0.00 1683/599650 setstatus [1390] +----------------------------------------------- + 0.00 0.00 923/923 name_unit [803] +[905] 0.0 0.00 0.00 923 race_namegen [905] + 0.00 0.00 666/666 generic_name [962] + 0.00 0.00 74/74 ghoul_name [1029] + 0.00 0.00 70/70 skeleton_name [1035] + 0.00 0.00 52/52 zombie_name [1056] + 0.00 0.00 27/27 dragon_name [1095] + 0.00 0.00 34/34 dracoid_name [1126] +----------------------------------------------- + 0.00 0.00 1/1 processorders [6] +[906] 0.0 0.00 0.00 1 wormholes_update [906] + 0.00 0.00 1/1 select_wormhole_regions [909] + 0.00 0.00 1/1 make_wormholes [1151] + 0.00 0.00 1/560926 bt_find [237] + 0.00 0.00 1/1 sort_wormhole_regions [1864] +----------------------------------------------- + 0.00 0.00 834/834 parse_symbol [42] +[907] 0.0 0.00 0.00 834 eval_resources [907] + 0.00 0.00 1490/24887945 locale_string [27] + 0.00 0.00 1490/13259934 resourcename [233] + 0.00 0.00 834/13102790 opstack_pop [176] + 0.00 0.00 834/13102790 opstack_push [202] + 0.00 0.00 1490/36653945 wrptr [178] + 0.00 0.00 834/13399069 balloc [363] +----------------------------------------------- + 0.00 0.00 81/81 allocate_resource [752] +[908] 0.0 0.00 0.00 81 can_guard [908] + 0.00 0.00 81/1437425 cansee [22] + 0.00 0.00 79/771861 armedmen [151] + 0.00 0.00 79/9953180 alliedunit [31] + 0.00 0.00 79/129167539 u_race [89] + 0.00 0.00 79/8506411 besieged [547] +----------------------------------------------- + 0.00 0.00 1/1 wormholes_update [906] +[909] 0.0 0.00 0.00 1 select_wormhole_regions [909] + 0.00 0.00 178255/178255 good_region [910] + 0.00 0.00 3/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 178255/178255 select_wormhole_regions [909] +[910] 0.0 0.00 0.00 178255 good_region [910] + 0.00 0.00 174658/18647447 getplane [596] +----------------------------------------------- + 0.00 0.00 443/443 res_changepermaura [912] +[911] 0.0 0.00 0.00 443 change_maxspellpoints [911] + 0.00 0.00 443/5358 max_spellpoints [755] + 0.00 0.00 443/2426021 get_mage [198] +----------------------------------------------- + 0.00 0.00 86/443 change_resource [240] + 0.00 0.00 357/443 get_resource [99] +[912] 0.0 0.00 0.00 443 res_changepermaura [912] + 0.00 0.00 443/443 change_maxspellpoints [911] +----------------------------------------------- + 0.00 0.00 5925/5925 readfaction [767] +[913] 0.0 0.00 0.00 5925 addally [913] + 0.00 0.00 5925/4625636 findfaction [259] + 0.00 0.00 5925/10383360 HelpMask [288] + 0.00 0.00 5925/55547 ally_add [1452] + 0.00 0.00 2941/34565 ur_add [1472] +----------------------------------------------- + 0.00 0.00 1422/1422 split_allocations [743] +[914] 0.0 0.00 0.00 1422 attrib_allocation [914] + 0.00 0.00 1584/1584 produce_resource [994] + 0.00 0.00 1414/3123 limit_resource [943] + 0.00 0.00 1596/7641081 genrand_int31 [171] + 0.00 0.00 1422/51974272 a_find [65] + 0.00 0.00 4789/7493 required [1527] + 0.00 0.00 11/11 produce_seeds [1725] + 0.00 0.00 7/30 limit_seeds [1691] + 0.00 0.00 1/2 limit_mallornseeds [1775] + 0.00 0.00 1/1 produce_mallornseeds [1829] +----------------------------------------------- + 0.00 0.00 1725/1725 add_skill [355] +[915] 0.0 0.00 0.00 1725 max_magicians [915] + 0.00 0.00 1725/71815034 get_race [12] + 0.00 0.00 1725/51974272 a_find [65] + 0.00 0.00 1725/4984610 config_get_int [348] +----------------------------------------------- + +[916] 0.0 0.00 0.00 tolua_unit_create [916] + 0.00 0.00 6/2889 create_unit [296] + 0.00 0.00 6/68430117 rc_find [15] +----------------------------------------------- + 0.00 0.00 1/1 process [7] +[917] 0.0 0.00 0.00 1 promotion_cmd [917] + 0.00 0.00 1/461 maxheroes [492] + 0.00 0.00 1/967 count_all [357] + 0.00 0.00 1/457 countheroes [572] + 0.00 0.00 1/860263 use_pooled [39] + 0.00 0.00 1/541982 get_pooled [104] + 0.00 0.00 1/967784 msg_message [132] + 0.00 0.00 1/392959 add_message [434] + 0.00 0.00 1/129167539 u_race [89] + 0.00 0.00 1/56052475 get_resourcetype [194] + 0.00 0.00 1/1 valid_race [1893] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 61/3496 json_keyword [1127] + 0.00 0.00 3435/3496 xml_readstrings [863] +[918] 0.0 0.00 0.00 3496 locale_setstring [918] + 0.00 0.00 3496/32337529 hashstring [37] +----------------------------------------------- + 0.00 0.00 1551/8034 spskill [53] + 0.00 0.00 1637/8034 cr_output_unit [19] + 0.00 0.00 4846/8034 eff_stealth [163] +[919] 0.0 0.00 0.00 8034 u_geteffstealth [919] + 0.00 0.00 8034/51974272 a_find [65] + 0.00 0.00 8034/21345834 skill_enabled [365] +----------------------------------------------- + 0.00 0.00 232/232 writefaction [762] +[920] 0.0 0.00 0.00 232 write_groups [920] + 0.00 0.00 1692/841675 a_write [299] + 0.00 0.00 51104/647569 write_faction_reference [1382] +----------------------------------------------- + 0.00 0.00 35/35 mail_cmd [844] +[921] 0.0 0.00 0.00 35 mailunit [921] + 0.00 0.00 35/39 deliverMail [966] + 0.00 0.00 35/1437425 cansee [22] + 0.00 0.00 35/145 findunitr [991] +----------------------------------------------- + 0.00 0.00 1196/1196 parse_symbol [42] +[922] 0.0 0.00 0.00 1196 eval_localize [922] + 0.00 0.00 1196/24887945 locale_string [27] + 0.00 0.00 1196/13102790 opstack_pop [176] + 0.00 0.00 1196/13102790 opstack_push [202] + 0.00 0.00 1196/13399069 balloc [363] +----------------------------------------------- + 0.00 0.00 2/2 do_combatmagic [825] +[923] 0.0 0.00 0.00 2 sp_igjarjuk [923] + 0.00 0.00 2/2 summon_allies [925] + 0.00 0.00 2/361 regionname [987] + 0.00 0.00 2/2383101 unitname [142] + 0.00 0.00 2/71815034 get_race [12] + 0.00 0.00 2/64 log_info [1339] + 0.00 0.00 2/3862 unit_setname [1540] +----------------------------------------------- + +[924] 0.0 0.00 0.00 cb_foreach_i [924] + 0.00 0.00 324/324 add_resourcename_cb [977] + 0.00 0.00 324/324 add_itemname_cb [980] +----------------------------------------------- + 0.00 0.00 2/2 sp_igjarjuk [923] +[925] 0.0 0.00 0.00 2 summon_allies [925] + 0.00 0.00 2/1297 make_fighter [424] + 0.00 0.00 2/2889 create_unit [296] + 0.00 0.00 2/2887 leave [432] + 0.00 0.00 2/1486 message_all [834] + 0.00 0.00 2/967784 msg_message [132] + 0.00 0.00 2/1381157 unit_max_hp [136] + 0.00 0.00 2/779419 a_add [555] + 0.00 0.00 2/599650 setstatus [1390] + 0.00 0.00 2/779868 a_new [1376] + 0.00 0.00 2/1009028 msg_release [1373] + 0.00 0.00 2/2854 is_attacker [1550] +----------------------------------------------- + 0.00 0.00 138/6530 renumber_cmd [780] + 0.00 0.00 623/6530 mail_cmd [844] + 0.00 0.00 639/6530 do_enter [128] + 0.00 0.00 2013/6530 display_cmd [859] + 0.00 0.00 3117/6530 name_cmd [835] +[926] 0.0 0.00 0.00 6530 findparam_ex [926] + 0.00 0.00 6530/1787006 findparam [458] + 0.00 0.00 2/4261 findbuildingtype [866] +----------------------------------------------- + 0.00 0.00 2/8898 sp_enterastral [1045] + 0.00 0.00 20/8898 can_give_to [600] + 0.00 0.00 50/8898 give_cmd [102] + 0.00 0.00 186/8898 mayboard [1046] + 0.00 0.00 317/8898 mayenter [936] + 0.00 0.00 397/8898 is_guardian_u [626] + 0.00 0.00 588/8898 give_men [857] + 0.00 0.00 1198/8898 check_ship_allowed [657] + 0.00 0.00 6140/8898 bewegung_blockiert_von [631] +[927] 0.0 0.00 0.00 8898 ucontact [927] + 0.00 0.00 8144/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 58/30308 peasant_luck_effect [984] + 0.00 0.00 30250/30308 peasants [658] +[928] 0.0 0.00 0.00 30308 peasant_growth_factor [928] + 0.00 0.00 30308/717218 config_get_flt [714] +----------------------------------------------- + 0.00 0.00 7815/7815 show_new_spells [889] +[929] 0.0 0.00 0.00 7815 already_seen [929] + 0.00 0.00 7815/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 4024/4024 a_write [299] +[930] 0.0 0.00 0.00 4024 curse_write [930] + 0.00 0.00 4024/604861 write_unit_reference [557] + 0.00 0.00 3/3 write_skill [1769] +----------------------------------------------- + 0.00 0.00 1/10 do_fumble [1062] + 0.00 0.00 9/10 magic [157] +[931] 0.0 0.00 0.00 10 sp_hain [931] + 0.00 0.00 9/28 report_effect [861] + 0.00 0.00 18/967784 msg_message [132] + 0.00 0.00 9/201744 lovar [644] + 0.00 0.00 1/15102 cmistake [718] + 0.00 0.00 9/10053919 rtrees [302] + 0.00 0.00 18/1009028 msg_release [1373] + 0.00 0.00 10/608 co_get_region [1594] + 0.00 0.00 9/229715 rsettrees [1410] +----------------------------------------------- + 0.00 0.00 9/105 melt_iceberg [1082] + 0.00 0.00 96/105 chaos [848] +[932] 0.0 0.00 0.00 105 terraform_region [932] + 0.00 0.00 105/105 terraform_resources [986] + 0.00 0.00 48/32727 rsetherbtype [537] + 0.00 0.00 48/48 makename [1084] + 0.00 0.00 298/7641081 genrand_int31 [171] + 0.00 0.00 48/60 equip_items [1121] + 0.00 0.00 57/264251 rsetpeasants [545] + 0.00 0.00 29/752645 chance [495] + 0.00 0.00 10/369586 r_connect [474] + 0.00 0.00 57/2186159 rsetmoney [553] + 0.00 0.00 58/10053919 rtrees [302] + 0.00 0.00 252/229715 rsettrees [1410] + 0.00 0.00 64/257693 rsethorses [1408] + 0.00 0.00 57/178311 region_setinfo [1422] + 0.00 0.00 57/10475 i_freeall [1515] + 0.00 0.00 57/57 free_land [1673] + 0.00 0.00 48/32727 region_set_morale [1476] + 0.00 0.00 48/48 region_setname [1683] + 0.00 0.00 48/48 get_maxluxuries [1682] + 0.00 0.00 48/2742 get_equipment [1551] + 0.00 0.00 48/101322 rsetherbs [1438] + 0.00 0.00 29/1511812 newterrain [1359] +----------------------------------------------- + 0.00 0.00 3/1873 do_fumble [1062] + 0.00 0.00 1870/1873 regenerate_aura [346] +[933] 0.0 0.00 0.00 1873 set_spellpoints [933] + 0.00 0.00 1873/2426021 get_mage [198] +----------------------------------------------- + 0.00 0.00 1/45891 sp_summonshadowlords [1034] + 0.00 0.00 17/45891 study_cmd [105] + 0.00 0.00 724/45891 study_cost [433] + 0.00 0.00 45149/45891 drain_exp [850] +[934] 0.0 0.00 0.00 45891 get_level [934] + 0.00 0.00 45891/21345834 skill_enabled [365] +----------------------------------------------- + 0.00 0.00 56/56 use_item [765] +[935] 0.0 0.00 0.00 56 use_bloodpotion [935] + 0.00 0.00 56/860263 use_pooled [39] + 0.00 0.00 56/967784 msg_message [132] + 0.00 0.00 56/392959 add_message [434] + 0.00 0.00 56/71815034 get_race [12] + 0.00 0.00 56/404 usetpotionuse [1078] + 0.00 0.00 55/2977 change_effect [982] + 0.00 0.00 58/129167539 u_race [89] + 0.00 0.00 1/68430117 rc_find [15] + 0.00 0.00 1/3 trigger_changerace [1297] + 0.00 0.00 1/2868601 u_irace [257] + 0.00 0.00 1/11 add_trigger [1260] + 0.00 0.00 1/7641081 genrand_int31 [171] + 0.00 0.00 56/1009028 msg_release [1373] + 0.00 0.00 1/5 trigger_timeout [1753] + 0.00 0.00 1/600145 u_setrace [1389] +----------------------------------------------- + 0.00 0.00 401/401 enter_building [695] +[936] 0.0 0.00 0.00 401 mayenter [936] + 0.00 0.00 401/593636 building_owner [232] + 0.00 0.00 215/9953180 alliedunit [31] + 0.00 0.00 317/8898 ucontact [927] +----------------------------------------------- + 0.00 0.00 791/791 ally_cmd [877] +[937] 0.0 0.00 0.00 791 getfaction [937] + 0.00 0.00 791/228907 getid [483] + 0.00 0.00 791/4625636 findfaction [259] +----------------------------------------------- + 0.00 0.00 230/45860 report_computer [9] + 0.00 0.00 45630/45860 cr_output_region [10] +[938] 0.0 0.00 0.00 45860 print_items [938] + 0.00 0.00 446/4434556 translate [75] + 0.00 0.00 446/24887945 locale_string [27] + 0.00 0.00 446/13259934 resourcename [233] +----------------------------------------------- + 0.00 0.00 3/3 magic [157] +[939] 0.0 0.00 0.00 3 sp_song_of_peace [939] + 0.00 0.00 3/45 create_curse [800] + 0.00 0.00 30/1437425 cansee [22] + 0.00 0.00 30/12265 r_addmessage [779] + 0.00 0.00 5/967784 msg_message [132] + 0.00 0.00 3/201744 lovar [644] + 0.00 0.00 3/12246335 ct_find [114] + 0.00 0.00 5/1009028 msg_release [1373] + 0.00 0.00 3/608 co_get_region [1594] +----------------------------------------------- + 0.00 0.00 71/659 disband_men [999] + 0.00 0.00 588/659 give_men [857] +[940] 0.0 0.00 0.00 659 can_give_men [940] + 0.00 0.00 659/71815034 get_race [12] + 0.00 0.00 659/2624955 has_skill [193] + 0.00 0.00 349/12246335 ct_find [114] + 0.00 0.00 349/10190660 get_curse [143] + 0.00 0.00 659/129167539 u_race [89] + 0.00 0.00 349/4201030 curse_active [543] + 0.00 0.00 659/1361 unit_has_cursed_item [1577] + 0.00 0.00 349/651711 oldcursename [1381] +----------------------------------------------- + 0.00 0.00 345/345 use_potion [801] +[941] 0.0 0.00 0.00 345 do_potion [941] + 0.00 0.00 51/51 potion_water_of_life [945] + 0.00 0.00 232/2977 change_effect [982] + 0.00 0.00 62/62 potion_luck [1176] +----------------------------------------------- + 0.00 0.00 508/508 regenerate_aura [346] +[942] 0.0 0.00 0.00 508 regeneration [942] + 0.00 0.00 508/12320804 effskill [100] + 0.00 0.00 1016/1336242 rng_injectable_double [396] + 0.00 0.00 508/129167539 u_race [89] + 0.00 0.00 508/508 MagicRegeneration [1185] +----------------------------------------------- + 0.00 0.00 1414/3123 attrib_allocation [914] + 0.00 0.00 1709/3123 allocate_resource [752] +[943] 0.0 0.00 0.00 3123 limit_resource [943] + 0.00 0.00 3123/34611296 strlcpy [45] + 0.00 0.00 3123/987128 strlcat [1374] +----------------------------------------------- + 0.00 0.00 230/230 report_plaintext [4] +[944] 0.0 0.00 0.00 230 gamedate_season [944] + 0.00 0.00 1150/24887945 locale_string [27] + 0.00 0.00 230/40692 get_gamedate [1466] +----------------------------------------------- + 0.00 0.00 51/51 do_potion [941] +[945] 0.0 0.00 0.00 51 potion_water_of_life [945] + 0.00 0.00 51/860263 use_pooled [39] + 0.00 0.00 51/967784 msg_message [132] + 0.00 0.00 51/392959 add_message [434] + 0.00 0.00 51/2032164 rt_find [597] + 0.00 0.00 51/10053919 rtrees [302] + 0.00 0.00 2/4984610 config_get_int [348] + 0.00 0.00 51/2386892 config_changed [1352] + 0.00 0.00 51/229715 rsettrees [1410] + 0.00 0.00 51/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 2/122 create_ship [1014] + 0.00 0.00 120/122 continue_ship [813] +[946] 0.0 0.00 0.00 122 maxbuild [946] + 0.00 0.00 122/541982 get_pooled [104] + 0.00 0.00 122/3100 required [1547] +----------------------------------------------- + 0.00 0.00 1/3 config_parse [462] + 0.00 0.00 1/3 reset_game [356] + 0.00 0.00 1/3 readgame [60] +[947] 0.0 0.00 0.00 3 init_locales [947] + 0.00 0.00 2/2 init_locale [948] + 0.00 0.00 2/6 get_or_create_locale [1275] +----------------------------------------------- + 0.00 0.00 2/2 init_locales [947] +[948] 0.0 0.00 0.00 2 init_locale [948] + 0.00 0.00 282/24887945 locale_string [27] + 0.00 0.00 282/8993 addtoken [811] + 0.00 0.00 2/2 init_keywords [1099] + 0.00 0.00 2/2 init_skills [1101] + 0.00 0.00 2/2 init_parameters [1100] + 0.00 0.00 272/2818494 rc_name_s [260] + 0.00 0.00 2/2 init_terrains_translation [1129] + 0.00 0.00 2/2 init_directions [1143] + 0.00 0.00 2/2 init_options_translation [1157] + 0.00 0.00 10/4133717 mkname [261] + 0.00 0.00 4/4558423 get_translations [437] + 0.00 0.00 2/20777534 config_get [224] +----------------------------------------------- + 0.00 0.00 356/356 cr_render [196] +[949] 0.0 0.00 0.00 356 cr_race [949] + 0.00 0.00 356/4434556 translate [75] + 0.00 0.00 356/24887945 locale_string [27] + 0.00 0.00 356/2818494 rc_name_s [260] +----------------------------------------------- + 0.00 0.00 41/41 make_cmd [383] +[950] 0.0 0.00 0.00 41 build_road [950] + 0.00 0.00 21/860263 use_pooled [39] + 0.00 0.00 23/541982 get_pooled [104] + 0.00 0.00 60/143730 rroad [508] + 0.00 0.00 21/967784 msg_message [132] + 0.00 0.00 41/12320804 effskill [100] + 0.00 0.00 21/22 rsetroad [1152] + 0.00 0.00 16/41248 msg_feedback [647] + 0.00 0.00 37/392959 add_message [434] + 0.00 0.00 36/369586 r_connect [474] + 0.00 0.00 21/472418 produceexp [322] + 0.00 0.00 44/71815034 get_race [12] + 0.00 0.00 5/560926 bt_find [237] + 0.00 0.00 4/15102 cmistake [718] + 0.00 0.00 11/6010308 i_find [127] + 0.00 0.00 11/2858912 get_effect [225] + 0.00 0.00 44/129167539 u_race [89] + 0.00 0.00 55/56052475 get_resourcetype [194] + 0.00 0.00 41/8506411 besieged [547] + 0.00 0.00 114/1511812 newterrain [1359] + 0.00 0.00 37/1009028 msg_release [1373] + 0.00 0.00 5/75797 buildingtype_exists [1443] +----------------------------------------------- + 0.00 0.00 10/492 set_combatspell [1146] + 0.00 0.00 482/492 knowsspell [956] +[951] 0.0 0.00 0.00 492 u_hasspell [951] + 0.00 0.00 489/12320804 effskill [100] + 0.00 0.00 492/597806 unit_get_spellbook [427] + 0.00 0.00 489/2112 spellbook_get [1557] +----------------------------------------------- + 0.00 0.00 114/114 give_cmd [102] +[952] 0.0 0.00 0.00 114 give_unit [952] + 0.00 0.00 112/94420 add_give [379] + 0.00 0.00 112/9953180 alliedunit [31] + 0.00 0.00 224/2624955 has_skill [193] + 0.00 0.00 114/118 rule_transfermen [1204] + 0.00 0.00 114/702 max_transfers [1109] + 0.00 0.00 112/129167539 u_race [89] + 0.00 0.00 2/15102 cmistake [718] + 0.00 0.00 112/56052475 get_resourcetype [194] + 0.00 0.00 112/598129 u_setfaction [1111] + 0.00 0.00 114/1361 unit_has_cursed_item [1577] +----------------------------------------------- +[953] 0.0 0.00 0.00 1564+36 [953] + 0.00 0.00 1582 write_triggers [954] + 0.00 0.00 18 timeout_write [1711] +----------------------------------------------- + 18 timeout_write [1711] + 0.00 0.00 1564/1564 write_handler [955] +[954] 0.0 0.00 0.00 1582 write_triggers [954] + 0.00 0.00 2304/2304 killunit_write [978] + 0.00 0.00 769/769 shock_write [1050] + 0.00 0.00 12/12 changefaction_write [1258] + 0.00 0.00 6/6 changerace_write [1287] + 0.00 0.00 2/2 giveitem_write [1309] + 0.00 0.00 1/1 clonedied_write [1321] + 0.00 0.00 1/1 caldera_write [1795] + 18 timeout_write [1711] +----------------------------------------------- + 0.00 0.00 1564/1564 a_write [299] +[955] 0.0 0.00 0.00 1564 write_handler [955] + 0.00 0.00 1564/1564 write_triggers [954] +----------------------------------------------- + 0.00 0.00 10/482 set_combatspell [1146] + 0.00 0.00 221/482 cast_cmd [760] + 0.00 0.00 251/482 cancast [833] +[956] 0.0 0.00 0.00 482 knowsspell [956] + 0.00 0.00 482/492 u_hasspell [951] +----------------------------------------------- + 0.00 0.00 21/21 cast_combatspell [623] +[957] 0.0 0.00 0.00 21 sp_kampfzauber [957] + 0.00 0.00 45/80630 terminate [242] + 0.00 0.00 45/372173 select_enemy [172] + 0.00 0.00 21/1486 message_all [834] + 0.00 0.00 21/967784 msg_message [132] + 0.00 0.00 21/201744 lovar [644] + 0.00 0.00 21/876979 count_enemies [611] + 0.00 0.00 21/74 spell_damage [1657] + 0.00 0.00 21/74 get_force [1656] + 0.00 0.00 21/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1/178429 sp_holyground [1068] + 0.00 0.00 59/178429 setstealth_cmd [182] + 0.00 0.00 115/178429 reshow [822] + 0.00 0.00 178254/178429 age_piracy [959] +[958] 0.0 0.00 0.00 178429 a_removeall [958] + 0.00 0.00 2172/454395 a_free [558] +----------------------------------------------- + 0.00 0.00 178254/178254 move_pirates [326] +[959] 0.0 0.00 0.00 178254 age_piracy [959] + 0.00 0.00 178254/178429 a_removeall [958] +----------------------------------------------- + 0.00 0.00 210/210 cr_render [196] +[960] 0.0 0.00 0.00 210 cr_resources [960] + 0.00 0.00 352/4434556 translate [75] + 0.00 0.00 352/24887945 locale_string [27] + 0.00 0.00 352/13259934 resourcename [233] +----------------------------------------------- + 0.00 0.00 604/604 parse_symbol [42] +[961] 0.0 0.00 0.00 604 eval_spell [961] + 0.00 0.00 604/86400 spell_name [646] + 0.00 0.00 604/13102790 opstack_pop [176] + 0.00 0.00 604/13102790 opstack_push [202] + 0.00 0.00 604/13399069 balloc [363] +----------------------------------------------- + 0.00 0.00 666/666 race_namegen [905] +[962] 0.0 0.00 0.00 666 generic_name [962] + 0.00 0.00 666/24887945 locale_string [27] + 0.00 0.00 666/2818494 rc_name_s [260] + 0.00 0.00 666/129167539 u_race [89] + 0.00 0.00 666/3862 unit_setname [1540] +----------------------------------------------- + 0.00 0.00 47/47 reshow_other [823] +[963] 0.0 0.00 0.00 47 display_race [963] + 0.00 0.00 495/24887945 locale_string [27] + 0.00 0.00 47/48 addmessage [1069] + 0.00 0.00 211/17451017 strlcpy_w [67] + 0.00 0.00 47/779486 locale_getstring [266] + 0.00 0.00 456/36653945 wrptr [178] + 0.00 0.00 86/4133717 mkname [261] + 0.00 0.00 47/2818494 rc_name_s [260] + 0.00 0.00 211/5461936 slprintf [548] +----------------------------------------------- + 0.00 0.00 9352/9352 nr_spell [507] +[964] 0.0 0.00 0.00 9352 write_spell_modifier [964] + 0.00 0.00 2478/34611296 strlcpy [45] +----------------------------------------------- + 0.00 0.00 147/147 do_contact [250] +[965] 0.0 0.00 0.00 147 contact_cmd [965] + 0.00 0.00 147/888603 findunit [123] + 0.00 0.00 147/284005 read_unitid [413] + 0.00 0.00 115/115 usetcontact [1147] + 0.00 0.00 147/1027665 init_order [613] + 0.00 0.00 115/192 can_contact [1634] +----------------------------------------------- + 0.00 0.00 4/39 mailfaction [1106] + 0.00 0.00 35/39 mailunit [921] +[966] 0.0 0.00 0.00 39 deliverMail [966] + 0.00 0.00 39/1437425 cansee [22] + 0.00 0.00 39/967784 msg_message [132] + 0.00 0.00 39/392959 add_message [434] + 0.00 0.00 39/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 5049/5049 piracy_cmd [660] +[967] 0.0 0.00 0.00 5049 find_piracy_target [967] + 0.00 0.00 5049/51974272 a_find [65] + 0.00 0.00 2/9953180 alliedunit [31] +----------------------------------------------- + 0.00 0.00 6/6 magic [157] +[968] 0.0 0.00 0.00 6 sp_mallornhain [968] + 0.00 0.00 6/28 report_effect [861] + 0.00 0.00 12/967784 msg_message [132] + 0.00 0.00 6/201744 lovar [644] + 0.00 0.00 6/10053919 rtrees [302] + 0.00 0.00 12/1009028 msg_release [1373] + 0.00 0.00 6/608 co_get_region [1594] + 0.00 0.00 6/229715 rsettrees [1410] +----------------------------------------------- + 0.00 0.00 1/3178 res_changeitem [101] + 0.00 0.00 1/3178 make_zombie [1267] + 0.00 0.00 3/3178 drown [394] + 0.00 0.00 4/3178 age_firedragon [1123] + 0.00 0.00 7/3178 age_ghoul [1024] + 0.00 0.00 16/3178 damage_unit [1044] + 0.00 0.00 17/3178 age_zombie [1019] + 0.00 0.00 19/3178 age_skeleton [1008] + 0.00 0.00 27/3178 hunger [808] + 0.00 0.00 41/3178 dissolve_units [241] + 0.00 0.00 425/3178 aftermath [701] + 0.00 0.00 681/3178 absorbed_by_monster [804] + 0.00 0.00 1936/3178 transfermen [899] +[969] 0.0 0.00 0.00 3178 scale_number [969] + 0.00 0.00 3035/51974272 a_find [65] + 0.00 0.00 1279/7641081 genrand_int31 [171] + 0.00 0.00 50953/51060 remove_skill [1456] + 0.00 0.00 3036/603524 set_number [1387] +----------------------------------------------- + 0.00 0.00 52/196 zombie_name [1056] + 0.00 0.00 70/196 skeleton_name [1035] + 0.00 0.00 74/196 ghoul_name [1029] +[970] 0.0 0.00 0.00 196 make_name [970] + 0.00 0.00 407/779486 locale_getstring [266] + 0.00 0.00 588/7641081 genrand_int31 [171] + 0.00 0.00 3/3 count_particles [1089] + 0.00 0.00 76/34611296 strlcpy [45] + 0.00 0.00 542/987128 strlcat [1374] + 0.00 0.00 196/3862 unit_setname [1540] +----------------------------------------------- + 0.00 0.00 2/1201 sp_bloodsacrifice [1209] + 0.00 0.00 1199/1201 res_changeaura [972] +[971] 0.0 0.00 0.00 1201 change_spellpoints [971] + 0.00 0.00 1201/2426021 get_mage [198] +----------------------------------------------- + 0.00 0.00 216/1199 change_resource [240] + 0.00 0.00 983/1199 get_resource [99] +[972] 0.0 0.00 0.00 1199 res_changeaura [972] + 0.00 0.00 1199/1201 change_spellpoints [971] +----------------------------------------------- + 0.00 0.00 8/226 do_combatmagic [825] + 0.00 0.00 23/226 do_combatspell [702] + 0.00 0.00 195/226 magic [157] +[973] 0.0 0.00 0.00 226 fumble [973] + 0.00 0.00 226/12320804 effskill [100] + 0.00 0.00 226/2426021 get_mage [198] + 0.00 0.00 452/12246335 ct_find [114] + 0.00 0.00 452/10190660 get_curse [143] + 0.00 0.00 226/4984610 config_get_int [348] + 0.00 0.00 83/7641081 genrand_int31 [171] + 0.00 0.00 452/4201030 curse_active [543] + 0.00 0.00 452/651711 oldcursename [1381] + 0.00 0.00 226/26995 inside_building [1486] + 0.00 0.00 226/26164 building_is_active [1488] +----------------------------------------------- + 0.00 0.00 4/4 magic [157] +[974] 0.0 0.00 0.00 4 sp_goodwinds [974] + 0.00 0.00 4/45 create_curse [800] + 0.00 0.00 13/12265 r_addmessage [779] + 0.00 0.00 4/967784 msg_message [132] + 0.00 0.00 4/12246335 ct_find [114] + 0.00 0.00 4/608 co_get_region [1594] + 0.00 0.00 4/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 4475/4475 build [691] +[975] 0.0 0.00 0.00 4475 matmod [975] + 0.00 0.00 4475/51974272 a_find [65] + 0.00 0.00 505/505 mm_smithy [1203] +----------------------------------------------- + +[976] 0.0 0.00 0.00 tolua_region_get_resource [976] + 0.00 0.00 3355/2032164 rt_find [597] + 0.00 0.00 2772/10053919 rtrees [302] + 0.00 0.00 3355/3355 region_getresource [1058] + 0.00 0.00 6127/7889 special_resources [1526] +----------------------------------------------- + 0.00 0.00 324/324 cb_foreach_i [924] +[977] 0.0 0.00 0.00 324 add_resourcename_cb [977] + 0.00 0.00 648/24887945 locale_string [27] + 0.00 0.00 648/4457785 transliterate [358] + 0.00 0.00 648/13259934 resourcename [233] + 0.00 0.00 324/2124526 locale_index [1354] +----------------------------------------------- + 0.00 0.00 2304/2304 write_triggers [954] +[978] 0.0 0.00 0.00 2304 killunit_write [978] + 0.00 0.00 2304/604861 write_unit_reference [557] +----------------------------------------------- + 0.00 0.00 406/406 readfaction [767] +[979] 0.0 0.00 0.00 406 faction_setorigin [979] + 0.00 0.00 406/760673 addlist [217] +----------------------------------------------- + 0.00 0.00 324/324 cb_foreach_i [924] +[980] 0.0 0.00 0.00 324 add_itemname_cb [980] + 0.00 0.00 628/24887945 locale_string [27] + 0.00 0.00 628/4457785 transliterate [358] + 0.00 0.00 628/13259934 resourcename [233] + 0.00 0.00 324/2124526 locale_index [1354] +----------------------------------------------- + 0.00 0.00 1/1 randomevents [91] +[981] 0.0 0.00 0.00 1 volcano_update [981] + 0.00 0.00 6/6 volcano_outbreak [1023] + 0.00 0.00 648/7641081 genrand_int31 [171] + 0.00 0.00 37/967784 msg_message [132] + 0.00 0.00 37/392959 add_message [434] + 0.00 0.00 85/51974272 a_find [65] + 0.00 0.00 6/6 rrandneighbour [1221] + 0.00 0.00 37/1009028 msg_release [1373] + 0.00 0.00 2/178270 get_terrain [1423] +----------------------------------------------- + 0.00 0.00 7/2977 allocate_resource [752] + 0.00 0.00 9/2977 movement_speed [155] + 0.00 0.00 55/2977 use_bloodpotion [935] + 0.00 0.00 95/2977 build [691] + 0.00 0.00 232/2977 do_potion [941] + 0.00 0.00 1118/2977 study_cmd [105] + 0.00 0.00 1461/2977 get_food [88] +[982] 0.0 0.00 0.00 2977 change_effect [982] + 0.00 0.00 2977/51974272 a_find [65] + 0.00 0.00 105/451774 a_remove [366] + 0.00 0.00 159/779419 a_add [555] + 0.00 0.00 159/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 287/287 readorders [43] +[983] 0.0 0.00 0.00 287 factionorders [983] + 0.00 0.00 287/228907 getid [483] + 0.00 0.00 286/2281756 gettoken [195] + 0.00 0.00 287/4625636 findfaction [259] + 0.00 0.00 4/967784 msg_message [132] + 0.00 0.00 4/392959 add_message [434] + 0.00 0.00 5/5100840 itoa36 [116] + 0.00 0.00 286/286 checkpasswd [1268] + 0.00 0.00 5/49235 log_debug [1245] + 0.00 0.00 4/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 30250/30250 peasants [658] +[984] 0.0 0.00 0.00 30250 peasant_luck_effect [984] + 0.00 0.00 174/147217 normalvariate [376] + 0.00 0.00 58/1336242 rng_injectable_double [396] + 0.00 0.00 58/30308 peasant_growth_factor [928] + 0.00 0.00 58/58 peasant_luck_factor [1277] +----------------------------------------------- + 0.00 0.00 621/621 process [7] +[985] 0.0 0.00 0.00 621 group_cmd [985] + 0.00 0.00 621/54318 getstrtoken [710] + 0.00 0.00 621/735 join_group [1083] + 0.00 0.00 621/1027665 init_order [613] +----------------------------------------------- + 0.00 0.00 105/105 terraform_region [932] +[986] 0.0 0.00 0.00 105 terraform_resources [986] + 0.00 0.00 174/146997 dice_rand [409] + 0.00 0.00 138/752645 chance [495] + 0.00 0.00 58/58 add_resource [1162] + 0.00 0.00 105/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 1/361 tolua_region_tostring [1291] + 0.00 0.00 2/361 sp_igjarjuk [923] + 0.00 0.00 10/361 spawn_dragons [411] + 0.00 0.00 50/361 rsetherbtype [537] + 0.00 0.00 92/361 spawn_undead [629] + 0.00 0.00 206/361 do_battle [64] +[987] 0.0 0.00 0.00 361 regionname [987] + 0.00 0.00 361/515911 write_regionname [280] +----------------------------------------------- + 0.00 0.00 3/3 magic [157] +[988] 0.0 0.00 0.00 3 sp_eternizewall [988] + 0.00 0.00 3/45 create_curse [800] + 0.00 0.00 3/967784 msg_message [132] + 0.00 0.00 5/12265 r_addmessage [779] + 0.00 0.00 3/12246335 ct_find [114] + 0.00 0.00 3/608 co_get_region [1594] + 0.00 0.00 3/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 7/7 do_combatmagic [825] +[989] 0.0 0.00 0.00 7 sp_healing [989] + 0.00 0.00 7/7 fighters [1012] + 0.00 0.00 7/7 scramble_fighters [1116] + 0.00 0.00 14/14 heal_fighters [1158] + 0.00 0.00 7/1486 message_all [834] + 0.00 0.00 7/967784 msg_message [132] + 0.00 0.00 7/7 has_ao_healing [1269] + 0.00 0.00 7/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 16/16 produce [29] +[990] 0.0 0.00 0.00 16 spy_cmd [990] + 0.00 0.00 8/8 spy_message [1038] + 0.00 0.00 96/12320804 effskill [100] + 0.00 0.00 16/282847 getunit [205] + 0.00 0.00 12/1753922 invisible [139] + 0.00 0.00 6/967784 msg_message [132] + 0.00 0.00 8/472418 produceexp [322] + 0.00 0.00 10/392959 add_message [434] + 0.00 0.00 4/41248 msg_feedback [647] + 0.00 0.00 24/752645 chance [495] + 0.00 0.00 16/1027665 init_order [613] + 0.00 0.00 12/192 can_contact [1634] + 0.00 0.00 10/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 35/145 mailunit [921] + 0.00 0.00 110/145 steal_cmd [766] +[991] 0.0 0.00 0.00 145 findunitr [991] + 0.00 0.00 145/1118718 ufindhash [109] +----------------------------------------------- + 0.00 0.00 318/760 resolve_mage [856] + 0.00 0.00 442/760 resolve_familiar [846] +[992] 0.0 0.00 0.00 760 set_familiar [992] + 0.00 0.00 2280/51974272 a_find [65] + 0.00 0.00 760/779419 a_add [555] + 0.00 0.00 760/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 3/3 magic [157] +[993] 0.0 0.00 0.00 3 sp_charmingsong [993] + 0.00 0.00 2/45 create_curse [800] + 0.00 0.00 90/12320804 effskill [100] + 0.00 0.00 3/3 target_resists_magic [1154] + 0.00 0.00 2/967784 msg_message [132] + 0.00 0.00 1/15102 cmistake [718] + 0.00 0.00 1/1 report_failure [1285] + 0.00 0.00 2/392959 add_message [434] + 0.00 0.00 6/11 add_trigger [1260] + 0.00 0.00 2/12246335 ct_find [114] + 0.00 0.00 2/7641081 genrand_int31 [171] + 0.00 0.00 3/3 can_charm [1338] + 0.00 0.00 2/598129 u_setfaction [1111] + 0.00 0.00 2/154110 rule_stealth_anon [1325] + 0.00 0.00 4/5 trigger_killunit [1752] + 0.00 0.00 2/2 trigger_changefaction [1783] + 0.00 0.00 2/5 trigger_timeout [1753] + 0.00 0.00 2/1291427 set_order [1365] + 0.00 0.00 2/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1584/1584 attrib_allocation [914] +[994] 0.0 0.00 0.00 1584 produce_resource [994] + 0.00 0.00 1584/34611296 strlcpy [45] + 0.00 0.00 1584/987128 strlcat [1374] +----------------------------------------------- + 0.00 0.00 249/767 eff_spelllevel [845] + 0.00 0.00 249/767 cancast [833] + 0.00 0.00 269/767 pay_spell [805] +[995] 0.0 0.00 0.00 767 spellcost [995] + 0.00 0.00 767/2831 countspells [903] + 0.00 0.00 767/56052475 get_resourcetype [194] +----------------------------------------------- + 0.00 0.00 183/183 msg_curse [664] +[996] 0.0 0.00 0.00 183 cinfo_magicrunes [996] + 0.00 0.00 174/967784 msg_message [132] +----------------------------------------------- + 0.00 0.00 163/163 msg_curse [664] +[997] 0.0 0.00 0.00 163 cinfo_shipnodrift [997] + 0.00 0.00 163/967784 msg_message [132] +----------------------------------------------- + 0.00 0.00 1522/1522 a_write [299] +[998] 0.0 0.00 0.00 1522 a_write_unit [998] + 0.00 0.00 1522/604861 write_unit_reference [557] +----------------------------------------------- + 0.00 0.00 71/71 give_cmd [102] +[999] 0.0 0.00 0.00 71 disband_men [999] + 0.00 0.00 71/967784 msg_message [132] + 0.00 0.00 71/659 can_give_men [940] + 0.00 0.00 71/1936 transfermen [899] + 0.00 0.00 71/71815034 get_race [12] + 0.00 0.00 71/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 8/225 do_combatmagic [825] + 0.00 0.00 21/225 do_combatspell [702] + 0.00 0.00 196/225 magic [157] +[1000] 0.0 0.00 0.00 225 spellpower [1000] + 0.00 0.00 450/12246335 ct_find [114] + 0.00 0.00 225/5395063 i_get [130] + 0.00 0.00 450/10190660 get_curse [143] + 0.00 0.00 225/4984610 config_get_int [348] + 0.00 0.00 225/2032164 rt_find [597] + 0.00 0.00 450/4201030 curse_active [543] + 0.00 0.00 225/26995 inside_building [1486] + 0.00 0.00 225/26164 building_is_active [1488] +----------------------------------------------- + 0.00 0.00 2723/2723 split_allocations [743] +[1001] 0.0 0.00 0.00 2723 get_allocator [1001] + 0.00 0.00 2723/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 15/15 drifting_ships [490] +[1002] 0.0 0.00 0.00 15 overload [1002] + 0.00 0.00 15/47902 getshipweight [212] +----------------------------------------------- + 0.00 0.00 133/324 travel [81] + 0.00 0.00 191/324 sail [181] +[1003] 0.0 0.00 0.00 324 caught_target [1003] + 0.00 0.00 131/9953180 alliedunit [31] + 0.00 0.00 8/1437425 cansee [22] + 0.00 0.00 324/51974272 a_find [65] + 0.00 0.00 4/967784 msg_message [132] + 0.00 0.00 4/392959 add_message [434] + 0.00 0.00 133/133 present [1643] + 0.00 0.00 4/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 3659/3659 study_cmd [105] +[1004] 0.0 0.00 0.00 3659 ExpensiveMigrants [1004] + 0.00 0.00 3659/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 20/182 create_potion [821] + 0.00 0.00 71/182 manufacture [759] + 0.00 0.00 91/182 build_building [696] +[1005] 0.0 0.00 0.00 182 msg_materials_required [1005] + 0.00 0.00 182/41248 msg_feedback [647] +----------------------------------------------- + 0.00 0.00 957/957 parse_messages [832] +[1006] 0.0 0.00 0.00 957 crt_register [1006] + 0.00 0.00 957/32337529 hashstring [37] + 0.00 0.00 2468/2468 tsf_find [1554] +----------------------------------------------- + 0.00 0.00 957/957 parse_messages [832] +[1007] 0.0 0.00 0.00 957 mt_register [1007] + 0.00 0.00 957/32337529 hashstring [37] + 0.00 0.00 957/957 mt_id [1587] +----------------------------------------------- + 0.00 0.00 1363/1363 age_unit [336] +[1008] 0.0 0.00 0.00 1363 age_skeleton [1008] + 0.00 0.00 725/7641081 genrand_int31 [171] + 0.00 0.00 725/3902878 get_monsters [293] + 0.00 0.00 38/1381157 unit_max_hp [136] + 0.00 0.00 19/71815034 get_race [12] + 0.00 0.00 19/3178 scale_number [969] + 0.00 0.00 19/600145 u_setrace [1389] +----------------------------------------------- + 0.00 0.00 1125/1125 leave [432] +[1009] 0.0 0.00 0.00 1125 leave_building [1009] + 0.00 0.00 92/92 building_update_owner [1010] +----------------------------------------------- + 0.00 0.00 92/92 leave_building [1009] +[1010] 0.0 0.00 0.00 92 building_update_owner [1010] + 0.00 0.00 92/209572 building_owner_ex [253] +----------------------------------------------- + 0.00 0.00 37/37 init_transportation [384] +[1011] 0.0 0.00 0.00 37 transport [1011] + 0.00 0.00 70/282847 getunit [205] + 0.00 0.00 148/55492327 getkeyword [54] + 0.00 0.00 70/1027665 init_order [613] + 0.00 0.00 37/1629412 LongHunger [536] +----------------------------------------------- + 0.00 0.00 7/7 sp_healing [989] +[1012] 0.0 0.00 0.00 7 fighters [1012] + 0.00 0.00 308/1662377 get_unitrow [154] + 0.00 0.00 8/25 allysf [1160] +----------------------------------------------- + 0.00 0.00 1091/1091 loot_items [810] +[1013] 0.0 0.00 0.00 1091 loot_quota [1013] + 0.00 0.00 1062/752645 chance [495] + 0.00 0.00 1062/717218 config_get_flt [714] +----------------------------------------------- + 0.00 0.00 2/2 make_cmd [383] +[1014] 0.0 0.00 0.00 2 create_ship [1014] + 0.00 0.00 2/2887 leave [432] + 0.00 0.00 2/115 build_ship [839] + 0.00 0.00 2/14326 replace_order [526] + 0.00 0.00 2/122 maxbuild [946] + 0.00 0.00 2/2 new_ship [1229] + 0.00 0.00 4/12320804 effskill [100] + 0.00 0.00 2/447808 create_order [341] + 0.00 0.00 2/24887945 locale_string [27] + 0.00 0.00 2/129167539 u_race [89] + 0.00 0.00 2/8506411 besieged [547] + 0.00 0.00 2/27640 u_set_ship [1485] + 0.00 0.00 2/1936876 free_order [1356] +----------------------------------------------- + 0.00 0.00 359/2421 give_men [857] + 0.00 0.00 2062/2421 create_unit [296] +[1015] 0.0 0.00 0.00 2421 set_racename [1015] + 0.00 0.00 2421/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 1/573 config_read [460] + 0.00 0.00 1/573 reports [2] + 0.00 0.00 1/573 writepasswd [1074] + 0.00 0.00 1/573 readgame [60] + 0.00 0.00 1/573 writegame [82] + 0.00 0.00 2/573 writeturn [1253] + 0.00 0.00 2/573 report_summary [614] + 0.00 0.00 2/573 score [23] + 0.00 0.00 3/573 json_include [1283] + 0.00 0.00 559/573 write_reports [3] +[1016] 0.0 0.00 0.00 573 join_path [1016] + 0.00 0.00 1146/34611296 strlcpy [45] +----------------------------------------------- + 0.00 0.00 106/106 a_age [418] +[1017] 0.0 0.00 0.00 106 age_reduceproduction [1017] + 0.00 0.00 100/967784 msg_message [132] + 0.00 0.00 100/392959 add_message [434] + 0.00 0.00 100/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1/307 mail_cmd [844] + 0.00 0.00 306/307 continue_ship [813] +[1018] 0.0 0.00 0.00 307 getship [1018] + 0.00 0.00 307/228907 getid [483] + 0.00 0.00 307/28818 findship [1483] +----------------------------------------------- + 0.00 0.00 688/688 age_unit [336] +[1019] 0.0 0.00 0.00 688 age_zombie [1019] + 0.00 0.00 665/7641081 genrand_int31 [171] + 0.00 0.00 665/3902878 get_monsters [293] + 0.00 0.00 34/1381157 unit_max_hp [136] + 0.00 0.00 17/71815034 get_race [12] + 0.00 0.00 17/3178 scale_number [969] + 0.00 0.00 17/600145 u_setrace [1389] +----------------------------------------------- + 0.00 0.00 133/133 travel [81] +[1020] 0.0 0.00 0.00 133 reroute [1020] + 0.00 0.00 233/113487 next_region [601] +----------------------------------------------- + 0.00 0.00 124/124 age_building [712] +[1021] 0.0 0.00 0.00 124 age_stonecircle [1021] + 0.00 0.00 124/125 r_standard_to_astral [1067] + 0.00 0.00 87/1441945 is_mage [262] + 0.00 0.00 124/987612 get_astralplane [482] + 0.00 0.00 98/752645 chance [495] + 0.00 0.00 15/12320804 effskill [100] + 0.00 0.00 15/12246335 ct_find [114] + 0.00 0.00 97/129167539 u_race [89] + 0.00 0.00 124/56052475 get_resourcetype [194] + 0.00 0.00 15/10190660 get_curse [143] + 0.00 0.00 1/967784 msg_message [132] + 0.00 0.00 1/392959 add_message [434] + 0.00 0.00 1/11241829 i_change [115] + 0.00 0.00 140/26995 inside_building [1486] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 12/12 volcano_outbreak [1023] +[1022] 0.0 0.00 0.00 12 volcano_destruction [1022] + 0.00 0.00 16/16 damage_unit [1044] + 0.00 0.00 13/967784 msg_message [132] + 0.00 0.00 12/1375380 remove_empty_units_in_region [134] + 0.00 0.00 13/392959 add_message [434] + 0.00 0.00 12/7641081 genrand_int31 [171] + 0.00 0.00 12/779419 a_add [555] + 0.00 0.00 12/51974272 a_find [65] + 0.00 0.00 36/229715 rsettrees [1410] + 0.00 0.00 13/1009028 msg_release [1373] + 0.00 0.00 12/12 make_reduceproduction [1722] +----------------------------------------------- + 0.00 0.00 6/6 volcano_update [981] +[1023] 0.0 0.00 0.00 6 volcano_outbreak [1023] + 0.00 0.00 12/12 volcano_destruction [1022] +----------------------------------------------- + 0.00 0.00 708/708 age_unit [336] +[1024] 0.0 0.00 0.00 708 age_ghoul [1024] + 0.00 0.00 653/7641081 genrand_int31 [171] + 0.00 0.00 653/3902878 get_monsters [293] + 0.00 0.00 14/1381157 unit_max_hp [136] + 0.00 0.00 7/71815034 get_race [12] + 0.00 0.00 7/3178 scale_number [969] + 0.00 0.00 7/600145 u_setrace [1389] +----------------------------------------------- + 0.00 0.00 2/2 magic [157] +[1025] 0.0 0.00 0.00 2 sp_summon_familiar [1025] + 0.00 0.00 1/2889 create_unit [296] + 0.00 0.00 1/1380398 nr_render [25] + 0.00 0.00 8/2934859 skillname [122] + 0.00 0.00 1/1 make_familiar [1219] + 0.00 0.00 2/967784 msg_message [132] + 0.00 0.00 15/34611296 strlcpy [45] + 0.00 0.00 1/15102 cmistake [718] + 0.00 0.00 58/21345834 skill_enabled [365] + 0.00 0.00 1/392959 add_message [434] + 0.00 0.00 1/24887945 locale_string [27] + 0.00 0.00 15/36653945 wrptr [178] + 0.00 0.00 2/54351 get_familiar [796] + 0.00 0.00 1/1 select_familiar [1322] + 0.00 0.00 2/608 co_get_region [1594] + 0.00 0.00 2/1009028 msg_release [1373] + 0.00 0.00 1/599650 setstatus [1390] +----------------------------------------------- + 0.00 0.00 279/279 cr_render [196] +[1026] 0.0 0.00 0.00 279 cr_spell [1026] + 0.00 0.00 279/86400 spell_name [646] +----------------------------------------------- + 0.00 0.00 196/196 magic [157] +[1027] 0.0 0.00 0.00 196 verify_targets [1027] + 0.00 0.00 16/16 verify_unit [1028] + 0.00 0.00 4/4 verify_building [1255] + 0.00 0.00 196/608 co_get_region [1594] + 0.00 0.00 22/22 verify_ship [1704] +----------------------------------------------- + 0.00 0.00 16/16 verify_targets [1027] +[1028] 0.0 0.00 0.00 16 verify_unit [1028] + 0.00 0.00 14/1437425 cansee [22] + 0.00 0.00 16/888603 findunit [123] +----------------------------------------------- + 0.00 0.00 74/74 race_namegen [905] +[1029] 0.0 0.00 0.00 74 ghoul_name [1029] + 0.00 0.00 74/196 make_name [970] +----------------------------------------------- + 0.00 0.00 4/338 recruit [650] + 0.00 0.00 103/338 reshow_other [823] + 0.00 0.00 231/338 setstealth_cmd [182] +[1030] 0.0 0.00 0.00 338 findrace [1030] + 0.00 0.00 338/302482 findtoken [501] + 0.00 0.00 338/4558423 get_translations [437] +----------------------------------------------- + 0.00 0.00 3/242 drown [394] + 0.00 0.00 5/242 chaos [848] + 0.00 0.00 234/242 travel_route [147] +[1031] 0.0 0.00 0.00 242 canfly [1031] + 0.00 0.00 242/5395063 i_get [130] + 0.00 0.00 242/1177511 it_find [385] + 0.00 0.00 240/116002 get_movement [750] + 0.00 0.00 242/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 6/6 sp_summonundead [896] +[1032] 0.0 0.00 0.00 6 skill_summoned [1032] + 0.00 0.00 54/2457 set_level [774] + 0.00 0.00 6/1381157 unit_max_hp [136] + 0.00 0.00 6/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 2/6 init_keywords [1099] + 0.00 0.00 2/6 init_skills [1101] + 0.00 0.00 2/6 init_parameters [1100] +[1033] 0.0 0.00 0.00 6 init_translations [1033] + 0.00 0.00 264/24887945 locale_string [27] + 0.00 0.00 264/371 add_translation [1145] + 0.00 0.00 58/58 skill_key [1205] + 0.00 0.00 6/4558423 get_translations [437] + 0.00 0.00 118/118 keyword_key [1647] + 0.00 0.00 88/88 parameter_key [1655] +----------------------------------------------- + 0.00 0.00 1/1 magic [157] +[1034] 0.0 0.00 0.00 1 sp_summonshadowlords [1034] + 0.00 0.00 1/2889 create_unit [296] + 0.00 0.00 2/2457 set_level [774] + 0.00 0.00 1/967784 msg_message [132] + 0.00 0.00 1/392959 add_message [434] + 0.00 0.00 1/71815034 get_race [12] + 0.00 0.00 1/129167539 u_race [89] + 0.00 0.00 1/45891 get_level [934] + 0.00 0.00 1/608 co_get_region [1594] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 70/70 race_namegen [905] +[1035] 0.0 0.00 0.00 70 skeleton_name [1035] + 0.00 0.00 70/196 make_name [970] +----------------------------------------------- + 0.00 0.00 119/119 recruit [650] +[1036] 0.0 0.00 0.00 119 syntax_error [1036] + 0.00 0.00 119/15240 msg_error [744] + 0.00 0.00 119/392959 add_message [434] + 0.00 0.00 119/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 65/65 steal_cmd [766] +[1037] 0.0 0.00 0.00 65 max_skill [1037] + 0.00 0.00 200/12320804 effskill [100] +----------------------------------------------- + 0.00 0.00 8/8 spy_cmd [990] +[1038] 0.0 0.00 0.00 8 spy_message [1038] + 0.00 0.00 48/12320804 eff_skill [334] + 0.00 0.00 22/967784 msg_message [132] + 0.00 0.00 48/2934859 skillname [122] + 0.00 0.00 48/884940 itoa10 [338] + 0.00 0.00 22/392959 add_message [434] + 0.00 0.00 8/4374788 visible_faction [68] + 0.00 0.00 8/598234 report_status [318] + 0.00 0.00 1/2426021 get_mage [198] + 0.00 0.00 22/1009028 msg_release [1373] + 0.00 0.00 1/1 add_seen_faction [1788] +----------------------------------------------- + 0.00 0.00 1610/1610 transfermen [899] +[1039] 0.0 0.00 0.00 1610 transfer_curse [1039] + 0.00 0.00 1610/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 1/1 magic [157] +[1040] 0.0 0.00 0.00 1 sp_generous [1040] + 0.00 0.00 1/45 create_curse [800] + 0.00 0.00 4/1437425 cansee [22] + 0.00 0.00 4/12265 r_addmessage [779] + 0.00 0.00 1/967784 msg_message [132] + 0.00 0.00 2/12246335 ct_find [114] + 0.00 0.00 1/10190660 get_curse [143] + 0.00 0.00 1/4201030 curse_active [543] + 0.00 0.00 1/608 co_get_region [1594] + 0.00 0.00 1/651711 oldcursename [1381] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1573/1573 display_cmd [859] +[1041] 0.0 0.00 0.00 1573 usetprivate [1041] + 0.00 0.00 1573/51974272 a_find [65] + 0.00 0.00 1/451774 a_remove [366] + 0.00 0.00 3/779419 a_add [555] + 0.00 0.00 3/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 121/121 tolua_msg_send_faction [1043] +[1042] 0.0 0.00 0.00 121 msg_send_faction [1042] + 0.00 0.00 121/1009159 msg_create [228] + 0.00 0.00 121/392959 add_message [434] +----------------------------------------------- + +[1043] 0.0 0.00 0.00 tolua_msg_send_faction [1043] + 0.00 0.00 121/121 msg_send_faction [1042] +----------------------------------------------- + 0.00 0.00 16/16 volcano_destruction [1022] +[1044] 0.0 0.00 0.00 16 damage_unit [1044] + 0.00 0.00 60/146997 dice_rand [409] + 0.00 0.00 16/7957 magic_resistance [727] + 0.00 0.00 20/71815034 get_race [12] + 0.00 0.00 16/3178 scale_number [969] + 0.00 0.00 60/60 nb_armor [1273] + 0.00 0.00 4/5395063 i_get [130] + 0.00 0.00 4/2858912 get_effect [225] + 0.00 0.00 36/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 1/1 magic [157] +[1045] 0.0 0.00 0.00 1 sp_enterastral [1045] + 0.00 0.00 12/1437425 cansee [22] + 0.00 0.00 4/967784 msg_message [132] + 0.00 0.00 12/12265 r_addmessage [779] + 0.00 0.00 2/109785 move_unit [421] + 0.00 0.00 2/279395 weight [459] + 0.00 0.00 1/125 r_standard_to_astral [1067] + 0.00 0.00 2/12246335 ct_find [114] + 0.00 0.00 2/10190660 get_curse [143] + 0.00 0.00 2/8898 ucontact [927] + 0.00 0.00 2/797288 can_survive [640] + 0.00 0.00 2/4201030 curse_active [543] + 0.00 0.00 1/3 getplaneid [1337] + 0.00 0.00 4/1009028 msg_release [1373] + 0.00 0.00 2/651711 oldcursename [1381] + 0.00 0.00 1/608 co_get_region [1594] +----------------------------------------------- + 0.00 0.00 195/195 enter_ship [733] +[1046] 0.0 0.00 0.00 195 mayboard [1046] + 0.00 0.00 112/9953180 alliedunit [31] + 0.00 0.00 186/8898 ucontact [927] + 0.00 0.00 195/3358315 ship_owner [438] +----------------------------------------------- + 0.00 0.00 3659/3659 study_cmd [105] +[1047] 0.0 0.00 0.00 3659 is_migrant [1047] + 0.00 0.00 4069/129167539 u_race [89] + 0.00 0.00 260/793 is_familiar [1092] + 0.00 0.00 150/12560453 rc_changed [256] + 0.00 0.00 1/71815034 get_race [12] +----------------------------------------------- + 0.00 0.00 535/1270 create_unit [296] + 0.00 0.00 735/1270 join_group [1083] +[1048] 0.0 0.00 0.00 1270 set_group [1048] + 0.00 0.00 631/779419 a_add [555] + 0.00 0.00 380/51974272 a_find [65] + 0.00 0.00 23/451774 a_remove [366] + 0.00 0.00 631/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 55/1848 renumber_unit [1159] + 0.00 0.00 1793/1848 remove_unit [499] +[1049] 0.0 0.00 0.00 1848 uunhash [1049] + 0.00 0.00 1848/2903884 jenkins_hash [439] +----------------------------------------------- + 0.00 0.00 769/769 write_triggers [954] +[1050] 0.0 0.00 0.00 769 shock_write [1050] + 0.00 0.00 769/604861 write_unit_reference [557] +----------------------------------------------- + 0.00 0.00 5049/5049 piracy_cmd [660] +[1051] 0.0 0.00 0.00 5049 validate_pirate [1051] + 0.00 0.00 5049/129167539 u_race [89] + 0.00 0.00 6/3358315 ship_owner [438] +----------------------------------------------- + 0.00 0.00 2491/2491 a_read_i [390] +[1052] 0.0 0.00 0.00 2491 a_readeffect [1052] + 0.00 0.00 2491/2032164 rt_find [597] +----------------------------------------------- + 0.00 0.00 15/15 drifting_ships [490] +[1053] 0.0 0.00 0.00 15 drift_target [1053] + 0.00 0.00 79/39810 check_ship_allowed [657] + 0.00 0.00 58/369586 r_connect [474] + 0.00 0.00 15/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 39/39 reshow_other [823] +[1054] 0.0 0.00 0.00 39 display_item [1054] + 0.00 0.00 39/967784 msg_message [132] + 0.00 0.00 39/779486 locale_getstring [266] + 0.00 0.00 39/392959 add_message [434] + 0.00 0.00 47/4133717 mkname [261] + 0.00 0.00 8/24887945 locale_string [27] + 0.00 0.00 39/13259934 resourcename [233] + 0.00 0.00 39/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 13/1297 follow_unit [331] + 0.00 0.00 1284/1297 follow_ship [749] +[1055] 0.0 0.00 0.00 1297 hunted_dir [1055] + 0.00 0.00 1297/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 52/52 race_namegen [905] +[1056] 0.0 0.00 0.00 52 zombie_name [1056] + 0.00 0.00 52/196 make_name [970] +----------------------------------------------- + +[1057] 0.0 0.00 0.00 tolua_region_set_resource [1057] + 0.00 0.00 1139/2032164 rt_find [597] + 0.00 0.00 1139/1139 region_setresource [1097] + 0.00 0.00 1762/7889 special_resources [1526] + 0.00 0.00 623/229715 rsettrees [1410] +----------------------------------------------- + 0.00 0.00 3355/3355 tolua_region_get_resource [976] +[1058] 0.0 0.00 0.00 3355 region_getresource [1058] + 0.00 0.00 6714/56052475 get_resourcetype [194] + 0.00 0.00 45/2605004 rpeasants [435] + 0.00 0.00 41/4666665 rmoney [452] + 0.00 0.00 3269/1160345 rhorses [1369] +----------------------------------------------- + 0.00 0.00 2/11 make_wormhole [1150] + 0.00 0.00 9/11 build_building [696] +[1059] 0.0 0.00 0.00 11 new_building [1059] + 0.00 0.00 11/10232 update_lighthouse [605] + 0.00 0.00 11/24887945 locale_string [27] + 0.00 0.00 11/5100840 itoa36 [116] + 0.00 0.00 3/218425 buildingtype [414] + 0.00 0.00 11/13 newcontainerid [1263] + 0.00 0.00 11/5461936 slprintf [548] + 0.00 0.00 11/46196 bhash [1464] +----------------------------------------------- + 0.00 0.00 47/47 reduce_weight [404] +[1060] 0.0 0.00 0.00 47 give_peasants [1060] + 0.00 0.00 47/1481407 parse_order [117] + 0.00 0.00 94/24887945 locale_string [27] + 0.00 0.00 47/5461936 slprintf [548] + 0.00 0.00 47/2009097 keyword [1355] + 0.00 0.00 47/48 unit_addorder [1684] +----------------------------------------------- + 0.00 0.00 5/569 datapath [1289] + 0.00 0.00 564/569 reportpath [1063] +[1061] 0.0 0.00 0.00 569 relpath [1061] + 0.00 0.00 569/34611296 strlcpy [45] +----------------------------------------------- + 0.00 0.00 8/8 magic [157] +[1062] 0.0 0.00 0.00 8 do_fumble [1062] + 0.00 0.00 1/10 sp_hain [931] + 0.00 0.00 15/967784 msg_message [132] + 0.00 0.00 15/392959 add_message [434] + 0.00 0.00 10/7641081 genrand_int31 [171] + 0.00 0.00 3/1873 set_spellpoints [933] + 0.00 0.00 1/1 fumble_default [1284] + 0.00 0.00 2/71815034 get_race [12] + 0.00 0.00 2/2831 countspells [903] + 0.00 0.00 2/3 trigger_changerace [1297] + 0.00 0.00 2/752645 chance [495] + 0.00 0.00 2/11 add_trigger [1260] + 0.00 0.00 2/129167539 u_race [89] + 0.00 0.00 1/2032164 rt_find [597] + 0.00 0.00 15/1009028 msg_release [1373] + 0.00 0.00 8/608 co_get_region [1594] + 0.00 0.00 2/5 trigger_timeout [1753] + 0.00 0.00 2/600145 u_setrace [1389] + 0.00 0.00 2/121 lua_callspell [1645] + 0.00 0.00 1/1 trigger_giveitem [1891] + 0.00 0.00 1/1 t_add [1865] +----------------------------------------------- + 0.00 0.00 1/564 load_inifile [1293] + 0.00 0.00 1/564 parse_inifile [1317] + 0.00 0.00 1/564 reports [2] + 0.00 0.00 2/564 create_directories [1294] + 0.00 0.00 559/564 write_reports [3] +[1063] 0.0 0.00 0.00 564 reportpath [1063] + 0.00 0.00 564/569 relpath [1061] +----------------------------------------------- + 0.00 0.00 1/1 magic [157] +[1064] 0.0 0.00 0.00 1 sp_flying_ship [1064] + 0.00 0.00 1/1 levitate_ship [1071] + 0.00 0.00 5/392959 add_message [434] + 0.00 0.00 1/967784 msg_message [132] + 0.00 0.00 1/608 co_get_region [1594] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 39/39 plan_dragon [273] +[1065] 0.0 0.00 0.00 39 random_growl [1065] + 0.00 0.00 39/967784 msg_message [132] + 0.00 0.00 39/1552289 rname [200] + 0.00 0.00 39/392959 add_message [434] + 0.00 0.00 39/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 83/303 create_castorder_combat [1137] + 0.00 0.00 220/303 cast_cmd [760] +[1066] 0.0 0.00 0.00 303 create_castorder [1066] + 0.00 0.00 303/635885 copy_order [441] + 0.00 0.00 303/499 MagicPower [1195] +----------------------------------------------- + 0.00 0.00 1/125 sp_enterastral [1045] + 0.00 0.00 124/125 age_stonecircle [1021] +[1067] 0.0 0.00 0.00 125 r_standard_to_astral [1067] + 0.00 0.00 125/125 tpregion [1085] + 0.00 0.00 125/987488 is_astral [479] +----------------------------------------------- + 0.00 0.00 1/1 magic [157] +[1068] 0.0 0.00 0.00 1 sp_holyground [1068] + 0.00 0.00 1/45 create_curse [800] + 0.00 0.00 1/967784 msg_message [132] + 0.00 0.00 1/1 report_spell [1301] + 0.00 0.00 1/12246335 ct_find [114] + 0.00 0.00 1/178429 a_removeall [958] + 0.00 0.00 1/608 co_get_region [1594] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1/48 tolua_unit_addnotice [1256] + 0.00 0.00 47/48 display_race [963] +[1069] 0.0 0.00 0.00 48 addmessage [1069] + 0.00 0.00 48/48 caddmessage [1070] +----------------------------------------------- + 0.00 0.00 48/48 addmessage [1069] +[1070] 0.0 0.00 0.00 48 caddmessage [1070] + 0.00 0.00 48/967784 msg_message [132] + 0.00 0.00 47/392959 add_message [434] + 0.00 0.00 1/12265 r_addmessage [779] + 0.00 0.00 48/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1/1 sp_flying_ship [1064] +[1071] 0.0 0.00 0.00 1 levitate_ship [1071] + 0.00 0.00 1/1 shipcurse_flyingship [1072] +----------------------------------------------- + 0.00 0.00 1/1 levitate_ship [1071] +[1072] 0.0 0.00 0.00 1 shipcurse_flyingship [1072] + 0.00 0.00 1/45 create_curse [800] + 0.00 0.00 2/12246335 ct_find [114] + 0.00 0.00 2/10190660 get_curse [143] + 0.00 0.00 2/4201030 curse_active [543] + 0.00 0.00 1/651711 oldcursename [1381] +----------------------------------------------- + 0.00 0.00 2096/2096 a_write [299] +[1073] 0.0 0.00 0.00 2096 a_writeeffect [1073] + 0.00 0.00 2096/13259934 resourcename [233] +----------------------------------------------- + 0.00 0.00 1/1 tolua_write_passwords [1075] +[1074] 0.0 0.00 0.00 1 writepasswd [1074] + 0.00 0.00 232/5100840 itoa36 [116] + 0.00 0.00 1/573 join_path [1016] + 0.00 0.00 1/64 log_info [1339] + 0.00 0.00 1/9 basepath [1730] +----------------------------------------------- + +[1075] 0.0 0.00 0.00 tolua_write_passwords [1075] + 0.00 0.00 1/1 writepasswd [1074] +----------------------------------------------- + 0.00 0.00 124/124 parse_symbol [42] +[1076] 0.0 0.00 0.00 124 eval_unit_dative [1076] + 0.00 0.00 122/2383101 unitname [142] + 0.00 0.00 124/13102790 opstack_pop [176] + 0.00 0.00 124/13102790 opstack_push [202] + 0.00 0.00 124/13399069 balloc [363] + 0.00 0.00 2/24887945 locale_string [27] +----------------------------------------------- + 0.00 0.00 9312/21517 spawn_undead [629] + 0.00 0.00 12205/21517 spawn_dragons [411] +[1077] 0.0 0.00 0.00 21517 chaosfactor [1077] + 0.00 0.00 981/179235 get_chaoscount [717] +----------------------------------------------- + 0.00 0.00 3/404 use_healingpotion [1119] + 0.00 0.00 56/404 use_bloodpotion [935] + 0.00 0.00 345/404 end_potion [814] +[1078] 0.0 0.00 0.00 404 usetpotionuse [1078] + 0.00 0.00 389/779419 a_add [555] + 0.00 0.00 404/51974272 a_find [65] + 0.00 0.00 389/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 4782/4782 expandrecruit [349] +[1079] 0.0 0.00 0.00 4782 select_recruitment [1079] + 0.00 0.00 3340/129167539 u_race [89] + 0.00 0.00 1670/1670 any_recruiters [1566] + 0.00 0.00 1670/1670 horse_recruiters [1567] +----------------------------------------------- + 0.00 0.00 127/127 tolua_msg_create [1081] +[1080] 0.0 0.00 0.00 127 msg_create_message [1080] + 0.00 0.00 127/1010116 mt_find [227] +----------------------------------------------- + +[1081] 0.0 0.00 0.00 tolua_msg_create [1081] + 0.00 0.00 127/127 msg_create_message [1080] +----------------------------------------------- + 0.00 0.00 9/9 move_icebergs [534] +[1082] 0.0 0.00 0.00 9 melt_iceberg [1082] + 0.00 0.00 9/105 terraform_region [932] + 0.00 0.00 9/178263 drown [394] + 0.00 0.00 8/451774 a_remove [366] + 0.00 0.00 3/967784 msg_message [132] + 0.00 0.00 3/392959 add_message [434] + 0.00 0.00 9/51974272 a_find [65] + 0.00 0.00 9/1511812 newterrain [1359] + 0.00 0.00 3/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 114/735 u_setfaction [1111] + 0.00 0.00 621/735 group_cmd [985] +[1083] 0.0 0.00 0.00 735 join_group [1083] + 0.00 0.00 735/1270 set_group [1048] + 0.00 0.00 453/453 find_groupbyname [1217] + 0.00 0.00 3/1697 new_group [1565] + 0.00 0.00 3/3 init_group [1764] +----------------------------------------------- + 0.00 0.00 48/48 terraform_region [932] +[1084] 0.0 0.00 0.00 48 makename [1084] + 0.00 0.00 598/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 125/125 r_standard_to_astral [1067] +[1085] 0.0 0.00 0.00 125 tpregion [1085] + 0.00 0.00 125/459083 findregion [420] + 0.00 0.00 125/987488 is_astral [479] + 0.00 0.00 250/250 real2tp [1612] +----------------------------------------------- + 0.00 0.00 1/1 read_xml [791] +[1086] 0.0 0.00 0.00 1 parse_resources [1086] + 0.00 0.00 157/157 xml_readitem [1107] + 0.00 0.00 12/39 bt_get_or_create [1114] + 0.00 0.00 159/383 rt_get_or_create [1139] + 0.00 0.00 1/1 init_resources [1228] + 0.00 0.00 7/779419 a_add [555] + 0.00 0.00 2/68430117 rc_find [15] + 0.00 0.00 2/150 rc_get_or_create [1105] + 0.00 0.00 7/51974272 a_find [65] + 0.00 0.00 1/1 init_itemtypes [1307] + 0.00 0.00 318/6576 xml_bvalue [1532] + 0.00 0.00 54/54 it_set_appearance [1679] + 0.00 0.00 19/178 parse_function [1637] + 0.00 0.00 7/7 rmt_create [1741] + 0.00 0.00 7/779868 a_new [1376] + 0.00 0.00 6/501 xml_fvalue [1599] + 0.00 0.00 6/465 get_function [1600] + 0.00 0.00 4/5453 xml_ivalue [1533] +----------------------------------------------- + 0.00 0.00 49/49 plan_dragon [273] +[1087] 0.0 0.00 0.00 49 get_money_for_dragon [1087] + 0.00 0.00 10/160206 monster_attacks [248] + 0.00 0.00 43/447808 create_order [341] + 0.00 0.00 43/752645 chance [495] + 0.00 0.00 59/4666665 rmoney [452] + 0.00 0.00 10/6610983 is_guard [211] + 0.00 0.00 43/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 9/188 travel_route [147] + 0.00 0.00 179/188 check_ship_allowed [657] +[1088] 0.0 0.00 0.00 188 is_freezing [1088] + 0.00 0.00 188/71815034 get_race [12] + 0.00 0.00 188/129167539 u_race [89] + 0.00 0.00 9/12246335 ct_find [114] + 0.00 0.00 9/10190660 get_curse [143] + 0.00 0.00 9/4201030 curse_active [543] + 0.00 0.00 9/651711 oldcursename [1381] +----------------------------------------------- + 0.00 0.00 3/3 make_name [970] +[1089] 0.0 0.00 0.00 3 count_particles [1089] + 0.00 0.00 117/779486 locale_getstring [266] +----------------------------------------------- + 0.00 0.00 1/328 reshow_other [823] + 0.00 0.00 327/328 reshow [822] +[1090] 0.0 0.00 0.00 328 display_potion [1090] + 0.00 0.00 328/779419 a_add [555] + 0.00 0.00 328/51974272 a_find [65] + 0.00 0.00 328/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 75/1583 drain_exp [850] + 0.00 0.00 1508/1583 demon_skillchange [826] +[1091] 0.0 0.00 0.00 1583 reduce_skill [1091] + 0.00 0.00 27/47562 skill_weeks [509] +----------------------------------------------- + 0.00 0.00 4/793 cast_cmd [760] + 0.00 0.00 5/793 count_skill [868] + 0.00 0.00 260/793 is_migrant [1047] + 0.00 0.00 524/793 study_cmd [105] +[1092] 0.0 0.00 0.00 793 is_familiar [1092] + 0.00 0.00 793/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 12/12 economics [78] +[1093] 0.0 0.00 0.00 12 forget_cmd [1093] + 0.00 0.00 12/2457 set_level [774] + 0.00 0.00 12/967784 msg_message [132] + 0.00 0.00 12/392959 add_message [434] + 0.00 0.00 12/2281756 gettoken [195] + 0.00 0.00 12/996009 get_skill [423] + 0.00 0.00 6/12246335 ct_find [114] + 0.00 0.00 12/1027665 init_order [613] + 0.00 0.00 6/10190660 get_curse [143] + 0.00 0.00 6/4201030 curse_active [543] + 0.00 0.00 12/1009028 msg_release [1373] + 0.00 0.00 6/651711 oldcursename [1381] +----------------------------------------------- + 0.00 0.00 7/27 create_icebergs [538] + 0.00 0.00 20/27 move_icebergs [534] +[1094] 0.0 0.00 0.00 27 move_iceberg [1094] + 0.00 0.00 1/6963 move_ship [374] + 0.00 0.00 4/967784 msg_message [132] + 0.00 0.00 37/7641081 genrand_int31 [171] + 0.00 0.00 36/36 runhash [1247] + 0.00 0.00 36/178290 rhash [737] + 0.00 0.00 27/51974272 a_find [65] + 0.00 0.00 4/392959 add_message [434] + 0.00 0.00 13/779419 a_add [555] + 0.00 0.00 1/369586 r_connect [474] + 0.00 0.00 1/3358315 ship_owner [438] + 0.00 0.00 1/717218 config_get_flt [714] + 0.00 0.00 13/13 make_iceberg [1718] + 0.00 0.00 4/1009028 msg_release [1373] + 0.00 0.00 1/160 damage_ship [1641] +----------------------------------------------- + 0.00 0.00 27/27 race_namegen [905] +[1095] 0.0 0.00 0.00 27 dragon_name [1095] + 0.00 0.00 58/779486 locale_getstring [266] + 0.00 0.00 92/7641081 genrand_int31 [171] + 0.00 0.00 18/1552289 rname [200] + 0.00 0.00 22/34611296 strlcpy [45] + 0.00 0.00 52/987128 strlcat [1374] + 0.00 0.00 27/560 oldterrain [1596] + 0.00 0.00 27/3862 unit_setname [1540] +----------------------------------------------- + 0.00 0.00 348/348 use_potion [801] +[1096] 0.0 0.00 0.00 348 begin_potion [1096] + 0.00 0.00 348/348 ugetpotionuse [1133] + 0.00 0.00 348/4984610 config_get_int [348] + 0.00 0.00 3/967784 msg_message [132] + 0.00 0.00 3/392959 add_message [434] + 0.00 0.00 3/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1139/1139 tolua_region_set_resource [1057] +[1097] 0.0 0.00 0.00 1139 region_setresource [1097] + 0.00 0.00 3335/56052475 get_resourcetype [194] + 0.00 0.00 41/2186159 rsetmoney [553] + 0.00 0.00 1098/257693 rsethorses [1408] +----------------------------------------------- + 0.00 0.00 295/295 age_unit [336] +[1098] 0.0 0.00 0.00 295 age_dragon [1098] + 0.00 0.00 295/7641081 genrand_int31 [171] + 0.00 0.00 10/1381157 unit_max_hp [136] + 0.00 0.00 5/71815034 get_race [12] + 0.00 0.00 5/600145 u_setrace [1389] +----------------------------------------------- + 0.00 0.00 2/2 init_locale [948] +[1099] 0.0 0.00 0.00 2 init_keywords [1099] + 0.00 0.00 2/6 init_translations [1033] +----------------------------------------------- + 0.00 0.00 2/2 init_locale [948] +[1100] 0.0 0.00 0.00 2 init_parameters [1100] + 0.00 0.00 2/6 init_translations [1033] +----------------------------------------------- + 0.00 0.00 2/2 init_locale [948] +[1101] 0.0 0.00 0.00 2 init_skills [1101] + 0.00 0.00 2/6 init_translations [1033] +----------------------------------------------- + 0.00 0.00 78/78 parse_symbol [42] +[1102] 0.0 0.00 0.00 78 eval_weight [1102] + 0.00 0.00 78/24887945 locale_string [27] + 0.00 0.00 78/13102790 opstack_pop [176] + 0.00 0.00 78/13102790 opstack_push [202] + 0.00 0.00 78/13399069 balloc [363] +----------------------------------------------- + +[1103] 0.0 0.00 0.00 tolua_unit_add_item [1103] + 0.00 0.00 121/1177511 it_find [385] + 0.00 0.00 121/11241829 i_change [115] +----------------------------------------------- + 0.00 0.00 1/1 read_xml [791] +[1104] 0.0 0.00 0.00 1 parse_races [1104] + 0.00 0.00 146/150 rc_get_or_create [1105] + 0.00 0.00 68/717287 get_param_flt [713] + 0.00 0.00 2798/6576 xml_bvalue [1532] + 0.00 0.00 2706/5453 xml_ivalue [1533] + 0.00 0.00 820/1041 findskill [1586] + 0.00 0.00 340/501 xml_fvalue [1599] + 0.00 0.00 69/178 parse_function [1637] + 0.00 0.00 67/67 parse_ai [1662] + 0.00 0.00 11/11 xml_spell [1727] + 0.00 0.00 3/3 parse_param [1765] +----------------------------------------------- + 0.00 0.00 2/150 xml_readweapon [1266] + 0.00 0.00 2/150 parse_resources [1086] + 0.00 0.00 146/150 parse_races [1104] +[1105] 0.0 0.00 0.00 150 rc_get_or_create [1105] + 0.00 0.00 150/68430271 rc_find_i [16] + 0.00 0.00 68/68 rc_create [1661] +----------------------------------------------- + 0.00 0.00 4/4 mail_cmd [844] +[1106] 0.0 0.00 0.00 4 mailfaction [1106] + 0.00 0.00 4/39 deliverMail [966] + 0.00 0.00 4/4625636 findfaction [259] +----------------------------------------------- + 0.00 0.00 157/157 parse_resources [1086] +[1107] 0.0 0.00 0.00 157 xml_readitem [1107] + 0.00 0.00 157/185 it_get_or_create [1115] + 0.00 0.00 157/191 xml_readconstruction [1183] + 0.00 0.00 23/23 xml_readweapon [1266] + 0.00 0.00 942/6576 xml_bvalue [1532] + 0.00 0.00 471/5453 xml_ivalue [1533] + 0.00 0.00 72/72 default_score [1659] + 0.00 0.00 55/178 parse_function [1637] + 0.00 0.00 15/15 xml_readpotion [1714] + 0.00 0.00 8/8 xml_readarmor [1736] + 0.00 0.00 7/7 xml_readluxury [1745] +----------------------------------------------- + 0.00 0.00 1761/1761 give_item [126] +[1108] 0.0 0.00 0.00 1761 give_horses [1108] + 0.00 0.00 5/860263 use_pooled [39] + 0.00 0.00 5/283711 item2resource [561] + 0.00 0.00 5/1160345 rhorses [1369] + 0.00 0.00 5/257693 rsethorses [1408] +----------------------------------------------- + 0.00 0.00 114/702 give_unit [952] + 0.00 0.00 588/702 give_men [857] +[1109] 0.0 0.00 0.00 702 max_transfers [1109] + 0.00 0.00 702/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 62/62 msg_curse [664] +[1110] 0.0 0.00 0.00 62 cinfo_speed [1110] + 0.00 0.00 28/967784 msg_message [132] +----------------------------------------------- + 0.00 0.00 1/598129 make_zombie [1267] + 0.00 0.00 2/598129 sp_charmingsong [993] + 0.00 0.00 112/598129 give_unit [952] + 0.00 0.00 2889/598129 create_unit [296] + 0.00 0.00 595125/598129 read_unit [74] +[1111] 0.0 0.00 0.00 598129 u_setfaction [1111] + 0.00 0.00 114/1644867 free_orders [306] + 0.00 0.00 114/735 join_group [1083] + 0.00 0.00 114/3383689 update_interval [551] + 0.00 0.00 228/603524 set_number [1387] + 0.00 0.00 114/1291427 set_order [1365] +----------------------------------------------- + 0.00 0.00 199/95593 travel_i [92] + 0.00 0.00 734/95593 leave [432] + 0.00 0.00 94660/95593 travel [81] +[1112] 0.0 0.00 0.00 95593 can_leave [1112] + 0.00 0.00 688/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 23/23 economics [78] +[1113] 0.0 0.00 0.00 23 destroy_cmd [1113] + 0.00 0.00 22/15102 cmistake [718] + 0.00 0.00 38/2281756 gettoken [195] + 0.00 0.00 1/1 destroy_road [1230] + 0.00 0.00 22/1027665 init_order [613] + 0.00 0.00 1/534930 isparam [668] +----------------------------------------------- + 0.00 0.00 12/39 parse_resources [1086] + 0.00 0.00 27/39 parse_buildings [1131] +[1114] 0.0 0.00 0.00 39 bt_get_or_create [1114] + 0.00 0.00 39/560965 bt_find_i [236] + 0.00 0.00 27/27 bt_register [1698] +----------------------------------------------- + 0.00 0.00 1/185 init_resources [1228] + 0.00 0.00 27/185 json_terrain [1189] + 0.00 0.00 157/185 xml_readitem [1107] +[1115] 0.0 0.00 0.00 185 it_get_or_create [1115] + 0.00 0.00 185/1177511 it_find [385] + 0.00 0.00 185/185 it_register [1636] +----------------------------------------------- + 0.00 0.00 7/7 sp_healing [989] +[1116] 0.0 0.00 0.00 7 scramble_fighters [1116] + 0.00 0.00 290/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 4/4 mail_cmd [844] +[1117] 0.0 0.00 0.00 4 seefaction [1117] + 0.00 0.00 4/1437425 cansee [22] +----------------------------------------------- + 0.00 0.00 134/134 msg_curse [664] +[1118] 0.0 0.00 0.00 134 cinfo_slave [1118] + 0.00 0.00 24/967784 msg_message [132] +----------------------------------------------- + 0.00 0.00 3/3 use_item [765] +[1119] 0.0 0.00 0.00 3 use_healingpotion [1119] + 0.00 0.00 3/860263 use_pooled [39] + 0.00 0.00 3/967784 msg_message [132] + 0.00 0.00 4/4 heal [1224] + 0.00 0.00 3/392959 add_message [434] + 0.00 0.00 3/404 usetpotionuse [1078] + 0.00 0.00 3/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1/1 read_xml [791] +[1120] 0.0 0.00 0.00 1 parse_spells [1120] + 0.00 0.00 137/34611296 strlcpy [45] + 0.00 0.00 233/2032164 rt_find [597] + 0.00 0.00 1660/6576 xml_bvalue [1532] + 0.00 0.00 731/5453 xml_ivalue [1533] + 0.00 0.00 274/465 get_function [1600] + 0.00 0.00 166/166 create_spell [1639] + 0.00 0.00 29/178 parse_function [1637] +----------------------------------------------- + 0.00 0.00 12/60 kill_troop [532] + 0.00 0.00 48/60 terraform_region [932] +[1121] 0.0 0.00 0.00 60 equip_items [1121] + 0.00 0.00 23/146997 dice_rand [409] + 0.00 0.00 23/822780 i_new [1375] + 0.00 0.00 23/87004 i_add [1442] +----------------------------------------------- + 0.00 0.00 23/48 join_allies [693] + 0.00 0.00 25/48 allysf [1160] +[1122] 0.0 0.00 0.00 48 allysfm [1122] + 0.00 0.00 27/10375491 alliedgroup [34] + 0.00 0.00 14/1205451 alliedfaction [162] +----------------------------------------------- + 0.00 0.00 182/182 age_unit [336] +[1123] 0.0 0.00 0.00 182 age_firedragon [1123] + 0.00 0.00 182/7641081 genrand_int31 [171] + 0.00 0.00 8/1381157 unit_max_hp [136] + 0.00 0.00 4/71815034 get_race [12] + 0.00 0.00 4/3178 scale_number [969] + 0.00 0.00 4/600145 u_setrace [1389] +----------------------------------------------- + 0.00 0.00 1/1 json_config [464] +[1124] 0.0 0.00 0.00 1 json_keywords [1124] + 0.00 0.00 2/2 json_keyword [1127] + 0.00 0.00 2/6 get_or_create_locale [1275] +----------------------------------------------- + 0.00 0.00 206/206 aftermath [701] +[1125] 0.0 0.00 0.00 206 battle_effects [1125] + 0.00 0.00 246/2605004 rpeasants [435] + 0.00 0.00 34/264251 rsetpeasants [545] + 0.00 0.00 34/37974 deathcounts [843] + 0.00 0.00 34/18059 add_chaoscount [1198] + 0.00 0.00 406/406 PopulationDamage [1605] +----------------------------------------------- + 0.00 0.00 34/34 race_namegen [905] +[1126] 0.0 0.00 0.00 34 dracoid_name [1126] + 0.00 0.00 208/7641081 genrand_int31 [171] + 0.00 0.00 34/34611296 strlcpy [45] + 0.00 0.00 109/987128 strlcat [1374] + 0.00 0.00 34/3862 unit_setname [1540] +----------------------------------------------- + 0.00 0.00 2/2 json_keywords [1124] +[1127] 0.0 0.00 0.00 2 json_keyword [1127] + 0.00 0.00 61/3496 locale_setstring [918] + 0.00 0.00 107/107 init_keyword [1179] + 0.00 0.00 61/4133717 mkname [261] + 0.00 0.00 61/65 findkeyword [1665] +----------------------------------------------- + 0.00 0.00 167/167 teach_cmd [272] +[1128] 0.0 0.00 0.00 167 academy_teaching_bonus [1128] + 0.00 0.00 167/892307 learn_skill [471] +----------------------------------------------- + 0.00 0.00 2/2 init_locale [948] +[1129] 0.0 0.00 0.00 2 init_terrains_translation [1129] + 0.00 0.00 36/24887945 locale_string [27] + 0.00 0.00 36/8993 addtoken [811] + 0.00 0.00 2/4558423 get_translations [437] + 0.00 0.00 2/4 terrains [1760] +----------------------------------------------- + 0.00 0.00 2/2 a_age [418] +[1130] 0.0 0.00 0.00 2 wormhole_age [1130] + 0.00 0.00 2/2 remove_building [1153] + 0.00 0.00 3/967784 msg_message [132] + 0.00 0.00 4/392959 add_message [434] + 0.00 0.00 1/109785 move_unit [421] + 0.00 0.00 3/1009028 msg_release [1373] + 0.00 0.00 1/1 has_limited_skills [1808] +----------------------------------------------- + 0.00 0.00 1/1 read_xml [791] +[1131] 0.0 0.00 0.00 1 parse_buildings [1131] + 0.00 0.00 27/39 bt_get_or_create [1114] + 0.00 0.00 27/191 xml_readconstruction [1183] + 0.00 0.00 17/2032164 rt_find [597] + 0.00 0.00 1/1 init_smithy [1312] + 0.00 0.00 250/6576 xml_bvalue [1532] + 0.00 0.00 179/5453 xml_ivalue [1533] + 0.00 0.00 27/501 xml_fvalue [1599] + 0.00 0.00 3/178 parse_function [1637] +----------------------------------------------- + 0.00 0.00 38/38 loot_items [810] +[1132] 0.0 0.00 0.00 38 select_ally [1132] + 0.00 0.00 33/1662377 get_unitrow [154] + 0.00 0.00 38/38 count_allies [1220] + 0.00 0.00 29/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 348/348 begin_potion [1096] +[1133] 0.0 0.00 0.00 348 ugetpotionuse [1133] + 0.00 0.00 348/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 5/234 give_men [857] + 0.00 0.00 5/234 transfermen [899] + 0.00 0.00 224/234 leave_ship [540] +[1134] 0.0 0.00 0.00 234 set_leftship [1134] + 0.00 0.00 234/779419 a_add [555] + 0.00 0.00 234/234 make_leftship [1615] +----------------------------------------------- + 0.00 0.00 324/1572 report_computer [9] + 0.00 0.00 324/1572 report_plaintext [4] + 0.00 0.00 924/1572 score [23] +[1135] 0.0 0.00 0.00 1572 write_score [1135] + 0.00 0.00 1572/5461936 slprintf [548] +----------------------------------------------- + 0.00 0.00 224/457 update_spells [381] + 0.00 0.00 233/457 readfaction [767] +[1136] 0.0 0.00 0.00 457 FactionSpells [1136] + 0.00 0.00 457/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 9/83 do_combatmagic [825] + 0.00 0.00 74/83 cast_combatspell [623] +[1137] 0.0 0.00 0.00 83 create_castorder_combat [1137] + 0.00 0.00 83/303 create_castorder [1066] +----------------------------------------------- + 0.00 0.00 102761/102761 give_cmd [102] +[1138] 0.0 0.00 0.00 102761 check_give [1138] + 0.00 0.00 22/41248 msg_feedback [647] + 0.00 0.00 102761/217696 can_give [1335] +----------------------------------------------- + 0.00 0.00 6/383 init_resources [1228] + 0.00 0.00 56/383 json_terrain [1189] + 0.00 0.00 159/383 parse_resources [1086] + 0.00 0.00 162/383 xml_readrequirements [1186] +[1139] 0.0 0.00 0.00 383 rt_get_or_create [1139] + 0.00 0.00 545/2032164 rt_find [597] + 0.00 0.00 162/162 rt_register [1640] +----------------------------------------------- + 0.00 0.00 44/44 ct_checknames [1142] +[1140] 0.0 0.00 0.00 44 curse_name [1140] + 0.00 0.00 44/24887945 locale_string [27] + 0.00 0.00 44/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 1/1 init_reports [399] +[1141] 0.0 0.00 0.00 1 check_messages_exist [1141] + 0.00 0.00 1/1 ct_checknames [1142] +----------------------------------------------- + 0.00 0.00 1/1 check_messages_exist [1141] +[1142] 0.0 0.00 0.00 1 ct_checknames [1142] + 0.00 0.00 44/44 curse_name [1140] +----------------------------------------------- + 0.00 0.00 2/2 init_locale [948] +[1143] 0.0 0.00 0.00 2 init_directions [1143] + 0.00 0.00 26/24887945 locale_string [27] + 0.00 0.00 26/8993 addtoken [811] + 0.00 0.00 2/2 register_special_direction [1259] + 0.00 0.00 2/4558423 get_translations [437] +----------------------------------------------- + 0.00 0.00 176/176 kill_troop [532] +[1144] 0.0 0.00 0.00 176 default_spoil [1144] + 0.00 0.00 176/7641081 genrand_int31 [171] + 0.00 0.00 9/1177511 it_find [385] + 0.00 0.00 9/822780 i_new [1375] + 0.00 0.00 9/87004 i_add [1442] +----------------------------------------------- + 0.00 0.00 107/371 init_keyword [1179] + 0.00 0.00 264/371 init_translations [1033] +[1145] 0.0 0.00 0.00 371 add_translation [1145] + 0.00 0.00 371/4457785 transliterate [358] +----------------------------------------------- + 0.00 0.00 10/10 combatspell_cmd [898] +[1146] 0.0 0.00 0.00 10 set_combatspell [1146] + 0.00 0.00 10/492 u_hasspell [951] + 0.00 0.00 10/482 knowsspell [956] + 0.00 0.00 10/2426021 get_mage [198] +----------------------------------------------- + 0.00 0.00 115/115 contact_cmd [965] +[1147] 0.0 0.00 0.00 115 usetcontact [1147] + 0.00 0.00 114/779419 a_add [555] + 0.00 0.00 115/51974272 a_find [65] + 0.00 0.00 114/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 2/2 breed_cmd [741] +[1148] 0.0 0.00 0.00 2 breedtrees [1148] + 0.00 0.00 1/860263 use_pooled [39] + 0.00 0.00 1/1 planttrees [1206] + 0.00 0.00 1/541982 get_pooled [104] + 0.00 0.00 1/967784 msg_message [132] + 0.00 0.00 2/12320804 effskill [100] + 0.00 0.00 1/472418 produceexp [322] + 0.00 0.00 1/392959 add_message [434] + 0.00 0.00 1/7641081 genrand_int31 [171] + 0.00 0.00 1/10053919 rtrees [302] + 0.00 0.00 2/56052475 get_resourcetype [194] + 0.00 0.00 2/40692 get_gamedate [1466] + 0.00 0.00 1/229715 rsettrees [1410] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1245/1245 leveled_allocation [888] +[1149] 0.0 0.00 0.00 1245 use_default [1149] + 0.00 0.00 170/7641081 genrand_int31 [171] + 0.00 0.00 85/143 update_resource [1237] +----------------------------------------------- + 0.00 0.00 1/1 make_wormholes [1151] +[1150] 0.0 0.00 0.00 1 make_wormhole [1150] + 0.00 0.00 2/11 new_building [1059] + 0.00 0.00 2/967784 msg_message [132] + 0.00 0.00 2/392959 add_message [434] + 0.00 0.00 2/779419 a_add [555] + 0.00 0.00 2/779868 a_new [1376] + 0.00 0.00 2/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1/1 wormholes_update [906] +[1151] 0.0 0.00 0.00 1 make_wormholes [1151] + 0.00 0.00 1/1 make_wormhole [1150] +----------------------------------------------- + 0.00 0.00 1/22 destroy_road [1230] + 0.00 0.00 21/22 build_road [950] +[1152] 0.0 0.00 0.00 22 rsetroad [1152] + 0.00 0.00 22/2225796 get_borders [120] + 0.00 0.00 6/22644 new_border [705] +----------------------------------------------- + 0.00 0.00 2/2 wormhole_age [1130] +[1153] 0.0 0.00 0.00 2 remove_building [1153] + 0.00 0.00 2/10232 update_lighthouse [605] + 0.00 0.00 6/560926 bt_find [237] + 0.00 0.00 2/48457 bfindhash [1461] + 0.00 0.00 2/1342832 handle_event [1363] + 0.00 0.00 2/12 bunhash [1720] +----------------------------------------------- + 0.00 0.00 3/3 sp_charmingsong [993] +[1154] 0.0 0.00 0.00 3 target_resists_magic [1154] + 0.00 0.00 20/12320804 eff_skill [334] + 0.00 0.00 3/7957 magic_resistance [727] + 0.00 0.00 3/12320804 effskill [100] + 0.00 0.00 3/752645 chance [495] +----------------------------------------------- + 0.00 0.00 1/3 tolua_get_nmrs [1208] + 0.00 0.00 2/3 report_summary [614] +[1155] 0.0 0.00 0.00 3 update_nmrs [1155] + 0.00 0.00 52/5100840 itoa36 [116] + 0.00 0.00 3/27 NMRTimeout [1264] + 0.00 0.00 52/49235 log_debug [1245] +----------------------------------------------- + 0.00 0.00 1/1 process [7] +[1156] 0.0 0.00 0.00 1 renumber_factions [1156] + 0.00 0.00 232/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 2/2 init_locale [948] +[1157] 0.0 0.00 0.00 2 init_options_translation [1157] + 0.00 0.00 22/24887945 locale_string [27] + 0.00 0.00 22/8993 addtoken [811] + 0.00 0.00 2/4558423 get_translations [437] +----------------------------------------------- + 0.00 0.00 14/14 sp_healing [989] +[1158] 0.0 0.00 0.00 14 heal_fighters [1158] + 0.00 0.00 802/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 55/55 renumber_cmd [780] +[1159] 0.0 0.00 0.00 55 renumber_unit [1159] + 0.00 0.00 55/779419 a_add [555] + 0.00 0.00 55/285923 ualias [692] + 0.00 0.00 55/598069 uhash [667] + 0.00 0.00 55/1848 uunhash [1049] + 0.00 0.00 55/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 8/25 fighters [1012] + 0.00 0.00 17/25 helping [1177] +[1160] 0.0 0.00 0.00 25 allysf [1160] + 0.00 0.00 25/48 allysfm [1122] +----------------------------------------------- + +[1161] 0.0 0.00 0.00 config_get_locales [1161] + 0.00 0.00 2/11719 locale_name [568] + 0.00 0.00 4/4 nextlocale [1758] +----------------------------------------------- + 0.00 0.00 58/58 terraform_resources [986] +[1162] 0.0 0.00 0.00 58 add_resource [1162] + 0.00 0.00 58/58 terraform_default [1165] + 0.00 0.00 58/143 update_resource [1237] + 0.00 0.00 58/58 rmt_get [1672] +----------------------------------------------- + +[1163] 0.0 0.00 0.00 tolua_unit_setskill [1163] + 0.00 0.00 6/2457 set_level [774] + 0.00 0.00 6/1041 findskill [1586] +----------------------------------------------- + 0.00 0.00 1/1 read_game [62] +[1164] 0.0 0.00 0.00 1 read_planes [1164] + 0.00 0.00 13/760673 addlist [217] + 0.00 0.00 13/840577 read_attribs [388] + 0.00 0.00 13/13 getplanebyid [1717] + 0.00 0.00 13/51239 read_faction_reference [1455] +----------------------------------------------- + 0.00 0.00 58/58 add_resource [1162] +[1165] 0.0 0.00 0.00 58 terraform_default [1165] + 0.00 0.00 116/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 10/10 read_triggers [798] +[1166] 0.0 0.00 0.00 10 changefaction_read [1166] + 0.00 0.00 10/9763 read_reference [726] + 0.00 0.00 10/51239 read_faction_reference [1455] + 0.00 0.00 10/34565 ur_add [1472] +----------------------------------------------- + 0.00 0.00 43/43 combatspell_cmd [898] +[1167] 0.0 0.00 0.00 43 unset_combatspell [1167] + 0.00 0.00 43/2426021 get_mage [198] +----------------------------------------------- + 0.00 0.00 2/462 report_summary [614] + 0.00 0.00 230/462 report_computer [9] + 0.00 0.00 230/462 report_plaintext [4] +[1168] 0.0 0.00 0.00 462 game_name [1168] + 0.00 0.00 462/20777534 config_get [224] +----------------------------------------------- + 0.00 0.00 61/61 parse_equipment [1170] +[1169] 0.0 0.00 0.00 61 add_items [1169] + 0.00 0.00 66/1177511 it_find [385] + 0.00 0.00 65/65 equipment_setitem [1664] +----------------------------------------------- + 0.00 0.00 1/1 read_xml [791] +[1170] 0.0 0.00 0.00 1 parse_equipment [1170] + 0.00 0.00 61/61 add_items [1169] + 0.00 0.00 61/73 create_equipment [1658] + 0.00 0.00 61/61 add_callbacks [1666] + 0.00 0.00 61/61 add_spells [1668] + 0.00 0.00 61/61 add_skills [1667] + 0.00 0.00 61/61 add_subsets [1669] +----------------------------------------------- + 0.00 0.00 231/231 remove_idle_players [391] +[1171] 0.0 0.00 0.00 231 RemoveNMRNewbie [1171] + 0.00 0.00 231/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 1/1583 can_charm [1338] + 0.00 0.00 4/1583 study_cmd [105] + 0.00 0.00 1578/1583 build [691] +[1172] 0.0 0.00 0.00 1583 skill_limit [1172] + 0.00 0.00 226/4984610 config_get_int [348] + 0.00 0.00 1583/1583 allied_skilllimit [1330] +----------------------------------------------- + 0.00 0.00 26/26 cast_cmd [760] +[1173] 0.0 0.00 0.00 26 add_spellparameter [1173] + 0.00 0.00 22/22 addparam_ship [1212] + 0.00 0.00 16/16 addparam_unit [1214] + 0.00 0.00 6/6 addparam_building [1261] +----------------------------------------------- + 0.00 0.00 125/125 chaos [848] +[1174] 0.0 0.00 0.00 125 random_unit [1174] + 0.00 0.00 31/71815034 get_race [12] + 0.00 0.00 15/7641081 genrand_int31 [171] + 0.00 0.00 31/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 1/207 init_processor [1310] + 0.00 0.00 206/207 do_battle [64] +[1175] 0.0 0.00 0.00 207 rule_force_leave [1175] + 0.00 0.00 207/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 62/62 do_potion [941] +[1176] 0.0 0.00 0.00 62 potion_luck [1176] + 0.00 0.00 58/779419 a_add [555] + 0.00 0.00 62/51974272 a_find [65] + 0.00 0.00 58/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 432/432 get_tactics [1178] +[1177] 0.0 0.00 0.00 432 helping [1177] + 0.00 0.00 17/25 allysf [1160] +----------------------------------------------- + 0.00 0.00 378/378 battle_attacks [79] +[1178] 0.0 0.00 0.00 378 get_tactics [1178] + 0.00 0.00 432/432 helping [1177] +----------------------------------------------- + 0.00 0.00 107/107 json_keyword [1127] +[1179] 0.0 0.00 0.00 107 init_keyword [1179] + 0.00 0.00 107/371 add_translation [1145] + 0.00 0.00 107/4558423 get_translations [437] +----------------------------------------------- + 0.00 0.00 191/191 enter_ship [733] +[1180] 0.0 0.00 0.00 191 CheckOverload [1180] + 0.00 0.00 191/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 174/174 breed_cmd [741] +[1181] 0.0 0.00 0.00 174 findresourcetype [1181] + 0.00 0.00 174/4457785 transliterate [358] + 0.00 0.00 174/2124526 locale_index [1354] +----------------------------------------------- + 0.00 0.00 54/54 parse_symbol [42] +[1182] 0.0 0.00 0.00 54 eval_add [1182] + 0.00 0.00 108/13102790 opstack_pop [176] + 0.00 0.00 54/13102790 opstack_push [202] +----------------------------------------------- + 0.00 0.00 7/191 parse_ships [1305] + 0.00 0.00 27/191 parse_buildings [1131] + 0.00 0.00 157/191 xml_readitem [1107] +[1183] 0.0 0.00 0.00 191 xml_readconstruction [1183] + 0.00 0.00 84/84 xml_readrequirements [1186] + 0.00 0.00 1/779419 a_add [555] + 0.00 0.00 504/5453 xml_ivalue [1533] + 0.00 0.00 84/1041 findskill [1586] + 0.00 0.00 1/465 get_function [1600] + 0.00 0.00 1/2 make_skillmod [1777] +----------------------------------------------- + 0.00 0.00 1/1 breed_cmd [741] +[1184] 0.0 0.00 0.00 1 plant [1184] + 0.00 0.00 2/541982 get_pooled [104] + 0.00 0.00 1/41248 msg_feedback [647] + 0.00 0.00 1/12320804 effskill [100] + 0.00 0.00 1/392959 add_message [434] + 0.00 0.00 1/56052475 get_resourcetype [194] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 508/508 regeneration [942] +[1185] 0.0 0.00 0.00 508 MagicRegeneration [1185] + 0.00 0.00 508/717218 config_get_flt [714] +----------------------------------------------- + 0.00 0.00 84/84 xml_readconstruction [1183] +[1186] 0.0 0.00 0.00 84 xml_readrequirements [1186] + 0.00 0.00 162/383 rt_get_or_create [1139] + 0.00 0.00 162/5453 xml_ivalue [1533] +----------------------------------------------- + 0.00 0.00 1/3 do_combatmagic [825] + 0.00 0.00 2/3 do_combatspell [702] +[1187] 0.0 0.00 0.00 3 report_failed_spell [1187] + 0.00 0.00 3/1486 message_all [834] + 0.00 0.00 3/967784 msg_message [132] + 0.00 0.00 3/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 6/6 sp_summonundead [896] +[1188] 0.0 0.00 0.00 6 make_undead_unit [1188] + 0.00 0.00 6/2931 name_unit [803] + 0.00 0.00 6/1644867 free_orders [306] +----------------------------------------------- + 0.00 0.00 18/18 json_terrains [1190] +[1189] 0.0 0.00 0.00 18 json_terrain [1189] + 0.00 0.00 27/185 it_get_or_create [1115] + 0.00 0.00 56/383 rt_get_or_create [1139] + 0.00 0.00 29/29 json_terrain_production [1694] + 0.00 0.00 18/18 json_flags [1707] +----------------------------------------------- + 0.00 0.00 1/1 json_config [464] +[1190] 0.0 0.00 0.00 1 json_terrains [1190] + 0.00 0.00 18/18 json_terrain [1189] + 0.00 0.00 18/52 get_or_create_terrain [1680] +----------------------------------------------- + 0.00 0.00 53/53 get_resource [99] +[1191] 0.0 0.00 0.00 53 lua_getresource [1191] + 0.00 0.00 53/34611296 strlcpy [45] + 0.00 0.00 53/987128 strlcat [1374] +----------------------------------------------- + 0.00 0.00 52/52 msg_curse [664] +[1192] 0.0 0.00 0.00 52 cinfo_skillmod [1192] + 0.00 0.00 6/967784 msg_message [132] +----------------------------------------------- + 0.00 0.00 4/955 make_route [289] + 0.00 0.00 951/955 sail [181] +[1193] 0.0 0.00 0.00 955 movement_error [1193] + 0.00 0.00 4/967784 msg_message [132] + 0.00 0.00 4/293362 get_direction [496] + 0.00 0.00 1/41248 msg_feedback [647] +----------------------------------------------- + +[1194] 0.0 0.00 0.00 tolua_unit_get_name [1194] + 0.00 0.00 86/3351853 unit_getname [332] +----------------------------------------------- + 0.00 0.00 196/499 magic [157] + 0.00 0.00 303/499 create_castorder [1066] +[1195] 0.0 0.00 0.00 499 MagicPower [1195] + 0.00 0.00 279/20777534 config_get [224] +----------------------------------------------- + 0.00 0.00 266/266 age_unit [336] +[1196] 0.0 0.00 0.00 266 age_undead [1196] + 0.00 0.00 82/3902878 get_monsters [293] +----------------------------------------------- + +[1197] 0.0 0.00 0.00 tolua_faction_get_locale [1197] + 0.00 0.00 1/11719 locale_name [568] +----------------------------------------------- + 0.00 0.00 34/18059 battle_effects [1125] + 0.00 0.00 18025/18059 chaos_update [514] +[1198] 0.0 0.00 0.00 18059 add_chaoscount [1198] + 0.00 0.00 89/51974272 a_find [65] + 0.00 0.00 6/779419 a_add [555] + 0.00 0.00 6/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 569/569 setstealth_cmd [182] +[1199] 0.0 0.00 0.00 569 u_seteffstealth [1199] + 0.00 0.00 569/21345834 skill_enabled [365] + 0.00 0.00 2/51974272 a_find [65] +----------------------------------------------- + 0.00 0.00 15/15 change_resource [240] +[1200] 0.0 0.00 0.00 15 res_changepeasants [1200] + 0.00 0.00 15/264251 rsetpeasants [545] + 0.00 0.00 30/2605004 rpeasants [435] +----------------------------------------------- + 0.00 0.00 30/30 monster_move [129] +[1201] 0.0 0.00 0.00 30 treeman_neighbour [1201] + 0.00 0.00 30/1087065 get_neighbours [480] + 0.00 0.00 25/7641081 genrand_int31 [171] + 0.00 0.00 533/560 oldterrain [1596] +----------------------------------------------- + 0.00 0.00 6/6 process [7] +[1202] 0.0 0.00 0.00 6 send_cmd [1202] + 0.00 0.00 6/6 findoption [1241] + 0.00 0.00 6/69432 getparam [681] + 0.00 0.00 6/2281756 gettoken [195] + 0.00 0.00 6/1027665 init_order [613] +----------------------------------------------- + 0.00 0.00 505/505 matmod [975] +[1203] 0.0 0.00 0.00 505 mm_smithy [1203] + 0.00 0.00 505/56052475 get_resourcetype [194] +----------------------------------------------- + 0.00 0.00 4/118 give_men [857] + 0.00 0.00 114/118 give_unit [952] +[1204] 0.0 0.00 0.00 118 rule_transfermen [1204] + 0.00 0.00 118/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 58/58 init_translations [1033] +[1205] 0.0 0.00 0.00 58 skill_key [1205] + 0.00 0.00 58/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 1/1 breedtrees [1148] +[1206] 0.0 0.00 0.00 1 planttrees [1206] + 0.00 0.00 1/541982 get_pooled [104] + 0.00 0.00 1/41248 msg_feedback [647] + 0.00 0.00 1/12320804 effskill [100] + 0.00 0.00 1/392959 add_message [434] + 0.00 0.00 1/56052475 get_resourcetype [194] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 1/1 write_game [83] +[1207] 0.0 0.00 0.00 1 write_planes [1207] + 0.00 0.00 13/841675 a_write [299] + 0.00 0.00 1/1248014 listlen [190] +----------------------------------------------- + +[1208] 0.0 0.00 0.00 tolua_get_nmrs [1208] + 0.00 0.00 1/3 update_nmrs [1155] + 0.00 0.00 1/27 NMRTimeout [1264] +----------------------------------------------- + 0.00 0.00 2/2 magic [157] +[1209] 0.0 0.00 0.00 2 sp_bloodsacrifice [1209] + 0.00 0.00 2/967784 msg_message [132] + 0.00 0.00 2/12320804 effskill [100] + 0.00 0.00 2/392959 add_message [434] + 0.00 0.00 2/1201 change_spellpoints [971] + 0.00 0.00 2/201744 lovar [644] + 0.00 0.00 2/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 6/6 tolua_msg_send_region [1211] +[1210] 0.0 0.00 0.00 6 msg_send_region [1210] + 0.00 0.00 6/1009159 msg_create [228] + 0.00 0.00 6/392959 add_message [434] +----------------------------------------------- + +[1211] 0.0 0.00 0.00 tolua_msg_send_region [1211] + 0.00 0.00 6/6 msg_send_region [1210] +----------------------------------------------- + 0.00 0.00 22/22 add_spellparameter [1173] +[1212] 0.0 0.00 0.00 22 addparam_ship [1212] + 0.00 0.00 22/688711 atoi36 [440] +----------------------------------------------- + 0.00 0.00 48/48 chaos [848] +[1213] 0.0 0.00 0.00 48 chaosterrain [1213] + 0.00 0.00 48/7641081 genrand_int31 [171] + 0.00 0.00 2/4 terrains [1760] +----------------------------------------------- + 0.00 0.00 16/16 add_spellparameter [1173] +[1214] 0.0 0.00 0.00 16 addparam_unit [1214] + 0.00 0.00 16/688711 atoi36 [440] + 0.00 0.00 16/534930 isparam [668] +----------------------------------------------- + 0.00 0.00 3/3 read_triggers [798] +[1215] 0.0 0.00 0.00 3 changerace_read [1215] + 0.00 0.00 3/9763 read_reference [726] + 0.00 0.00 6/6 read_race_reference [1278] +----------------------------------------------- + 0.00 0.00 6787/6787 find_groupbyname [1217] +[1216] 0.0 0.00 0.00 6787 unicode_utf8_strcasecmp [1216] + 0.00 0.00 248/46391457 unicode_utf8_to_ucs4 [177] +----------------------------------------------- + 0.00 0.00 453/453 join_group [1083] +[1217] 0.0 0.00 0.00 453 find_groupbyname [1217] + 0.00 0.00 6787/6787 unicode_utf8_strcasecmp [1216] +----------------------------------------------- + +[1218] 0.0 0.00 0.00 tolua_dict_get [1218] + 0.00 0.00 58/51974272 a_find [65] + 0.00 0.00 58/58 dict_name [1671] + 0.00 0.00 58/58 dict_get [1670] +----------------------------------------------- + 0.00 0.00 1/1 sp_summon_familiar [1025] +[1219] 0.0 0.00 0.00 1 make_familiar [1219] + 0.00 0.00 1/1 oldfamiliars [1240] + 0.00 0.00 1/1381157 unit_max_hp [136] + 0.00 0.00 1/1 create_newfamiliar [1288] + 0.00 0.00 2/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 38/38 select_ally [1132] +[1220] 0.0 0.00 0.00 38 count_allies [1220] + 0.00 0.00 38/317239 count_side [666] +----------------------------------------------- + 0.00 0.00 6/6 volcano_update [981] +[1221] 0.0 0.00 0.00 6 rrandneighbour [1221] + 0.00 0.00 8/369586 r_connect [474] + 0.00 0.00 6/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 1/3 writeturn [1253] + 0.00 0.00 2/3 report_summary [614] +[1222] 0.0 0.00 0.00 3 gamedate2 [1222] + 0.00 0.00 9/24887945 locale_string [27] + 0.00 0.00 3/40692 get_gamedate [1466] +----------------------------------------------- + 0.00 0.00 88/88 hunger [808] +[1223] 0.0 0.00 0.00 88 hunger_damage [1223] + 0.00 0.00 73/20777534 config_get [224] + 0.00 0.00 88/26776263 get_param [235] +----------------------------------------------- + 0.00 0.00 4/4 use_healingpotion [1119] +[1224] 0.0 0.00 0.00 4 heal [1224] + 0.00 0.00 4/1381157 unit_max_hp [136] +----------------------------------------------- + 0.00 0.00 4/4 name_cmd [835] +[1225] 0.0 0.00 0.00 4 try_rename [1225] + 0.00 0.00 3/593636 building_owner [232] + 0.00 0.00 1/15102 cmistake [718] +----------------------------------------------- + 0.00 0.00 80/80 tolua_msg_set_resource [1227] +[1226] 0.0 0.00 0.00 80 msg_set_resource [1226] + 0.00 0.00 80/2032164 rt_find [597] + 0.00 0.00 80/451 mtype_get_param [1602] +----------------------------------------------- + +[1227] 0.0 0.00 0.00 tolua_msg_set_resource [1227] + 0.00 0.00 80/80 msg_set_resource [1226] +----------------------------------------------- + 0.00 0.00 1/1 parse_resources [1086] +[1228] 0.0 0.00 0.00 1 init_resources [1228] + 0.00 0.00 1/1 init_oldpotions [1235] + 0.00 0.00 6/383 rt_get_or_create [1139] + 0.00 0.00 1/185 it_get_or_create [1115] +----------------------------------------------- + 0.00 0.00 2/2 create_ship [1014] +[1229] 0.0 0.00 0.00 2 new_ship [1229] + 0.00 0.00 2/760673 addlist [217] + 0.00 0.00 2/24887945 locale_string [27] + 0.00 0.00 2/5100840 itoa36 [116] + 0.00 0.00 2/13 newcontainerid [1263] + 0.00 0.00 2/5461936 slprintf [548] + 0.00 0.00 2/19085 shash [1502] +----------------------------------------------- + 0.00 0.00 1/1 destroy_cmd [1113] +[1230] 0.0 0.00 0.00 1 destroy_road [1230] + 0.00 0.00 1/22 rsetroad [1152] + 0.00 0.00 1/143730 rroad [508] + 0.00 0.00 1/12320804 effskill [100] + 0.00 0.00 1/293362 get_direction [496] + 0.00 0.00 1/2281756 gettoken [195] + 0.00 0.00 3/6610983 is_guard [211] +----------------------------------------------- + 0.00 0.00 24/24 cast_cmd [760] +[1231] 0.0 0.00 0.00 24 is_moving_ship [1231] + 0.00 0.00 24/55492327 getkeyword [54] + 0.00 0.00 24/3358315 ship_owner [438] +----------------------------------------------- + 0.00 0.00 10/10 spawn_dragons [411] +[1232] 0.0 0.00 0.00 10 nrand [1232] + 0.00 0.00 27/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 1/1 use_item [765] +[1233] 0.0 0.00 0.00 1 use_skillpotion [1233] + 0.00 0.00 1/967784 msg_message [132] + 0.00 0.00 7/892307 learn_skill [471] + 0.00 0.00 1/392959 add_message [434] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 111/111 steal_cmd [766] +[1234] 0.0 0.00 0.00 111 check_steal [1234] + 0.00 0.00 111/129167539 u_race [89] + 0.00 0.00 111/18647447 getplane [596] +----------------------------------------------- + 0.00 0.00 1/1 init_resources [1228] +[1235] 0.0 0.00 0.00 1 init_oldpotions [1235] + 0.00 0.00 15/1177511 it_find [385] +----------------------------------------------- + 0.00 0.00 143/143 update_resource [1237] +[1236] 0.0 0.00 0.00 143 ResourceFactor [1236] + 0.00 0.00 143/717218 config_get_flt [714] +----------------------------------------------- + 0.00 0.00 58/143 add_resource [1162] + 0.00 0.00 85/143 use_default [1149] +[1237] 0.0 0.00 0.00 143 update_resource [1237] + 0.00 0.00 143/143 ResourceFactor [1236] +----------------------------------------------- + 0.00 0.00 2/2 a_read_i [390] +[1238] 0.0 0.00 0.00 2 wormhole_read [1238] + 0.00 0.00 2/9763 read_reference [726] +----------------------------------------------- + 0.00 0.00 8/8 skillmod [214] +[1239] 0.0 0.00 0.00 8 mod_elves_only [1239] + 0.00 0.00 8/71815034 get_race [12] + 0.00 0.00 8/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 1/1 make_familiar [1219] +[1240] 0.0 0.00 0.00 1 oldfamiliars [1240] + 0.00 0.00 1/2375 equip_unit [775] + 0.00 0.00 1/1 create_mage [1315] + 0.00 0.00 1/129167539 u_race [89] + 0.00 0.00 1/2742 get_equipment [1551] +----------------------------------------------- + 0.00 0.00 6/6 send_cmd [1202] +[1241] 0.0 0.00 0.00 6 findoption [1241] + 0.00 0.00 6/302482 findtoken [501] + 0.00 0.00 6/4558423 get_translations [437] +----------------------------------------------- + 0.00 0.00 2/2 process [7] +[1242] 0.0 0.00 0.00 2 claim_cmd [1242] + 0.00 0.00 3/2281756 gettoken [195] + 0.00 0.00 4/11241829 i_change [115] + 0.00 0.00 2/6010308 i_find [127] + 0.00 0.00 2/1027665 init_order [613] + 0.00 0.00 2/191379 finditemtype [735] +----------------------------------------------- + 0.00 0.00 5/49317 log_warning [1342] + 0.00 0.00 13/49317 log_error [1340] + 0.00 0.00 64/49317 log_info [1339] + 0.00 0.00 49235/49317 log_debug [1245] +[1243] 0.0 0.00 0.00 49317 log_write [1243] + 0.00 0.00 18/18 check_dupe [1244] + 0.00 0.00 49331/49331 log_stdio [1459] +----------------------------------------------- + 0.00 0.00 18/18 log_write [1243] +[1244] 0.0 0.00 0.00 18 check_dupe [1244] + 0.00 0.00 15/34611296 strlcpy [45] +----------------------------------------------- + 0.00 0.00 1/49235 parse_config [1292] + 0.00 0.00 1/49235 eressea_run [1346] + 0.00 0.00 1/49235 give_men [857] + 0.00 0.00 1/49235 disable_feature [771] + 0.00 0.00 2/49235 readgame [60] + 0.00 0.00 4/49235 tolua_log_eressea_log_debug00 [1343] + 0.00 0.00 5/49235 factionorders [983] + 0.00 0.00 10/49235 spawn_dragons [411] + 0.00 0.00 50/49235 rsetherbtype [537] + 0.00 0.00 52/49235 update_nmrs [1155] + 0.00 0.00 68/49235 process [7] + 0.00 0.00 92/49235 spawn_undead [629] + 0.00 0.00 176/49235 write_game [83] + 0.00 0.00 182/49235 read_game [62] + 0.00 0.00 206/49235 do_battle [64] + 0.00 0.00 232/49235 write_reports [3] + 0.00 0.00 233/49235 readfaction [767] + 0.00 0.00 6664/49235 findtoken [501] + 0.00 0.00 41255/49235 log_orders [251] +[1245] 0.0 0.00 0.00 49235 log_debug [1245] + 0.00 0.00 49235/49317 log_write [1243] +----------------------------------------------- + +[1246] 0.0 0.00 0.00 tolua_faction_get [1246] + 0.00 0.00 12/13 tolua_toid [1274] + 0.00 0.00 12/4625636 findfaction [259] +----------------------------------------------- + 0.00 0.00 36/36 move_iceberg [1094] +[1247] 0.0 0.00 0.00 36 runhash [1247] + 0.00 0.00 36/2903884 jenkins_hash [439] +----------------------------------------------- + 0.00 0.00 230/230 report_computer [9] +[1248] 0.0 0.00 0.00 230 show_alliances_cr [1248] + 0.00 0.00 230/20836359 f_get_alliance [455] +----------------------------------------------- + 0.00 0.00 1/1 main [541] +[1249] 0.0 0.00 0.00 1 game_init [1249] + 0.00 0.00 1/1 register_spells [1251] + 0.00 0.00 1/1 register_triggers [1855] + 0.00 0.00 1/1 kernel_init [1814] + 0.00 0.00 1/1 register_races [1849] + 0.00 0.00 1/1 register_cr [1838] + 0.00 0.00 1/1 register_nr [1847] + 0.00 0.00 1/1 register_xmas [1859] + 0.00 0.00 1/1 register_resources [1852] + 0.00 0.00 1/1 register_names [1846] + 0.00 0.00 1/1 register_museum [1845] + 0.00 0.00 1/1 register_itemfunctions [1842] + 0.00 0.00 1/1 register_buildings [1837] + 0.00 0.00 1/1 register_itemtypes [1843] + 0.00 0.00 1/1 wormholes_register [1895] + 0.00 0.00 1/1 register_arena [1832] + 0.00 0.00 1/1 register_gmcmd [1841] + 0.00 0.00 1/1 register_attributes [1834] + 0.00 0.00 1/1 register_xmlreader [1860] + 0.00 0.00 1/1 chaos_register [1797] +----------------------------------------------- + 0.00 0.00 1/1 register_spells [1251] +[1250] 0.0 0.00 0.00 1 register_spelldata [1250] + 0.00 0.00 12/34611296 strlcpy [45] + 0.00 0.00 151/240 register_function [1614] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1251] 0.0 0.00 0.00 1 register_spells [1251] + 0.00 0.00 1/1 register_spelldata [1250] + 0.00 0.00 5/240 register_function [1614] + 0.00 0.00 2/55 at_register [1678] + 0.00 0.00 2/44 ct_register [1686] + 0.00 0.00 1/1 register_borders [1835] + 0.00 0.00 1/1 register_shipcurse [1853] + 0.00 0.00 1/1 register_regioncurse [1850] + 0.00 0.00 1/1 register_unitcurse [1856] + 0.00 0.00 1/1 register_flyingship [1840] + 0.00 0.00 1/1 register_magicresistance [1844] + 0.00 0.00 1/1 register_buildingcurse [1836] +----------------------------------------------- + 0.00 0.00 1/1 read_xml [791] +[1252] 0.0 0.00 0.00 1 parse_calendar [1252] + 0.00 0.00 18/4133717 mkname [261] + 0.00 0.00 11/5453 xml_ivalue [1533] +----------------------------------------------- + 0.00 0.00 1/1 report_summary [614] +[1253] 0.0 0.00 0.00 1 writeturn [1253] + 0.00 0.00 1/3 gamedate2 [1222] + 0.00 0.00 2/573 join_path [1016] + 0.00 0.00 2/9 basepath [1730] +----------------------------------------------- + +[1254] 0.0 0.00 0.00 tolua_get_unit [1254] + 0.00 0.00 1/888603 findunit [123] + 0.00 0.00 1/13 tolua_toid [1274] +----------------------------------------------- + 0.00 0.00 4/4 verify_targets [1027] +[1255] 0.0 0.00 0.00 4 verify_building [1255] + 0.00 0.00 1/967784 msg_message [132] + 0.00 0.00 1/392959 add_message [434] + 0.00 0.00 4/48455 findbuilding [1462] + 0.00 0.00 1/1009028 msg_release [1373] +----------------------------------------------- + +[1256] 0.0 0.00 0.00 tolua_unit_addnotice [1256] + 0.00 0.00 1/48 addmessage [1069] +----------------------------------------------- + +[1257] 0.0 0.00 0.00 tolua_faction_tostring [1257] + 0.00 0.00 5/1295787 factionname [247] +----------------------------------------------- + 0.00 0.00 12/12 write_triggers [954] +[1258] 0.0 0.00 0.00 12 changefaction_write [1258] + 0.00 0.00 12/604861 write_unit_reference [557] + 0.00 0.00 12/647569 write_faction_reference [1382] +----------------------------------------------- + 0.00 0.00 2/2 init_directions [1143] +[1259] 0.0 0.00 0.00 2 register_special_direction [1259] + 0.00 0.00 2/24887945 locale_string [27] + 0.00 0.00 2/8993 addtoken [811] + 0.00 0.00 2/4558423 get_translations [437] +----------------------------------------------- + 0.00 0.00 1/11 use_bloodpotion [935] + 0.00 0.00 2/11 do_fumble [1062] + 0.00 0.00 2/11 create_newfamiliar [1288] + 0.00 0.00 6/11 sp_charmingsong [993] +[1260] 0.0 0.00 0.00 11 add_trigger [1260] + 0.00 0.00 11/51974272 a_find [65] + 0.00 0.00 7/779419 a_add [555] + 0.00 0.00 7/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 6/6 add_spellparameter [1173] +[1261] 0.0 0.00 0.00 6 addparam_building [1261] + 0.00 0.00 6/688711 atoi36 [440] +----------------------------------------------- + 0.00 0.00 1/1 read_triggers [798] +[1262] 0.0 0.00 0.00 1 giveitem_read [1262] + 0.00 0.00 1/9763 read_reference [726] + 0.00 0.00 1/1177511 it_find [385] +----------------------------------------------- + 0.00 0.00 2/13 new_ship [1229] + 0.00 0.00 11/13 new_building [1059] +[1263] 0.0 0.00 0.00 13 newcontainerid [1263] + 0.00 0.00 13/7641081 genrand_int31 [171] + 0.00 0.00 16/28818 findship [1483] + 0.00 0.00 16/48455 findbuilding [1462] +----------------------------------------------- + 0.00 0.00 1/27 tolua_get_nmrs [1208] + 0.00 0.00 1/27 remove_idle_players [391] + 0.00 0.00 2/27 report_summary [614] + 0.00 0.00 3/27 update_nmrs [1155] + 0.00 0.00 20/27 nmr_warnings [878] +[1264] 0.0 0.00 0.00 27 NMRTimeout [1264] + 0.00 0.00 27/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 13/13 create_curse [800] +[1265] 0.0 0.00 0.00 13 set_curseingmagician [1265] + 0.00 0.00 13/10190660 get_curse [143] +----------------------------------------------- + 0.00 0.00 23/23 xml_readitem [1107] +[1266] 0.0 0.00 0.00 23 xml_readweapon [1266] + 0.00 0.00 3/68430117 rc_find [15] + 0.00 0.00 2/150 rc_get_or_create [1105] + 0.00 0.00 303/6576 xml_bvalue [1532] + 0.00 0.00 108/5453 xml_ivalue [1533] + 0.00 0.00 23/501 xml_fvalue [1599] + 0.00 0.00 23/1041 findskill [1586] + 0.00 0.00 23/23 new_weapontype [1703] + 0.00 0.00 3/3 racelist_insert [1766] + 0.00 0.00 3/178 parse_function [1637] +----------------------------------------------- + 0.00 0.00 1/1 remove_unit [499] +[1267] 0.0 0.00 0.00 1 make_zombie [1267] + 0.00 0.00 1/1381157 unit_max_hp [136] + 0.00 0.00 1/71815034 get_race [12] + 0.00 0.00 1/3178 scale_number [969] + 0.00 0.00 1/3902878 get_monsters [293] + 0.00 0.00 1/598129 u_setfaction [1111] + 0.00 0.00 1/600145 u_setrace [1389] +----------------------------------------------- + 0.00 0.00 286/286 factionorders [983] +[1268] 0.0 0.00 0.00 286 checkpasswd [1268] + 0.00 0.00 4/1295787 factionname [247] + 0.00 0.00 4/5 log_warning [1342] + 0.00 0.00 286/286 password_verify [1610] +----------------------------------------------- + 0.00 0.00 7/7 sp_healing [989] +[1269] 0.0 0.00 0.00 7 has_ao_healing [1269] + 0.00 0.00 7/1177511 it_find [385] + 0.00 0.00 7/7 i_findc [1737] +----------------------------------------------- + 0.00 0.00 1/1 read_triggers [798] +[1270] 0.0 0.00 0.00 1 caldera_read [1270] + 0.00 0.00 1/9763 read_reference [726] +----------------------------------------------- + 0.00 0.00 1/1 read_triggers [798] +[1271] 0.0 0.00 0.00 1 clonedied_read [1271] + 0.00 0.00 1/9763 read_reference [726] +----------------------------------------------- + 0.00 0.00 1/1 do_battles [63] +[1272] 0.0 0.00 0.00 1 init_rules [1272] + 0.00 0.00 16/4984610 config_get_int [348] + 0.00 0.00 3/12246335 ct_find [114] +----------------------------------------------- + 0.00 0.00 60/60 damage_unit [1044] +[1273] 0.0 0.00 0.00 60 nb_armor [1273] + 0.00 0.00 60/129167539 u_race [89] +----------------------------------------------- + 0.00 0.00 1/13 tolua_get_unit [1254] + 0.00 0.00 12/13 tolua_faction_get [1246] +[1274] 0.0 0.00 0.00 13 tolua_toid [1274] + 0.00 0.00 5/688711 atoi36 [440] +----------------------------------------------- + 0.00 0.00 2/6 json_keywords [1124] + 0.00 0.00 2/6 make_locales [1303] + 0.00 0.00 2/6 init_locales [947] +[1275] 0.0 0.00 0.00 6 get_or_create_locale [1275] + 0.00 0.00 6/32337529 hashstring [37] +----------------------------------------------- + +[1276] 0.0 0.00 0.00 tolua_unit_add_order [1276] + 0.00 0.00 1/1481407 parse_order [117] + 0.00 0.00 1/48 unit_addorder [1684] +----------------------------------------------- + 0.00 0.00 58/58 peasant_luck_effect [984] +[1277] 0.0 0.00 0.00 58 peasant_luck_factor [1277] + 0.00 0.00 58/717218 config_get_flt [714] +----------------------------------------------- + 0.00 0.00 6/6 changerace_read [1215] +[1278] 0.0 0.00 0.00 6 read_race_reference [1278] + 0.00 0.00 4/68430271 rc_find_i [16] +----------------------------------------------- + 0.00 0.00 2/2 border_name [641] +[1279] 0.0 0.00 0.00 2 b_namequestportal [1279] + 0.00 0.00 2/24887945 locale_string [27] + 0.00 0.00 2/4133717 mkname [261] +----------------------------------------------- + 0.00 0.00 38/3002 renumber_cmd [780] + 0.00 0.00 146/3002 createunitid [317] + 0.00 0.00 2818/3002 newunitid [319] +[1280] 0.0 0.00 0.00 3002 forbiddenid [1280] + 0.00 0.00 4/688711 atoi36 [440] +----------------------------------------------- + +[1281] 0.0 0.00 0.00 tolua_getkey [1281] + 0.00 0.00 3/688711 atoi36 [440] + 0.00 0.00 3/178257 key_get [719] +----------------------------------------------- + 0.00 0.00 206/206 start_battle [297] +[1282] 0.0 0.00 0.00 206 make_battle [1282] + 0.00 0.00 206/18647447 getplane [596] +----------------------------------------------- + 1 json_config [464] +[1283] 0.0 0.00 0.00 1 json_include [1283] + 0.00 0.00 3/573 join_path [1016] + 3 json_config [464] +----------------------------------------------- + 0.00 0.00 1/1 do_fumble [1062] +[1284] 0.0 0.00 0.00 1 fumble_default [1284] + 0.00 0.00 1/15102 cmistake [718] +----------------------------------------------- + 0.00 0.00 1/1 sp_charmingsong [993] +[1285] 0.0 0.00 0.00 1 report_failure [1285] + 0.00 0.00 1/15102 cmistake [718] +----------------------------------------------- + 0.00 0.00 12/12 drifting_ships [490] +[1286] 0.0 0.00 0.00 12 msg_to_ship_inmates [1286] + 0.00 0.00 2/392959 add_message [434] + 0.00 0.00 12/1009028 msg_release [1373] +----------------------------------------------- + 0.00 0.00 6/6 write_triggers [954] +[1287] 0.0 0.00 0.00 6 changerace_write [1287] + 0.00 0.00 6/604861 write_unit_reference [557] + 0.00 0.00 12/12 write_race_reference [1723] +----------------------------------------------- + 0.00 0.00 1/1 make_familiar [1219] +[1288] 0.0 0.00 0.00 1 create_newfamiliar [1288] + 0.00 0.00 3/779419 a_add [555] + 0.00 0.00 2/11 add_trigger [1260] + 0.00 0.00 3/51974272 a_find [65] + 0.00 0.00 3/779868 a_new [1376] + 0.00 0.00 1/5 trigger_killunit [1752] + 0.00 0.00 1/1 trigger_shock [1892] +----------------------------------------------- + 0.00 0.00 1/5 load_inifile [1293] + 0.00 0.00 1/5 readgame [60] + 0.00 0.00 1/5 writegame [82] + 0.00 0.00 2/5 create_directories [1294] +[1289] 0.0 0.00 0.00 5 datapath [1289] + 0.00 0.00 5/569 relpath [1061] +----------------------------------------------- + 0.00 0.00 1/1 ally_cmd [877] +[1290] 0.0 0.00 0.00 1 removelist [1290] + 0.00 0.00 1/113845 choplist [565] +----------------------------------------------- + +[1291] 0.0 0.00 0.00 tolua_region_tostring [1291] + 0.00 0.00 1/361 regionname [987] +----------------------------------------------- + 0.00 0.00 1/1 main [541] +[1292] 0.0 0.00 0.00 1 parse_config [1292] + 0.00 0.00 1/1 load_inifile [1293] + 0.00 0.00 1/49235 log_debug [1245] +----------------------------------------------- + 0.00 0.00 1/1 parse_config [1292] +[1293] 0.0 0.00 0.00 1 load_inifile [1293] + 0.00 0.00 1/1 make_locales [1303] + 0.00 0.00 1/5 datapath [1289] + 0.00 0.00 1/564 reportpath [1063] + 0.00 0.00 1/9 basepath [1730] +----------------------------------------------- + 0.00 0.00 1/2 init_reports [399] + 0.00 0.00 1/2 writegame [82] +[1294] 0.0 0.00 0.00 2 create_directories [1294] + 0.00 0.00 2/5 datapath [1289] + 0.00 0.00 2/564 reportpath [1063] +----------------------------------------------- + 0.00 0.00 30/30 drifting_ships [490] +[1295] 0.0 0.00 0.00 30 overload_start [1295] + 0.00 0.00 30/717218 config_get_flt [714] +----------------------------------------------- + +[1296] 0.0 0.00 0.00 tolua_get_region [1296] + 0.00 0.00 1/459083 findregion [420] + 0.00 0.00 1/1206547 findplane [457] + 0.00 0.00 1/3587241 pnormalize [1350] +----------------------------------------------- + 0.00 0.00 1/3 use_bloodpotion [935] + 0.00 0.00 2/3 do_fumble [1062] +[1297] 0.0 0.00 0.00 3 trigger_changerace [1297] + 0.00 0.00 3/2868601 u_irace [257] + 0.00 0.00 3/129167539 u_race [89] + 0.00 0.00 3/3113 t_new [1546] +----------------------------------------------- + 0.00 0.00 206/206 do_battle [64] +[1298] 0.0 0.00 0.00 206 make_heroes [1298] + 0.00 0.00 24/129167539 u_race [89] +----------------------------------------------- + +[1299] 0.0 0.00 0.00 tolua_atoi36 [1299] + 0.00 0.00 2/688711 atoi36 [440] +----------------------------------------------- + +[1300] 0.0 0.00 0.00 tolua_unit_tostring [1300] + 0.00 0.00 1/2383101 unitname [142] +----------------------------------------------- + 0.00 0.00 1/1 sp_holyground [1068] +[1301] 0.0 0.00 0.00 1 report_spell [1301] + 0.00 0.00 1/12265 r_addmessage [779] +----------------------------------------------- + +[1302] 0.0 0.00 0.00 tolua_region_get_next [1302] + 0.00 0.00 1/369586 r_connect [474] +----------------------------------------------- + 0.00 0.00 1/1 load_inifile [1293] +[1303] 0.0 0.00 0.00 1 make_locales [1303] + 0.00 0.00 2/6 get_or_create_locale [1275] +----------------------------------------------- + 0.00 0.00 1/1 movewhere [350] +[1304] 0.0 0.00 0.00 1 get_translation [1304] + 0.00 0.00 1/302482 findtoken [501] + 0.00 0.00 1/4558423 get_translations [437] +----------------------------------------------- + 0.00 0.00 1/1 read_xml [791] +[1305] 0.0 0.00 0.00 1 parse_ships [1305] + 0.00 0.00 7/191 xml_readconstruction [1183] + 0.00 0.00 63/5453 xml_ivalue [1533] + 0.00 0.00 34/52 get_or_create_terrain [1680] + 0.00 0.00 21/6576 xml_bvalue [1532] + 0.00 0.00 14/501 xml_fvalue [1599] + 0.00 0.00 7/7 st_get_or_create [1743] +----------------------------------------------- + +[1306] 0.0 0.00 0.00 tolua_building_tostring [1306] + 0.00 0.00 1/180818 buildingname [621] +----------------------------------------------- + 0.00 0.00 1/1 parse_resources [1086] +[1307] 0.0 0.00 0.00 1 init_itemtypes [1307] + 0.00 0.00 1/1 init_seed [1320] + 0.00 0.00 1/1 init_mallornseed [1319] +----------------------------------------------- + 0.00 0.00 1/1 age_unit [336] +[1308] 0.0 0.00 0.00 1 age_illusion [1308] + 0.00 0.00 1/71815034 get_race [12] +----------------------------------------------- + 0.00 0.00 2/2 write_triggers [954] +[1309] 0.0 0.00 0.00 2 giveitem_write [1309] + 0.00 0.00 2/604861 write_unit_reference [557] +----------------------------------------------- + 0.00 0.00 1/1 processorders [6] +[1310] 0.0 0.00 0.00 1 init_processor [1310] + 0.00 0.00 4/4984610 config_get_int [348] + 0.00 0.00 1/207 rule_force_leave [1175] + 0.00 0.00 29/29 add_proc_order [1692] + 0.00 0.00 13/13 add_proc_global [1716] + 0.00 0.00 8/8 add_proc_region [1733] + 0.00 0.00 6/11194781 keyword_disabled [1348] + 0.00 0.00 3/3 add_proc_unit [1762] + 0.00 0.00 3/3 add_proc_postregion [1761] +----------------------------------------------- + 0.00 0.00 1/1 game_done [542] +[1311] 0.0 0.00 0.00 1 free_locales [1311] + 0.00 0.00 6/4558423 get_translations [437] + 0.00 0.00 12/267 freetokens [1611] +----------------------------------------------- + 0.00 0.00 1/1 parse_buildings [1131] +[1312] 0.0 0.00 0.00 1 init_smithy [1312] + 0.00 0.00 2/779419 a_add [555] + 0.00 0.00 1/2 make_skillmod [1777] + 0.00 0.00 1/1 make_matmod [1821] +----------------------------------------------- + +[1313] 0.0 0.00 0.00 tolua_unit_clear_orders [1313] + 0.00 0.00 1/1644867 free_orders [306] +----------------------------------------------- + 0.00 0.00 1/1 read_attribs [388] +[1314] 0.0 0.00 0.00 1 a_upgradekeys [1314] + 0.00 0.00 1/779419 a_add [555] + 0.00 0.00 1/51974272 a_find [65] + 0.00 0.00 1/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 1/1 oldfamiliars [1240] +[1315] 0.0 0.00 0.00 1 create_mage [1315] + 0.00 0.00 1/779419 a_add [555] + 0.00 0.00 1/51974272 a_find [65] + 0.00 0.00 1/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 1/1 main [541] +[1316] 0.0 0.00 0.00 1 lua_init [1316] + 0.00 0.00 1/1 tolua_bindings_open [1318] + 0.00 0.00 2/2 tolua_unit_open [1782] + 0.00 0.00 1/1 openlibs [1824] + 0.00 0.00 1/1 register_tolua_helpers [1854] + 0.00 0.00 1/2 tolua_eressea_open [1780] + 0.00 0.00 1/1 tolua_sqlite_open [1887] + 0.00 0.00 1/1 tolua_building_open [1867] + 0.00 0.00 1/1 tolua_ship_open [1886] + 0.00 0.00 1/1 tolua_region_open [1884] + 0.00 0.00 1/1 tolua_faction_open [1870] + 0.00 0.00 1/1 tolua_message_open [1875] + 0.00 0.00 1/1 tolua_order_open [1876] + 0.00 0.00 1/1 tolua_gmtool_open [1872] + 0.00 0.00 1/1 tolua_dict_open [1869] + 0.00 0.00 1/1 tolua_storage_open [1888] +----------------------------------------------- + 0.00 0.00 1/1 tolua_bindings_open [1318] +[1317] 0.0 0.00 0.00 1 parse_inifile [1317] + 0.00 0.00 1/564 reportpath [1063] + 0.00 0.00 1/20777534 config_get [224] + 0.00 0.00 1/9 basepath [1730] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1318] 0.0 0.00 0.00 1 tolua_bindings_open [1318] + 0.00 0.00 1/1 parse_inifile [1317] + 0.00 0.00 1/1 tolua_bind_open [1866] +----------------------------------------------- + 0.00 0.00 1/1 init_itemtypes [1307] +[1319] 0.0 0.00 0.00 1 init_mallornseed [1319] + 0.00 0.00 1/779419 a_add [555] + 0.00 0.00 1/2032164 rt_find [597] + 0.00 0.00 1/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 1/1 init_itemtypes [1307] +[1320] 0.0 0.00 0.00 1 init_seed [1320] + 0.00 0.00 1/779419 a_add [555] + 0.00 0.00 1/2032164 rt_find [597] + 0.00 0.00 1/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 1/1 write_triggers [954] +[1321] 0.0 0.00 0.00 1 clonedied_write [1321] + 0.00 0.00 1/604861 write_unit_reference [557] +----------------------------------------------- + 0.00 0.00 1/1 sp_summon_familiar [1025] +[1322] 0.0 0.00 0.00 1 select_familiar [1322] + 0.00 0.00 1/7641081 genrand_int31 [171] +----------------------------------------------- + 0.00 0.00 5/1613387 get_cmp_region_owner [1347] + 0.00 0.00 233/1613387 readfaction [767] + 0.00 0.00 36937/1613387 cr_output_region [10] + 0.00 0.00 127676/1613387 describe [35] + 0.00 0.00 178254/1613387 ageing [185] + 0.00 0.00 356508/1613387 score [23] + 0.00 0.00 913774/1613387 is_guardian_r [186] +[1323] 0.0 0.00 0.00 1613387 rule_region_owners [1323] + 0.00 0.00 2/4984610 config_get_int [348] + 0.00 0.00 1613387/2386892 config_changed [1352] +----------------------------------------------- + 0.00 0.00 1/2 read_game [62] + 0.00 0.00 1/2 write_game [83] +[1324] 0.0 0.00 0.00 2 game_id [1324] + 0.00 0.00 2/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 2/154110 sp_charmingsong [993] + 0.00 0.00 230/154110 setstealth_cmd [182] + 0.00 0.00 153878/154110 read_unit [74] +[1325] 0.0 0.00 0.00 154110 rule_stealth_anon [1325] + 0.00 0.00 2/4984610 config_get_int [348] + 0.00 0.00 154110/2386892 config_changed [1352] +----------------------------------------------- + 0.00 0.00 5/5 chaos [848] +[1326] 0.0 0.00 0.00 5 set_money [1326] + 0.00 0.00 5/56052475 get_resourcetype [194] + 0.00 0.00 5/822780 i_new [1375] + 0.00 0.00 5/87004 i_add [1442] +----------------------------------------------- + 0.00 0.00 82525/508632 expandwork [277] + 0.00 0.00 426107/508632 default_wage [173] +[1327] 0.0 0.00 0.00 508632 rule_blessed_harvest [1327] + 0.00 0.00 1/4984610 config_get_int [348] + 0.00 0.00 508632/2386892 config_changed [1352] +----------------------------------------------- + 0.00 0.00 1803/103079 gift_items [891] + 0.00 0.00 101276/103079 can_give [1335] +[1328] 0.0 0.00 0.00 103079 rule_give [1328] + 0.00 0.00 1/4984610 config_get_int [348] + 0.00 0.00 103079/2386892 config_changed [1352] +----------------------------------------------- + 0.00 0.00 4/3003 steal_cmd [766] + 0.00 0.00 61/3003 build [691] + 0.00 0.00 2938/3003 allocate_resource [752] +[1329] 0.0 0.00 0.00 3003 roqf_factor [1329] + 0.00 0.00 1/4984610 config_get_int [348] + 0.00 0.00 3003/2386892 config_changed [1352] +----------------------------------------------- + 0.00 0.00 1583/1583 skill_limit [1172] +[1330] 0.0 0.00 0.00 1583 allied_skilllimit [1330] + 0.00 0.00 1/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 230/1214 report_computer [9] + 0.00 0.00 230/1214 report_plaintext [4] + 0.00 0.00 754/1214 checkunitnumber [402] +[1331] 0.0 0.00 0.00 1214 rule_faction_limit [1331] + 0.00 0.00 1/4984610 config_get_int [348] + 0.00 0.00 1214/2386892 config_changed [1352] +----------------------------------------------- + 0.00 0.00 754/754 checkunitnumber [402] +[1332] 0.0 0.00 0.00 754 rule_alliance_limit [1332] + 0.00 0.00 1/4984610 config_get_int [348] + 0.00 0.00 754/2386892 config_changed [1352] +----------------------------------------------- + 0.00 0.00 1/1 remove_idle_players [391] +[1333] 0.0 0.00 0.00 1 nmr_death [1333] + 0.00 0.00 1/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 1/1 economics [78] +[1334] 0.0 0.00 0.00 1 recruit_init [1334] + 0.00 0.00 1/4984610 config_get_int [348] +----------------------------------------------- + 0.00 0.00 102761/217696 check_give [1138] + 0.00 0.00 114935/217696 give_cmd [102] +[1335] 0.0 0.00 0.00 217696 can_give [1335] + 0.00 0.00 101276/103079 rule_give [1328] +----------------------------------------------- + 0.00 0.00 1/1 magic [157] +[1336] 0.0 0.00 0.00 1 sp_seduce [1336] + 0.00 0.00 1/129167539 u_race [89] + 0.00 0.00 1/56052475 get_resourcetype [194] +----------------------------------------------- + 0.00 0.00 1/3 sp_enterastral [1045] + 0.00 0.00 2/3 sp_viewreality [784] +[1337] 0.0 0.00 0.00 3 getplaneid [1337] + 0.00 0.00 3/18647447 getplane [596] +----------------------------------------------- + 0.00 0.00 3/3 sp_charmingsong [993] +[1338] 0.0 0.00 0.00 3 can_charm [1338] + 0.00 0.00 1/1583 skill_limit [1172] +----------------------------------------------- + 0.00 0.00 1/64 reports [2] + 0.00 0.00 1/64 immigration [294] + 0.00 0.00 1/64 processorders [6] + 0.00 0.00 1/64 writepasswd [1074] + 0.00 0.00 1/64 disable_feature [771] + 0.00 0.00 2/64 remove_idle_players [391] + 0.00 0.00 2/64 sp_igjarjuk [923] + 0.00 0.00 2/64 readorders [43] + 0.00 0.00 3/64 report_summary [614] + 0.00 0.00 10/64 tolua_log_eressea_log_info00 [1341] + 0.00 0.00 40/64 write_unit [97] +[1339] 0.0 0.00 0.00 64 log_info [1339] + 0.00 0.00 64/49317 log_write [1243] +----------------------------------------------- + 0.00 0.00 1/13 tolua_log_eressea_log_error00 [1344] + 0.00 0.00 12/13 read_game [62] +[1340] 0.0 0.00 0.00 13 log_error [1340] + 0.00 0.00 13/49317 log_write [1243] +----------------------------------------------- + +[1341] 0.0 0.00 0.00 tolua_log_eressea_log_info00 [1341] + 0.00 0.00 10/64 log_info [1339] +----------------------------------------------- + 0.00 0.00 1/5 tolua_log_eressea_log_warning00 [1345] + 0.00 0.00 4/5 checkpasswd [1268] +[1342] 0.0 0.00 0.00 5 log_warning [1342] + 0.00 0.00 5/49317 log_write [1243] +----------------------------------------------- + +[1343] 0.0 0.00 0.00 tolua_log_eressea_log_debug00 [1343] + 0.00 0.00 4/49235 log_debug [1245] +----------------------------------------------- + +[1344] 0.0 0.00 0.00 tolua_log_eressea_log_error00 [1344] + 0.00 0.00 1/13 log_error [1340] +----------------------------------------------- + +[1345] 0.0 0.00 0.00 tolua_log_eressea_log_warning00 [1345] + 0.00 0.00 1/5 log_warning [1342] +----------------------------------------------- + 0.00 0.00 1/1 main [541] +[1346] 0.0 0.00 0.00 1 eressea_run [1346] + 0.00 0.00 1/49235 log_debug [1245] +----------------------------------------------- + 0.00 0.00 5/5 name_cmd [835] +[1347] 0.0 0.00 0.00 5 get_cmp_region_owner [1347] + 0.00 0.00 5/1613387 rule_region_owners [1323] +----------------------------------------------- + 0.00 0.00 1/11194781 defaultorders [249] + 0.00 0.00 6/11194781 init_processor [1310] + 0.00 0.00 29/11194781 add_proc_order [1692] + 0.00 0.00 1207012/11194781 create_order_i [175] + 0.00 0.00 1481322/11194781 get_keyword [274] + 0.00 0.00 8506411/11194781 besieged [547] +[1348] 0.0 0.00 0.00 11194781 keyword_disabled [1348] +----------------------------------------------- + 0.00 0.00 6656973/6656973 parse_string [86] +[1349] 0.0 0.00 0.00 6656973 bfree [1349] +----------------------------------------------- + 0.00 0.00 1/3587241 tolua_get_region [1296] + 0.00 0.00 5/3587241 cast_cmd [760] + 0.00 0.00 493/3587241 report_computer [9] + 0.00 0.00 7499/3587241 cr_regions [840] + 0.00 0.00 8892/3587241 r_astral_to_standard [783] + 0.00 0.00 10477/3587241 report_template [87] + 0.00 0.00 108425/3587241 update_lighthouse [605] + 0.00 0.00 132705/3587241 cr_region [662] + 0.00 0.00 163381/3587241 astralregions [329] + 0.00 0.00 178254/3587241 new_region [275] + 0.00 0.00 211668/3587241 cr_output_region [10] + 0.00 0.00 369586/3587241 r_connect [474] + 0.00 0.00 513251/3587241 write_regionname [280] + 0.00 0.00 932009/3587241 koor_reldirection [562] + 0.00 0.00 950595/3587241 f_regionid [161] +[1350] 0.0 0.00 0.00 3587241 pnormalize [1350] +----------------------------------------------- + 0.00 0.00 692/3166898 research_cmd [886] + 0.00 0.00 20639/3166898 herbsearch [493] + 0.00 0.00 32670/3166898 writeregion [519] + 0.00 0.00 3112897/3166898 growing_herbs [300] +[1351] 0.0 0.00 0.00 3166898 rherbs [1351] +----------------------------------------------- + 0.00 0.00 51/2386892 potion_water_of_life [945] + 0.00 0.00 232/2386892 prepare_report [8] + 0.00 0.00 754/2386892 rule_alliance_limit [1332] + 0.00 0.00 1214/2386892 rule_faction_limit [1331] + 0.00 0.00 2430/2386892 heal_factor [619] + 0.00 0.00 3003/2386892 roqf_factor [1329] + 0.00 0.00 103079/2386892 rule_give [1328] + 0.00 0.00 154110/2386892 rule_stealth_anon [1325] + 0.00 0.00 508632/2386892 rule_blessed_harvest [1327] + 0.00 0.00 1613387/2386892 rule_region_owners [1323] +[1352] 0.0 0.00 0.00 2386892 config_changed [1352] +----------------------------------------------- + 0.00 0.00 23/2379316 new_weapontype [1703] + 0.00 0.00 3531/2379316 make_fighter [424] + 0.00 0.00 2375762/2379316 armedmen [151] +[1353] 0.0 0.00 0.00 2379316 resource2weapon [1353] +----------------------------------------------- + 0.00 0.00 174/2124526 findresourcetype [1181] + 0.00 0.00 324/2124526 add_resourcename_cb [977] + 0.00 0.00 324/2124526 add_itemname_cb [980] + 0.00 0.00 3110/2124526 default_order [902] + 0.00 0.00 191379/2124526 finditemtype [735] + 0.00 0.00 1929215/2124526 create_order_i [175] +[1354] 0.0 0.00 0.00 2124526 locale_index [1354] +----------------------------------------------- + 0.00 0.00 47/2009097 give_peasants [1060] + 0.00 0.00 118/2009097 keyword_key [1647] + 0.00 0.00 136/2009097 make_movement_order [522] + 0.00 0.00 191/2009097 follow_ship [749] + 0.00 0.00 2081/2009097 nr_spell_syntax [732] + 0.00 0.00 2006524/2009097 get_command [108] +[1355] 0.0 0.00 0.00 2009097 keyword [1355] +----------------------------------------------- + 0.00 0.00 2/1936876 create_ship [1014] + 0.00 0.00 8/1936876 do_combatmagic [825] + 0.00 0.00 21/1936876 do_combatspell [702] + 0.00 0.00 99/1936876 piracy_cmd [660] + 0.00 0.00 133/1936876 travel [81] + 0.00 0.00 220/1936876 free_castorder [1609] + 0.00 0.00 262/1936876 defaultorders [249] + 0.00 0.00 310/1936876 remove_exclusive [571] + 0.00 0.00 490/1936876 build_building [696] + 0.00 0.00 514/1936876 do_enter [128] + 0.00 0.00 1670/1936876 free_recruitments [1568] + 0.00 0.00 5384/1936876 teach_cmd [272] + 0.00 0.00 8450/1936876 cycle_route [375] + 0.00 0.00 14326/1936876 replace_order [526] + 0.00 0.00 19315/1936876 expandorders [197] + 0.00 0.00 395426/1936876 unitorders [46] + 0.00 0.00 679696/1936876 set_order [1365] + 0.00 0.00 810550/1936876 free_orders [306] +[1356] 0.0 0.00 0.00 1936876 free_order [1356] + 0.00 0.00 1342381/1342381 release_data [1364] +----------------------------------------------- + 0.00 0.00 1785077/1785077 adjust_coordinates [234] +[1357] 0.0 0.00 0.00 1785077 faction_getorigin [1357] +----------------------------------------------- + 0.00 0.00 44924/1726748 attack [84] + 0.00 0.00 80630/1726748 terminate [242] + 0.00 0.00 1601194/1726748 weapon_effskill [168] +[1358] 0.0 0.00 0.00 1726748 is_riding [1358] +----------------------------------------------- + 0.00 0.00 1/1511812 eaten_by_monster [468] + 0.00 0.00 9/1511812 melt_iceberg [1082] + 0.00 0.00 29/1511812 terraform_region [932] + 0.00 0.00 48/1511812 chaos [848] + 0.00 0.00 105/1511812 bewegung_blockiert_von [631] + 0.00 0.00 114/1511812 build_road [950] + 0.00 0.00 847/1511812 buy [707] + 0.00 0.00 4628/1511812 expandselling [93] + 0.00 0.00 4629/1511812 produce [29] + 0.00 0.00 16651/1511812 sell [498] + 0.00 0.00 64838/1511812 calculate_emigration [603] + 0.00 0.00 139323/1511812 spawn_dragons [411] + 0.00 0.00 178254/1511812 move_icebergs [534] + 0.00 0.00 178261/1511812 create_icebergs [538] + 0.00 0.00 201709/1511812 make_summary [21] + 0.00 0.00 722366/1511812 skill_mod [264] +[1359] 0.0 0.00 0.00 1511812 newterrain [1359] +----------------------------------------------- + 0.00 0.00 1380398/1380398 translate [28] +[1360] 0.0 0.00 0.00 1380398 brelease [1360] +----------------------------------------------- + 0.00 0.00 1380398/1380398 translate [28] +[1361] 0.0 0.00 0.00 1380398 free_variables [1361] +----------------------------------------------- + 0.00 0.00 156/1380007 make_fighter [424] + 0.00 0.00 431/1380007 create_unit [296] + 0.00 0.00 39954/1380007 destroyfaction [392] + 0.00 0.00 151469/1380007 visible_faction [68] + 0.00 0.00 373997/1380007 nr_unit [11] + 0.00 0.00 401604/1380007 bufunit [17] + 0.00 0.00 412396/1380007 cr_output_unit [19] +[1362] 0.0 0.00 0.00 1380007 get_otherfaction [1362] +----------------------------------------------- + 0.00 0.00 1/1342832 destroyfaction [392] + 0.00 0.00 2/1342832 remove_building [1153] + 0.00 0.00 6/1342832 remove_ship [1748] + 0.00 0.00 1794/1342832 remove_unit [499] + 0.00 0.00 46184/1342832 age_building [712] + 0.00 0.00 178254/1342832 age_region [659] + 0.00 0.00 186260/1342832 give_item [126] + 0.00 0.00 315567/1342832 plan_monsters [52] + 0.00 0.00 614764/1342832 ageing [185] +[1363] 0.0 0.00 0.00 1342832 handle_event [1363] + 0.00 0.00 18/18 handle_triggers [1706] +----------------------------------------------- + 0.00 0.00 1342381/1342381 free_order [1356] +[1364] 0.0 0.00 0.00 1342381 release_data [1364] +----------------------------------------------- + 0.00 0.00 2/1291427 sp_charmingsong [993] + 0.00 0.00 3/1291427 cast_cmd [760] + 0.00 0.00 114/1291427 u_setfaction [1111] + 0.00 0.00 163/1291427 movement [47] + 0.00 0.00 703/1291427 follow_unit [331] + 0.00 0.00 2889/1291427 create_unit [296] + 0.00 0.00 6947/1291427 sail [181] + 0.00 0.00 103784/1291427 move_cmd [66] + 0.00 0.00 581697/1291427 update_long_order [270] + 0.00 0.00 595125/1291427 read_unit [74] +[1365] 0.0 0.00 0.00 1291427 set_order [1365] + 0.00 0.00 679696/1936876 free_order [1356] +----------------------------------------------- + 0.00 0.00 1252028/1252028 create_data [252] +[1366] 0.0 0.00 0.00 1252028 mkdata [1366] +----------------------------------------------- + 0.00 0.00 148748/1218663 terminate [242] + 0.00 0.00 363071/1218663 hits [131] + 0.00 0.00 706844/1218663 skilldiff [166] +[1367] 0.0 0.00 0.00 1218663 select_weapon [1367] + 0.00 0.00 516342/754589 preferred_weapon [1377] +----------------------------------------------- + 0.00 0.00 10565/1214628 list_address [635] + 0.00 0.00 453546/1214628 get_addresses [20] + 0.00 0.00 750517/1214628 nr_unit [11] +[1368] 0.0 0.00 0.00 1214628 is_allied [1368] +----------------------------------------------- + 0.00 0.00 5/1160345 give_horses [1108] + 0.00 0.00 5/1160345 gift_items [891] + 0.00 0.00 9/1160345 destroyfaction [392] + 0.00 0.00 3269/1160345 region_getresource [1058] + 0.00 0.00 28760/1160345 migrate [1478] + 0.00 0.00 32670/1160345 writeregion [519] + 0.00 0.00 45630/1160345 cr_output_region [10] + 0.00 0.00 91145/1160345 report_resources [210] + 0.00 0.00 225630/1160345 describe [35] + 0.00 0.00 356508/1160345 make_summary [21] + 0.00 0.00 376714/1160345 horses [330] +[1369] 0.0 0.00 0.00 1160345 rhorses [1369] +----------------------------------------------- + 0.00 0.00 1132609/1132609 update_long_order [270] +[1370] 0.0 0.00 0.00 1132609 is_long [1370] +----------------------------------------------- + 0.00 0.00 1067195/1067195 msg_free [1384] +[1371] 0.0 0.00 0.00 1067195 free_arg [1371] + 0.00 0.00 37202/37202 var_free_string [1470] + 0.00 0.00 209/209 var_free_resources [1628] +----------------------------------------------- + 0.00 0.00 1014205/1014205 add_seen_nb [386] +[1372] 0.0 0.00 0.00 1014205 add_seen [1372] +----------------------------------------------- + 0.00 0.00 1/1009028 sp_holyground [1068] + 0.00 0.00 1/1009028 sp_summonshadowlords [1034] + 0.00 0.00 1/1009028 sp_generous [1040] + 0.00 0.00 1/1009028 plant [1184] + 0.00 0.00 1/1009028 planttrees [1206] + 0.00 0.00 1/1009028 breedtrees [1148] + 0.00 0.00 1/1009028 promotion_cmd [917] + 0.00 0.00 1/1009028 age_stonecircle [1021] + 0.00 0.00 1/1009028 verify_building [1255] + 0.00 0.00 1/1009028 cast_cmd [760] + 0.00 0.00 1/1009028 sp_flying_ship [1064] + 0.00 0.00 1/1009028 use_skillpotion [1233] + 0.00 0.00 2/1009028 travel [81] + 0.00 0.00 2/1009028 sp_summon_familiar [1025] + 0.00 0.00 2/1009028 sp_bloodsacrifice [1209] + 0.00 0.00 2/1009028 sp_charmingsong [993] + 0.00 0.00 2/1009028 sp_viewreality [784] + 0.00 0.00 2/1009028 magic [157] + 0.00 0.00 2/1009028 create_icebergs [538] + 0.00 0.00 2/1009028 make_wormhole [1150] + 0.00 0.00 2/1009028 summon_allies [925] + 0.00 0.00 3/1009028 sp_eternizewall [988] + 0.00 0.00 3/1009028 report_failed_spell [1187] + 0.00 0.00 3/1009028 begin_potion [1096] + 0.00 0.00 3/1009028 give_control_cmd [287] + 0.00 0.00 3/1009028 drown [394] + 0.00 0.00 3/1009028 melt_iceberg [1082] + 0.00 0.00 3/1009028 wormhole_age [1130] + 0.00 0.00 3/1009028 use_healingpotion [1119] + 0.00 0.00 4/1009028 caught_target [1003] + 0.00 0.00 4/1009028 init_transportation [384] + 0.00 0.00 4/1009028 make_route [289] + 0.00 0.00 4/1009028 ship_ready [354] + 0.00 0.00 4/1009028 sp_goodwinds [974] + 0.00 0.00 4/1009028 sp_enterastral [1045] + 0.00 0.00 4/1009028 terminate [242] + 0.00 0.00 4/1009028 quit [276] + 0.00 0.00 4/1009028 move_iceberg [1094] + 0.00 0.00 4/1009028 factionorders [983] + 0.00 0.00 5/1009028 sp_song_of_peace [939] + 0.00 0.00 5/1009028 buy [707] + 0.00 0.00 7/1009028 sp_healing [989] + 0.00 0.00 9/1009028 sp_stormwinds [871] + 0.00 0.00 10/1009028 make_cmd [383] + 0.00 0.00 10/1009028 tax_cmd [697] + 0.00 0.00 10/1009028 spy_cmd [990] + 0.00 0.00 10/1009028 spawn_dragons [411] + 0.00 0.00 12/1009028 msg_to_ship_inmates [1286] + 0.00 0.00 12/1009028 sp_mallornhain [968] + 0.00 0.00 12/1009028 sp_summonundead [896] + 0.00 0.00 12/1009028 forget_cmd [1093] + 0.00 0.00 13/1009028 volcano_destruction [1022] + 0.00 0.00 15/1009028 do_fumble [1062] + 0.00 0.00 18/1009028 sp_hain [931] + 0.00 0.00 18/1009028 do_attack [80] + 0.00 0.00 18/1009028 attack_firesword [785] + 0.00 0.00 19/1009028 enter_building [695] + 0.00 0.00 21/1009028 sp_kampfzauber [957] + 0.00 0.00 22/1009028 spy_message [1038] + 0.00 0.00 24/1009028 nmr_warnings [878] + 0.00 0.00 24/1009028 cancast [833] + 0.00 0.00 26/1009028 sp_blessedharvest [847] + 0.00 0.00 33/1009028 travel_i [92] + 0.00 0.00 37/1009028 volcano_update [981] + 0.00 0.00 37/1009028 build_road [950] + 0.00 0.00 38/1009028 expandstealing [807] + 0.00 0.00 39/1009028 deliverMail [966] + 0.00 0.00 39/1009028 display_item [1054] + 0.00 0.00 39/1009028 random_growl [1065] + 0.00 0.00 41/1009028 dissolve_units [241] + 0.00 0.00 48/1009028 caddmessage [1070] + 0.00 0.00 51/1009028 potion_water_of_life [945] + 0.00 0.00 51/1009028 chaos [848] + 0.00 0.00 53/1009028 sp_dragonodem [627] + 0.00 0.00 55/1009028 start_battle [297] + 0.00 0.00 56/1009028 use_bloodpotion [935] + 0.00 0.00 58/1009028 add_recruits [371] + 0.00 0.00 76/1009028 steal_cmd [766] + 0.00 0.00 84/1009028 do_work [612] + 0.00 0.00 88/1009028 hunger [808] + 0.00 0.00 92/1009028 spawn_undead [629] + 0.00 0.00 100/1009028 age_reduceproduction [1017] + 0.00 0.00 110/1009028 peasants [658] + 0.00 0.00 115/1009028 build_ship [839] + 0.00 0.00 119/1009028 syntax_error [1036] + 0.00 0.00 120/1009028 plagues [781] + 0.00 0.00 149/1009028 create_potion [821] + 0.00 0.00 170/1009028 breedhorses [742] + 0.00 0.00 170/1009028 guard_on_cmd [656] + 0.00 0.00 328/1009028 mail_cmd [844] + 0.00 0.00 345/1009028 end_potion [814] + 0.00 0.00 349/1009028 research_cmd [886] + 0.00 0.00 377/1009028 manufacture [759] + 0.00 0.00 395/1009028 reportcasualties [881] + 0.00 0.00 508/1009028 regenerate_aura [346] + 0.00 0.00 567/1009028 eaten_by_monster [468] + 0.00 0.00 581/1009028 build_building [696] + 0.00 0.00 614/1009028 print_fighters [616] + 0.00 0.00 676/1009028 rp_battles [618] + 0.00 0.00 679/1009028 print_header [838] + 0.00 0.00 681/1009028 absorbed_by_monster [804] + 0.00 0.00 1080/1009028 report_plaintext [4] + 0.00 0.00 1225/1009028 give_item [126] + 0.00 0.00 1323/1009028 teach_cmd [272] + 0.00 0.00 1992/1009028 aftermath [701] + 0.00 0.00 2317/1009028 print_stats [525] + 0.00 0.00 2594/1009028 battle_report [503] + 0.00 0.00 2699/1009028 scared_by_monster [380] + 0.00 0.00 2938/1009028 split_allocations [743] + 0.00 0.00 5049/1009028 piracy_cmd [660] + 0.00 0.00 5810/1009028 report_transfer [724] + 0.00 0.00 5966/1009028 herbsearch [493] + 0.00 0.00 7043/1009028 sail [181] + 0.00 0.00 8710/1009028 maintain_buildings [339] + 0.00 0.00 8797/1009028 cmistake [718] + 0.00 0.00 11358/1009028 expandbuying [49] + 0.00 0.00 12398/1009028 fbattlerecord [688] + 0.00 0.00 12448/1009028 expandselling [93] + 0.00 0.00 12729/1009028 cr_output_curses [69] + 0.00 0.00 14939/1009028 maintain [478] + 0.00 0.00 15186/1009028 nr_curses_i [401] + 0.00 0.00 20258/1009028 study_cmd [105] + 0.00 0.00 29028/1009028 give_cmd [102] + 0.00 0.00 34409/1009028 add_income [625] + 0.00 0.00 80478/1009028 add_give [379] + 0.00 0.00 96460/1009028 travel_route [147] + 0.00 0.00 163573/1009028 describe [35] + 0.00 0.00 192618/1009028 statistics [70] + 0.00 0.00 247009/1009028 prices [85] +[1373] 0.0 0.00 0.00 1009028 msg_release [1373] + 0.00 0.00 633429/633429 msg_free [1384] +----------------------------------------------- + 0.00 0.00 52/987128 dragon_name [1095] + 0.00 0.00 53/987128 lua_getresource [1191] + 0.00 0.00 109/987128 dracoid_name [1126] + 0.00 0.00 116/987128 report_status [318] + 0.00 0.00 542/987128 make_name [970] + 0.00 0.00 886/987128 write_script [853] + 0.00 0.00 1584/987128 produce_resource [994] + 0.00 0.00 3123/987128 limit_resource [943] + 0.00 0.00 3334/987128 add_recruits [371] + 0.00 0.00 4016/987128 default_name [851] + 0.00 0.00 188092/987128 cycle_route [375] + 0.00 0.00 785221/987128 trailinto [207] +[1374] 0.0 0.00 0.00 987128 strlcat [1374] +----------------------------------------------- + 0.00 0.00 5/822780 set_money [1326] + 0.00 0.00 9/822780 default_spoil [1144] + 0.00 0.00 23/822780 equip_items [1121] + 0.00 0.00 60/822780 equip_unit_mask [776] + 0.00 0.00 86907/822780 change_money [337] + 0.00 0.00 735776/822780 i_change [115] +[1375] 0.0 0.00 0.00 822780 i_new [1375] +----------------------------------------------- + 0.00 0.00 1/779868 create_mage [1315] + 0.00 0.00 1/779868 init_seed [1320] + 0.00 0.00 1/779868 init_mallornseed [1319] + 0.00 0.00 1/779868 a_upgradekeys [1314] + 0.00 0.00 1/779868 make_matmod [1821] + 0.00 0.00 2/779868 make_wormhole [1150] + 0.00 0.00 2/779868 summon_allies [925] + 0.00 0.00 2/779868 make_skillmod [1777] + 0.00 0.00 3/779868 create_newfamiliar [1288] + 0.00 0.00 3/779868 usetprivate [1041] + 0.00 0.00 6/779868 add_chaoscount [1198] + 0.00 0.00 7/779868 parse_resources [1086] + 0.00 0.00 7/779868 add_trigger [1260] + 0.00 0.00 12/779868 make_reduceproduction [1722] + 0.00 0.00 13/779868 make_iceberg [1718] + 0.00 0.00 20/779868 init_transportation [384] + 0.00 0.00 25/779868 make_targetregion [1701] + 0.00 0.00 32/779868 growing_trees [624] + 0.00 0.00 32/779868 make_curse [802] + 0.00 0.00 35/779868 deathcounts [843] + 0.00 0.00 55/779868 renumber_unit [1159] + 0.00 0.00 58/779868 potion_luck [1176] + 0.00 0.00 97/779868 mk_piracy [1652] + 0.00 0.00 114/779868 usetcontact [1147] + 0.00 0.00 159/779868 change_effect [982] + 0.00 0.00 234/779868 make_leftship [1615] + 0.00 0.00 328/779868 display_potion [1090] + 0.00 0.00 389/779868 usetpotionuse [1078] + 0.00 0.00 433/779868 make_otherfaction [1603] + 0.00 0.00 631/779868 set_group [1048] + 0.00 0.00 754/779868 new_units [282] + 0.00 0.00 760/779868 set_familiar [992] + 0.00 0.00 894/779868 make_follow [1589] + 0.00 0.00 2063/779868 create_unit [296] + 0.00 0.00 2503/779868 sell [498] + 0.00 0.00 3233/779868 leave_trail [704] + 0.00 0.00 3642/779868 buy [707] + 0.00 0.00 4162/779868 show_new_spells [889] + 0.00 0.00 4738/779868 expandselling [93] + 0.00 0.00 5679/779868 expandbuying [49] + 0.00 0.00 11749/779868 teach_unit [426] + 0.00 0.00 27216/779868 travelthru_add [609] + 0.00 0.00 52117/779868 update_lighthouse [605] + 0.00 0.00 251814/779868 a_read_i [390] + 0.00 0.00 405840/779868 study_cmd [105] +[1376] 0.0 0.00 0.00 779868 a_new [1376] + 0.00 0.00 417580/417580 init_learning [1396] + 0.00 0.00 37453/37453 shiptrail_init [1469] + 0.00 0.00 4052/4052 curse_init [1539] + 0.00 0.00 2650/2650 a_initeffect [1552] + 0.00 0.00 2092/2092 init_mage [1558] + 0.00 0.00 2081/2081 a_init_reportspell [1561] + 0.00 0.00 1564/1564 init_handler [1570] + 0.00 0.00 763/763 init_skillmod [1592] + 0.00 0.00 97/97 piracy_init [1654] + 0.00 0.00 56/56 dict_init [1675] + 0.00 0.00 9/9 init_resourcelimit [1731] +----------------------------------------------- + 0.00 0.00 4005/754589 do_attack [80] + 0.00 0.00 234242/754589 attack [84] + 0.00 0.00 516342/754589 select_weapon [1367] +[1377] 0.0 0.00 0.00 754589 preferred_weapon [1377] +----------------------------------------------- + 0.00 0.00 1727/744202 travel_route [147] + 0.00 0.00 742475/744202 can_survive [640] +[1378] 0.0 0.00 0.00 744202 has_horses [1378] +----------------------------------------------- + 0.00 0.00 221718/734392 adjust_coordinates [234] + 0.00 0.00 512674/734392 koor_distance [476] +[1379] 0.0 0.00 0.00 734392 plane_height [1379] +----------------------------------------------- + 0.00 0.00 221718/734392 adjust_coordinates [234] + 0.00 0.00 512674/734392 koor_distance [476] +[1380] 0.0 0.00 0.00 734392 plane_width [1380] +----------------------------------------------- + 0.00 0.00 1/651711 sp_generous [1040] + 0.00 0.00 1/651711 shipcurse_flyingship [1072] + 0.00 0.00 2/651711 sp_enterastral [1045] + 0.00 0.00 6/651711 forget_cmd [1093] + 0.00 0.00 9/651711 is_freezing [1088] + 0.00 0.00 10/651711 sp_stormwinds [871] + 0.00 0.00 17/651711 produce [29] + 0.00 0.00 17/651711 process [7] + 0.00 0.00 17/651711 magic [157] + 0.00 0.00 22/651711 drifting_ships [490] + 0.00 0.00 34/651711 sp_viewreality [784] + 0.00 0.00 149/651711 sail [181] + 0.00 0.00 349/651711 can_give_men [940] + 0.00 0.00 452/651711 fumble [973] + 0.00 0.00 488/651711 give_men [857] + 0.00 0.00 508/651711 regenerate_aura [346] + 0.00 0.00 1689/651711 recruit [650] + 0.00 0.00 2815/651711 count_faction [219] + 0.00 0.00 5358/651711 max_spellpoints [755] + 0.00 0.00 8515/651711 describe [35] + 0.00 0.00 16560/651711 entertain_cmd [665] + 0.00 0.00 29173/651711 horses [330] + 0.00 0.00 32649/651711 growing_trees [624] + 0.00 0.00 37300/651711 cr_output_region [10] + 0.00 0.00 91155/651711 godcurse [405] + 0.00 0.00 94865/651711 ageing [185] + 0.00 0.00 159633/651711 entertainmoney [643] + 0.00 0.00 169917/651711 study_cmd [105] +[1381] 0.0 0.00 0.00 651711 oldcursename [1381] +----------------------------------------------- + 0.00 0.00 12/647569 changefaction_write [1258] + 0.00 0.00 232/647569 writefaction [762] + 0.00 0.00 51104/647569 write_groups [920] + 0.00 0.00 596221/647569 write_unit [97] +[1382] 0.0 0.00 0.00 647569 write_faction_reference [1382] +----------------------------------------------- + 0.00 0.00 1/642406 caldera_write [1795] + 0.00 0.00 46184/642406 write_game [83] + 0.00 0.00 596221/642406 write_unit [97] +[1383] 0.0 0.00 0.00 642406 write_building_reference [1383] +----------------------------------------------- + 0.00 0.00 633429/633429 msg_release [1373] +[1384] 0.0 0.00 0.00 633429 msg_free [1384] + 0.00 0.00 1067195/1067195 free_arg [1371] +----------------------------------------------- + 0.00 0.00 256354/619425 attack [84] + 0.00 0.00 363071/619425 hits [131] +[1385] 0.0 0.00 0.00 619425 getreload [1385] +----------------------------------------------- + 0.00 0.00 19078/615299 write_game [83] + 0.00 0.00 596221/615299 write_unit [97] +[1386] 0.0 0.00 0.00 615299 write_ship_reference [1386] +----------------------------------------------- + 0.00 0.00 3/603524 remove_unit [499] + 0.00 0.00 9/603524 destroyfaction [392] + 0.00 0.00 228/603524 u_setfaction [1111] + 0.00 0.00 369/603524 add_recruits [371] + 0.00 0.00 1865/603524 transfermen [899] + 0.00 0.00 2889/603524 create_unit [296] + 0.00 0.00 3036/603524 scale_number [969] + 0.00 0.00 595125/603524 read_unit [74] +[1387] 0.0 0.00 0.00 603524 set_number [1387] +----------------------------------------------- + 0.00 0.00 603246/603246 cr_output_unit [19] +[1388] 0.0 0.00 0.00 603246 level_days [1388] +----------------------------------------------- + 0.00 0.00 1/600145 make_zombie [1267] + 0.00 0.00 1/600145 use_bloodpotion [935] + 0.00 0.00 2/600145 do_fumble [1062] + 0.00 0.00 4/600145 age_firedragon [1123] + 0.00 0.00 5/600145 age_dragon [1098] + 0.00 0.00 7/600145 age_ghoul [1024] + 0.00 0.00 17/600145 age_zombie [1019] + 0.00 0.00 19/600145 age_skeleton [1008] + 0.00 0.00 359/600145 give_men [857] + 0.00 0.00 1716/600145 recruit [650] + 0.00 0.00 2889/600145 create_unit [296] + 0.00 0.00 595125/600145 read_unit [74] +[1389] 0.0 0.00 0.00 600145 u_setrace [1389] +----------------------------------------------- + 0.00 0.00 1/599650 sp_summon_familiar [1025] + 0.00 0.00 2/599650 summon_allies [925] + 0.00 0.00 23/599650 recruit_dracoids [837] + 0.00 0.00 754/599650 new_units [282] + 0.00 0.00 1683/599650 status_cmd [904] + 0.00 0.00 2062/599650 create_unit [296] + 0.00 0.00 595125/599650 read_unit [74] +[1390] 0.0 0.00 0.00 599650 setstatus [1390] +----------------------------------------------- + 0.00 0.00 5425/595705 drain_exp [850] + 0.00 0.00 34486/595705 effskill_study [504] + 0.00 0.00 108170/595705 transfermen [899] + 0.00 0.00 447624/595705 learn_skill [471] +[1391] 0.0 0.00 0.00 595705 unit_skill [1391] +----------------------------------------------- + 0.00 0.00 36929/515192 cr_output_region [10] + 0.00 0.00 52156/515192 describe [35] + 0.00 0.00 426107/515192 default_wage [173] +[1392] 0.0 0.00 0.00 515192 is_mourning [1392] + 0.00 0.00 515192/515192 owner_change [1393] +----------------------------------------------- + 0.00 0.00 515192/515192 is_mourning [1392] +[1393] 0.0 0.00 0.00 515192 owner_change [1393] +----------------------------------------------- + 0.00 0.00 512663/512663 koor_distance [476] +[1394] 0.0 0.00 0.00 512663 koor_distance_orig [1394] +----------------------------------------------- + 0.00 0.00 58/432940 att_modification [90] + 0.00 0.00 89/432940 entertainmoney [643] + 0.00 0.00 508/432940 regenerate_aura [346] + 0.00 0.00 820/432940 curse_geteffect_int [1590] + 0.00 0.00 5358/432940 max_spellpoints [755] + 0.00 0.00 426107/432940 default_wage [173] +[1395] 0.0 0.00 0.00 432940 curse_geteffect [1395] +----------------------------------------------- + 0.00 0.00 417580/417580 a_new [1376] +[1396] 0.0 0.00 0.00 417580 init_learning [1396] +----------------------------------------------- + 0.00 0.00 417577/417577 a_free [558] +[1397] 0.0 0.00 0.00 417577 done_learning [1397] +----------------------------------------------- + 0.00 0.00 417577/417577 study_cmd [105] +[1398] 0.0 0.00 0.00 417577 study_speedup [1398] +----------------------------------------------- + 0.00 0.00 392959/392959 add_message [434] +[1399] 0.0 0.00 0.00 392959 msg_addref [1399] +----------------------------------------------- + 0.00 0.00 86/374425 i_merge [1651] + 0.00 0.00 216/374425 gift_items [891] + 0.00 0.00 340/374425 free_fighter [1580] + 0.00 0.00 18220/374425 i_freeall [1515] + 0.00 0.00 87928/374425 change_money [337] + 0.00 0.00 98482/374425 i_change [115] + 0.00 0.00 169153/374425 statistics [70] +[1400] 0.0 0.00 0.00 374425 i_free [1400] +----------------------------------------------- + 0.00 0.00 1/353788 add_seen_faction [1788] + 0.00 0.00 3767/353788 cb_add_address [598] + 0.00 0.00 350020/353788 get_addresses [20] +[1401] 0.0 0.00 0.00 353788 add_seen_faction_i [1401] +----------------------------------------------- + 0.00 0.00 348444/348444 report_resources [210] +[1402] 0.0 0.00 0.00 348444 report_resource [1402] +----------------------------------------------- + 0.00 0.00 330438/330438 cr_render [196] +[1403] 0.0 0.00 0.00 330438 cr_unit [1403] +----------------------------------------------- + 0.00 0.00 5762/308950 buy [707] + 0.00 0.00 15730/308950 sell [498] + 0.00 0.00 287458/308950 expandselling [93] +[1404] 0.0 0.00 0.00 308950 r_demand [1404] +----------------------------------------------- + 0.00 0.00 297222/297222 render_messages [58] +[1405] 0.0 0.00 0.00 297222 messagehash [1405] +----------------------------------------------- + 0.00 0.00 279072/279072 cr_render [196] +[1406] 0.0 0.00 0.00 279072 cr_int [1406] +----------------------------------------------- + 0.00 0.00 86/257723 i_merge [1651] + 0.00 0.00 216/257723 gift_items [891] + 0.00 0.00 340/257723 free_fighter [1580] + 0.00 0.00 87928/257723 change_money [337] + 0.00 0.00 169153/257723 statistics [70] +[1407] 0.0 0.00 0.00 257723 i_remove [1407] +----------------------------------------------- + 0.00 0.00 5/257693 give_horses [1108] + 0.00 0.00 5/257693 gift_items [891] + 0.00 0.00 9/257693 destroyfaction [392] + 0.00 0.00 64/257693 terraform_region [932] + 0.00 0.00 1098/257693 region_setresource [1097] + 0.00 0.00 28760/257693 migrate [1478] + 0.00 0.00 32679/257693 readregion [209] + 0.00 0.00 195073/257693 horses [330] +[1408] 0.0 0.00 0.00 257693 rsethorses [1408] +----------------------------------------------- + 0.00 0.00 251867/251867 do_attack [80] +[1409] 0.0 0.00 0.00 251867 attacks_per_round [1409] +----------------------------------------------- + 0.00 0.00 1/229715 breedtrees [1148] + 0.00 0.00 6/229715 sp_mallornhain [968] + 0.00 0.00 9/229715 sp_hain [931] + 0.00 0.00 20/229715 dissolve_units [241] + 0.00 0.00 36/229715 volcano_destruction [1022] + 0.00 0.00 51/229715 potion_water_of_life [945] + 0.00 0.00 252/229715 terraform_region [932] + 0.00 0.00 623/229715 tolua_region_set_resource [1057] + 0.00 0.00 98037/229715 readregion [209] + 0.00 0.00 130680/229715 growing_trees [624] +[1410] 0.0 0.00 0.00 229715 rsettrees [1410] +----------------------------------------------- + 0.00 0.00 5/221723 rel_to_abs [1728] + 0.00 0.00 221718/221723 adjust_coordinates [234] +[1411] 0.0 0.00 0.00 221723 plane_center_x [1411] +----------------------------------------------- + 0.00 0.00 5/221723 rel_to_abs [1728] + 0.00 0.00 221718/221723 adjust_coordinates [234] +[1412] 0.0 0.00 0.00 221723 plane_center_y [1412] +----------------------------------------------- + 0.00 0.00 13/217405 expandselling [93] + 0.00 0.00 217392/217405 readregion [209] +[1413] 0.0 0.00 0.00 217405 r_setdemand [1413] +----------------------------------------------- + 0.00 0.00 209572/209572 cr_output_region [10] +[1414] 0.0 0.00 0.00 209572 cr_region_header [1414] +----------------------------------------------- + 0.00 0.00 174/204314 breedhorses [742] + 0.00 0.00 4629/204314 expandselling [93] + 0.00 0.00 5460/204314 buy [707] + 0.00 0.00 15797/204314 sell [498] + 0.00 0.00 178254/204314 produce [29] +[1415] 0.0 0.00 0.00 204314 bt_changed [1415] +----------------------------------------------- + 0.00 0.00 71388/203117 reserve_i [213] + 0.00 0.00 131729/203117 give_cmd [102] +[1416] 0.0 0.00 0.00 203117 atoip [1416] +----------------------------------------------- + 0.00 0.00 93450/196476 see_border [1440] + 0.00 0.00 103026/196476 cr_borders [135] +[1417] 0.0 0.00 0.00 196476 b_finvisible [1417] +----------------------------------------------- + 0.00 0.00 93450/196476 see_border [1440] + 0.00 0.00 103026/196476 cr_borders [135] +[1418] 0.0 0.00 0.00 196476 b_rvisibleroad [1418] +----------------------------------------------- + 0.00 0.00 15/192815 drifting_ships [490] + 0.00 0.00 39714/192815 sail [181] + 0.00 0.00 39832/192815 astralregions [329] + 0.00 0.00 113254/192815 make_route [289] +[1419] 0.0 0.00 0.00 192815 add_regionlist [1419] +----------------------------------------------- + 0.00 0.00 93450/190467 describe [35] + 0.00 0.00 97017/190467 cr_borders [135] +[1420] 0.0 0.00 0.00 190467 b_transparent [1420] +----------------------------------------------- + 0.00 0.00 52/178322 get_or_create_terrain [1680] + 0.00 0.00 178270/178322 get_terrain [1423] +[1421] 0.0 0.00 0.00 178322 terrain_find_i [1421] +----------------------------------------------- + 0.00 0.00 57/178311 terraform_region [932] + 0.00 0.00 178254/178311 readregion [209] +[1422] 0.0 0.00 0.00 178311 region_setinfo [1422] +----------------------------------------------- + 0.00 0.00 2/178270 volcano_update [981] + 0.00 0.00 14/178270 init_terrains [1810] + 0.00 0.00 178254/178270 readregion [209] +[1423] 0.0 0.00 0.00 178270 get_terrain [1423] + 0.00 0.00 178270/178322 terrain_find_i [1421] +----------------------------------------------- + 0.00 0.00 178254/178254 writeregion [519] +[1424] 0.0 0.00 0.00 178254 region_getinfo [1424] +----------------------------------------------- + 0.00 0.00 48/157830 internal_path_find [345] + 0.00 0.00 157782/157830 allowed_dragon [564] +[1425] 0.0 0.00 0.00 157830 allowed_fly [1425] +----------------------------------------------- + 0.00 0.00 152803/152803 free_nodes [1604] +[1426] 0.0 0.00 0.00 152803 free_node [1426] +----------------------------------------------- + 0.00 0.00 27734/152803 regions_in_range [675] + 0.00 0.00 125069/152803 internal_path_find [345] +[1427] 0.0 0.00 0.00 152803 new_node [1427] +----------------------------------------------- + 0.00 0.00 2295/147171 buildingtype_exists [1443] + 0.00 0.00 2920/147171 owner_buildingtyp [676] + 0.00 0.00 12068/147171 building_is_active [1488] + 0.00 0.00 16296/147171 inside_building [1486] + 0.00 0.00 113592/147171 nr_building [141] +[1428] 0.0 0.00 0.00 147171 building_finished [1428] +----------------------------------------------- + 0.00 0.00 141675/141675 addtoken [811] +[1429] 0.0 0.00 0.00 141675 mknode [1429] +----------------------------------------------- + 0.00 0.00 140305/140305 reserve_i [213] +[1430] 0.0 0.00 0.00 140305 set_resvalue [1430] +----------------------------------------------- + 0.00 0.00 12787/130867 canwalk [633] + 0.00 0.00 21443/130867 ridingcapacity [694] + 0.00 0.00 96637/130867 walkingcapacity [403] +[1431] 0.0 0.00 0.00 130867 get_transporters [1431] +----------------------------------------------- + 0.00 0.00 128596/128596 report_plaintext [4] +[1432] 0.0 0.00 0.00 128596 check_errno [1432] +----------------------------------------------- + 0.00 0.00 229/128135 list_address [635] + 0.00 0.00 127906/128135 report_plaintext [4] +[1433] 0.0 0.00 0.00 128135 rpline [1433] +----------------------------------------------- + 0.00 0.00 123744/123744 msg_feedback [647] +[1434] 0.0 0.00 0.00 123744 arg_set [1434] +----------------------------------------------- + 0.00 0.00 110533/110533 make_fighter [424] +[1435] 0.0 0.00 0.00 110533 weapon_weight [1435] +----------------------------------------------- + 0.00 0.00 2/109377 sp_viewreality [784] + 0.00 0.00 15/109377 drifting_ships [490] + 0.00 0.00 311/109377 cr_output_region [10] + 0.00 0.00 5680/109377 describe [35] + 0.00 0.00 103369/109377 move_cmd [66] +[1436] 0.0 0.00 0.00 109377 free_regionlist [1436] +----------------------------------------------- + 0.00 0.00 105958/105958 travel_route [147] +[1437] 0.0 0.00 0.00 105958 entrance_allowed [1437] +----------------------------------------------- + 0.00 0.00 48/101322 terraform_region [932] + 0.00 0.00 5966/101322 herbsearch [493] + 0.00 0.00 32679/101322 readregion [209] + 0.00 0.00 62629/101322 growing_herbs [300] +[1438] 0.0 0.00 0.00 101322 rsetherbs [1438] +----------------------------------------------- + 0.00 0.00 96208/96208 travel_route [147] +[1439] 0.0 0.00 0.00 96208 var_copy_regions [1439] +----------------------------------------------- + 0.00 0.00 93452/93452 describe [35] +[1440] 0.0 0.00 0.00 93452 see_border [1440] + 0.00 0.00 93450/196476 b_finvisible [1417] + 0.00 0.00 93450/196476 b_rvisibleroad [1418] + 0.00 0.00 14192/26515 b_uinvisible [1487] + 0.00 0.00 2/2 b_fvisible [1771] +----------------------------------------------- + 0.00 0.00 1/93120 use_pooled [39] + 0.00 0.00 93119/93120 give_item [126] +[1441] 0.0 0.00 0.00 93120 change_reservation [1441] +----------------------------------------------- + 0.00 0.00 5/87004 set_money [1326] + 0.00 0.00 9/87004 default_spoil [1144] + 0.00 0.00 23/87004 equip_items [1121] + 0.00 0.00 60/87004 equip_unit_mask [776] + 0.00 0.00 86907/87004 change_money [337] +[1442] 0.0 0.00 0.00 87004 i_add [1442] +----------------------------------------------- + 0.00 0.00 2/75797 build_building [696] + 0.00 0.00 5/75797 build_road [950] + 0.00 0.00 208/75797 demographics [50] + 0.00 0.00 322/75797 can_takeoff [854] + 0.00 0.00 344/75797 expandselling [93] + 0.00 0.00 344/75797 produce [29] + 0.00 0.00 1112/75797 sell [498] + 0.00 0.00 2495/75797 study_cmd [105] + 0.00 0.00 31155/75797 statistics [70] + 0.00 0.00 39810/75797 check_ship_allowed [657] +[1443] 0.0 0.00 0.00 75797 buildingtype_exists [1443] + 0.00 0.00 2295/147171 building_finished [1428] +----------------------------------------------- + 0.00 0.00 5/65345 expandloot [816] + 0.00 0.00 32670/65345 morale_update [1479] + 0.00 0.00 32670/65345 writeregion [519] +[1444] 0.0 0.00 0.00 65345 region_get_morale [1444] +----------------------------------------------- + 0.00 0.00 62267/62267 horses [330] +[1445] 0.0 0.00 0.00 62267 get_migrants [1445] +----------------------------------------------- + 0.00 0.00 89/59694 recruit [650] + 0.00 0.00 1567/59694 travel_route [147] + 0.00 0.00 4139/59694 produce [29] + 0.00 0.00 5588/59694 process [7] + 0.00 0.00 8501/59694 magic [157] + 0.00 0.00 39810/59694 check_ship_allowed [657] +[1446] 0.0 0.00 0.00 59694 r_insectstalled [1446] +----------------------------------------------- + 0.00 0.00 58524/58524 a_write [299] +[1447] 0.0 0.00 0.00 58524 a_writeint [1447] +----------------------------------------------- + 0.00 0.00 106/58518 a_readkey [1648] + 0.00 0.00 58412/58518 a_read_i [390] +[1448] 0.0 0.00 0.00 58518 a_readint [1448] +----------------------------------------------- + 0.00 0.00 56646/56646 a_write [299] +[1449] 0.0 0.00 0.00 56646 write_group [1449] +----------------------------------------------- + 0.00 0.00 56503/56503 read_group [1451] +[1450] 0.0 0.00 0.00 56503 find_group [1450] +----------------------------------------------- + 0.00 0.00 56503/56503 a_read_i [390] +[1451] 0.0 0.00 0.00 56503 read_group [1451] + 0.00 0.00 56503/56503 find_group [1450] +----------------------------------------------- + 0.00 0.00 2/55547 ally_cmd [877] + 0.00 0.00 98/55547 init_group [1764] + 0.00 0.00 5925/55547 addally [913] + 0.00 0.00 49522/55547 read_groups [782] +[1452] 0.0 0.00 0.00 55547 ally_add [1452] +----------------------------------------------- + 0.00 0.00 54735/54735 write_travelthru [327] +[1453] 0.0 0.00 0.00 54735 init_cb [1453] +----------------------------------------------- + 0.00 0.00 54163/54163 copy_arg [521] +[1454] 0.0 0.00 0.00 54163 var_copy_string [1454] +----------------------------------------------- + 0.00 0.00 10/51239 changefaction_read [1166] + 0.00 0.00 13/51239 read_planes [1164] + 0.00 0.00 51216/51239 read_groups [782] +[1455] 0.0 0.00 0.00 51239 read_faction_reference [1455] +----------------------------------------------- + 0.00 0.00 12/51060 set_level [774] + 0.00 0.00 95/51060 transfermen [899] + 0.00 0.00 50953/51060 scale_number [969] +[1456] 0.0 0.00 0.00 51060 remove_skill [1456] +----------------------------------------------- + 0.00 0.00 50673/50673 demographics [50] +[1457] 0.0 0.00 0.00 50673 update_resources [1457] +----------------------------------------------- + 0.00 0.00 49331/49331 log_stdio [1459] +[1458] 0.0 0.00 0.00 49331 log_prefix [1458] +----------------------------------------------- + 0.00 0.00 49331/49331 log_write [1243] +[1459] 0.0 0.00 0.00 49331 log_stdio [1459] + 0.00 0.00 49331/49331 log_prefix [1458] + 0.00 0.00 49331/49331 _log_write [3280] +----------------------------------------------- + 0.00 0.00 9/48565 build_building [696] + 0.00 0.00 323/48565 enter_building [695] + 0.00 0.00 837/48565 create_unit [296] + 0.00 0.00 47396/48565 read_unit [74] +[1460] 0.0 0.00 0.00 48565 u_set_building [1460] + 0.00 0.00 18971/18971 building_set_owner [1504] +----------------------------------------------- + 0.00 0.00 2/48457 remove_building [1153] + 0.00 0.00 48455/48457 findbuilding [1462] +[1461] 0.0 0.00 0.00 48457 bfindhash [1461] +----------------------------------------------- + 0.00 0.00 1/48455 resolve_building [1862] + 0.00 0.00 4/48455 verify_building [1255] + 0.00 0.00 16/48455 newcontainerid [1263] + 0.00 0.00 27/48455 renumber_cmd [780] + 0.00 0.00 401/48455 enter_building [695] + 0.00 0.00 610/48455 build_building [696] + 0.00 0.00 47396/48455 read_unit [74] +[1462] 0.0 0.00 0.00 48455 findbuilding [1462] + 0.00 0.00 48455/48457 bfindhash [1461] +----------------------------------------------- + 0.00 0.00 1466/46742 resolve_region_id [1575] + 0.00 0.00 45276/46742 read_borders [706] +[1463] 0.0 0.00 0.00 46742 findregionbyid [1463] +----------------------------------------------- + 0.00 0.00 10/46196 renumber_cmd [780] + 0.00 0.00 11/46196 new_building [1059] + 0.00 0.00 46175/46196 read_game [62] +[1464] 0.0 0.00 0.00 46196 bhash [1464] +----------------------------------------------- + 0.00 0.00 4307/44216 set_coast [875] + 0.00 0.00 39909/44216 sail [181] +[1465] 0.0 0.00 0.00 44216 flying_ship [1465] +----------------------------------------------- + 0.00 0.00 2/40692 tolua_get_season [2888] + 0.00 0.00 2/40692 breedtrees [1148] + 0.00 0.00 2/40692 demographics [50] + 0.00 0.00 3/40692 gamedate2 [1222] + 0.00 0.00 89/40692 recruit [650] + 0.00 0.00 230/40692 gamedate_season [944] + 0.00 0.00 460/40692 report_plaintext [4] + 0.00 0.00 39904/40692 sail [181] +[1466] 0.0 0.00 0.00 40692 get_gamedate [1466] +----------------------------------------------- + 0.00 0.00 39955/39955 a_write [299] +[1467] 0.0 0.00 0.00 39955 write_of [1467] +----------------------------------------------- + 0.00 0.00 37453/37453 a_age [418] +[1468] 0.0 0.00 0.00 37453 shiptrail_age [1468] +----------------------------------------------- + 0.00 0.00 37453/37453 a_new [1376] +[1469] 0.0 0.00 0.00 37453 shiptrail_init [1469] +----------------------------------------------- + 0.00 0.00 37202/37202 free_arg [1371] +[1470] 0.0 0.00 0.00 37202 var_free_string [1470] +----------------------------------------------- + 0.00 0.00 37024/37024 move_blocked [283] +[1471] 0.0 0.00 0.00 37024 b_blocknone [1471] +----------------------------------------------- + 0.00 0.00 10/34565 changefaction_read [1166] + 0.00 0.00 2941/34565 addally [913] + 0.00 0.00 3693/34565 read_reference [726] + 0.00 0.00 27921/34565 read_groups [782] +[1472] 0.0 0.00 0.00 34565 ur_add [1472] +----------------------------------------------- + 0.00 0.00 34420/34420 a_write [299] +[1473] 0.0 0.00 0.00 34420 a_writeshorts [1473] +----------------------------------------------- + 0.00 0.00 34382/34382 a_read_i [390] +[1474] 0.0 0.00 0.00 34382 a_readshorts [1474] +----------------------------------------------- + 0.00 0.00 34220/34220 a_read_i [390] +[1475] 0.0 0.00 0.00 34220 shiptrail_read [1475] +----------------------------------------------- + 0.00 0.00 48/32727 terraform_region [932] + 0.00 0.00 32679/32727 readregion [209] +[1476] 0.0 0.00 0.00 32727 region_set_morale [1476] +----------------------------------------------- + 0.00 0.00 32679/32679 readregion [209] +[1477] 0.0 0.00 0.00 32679 read_owner [1477] +----------------------------------------------- + 0.00 0.00 32670/32670 demographics [50] +[1478] 0.0 0.00 0.00 32670 migrate [1478] + 0.00 0.00 28760/1160345 rhorses [1369] + 0.00 0.00 28760/257693 rsethorses [1408] +----------------------------------------------- + 0.00 0.00 32670/32670 age_region [659] +[1479] 0.0 0.00 0.00 32670 morale_update [1479] + 0.00 0.00 32670/65345 region_get_morale [1444] +----------------------------------------------- + 0.00 0.00 32670/32670 writeregion [519] +[1480] 0.0 0.00 0.00 32670 write_owner [1480] +----------------------------------------------- + 0.00 0.00 31688/31688 cr_render [196] +[1481] 0.0 0.00 0.00 31688 cr_building [1481] +----------------------------------------------- + 0.00 0.00 30150/30150 nr_ship [111] +[1482] 0.0 0.00 0.00 30150 ship_damage_percent [1482] +----------------------------------------------- + 0.00 0.00 16/28818 newcontainerid [1263] + 0.00 0.00 22/28818 verify_ship [1704] + 0.00 0.00 31/28818 renumber_cmd [780] + 0.00 0.00 222/28818 enter_ship [733] + 0.00 0.00 283/28818 follow_ship [749] + 0.00 0.00 307/28818 getship [1018] + 0.00 0.00 525/28818 follow_unit [331] + 0.00 0.00 27412/28818 read_unit [74] +[1483] 0.0 0.00 0.00 28818 findship [1483] + 0.00 0.00 28818/28818 sfindhash [1484] +----------------------------------------------- + 0.00 0.00 28818/28818 findship [1483] +[1484] 0.0 0.00 0.00 28818 sfindhash [1484] +----------------------------------------------- + 0.00 0.00 2/27640 create_ship [1014] + 0.00 0.00 35/27640 create_unit [296] + 0.00 0.00 191/27640 enter_ship [733] + 0.00 0.00 27412/27640 read_unit [74] +[1485] 0.0 0.00 0.00 27640 u_set_ship [1485] + 0.00 0.00 18960/18963 ship_set_owner [1505] +----------------------------------------------- + 0.00 0.00 140/26995 age_stonecircle [1021] + 0.00 0.00 225/26995 spellpower [1000] + 0.00 0.00 226/26995 fumble [973] + 0.00 0.00 318/26995 in_safe_building [1585] + 0.00 0.00 508/26995 regenerate_aura [346] + 0.00 0.00 1733/26995 build [691] + 0.00 0.00 3563/26995 prepare_report [8] + 0.00 0.00 5920/26995 allocate_resource [752] + 0.00 0.00 6405/26995 active_building [560] + 0.00 0.00 7957/26995 magic_resistance [727] +[1486] 0.0 0.00 0.00 26995 inside_building [1486] + 0.00 0.00 16296/147171 building_finished [1428] + 0.00 0.00 16284/19671 buildingcapacity [1500] +----------------------------------------------- + 0.00 0.00 12323/26515 cr_borders [135] + 0.00 0.00 14192/26515 see_border [1440] +[1487] 0.0 0.00 0.00 26515 b_uinvisible [1487] +----------------------------------------------- + 0.00 0.00 225/26164 spellpower [1000] + 0.00 0.00 226/26164 fumble [973] + 0.00 0.00 508/26164 regenerate_aura [346] + 0.00 0.00 4530/26164 build [691] + 0.00 0.00 5920/26164 allocate_resource [752] + 0.00 0.00 6798/26164 active_building [560] + 0.00 0.00 7957/26164 magic_resistance [727] +[1488] 0.0 0.00 0.00 26164 building_is_active [1488] + 0.00 0.00 12068/147171 building_finished [1428] +----------------------------------------------- + 0.00 0.00 12828/26045 cr_output_curses [69] + 0.00 0.00 13217/26045 nr_curses_i [401] +[1489] 0.0 0.00 0.00 26045 curse_cansee [1489] +----------------------------------------------- + 0.00 0.00 25441/25441 readregion [209] +[1490] 0.0 0.00 0.00 25441 rmt_find [1490] +----------------------------------------------- + 0.00 0.00 1084/24449 print_header [838] + 0.00 0.00 2168/24449 aftermath [701] + 0.00 0.00 7336/24449 battle_report [503] + 0.00 0.00 13861/24449 print_stats [525] +[1491] 0.0 0.00 0.00 24449 seematrix [1491] +----------------------------------------------- + 0.00 0.00 23342/23342 a_free [558] +[1492] 0.0 0.00 0.00 23342 shiptrail_finalize [1492] +----------------------------------------------- + 0.00 0.00 23233/23233 cr_render [196] +[1493] 0.0 0.00 0.00 23233 cr_faction [1493] +----------------------------------------------- + 0.00 0.00 22643/22643 write_borders [1897] +[1494] 0.0 0.00 0.00 22643 b_validroad [1494] +----------------------------------------------- + 0.00 0.00 22643/22643 write_borders [1897] +[1495] 0.0 0.00 0.00 22643 b_writeroad [1495] +----------------------------------------------- + 0.00 0.00 22638/22638 read_borders [706] +[1496] 0.0 0.00 0.00 22638 find_bordertype [1496] +----------------------------------------------- + 0.00 0.00 22637/22637 read_borders [706] +[1497] 0.0 0.00 0.00 22637 b_readroad [1497] +----------------------------------------------- + 0.00 0.00 1104/22301 aftermath [701] + 0.00 0.00 7336/22301 battle_report [503] + 0.00 0.00 13861/22301 print_stats [525] +[1498] 0.0 0.00 0.00 22301 army_index [1498] +----------------------------------------------- + 0.00 0.00 7/21500 new_luxurytype [1739] + 0.00 0.00 5762/21500 buy [707] + 0.00 0.00 15731/21500 sell [498] +[1499] 0.0 0.00 0.00 21500 resource2luxury [1499] +----------------------------------------------- + 0.00 0.00 3387/19671 lighthouse_range [728] + 0.00 0.00 16284/19671 inside_building [1486] +[1500] 0.0 0.00 0.00 19671 buildingcapacity [1500] +----------------------------------------------- + 0.00 0.00 7/19089 st_get_or_create [1743] + 0.00 0.00 19082/19089 st_find [1503] +[1501] 0.0 0.00 0.00 19089 st_find_i [1501] +----------------------------------------------- + 0.00 0.00 1/19085 renumber_cmd [780] + 0.00 0.00 2/19085 new_ship [1229] + 0.00 0.00 19082/19085 read_game [62] +[1502] 0.0 0.00 0.00 19085 shash [1502] +----------------------------------------------- + 0.00 0.00 19082/19082 read_game [62] +[1503] 0.0 0.00 0.00 19082 st_find [1503] + 0.00 0.00 19082/19089 st_find_i [1501] +----------------------------------------------- + 0.00 0.00 18971/18971 u_set_building [1460] +[1504] 0.0 0.00 0.00 18971 building_set_owner [1504] +----------------------------------------------- + 0.00 0.00 3/18963 give_control [1763] + 0.00 0.00 18960/18963 u_set_ship [1485] +[1505] 0.0 0.00 0.00 18963 ship_set_owner [1505] +----------------------------------------------- + 0.00 0.00 17289/17289 teach_cmd [272] +[1506] 0.0 0.00 0.00 17289 parser_popstate [1506] +----------------------------------------------- + 0.00 0.00 17289/17289 teach_cmd [272] +[1507] 0.0 0.00 0.00 17289 parser_pushstate [1507] +----------------------------------------------- + 0.00 0.00 16737/16737 roadto [606] +[1508] 0.0 0.00 0.00 16737 dir_invert [1508] +----------------------------------------------- + 0.00 0.00 16191/16191 help_feed [678] +[1509] 0.0 0.00 0.00 16191 add_donation [1509] +----------------------------------------------- + 0.00 0.00 14994/14994 cr_render [196] +[1510] 0.0 0.00 0.00 14994 cr_string [1510] +----------------------------------------------- + 0.00 0.00 14111/14111 a_write [299] +[1511] 0.0 0.00 0.00 14111 shiptrail_write [1511] +----------------------------------------------- + 0.00 0.00 3115/13500 drifting_ships [490] + 0.00 0.00 3135/13500 sinkships [475] + 0.00 0.00 7250/13500 ship_ready [354] +[1512] 0.0 0.00 0.00 13500 enoughsailors [1512] +----------------------------------------------- + 0.00 0.00 9/11052 xml_spell [1727] + 0.00 0.00 16/11052 do_combatmagic [825] + 0.00 0.00 24/11052 add_spells [1668] + 0.00 0.00 326/11052 parse_spellbooks [1827] + 0.00 0.00 1174/11052 read_spellbook [1555] + 0.00 0.00 1312/11052 read_mage [1559] + 0.00 0.00 8191/11052 read_seenspell [1522] +[1513] 0.0 0.00 0.00 11052 find_spell [1513] + 0.00 0.00 11052/11052 sp_alias [1514] +----------------------------------------------- + 0.00 0.00 11052/11052 find_spell [1513] +[1514] 0.0 0.00 0.00 11052 sp_alias [1514] +----------------------------------------------- + 0.00 0.00 1/10475 item_done [1811] + 0.00 0.00 57/10475 terraform_region [932] + 0.00 0.00 10417/10475 free_luxuries [1516] +[1515] 0.0 0.00 0.00 10475 i_freeall [1515] + 0.00 0.00 18220/374425 i_free [1400] +----------------------------------------------- + 0.00 0.00 10417/10417 a_free [558] +[1516] 0.0 0.00 0.00 10417 free_luxuries [1516] + 0.00 0.00 10417/10475 i_freeall [1515] +----------------------------------------------- + 0.00 0.00 9147/9147 report_plaintext [4] +[1517] 0.0 0.00 0.00 9147 merge_messages [1517] +----------------------------------------------- + 0.00 0.00 9147/9147 report_plaintext [4] +[1518] 0.0 0.00 0.00 9147 split_messages [1518] +----------------------------------------------- + 0.00 0.00 8962/8962 battle_flee [352] +[1519] 0.0 0.00 0.00 8962 hpflee [1519] +----------------------------------------------- + 0.00 0.00 1909/8788 parse_messages [832] + 0.00 0.00 6879/8788 xml_readstrings [863] +[1520] 0.0 0.00 0.00 8788 xml_cleanup_string [1520] +----------------------------------------------- + 0.00 0.00 8622/8622 read_reference [726] +[1521] 0.0 0.00 0.00 8622 read_unit_reference [1521] +----------------------------------------------- + 0.00 0.00 8191/8191 a_read_i [390] +[1522] 0.0 0.00 0.00 8191 read_seenspell [1522] + 0.00 0.00 8191/11052 find_spell [1513] +----------------------------------------------- + 0.00 0.00 8187/8187 a_write [299] +[1523] 0.0 0.00 0.00 8187 write_seenspell [1523] +----------------------------------------------- + 0.00 0.00 7964/7964 report_crtypes [428] +[1524] 0.0 0.00 0.00 7964 nrt_section [1524] +----------------------------------------------- + 0.00 0.00 7915/7915 report_resources [210] +[1525] 0.0 0.00 0.00 7915 visible_default [1525] +----------------------------------------------- + 0.00 0.00 1762/7889 tolua_region_set_resource [1057] + 0.00 0.00 6127/7889 tolua_region_get_resource [976] +[1526] 0.0 0.00 0.00 7889 special_resources [1526] +----------------------------------------------- + 0.00 0.00 2704/7493 leveled_allocation [888] + 0.00 0.00 4789/7493 attrib_allocation [914] +[1527] 0.0 0.00 0.00 7493 required [1527] +----------------------------------------------- + 0.00 0.00 7336/7336 battle_report [503] +[1528] 0.0 0.00 0.00 7336 get_alive [1528] +----------------------------------------------- + 0.00 0.00 7220/7220 a_write [299] +[1529] 0.0 0.00 0.00 7220 a_writestring [1529] +----------------------------------------------- + 0.00 0.00 7153/7153 cr_render [196] +[1530] 0.0 0.00 0.00 7153 cr_ship [1530] +----------------------------------------------- + 0.00 0.00 7085/7085 a_read_i [390] +[1531] 0.0 0.00 0.00 7085 a_readprivate [1531] +----------------------------------------------- + 0.00 0.00 16/6576 xml_readarmor [1736] + 0.00 0.00 21/6576 parse_ships [1305] + 0.00 0.00 250/6576 parse_buildings [1131] + 0.00 0.00 268/6576 parse_ai [1662] + 0.00 0.00 303/6576 xml_readweapon [1266] + 0.00 0.00 318/6576 parse_resources [1086] + 0.00 0.00 942/6576 xml_readitem [1107] + 0.00 0.00 1660/6576 parse_spells [1120] + 0.00 0.00 2798/6576 parse_races [1104] +[1532] 0.0 0.00 0.00 6576 xml_bvalue [1532] +----------------------------------------------- + 0.00 0.00 4/5453 parse_resources [1086] + 0.00 0.00 7/5453 xml_readluxury [1745] + 0.00 0.00 8/5453 xml_readarmor [1736] + 0.00 0.00 11/5453 parse_calendar [1252] + 0.00 0.00 15/5453 xml_readpotion [1714] + 0.00 0.00 24/5453 add_spells [1668] + 0.00 0.00 63/5453 parse_ships [1305] + 0.00 0.00 108/5453 xml_readweapon [1266] + 0.00 0.00 134/5453 parse_ai [1662] + 0.00 0.00 162/5453 xml_readrequirements [1186] + 0.00 0.00 179/5453 parse_buildings [1131] + 0.00 0.00 326/5453 parse_spellbooks [1827] + 0.00 0.00 471/5453 xml_readitem [1107] + 0.00 0.00 504/5453 xml_readconstruction [1183] + 0.00 0.00 731/5453 parse_spells [1120] + 0.00 0.00 2706/5453 parse_races [1104] +[1533] 0.0 0.00 0.00 5453 xml_ivalue [1533] +----------------------------------------------- + 0.00 0.00 946/5330 centre [789] + 0.00 0.00 4384/5330 battle_punit [620] +[1534] 0.0 0.00 0.00 5330 freestrlist [1534] +----------------------------------------------- + 0.00 0.00 4066/4066 report_template [87] +[1535] 0.0 0.00 0.00 4066 buildingmaintenance [1535] +----------------------------------------------- + 0.00 0.00 4052/4052 curse_age [1538] +[1536] 0.0 0.00 0.00 4052 c_clearflag [1536] +----------------------------------------------- + 0.00 0.00 32/4052 make_curse [802] + 0.00 0.00 4020/4052 curse_read [770] +[1537] 0.0 0.00 0.00 4052 chash [1537] +----------------------------------------------- + 0.00 0.00 4052/4052 a_age [418] +[1538] 0.0 0.00 0.00 4052 curse_age [1538] + 0.00 0.00 4052/4052 c_clearflag [1536] + 0.00 0.00 1/1 flyingship_age [1803] +----------------------------------------------- + 0.00 0.00 4052/4052 a_new [1376] +[1539] 0.0 0.00 0.00 4052 curse_init [1539] +----------------------------------------------- + 0.00 0.00 2/3862 sp_igjarjuk [923] + 0.00 0.00 6/3862 tolua_unit_set_name [3148] + 0.00 0.00 27/3862 dragon_name [1095] + 0.00 0.00 34/3862 dracoid_name [1126] + 0.00 0.00 196/3862 make_name [970] + 0.00 0.00 666/3862 generic_name [962] + 0.00 0.00 2931/3862 name_unit [803] +[1540] 0.0 0.00 0.00 3862 unit_setname [1540] +----------------------------------------------- + 0.00 0.00 9/3717 magic [157] + 0.00 0.00 3708/3717 do_combatmagic [825] +[1541] 0.0 0.00 0.00 3717 free_castorders [1541] + 0.00 0.00 229/303 free_castorder [1609] +----------------------------------------------- + 0.00 0.00 3639/3639 attack [84] +[1542] 0.0 0.00 0.00 3639 setreload [1542] +----------------------------------------------- + 0.00 0.00 231/3203 update_spells [381] + 0.00 0.00 2972/3203 unit_get_spellbook [427] +[1543] 0.0 0.00 0.00 3203 faction_get_spellbook [1543] + 0.00 0.00 3165/3171 get_spellbook [1544] +----------------------------------------------- + 0.00 0.00 6/3171 parse_spellbooks [1827] + 0.00 0.00 3165/3171 faction_get_spellbook [1543] +[1544] 0.0 0.00 0.00 3171 get_spellbook [1544] + 0.00 0.00 6/380 create_spellbook [1606] +----------------------------------------------- + 0.00 0.00 3114/3114 name_cmd [835] +[1545] 0.0 0.00 0.00 3114 rename_cmd [1545] +----------------------------------------------- + 0.00 0.00 1/3113 trigger_giveitem [1891] + 0.00 0.00 1/3113 trigger_shock [1892] + 0.00 0.00 2/3113 trigger_changefaction [1783] + 0.00 0.00 3/3113 trigger_changerace [1297] + 0.00 0.00 5/3113 trigger_killunit [1752] + 0.00 0.00 5/3113 trigger_timeout [1753] + 0.00 0.00 3096/3113 read_triggers [798] +[1546] 0.0 0.00 0.00 3113 t_new [1546] + 0.00 0.00 18/18 timeout_init [1710] + 0.00 0.00 12/12 changefaction_init [1721] + 0.00 0.00 6/6 changerace_init [1746] + 0.00 0.00 2/2 giveitem_init [1774] +----------------------------------------------- + 0.00 0.00 122/3100 maxbuild [946] + 0.00 0.00 2978/3100 build [691] +[1547] 0.0 0.00 0.00 3100 required [1547] +----------------------------------------------- + 0.00 0.00 3096/3096 read_triggers [798] +[1548] 0.0 0.00 0.00 3096 tt_find [1548] +----------------------------------------------- + 0.00 0.00 319/2913 loot_items [810] + 0.00 0.00 2594/2913 aftermath [701] +[1549] 0.0 0.00 0.00 2913 dead_fighters [1549] +----------------------------------------------- + 0.00 0.00 2/2854 summon_allies [925] + 0.00 0.00 149/2854 print_stats [525] + 0.00 0.00 2703/2854 print_header [838] +[1550] 0.0 0.00 0.00 2854 is_attacker [1550] +----------------------------------------------- + 0.00 0.00 1/2742 oldfamiliars [1240] + 0.00 0.00 10/2742 spawn_dragons [411] + 0.00 0.00 17/2742 recruit_dracoids [837] + 0.00 0.00 20/2742 spawn_seaserpent [831] + 0.00 0.00 21/2742 spawn_undead [629] + 0.00 0.00 48/2742 terraform_region [932] + 0.00 0.00 319/2742 kill_troop [532] + 0.00 0.00 639/2742 spawn_braineaters [505] + 0.00 0.00 1667/2742 add_recruits [371] +[1551] 0.0 0.00 0.00 2742 get_equipment [1551] +----------------------------------------------- + 0.00 0.00 2650/2650 a_new [1376] +[1552] 0.0 0.00 0.00 2650 a_initeffect [1552] +----------------------------------------------- + 0.00 0.00 2468/2468 mt_new [1588] +[1553] 0.0 0.00 0.00 2468 find_argtype [1553] +----------------------------------------------- + 0.00 0.00 2468/2468 crt_register [1006] +[1554] 0.0 0.00 0.00 2468 tsf_find [1554] +----------------------------------------------- + 0.00 0.00 233/2324 readfaction [767] + 0.00 0.00 2091/2324 read_mage [1559] +[1555] 0.0 0.00 0.00 2324 read_spellbook [1555] + 0.00 0.00 1174/11052 find_spell [1513] + 0.00 0.00 1174/1524 spellbook_add [1572] + 0.00 0.00 367/380 create_spellbook [1606] +----------------------------------------------- + 0.00 0.00 232/2321 writefaction [762] + 0.00 0.00 2089/2321 write_mage [1560] +[1556] 0.0 0.00 0.00 2321 write_spellbook [1556] +----------------------------------------------- + 0.00 0.00 99/2112 eff_spelllevel [845] + 0.00 0.00 489/2112 u_hasspell [951] + 0.00 0.00 1524/2112 spellbook_add [1572] +[1557] 0.0 0.00 0.00 2112 spellbook_get [1557] +----------------------------------------------- + 0.00 0.00 2092/2092 a_new [1376] +[1558] 0.0 0.00 0.00 2092 init_mage [1558] +----------------------------------------------- + 0.00 0.00 2091/2091 a_read_i [390] +[1559] 0.0 0.00 0.00 2091 read_mage [1559] + 0.00 0.00 2091/2324 read_spellbook [1555] + 0.00 0.00 1312/11052 find_spell [1513] +----------------------------------------------- + 0.00 0.00 2089/2089 a_write [299] +[1560] 0.0 0.00 0.00 2089 write_mage [1560] + 0.00 0.00 2089/2321 write_spellbook [1556] +----------------------------------------------- + 0.00 0.00 2081/2081 a_new [1376] +[1561] 0.0 0.00 0.00 2081 a_init_reportspell [1561] +----------------------------------------------- + 0.00 0.00 644/2073 join_allies [693] + 0.00 0.00 1429/2073 start_battle [297] +[1562] 0.0 0.00 0.00 2073 set_enemy [1562] +----------------------------------------------- + 0.00 0.00 1909/1909 nrt_register [883] +[1563] 0.0 0.00 0.00 1909 section_find [1563] +----------------------------------------------- + 0.00 0.00 1716/1716 recruit [650] +[1564] 0.0 0.00 0.00 1716 recruit_cost [1564] +----------------------------------------------- + 0.00 0.00 3/1697 join_group [1083] + 0.00 0.00 1694/1697 read_groups [782] +[1565] 0.0 0.00 0.00 1697 new_group [1565] +----------------------------------------------- + 0.00 0.00 1670/1670 select_recruitment [1079] +[1566] 0.0 0.00 0.00 1670 any_recruiters [1566] +----------------------------------------------- + 0.00 0.00 1670/1670 select_recruitment [1079] +[1567] 0.0 0.00 0.00 1670 horse_recruiters [1567] +----------------------------------------------- + 0.00 0.00 1594/1594 expandrecruit [349] +[1568] 0.0 0.00 0.00 1594 free_recruitments [1568] + 0.00 0.00 1670/1936876 free_order [1356] +----------------------------------------------- + 0.00 0.00 15/1582 new_potiontype [1712] + 0.00 0.00 19/1582 reshow_other [823] + 0.00 0.00 337/1582 report_computer [9] + 0.00 0.00 337/1582 report_plaintext [4] + 0.00 0.00 348/1582 use_potion [801] + 0.00 0.00 526/1582 create_item [617] +[1569] 0.0 0.00 0.00 1582 resource2potion [1569] +----------------------------------------------- + 0.00 0.00 1564/1564 a_new [1376] +[1570] 0.0 0.00 0.00 1564 init_handler [1570] +----------------------------------------------- + 0.00 0.00 18/1529 ship_update_owner [573] + 0.00 0.00 1511/1529 ship_owner [438] +[1571] 0.0 0.00 0.00 1529 ship_owner_ex [1571] +----------------------------------------------- + 0.00 0.00 24/1524 equipment_addspell [1702] + 0.00 0.00 326/1524 parse_spellbooks [1827] + 0.00 0.00 1174/1524 read_spellbook [1555] +[1572] 0.0 0.00 0.00 1524 spellbook_add [1572] + 0.00 0.00 1524/2112 spellbook_get [1557] +----------------------------------------------- + 0.00 0.00 1522/1522 a_age [418] +[1573] 0.0 0.00 0.00 1522 age_unit [1573] +----------------------------------------------- + 0.00 0.00 1520/1520 join_allies [693] +[1574] 0.0 0.00 0.00 1520 set_friendly [1574] +----------------------------------------------- + 0.00 0.00 326/1466 resolve [757] + 0.00 0.00 1140/1466 read_reference [726] +[1575] 0.0 0.00 0.00 1466 resolve_region_id [1575] + 0.00 0.00 1466/46742 findregionbyid [1463] +----------------------------------------------- + 0.00 0.00 661/1429 join_battle [425] + 0.00 0.00 768/1429 make_fighter [424] +[1576] 0.0 0.00 0.00 1429 set_attacker [1576] +----------------------------------------------- + 0.00 0.00 114/1361 give_unit [952] + 0.00 0.00 588/1361 give_men [857] + 0.00 0.00 659/1361 can_give_men [940] +[1577] 0.0 0.00 0.00 1361 unit_has_cursed_item [1577] +----------------------------------------------- + 0.00 0.00 1301/1301 leveled_allocation [888] +[1578] 0.0 0.00 0.00 1301 rm_get [1578] +----------------------------------------------- + 0.00 0.00 1297/1297 make_fighter [424] +[1579] 0.0 0.00 0.00 1297 add_tactics [1579] +----------------------------------------------- + 0.00 0.00 1297/1297 battle_free [1629] +[1580] 0.0 0.00 0.00 1297 free_fighter [1580] + 0.00 0.00 340/374425 i_free [1400] + 0.00 0.00 340/257723 i_remove [1407] +----------------------------------------------- + 0.00 0.00 1295/1295 make_fighter [424] +[1581] 0.0 0.00 0.00 1295 find_side [1581] +----------------------------------------------- + 0.00 0.00 1140/1140 read_reference [726] +[1582] 0.0 0.00 0.00 1140 read_region_reference [1582] +----------------------------------------------- + 0.00 0.00 2/1119 wormhole_write [1785] + 0.00 0.00 1117/1119 write_targetregion [1584] +[1583] 0.0 0.00 0.00 1119 write_region_reference [1583] +----------------------------------------------- + 0.00 0.00 1117/1117 a_write [299] +[1584] 0.0 0.00 0.00 1117 write_targetregion [1584] + 0.00 0.00 1117/1119 write_region_reference [1583] +----------------------------------------------- + 0.00 0.00 1042/1042 monster_attacks [248] +[1585] 0.0 0.00 0.00 1042 in_safe_building [1585] + 0.00 0.00 318/26995 inside_building [1486] +----------------------------------------------- + 0.00 0.00 2/1041 disable_feature [771] + 0.00 0.00 6/1041 tolua_unit_setskill [1163] + 0.00 0.00 23/1041 xml_readweapon [1266] + 0.00 0.00 84/1041 xml_readconstruction [1183] + 0.00 0.00 106/1041 add_skills [1667] + 0.00 0.00 820/1041 parse_races [1104] +[1586] 0.0 0.00 0.00 1041 findskill [1586] +----------------------------------------------- + 0.00 0.00 957/957 mt_register [1007] +[1587] 0.0 0.00 0.00 957 mt_id [1587] +----------------------------------------------- + 0.00 0.00 957/957 parse_messages [832] +[1588] 0.0 0.00 0.00 957 mt_new [1588] + 0.00 0.00 2468/2468 find_argtype [1553] +----------------------------------------------- + 0.00 0.00 894/894 follow_unit [331] +[1589] 0.0 0.00 0.00 894 make_follow [1589] + 0.00 0.00 894/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 820/820 shipspeed [669] +[1590] 0.0 0.00 0.00 820 curse_geteffect_int [1590] + 0.00 0.00 820/432940 curse_geteffect [1395] +----------------------------------------------- + 0.00 0.00 785/785 i_canuse [569] +[1591] 0.0 0.00 0.00 785 lua_canuse_item [1591] +----------------------------------------------- + 0.00 0.00 763/763 a_new [1376] +[1592] 0.0 0.00 0.00 763 init_skillmod [1592] +----------------------------------------------- + 0.00 0.00 132/677 can_contact [1634] + 0.00 0.00 222/677 leave_cmd [721] + 0.00 0.00 323/677 enter_building [695] +[1593] 0.0 0.00 0.00 677 slipthru [1593] +----------------------------------------------- + 0.00 0.00 1/608 sp_holyground [1068] + 0.00 0.00 1/608 sp_summonshadowlords [1034] + 0.00 0.00 1/608 sp_generous [1040] + 0.00 0.00 1/608 sp_enterastral [1045] + 0.00 0.00 1/608 sp_flying_ship [1064] + 0.00 0.00 2/608 sp_summon_familiar [1025] + 0.00 0.00 2/608 sp_viewreality [784] + 0.00 0.00 3/608 sp_song_of_peace [939] + 0.00 0.00 3/608 sp_eternizewall [988] + 0.00 0.00 4/608 sp_goodwinds [974] + 0.00 0.00 6/608 sp_mallornhain [968] + 0.00 0.00 6/608 sp_summonundead [896] + 0.00 0.00 8/608 do_fumble [1062] + 0.00 0.00 9/608 sp_stormwinds [871] + 0.00 0.00 10/608 sp_hain [931] + 0.00 0.00 13/608 sp_blessedharvest [847] + 0.00 0.00 121/608 lua_callspell [1645] + 0.00 0.00 196/608 verify_targets [1027] + 0.00 0.00 220/608 magic [157] +[1594] 0.0 0.00 0.00 608 co_get_region [1594] +----------------------------------------------- + 0.00 0.00 574/574 do_battle [64] +[1595] 0.0 0.00 0.00 574 battle_update [1595] +----------------------------------------------- + 0.00 0.00 27/560 dragon_name [1095] + 0.00 0.00 533/560 treeman_neighbour [1201] +[1596] 0.0 0.00 0.00 560 oldterrain [1596] +----------------------------------------------- + 0.00 0.00 554/554 a_free [558] +[1597] 0.0 0.00 0.00 554 a_finalizeeffect [1597] +----------------------------------------------- + 0.00 0.00 552/552 battle_free [1629] +[1598] 0.0 0.00 0.00 552 free_side [1598] +----------------------------------------------- + 0.00 0.00 6/501 parse_resources [1086] + 0.00 0.00 14/501 parse_ships [1305] + 0.00 0.00 23/501 xml_readweapon [1266] + 0.00 0.00 24/501 xml_readarmor [1736] + 0.00 0.00 27/501 parse_buildings [1131] + 0.00 0.00 67/501 parse_ai [1662] + 0.00 0.00 340/501 parse_races [1104] +[1599] 0.0 0.00 0.00 501 xml_fvalue [1599] +----------------------------------------------- + 0.00 0.00 1/465 xml_readconstruction [1183] + 0.00 0.00 6/465 parse_resources [1086] + 0.00 0.00 6/465 add_callbacks [1666] + 0.00 0.00 178/465 parse_function [1637] + 0.00 0.00 274/465 parse_spells [1120] +[1600] 0.0 0.00 0.00 465 get_function [1600] +----------------------------------------------- + 0.00 0.00 464/464 prepare_report [8] +[1601] 0.0 0.00 0.00 464 lastregion [1601] +----------------------------------------------- + 0.00 0.00 47/451 msg_set_region [1685] + 0.00 0.00 80/451 msg_set_resource [1226] + 0.00 0.00 121/451 msg_set_unit [1646] + 0.00 0.00 203/451 msg_set_int [1633] +[1602] 0.0 0.00 0.00 451 mtype_get_param [1602] +----------------------------------------------- + 0.00 0.00 2/433 set_factionstealth [183] + 0.00 0.00 431/433 create_unit [296] +[1603] 0.0 0.00 0.00 433 make_otherfaction [1603] + 0.00 0.00 433/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 40/428 regions_in_range [675] + 0.00 0.00 388/428 internal_path_find [345] +[1604] 0.0 0.00 0.00 428 free_nodes [1604] + 0.00 0.00 152803/152803 free_node [1426] +----------------------------------------------- + 0.00 0.00 406/406 battle_effects [1125] +[1605] 0.0 0.00 0.00 406 PopulationDamage [1605] +----------------------------------------------- + 0.00 0.00 6/380 get_spellbook [1544] + 0.00 0.00 7/380 equipment_addspell [1702] + 0.00 0.00 367/380 read_spellbook [1555] +[1606] 0.0 0.00 0.00 380 create_spellbook [1606] +----------------------------------------------- + 0.00 0.00 343/343 research_cmd [886] +[1607] 0.0 0.00 0.00 343 rough_amount [1607] +----------------------------------------------- + 0.00 0.00 314/314 make_fighter [424] +[1608] 0.0 0.00 0.00 314 CavalrySkill [1608] +----------------------------------------------- + 0.00 0.00 74/303 cast_combatspell [623] + 0.00 0.00 229/303 free_castorders [1541] +[1609] 0.0 0.00 0.00 303 free_castorder [1609] + 0.00 0.00 220/1936876 free_order [1356] + 0.00 0.00 26/26 free_spellparameter [1700] +----------------------------------------------- + 0.00 0.00 286/286 checkpasswd [1268] +[1610] 0.0 0.00 0.00 286 password_verify [1610] +----------------------------------------------- + 272147 freetokens [1611] + 0.00 0.00 12/267 free_locales [1311] + 0.00 0.00 255/267 unit_getspell [758] +[1611] 0.0 0.00 0.00 267+272147 freetokens [1611] + 272147 freetokens [1611] +----------------------------------------------- + 0.00 0.00 250/250 tpregion [1085] +[1612] 0.0 0.00 0.00 250 real2tp [1612] +----------------------------------------------- + 0.00 0.00 248/248 skillmod [214] +[1613] 0.0 0.00 0.00 248 sm_smithy [1613] +----------------------------------------------- + 0.00 0.00 1/240 kernel_init [1814] + 0.00 0.00 1/240 register_race_description_function [1848] + 0.00 0.00 2/240 register_weapons [1857] + 0.00 0.00 2/240 register_arena [1832] + 0.00 0.00 2/240 register_item_useonother [1778] + 0.00 0.00 3/240 register_item_give [1767] + 0.00 0.00 5/240 register_spells [1251] + 0.00 0.00 5/240 register_buildings [1837] + 0.00 0.00 7/240 register_race_name_function [1740] + 0.00 0.00 9/240 register_resources [1852] + 0.00 0.00 12/240 register_tolua_helpers [1854] + 0.00 0.00 13/240 register_races [1849] + 0.00 0.00 27/240 register_item_use [1699] + 0.00 0.00 151/240 register_spelldata [1250] +[1614] 0.0 0.00 0.00 240 register_function [1614] +----------------------------------------------- + 0.00 0.00 234/234 set_leftship [1134] +[1615] 0.0 0.00 0.00 234 make_leftship [1615] + 0.00 0.00 234/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 233/233 read_password [1619] +[1616] 0.0 0.00 0.00 233 faction_setpassword [1616] +----------------------------------------------- + 0.00 0.00 233/233 read_game [62] +[1617] 0.0 0.00 0.00 233 fhash [1617] +----------------------------------------------- + 0.00 0.00 233/233 read_password [1619] +[1618] 0.0 0.00 0.00 233 password_encode [1618] +----------------------------------------------- + 0.00 0.00 233/233 readfaction [767] +[1619] 0.0 0.00 0.00 233 read_password [1619] + 0.00 0.00 233/233 password_encode [1618] + 0.00 0.00 233/233 faction_setpassword [1616] +----------------------------------------------- + 0.00 0.00 233/233 readfaction [767] +[1620] 0.0 0.00 0.00 233 set_email [1620] + 0.00 0.00 232/232 spc_email_isvalid [1621] +----------------------------------------------- + 0.00 0.00 232/232 set_email [1620] +[1621] 0.0 0.00 0.00 232 spc_email_isvalid [1621] +----------------------------------------------- + 0.00 0.00 232/232 get_addresses [20] +[1622] 0.0 0.00 0.00 232 transfer_seen [1622] +----------------------------------------------- + 0.00 0.00 232/232 writefaction [762] +[1623] 0.0 0.00 0.00 232 write_password [1623] +----------------------------------------------- + 0.00 0.00 1/231 writegame [82] + 0.00 0.00 230/231 report_computer [9] +[1624] 0.0 0.00 0.00 231 eressea_version [1624] +----------------------------------------------- + 0.00 0.00 230/230 report_computer [9] +[1625] 0.0 0.00 0.00 230 reset_translations [1625] +----------------------------------------------- + 0.00 0.00 9/229 do_combatmagic [825] + 0.00 0.00 220/229 magic [157] +[1626] 0.0 0.00 0.00 229 add_castorder [1626] +----------------------------------------------- + 0.00 0.00 214/214 copy_arg [521] +[1627] 0.0 0.00 0.00 214 var_copy_items [1627] +----------------------------------------------- + 0.00 0.00 209/209 free_arg [1371] +[1628] 0.0 0.00 0.00 209 var_free_resources [1628] +----------------------------------------------- + 0.00 0.00 206/206 free_battle [1630] +[1629] 0.0 0.00 0.00 206 battle_free [1629] + 0.00 0.00 1297/1297 free_fighter [1580] + 0.00 0.00 552/552 free_side [1598] +----------------------------------------------- + 0.00 0.00 206/206 do_battle [64] +[1630] 0.0 0.00 0.00 206 free_battle [1630] + 0.00 0.00 206/206 battle_free [1629] +----------------------------------------------- + 0.00 0.00 206/206 aftermath [701] +[1631] 0.0 0.00 0.00 206 reorder_fleeing [1631] +----------------------------------------------- + 0.00 0.00 206/206 copy_arg [521] +[1632] 0.0 0.00 0.00 206 var_copy_resources [1632] +----------------------------------------------- + 0.00 0.00 203/203 tolua_msg_set_int [2937] +[1633] 0.0 0.00 0.00 203 msg_set_int [1633] + 0.00 0.00 203/451 mtype_get_param [1602] +----------------------------------------------- + 0.00 0.00 12/192 spy_cmd [990] + 0.00 0.00 65/192 steal_cmd [766] + 0.00 0.00 115/192 contact_cmd [965] +[1634] 0.0 0.00 0.00 192 can_contact [1634] + 0.00 0.00 132/677 slipthru [1593] +----------------------------------------------- + 0.00 0.00 186/186 a_age [418] +[1635] 0.0 0.00 0.00 186 leftship_age [1635] +----------------------------------------------- + 0.00 0.00 185/185 it_get_or_create [1115] +[1636] 0.0 0.00 0.00 185 it_register [1636] +----------------------------------------------- + 0.00 0.00 3/178 parse_buildings [1131] + 0.00 0.00 3/178 xml_readweapon [1266] + 0.00 0.00 19/178 parse_resources [1086] + 0.00 0.00 29/178 parse_spells [1120] + 0.00 0.00 55/178 xml_readitem [1107] + 0.00 0.00 69/178 parse_races [1104] +[1637] 0.0 0.00 0.00 178 parse_function [1637] + 0.00 0.00 178/465 get_function [1600] +----------------------------------------------- + 0.00 0.00 166/166 create_spell [1639] +[1638] 0.0 0.00 0.00 166 add_spell [1638] +----------------------------------------------- + 0.00 0.00 166/166 parse_spells [1120] +[1639] 0.0 0.00 0.00 166 create_spell [1639] + 0.00 0.00 166/166 add_spell [1638] +----------------------------------------------- + 0.00 0.00 162/162 rt_get_or_create [1139] +[1640] 0.0 0.00 0.00 162 rt_register [1640] +----------------------------------------------- + 0.00 0.00 1/160 move_iceberg [1094] + 0.00 0.00 7/160 attack [84] + 0.00 0.00 12/160 aftermath [701] + 0.00 0.00 15/160 drifting_ships [490] + 0.00 0.00 29/160 sail [181] + 0.00 0.00 96/160 sinkships [475] +[1641] 0.0 0.00 0.00 160 damage_ship [1641] +----------------------------------------------- + 0.00 0.00 136/136 a_read_i [390] +[1642] 0.0 0.00 0.00 136 a_readstring [1642] +----------------------------------------------- + 0.00 0.00 133/133 caught_target [1003] +[1643] 0.0 0.00 0.00 133 present [1643] +----------------------------------------------- + 0.00 0.00 121/121 lua_callspell [1645] +[1644] 0.0 0.00 0.00 121 co_get_caster [1644] +----------------------------------------------- + 0.00 0.00 2/121 do_fumble [1062] + 0.00 0.00 119/121 magic [157] +[1645] 0.0 0.00 0.00 121 lua_callspell [1645] + 0.00 0.00 121/121 co_get_caster [1644] + 0.00 0.00 121/608 co_get_region [1594] +----------------------------------------------- + 0.00 0.00 121/121 tolua_msg_set_unit [2941] +[1646] 0.0 0.00 0.00 121 msg_set_unit [1646] + 0.00 0.00 121/451 mtype_get_param [1602] +----------------------------------------------- + 0.00 0.00 118/118 init_translations [1033] +[1647] 0.0 0.00 0.00 118 keyword_key [1647] + 0.00 0.00 118/2009097 keyword [1355] +----------------------------------------------- + 0.00 0.00 106/106 a_read_i [390] +[1648] 0.0 0.00 0.00 106 a_readkey [1648] + 0.00 0.00 106/58518 a_readint [1448] +----------------------------------------------- + 0.00 0.00 106/106 add_skills [1667] +[1649] 0.0 0.00 0.00 106 equipment_setskill [1649] +----------------------------------------------- + 0.00 0.00 99/99 magic [157] +[1650] 0.0 0.00 0.00 99 spl_costtyp [1650] +----------------------------------------------- + 0.00 0.00 9/97 kill_troop [532] + 0.00 0.00 88/97 gift_items [891] +[1651] 0.0 0.00 0.00 97 i_merge [1651] + 0.00 0.00 86/374425 i_free [1400] + 0.00 0.00 86/257723 i_remove [1407] +----------------------------------------------- + 0.00 0.00 97/97 piracy_cmd [660] +[1652] 0.0 0.00 0.00 97 mk_piracy [1652] + 0.00 0.00 97/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 97/97 a_free [558] +[1653] 0.0 0.00 0.00 97 piracy_done [1653] +----------------------------------------------- + 0.00 0.00 97/97 a_new [1376] +[1654] 0.0 0.00 0.00 97 piracy_init [1654] +----------------------------------------------- + 0.00 0.00 88/88 init_translations [1033] +[1655] 0.0 0.00 0.00 88 parameter_key [1655] +----------------------------------------------- + 0.00 0.00 21/74 sp_kampfzauber [957] + 0.00 0.00 53/74 sp_dragonodem [627] +[1656] 0.0 0.00 0.00 74 get_force [1656] +----------------------------------------------- + 0.00 0.00 21/74 sp_kampfzauber [957] + 0.00 0.00 53/74 sp_dragonodem [627] +[1657] 0.0 0.00 0.00 74 spell_damage [1657] +----------------------------------------------- + 0.00 0.00 12/73 add_subsets [1669] + 0.00 0.00 61/73 parse_equipment [1170] +[1658] 0.0 0.00 0.00 73 create_equipment [1658] +----------------------------------------------- + 0.00 0.00 72/72 xml_readitem [1107] +[1659] 0.0 0.00 0.00 72 default_score [1659] +----------------------------------------------- + 0.00 0.00 68/68 a_read_i [390] +[1660] 0.0 0.00 0.00 68 a_readchars [1660] +----------------------------------------------- + 0.00 0.00 68/68 rc_get_or_create [1105] +[1661] 0.0 0.00 0.00 68 rc_create [1661] +----------------------------------------------- + 0.00 0.00 67/67 parse_races [1104] +[1662] 0.0 0.00 0.00 67 parse_ai [1662] + 0.00 0.00 268/6576 xml_bvalue [1532] + 0.00 0.00 134/5453 xml_ivalue [1533] + 0.00 0.00 67/501 xml_fvalue [1599] +----------------------------------------------- + 0.00 0.00 66/66 a_write [299] +[1663] 0.0 0.00 0.00 66 a_writechars [1663] +----------------------------------------------- + 0.00 0.00 65/65 add_items [1169] +[1664] 0.0 0.00 0.00 65 equipment_setitem [1664] +----------------------------------------------- + 0.00 0.00 2/65 default_order [902] + 0.00 0.00 2/65 disable_feature [771] + 0.00 0.00 61/65 json_keyword [1127] +[1665] 0.0 0.00 0.00 65 findkeyword [1665] +----------------------------------------------- + 0.00 0.00 61/61 parse_equipment [1170] +[1666] 0.0 0.00 0.00 61 add_callbacks [1666] + 0.00 0.00 6/465 get_function [1600] + 0.00 0.00 6/6 equipment_setcallback [1747] +----------------------------------------------- + 0.00 0.00 61/61 parse_equipment [1170] +[1667] 0.0 0.00 0.00 61 add_skills [1667] + 0.00 0.00 106/1041 findskill [1586] + 0.00 0.00 106/106 equipment_setskill [1649] +----------------------------------------------- + 0.00 0.00 61/61 parse_equipment [1170] +[1668] 0.0 0.00 0.00 61 add_spells [1668] + 0.00 0.00 24/11052 find_spell [1513] + 0.00 0.00 24/5453 xml_ivalue [1533] + 0.00 0.00 24/24 equipment_addspell [1702] +----------------------------------------------- + 0.00 0.00 61/61 parse_equipment [1170] +[1669] 0.0 0.00 0.00 61 add_subsets [1669] + 0.00 0.00 12/73 create_equipment [1658] +----------------------------------------------- + 0.00 0.00 58/58 tolua_dict_get [1218] +[1670] 0.0 0.00 0.00 58 dict_get [1670] +----------------------------------------------- + 0.00 0.00 58/58 tolua_dict_get [1218] +[1671] 0.0 0.00 0.00 58 dict_name [1671] +----------------------------------------------- + 0.00 0.00 58/58 add_resource [1162] +[1672] 0.0 0.00 0.00 58 rmt_get [1672] +----------------------------------------------- + 0.00 0.00 57/57 terraform_region [932] +[1673] 0.0 0.00 0.00 57 free_land [1673] +----------------------------------------------- + 0.00 0.00 3/56 add_proc_postregion [1761] + 0.00 0.00 3/56 add_proc_unit [1762] + 0.00 0.00 8/56 add_proc_region [1733] + 0.00 0.00 13/56 add_proc_global [1716] + 0.00 0.00 29/56 add_proc_order [1692] +[1674] 0.0 0.00 0.00 56 add_proc [1674] +----------------------------------------------- + 0.00 0.00 56/56 a_new [1376] +[1675] 0.0 0.00 0.00 56 dict_init [1675] +----------------------------------------------- + 0.00 0.00 56/56 a_read_i [390] +[1676] 0.0 0.00 0.00 56 dict_read [1676] +----------------------------------------------- + 0.00 0.00 56/56 a_write [299] +[1677] 0.0 0.00 0.00 56 dict_write [1677] +----------------------------------------------- + 0.00 0.00 1/55 chaos_register [1797] + 0.00 0.00 1/55 wormholes_register [1895] + 0.00 0.00 1/55 register_borders [1835] + 0.00 0.00 1/55 register_arena [1832] + 0.00 0.00 1/55 register_artrewards [1833] + 0.00 0.00 2/55 register_tolua_helpers [1854] + 0.00 0.00 2/55 register_spells [1251] + 0.00 0.00 4/55 register_museum [1845] + 0.00 0.00 42/55 register_attributes [1834] +[1678] 0.0 0.00 0.00 55 at_register [1678] + 0.00 0.00 55/251874 __at_hashkey [3279] +----------------------------------------------- + 0.00 0.00 54/54 parse_resources [1086] +[1679] 0.0 0.00 0.00 54 it_set_appearance [1679] +----------------------------------------------- + 0.00 0.00 18/52 json_terrains [1190] + 0.00 0.00 34/52 parse_ships [1305] +[1680] 0.0 0.00 0.00 52 get_or_create_terrain [1680] + 0.00 0.00 52/178322 terrain_find_i [1421] +----------------------------------------------- + 0.00 0.00 51/51 report_summary [614] +[1681] 0.0 0.00 0.00 51 rcomp [1681] +----------------------------------------------- + 0.00 0.00 48/48 terraform_region [932] +[1682] 0.0 0.00 0.00 48 get_maxluxuries [1682] +----------------------------------------------- + 0.00 0.00 48/48 terraform_region [932] +[1683] 0.0 0.00 0.00 48 region_setname [1683] +----------------------------------------------- + 0.00 0.00 1/48 tolua_unit_add_order [1276] + 0.00 0.00 47/48 give_peasants [1060] +[1684] 0.0 0.00 0.00 48 unit_addorder [1684] +----------------------------------------------- + 0.00 0.00 47/47 tolua_msg_set_region [2939] +[1685] 0.0 0.00 0.00 47 msg_set_region [1685] + 0.00 0.00 47/451 mtype_get_param [1602] +----------------------------------------------- + 0.00 0.00 1/44 register_magicresistance [1844] + 0.00 0.00 1/44 register_flyingship [1840] + 0.00 0.00 2/44 register_spells [1251] + 0.00 0.00 3/44 register_shipcurse [1853] + 0.00 0.00 4/44 register_buildingcurse [1836] + 0.00 0.00 14/44 register_unitcurse [1856] + 0.00 0.00 19/44 register_regioncurse [1850] +[1686] 0.0 0.00 0.00 44 ct_register [1686] +----------------------------------------------- + 0.00 0.00 42/42 report_summary [614] +[1687] 0.0 0.00 0.00 42 pcomp [1687] +----------------------------------------------- + 0.00 0.00 33/33 set_param [1689] +[1688] 0.0 0.00 0.00 33 pack_keyval [1688] +----------------------------------------------- + 0.00 0.00 3/33 parse_param [1765] + 0.00 0.00 30/33 config_set [444] +[1689] 0.0 0.00 0.00 33 set_param [1689] + 0.00 0.00 33/33 pack_keyval [1688] +----------------------------------------------- + 0.00 0.00 7/32 translation_init [1890] + 0.00 0.00 25/32 register_reports [1851] +[1690] 0.0 0.00 0.00 32 add_function [1690] +----------------------------------------------- + 0.00 0.00 7/30 attrib_allocation [914] + 0.00 0.00 23/30 allocate_resource [752] +[1691] 0.0 0.00 0.00 30 limit_seeds [1691] +----------------------------------------------- + 0.00 0.00 29/29 init_processor [1310] +[1692] 0.0 0.00 0.00 29 add_proc_order [1692] + 0.00 0.00 29/11194781 keyword_disabled [1348] + 0.00 0.00 29/56 add_proc [1674] +----------------------------------------------- + 0.00 0.00 29/29 json_prefixes [1812] +[1693] 0.0 0.00 0.00 29 add_raceprefix [1693] +----------------------------------------------- + 0.00 0.00 29/29 json_terrain [1189] +[1694] 0.0 0.00 0.00 29 json_terrain_production [1694] +----------------------------------------------- + 0.00 0.00 28/28 destroy_curse [1697] +[1695] 0.0 0.00 0.00 28 cunhash [1695] +----------------------------------------------- + 0.00 0.00 28/28 a_free [558] +[1696] 0.0 0.00 0.00 28 curse_done [1696] + 0.00 0.00 28/28 destroy_curse [1697] +----------------------------------------------- + 0.00 0.00 28/28 curse_done [1696] +[1697] 0.0 0.00 0.00 28 destroy_curse [1697] + 0.00 0.00 28/28 cunhash [1695] +----------------------------------------------- + 0.00 0.00 27/27 bt_get_or_create [1114] +[1698] 0.0 0.00 0.00 27 bt_register [1698] +----------------------------------------------- + 0.00 0.00 1/27 register_tolua_helpers [1854] + 0.00 0.00 1/27 register_demonseye [1839] + 0.00 0.00 1/27 register_arena [1832] + 0.00 0.00 2/27 register_xerewards [1858] + 0.00 0.00 2/27 register_artrewards [1833] + 0.00 0.00 3/27 register_museum [1845] + 0.00 0.00 7/27 register_itemfunctions [1842] + 0.00 0.00 10/27 register_resources [1852] +[1699] 0.0 0.00 0.00 27 register_item_use [1699] + 0.00 0.00 27/240 register_function [1614] +----------------------------------------------- + 0.00 0.00 26/26 free_castorder [1609] +[1700] 0.0 0.00 0.00 26 free_spellparameter [1700] +----------------------------------------------- + 0.00 0.00 25/25 set_new_dragon_target [486] +[1701] 0.0 0.00 0.00 25 make_targetregion [1701] + 0.00 0.00 25/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 24/24 add_spells [1668] +[1702] 0.0 0.00 0.00 24 equipment_addspell [1702] + 0.00 0.00 24/1524 spellbook_add [1572] + 0.00 0.00 7/380 create_spellbook [1606] +----------------------------------------------- + 0.00 0.00 23/23 xml_readweapon [1266] +[1703] 0.0 0.00 0.00 23 new_weapontype [1703] + 0.00 0.00 23/2379316 resource2weapon [1353] +----------------------------------------------- + 0.00 0.00 22/22 verify_targets [1027] +[1704] 0.0 0.00 0.00 22 verify_ship [1704] + 0.00 0.00 22/28818 findship [1483] +----------------------------------------------- + 0.00 0.00 19/19 register_cr [1838] +[1705] 0.0 0.00 0.00 19 tsf_register [1705] +----------------------------------------------- + 0.00 0.00 18/18 handle_event [1363] +[1706] 0.0 0.00 0.00 18 handle_triggers [1706] + 0.00 0.00 18/18 timeout_handle [1709] + 0.00 0.00 1/1 caldera_handle [1794] +----------------------------------------------- + 0.00 0.00 18/18 json_terrain [1189] +[1707] 0.0 0.00 0.00 18 json_flags [1707] +----------------------------------------------- + 0.00 0.00 18/18 register_reports [1851] +[1708] 0.0 0.00 0.00 18 register_argtype [1708] +----------------------------------------------- + 0.00 0.00 18/18 handle_triggers [1706] +[1709] 0.0 0.00 0.00 18 timeout_handle [1709] +----------------------------------------------- + 0.00 0.00 18/18 t_new [1546] +[1710] 0.0 0.00 0.00 18 timeout_init [1710] +----------------------------------------------- + 18 write_triggers [954] +[1711] 0.0 0.00 0.00 18 timeout_write [1711] + 18 write_triggers [954] +----------------------------------------------- + 0.00 0.00 15/15 xml_readpotion [1714] +[1712] 0.0 0.00 0.00 15 new_potiontype [1712] + 0.00 0.00 15/1582 resource2potion [1569] + 0.00 0.00 15/15 pt_register [1713] +----------------------------------------------- + 0.00 0.00 15/15 new_potiontype [1712] +[1713] 0.0 0.00 0.00 15 pt_register [1713] +----------------------------------------------- + 0.00 0.00 15/15 xml_readitem [1107] +[1714] 0.0 0.00 0.00 15 xml_readpotion [1714] + 0.00 0.00 15/5453 xml_ivalue [1533] + 0.00 0.00 15/15 new_potiontype [1712] +----------------------------------------------- + 0.00 0.00 1/14 register_arena [1832] + 0.00 0.00 1/14 register_xmas [1859] + 0.00 0.00 12/14 register_triggers [1855] +[1715] 0.0 0.00 0.00 14 tt_register [1715] +----------------------------------------------- + 0.00 0.00 13/13 init_processor [1310] +[1716] 0.0 0.00 0.00 13 add_proc_global [1716] + 0.00 0.00 13/56 add_proc [1674] +----------------------------------------------- + 0.00 0.00 13/13 read_planes [1164] +[1717] 0.0 0.00 0.00 13 getplanebyid [1717] +----------------------------------------------- + 0.00 0.00 13/13 move_iceberg [1094] +[1718] 0.0 0.00 0.00 13 make_iceberg [1718] + 0.00 0.00 13/779868 a_new [1376] +----------------------------------------------- + 13 read_triggers [798] +[1719] 0.0 0.00 0.00 13 timeout_read [1719] + 13 read_triggers [798] +----------------------------------------------- + 0.00 0.00 2/12 remove_building [1153] + 0.00 0.00 10/12 renumber_cmd [780] +[1720] 0.0 0.00 0.00 12 bunhash [1720] +----------------------------------------------- + 0.00 0.00 12/12 t_new [1546] +[1721] 0.0 0.00 0.00 12 changefaction_init [1721] +----------------------------------------------- + 0.00 0.00 12/12 volcano_destruction [1022] +[1722] 0.0 0.00 0.00 12 make_reduceproduction [1722] + 0.00 0.00 12/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 12/12 changerace_write [1287] +[1723] 0.0 0.00 0.00 12 write_race_reference [1723] +----------------------------------------------- + 0.00 0.00 11/11 koor_distance [476] +[1724] 0.0 0.00 0.00 11 koor_distance_wrap_xy [1724] +----------------------------------------------- + 0.00 0.00 11/11 attrib_allocation [914] +[1725] 0.0 0.00 0.00 11 produce_seeds [1725] +----------------------------------------------- + 0.00 0.00 11/11 register_xmlreader [1860] +[1726] 0.0 0.00 0.00 11 xml_register_callback [1726] +----------------------------------------------- + 0.00 0.00 11/11 parse_races [1104] +[1727] 0.0 0.00 0.00 11 xml_spell [1727] + 0.00 0.00 9/11052 find_spell [1513] +----------------------------------------------- + 0.00 0.00 10/10 cast_cmd [760] +[1728] 0.0 0.00 0.00 10 rel_to_abs [1728] + 0.00 0.00 5/5 ursprung_x [1754] + 0.00 0.00 5/221723 plane_center_x [1411] + 0.00 0.00 5/5 ursprung_y [1755] + 0.00 0.00 5/221723 plane_center_y [1412] +----------------------------------------------- + 0.00 0.00 10/10 nrt_register [883] +[1729] 0.0 0.00 0.00 10 section_add [1729] +----------------------------------------------- + 0.00 0.00 1/9 load_inifile [1293] + 0.00 0.00 1/9 parse_inifile [1317] + 0.00 0.00 1/9 writepasswd [1074] + 0.00 0.00 2/9 writeturn [1253] + 0.00 0.00 2/9 report_summary [614] + 0.00 0.00 2/9 score [23] +[1730] 0.0 0.00 0.00 9 basepath [1730] +----------------------------------------------- + 0.00 0.00 9/9 a_new [1376] +[1731] 0.0 0.00 0.00 9 init_resourcelimit [1731] +----------------------------------------------- + 0.00 0.00 1/9 register_museum [1845] + 0.00 0.00 3/9 register_borders [1835] + 0.00 0.00 5/9 register_attributes [1834] +[1732] 0.0 0.00 0.00 9 register_bordertype [1732] +----------------------------------------------- + 0.00 0.00 8/8 init_processor [1310] +[1733] 0.0 0.00 0.00 8 add_proc_region [1733] + 0.00 0.00 8/56 add_proc [1674] +----------------------------------------------- + 0.00 0.00 8/8 xml_readarmor [1736] +[1734] 0.0 0.00 0.00 8 new_armortype [1734] +----------------------------------------------- + 0.00 0.00 8/8 tolua_unit_get_hp [3117] +[1735] 0.0 0.00 0.00 8 unit_gethp [1735] +----------------------------------------------- + 0.00 0.00 8/8 xml_readitem [1107] +[1736] 0.0 0.00 0.00 8 xml_readarmor [1736] + 0.00 0.00 24/501 xml_fvalue [1599] + 0.00 0.00 16/6576 xml_bvalue [1532] + 0.00 0.00 8/5453 xml_ivalue [1533] + 0.00 0.00 8/8 new_armortype [1734] +----------------------------------------------- + 0.00 0.00 7/7 has_ao_healing [1269] +[1737] 0.0 0.00 0.00 7 i_findc [1737] +----------------------------------------------- + 0.00 0.00 7/7 new_luxurytype [1739] +[1738] 0.0 0.00 0.00 7 lt_register [1738] +----------------------------------------------- + 0.00 0.00 7/7 xml_readluxury [1745] +[1739] 0.0 0.00 0.00 7 new_luxurytype [1739] + 0.00 0.00 7/21500 resource2luxury [1499] + 0.00 0.00 7/7 lt_register [1738] +----------------------------------------------- + 0.00 0.00 7/7 register_names [1846] +[1740] 0.0 0.00 0.00 7 register_race_name_function [1740] + 0.00 0.00 7/240 register_function [1614] +----------------------------------------------- + 0.00 0.00 7/7 parse_resources [1086] +[1741] 0.0 0.00 0.00 7 rmt_create [1741] +----------------------------------------------- + 0.00 0.00 7/7 equipment_done [1802] +[1742] 0.0 0.00 0.00 7 spellbook_clear [1742] +----------------------------------------------- + 0.00 0.00 7/7 parse_ships [1305] +[1743] 0.0 0.00 0.00 7 st_get_or_create [1743] + 0.00 0.00 7/19089 st_find_i [1501] +----------------------------------------------- + 0.00 0.00 1/7 renumber_cmd [780] + 0.00 0.00 6/7 remove_ship [1748] +[1744] 0.0 0.00 0.00 7 sunhash [1744] +----------------------------------------------- + 0.00 0.00 7/7 xml_readitem [1107] +[1745] 0.0 0.00 0.00 7 xml_readluxury [1745] + 0.00 0.00 7/5453 xml_ivalue [1533] + 0.00 0.00 7/7 new_luxurytype [1739] +----------------------------------------------- + 0.00 0.00 6/6 t_new [1546] +[1746] 0.0 0.00 0.00 6 changerace_init [1746] +----------------------------------------------- + 0.00 0.00 6/6 add_callbacks [1666] +[1747] 0.0 0.00 0.00 6 equipment_setcallback [1747] +----------------------------------------------- + 0.00 0.00 1/6 drifting_ships [490] + 0.00 0.00 5/6 sinkships [475] +[1748] 0.0 0.00 0.00 6 remove_ship [1748] + 0.00 0.00 6/1342832 handle_event [1363] + 0.00 0.00 6/7 sunhash [1744] +----------------------------------------------- + 0.00 0.00 2/5 register_gmcmd [1841] + 0.00 0.00 3/5 register_attributes [1834] +[1749] 0.0 0.00 0.00 5 at_deprecate [1749] + 0.00 0.00 5/251874 __at_hashkey [3279] +----------------------------------------------- + 0.00 0.00 5/5 process [7] +[1750] 0.0 0.00 0.00 5 free_group [1750] +----------------------------------------------- + 0.00 0.00 1/5 init_data [790] + 0.00 0.00 4/5 json_config [464] +[1751] 0.0 0.00 0.00 5 reset_locales [1751] +----------------------------------------------- + 0.00 0.00 1/5 create_newfamiliar [1288] + 0.00 0.00 4/5 sp_charmingsong [993] +[1752] 0.0 0.00 0.00 5 trigger_killunit [1752] + 0.00 0.00 5/3113 t_new [1546] +----------------------------------------------- + 0.00 0.00 1/5 use_bloodpotion [935] + 0.00 0.00 2/5 sp_charmingsong [993] + 0.00 0.00 2/5 do_fumble [1062] +[1753] 0.0 0.00 0.00 5 trigger_timeout [1753] + 0.00 0.00 5/3113 t_new [1546] +----------------------------------------------- + 0.00 0.00 5/5 rel_to_abs [1728] +[1754] 0.0 0.00 0.00 5 ursprung_x [1754] +----------------------------------------------- + 0.00 0.00 5/5 rel_to_abs [1728] +[1755] 0.0 0.00 0.00 5 ursprung_y [1755] +----------------------------------------------- + 0.00 0.00 4/4 parse_ids [852] +[1756] 0.0 0.00 0.00 4 intlist_add [1756] +----------------------------------------------- + 0.00 0.00 4/4 parse_ids [852] +[1757] 0.0 0.00 0.00 4 intlist_init [1757] +----------------------------------------------- + 0.00 0.00 4/4 config_get_locales [1161] +[1758] 0.0 0.00 0.00 4 nextlocale [1758] +----------------------------------------------- + 0.00 0.00 4/4 curse_read [770] +[1759] 0.0 0.00 0.00 4 read_skill [1759] +----------------------------------------------- + 0.00 0.00 2/4 chaosterrain [1213] + 0.00 0.00 2/4 init_terrains_translation [1129] +[1760] 0.0 0.00 0.00 4 terrains [1760] +----------------------------------------------- + 0.00 0.00 3/3 init_processor [1310] +[1761] 0.0 0.00 0.00 3 add_proc_postregion [1761] + 0.00 0.00 3/56 add_proc [1674] +----------------------------------------------- + 0.00 0.00 3/3 init_processor [1310] +[1762] 0.0 0.00 0.00 3 add_proc_unit [1762] + 0.00 0.00 3/56 add_proc [1674] +----------------------------------------------- + 0.00 0.00 3/3 give_control_cmd [287] +[1763] 0.0 0.00 0.00 3 give_control [1763] + 0.00 0.00 3/18963 ship_set_owner [1505] +----------------------------------------------- + 0.00 0.00 3/3 join_group [1083] +[1764] 0.0 0.00 0.00 3 init_group [1764] + 0.00 0.00 98/55547 ally_add [1452] +----------------------------------------------- + 0.00 0.00 3/3 parse_races [1104] +[1765] 0.0 0.00 0.00 3 parse_param [1765] + 0.00 0.00 3/33 set_param [1689] +----------------------------------------------- + 0.00 0.00 3/3 xml_readweapon [1266] +[1766] 0.0 0.00 0.00 3 racelist_insert [1766] +----------------------------------------------- + 0.00 0.00 1/3 register_tolua_helpers [1854] + 0.00 0.00 1/3 register_demonseye [1839] + 0.00 0.00 1/3 register_resources [1852] +[1767] 0.0 0.00 0.00 3 register_item_give [1767] + 0.00 0.00 3/240 register_function [1614] +----------------------------------------------- + 0.00 0.00 1/3 register_cr [1838] + 0.00 0.00 2/3 register_nr [1847] +[1768] 0.0 0.00 0.00 3 register_reporttype [1768] +----------------------------------------------- + 0.00 0.00 3/3 curse_write [930] +[1769] 0.0 0.00 0.00 3 write_skill [1769] +----------------------------------------------- + 0.00 0.00 2/2 move_blocked [283] +[1770] 0.0 0.00 0.00 2 b_blockquestportal [1770] +----------------------------------------------- + 0.00 0.00 2/2 see_border [1440] +[1771] 0.0 0.00 0.00 2 b_fvisible [1771] +----------------------------------------------- + 0.00 0.00 2/2 describe [35] +[1772] 0.0 0.00 0.00 2 b_opaque [1772] +----------------------------------------------- + 0.00 0.00 2/2 tolua_write_summary [38] +[1773] 0.0 0.00 0.00 2 free_summary [1773] +----------------------------------------------- + 0.00 0.00 2/2 t_new [1546] +[1774] 0.0 0.00 0.00 2 giveitem_init [1774] +----------------------------------------------- + 0.00 0.00 1/2 allocate_resource [752] + 0.00 0.00 1/2 attrib_allocation [914] +[1775] 0.0 0.00 0.00 2 limit_mallornseeds [1775] +----------------------------------------------- + 0.00 0.00 1/2 log_to_file [1819] + 0.00 0.00 1/2 log_open [1817] +[1776] 0.0 0.00 0.00 2 log_create [1776] +----------------------------------------------- + 0.00 0.00 1/2 init_smithy [1312] + 0.00 0.00 1/2 xml_readconstruction [1183] +[1777] 0.0 0.00 0.00 2 make_skillmod [1777] + 0.00 0.00 2/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 1/2 register_resources [1852] + 0.00 0.00 1/2 register_artrewards [1833] +[1778] 0.0 0.00 0.00 2 register_item_useonother [1778] + 0.00 0.00 2/240 register_function [1614] +----------------------------------------------- + 0.00 0.00 2/2 change_resource [240] +[1779] 0.0 0.00 0.00 2 res_changehp [1779] +----------------------------------------------- + 0.00 0.00 1/2 tolua_bind_open [1866] + 0.00 0.00 1/2 lua_init [1316] +[1780] 0.0 0.00 0.00 2 tolua_eressea_open [1780] +----------------------------------------------- + 0.00 0.00 2/2 luaopen_eressea [2406] +[1781] 0.0 0.00 0.00 2 tolua_reg_types_eressea [1781] +----------------------------------------------- + 0.00 0.00 2/2 lua_init [1316] +[1782] 0.0 0.00 0.00 2 tolua_unit_open [1782] +----------------------------------------------- + 0.00 0.00 2/2 sp_charmingsong [993] +[1783] 0.0 0.00 0.00 2 trigger_changefaction [1783] + 0.00 0.00 2/3113 t_new [1546] +----------------------------------------------- + 0.00 0.00 2/2 parse_args [1825] +[1784] 0.0 0.00 0.00 2 verbosity_to_flags [1784] +----------------------------------------------- + 0.00 0.00 2/2 a_write [299] +[1785] 0.0 0.00 0.00 2 wormhole_write [1785] + 0.00 0.00 2/1119 write_region_reference [1583] +----------------------------------------------- + 0.00 0.00 1/1 a_free [558] +[1786] 0.0 0.00 0.00 1 a_finalizestring [1786] +----------------------------------------------- + 0.00 0.00 1/1 a_write [299] +[1787] 0.0 0.00 0.00 1 a_writekeys [1787] +----------------------------------------------- + 0.00 0.00 1/1 spy_message [1038] +[1788] 0.0 0.00 0.00 1 add_seen_faction [1788] + 0.00 0.00 1/353788 add_seen_faction_i [1401] +----------------------------------------------- + 0.00 0.00 1/1 ageing [185] +[1789] 0.0 0.00 0.00 1 age_borders [1789] +----------------------------------------------- + 0.00 0.00 1/1 kernel_done [1813] +[1790] 0.0 0.00 0.00 1 attrib_done [1790] +----------------------------------------------- + 0.00 0.00 1/1 read_borders [706] +[1791] 0.0 0.00 0.00 1 b_read [1791] +----------------------------------------------- + 0.00 0.00 1/1 write_borders [1897] +[1792] 0.0 0.00 0.00 1 b_write [1792] +----------------------------------------------- + 0.00 0.00 1/1 main [541] +[1793] 0.0 0.00 0.00 1 bind_monsters [1793] +----------------------------------------------- + 0.00 0.00 1/1 handle_triggers [1706] +[1794] 0.0 0.00 0.00 1 caldera_handle [1794] +----------------------------------------------- + 0.00 0.00 1/1 write_triggers [954] +[1795] 0.0 0.00 0.00 1 caldera_write [1795] + 0.00 0.00 1/642406 write_building_reference [1383] +----------------------------------------------- + 0.00 0.00 1/1 game_done [542] +[1796] 0.0 0.00 0.00 1 calendar_cleanup [1796] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1797] 0.0 0.00 0.00 1 chaos_register [1797] + 0.00 0.00 1/55 at_register [1678] +----------------------------------------------- + 0.00 0.00 1/1 kernel_done [1813] +[1798] 0.0 0.00 0.00 1 crmessage_done [1798] +----------------------------------------------- + 0.00 0.00 1/1 kernel_done [1813] +[1799] 0.0 0.00 0.00 1 curses_done [1799] +----------------------------------------------- + 0.00 0.00 1/1 attack [84] +[1800] 0.0 0.00 0.00 1 dazzle [1800] +----------------------------------------------- + 0.00 0.00 1/1 disable_feature [771] +[1801] 0.0 0.00 0.00 1 enable_keyword [1801] +----------------------------------------------- + 0.00 0.00 1/1 kernel_done [1813] +[1802] 0.0 0.00 0.00 1 equipment_done [1802] + 0.00 0.00 7/7 spellbook_clear [1742] +----------------------------------------------- + 0.00 0.00 1/1 curse_age [1538] +[1803] 0.0 0.00 0.00 1 flyingship_age [1803] +----------------------------------------------- + 0.00 0.00 1/1 game_done [542] +[1804] 0.0 0.00 0.00 1 free_functions [1804] +----------------------------------------------- + 0.00 0.00 1/1 translation_done [1889] +[1805] 0.0 0.00 0.00 1 free_functions [1805] +----------------------------------------------- + 0.00 0.00 1/1 destroyfaction [392] +[1806] 0.0 0.00 0.00 1 funhash [1806] +----------------------------------------------- + 0.00 0.00 1/1 parse_args [1825] +[1807] 0.0 0.00 0.00 1 get_arg [1807] +----------------------------------------------- + 0.00 0.00 1/1 wormhole_age [1130] +[1808] 0.0 0.00 0.00 1 has_limited_skills [1808] +----------------------------------------------- + 0.00 0.00 1/1 read_game [62] +[1809] 0.0 0.00 0.00 1 init_genrand [1809] +----------------------------------------------- + 0.00 0.00 1/1 json_config [464] +[1810] 0.0 0.00 0.00 1 init_terrains [1810] + 0.00 0.00 14/178270 get_terrain [1423] +----------------------------------------------- + 0.00 0.00 1/1 kernel_done [1813] +[1811] 0.0 0.00 0.00 1 item_done [1811] + 0.00 0.00 1/10475 i_freeall [1515] +----------------------------------------------- + 0.00 0.00 1/1 json_config [464] +[1812] 0.0 0.00 0.00 1 json_prefixes [1812] + 0.00 0.00 29/29 add_raceprefix [1693] +----------------------------------------------- + 0.00 0.00 1/1 game_done [542] +[1813] 0.0 0.00 0.00 1 kernel_done [1813] + 0.00 0.00 1/1 xml_done [1898] + 0.00 0.00 1/1 equipment_done [1802] + 0.00 0.00 1/1 message_done [1822] + 0.00 0.00 1/1 item_done [1811] + 0.00 0.00 1/1 attrib_done [1790] + 0.00 0.00 1/1 crmessage_done [1798] + 0.00 0.00 1/1 curses_done [1799] + 0.00 0.00 1/1 reports_done [1861] + 0.00 0.00 1/1 translation_done [1889] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1814] 0.0 0.00 0.00 1 kernel_init [1814] + 0.00 0.00 1/1 translation_init [1890] + 0.00 0.00 1/1 mt_clear [1823] + 0.00 0.00 1/240 register_function [1614] +----------------------------------------------- + 0.00 0.00 1/1 main [541] +[1815] 0.0 0.00 0.00 1 locale_init [1815] +----------------------------------------------- + 0.00 0.00 1/1 main [541] +[1816] 0.0 0.00 0.00 1 log_close [1816] +----------------------------------------------- + 0.00 0.00 1/1 parse_args [1825] +[1817] 0.0 0.00 0.00 1 log_open [1817] + 0.00 0.00 1/1 log_rotate [1818] + 0.00 0.00 1/2 log_create [1776] +----------------------------------------------- + 0.00 0.00 1/1 log_open [1817] +[1818] 0.0 0.00 0.00 1 log_rotate [1818] +----------------------------------------------- + 0.00 0.00 1/1 parse_args [1825] +[1819] 0.0 0.00 0.00 1 log_to_file [1819] + 0.00 0.00 1/2 log_create [1776] +----------------------------------------------- + 0.00 0.00 1/1 main [541] +[1820] 0.0 0.00 0.00 1 lua_done [1820] +----------------------------------------------- + 0.00 0.00 1/1 init_smithy [1312] +[1821] 0.0 0.00 0.00 1 make_matmod [1821] + 0.00 0.00 1/779868 a_new [1376] +----------------------------------------------- + 0.00 0.00 1/1 kernel_done [1813] +[1822] 0.0 0.00 0.00 1 message_done [1822] +----------------------------------------------- + 0.00 0.00 1/1 kernel_init [1814] +[1823] 0.0 0.00 0.00 1 mt_clear [1823] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1824] 0.0 0.00 0.00 1 openlibs [1824] +----------------------------------------------- + 0.00 0.00 1/1 main [541] +[1825] 0.0 0.00 0.00 1 parse_args [1825] + 0.00 0.00 2/2 verbosity_to_flags [1784] + 0.00 0.00 1/1 get_arg [1807] + 0.00 0.00 1/1 log_open [1817] + 0.00 0.00 1/1 log_to_file [1819] +----------------------------------------------- + 0.00 0.00 1/1 read_xml [791] +[1826] 0.0 0.00 0.00 1 parse_rules [1826] +----------------------------------------------- + 0.00 0.00 1/1 read_xml [791] +[1827] 0.0 0.00 0.00 1 parse_spellbooks [1827] + 0.00 0.00 326/5453 xml_ivalue [1533] + 0.00 0.00 326/11052 find_spell [1513] + 0.00 0.00 326/1524 spellbook_add [1572] + 0.00 0.00 6/3171 get_spellbook [1544] +----------------------------------------------- + 0.00 0.00 1/1 plan_monsters [52] +[1828] 0.0 0.00 0.00 1 pathfinder_cleanup [1828] +----------------------------------------------- + 0.00 0.00 1/1 attrib_allocation [914] +[1829] 0.0 0.00 0.00 1 produce_mallornseeds [1829] +----------------------------------------------- + 0.00 0.00 1/1 read_game [62] +[1830] 0.0 0.00 0.00 1 read_alliances [1830] +----------------------------------------------- + 0.00 0.00 1/1 read_reference [726] +[1831] 0.0 0.00 0.00 1 read_building_reference [1831] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1832] 0.0 0.00 0.00 1 register_arena [1832] + 0.00 0.00 2/240 register_function [1614] + 0.00 0.00 1/55 at_register [1678] + 0.00 0.00 1/27 register_item_use [1699] + 0.00 0.00 1/14 tt_register [1715] +----------------------------------------------- + 0.00 0.00 1/1 register_itemtypes [1843] +[1833] 0.0 0.00 0.00 1 register_artrewards [1833] + 0.00 0.00 2/27 register_item_use [1699] + 0.00 0.00 1/55 at_register [1678] + 0.00 0.00 1/2 register_item_useonother [1778] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1834] 0.0 0.00 0.00 1 register_attributes [1834] + 0.00 0.00 42/55 at_register [1678] + 0.00 0.00 5/9 register_bordertype [1732] + 0.00 0.00 3/5 at_deprecate [1749] +----------------------------------------------- + 0.00 0.00 1/1 register_spells [1251] +[1835] 0.0 0.00 0.00 1 register_borders [1835] + 0.00 0.00 3/9 register_bordertype [1732] + 0.00 0.00 1/55 at_register [1678] +----------------------------------------------- + 0.00 0.00 1/1 register_spells [1251] +[1836] 0.0 0.00 0.00 1 register_buildingcurse [1836] + 0.00 0.00 4/44 ct_register [1686] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1837] 0.0 0.00 0.00 1 register_buildings [1837] + 0.00 0.00 5/240 register_function [1614] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1838] 0.0 0.00 0.00 1 register_cr [1838] + 0.00 0.00 19/19 tsf_register [1705] + 0.00 0.00 1/3 register_reporttype [1768] +----------------------------------------------- + 0.00 0.00 1/1 register_itemfunctions [1842] +[1839] 0.0 0.00 0.00 1 register_demonseye [1839] + 0.00 0.00 1/3 register_item_give [1767] + 0.00 0.00 1/27 register_item_use [1699] +----------------------------------------------- + 0.00 0.00 1/1 register_spells [1251] +[1840] 0.0 0.00 0.00 1 register_flyingship [1840] + 0.00 0.00 1/44 ct_register [1686] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1841] 0.0 0.00 0.00 1 register_gmcmd [1841] + 0.00 0.00 2/5 at_deprecate [1749] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1842] 0.0 0.00 0.00 1 register_itemfunctions [1842] + 0.00 0.00 7/27 register_item_use [1699] + 0.00 0.00 1/1 register_demonseye [1839] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1843] 0.0 0.00 0.00 1 register_itemtypes [1843] + 0.00 0.00 1/1 register_artrewards [1833] + 0.00 0.00 1/1 register_xerewards [1858] + 0.00 0.00 1/1 register_weapons [1857] +----------------------------------------------- + 0.00 0.00 1/1 register_spells [1251] +[1844] 0.0 0.00 0.00 1 register_magicresistance [1844] + 0.00 0.00 1/44 ct_register [1686] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1845] 0.0 0.00 0.00 1 register_museum [1845] + 0.00 0.00 4/55 at_register [1678] + 0.00 0.00 3/27 register_item_use [1699] + 0.00 0.00 1/9 register_bordertype [1732] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1846] 0.0 0.00 0.00 1 register_names [1846] + 0.00 0.00 7/7 register_race_name_function [1740] + 0.00 0.00 1/1 register_race_description_function [1848] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1847] 0.0 0.00 0.00 1 register_nr [1847] + 0.00 0.00 2/3 register_reporttype [1768] +----------------------------------------------- + 0.00 0.00 1/1 register_names [1846] +[1848] 0.0 0.00 0.00 1 register_race_description_function [1848] + 0.00 0.00 1/240 register_function [1614] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1849] 0.0 0.00 0.00 1 register_races [1849] + 0.00 0.00 13/240 register_function [1614] +----------------------------------------------- + 0.00 0.00 1/1 register_spells [1251] +[1850] 0.0 0.00 0.00 1 register_regioncurse [1850] + 0.00 0.00 19/44 ct_register [1686] +----------------------------------------------- + 0.00 0.00 1/1 lovar [644] +[1851] 0.0 0.00 0.00 1 register_reports [1851] + 0.00 0.00 25/32 add_function [1690] + 0.00 0.00 18/18 register_argtype [1708] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1852] 0.0 0.00 0.00 1 register_resources [1852] + 0.00 0.00 10/27 register_item_use [1699] + 0.00 0.00 9/240 register_function [1614] + 0.00 0.00 1/2 register_item_useonother [1778] + 0.00 0.00 1/3 register_item_give [1767] +----------------------------------------------- + 0.00 0.00 1/1 register_spells [1251] +[1853] 0.0 0.00 0.00 1 register_shipcurse [1853] + 0.00 0.00 3/44 ct_register [1686] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1854] 0.0 0.00 0.00 1 register_tolua_helpers [1854] + 0.00 0.00 12/240 register_function [1614] + 0.00 0.00 2/55 at_register [1678] + 0.00 0.00 1/27 register_item_use [1699] + 0.00 0.00 1/3 register_item_give [1767] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1855] 0.0 0.00 0.00 1 register_triggers [1855] + 0.00 0.00 12/14 tt_register [1715] +----------------------------------------------- + 0.00 0.00 1/1 register_spells [1251] +[1856] 0.0 0.00 0.00 1 register_unitcurse [1856] + 0.00 0.00 14/44 ct_register [1686] +----------------------------------------------- + 0.00 0.00 1/1 register_itemtypes [1843] +[1857] 0.0 0.00 0.00 1 register_weapons [1857] + 0.00 0.00 2/240 register_function [1614] +----------------------------------------------- + 0.00 0.00 1/1 register_itemtypes [1843] +[1858] 0.0 0.00 0.00 1 register_xerewards [1858] + 0.00 0.00 2/27 register_item_use [1699] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1859] 0.0 0.00 0.00 1 register_xmas [1859] + 0.00 0.00 1/14 tt_register [1715] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1860] 0.0 0.00 0.00 1 register_xmlreader [1860] + 0.00 0.00 11/11 xml_register_callback [1726] +----------------------------------------------- + 0.00 0.00 1/1 kernel_done [1813] +[1861] 0.0 0.00 0.00 1 reports_done [1861] +----------------------------------------------- + 0.00 0.00 1/1 read_reference [726] +[1862] 0.0 0.00 0.00 1 resolve_building [1862] + 0.00 0.00 1/48455 findbuilding [1462] +----------------------------------------------- + 0.00 0.00 1/1 main [541] +[1863] 0.0 0.00 0.00 1 setup_signal_handler [1863] +----------------------------------------------- + 0.00 0.00 1/1 wormholes_update [906] +[1864] 0.0 0.00 0.00 1 sort_wormhole_regions [1864] +----------------------------------------------- + 0.00 0.00 1/1 do_fumble [1062] +[1865] 0.0 0.00 0.00 1 t_add [1865] +----------------------------------------------- + 0.00 0.00 1/1 tolua_bindings_open [1318] +[1866] 0.0 0.00 0.00 1 tolua_bind_open [1866] + 0.00 0.00 1/1 tolua_process_open [1877] + 0.00 0.00 1/2 tolua_eressea_open [1780] + 0.00 0.00 1/1 tolua_settings_open [1885] + 0.00 0.00 1/1 tolua_game_open [1871] + 0.00 0.00 1/1 tolua_locale_open [1873] + 0.00 0.00 1/1 tolua_config_open [1868] + 0.00 0.00 1/1 tolua_log_open [1874] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1867] 0.0 0.00 0.00 1 tolua_building_open [1867] +----------------------------------------------- + 0.00 0.00 1/1 tolua_bind_open [1866] +[1868] 0.0 0.00 0.00 1 tolua_config_open [1868] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1869] 0.0 0.00 0.00 1 tolua_dict_open [1869] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1870] 0.0 0.00 0.00 1 tolua_faction_open [1870] +----------------------------------------------- + 0.00 0.00 1/1 tolua_bind_open [1866] +[1871] 0.0 0.00 0.00 1 tolua_game_open [1871] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1872] 0.0 0.00 0.00 1 tolua_gmtool_open [1872] +----------------------------------------------- + 0.00 0.00 1/1 tolua_bind_open [1866] +[1873] 0.0 0.00 0.00 1 tolua_locale_open [1873] +----------------------------------------------- + 0.00 0.00 1/1 tolua_bind_open [1866] +[1874] 0.0 0.00 0.00 1 tolua_log_open [1874] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1875] 0.0 0.00 0.00 1 tolua_message_open [1875] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1876] 0.0 0.00 0.00 1 tolua_order_open [1876] +----------------------------------------------- + 0.00 0.00 1/1 tolua_bind_open [1866] +[1877] 0.0 0.00 0.00 1 tolua_process_open [1877] +----------------------------------------------- + 0.00 0.00 1/1 luaopen_config [2405] +[1878] 0.0 0.00 0.00 1 tolua_reg_types_config [1878] +----------------------------------------------- + 0.00 0.00 1/1 luaopen_game [2407] +[1879] 0.0 0.00 0.00 1 tolua_reg_types_game [1879] +----------------------------------------------- + 0.00 0.00 1/1 luaopen_locale [2408] +[1880] 0.0 0.00 0.00 1 tolua_reg_types_locale [1880] +----------------------------------------------- + 0.00 0.00 1/1 luaopen_log [2409] +[1881] 0.0 0.00 0.00 1 tolua_reg_types_log [1881] +----------------------------------------------- + 0.00 0.00 1/1 luaopen_process [2410] +[1882] 0.0 0.00 0.00 1 tolua_reg_types_process [1882] +----------------------------------------------- + 0.00 0.00 1/1 luaopen_settings [2411] +[1883] 0.0 0.00 0.00 1 tolua_reg_types_settings [1883] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1884] 0.0 0.00 0.00 1 tolua_region_open [1884] +----------------------------------------------- + 0.00 0.00 1/1 tolua_bind_open [1866] +[1885] 0.0 0.00 0.00 1 tolua_settings_open [1885] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1886] 0.0 0.00 0.00 1 tolua_ship_open [1886] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1887] 0.0 0.00 0.00 1 tolua_sqlite_open [1887] +----------------------------------------------- + 0.00 0.00 1/1 lua_init [1316] +[1888] 0.0 0.00 0.00 1 tolua_storage_open [1888] +----------------------------------------------- + 0.00 0.00 1/1 kernel_done [1813] +[1889] 0.0 0.00 0.00 1 translation_done [1889] + 0.00 0.00 1/1 free_functions [1805] +----------------------------------------------- + 0.00 0.00 1/1 kernel_init [1814] +[1890] 0.0 0.00 0.00 1 translation_init [1890] + 0.00 0.00 7/32 add_function [1690] +----------------------------------------------- + 0.00 0.00 1/1 do_fumble [1062] +[1891] 0.0 0.00 0.00 1 trigger_giveitem [1891] + 0.00 0.00 1/3113 t_new [1546] +----------------------------------------------- + 0.00 0.00 1/1 create_newfamiliar [1288] +[1892] 0.0 0.00 0.00 1 trigger_shock [1892] + 0.00 0.00 1/3113 t_new [1546] +----------------------------------------------- + 0.00 0.00 1/1 promotion_cmd [917] +[1893] 0.0 0.00 0.00 1 valid_race [1893] +----------------------------------------------- + 0.00 0.00 1/1 writegame [82] +[1894] 0.0 0.00 0.00 1 version_no [1894] +----------------------------------------------- + 0.00 0.00 1/1 game_init [1249] +[1895] 0.0 0.00 0.00 1 wormholes_register [1895] + 0.00 0.00 1/55 at_register [1678] +----------------------------------------------- + 0.00 0.00 1/1 write_game [83] +[1896] 0.0 0.00 0.00 1 write_alliances [1896] +----------------------------------------------- + 0.00 0.00 1/1 write_game [83] +[1897] 0.0 0.00 0.00 1 write_borders [1897] + 0.00 0.00 22643/22643 b_validroad [1494] + 0.00 0.00 22643/22643 b_writeroad [1495] + 0.00 0.00 1/1 b_write [1792] +----------------------------------------------- + 0.00 0.00 1/1 kernel_done [1813] +[1898] 0.0 0.00 0.00 1 xml_done [1898] +----------------------------------------------- + 0.00 0.00 5/251874 at_deprecate [1749] + 0.00 0.00 55/251874 at_register [1678] + 0.00 0.00 251814/251874 a_read_orig [389] +[3279] 0.0 0.00 0.00 251874 __at_hashkey [3279] +----------------------------------------------- + 0.00 0.00 49331/49331 log_stdio [1459] +[3280] 0.0 0.00 0.00 49331 _log_write [3280] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + + +Index by function name + + [535] AllianceAuto [1673] free_land [1830] read_alliances (save.c) + [164] AllianceRestricted (ally.c) [1311] free_locales [388] read_attribs + [491] CavalryBonus (battle.c) [1516] free_luxuries (economy.c) [706] read_borders + [1608] CavalrySkill (battle.c) [1426] free_node (pathfinder.c) [1831] read_building_reference + [1180] CheckOverload (laws.c) [1604] free_nodes (pathfinder.c) [1455] read_faction_reference + [1004] ExpensiveMigrants [1356] free_order [893] read_familiar (magic.c) + [1136] FactionSpells [306] free_orders [62] read_game + [836] GiveRestriction (give.c) [575] free_params [1451] read_group (group.c) + [288] HelpMask [1568] free_recruitments [782] read_groups + [901] IsImmune [1436] free_regionlist [799] read_handler (event.c) + [536] LongHunger [1598] free_side (battle.c) [320] read_items + [1195] MagicPower (magic.c) [1700] free_spellparameter (magic.c) [1559] read_mage (magic.c) + [1185] MagicRegeneration (magic.c) [1773] free_summary [894] read_magician (magic.c) + [1264] NMRTimeout [1361] free_variables (translation.c) [586] read_movement (movement.c) + [900] NewbieImmunity [1534] freestrlist [739] read_newunitid (unit.c) + [1605] PopulationDamage (battle.c) [1611] freetokens [524] read_of + [1171] RemoveNMRNewbie (laws.c) [96] from_external_node (critbit.c) [1477] read_owner (save.c) + [1236] ResourceFactor (resources.c) [310] fs_read (filestream.c) [1619] read_password (save.c) + [806] ShipSpeedBonus (ship.c) [447] fs_readln (filestream.c) [1164] read_planes + [3279] __at_hashkey (attrib.c) [124] fs_write (filestream.c) [1278] read_race_reference + [3280] _log_write (log.c) [159] fs_writeln (filestream.c) [726] read_reference + [555] a_add [137] fstream_done [1582] read_region_reference + [418] a_age [973] fumble [1522] read_seenspell (magic.c) + [1597] a_finalizeeffect (alchemy.c) [1284] fumble_default (magic.c) [1759] read_skill (unitcurse.c) + [1786] a_finalizestring [1806] funhash [1555] read_spellbook + [65] a_find [191] fwritestr (creport.c) [870] read_targetregion (targetregion.c) + [558] a_free (attrib.c) [542] game_done [798] read_triggers + [1561] a_init_reportspell (magic.c) [1324] game_id [74] read_unit + [1552] a_initeffect (alchemy.c) [1249] game_init [1521] read_unit_reference + [566] a_insert (attrib.c) [1168] game_name [413] read_unitid + [1376] a_new [1222] gamedate2 (summary.c) [791] read_xml + [390] a_read_i (attrib.c) [944] gamedate_season (report.c) [767] readfaction + [389] a_read_orig [962] generic_name (names.c) [60] readgame + [1660] a_readchars [171] genrand_int31 [43] readorders + [1052] a_readeffect (alchemy.c) [150] genrand_int32 [209] readregion (save.c) + [1448] a_readint [395] genrand_real2 [1612] real2tp (teleport.c) + [1648] a_readkey (key.c) [20] get_addresses (reports.c) [650] recruit (economy.c) + [1531] a_readprivate [1528] get_alive (battle.c) [1564] recruit_cost (economy.c) + [1474] a_readshorts [1001] get_allocator (economy.c) [837] recruit_dracoids (monsters.c) + [1642] a_readstring [1807] get_arg (main.c) [1334] recruit_init (economy.c) + [366] a_remove [482] get_astralplane [1091] reduce_skill + [958] a_removeall [120] get_borders [404] reduce_weight (monsters.c) + [361] a_select [118] get_borders_i (connection.c) [346] regenerate_aura + [559] a_unlink (attrib.c) [717] get_chaoscount [942] regeneration (magic.c) + [1314] a_upgradekeys [1347] get_cmp_region_owner (laws.c) [1444] region_get_morale + [299] a_write [874] get_combatspell [1424] region_getinfo + [998] a_write_unit (magic.c) [880] get_combatspelllevel [1058] region_getresource + [1663] a_writechars [108] get_command [1476] region_set_morale + [1073] a_writeeffect (alchemy.c) [143] get_curse [1422] region_setinfo + [1447] a_writeint [496] get_direction [1683] region_setname + [1787] a_writekeys (key.c) [225] get_effect [1097] region_setresource + [1473] a_writeshorts [1551] get_equipment [987] regionname + [1529] a_writestring [796] get_familiar [675] regions_in_range + [804] absorbed_by_monster (monster.c) [722] get_familiar_mage [1832] register_arena + [527] academy_can_teach [254] get_followers (move.c) [1708] register_argtype + [1128] academy_teaching_bonus [88] get_food [1833] register_artrewards + [560] active_building [1656] get_force (combatspells.c) [1834] register_attributes + [1666] add_callbacks (xmlreader.c) [895] get_friends (unit.c) [1835] register_borders + [1626] add_castorder [1600] get_function [1732] register_bordertype + [1198] add_chaoscount [1466] get_gamedate [1836] register_buildingcurse + [1509] add_donation [581] get_homeplane [1837] register_buildings + [1690] add_function [274] get_keyword [1838] register_cr + [379] add_give (give.c) [934] get_level [1839] register_demonseye + [625] add_income (economy.c) [884] get_locale [1840] register_flyingship + [980] add_itemname_cb (item.c) [198] get_mage [1614] register_function + [1169] add_items (xmlreader.c) [1682] get_maxluxuries [1841] register_gmcmd + [434] add_message [1445] get_migrants (laws.c) [1767] register_item_give + [1674] add_proc (laws.c) [55] get_modifier [1699] register_item_use + [1716] add_proc_global [187] get_money [1778] register_item_useonother + [1692] add_proc_order [1087] get_money_for_dragon (monsters.c) [1842] register_itemfunctions + [1761] add_proc_postregion [293] get_monsters [1843] register_itemtypes + [1733] add_proc_region [750] get_movement [1844] register_magicresistance + [1762] add_proc_unit [480] get_neighbours [1845] register_museum + [1693] add_raceprefix [1275] get_or_create_locale [1846] register_names + [371] add_recruits [292] get_or_create_monsters [1847] register_nr + [1419] add_regionlist [1680] get_or_create_terrain [1848] register_race_description_function + [1162] add_resource [1362] get_otherfaction [1740] register_race_name_function + [977] add_resourcename_cb (item.c) [235] get_param [1849] register_races + [1372] add_seen (reports.c) [713] get_param_flt [1850] register_regioncurse + [1788] add_seen_faction [422] get_param_int [1851] register_reports + [1401] add_seen_faction_i (reports.c) [104] get_pooled [1768] register_reporttype + [386] add_seen_nb (reports.c) [263] get_prefix [1852] register_resources + [355] add_skill [12] get_race [1853] register_shipcurse + [1667] add_skills (xmlreader.c) [368] get_racename [1259] register_special_direction + [1638] add_spell [372] get_regions_distance (reports.c) [1250] register_spelldata (spells.c) + [1173] add_spellparameter (magic.c) [281] get_reservation [1251] register_spells + [1668] add_spells (xmlreader.c) [99] get_resource [1854] register_tolua_helpers + [1669] add_subsets (xmlreader.c) [194] get_resourcetype [1855] register_triggers + [1579] add_tactics (battle.c) [189] get_row (battle.c) [1856] register_unitcurse + [1145] add_translation [423] get_skill [1857] register_weapons + [673] add_travelthru_addresses (reports.c) [862] get_spchange (magic.c) [1858] register_xerewards + [1260] add_trigger [1544] get_spellbook [1859] register_xmas + [607] add_variable (translation.c) [872] get_spellpoints [1860] register_xmlreader + [913] addally (save.c) [1178] get_tactics (battle.c) [1728] rel_to_abs + [217] addlist [1423] get_terrain [528] reldirection + [1069] addmessage [1304] get_translation [1364] release_data (order.c) + [1261] addparam_building (magic.c) [437] get_translations [1061] relpath (config.c) + [1212] addparam_ship (magic.c) [1431] get_transporters (move.c) [1153] remove_building + [1214] addparam_unit (magic.c) [154] get_unitrow (battle.c) [576] remove_empty_factions + [769] addstrlist [71] getbuf [146] remove_empty_units + [811] addtoken [72] getbuf_utf8 (filereader.c) [134] remove_empty_units_in_region + [234] adjust_coordinates [937] getfaction [571] remove_exclusive (laws.c) + [701] aftermath (battle.c) [652] getguard [391] remove_idle_players (laws.c) + [1789] age_borders [483] getid [587] remove_plane + [712] age_building (laws.c) [699] getint [1748] remove_ship + [1098] age_dragon [54] getkeyword [1456] remove_skill + [1123] age_firedragon [681] getparam [499] remove_unit + [1024] age_ghoul [596] getplane [1290] removelist + [1308] age_illusion [1717] getplanebyid [1545] rename_cmd (laws.c) + [959] age_piracy [595] getplanebyname [58] render_messages (creport.c) + [1017] age_reduceproduction (reduceproduction.c) [1337] getplaneid [780] renumber_cmd + [659] age_region (laws.c) [1385] getreload [1156] renumber_factions + [1008] age_skeleton [1018] getship [1159] renumber_unit + [1021] age_stonecircle (laws.c) [212] getshipweight [1631] reorder_fleeing (battle.c) + [720] age_traveldir (move.c) [387] getskill (study.c) [400] reorder_units + [1196] age_undead [710] getstrtoken [526] replace_order + [336] age_unit (laws.c) [195] gettoken [860] report_action + [1573] age_unit (magic.c) [778] getuint [397] report_building + [1019] age_zombie [205] getunit [9] report_computer (creport.c) + [185] ageing (laws.c) [1029] ghoul_name (names.c) [428] report_crtypes (creport.c) + [529] all_money (monsters.c) [891] gift_items [725] report_donations + [1330] allied_skilllimit (faction.c) [102] give_cmd [861] report_effect (spells.c) + [162] alliedfaction [1763] give_control [1187] report_failed_spell (battle.c) + [34] alliedgroup [287] give_control_cmd [1285] report_failure (spells.c) + [31] alliedunit [1108] give_horses (item.c) [106] report_item + [419] allies (report.c) [126] give_item [103] report_items + [752] allocate_resource (economy.c) [857] give_men [4] report_plaintext + [564] allowed_dragon [484] give_money (item.c) [1402] report_resource (reports.c) + [1425] allowed_fly [1060] give_peasants (monsters.c) [210] report_resources + [1452] ally_add [858] give_quota [1301] report_spell (spells.c) + [877] ally_cmd [952] give_unit [318] report_status + [456] ally_mode (ally.c) [1774] giveitem_init (giveitem.c) [614] report_summary + [1160] allysf (battle.c) [1262] giveitem_read (giveitem.c) [87] report_template (report.c) + [1122] allysfm (battle.c) [1309] giveitem_write (giveitem.c) [724] report_transfer (donations.c) + [929] already_seen (magic.c) [405] godcurse (randenc.c) [881] reportcasualties (battle.c) + [1566] any_recruiters (economy.c) [265] golem_factor (item.c) [1063] reportpath + [1434] arg_set (messages.c) [910] good_region (wormhole.c) [2] reports + [151] armedmen [985] group_cmd [1861] reports_done + [819] armor_bonus (battle.c) [698] groupid (reports.c) [1527] required (economy.c) + [1498] army_index (battle.c) [300] growing_herbs (laws.c) [1547] required (build.c) + [329] astralregions [624] growing_trees (laws.c) [1020] reroute (move.c) + [1749] at_deprecate [865] guard [972] res_changeaura (item.c) + [563] at_find (attrib.c) [690] guard_flags [1779] res_changehp (item.c) + [1678] at_register [711] guard_off_cmd [101] res_changeitem (item.c) + [440] atoi36 [656] guard_on_cmd [1200] res_changepeasants (item.c) + [1416] atoip [229] guards (report.c) [912] res_changepermaura (item.c) + [90] att_modification (unit.c) [1363] handle_event [886] research_cmd (economy.c) + [84] attack (battle.c) [1706] handle_triggers [324] reserve_cmd + [785] attack_firesword (weapons.c) [1269] has_ao_healing (combatspells.c) [213] reserve_i (laws.c) + [1409] attacks_per_round (battle.c) [1378] has_horses [325] reserve_self + [914] attrib_allocation (economy.c) [1808] has_limited_skills [356] reset_game (bindings.c) + [1790] attrib_done [193] has_skill [1751] reset_locales + [179] autoalliance (ally.c) [442] hash_uid (region.c) [1625] reset_translations (creport.c) + [777] average_score_of_age [37] hashstring [822] reshow (laws.c) + [1471] b_blocknone [1224] heal (item.c) [818] reshow_cmd + [1770] b_blockquestportal [619] heal_factor (laws.c) [823] reshow_other (laws.c) + [1417] b_finvisible [1158] heal_fighters (combatspells.c) [757] resolve + [1771] b_fvisible [678] help_feed (upkeep.c) [1862] resolve_building + [1279] b_namequestportal (museum.c) [663] help_money (upkeep.c) [820] resolve_faction + [642] b_nameroad (connection.c) [1177] helping [846] resolve_familiar (magic.c) + [1772] b_opaque [493] herbsearch [856] resolve_mage (magic.c) + [1791] b_read [131] hits [1575] resolve_region_id + [1497] b_readroad (connection.c) [604] horse_fleeing_bonus (battle.c) [703] resolve_unit + [1418] b_rvisibleroad (connection.c) [1567] horse_recruiters (economy.c) [546] resource2item + [1420] b_transparent [330] horses (laws.c) [1499] resource2luxury + [1487] b_uinvisible [206] hp_status [1569] resource2potion + [1494] b_validroad (connection.c) [1519] hpflee (battle.c) [1353] resource2weapon + [1792] b_write [808] hunger (upkeep.c) [233] resourcename + [1495] b_writeroad (connection.c) [1223] hunger_damage (upkeep.c) [353] restack_units + [363] balloc [1055] hunted_dir (move.c) [271] rfindhash (region.c) + [1730] basepath [582] i10toi36 [737] rhash + [79] battle_attacks (battle.c) [1442] i_add [1351] rherbs + [1125] battle_effects (battle.c) [569] i_canuse (battle.c) [1369] rhorses + [352] battle_flee (battle.c) [115] i_change [694] ridingcapacity (move.c) + [1629] battle_free (battle.c) [127] i_find [1578] rm_get + [620] battle_punit (battle.c) [1737] i_findc [890] rmfighter + [503] battle_report (battle.c) [1400] i_free [452] rmoney + [1595] battle_update (battle.c) [1515] i_freeall [1741] rmt_create + [1096] begin_potion (alchemy.c) [130] i_get [1490] rmt_find + [547] besieged [1651] i_merge [1672] rmt_get + [631] bewegung_blockiert_von (move.c) [1375] i_new [533] rmtroop (battle.c) + [1461] bfindhash (building.c) [1407] i_remove [200] rname + [1349] bfree [285] icebergs (randenc.c) [396] rng_injectable_double + [1464] bhash [294] immigration [606] roadto (move.c) + [119] bin_r_int_pak (binarystore.c) [1585] in_safe_building [165] room_for_race_in_region (monsters.c) + [216] bin_r_str_buf (binarystore.c) [885] income [1329] roqf_factor + [445] bin_w_brk (binarystore.c) [454] inhabitable [284] rotting_herbs (randenc.c) + [218] bin_w_int_pak (binarystore.c) [1453] init_cb (report.c) [1607] rough_amount (economy.c) + [446] bin_w_str (binarystore.c) [790] init_data (bindings.c) [618] rp_battles (report.c) + [1793] bind_monsters [1143] init_directions [36] rp_messages (report.c) + [641] border_name [1809] init_genrand [435] rpeasants + [741] breed_cmd (economy.c) [1764] init_group (group.c) [1433] rpline (report.c) + [742] breedhorses (economy.c) [1570] init_handler (event.c) [359] rps_nowrap (report.c) + [1148] breedtrees (economy.c) [1307] init_itemtypes [1221] rrandneighbour (volcano.c) + [1360] brelease [1179] init_keyword [508] rroad + [1415] bt_changed [1099] init_keywords [1438] rsetherbs + [343] bt_effsize [1396] init_learning (study.c) [537] rsetherbtype + [237] bt_find [948] init_locale [1408] rsethorses + [236] bt_find_i (building.c) [947] init_locales [553] rsetmoney + [1114] bt_get_or_create [1558] init_mage (magic.c) [545] rsetpeasants + [1698] bt_register [1319] init_mallornseed [1152] rsetroad + [201] buforder (reports.c) [1235] init_oldpotions (item.c) [1410] rsettrees + [17] bufunit [1157] init_options_translation [597] rt_find + [691] build [613] init_order [1139] rt_get_or_create + [696] build_building [1100] init_parameters [1640] rt_register (item.c) + [950] build_road [1310] init_processor [302] rtrees + [839] build_ship (build.c) [399] init_reports [1332] rule_alliance_limit + [1428] building_finished [1731] init_resourcelimit (item.c) [855] rule_auto_taxation (economy.c) + [1488] building_is_active [1228] init_resources [738] rule_autowork (economy.c) + [232] building_owner [1272] init_rules (battle.c) [1327] rule_blessed_harvest + [253] building_owner_ex (building.c) [1320] init_seed [1331] rule_faction_limit + [708] building_protection (building.c) [1592] init_skillmod (skills.c) [1175] rule_force_leave + [1504] building_set_owner [1101] init_skills [1328] rule_give + [1010] building_update_owner [1312] init_smithy (building.c) [829] rule_random_progress (skills.c) + [1500] buildingcapacity [1810] init_terrains [1323] rule_region_owners + [367] buildingeffsize [1129] init_terrains_translation [1325] rule_stealth_anon + [1535] buildingmaintenance (report.c) [544] init_tokens_str [530] rule_stealth_other + [621] buildingname [1033] init_translations [1204] rule_transfermen (give.c) + [414] buildingtype [384] init_transportation (move.c) [1247] runhash + [1443] buildingtype_exists [1486] inside_building [181] sail (move.c) + [1720] bunhash [345] internal_path_find (pathfinder.c) [969] scale_number + [707] buy (economy.c) [1756] intlist_add [768] scareaway (monster.c) + [1536] c_clearflag [1757] intlist_init [380] scared_by_monster (monster.c) + [1070] caddmessage (messages.c) [139] invisible [23] score + [645] calculate_armor [1368] is_allied [244] scramble (economy.c) + [603] calculate_emigration (laws.c) [479] is_astral [1116] scramble_fighters (combatspells.c) + [1794] caldera_handle (arena.c) [1550] is_attacker [1729] section_add + [1270] caldera_read (arena.c) [554] is_building_type [1563] section_find + [1795] caldera_write (arena.c) [570] is_exclusive [1440] see_border + [1796] calendar_cleanup [1092] is_familiar [1117] seefaction + [1338] can_charm (spells.c) [1088] is_freezing (move.c) [1491] seematrix (battle.c) + [1634] can_contact [211] is_guard [1132] select_ally + [1335] can_give (give.c) [377] is_guarded [700] select_armor (battle.c) + [940] can_give_men (give.c) [186] is_guardian_r (move.c) [172] select_enemy + [600] can_give_to [626] is_guardian_u (move.c) [1322] select_familiar (spells.c) + [908] can_guard (economy.c) [1370] is_long [680] select_magicarmor + [1112] can_leave [262] is_mage [160] select_opponent (battle.c) + [736] can_move (move.c) [1047] is_migrant [1079] select_recruitment (economy.c) + [679] can_start_guarding [1392] is_mourning [761] select_spellbook (magic.c) + [640] can_survive [1231] is_moving_ship (magic.c) [1367] select_weapon (battle.c) + [854] can_takeoff [687] is_persistent [909] select_wormhole_regions (wormhole.c) + [833] cancast [552] is_repeated [498] sell (economy.c) + [1031] canfly [1358] is_riding (battle.c) [1202] send_cmd + [465] canride (move.c) [668] isparam [1576] set_attacker (battle.c) + [469] cansail (move.c) [453] it_alias (item.c) [875] set_coast (move.c) + [22] cansee [385] it_find [1146] set_combatspell + [170] cansee_durchgezogen [1115] it_get_or_create [1265] set_curseingmagician (curse.c) + [684] cansee_unit [1636] it_register (item.c) [1620] set_email + [682] canswim [1679] it_set_appearance [1562] set_enemy (battle.c) + [633] canwalk (move.c) [561] item2resource [183] set_factionstealth + [502] cap_route (move.c) [1811] item_done [992] set_familiar (magic.c) + [760] cast_cmd (magic.c) [149] item_invis (unit.c) [1574] set_friendly (battle.c) + [623] cast_combatspell (battle.c) [338] itoa10 [1048] set_group + [512] castle_name (building.c) [116] itoa36 [1134] set_leftship + [513] castle_name_i (building.c) [107] itoab [774] set_level + [1003] caught_target (move.c) [439] jenkins_hash [1326] set_money + [598] cb_add_address (reports.c) [693] join_allies (battle.c) [486] set_new_dragon_target (monsters.c) + [94] cb_add_seen (reports.c) [425] join_battle (battle.c) [1387] set_number + [204] cb_cr_travelthru_ship (creport.c) [1083] join_group [1365] set_order + [466] cb_cr_travelthru_unit (creport.c) [1016] join_path [1689] set_param + [308] cb_find_prefix [464] json_config [1015] set_racename + [95] cb_find_prefix_i (critbit.c) [772] json_disable_features (jsonconf.c) [1430] set_resvalue + [13] cb_find_top_i (critbit.c) [583] json_export [933] set_spellpoints + [335] cb_get_kv [1707] json_flags (jsonconf.c) [588] set_string + [577] cb_insert [1283] json_include (jsonconf.c) [815] setguard + [653] cb_new_kv [1127] json_keyword (jsonconf.c) [1542] setreload (battle.c) + [169] cb_write_travelthru (report.c) [1124] json_keywords (jsonconf.c) [1390] setstatus + [789] centre (report.c) [1812] json_prefixes (jsonconf.c) [182] setstealth_cmd + [495] chance [467] json_settings (jsonconf.c) [1863] setup_signal_handler (main.c) + [982] change_effect [1189] json_terrain (jsonconf.c) [1484] sfindhash (ship.c) + [911] change_maxspellpoints [1694] json_terrain_production (jsonconf.c) [1502] shash + [337] change_money [1190] json_terrains (jsonconf.c) [1482] ship_damage_percent + [1441] change_reservation [1813] kernel_done [438] ship_owner + [240] change_resource [1814] kernel_init [1571] ship_owner_ex (ship.c) + [971] change_spellpoints [719] key_get [354] ship_ready (move.c) + [1721] changefaction_init (changefaction.c) [1355] keyword [1505] ship_set_owner + [1166] changefaction_read (changefaction.c) [1348] keyword_disabled [573] ship_update_owner + [1258] changefaction_write (changefaction.c) [1647] keyword_key (keyword.c) [567] shipcapacity + [1746] changerace_init (changerace.c) [532] kill_troop [1072] shipcurse_flyingship (flyingship.c) + [1215] changerace_read (changerace.c) [817] killunit_read (killunit.c) [290] shipname + [1287] changerace_write (changerace.c) [978] killunit_write (killunit.c) [669] shipspeed + [848] chaos (chaos.c) [956] knowsspell [1468] shiptrail_age (move.c) + [1797] chaos_register [476] koor_distance [1492] shiptrail_finalize (move.c) + [514] chaos_update [1394] koor_distance_orig (region.c) [1469] shiptrail_init (move.c) + [1077] chaosfactor (monsters.c) [1724] koor_distance_wrap_xy (region.c) [1475] shiptrail_read (move.c) + [1213] chaosterrain (chaos.c) [562] koor_reldirection (move.c) [1511] shiptrail_write (move.c) + [1537] chash [651] largestbuilding [892] shock_read (shock.c) + [1244] check_dupe (log.c) [1601] lastregion (reports.c) [1050] shock_write (shock.c) + [1432] check_errno (report.c) [471] learn_skill [1248] show_alliances_cr (creport.c) + [1138] check_give [432] leave [429] show_allies (report.c) + [786] check_leuchtturm [1009] leave_building [661] show_allies_cr (creport.c) + [1141] check_messages_exist (reports.c) [721] leave_cmd [889] show_new_spells + [184] check_overpopulated (monsters.c) [540] leave_ship [745] sideabkz (battle.c) + [793] check_param [704] leave_trail (move.c) [867] sidename (battle.c) + [657] check_ship_allowed [500] leftship [475] sinkships + [1234] check_steal [1635] leftship_age (unit.c) [510] sk_set + [1268] checkpasswd [1388] level_days [1035] skeleton_name (names.c) + [402] checkunitnumber [888] leveled_allocation (economy.c) [365] skill_enabled + [565] choplist (lists.c) [1071] levitate_ship [1205] skill_key (skill.c) + [686] cinfo_building [286] lifestyle [1172] skill_limit + [824] cinfo_magicresistance (magicresistance.c) [728] lighthouse_range [264] skill_mod + [996] cinfo_magicrunes (buildingcurse.c) [1775] limit_mallornseeds (seed.c) [1032] skill_summoned (spells.c) + [812] cinfo_ship [943] limit_resource (helpers.c) [509] skill_weeks + [997] cinfo_shipnodrift (shipcurse.c) [1691] limit_seeds (seed.c) [166] skilldiff + [751] cinfo_simple [879] limited_give (give.c) [214] skillmod + [1192] cinfo_skillmod (unitcurse.c) [635] list_address (report.c) [122] skillname + [1118] cinfo_slave (unitcurse.c) [190] listlen [1593] slipthru (laws.c) + [1110] cinfo_speed (unitcurse.c) [73] live (laws.c) [548] slprintf + [1242] claim_cmd [1293] load_inifile (main.c) [520] sm_familiar (magic.c) + [309] class_index_event [266] locale_getstring [1613] sm_smithy (building.c) + [531] clear_npc_orders (save.c) [1354] locale_index [1864] sort_wormhole_regions + [1271] clonedied_read (clonedied.c) [1815] locale_init [1514] sp_alias (spell.c) + [1321] clonedied_write (clonedied.c) [568] locale_name [847] sp_blessedharvest (spells.c) + [718] cmistake [918] locale_setstring [1209] sp_bloodsacrifice (spells.c) + [578] cmp_curse (curse.c) [27] locale_string [993] sp_charmingsong (spells.c) + [305] cmp_faction [1816] log_close [627] sp_dragonodem + [203] cmp_transfer [1776] log_create [1045] sp_enterastral + [670] cmp_wage [1245] log_debug [988] sp_eternizewall (spells.c) + [1644] co_get_caster [1340] log_error [1064] sp_flying_ship + [1594] co_get_region [1339] log_info [1040] sp_generous (spells.c) + [898] combatspell_cmd [1817] log_open [974] sp_goodwinds (spells.c) + [1352] config_changed [251] log_orders (reports.c) [931] sp_hain (spells.c) + [224] config_get [1458] log_prefix (log.c) [989] sp_healing + [714] config_get_flt [1818] log_rotate [1068] sp_holyground (spells.c) + [348] config_get_int [1459] log_stdio (log.c) [923] sp_igjarjuk + [462] config_parse [1819] log_to_file [957] sp_kampfzauber + [460] config_read [1342] log_warning [968] sp_mallornhain (spells.c) + [444] config_set [1243] log_write (log.c) [1336] sp_seduce (spells.c) + [794] config_token [873] loot_cmd [939] sp_song_of_peace (spells.c) + [965] contact_cmd [810] loot_items (battle.c) [871] sp_stormwinds (spells.c) + [654] contest (battle.c) [1013] loot_quota (battle.c) [1025] sp_summon_familiar (spells.c) + [655] contest_classic (battle.c) [644] lovar [1034] sp_summonshadowlords (spells.c) + [813] continue_ship [809] lparagraph [896] sp_summonundead (spells.c) + [521] copy_arg (message.c) [1738] lt_register (item.c) [784] sp_viewreality + [441] copy_order [1645] lua_callspell (helpers.c) [827] sparagraph + [357] count_all [1591] lua_canuse_item (helpers.c) [505] spawn_braineaters + [1220] count_allies [1820] lua_done [411] spawn_dragons + [231] count_cb (reports.c) [1191] lua_getresource (helpers.c) [831] spawn_seaserpent + [611] count_enemies [1316] lua_init [629] spawn_undead + [636] count_enemies_i (battle.c) [157] magic [1621] spc_email_isvalid (goodies.c) + [219] count_faction [897] magic_lowskill [1526] special_resources (bind_region.c) + [730] count_maxmigrants [727] magic_resistance [1657] spell_damage (combatspells.c) + [731] count_migrants [844] mail_cmd [841] spell_info + [1089] count_particles (names.c) [1106] mailfaction (laws.c) [646] spell_name + [666] count_side (battle.c) [921] mailunit (laws.c) [1572] spellbook_add + [868] count_skill [478] maintain (economy.c) [1742] spellbook_clear + [518] count_travelthru [339] maintain_buildings [1557] spellbook_get + [487] count_units [481] maintenance_cost [995] spellcost + [572] countheroes [1282] make_battle [1000] spellpower + [903] countspells [383] make_cmd [1650] spl_costtyp (magic.c) + [135] cr_borders (creport.c) [802] make_curse (curse.c) [743] split_allocations + [1481] cr_building (creport.c) [584] make_external_node (critbit.c) [1518] split_messages + [1493] cr_faction (creport.c) [1219] make_familiar (spells.c) [828] split_paragraph + [602] cr_find_address (creport.c) [424] make_fighter [53] spskill + [1406] cr_int [1589] make_follow [632] spunit + [489] cr_order (creport.c) [1298] make_heroes (battle.c) [990] spy_cmd + [239] cr_output_building (creport.c) [1718] make_iceberg [1038] spy_message + [69] cr_output_curses (creport.c) [1615] make_leftship (unit.c) [1503] st_find + [144] cr_output_curses_compat (creport.c) [1303] make_locales [1501] st_find_i (ship.c) + [57] cr_output_messages (creport.c) [1821] make_matmod [1743] st_get_or_create + [10] cr_output_region (creport.c) [522] make_movement_order (monsters.c) [297] start_battle (battle.c) + [378] cr_output_resource (creport.c) [970] make_name (names.c) [70] statistics (report.c) + [238] cr_output_resources (creport.c) [1603] make_otherfaction [904] status_cmd + [152] cr_output_ship (creport.c) [1722] make_reduceproduction [550] statusrow + [639] cr_output_spells (creport.c) [289] make_route (move.c) [766] steal_cmd (economy.c) + [298] cr_output_travelthru (creport.c) [876] make_side [188] stealth_modifier + [19] cr_output_unit [1777] make_skillmod [167] stream_order (creport.c) + [18] cr_output_unit_compat (creport.c) [21] make_summary [158] stream_printf + [949] cr_race (creport.c) [1701] make_targetregion [1374] strlcat + [662] cr_region (creport.c) [1188] make_undead_unit [45] strlcpy + [1414] cr_region_header (creport.c) [1150] make_wormhole (wormhole.c) [67] strlcpy_w + [840] cr_regions (creport.c) [1151] make_wormholes [105] study_cmd + [196] cr_render [1267] make_zombie [433] study_cost + [756] cr_reportspell (creport.c) [1084] makename (region.c) [747] study_days (study.c) + [488] cr_resource (creport.c) [759] manufacture (economy.c) [1398] study_speedup (study.c) + [960] cr_resources (creport.c) [610] mark_travelthru (move.c) [925] summon_allies (combatspells.c) + [1530] cr_ship (creport.c) [748] markets_module [1744] sunhash + [672] cr_skill (creport.c) [975] matmod (build.c) [1036] syntax_error + [1026] cr_spell (creport.c) [915] max_magicians [1865] t_add + [1510] cr_string [1037] max_skill (economy.c) [1546] t_new + [1403] cr_unit (creport.c) [755] max_spellpoints [1154] target_resists_magic + [579] create_backup [1109] max_transfers (give.c) [697] tax_cmd + [1066] create_castorder [946] maxbuild [272] teach_cmd + [1137] create_castorder_combat (battle.c) [492] maxheroes [426] teach_unit (study.c) + [800] create_curse [473] maxworkingpeasants [410] term_eval (dice.c) + [252] create_data (order.c) [1046] mayboard (laws.c) [242] terminate + [1294] create_directories [936] mayenter (laws.c) [1165] terraform_default (resources.c) + [1658] create_equipment [1082] melt_iceberg (randenc.c) [932] terraform_region + [538] create_icebergs [1517] merge_messages [986] terraform_resources + [617] create_item (economy.c) [834] message_all [1421] terrain_find_i (terrain.c) + [1315] create_mage [1822] message_done [226] terrain_name + [1288] create_newfamiliar [716] message_faction (battle.c) [1760] terrains + [341] create_order [1405] messagehash (creport.c) [1709] timeout_handle (timeout.c) + [175] create_order_i (order.c) [1478] migrate (laws.c) [1710] timeout_init (timeout.c) + [821] create_potion (economy.c) [1652] mk_piracy (piracy.c) [1719] timeout_read (timeout.c) + [1014] create_ship [1366] mkdata (order.c) [1711] timeout_write (timeout.c) + [1639] create_spell [261] mkname [1866] tolua_bind_open + [1606] create_spellbook [316] mkname_buf [1318] tolua_bindings_open + [296] create_unit [1429] mknode [1867] tolua_building_open + [317] createunitid (unit.c) [1203] mm_smithy (building.c) [589] tolua_buildinglist_next + [344] crew_skill [1239] mod_elves_only (item.c) [1868] tolua_config_open + [1798] crmessage_done [764] monster_attack (monsters.c) [1869] tolua_dict_open + [321] crt_find (crmessage.c) [248] monster_attacks [1780] tolua_eressea_open + [1006] crt_register [407] monster_is_waiting [1870] tolua_faction_open + [110] crtag (creport.c) [230] monster_kills_peasants [1871] tolua_game_open + [592] ct_changed [269] monster_learn (monsters.c) [1872] tolua_gmtool_open + [1142] ct_checknames [129] monster_move (monsters.c) [1873] tolua_locale_open + [114] ct_find [215] monthly_healing [1874] tolua_log_open + [1686] ct_register [1479] morale_update [1875] tolua_message_open + [580] ct_remove [283] move_blocked [1876] tolua_order_open + [1695] cunhash (curse.c) [66] move_cmd [1877] tolua_process_open + [543] curse_active [342] move_hunters (move.c) [1878] tolua_reg_types_config (config.pkg.c) + [1538] curse_age [1094] move_iceberg (randenc.c) [1781] tolua_reg_types_eressea (eressea.pkg.c) + [1489] curse_cansee [534] move_icebergs (randenc.c) [1879] tolua_reg_types_game (game.pkg.c) + [1696] curse_done [326] move_pirates (move.c) [1880] tolua_reg_types_locale (locale.pkg.c) + [1395] curse_geteffect [374] move_ship [1881] tolua_reg_types_log (log.pkg.c) + [1590] curse_geteffect_int [421] move_unit [1882] tolua_reg_types_process (process.pkg.c) + [1539] curse_init [47] movement [1883] tolua_reg_types_settings (settings.pkg.c) + [1140] curse_name [1193] movement_error (move.c) [1884] tolua_region_open + [770] curse_read [155] movement_speed (move.c) [590] tolua_regionlist_next + [930] curse_write [350] movewhere [1885] tolua_settings_open + [1799] curses_done [1399] msg_addref [1886] tolua_ship_open + [375] cycle_route (move.c) [228] msg_create [1887] tolua_sqlite_open + [1641] damage_ship [1080] msg_create_message (bind_message.c) [1888] tolua_storage_open + [1044] damage_unit (volcano.c) [664] msg_curse [1274] tolua_toid + [1289] datapath [744] msg_error [591] tolua_tousertype + [1800] dazzle [647] msg_feedback [449] tolua_unit_get_faction (bind_unit.c) + [1549] dead_fighters (battle.c) [1384] msg_free [1782] tolua_unit_open + [674] deathcount [1005] msg_materials_required [313] tolua_unitlist_next + [843] deathcounts [132] msg_message [1085] tpregion (teleport.c) + [56] decode_pointer (critbit.c) [1373] msg_release [207] trailinto + [851] default_name [1042] msg_send_faction (bind_message.c) [1039] transfer_curse + [902] default_order [1210] msg_send_region (bind_message.c) [1622] transfer_seen + [1659] default_score [1633] msg_set_int (bind_message.c) [899] transfermen + [1144] default_spoil (item.c) [1685] msg_set_region (bind_message.c) [75] translate (creport.c) + [173] default_wage (config.c) [1226] msg_set_resource (bind_message.c) [28] translate + [249] defaultorders [1646] msg_set_unit (bind_message.c) [1889] translation_done + [966] deliverMail [1286] msg_to_ship_inmates (move.c) [1890] translation_init + [50] demographics [1823] mt_clear [430] translist + [826] demon_skillchange [227] mt_find [358] transliterate + [246] demon_skillchanges (randenc.c) [1587] mt_id (message.c) [1011] transport (move.c) + [35] describe (report.c) [1588] mt_new [81] travel (move.c) + [267] describe_race (names.c) [1007] mt_register [92] travel_i (move.c) + [1113] destroy_cmd [1602] mtype_get_param [147] travel_route (move.c) + [1697] destroy_curse [835] name_cmd [609] travelthru_add + [1230] destroy_road (build.c) [803] name_unit [180] travelthru_cansee + [392] destroyfaction [788] natural_armor [41] travelthru_map + [307] dfindhash [1273] nb_armor (volcano.c) [1201] treeman_neighbour (monsters.c) + [787] dice [1734] new_armortype [1783] trigger_changefaction + [409] dice_rand [705] new_border [1297] trigger_changerace + [1670] dict_get [1059] new_building [1891] trigger_giveitem + [1675] dict_init (dict.c) [1565] new_group [1752] trigger_killunit + [1671] dict_name [1739] new_luxurytype [1892] trigger_shock + [1676] dict_read (dict.c) [1427] new_node (pathfinder.c) [1753] trigger_timeout + [1677] dict_write (dict.c) [1712] new_potiontype [677] trollbelts (battle.c) + [1508] dir_invert [275] new_region [1225] try_rename (laws.c) + [771] disable_feature (jsonconf.c) [1229] new_ship [1554] tsf_find (crmessage.c) + [999] disband_men [282] new_units [1705] tsf_register + [859] display_cmd [1703] new_weapontype [1548] tt_find + [1054] display_item (laws.c) [1263] newcontainerid [1715] tt_register + [1090] display_potion (laws.c) [594] newline [347] u_description + [963] display_race (laws.c) [1359] newterrain [919] u_geteffstealth + [241] dissolve_units (randenc.c) [319] newunitid [951] u_hasspell + [599] distance [601] next_region (move.c) [257] u_irace + [80] do_attack [1758] nextlocale [89] u_race + [64] do_battle [1333] nmr_death (laws.c) [1460] u_set_building + [63] do_battles [878] nmr_warnings [1485] u_set_ship + [825] do_combatmagic [376] normalvariate [1199] u_seteffstealth + [702] do_combatspell (battle.c) [141] nr_building (report.c) [1111] u_setfaction + [250] do_contact (laws.c) [48] nr_curses (report.c) [1389] u_setrace + [128] do_enter [401] nr_curses_i (report.c) [692] ualias + [648] do_extra_spell (battle.c) [25] nr_render [927] ucontact + [1062] do_fumble (magic.c) [113] nr_section [109] ufindhash + [941] do_potion (alchemy.c) [111] nr_ship (report.c) [1133] ugetpotionuse + [351] do_recruiting (economy.c) [507] nr_spell [667] uhash + [515] do_siege [732] nr_spell_syntax [314] unicode_ucs4_to_utf8 + [612] do_work (economy.c) [11] nr_unit (report.c) [1216] unicode_utf8_strcasecmp + [1397] done_learning (study.c) [1232] nrand (monsters.c) [177] unicode_utf8_to_ucs4 + [1126] dracoid_name (names.c) [98] nrt_find [1684] unit_addorder + [516] dragon_affinity_value (monsters.c) [883] nrt_register [709] unit_can_study + [1095] dragon_name (names.c) [1524] nrt_section [427] unit_get_spellbook + [850] drain_exp [443] nrt_string [1735] unit_gethp + [1053] drift_target [723] ntimespprob [332] unit_getname + [490] drifting_ships (move.c) [14] old_race [758] unit_getspell + [394] drown [1381] oldcursename [1577] unit_has_cursed_item (give.c) + [468] eaten_by_monster (monster.c) [1240] oldfamiliars (races.c) [136] unit_max_hp + [243] eatwhite [1596] oldterrain [1540] unit_setname + [255] eatwhitespace_c (parser.c) [470] omniscient [1391] unit_skill + [78] economics [1824] openlibs (bindings.c) [142] unitname + [334] eff_skill [176] opstack_pop [46] unitorders (save.c) + [845] eff_spelllevel [202] opstack_push [1167] unset_combatspell + [163] eff_stealth [370] orc_growth (randenc.c) [415] update_guards + [683] eff_weight (move.c) [615] out_faction (summary.c) [551] update_interval + [100] effskill [1002] overload (move.c) [605] update_lighthouse + [504] effskill_study [1295] overload_start (move.c) [270] update_long_order + [1801] enable_keyword [676] owner_buildingtyp [1155] update_nmrs + [814] end_potion (alchemy.c) [1393] owner_change [1237] update_resource (resources.c) + [1512] enoughsailors [311] pack_int (binarystore.c) [1457] update_resources + [145] enter_1 (laws.c) [1688] pack_keyval [381] update_spells (laws.c) + [295] enter_2 (laws.c) [26] paragraph (report.c) [497] uprivate + [695] enter_building [1655] parameter_key (config.c) [1472] ur_add + [733] enter_ship [333] parse (translation.c) [436] urace + [665] entertain_cmd [1662] parse_ai (xmlreader.c) [1754] ursprung_x (plane.c) + [643] entertainmoney [1825] parse_args (main.c) [1755] ursprung_y (plane.c) + [1437] entrance_allowed (move.c) [1131] parse_buildings (xmlreader.c) [935] use_bloodpotion (item.c) + [1121] equip_items [1252] parse_calendar (xmlreader.c) [763] use_cmd + [775] equip_unit [1292] parse_config (main.c) [1149] use_default (resources.c) + [776] equip_unit_mask [1170] parse_equipment (xmlreader.c) [1119] use_healingpotion (item.c) + [1702] equipment_addspell [1637] parse_function (xmlreader.c) [765] use_item (laws.c) + [1802] equipment_done [852] parse_ids [39] use_pooled + [1747] equipment_setcallback [1317] parse_inifile (bindings.c) [801] use_potion + [1664] equipment_setitem [649] parse_int (translation.c) [1233] use_skillpotion + [1649] equipment_setskill [832] parse_messages (xmlreader.c) [1147] usetcontact + [59] eressea_read_game [117] parse_order [1078] usetpotionuse + [1346] eressea_run [1765] parse_param (xmlreader.c) [1041] usetprivate + [1624] eressea_version [1104] parse_races (xmlreader.c) [593] usiege + [76] eressea_write_game [1086] parse_resources (xmlreader.c) [1049] uunhash + [556] escape_string [1826] parse_rules (xmlreader.c) [1893] valid_race + [1182] eval_add (translation.c) [1305] parse_ships (xmlreader.c) [1051] validate_pirate (piracy.c) + [494] eval_building (reports.c) [1827] parse_spellbooks (xmlreader.c) [1627] var_copy_items (reports.c) + [608] eval_direction (reports.c) [1120] parse_spells (xmlreader.c) [734] var_copy_order (reports.c) + [398] eval_eq (translation.c) [86] parse_string (translation.c) [1439] var_copy_regions (move.c) + [685] eval_faction (reports.c) [864] parse_strings (xmlreader.c) [1632] var_copy_resources (reports.c) + [393] eval_if (translation.c) [42] parse_symbol (translation.c) [1454] var_copy_string (reports.c) + [268] eval_int (translation.c) [125] parse_token [1628] var_free_resources (reports.c) + [729] eval_int36 (reports.c) [220] parse_token_depr [1470] var_free_string (reports.c) + [517] eval_isnull (translation.c) [849] parser_end [1784] verbosity_to_flags (main.c) + [922] eval_localize (reports.c) [1506] parser_popstate [1255] verify_building (magic.c) + [539] eval_lt (translation.c) [1507] parser_pushstate [1704] verify_ship (magic.c) + [472] eval_order (reports.c) [1618] password_encode [1027] verify_targets (magic.c) + [882] eval_race (reports.c) [1610] password_verify [1028] verify_unit (magic.c) + [245] eval_region (reports.c) [431] path_exists [1894] version_no + [328] eval_resource (reports.c) [523] path_find [1525] visible_default (resources.c) + [907] eval_resources (reports.c) [1828] pathfinder_cleanup [68] visible_faction + [740] eval_ship (reports.c) [805] pay_spell [1022] volcano_destruction (volcano.c) + [671] eval_skill (reports.c) [1687] pcomp (summary.c) [1023] volcano_outbreak + [961] eval_spell (reports.c) [928] peasant_growth_factor (laws.c) [981] volcano_update + [634] eval_trail (reports.c) [984] peasant_luck_effect [174] wage + [369] eval_trailto (reports.c) [1277] peasant_luck_factor (laws.c) [403] walkingcapacity + [223] eval_unit (reports.c) [658] peasants (laws.c) [450] wang_hash + [1076] eval_unit_dative (reports.c) [795] personcapacity [168] weapon_effskill (battle.c) + [1102] eval_weight (reports.c) [660] piracy_cmd [221] weapon_skill (battle.c) + [49] expandbuying (economy.c) [1653] piracy_done (piracy.c) [1435] weapon_weight (battle.c) + [637] expandentertainment (economy.c) [1654] piracy_init (piracy.c) [459] weight + [816] expandloot (economy.c) [781] plagues [1130] wormhole_age (wormhole.c) + [197] expandorders (economy.c) [715] plain_name (terrain.c) [1238] wormhole_read (wormhole.c) + [349] expandrecruit (economy.c) [273] plan_dragon (monsters.c) [1785] wormhole_write (wormhole.c) + [93] expandselling (economy.c) [52] plan_monsters [1895] wormholes_register + [807] expandstealing (economy.c) [1411] plane_center_x [906] wormholes_update + [278] expandtax [1412] plane_center_y [1896] write_alliances + [277] expandwork (economy.c) [1379] plane_height [301] write_attribs + [455] f_get_alliance [1380] plane_width [1897] write_borders + [161] f_regionid [1184] plant (economy.c) [1383] write_building_reference + [477] f_regionid_s (reports.c) [1206] planttrees (economy.c) [622] write_buildingname + [451] faction_alive [1350] pnormalize [1382] write_faction_reference + [1543] faction_get_spellbook [1176] potion_luck (alchemy.c) [83] write_game + [382] faction_getmages (laws.c) [945] potion_water_of_life (alchemy.c) [1449] write_group (group.c) + [1357] faction_getorigin [1377] preferred_weapon (battle.c) [920] write_groups + [979] faction_setorigin [340] prepare_lighthouse (reports.c) [955] write_handler (event.c) + [1616] faction_setpassword [8] prepare_report [511] write_items + [247] factionname [1643] present (move.c) [1560] write_mage (magic.c) + [983] factionorders (save.c) [85] prices (report.c) [1467] write_of + [842] farcasting (magic.c) [616] print_fighters (battle.c) [121] write_order + [688] fbattlerecord (battle.c) [838] print_header (battle.c) [1480] write_owner (save.c) + [315] ffindhash (faction.c) [938] print_items (creport.c) [1623] write_password (save.c) + [1617] fhash [525] print_stats (battle.c) [1207] write_planes + [1012] fighters [7] process [1723] write_race_reference + [1553] find_argtype [6] processorders [1583] write_region_reference + [1496] find_bordertype [29] produce [280] write_regionname + [549] find_function (translation.c) [1829] produce_mallornseeds (seed.c) [3] write_reports + [1450] find_group (group.c) [994] produce_resource (helpers.c) [1135] write_score + [1217] find_groupbyname (group.c) [1725] produce_seeds (seed.c) [853] write_script (reports.c) + [967] find_piracy_target [322] produceexp [1523] write_seenspell (magic.c) + [1581] find_side [406] produceexp_days (study.c) [1386] write_ship_reference + [1513] find_spell [323] produceexp_ex [291] write_shipname + [304] find_variable (translation.c) [417] production [1769] write_skill (unitcurse.c) + [1462] findbuilding [917] promotion_cmd [303] write_spaces + [866] findbuildingtype [1713] pt_register (item.c) [964] write_spell_modifier (report.c) + [259] findfaction [112] ql_advance [1556] write_spellbook + [735] finditemtype [312] ql_find [1584] write_targetregion (targetregion.c) + [1665] findkeyword [362] ql_foreachx [689] write_translations (creport.c) + [753] findnewunit [138] ql_get [327] write_travelthru + [1241] findoption [448] ql_push [954] write_triggers + [458] findparam [156] ql_set_insert_ex [97] write_unit + [926] findparam_ex [258] qli_init [557] write_unit_reference + [457] findplane [192] qli_more [148] write_unitname + [1030] findrace [585] qli_next [762] writefaction + [420] findregion [276] quit [82] writegame + [1463] findregionbyid [779] r_addmessage [208] writeorder (save.c) + [1181] findresourcetype [783] r_astral_to_standard [1074] writepasswd + [1483] findship [474] r_connect [519] writeregion + [869] findshiptype [1404] r_demand [1253] writeturn (summary.c) + [1586] findskill [360] r_getmessages [178] wrptr + [501] findtoken [1446] r_insectstalled [1532] xml_bvalue + [123] findunit [199] r_isforest [1520] xml_cleanup_string (xmlreader.c) + [279] findunitg [1413] r_setdemand [1898] xml_done + [991] findunitr [1067] r_standard_to_astral [1599] xml_fvalue + [33] finish_reports [905] race_namegen [1533] xml_ivalue + [485] firstregion (reports.c) [1766] racelist_insert [1736] xml_readarmor (xmlreader.c) + [638] flee (battle.c) [133] racename [1183] xml_readconstruction + [408] fleechance [222] raceprefix [1107] xml_readitem (xmlreader.c) + [1465] flying_ship [1065] random_growl [1745] xml_readluxury (xmlreader.c) + [1803] flyingship_age (flyingship.c) [754] random_move_chance (monsters.c) [1714] xml_readpotion (xmlreader.c) + [749] follow_ship [153] random_neighbour (monsters.c) [1186] xml_readrequirements (xmlreader.c) + [331] follow_unit [1174] random_unit (chaos.c) [863] xml_readstrings (xmlreader.c) + [1280] forbiddenid [91] randomevents [887] xml_readtext (xmlreader.c) + [1093] forget_cmd (economy.c) [256] rc_changed [1266] xml_readweapon (xmlreader.c) + [1371] free_arg (message.c) [1661] rc_create [1726] xml_register_callback + [1630] free_battle [15] rc_find [1727] xml_spell (xmlreader.c) + [1609] free_castorder [16] rc_find_i (race.c) [1056] zombie_name (names.c) + [1541] free_castorders [1105] rc_get_or_create [32] + [574] free_config [364] rc_name [463] + [1580] free_fighter (battle.c) [260] rc_name_s [953] + [1804] free_functions [140] rc_skillmod [797] + [1805] free_functions (translation.c) [830] rc_specialdamage (battle.c) [30] + [1750] free_group [1681] rcomp (summary.c) From 2c0f0bfc1e816288ae3d65983b4b9befd6424e3c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Sep 2016 15:51:11 +0200 Subject: [PATCH 095/675] reduce get_race calls by a few more --- src/economy.c | 16 +++++++++++----- src/magic.c | 9 +++++++-- src/upkeep.c | 11 ++++++++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/economy.c b/src/economy.c index caa771142..06b8c0f84 100644 --- a/src/economy.c +++ b/src/economy.c @@ -3106,11 +3106,17 @@ void produce(struct region *r) request *nextworker = workers; static int bt_cache; static const struct building_type *caravan_bt; - + static int rc_cache; + static const race *rc_spell, *rc_insect, *rc_aquarian; + if (bt_changed(&bt_cache)) { caravan_bt = bt_find("caravan"); } - + if (rc_changed(&rc_cache)) { + rc_spell = get_race(RC_SPELL); + rc_insect = get_race(RC_INSECT); + rc_aquarian = get_race(RC_AQUARIAN); + } assert(r); /* das sind alles befehle, die 30 tage brauchen, und die in thisorder @@ -3145,10 +3151,10 @@ void produce(struct region *r) bool trader = false; keyword_t todo; - if (u_race(u) == get_race(RC_SPELL) || fval(u, UFL_LONGACTION)) + if (u_race(u) == rc_spell || fval(u, UFL_LONGACTION)) continue; - if (u_race(u) == get_race(RC_INSECT) && r_insectstalled(r) && + if (u_race(u) == rc_insect && r_insectstalled(r) && !is_cursed(u->attribs, C_KAELTESCHUTZ, 0)) continue; @@ -3185,7 +3191,7 @@ void produce(struct region *r) if (todo == NOKEYWORD) continue; - if (fval(r->terrain, SEA_REGION) && u_race(u) != get_race(RC_AQUARIAN) + if (fval(r->terrain, SEA_REGION) && u_race(u) != rc_aquarian && !(u_race(u)->flags & RCF_SWIM) && todo != K_STEAL && todo != K_SPY && todo != K_SABOTAGE) continue; diff --git a/src/magic.c b/src/magic.c index 1c4ca2adb..83899f583 100644 --- a/src/magic.c +++ b/src/magic.c @@ -1363,7 +1363,9 @@ static void do_fumble(castorder * co) int level = co->level; int duration; double effect; - + static const race *rc_toad; + static int rc_cache; + ADDMSG(&u->faction->msgs, msg_message("patzer", "unit region spell", u, r, sp)); switch (rng_int() % 10) { @@ -1394,7 +1396,10 @@ static void do_fumble(castorder * co) duration = rng_int() % level / 2; if (duration < 2) duration = 2; add_trigger(&u->attribs, "timer", trigger_timeout(duration, trestore)); - u_setrace(u, get_race(RC_TOAD)); + if (rc_changed(&rc_cache)) { + rc_toad = get_race(RC_TOAD); + } + u_setrace(u, rc_toad); u->irace = NULL; ADDMSG(&r->msgs, msg_message("patzer6", "unit region spell", u, r, sp)); break; diff --git a/src/upkeep.c b/src/upkeep.c index a9feca37a..198ce73df 100644 --- a/src/upkeep.c +++ b/src/upkeep.c @@ -115,7 +115,12 @@ void get_food(region * r) unit *u; int peasantfood = rpeasants(r) * 10; int food_rules = config_get_int("rules.food.flags", 0); - + static const race *rc_demon; + static int rc_cache; + + if (rc_changed(&rc_cache)) { + rc_demon = get_race(RC_DAEMON); + } if (food_rules & FOOD_IS_FREE) { return; } @@ -228,7 +233,7 @@ void get_food(region * r) * bei fehlenden Bauern den Dmon hungern lassen */ for (u = r->units; u; u = u->next) { - if (u_race(u) == get_race(RC_DAEMON)) { + if (u_race(u) == rc_demon) { int hungry = u->number; /* use peasantblood before eating the peasants themselves */ @@ -250,7 +255,7 @@ void get_food(region * r) if (donor == u) donor = r->units; while (donor != NULL) { - if (u_race(donor) == get_race(RC_DAEMON) && donor != u) { + if (u_race(donor) == rc_demon && donor != u) { if (get_effect(donor, pt_blood)) { /* if he's in our faction, drain him: */ if (donor->faction == u->faction) From 5ccb2c3dc81a80e3cec11be216cf6956dcde19f9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Sep 2016 18:28:37 +0200 Subject: [PATCH 096/675] remove recruitcost from non-player races. make score not call old_race. fix orcs don't get scored. https://bugs.eressea.de/view.php?id=2241 delete some unused race-enums. delete centaurs. --- res/core/de/strings.xml | 17 ---- res/core/fr/strings.xml | 6 -- res/e3a/races.xml | 6 +- res/eressea/equipment.xml | 4 - res/eressea/races.xml | 160 ++++++++++++-------------------------- src/kernel/race.c | 6 +- src/kernel/race.h | 19 +---- src/modules/score.c | 11 +-- src/races/races.c | 3 - 9 files changed, 67 insertions(+), 165 deletions(-) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 8b207e6d9..4582644c7 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -2456,23 +2456,6 @@ skeleton - - Zentaur - centaur - - - Zentauren - centaurs - - - Zentauren - centaurs - - - Zentauren - centaur - - Schattenritter shadow knight diff --git a/res/core/fr/strings.xml b/res/core/fr/strings.xml index 8acc1d89f..d1801b338 100644 --- a/res/core/fr/strings.xml +++ b/res/core/fr/strings.xml @@ -1894,12 +1894,6 @@ aigle - - centaures - - - centaure - squelettes diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 99c3420af..2b0f68b9d 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -890,7 +890,7 @@ - + @@ -898,7 +898,7 @@ - + @@ -909,7 +909,7 @@ - + diff --git a/res/eressea/equipment.xml b/res/eressea/equipment.xml index d78705a06..f35505bc0 100644 --- a/res/eressea/equipment.xml +++ b/res/eressea/equipment.xml @@ -68,10 +68,6 @@ - - - - diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 513797d8d..b3f384923 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -27,7 +27,7 @@ - + @@ -61,7 +61,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -118,7 +118,7 @@ - + @@ -148,7 +148,7 @@ - + @@ -178,7 +178,7 @@ - + @@ -209,7 +209,7 @@ - + @@ -244,7 +244,7 @@ - + @@ -275,7 +275,7 @@ - + @@ -308,7 +308,7 @@ - + @@ -339,7 +339,7 @@ - + @@ -370,7 +370,7 @@ - + @@ -401,7 +401,7 @@ - + @@ -431,7 +431,7 @@ - + @@ -463,7 +463,7 @@ - + @@ -495,7 +495,7 @@ - + @@ -525,7 +525,7 @@ - + @@ -558,7 +558,7 @@ - + @@ -589,17 +589,17 @@ - + - + + regaura="1.000000" weight="100" capacity="540" speed="1.000000" hp="20" damage="0d0" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" invinciblenonmagic="yes"> @@ -607,7 +607,7 @@ - + @@ -676,41 +676,41 @@ - + - + - + - + - + - + - + @@ -724,13 +724,13 @@ - + - + @@ -742,7 +742,7 @@ - + @@ -755,7 +755,7 @@ - + @@ -769,13 +769,13 @@ - + - + @@ -978,7 +978,7 @@ - + @@ -1011,11 +1011,11 @@ - + - + @@ -1023,7 +1023,7 @@ - + @@ -1037,7 +1037,7 @@ - + @@ -1055,7 +1055,7 @@ - + @@ -1073,7 +1073,7 @@ - + @@ -1089,7 +1089,7 @@ - + @@ -1104,7 +1104,7 @@ - + @@ -1119,7 +1119,7 @@ - + @@ -1134,40 +1134,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + @@ -1209,36 +1181,6 @@ - @@ -1328,7 +1270,7 @@ - + @@ -1342,13 +1284,13 @@ - + - + @@ -1357,7 +1299,7 @@ - + diff --git a/src/kernel/race.c b/src/kernel/race.c index b7b466cc8..4003c701e 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -65,13 +65,13 @@ static const char *racenames[MAXRACES] = { "dwarf", "elf", NULL, "goblin", "human", "troll", "demon", "insect", "halfling", "cat", "aquarian", "orc", "snotling", "undead", "illusion", "youngdragon", "dragon", "wyrm", "ent", "catdragon", "dracoid", - "special", "spell", "irongolem", "stonegolem", "shadowdemon", + NULL, "spell", "irongolem", "stonegolem", "shadowdemon", "shadowmaster", "mountainguard", "alp", "toad", "braineater", "peasant", "wolf", NULL, NULL, NULL, NULL, "songdragon", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "seaserpent", - "shadowknight", "centaur", "skeleton", "skeletonlord", "zombie", - "juju-zombie", "ghoul", "ghast", "museumghost", "gnome", "template", + "shadowknight", NULL, "skeleton", "skeletonlord", "zombie", + "juju-zombie", "ghoul", "ghast", NULL, NULL, "template", "clone" }; diff --git a/src/kernel/race.h b/src/kernel/race.h index f42e769a6..17c2bc61f 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -52,37 +52,31 @@ extern "C" { RC_ELF, RC_GOBLIN = 3, RC_HUMAN, - RC_TROLL, RC_DAEMON, RC_INSECT, RC_HALFLING, RC_CAT, - RC_AQUARIAN, RC_ORC, RC_SNOTLING, RC_UNDEAD, RC_ILLUSION, - RC_FIREDRAGON, RC_DRAGON, RC_WYRM, RC_TREEMAN, RC_BIRTHDAYDRAGON, - RC_DRACOID, - RC_SPECIAL, - RC_SPELL, + + RC_SPELL = 22, RC_IRONGOLEM, RC_STONEGOLEM, - RC_SHADOW, RC_SHADOWLORD, RC_IRONKEEPER, RC_ALP, RC_TOAD, - RC_HIRNTOETER, RC_PEASANT, RC_WOLF = 32, @@ -91,20 +85,15 @@ extern "C" { RC_SEASERPENT = 51, RC_SHADOWKNIGHT, - RC_CENTAUR, - RC_SKELETON, + RC_SKELETON = 54, RC_SKELETON_LORD, RC_ZOMBIE, RC_ZOMBIE_LORD, RC_GHOUL, RC_GHOUL_LORD, - - RC_MUS_SPIRIT, - RC_GNOME, - RC_TEMPLATE, + RC_TEMPLATE = 62, RC_CLONE, - MAXRACES, NORACE = -1 } race_t; diff --git a/src/modules/score.c b/src/modules/score.c index 2fd3cf230..89cf90655 100644 --- a/src/modules/score.c +++ b/src/modules/score.c @@ -38,6 +38,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include /* libc includes */ +#include #include #include @@ -105,14 +106,14 @@ void score(void) int itemscore = 0; int i; faction *f = u->faction; + const race *rc = u_race(u); - if (f == NULL || u_race(u) == get_race(RC_SPELL) - || u_race(u) == get_race(RC_BIRTHDAYDRAGON)) { + if (f == NULL) { continue; } - - if (old_race(u_race(u)) <= RC_AQUARIAN) { - f->score += (u_race(u)->recruitcost * u->number) / 50; + else if (rc->recruitcost>0) { + assert(playerrace(rc)); + f->score += (rc->recruitcost * u->number) / 50; } f->score += get_money(u) / 50; for (itm = u->items; itm; itm = itm->next) { diff --git a/src/races/races.c b/src/races/races.c index 38d69ac3e..68b3c5ae2 100644 --- a/src/races/races.c +++ b/src/races/races.c @@ -84,9 +84,6 @@ static void equip_newunits(const struct equipment *eq, struct unit *u) u_set_ship(u, sh); } break; - case RC_CENTAUR: - rsethorses(r, 250 + rng_int() % 51 + rng_int() % 51); - break; default: break; } From 37a5954c20575eba347d05493215597d6e1d9f9c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Sep 2016 20:11:14 +0200 Subject: [PATCH 097/675] NPC races cannot be recruited (and provide no score). --- res/eressea/races.xml | 4 ++-- src/kernel/xmlreader.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/res/eressea/races.xml b/res/eressea/races.xml index b3f384923..7c3a5ab0c 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -671,7 +671,7 @@ - + @@ -717,7 +717,7 @@ - + diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 1dd822130..68f62d11f 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1673,8 +1673,10 @@ static int parse_races(xmlDocPtr doc) rc->at_bonus = (char)xml_ivalue(node, "attackmodifier", rc->at_bonus); rc->df_bonus = (char)xml_ivalue(node, "defensemodifier", rc->df_bonus); - if (!xml_bvalue(node, "playerrace", false)) + if (!xml_bvalue(node, "playerrace", false)) { + assert(rc->recruitcost == 0); rc->flags |= RCF_NPC; + } if (xml_bvalue(node, "scarepeasants", false)) rc->flags |= RCF_SCAREPEASANTS; if (!xml_bvalue(node, "cansteal", true)) From c606a9ac4d75073310ef6634f4c9309f933f0b58 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Sep 2016 20:22:23 +0200 Subject: [PATCH 098/675] extract RC_SPELL handling into a small function, minimize get_race calls. --- src/reports.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/reports.c b/src/reports.c index 681802fd3..ff076a866 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1308,6 +1308,17 @@ static void cb_add_seen(region *r, unit *u, void *cbdata) { } } +static bool unit_cansee(const unit *u) +{ + const race *rc = u_race(u); + static const race *rc_spell; + static int rc_cache; + if (rc_changed(&rc_cache)) { + rc_spell = get_race(RC_SPELL); + } + return (rc!=rc_spell || u->number == RS_FARVISION); +} + /** set region.seen based on visibility by one faction. * * this function may also update ctx->last and ctx->first for potential @@ -1344,7 +1355,7 @@ void prepare_report(report_context *ctx, faction *f) u = building_owner(b); if (u && u->faction==f) { prepare_lighthouse(b, ctx); - if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { + if (unit_cansee(u)) { add_seen_nb(f, r, seen_unit); } } @@ -1355,7 +1366,7 @@ void prepare_report(report_context *ctx, faction *f) } for (u = r->units; u; u = u->next) { if (u->faction==f) { - if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { + if (unit_cansee(u)) { add_seen_nb(f, r, seen_unit); } if (fval(r, RF_LIGHTHOUSE)) { From 423e2937456c0956fac09808c6d28a0a88edab13 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 23 Sep 2016 20:36:57 +0200 Subject: [PATCH 099/675] some more config lookup caching --- src/kernel/ally.c | 26 ++++++++++++++------------ src/kernel/config.c | 7 +++++-- src/kernel/faction.c | 22 +++++++++++++++++----- src/kernel/skills.c | 8 ++++++-- src/kernel/unit.c | 17 +++++++++++------ src/magic.c | 6 +++++- src/monsters.c | 7 ++++++- src/study.c | 12 ++++++++++-- src/teleport.c | 8 ++++++-- 9 files changed, 80 insertions(+), 33 deletions(-) diff --git a/src/kernel/ally.c b/src/kernel/ally.c index 3152ab4b7..2bb980dd0 100644 --- a/src/kernel/ally.c +++ b/src/kernel/ally.c @@ -133,19 +133,21 @@ attrib_type at_npcfaction = { */ int HelpMask(void) { - const char *str = config_get("rules.help.mask"); - int rule = 0; - if (str != NULL) { - char *sstr = _strdup(str); - char *tok = strtok(sstr, " "); - while (tok) { - rule |= ally_flag(tok, -1); - tok = strtok(NULL, " "); + static int config, rule = 0; + if (config_changed(&config)) { + const char *str = config_get("rules.help.mask"); + if (str != NULL) { + char *sstr = _strdup(str); + char *tok = strtok(sstr, " "); + while (tok) { + rule |= ally_flag(tok, -1); + tok = strtok(NULL, " "); + } + free(sstr); + } + else { + rule = HELP_ALL; } - free(sstr); - } - else { - rule = HELP_ALL; } return rule; } diff --git a/src/kernel/config.c b/src/kernel/config.c index aaecd2c91..5921535c7 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -731,7 +731,7 @@ int create_directories(void) { double get_param_flt(const struct param *p, const char *key, double def) { - const char *str = get_param(p, key); + const char *str = p ? get_param(p, key) : NULL; return str ? atof(str) : def; } @@ -862,7 +862,10 @@ int cmp_current_owner(const building * b, const building * a) bool rule_stealth_other(void) { - int rule = config_get_int("stealth.faction.other", 1); + static int rule, config; + if (config_changed(&config)) { + rule = config_get_int("stealth.faction.other", 1); + } return rule != 0; } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 823932f88..0ccf62f52 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -796,14 +796,26 @@ attrib_type at_maxmagicians = { int max_magicians(const faction * f) { - int m = config_get_int("rules.maxskills.magic", MAXMAGICIANS); - attrib *a; + static int rule, config, rc_cache; + static const race *rc_elf; + int m; - if ((a = a_find(f->attribs, &at_maxmagicians)) != NULL) { - m = a->data.i; + if (config_changed(&config)) { + rule = config_get_int("rules.maxskills.magic", MAXMAGICIANS); } - if (f->race == get_race(RC_ELF)) + m = rule; + if (f->attribs) { + attrib *a = a_find(f->attribs, &at_maxmagicians); + if (a) { + m = a->data.i; + } + } + if (rc_changed(&rc_cache)) { + rc_elf = get_race(RC_ELF); + } + if (f->race == rc_elf) { ++m; + } return m; } diff --git a/src/kernel/skills.c b/src/kernel/skills.c index 9a6c0f1d7..17e1194c1 100644 --- a/src/kernel/skills.c +++ b/src/kernel/skills.c @@ -184,9 +184,13 @@ void sk_set(skill * sv, int level) sv->level = level; } -static int rule_random_progress(void) +static bool rule_random_progress(void) { - return config_get_int("study.random_progress", 1); + static int rule, config; + if (config_changed(&config)) { + rule = config_get_int("study.random_progress", 1); + } + return rule != 0; } int skill_weeks(int level) diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 4623e895e..c5172cafc 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -883,15 +883,16 @@ void leave_building(unit * u) bool can_leave(unit * u) { - int rule_leave; + static int config; + static bool rule_leave; if (!u->building) { return true; } - - rule_leave = config_get_int("rules.move.owner_leave", 0); - - if (rule_leave != 0 && u->building && u == building_owner(u->building)) { + if (config_changed(&config)) { + rule_leave = config_get_int("rules.move.owner_leave", 0) != 0; + } + if (rule_leave && u->building && u == building_owner(u->building)) { return false; } return true; @@ -1721,9 +1722,13 @@ int unit_max_hp(const unit * u) { int h; double p; - int rule_stamina = config_get_int("rules.stamina", STAMINA_AFFECTS_HP); + static int config; + static int rule_stamina; h = u_race(u)->hitpoints; + if (config_changed(&config)) { + rule_stamina = config_get_int("rules.stamina", STAMINA_AFFECTS_HP); + } if (rule_stamina & 1) { p = pow(effskill(u, SK_STAMINA, u->region) / 2.0, 1.5) * 0.2; h += (int)(h * p + 0.5); diff --git a/src/magic.c b/src/magic.c index 83899f583..bcf3403aa 100644 --- a/src/magic.c +++ b/src/magic.c @@ -225,7 +225,11 @@ static void free_mage(attrib * a) bool FactionSpells(void) { - return config_get_int("rules.magic.factionlist", 0) != 0; + static int config, rule; + if (config_changed(&config)) { + rule = config_get_int("rules.magic.factionlist", 0); + } + return rule != 0; } void read_spells(struct quicklist **slistp, magic_t mtype, diff --git a/src/monsters.c b/src/monsters.c index 78999e015..ecf768cab 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -84,7 +84,12 @@ static void give_peasants(unit *u, const item_type *itype, int reduce) { } static double random_move_chance(void) { - return config_get_flt("rules.monsters.random_move_chance", MOVECHANCE); + static double rule; + static int config; + if (config_changed(&config)) { + rule = config_get_flt("rules.monsters.random_move_chance", MOVECHANCE); + } + return rule; } static void reduce_weight(unit * u) diff --git a/src/study.c b/src/study.c index eb5cec12d..027f67dde 100644 --- a/src/study.c +++ b/src/study.c @@ -800,7 +800,11 @@ int study_cmd(unit * u, order * ord) } static int produceexp_days(void) { - return config_get_int("study.produceexp", 10); + static int config, rule; + if (config_changed(&config)) { + rule = config_get_int("study.produceexp", 10); + } + return rule; } void produceexp_ex(struct unit *u, skill_t sk, int n, learn_fun learn) @@ -863,7 +867,11 @@ void demon_skillchange(unit *u) if (fval(u, UFL_HUNGER)) { /* hungry demons only go down, never up in skill */ - int rule_hunger = config_get_int("hunger.demon.skill", 0) != 0; + static int config; + static bool rule_hunger; + if (config_changed(&config)) { + rule_hunger = config_get_int("hunger.demon.skill", 0) != 0; + } if (rule_hunger) { upchance = 0; downchance = 15; diff --git a/src/teleport.c b/src/teleport.c index 5b7f71831..c7e775345 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -176,8 +176,12 @@ bool is_astral(const region * r) plane *get_astralplane(void) { plane *astralspace = 0; - int rule_astralplane = config_get_int("modules.astralspace", 1); - + static int config; + static bool rule_astralplane; + + if (config_changed(&config)) { + rule_astralplane = config_get_int("modules.astralspace", 1) != 0; + } if (!rule_astralplane) { return NULL; } From 42c44724f8d1b436d23041be16d00acd9d01cfbb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 24 Sep 2016 17:29:55 +0200 Subject: [PATCH 100/675] testing lazy find_spell calls for equipment configuration --- src/kernel/equipment.c | 42 ++++++++++++++++++++++++++----------- src/kernel/equipment.h | 4 ++-- src/kernel/equipment.test.c | 2 +- src/kernel/xmlreader.c | 20 +++++++----------- 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index 424352347..8266ada9a 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -25,7 +25,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "unit.h" #include "faction.h" #include "race.h" -#include "spellbook.h" +#include "spell.h" /* util includes */ #include @@ -86,13 +86,20 @@ void equipment_setskill(equipment * eq, skill_t sk, const char *value) } } -void equipment_addspell(equipment * eq, struct spell * sp, int level) +typedef struct lazy_spell { + char *name; + struct spell *sp; + int level; +} lazy_spell; + +void equipment_addspell(equipment * eq, const char * name, int level) { if (eq) { - if (!eq->spellbook) { - eq->spellbook = create_spellbook(0); - } - spellbook_add(eq->spellbook, sp, level); + lazy_spell *ls = malloc(sizeof(lazy_spell)); + ls->sp = NULL; + ls->level = level; + ls->name = _strdup(name); + ql_push(&eq->spells, ls); } } @@ -148,13 +155,18 @@ void equip_unit_mask(struct unit *u, const struct equipment *eq, int mask) } if (mask & EQUIP_SPELLS) { - if (eq->spellbook) { - quicklist * ql = eq->spellbook->spells; + if (eq->spells) { + quicklist * ql = eq->spells; int qi; sc_mage * mage = get_mage(u); for (qi = 0; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi); + lazy_spell *sbe = (lazy_spell *)ql_get(ql, qi); + if (!sbe->sp) { + sbe->sp = find_spell(sbe->name); + free(sbe->name); + sbe->name = NULL; + } unit_add_spell(u, mage, sbe->sp, sbe->level); } } @@ -224,6 +236,12 @@ void equip_items(struct item **items, const struct equipment *eq) } } +void free_ls(void *arg) { + lazy_spell *ls = (lazy_spell*)arg; + free(ls->name); + free(ls); +} + void equipment_done(void) { equipment **eqp = &equipment_sets; while (*eqp) { @@ -231,9 +249,9 @@ void equipment_done(void) { equipment *eq = *eqp; *eqp = eq->next; free(eq->name); - if (eq->spellbook) { - spellbook_clear(eq->spellbook); - free(eq->spellbook); + if (eq->spells) { + ql_foreach(eq->spells, free_ls); + ql_free(eq->spells); } while (eq->items) { itemdata *next = eq->items->next; diff --git a/src/kernel/equipment.h b/src/kernel/equipment.h index 11511d99a..5c7b3407b 100644 --- a/src/kernel/equipment.h +++ b/src/kernel/equipment.h @@ -48,7 +48,7 @@ extern "C" { char *name; struct itemdata *items; char *skills[MAXSKILLS]; - struct spellbook *spellbook; + struct quicklist *spells; struct subset *subsets; struct equipment *next; void(*callback) (const struct equipment *, struct unit *); @@ -63,7 +63,7 @@ extern "C" { const struct item_type *itype, const char *value); void equipment_setskill(struct equipment *eq, skill_t sk, const char *value); - void equipment_addspell(struct equipment *eq, struct spell *sp, int level); + void equipment_addspell(struct equipment *eq, const char *name, int level); void equipment_setcallback(struct equipment *eq, void(*callback) (const struct equipment *, struct unit *)); diff --git a/src/kernel/equipment.test.c b/src/kernel/equipment.test.c index 490a44a78..2911af1ea 100644 --- a/src/kernel/equipment.test.c +++ b/src/kernel/equipment.test.c @@ -34,7 +34,7 @@ void test_equipment(CuTest * tc) equipment_setitem(eq, it_horses, "1"); equipment_setskill(eq, SK_MAGIC, "5"); - equipment_addspell(eq, sp, 1); + equipment_addspell(eq, sp->sname, 1); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); equip_unit_mask(u, eq, EQUIP_ALL); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 68f62d11f..66825a9b8 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1191,22 +1191,18 @@ static void add_spells(equipment * eq, xmlNodeSetPtr nsetItems) for (i = 0; i != nsetItems->nodeNr; ++i) { xmlNodePtr node = nsetItems->nodeTab[i]; xmlChar *propValue; - struct spell *sp; + int level; + const char *name; propValue = xmlGetProp(node, BAD_CAST "name"); assert(propValue != NULL); - sp = find_spell((const char *)propValue); - if (!sp) { - log_error("no spell '%s' for equipment-set '%s'\n", (const char *)propValue, eq->name); + name = (const char *)propValue; + level = xml_ivalue(node, "level", 0); + if (level > 0) { + equipment_addspell(eq, name, level); } else { - int level = xml_ivalue(node, "level", 0); - if (level > 0) { - equipment_addspell(eq, sp, level); - } - else { - log_error("spell '%s' for equipment-set '%s' has no level\n", sp->sname, eq->name); - } + log_error("spell '%s' for equipment-set '%s' has no level\n", name, eq->name); } xmlFree(propValue); } @@ -1331,7 +1327,7 @@ static int parse_equipment(xmlDocPtr doc) xmlXPathFreeObject(xpathResult); xpathResult = xmlXPathEvalExpression(BAD_CAST "spell", xpath); - assert(!eq->spellbook); + assert(!eq->spells); add_spells(eq, xpathResult->nodesetval); xmlXPathFreeObject(xpathResult); From 10806a1d95603965aa1071e9d32a7456c18abe26 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 27 Sep 2016 08:25:58 +0200 Subject: [PATCH 101/675] add a failing test for bug 2234 --- src/economy.test.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/economy.test.c b/src/economy.test.c index fbcc720bc..c1459544e 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -246,6 +246,7 @@ static void test_maintain_buildings(CuTest *tc) { building *b; building_type *btype; unit *u; + faction *f; maintenance *req; item_type *itype; @@ -253,7 +254,8 @@ static void test_maintain_buildings(CuTest *tc) { btype = test_create_buildingtype("Hort"); btype->maxsize = 10; r = test_create_region(0, 0, 0); - u = test_create_unit(test_create_faction(0), r); + f = test_create_faction(0); + u = test_create_unit(f, r); b = test_create_building(r, btype); itype = test_create_itemtype("money"); b->size = btype->maxsize; @@ -263,6 +265,7 @@ static void test_maintain_buildings(CuTest *tc) { b->flags = 0; maintain_buildings(r); CuAssertIntEquals(tc, BLD_MAINTAINED, fval(b, BLD_MAINTAINED)); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "maintenance_nowork")); req = calloc(2, sizeof(maintenance)); req[0].number = 100; @@ -273,6 +276,8 @@ static void test_maintain_buildings(CuTest *tc) { b->flags = 0; maintain_buildings(r); CuAssertIntEquals(tc, 0, fval(b, BLD_MAINTAINED)); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "maintenance_nowork")); + CuAssertPtrEquals(tc, 0, test_find_messagetype(r->msgs, "maintenance_noowner")); // we can afford to pay: i_change(&u->items, itype, 100); @@ -286,6 +291,8 @@ static void test_maintain_buildings(CuTest *tc) { b->flags = 0; maintain_buildings(r); CuAssertIntEquals(tc, 0, fval(b, BLD_MAINTAINED)); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "maintenance_nowork")); + CuAssertPtrNotNull(tc, test_find_messagetype(r->msgs, "maintenance_noowner")); test_cleanup(); } From f2d0d74e70b72941d60d358997fb69ee5b1156fa Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 27 Sep 2016 15:02:22 +0200 Subject: [PATCH 102/675] fix the test, except it doesn't fail anymore? --- src/economy.test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/economy.test.c b/src/economy.test.c index c1459544e..bbdd75df5 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -278,13 +278,15 @@ static void test_maintain_buildings(CuTest *tc) { CuAssertIntEquals(tc, 0, fval(b, BLD_MAINTAINED)); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "maintenance_nowork")); CuAssertPtrEquals(tc, 0, test_find_messagetype(r->msgs, "maintenance_noowner")); - + test_clear_messages(f); + // we can afford to pay: i_change(&u->items, itype, 100); b->flags = 0; maintain_buildings(r); CuAssertIntEquals(tc, BLD_MAINTAINED, fval(b, BLD_MAINTAINED)); CuAssertIntEquals(tc, 0, i_get(u->items, itype)); + test_clear_messages(f); // this building has no owner, it doesn't work: u_set_building(u, NULL); From fc6ab724a5762e710c5aa98c90b656e4bedf93a1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 27 Sep 2016 15:40:03 +0200 Subject: [PATCH 103/675] fix the economy test. no idea why it passes now? this doesn't represent the bug 2234 that I am trying to repro, yet. --- src/economy.test.c | 5 ++++- src/tests.c | 8 ++++++++ src/tests.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/economy.test.c b/src/economy.test.c index bbdd75df5..e7fb5e332 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -286,6 +286,9 @@ static void test_maintain_buildings(CuTest *tc) { maintain_buildings(r); CuAssertIntEquals(tc, BLD_MAINTAINED, fval(b, BLD_MAINTAINED)); CuAssertIntEquals(tc, 0, i_get(u->items, itype)); + CuAssertPtrEquals(tc, 0, r->msgs); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "maintenance_nowork")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "maintenance")); test_clear_messages(f); // this building has no owner, it doesn't work: @@ -293,7 +296,7 @@ static void test_maintain_buildings(CuTest *tc) { b->flags = 0; maintain_buildings(r); CuAssertIntEquals(tc, 0, fval(b, BLD_MAINTAINED)); - CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "maintenance_nowork")); + CuAssertPtrEquals(tc, 0, f->msgs); CuAssertPtrNotNull(tc, test_find_messagetype(r->msgs, "maintenance_noowner")); test_cleanup(); diff --git a/src/tests.c b/src/tests.c index 53f5ea470..177ad50fc 100644 --- a/src/tests.c +++ b/src/tests.c @@ -452,6 +452,14 @@ struct message * test_find_messagetype(struct message_list *msgs, const char *na return test_find_messagetype_ex(msgs, name, NULL); } +void test_clear_messagelist(message_list **msgs) { + if (*msgs) { + free_messagelist((*msgs)->begin); + free(*msgs); + *msgs = NULL; + } +} + void test_clear_messages(faction *f) { if (f->msgs) { free_messagelist(f->msgs->begin); diff --git a/src/tests.h b/src/tests.h index 10934c3d7..cbc2a2511 100644 --- a/src/tests.h +++ b/src/tests.h @@ -61,6 +61,7 @@ extern "C" { struct message * test_find_messagetype(struct message_list *msgs, const char *name); struct message * test_get_last_message(struct message_list *mlist); void test_clear_messages(struct faction *f); + void test_clear_messagelist(struct message_list **msgs); void assert_message(struct CuTest * tc, struct message *msg, char *name, int numpar); void assert_pointer_parameter(struct CuTest * tc, struct message *msg, int index, void *arg); From 04333e71d6b43dde21b09100017e291159ec76c7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 30 Sep 2016 19:46:29 +0000 Subject: [PATCH 104/675] working on a new tolua build step that supports 5.1 --- .gitmodules | 3 --- s/build | 5 ----- s/cmake-init | 13 ++++++++++++- src/kernel/config.c | 2 ++ tolua | 1 - 5 files changed, 14 insertions(+), 10 deletions(-) delete mode 160000 tolua diff --git a/.gitmodules b/.gitmodules index 81c45896e..2242a8068 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,6 +26,3 @@ path = storage url = https://github.com/ennorehling/storage.git branch = master -[submodule "tolua"] - path = tolua - url = https://github.com/ennorehling/tolua.git diff --git a/s/build b/s/build index 178fa4f43..b59804626 100755 --- a/s/build +++ b/s/build @@ -35,11 +35,6 @@ fi git submodule update -if [ -z `which tolua` ]; then -echo "build tolua" -cd $ROOT/tolua ; make -fi - echo "build eressea" cd $ROOT/$BUILD VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//') diff --git a/s/cmake-init b/s/cmake-init index 35378d6a5..481bfee80 100755 --- a/s/cmake-init +++ b/s/cmake-init @@ -44,7 +44,18 @@ ARGS=" -DCMAKE_MODULE_PATH=$ROOT/cmake/Modules \ path="$(which tolua)" if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then echo "tolua is not installed, building from source" - cd $ROOT/tolua ; make + cd $ROOT + if [ ! -d tolua ]; then + LUA_VERSION="5.2" + if [ ! -d /usr/include/lua5.2 ] ; then + LUA_VERSION="5.1" + fi + echo "fetching tolua ${LUA_VERSION} from github..." + git clone https://github.com/ennorehling/tolua-${LUA_VERSION}.git tolua + fi + echo "building tolua..." + cd tolua + make ARGS="$ARGS -DPC_TOLUA_DIR=$ROOT/tolua" else echo "tolua is $path" diff --git a/src/kernel/config.c b/src/kernel/config.c index 5921535c7..f7eb0e303 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -740,7 +740,9 @@ void kernel_done(void) /* calling this function releases memory assigned to static variables, etc. * calling it is optional, e.g. a release server will most likely not do it. */ +#ifdef USE_LIBXML2 xml_done(); +#endif attrib_done(); item_done(); message_done(); diff --git a/tolua b/tolua deleted file mode 160000 index 32cc6a3e7..000000000 --- a/tolua +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 32cc6a3e78238278bc5b1fb8566526558e5afdda From 95872aabb8dd7e3f21eb92b3d3d8335c05c6ba29 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 30 Sep 2016 20:00:48 +0000 Subject: [PATCH 105/675] try to install libtolua-dev on travis builders --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 003fb67ad..df0e62c84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ addons: - libsqlite3-dev - libxml2-dev - valgrind + - libtolua-dev os: - linux notifications: From 4fc4e8a5884bd94c4f029c606c44072bb7599e37 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 30 Sep 2016 22:21:26 +0200 Subject: [PATCH 106/675] change how lua version is determined to work with my mac --- s/cmake-init | 6 +++--- s/travis-build | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/s/cmake-init b/s/cmake-init index 481bfee80..2cd5b4834 100755 --- a/s/cmake-init +++ b/s/cmake-init @@ -46,9 +46,9 @@ if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then echo "tolua is not installed, building from source" cd $ROOT if [ ! -d tolua ]; then - LUA_VERSION="5.2" - if [ ! -d /usr/include/lua5.2 ] ; then - LUA_VERSION="5.1" + LUA_VERSION="5.1" + if [ -d /usr/include/lua5.2 ] || [ -d /usr/local/include/lua5.2 ]; then + LUA_VERSION="5.2" fi echo "fetching tolua ${LUA_VERSION} from github..." git clone https://github.com/ennorehling/tolua-${LUA_VERSION}.git tolua diff --git a/s/travis-build b/s/travis-build index 45db05c60..011e9e7de 100755 --- a/s/travis-build +++ b/s/travis-build @@ -18,7 +18,6 @@ cd tests set -e [ -z $BUILD ] && BUILD=Debug ; export BUILD -cmake --version s/cmake-init s/build cd $ROOT From cbd1e8c457b949c1ef9067367054890890135f0e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 1 Oct 2016 18:34:38 +0200 Subject: [PATCH 107/675] Fixing https://bugs.eressea.de/view.php?id=2234 remove the MTF_VITAL materials flag. remove remaining BLD_MAINTAINED vs BLD_WORKING code. --- res/core/common/buildings.xml | 26 +++++------ res/e3a/buildings.xml | 2 +- src/economy.c | 85 +++++++---------------------------- src/economy.test.c | 16 ++++--- src/kernel/building.h | 1 - src/kernel/jsonconf.c | 2 +- src/kernel/jsonconf.test.c | 4 +- src/kernel/xmlreader.c | 3 -- 8 files changed, 45 insertions(+), 94 deletions(-) diff --git a/res/core/common/buildings.xml b/res/core/common/buildings.xml index 423e90deb..cf183086b 100644 --- a/res/core/common/buildings.xml +++ b/res/core/common/buildings.xml @@ -23,7 +23,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -56,7 +56,7 @@ - + @@ -75,7 +75,7 @@ - + @@ -85,7 +85,7 @@ - + @@ -96,7 +96,7 @@ - + @@ -107,7 +107,7 @@ - + @@ -119,7 +119,7 @@ - + @@ -129,7 +129,7 @@ - + @@ -138,7 +138,7 @@ - + @@ -148,7 +148,7 @@ - + @@ -158,7 +158,7 @@ - + diff --git a/res/e3a/buildings.xml b/res/e3a/buildings.xml index 8ca30d27d..c1edbcc0b 100644 --- a/res/e3a/buildings.xml +++ b/res/e3a/buildings.xml @@ -19,7 +19,7 @@ - + diff --git a/src/economy.c b/src/economy.c index 06b8c0f84..099e9786d 100644 --- a/src/economy.c +++ b/src/economy.c @@ -717,7 +717,7 @@ static int maintain(building * b) { int c; region *r = b->region; - bool paid = true, work = true; + bool paid = true; unit *u; if (fval(b, BLD_MAINTAINED) || b->type == NULL || b->type->maintenance == NULL) { @@ -738,78 +738,40 @@ static int maintain(building * b) return 0; } } - for (c = 0; b->type->maintenance[c].number; ++c) { + for (c = 0; b->type->maintenance[c].number && paid; ++c) { const maintenance *m = b->type->maintenance + c; int need = m->number; if (fval(m, MTF_VARIABLE)) need = need * b->size; - if (u) { - /* first ist im ersten versuch true, im zweiten aber false! Das - * bedeutet, das in der Runde in die Region geschafften Resourcen - * nicht genutzt werden knnen, weil die reserviert sind! */ - need -= get_pooled(u, m->rtype, GET_DEFAULT, need); - } + need -= get_pooled(u, m->rtype, GET_DEFAULT, need); if (need > 0) { - if (!fval(m, MTF_VITAL)) - work = false; - else { - paid = false; - break; - } + paid = false; } } if (fval(b, BLD_DONTPAY)) { + ADDMSG(&r->msgs, msg_message("maintenance_nowork", "building", b)); return 0; } - u = building_owner(b); - if (!u) { + if (!paid) { + ADDMSG(&u->faction->msgs, msg_message("maintenancefail", "unit building", u, b)); + ADDMSG(&r->msgs, msg_message("maintenance_nowork", "building", b)); return 0; } for (c = 0; b->type->maintenance[c].number; ++c) { const maintenance *m = b->type->maintenance + c; - int need = m->number; + int cost = m->number; - if (fval(m, MTF_VARIABLE)) - need = need * b->size; - if (u) { - need -= get_pooled(u, m->rtype, GET_DEFAULT, need); - if (need > 0) { - work = false; - if (fval(m, MTF_VITAL)) { - paid = false; - break; - } - } + if (fval(m, MTF_VARIABLE)) { + cost = cost * b->size; } + cost -= + use_pooled(u, m->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, + cost); + assert(cost == 0); } - if (paid && c > 0) { - if (!work) { - ADDMSG(&u->faction->msgs, msg_message("maintenancefail", "unit building", u, b)); - return 0; - } - - for (c = 0; b->type->maintenance[c].number; ++c) { - const maintenance *m = b->type->maintenance + c; - int cost = m->number; - - if (!fval(m, MTF_VITAL) && !work) - continue; - if (fval(m, MTF_VARIABLE)) - cost = cost * b->size; - - cost -= - use_pooled(u, m->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, - cost); - assert(cost == 0); - } - if (work) { - ADDMSG(&u->faction->msgs, msg_message("maintenance", "unit building", u, b)); - return BLD_MAINTAINED; - } - } - ADDMSG(&u->faction->msgs, msg_message("maintenancefail", "unit building", u, b)); - return 0; + ADDMSG(&u->faction->msgs, msg_message("maintenance", "unit building", u, b)); + return BLD_MAINTAINED; } void maintain_buildings(region * r) @@ -824,19 +786,6 @@ void maintain_buildings(region * r) flags = maintain(b); } fset(b, flags); - - if (!fval(b, BLD_MAINTAINED)) { - unit *u = building_owner(b); - struct message *msg = msg_message("maintenance_nowork", "building", b); - if (u) { - add_message(&u->faction->msgs, msg); - r_addmessage(r, u->faction, msg); - } - else { - add_message(&r->msgs, msg); - } - msg_release(msg); - } bp = &b->next; } } diff --git a/src/economy.test.c b/src/economy.test.c index e7fb5e332..7f48df289 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -241,6 +241,9 @@ static void test_tax_cmd(CuTest *tc) { test_cleanup(); } +/** + * see https://bugs.eressea.de/view.php?id=2234 + */ static void test_maintain_buildings(CuTest *tc) { region *r; building *b; @@ -265,7 +268,8 @@ static void test_maintain_buildings(CuTest *tc) { b->flags = 0; maintain_buildings(r); CuAssertIntEquals(tc, BLD_MAINTAINED, fval(b, BLD_MAINTAINED)); - CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "maintenance_nowork")); + CuAssertPtrEquals(tc, 0, f->msgs); + CuAssertPtrEquals(tc, 0, r->msgs); req = calloc(2, sizeof(maintenance)); req[0].number = 100; @@ -276,9 +280,10 @@ static void test_maintain_buildings(CuTest *tc) { b->flags = 0; maintain_buildings(r); CuAssertIntEquals(tc, 0, fval(b, BLD_MAINTAINED)); - CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "maintenance_nowork")); - CuAssertPtrEquals(tc, 0, test_find_messagetype(r->msgs, "maintenance_noowner")); - test_clear_messages(f); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "maintenancefail")); + CuAssertPtrNotNull(tc, test_find_messagetype(r->msgs, "maintenance_nowork")); + test_clear_messagelist(&f->msgs); + test_clear_messagelist(&r->msgs); // we can afford to pay: i_change(&u->items, itype, 100); @@ -289,7 +294,7 @@ static void test_maintain_buildings(CuTest *tc) { CuAssertPtrEquals(tc, 0, r->msgs); CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "maintenance_nowork")); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "maintenance")); - test_clear_messages(f); + test_clear_messagelist(&f->msgs); // this building has no owner, it doesn't work: u_set_building(u, NULL); @@ -298,6 +303,7 @@ static void test_maintain_buildings(CuTest *tc) { CuAssertIntEquals(tc, 0, fval(b, BLD_MAINTAINED)); CuAssertPtrEquals(tc, 0, f->msgs); CuAssertPtrNotNull(tc, test_find_messagetype(r->msgs, "maintenance_noowner")); + test_clear_messagelist(&r->msgs); test_cleanup(); } diff --git a/src/kernel/building.h b/src/kernel/building.h index dad9ffdde..1ea1836dc 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -31,7 +31,6 @@ extern "C" { /* maintenance::flags */ #define MTF_NONE 0x00 #define MTF_VARIABLE 0x01 /* resource usage scales with size */ -#define MTF_VITAL 0x02 /* if resource missing, building may crash */ typedef struct maintenance { const struct resource_type *rtype; /* type of resource required */ diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 721e6e60f..9e6001f8d 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -106,7 +106,7 @@ static void json_maintenance_i(cJSON *json, maintenance *mt) { break; case cJSON_Array: if (strcmp(child->string, "flags") == 0) { - const char * flags[] = { "variable", "required", 0 }; + const char * flags[] = { "variable", 0 }; mt->flags = json_flags(child, flags); } else { diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 38b2047e6..3fac3478a 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -319,7 +319,7 @@ static void test_spells(CuTest * tc) static const char * building_data = "{\"buildings\": { " "\"house\" : { " "\"maintenance\" : " -"{ \"type\" : \"iron\", \"amount\" : 1, \"flags\" : [ \"required\", \"variable\" ] }" +"{ \"type\" : \"iron\", \"amount\" : 1, \"flags\" : [ \"variable\" ] }" "," "\"construction\" : {" "\"maxsize\" : 20," @@ -363,7 +363,7 @@ static void test_buildings(CuTest * tc) CuAssertPtrNotNull(tc, bt->maintenance); CuAssertIntEquals(tc, 1, bt->maintenance[0].number); CuAssertPtrEquals(tc, (void *)get_resourcetype(R_IRON), (void *)bt->maintenance[0].rtype); - CuAssertIntEquals(tc, MTF_VARIABLE | MTF_VITAL, bt->maintenance[0].flags); + CuAssertIntEquals(tc, MTF_VARIABLE, bt->maintenance[0].flags); CuAssertIntEquals(tc, 0, bt->maintenance[1].number); CuAssertPtrNotNull(tc, bt->construction); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 66825a9b8..06363de48 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -339,9 +339,6 @@ static int parse_buildings(xmlDocPtr doc) if (xml_bvalue(node, "variable", false)) mt->flags |= MTF_VARIABLE; - if (xml_bvalue(node, "vital", false)) - mt->flags |= MTF_VITAL; - } xmlXPathFreeObject(result); From c640fb4be85a682dce80da91ebc257b9d1e0ccd4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 1 Oct 2016 16:39:35 +0000 Subject: [PATCH 108/675] compile in the absence of libxml2-dev --- src/kernel/config.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kernel/config.c b/src/kernel/config.c index 5921535c7..f7eb0e303 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -740,7 +740,9 @@ void kernel_done(void) /* calling this function releases memory assigned to static variables, etc. * calling it is optional, e.g. a release server will most likely not do it. */ +#ifdef USE_LIBXML2 xml_done(); +#endif attrib_done(); item_done(); message_done(); From 530e47efae505b68b4cd09a509fef02455256eef Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 1 Oct 2016 16:59:19 +0000 Subject: [PATCH 109/675] Tippfehler bei Steinkreis-Weihung. https://bugs.eressea.de/view.php?id=2240 --- res/core/messages.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index c07393609..2cb5a0a09 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -7512,7 +7512,7 @@ - "$unit($mage) weight $building($building)." + "$unit($mage) weiht $building($building)." "$unit($mage) blesses $building($building)." From c53ac9d8aab7bcdd265bdc0ac4ef603cb1ad50fd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 1 Oct 2016 21:03:16 +0200 Subject: [PATCH 110/675] remove RS_FARVISION, it is the only spell that uses units. --- src/kernel/unit.c | 1 - src/magic.h | 6 ------ src/reports.c | 19 ++----------------- src/spells.c | 6 +++--- 4 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/kernel/unit.c b/src/kernel/unit.c index c5172cafc..ab3bd294c 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1172,7 +1172,6 @@ void u_setfaction(unit * u, faction * f) } } -/* vorsicht Sprueche koennen u->number == RS_FARVISION haben! */ void set_number(unit * u, int count) { assert(count >= 0); diff --git a/src/magic.h b/src/magic.h index 257ba11c4..59ef92475 100644 --- a/src/magic.h +++ b/src/magic.h @@ -184,12 +184,6 @@ extern "C" { SPC_LINEAR /* Komponenten pro Level und mssen vorhanden sein */ }; - enum { - RS_DUMMY, - RS_FARVISION, - MAX_REGIONSPELLS - }; - /* ------------------------------------------------------------- */ /* Prototypen */ diff --git a/src/reports.c b/src/reports.c index ff076a866..dc0edf1b3 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1308,17 +1308,6 @@ static void cb_add_seen(region *r, unit *u, void *cbdata) { } } -static bool unit_cansee(const unit *u) -{ - const race *rc = u_race(u); - static const race *rc_spell; - static int rc_cache; - if (rc_changed(&rc_cache)) { - rc_spell = get_race(RC_SPELL); - } - return (rc!=rc_spell || u->number == RS_FARVISION); -} - /** set region.seen based on visibility by one faction. * * this function may also update ctx->last and ctx->first for potential @@ -1355,9 +1344,7 @@ void prepare_report(report_context *ctx, faction *f) u = building_owner(b); if (u && u->faction==f) { prepare_lighthouse(b, ctx); - if (unit_cansee(u)) { - add_seen_nb(f, r, seen_unit); - } + add_seen_nb(f, r, seen_unit); } } } @@ -1366,9 +1353,7 @@ void prepare_report(report_context *ctx, faction *f) } for (u = r->units; u; u = u->next) { if (u->faction==f) { - if (unit_cansee(u)) { - add_seen_nb(f, r, seen_unit); - } + add_seen_nb(f, r, seen_unit); if (fval(r, RF_LIGHTHOUSE)) { if (u->building && u->building->type == bt_lighthouse && inside_building(u)) { /* we are in a lighthouse. add the regions we can see from here! */ diff --git a/src/spells.c b/src/spells.c index 4f2d49d9d..7d300c5e1 100644 --- a/src/spells.c +++ b/src/spells.c @@ -4168,7 +4168,7 @@ static int sp_pump(castorder * co) } u = - create_unit(rt, mage->faction, RS_FARVISION, get_race(RC_SPELL), 0, + create_unit(rt, mage->faction, 1, get_race(RC_SPELL), 0, "spell/pump", NULL); u->age = 2; set_level(u, SK_PERCEPTION, effskill(target, SK_PERCEPTION, 0)); @@ -4812,7 +4812,7 @@ int sp_dreamreading(castorder * co) } u2 = - create_unit(u->region, mage->faction, RS_FARVISION, get_race(RC_SPELL), 0, + create_unit(u->region, mage->faction, 1, get_race(RC_SPELL), 0, "spell/dreamreading", NULL); set_number(u2, 1); u2->age = 2; /* Nur fuer diese Runde. */ @@ -5691,7 +5691,7 @@ int sp_viewreality(castorder * co) region *rt = rl2->data; if (!is_cursed(rt->attribs, C_ASTRALBLOCK, 0)) { u = - create_unit(rt, mage->faction, RS_FARVISION, get_race(RC_SPELL), 0, + create_unit(rt, mage->faction, 1, get_race(RC_SPELL), 0, "spell/viewreality", NULL); set_level(u, SK_PERCEPTION, co->level / 2); u->age = 2; From 5a129f8bd4b3a3741f3f8696f33e5d2f90aa4706 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Oct 2016 11:42:31 +0200 Subject: [PATCH 111/675] Create the snowman with full hitpoints. https://bugs.eressea.de/view.php?id=2239 --- scripts/eressea/ponnuki.lua | 3 +-- scripts/eressea/xmasitems.lua | 4 +--- scripts/tests/e2/e2features.lua | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/eressea/ponnuki.lua b/scripts/eressea/ponnuki.lua index f220aa380..994a16ff0 100644 --- a/scripts/eressea/ponnuki.lua +++ b/scripts/eressea/ponnuki.lua @@ -25,11 +25,10 @@ function ponnuki.init() local home = get_region(-67, -5) local f = get_faction(666) if home and f then - u = add_unit(f, home) + u = unit.create(f, home, 1, "illusion") u.id = atoi36("ponn") u.name = "Ponnuki" u.info = "Go, Ponnuki, Go!" - u.race = "illusion" u:set_racename("Ritter von Go") else eressea.log.error("Ponnuki cannot find Magrathea") diff --git a/scripts/eressea/xmasitems.lua b/scripts/eressea/xmasitems.lua index b31691d72..a05e023b8 100644 --- a/scripts/eressea/xmasitems.lua +++ b/scripts/eressea/xmasitems.lua @@ -62,9 +62,7 @@ end function use_snowman(u, amount) if amount>0 and u.region.terrain == "glacier" then - local man = unit.create(u.faction, u.region) - man.race = "snowman" - man.number = amount + local man = unit.create(u.faction, u.region, amount, "snowman") return amount end return -4 diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index efed50ea1..c4a53da76 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -215,7 +215,8 @@ function test_snowman() process_orders() for u2 in r.units do if u2.id~=u.id then - assert_equal(u2.race, "snowman") + assert_equal("snowman", u2.race) + assert_equal(1000, u2.hp) u = nil break end From 8728fccaec24940f35c4927d65f95b79aa80e664 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Oct 2016 12:46:07 +0200 Subject: [PATCH 112/675] fix an endless loop in unicode_utf8_to_cp437 for characters not in the table. --- src/util/unicode.c | 12 ++++++++---- src/util/unicode.test.c | 11 +++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/util/unicode.c b/src/util/unicode.c index 94b6e3d5a..ffc170cc9 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -506,10 +506,14 @@ size_t * length) *cp_character = (char)xref[m].cp437; break; } - else if (xref[m].ucs4 < ucs4_character) - l = m; - else - r = m; + else if (xref[m].ucs4 < ucs4_character) { + if (l == m) l = r; + else l = m; + } + else { + if (r == m) r = l; + else r = m; + } } if (l == r) { *cp_character = '?'; diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index 958b695e2..b643775a9 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -16,9 +16,20 @@ static void test_unicode_tolower(CuTest * tc) CuAssertStrEquals(tc, "helloX", buffer); } +static void test_unicode_utf8_to_cp437(CuTest *tc) +{ + const char utf8_str[4] = { 0xc3, 0x98, 'l', 0 }; // Øl + char ch; + size_t sz; + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); +} + CuSuite *get_unicode_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_unicode_tolower); + SUITE_ADD_TEST(suite, test_unicode_utf8_to_cp437); return suite; } From 693f1be6d13b117aeef225b20f0cdb54524ba91d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Oct 2016 13:12:47 +0200 Subject: [PATCH 113/675] fix endless loop in cp1252 search (wrong sort) fix indentation additional testing --- src/gmtool.c | 4 +- src/util/log.c | 8 +- src/util/unicode.c | 408 ++++++++++++++++++++-------------------- src/util/unicode.h | 6 +- src/util/unicode.test.c | 43 ++++- 5 files changed, 251 insertions(+), 218 deletions(-) diff --git a/src/gmtool.c b/src/gmtool.c index 47b7794a2..608ad3c71 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -87,7 +87,7 @@ static void unicode_remove_diacritics(const char *rp, char *wp) { while (*rp) { if (gm_codepage >=0 && *rp & 0x80) { size_t sz = 0; - char ch; + unsigned char ch; switch (gm_codepage) { case 1252: unicode_utf8_to_cp1252(&ch, rp, &sz); @@ -100,7 +100,7 @@ static void unicode_remove_diacritics(const char *rp, char *wp) { break; } rp += sz; - *wp++ = ch; + *wp++ = (char)ch; } else { *wp++ = *rp++; diff --git a/src/util/log.c b/src/util/log.c index f61d50848..d394aa20d 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -64,11 +64,11 @@ void log_destroy(log_t *handle) { #define LOG_MAXBACKUPS 5 static int -cp_convert(const char *format, char *buffer, size_t length, int codepage) +cp_convert(const char *format, unsigned char *buffer, size_t length, int codepage) { /* when console output on MSDOS, convert to codepage */ const char *input = format; - char *pos = buffer; + unsigned char *pos = buffer; while (pos + 1 < buffer + length && *input) { size_t size = 0; @@ -157,10 +157,10 @@ static void _log_write(FILE * stream, int codepage, const char *format, va_list { if (codepage) { char buffer[MAXLENGTH]; - char converted[MAXLENGTH]; + unsigned char converted[MAXLENGTH]; vsnprintf(buffer, sizeof(buffer), format, args); if (cp_convert(buffer, converted, MAXLENGTH, codepage) == 0) { - fputs(converted, stream); + fputs((char *)converted, stream); } else { /* fall back to non-converted output */ diff --git a/src/util/unicode.c b/src/util/unicode.c index ffc170cc9..f7ea2653b 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -1,4 +1,4 @@ -/* +/* * +-------------------+ Christian Schlittchen * | | Enno Rehling * | Eressea PBEM host | Katja Zedel @@ -71,7 +71,7 @@ int unicode_utf8_tolower(utf8_t * op, size_t outlen, const utf8_t * ip) int unicode_latin1_to_utf8(utf8_t * dst, size_t * outlen, const char *in, -size_t * inlen) + size_t * inlen) { int is = (int)*inlen; int os = (int)*outlen; @@ -104,7 +104,7 @@ size_t * inlen) return (int)*outlen; } -int unicode_utf8_strcasecmp(const utf8_t * a, const char *b) +int unicode_utf8_strcasecmp(const utf8_t * a, const utf8_t *b) { while (*a && *b) { int ret; @@ -147,7 +147,7 @@ int unicode_utf8_strcasecmp(const utf8_t * a, const char *b) /* Convert a UCS-4 character to UTF-8. */ int unicode_ucs4_to_utf8(utf8_t * utf8_character, size_t * size, -ucs4_t ucs4_character) + ucs4_t ucs4_character) { int utf8_bytes; @@ -214,7 +214,7 @@ ucs4_t ucs4_character) /* Convert a UTF-8 encoded character to UCS-4. */ int unicode_utf8_to_ucs4(ucs4_t * ucs4_character, const utf8_t * utf8_string, -size_t * length) + size_t * length) { utf8_t utf8_character = utf8_string[0]; @@ -317,8 +317,8 @@ size_t * length) /** Convert a UTF-8 encoded character to CP437. */ int -unicode_utf8_to_cp437(char *cp_character, const utf8_t * utf8_string, -size_t * length) +unicode_utf8_to_cp437(unsigned char *cp_character, const utf8_t * utf8_string, + size_t * length) { ucs4_t ucs4_character; int result; @@ -330,174 +330,173 @@ size_t * length) } if (ucs4_character < 0x7F) { - *cp_character = (char)ucs4_character; + *cp_character = (unsigned char)ucs4_character; } else { struct { ucs4_t ucs4; unsigned char cp437; } xref[160] = { - { - 0x00A0, 255 }, { - 0x00A1, 173 }, { - 0x00A2, 155 }, { - 0x00A3, 156 }, { - 0x00A5, 157 }, { - 0x00A7, 21 }, { - 0x00AA, 166 }, { - 0x00AB, 174 }, { - 0x00AC, 170 }, { - 0x00B0, 248 }, { - 0x00B1, 241 }, { - 0x00B2, 253 }, { - 0x00B5, 230 }, { - 0x00B6, 20 }, { - 0x00B7, 250 }, { - 0x00BA, 167 }, { - 0x00BB, 175 }, { - 0x00BC, 172 }, { - 0x00BD, 171 }, { - 0x00BF, 168 }, { - 0x00C4, 142 }, { - 0x00C5, 143 }, { - 0x00C6, 146 }, { - 0x00C7, 128 }, { - 0x00C9, 144 }, { - 0x00D1, 165 }, { - 0x00D6, 153 }, { - 0x00DC, 154 }, { - 0x00DF, 225 }, { - 0x00E0, 133 }, { - 0x00E1, 160 }, { - 0x00E2, 131 }, { - 0x00E4, 132 }, { - 0x00E5, 134 }, { - 0x00E6, 145 }, { - 0x00E7, 135 }, { - 0x00E8, 138 }, { - 0x00E9, 130 }, { - 0x00EA, 136 }, { - 0x00EB, 137 }, { - 0x00EC, 141 }, { - 0x00ED, 161 }, { - 0x00EE, 140 }, { - 0x00EF, 139 }, { - 0x00F1, 164 }, { - 0x00F2, 149 }, { - 0x00F3, 162 }, { - 0x00F4, 147 }, { - 0x00F6, 148 }, { - 0x00F7, 246 }, { - 0x00F9, 151 }, { - 0x00FA, 163 }, { - 0x00FB, 150 }, { - 0x00FC, 129 }, { - 0x00FF, 152 }, { - 0x0192, 159 }, { - 0x0393, 226 }, { - 0x0398, 233 }, { - 0x03A3, 228 }, { - 0x03A6, 232 }, { - 0x03A9, 234 }, { - 0x03B1, 224 }, { - 0x03B4, 235 }, { - 0x03B5, 238 }, { - 0x03C0, 227 }, { - 0x03C3, 229 }, { - 0x03C4, 231 }, { - 0x03C6, 237 }, { - 0x2022, 7 }, { - 0x203C, 19 }, { - 0x207F, 252 }, { - 0x20A7, 158 }, { - 0x2190, 27 }, { - 0x2191, 24 }, { - 0x2192, 26 }, { - 0x2193, 25 }, { - 0x2194, 29 }, { - 0x2195, 18 }, { - 0x21A8, 23 }, { - 0x2219, 249 }, { - 0x221A, 251 }, { - 0x221E, 236 }, { - 0x221F, 28 }, { - 0x2229, 239 }, { - 0x2248, 247 }, { - 0x2261, 240 }, { - 0x2264, 243 }, { - 0x2265, 242 }, { - 0x2302, 127 }, { - 0x2310, 169 }, { - 0x2320, 244 }, { - 0x2321, 245 }, { - 0x2500, 196 }, { - 0x2502, 179 }, { - 0x250C, 218 }, { - 0x2510, 191 }, { - 0x2514, 192 }, { - 0x2518, 217 }, { - 0x251C, 195 }, { - 0x2524, 180 }, { - 0x252C, 194 }, { - 0x2534, 193 }, { - 0x253C, 197 }, { - 0x2550, 205 }, { - 0x2551, 186 }, { - 0x2552, 213 }, { - 0x2553, 214 }, { - 0x2554, 201 }, { - 0x2555, 184 }, { - 0x2556, 183 }, { - 0x2557, 187 }, { - 0x2558, 212 }, { - 0x2559, 211 }, { - 0x255A, 200 }, { - 0x255B, 190 }, { - 0x255C, 189 }, { - 0x255D, 188 }, { - 0x255E, 198 }, { - 0x255F, 199 }, { - 0x2560, 204 }, { - 0x2561, 181 }, { - 0x2562, 182 }, { - 0x2563, 185 }, { - 0x2564, 209 }, { - 0x2565, 210 }, { - 0x2566, 203 }, { - 0x2567, 207 }, { - 0x2568, 208 }, { - 0x2569, 202 }, { - 0x256A, 216 }, { - 0x256B, 215 }, { - 0x256C, 206 }, { - 0x2580, 223 }, { - 0x2584, 220 }, { - 0x2588, 219 }, { - 0x258C, 221 }, { - 0x2590, 222 }, { - 0x2591, 176 }, { - 0x2592, 177 }, { - 0x2593, 178 }, { - 0x25A0, 254 }, { - 0x25AC, 22 }, { - 0x25B2, 30 }, { - 0x25BA, 16 }, { - 0x25BC, 31 }, { - 0x25C4, 17 }, { - 0x25CB, 9 }, { - 0x25D8, 8 }, { - 0x25D9, 10 }, { - 0x263A, 1 }, { - 0x263B, 2 }, { - 0x263C, 15 }, { - 0x2640, 12 }, { - 0x2642, 11 }, { - 0x2660, 6 }, { - 0x2663, 5 }, { - 0x2665, 3 }, { - 0x2666, 4 }, { - 0x266A, 13 }, { - 0x266B, 14 } + { 0x00A0, 255 }, + { 0x00A1, 173 }, + { 0x00A2, 155 }, + { 0x00A3, 156 }, + { 0x00A5, 157 }, + { 0x00A7, 21 }, + { 0x00AA, 166 }, + { 0x00AB, 174 }, + { 0x00AC, 170 }, + { 0x00B0, 248 }, + { 0x00B1, 241 }, + { 0x00B2, 253 }, + { 0x00B5, 230 }, + { 0x00B6, 20 }, + { 0x00B7, 250 }, + { 0x00BA, 167 }, + { 0x00BB, 175 }, + { 0x00BC, 172 }, + { 0x00BD, 171 }, + { 0x00BF, 168 }, + { 0x00C4, 142 }, + { 0x00C5, 143 }, + { 0x00C6, 146 }, + { 0x00C7, 128 }, + { 0x00C9, 144 }, + { 0x00D1, 165 }, + { 0x00D6, 153 }, + { 0x00DC, 154 }, + { 0x00DF, 225 }, + { 0x00E0, 133 }, + { 0x00E1, 160 }, + { 0x00E2, 131 }, + { 0x00E4, 132 }, + { 0x00E5, 134 }, + { 0x00E6, 145 }, + { 0x00E7, 135 }, + { 0x00E8, 138 }, + { 0x00E9, 130 }, + { 0x00EA, 136 }, + { 0x00EB, 137 }, + { 0x00EC, 141 }, + { 0x00ED, 161 }, + { 0x00EE, 140 }, + { 0x00EF, 139 }, + { 0x00F1, 164 }, + { 0x00F2, 149 }, + { 0x00F3, 162 }, + { 0x00F4, 147 }, + { 0x00F6, 148 }, + { 0x00F7, 246 }, + { 0x00F9, 151 }, + { 0x00FA, 163 }, + { 0x00FB, 150 }, + { 0x00FC, 129 }, + { 0x00FF, 152 }, + { 0x0192, 159 }, + { 0x0393, 226 }, + { 0x0398, 233 }, + { 0x03A3, 228 }, + { 0x03A6, 232 }, + { 0x03A9, 234 }, + { 0x03B1, 224 }, + { 0x03B4, 235 }, + { 0x03B5, 238 }, + { 0x03C0, 227 }, + { 0x03C3, 229 }, + { 0x03C4, 231 }, + { 0x03C6, 237 }, + { 0x2022, 7 }, + { 0x203C, 19 }, + { 0x207F, 252 }, + { 0x20A7, 158 }, + { 0x2190, 27 }, + { 0x2191, 24 }, + { 0x2192, 26 }, + { 0x2193, 25 }, + { 0x2194, 29 }, + { 0x2195, 18 }, + { 0x21A8, 23 }, + { 0x2219, 249 }, + { 0x221A, 251 }, + { 0x221E, 236 }, + { 0x221F, 28 }, + { 0x2229, 239 }, + { 0x2248, 247 }, + { 0x2261, 240 }, + { 0x2264, 243 }, + { 0x2265, 242 }, + { 0x2302, 127 }, + { 0x2310, 169 }, + { 0x2320, 244 }, + { 0x2321, 245 }, + { 0x2500, 196 }, + { 0x2502, 179 }, + { 0x250C, 218 }, + { 0x2510, 191 }, + { 0x2514, 192 }, + { 0x2518, 217 }, + { 0x251C, 195 }, + { 0x2524, 180 }, + { 0x252C, 194 }, + { 0x2534, 193 }, + { 0x253C, 197 }, + { 0x2550, 205 }, + { 0x2551, 186 }, + { 0x2552, 213 }, + { 0x2553, 214 }, + { 0x2554, 201 }, + { 0x2555, 184 }, + { 0x2556, 183 }, + { 0x2557, 187 }, + { 0x2558, 212 }, + { 0x2559, 211 }, + { 0x255A, 200 }, + { 0x255B, 190 }, + { 0x255C, 189 }, + { 0x255D, 188 }, + { 0x255E, 198 }, + { 0x255F, 199 }, + { 0x2560, 204 }, + { 0x2561, 181 }, + { 0x2562, 182 }, + { 0x2563, 185 }, + { 0x2564, 209 }, + { 0x2565, 210 }, + { 0x2566, 203 }, + { 0x2567, 207 }, + { 0x2568, 208 }, + { 0x2569, 202 }, + { 0x256A, 216 }, + { 0x256B, 215 }, + { 0x256C, 206 }, + { 0x2580, 223 }, + { 0x2584, 220 }, + { 0x2588, 219 }, + { 0x258C, 221 }, + { 0x2590, 222 }, + { 0x2591, 176 }, + { 0x2592, 177 }, + { 0x2593, 178 }, + { 0x25A0, 254 }, + { 0x25AC, 22 }, + { 0x25B2, 30 }, + { 0x25BA, 16 }, + { 0x25BC, 31 }, + { 0x25C4, 17 }, + { 0x25CB, 9 }, + { 0x25D8, 8 }, + { 0x25D9, 10 }, + { 0x263A, 1 }, + { 0x263B, 2 }, + { 0x263C, 15 }, + { 0x2640, 12 }, + { 0x2642, 11 }, + { 0x2660, 6 }, + { 0x2663, 5 }, + { 0x2665, 3 }, + { 0x2666, 4 }, + { 0x266A, 13 }, + { 0x266B, 14 } }; int l = 0, r = 160; while (l != r) { @@ -509,7 +508,7 @@ size_t * length) else if (xref[m].ucs4 < ucs4_character) { if (l == m) l = r; else l = m; - } + } else { if (r == m) r = l; else r = m; @@ -523,7 +522,7 @@ size_t * length) } /** Convert a UTF-8 encoded character to ASCII, with '?' replacements. */ -int unicode_utf8_to_ascii(char *cp_character, const utf8_t * utf8_string, +int unicode_utf8_to_ascii(unsigned char *cp_character, const utf8_t * utf8_string, size_t *length) { int result = unicode_utf8_to_cp437(cp_character, utf8_string, length); @@ -536,7 +535,7 @@ int unicode_utf8_to_ascii(char *cp_character, const utf8_t * utf8_string, } /** Convert a UTF-8 encoded character to CP1252. */ -int unicode_utf8_to_cp1252(char *cp_character, const utf8_t * utf8_string, +int unicode_utf8_to_cp1252(unsigned char *cp_character, const utf8_t * utf8_string, size_t * length) { ucs4_t ucs4_character; @@ -556,39 +555,38 @@ int unicode_utf8_to_cp1252(char *cp_character, const utf8_t * utf8_string, ucs4_t ucs4; unsigned char cp; } xref[] = { - { - 0x20ac, 0x80 }, { - 0x0081, 0x81 }, { - 0x201a, 0x82 }, { - 0x0192, 0x83 }, { - 0x201e, 0x84 }, { - 0x2026, 0x85 }, { - 0x2020, 0x86 }, { - 0x2021, 0x87 }, { - 0x02c6, 0x88 }, { - 0x2030, 0x89 }, { - 0x0160, 0x8a }, { - 0x2039, 0x8b }, { - 0x0152, 0x8c }, { - 0x008d, 0x8d }, { - 0x017d, 0x8e }, { - 0x008f, 0x8f }, { - 0x0090, 0x90 }, { - 0x2018, 0x91 }, { - 0x2019, 0x92 }, { - 0x201c, 0x93 }, { - 0x201d, 0x94 }, { - 0x2022, 0x95 }, { - 0x2013, 0x96 }, { - 0x2014, 0x97 }, { - 0x02dc, 0x98 }, { - 0x2122, 0x99 }, { - 0x0161, 0x9a }, { - 0x203a, 0x9b }, { - 0x0153, 0x9c }, { - 0x009d, 0x9d }, { - 0x017e, 0x9e }, { - 0x0178, 0x9f } + { 0x0081, 0x81 }, + { 0x008d, 0x8d }, + { 0x008f, 0x8f }, + { 0x0090, 0x90 }, + { 0x009d, 0x9d }, + { 0x0152, 0x8c }, + { 0x0153, 0x9c }, + { 0x0160, 0x8a }, + { 0x0161, 0x9a }, + { 0x0178, 0x9f }, + { 0x017d, 0x8e }, + { 0x017e, 0x9e }, + { 0x0192, 0x83 }, + { 0x02c6, 0x88 }, + { 0x02dc, 0x98 }, + { 0x2013, 0x96 }, + { 0x2014, 0x97 }, + { 0x2018, 0x91 }, + { 0x2019, 0x92 }, + { 0x201a, 0x82 }, + { 0x201c, 0x93 }, + { 0x201d, 0x94 }, + { 0x201e, 0x84 }, + { 0x2022, 0x95 }, + { 0x2026, 0x85 }, + { 0x2020, 0x86 }, + { 0x2021, 0x87 }, + { 0x2030, 0x89 }, + { 0x203a, 0x9b }, + { 0x2039, 0x8b }, + { 0x20ac, 0x80 }, + { 0x2122, 0x99 } }; int l = 0, r = sizeof(xref) / sizeof(xref[0]); while (l != r) { diff --git a/src/util/unicode.h b/src/util/unicode.h index b061cd6fb..df68ade02 100644 --- a/src/util/unicode.h +++ b/src/util/unicode.h @@ -28,15 +28,15 @@ extern "C" { typedef unsigned long ucs4_t; typedef char utf8_t; - int unicode_utf8_to_cp437(char *result, const utf8_t * utf8_string, + int unicode_utf8_to_cp437(unsigned char *result, const utf8_t * utf8_string, size_t * length); - int unicode_utf8_to_cp1252(char *result, const utf8_t * utf8_string, + int unicode_utf8_to_cp1252(unsigned char *result, const utf8_t * utf8_string, size_t * length); int unicode_utf8_to_ucs4(ucs4_t * result, const utf8_t * utf8_string, size_t * length); int unicode_ucs4_to_utf8(utf8_t * result, size_t * size, ucs4_t ucs4_character); - int unicode_utf8_to_ascii(char *cp_character, const utf8_t * utf8_string, + int unicode_utf8_to_ascii(unsigned char *cp_character, const utf8_t * utf8_string, size_t *length); int unicode_utf8_strcasecmp(const utf8_t * a, const utf8_t * b); int unicode_latin1_to_utf8(utf8_t * out, size_t * outlen, diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index b643775a9..dc33b02a8 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -16,20 +16,55 @@ static void test_unicode_tolower(CuTest * tc) CuAssertStrEquals(tc, "helloX", buffer); } -static void test_unicode_utf8_to_cp437(CuTest *tc) +static void test_unicode_utf8_to_other(CuTest *tc) { - const char utf8_str[4] = { 0xc3, 0x98, 'l', 0 }; // Øl - char ch; + const char utf8_str[] = { 0xc3, 0x98, 0xc5, 0xb8, 0xc2, 0x9d, 'l', 0 }; // ØŸl + unsigned char ch; size_t sz; CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str, &sz)); CuAssertIntEquals(tc, 2, sz); CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str+2, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str+4, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str + 6, &sz)); + CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 'l', ch); + + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 216, ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str+2, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 120, ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str + 4, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 0x9d, ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str + 6, &sz)); + CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 'l', ch); + + CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 2, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 4, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 6, &sz)); + CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 'l', ch); } CuSuite *get_unicode_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_unicode_tolower); - SUITE_ADD_TEST(suite, test_unicode_utf8_to_cp437); + SUITE_ADD_TEST(suite, test_unicode_utf8_to_other); return suite; } From fadf591a32ddbcb533a48d560b2ad8f89cf1101f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Oct 2016 13:19:39 +0200 Subject: [PATCH 114/675] gcc appeasement (overflow in constant conversion). --- src/util/unicode.test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index dc33b02a8..f485808cb 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -18,7 +18,8 @@ static void test_unicode_tolower(CuTest * tc) static void test_unicode_utf8_to_other(CuTest *tc) { - const char utf8_str[] = { 0xc3, 0x98, 0xc5, 0xb8, 0xc2, 0x9d, 'l', 0 }; // ØŸl + const unsigned char uchar_str[] = { 0xc3, 0x98, 0xc5, 0xb8, 0xc2, 0x9d, 'l', 0 }; // ØŸl + utf8_t *utf8_str = (utf8_t *)uchar_str; unsigned char ch; size_t sz; CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str, &sz)); From 879d791a60b1f57dc1bd37e9e938964eff872e7e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Oct 2016 14:30:27 +0200 Subject: [PATCH 115/675] seems like I forgot to commit this change, which is making the test fail. why only on my mac, though? --- scripts/eressea/xmasitems.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/eressea/xmasitems.lua b/scripts/eressea/xmasitems.lua index b31691d72..a05e023b8 100644 --- a/scripts/eressea/xmasitems.lua +++ b/scripts/eressea/xmasitems.lua @@ -62,9 +62,7 @@ end function use_snowman(u, amount) if amount>0 and u.region.terrain == "glacier" then - local man = unit.create(u.faction, u.region) - man.race = "snowman" - man.number = amount + local man = unit.create(u.faction, u.region, amount, "snowman") return amount end return -4 From f6beda43f447baf9f3ccc5af1c23261dc420aa26 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 3 Oct 2016 16:16:17 +0200 Subject: [PATCH 116/675] fix small typo --- s/travis-build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s/travis-build b/s/travis-build index 011e9e7de..9293ac12d 100755 --- a/s/travis-build +++ b/s/travis-build @@ -10,7 +10,7 @@ $BUILD/iniparser/inifile eressea.ini add lua:paths lunit:scripts fi } -integraton_tests() { +integration_tests() { cd tests ./write-reports.sh ./run-turn.sh @@ -24,4 +24,4 @@ cd $ROOT inifile s/runtests -integraton_tests +integration_tests From 42e75007c32bf5ef6daa255c919c16f7f3b770dc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 3 Oct 2016 16:26:40 +0200 Subject: [PATCH 117/675] little bit of refactoring and better variable names. --- .gitignore | 1 + src/monsters.c | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 8e19d4018..24219490f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.vscode/ *.orig eressea.ini Debug diff --git a/src/monsters.c b/src/monsters.c index ecf768cab..72decb304 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -277,27 +277,26 @@ static bool room_for_race_in_region(region * r, const race * rc) c += u->number; } - if (c > (rc->splitsize * 2)) - return false; - - return true; + return (c <= (rc->splitsize * 2)); } static direction_t random_neighbour(region * r, unit * u) { int i; - region *rc; region * next[MAXDIRECTIONS]; int rr, c = 0, c2 = 0; + const race *rc = u_race(u); get_neighbours(r, next); /* Nachsehen, wieviele Regionen in Frage kommen */ for (i = 0; i != MAXDIRECTIONS; i++) { - rc = next[i]; - if (rc && can_survive(u, rc)) { - if (room_for_race_in_region(rc, u_race(u))) { + region *rn = next[i]; + if (rn && can_survive(u, rn)) { + if (room_for_race_in_region(rn, rc)) { c++; + } else { + next[i] = NULL; } c2++; } @@ -321,12 +320,12 @@ static direction_t random_neighbour(region * r, unit * u) c = -1; for (i = 0; i != MAXDIRECTIONS; i++) { - rc = next[i]; - if (rc && can_survive(u, rc)) { + region *rn = next[i]; + if (rn && can_survive(u, rn)) { if (c2 == 0) { c++; } - else if (room_for_race_in_region(rc, u_race(u))) { + else if (room_for_race_in_region(rn, rc)) { c++; } if (c == rr) From ef43aaa830f54cd7faa195c53c286f3228d3f262 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 3 Oct 2016 16:28:18 +0200 Subject: [PATCH 118/675] eliminate some duplicate calculations. --- src/monsters.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/monsters.c b/src/monsters.c index 72decb304..4e3e47623 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -322,14 +322,10 @@ static direction_t random_neighbour(region * r, unit * u) for (i = 0; i != MAXDIRECTIONS; i++) { region *rn = next[i]; if (rn && can_survive(u, rn)) { - if (c2 == 0) { - c++; - } - else if (room_for_race_in_region(rn, rc)) { - c++; - } - if (c == rr) + c++; + if (c == rr) { return (direction_t)i; + } } } From 26a416c5badf08a2820b3df1d8a2f664bff115c0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 3 Oct 2016 16:38:17 +0200 Subject: [PATCH 119/675] do not call can_survive all this much. --- src/monsters.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/monsters.c b/src/monsters.c index 4e3e47623..2678c284e 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -299,6 +299,8 @@ static direction_t random_neighbour(region * r, unit * u) next[i] = NULL; } c2++; + } else { + next[i] = NULL; } } @@ -321,7 +323,7 @@ static direction_t random_neighbour(region * r, unit * u) c = -1; for (i = 0; i != MAXDIRECTIONS; i++) { region *rn = next[i]; - if (rn && can_survive(u, rn)) { + if (rn) { c++; if (c == rr) { return (direction_t)i; From fbdf845cb99f850665f90b95f5c7389d9bb5d2f6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 3 Oct 2016 20:15:38 +0200 Subject: [PATCH 120/675] fix overpopulation-checks and movement based on splitsize. --- src/monsters.c | 55 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/src/monsters.c b/src/monsters.c index 2678c284e..258175b43 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -269,21 +269,27 @@ static direction_t richest_neighbour(region * r, faction * f, int absolut) static bool room_for_race_in_region(region * r, const race * rc) { - unit *u; - int c = 0; + if (rc->splitsize > 0) { + unit *u; + int c = 0; - for (u = r->units; u; u = u->next) { - if (u_race(u) == rc) - c += u->number; + for (u = r->units; u; u = u->next) { + if (u_race(u) == rc) { + c += u->number; + if (c > rc->splitsize * 2) { + return false; + } + } + } } - - return (c <= (rc->splitsize * 2)); + return true; } static direction_t random_neighbour(region * r, unit * u) { int i; - region * next[MAXDIRECTIONS]; + region *next[MAXDIRECTIONS], *backup[MAXDIRECTIONS]; + region **pick; int rr, c = 0, c2 = 0; const race *rc = u_race(u); @@ -298,19 +304,22 @@ static direction_t random_neighbour(region * r, unit * u) } else { next[i] = NULL; } + backup[i] = rn; c2++; } else { next[i] = NULL; + backup[i] = NULL; } } + pick = next; if (c == 0) { if (c2 == 0) { return NODIRECTION; } else { + pick = backup; c = c2; - c2 = 0; /* c2 == 0 -> room_for_race nicht beachten */ } } @@ -320,14 +329,14 @@ static direction_t random_neighbour(region * r, unit * u) /* Durchzhlen */ - c = -1; + c = 0; for (i = 0; i != MAXDIRECTIONS; i++) { - region *rn = next[i]; + region *rn = pick[i]; if (rn) { - c++; if (c == rr) { return (direction_t)i; } + c++; } } @@ -543,19 +552,21 @@ static order *monster_learn(unit * u) return NULL; } -static bool check_overpopulated(unit * u) +static bool check_overpopulated(const unit * u) { - unit *u2; - int c = 0; + const race *rc = u_race(u); + if (rc->splitsize > 0) { + unit *u2; + int c = 0; - for (u2 = u->region->units; u2; u2 = u2->next) { - if (u_race(u2) == u_race(u) && u != u2) - c += u2->number; + for (u2 = u->region->units; u2; u2 = u2->next) { + if (u != u2 && u_race(u2) == rc) { + c += u2->number; + if (c > rc->splitsize * 2) + return true; + } + } } - - if (c > u_race(u)->splitsize * 2) - return true; - return false; } From 8f1a1fc8c35dc2572142e5aeb7e2c7bcb2180300 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 3 Oct 2016 20:27:36 +0200 Subject: [PATCH 121/675] tighten up some lookups. --- src/magic.c | 96 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/src/magic.c b/src/magic.c index bcf3403aa..0a2c685d4 100644 --- a/src/magic.c +++ b/src/magic.c @@ -1031,9 +1031,8 @@ cancast(unit * u, const spell * sp, int level, int range, struct order * ord) double spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order *ord) { - curse *c; double force = cast_level; - int elf_power; + static int elf_power, config; const struct resource_type *rtype; if (sp == NULL) { @@ -1046,54 +1045,65 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order if (btype && btype->flags & BTF_MAGIC) ++force; } - elf_power = config_get_int("rules.magic.elfpower", 0); - - if (elf_power && u_race(u) == get_race(RC_ELF) && r_isforest(r)) { - ++force; + if (config_changed(&config)) { + elf_power = config_get_int("rules.magic.elfpower", 0); + } + if (elf_power) { + static int rc_cache; + static const race *rc_elf; + if (rc_changed(&rc_cache)) { + rc_elf = get_race(RC_ELF); + } + if (u_race(u) == rc_elf && r_isforest(r)) { + ++force; + } } rtype = rt_find("rop"); if (rtype && i_get(u->items, rtype->itype) > 0) { ++force; } - /* Antimagie in der Zielregion */ - c = get_curse(r->attribs, ct_find("antimagiczone")); - if (curse_active(c)) { - unit *mage = c->magician; - force -= curse_geteffect(c); - curse_changevigour(&r->attribs, c, -cast_level); - cmistake(u, ord, 185, MSG_MAGIC); - if (mage != NULL && mage->faction != NULL) { - if (force > 0) { - ADDMSG(&mage->faction->msgs, msg_message("reduce_spell", - "self mage region", mage, u, r)); + if (r->attribs) { + curse *c; + + /* Antimagie in der Zielregion */ + c = get_curse(r->attribs, ct_find("antimagiczone")); + if (curse_active(c)) { + unit *mage = c->magician; + force -= curse_geteffect(c); + curse_changevigour(&r->attribs, c, -cast_level); + cmistake(u, ord, 185, MSG_MAGIC); + if (mage != NULL && mage->faction != NULL) { + if (force > 0) { + ADDMSG(&mage->faction->msgs, msg_message("reduce_spell", + "self mage region", mage, u, r)); + } + else { + ADDMSG(&mage->faction->msgs, msg_message("block_spell", + "self mage region", mage, u, r)); + } } - else { - ADDMSG(&mage->faction->msgs, msg_message("block_spell", - "self mage region", mage, u, r)); + } + + /* Patzerfluch-Effekt: */ + c = get_curse(r->attribs, ct_find("fumble")); + if (curse_active(c)) { + unit *mage = c->magician; + force -= curse_geteffect(c); + curse_changevigour(&u->attribs, c, -1); + cmistake(u, ord, 185, MSG_MAGIC); + if (mage != NULL && mage->faction != NULL) { + if (force > 0) { + ADDMSG(&mage->faction->msgs, msg_message("reduce_spell", + "self mage region", mage, u, r)); + } + else { + ADDMSG(&mage->faction->msgs, msg_message("block_spell", + "self mage region", mage, u, r)); + } } } } - - /* Patzerfluch-Effekt: */ - c = get_curse(r->attribs, ct_find("fumble")); - if (curse_active(c)) { - unit *mage = c->magician; - force -= curse_geteffect(c); - curse_changevigour(&u->attribs, c, -1); - cmistake(u, ord, 185, MSG_MAGIC); - if (mage != NULL && mage->faction != NULL) { - if (force > 0) { - ADDMSG(&mage->faction->msgs, msg_message("reduce_spell", - "self mage region", mage, u, r)); - } - else { - ADDMSG(&mage->faction->msgs, msg_message("block_spell", - "self mage region", mage, u, r)); - } - } - } - return _max(force, 0); } @@ -2784,6 +2794,8 @@ void magic(void) int rank; castorder *co; spellrank spellranks[MAX_SPELLRANK]; + const race *rc_spell = get_race(RC_SPELL); + const race *rc_insect = get_race(RC_INSECT); memset(spellranks, 0, sizeof(spellranks)); @@ -2792,10 +2804,10 @@ void magic(void) for (u = r->units; u; u = u->next) { order *ord; - if (u->number <= 0 || u_race(u) == get_race(RC_SPELL)) + if (u->number <= 0 || u_race(u) == rc_spell) continue; - if (u_race(u) == get_race(RC_INSECT) && r_insectstalled(r) && + if (u_race(u) == rc_insect && r_insectstalled(r) && !is_cursed(u->attribs, C_KAELTESCHUTZ, 0)) continue; From 63f60a2465c88d3fb61bc68c794240ceb56a93ba Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 3 Oct 2016 20:36:46 +0200 Subject: [PATCH 122/675] cache some more get_race calls, especially for RC_SPELL. --- src/battle.c | 11 ++++++++--- src/laws.c | 8 +++++++- src/randenc.c | 7 ++++++- src/study.c | 8 +++++++- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/battle.c b/src/battle.c index 1bbaaadfe..fb411d778 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1886,7 +1886,13 @@ int skilldiff(troop at, troop dt, int dist) unit *au = af->unit, *du = df->unit; int is_protected = 0, skdiff = 0; weapon *awp = select_weapon(at, true, dist > 1); + static int rc_cache; + static const race *rc_halfling, *rc_goblin; + if (rc_changed(&rc_cache)) { + rc_halfling = get_race(RC_HALFLING); + rc_goblin = get_race(RC_GOBLIN); + } skdiff += af->person[at.index].attack; skdiff -= df->person[dt.index].defence; @@ -1894,11 +1900,10 @@ int skilldiff(troop at, troop dt, int dist) skdiff += 2; /* Effekte durch Rassen */ - if (awp != NULL && u_race(au) == get_race(RC_HALFLING) && dragonrace(u_race(du))) { + if (awp != NULL && u_race(au) == rc_halfling && dragonrace(u_race(du))) { skdiff += 5; } - - if (u_race(au) == get_race(RC_GOBLIN)) { + else if (u_race(au) == rc_goblin) { if (af->side->size[SUM_ROW] >= df->side->size[SUM_ROW] * rule_goblin_bonus) { skdiff += 1; } diff --git a/src/laws.c b/src/laws.c index f854ed7ef..e243378dd 100755 --- a/src/laws.c +++ b/src/laws.c @@ -125,7 +125,13 @@ static bool RemoveNMRNewbie(void) static void age_unit(region * r, unit * u) { - if (u_race(u) == get_race(RC_SPELL)) { + static int rc_cache; + static const race *rc_spell; + + if (rc_changed(&rc_cache)) { + rc_spell = get_race(RC_SPELL); + } + if (u_race(u) == rc_spell) { if (--u->age <= 0) { remove_unit(&r->units, u); } diff --git a/src/randenc.c b/src/randenc.c index 85c3dd8d3..0fe76e883 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -731,11 +731,16 @@ static void orc_growth(void) static void demon_skillchanges(void) { region *r; + static const race *rc_demon; + static int rc_cache; + if (rc_changed(&rc_cache)) { + rc_demon = get_race(RC_DAEMON); + } for (r = regions; r; r = r->next) { unit *u; for (u = r->units; u; u = u->next) { - if (u_race(u) == get_race(RC_DAEMON)) { + if (u_race(u) == rc_demon) { demon_skillchange(u); } } diff --git a/src/study.c b/src/study.c index 027f67dde..1ddaf8dfe 100644 --- a/src/study.c +++ b/src/study.c @@ -546,6 +546,12 @@ int study_cmd(unit * u, order * ord) int maxalchemy = 0; int speed_rule = (study_rule_t)config_get_int("study.speedup", 0); bool learn_newskills = config_get_int("study.newskills", 1) != 0; + static const race *rc_snotling; + static int rc_cache; + + if (rc_changed(&rc_cache)) { + rc_snotling = get_race(RC_SNOTLING); + } if (!unit_can_study(u)) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race", @@ -575,7 +581,7 @@ int study_cmd(unit * u, order * ord) } /* snotlings koennen Talente nur bis T8 lernen */ - if (u_race(u) == get_race(RC_SNOTLING)) { + if (u_race(u) == rc_snotling) { if (get_level(u, sk) >= 8) { cmistake(u, ord, 308, MSG_EVENT); return 0; From d3efc265c3f26f4f34bcf64525908d45c11de3b7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 4 Oct 2016 09:14:49 +0200 Subject: [PATCH 123/675] calculating income for dragons is no longer hard-coded --- res/races/dragon.xml | 3 ++- res/races/wyrm.xml | 6 +++++- res/races/youngdragon.xml | 6 +++++- src/economy.c | 16 ++-------------- src/economy.test.c | 14 ++++++++++++++ src/kernel/jsonconf.c | 3 +++ src/kernel/jsonconf.test.c | 2 ++ src/kernel/race.c | 1 + src/kernel/race.h | 1 + src/kernel/race.test.c | 1 + src/kernel/xmlreader.c | 1 + 11 files changed, 37 insertions(+), 17 deletions(-) diff --git a/res/races/dragon.xml b/res/races/dragon.xml index 907ff90a7..e4a1a7fec 100644 --- a/res/races/dragon.xml +++ b/res/races/dragon.xml @@ -1,7 +1,8 @@ +income="1000" walk="yes" teach="no" getitem="yes" resistbash="yes" +dragon="yes"> diff --git a/res/races/wyrm.xml b/res/races/wyrm.xml index b5d3bd7a2..b9f95d9ef 100644 --- a/res/races/wyrm.xml +++ b/res/races/wyrm.xml @@ -1,4 +1,8 @@ - + diff --git a/res/races/youngdragon.xml b/res/races/youngdragon.xml index d1b3a4752..71bc4214b 100644 --- a/res/races/youngdragon.xml +++ b/res/races/youngdragon.xml @@ -1,4 +1,8 @@ - + diff --git a/src/economy.c b/src/economy.c index 099e9786d..8f6a1afa1 100644 --- a/src/economy.c +++ b/src/economy.c @@ -114,20 +114,8 @@ static void recruit_init(void) int income(const unit * u) { - // TODO: make this a property, like race.income, no hard-coding of values - if (fval(u_race(u), RCF_DRAGON)) { - switch (old_race(u_race(u))) { - case RC_FIREDRAGON: - return 150 * u->number; - case RC_DRAGON: - return 1000 * u->number; - case RC_WYRM: - return 5000 * u->number; - default: - break; - } - } - return 20 * u->number; + const race *rc = u_race(u); + return rc->income * u->number; } static void scramble(void *data, unsigned int n, size_t width) diff --git a/src/economy.test.c b/src/economy.test.c index 7f48df289..3c4a5f257 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -328,11 +328,25 @@ static void test_recruit(CuTest *tc) { test_cleanup(); } +static void test_income(CuTest *tc) +{ + race *rc; + unit *u; + test_setup(); + rc = test_create_race("nerd"); + u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); + CuAssertIntEquals(tc, 20, income(u)); + u->number = 5; + CuAssertIntEquals(tc, 100, income(u)); + test_cleanup(); +} + CuSuite *get_economy_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_give_control_building); SUITE_ADD_TEST(suite, test_give_control_ship); + SUITE_ADD_TEST(suite, test_income); SUITE_ADD_TEST(suite, test_steal_okay); SUITE_ADD_TEST(suite, test_steal_ocean); SUITE_ADD_TEST(suite, test_steal_nosteal); diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 9e6001f8d..6e60fc90c 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -481,6 +481,9 @@ static void json_race(cJSON *json, race *rc) { else if (strcmp(child->string, "capacity") == 0) { rc->capacity = child->valueint; } + else if (strcmp(child->string, "income") == 0) { + rc->income = child->valueint; + } else if (strcmp(child->string, "hp") == 0) { rc->hitpoints = child->valueint; } diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 3fac3478a..76784ed56 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -141,6 +141,7 @@ static void test_races(CuTest * tc) "\"maintenance\" : 2," "\"weight\" : 3," "\"capacity\" : 4," + "\"income\" : 30," "\"hp\" : 5," "\"ac\" : 6," "\"flags\" : [ \"npc\", \"walk\", \"undead\" ]" @@ -167,6 +168,7 @@ static void test_races(CuTest * tc) CuAssertIntEquals(tc, 2, rc->maintenance); CuAssertIntEquals(tc, 3, rc->weight); CuAssertIntEquals(tc, 4, rc->capacity); + CuAssertIntEquals(tc, 30, rc->income); CuAssertIntEquals(tc, 5, rc->hitpoints); CuAssertIntEquals(tc, 6, rc->armor); cJSON_Delete(json); diff --git a/src/kernel/race.c b/src/kernel/race.c index 4003c701e..57ebe972a 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -173,6 +173,7 @@ race *rc_create(const char *zName) rc->hitpoints = 1; rc->weight = PERSON_WEIGHT; rc->capacity = 540; + rc->income = 20; rc->recruit_multi = 1.0F; rc->regaura = 1.0F; rc->speed = 1.0F; diff --git a/src/kernel/race.h b/src/kernel/race.h index 17c2bc61f..214f2738d 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -124,6 +124,7 @@ extern "C" { int splitsize; int weight; int capacity; + int income; float speed; float aggression; /* chance that a monster will attack */ int hitpoints; diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index ec4b40f92..7bccdbba8 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -32,6 +32,7 @@ static void test_rc_defaults(CuTest *tc) { CuAssertIntEquals(tc, 0, rc->recruitcost); CuAssertIntEquals(tc, 0, rc->maintenance); CuAssertIntEquals(tc, 540, rc->capacity); + CuAssertIntEquals(tc, 20, rc->income); CuAssertIntEquals(tc, 1, rc->hitpoints); CuAssertIntEquals(tc, 0, rc->armor); CuAssertIntEquals(tc, 0, rc->at_bonus); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 06363de48..894647f89 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1656,6 +1656,7 @@ static int parse_races(xmlDocPtr doc) rc->maintenance = xml_ivalue(node, "maintenance", rc->maintenance); rc->weight = xml_ivalue(node, "weight", rc->weight); rc->capacity = xml_ivalue(node, "capacity", rc->capacity); + rc->income = xml_ivalue(node, "income", rc->income); rc->speed = (float)xml_fvalue(node, "speed", rc->speed); rc->hitpoints = xml_ivalue(node, "hp", rc->hitpoints); rc->armor = (char)xml_ivalue(node, "ac", rc->armor); From 61f76e6722c809de2ead96bb027cd4f77df0ac04 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 4 Oct 2016 10:34:18 +0200 Subject: [PATCH 124/675] make old_race a little bit less awful. --- src/kernel/config.c | 10 ---------- src/kernel/race.c | 44 ++++++++++++++++++++++++++++++++++++++++++ src/kernel/race.test.c | 16 +++++++++++++++ 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index f7eb0e303..ba69f142e 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -137,16 +137,6 @@ int NMRTimeout(void) return config_get_int("nmr.timeout", 0); } -race_t old_race(const struct race * rc) -{ - race_t i; - // TODO: this sucks so bad! - for (i = 0; i != MAXRACES; ++i) { - if (get_race(i) == rc) return i; - } - return NORACE; -} - helpmode helpmodes[] = { { "all", HELP_ALL } , diff --git a/src/kernel/race.c b/src/kernel/race.c index 57ebe972a..ce13d1ef7 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -86,6 +86,50 @@ const struct race *get_race(race_t rt) { return rc_find(name); } +typedef struct xref { + race_t id; + const race *rc; +} rc_xref; + +int cmp_xref(const void *a, const void *b) +{ + const rc_xref *l = (const rc_xref *)a; + const rc_xref *r = (const rc_xref *)b; + if (l->rcrc) return -1; + if (l->rc>r->rc) return 1; + return 0; +} + +race_t old_race(const struct race * rc) +{ + static int cache; + static rc_xref *xrefs; + int i, l, r; + + if (rc_changed(&cache)) { + if (!xrefs) { + xrefs = malloc(sizeof(rc_xref) * MAXRACES); + } + for (i = 0; i != MAXRACES; ++i) { + xrefs[i].rc = get_race(i); + xrefs[i].id = (race_t)i; + } + qsort(xrefs, MAXRACES, sizeof(rc_xref), cmp_xref); + } + l=0; r=MAXRACES-1; + while (l<=r) { + int m = (l+r)/2; + if (rcxrefs[m].rc) { + l = m+1; + } else { + return (race_t)xrefs[m].id; + } + } + return NORACE; +} + race_list *get_familiarraces(void) { static int init = 0; diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index 7bccdbba8..663a538ee 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -66,10 +66,26 @@ static void test_race_get(CuTest *tc) { test_cleanup(); } +static void test_old_race(CuTest *tc) +{ + race * rc1, *rc2; + test_setup(); + test_create_race("dwarf"); + rc1 = test_create_race("elf"); + rc2 = test_create_race("onkel"); + CuAssertIntEquals(tc, RC_ELF, old_race(rc1)); + CuAssertIntEquals(tc, NORACE, old_race(rc2)); + rc2 = test_create_race("human"); + CuAssertIntEquals(tc, RC_ELF, old_race(rc1)); + CuAssertIntEquals(tc, RC_HUMAN, old_race(rc2)); + test_cleanup(); +} + CuSuite *get_race_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_race_get); + SUITE_ADD_TEST(suite, test_old_race); SUITE_ADD_TEST(suite, test_rc_name); SUITE_ADD_TEST(suite, test_rc_defaults); SUITE_ADD_TEST(suite, test_rc_find); From e79b36bc366c235dd42f75cb4eef0bb85daa598d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 4 Oct 2016 10:51:37 +0200 Subject: [PATCH 125/675] introduced a memory leak i last commit --- src/kernel/race.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/kernel/race.c b/src/kernel/race.c index ce13d1ef7..5b991eca6 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -100,10 +100,10 @@ int cmp_xref(const void *a, const void *b) return 0; } +static rc_xref *xrefs; race_t old_race(const struct race * rc) { static int cache; - static rc_xref *xrefs; int i, l, r; if (rc_changed(&cache)) { @@ -170,6 +170,8 @@ void free_races(void) { while (races) { race * rc = races->next; free_params(&races->parameters); + free(xrefs); + xrefs = 0; free(races->_name); free(races->def_damage); free(races); From f65bd3b079b3d30ee6bf60a6aaa217cf2cef573d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 5 Oct 2016 09:28:23 +0200 Subject: [PATCH 126/675] disable logging of passwords. yikes --- process/sendreport.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/sendreport.sh b/process/sendreport.sh index 003026f4a..1b9af1d35 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -14,7 +14,7 @@ GAME=$1 EMAIL=$2 FACTION=$3 PASSWD=$4 -echo "$GAME $EMAIL $FACTION $PASSWD" >> /tmp/report.log +#echo "$GAME $EMAIL $FACTION $PASSWD" >> /tmp/report.log function reply() { echo $@ | mutt -s "Reportnachforderung Partei ${FACTION}" $EMAIL From f6b3027d6320a5a6dccfe409528ec0d9247d8085 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 5 Oct 2016 09:30:17 +0200 Subject: [PATCH 127/675] do not log passwords to /tmp, bug 2236 --- process/sendreport.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/sendreport.sh b/process/sendreport.sh index 003026f4a..1b9af1d35 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -14,7 +14,7 @@ GAME=$1 EMAIL=$2 FACTION=$3 PASSWD=$4 -echo "$GAME $EMAIL $FACTION $PASSWD" >> /tmp/report.log +#echo "$GAME $EMAIL $FACTION $PASSWD" >> /tmp/report.log function reply() { echo $@ | mutt -s "Reportnachforderung Partei ${FACTION}" $EMAIL From 5fe0503cd804bc913463142a2be8d62c05a45e12 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 5 Oct 2016 16:43:14 +0200 Subject: [PATCH 128/675] remove the unicode.h include from files that don't use it. --- src/kernel/config.c | 1 - src/kernel/faction.c | 1 - src/kernel/save.c | 1 - src/sqlite.c | 1 - src/xmlreport.c | 1 - 5 files changed, 5 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index ba69f142e..17ac32643 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -70,7 +70,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 0ccf62f52..f97142e45 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -49,7 +49,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include diff --git a/src/kernel/save.c b/src/kernel/save.c index 34a408113..2373d60a0 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -69,7 +69,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include diff --git a/src/sqlite.c b/src/sqlite.c index 37535c9d1..42bfdb3b5 100644 --- a/src/sqlite.c +++ b/src/sqlite.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include diff --git a/src/xmlreport.c b/src/xmlreport.c index 43d7cc55b..fd2b5e464 100644 --- a/src/xmlreport.c +++ b/src/xmlreport.c @@ -61,7 +61,6 @@ without prior permission by the authors of Eressea. #include #include #include -#include #include #ifdef USE_LIBXML2 From fb470b7af1fddce5e3ab9da08d3498c4245a227e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 5 Oct 2016 20:36:01 +0200 Subject: [PATCH 129/675] re-organize lighthouse reporting. --- src/lighthouse.c | 8 +++----- src/reports.c | 39 +++++++++++++++++++-------------------- src/reports.test.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 25 deletions(-) diff --git a/src/lighthouse.c b/src/lighthouse.c index 96b42b333..dd1183558 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -73,13 +73,11 @@ int lighthouse_range(const building * b, const faction * f) region *r = b->region; int c = 0; int cap = buildingcapacity(b); - unit *u; + unit *u, *uown = building_owner(b); for (u = r->units; u; u = u->next) { - if (u->building == b || u == building_owner(b)) { - if (u->building == b) { - c += u->number; - } + if (u->building == b || u == uown) { + c += u->number; if (c > cap) { break; } diff --git a/src/reports.c b/src/reports.c index dc0edf1b3..5a7f29a10 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1170,11 +1170,9 @@ static void add_seen_nb(faction *f, region *r, seen_mode mode) { /** mark all regions seen by the lighthouse. */ -static void prepare_lighthouse(building * b, report_context *ctx) +static void prepare_lighthouse(faction *f, region *r, int range) { - faction *f = ctx->f; - int range = lighthouse_range(b, f); - quicklist *ql, *rlist = get_regions_distance(b->region, range); + quicklist *ql, *rlist = get_regions_distance(r, range); int qi; for (ql = rlist, qi = 0; ql; ql_advance(&ql, &qi, 1)) { @@ -1316,7 +1314,6 @@ static void cb_add_seen(region *r, unit *u, void *cbdata) { void prepare_report(report_context *ctx, faction *f) { region *r; - building *b; static int config; static bool rule_region_owners; const struct building_type *bt_lighthouse = bt_find("lighthouse"); @@ -1334,34 +1331,36 @@ void prepare_report(report_context *ctx, faction *f) ctx->last = lastregion(f); for (r = ctx->first; r!=ctx->last; r = r->next) { + int range = 0; unit *u; + if (fval(r, RF_LIGHTHOUSE) && bt_lighthouse) { + if (rule_region_owners && f == region_get_owner(r)) { + /* region owners get the report from lighthouses */ + building *b; - if (fval(r, RF_LIGHTHOUSE)) { - /* region owners get the report from lighthouses */ - if (rule_region_owners && bt_lighthouse) { - for (b = rbuildings(r); b; b = b->next) { - if (b && b->type == bt_lighthouse) { - u = building_owner(b); - if (u && u->faction==f) { - prepare_lighthouse(b, ctx); - add_seen_nb(f, r, seen_unit); - } + for (b = r->buildings; b; b = b->next) { + if (b->type == bt_lighthouse) { + int br = lighthouse_range(b, NULL); + if (br > range) range = br; } } } - } for (u = r->units; u; u = u->next) { - if (u->faction==f) { + if (u->faction == f) { add_seen_nb(f, r, seen_unit); - if (fval(r, RF_LIGHTHOUSE)) { + if (fval(r, RF_LIGHTHOUSE) && bt_lighthouse) { if (u->building && u->building->type == bt_lighthouse && inside_building(u)) { - /* we are in a lighthouse. add the regions we can see from here! */ - prepare_lighthouse(u->building, ctx); + int br = lighthouse_range(u->building, f); + if (br > range) range = br; } } } } + if (range > 0) { + /* we are in at least one lighthouse. add the regions we can see from here! */ + prepare_lighthouse(f, r, range); + } if (fval(r, RF_TRAVELUNIT) && r->seen.mode #include #include #include @@ -344,6 +345,43 @@ static void test_prepare_lighthouse(CuTest *tc) { test_cleanup(); } +static void test_prepare_lighthouse_owners(CuTest *tc) { + report_context ctx; + faction *f; + region *r1, *r2, *r3; + unit *u; + building *b; + building_type *btype; + const struct terrain_type *t_ocean, *t_plain; + + test_setup(); + config_set("rules.region_owner_pay_building", "lighthouse"); + config_set("rules.region_owners", "1"); + t_ocean = test_create_terrain("ocean", SEA_REGION); + t_plain = test_create_terrain("plain", LAND_REGION); + f = test_create_faction(0); + r1 = test_create_region(0, 0, t_plain); + r2 = test_create_region(1, 0, t_ocean); + r3 = test_create_region(2, 0, t_ocean); + btype = test_create_buildingtype("lighthouse"); + b = test_create_building(r1, btype); + b->flags |= BLD_MAINTAINED; + b->size = 10; + update_lighthouse(b); + u = test_create_unit(f, r1); + u = test_create_unit(test_create_faction(0), r1); + u->building = b; + set_level(u, SK_PERCEPTION, 3); + region_set_owner(b->region, f, 0); + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, r1, ctx.first); + CuAssertPtrEquals(tc, NULL, ctx.last); + CuAssertIntEquals(tc, seen_unit, r1->seen.mode); + CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode); + CuAssertIntEquals(tc, seen_neighbour, r3->seen.mode); + test_cleanup(); +} + static void test_prepare_report(CuTest *tc) { report_context ctx; faction *f; @@ -432,6 +470,7 @@ CuSuite *get_reports_suite(void) SUITE_ADD_TEST(suite, test_seen_neighbours); SUITE_ADD_TEST(suite, test_seen_travelthru); SUITE_ADD_TEST(suite, test_prepare_lighthouse); + SUITE_ADD_TEST(suite, test_prepare_lighthouse_owners); SUITE_ADD_TEST(suite, test_prepare_lighthouse_capacity); SUITE_ADD_TEST(suite, test_prepare_travelthru); SUITE_ADD_TEST(suite, test_reorder_units); From 38721e20464d9d14620fd5d771e263f969901253 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 7 Oct 2016 19:33:50 +0200 Subject: [PATCH 130/675] remove all mention of centaurs from the code and configuration --- res/eressea/equipment.xml | 5 ----- res/races/zombie.xml | 2 +- src/economy.c | 35 +---------------------------------- src/kernel/faction.c | 11 +++-------- src/kernel/race.h | 1 - src/kernel/unit.c | 12 +++--------- src/kernel/xmlreader.c | 2 -- 7 files changed, 8 insertions(+), 60 deletions(-) diff --git a/res/eressea/equipment.xml b/res/eressea/equipment.xml index f35505bc0..bf7e38376 100644 --- a/res/eressea/equipment.xml +++ b/res/eressea/equipment.xml @@ -269,11 +269,6 @@ - - - - - diff --git a/res/races/zombie.xml b/res/races/zombie.xml index faecf021d..8c23aea83 100644 --- a/res/races/zombie.xml +++ b/res/races/zombie.xml @@ -3,7 +3,7 @@ recruitcost="-1" maintenance="0" weight="1000" capacity="440" speed="1.000000" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="no" walk="yes" shapeshift="no" giveperson="no" giveunit="no" - getitem="no" recruitethereal="no" equipment="yes" scarepeasants="yes" + getitem="no" equipment="yes" scarepeasants="yes" cansteal="no" unarmedguard="yes" absorbpeasants="yes" noheal="yes" undead="yes" resistpierce="yes"> diff --git a/src/economy.c b/src/economy.c index 8f6a1afa1..b17ef1cad 100644 --- a/src/economy.c +++ b/src/economy.c @@ -258,10 +258,6 @@ void add_recruits(unit * u, int number, int wanted) strlcat(equipment, "_unit", sizeof(equipment)); equip_unit(unew, get_equipment(equipment)); - if (u_race(unew)->ec_flags & ECF_REC_HORSES) { - change_level(unew, SK_RIDING, 1); - } - if (unew != u) { transfermen(unew, u, unew->number); remove_unit(&r->units, unew); @@ -278,24 +274,6 @@ static int any_recruiters(const struct race *rc, int qty) return (int)(qty * 2 * rc->recruit_multi); } -/*static int peasant_recruiters(const struct race *rc, int qty) -{ -if (rc->ec_flags & ECF_REC_ETHEREAL) -return -1; -if (rc->ec_flags & ECF_REC_HORSES) -return -1; -return (int)(qty * 2 * rc->recruit_multi); -}*/ - -static int horse_recruiters(const struct race *rc, int qty) -{ - if (rc->ec_flags & ECF_REC_ETHEREAL) - return -1; - if (rc->ec_flags & ECF_REC_HORSES) - return (int)(qty * 2.0 * rc->recruit_multi); - return -1; -} - static int do_recruiting(recruitment * recruits, int available) { recruitment *rec; @@ -407,17 +385,6 @@ static void expandrecruit(region * r, request * recruitorders) int orc_total = 0; - /* centaurs: */ - recruits = select_recruitment(&recruitorders, horse_recruiters, &orc_total); - if (recruits) { - int recruited, horses = rhorses(r) * 2; - if (orc_total < horses) - horses = orc_total; - recruited = do_recruiting(recruits, horses); - rsethorses(r, (horses - recruited) / 2); - free_recruitments(recruits); - } - /* peasant limited: */ recruits = select_recruitment(&recruitorders, any_recruiters, &orc_total); if (recruits) { @@ -539,7 +506,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders) return; } - if (!(rc->ec_flags & ECF_REC_HORSES) && fval(r, RF_ORCIFIED)) { + if (fval(r, RF_ORCIFIED)) { if (rc != get_race(RC_ORC)) { cmistake(u, ord, 238, MSG_EVENT); return; diff --git a/src/kernel/faction.c b/src/kernel/faction.c index f97142e45..774a6aec8 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -386,19 +386,14 @@ void destroyfaction(faction ** fp) const race *rc = u_race(u); int m = rmoney(r); + /* Personen gehen nur an die Bauern, wenn sie auch von dort + * stammen */ if ((rc->ec_flags & ECF_REC_ETHEREAL) == 0) { int p = rpeasants(u->region); int h = rhorses(u->region); item *itm; - /* Personen gehen nur an die Bauern, wenn sie auch von dort - * stammen */ - if (rc->ec_flags & ECF_REC_HORSES) { /* Zentauren an die Pferde */ - h += u->number; - } - else { /* Orks zählen nur zur Hälfte */ - p += (int)(u->number * rc->recruit_multi); - } + p += (int)(u->number * rc->recruit_multi); for (itm = u->items; itm; itm = itm->next) { if (itm->type->flags & ITF_ANIMAL) { h += itm->number; diff --git a/src/kernel/race.h b/src/kernel/race.h index 214f2738d..dc3becabb 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -217,7 +217,6 @@ extern "C" { #define GIVEPERSON (1<<2) /* bergibt Personen */ #define GIVEUNIT (1<<3) /* Einheiten an andere Partei bergeben */ #define GETITEM (1<<4) /* nimmt Gegenstnde an */ -#define ECF_REC_HORSES (1<<6) /* Rekrutiert aus Pferden */ #define ECF_REC_ETHEREAL (1<<7) /* Rekrutiert aus dem Nichts */ #define ECF_REC_UNLIMITED (1<<8) /* Rekrutiert ohne Limit */ diff --git a/src/kernel/unit.c b/src/kernel/unit.c index ab3bd294c..b499705a4 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1084,15 +1084,9 @@ void transfermen(unit * u, unit * dst, int n) else if (r->land) { if ((u_race(u)->ec_flags & ECF_REC_ETHEREAL) == 0) { const race *rc = u_race(u); - if (rc->ec_flags & ECF_REC_HORSES) { /* Zentauren an die Pferde */ - int h = rhorses(r) + n; - rsethorses(r, h); - } - else { - int p = rpeasants(r); - p += (int)(n * rc->recruit_multi); - rsetpeasants(r, p); - } + int p = rpeasants(r); + p += (int)(n * rc->recruit_multi); + rsetpeasants(r, p); } } } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 894647f89..e022effaf 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1730,8 +1730,6 @@ static int parse_races(xmlDocPtr doc) rc->ec_flags |= GIVEUNIT; if (xml_bvalue(node, "getitem", false)) rc->ec_flags |= GETITEM; - if (xml_bvalue(node, "recruithorses", false)) - rc->ec_flags |= ECF_REC_HORSES; if (xml_bvalue(node, "recruitethereal", false)) rc->ec_flags |= ECF_REC_ETHEREAL; if (xml_bvalue(node, "recruitunlimited", false)) From 9287d0c1b4cf2a9ac117947d19862e7cebf5c919 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 7 Oct 2016 22:06:47 +0200 Subject: [PATCH 131/675] unused function --- src/economy.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/economy.c b/src/economy.c index b17ef1cad..6ec5d9191 100644 --- a/src/economy.c +++ b/src/economy.c @@ -180,15 +180,6 @@ static void expandorders(region * r, request * requests) /* ------------------------------------------------------------- */ -static void change_level(unit * u, skill_t sk, int bylevel) -{ - skill *sv = unit_skill(u, sk); - assert(bylevel > 0); - if (sv == 0) - sv = add_skill(u, sk); - sk_set(sv, sv->level + bylevel); -} - typedef struct recruitment { struct recruitment *next; faction *f; From 3d191b65732c9fb81b3fdc578a0e0944f20e3a5f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 9 Oct 2016 10:01:31 +0200 Subject: [PATCH 132/675] not likely to get fixed --- src/kernel/config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index f7eb0e303..8df618aa5 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -690,7 +690,7 @@ static const char * relpath(char *buf, size_t sz, const char *path) { static const char *g_datadir; const char *datapath(void) { - static char zText[MAX_PATH]; // FIXME: static return value + static char zText[MAX_PATH]; if (g_datadir) return g_datadir; return relpath(zText, sizeof(zText), "data"); @@ -704,7 +704,7 @@ void set_datapath(const char *path) static const char *g_reportdir; const char *reportpath(void) { - static char zText[MAX_PATH]; // FIXME: static return value + static char zText[MAX_PATH]; if (g_reportdir) return g_reportdir; return relpath(zText, sizeof(zText), "reports"); From 331015a511cec2beb578224b3a3b1401b5ddb854 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Oct 2016 12:46:07 +0200 Subject: [PATCH 133/675] fix an endless loop in unicode_utf8_to_cp437 for characters not in the table. --- src/util/unicode.c | 12 ++++++++---- src/util/unicode.test.c | 11 +++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/util/unicode.c b/src/util/unicode.c index 94b6e3d5a..ffc170cc9 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -506,10 +506,14 @@ size_t * length) *cp_character = (char)xref[m].cp437; break; } - else if (xref[m].ucs4 < ucs4_character) - l = m; - else - r = m; + else if (xref[m].ucs4 < ucs4_character) { + if (l == m) l = r; + else l = m; + } + else { + if (r == m) r = l; + else r = m; + } } if (l == r) { *cp_character = '?'; diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index 958b695e2..b643775a9 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -16,9 +16,20 @@ static void test_unicode_tolower(CuTest * tc) CuAssertStrEquals(tc, "helloX", buffer); } +static void test_unicode_utf8_to_cp437(CuTest *tc) +{ + const char utf8_str[4] = { 0xc3, 0x98, 'l', 0 }; // Øl + char ch; + size_t sz; + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); +} + CuSuite *get_unicode_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_unicode_tolower); + SUITE_ADD_TEST(suite, test_unicode_utf8_to_cp437); return suite; } From 103a946f413af04ff135caa7638188fd497f3388 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Oct 2016 13:12:47 +0200 Subject: [PATCH 134/675] fix endless loop in cp1252 search (wrong sort) fix indentation additional testing --- src/gmtool.c | 4 +- src/util/log.c | 8 +- src/util/unicode.c | 408 ++++++++++++++++++++-------------------- src/util/unicode.h | 6 +- src/util/unicode.test.c | 43 ++++- 5 files changed, 251 insertions(+), 218 deletions(-) diff --git a/src/gmtool.c b/src/gmtool.c index 7a87e4ae6..9533ccab8 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -88,7 +88,7 @@ static void unicode_remove_diacritics(const char *rp, char *wp) { while (*rp) { if (gm_codepage >=0 && *rp & 0x80) { size_t sz = 0; - char ch; + unsigned char ch; switch (gm_codepage) { case 1252: unicode_utf8_to_cp1252(&ch, rp, &sz); @@ -101,7 +101,7 @@ static void unicode_remove_diacritics(const char *rp, char *wp) { break; } rp += sz; - *wp++ = ch; + *wp++ = (char)ch; } else { *wp++ = *rp++; diff --git a/src/util/log.c b/src/util/log.c index d330a96db..1d3724c50 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -64,11 +64,11 @@ void log_destroy(log_t *handle) { #define LOG_MAXBACKUPS 5 static int -cp_convert(const char *format, char *buffer, size_t length, int codepage) +cp_convert(const char *format, unsigned char *buffer, size_t length, int codepage) { /* when console output on MSDOS, convert to codepage */ const char *input = format; - char *pos = buffer; + unsigned char *pos = buffer; while (pos + 1 < buffer + length && *input) { size_t size = 0; @@ -156,10 +156,10 @@ static void _log_write(FILE * stream, int codepage, const char *format, va_list { if (codepage) { char buffer[MAXLENGTH]; - char converted[MAXLENGTH]; + unsigned char converted[MAXLENGTH]; vsnprintf(buffer, sizeof(buffer), format, args); if (cp_convert(buffer, converted, MAXLENGTH, codepage) == 0) { - fputs(converted, stream); + fputs((char *)converted, stream); } else { /* fall back to non-converted output */ diff --git a/src/util/unicode.c b/src/util/unicode.c index ffc170cc9..f7ea2653b 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -1,4 +1,4 @@ -/* +/* * +-------------------+ Christian Schlittchen * | | Enno Rehling * | Eressea PBEM host | Katja Zedel @@ -71,7 +71,7 @@ int unicode_utf8_tolower(utf8_t * op, size_t outlen, const utf8_t * ip) int unicode_latin1_to_utf8(utf8_t * dst, size_t * outlen, const char *in, -size_t * inlen) + size_t * inlen) { int is = (int)*inlen; int os = (int)*outlen; @@ -104,7 +104,7 @@ size_t * inlen) return (int)*outlen; } -int unicode_utf8_strcasecmp(const utf8_t * a, const char *b) +int unicode_utf8_strcasecmp(const utf8_t * a, const utf8_t *b) { while (*a && *b) { int ret; @@ -147,7 +147,7 @@ int unicode_utf8_strcasecmp(const utf8_t * a, const char *b) /* Convert a UCS-4 character to UTF-8. */ int unicode_ucs4_to_utf8(utf8_t * utf8_character, size_t * size, -ucs4_t ucs4_character) + ucs4_t ucs4_character) { int utf8_bytes; @@ -214,7 +214,7 @@ ucs4_t ucs4_character) /* Convert a UTF-8 encoded character to UCS-4. */ int unicode_utf8_to_ucs4(ucs4_t * ucs4_character, const utf8_t * utf8_string, -size_t * length) + size_t * length) { utf8_t utf8_character = utf8_string[0]; @@ -317,8 +317,8 @@ size_t * length) /** Convert a UTF-8 encoded character to CP437. */ int -unicode_utf8_to_cp437(char *cp_character, const utf8_t * utf8_string, -size_t * length) +unicode_utf8_to_cp437(unsigned char *cp_character, const utf8_t * utf8_string, + size_t * length) { ucs4_t ucs4_character; int result; @@ -330,174 +330,173 @@ size_t * length) } if (ucs4_character < 0x7F) { - *cp_character = (char)ucs4_character; + *cp_character = (unsigned char)ucs4_character; } else { struct { ucs4_t ucs4; unsigned char cp437; } xref[160] = { - { - 0x00A0, 255 }, { - 0x00A1, 173 }, { - 0x00A2, 155 }, { - 0x00A3, 156 }, { - 0x00A5, 157 }, { - 0x00A7, 21 }, { - 0x00AA, 166 }, { - 0x00AB, 174 }, { - 0x00AC, 170 }, { - 0x00B0, 248 }, { - 0x00B1, 241 }, { - 0x00B2, 253 }, { - 0x00B5, 230 }, { - 0x00B6, 20 }, { - 0x00B7, 250 }, { - 0x00BA, 167 }, { - 0x00BB, 175 }, { - 0x00BC, 172 }, { - 0x00BD, 171 }, { - 0x00BF, 168 }, { - 0x00C4, 142 }, { - 0x00C5, 143 }, { - 0x00C6, 146 }, { - 0x00C7, 128 }, { - 0x00C9, 144 }, { - 0x00D1, 165 }, { - 0x00D6, 153 }, { - 0x00DC, 154 }, { - 0x00DF, 225 }, { - 0x00E0, 133 }, { - 0x00E1, 160 }, { - 0x00E2, 131 }, { - 0x00E4, 132 }, { - 0x00E5, 134 }, { - 0x00E6, 145 }, { - 0x00E7, 135 }, { - 0x00E8, 138 }, { - 0x00E9, 130 }, { - 0x00EA, 136 }, { - 0x00EB, 137 }, { - 0x00EC, 141 }, { - 0x00ED, 161 }, { - 0x00EE, 140 }, { - 0x00EF, 139 }, { - 0x00F1, 164 }, { - 0x00F2, 149 }, { - 0x00F3, 162 }, { - 0x00F4, 147 }, { - 0x00F6, 148 }, { - 0x00F7, 246 }, { - 0x00F9, 151 }, { - 0x00FA, 163 }, { - 0x00FB, 150 }, { - 0x00FC, 129 }, { - 0x00FF, 152 }, { - 0x0192, 159 }, { - 0x0393, 226 }, { - 0x0398, 233 }, { - 0x03A3, 228 }, { - 0x03A6, 232 }, { - 0x03A9, 234 }, { - 0x03B1, 224 }, { - 0x03B4, 235 }, { - 0x03B5, 238 }, { - 0x03C0, 227 }, { - 0x03C3, 229 }, { - 0x03C4, 231 }, { - 0x03C6, 237 }, { - 0x2022, 7 }, { - 0x203C, 19 }, { - 0x207F, 252 }, { - 0x20A7, 158 }, { - 0x2190, 27 }, { - 0x2191, 24 }, { - 0x2192, 26 }, { - 0x2193, 25 }, { - 0x2194, 29 }, { - 0x2195, 18 }, { - 0x21A8, 23 }, { - 0x2219, 249 }, { - 0x221A, 251 }, { - 0x221E, 236 }, { - 0x221F, 28 }, { - 0x2229, 239 }, { - 0x2248, 247 }, { - 0x2261, 240 }, { - 0x2264, 243 }, { - 0x2265, 242 }, { - 0x2302, 127 }, { - 0x2310, 169 }, { - 0x2320, 244 }, { - 0x2321, 245 }, { - 0x2500, 196 }, { - 0x2502, 179 }, { - 0x250C, 218 }, { - 0x2510, 191 }, { - 0x2514, 192 }, { - 0x2518, 217 }, { - 0x251C, 195 }, { - 0x2524, 180 }, { - 0x252C, 194 }, { - 0x2534, 193 }, { - 0x253C, 197 }, { - 0x2550, 205 }, { - 0x2551, 186 }, { - 0x2552, 213 }, { - 0x2553, 214 }, { - 0x2554, 201 }, { - 0x2555, 184 }, { - 0x2556, 183 }, { - 0x2557, 187 }, { - 0x2558, 212 }, { - 0x2559, 211 }, { - 0x255A, 200 }, { - 0x255B, 190 }, { - 0x255C, 189 }, { - 0x255D, 188 }, { - 0x255E, 198 }, { - 0x255F, 199 }, { - 0x2560, 204 }, { - 0x2561, 181 }, { - 0x2562, 182 }, { - 0x2563, 185 }, { - 0x2564, 209 }, { - 0x2565, 210 }, { - 0x2566, 203 }, { - 0x2567, 207 }, { - 0x2568, 208 }, { - 0x2569, 202 }, { - 0x256A, 216 }, { - 0x256B, 215 }, { - 0x256C, 206 }, { - 0x2580, 223 }, { - 0x2584, 220 }, { - 0x2588, 219 }, { - 0x258C, 221 }, { - 0x2590, 222 }, { - 0x2591, 176 }, { - 0x2592, 177 }, { - 0x2593, 178 }, { - 0x25A0, 254 }, { - 0x25AC, 22 }, { - 0x25B2, 30 }, { - 0x25BA, 16 }, { - 0x25BC, 31 }, { - 0x25C4, 17 }, { - 0x25CB, 9 }, { - 0x25D8, 8 }, { - 0x25D9, 10 }, { - 0x263A, 1 }, { - 0x263B, 2 }, { - 0x263C, 15 }, { - 0x2640, 12 }, { - 0x2642, 11 }, { - 0x2660, 6 }, { - 0x2663, 5 }, { - 0x2665, 3 }, { - 0x2666, 4 }, { - 0x266A, 13 }, { - 0x266B, 14 } + { 0x00A0, 255 }, + { 0x00A1, 173 }, + { 0x00A2, 155 }, + { 0x00A3, 156 }, + { 0x00A5, 157 }, + { 0x00A7, 21 }, + { 0x00AA, 166 }, + { 0x00AB, 174 }, + { 0x00AC, 170 }, + { 0x00B0, 248 }, + { 0x00B1, 241 }, + { 0x00B2, 253 }, + { 0x00B5, 230 }, + { 0x00B6, 20 }, + { 0x00B7, 250 }, + { 0x00BA, 167 }, + { 0x00BB, 175 }, + { 0x00BC, 172 }, + { 0x00BD, 171 }, + { 0x00BF, 168 }, + { 0x00C4, 142 }, + { 0x00C5, 143 }, + { 0x00C6, 146 }, + { 0x00C7, 128 }, + { 0x00C9, 144 }, + { 0x00D1, 165 }, + { 0x00D6, 153 }, + { 0x00DC, 154 }, + { 0x00DF, 225 }, + { 0x00E0, 133 }, + { 0x00E1, 160 }, + { 0x00E2, 131 }, + { 0x00E4, 132 }, + { 0x00E5, 134 }, + { 0x00E6, 145 }, + { 0x00E7, 135 }, + { 0x00E8, 138 }, + { 0x00E9, 130 }, + { 0x00EA, 136 }, + { 0x00EB, 137 }, + { 0x00EC, 141 }, + { 0x00ED, 161 }, + { 0x00EE, 140 }, + { 0x00EF, 139 }, + { 0x00F1, 164 }, + { 0x00F2, 149 }, + { 0x00F3, 162 }, + { 0x00F4, 147 }, + { 0x00F6, 148 }, + { 0x00F7, 246 }, + { 0x00F9, 151 }, + { 0x00FA, 163 }, + { 0x00FB, 150 }, + { 0x00FC, 129 }, + { 0x00FF, 152 }, + { 0x0192, 159 }, + { 0x0393, 226 }, + { 0x0398, 233 }, + { 0x03A3, 228 }, + { 0x03A6, 232 }, + { 0x03A9, 234 }, + { 0x03B1, 224 }, + { 0x03B4, 235 }, + { 0x03B5, 238 }, + { 0x03C0, 227 }, + { 0x03C3, 229 }, + { 0x03C4, 231 }, + { 0x03C6, 237 }, + { 0x2022, 7 }, + { 0x203C, 19 }, + { 0x207F, 252 }, + { 0x20A7, 158 }, + { 0x2190, 27 }, + { 0x2191, 24 }, + { 0x2192, 26 }, + { 0x2193, 25 }, + { 0x2194, 29 }, + { 0x2195, 18 }, + { 0x21A8, 23 }, + { 0x2219, 249 }, + { 0x221A, 251 }, + { 0x221E, 236 }, + { 0x221F, 28 }, + { 0x2229, 239 }, + { 0x2248, 247 }, + { 0x2261, 240 }, + { 0x2264, 243 }, + { 0x2265, 242 }, + { 0x2302, 127 }, + { 0x2310, 169 }, + { 0x2320, 244 }, + { 0x2321, 245 }, + { 0x2500, 196 }, + { 0x2502, 179 }, + { 0x250C, 218 }, + { 0x2510, 191 }, + { 0x2514, 192 }, + { 0x2518, 217 }, + { 0x251C, 195 }, + { 0x2524, 180 }, + { 0x252C, 194 }, + { 0x2534, 193 }, + { 0x253C, 197 }, + { 0x2550, 205 }, + { 0x2551, 186 }, + { 0x2552, 213 }, + { 0x2553, 214 }, + { 0x2554, 201 }, + { 0x2555, 184 }, + { 0x2556, 183 }, + { 0x2557, 187 }, + { 0x2558, 212 }, + { 0x2559, 211 }, + { 0x255A, 200 }, + { 0x255B, 190 }, + { 0x255C, 189 }, + { 0x255D, 188 }, + { 0x255E, 198 }, + { 0x255F, 199 }, + { 0x2560, 204 }, + { 0x2561, 181 }, + { 0x2562, 182 }, + { 0x2563, 185 }, + { 0x2564, 209 }, + { 0x2565, 210 }, + { 0x2566, 203 }, + { 0x2567, 207 }, + { 0x2568, 208 }, + { 0x2569, 202 }, + { 0x256A, 216 }, + { 0x256B, 215 }, + { 0x256C, 206 }, + { 0x2580, 223 }, + { 0x2584, 220 }, + { 0x2588, 219 }, + { 0x258C, 221 }, + { 0x2590, 222 }, + { 0x2591, 176 }, + { 0x2592, 177 }, + { 0x2593, 178 }, + { 0x25A0, 254 }, + { 0x25AC, 22 }, + { 0x25B2, 30 }, + { 0x25BA, 16 }, + { 0x25BC, 31 }, + { 0x25C4, 17 }, + { 0x25CB, 9 }, + { 0x25D8, 8 }, + { 0x25D9, 10 }, + { 0x263A, 1 }, + { 0x263B, 2 }, + { 0x263C, 15 }, + { 0x2640, 12 }, + { 0x2642, 11 }, + { 0x2660, 6 }, + { 0x2663, 5 }, + { 0x2665, 3 }, + { 0x2666, 4 }, + { 0x266A, 13 }, + { 0x266B, 14 } }; int l = 0, r = 160; while (l != r) { @@ -509,7 +508,7 @@ size_t * length) else if (xref[m].ucs4 < ucs4_character) { if (l == m) l = r; else l = m; - } + } else { if (r == m) r = l; else r = m; @@ -523,7 +522,7 @@ size_t * length) } /** Convert a UTF-8 encoded character to ASCII, with '?' replacements. */ -int unicode_utf8_to_ascii(char *cp_character, const utf8_t * utf8_string, +int unicode_utf8_to_ascii(unsigned char *cp_character, const utf8_t * utf8_string, size_t *length) { int result = unicode_utf8_to_cp437(cp_character, utf8_string, length); @@ -536,7 +535,7 @@ int unicode_utf8_to_ascii(char *cp_character, const utf8_t * utf8_string, } /** Convert a UTF-8 encoded character to CP1252. */ -int unicode_utf8_to_cp1252(char *cp_character, const utf8_t * utf8_string, +int unicode_utf8_to_cp1252(unsigned char *cp_character, const utf8_t * utf8_string, size_t * length) { ucs4_t ucs4_character; @@ -556,39 +555,38 @@ int unicode_utf8_to_cp1252(char *cp_character, const utf8_t * utf8_string, ucs4_t ucs4; unsigned char cp; } xref[] = { - { - 0x20ac, 0x80 }, { - 0x0081, 0x81 }, { - 0x201a, 0x82 }, { - 0x0192, 0x83 }, { - 0x201e, 0x84 }, { - 0x2026, 0x85 }, { - 0x2020, 0x86 }, { - 0x2021, 0x87 }, { - 0x02c6, 0x88 }, { - 0x2030, 0x89 }, { - 0x0160, 0x8a }, { - 0x2039, 0x8b }, { - 0x0152, 0x8c }, { - 0x008d, 0x8d }, { - 0x017d, 0x8e }, { - 0x008f, 0x8f }, { - 0x0090, 0x90 }, { - 0x2018, 0x91 }, { - 0x2019, 0x92 }, { - 0x201c, 0x93 }, { - 0x201d, 0x94 }, { - 0x2022, 0x95 }, { - 0x2013, 0x96 }, { - 0x2014, 0x97 }, { - 0x02dc, 0x98 }, { - 0x2122, 0x99 }, { - 0x0161, 0x9a }, { - 0x203a, 0x9b }, { - 0x0153, 0x9c }, { - 0x009d, 0x9d }, { - 0x017e, 0x9e }, { - 0x0178, 0x9f } + { 0x0081, 0x81 }, + { 0x008d, 0x8d }, + { 0x008f, 0x8f }, + { 0x0090, 0x90 }, + { 0x009d, 0x9d }, + { 0x0152, 0x8c }, + { 0x0153, 0x9c }, + { 0x0160, 0x8a }, + { 0x0161, 0x9a }, + { 0x0178, 0x9f }, + { 0x017d, 0x8e }, + { 0x017e, 0x9e }, + { 0x0192, 0x83 }, + { 0x02c6, 0x88 }, + { 0x02dc, 0x98 }, + { 0x2013, 0x96 }, + { 0x2014, 0x97 }, + { 0x2018, 0x91 }, + { 0x2019, 0x92 }, + { 0x201a, 0x82 }, + { 0x201c, 0x93 }, + { 0x201d, 0x94 }, + { 0x201e, 0x84 }, + { 0x2022, 0x95 }, + { 0x2026, 0x85 }, + { 0x2020, 0x86 }, + { 0x2021, 0x87 }, + { 0x2030, 0x89 }, + { 0x203a, 0x9b }, + { 0x2039, 0x8b }, + { 0x20ac, 0x80 }, + { 0x2122, 0x99 } }; int l = 0, r = sizeof(xref) / sizeof(xref[0]); while (l != r) { diff --git a/src/util/unicode.h b/src/util/unicode.h index b061cd6fb..df68ade02 100644 --- a/src/util/unicode.h +++ b/src/util/unicode.h @@ -28,15 +28,15 @@ extern "C" { typedef unsigned long ucs4_t; typedef char utf8_t; - int unicode_utf8_to_cp437(char *result, const utf8_t * utf8_string, + int unicode_utf8_to_cp437(unsigned char *result, const utf8_t * utf8_string, size_t * length); - int unicode_utf8_to_cp1252(char *result, const utf8_t * utf8_string, + int unicode_utf8_to_cp1252(unsigned char *result, const utf8_t * utf8_string, size_t * length); int unicode_utf8_to_ucs4(ucs4_t * result, const utf8_t * utf8_string, size_t * length); int unicode_ucs4_to_utf8(utf8_t * result, size_t * size, ucs4_t ucs4_character); - int unicode_utf8_to_ascii(char *cp_character, const utf8_t * utf8_string, + int unicode_utf8_to_ascii(unsigned char *cp_character, const utf8_t * utf8_string, size_t *length); int unicode_utf8_strcasecmp(const utf8_t * a, const utf8_t * b); int unicode_latin1_to_utf8(utf8_t * out, size_t * outlen, diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index b643775a9..dc33b02a8 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -16,20 +16,55 @@ static void test_unicode_tolower(CuTest * tc) CuAssertStrEquals(tc, "helloX", buffer); } -static void test_unicode_utf8_to_cp437(CuTest *tc) +static void test_unicode_utf8_to_other(CuTest *tc) { - const char utf8_str[4] = { 0xc3, 0x98, 'l', 0 }; // Øl - char ch; + const char utf8_str[] = { 0xc3, 0x98, 0xc5, 0xb8, 0xc2, 0x9d, 'l', 0 }; // ØŸl + unsigned char ch; size_t sz; CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str, &sz)); CuAssertIntEquals(tc, 2, sz); CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str+2, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str+4, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str + 6, &sz)); + CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 'l', ch); + + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 216, ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str+2, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 120, ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str + 4, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 0x9d, ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str + 6, &sz)); + CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 'l', ch); + + CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 2, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 4, &sz)); + CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, '?', ch); + CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 6, &sz)); + CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 'l', ch); } CuSuite *get_unicode_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_unicode_tolower); - SUITE_ADD_TEST(suite, test_unicode_utf8_to_cp437); + SUITE_ADD_TEST(suite, test_unicode_utf8_to_other); return suite; } From 75aa7954676cc27f135436a099a09e5f1a8b65f3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Oct 2016 13:19:39 +0200 Subject: [PATCH 135/675] gcc appeasement (overflow in constant conversion). --- src/util/unicode.test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index dc33b02a8..f485808cb 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -18,7 +18,8 @@ static void test_unicode_tolower(CuTest * tc) static void test_unicode_utf8_to_other(CuTest *tc) { - const char utf8_str[] = { 0xc3, 0x98, 0xc5, 0xb8, 0xc2, 0x9d, 'l', 0 }; // ØŸl + const unsigned char uchar_str[] = { 0xc3, 0x98, 0xc5, 0xb8, 0xc2, 0x9d, 'l', 0 }; // ØŸl + utf8_t *utf8_str = (utf8_t *)uchar_str; unsigned char ch; size_t sz; CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str, &sz)); From a4305f3b0c2407493dc0c82c3426c4583507e72f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 9 Oct 2016 10:06:51 +0200 Subject: [PATCH 136/675] fix gcc conversion warnings --- src/util/unicode.test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index f485808cb..410e8e68a 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -23,42 +23,42 @@ static void test_unicode_utf8_to_other(CuTest *tc) unsigned char ch; size_t sz; CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str+2, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str+4, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str + 6, &sz)); - CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 1, (int)sz); CuAssertIntEquals(tc, 'l', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, 216, ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str+2, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, 120, ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str + 4, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, 0x9d, ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str + 6, &sz)); - CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 1, (int)sz); CuAssertIntEquals(tc, 'l', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 2, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 4, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 6, &sz)); - CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 1, (int)sz); CuAssertIntEquals(tc, 'l', ch); } From 75422e1ba630830b19030235db824a28d0df969f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 9 Oct 2016 10:06:51 +0200 Subject: [PATCH 137/675] fix gcc conversion warnings --- src/util/unicode.test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index f485808cb..410e8e68a 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -23,42 +23,42 @@ static void test_unicode_utf8_to_other(CuTest *tc) unsigned char ch; size_t sz; CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str+2, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str+4, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str + 6, &sz)); - CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 1, (int)sz); CuAssertIntEquals(tc, 'l', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, 216, ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str+2, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, 120, ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str + 4, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, 0x9d, ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_cp1252(&ch, utf8_str + 6, &sz)); - CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 1, (int)sz); CuAssertIntEquals(tc, 'l', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 2, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 4, &sz)); - CuAssertIntEquals(tc, 2, sz); + CuAssertIntEquals(tc, 2, (int)sz); CuAssertIntEquals(tc, '?', ch); CuAssertIntEquals(tc, 0, unicode_utf8_to_ascii(&ch, utf8_str + 6, &sz)); - CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 1, (int)sz); CuAssertIntEquals(tc, 'l', ch); } From 18679c9d9d45a770b47f8abc3f36a4a86d04a3d4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 9 Oct 2016 10:08:06 +0200 Subject: [PATCH 138/675] release version 3.9.3 --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index e8e29ed2a..88c0c65aa 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 9 -#define VERSION_BUILD 2 +#define VERSION_BUILD 3 From 0de30cd3768ac73cd54ce529fa23ca6835bee328 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 16 Oct 2016 11:58:42 +0200 Subject: [PATCH 139/675] remove discontinued submodules if they are checked out --- s/build | 1 + s/preview | 1 + 2 files changed, 2 insertions(+) diff --git a/s/build b/s/build index b59804626..820e330f9 100755 --- a/s/build +++ b/s/build @@ -33,6 +33,7 @@ if [ ! -d $ROOT/$BUILD ]; then exit fi +rm -rf crypto tolua git submodule update echo "build eressea" diff --git a/s/preview b/s/preview index 79411aea6..86a4f8918 100755 --- a/s/preview +++ b/s/preview @@ -22,6 +22,7 @@ exit $2 # otherwise function build() { assert_dir $SOURCE cd $SOURCE +rm -rf crypto tolua git fetch || abort "failed to update source. do you have local changes?" [ -z $1 ] || git checkout $1 git pull From 919001fae0a8c4b3fafe68b3187602fe88a2fbe2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 16 Oct 2016 16:41:08 +0200 Subject: [PATCH 140/675] do not rmdir tolua, we need it --- s/build | 1 - 1 file changed, 1 deletion(-) diff --git a/s/build b/s/build index 820e330f9..b59804626 100755 --- a/s/build +++ b/s/build @@ -33,7 +33,6 @@ if [ ! -d $ROOT/$BUILD ]; then exit fi -rm -rf crypto tolua git submodule update echo "build eressea" From f697e06d179550c85d27c90e23d07682bce3baec Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 16 Oct 2016 18:07:45 +0200 Subject: [PATCH 141/675] do not use tolua from package --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index df0e62c84..003fb67ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ addons: - libsqlite3-dev - libxml2-dev - valgrind - - libtolua-dev os: - linux notifications: From f0fdb8d1a507325b97f0b735dc9049522dca92e3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 16 Oct 2016 18:15:14 +0200 Subject: [PATCH 142/675] issue #594: temporary fix --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index df0e62c84..003fb67ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ addons: - libsqlite3-dev - libxml2-dev - valgrind - - libtolua-dev os: - linux notifications: From c7ede945b3f794fadf7534a23a136df6aed168c6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 17 Oct 2016 19:59:06 +0200 Subject: [PATCH 143/675] use site packages on Travis CI, revert to Lua 5.1 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 003fb67ad..78aaf3648 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,8 @@ script: s/travis-build addons: apt: packages: - - liblua5.2-dev + - liblua5.1-dev + - libtolua-dev - libncurses5-dev - libsqlite3-dev - libxml2-dev From 34a6dd8d543915c91be0eb411a068d622908bd11 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 22 Oct 2016 22:35:10 +0200 Subject: [PATCH 144/675] fix crash in 997: re-introduce cfindhash. this prevents duplicate curse.no values. --- src/kernel/curse.c | 9 +++++++++ src/kernel/curse.h | 1 + src/kernel/unit.c | 1 + 3 files changed, 11 insertions(+) diff --git a/src/kernel/curse.c b/src/kernel/curse.c index 612127182..d545bfd71 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -98,6 +98,15 @@ static void cunhash(curse * c) } } +curse *cfindhash(int i) +{ + curse *old; + + for (old = cursehash[i % MAXENTITYHASH]; old; old = old->nexthash) + if (old->no == i) + return old; + return NULL; +} /* ------------------------------------------------------------- */ /* at_curse */ void curse_init(attrib * a) diff --git a/src/kernel/curse.h b/src/kernel/curse.h index c78e43405..534a936e3 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -285,6 +285,7 @@ extern "C" { void ct_register(const curse_type *); void ct_checknames(void); + curse *cfindhash(int i); curse *findcurse(int curseid); void curse_init(struct attrib *a); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index a95dbe4cb..455c789ac 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1876,6 +1876,7 @@ int newunitid(void) start_random_no = random_unit_no; while (ufindhash(random_unit_no) || dfindhash(random_unit_no) + || cfindhash(random_unit_no) || forbiddenid(random_unit_no)) { random_unit_no++; if (random_unit_no == MAX_UNIT_NR + 1) { From ccfe616380439d0cf33c2adbb169d358a80c122a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 22 Oct 2016 22:40:18 +0200 Subject: [PATCH 145/675] release version 3.9.4 --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index 88c0c65aa..783125b69 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 9 -#define VERSION_BUILD 3 +#define VERSION_BUILD 4 From bca90d2076309b670d60e1f74ed45d5019e71d5a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 23 Oct 2016 09:42:43 +0200 Subject: [PATCH 146/675] buildno.h is gone, don't try to read it. --- process/cron/preview.cron | 1 - s/preview | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/process/cron/preview.cron b/process/cron/preview.cron index b18038843..985ddf40b 100755 --- a/process/cron/preview.cron +++ b/process/cron/preview.cron @@ -7,7 +7,6 @@ if [ -e ${ERESSEA}/build/.preview ]; then fi SRC=${ERESSEA}/git ${SRC}/s/preview build ${branch} || exit $? -${SRC}/s/preview version for game in 2 3 4 ; do ${SRC}/s/preview -g ${game} run && \ ${SRC}/s/preview -g ${game} send diff --git a/s/preview b/s/preview index 86a4f8918..1e5d0db48 100755 --- a/s/preview +++ b/s/preview @@ -45,13 +45,6 @@ function assert_dir() { [ -d $1 ] || abort "missing directory: $1" } -function version() { -assert_dir $SOURCE -cd $SOURCE -build=$(grep BUILD src/buildno.h | awk '{ print $3 }') -echo "eressea build $build" -} - function setup() { assert_dir $SOURCE assert_dir $LIVE @@ -138,9 +131,6 @@ shift $((OPTIND-1)) while [ ! -z $1 ]; do case "$1" in -"version") - version - ;; "build") shift build $* From f12eda8bdfc945c000dd36dd168ad874079dbc9e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 23 Oct 2016 10:03:33 +0200 Subject: [PATCH 147/675] remove cfindhash, again. curse and unit ids can collide, there is no reason why they should be from the same pool. --- src/kernel/curse.c | 29 +++++++++++++++++++---------- src/kernel/curse.h | 2 -- src/kernel/unit.c | 43 +++++++++++++++++++++---------------------- src/kernel/unit.h | 1 - src/laws.c | 7 ++----- 5 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/kernel/curse.c b/src/kernel/curse.c index bc3cdbfba..3ecf48899 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -97,15 +97,6 @@ static void cunhash(curse * c) } } -curse *cfindhash(int i) -{ - curse *old; - - for (old = cursehash[i % MAXENTITYHASH]; old; old = old->nexthash) - if (old->no == i) - return old; - return NULL; -} /* ------------------------------------------------------------- */ /* at_curse */ void curse_init(attrib * a) @@ -531,6 +522,24 @@ static void set_cursedmen(curse * c, int cursedmen) } } +static int newcurseid(void) { + int random_no; + int start_random_no; + random_no = 1 + (rng_int() % MAX_UNIT_NR); + start_random_no = random_no; + + while (findcurse(random_no)) { + random_no++; + if (random_no == MAX_UNIT_NR + 1) { + random_no = 1; + } + if (random_no == start_random_no) { + random_no = (int)MAX_UNIT_NR + 1; + } + } + return random_no; +} + /* ------------------------------------------------------------- */ /* Legt eine neue Verzauberung an. Sollte es schon einen Zauber * dieses Typs geben, gibt es den bestehenden zurck. @@ -552,7 +561,7 @@ static curse *make_curse(unit * mage, attrib ** ap, const curse_type * ct, c->effect = effect; c->magician = mage; - c->no = newunitid(); + c->no = newcurseid(); chash(c); switch (c->type->typ) { diff --git a/src/kernel/curse.h b/src/kernel/curse.h index 9f6688a4f..0de1211c7 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -280,14 +280,12 @@ extern "C" { * */ struct curse *get_curse(struct attrib *ap, const curse_type * ctype); - int find_cursebyname(const char *c); const curse_type *ct_find(const char *c); bool ct_changed(int *cache); void ct_register(const curse_type *); void ct_remove(const char *c); void ct_checknames(void); - curse *cfindhash(int i); curse *findcurse(int curseid); void curse_init(struct attrib *a); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 2046a72c5..d95096484 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1437,6 +1437,26 @@ void free_unit(unit * u) } } +static int newunitid(void) +{ + int random_unit_no; + int start_random_no; + random_unit_no = 1 + (rng_int() % MAX_UNIT_NR); + start_random_no = random_unit_no; + + while (ufindhash(random_unit_no) || dfindhash(random_unit_no) + || forbiddenid(random_unit_no)) { + random_unit_no++; + if (random_unit_no == MAX_UNIT_NR + 1) { + random_unit_no = 1; + } + if (random_unit_no == start_random_no) { + random_unit_no = (int)MAX_UNIT_NR + 1; + } + } + return random_unit_no; +} + static void createunitid(unit * u, int id) { if (id <= 0 || id > MAX_UNIT_NR || ufindhash(id) || dfindhash(id) @@ -1699,6 +1719,7 @@ int unit_getcapacity(const unit * u) } void renumber_unit(unit *u, int no) { + if (no == 0) no = newunitid(); uunhash(u); if (!ualias(u)) { attrib *a = a_add(&u->attribs, a_new(&at_alias)); @@ -1929,28 +1950,6 @@ bool unit_can_study(const unit *u) { return !((u_race(u)->flags & RCF_NOLEARN) || fval(u, UFL_WERE)); } -/* ID's fr Einheiten und Zauber */ -int newunitid(void) -{ - int random_unit_no; - int start_random_no; - random_unit_no = 1 + (rng_int() % MAX_UNIT_NR); - start_random_no = random_unit_no; - - while (ufindhash(random_unit_no) || dfindhash(random_unit_no) - || cfindhash(random_unit_no) - || forbiddenid(random_unit_no)) { - random_unit_no++; - if (random_unit_no == MAX_UNIT_NR + 1) { - random_unit_no = 1; - } - if (random_unit_no == start_random_no) { - random_unit_no = (int)MAX_UNIT_NR + 1; - } - } - return random_unit_no; -} - static int read_newunitid(const faction * f, const region * r) { int n; diff --git a/src/kernel/unit.h b/src/kernel/unit.h index 32e48a950..a360321a2 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -258,7 +258,6 @@ extern "C" { #define GET_PEASANTS 2 int getunit(const struct region * r, const struct faction * f, struct unit **uresult); - int newunitid(void); int read_unitid(const struct faction *f, const struct region *r); void setstatus(struct unit *u, int status); diff --git a/src/laws.c b/src/laws.c index e243378dd..623a163d6 100755 --- a/src/laws.c +++ b/src/laws.c @@ -2916,7 +2916,7 @@ int renumber_cmd(unit * u, order * ord) { char token[128]; const char *s; - int i; + int i = 0; faction *f = u->faction; init_order(ord); @@ -2936,10 +2936,7 @@ int renumber_cmd(unit * u, order * ord) case P_UNIT: s = gettoken(token, sizeof(token)); - if (s == NULL || *s == 0) { - i = newunitid(); - } - else { + if (s && *s) { i = atoi36((const char *)s); if (i <= 0 || i > MAX_UNIT_NR) { cmistake(u, ord, 114, MSG_EVENT); From 2fbc7a44d59f6be5fb0d329fceb3881b1cdf63e0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 23 Oct 2016 13:02:53 +0200 Subject: [PATCH 148/675] add missing tests for recent failures. --- src/kernel/curse.test.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/kernel/unit.c | 2 +- src/kernel/unit.test.c | 17 ++++++++++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/kernel/curse.test.c b/src/kernel/curse.test.c index d7c86b9b0..0ca4510d9 100644 --- a/src/kernel/curse.test.c +++ b/src/kernel/curse.test.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -175,6 +176,43 @@ static void test_curse_cache(CuTest *tc) test_cleanup(); } +static void test_curse_ids(CuTest *tc) { + const curse_type ct_dummy = { "dummy", CURSETYP_NORM, 0, M_SUMEFFECT, NULL }; + curse *c1, *c2; + attrib *a1 = 0, *a2 = 0; + + test_setup(); + rng_init(0); + c1 = create_curse(NULL, &a1, &ct_dummy, 1, 1, 1, 1); + rng_init(0); + c2 = create_curse(NULL, &a2, &ct_dummy, 1, 1, 1, 1); + CuAssertTrue(tc, c1->no != c2->no); + a_remove(&a1, a1); + a_remove(&a2, a2); + test_cleanup(); +} + +static void test_curse_flags(CuTest *tc) { + const curse_type ct_dummy = { "dummy", CURSETYP_NORM, 0, M_SUMEFFECT, NULL }; + curse *c1, *c2; + unit *u; + + test_setup(); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + c1 = create_curse(u, &u->attribs, &ct_dummy, 1, 1, 1, 0); + CuAssertPtrEquals(tc, u, c1->magician); + CuAssertIntEquals(tc, 1, (int)c1->effect); + CuAssertIntEquals(tc, 1, (int)c1->vigour); + CuAssertIntEquals(tc, 1, c1->duration); + c2 = create_curse(u, &u->attribs, &ct_dummy, 1, 1, 1, 0); + CuAssertPtrEquals(tc, c1, c2); + CuAssertPtrEquals(tc, u, c1->magician); + CuAssertIntEquals(tc, 2, (int)c1->effect); + CuAssertIntEquals(tc, 1, (int)c1->vigour); + CuAssertIntEquals(tc, 1, c1->duration); + test_cleanup(); +} + CuSuite *get_curse_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -186,5 +224,7 @@ CuSuite *get_curse_suite(void) SUITE_ADD_TEST(suite, test_bad_dreams); SUITE_ADD_TEST(suite, test_memstream); SUITE_ADD_TEST(suite, test_write_flag); + SUITE_ADD_TEST(suite, test_curse_flags); + SUITE_ADD_TEST(suite, test_curse_ids); return suite; } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 201153663..ad8377254 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1717,7 +1717,7 @@ void renumber_unit(unit *u, int no) { uunhash(u); if (!ualias(u)) { attrib *a = a_add(&u->attribs, a_new(&at_alias)); - a->data.i = -u->no; + a->data.i = -u->no; // TODO: why is the alias negative? confusing! } u->no = no; uhash(u); diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index 054a45652..c4b1f46ed 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -8,9 +8,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include @@ -454,6 +455,19 @@ static void test_remove_unit(CuTest *tc) { test_cleanup(); } +static void test_renumber_unit(CuTest *tc) { + unit *u1, *u2; + test_setup(); + u1 = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + u2 = test_create_unit(u1->faction, u1->region); + rng_init(0); + renumber_unit(u1, 0); + rng_init(0); + renumber_unit(u2, 0); + CuAssertTrue(tc, u1->no != u2->no); + test_cleanup(); +} + CuSuite *get_unit_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -476,5 +490,6 @@ CuSuite *get_unit_suite(void) SUITE_ADD_TEST(suite, test_age_familiar); SUITE_ADD_TEST(suite, test_inside_building); SUITE_ADD_TEST(suite, test_limited_skills); + SUITE_ADD_TEST(suite, test_renumber_unit); return suite; } From cd69936922c1b59d39c28739bc9952e0c15ba1e6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 24 Oct 2016 13:47:38 +0200 Subject: [PATCH 149/675] fix demand in terraformed regions. https://bugs.eressea.de/view.php?id=2249 --- src/bind_region.c | 3 --- src/kernel/CMakeLists.txt | 2 +- src/kernel/region.c | 2 +- src/kernel/region.test.c | 39 +++++++++++++++++++++++++++++++++++++++ src/test_eressea.c | 3 ++- 5 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 src/kernel/region.test.c diff --git a/src/bind_region.c b/src/bind_region.c index e56c3443c..1296e4a65 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -474,9 +474,6 @@ static int tolua_region_create(lua_State * L) } if (result) { terraform_region(result, terrain); - if (result->land) { - fix_demand(result); - } } tolua_pushusertype(L, result, TOLUA_CAST "region"); diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 6bb860ad7..d3a2e8e56 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -20,7 +20,7 @@ order.test.c plane.test.c pool.test.c race.test.c -# region.test.c +region.test.c # resources.test.c save.test.c ship.test.c diff --git a/src/kernel/region.c b/src/kernel/region.c index 4c66e04f8..bda362dc5 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -1057,7 +1057,6 @@ void terraform_region(region * r, const terrain_type * terrain) rsetmoney(r, 0); freset(r, RF_ENCOUNTER); freset(r, RF_MALLORN); - /* Beschreibung und Namen lschen */ return; } @@ -1082,6 +1081,7 @@ void terraform_region(region * r, const terrain_type * terrain) r->land->ownership = NULL; region_set_morale(r, MORALE_DEFAULT, -1); region_setname(r, makename()); + fix_demand(r); for (d = 0; d != MAXDIRECTIONS; ++d) { region *nr = rconnect(r, d); if (nr && nr->land) { diff --git a/src/kernel/region.test.c b/src/kernel/region.test.c new file mode 100644 index 000000000..01ecae2a8 --- /dev/null +++ b/src/kernel/region.test.c @@ -0,0 +1,39 @@ +#include + +#include "region.h" +#include "terrain.h" +#include "item.h" + +#include +#include + +void test_terraform(CuTest *tc) { + region *r; + terrain_type *t_plain, *t_ocean; + item_type *itype; + + test_setup(); + itype = test_create_itemtype("ointment"); + itype->rtype->flags |= (RTF_ITEM | RTF_POOLED); + new_luxurytype(itype, 0); + + t_plain = test_create_terrain("plain", LAND_REGION); + t_ocean = test_create_terrain("ocean", SEA_REGION); + r = test_create_region(0, 0, t_ocean); + CuAssertPtrEquals(tc, 0, r->land); + terraform_region(r, t_plain); + CuAssertPtrNotNull(tc, r->land); + CuAssertPtrNotNull(tc, r->land->demands); + CuAssertPtrEquals(tc, itype, (void *)r->land->demands->type->itype); + CuAssertIntEquals(tc, 0, r->land->demands->type->price); + terraform_region(r, t_ocean); + CuAssertPtrEquals(tc, 0, r->land); + test_cleanup(); +} + +CuSuite *get_region_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_terraform); + return suite; +} diff --git a/src/test_eressea.c b/src/test_eressea.c index df4b762f3..002d9a0cb 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -100,6 +100,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(magic); ADD_SUITE(alchemy); ADD_SUITE(reports); + ADD_SUITE(region); ADD_SUITE(save); ADD_SUITE(ship); ADD_SUITE(spellbook); @@ -111,7 +112,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(messages); /* gamecode */ ADD_SUITE(report); -// ADD_SUITE(creport); + ADD_SUITE(creport); ADD_SUITE(prefix); ADD_SUITE(summary); ADD_SUITE(names); From e5dc754c2551e88c79653696d59d7d7a9ea57ec8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 24 Oct 2016 13:54:53 +0200 Subject: [PATCH 150/675] fix demand in broken regions, after load. --- src/kernel/region.c | 14 ++++++++++++++ src/kernel/region.h | 1 + src/kernel/save.c | 3 +++ src/modules/autoseed.c | 14 -------------- src/modules/autoseed.h | 1 - 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/kernel/region.c b/src/kernel/region.c index bda362dc5..a92a87291 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -1009,6 +1009,20 @@ void setluxuries(region * r, const luxury_type * sale) } } +int fix_demand(region * rd) { + luxury_type * ltype; + int maxluxuries = get_maxluxuries(); + if (maxluxuries > 0) { + int sale = rng_int() % maxluxuries; + for (ltype = luxurytypes; sale != 0 && ltype; ltype = ltype->next) { + --sale; + } + setluxuries(rd, ltype); + return 0; + } + return -1; +} + void terraform_region(region * r, const terrain_type * terrain) { /* Resourcen, die nicht mehr vorkommen knnen, lschen */ diff --git a/src/kernel/region.h b/src/kernel/region.h index 6e231529d..5efd416f6 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -160,6 +160,7 @@ extern "C" { #define reg_hashkey(r) (r->index) + extern int fix_demand(struct region *r); int distance(const struct region *, const struct region *); int koor_distance(int ax, int ay, int bx, int by); struct region *findregion(int x, int y); diff --git a/src/kernel/save.c b/src/kernel/save.c index 2373d60a0..0b0ea222d 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1096,6 +1096,9 @@ static region *readregion(struct gamedata *data, int x, int y) READ_INT(data->store, &n); r_setdemand(r, rtype->ltype, n); } + if (!r->land->demands) { + fix_demand(r); + } read_items(data->store, &r->land->items); if (data->version >= REGIONOWNER_VERSION) { READ_INT(data->store, &n); diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index e8855683e..3bcf36848 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -132,20 +132,6 @@ static bool f_nolux(const region * r) return (r->land && count_demand(r) != get_maxluxuries()); } -int fix_demand(region * rd) { - luxury_type * ltype; - int maxluxuries = get_maxluxuries(); - if (maxluxuries > 0) { - int sale = rng_int() % maxluxuries; - for (ltype = luxurytypes; sale != 0 && ltype; ltype = ltype->next) { - --sale; - } - setluxuries(rd, ltype); - return 0; - } - return -1; -} - int fix_all_demand(region *rd) { region_list *rl, *rlist = NULL; recurse_regions(rd, &rlist, f_nolux); diff --git a/src/modules/autoseed.h b/src/modules/autoseed.h index 3cfe6225c..06ce646c2 100644 --- a/src/modules/autoseed.h +++ b/src/modules/autoseed.h @@ -35,7 +35,6 @@ extern "C" { extern int autoseed(newfaction ** players, int nsize, int max_agediff); extern newfaction *read_newfactions(const char *filename); - extern int fix_demand(struct region *r); extern const struct terrain_type *random_terrain(const struct terrain_type *terrains[], int distribution[], int size); From 8f802c11e1c941e6fa45c3cbe533e4777665d07e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 25 Oct 2016 00:04:33 +0200 Subject: [PATCH 151/675] off-by-one error for early break from loop. --- src/laws.c | 2 +- src/laws.test.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/laws.c b/src/laws.c index 623a163d6..bd0ae7b92 100755 --- a/src/laws.c +++ b/src/laws.c @@ -4128,7 +4128,7 @@ int armedmen(const unit * u, bool siege_weapons) if (effskill(u, wtype->skill, 0) >= wtype->minskill) n += itm->number; /* if (effskill(u, wtype->skill) >= wtype->minskill) n += itm->number; */ - if (n > u->number) + if (n >= u->number) break; } n = _min(n, u->number); diff --git a/src/laws.test.c b/src/laws.test.c index 66cb5ef10..60438709e 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1402,6 +1402,26 @@ static void test_demon_hunger(CuTest * tc) test_cleanup(); } +static void test_armedmen(CuTest *tc) { + unit *u; + item_type *it_sword; + test_setup(); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + it_sword = test_create_itemtype("sword"); + new_weapontype(it_sword, 0, 0.5, 0, 0, 0, 0, SK_MELEE, 1); + CuAssertIntEquals(tc, 0, armedmen(u, false)); + CuAssertIntEquals(tc, 0, armedmen(u, true)); + set_level(u, SK_MELEE, 1); + CuAssertIntEquals(tc, 0, armedmen(u, false)); + i_change(&u->items, it_sword, 1); + CuAssertIntEquals(tc, 1, armedmen(u, false)); + i_change(&u->items, it_sword, 1); + CuAssertIntEquals(tc, 1, armedmen(u, false)); + set_level(u, SK_MELEE, 0); + CuAssertIntEquals(tc, 0, armedmen(u, false)); + test_cleanup(); +} + CuSuite *get_laws_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -1464,6 +1484,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_show_race); SUITE_ADD_TEST(suite, test_immigration); SUITE_ADD_TEST(suite, test_demon_hunger); + SUITE_ADD_TEST(suite, test_armedmen); return suite; } From 97918799c161044dae9e671add9710abbe579b95 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 25 Oct 2016 00:13:57 +0200 Subject: [PATCH 152/675] additional testing for armedmen(). --- src/laws.test.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/laws.test.c b/src/laws.test.c index 60438709e..9c714e465 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1403,6 +1403,8 @@ static void test_demon_hunger(CuTest * tc) } static void test_armedmen(CuTest *tc) { + // TODO: test wtype->minskill and WTF_SIEGE + // TODO: test RCF_NOWEAPONS and SK_WEAPONLESS unit *u; item_type *it_sword; test_setup(); @@ -1417,6 +1419,9 @@ static void test_armedmen(CuTest *tc) { CuAssertIntEquals(tc, 1, armedmen(u, false)); i_change(&u->items, it_sword, 1); CuAssertIntEquals(tc, 1, armedmen(u, false)); + scale_number(u, 2); + set_level(u, SK_MELEE, 1); + CuAssertIntEquals(tc, 2, armedmen(u, false)); set_level(u, SK_MELEE, 0); CuAssertIntEquals(tc, 0, armedmen(u, false)); test_cleanup(); From 91ae9245ca6e0eb168bbfb01ae220ad8d6dddf01 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 25 Oct 2016 15:01:54 +0200 Subject: [PATCH 153/675] armedmen tests. check missing weapons, WTF_SIEGE and minskill --- src/laws.test.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/laws.test.c b/src/laws.test.c index 9c714e465..0f2d54e47 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1403,14 +1403,14 @@ static void test_demon_hunger(CuTest * tc) } static void test_armedmen(CuTest *tc) { - // TODO: test wtype->minskill and WTF_SIEGE // TODO: test RCF_NOWEAPONS and SK_WEAPONLESS unit *u; item_type *it_sword; + weapon_type *wtype; test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); it_sword = test_create_itemtype("sword"); - new_weapontype(it_sword, 0, 0.5, 0, 0, 0, 0, SK_MELEE, 1); + wtype = new_weapontype(it_sword, 0, 0.5, 0, 0, 0, 0, SK_MELEE, 1); CuAssertIntEquals(tc, 0, armedmen(u, false)); CuAssertIntEquals(tc, 0, armedmen(u, true)); set_level(u, SK_MELEE, 1); @@ -1424,6 +1424,17 @@ static void test_armedmen(CuTest *tc) { CuAssertIntEquals(tc, 2, armedmen(u, false)); set_level(u, SK_MELEE, 0); CuAssertIntEquals(tc, 0, armedmen(u, false)); + set_level(u, SK_MELEE, 1); + i_change(&u->items, it_sword, -1); + CuAssertIntEquals(tc, 1, armedmen(u, false)); + wtype->minskill = 2; + CuAssertIntEquals(tc, 0, armedmen(u, false)); + set_level(u, SK_MELEE, 2); + CuAssertIntEquals(tc, 1, armedmen(u, false)); + CuAssertIntEquals(tc, 1, armedmen(u, true)); + wtype->flags |= WTF_SIEGE; + CuAssertIntEquals(tc, 0, armedmen(u, false)); + CuAssertIntEquals(tc, 1, armedmen(u, true)); test_cleanup(); } From e0a661819946b7bcb3fe0ddf25160eac09012274 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 26 Oct 2016 11:33:41 +0200 Subject: [PATCH 154/675] WIP: test production guarding. ents are not working, because they rely on being part of the monster faction? bad! --- scripts/tests/e2/init.lua | 1 + scripts/tests/economy.lua | 94 +++++++++++++++++++++++++++++++++++++++ src/bind_monsters.c | 9 +++- 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 scripts/tests/economy.lua diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 2fdad1898..9e9163256 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -13,3 +13,4 @@ require 'tests.storage' require 'tests.magicbag' require 'tests.process' require 'tests.xmas' +require 'tests.economy' diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua new file mode 100644 index 000000000..f528f16d2 --- /dev/null +++ b/scripts/tests/economy.lua @@ -0,0 +1,94 @@ +require "lunit" + +module("tests.economy", package.seeall, lunit.testcase) + +function setup() + eressea.free_game() + eressea.settings.set("NewbieImmunity", "0") + eressea.settings.set("study.produceexp", "0") + eressea.settings.set("nmr.timeout", "0") + eressea.settings.set("rules.food.flags", "4") -- FOOD_IS_FREE + eressea.settings.set("rules.encounters", "0") +end + +function test_no_guards() + local r = region.create(0, 0, "plain") + r:set_resource("tree", 100) + local u = unit.create(faction.create("human"), r) + u:set_skill("forestry", 1) + u:add_order("MACHE HOLZ") + process_orders() + assert_equal(1, u:get_item("log")) + process_orders() + assert_equal(2, u:get_item("log")) +end + +function test_elf_guards_trees() + local r = region.create(0, 0, "plain") + r:set_resource("tree", 100) + local u = unit.create(faction.create("human"), r) + u:set_skill("forestry", 1) + local guard = unit.create(faction.create("elf"), r, 1, "elf") + guard:add_order("BEWACHEN") -- fails, because unarmed + u:add_order("MACHE HOLZ") + process_orders() + assert_equal(1, u:get_item("log")) + guard:add_item("sword", 1) + guard:set_skill("melee", 1) + guard:add_order("BEWACHEN") -- success + process_orders() + -- GUARD starts after MAKE: + assert_equal(2, u:get_item("log")) + process_orders() + -- GUARD was active this turn: + assert_equal(2, u:get_item("log")) +end + +function test_catapults_dont_guard() + local r = region.create(0, 0, "plain") + r:set_resource("tree", 100) + local u = unit.create(faction.create("human"), r) + u:set_skill("forestry", 1) + local guard = unit.create(faction.create("elf"), r, 1, "elf") + guard:add_order("BEWACHEN") + u:add_order("MACHE HOLZ") + process_orders() + assert_equal(1, u:get_item("log")) + guard:add_item("catapult", 1) + guard:set_skill("catapult", 1) + guard:add_order("BEWACHEN") + process_orders() + -- GUARD starts after MAKE: + assert_equal(2, u:get_item("log")) + process_orders() + -- GUARD was active this turn, but catapults do not count: + assert_equal(3, u:get_item("log")) +end + +function test_ent_guards_trees() + local r = region.create(0, 0, "plain") + r:set_resource("tree", 100) + local u = unit.create(faction.create("human"), r) + u:set_skill("forestry", 1) + local guard = unit.create(get_monsters(), r, 1, "ent") + guard:add_order("BEWACHEN") + u:add_order("MACHE HOLZ") + process_orders() + assert_equal(1, u:get_item("log")) + process_orders() + assert_equal(1, u:get_item("log")) +end + +function test_ironkeeper_guards_iron() + local r = region.create(0, 0, "plain") + r:set_resource("iron", 100) + local u = unit.create(faction.create("human"), r) + u:set_skill("mining", 1) + local guard = unit.create(faction.create("mountainguard"), r, 1, "mountainguard") + guard:add_order("BEWACHEN") + u:add_order("MACHE EISEN") + process_orders() + assert_equal(1, u:get_item("iron")) + process_orders() + assert_equal(1, u:get_item("iron")) +end diff --git a/src/bind_monsters.c b/src/bind_monsters.c index 271045491..3e3f24bee 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -47,6 +47,12 @@ static int tolua_spawn_dragons(lua_State * L) return 0; } +static int tolua_get_monsters(lua_State * L) +{ + tolua_pushusertype(L, get_monsters(), "faction"); + return 1; +} + static int tolua_spawn_undead(lua_State * L) { spawn_undead(); @@ -90,7 +96,8 @@ void bind_monsters(struct lua_State *L) tolua_function(L, TOLUA_CAST "plan_monsters", tolua_planmonsters); tolua_function(L, TOLUA_CAST "spawn_undead", tolua_spawn_undead); tolua_function(L, TOLUA_CAST "spawn_dragons", tolua_spawn_dragons); - tolua_function(L, TOLUA_CAST "fix_familiars", &fix_familiars); + tolua_function(L, TOLUA_CAST "fix_familiars", fix_familiars); + tolua_function(L, TOLUA_CAST "get_monsters", tolua_get_monsters); } tolua_endmodule(L); } From f17b6f2bb5dfaa63f25fa3a3bf8779208cbc0aa0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 28 Oct 2016 20:26:34 +0200 Subject: [PATCH 155/675] WIP: additional testing for GUARD. BUG: ents cannot guard, do not protect trees. FIX: issue #589 (bad test for stardust) --- scripts/tests/e2/init.lua | 3 +- scripts/tests/economy.lua | 71 +++++++++++++++++++++++++++++++++++++++ scripts/tests/xmas.lua | 1 + 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 9e9163256..afaac7209 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,3 +1,5 @@ +require 'tests.economy' + require 'tests.e2.undead' require 'tests.e2.shiplanding' require 'tests.e2.e2features' @@ -13,4 +15,3 @@ require 'tests.storage' require 'tests.magicbag' require 'tests.process' require 'tests.xmas' -require 'tests.economy' diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua index f528f16d2..ebacc32e1 100644 --- a/scripts/tests/economy.lua +++ b/scripts/tests/economy.lua @@ -79,6 +79,38 @@ function test_ent_guards_trees() assert_equal(1, u:get_item("log")) end +function test_guard_stops_recruit() + local r = region.create(0, 0, "plain") + r:set_resource("peasant", 100) + local u = unit.create(faction.create("human"), r) + local guard = unit.create(get_monsters(), r, 1) + guard:add_order("BEWACHEN") + + u:add_item("money", 1000) + assert_equal(1, u.number) + u:add_order("REKRUTIERE 1") + process_orders() + assert_equal(2, u.number) + u:add_order("REKRUTIERE 1") + process_orders() + assert_equal(2, u.number) +end + +function test_guard_protects_iron() + local r = region.create(0, 0, "plain") + r:set_resource("iron", 100) + local u = unit.create(faction.create("human"), r) + u:set_skill("mining", 1) + local guard = unit.create(get_monsters(), r, 1) + guard:add_order("BEWACHEN") + + u:add_order("MACHE EISEN") + process_orders() + assert_equal(1, u:get_item("iron")) + process_orders() + assert_equal(1, u:get_item("iron")) +end + function test_ironkeeper_guards_iron() local r = region.create(0, 0, "plain") r:set_resource("iron", 100) @@ -92,3 +124,42 @@ function test_ironkeeper_guards_iron() process_orders() assert_equal(1, u:get_item("iron")) end + +function test_ent_guards_trees() + local r = region.create(0, 0, "plain") + r:set_resource("tree", 100) + local u = unit.create(faction.create("human"), r) + u:set_skill("mining", 1) + local guard = unit.create(get_monsters(), r, 1, "ent") + u:set_skill("forestry", 1) + guard:add_order("BEWACHEN") + guard:clear_orders() + u:clear_orders() + + u:add_order("MACHE HOLZ") + process_orders() + assert_equal(1, u:get_item("log")) + process_orders() + -- print("report: " .. tostring(u.faction)) + -- init_reports() + -- write_report(u.faction) + assert_equal(1, u:get_item("log")) +end + +function test_ironkeeper_allows_recruit() + local r = region.create(0, 0, "plain") + r:set_resource("iron", 100) + local u = unit.create(faction.create("human"), r) + u:set_skill("mining", 1) + local guard = unit.create(faction.create("mountainguard"), r, 1, "mountainguard") + guard:add_order("BEWACHEN") + + u:add_item("money", 1000) + assert_equal(1, u.number) + u:add_order("REKRUTIERE 1") + process_orders() + assert_equal(2, u.number) + u:add_order("REKRUTIERE 1") + process_orders() + assert_equal(3, u.number) +end diff --git a/scripts/tests/xmas.lua b/scripts/tests/xmas.lua index e1cd4753b..bbd4941f2 100644 --- a/scripts/tests/xmas.lua +++ b/scripts/tests/xmas.lua @@ -6,6 +6,7 @@ function setup() eressea.free_game() eressea.settings.set("nmr.timeout", "0") eressea.settings.set("rules.grow.formula", "0") + eressea.settings.set("rules.peasants.growth.factor", "0") end function test_snowglobe_fail() From f1d07fb647a9a27c4e2f6b93d6a60717e1b54911 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 29 Oct 2016 10:53:18 +0200 Subject: [PATCH 156/675] I no longer use CRTDBG to find bugs. Valgrind rules. --- src/main.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/src/main.c b/src/main.c index 58a15edc0..5fd154b23 100644 --- a/src/main.c +++ b/src/main.c @@ -262,27 +262,6 @@ static int setup_signal_handler(void) } #endif -#undef CRTDBG -#ifdef CRTDBG -#include -void init_crtdbg(void) -{ -#if (defined(_MSC_VER)) - int flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); - if (memdebug == 1) { - flags |= _CRTDBG_CHECK_ALWAYS_DF; /* expensive */ - } else if (memdebug == 2) { - flags = (flags & 0x0000FFFF) | _CRTDBG_CHECK_EVERY_16_DF; - } else if (memdebug == 3) { - flags = (flags & 0x0000FFFF) | _CRTDBG_CHECK_EVERY_128_DF; - } else if (memdebug == 4) { - flags = (flags & 0x0000FFFF) | _CRTDBG_CHECK_EVERY_1024_DF; - } - _CrtSetDbgFlag(flags); -#endif -} -#endif - void locale_init(void) { setlocale(LC_CTYPE, ""); @@ -310,10 +289,6 @@ int main(int argc, char **argv) locale_init(); -#ifdef CRTDBG - init_crtdbg(); -#endif - L = lua_init(); game_init(); bind_monsters(L); From 6075396de3248e1a5ae51e2c7ebda54f4093d6ca Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 29 Oct 2016 14:16:40 +0200 Subject: [PATCH 157/675] WIP: make guard tests pass. BUG: monsters are always allowed to guard unarmed. TODO: more code duplication, refactor it. TODO: ents do not guard resources? --- src/move.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/move.c b/src/move.c index 96a999f0d..f227118bb 100644 --- a/src/move.c +++ b/src/move.c @@ -1015,7 +1015,7 @@ static bool is_guardian_r(const unit * guard) if ((guard->flags & UFL_GUARD) == 0) return false; - return armedmen(guard, true) > 0 || fval(u_race(guard), RCF_UNARMEDGUARD); + return fval(u_race(guard), RCF_UNARMEDGUARD) || is_monsters(guard->faction) || (armedmen(guard, true) > 0); } bool is_guard(const struct unit * u, unsigned int mask) From 59c8fbc5a55a8f3f9f24a5f22111bfc9d6400f67 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 29 Oct 2016 17:51:01 +0200 Subject: [PATCH 158/675] fix bad Lua test for ents, so they actually guard. --- scripts/tests/economy.lua | 2 +- src/settings.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua index ebacc32e1..5678cfc6c 100644 --- a/scripts/tests/economy.lua +++ b/scripts/tests/economy.lua @@ -132,10 +132,10 @@ function test_ent_guards_trees() u:set_skill("mining", 1) local guard = unit.create(get_monsters(), r, 1, "ent") u:set_skill("forestry", 1) - guard:add_order("BEWACHEN") guard:clear_orders() u:clear_orders() + guard:add_order("BEWACHEN") u:add_order("MACHE HOLZ") process_orders() assert_equal(1, u:get_item("log")) diff --git a/src/settings.h b/src/settings.h index c44bc0f2a..ecf3df9f2 100644 --- a/src/settings.h +++ b/src/settings.h @@ -10,10 +10,6 @@ without prior permission by the authors of Eressea. */ -/* - * Contains defines for the "free" game (Eressea) . - * Include this file from settings.h to make eressea work. - */ #define ENTERTAINFRACTION 20 #define TEACHDIFFERENCE 2 #define GUARD_DISABLES_RECRUIT 1 From 5bb2dbfd87298ad76bbd49a38dba9c7c8196e083 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 26 Oct 2016 11:35:20 +0200 Subject: [PATCH 159/675] move is_guarded from move.h to guard.h Conflicts: src/move.c --- src/alchemy.c | 1 + src/guard.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/guard.h | 3 ++ src/move.c | 76 ------------------------------------------------- src/move.h | 2 -- 5 files changed, 83 insertions(+), 78 deletions(-) diff --git a/src/alchemy.c b/src/alchemy.c index 89b00c5f0..a0a9d1ef2 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -19,6 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "alchemy.h" +#include "guard.h" #include "move.h" #include "skill.h" #include "study.h" diff --git a/src/guard.c b/src/guard.c index da879fa53..6f61cc599 100644 --- a/src/guard.c +++ b/src/guard.c @@ -20,7 +20,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "guard.h" +#include "laws.h" +#include "monster.h" +#include #include #include #include @@ -145,3 +148,79 @@ void guard(unit * u, unsigned int mask) unsigned int flags = guard_flags(u); setguard(u, flags & mask); } + +static bool is_guardian_u(const unit * guard, unit * u, unsigned int mask) +{ + if (guard->faction == u->faction) + return false; + if (is_guard(guard, mask) == 0) + return false; + if (alliedunit(guard, u->faction, HELP_GUARD)) + return false; + if (ucontact(guard, u)) + return false; + if (!cansee(guard->faction, u->region, u, 0)) + return false; + if (!(u_race(guard)->flags & RCF_FLY) && u_race(u)->flags & RCF_FLY) + return false; + + return true; +} + +static bool is_guardian_r(const unit * guard) +{ + if (guard->number == 0) + return false; + if (besieged(guard)) + return false; + + /* if region_owners exist then they may be guardians: */ + if (guard->building && rule_region_owners() && guard == building_owner(guard->building)) { + faction *owner = region_get_owner(guard->region); + if (owner == guard->faction) { + building *bowner = largestbuilding(guard->region, &cmp_taxes, false); + if (bowner == guard->building) { + return true; + } + } + } + + if ((guard->flags & UFL_GUARD) == 0) + return false; + return fval(u_race(guard), RCF_UNARMEDGUARD) || is_monsters(guard->faction) || (armedmen(guard, true) > 0); +} + +bool is_guard(const struct unit * u, unsigned int mask) +{ + return is_guardian_r(u) && (getguard(u) & mask) != 0; +} + +unit *is_guarded(region * r, unit * u, unsigned int mask) +{ + unit *u2; + int noguards = 1; + + if (!fval(r, RF_GUARDED)) { + return NULL; + } + + /* at this point, u2 is the last unit we tested to + * be a guard (and failed), or NULL + * i is the position of the first free slot in the cache */ + + for (u2 = r->units; u2; u2 = u2->next) { + if (is_guardian_r(u2)) { + noguards = 0; + if (is_guardian_u(u2, u, mask)) { + /* u2 is our guard. stop processing (we might have to go further next time) */ + return u2; + } + } + } + + if (noguards) { + /* you are mistaken, sir. there are no guards in these lands */ + freset(r, RF_GUARDED); + } + return NULL; +} diff --git a/src/guard.h b/src/guard.h index 564be61a2..e65f2c7d4 100644 --- a/src/guard.h +++ b/src/guard.h @@ -20,6 +20,9 @@ extern "C" { void guard(struct unit * u, unsigned int mask); + struct unit *is_guarded(struct region *r, struct unit *u, unsigned int mask); + bool is_guard(const struct unit *u, unsigned int mask); + #ifdef __cplusplus } #endif diff --git a/src/move.c b/src/move.c index f227118bb..ac7c46083 100644 --- a/src/move.c +++ b/src/move.c @@ -977,82 +977,6 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r) return NULL; } -static bool is_guardian_u(const unit * guard, unit * u, unsigned int mask) -{ - if (guard->faction == u->faction) - return false; - if (is_guard(guard, mask) == 0) - return false; - if (alliedunit(guard, u->faction, HELP_GUARD)) - return false; - if (ucontact(guard, u)) - return false; - if (!cansee(guard->faction, u->region, u, 0)) - return false; - if (!(u_race(guard)->flags & RCF_FLY) && u_race(u)->flags & RCF_FLY) - return false; - - return true; -} - -static bool is_guardian_r(const unit * guard) -{ - if (guard->number == 0) - return false; - if (besieged(guard)) - return false; - - /* if region_owners exist then they may be guardians: */ - if (guard->building && rule_region_owners() && guard == building_owner(guard->building)) { - faction *owner = region_get_owner(guard->region); - if (owner == guard->faction) { - building *bowner = largestbuilding(guard->region, &cmp_taxes, false); - if (bowner == guard->building) { - return true; - } - } - } - - if ((guard->flags & UFL_GUARD) == 0) - return false; - return fval(u_race(guard), RCF_UNARMEDGUARD) || is_monsters(guard->faction) || (armedmen(guard, true) > 0); -} - -bool is_guard(const struct unit * u, unsigned int mask) -{ - return is_guardian_r(u) && (getguard(u) & mask) != 0; -} - -unit *is_guarded(region * r, unit * u, unsigned int mask) -{ - unit *u2; - int noguards = 1; - - if (!fval(r, RF_GUARDED)) { - return NULL; - } - - /* at this point, u2 is the last unit we tested to - * be a guard (and failed), or NULL - * i is the position of the first free slot in the cache */ - - for (u2 = r->units; u2; u2 = u2->next) { - if (is_guardian_r(u2)) { - noguards = 0; - if (is_guardian_u(u2, u, mask)) { - /* u2 is our guard. stop processing (we might have to go further next time) */ - return u2; - } - } - } - - if (noguards) { - /* you are mistaken, sir. there are no guards in these lands */ - freset(r, RF_GUARDED); - } - return NULL; -} - bool move_blocked(const unit * u, const region * r, const region * r2) { connection *b; diff --git a/src/move.h b/src/move.h index 70dddbb0b..6363fe2f9 100644 --- a/src/move.h +++ b/src/move.h @@ -60,8 +60,6 @@ extern "C" { int personcapacity(const struct unit *u); void movement(void); void run_to(struct unit *u, struct region *to); - struct unit *is_guarded(struct region *r, struct unit *u, unsigned int mask); - bool is_guard(const struct unit *u, unsigned int mask); int enoughsailors(const struct ship *sh, int sumskill); bool canswim(struct unit *u); bool canfly(struct unit *u); From 654926fa06f164fc784430b7310d4e73afbdec06 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 26 Oct 2016 11:45:44 +0200 Subject: [PATCH 160/675] add a failing test for "monsters can guard when unarmed" --- src/CMakeLists.txt | 1 + src/guard.test.c | 37 +++++++++++++++++++++++++++++++++++++ src/test_eressea.c | 1 + 3 files changed, 39 insertions(+) create mode 100644 src/guard.test.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df92085db..b4e600e0d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -192,6 +192,7 @@ set(TESTS_SRC donations.test.c wormhole.test.c alchemy.test.c + guard.test.c test_eressea.c tests.c battle.test.c diff --git a/src/guard.test.c b/src/guard.test.c new file mode 100644 index 000000000..b00f50b49 --- /dev/null +++ b/src/guard.test.c @@ -0,0 +1,37 @@ +#include + +#include "guard.h" +#include "monster.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include "tests.h" + +static void test_guard_monsters(CuTest * tc) +{ + unit *u, *ug; + region *r; + + test_setup(); + r = test_create_region(0, 0, 0); + u = test_create_unit(test_create_faction(0), r); + ug = test_create_unit(get_monsters(), r); + setguard(ug, GUARD_ALL); + CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); + test_cleanup(); +} + +CuSuite *get_guard_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_guard_monsters); + return suite; +} diff --git a/src/test_eressea.c b/src/test_eressea.c index 002d9a0cb..39ec90be6 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -111,6 +111,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(ally); ADD_SUITE(messages); /* gamecode */ + ADD_SUITE(guard); ADD_SUITE(report); ADD_SUITE(creport); ADD_SUITE(prefix); From 7c827c0389cbc05f1b638ddb32611a2e775338d0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 26 Oct 2016 11:48:52 +0200 Subject: [PATCH 161/675] add test for races with "unarmed guard" flag. --- src/guard.test.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/guard.test.c b/src/guard.test.c index b00f50b49..2aeedbf70 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -15,6 +15,23 @@ #include #include "tests.h" +static void test_guard_unarmed(CuTest * tc) +{ + unit *u, *ug; + region *r; + race *rc; + + test_setup(); + rc = test_create_race("mountainguard"); + rc->flags |= RCF_UNARMEDGUARD; + r = test_create_region(0, 0, 0); + u = test_create_unit(test_create_faction(0), r); + ug = test_create_unit(test_create_faction(rc), r); + setguard(ug, GUARD_ALL); + CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); + test_cleanup(); +} + static void test_guard_monsters(CuTest * tc) { unit *u, *ug; @@ -32,6 +49,7 @@ static void test_guard_monsters(CuTest * tc) CuSuite *get_guard_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_guard_unarmed); SUITE_ADD_TEST(suite, test_guard_monsters); return suite; } From 29c5bd6f55322dd906a9143581005bf201ec7220 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 26 Oct 2016 11:55:31 +0200 Subject: [PATCH 162/675] test that regular guards need weapons and skills --- src/guard.test.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/guard.test.c b/src/guard.test.c index 2aeedbf70..f9c78e7c1 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -15,6 +15,45 @@ #include #include "tests.h" +static void test_guard_unskilled(CuTest * tc) +// TODO: it would be better to test armedmen() +{ + unit *u, *ug; + region *r; + item_type *itype; + + test_setup(); + itype = it_get_or_create(rt_get_or_create("sword")); + new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2); + r = test_create_region(0, 0, 0); + u = test_create_unit(test_create_faction(0), r); + ug = test_create_unit(test_create_faction(0), r); + i_change(&ug->items, itype, 1); + set_level(ug, SK_MELEE, 1); + setguard(ug, GUARD_ALL); + CuAssertPtrEquals(tc, 0, is_guarded(r, u, GUARD_PRODUCE)); + test_cleanup(); +} + +static void test_guard_armed(CuTest * tc) +{ + unit *u, *ug; + region *r; + item_type *itype; + + test_setup(); + itype = it_get_or_create(rt_get_or_create("sword")); + new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2); + r = test_create_region(0, 0, 0); + u = test_create_unit(test_create_faction(0), r); + ug = test_create_unit(test_create_faction(0), r); + i_change(&ug->items, itype, 1); + set_level(ug, SK_MELEE, 2); + setguard(ug, GUARD_ALL); + CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); + test_cleanup(); +} + static void test_guard_unarmed(CuTest * tc) { unit *u, *ug; @@ -49,6 +88,8 @@ static void test_guard_monsters(CuTest * tc) CuSuite *get_guard_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_guard_unskilled); + SUITE_ADD_TEST(suite, test_guard_armed); SUITE_ADD_TEST(suite, test_guard_unarmed); SUITE_ADD_TEST(suite, test_guard_monsters); return suite; From 4487f4d3e19e77e3dabf72deadbfacaad32a8bfd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 26 Oct 2016 14:37:57 +0200 Subject: [PATCH 163/675] missing declaration --- src/guard.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/guard.h b/src/guard.h index e65f2c7d4..39533dee3 100644 --- a/src/guard.h +++ b/src/guard.h @@ -7,7 +7,8 @@ extern "C" { #endif struct unit; - + struct region; + typedef enum { E_GUARD_OK, E_GUARD_UNARMED, E_GUARD_NEWBIE, E_GUARD_FLEEING } guard_t; extern struct attrib_type at_guard; From 1ea8c80845895c007cf8b7115484b6b269d3c5fc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 26 Oct 2016 17:51:24 +0200 Subject: [PATCH 164/675] test that is_guard changes when armedmen does. --- src/guard.c | 14 ++++++++++++++ src/guard.test.c | 27 +++++++++++++++++++++++++++ src/laws.c | 14 -------------- src/laws.h | 1 - 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/guard.c b/src/guard.c index 6f61cc599..cefcdb925 100644 --- a/src/guard.c +++ b/src/guard.c @@ -45,6 +45,20 @@ attrib_type at_guard = { ATF_UNIQUE }; +guard_t can_start_guarding(const unit * u) +{ + if (u->status >= ST_FLEE || fval(u, UFL_FLEEING)) + return E_GUARD_FLEEING; + /* Monster der Monsterpartei dürfen immer bewachen */ + if (is_monsters(u->faction) || fval(u_race(u), RCF_UNARMEDGUARD)) + return E_GUARD_OK; + if (!armedmen(u, true)) + return E_GUARD_UNARMED; + if (IsImmune(u->faction)) + return E_GUARD_NEWBIE; + return E_GUARD_OK; +} + void update_guards(void) { const region *r; diff --git a/src/guard.test.c b/src/guard.test.c index f9c78e7c1..262631a30 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -1,6 +1,7 @@ #include #include "guard.h" +#include "laws.h" #include "monster.h" #include @@ -54,6 +55,31 @@ static void test_guard_armed(CuTest * tc) test_cleanup(); } +static void test_is_guard(CuTest * tc) +{ + unit *ug; + region *r; + item_type *itype; + + test_setup(); + itype = it_get_or_create(rt_get_or_create("sword")); + new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2); + r = test_create_region(0, 0, 0); + ug = test_create_unit(test_create_faction(0), r); + i_change(&ug->items, itype, 1); + set_level(ug, SK_MELEE, 2); + setguard(ug, GUARD_ALL); + CuAssertIntEquals(tc, 1, armedmen(ug, false)); + CuAssertTrue(tc, is_guard(ug, GUARD_RECRUIT)); + set_level(ug, SK_MELEE, 1); + CuAssertIntEquals(tc, 0, armedmen(ug, false)); + CuAssertTrue(tc, !is_guard(ug, GUARD_RECRUIT)); + set_level(ug, SK_MELEE, 2); + CuAssertIntEquals(tc, 1, armedmen(ug, false)); + CuAssertTrue(tc, is_guard(ug, GUARD_RECRUIT)); + test_cleanup(); +} + static void test_guard_unarmed(CuTest * tc) { unit *u, *ug; @@ -88,6 +114,7 @@ static void test_guard_monsters(CuTest * tc) CuSuite *get_guard_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_is_guard); SUITE_ADD_TEST(suite, test_guard_unskilled); SUITE_ADD_TEST(suite, test_guard_armed); SUITE_ADD_TEST(suite, test_guard_unarmed); diff --git a/src/laws.c b/src/laws.c index bd0ae7b92..a2f7f0044 100755 --- a/src/laws.c +++ b/src/laws.c @@ -2671,20 +2671,6 @@ int combatspell_cmd(unit * u, struct order *ord) return 0; } -guard_t can_start_guarding(const unit * u) -{ - if (u->status >= ST_FLEE || fval(u, UFL_FLEEING)) - return E_GUARD_FLEEING; - /* Monster der Monsterpartei dürfen immer bewachen */ - if (is_monsters(u->faction) || fval(u_race(u), RCF_UNARMEDGUARD)) - return E_GUARD_OK; - if (!armedmen(u, true)) - return E_GUARD_UNARMED; - if (IsImmune(u->faction)) - return E_GUARD_NEWBIE; - return E_GUARD_OK; -} - int guard_on_cmd(unit * u, struct order *ord) { assert(getkeyword(ord) == K_GUARD); diff --git a/src/laws.h b/src/laws.h index 6c8633536..55020dc06 100755 --- a/src/laws.h +++ b/src/laws.h @@ -112,7 +112,6 @@ extern "C" { #define FORCE_LEAVE_ALL 2 bool rule_force_leave(int flag); bool help_enter(struct unit *uo, struct unit *u); - guard_t can_start_guarding(const struct unit * u); #ifdef __cplusplus } From 1116afed2b0a795bb4f2a21d3db682fd611d1940 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 26 Oct 2016 18:09:51 +0200 Subject: [PATCH 165/675] merge conflict resolve --- src/alchemy.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/alchemy.c b/src/alchemy.c index a0a9d1ef2..11a205869 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "alchemy.h" #include "guard.h" -#include "move.h" #include "skill.h" #include "study.h" From a5e63a2472c37bce3bfa96ad2fca3184589302dd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 30 Oct 2016 05:37:12 +0100 Subject: [PATCH 166/675] move GUARD_* flags to guard.h --- s/cmake-init | 6 +++--- src/guard.h | 19 +++++++++++++++++++ src/kernel/config.h | 19 ------------------- src/kernel/xmlreader.c | 1 + 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/s/cmake-init b/s/cmake-init index 2cd5b4834..b1ea6759a 100755 --- a/s/cmake-init +++ b/s/cmake-init @@ -46,9 +46,9 @@ if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then echo "tolua is not installed, building from source" cd $ROOT if [ ! -d tolua ]; then - LUA_VERSION="5.1" - if [ -d /usr/include/lua5.2 ] || [ -d /usr/local/include/lua5.2 ]; then - LUA_VERSION="5.2" + LUA_VERSION="5.2" + if [ -d /usr/include/lua5.1 ] || [ -d /usr/local/include/lua5.1 ]; then + LUA_VERSION="5.1" fi echo "fetching tolua ${LUA_VERSION} from github..." git clone https://github.com/ennorehling/tolua-${LUA_VERSION}.git tolua diff --git a/src/guard.h b/src/guard.h index 39533dee3..5fe476e11 100644 --- a/src/guard.h +++ b/src/guard.h @@ -11,6 +11,25 @@ extern "C" { typedef enum { E_GUARD_OK, E_GUARD_UNARMED, E_GUARD_NEWBIE, E_GUARD_FLEEING } guard_t; +#define GUARD_NONE 0 +#define GUARD_TAX 1 + /* Verhindert Steuereintreiben */ +#define GUARD_MINING 2 + /* Verhindert Bergbau */ +#define GUARD_TREES 4 + /* Verhindert Waldarbeiten */ +#define GUARD_TRAVELTHRU 8 + /* Blockiert Durchreisende */ +#define GUARD_LANDING 16 + /* Verhindert Ausstieg + Weiterreise */ +#define GUARD_CREWS 32 + /* Verhindert Unterhaltung auf Schiffen */ +#define GUARD_RECRUIT 64 + /* Verhindert Rekrutieren */ +#define GUARD_PRODUCE 128 + /* Verhindert Abbau von Resourcen mit RTF_LIMITED */ +#define GUARD_ALL 0xFFFF + extern struct attrib_type at_guard; guard_t can_start_guarding(const struct unit * u); diff --git a/src/kernel/config.h b/src/kernel/config.h index 74565e25e..8c46e4185 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -114,25 +114,6 @@ struct param; #define GF_PURE 64 /* untranslated */ -#define GUARD_NONE 0 -#define GUARD_TAX 1 - /* Verhindert Steuereintreiben */ -#define GUARD_MINING 2 - /* Verhindert Bergbau */ -#define GUARD_TREES 4 - /* Verhindert Waldarbeiten */ -#define GUARD_TRAVELTHRU 8 - /* Blockiert Durchreisende */ -#define GUARD_LANDING 16 - /* Verhindert Ausstieg + Weiterreise */ -#define GUARD_CREWS 32 - /* Verhindert Unterhaltung auf Schiffen */ -#define GUARD_RECRUIT 64 - /* Verhindert Rekrutieren */ -#define GUARD_PRODUCE 128 - /* Verhindert Abbau von Resourcen mit RTF_LIMITED */ -#define GUARD_ALL 0xFFFF - int maxworkingpeasants(const struct region *r); bool markets_module(void); int wage(const struct region *r, const struct faction *f, diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index e022effaf..38ead12ab 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -15,6 +15,7 @@ without prior permission by the authors of Eressea. #include "xmlreader.h" #include "building.h" +#include "guard.h" #include "equipment.h" #include "item.h" #include "keyword.h" From 8597e8b16a6f0994140c7d96a53530268417aff5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 30 Oct 2016 05:39:25 +0100 Subject: [PATCH 167/675] move guard test to guard.test.c --- src/guard.test.c | 25 +++++++++++++++++++++++++ src/move.test.c | 26 -------------------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/guard.test.c b/src/guard.test.c index 262631a30..61f08be05 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -16,6 +16,30 @@ #include #include "tests.h" +static void test_is_guarded(CuTest *tc) { + unit *u1, *u2; + region *r; + race *rc; + + test_cleanup(); + rc = rc_get_or_create("dragon"); + rc->flags |= RCF_UNARMEDGUARD; + r = test_create_region(0, 0, 0); + u1 = test_create_unit(test_create_faction(0), r); + u2 = test_create_unit(test_create_faction(rc), r); + CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TRAVELTHRU)); + CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_PRODUCE)); + CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TREES)); + CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_MINING)); + guard(u2, GUARD_MINING | GUARD_PRODUCE); + CuAssertIntEquals(tc, GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX | GUARD_PRODUCE | GUARD_RECRUIT, guard_flags(u2)); + CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TRAVELTHRU)); + CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TREES)); + CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_MINING)); + CuAssertPtrEquals(tc, u2, is_guarded(r, u1, GUARD_PRODUCE)); + test_cleanup(); +} + static void test_guard_unskilled(CuTest * tc) // TODO: it would be better to test armedmen() { @@ -114,6 +138,7 @@ static void test_guard_monsters(CuTest * tc) CuSuite *get_guard_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_is_guarded); SUITE_ADD_TEST(suite, test_is_guard); SUITE_ADD_TEST(suite, test_guard_unskilled); SUITE_ADD_TEST(suite, test_guard_armed); diff --git a/src/move.test.c b/src/move.test.c index 2ce9cccda..5c89166c8 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -2,7 +2,6 @@ #include #include "move.h" -#include "guard.h" #include "keyword.h" #include @@ -201,30 +200,6 @@ static void test_walkingcapacity(CuTest *tc) { test_cleanup(); } -static void test_is_guarded(CuTest *tc) { - unit *u1, *u2; - region *r; - race *rc; - - test_cleanup(); - rc = rc_get_or_create("dragon"); - rc->flags |= RCF_UNARMEDGUARD; - r = test_create_region(0, 0, 0); - u1 = test_create_unit(test_create_faction(0), r); - u2 = test_create_unit(test_create_faction(rc), r); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TRAVELTHRU)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_PRODUCE)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TREES)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_MINING)); - guard(u2, GUARD_MINING | GUARD_PRODUCE); - CuAssertIntEquals(tc, GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX | GUARD_PRODUCE | GUARD_RECRUIT, guard_flags(u2)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TRAVELTHRU)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TREES)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_MINING)); - CuAssertPtrEquals(tc, u2, is_guarded(r, u1, GUARD_PRODUCE)); - test_cleanup(); -} - static void test_ship_trails(CuTest *tc) { ship *sh; region *r1, *r2, *r3; @@ -526,7 +501,6 @@ CuSuite *get_move_suite(void) SUITE_ADD_TEST(suite, test_ship_has_harbormaster_contact); SUITE_ADD_TEST(suite, test_ship_has_harbormaster_ally); SUITE_ADD_TEST(suite, test_ship_has_harbormaster_same_faction); - SUITE_ADD_TEST(suite, test_is_guarded); SUITE_ADD_TEST(suite, test_ship_trails); SUITE_ADD_TEST(suite, test_age_trails); SUITE_ADD_TEST(suite, test_ship_no_overload); From 2c0f708d1bb4d0231c4977bff5801f20d5d1a921 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 30 Oct 2016 09:18:19 +0100 Subject: [PATCH 168/675] WIP: remove at_guard, GUARD_TREES and GUARD_MINING TODO: fix tests TODO: write new guard coverage --- res/core/resources/iron.xml | 1 - res/core/resources/laen.xml | 1 - res/core/resources/log.xml | 1 - src/attributes/attributes.c | 3 +- src/economy.c | 13 +-------- src/guard.c | 58 +++++-------------------------------- src/guard.h | 8 ----- src/guard.test.c | 13 ++------- src/kernel/item.h | 1 - src/kernel/xmlreader.c | 18 ------------ src/spells.c | 2 +- 11 files changed, 14 insertions(+), 105 deletions(-) diff --git a/res/core/resources/iron.xml b/res/core/resources/iron.xml index 7bc4cb428..3f8897abc 100644 --- a/res/core/resources/iron.xml +++ b/res/core/resources/iron.xml @@ -7,6 +7,5 @@ - diff --git a/res/core/resources/laen.xml b/res/core/resources/laen.xml index 571026a0a..12062bf07 100644 --- a/res/core/resources/laen.xml +++ b/res/core/resources/laen.xml @@ -5,6 +5,5 @@ - diff --git a/res/core/resources/log.xml b/res/core/resources/log.xml index 012fe9a20..e3a33ef8b 100644 --- a/res/core/resources/log.xml +++ b/res/core/resources/log.xml @@ -6,7 +6,6 @@ - diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index a82e1941d..e46988667 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -22,7 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "laws.h" #include "move.h" -#include "guard.h" /* attributes includes */ #include "follow.h" @@ -105,7 +104,6 @@ void register_attributes(void) at_register(&at_private); at_register(&at_icastle); - at_register(&at_guard); at_register(&at_group); at_register(&at_building_generic_type); @@ -124,6 +122,7 @@ void register_attributes(void) at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */ at_deprecate("lua", read_ext); /* required for old datafiles */ at_deprecate("gm", a_readint); + at_deprecate("guard", a_readint); /* used to contain guard-flags (v3.10.0-259-g8597e8b) */ at_register(&at_stealth); at_register(&at_dict); at_register(&at_unitdissolve); diff --git a/src/economy.c b/src/economy.c index 6ec5d9191..2aa3392ad 100644 --- a/src/economy.c +++ b/src/economy.c @@ -935,17 +935,6 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) } } - if (rdata->guard != 0) { - unit *u2; - for (u2 = r->units; u2; u2 = u2->next) { - if (is_guard(u2, rdata->guard) != 0 && can_guard(u2, u)) { - ADDMSG(&u->faction->msgs, - msg_feedback(u, u->thisorder, "region_guarded", "guard", u2)); - return; - } - } - } - /* Bergwchter knnen Abbau von Eisen/Laen durch Bewachen verhindern. * Als magische Wesen 'sehen' Bergwchter alles und werden durch * Belagerung nicht aufgehalten. (Ansonsten wie oben bei Elfen anpassen). @@ -953,7 +942,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) if (itype->rtype && (itype->rtype == get_resourcetype(R_IRON) || itype->rtype == rt_find("laen"))) { unit *u2; for (u2 = r->units; u2; u2 = u2->next) { - if (is_guard(u, GUARD_MINING) + if (is_guard(u, GUARD_ALL) && !fval(u2, UFL_ISNEW) && u2->number && !alliedunit(u2, u->faction, HELP_GUARD)) { ADDMSG(&u->faction->msgs, diff --git a/src/guard.c b/src/guard.c index cefcdb925..eb55525e8 100644 --- a/src/guard.c +++ b/src/guard.c @@ -39,7 +39,7 @@ attrib_type at_guard = { DEFAULT_INIT, DEFAULT_FINALIZE, DEFAULT_AGE, - a_writeint, + NULL, a_readint, NULL, ATF_UNIQUE @@ -70,13 +70,6 @@ void update_guards(void) if (can_start_guarding(u) != E_GUARD_OK) { setguard(u, GUARD_NONE); } - else { - attrib *a = a_find(u->attribs, &at_guard); - if (a && a->data.i == (int)guard_flags(u)) { - /* this is really rather not necessary */ - a_remove(&u->attribs, a); - } - } } } } @@ -97,50 +90,19 @@ unsigned int guard_flags(const unit * u) #if GUARD_DISABLES_RECRUIT == 1 flags |= GUARD_RECRUIT; #endif - if (rc_changed(&rc_cache)) { - rc_elf = get_race(RC_ELF); - rc_ent = get_race(RC_TREEMAN); - rc_ironkeeper = get_race(RC_IRONKEEPER); - } - if (rc == rc_elf) { - if (u->faction->race == u_race(u)) { - flags |= GUARD_TREES; - } - } - else if (rc == rc_ent) { - flags |= GUARD_TREES; - } - else if (rc == rc_ironkeeper) { - flags = GUARD_MINING; - } return flags; } void setguard(unit * u, unsigned int flags) { - /* setzt die guard-flags der Einheit */ - attrib *a = NULL; - assert(flags == 0 || !fval(u, UFL_MOVED)); - assert(flags == 0 || u->status < ST_FLEE); - if (fval(u, UFL_GUARD)) { - a = a_find(u->attribs, &at_guard); - } - if (flags == GUARD_NONE) { + bool enabled = (flags!=GUARD_NONE); + if (!enabled) { + assert(!fval(u, UFL_MOVED)); + assert(u->status < ST_FLEE); freset(u, UFL_GUARD); - if (a) - a_remove(&u->attribs, a); - return; - } - fset(u, UFL_GUARD); - fset(u->region, RF_GUARDED); - if (flags == guard_flags(u)) { - if (a) - a_remove(&u->attribs, a); - } - else { - if (!a) - a = a_add(&u->attribs, a_new(&at_guard)); - a->data.i = (int)flags; + } else { + fset(u, UFL_GUARD); + fset(u->region, RF_GUARDED); } } @@ -150,10 +112,6 @@ unsigned int getguard(const unit * u) assert(fval(u, UFL_GUARD) || (u->building && u == building_owner(u->building)) || !"you're doing it wrong! check is_guard first"); - a = a_find(u->attribs, &at_guard); - if (a) { - return (unsigned int)a->data.i; - } return guard_flags(u); } diff --git a/src/guard.h b/src/guard.h index 5fe476e11..d88db3b49 100644 --- a/src/guard.h +++ b/src/guard.h @@ -14,10 +14,6 @@ extern "C" { #define GUARD_NONE 0 #define GUARD_TAX 1 /* Verhindert Steuereintreiben */ -#define GUARD_MINING 2 - /* Verhindert Bergbau */ -#define GUARD_TREES 4 - /* Verhindert Waldarbeiten */ #define GUARD_TRAVELTHRU 8 /* Blockiert Durchreisende */ #define GUARD_LANDING 16 @@ -30,14 +26,10 @@ extern "C" { /* Verhindert Abbau von Resourcen mit RTF_LIMITED */ #define GUARD_ALL 0xFFFF - extern struct attrib_type at_guard; - guard_t can_start_guarding(const struct unit * u); void update_guards(void); - unsigned int guard_flags(const struct unit * u); unsigned int getguard(const struct unit * u); void setguard(struct unit * u, unsigned int flags); - void guard(struct unit * u, unsigned int mask); struct unit *is_guarded(struct region *r, struct unit *u, unsigned int mask); diff --git a/src/guard.test.c b/src/guard.test.c index 61f08be05..149b3df01 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -27,16 +27,9 @@ static void test_is_guarded(CuTest *tc) { r = test_create_region(0, 0, 0); u1 = test_create_unit(test_create_faction(0), r); u2 = test_create_unit(test_create_faction(rc), r); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TRAVELTHRU)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_PRODUCE)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TREES)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_MINING)); - guard(u2, GUARD_MINING | GUARD_PRODUCE); - CuAssertIntEquals(tc, GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX | GUARD_PRODUCE | GUARD_RECRUIT, guard_flags(u2)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TRAVELTHRU)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TREES)); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_MINING)); - CuAssertPtrEquals(tc, u2, is_guarded(r, u1, GUARD_PRODUCE)); + CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_ALL)); + guard(u2, GUARD_ALL); + CuAssertPtrEquals(tc, u2, is_guarded(r, u1, GUARD_ALL)); test_cleanup(); } diff --git a/src/kernel/item.h b/src/kernel/item.h index c3b33070e..26231fa2e 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -108,7 +108,6 @@ extern "C" { typedef struct resource_limit { rlimit_limit limit; rlimit_produce produce; - unsigned int guard; /* how to guard against theft */ int value; resource_mod *modifiers; } resource_limit; diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 38ead12ab..640a28940 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1053,24 +1053,6 @@ static int parse_resources(xmlDocPtr doc) } xmlXPathFreeObject(result); - result = xmlXPathEvalExpression(BAD_CAST "guard", xpath); - if (result->nodesetval != NULL) - for (k = 0; k != result->nodesetval->nodeNr; ++k) { - xmlNodePtr node = result->nodesetval->nodeTab[k]; - xmlChar *propFlag = xmlGetProp(node, BAD_CAST "flag"); - - if (propFlag != NULL) { - if (strcmp((const char *)propFlag, "logging") == 0) { - rdata->guard |= GUARD_TREES; - } - else if (strcmp((const char *)propFlag, "mining") == 0) { - rdata->guard |= GUARD_MINING; - } - xmlFree(propFlag); - } - } - xmlXPathFreeObject(result); - /* reading eressea/resources/resource/resourcelimit/function */ result = xmlXPathEvalExpression(BAD_CAST "function", xpath); if (result->nodesetval != NULL) diff --git a/src/spells.c b/src/spells.c index 7d300c5e1..c48c777f0 100644 --- a/src/spells.c +++ b/src/spells.c @@ -2196,7 +2196,7 @@ static int sp_ironkeeper(castorder * co) /*keeper->age = cast_level + 2; */ setstatus(keeper, ST_AVOID); /* kaempft nicht */ - guard(keeper, GUARD_MINING); + setguard(keeper, GUARD_ALL); fset(keeper, UFL_ISNEW); /* Parteitarnen, damit man nicht sofort wei, wer dahinter steckt */ if (rule_stealth_anon()) { From f147d6a8c84293d4fa4687b729a57fac001cfed6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 30 Oct 2016 09:43:28 +0100 Subject: [PATCH 169/675] remove at_guard from guard.c, fix compilation. --- src/guard.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/guard.c b/src/guard.c index eb55525e8..7a887c4c0 100644 --- a/src/guard.c +++ b/src/guard.c @@ -30,21 +30,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include -attrib_type at_guard = { - "guard", - DEFAULT_INIT, - DEFAULT_FINALIZE, - DEFAULT_AGE, - NULL, - a_readint, - NULL, - ATF_UNIQUE -}; - guard_t can_start_guarding(const unit * u) { if (u->status >= ST_FLEE || fval(u, UFL_FLEEING)) @@ -80,7 +68,6 @@ unsigned int guard_flags(const unit * u) // TODO: this should be a property of the race, like race.guard_flags static int rc_cache; static const race *rc_elf, *rc_ent, *rc_ironkeeper; - const race *rc = u_race(u); unsigned int flags = GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX; // TODO: configuration, not define @@ -108,8 +95,6 @@ void setguard(unit * u, unsigned int flags) unsigned int getguard(const unit * u) { - attrib *a; - assert(fval(u, UFL_GUARD) || (u->building && u == building_owner(u->building)) || !"you're doing it wrong! check is_guard first"); return guard_flags(u); From eb7199450dd63a1094f862245a8470f8e2d276ae Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 30 Oct 2016 09:47:18 +0100 Subject: [PATCH 170/675] fix Linux compilation. --- src/economy.c | 13 ------------- src/guard.c | 2 -- 2 files changed, 15 deletions(-) diff --git a/src/economy.c b/src/economy.c index 2aa3392ad..dd6efa890 100644 --- a/src/economy.c +++ b/src/economy.c @@ -872,19 +872,6 @@ typedef struct allocation_list { static allocation_list *allocations; -static bool can_guard(const unit * guard, const unit * u) -{ - if (fval(guard, UFL_ISNEW)) - return false; - if (guard->number <= 0 || !cansee(guard->faction, guard->region, u, 0)) - return false; - if (besieged(guard) || !(fval(u_race(guard), RCF_UNARMEDGUARD) - || armedmen(guard, true))) - return false; - - return !alliedunit(guard, u->faction, HELP_GUARD); -} - enum { AFL_DONE = 1 << 0, AFL_LOWSKILL = 1 << 1 diff --git a/src/guard.c b/src/guard.c index 7a887c4c0..739ad8c48 100644 --- a/src/guard.c +++ b/src/guard.c @@ -66,8 +66,6 @@ void update_guards(void) unsigned int guard_flags(const unit * u) { // TODO: this should be a property of the race, like race.guard_flags - static int rc_cache; - static const race *rc_elf, *rc_ent, *rc_ironkeeper; unsigned int flags = GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX; // TODO: configuration, not define From 2953a5f03621bb76ba0c413c318ae69500a5b649 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 30 Oct 2016 09:49:30 +0100 Subject: [PATCH 171/675] fix swapped assertions. --- src/guard.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/guard.c b/src/guard.c index 739ad8c48..ac8809534 100644 --- a/src/guard.c +++ b/src/guard.c @@ -82,10 +82,10 @@ void setguard(unit * u, unsigned int flags) { bool enabled = (flags!=GUARD_NONE); if (!enabled) { - assert(!fval(u, UFL_MOVED)); - assert(u->status < ST_FLEE); freset(u, UFL_GUARD); } else { + assert(!fval(u, UFL_MOVED)); + assert(u->status < ST_FLEE); fset(u, UFL_GUARD); fset(u->region, RF_GUARDED); } From 182cecf31b159f7801d2cbdc6acc7d6e983b3c60 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 30 Oct 2016 19:27:00 +0100 Subject: [PATCH 172/675] fix tests that use leveled resources. --- scripts/tests/economy.lua | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua index 5678cfc6c..b628dd47b 100644 --- a/scripts/tests/economy.lua +++ b/scripts/tests/economy.lua @@ -99,30 +99,32 @@ end function test_guard_protects_iron() local r = region.create(0, 0, "plain") r:set_resource("iron", 100) + local level = r:get_resourcelevel("iron") local u = unit.create(faction.create("human"), r) - u:set_skill("mining", 1) + u:set_skill("mining", level) local guard = unit.create(get_monsters(), r, 1) guard:add_order("BEWACHEN") u:add_order("MACHE EISEN") process_orders() - assert_equal(1, u:get_item("iron")) + assert_equal(level, u:get_item("iron")) process_orders() - assert_equal(1, u:get_item("iron")) + assert_equal(level, u:get_item("iron")) end function test_ironkeeper_guards_iron() local r = region.create(0, 0, "plain") r:set_resource("iron", 100) + local level = r:get_resourcelevel("iron") local u = unit.create(faction.create("human"), r) - u:set_skill("mining", 1) + u:set_skill("mining", level) local guard = unit.create(faction.create("mountainguard"), r, 1, "mountainguard") guard:add_order("BEWACHEN") u:add_order("MACHE EISEN") process_orders() - assert_equal(1, u:get_item("iron")) + assert_equal(level, u:get_item("iron")) process_orders() - assert_equal(1, u:get_item("iron")) + assert_equal(level, u:get_item("iron")) end function test_ent_guards_trees() @@ -140,26 +142,5 @@ function test_ent_guards_trees() process_orders() assert_equal(1, u:get_item("log")) process_orders() - -- print("report: " .. tostring(u.faction)) - -- init_reports() - -- write_report(u.faction) assert_equal(1, u:get_item("log")) end - -function test_ironkeeper_allows_recruit() - local r = region.create(0, 0, "plain") - r:set_resource("iron", 100) - local u = unit.create(faction.create("human"), r) - u:set_skill("mining", 1) - local guard = unit.create(faction.create("mountainguard"), r, 1, "mountainguard") - guard:add_order("BEWACHEN") - - u:add_item("money", 1000) - assert_equal(1, u.number) - u:add_order("REKRUTIERE 1") - process_orders() - assert_equal(2, u.number) - u:add_order("REKRUTIERE 1") - process_orders() - assert_equal(3, u.number) -end From 754ad78db7834652299f0b0abe1ef6af0855f9e1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 31 Oct 2016 07:45:06 +0100 Subject: [PATCH 173/675] WIP: remove GUARD_* flags. TODO: does not compile TODO: write new guard.test.c tests --- src/alchemy.c | 2 +- src/alchemy.test.c | 8 +++---- src/battle.c | 10 ++++----- src/bind_unit.c | 9 +++----- src/creport.c | 2 +- src/economy.c | 20 +++++++++--------- src/guard.c | 44 +++++++++------------------------------ src/guard.h | 24 ++++----------------- src/guard.test.c | 10 ++++----- src/kernel/build.c | 2 +- src/kernel/unit.c | 2 +- src/laws.c | 12 +++++------ src/monsters.c | 4 ++-- src/monsters.test.c | 10 ++++----- src/move.c | 8 +++---- src/report.c | 2 +- src/reports.c | 2 +- src/spells.c | 7 +++---- src/spells/combatspells.c | 4 ++-- src/spy.c | 2 +- 20 files changed, 70 insertions(+), 114 deletions(-) diff --git a/src/alchemy.c b/src/alchemy.c index 11a205869..7eac102fb 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -61,7 +61,7 @@ void herbsearch(unit * u, int max) return; } - if (is_guarded(r, u, GUARD_PRODUCE)) { + if (is_guarded(r, u)) { cmistake(u, u->thisorder, 70, MSG_EVENT); return; } diff --git a/src/alchemy.test.c b/src/alchemy.test.c index 7fd2da8e1..c281a1c98 100644 --- a/src/alchemy.test.c +++ b/src/alchemy.test.c @@ -30,7 +30,7 @@ static void test_herbsearch(CuTest * tc) rc = rc_get_or_create("dragon"); rc->flags |= RCF_UNARMEDGUARD; u2 = test_create_unit(test_create_faction(rc), r); - guard(u2, GUARD_PRODUCE); + setguard(u2, true); f = test_create_faction(0); u = test_create_unit(f, r); @@ -41,14 +41,14 @@ static void test_herbsearch(CuTest * tc) test_clear_messages(f); set_level(u, SK_HERBALISM, 1); - CuAssertPtrEquals(tc, u2, is_guarded(r, u, GUARD_PRODUCE)); + CuAssertPtrEquals(tc, u2, is_guarded(r, u)); herbsearch(u, INT_MAX); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error70")); CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error59")); test_clear_messages(f); - guard(u2, GUARD_NONE); - CuAssertPtrEquals(tc, 0, is_guarded(r, u, GUARD_PRODUCE)); + setguard(u2, false); + CuAssertPtrEquals(tc, 0, is_guarded(r, u)); CuAssertPtrEquals(tc, 0, (void *)rherbtype(r)); herbsearch(u, INT_MAX); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error108")); diff --git a/src/battle.c b/src/battle.c index fb411d778..5bf35f191 100644 --- a/src/battle.c +++ b/src/battle.c @@ -2425,7 +2425,7 @@ side *make_side(battle * b, const faction * f, const group * g, else { unit *u; for (u = b->region->units; u; u = u->next) { - if (is_guard(u, HELP_ALL)) { + if (is_guard(u)) { if (alliedunit(u, f, HELP_GUARD)) { flags |= SIDE_HASGUARDS; break; @@ -2726,7 +2726,7 @@ static void aftermath(battle * b) } scale_number(du, df->run.number); du->hp = df->run.hp; - setguard(du, GUARD_NONE); + setguard(du, false); /* must leave ships or buildings, or a stealthy hobbit * can hold castles indefinitely */ if (!fval(r->terrain, SEA_REGION)) { @@ -2763,7 +2763,7 @@ static void aftermath(battle * b) /* Distribute Loot */ loot_items(df); - setguard(du, GUARD_NONE); + setguard(du, true); scale_number(du, 0); } else { @@ -3878,7 +3878,7 @@ static void flee(const troop dt) fig->run.hp += fig->person[dt.index].hp; ++fig->run.number; - setguard(u, GUARD_NONE); + setguard(u, false); kill_troop(dt); } @@ -3941,7 +3941,7 @@ static bool start_battle(region * r, battle ** bp) if ((u->ship != NULL && !fval(r->terrain, SEA_REGION)) || (lsh = leftship(u)) != NULL) { - if (is_guarded(r, u, GUARD_TRAVELTHRU)) { + if (is_guarded(r, u)) { if (lsh) { cmistake(u, ord, 234, MSG_BATTLE); } diff --git a/src/bind_unit.c b/src/bind_unit.c index 3f3848e78..576678642 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -258,18 +258,15 @@ static int tolua_unit_set_flags(lua_State * L) static int tolua_unit_get_guard(lua_State * L) { unit *self = (unit *)tolua_tousertype(L, 1, 0); - if (is_guard(self, GUARD_ALL)) { - lua_pushinteger(L, getguard(self)); - return 1; - } - return 0; + lua_pushboolean(L, is_guard(self)); + return 1; } static int tolua_unit_set_guard(lua_State * L) { unit *self = (unit *)tolua_tousertype(L, 1, 0); unsigned int flags = (unsigned int)tolua_tonumber(L, 2, 0); - setguard(self, flags); + setguard(self, flags!=0); return 0; } diff --git a/src/creport.c b/src/creport.c index 5e7442030..0eb2d4abb 100644 --- a/src/creport.c +++ b/src/creport.c @@ -849,7 +849,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f, assert(u->ship->region); stream_printf(out, "%d;Schiff\n", u->ship->no); } - if (is_guard(u, GUARD_ALL) != 0) { + if (is_guard(u)) { stream_printf(out, "%d;bewacht\n", 1); } if ((b = usiege(u)) != NULL) { diff --git a/src/economy.c b/src/economy.c index dd6efa890..1836c1305 100644 --- a/src/economy.c +++ b/src/economy.c @@ -459,7 +459,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders) /* this is a very special case because the recruiting unit may be empty * at this point and we have to look at the creating unit instead. This * is done in cansee, which is called indirectly by is_guarded(). */ - if (is_guarded(r, u, GUARD_RECRUIT)) { + if (is_guarded(r, u)) { cmistake(u, ord, 70, MSG_EVENT); return; } @@ -929,7 +929,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) if (itype->rtype && (itype->rtype == get_resourcetype(R_IRON) || itype->rtype == rt_find("laen"))) { unit *u2; for (u2 = r->units; u2; u2 = u2->next) { - if (is_guard(u, GUARD_ALL) + if (is_guard(u) && !fval(u2, UFL_ISNEW) && u2->number && !alliedunit(u2, u->faction, HELP_GUARD)) { ADDMSG(&u->faction->msgs, @@ -1246,7 +1246,7 @@ static void create_item(unit * u, const item_type * itype, int want) { if (itype->construction && fval(itype->rtype, RTF_LIMITED)) { #if GUARD_DISABLES_PRODUCTION == 1 - if (is_guarded(u->region, u, GUARD_PRODUCE)) { + if (is_guarded(u->region, u)) { cmistake(u, u->thisorder, 70, MSG_EVENT); return; } @@ -1548,11 +1548,11 @@ static void buy(unit * u, request ** buyorders, struct order *ord) keyword_t kwd; const char *s; - if (u->ship && is_guarded(r, u, GUARD_CREWS)) { + if (u->ship && is_guarded(r, u)) { cmistake(u, ord, 69, MSG_INCOME); return; } - if (u->ship && is_guarded(r, u, GUARD_CREWS)) { + if (u->ship && is_guarded(r, u)) { cmistake(u, ord, 69, MSG_INCOME); return; } @@ -1866,7 +1866,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) caravan_bt = bt_find("caravan"); } - if (u->ship && is_guarded(r, u, GUARD_CREWS)) { + if (u->ship && is_guarded(r, u)) { cmistake(u, ord, 69, MSG_INCOME); return false; } @@ -2581,7 +2581,7 @@ void entertain_cmd(unit * u, struct order *ord) cmistake(u, ord, 60, MSG_INCOME); return; } - if (u->ship && is_guarded(r, u, GUARD_CREWS)) { + if (u->ship && is_guarded(r, u)) { cmistake(u, ord, 69, MSG_INCOME); return; } @@ -2678,7 +2678,7 @@ static int do_work(unit * u, order * ord, request * o) cmistake(u, ord, 60, MSG_INCOME); return -1; } - if (u->ship && is_guarded(r, u, GUARD_CREWS)) { + if (u->ship && is_guarded(r, u)) { if (ord) cmistake(u, ord, 69, MSG_INCOME); return -1; @@ -2815,7 +2815,7 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders) u->wants = _min(n * effskill(u, SK_TAXING, 0) * taxperlevel, max); } - u2 = is_guarded(r, u, GUARD_TAX); + u2 = is_guarded(r, u); if (u2) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "region_guarded", "guard", u2)); @@ -2870,7 +2870,7 @@ void loot_cmd(unit * u, struct order *ord, request ** lootorders) return; } - u2 = is_guarded(r, u, GUARD_TAX); + u2 = is_guarded(r, u); if (u2) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "region_guarded", "guard", u2)); diff --git a/src/guard.c b/src/guard.c index ac8809534..86af55f85 100644 --- a/src/guard.c +++ b/src/guard.c @@ -56,31 +56,15 @@ void update_guards(void) for (u = r->units; u; u = u->next) { if (fval(u, UFL_GUARD)) { if (can_start_guarding(u) != E_GUARD_OK) { - setguard(u, GUARD_NONE); + setguard(u, false); } } } } } -unsigned int guard_flags(const unit * u) +void setguard(unit * u, bool enabled) { - // TODO: this should be a property of the race, like race.guard_flags - unsigned int flags = - GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX; - // TODO: configuration, not define -#if GUARD_DISABLES_PRODUCTION == 1 - flags |= GUARD_PRODUCE; -#endif -#if GUARD_DISABLES_RECRUIT == 1 - flags |= GUARD_RECRUIT; -#endif - return flags; -} - -void setguard(unit * u, unsigned int flags) -{ - bool enabled = (flags!=GUARD_NONE); if (!enabled) { freset(u, UFL_GUARD); } else { @@ -91,24 +75,16 @@ void setguard(unit * u, unsigned int flags) } } -unsigned int getguard(const unit * u) +void guard(unit * u) { - assert(fval(u, UFL_GUARD) || (u->building && u == building_owner(u->building)) - || !"you're doing it wrong! check is_guard first"); - return guard_flags(u); + setguard(u, true); } -void guard(unit * u, unsigned int mask) -{ - unsigned int flags = guard_flags(u); - setguard(u, flags & mask); -} - -static bool is_guardian_u(const unit * guard, unit * u, unsigned int mask) +static bool is_guardian_u(const unit * guard, unit * u) { if (guard->faction == u->faction) return false; - if (is_guard(guard, mask) == 0) + if (is_guard(guard) == 0) return false; if (alliedunit(guard, u->faction, HELP_GUARD)) return false; @@ -145,12 +121,12 @@ static bool is_guardian_r(const unit * guard) return fval(u_race(guard), RCF_UNARMEDGUARD) || is_monsters(guard->faction) || (armedmen(guard, true) > 0); } -bool is_guard(const struct unit * u, unsigned int mask) +bool is_guard(const struct unit * u) { - return is_guardian_r(u) && (getguard(u) & mask) != 0; + return is_guardian_r(u); } -unit *is_guarded(region * r, unit * u, unsigned int mask) +unit *is_guarded(region * r, unit * u) { unit *u2; int noguards = 1; @@ -166,7 +142,7 @@ unit *is_guarded(region * r, unit * u, unsigned int mask) for (u2 = r->units; u2; u2 = u2->next) { if (is_guardian_r(u2)) { noguards = 0; - if (is_guardian_u(u2, u, mask)) { + if (is_guardian_u(u2, u)) { /* u2 is our guard. stop processing (we might have to go further next time) */ return u2; } diff --git a/src/guard.h b/src/guard.h index d88db3b49..4743230d3 100644 --- a/src/guard.h +++ b/src/guard.h @@ -11,29 +11,13 @@ extern "C" { typedef enum { E_GUARD_OK, E_GUARD_UNARMED, E_GUARD_NEWBIE, E_GUARD_FLEEING } guard_t; -#define GUARD_NONE 0 -#define GUARD_TAX 1 - /* Verhindert Steuereintreiben */ -#define GUARD_TRAVELTHRU 8 - /* Blockiert Durchreisende */ -#define GUARD_LANDING 16 - /* Verhindert Ausstieg + Weiterreise */ -#define GUARD_CREWS 32 - /* Verhindert Unterhaltung auf Schiffen */ -#define GUARD_RECRUIT 64 - /* Verhindert Rekrutieren */ -#define GUARD_PRODUCE 128 - /* Verhindert Abbau von Resourcen mit RTF_LIMITED */ -#define GUARD_ALL 0xFFFF - guard_t can_start_guarding(const struct unit * u); void update_guards(void); - unsigned int getguard(const struct unit * u); - void setguard(struct unit * u, unsigned int flags); - void guard(struct unit * u, unsigned int mask); + void setguard(struct unit * u, bool enabled); + void guard(struct unit *u); - struct unit *is_guarded(struct region *r, struct unit *u, unsigned int mask); - bool is_guard(const struct unit *u, unsigned int mask); + struct unit *is_guarded(struct region *r, struct unit *u); + bool is_guard(const struct unit *u); #ifdef __cplusplus } diff --git a/src/guard.test.c b/src/guard.test.c index 149b3df01..e1b8e406c 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -48,7 +48,7 @@ static void test_guard_unskilled(CuTest * tc) ug = test_create_unit(test_create_faction(0), r); i_change(&ug->items, itype, 1); set_level(ug, SK_MELEE, 1); - setguard(ug, GUARD_ALL); + setguard(ug, true); CuAssertPtrEquals(tc, 0, is_guarded(r, u, GUARD_PRODUCE)); test_cleanup(); } @@ -67,7 +67,7 @@ static void test_guard_armed(CuTest * tc) ug = test_create_unit(test_create_faction(0), r); i_change(&ug->items, itype, 1); set_level(ug, SK_MELEE, 2); - setguard(ug, GUARD_ALL); + setguard(ug, true); CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); test_cleanup(); } @@ -85,7 +85,7 @@ static void test_is_guard(CuTest * tc) ug = test_create_unit(test_create_faction(0), r); i_change(&ug->items, itype, 1); set_level(ug, SK_MELEE, 2); - setguard(ug, GUARD_ALL); + setguard(ug, true); CuAssertIntEquals(tc, 1, armedmen(ug, false)); CuAssertTrue(tc, is_guard(ug, GUARD_RECRUIT)); set_level(ug, SK_MELEE, 1); @@ -109,7 +109,7 @@ static void test_guard_unarmed(CuTest * tc) r = test_create_region(0, 0, 0); u = test_create_unit(test_create_faction(0), r); ug = test_create_unit(test_create_faction(rc), r); - setguard(ug, GUARD_ALL); + setguard(ug, true); CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); test_cleanup(); } @@ -123,7 +123,7 @@ static void test_guard_monsters(CuTest * tc) r = test_create_region(0, 0, 0); u = test_create_unit(test_create_faction(0), r); ug = test_create_unit(get_monsters(), r); - setguard(ug, GUARD_ALL); + setguard(ug, true); CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); test_cleanup(); } diff --git a/src/kernel/build.c b/src/kernel/build.c index 6bc953241..f963797fd 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -113,7 +113,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord) } for (u2 = r->units; u2; u2 = u2->next) { - if (u2->faction != u->faction && is_guard(u2, GUARD_TAX) + if (u2->faction != u->faction && is_guard(u2) && cansee(u2->faction, u->region, u, 0) && !alliedunit(u, u2->faction, HELP_GUARD)) { cmistake(u, ord, 70, MSG_EVENT); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index ad8377254..f43ef53bc 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -948,7 +948,7 @@ void move_unit(unit * u, region * r, unit ** ulist) if (!ulist) ulist = (&r->units); if (u->region) { - setguard(u, GUARD_NONE); + setguard(u, false); fset(u, UFL_MOVED); if (u->ship || u->building) { /* can_leave must be checked in travel_i */ diff --git a/src/laws.c b/src/laws.c index a2f7f0044..47cb4b13a 100755 --- a/src/laws.c +++ b/src/laws.c @@ -2556,7 +2556,7 @@ int guard_off_cmd(unit * u, struct order *ord) init_order(ord); if (getparam(u->faction->locale) == P_NOT) { - setguard(u, GUARD_NONE); + setguard(u, false); } return 0; } @@ -2698,7 +2698,7 @@ int guard_on_cmd(unit * u, struct order *ord) else { int err = can_start_guarding(u); if (err == E_GUARD_OK) { - guard(u, GUARD_ALL); + setguard(u, true); } else if (err == E_GUARD_UNARMED) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "unit_unarmed", "")); @@ -4171,7 +4171,7 @@ int siege_cmd(unit * u, order * ord) return 80; } - if (!is_guard(u, GUARD_TRAVELTHRU)) { + if (!is_guard(u)) { /* abbruch, wenn die einheit nicht vorher die region bewacht - als * warnung fuer alle anderen! */ cmistake(u, ord, 81, MSG_EVENT); @@ -4485,7 +4485,7 @@ cansee(const faction * f, const region * r, const unit * u, int modifier) return false; /* simple visibility, just gotta have a unit in the region to see 'em */ - if (is_guard(u, GUARD_ALL) != 0 || usiege(u) || u->building || u->ship) { + if (is_guard(u) || usiege(u) || u->building || u->ship) { return true; } @@ -4524,7 +4524,7 @@ bool cansee_unit(const unit * u, const unit * target, int modifier) else { int n, rings, o; - if (is_guard(target, GUARD_ALL) != 0 || usiege(target) || target->building + if (is_guard(target) || usiege(target) || target->building || target->ship) { return true; } @@ -4568,7 +4568,7 @@ cansee_durchgezogen(const faction * f, const region * r, const unit * u, else { int rings; - if (is_guard(u, GUARD_ALL) != 0 || usiege(u) || u->building || u->ship) { + if (is_guard(u) || usiege(u) || u->building || u->ship) { return true; } diff --git a/src/monsters.c b/src/monsters.c index 258175b43..3301f157a 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -202,7 +202,7 @@ static order *get_money_for_dragon(region * r, unit * udragon, int wanted) /* falls der drache launisch ist, oder das regionssilber knapp, greift er alle an * und holt sich Silber von Einheiten, vorausgesetzt er bewacht bereits */ money = 0; - if (attacks && is_guard(udragon, GUARD_TAX)) { + if (attacks && is_guard(udragon)) { money += monster_attacks(udragon, true, true); } @@ -735,7 +735,7 @@ void plan_monsters(faction * f) setstatus(u, ST_FIGHT); /* all monsters fight */ } - if (attacking && (!r->land || is_guard(u, GUARD_TAX))) { + if (attacking && (!r->land || is_guard(u))) { monster_attacks(u, true, false); } diff --git a/src/monsters.test.c b/src/monsters.test.c index 6797a9ce0..ca793891c 100644 --- a/src/monsters.test.c +++ b/src/monsters.test.c @@ -74,7 +74,7 @@ static void test_monsters_attack(CuTest * tc) create_monsters(&f, &f2, &u, &m); - guard(m, GUARD_TAX); + setguard(m, true); config_set("rules.monsters.attack_chance", "1"); @@ -111,7 +111,7 @@ static void test_monsters_waiting(CuTest * tc) unit *u, *m; create_monsters(&f, &f2, &u, &m); - guard(m, GUARD_TAX); + setguard(m, true); fset(m, UFL_ISNEW); monster_attacks(m, false, false); CuAssertPtrEquals(tc, 0, find_order("attack 1", m)); @@ -150,8 +150,8 @@ static void test_monsters_attack_not(CuTest * tc) create_monsters(&f, &f2, &u, &m); - guard(m, GUARD_TAX); - guard(u, GUARD_TAX); + setguard(m, true); + setguard(u, true); config_set("rules.monsters.attack_chance", "0"); @@ -170,7 +170,7 @@ static void test_dragon_attacks_the_rich(CuTest * tc) create_monsters(&f, &f2, &u, &m); init_resources(); - guard(m, GUARD_TAX); + setguard(m, true); set_level(m, SK_WEAPONLESS, 10); rsetmoney(findregion(0, 0), 1); diff --git a/src/move.c b/src/move.c index ac7c46083..78232480f 100644 --- a/src/move.c +++ b/src/move.c @@ -934,7 +934,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r) if (fval(u_race(reisender), RCF_ILLUSIONARY)) return NULL; for (u = r->units; u; u = u->next) { - if (is_guard(u, GUARD_TRAVELTHRU)) { + if (is_guard(u)) { int sk = effskill(u, SK_PERCEPTION, r); if (invisible(reisender, u) >= reisender->number) continue; @@ -1615,7 +1615,7 @@ static const region_list *travel_route(unit * u, /* the unit has moved at least one region */ int walkmode; - setguard(u, GUARD_NONE); + setguard(u, false); cycle_route(ord, u, steps); if (mode == TRAVEL_RUNNING) { @@ -1643,7 +1643,7 @@ static const region_list *travel_route(unit * u, /* make orders for the followers */ } fset(u, UFL_LONGACTION | UFL_NOTMOVING); - setguard(u, GUARD_NONE); + setguard(u, false); assert(u->region == current); return iroute; } @@ -2141,7 +2141,7 @@ static void travel(unit * u, region_list ** routep) sh = NULL; } if (sh) { - unit *guard = is_guarded(r, u, GUARD_LANDING); + unit *guard = is_guarded(r, u); if (guard) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "region_guarded", "guard", guard)); diff --git a/src/report.c b/src/report.c index c7093da73..e9a0681ba 100644 --- a/src/report.c +++ b/src/report.c @@ -1671,7 +1671,7 @@ static void guards(stream *out, const region * r, const faction * see) /* Bewachung */ for (u = r->units; u; u = u->next) { - if (is_guard(u, GUARD_ALL) != 0) { + if (is_guard(u) != 0) { faction *f = u->faction; faction *fv = visible_faction(see, u); diff --git a/src/reports.c b/src/reports.c index 5a7f29a10..b99cda5fc 100644 --- a/src/reports.c +++ b/src/reports.c @@ -582,7 +582,7 @@ size_t size) } } } - if (is_guard(u, GUARD_ALL) != 0) { + if (is_guard(u)) { bufp = STRLCPY(bufp, ", ", size); bufp = STRLCPY(bufp, LOC(f->locale, "unit_guards"), size); } diff --git a/src/spells.c b/src/spells.c index c48c777f0..e4ca75fbc 100644 --- a/src/spells.c +++ b/src/spells.c @@ -2196,7 +2196,7 @@ static int sp_ironkeeper(castorder * co) /*keeper->age = cast_level + 2; */ setstatus(keeper, ST_AVOID); /* kaempft nicht */ - setguard(keeper, GUARD_ALL); + setguard(keeper, true); fset(keeper, UFL_ISNEW); /* Parteitarnen, damit man nicht sofort wei, wer dahinter steckt */ if (rule_stealth_anon()) { @@ -2386,7 +2386,6 @@ void patzer_peasantmob(const castorder * co) create_unit(r, f, n, get_race(RC_PEASANT), 0, LOC(f->locale, "angry_mob"), NULL); fset(u, UFL_ISNEW); - /* guard(u, GUARD_ALL); hier zu frueh! Befehl BEWACHE setzten */ addlist(&u->orders, create_order(K_GUARD, lang, NULL)); set_order(&u->thisorder, default_order(lang)); a = a_new(&at_unitdissolve); @@ -3746,7 +3745,7 @@ static int sp_rallypeasantmob(castorder * co) rsetpeasants(r, rpeasants(r) + u->number); rsetmoney(r, rmoney(r) + get_money(u)); set_money(u, 0); - setguard(u, GUARD_NONE); + setguard(u, false); set_number(u, 0); erfolg = cast_level; } @@ -3813,7 +3812,7 @@ static int sp_raisepeasantmob(castorder * co) create_unit(r, monsters, n, get_race(RC_PEASANT), 0, LOC(monsters->locale, "furious_mob"), NULL); fset(u, UFL_ISNEW); - guard(u, GUARD_ALL); + setguard(u, true); a = a_new(&at_unitdissolve); a->data.ca[0] = 1; /* An rpeasants(r). */ a->data.ca[1] = 15; /* 15% */ diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index bcbbb1b52..bf122729a 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -1437,7 +1437,7 @@ int sp_denyattack(struct castorder * co) leave(mage, false); } /* und bewachen nicht */ - setguard(mage, GUARD_NONE); + setguard(mage, false); /* irgendwie den langen befehl sperren */ /* fset(fi, FIG_ATTACKED); */ @@ -1800,7 +1800,7 @@ int sp_undeadhero(struct castorder * co) unit_setinfo(u, NULL); } setstatus(u, du->status); - setguard(u, GUARD_NONE); + setguard(u, false); for (ilist = &du->items; *ilist;) { item *itm = *ilist; int loot = itm->number * j / du->number; diff --git a/src/spy.c b/src/spy.c index 9b8fe4601..01a419aba 100644 --- a/src/spy.c +++ b/src/spy.c @@ -463,7 +463,7 @@ static void sink_ship(region * r, ship * sh, unit * saboteur) } leave_ship(u); if (r != safety) { - setguard(u, GUARD_NONE); + setguard(u, false); } while (u->items) { i_remove(&u->items, u->items); From 0bcb3a853f4dab373fd1de244f29969cc43db7f7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 31 Oct 2016 09:40:36 +0100 Subject: [PATCH 174/675] WIP: finish removing GUARD_* flags TODO: fix failing tests --- src/guard.test.c | 20 ++++++++++---------- src/kernel/build.test.c | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/guard.test.c b/src/guard.test.c index e1b8e406c..60e5453c6 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -27,9 +27,9 @@ static void test_is_guarded(CuTest *tc) { r = test_create_region(0, 0, 0); u1 = test_create_unit(test_create_faction(0), r); u2 = test_create_unit(test_create_faction(rc), r); - CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_ALL)); - guard(u2, GUARD_ALL); - CuAssertPtrEquals(tc, u2, is_guarded(r, u1, GUARD_ALL)); + CuAssertPtrEquals(tc, 0, is_guarded(r, u1)); + setguard(u2, true); + CuAssertPtrEquals(tc, u2, is_guarded(r, u1)); test_cleanup(); } @@ -49,7 +49,7 @@ static void test_guard_unskilled(CuTest * tc) i_change(&ug->items, itype, 1); set_level(ug, SK_MELEE, 1); setguard(ug, true); - CuAssertPtrEquals(tc, 0, is_guarded(r, u, GUARD_PRODUCE)); + CuAssertPtrEquals(tc, 0, is_guarded(r, u)); test_cleanup(); } @@ -68,7 +68,7 @@ static void test_guard_armed(CuTest * tc) i_change(&ug->items, itype, 1); set_level(ug, SK_MELEE, 2); setguard(ug, true); - CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); + CuAssertPtrEquals(tc, ug, is_guarded(r, u)); test_cleanup(); } @@ -87,13 +87,13 @@ static void test_is_guard(CuTest * tc) set_level(ug, SK_MELEE, 2); setguard(ug, true); CuAssertIntEquals(tc, 1, armedmen(ug, false)); - CuAssertTrue(tc, is_guard(ug, GUARD_RECRUIT)); + CuAssertTrue(tc, is_guard(ug)); set_level(ug, SK_MELEE, 1); CuAssertIntEquals(tc, 0, armedmen(ug, false)); - CuAssertTrue(tc, !is_guard(ug, GUARD_RECRUIT)); + CuAssertTrue(tc, !is_guard(ug)); set_level(ug, SK_MELEE, 2); CuAssertIntEquals(tc, 1, armedmen(ug, false)); - CuAssertTrue(tc, is_guard(ug, GUARD_RECRUIT)); + CuAssertTrue(tc, is_guard(ug)); test_cleanup(); } @@ -110,7 +110,7 @@ static void test_guard_unarmed(CuTest * tc) u = test_create_unit(test_create_faction(0), r); ug = test_create_unit(test_create_faction(rc), r); setguard(ug, true); - CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); + CuAssertPtrEquals(tc, ug, is_guarded(r, u)); test_cleanup(); } @@ -124,7 +124,7 @@ static void test_guard_monsters(CuTest * tc) u = test_create_unit(test_create_faction(0), r); ug = test_create_unit(get_monsters(), r); setguard(ug, true); - CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); + CuAssertPtrEquals(tc, ug, is_guarded(r, u)); test_cleanup(); } diff --git a/src/kernel/build.test.c b/src/kernel/build.test.c index 9ea473725..390a0f1a9 100644 --- a/src/kernel/build.test.c +++ b/src/kernel/build.test.c @@ -318,7 +318,7 @@ unit *test_create_guard(region *r, faction *f, race *rc) { f = test_create_faction(rc); } ug = test_create_unit(f, r); - guard(ug, GUARD_TAX); + setguard(ug, true); return ug; } @@ -345,7 +345,7 @@ static void test_build_destroy_road_guard(CuTest *tc) CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "destroy_road")); test_clear_messages(f); - guard(ug, GUARD_NONE); + setguard(ug, true); CuAssertIntEquals(tc, 0, destroy_cmd(u, ord)); CuAssertIntEquals(tc, 99, rroad(r, D_EAST)); From 313d988e59a3a9f26f361a0b11cc2dd934d8a698 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 31 Oct 2016 20:10:17 +0100 Subject: [PATCH 175/675] fix remaining unit test after guard changes. --- src/kernel/build.test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/build.test.c b/src/kernel/build.test.c index 390a0f1a9..b714f58f0 100644 --- a/src/kernel/build.test.c +++ b/src/kernel/build.test.c @@ -345,7 +345,7 @@ static void test_build_destroy_road_guard(CuTest *tc) CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "destroy_road")); test_clear_messages(f); - setguard(ug, true); + setguard(ug, false); CuAssertIntEquals(tc, 0, destroy_cmd(u, ord)); CuAssertIntEquals(tc, 99, rroad(r, D_EAST)); From a285bd332c48db1696ed9bfe9b853c92193c88c8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 31 Oct 2016 20:12:19 +0100 Subject: [PATCH 176/675] fix lua tests to not expect numeric values for unit.guard --- scripts/tests/e2/guard.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/tests/e2/guard.lua b/scripts/tests/e2/guard.lua index f5be800c2..8e62a364d 100644 --- a/scripts/tests/e2/guard.lua +++ b/scripts/tests/e2/guard.lua @@ -13,24 +13,24 @@ function test_guard_unarmed() local r1 = region.create(0, 0, "plain") local f1 = faction.create("hodor@eressea.de", "human", "de") local u1 = unit.create(f1, r1, 1) - assert_equal(nil, u1.guard) + assert_equal(false, u1.guard) u1:clear_orders() u1:add_order("BEWACHE") process_orders() - assert_equal(nil, u1.guard) + assert_equal(false, u1.guard) end function test_guard_armed() local r1 = region.create(0, 0, "plain") local f1 = faction.create("hodor@eressea.de", "human", "de") local u1 = unit.create(f1, r1, 1) - assert_equal(nil, u1.guard) + assert_equal(false, u1.guard) u1:add_item("sword", 1) u1:set_skill("melee", 2) u1:clear_orders() u1:add_order("BEWACHE") process_orders() - assert_equal(249, u1.guard) + assert_equal(true, u1.guard) end function test_guard_allows_move_after_combat() -- bug 1493 @@ -47,7 +47,7 @@ function test_guard_allows_move_after_combat() -- bug 1493 u1:clear_orders() u1:add_order("BEWACHE") process_orders() - assert_equal(249, u1.guard) + assert_equal(true, u1.guard) u1:clear_orders() u1:add_order("NACH O") u1:add_order("ATTACKIERE " .. itoa36(u2.id)) @@ -67,7 +67,7 @@ function test_no_guard_no_move_after_combat() -- bug 1493 u1:add_order("BEWACHE") u1:add_item("sword", 10) u1:set_skill("melee", 2) - assert_equal(nil, u1.guard) + assert_equal(false, u1.guard) u1:clear_orders() u1:add_order("NACH O") u1:add_order("ATTACKIERE " .. itoa36(u2.id)) From 92d027014a2a5308ffa4d7c283e1e23e7a82d5c9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 31 Oct 2016 20:36:05 +0100 Subject: [PATCH 177/675] Make runtests more verbose in case of errors. Eliminate stray ERROR messages from tests. --- s/runtests | 8 ++++---- scripts/tests/config.lua | 6 +----- src/bind_faction.c | 2 +- src/reports.c | 6 +++--- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/s/runtests b/s/runtests index 2f22402dc..e0e20b5c7 100755 --- a/s/runtests +++ b/s/runtests @@ -16,10 +16,10 @@ fi $ROOT/$BUILD/eressea/test_eressea cd $ROOT [ -e eressea.ini ] || ln -sf conf/eressea.ini -$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests.lua -$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e2.lua -$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e3.lua -$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e4.lua +$ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests.lua +$ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests-e2.lua +$ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests-e3.lua +$ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests-e4.lua rm -rf data reports orders.txt score score.alliances datum turn cd $OLDWPD diff --git a/scripts/tests/config.lua b/scripts/tests/config.lua index d21ecda1e..e47b7f925 100644 --- a/scripts/tests/config.lua +++ b/scripts/tests/config.lua @@ -9,19 +9,15 @@ end function test_read_race() local f eressea.free_game() - f = faction.create("orc@example.com", "orc", "en") - assert_equal(nil, f) assert_not_nil(eressea.config) eressea.config.parse('{ "races": { "orc" : {}}}') f = faction.create("orc@example.com", "orc", "en") assert_not_nil(f) end -function test_read_ship() +function disable_test_read_ship() local s eressea.free_game() - s = ship.create(nil, "boat") - assert_equal(nil, s) assert_not_nil(eressea.config) conf = [[{ "ships": { diff --git a/src/bind_faction.c b/src/bind_faction.c index a4302f3c9..688b093b5 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -376,7 +376,7 @@ static int tolua_faction_create(lua_State * L) f = addfaction(email, NULL, frace, loc, 0); } if (!f) { - log_error("faction.create(%s, %s, %s)\n", email, racename, locale_name(loc)); + log_error("cannot create %s faction for %s, unknown race.", racename, email); } tolua_pushusertype(L, f, TOLUA_CAST "faction"); return 1; diff --git a/src/reports.c b/src/reports.c index b99cda5fc..a136645de 100644 --- a/src/reports.c +++ b/src/reports.c @@ -141,9 +141,9 @@ size_t report_status(const unit * u, const struct locale *lang, char *fsbuf, siz if (!status) { const char *lname = locale_name(lang); struct locale *wloc = get_or_create_locale(lname); - log_error("no translation for combat status %s in %s", combatstatus[u->status], lname); - locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]); - len = strlcpy(fsbuf, combatstatus[u->status], buflen); + log_warning("no translation for combat status %s in %s", combatstatus[u->status], lname); + locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]+7); + len = strlcpy(fsbuf, combatstatus[u->status]+7, buflen); } else { len = strlcpy(fsbuf, status, buflen); From a1422ce5e4eb73ec27240a1e1cd443e670fe3c89 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 31 Oct 2016 20:36:05 +0100 Subject: [PATCH 178/675] Make runtests more verbose in case of errors. Eliminate stray ERROR messages from tests. --- s/runtests | 8 ++++---- scripts/tests/config.lua | 6 +----- src/bind_faction.c | 2 +- src/reports.c | 6 +++--- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/s/runtests b/s/runtests index 2f22402dc..e0e20b5c7 100755 --- a/s/runtests +++ b/s/runtests @@ -16,10 +16,10 @@ fi $ROOT/$BUILD/eressea/test_eressea cd $ROOT [ -e eressea.ini ] || ln -sf conf/eressea.ini -$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests.lua -$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e2.lua -$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e3.lua -$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e4.lua +$ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests.lua +$ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests-e2.lua +$ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests-e3.lua +$ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests-e4.lua rm -rf data reports orders.txt score score.alliances datum turn cd $OLDWPD diff --git a/scripts/tests/config.lua b/scripts/tests/config.lua index d21ecda1e..e47b7f925 100644 --- a/scripts/tests/config.lua +++ b/scripts/tests/config.lua @@ -9,19 +9,15 @@ end function test_read_race() local f eressea.free_game() - f = faction.create("orc@example.com", "orc", "en") - assert_equal(nil, f) assert_not_nil(eressea.config) eressea.config.parse('{ "races": { "orc" : {}}}') f = faction.create("orc@example.com", "orc", "en") assert_not_nil(f) end -function test_read_ship() +function disable_test_read_ship() local s eressea.free_game() - s = ship.create(nil, "boat") - assert_equal(nil, s) assert_not_nil(eressea.config) conf = [[{ "ships": { diff --git a/src/bind_faction.c b/src/bind_faction.c index a4302f3c9..688b093b5 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -376,7 +376,7 @@ static int tolua_faction_create(lua_State * L) f = addfaction(email, NULL, frace, loc, 0); } if (!f) { - log_error("faction.create(%s, %s, %s)\n", email, racename, locale_name(loc)); + log_error("cannot create %s faction for %s, unknown race.", racename, email); } tolua_pushusertype(L, f, TOLUA_CAST "faction"); return 1; diff --git a/src/reports.c b/src/reports.c index 5a7f29a10..cfdc28bd2 100644 --- a/src/reports.c +++ b/src/reports.c @@ -141,9 +141,9 @@ size_t report_status(const unit * u, const struct locale *lang, char *fsbuf, siz if (!status) { const char *lname = locale_name(lang); struct locale *wloc = get_or_create_locale(lname); - log_error("no translation for combat status %s in %s", combatstatus[u->status], lname); - locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]); - len = strlcpy(fsbuf, combatstatus[u->status], buflen); + log_warning("no translation for combat status %s in %s", combatstatus[u->status], lname); + locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]+7); + len = strlcpy(fsbuf, combatstatus[u->status]+7, buflen); } else { len = strlcpy(fsbuf, status, buflen); From 03d90c5680c1bc9e27dbe5782a5100a2af9c237d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 1 Nov 2016 17:25:52 +0100 Subject: [PATCH 179/675] remove BOM from UTF-8 files, replace Umlauts --- src/creport.c | 6 +++--- src/give.c | 2 +- src/guard.c | 4 ++-- src/guard.h | 2 +- src/jsreport.c | 2 +- src/laws.c | 2 +- src/magic.c | 2 +- src/move.c | 2 +- src/report.c | 2 +- src/spy.c | 2 +- src/study.c | 2 +- src/summary.c | 2 +- src/travelthru.c | 2 +- src/travelthru.h | 2 +- src/travelthru.test.c | 2 +- src/upkeep.test.c | 2 +- 16 files changed, 19 insertions(+), 19 deletions(-) mode change 100755 => 100644 src/laws.c diff --git a/src/creport.c b/src/creport.c index 0eb2d4abb..986f58e09 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1,4 +1,4 @@ -/* +/* +-------------------+ Enno Rehling | Eressea PBEM host | Christian Schlittchen | (c) 1998 - 2008 | Katja Zedel @@ -185,9 +185,9 @@ cr_output_curses(stream *out, const faction * viewer, const void *obj, objtype_t region *r; /* Die Sichtbarkeit eines Zaubers und die Zaubermeldung sind bei - * Gebäuden und Schiffen je nach, ob man Besitzer ist, verschieden. + * Gebaeuden und Schiffen je nach, ob man Besitzer ist, verschieden. * Bei Einheiten sieht man Wirkungen auf eigene Einheiten immer. - * Spezialfälle (besonderes Talent, verursachender Magier usw. werde + * Spezialfaelle (besonderes Talent, verursachender Magier usw. werde * bei jedem curse gesondert behandelt. */ if (typ == TYP_SHIP) { ship *sh = (ship *)obj; diff --git a/src/give.c b/src/give.c index 80f4a1ab5..b6d1bd118 100644 --- a/src/give.c +++ b/src/give.c @@ -1,4 +1,4 @@ -/* +/* +-------------------+ Christian Schlittchen | | Enno Rehling | Eressea PBEM host | Katja Zedel diff --git a/src/guard.c b/src/guard.c index 86af55f85..adacd1bf6 100644 --- a/src/guard.c +++ b/src/guard.c @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 1998-2015, Enno Rehling Katja Zedel status >= ST_FLEE || fval(u, UFL_FLEEING)) return E_GUARD_FLEEING; - /* Monster der Monsterpartei dürfen immer bewachen */ + /* Monster der Monsterpartei duerfen immer bewachen */ if (is_monsters(u->faction) || fval(u_race(u), RCF_UNARMEDGUARD)) return E_GUARD_OK; if (!armedmen(u, true)) diff --git a/src/guard.h b/src/guard.h index 4743230d3..4fb6cbf56 100644 --- a/src/guard.h +++ b/src/guard.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #ifndef H_GUARD #define H_GUARD diff --git a/src/jsreport.c b/src/jsreport.c index d75b7919d..dc22c760a 100644 --- a/src/jsreport.c +++ b/src/jsreport.c @@ -1,4 +1,4 @@ -#include "reports.h" +#include "reports.h" #include "jsreport.h" #include #include diff --git a/src/laws.c b/src/laws.c old mode 100755 new mode 100644 index 47cb4b13a..9e53a465f --- a/src/laws.c +++ b/src/laws.c @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 1998-2014, Enno Rehling Katja Zedel Katja Zedel Katja Zedel Katja Zedel diff --git a/src/spy.c b/src/spy.c index 01a419aba..2abd10b75 100644 --- a/src/spy.c +++ b/src/spy.c @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 1998-2015, Enno Rehling Katja Zedel diff --git a/src/study.c b/src/study.c index 1ddaf8dfe..59f1130ea 100644 --- a/src/study.c +++ b/src/study.c @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 1998-2015, Enno Rehling Katja Zedel diff --git a/src/summary.c b/src/summary.c index cbc998b4a..6e94f31a8 100644 --- a/src/summary.c +++ b/src/summary.c @@ -1,4 +1,4 @@ -/* +/* * +-------------------+ Christian Schlittchen * | | Enno Rehling * | Eressea PBEM host | Katja Zedel diff --git a/src/travelthru.c b/src/travelthru.c index e55cacaa0..5e6cac41b 100644 --- a/src/travelthru.c +++ b/src/travelthru.c @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 1998-2015, Enno Rehling Katja Zedel diff --git a/src/travelthru.h b/src/travelthru.h index 4e43dd25a..16452869a 100644 --- a/src/travelthru.h +++ b/src/travelthru.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #ifndef H_TRAVELTHRU #define H_TRAVELTHRU diff --git a/src/travelthru.test.c b/src/travelthru.test.c index 74ab29b7e..be87743d2 100644 --- a/src/travelthru.test.c +++ b/src/travelthru.test.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/upkeep.test.c b/src/upkeep.test.c index 1013314aa..b4f2ae412 100644 --- a/src/upkeep.test.c +++ b/src/upkeep.test.c @@ -1,4 +1,4 @@ -#include +#include #include "upkeep.h" #include From 467ffe2db05511a1d8c5be77b35e71d3f74661db Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 1 Nov 2016 22:11:10 +0100 Subject: [PATCH 180/675] include guard.h directly, not through laws.h --- src/battle.c | 5 +++-- src/creport.c | 1 + src/economy.c | 1 + src/kernel/build.c | 1 + src/laws.h | 1 - src/laws.test.c | 1 + src/monsters.c | 1 + src/move.c | 1 + src/report.c | 1 + src/reports.c | 1 + src/spells.c | 1 + src/spy.c | 1 + 12 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/battle.c b/src/battle.c index 5bf35f191..20e80e7c7 100644 --- a/src/battle.c +++ b/src/battle.c @@ -21,10 +21,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "battle.h" #include "alchemy.h" #include "chaos.h" -#include "move.h" +#include "guard.h" #include "laws.h" -#include "skill.h" #include "monster.h" +#include "move.h" +#include "skill.h" #include #include diff --git a/src/creport.c b/src/creport.c index 986f58e09..8f32d3ac3 100644 --- a/src/creport.c +++ b/src/creport.c @@ -11,6 +11,7 @@ without prior permission by the authors of Eressea. #include #include #include "creport.h" +#include "guard.h" #include "travelthru.h" /* tweakable features */ diff --git a/src/economy.c b/src/economy.c index 1836c1305..50978152d 100644 --- a/src/economy.c +++ b/src/economy.c @@ -24,6 +24,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "alchemy.h" #include "direction.h" #include "donations.h" +#include "guard.h" #include "give.h" #include "laws.h" #include "randenc.h" diff --git a/src/kernel/build.c b/src/kernel/build.c index f963797fd..649679d93 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -24,6 +24,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "direction.h" #include "move.h" #include "study.h" +#include "guard.h" #include "laws.h" #include "skill.h" #include "lighthouse.h" diff --git a/src/laws.h b/src/laws.h index 55020dc06..c5e9d573c 100755 --- a/src/laws.h +++ b/src/laws.h @@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define H_GC_LAWS #include -#include "guard.h" #ifdef __cplusplus extern "C" { diff --git a/src/laws.test.c b/src/laws.test.c index 0f2d54e47..65f48012d 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1,6 +1,7 @@ #include #include "laws.h" #include "battle.h" +#include "guard.h" #include "monster.h" #include diff --git a/src/monsters.c b/src/monsters.c index 3301f157a..9f49a2603 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -25,6 +25,7 @@ #include "economy.h" #include "chaos.h" #include "give.h" +#include "guard.h" #include "monster.h" #include "laws.h" #include "keyword.h" diff --git a/src/move.c b/src/move.c index dffa1243c..e7148a521 100644 --- a/src/move.c +++ b/src/move.c @@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "move.h" +#include "guard.h" #include "laws.h" #include "reports.h" #include "study.h" diff --git a/src/report.c b/src/report.c index dbd15f5e2..ddf78bc73 100644 --- a/src/report.c +++ b/src/report.c @@ -23,6 +23,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "report.h" #include "reports.h" +#include "guard.h" #include "laws.h" #include "travelthru.h" #include "monster.h" diff --git a/src/reports.c b/src/reports.c index a136645de..c183786b4 100644 --- a/src/reports.c +++ b/src/reports.c @@ -19,6 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "reports.h" +#include "guard.h" #include "laws.h" #include "travelthru.h" #include "lighthouse.h" diff --git a/src/spells.c b/src/spells.c index e4ca75fbc..46eda80bd 100644 --- a/src/spells.c +++ b/src/spells.c @@ -15,6 +15,7 @@ #include #include +#include "guard.h" #include "spy.h" #include "vortex.h" #include "laws.h" diff --git a/src/spy.c b/src/spy.c index 2abd10b75..3233fb563 100644 --- a/src/spy.c +++ b/src/spy.c @@ -19,6 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "spy.h" +#include "guard.h" #include "laws.h" #include "move.h" #include "reports.h" From bad4fb47c5b67a953e89e2296c78fba9a2a92bf2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 5 Nov 2016 16:20:00 +0100 Subject: [PATCH 181/675] bad GUARD_NONE conversion, should have been false. --- src/battle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle.c b/src/battle.c index 20e80e7c7..5ae215135 100644 --- a/src/battle.c +++ b/src/battle.c @@ -2764,7 +2764,7 @@ static void aftermath(battle * b) /* Distribute Loot */ loot_items(df); - setguard(du, true); + setguard(du, false); scale_number(du, 0); } else { From fec99454580ac58c68e7782cf10e75dbc7017d9a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 5 Nov 2016 18:20:56 +0100 Subject: [PATCH 182/675] Fixing Bugs 2246 & 2251 parse error message for bad orders: https://bugs.eressea.de/view.php?id=2251 report when TEMP-Units cannot recuit: https://bugs.eressea.de/view.php?id=2246 --- res/core/messages.xml | 8 ++++++++ src/economy.c | 2 +- src/kernel/order.c | 4 ++-- src/kernel/save.c | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 2cb5a0a09..bf4b0c041 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -1,5 +1,13 @@ + + + + + + "$unit($unit): '$command' - Dieser Befehl ist unbekannt." + "$unit($unit): '$command' - Parse error, unknown command." + Die Region ist verwüstet, der Boden karg. The region is ravaged, the ground infertile. diff --git a/src/economy.c b/src/economy.c index 50978152d..10215d0da 100644 --- a/src/economy.c +++ b/src/economy.c @@ -341,8 +341,8 @@ static int do_recruiting(recruitment * recruits, int available) /* unit is empty, dead, and cannot recruit */ number = 0; } + add_recruits(u, number, req->qty); if (number > 0) { - add_recruits(u, number, req->qty); dec = (int)(number * multi); if ((rc->ec_flags & ECF_REC_ETHEREAL) == 0) { recruited += dec; diff --git a/src/kernel/order.c b/src/kernel/order.c index f79b2dd68..3fd1dc92f 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -285,7 +285,7 @@ static order *create_order_i(keyword_t kwd, const char *sptr, bool persistent, order *ord = NULL; int lindex; - if ((int)kwd > 0 && keyword_disabled(kwd)) { + if (kwd == NOKEYWORD || keyword_disabled(kwd)) { log_error("trying to create an order for disabled keyword %s.", keyword(kwd)); return NULL; } @@ -407,8 +407,8 @@ order *parse_order(const char *s, const struct locale * lang) if (kwd != NOKEYWORD) { while (isxspace(*(unsigned char *)sptr)) ++sptr; s = sptr; + return create_order_i(kwd, s, persistent, lang); } - return create_order_i(kwd, s, persistent, lang); } return NULL; } diff --git a/src/kernel/save.c b/src/kernel/save.c index 0b0ea222d..93c4f7e4b 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -206,12 +206,14 @@ static unit *unitorders(FILE * F, int enc, struct faction *f) if (*ordp) { ordp = &(*ordp)->next; } + else { + ADDMSG(&f->msgs, msg_message("parse_error", "unit command", u, s)); + } } } } else { - /* cmistake(?, buf, 160, MSG_EVENT); */ return NULL; } return u; From b9f6a3f62027ff449a38b2657f51dea6ef3a5237 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 5 Nov 2016 19:58:18 +0100 Subject: [PATCH 183/675] skillpotion appears as a vial to other players. https://bugs.eressea.de/view.php?id=2254 --- res/core/common/items.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/core/common/items.xml b/res/core/common/items.xml index 6afd220ff..444ea26a1 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -100,14 +100,14 @@ - + - + From f68fcf40a658671507ea044b41a4eb8fbabcfb22 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 8 Nov 2016 22:54:47 +0100 Subject: [PATCH 184/675] custom function to make "valid" names. remove any non-printable characters from a string. TODO: test with utf-8 values. TODO: remove leading/trainling whitespace. --- src/util/unicode.c | 32 ++++++++++++++++++++++++++++++++ src/util/unicode.h | 4 ++-- src/util/unicode.test.c | 12 ++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/util/unicode.c b/src/util/unicode.c index f7ea2653b..dd8e03814 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -14,6 +14,7 @@ #include #include #include +#include #define B00000000 0x00 #define B10000000 0x80 @@ -31,6 +32,37 @@ #define B00000011 0x03 #define B00000001 0x01 +int unicode_utf8_mkname(utf8_t * op, size_t outlen, const utf8_t * ip) +{ + while (*ip) { + ucs4_t ucs = *ip; + size_t size = 1; + bool isp = false; +// bool iss = false; + if (ucs & 0x80) { + int ret = unicode_utf8_to_ucs4(&ucs, ip, &size); + if (ret !=0) { + return ret; + } + isp = iswprint(ucs); +// iss = iswspace(ucs); + } else { + isp = isprint(ucs); +// iss = isspace(ucs); + } + if (size > outlen) { + return ENOMEM; + } + if (isp) { + memcpy(op, ip, size); + op += size; + outlen -= size; + } + ip += size; + } + return 0; +} + int unicode_utf8_tolower(utf8_t * op, size_t outlen, const utf8_t * ip) { while (*ip) { diff --git a/src/util/unicode.h b/src/util/unicode.h index df68ade02..c817a04e3 100644 --- a/src/util/unicode.h +++ b/src/util/unicode.h @@ -41,8 +41,8 @@ extern "C" { int unicode_utf8_strcasecmp(const utf8_t * a, const utf8_t * b); int unicode_latin1_to_utf8(utf8_t * out, size_t * outlen, const char *in, size_t * inlen); - int unicode_utf8_tolower(utf8_t * out, size_t outlen, - const utf8_t * in); + int unicode_utf8_tolower(utf8_t *op, size_t outlen, const utf8_t *ip); + int unicode_utf8_mkname(utf8_t *op, size_t outlen, const utf8_t *ip); #ifdef __cplusplus } diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index 410e8e68a..3cfa0615c 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -5,6 +5,17 @@ #include #include +static void test_unicode_mkname(CuTest * tc) +{ + char buffer[32]; + CuAssertIntEquals(tc, 0, unicode_utf8_mkname(buffer, sizeof(buffer), "HeLlO\nW0Rld")); + CuAssertStrEquals(tc, "HeLlOW0Rld", buffer); + memset(buffer, 0, sizeof(buffer)); + buffer[5] = 'X'; + CuAssertIntEquals(tc, ENOMEM, unicode_utf8_mkname(buffer, 5, "HeLl\n W0Rld")); + CuAssertStrEquals(tc, "HeLl X", buffer); +} + static void test_unicode_tolower(CuTest * tc) { char buffer[32]; @@ -66,6 +77,7 @@ CuSuite *get_unicode_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_unicode_tolower); + SUITE_ADD_TEST(suite, test_unicode_mkname); SUITE_ADD_TEST(suite, test_unicode_utf8_to_other); return suite; } From 7d79822aa40d626a6ccf5990de2ead7abb5fef0f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 9 Nov 2016 11:54:34 +0100 Subject: [PATCH 185/675] fix missing nul-terminator. --- src/util/unicode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/unicode.c b/src/util/unicode.c index dd8e03814..c4dfb40e2 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -60,6 +60,10 @@ int unicode_utf8_mkname(utf8_t * op, size_t outlen, const utf8_t * ip) } ip += size; } + if (outlen <= 0) { + return ENOMEM; + } + *op = 0; return 0; } From f03e8f3b62619519e397cabd411f30801febf521 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 9 Nov 2016 14:58:51 +0100 Subject: [PATCH 186/675] return an error code if the string had any characters removed. --- src/util/unicode.c | 7 +++++-- src/util/unicode.test.c | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/util/unicode.c b/src/util/unicode.c index c4dfb40e2..6ae1a0676 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -34,13 +34,14 @@ int unicode_utf8_mkname(utf8_t * op, size_t outlen, const utf8_t * ip) { + int ret = 0; while (*ip) { ucs4_t ucs = *ip; size_t size = 1; bool isp = false; // bool iss = false; if (ucs & 0x80) { - int ret = unicode_utf8_to_ucs4(&ucs, ip, &size); + ret = unicode_utf8_to_ucs4(&ucs, ip, &size); if (ret !=0) { return ret; } @@ -57,6 +58,8 @@ int unicode_utf8_mkname(utf8_t * op, size_t outlen, const utf8_t * ip) memcpy(op, ip, size); op += size; outlen -= size; + } else { + ret = 1; } ip += size; } @@ -64,7 +67,7 @@ int unicode_utf8_mkname(utf8_t * op, size_t outlen, const utf8_t * ip) return ENOMEM; } *op = 0; - return 0; + return ret; } int unicode_utf8_tolower(utf8_t * op, size_t outlen, const utf8_t * ip) diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index 3cfa0615c..e70e03752 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -8,7 +8,10 @@ static void test_unicode_mkname(CuTest * tc) { char buffer[32]; - CuAssertIntEquals(tc, 0, unicode_utf8_mkname(buffer, sizeof(buffer), "HeLlO\nW0Rld")); + CuAssertIntEquals(tc, 0, unicode_utf8_mkname(buffer, sizeof(buffer), "HeLlO W0Rld")); + CuAssertStrEquals(tc, "HeLlO W0Rld", buffer); + memset(buffer, 0, sizeof(buffer)); + CuAssertIntEquals(tc, 1, unicode_utf8_mkname(buffer, sizeof(buffer), "HeLlO\nW0Rld")); CuAssertStrEquals(tc, "HeLlOW0Rld", buffer); memset(buffer, 0, sizeof(buffer)); buffer[5] = 'X'; From 7b412399b7cd6360bfa97a2d7add216359d20975 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 9 Nov 2016 22:03:46 +0100 Subject: [PATCH 187/675] delete leading spaces from names. --- src/util/unicode.c | 31 ++++++++++++++++++------------- src/util/unicode.test.c | 3 ++- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/util/unicode.c b/src/util/unicode.c index 6ae1a0676..98d9f2d07 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -35,22 +35,27 @@ int unicode_utf8_mkname(utf8_t * op, size_t outlen, const utf8_t * ip) { int ret = 0; + bool iss = true; while (*ip) { - ucs4_t ucs = *ip; size_t size = 1; bool isp = false; -// bool iss = false; - if (ucs & 0x80) { - ret = unicode_utf8_to_ucs4(&ucs, ip, &size); - if (ret !=0) { - return ret; - } - isp = iswprint(ucs); -// iss = iswspace(ucs); - } else { - isp = isprint(ucs); -// iss = isspace(ucs); - } + do { + ucs4_t ucs = *ip; + if (ucs & 0x80) { + ret = unicode_utf8_to_ucs4(&ucs, ip, &size); + if (ret !=0) { + return ret; + } + isp = iswprint(ucs); + iss &= !!iswspace(ucs); + } else { + isp = isprint(ucs); + iss &= !!isspace(ucs); + } + if (iss) { + ip += size; + } + } while (iss); if (size > outlen) { return ENOMEM; } diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index e70e03752..6d4f0fd67 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -8,9 +8,10 @@ static void test_unicode_mkname(CuTest * tc) { char buffer[32]; + CuAssertIntEquals(tc, 0, unicode_utf8_mkname(buffer, sizeof(buffer), " HeLlO W0Rld")); + CuAssertStrEquals(tc, "HeLlO W0Rld", buffer); CuAssertIntEquals(tc, 0, unicode_utf8_mkname(buffer, sizeof(buffer), "HeLlO W0Rld")); CuAssertStrEquals(tc, "HeLlO W0Rld", buffer); - memset(buffer, 0, sizeof(buffer)); CuAssertIntEquals(tc, 1, unicode_utf8_mkname(buffer, sizeof(buffer), "HeLlO\nW0Rld")); CuAssertStrEquals(tc, "HeLlOW0Rld", buffer); memset(buffer, 0, sizeof(buffer)); From 97e91fd8eb2c0edd208fceb8673bcc6c75e0f7e2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Nov 2016 00:30:49 +0100 Subject: [PATCH 188/675] fix bad names. trim leading whitespace and non-printable characters from existing unit, region and faction names/descriptions. --- src/kernel/save.c | 20 ++++++++++++- src/util/unicode.c | 62 ++++++++++++++++++++++++++++++----------- src/util/unicode.h | 1 + src/util/unicode.test.c | 22 +++++++++++++++ 4 files changed, 88 insertions(+), 17 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 93c4f7e4b..eae3ee6c4 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -69,6 +69,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include #include @@ -747,12 +748,18 @@ unit *read_unit(struct gamedata *data) } READ_STR(data->store, obuf, sizeof(obuf)); + if (unicode_utf8_trim(obuf)!=0) { + log_error("trim unit %s name to '%s'", itoa36(u->no), obuf); + }; u->_name = obuf[0] ? _strdup(obuf) : 0; if (lomem) { READ_STR(data->store, NULL, 0); } else { READ_STR(data->store, obuf, sizeof(obuf)); + if (unicode_utf8_trim(obuf)!=0) { + log_error("trim unit %s info to '%s'", itoa36(u->no), obuf); + }; u->display = obuf[0] ? _strdup(obuf) : 0; } READ_INT(data->store, &number); @@ -986,6 +993,9 @@ static region *readregion(struct gamedata *data, int x, int y) else { char info[DISPLAYSIZE]; READ_STR(data->store, info, sizeof(info)); + if (unicode_utf8_trim(info)!=0) { + log_error("trim region %d info to '%s'", uid, info); + }; region_setinfo(r, info); } @@ -1003,6 +1013,9 @@ static region *readregion(struct gamedata *data, int x, int y) if (fval(r->terrain, LAND_REGION)) { r->land = calloc(1, sizeof(land_region)); READ_STR(data->store, name, sizeof(name)); + if (unicode_utf8_trim(name)!=0) { + log_error("trim region %d name to '%s'", uid, name); + }; r->land->name = _strdup(name); } if (r->land) { @@ -1386,8 +1399,14 @@ faction *readfaction(struct gamedata * data) } READ_STR(data->store, name, sizeof(name)); + if (unicode_utf8_trim(name)!=0) { + log_error("trim faction %s name to '%s'", itoa36(f->no), name); + }; f->name = _strdup(name); READ_STR(data->store, name, sizeof(name)); + if (unicode_utf8_trim(name)!=0) { + log_error("trim faction %s banner to '%s'", itoa36(f->no), name); + }; f->banner = _strdup(name); log_debug(" - Lese Partei %s (%s)", f->name, factionid(f)); @@ -1686,7 +1705,6 @@ int read_game(gamedata *data) { bp = &r->buildings; while (--p >= 0) { - b = (building *)calloc(1, sizeof(building)); READ_INT(store, &b->no); *bp = b; diff --git a/src/util/unicode.c b/src/util/unicode.c index 98d9f2d07..15b914fac 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -32,6 +32,36 @@ #define B00000011 0x03 #define B00000001 0x01 +int unicode_utf8_trim(utf8_t *buf) +{ + int result = 0; + utf8_t *op = buf, *ip = buf; + while (*ip) { + ucs4_t ucs = *ip; + size_t size = 1; + if (ucs & 0x80) { + int ret = unicode_utf8_to_ucs4(&ucs, ip, &size); + if (ret != 0) { + return ret; + } + } + if (op == buf && iswspace(ucs)) { + ++result; + } + else if (iswprint(ucs)) { + if (op != ip) { + memcpy(op, ip, size); + } + op += size; + } else { + ++result; + } + ip += size; + } + *op = '\0'; + return result; +} + int unicode_utf8_mkname(utf8_t * op, size_t outlen, const utf8_t * ip) { int ret = 0; @@ -40,22 +70,22 @@ int unicode_utf8_mkname(utf8_t * op, size_t outlen, const utf8_t * ip) size_t size = 1; bool isp = false; do { - ucs4_t ucs = *ip; - if (ucs & 0x80) { - ret = unicode_utf8_to_ucs4(&ucs, ip, &size); - if (ret !=0) { - return ret; - } - isp = iswprint(ucs); - iss &= !!iswspace(ucs); - } else { - isp = isprint(ucs); - iss &= !!isspace(ucs); - } - if (iss) { - ip += size; - } - } while (iss); + ucs4_t ucs = *ip; + if (ucs & 0x80) { + ret = unicode_utf8_to_ucs4(&ucs, ip, &size); + if (ret !=0) { + return ret; + } + isp = iswprint(ucs); + iss &= !!iswspace(ucs); + } else { + isp = isprint(ucs); + iss &= !!isspace(ucs); + } + if (iss) { + ip += size; + } + } while (iss); if (size > outlen) { return ENOMEM; } diff --git a/src/util/unicode.h b/src/util/unicode.h index c817a04e3..3231f1e94 100644 --- a/src/util/unicode.h +++ b/src/util/unicode.h @@ -43,6 +43,7 @@ extern "C" { const char *in, size_t * inlen); int unicode_utf8_tolower(utf8_t *op, size_t outlen, const utf8_t *ip); int unicode_utf8_mkname(utf8_t *op, size_t outlen, const utf8_t *ip); + int unicode_utf8_trim(utf8_t *ip); #ifdef __cplusplus } diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index 6d4f0fd67..db3fb0ccf 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -5,6 +5,27 @@ #include #include +static void test_unicode_trim(CuTest * tc) +{ + char buffer[32]; + + strcpy(buffer, "Hello Word"); + CuAssertIntEquals(tc, 0, unicode_utf8_trim(buffer)); + CuAssertStrEquals(tc, "Hello Word", buffer); + + strcpy(buffer, "Hello Word\n"); + CuAssertIntEquals(tc, 1, unicode_utf8_trim(buffer)); + CuAssertStrEquals(tc, "Hello Word", buffer); + + strcpy(buffer, " Hello Word\t\n"); + CuAssertIntEquals(tc, 4, unicode_utf8_trim(buffer)); + CuAssertStrEquals(tc, "Hello Word", buffer); + + strcpy(buffer, " \t Hello Word"); + CuAssertIntEquals(tc, 3, unicode_utf8_trim(buffer)); + CuAssertStrEquals(tc, "Hello Word", buffer); +} + static void test_unicode_mkname(CuTest * tc) { char buffer[32]; @@ -82,6 +103,7 @@ CuSuite *get_unicode_suite(void) CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_unicode_tolower); SUITE_ADD_TEST(suite, test_unicode_mkname); + SUITE_ADD_TEST(suite, test_unicode_trim); SUITE_ADD_TEST(suite, test_unicode_utf8_to_other); return suite; } From e0add2275ffea20eec0c7af3369eb51ccd2bf498 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Nov 2016 01:34:59 +0100 Subject: [PATCH 189/675] also remove trailing spaces. --- src/util/unicode.c | 25 +++++++++++++++---------- src/util/unicode.test.c | 4 ++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/util/unicode.c b/src/util/unicode.c index 15b914fac..0e6aedb9f 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -34,8 +34,8 @@ int unicode_utf8_trim(utf8_t *buf) { - int result = 0; - utf8_t *op = buf, *ip = buf; + int result = 0, ts = 0; + utf8_t *op = buf, *ip = buf, *lc = buf; while (*ip) { ucs4_t ucs = *ip; size_t size = 1; @@ -46,20 +46,25 @@ int unicode_utf8_trim(utf8_t *buf) } } if (op == buf && iswspace(ucs)) { - ++result; - } + ++result; + } else if (iswprint(ucs)) { - if (op != ip) { - memcpy(op, ip, size); + if (op != ip) { + memcpy(op, ip, size); } op += size; + if (iswspace(ucs)) ++ts; + else { + lc = op; + ts = 0; + } } else { - ++result; - } + ++result; + } ip += size; } - *op = '\0'; - return result; + *lc = '\0'; + return result + ts; } int unicode_utf8_mkname(utf8_t * op, size_t outlen, const utf8_t * ip) diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index db3fb0ccf..167538a3f 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -13,6 +13,10 @@ static void test_unicode_trim(CuTest * tc) CuAssertIntEquals(tc, 0, unicode_utf8_trim(buffer)); CuAssertStrEquals(tc, "Hello Word", buffer); + strcpy(buffer, " Hello Word "); + CuAssertIntEquals(tc, 4, unicode_utf8_trim(buffer)); + CuAssertStrEquals(tc, "Hello Word", buffer); + strcpy(buffer, "Hello Word\n"); CuAssertIntEquals(tc, 1, unicode_utf8_trim(buffer)); CuAssertStrEquals(tc, "Hello Word", buffer); From ff09defa695b9d1f0f7ecb3471fc5714f8e7d7ec Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Nov 2016 01:59:43 +0100 Subject: [PATCH 190/675] prevent badly naming units/factions/regions. --- src/laws.c | 14 +++++++------- src/laws.test.c | 26 ++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/laws.c b/src/laws.c index 9e53a465f..de87afeb1 100644 --- a/src/laws.c +++ b/src/laws.c @@ -79,17 +79,17 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include #include -#include #include #include #include -#include -#include +#include #include +#include #include /* libc includes */ #include @@ -1627,6 +1627,7 @@ bool renamed_building(const building * b) static int rename_cmd(unit * u, order * ord, char **s, const char *s2) { + char name[NAMESIZE]; assert(s2); if (!s2[0]) { cmistake(u, ord, 84, MSG_EVENT); @@ -1635,12 +1636,11 @@ static int rename_cmd(unit * u, order * ord, char **s, const char *s2) /* TODO: Validate to make sure people don't have illegal characters in * names, phishing-style? () come to mind. */ + strlcpy(name, s2, sizeof(name)); + unicode_utf8_trim(name); free(*s); - *s = _strdup(s2); - if (strlen(s2) >= NAMESIZE) { - (*s)[NAMESIZE] = 0; - } + *s = _strdup(name); return 0; } diff --git a/src/laws.test.c b/src/laws.test.c index 65f48012d..0f3566714 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1024,7 +1024,7 @@ static void test_ally_cmd_errors(CuTest *tc) { int fid; order *ord; - test_cleanup(); + test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); fid = u->faction->no + 1; CuAssertPtrEquals(tc, 0, findfaction(fid)); @@ -1037,12 +1037,33 @@ static void test_ally_cmd_errors(CuTest *tc) { test_cleanup(); } +static void test_name_cmd(CuTest *tc) { + unit *u; + faction *f; + order *ord; + + test_setup(); + u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0)); + + ord = create_order(K_NAME, f->locale, "%s ' Ho\tdor '", LOC(f->locale, parameters[P_UNIT])); + name_cmd(u, ord); + CuAssertStrEquals(tc, "Hodor", u->_name); + free_order(ord); + + ord = create_order(K_NAME, f->locale, "%s ' Ho\tdor '", LOC(f->locale, parameters[P_FACTION])); + name_cmd(u, ord); + CuAssertStrEquals(tc, "Hodor", f->name); + free_order(ord); + + test_cleanup(); +} + static void test_ally_cmd(CuTest *tc) { unit *u; faction * f; order *ord; - test_cleanup(); + test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); f = test_create_faction(0); @@ -1444,6 +1465,7 @@ CuSuite *get_laws_suite(void) CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_nmr_warnings); SUITE_ADD_TEST(suite, test_ally_cmd); + SUITE_ADD_TEST(suite, test_name_cmd); SUITE_ADD_TEST(suite, test_ally_cmd_errors); SUITE_ADD_TEST(suite, test_long_order_normal); SUITE_ADD_TEST(suite, test_long_order_none); From bc44caa17f58d17040d0550a4ff544e0f30d973d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Nov 2016 02:07:11 +0100 Subject: [PATCH 191/675] backfill tests for renaming regions. --- src/laws.test.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/laws.test.c b/src/laws.test.c index 0f3566714..922cfb676 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1055,6 +1055,14 @@ static void test_name_cmd(CuTest *tc) { CuAssertStrEquals(tc, "Hodor", f->name); free_order(ord); + ord = create_order(K_NAME, f->locale, "%s ' Ho\tdor '", LOC(f->locale, parameters[P_REGION])); + name_cmd(u, ord); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error145")); + u->building = test_create_building(u->region, 0); + name_cmd(u, ord); + CuAssertStrEquals(tc, "Hodor", u->region->land->name); + free_order(ord); + test_cleanup(); } From dea10209835354077876bb76e8e987c6ce7481ff Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Nov 2016 11:09:57 +0100 Subject: [PATCH 192/675] log a warning, not an error, when fixing bad save data. --- src/kernel/save.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index eae3ee6c4..7c5091d41 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -749,7 +749,7 @@ unit *read_unit(struct gamedata *data) READ_STR(data->store, obuf, sizeof(obuf)); if (unicode_utf8_trim(obuf)!=0) { - log_error("trim unit %s name to '%s'", itoa36(u->no), obuf); + log_warning("trim unit %s name to '%s'", itoa36(u->no), obuf); }; u->_name = obuf[0] ? _strdup(obuf) : 0; if (lomem) { @@ -758,7 +758,7 @@ unit *read_unit(struct gamedata *data) else { READ_STR(data->store, obuf, sizeof(obuf)); if (unicode_utf8_trim(obuf)!=0) { - log_error("trim unit %s info to '%s'", itoa36(u->no), obuf); + log_warning("trim unit %s info to '%s'", itoa36(u->no), obuf); }; u->display = obuf[0] ? _strdup(obuf) : 0; } @@ -994,7 +994,7 @@ static region *readregion(struct gamedata *data, int x, int y) char info[DISPLAYSIZE]; READ_STR(data->store, info, sizeof(info)); if (unicode_utf8_trim(info)!=0) { - log_error("trim region %d info to '%s'", uid, info); + log_warning("trim region %d info to '%s'", uid, info); }; region_setinfo(r, info); } @@ -1014,7 +1014,7 @@ static region *readregion(struct gamedata *data, int x, int y) r->land = calloc(1, sizeof(land_region)); READ_STR(data->store, name, sizeof(name)); if (unicode_utf8_trim(name)!=0) { - log_error("trim region %d name to '%s'", uid, name); + log_warning("trim region %d name to '%s'", uid, name); }; r->land->name = _strdup(name); } @@ -1400,12 +1400,12 @@ faction *readfaction(struct gamedata * data) READ_STR(data->store, name, sizeof(name)); if (unicode_utf8_trim(name)!=0) { - log_error("trim faction %s name to '%s'", itoa36(f->no), name); + log_warning("trim faction %s name to '%s'", itoa36(f->no), name); }; f->name = _strdup(name); READ_STR(data->store, name, sizeof(name)); if (unicode_utf8_trim(name)!=0) { - log_error("trim faction %s banner to '%s'", itoa36(f->no), name); + log_warning("trim faction %s banner to '%s'", itoa36(f->no), name); }; f->banner = _strdup(name); From 64f80274a09dadafa27c19c00a4a4fb6c15c66d7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Nov 2016 14:00:04 +0100 Subject: [PATCH 193/675] test that ship and building cannot be named poorly. --- src/laws.test.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/laws.test.c b/src/laws.test.c index 922cfb676..69e9f5e04 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1055,11 +1055,20 @@ static void test_name_cmd(CuTest *tc) { CuAssertStrEquals(tc, "Hodor", f->name); free_order(ord); - ord = create_order(K_NAME, f->locale, "%s ' Ho\tdor '", LOC(f->locale, parameters[P_REGION])); + ord = create_order(K_NAME, f->locale, "%s ' Ho\tdor '", LOC(f->locale, parameters[P_SHIP])); + u->ship = test_create_ship(u->region, 0); name_cmd(u, ord); - CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error145")); + CuAssertStrEquals(tc, "Hodor", u->ship->name); + free_order(ord); + + ord = create_order(K_NAME, f->locale, "%s ' Ho\tdor '", LOC(f->locale, parameters[P_BUILDING])); u->building = test_create_building(u->region, 0); name_cmd(u, ord); + CuAssertStrEquals(tc, "Hodor", u->building->name); + free_order(ord); + + ord = create_order(K_NAME, f->locale, "%s ' Ho\tdor '", LOC(f->locale, parameters[P_REGION])); + name_cmd(u, ord); CuAssertStrEquals(tc, "Hodor", u->region->land->name); free_order(ord); From a47da05f515f425f301eba5eed7e8e756cda2494 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Nov 2016 15:41:34 +0100 Subject: [PATCH 194/675] test unit names get fixed during read. --- src/kernel/save.test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index 00b5ff96c..2b1f0464d 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -55,7 +55,8 @@ static void test_readwrite_unit(CuTest * tc) f = test_create_faction(0); fno = f->no; u = test_create_unit(f, r); - + unit_setname(u, " Hodor "); + CuAssertStrEquals(tc, " Hodor ", u->_name); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); write_unit(&data, u); @@ -69,6 +70,7 @@ static void test_readwrite_unit(CuTest * tc) u = read_unit(&data); CuAssertPtrNotNull(tc, u); CuAssertPtrEquals(tc, f, u->faction); + CuAssertStrEquals(tc, "Hodor", u->_name); CuAssertPtrEquals(tc, 0, u->region); mstream_done(&data.strm); From 599c4228524e1c22f6fa04fc37bda86e6dd71212 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Nov 2016 21:41:25 +0100 Subject: [PATCH 195/675] refactor: extract read_/write_building. add a failing test for conversion of bad names. --- src/kernel/save.c | 84 ++++++++++++++++++++++++------------------ src/kernel/save.h | 3 ++ src/kernel/save.test.c | 36 ++++++++++++++++++ src/tests.c | 4 +- 4 files changed, 91 insertions(+), 36 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 7c5091d41..cdedbb525 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 1998-2015, Enno Rehling Katja Zedel @@ -1625,17 +1625,60 @@ int readgame(const char *filename, bool backup) return n; } +void write_building(gamedata *data, const building *b) +{ + storage *store = data->store; + + write_building_reference(b, store); + WRITE_STR(store, b->name); + WRITE_STR(store, b->display ? b->display : ""); + WRITE_INT(store, b->size); + WRITE_TOK(store, b->type->_name); + write_attribs(store, b->attribs, b); +} + +struct building *read_building(gamedata *data) { + char name[DISPLAYSIZE]; + building *b; + storage * store = data->store; + + b = (building *)calloc(1, sizeof(building)); + READ_INT(store, &b->no); + bhash(b); + READ_STR(store, name, sizeof(name)); + b->name = _strdup(name); + if (lomem) { + READ_STR(store, NULL, 0); + } + else { + READ_STR(store, name, sizeof(name)); + b->display = _strdup(name); + } + READ_INT(store, &b->size); + READ_STR(store, name, sizeof(name)); + b->type = bt_find(name); + read_attribs(data, &b->attribs, b); + + // repairs, bug 2221: + if (b->type->maxsize>0 && b->size>b->type->maxsize) { + log_error("building too big: %s (%s size %d of %d), fixing.", buildingname(b), b->type->_name, b->size, b->type->maxsize); + b->size = b->type->maxsize; + } + return b; +} + int read_game(gamedata *data) { char name[DISPLAYSIZE]; int n, p, nread; faction *f, **fp; region *r; - building *b, **bp; + building **bp; ship **shp; unit *u; int rmax = maxregions; - const struct building_type *bt_lighthouse = bt_find("lighthouse"); storage * store = data->store; + const struct building_type *bt_lighthouse = bt_find("lighthouse"); + if (data->version >= SAVEGAMEID_VERSION) { int gameid; @@ -1705,34 +1748,12 @@ int read_game(gamedata *data) { bp = &r->buildings; while (--p >= 0) { - b = (building *)calloc(1, sizeof(building)); - READ_INT(store, &b->no); - *bp = b; - bp = &b->next; - bhash(b); - READ_STR(store, name, sizeof(name)); - b->name = _strdup(name); - if (lomem) { - READ_STR(store, NULL, 0); - } - else { - READ_STR(store, name, sizeof(name)); - b->display = _strdup(name); - } - READ_INT(store, &b->size); - READ_STR(store, name, sizeof(name)); - b->type = bt_find(name); + building *b = *bp = read_building(data); b->region = r; - read_attribs(data, &b->attribs, b); if (b->type == bt_lighthouse) { r->flags |= RF_LIGHTHOUSE; } - - // repairs, bug 2221: - if (b->type->maxsize>0 && b->size>b->type->maxsize) { - log_error("building too big: %s (%s size %d of %d), fixing.", buildingname(b), b->type->_name, b->size, b->type->maxsize); - b->size = b->type->maxsize; - } + bp = &b->next; } /* Schiffe */ @@ -1979,14 +2000,7 @@ int write_game(gamedata *data) { WRITE_INT(store, listlen(r->buildings)); WRITE_SECTION(store); for (b = r->buildings; b; b = b->next) { - write_building_reference(b, store); - WRITE_STR(store, b->name); - WRITE_STR(store, b->display ? b->display : ""); - WRITE_INT(store, b->size); - WRITE_TOK(store, b->type->_name); - WRITE_SECTION(store); - write_attribs(store, b->attribs, b); - WRITE_SECTION(store); + write_building(data, b); } WRITE_INT(store, listlen(r->ships)); diff --git a/src/kernel/save.h b/src/kernel/save.h index 3cd443926..6854bad3a 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -57,6 +57,9 @@ extern "C" { void write_unit(struct gamedata *data, const struct unit *u); struct unit *read_unit(struct gamedata *data); + + void write_building(struct gamedata *data, const struct building *b); + struct building *read_building(struct gamedata *data); int a_readint(struct attrib *a, void *owner, struct gamedata *); void a_writeint(const struct attrib *a, const void *owner, diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index 2b1f0464d..9bb544462 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -6,6 +6,7 @@ #include "save.h" #include "version.h" +#include "building.h" #include "unit.h" #include "group.h" #include "ally.h" @@ -27,6 +28,7 @@ #include #include +#include #include static void test_readwrite_data(CuTest * tc) @@ -79,6 +81,39 @@ static void test_readwrite_unit(CuTest * tc) test_cleanup(); } +static void test_readwrite_building(CuTest * tc) +{ + gamedata data; + storage store; + struct building *b; + struct region *r; + + test_setup(); + r = test_create_region(0, 0, 0); + b = test_create_building(r, 0); + free(b->name); + b->name = strdup(" Hodor "); + CuAssertStrEquals(tc, " Hodor ", b->name); + mstream_init(&data.strm); + gamedata_init(&data, &store, RELEASE_VERSION); + write_building(&data, b); + + data.strm.api->rewind(data.strm.handle); + free_gamedata(); + r = test_create_region(0, 0, 0); + gamedata_init(&data, &store, RELEASE_VERSION); + b = read_building(&data); + CuAssertPtrNotNull(tc, b); + CuAssertStrEquals(tc, "Hodor", b->name); + CuAssertPtrEquals(tc, 0, b->region); + b->region = r; + r->buildings = b; + + mstream_done(&data.strm); + gamedata_done(&data); + test_cleanup(); +} + static void test_readwrite_attrib(CuTest *tc) { gamedata data; storage store; @@ -328,6 +363,7 @@ CuSuite *get_save_suite(void) SUITE_ADD_TEST(suite, test_readwrite_attrib); SUITE_ADD_TEST(suite, test_readwrite_data); SUITE_ADD_TEST(suite, test_readwrite_unit); + SUITE_ADD_TEST(suite, test_readwrite_building); SUITE_ADD_TEST(suite, test_readwrite_dead_faction_createunit); SUITE_ADD_TEST(suite, test_readwrite_dead_faction_changefaction); SUITE_ADD_TEST(suite, test_readwrite_dead_faction_regionowner); diff --git a/src/tests.c b/src/tests.c index 177ad50fc..05855563a 100644 --- a/src/tests.c +++ b/src/tests.c @@ -217,7 +217,9 @@ test_create_terrain(const char * name, unsigned int flags) building * test_create_building(region * r, const building_type * btype) { - building * b = new_building(btype ? btype : test_create_buildingtype("castle"), r, default_locale); + building * b; + assert(r); + b = new_building(btype ? btype : test_create_buildingtype("castle"), r, default_locale); b->size = b->type->maxsize > 0 ? b->type->maxsize : 1; return b; } From 110e87916d2ee85776e96d32cacfed48d013ffd3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Nov 2016 21:46:56 +0100 Subject: [PATCH 196/675] fix bad ship names in save file. --- src/kernel/save.c | 10 ++++++++-- src/kernel/save.test.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index cdedbb525..2abd0b93f 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -750,7 +750,7 @@ unit *read_unit(struct gamedata *data) READ_STR(data->store, obuf, sizeof(obuf)); if (unicode_utf8_trim(obuf)!=0) { log_warning("trim unit %s name to '%s'", itoa36(u->no), obuf); - }; + } u->_name = obuf[0] ? _strdup(obuf) : 0; if (lomem) { READ_STR(data->store, NULL, 0); @@ -759,7 +759,7 @@ unit *read_unit(struct gamedata *data) READ_STR(data->store, obuf, sizeof(obuf)); if (unicode_utf8_trim(obuf)!=0) { log_warning("trim unit %s info to '%s'", itoa36(u->no), obuf); - }; + } u->display = obuf[0] ? _strdup(obuf) : 0; } READ_INT(data->store, &number); @@ -1646,12 +1646,18 @@ struct building *read_building(gamedata *data) { READ_INT(store, &b->no); bhash(b); READ_STR(store, name, sizeof(name)); + if (unicode_utf8_trim(name)!=0) { + log_warning("trim building %s name to '%s'", itoa36(b->no), name); + } b->name = _strdup(name); if (lomem) { READ_STR(store, NULL, 0); } else { READ_STR(store, name, sizeof(name)); + if (unicode_utf8_trim(name)!=0) { + log_warning("trim building %s info to '%s'", itoa36(b->no), name); + } b->display = _strdup(name); } READ_INT(store, &b->size); diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index 9bb544462..af7c4c1f4 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -92,7 +92,7 @@ static void test_readwrite_building(CuTest * tc) r = test_create_region(0, 0, 0); b = test_create_building(r, 0); free(b->name); - b->name = strdup(" Hodor "); + b->name = _strdup(" Hodor "); CuAssertStrEquals(tc, " Hodor ", b->name); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); From 5032d44af46d16a9f11403392dbcdbcb42559a4e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Nov 2016 22:25:56 +0100 Subject: [PATCH 197/675] refactor: extract read_/write_ship functions. add test: bad names are cleaned up (failing). --- src/kernel/save.c | 116 +++++++++++++++++++++++------------------ src/kernel/save.h | 5 ++ src/kernel/save.test.c | 39 +++++++++++++- 3 files changed, 108 insertions(+), 52 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 2abd0b93f..528a71808 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1673,9 +1673,68 @@ struct building *read_building(gamedata *data) { return b; } -int read_game(gamedata *data) { +void write_ship(gamedata *data, const ship *sh) +{ + storage *store = data->store; + write_ship_reference(sh, store); + WRITE_STR(store, (const char *)sh->name); + WRITE_STR(store, sh->display ? (const char *)sh->display : ""); + WRITE_TOK(store, sh->type->_name); + WRITE_INT(store, sh->size); + WRITE_INT(store, sh->damage); + WRITE_INT(store, sh->flags & SFL_SAVEMASK); + assert((sh->type->flags & SFL_NOCOAST) == 0 || sh->coast == NODIRECTION); + WRITE_INT(store, sh->coast); + write_attribs(store, sh->attribs, sh); +} + +ship *read_ship(struct gamedata *data) +{ char name[DISPLAYSIZE]; - int n, p, nread; + ship *sh; + int n; + storage *store = data->store; + + sh = (ship *)calloc(1, sizeof(ship)); + READ_INT(store, &sh->no); + shash(sh); + READ_STR(store, name, sizeof(name)); + sh->name = _strdup(name); + if (lomem) { + READ_STR(store, NULL, 0); + } + else { + READ_STR(store, name, sizeof(name)); + sh->display = _strdup(name); + } + READ_STR(store, name, sizeof(name)); + sh->type = st_find(name); + if (sh->type == NULL) { + /* old datafiles */ + sh->type = st_find((const char *)LOC(default_locale, name)); + } + assert(sh->type || !"ship_type not registered!"); + + READ_INT(store, &sh->size); + READ_INT(store, &sh->damage); + if (data->version >= FOSS_VERSION) { + READ_INT(store, &sh->flags); + } + + /* Attribute rekursiv einlesen */ + + READ_INT(store, &n); + sh->coast = (direction_t)n; + if (sh->type->flags & SFL_NOCOAST) { + sh->coast = NODIRECTION; + } + read_attribs(data, &sh->attribs, sh); + return sh; +} + + +int read_game(gamedata *data) { + int p, nread; faction *f, **fp; region *r; building **bp; @@ -1755,10 +1814,10 @@ int read_game(gamedata *data) { while (--p >= 0) { building *b = *bp = read_building(data); - b->region = r; if (b->type == bt_lighthouse) { r->flags |= RF_LIGHTHOUSE; } + b->region = r; bp = &b->next; } /* Schiffe */ @@ -1767,43 +1826,9 @@ int read_game(gamedata *data) { shp = &r->ships; while (--p >= 0) { - ship *sh = (ship *)calloc(1, sizeof(ship)); + ship *sh = *shp = read_ship(data); sh->region = r; - READ_INT(store, &sh->no); - *shp = sh; shp = &sh->next; - shash(sh); - READ_STR(store, name, sizeof(name)); - sh->name = _strdup(name); - if (lomem) { - READ_STR(store, NULL, 0); - } - else { - READ_STR(store, name, sizeof(name)); - sh->display = _strdup(name); - } - READ_STR(store, name, sizeof(name)); - sh->type = st_find(name); - if (sh->type == NULL) { - /* old datafiles */ - sh->type = st_find((const char *)LOC(default_locale, name)); - } - assert(sh->type || !"ship_type not registered!"); - - READ_INT(store, &sh->size); - READ_INT(store, &sh->damage); - if (data->version >= FOSS_VERSION) { - READ_INT(store, &sh->flags); - } - - /* Attribute rekursiv einlesen */ - - READ_INT(store, &n); - sh->coast = (direction_t)n; - if (sh->type->flags & SFL_NOCOAST) { - sh->coast = NODIRECTION; - } - read_attribs(data, &sh->attribs, sh); } *shp = 0; @@ -2006,6 +2031,7 @@ int write_game(gamedata *data) { WRITE_INT(store, listlen(r->buildings)); WRITE_SECTION(store); for (b = r->buildings; b; b = b->next) { + assert(b->region == r); write_building(data, b); } @@ -2013,23 +2039,13 @@ int write_game(gamedata *data) { WRITE_SECTION(store); for (sh = r->ships; sh; sh = sh->next) { assert(sh->region == r); - write_ship_reference(sh, store); - WRITE_STR(store, (const char *)sh->name); - WRITE_STR(store, sh->display ? (const char *)sh->display : ""); - WRITE_TOK(store, sh->type->_name); - WRITE_INT(store, sh->size); - WRITE_INT(store, sh->damage); - WRITE_INT(store, sh->flags & SFL_SAVEMASK); - assert((sh->type->flags & SFL_NOCOAST) == 0 || sh->coast == NODIRECTION); - WRITE_INT(store, sh->coast); - WRITE_SECTION(store); - write_attribs(store, sh->attribs, sh); - WRITE_SECTION(store); + write_ship(data, sh); } WRITE_INT(store, listlen(r->units)); WRITE_SECTION(store); for (u = r->units; u; u = u->next) { + assert(u->region == r); write_unit(data, u); } } diff --git a/src/kernel/save.h b/src/kernel/save.h index 6854bad3a..d74017f62 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -30,6 +30,8 @@ extern "C" { struct spell; struct spellbook; struct unit; + struct building; + struct ship; struct gamedata; #define MAX_INPUT_SIZE DISPLAYSIZE*2 @@ -61,6 +63,9 @@ extern "C" { void write_building(struct gamedata *data, const struct building *b); struct building *read_building(struct gamedata *data); + void write_ship(struct gamedata *data, const struct ship *sh); + struct ship *read_ship(struct gamedata *data); + int a_readint(struct attrib *a, void *owner, struct gamedata *); void a_writeint(const struct attrib *a, const void *owner, struct storage *store); diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index af7c4c1f4..4f13851cb 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -7,6 +7,7 @@ #include "save.h" #include "version.h" #include "building.h" +#include "ship.h" #include "unit.h" #include "group.h" #include "ally.h" @@ -85,8 +86,8 @@ static void test_readwrite_building(CuTest * tc) { gamedata data; storage store; - struct building *b; - struct region *r; + building *b; + region *r; test_setup(); r = test_create_region(0, 0, 0); @@ -114,6 +115,39 @@ static void test_readwrite_building(CuTest * tc) test_cleanup(); } +static void test_readwrite_ship(CuTest * tc) +{ + gamedata data; + storage store; + ship *sh; + region *r; + + test_setup(); + r = test_create_region(0, 0, 0); + sh = test_create_ship(r, 0); + free(sh->name); + sh->name = _strdup(" Hodor "); + CuAssertStrEquals(tc, " Hodor ", sh->name); + mstream_init(&data.strm); + gamedata_init(&data, &store, RELEASE_VERSION); + write_ship(&data, sh); + + data.strm.api->rewind(data.strm.handle); + free_gamedata(); + r = test_create_region(0, 0, 0); + gamedata_init(&data, &store, RELEASE_VERSION); + sh = read_ship(&data); + CuAssertPtrNotNull(tc, sh); + CuAssertStrEquals(tc, "Hodor", sh->name); + CuAssertPtrEquals(tc, 0, sh->region); + sh->region = r; + r->ships = sh; + + mstream_done(&data.strm); + gamedata_done(&data); + test_cleanup(); +} + static void test_readwrite_attrib(CuTest *tc) { gamedata data; storage store; @@ -364,6 +398,7 @@ CuSuite *get_save_suite(void) SUITE_ADD_TEST(suite, test_readwrite_data); SUITE_ADD_TEST(suite, test_readwrite_unit); SUITE_ADD_TEST(suite, test_readwrite_building); + SUITE_ADD_TEST(suite, test_readwrite_ship); SUITE_ADD_TEST(suite, test_readwrite_dead_faction_createunit); SUITE_ADD_TEST(suite, test_readwrite_dead_faction_changefaction); SUITE_ADD_TEST(suite, test_readwrite_dead_faction_regionowner); From 710811131f57ec36ea911ea83664c975ad881b43 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Nov 2016 22:28:22 +0100 Subject: [PATCH 198/675] fix bad ship and building names and descriptions in save. --- src/kernel/save.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/kernel/save.c b/src/kernel/save.c index 528a71808..d063fc8f7 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1699,12 +1699,18 @@ ship *read_ship(struct gamedata *data) READ_INT(store, &sh->no); shash(sh); READ_STR(store, name, sizeof(name)); + if (unicode_utf8_trim(name)!=0) { + log_warning("trim ship %s name to '%s'", itoa36(sh->no), name); + } sh->name = _strdup(name); if (lomem) { READ_STR(store, NULL, 0); } else { READ_STR(store, name, sizeof(name)); + if (unicode_utf8_trim(name)!=0) { + log_warning("trim ship %s info to '%s'", itoa36(sh->no), name); + } sh->display = _strdup(name); } READ_STR(store, name, sizeof(name)); From ec787743f00fecef6dc12b8d1531dfc00eedb555 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 12 Nov 2016 00:47:25 +0100 Subject: [PATCH 199/675] extract read_faction and test that it repairs bad names --- src/kernel/save.c | 16 +++++++++------- src/kernel/save.h | 3 +++ src/kernel/save.test.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index d063fc8f7..96263feed 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1348,7 +1348,7 @@ void _test_write_password(gamedata *data, const faction *f) { * This function requires no context, can be called in any state. The * faction may not already exist, however. */ -faction *readfaction(struct gamedata * data) +faction *read_faction(struct gamedata * data) { ally **sfp; int planes, n; @@ -1363,9 +1363,10 @@ faction *readfaction(struct gamedata * data) f->no = n; } else { - f->allies = NULL; /* mem leak */ - while (f->attribs) + f->allies = NULL; /* FIXME: mem leak */ + while (f->attribs) { a_remove(&f->attribs, f->attribs); + } } READ_INT(data->store, &f->subscription); @@ -1499,7 +1500,7 @@ faction *readfaction(struct gamedata * data) return f; } -void writefaction(struct gamedata *data, const faction * f) +void write_faction(struct gamedata *data, const faction * f) { ally *sf; ursprung *ur; @@ -1781,11 +1782,12 @@ int read_game(gamedata *data) { READ_INT(store, &nread); log_debug(" - Einzulesende Parteien: %d\n", nread); fp = &factions; - while (*fp) + while (*fp) { fp = &(*fp)->next; + } while (--nread >= 0) { - faction *f = readfaction(data); + faction *f = read_faction(data); *fp = f; fp = &f->next; @@ -2010,7 +2012,7 @@ int write_game(gamedata *data) { if (fval(f, FFL_NPC)) { clear_npc_orders(f); } - writefaction(data, f); + write_faction(data, f); WRITE_SECTION(store); } diff --git a/src/kernel/save.h b/src/kernel/save.h index d74017f62..7c28d6c43 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -60,6 +60,9 @@ extern "C" { void write_unit(struct gamedata *data, const struct unit *u); struct unit *read_unit(struct gamedata *data); + void write_faction(struct gamedata *data, const struct faction *f); + struct faction *read_faction(struct gamedata *data); + void write_building(struct gamedata *data, const struct building *b); struct building *read_building(struct gamedata *data); diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index 4f13851cb..298b9e21f 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -82,6 +82,35 @@ static void test_readwrite_unit(CuTest * tc) test_cleanup(); } +static void test_readwrite_faction(CuTest * tc) +{ + gamedata data; + storage store; + faction *f; + + test_setup(); + f = test_create_faction(0); + free(f->name); + f->name = _strdup(" Hodor "); + CuAssertStrEquals(tc, " Hodor ", f->name); + mstream_init(&data.strm); + gamedata_init(&data, &store, RELEASE_VERSION); + write_faction(&data, f); + + data.strm.api->rewind(data.strm.handle); + free_gamedata(); + gamedata_init(&data, &store, RELEASE_VERSION); + f = read_faction(&data); + CuAssertPtrNotNull(tc, f); + CuAssertStrEquals(tc, "Hodor", f->name); + CuAssertPtrEquals(tc, 0, f->units); + factions = f; + + mstream_done(&data.strm); + gamedata_done(&data); + test_cleanup(); +} + static void test_readwrite_building(CuTest * tc) { gamedata data; @@ -397,6 +426,7 @@ CuSuite *get_save_suite(void) SUITE_ADD_TEST(suite, test_readwrite_attrib); SUITE_ADD_TEST(suite, test_readwrite_data); SUITE_ADD_TEST(suite, test_readwrite_unit); + SUITE_ADD_TEST(suite, test_readwrite_faction); SUITE_ADD_TEST(suite, test_readwrite_building); SUITE_ADD_TEST(suite, test_readwrite_ship); SUITE_ADD_TEST(suite, test_readwrite_dead_faction_createunit); From 663ad17b5adaf249b347593d3b377e63ca2bd0b4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 12 Nov 2016 01:03:07 +0100 Subject: [PATCH 200/675] extract read_region and test that it fixes bad names. --- src/kernel/save.c | 45 ++++++++++++++++++++++++++---------------- src/kernel/save.h | 3 +++ src/kernel/save.test.c | 29 +++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 17 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 96263feed..327fa4f1a 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1125,6 +1125,17 @@ static region *readregion(struct gamedata *data, int x, int y) return r; } +region *read_region(gamedata *data) +{ + storage *store = data->store; + region *r; + int x, y; + READ_INT(store, &x); + READ_INT(store, &y); + r = readregion(data, x, y); + return r; +} + void writeregion(struct gamedata *data, const region * r) { assert(r); @@ -1189,6 +1200,14 @@ void writeregion(struct gamedata *data, const region * r) WRITE_SECTION(data->store); } +void write_region(gamedata *data, const region *r) +{ + storage *store = data->store; + WRITE_INT(store, r->x); + WRITE_INT(store, r->y); + writeregion(data, r); +} + static ally **addally(const faction * f, ally ** sfp, int aid, int state) { struct faction *af = findfaction(aid); @@ -1344,10 +1363,6 @@ void _test_write_password(gamedata *data, const faction *f) { write_password(data, f); } -/** Reads a faction from a file. - * This function requires no context, can be called in any state. The - * faction may not already exist, however. - */ faction *read_faction(struct gamedata * data) { ally **sfp; @@ -1803,18 +1818,11 @@ int read_game(gamedata *data) { rmax = nread; } log_debug(" - Einzulesende Regionen: %d/%d\r", rmax, nread); + while (--nread >= 0) { unit **up; - int x, y; - READ_INT(store, &x); - READ_INT(store, &y); - if ((nread & 0x3FF) == 0) { /* das spart extrem Zeit */ - log_debug(" - Einzulesende Regionen: %d/%d * %d,%d \r", rmax, nread, x, y); - } - --rmax; - - r = readregion(data, x, y); + r = read_region(data); /* Burgen */ READ_INT(store, &p); @@ -1861,8 +1869,13 @@ int read_game(gamedata *data) { *up = u; up = &u->next; - update_interval(u->faction, u->region); + update_interval(u->faction, r); } + + if ((nread & 0x3FF) == 0) { /* das spart extrem Zeit */ + log_debug(" - Einzulesende Regionen: %d/%d * %d,%d \r", rmax, nread, r->x, r->y); + } + --rmax; } read_borders(data); @@ -2032,9 +2045,7 @@ int write_game(gamedata *data) { log_debug(" - Schreibe Regionen: %d", n); } WRITE_SECTION(store); - WRITE_INT(store, r->x); - WRITE_INT(store, r->y); - writeregion(data, r); + write_region(data, r); WRITE_INT(store, listlen(r->buildings)); WRITE_SECTION(store); diff --git a/src/kernel/save.h b/src/kernel/save.h index 7c28d6c43..ffc9c2891 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -63,6 +63,9 @@ extern "C" { void write_faction(struct gamedata *data, const struct faction *f); struct faction *read_faction(struct gamedata *data); + void write_region(struct gamedata *data, const struct region *r); + struct region *read_region(struct gamedata *data); + void write_building(struct gamedata *data, const struct building *b); struct building *read_building(struct gamedata *data); diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index 298b9e21f..b4d79f4f8 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -111,6 +111,34 @@ static void test_readwrite_faction(CuTest * tc) test_cleanup(); } +static void test_readwrite_region(CuTest * tc) +{ + gamedata data; + storage store; + region *r; + + test_setup(); + r = test_create_region(0, 0, 0); + free(r->land->name); + r->land->name = _strdup(" Hodor "); + CuAssertStrEquals(tc, " Hodor ", r->land->name); + mstream_init(&data.strm); + gamedata_init(&data, &store, RELEASE_VERSION); + write_region(&data, r); + + data.strm.api->rewind(data.strm.handle); + free_gamedata(); + gamedata_init(&data, &store, RELEASE_VERSION); + r = read_region(&data); + CuAssertPtrNotNull(tc, r); + CuAssertStrEquals(tc, "Hodor", r->land->name); + regions = r; + + mstream_done(&data.strm); + gamedata_done(&data); + test_cleanup(); +} + static void test_readwrite_building(CuTest * tc) { gamedata data; @@ -427,6 +455,7 @@ CuSuite *get_save_suite(void) SUITE_ADD_TEST(suite, test_readwrite_data); SUITE_ADD_TEST(suite, test_readwrite_unit); SUITE_ADD_TEST(suite, test_readwrite_faction); + SUITE_ADD_TEST(suite, test_readwrite_region); SUITE_ADD_TEST(suite, test_readwrite_building); SUITE_ADD_TEST(suite, test_readwrite_ship); SUITE_ADD_TEST(suite, test_readwrite_dead_faction_createunit); From f63baddd5129a37b0d65e4c0d1933b700b50095d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 15:49:26 +0100 Subject: [PATCH 201/675] use memmove, not memcpy. fix unicode_trim for windows. remove unused unicode_mkname. --- src/util/unicode.c | 59 +++++++---------------------------------- src/util/unicode.h | 3 +-- src/util/unicode.test.c | 16 ----------- 3 files changed, 10 insertions(+), 68 deletions(-) diff --git a/src/util/unicode.c b/src/util/unicode.c index 0e6aedb9f..f9a6d48ec 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -37,23 +37,25 @@ int unicode_utf8_trim(utf8_t *buf) int result = 0, ts = 0; utf8_t *op = buf, *ip = buf, *lc = buf; while (*ip) { - ucs4_t ucs = *ip; size_t size = 1; - if (ucs & 0x80) { + wint_t wc = *ip; + if (wc & 0x80) { + ucs4_t ucs; int ret = unicode_utf8_to_ucs4(&ucs, ip, &size); if (ret != 0) { return ret; } + wc = (wint_t)ucs; } - if (op == buf && iswspace(ucs)) { + if (op == buf && iswspace(wc)) { ++result; } - else if (iswprint(ucs)) { + else if (iswprint(wc)) { if (op != ip) { - memcpy(op, ip, size); + memmove(op, ip, size); } op += size; - if (iswspace(ucs)) ++ts; + if (iswspace(wc)) ++ts; else { lc = op; ts = 0; @@ -67,49 +69,6 @@ int unicode_utf8_trim(utf8_t *buf) return result + ts; } -int unicode_utf8_mkname(utf8_t * op, size_t outlen, const utf8_t * ip) -{ - int ret = 0; - bool iss = true; - while (*ip) { - size_t size = 1; - bool isp = false; - do { - ucs4_t ucs = *ip; - if (ucs & 0x80) { - ret = unicode_utf8_to_ucs4(&ucs, ip, &size); - if (ret !=0) { - return ret; - } - isp = iswprint(ucs); - iss &= !!iswspace(ucs); - } else { - isp = isprint(ucs); - iss &= !!isspace(ucs); - } - if (iss) { - ip += size; - } - } while (iss); - if (size > outlen) { - return ENOMEM; - } - if (isp) { - memcpy(op, ip, size); - op += size; - outlen -= size; - } else { - ret = 1; - } - ip += size; - } - if (outlen <= 0) { - return ENOMEM; - } - *op = 0; - return ret; -} - int unicode_utf8_tolower(utf8_t * op, size_t outlen, const utf8_t * ip) { while (*ip) { @@ -128,7 +87,7 @@ int unicode_utf8_tolower(utf8_t * op, size_t outlen, const utf8_t * ip) } low = towlower((wint_t)ucs); if (low == ucs) { - memcpy(op, ip, size); + memmove(op, ip, size); ip += size; op += size; outlen -= size; diff --git a/src/util/unicode.h b/src/util/unicode.h index 3231f1e94..4fd860e45 100644 --- a/src/util/unicode.h +++ b/src/util/unicode.h @@ -25,7 +25,7 @@ extern "C" { #include #define USE_UNICODE - typedef unsigned long ucs4_t; + typedef long ucs4_t; typedef char utf8_t; int unicode_utf8_to_cp437(unsigned char *result, const utf8_t * utf8_string, @@ -42,7 +42,6 @@ extern "C" { int unicode_latin1_to_utf8(utf8_t * out, size_t * outlen, const char *in, size_t * inlen); int unicode_utf8_tolower(utf8_t *op, size_t outlen, const utf8_t *ip); - int unicode_utf8_mkname(utf8_t *op, size_t outlen, const utf8_t *ip); int unicode_utf8_trim(utf8_t *ip); #ifdef __cplusplus diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index 167538a3f..679c19d6b 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -30,21 +30,6 @@ static void test_unicode_trim(CuTest * tc) CuAssertStrEquals(tc, "Hello Word", buffer); } -static void test_unicode_mkname(CuTest * tc) -{ - char buffer[32]; - CuAssertIntEquals(tc, 0, unicode_utf8_mkname(buffer, sizeof(buffer), " HeLlO W0Rld")); - CuAssertStrEquals(tc, "HeLlO W0Rld", buffer); - CuAssertIntEquals(tc, 0, unicode_utf8_mkname(buffer, sizeof(buffer), "HeLlO W0Rld")); - CuAssertStrEquals(tc, "HeLlO W0Rld", buffer); - CuAssertIntEquals(tc, 1, unicode_utf8_mkname(buffer, sizeof(buffer), "HeLlO\nW0Rld")); - CuAssertStrEquals(tc, "HeLlOW0Rld", buffer); - memset(buffer, 0, sizeof(buffer)); - buffer[5] = 'X'; - CuAssertIntEquals(tc, ENOMEM, unicode_utf8_mkname(buffer, 5, "HeLl\n W0Rld")); - CuAssertStrEquals(tc, "HeLl X", buffer); -} - static void test_unicode_tolower(CuTest * tc) { char buffer[32]; @@ -106,7 +91,6 @@ CuSuite *get_unicode_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_unicode_tolower); - SUITE_ADD_TEST(suite, test_unicode_mkname); SUITE_ADD_TEST(suite, test_unicode_trim); SUITE_ADD_TEST(suite, test_unicode_utf8_to_other); return suite; From 7557b97deee6b52f45a6b181759810d95e1079de Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 16:09:58 +0100 Subject: [PATCH 202/675] BUG 2253: Magicians cannot give men to empty units or peasants. https://bugs.eressea.de/view.php?id=2253 --- src/give.c | 22 +++++++------- src/give.test.c | 70 +++++++++++++++++++++++++++++++------------ src/kernel/messages.c | 7 +++-- 3 files changed, 67 insertions(+), 32 deletions(-) diff --git a/src/give.c b/src/give.c index b6d1bd118..912aba2dc 100644 --- a/src/give.c +++ b/src/give.c @@ -224,15 +224,11 @@ static bool unit_has_cursed_item(const unit * u) return false; } -static bool can_give_men(const unit *u, order *ord, message **msg) { - if (u_race(u) == get_race(RC_SNOTLING)) { - /* snotlings may not be given to the peasants. */ - if (msg) *msg = msg_error(u, ord, 307); - } - else if (unit_has_cursed_item(u)) { +static bool can_give_men(const unit *u, const unit *dst, order *ord, message **msg) { + if (unit_has_cursed_item(u)) { if (msg) *msg = msg_error(u, ord, 78); } - else if (has_skill(u, SK_MAGIC)) { + else if (dst && (has_skill(u, SK_MAGIC) && dst->number > 0)) { /* cannot give units to and from magicians */ if (msg) *msg = msg_error(u, ord, 158); } @@ -263,9 +259,9 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord) message * msg; int maxt = max_transfers(); - assert(u2); + assert(u2); // use disband_men for GIVE 0 - if (!can_give_men(u, ord, &msg)) { + if (!can_give_men(u, u2, ord, &msg)) { return msg; } @@ -401,10 +397,16 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord) message * disband_men(int n, unit * u, struct order *ord) { message * msg; - if (!can_give_men(u, ord, &msg)) { + // TODO: cache RC_SNOTLING + if (u_race(u) == get_race(RC_SNOTLING)) { + /* snotlings may not be given to the peasants. */ + return msg_error(u, ord, 307); + } + if (!can_give_men(u, NULL, ord, &msg)) { return msg; } transfermen(u, NULL, n); + //TODO: is ORCIFICATION still working? snotlings cannot be given to peasants #ifdef ORCIFICATION if (u_race(u) == get_race(RC_SNOTLING) && !fval(u->region, RF_ORCIFIED)) { attrib *a = a_find(u->region->attribs, &at_orcification); diff --git a/src/give.test.c b/src/give.test.c index e65c2861c..c719ddd5c 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -50,7 +50,7 @@ static void setup_give(struct give *env) { static void test_give_unit_to_peasants(CuTest * tc) { struct give env; - test_cleanup(); + test_setup(); env.f1 = test_create_faction(0); env.f2 = 0; setup_give(&env); @@ -63,7 +63,7 @@ static void test_give_unit_to_peasants(CuTest * tc) { static void test_give_unit(CuTest * tc) { struct give env; - test_cleanup(); + test_setup(); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -82,7 +82,7 @@ static void test_give_unit(CuTest * tc) { static void test_give_unit_in_ocean(CuTest * tc) { struct give env; - test_cleanup(); + test_setup(); env.f1 = test_create_faction(0); env.f2 = 0; setup_give(&env); @@ -94,7 +94,7 @@ static void test_give_unit_in_ocean(CuTest * tc) { static void test_give_men(CuTest * tc) { struct give env; - test_cleanup(); + test_setup(); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); CuAssertPtrEquals(tc, 0, give_men(1, env.src, env.dst, NULL)); @@ -103,10 +103,41 @@ static void test_give_men(CuTest * tc) { test_cleanup(); } +static void test_give_men_magicians(CuTest * tc) { + struct give env; + int p; + message * msg; + + test_setup(); + env.f2 = env.f1 = test_create_faction(0); + setup_give(&env); + set_level(env.src, SK_MAGIC, 1); + CuAssertPtrNotNull(tc, msg = give_men(1, env.src, env.dst, NULL)); + CuAssertStrEquals(tc, "error158", (const char *)msg->parameters[3].v); + CuAssertIntEquals(tc, 1, env.dst->number); + CuAssertIntEquals(tc, 1, env.src->number); + msg_release(msg); + + + set_number(env.dst, 0); + CuAssertPtrEquals(tc, NULL, give_men(1, env.src, env.dst, NULL)); + CuAssertIntEquals(tc, 1, env.dst->number); + CuAssertIntEquals(tc, 0, env.src->number); + + p = rpeasants(env.r); + CuAssertPtrNotNull(tc, msg = disband_men(1, env.dst, NULL)); + CuAssertStrEquals(tc, "give_person_peasants", (const char *)msg->parameters[0].v); + CuAssertIntEquals(tc, 0, env.dst->number); + CuAssertIntEquals(tc, p+1, rpeasants(env.r)); + msg_release(msg); + + test_cleanup(); +} + static void test_give_men_limit(CuTest * tc) { struct give env; message *msg; - test_cleanup(); + test_setup(); env.f2 = test_create_faction(0); env.f1 = test_create_faction(0); setup_give(&env); @@ -137,7 +168,7 @@ static void test_give_men_in_ocean(CuTest * tc) { struct give env; message * msg; - test_cleanup(); + test_setup(); env.f1 = test_create_faction(0); env.f2 = 0; setup_give(&env); @@ -151,7 +182,7 @@ static void test_give_men_in_ocean(CuTest * tc) { static void test_give_men_too_many(CuTest * tc) { struct give env; - test_cleanup(); + test_setup(); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); CuAssertPtrEquals(tc, 0, give_men(2, env.src, env.dst, NULL)); @@ -164,7 +195,7 @@ static void test_give_men_none(CuTest * tc) { struct give env; message * msg; - test_cleanup(); + test_setup(); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); msg = give_men(0, env.src, env.dst, NULL); @@ -179,7 +210,7 @@ static void test_give_men_other_faction(CuTest * tc) { struct give env; message * msg; - test_cleanup(); + test_setup(); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -198,7 +229,7 @@ static void test_give_men_requires_contact(CuTest * tc) { order *ord; char cmd[32]; - test_cleanup(); + test_setup(); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -222,7 +253,7 @@ static void test_give_men_requires_contact(CuTest * tc) { static void test_give_men_not_to_self(CuTest * tc) { struct give env; message * msg; - test_cleanup(); + test_setup(); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); msg = give_men(1, env.src, env.src, NULL); @@ -236,7 +267,7 @@ static void test_give_peasants(CuTest * tc) { struct give env; message * msg; - test_cleanup(); + test_setup(); env.f1 = test_create_faction(0); env.f2 = 0; setup_give(&env); @@ -252,7 +283,7 @@ static void test_give_peasants(CuTest * tc) { static void test_give(CuTest * tc) { struct give env; - test_cleanup(); + test_setup(); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); @@ -272,7 +303,7 @@ static void test_give_herbs(CuTest * tc) { struct order *ord; char cmd[32]; - test_cleanup(); + test_setup(); test_create_world(); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); @@ -292,7 +323,7 @@ static void test_give_herbs(CuTest * tc) { static void test_give_okay(CuTest * tc) { struct give env; - test_cleanup(); + test_setup(); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); @@ -305,7 +336,7 @@ static void test_give_denied_by_rules(CuTest * tc) { struct give env; struct message *msg; - test_cleanup(); + test_setup(); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -320,7 +351,7 @@ static void test_give_dead_unit(CuTest * tc) { struct give env; struct message *msg; - test_cleanup(); + test_setup(); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -334,7 +365,7 @@ static void test_give_dead_unit(CuTest * tc) { static void test_give_new_unit(CuTest * tc) { struct give env; - test_cleanup(); + test_setup(); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -349,7 +380,7 @@ static void test_give_invalid_target(CuTest *tc) { struct give env; order *ord; - test_cleanup(); + test_setup(); env.f1 = test_create_faction(0); env.f2 = 0; setup_give(&env); @@ -370,6 +401,7 @@ CuSuite *get_give_suite(void) CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_give); SUITE_ADD_TEST(suite, test_give_men); + SUITE_ADD_TEST(suite, test_give_men_magicians); SUITE_ADD_TEST(suite, test_give_men_limit); SUITE_ADD_TEST(suite, test_give_men_in_ocean); SUITE_ADD_TEST(suite, test_give_men_none); diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 330c2feeb..566e9bdef 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -92,10 +92,11 @@ struct message *msg_feedback(const struct unit *u, struct order *ord, if (!mtype) { log_warning("trying to create message of unknown type \"%s\"\n", name); if (!mt_find("missing_feedback")) { - mt_register(mt_new_va("missing_feedback", "unit:unit", "region:region", "command:order", "name:string", 0)); + mt_register(mt_new_va("missing_feedback", "unit:unit", + "region:region", "command:order", "name:string", 0)); } - return msg_message("missing_feedback", "unit region command name", u, - u->region, ord, name); + return msg_message("missing_feedback", "name unit region command", + name, u, u->region, ord); } var.v = (void *)u; From 8b0ee77bda6ff66839b8a5add4a9a6723d87d94b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 17:06:28 +0100 Subject: [PATCH 203/675] begin removing orcification --- src/give.c | 11 ++++++++--- src/randenc.c | 21 ++++++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/give.c b/src/give.c index 912aba2dc..a7e416ee5 100644 --- a/src/give.c +++ b/src/give.c @@ -396,9 +396,14 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord) message * disband_men(int n, unit * u, struct order *ord) { message * msg; + static const race *rc_snotling; + static int rccache; - // TODO: cache RC_SNOTLING - if (u_race(u) == get_race(RC_SNOTLING)) { + if (rc_changed(&rccache)) { + rc_snotling = get_race(RC_SNOTLING); + } + + if (u_race(u) == rc_snotling) { /* snotlings may not be given to the peasants. */ return msg_error(u, ord, 307); } @@ -408,7 +413,7 @@ message * disband_men(int n, unit * u, struct order *ord) { transfermen(u, NULL, n); //TODO: is ORCIFICATION still working? snotlings cannot be given to peasants #ifdef ORCIFICATION - if (u_race(u) == get_race(RC_SNOTLING) && !fval(u->region, RF_ORCIFIED)) { + if (u_race(u) == rc_snotling && !fval(u->region, RF_ORCIFIED)) { attrib *a = a_find(u->region->attribs, &at_orcification); if (!a) { a = a_add(&u->region->attribs, a_new(&at_orcification)); diff --git a/src/randenc.c b/src/randenc.c index 0fe76e883..44b2d959d 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -827,19 +827,22 @@ void randomevents(void) else { attrib *a = a_find(r->attribs, &at_orcification); if (a != NULL) { - double probability = 0.0; - if (rpeasants(r) <= 0) - continue; - probability = a->data.i / (double)rpeasants(r); - if (chance(probability)) { - fset(r, RF_ORCIFIED); + if (rpeasants(r) <= 0) { a_remove(&r->attribs, a); - ADDMSG(&r->msgs, msg_message("orcified", "region", r)); } else { - a->data.i -= _max(10, a->data.i / 10); - if (a->data.i <= 0) + double probability = 0.0; + probability = a->data.i / (double)rpeasants(r); + if (chance(probability)) { + fset(r, RF_ORCIFIED); a_remove(&r->attribs, a); + ADDMSG(&r->msgs, msg_message("orcified", "region", r)); + } + else { + a->data.i -= _max(10, a->data.i / 10); + if (a->data.i <= 0) + a_remove(&r->attribs, a); + } } } } From 29d072a186c9ff5f1830249ffdc3ac2ad658d864 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 17:13:59 +0100 Subject: [PATCH 204/675] remove the old ORCIFICATION code. --- src/attributes/CMakeLists.txt | 1 - src/attributes/attributes.c | 3 +-- src/attributes/orcification.c | 39 -------------------------------- src/attributes/orcification.h | 28 ----------------------- src/creport.c | 4 ---- src/economy.c | 8 ------- src/give.c | 11 --------- src/kernel/config.c | 3 --- src/kernel/region.h | 3 +-- src/randenc.c | 42 ----------------------------------- src/report.c | 23 +++++-------------- src/summary.c | 5 ----- 12 files changed, 8 insertions(+), 162 deletions(-) delete mode 100644 src/attributes/orcification.c delete mode 100644 src/attributes/orcification.h diff --git a/src/attributes/CMakeLists.txt b/src/attributes/CMakeLists.txt index 1419f9e9a..d0aa252ee 100644 --- a/src/attributes/CMakeLists.txt +++ b/src/attributes/CMakeLists.txt @@ -16,7 +16,6 @@ matmod.c moved.c movement.c dict.c -orcification.c otherfaction.c overrideroads.c racename.c diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index e46988667..cae0c4742 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -33,7 +33,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "moved.h" #include "movement.h" #include "dict.h" -#include "orcification.h" #include "otherfaction.h" #include "overrideroads.h" #include "racename.h" @@ -120,6 +119,7 @@ void register_attributes(void) at_register(&at_germs); at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */ + at_deprecate("orcification", a_readint); /* required for old datafiles */ at_deprecate("lua", read_ext); /* required for old datafiles */ at_deprecate("gm", a_readint); at_deprecate("guard", a_readint); /* used to contain guard-flags (v3.10.0-259-g8597e8b) */ @@ -133,7 +133,6 @@ void register_attributes(void) at_register(&at_keys); at_register(&at_follow); at_register(&at_targetregion); - at_register(&at_orcification); at_register(&at_hate); at_register(&at_reduceproduction); at_register(&at_otherfaction); diff --git a/src/attributes/orcification.c b/src/attributes/orcification.c deleted file mode 100644 index dfb8f32f4..000000000 --- a/src/attributes/orcification.c +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#include -#include -#include "orcification.h" - -#include -#include - -/* - * simple attributes that do not yet have their own file - */ - -attrib_type at_orcification = { - "orcification", NULL, NULL, NULL, a_writeint, a_readint, NULL, ATF_UNIQUE -}; - -attrib *make_orcification(int orcification) -{ - attrib *a = a_new(&at_orcification); - a->data.i = orcification; - return a; -} diff --git a/src/attributes/orcification.h b/src/attributes/orcification.h deleted file mode 100644 index 3f1e2d418..000000000 --- a/src/attributes/orcification.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifdef __cplusplus -extern "C" { -#endif - extern struct attrib_type at_orcification; - - extern struct attrib *make_orcification(int orcification); - -#ifdef __cplusplus -} -#endif diff --git a/src/creport.c b/src/creport.c index 8f32d3ac3..2cdc2d42f 100644 --- a/src/creport.c +++ b/src/creport.c @@ -24,7 +24,6 @@ without prior permission by the authors of Eressea. /* attributes include */ #include -#include #include #include #include @@ -1329,9 +1328,6 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r) if (fval(r->terrain, LAND_REGION)) { assert(r->land); fprintf(F, "%d;Bauern\n", rpeasants(r)); - if (fval(r, RF_ORCIFIED)) { - fprintf(F, "1;Verorkt\n"); - } fprintf(F, "%d;Pferde\n", rhorses(r)); if (r->seen.mode >= seen_unit) { diff --git a/src/economy.c b/src/economy.c index 10215d0da..36e8de109 100644 --- a/src/economy.c +++ b/src/economy.c @@ -69,7 +69,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#include /* libs includes */ #include @@ -498,13 +497,6 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders) return; } - if (fval(r, RF_ORCIFIED)) { - if (rc != get_race(RC_ORC)) { - cmistake(u, ord, 238, MSG_EVENT); - return; - } - } - if (recruitcost) { pl = getplane(r); if (pl && fval(pl, PFL_NORECRUITS)) { diff --git a/src/give.c b/src/give.c index a7e416ee5..8f87cded3 100644 --- a/src/give.c +++ b/src/give.c @@ -34,7 +34,6 @@ /* attributes includes */ #include -#include /* util includes */ #include @@ -411,16 +410,6 @@ message * disband_men(int n, unit * u, struct order *ord) { return msg; } transfermen(u, NULL, n); - //TODO: is ORCIFICATION still working? snotlings cannot be given to peasants -#ifdef ORCIFICATION - if (u_race(u) == rc_snotling && !fval(u->region, RF_ORCIFIED)) { - attrib *a = a_find(u->region->attribs, &at_orcification); - if (!a) { - a = a_add(&u->region->attribs, a_new(&at_orcification)); - } - a->data.i += n; - } -#endif if (fval(u->region->terrain, SEA_REGION)) { return msg_message("give_person_ocean", "unit amount", u, n); } diff --git a/src/kernel/config.c b/src/kernel/config.c index 7c58d7766..42dcc5e09 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -942,9 +942,6 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn) else if (fval(r->terrain, SEA_REGION)) { wage = 11; } - else if (fval(r, RF_ORCIFIED)) { - wage = wagetable[esize][1]; - } else { wage = wagetable[esize][2]; } diff --git a/src/kernel/region.h b/src/kernel/region.h index 5efd416f6..eb7066cc6 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -44,7 +44,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define RF_ENCOUNTER (1<<9) /* persistent */ #define RF_MAPPER_HIGHLIGHT (1<<10) #define RF_LIGHTHOUSE (1<<11) /* this region may contain a lighthouse */ -#define RF_ORCIFIED (1<<12) /* persistent */ #define RF_MIGRATION (1<<13) #define RF_UNUSED_14 (1<<14) @@ -58,7 +57,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define RF_ALL 0xFFFFFF -#define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_ENCOUNTER|RF_ORCIFIED|RF_GUARDED|RF_LIGHTHOUSE) +#define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_ENCOUNTER|RF_GUARDED|RF_LIGHTHOUSE) struct message; struct message_list; struct rawmaterial; diff --git a/src/randenc.c b/src/randenc.c index 44b2d959d..ba51ab4e3 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -67,7 +67,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include extern struct attrib_type at_unitdissolve; -extern struct attrib_type at_orcification; /* In a->data.ca[1] steht der Prozentsatz mit dem sich die Einheit * auflst, in a->data.ca[0] kann angegeben werden, wohin die Personen @@ -807,47 +806,6 @@ void randomevents(void) godcurse(); orc_growth(); demon_skillchanges(); - - /* Orkifizierte Regionen mutieren und mutieren zurck */ - - for (r = regions; r; r = r->next) { - if (fval(r, RF_ORCIFIED)) { - direction_t dir; - double probability = 0.0; - for (dir = 0; dir < MAXDIRECTIONS; dir++) { - region *rc = rconnect(r, dir); - if (rc && rpeasants(rc) > 0 && !fval(rc, RF_ORCIFIED)) - probability += 0.02; - } - if (chance(probability)) { - ADDMSG(&r->msgs, msg_message("deorcified", "region", r)); - freset(r, RF_ORCIFIED); - } - } - else { - attrib *a = a_find(r->attribs, &at_orcification); - if (a != NULL) { - if (rpeasants(r) <= 0) { - a_remove(&r->attribs, a); - } - else { - double probability = 0.0; - probability = a->data.i / (double)rpeasants(r); - if (chance(probability)) { - fset(r, RF_ORCIFIED); - a_remove(&r->attribs, a); - ADDMSG(&r->msgs, msg_message("orcified", "region", r)); - } - else { - a->data.i -= _max(10, a->data.i / 10); - if (a->data.i <= 0) - a_remove(&r->attribs, a); - } - } - } - } - } - volcano_update(); /* Monumente zerfallen, Schiffe verfaulen */ diff --git a/src/report.c b/src/report.c index ddf78bc73..d41d567d7 100644 --- a/src/report.c +++ b/src/report.c @@ -1021,23 +1021,12 @@ static void describe(stream *out, const region * r, faction * f) if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } - if (fval(r, RF_ORCIFIED)) { - bytes = (int)strlcpy(bufp, " ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - - bytes = - (int)strlcpy(bufp, LOC(f->locale, n == 1 ? "rc_orc" : "rc_orc_p"), - size); - } - else { - bytes = (int)strlcpy(bufp, " ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = - (int)strlcpy(bufp, LOC(f->locale, n == 1 ? "peasant" : "peasant_p"), - size); - } + bytes = (int)strlcpy(bufp, " ", size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + bytes = + (int)strlcpy(bufp, LOC(f->locale, n == 1 ? "peasant" : "peasant_p"), + size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); if (is_mourning(r, turn + 1)) { diff --git a/src/summary.c b/src/summary.c index 6e94f31a8..d28b75202 100644 --- a/src/summary.c +++ b/src/summary.c @@ -59,7 +59,6 @@ typedef struct summary { int landregionen; int regionen_mit_spielern; int landregionen_mit_spielern; - int orkifizierte_regionen; int inactive_volcanos; int active_volcanos; int spielerpferde; @@ -227,7 +226,6 @@ void report_summary(summary * s, summary * o, bool full) fprintf(F, "Landregionen: %d\n", s->landregionen); fprintf(F, "Spielerregionen: %d\n", s->regionen_mit_spielern); fprintf(F, "Landspielerregionen: %d\n", s->landregionen_mit_spielern); - fprintf(F, "Orkifizierte Regionen: %d\n", s->orkifizierte_regionen); fprintf(F, "Inaktive Vulkane: %d\n", s->inactive_volcanos); fprintf(F, "Aktive Vulkane: %d\n\n", s->active_volcanos); } @@ -422,9 +420,6 @@ summary *make_summary(void) if (r->units) { s->landregionen_mit_spielern++; } - if (fval(r, RF_ORCIFIED)) { - s->orkifizierte_regionen++; - } if (r->terrain == newterrain(T_VOLCANO)) { s->inactive_volcanos++; } From 28aa2a56b8988cfb41ca412144b9e325beb064c7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 17:49:16 +0100 Subject: [PATCH 205/675] =?UTF-8?q?Entferne=20unbenutztes=20"Szepter=20der?= =?UTF-8?q?=20Tr=C3=A4nen".=20Was=20f=C3=BCr=20eine=20saubl=C3=B6de=20Idee?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/core/common/items.xml | 6 ------ res/core/de/strings.xml | 13 ------------- res/core/messages.xml | 15 --------------- src/modules/arena.c | 30 ------------------------------ 4 files changed, 64 deletions(-) diff --git a/res/core/common/items.xml b/res/core/common/items.xml index 444ea26a1..c903a6b78 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -135,12 +135,6 @@ - - - - - - diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 4582644c7..b23d44ffb 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -235,11 +235,6 @@ einzige Vorteil ihrer geringen Größe ist, dass sie sich leichter verstecken kann. - - Dieses magische Szepter, ein Geschenk Igjarjuks, sorgt für große - Verwirrung und Gedächtnisverlust. Syntax: BENUTZE "Szepter der - Tränen" - Setzt eine Einheit dieses Segel auf einem Schiff, so erhöht sich dessen Reichweite permanent um 1 Region. @@ -1614,14 +1609,6 @@ Akkreditionen des Xontormia-Expreß - - Szepter der Tränen - wand of tears - - - Szepter der Tränen - wands of tears - Schneeball snowball diff --git a/res/core/messages.xml b/res/core/messages.xml index bf4b0c041..2c8a80eb6 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -1253,14 +1253,6 @@ "$unit($unit) dies from poison damage taken in $region($region)." - - - - - "$unit($unit) schwenkt sein Szepter und sorgt für Verwirrung und Chaos in der Region." - "$unit($unit) waves their scepter and causes chaos and confusion in the region." - - @@ -1573,13 +1565,6 @@ "$unit($mage) konnte $int($amount) $if($eq($amount,1),"Bauer","Bauern") anwerben." "$unit($mage) managed to recruit $int($amount) $if($eq($amount,1),"peasant","peasants")." - - - - - "Ein bohrender Schmerz durchzuckt $unit($unit), Verwirrung macht sich breit." - "Pain pulses through $unit($unit), confusion spreads." - diff --git a/src/modules/arena.c b/src/modules/arena.c index 97488218a..d9ecac984 100644 --- a/src/modules/arena.c +++ b/src/modules/arena.c @@ -181,35 +181,6 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord) return 0; } -/*** - ** Szepter der Trnen, Demo-Item - ***/ - -static int -use_wand_of_tears(unit * user, const struct item_type *itype, int amount, -order * ord) -{ - int n; - unused_arg(ord); - for (n = 0; n != amount; ++n) { - unit *u; - for (u = user->region->units; u; u = u->next) { - if (u->faction != user->faction) { - int i; - - for (i = 0; i != u->skill_size; ++i) { - if (rng_int() % 3) - reduce_skill(u, u->skills + i, 1); - } - ADDMSG(&u->faction->msgs, msg_message("wand_of_tears_effect", - "unit", u)); - } - } - } - ADDMSG(&user->region->msgs, msg_message("wand_of_tears_usage", "unit", user)); - return 0; -} - /** * Tempel der Schreie, Demo-Gebude **/ @@ -556,7 +527,6 @@ void create_arena(void) void register_arena(void) { at_register(&at_hurting); - register_item_use(use_wand_of_tears, "use_wand_of_tears"); register_function((pf_generic)enter_arena, "enter_arena"); register_function((pf_generic)leave_arena, "leave_arena"); tt_register(&tt_caldera); From 2d2ded8f0d2ae740bd73e81c8c6da3b9443e86cf Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 17:57:57 +0100 Subject: [PATCH 206/675] fix a_readint for deprecated attribs. --- src/kernel/save.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 327fa4f1a..80e9ca3a6 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -2077,8 +2077,9 @@ int write_game(gamedata *data) { int a_readint(attrib * a, void *owner, struct gamedata *data) { - /* assert(sizeof(int)==sizeof(a->data)); */ - READ_INT(data->store, &a->data.i); + int n; + READ_INT(data->store, &n); + if (a) a->data.i = n; return AT_READ_OK; } From 76734c7929f6f19a03fa29b2b4bb70d1db48440e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 18:25:01 +0100 Subject: [PATCH 207/675] remove ARENA_CREATION code, it wasn't active. --- src/modules/arena.c | 224 -------------------------------------------- 1 file changed, 224 deletions(-) diff --git a/src/modules/arena.c b/src/modules/arena.c index d9ecac984..6eda93afd 100644 --- a/src/modules/arena.c +++ b/src/modules/arena.c @@ -70,11 +70,6 @@ plane *arena = NULL; /* local vars */ #define CENTRAL_VOLCANO 1 -#ifdef ARENA_CREATION -static unsigned int arena_id = 0; -static region *arena_center = NULL; -static int newarena = 0; -#endif static region *tower_region[6]; static region *start_region[6]; @@ -236,143 +231,6 @@ static attrib_type at_hurting = { "hurting", NULL, NULL, age_hurting, write_hurting, read_hurting }; -#ifdef ARENA_CREATION -static void make_temple(region * r) -{ - const building_type *btype = bt_find("temple"); - building *b; - if (btype == NULL) { - log_error("could not find buildingtype 'temple'\n"); - return; - } - - b = r->buildings; - while (b != NULL && b->type != btype) - b = b->next; - if (b != NULL) - return; /* gibt schon einen */ - - b = new_building(btype, r, NULL); - b->size = btype->maxsize; - b->name = _strdup("Igjarjuk's Tempel der Schreie"); - b->display = - _strdup - ("Ein Schrein aus spitzen Knochen und lodernden Flammen, gewidmet dem Wyrm der Wyrme"); - a_add(&b->attribs, a_new(&at_hurting))->data.v = b; -} -#endif - -/** - * Initialisierung Trme */ - -#ifdef ARENA_CREATION -static void tower_init(void) -{ - int i, first = newarena; - item_type *it_demonseye = it_find("demonseye"); - item_type *it_griphonwing = it_find("griphonwing"); - assert(it_griphonwing && it_demonseye); - for (i = 0; i != 6; ++i) { - region *r = tower_region[i] = - findregion(arena_center->x + delta_x[i] * 3, - arena_center->y + delta_y[i] * 3); - if (r) { - start_region[i] = - findregion(arena_center->x + delta_x[i] * 2, - arena_center->y + delta_y[i] * 2); - if (rterrain(r) != T_DESERT) - terraform(r, T_DESERT); - if (!r->buildings) { - building *b = new_building(bt_find("castle"), r, NULL); - b->size = 10; - if (i != 0) { - sprintf(buf, "Turm des %s", - LOC(default_locale, mkname("school", magic_school[i]))); - } else - sprintf(buf, "Turm der Ahnungslosen"); - set_string(&b->name, buf); - } - } - } - if (first && !arena_center->buildings) { - building *b = new_building(bt_find("castle"), arena_center, NULL); - attrib *a; - item *items; - - i_add(&items, i_new(it_griphonwing, 1)); - i_add(&items, i_new(it_demonseye, 1)); - a = a_add(&b->attribs, make_giveitem(b, items)); - - b->size = 10; - set_string(&b->name, "Hhle des Greifen"); - } -} -#endif - -#ifdef ARENA_CREATION -static void guardian_faction(plane * pl, int id) -{ - region *r; - faction *f = findfaction(id); - - if (!f) { - f = calloc(1, sizeof(faction)); - f->banner = _strdup("Sie dienen dem groen Wyrm"); - f->passw = _strdup(itoa36(rng_int())); - set_email(&f->email, "igjarjuk@eressea.de"); - f->name = _strdup("Igjarjuks Kundschafter"); - f->race = get_race(RC_ILLUSION); - f->age = turn; - f->locale = get_locale("de"); - f->options = - want(O_COMPRESS) | want(O_REPORT) | want(O_COMPUTER) | want(O_ADRESSEN) | - want(O_DEBUG); - - f->no = id; - addlist(&factions, f); - fhash(f); - } - if (f->race != get_race(RC_ILLUSION)) { - assert(!"guardian id vergeben"); - exit(0); - } - f->lastorders = turn; - f->alive = true; - for (r = regions; r; r = r->next) - if (getplane(r) == pl && rterrain(r) != T_FIREWALL) { - unit *u; - freset(r, RF_ENCOUNTER); - for (u = r->units; u; u = u->next) { - if (u->faction == f) - break; - } - if (u) - continue; - u = create_unit(r, f, 1, get_race(RC_GOBLIN), 0, NULL, NULL); - set_string(&u->name, "Igjarjuks Auge"); - i_change(&u->items, it_find("roi"), 1); - set_order(&u->thisorder, NULL); - fset(u, UFL_ANON_FACTION); - set_money(u, 1000); - } -} -#endif - -#define BLOCKSIZE 9 - -#ifdef ARENA_CREATION -static void block_create(int x1, int y1, char terrain) -{ - int x, y; - for (x = 0; x != BLOCKSIZE; ++x) { - for (y = 0; y != BLOCKSIZE; ++y) { - region *r = new_region(x1 + x, y1 + y, 0); - terraform(r, terrain); - } - } -} -#endif - #ifdef CENTRAL_VOLCANO static int caldera_handle(trigger * t, void *data) @@ -440,90 +298,8 @@ struct trigger_type tt_caldera = { caldera_read }; -#ifdef ARENA_CREATION -static trigger *trigger_caldera(building * b) -{ - trigger *t = t_new(&tt_caldera); - t->data.v = b; - return t; -} #endif -#ifdef ARENA_CREATION -static void init_volcano(void) -{ - building *b; - region *r = arena_center; - assert(arena_center); - if (rterrain(r) != T_DESERT) - return; /* been done before */ - terraform(arena_center, T_VOLCANO_SMOKING); - b = new_building(bt_find("caldera"), r, NULL); - b->size = 1; - b->name = _strdup("Igjarjuk's Schlund"); - b->display = - _strdup - ("Feurige Lava fliet aus dem Krater des groen Vulkans. Alles wird von ihr verschlungen."); - add_trigger(&b->attribs, "timer", trigger_caldera(b)); - tt_register(&tt_caldera); -} -#endif -#endif - -#ifdef ARENA_CREATION -void create_arena(void) -{ - int x; - arena_id = hashstring("arena"); - arena = getplanebyid(arena_id); - if (arena != NULL) - return; - score(); /* ist wichtig, damit alle Parteien einen score haben, wenn sie durchs Tor wollen. */ - guardian_faction(arena, 999); - if (arena) - arena_center = findregion(plane_center_x(arena), plane_center_y(arena)); - if (!arena_center) { - newarena = 1; - arena = - create_new_plane(arena_id, "Arena", -10000, -10000, 0, BLOCKSIZE - 1, - PFL_LOWSTEALING | PFL_NORECRUITS | PFL_NOALLIANCES); - block_create(arena->minx, arena->miny, T_OCEAN); - arena_center = findregion(plane_center_x(arena), plane_center_y(arena)); - for (x = 0; x != BLOCKSIZE; ++x) { - int y; - for (y = 0; y != BLOCKSIZE; ++y) { - region *r = findregion(arena->minx + x, arena->miny + y); - freset(r, RF_ENCOUNTER); - r->planep = arena; - switch (distance(r, arena_center)) { - case 4: - terraform(r, T_FIREWALL); - break; - case 0: - terraform(r, T_GLACIER); - break; - case 1: - terraform(r, T_SWAMP); - break; - case 2: - terraform(r, T_MOUNTAIN); - break; - } - } - } - } - make_temple(arena_center); -#ifdef CENTRAL_VOLCANO - init_volcano(); -#else - if (arena_center->terrain != T_DESERT) - terraform(arena_center, T_DESERT); -#endif - rsetmoney(arena_center, 0); - rsetpeasants(arena_center, 0); - tower_init(); -} -#endif void register_arena(void) { at_register(&at_hurting); From 353329171112b2de9b6efb8dc6a57c9e409d607d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 18:33:47 +0100 Subject: [PATCH 208/675] remove at_hurting, it was only used by the Temple of Pain, which is no longer in the game. --- res/core/messages.xml | 15 ----------- src/modules/arena.c | 59 ++----------------------------------------- 2 files changed, 2 insertions(+), 72 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 2c8a80eb6..260f76c70 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -1565,13 +1565,6 @@ "$unit($mage) konnte $int($amount) $if($eq($amount,1),"Bauer","Bauern") anwerben." "$unit($mage) managed to recruit $int($amount) $if($eq($amount,1),"peasant","peasants")." - - - - - ""AAAAAAAGHHHHHH!" - Ein Schrei durchzieht die Region, $unit($unit) windet sich vor Schmerz." - ""AAAAAAAGHHHHHH!" - $unit($unit) screams and squirms with pain." - @@ -1583,14 +1576,6 @@ "$unit($unit) in $region($region): '$order($command)' - A higher power prevents $unit($unit) from giving the object away. 'IT IS YOURS MY CHILD. ONLY YOURS.'." - - - - - "$unit($unit) sendet ein Stoßgebet an den Herrn der Schreie." - "$unit($unit) sends a prayer to the Lord of Screams." - - diff --git a/src/modules/arena.c b/src/modules/arena.c index 6eda93afd..d2b67d9af 100644 --- a/src/modules/arena.c +++ b/src/modules/arena.c @@ -38,6 +38,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include #include #include @@ -175,62 +176,6 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord) move_unit(u, start_region[rng_int() % 6], NULL); return 0; } - -/** - * Tempel der Schreie, Demo-Gebude **/ - -static int age_hurting(attrib * a, void *owner) -{ - building *b = (building *)a->data.v; - unit *u; - int active = 0; - assert(owner == b); - if (b == NULL) - return AT_AGE_REMOVE; - for (u = b->region->units; u; u = u->next) { - if (u->building == b) { - if (u->faction->magiegebiet == M_DRAIG) { - active++; - ADDMSG(&b->region->msgs, msg_message("praytoigjarjuk", "unit", u)); - } - } - } - if (active) - for (u = b->region->units; u; u = u->next) - if (playerrace(u->faction->race)) { - int i; - if (u->faction->magiegebiet != M_DRAIG) { - for (i = 0; i != active; ++i) - u->hp = (u->hp + 1) / 2; /* make them suffer, but not die */ - ADDMSG(&b->region->msgs, msg_message("cryinpain", "unit", u)); - } - } - return AT_AGE_KEEP; -} - -static void -write_hurting(const attrib * a, const void *owner, struct storage *store) -{ - building *b = a->data.v; - WRITE_INT(store, b->no); -} - -static int read_hurting(attrib * a, void *owner, struct gamedata *data) -{ - int i; - READ_INT(data->store, &i); - a->data.v = (void *)findbuilding(i); - if (a->data.v == NULL) { - log_error("temple of pain is broken\n"); - return AT_READ_FAIL; - } - return AT_READ_OK; -} - -static attrib_type at_hurting = { - "hurting", NULL, NULL, age_hurting, write_hurting, read_hurting -}; - #ifdef CENTRAL_VOLCANO static int caldera_handle(trigger * t, void *data) @@ -302,7 +247,7 @@ struct trigger_type tt_caldera = { void register_arena(void) { - at_register(&at_hurting); + at_deprecate("hurting", a_readint); register_function((pf_generic)enter_arena, "enter_arena"); register_function((pf_generic)leave_arena, "leave_arena"); tt_register(&tt_caldera); From 37bb9c7ae928f2695e79a670e7503cbd05d521b2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 19:00:59 +0100 Subject: [PATCH 209/675] Bug 2255: increase the max. number of teachers. https://bugs.eressea.de/view.php?id=2255 --- src/study.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/study.h b/src/study.h index e136d7345..20903583a 100644 --- a/src/study.h +++ b/src/study.h @@ -45,7 +45,7 @@ extern "C" { void demon_skillchange(struct unit *u); -#define MAXTEACHERS 20 +#define MAXTEACHERS 32 #define TEACHNUMBER 10 typedef struct teaching_info { struct unit *teachers[MAXTEACHERS]; From 11b122048b4fca1b12a77bfb19a8499b7c05ab0d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 19:40:38 +0100 Subject: [PATCH 210/675] reduce dependency on save.h moving a_write* functions to attrib.h, which was most of the reason everyone and their mom include save.h --- src/attributes/attributes.c | 1 - src/attributes/dict.c | 1 - src/attributes/iceberg.c | 1 - src/attributes/key.c | 1 - src/attributes/movement.c | 1 - src/attributes/overrideroads.c | 3 +- src/attributes/racename.c | 1 - src/attributes/raceprefix.c | 1 - src/attributes/reduceproduction.c | 1 - src/attributes/stealth.c | 1 - src/attributes/targetregion.c | 1 - src/chaos.c | 1 - src/creport.c | 4 +- src/items/artrewards.c | 1 - src/kernel/ally.c | 1 - src/kernel/building.c | 1 - src/kernel/faction.c | 1 - src/kernel/item.c | 1 - src/kernel/region.c | 1 - src/kernel/save.c | 92 +------------------------------ src/kernel/save.h | 19 +------ src/kernel/unit.c | 1 - src/laws.c | 1 - src/modules/arena.c | 1 - src/move.c | 1 - src/report.c | 52 ++++++++--------- src/spells.c | 3 +- src/spells/borders.c | 1 - src/summary.c | 1 - src/triggers/changefaction.c | 1 - src/util/attrib.c | 82 +++++++++++++++++++++++++++ src/util/attrib.h | 14 +++++ src/util/attrib.test.c | 90 +++++++++++++++++++++++++++++- 33 files changed, 218 insertions(+), 165 deletions(-) diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index cae0c4742..8e9b22139 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -48,7 +48,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include diff --git a/src/attributes/dict.c b/src/attributes/dict.c index cb24b148b..2bba9ea7b 100644 --- a/src/attributes/dict.c +++ b/src/attributes/dict.c @@ -24,7 +24,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include diff --git a/src/attributes/iceberg.c b/src/attributes/iceberg.c index 661a2ec80..e36e6303a 100644 --- a/src/attributes/iceberg.c +++ b/src/attributes/iceberg.c @@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "iceberg.h" -#include #include attrib_type at_iceberg = { diff --git a/src/attributes/key.c b/src/attributes/key.c index 39c7dab66..0b252e0c0 100644 --- a/src/attributes/key.c +++ b/src/attributes/key.c @@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "key.h" -#include #include #include #include diff --git a/src/attributes/movement.c b/src/attributes/movement.c index 0ad08030e..874da5eb3 100644 --- a/src/attributes/movement.c +++ b/src/attributes/movement.c @@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "movement.h" -#include #include #include diff --git a/src/attributes/overrideroads.c b/src/attributes/overrideroads.c index 72d2260bc..ef466de2d 100644 --- a/src/attributes/overrideroads.c +++ b/src/attributes/overrideroads.c @@ -20,9 +20,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "overrideroads.h" -#include #include attrib_type at_overrideroads = { - "roads_override", NULL, NULL, NULL, &a_writestring, &a_readstring + "roads_override", NULL, NULL, NULL, a_writestring, a_readstring }; diff --git a/src/attributes/racename.c b/src/attributes/racename.c index f60340b0c..b408cbf6a 100644 --- a/src/attributes/racename.c +++ b/src/attributes/racename.c @@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "racename.h" -#include #include /* libc includes */ diff --git a/src/attributes/raceprefix.c b/src/attributes/raceprefix.c index 308c75292..15f0036c1 100644 --- a/src/attributes/raceprefix.c +++ b/src/attributes/raceprefix.c @@ -19,7 +19,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "raceprefix.h" -#include #include diff --git a/src/attributes/reduceproduction.c b/src/attributes/reduceproduction.c index 3f31938d3..01041380a 100644 --- a/src/attributes/reduceproduction.c +++ b/src/attributes/reduceproduction.c @@ -19,7 +19,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "reduceproduction.h" -#include #include #include #include diff --git a/src/attributes/stealth.c b/src/attributes/stealth.c index b7336efc7..db2ec5304 100644 --- a/src/attributes/stealth.c +++ b/src/attributes/stealth.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #include diff --git a/src/attributes/targetregion.c b/src/attributes/targetregion.c index 93ef08d0b..f61214dfc 100644 --- a/src/attributes/targetregion.c +++ b/src/attributes/targetregion.c @@ -21,7 +21,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#include #include #include diff --git a/src/chaos.c b/src/chaos.c index afa787b29..7a1be7e56 100644 --- a/src/chaos.c +++ b/src/chaos.c @@ -28,7 +28,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include diff --git a/src/creport.c b/src/creport.c index 2cdc2d42f..becee2cb0 100644 --- a/src/creport.c +++ b/src/creport.c @@ -57,7 +57,6 @@ without prior permission by the authors of Eressea. #include #include #include -#include /* util includes */ #include @@ -70,6 +69,7 @@ without prior permission by the authors of Eressea. #include #include #include +#include /* libc includes */ #include @@ -177,7 +177,7 @@ static void print_items(FILE * F, item * items, const struct locale *lang) } static void -cr_output_curses(stream *out, const faction * viewer, const void *obj, objtype_t typ) +cr_output_curses(struct stream *out, const faction * viewer, const void *obj, objtype_t typ) { bool header = false; attrib *a = NULL; diff --git a/src/items/artrewards.c b/src/items/artrewards.c index 8b6288f61..0965125fd 100644 --- a/src/items/artrewards.c +++ b/src/items/artrewards.c @@ -26,7 +26,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include diff --git a/src/kernel/ally.c b/src/kernel/ally.c index 2bb980dd0..5a5a5b1c3 100644 --- a/src/kernel/ally.c +++ b/src/kernel/ally.c @@ -3,7 +3,6 @@ #include "types.h" #include "ally.h" -#include "save.h" #include "unit.h" #include "region.h" #include "group.h" diff --git a/src/kernel/building.c b/src/kernel/building.c index 0056fba1e..8789e40b2 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -28,7 +28,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "race.h" #include "region.h" #include "skill.h" -#include "save.h" #include "lighthouse.h" /* util includes */ diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 774a6aec8..0172ea835 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -29,7 +29,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "plane.h" #include "race.h" #include "region.h" -#include "save.h" #include "spellbook.h" #include "terrain.h" #include "unit.h" diff --git a/src/kernel/item.c b/src/kernel/item.c index 66e361156..64d01bce0 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -30,7 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "pool.h" #include "race.h" #include "region.h" -#include "save.h" #include "skill.h" #include "terrain.h" #include "unit.h" diff --git a/src/kernel/region.c b/src/kernel/region.c index a92a87291..e05bd76c1 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -32,7 +32,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "plane.h" #include "region.h" #include "resources.h" -#include "save.h" #include "ship.h" #include "terrain.h" #include "terrainid.h" diff --git a/src/kernel/save.c b/src/kernel/save.c index 80e9ca3a6..4a1b7897e 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -93,6 +93,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* exported symbols symbols */ int firstx = 0, firsty = 0; + +// TODO: is this still important? int enc_gamedata = ENCODING_UTF8; /* local symbols */ @@ -2074,93 +2076,3 @@ int write_game(gamedata *data) { return 0; } - -int a_readint(attrib * a, void *owner, struct gamedata *data) -{ - int n; - READ_INT(data->store, &n); - if (a) a->data.i = n; - return AT_READ_OK; -} - -void a_writeint(const attrib * a, const void *owner, struct storage *store) -{ - WRITE_INT(store, a->data.i); -} - -int a_readshorts(attrib * a, void *owner, struct gamedata *data) -{ - int n; - READ_INT(data->store, &n); - a->data.sa[0] = (short)n; - READ_INT(data->store, &n); - a->data.sa[1] = (short)n; - return AT_READ_OK; -} - -void a_writeshorts(const attrib * a, const void *owner, struct storage *store) -{ - WRITE_INT(store, a->data.sa[0]); - WRITE_INT(store, a->data.sa[1]); -} - -int a_readchars(attrib * a, void *owner, struct gamedata *data) -{ - int i; - for (i = 0; i != 4; ++i) { - int n; - READ_INT(data->store, &n); - a->data.ca[i] = (char)n; - } - return AT_READ_OK; -} - -void a_writechars(const attrib * a, const void *owner, struct storage *store) -{ - int i; - - for (i = 0; i != 4; ++i) { - WRITE_INT(store, a->data.ca[i]); - } -} - -int a_readvoid(attrib * a, void *owner, struct gamedata *data) -{ - return AT_READ_OK; -} - -void a_writevoid(const attrib * a, const void *owner, struct storage *store) -{ -} - -int a_readstring(attrib * a, void *owner, struct gamedata *data) -{ - char buf[DISPLAYSIZE]; - char * result = 0; - int e; - size_t len = 0; - do { - e = READ_STR(data->store, buf, sizeof(buf)); - if (result) { - result = realloc(result, len + DISPLAYSIZE - 1); - strcpy(result + len, buf); - len += DISPLAYSIZE - 1; - } - else { - result = _strdup(buf); - } - } while (e == ENOMEM); - a->data.v = result; - return AT_READ_OK; -} - -void a_writestring(const attrib * a, const void *owner, struct storage *store) -{ - assert(a->data.v); - WRITE_STR(store, (const char *)a->data.v); -} - -void a_finalizestring(attrib * a) -{ - free(a->data.v); -} diff --git a/src/kernel/save.h b/src/kernel/save.h index ffc9c2891..aa11ac1ad 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -39,6 +39,8 @@ extern "C" { * dass hier ein Fehler (fehlende ") vorliegt */ extern int data_version; + + // TODO: is this *really* still in use? extern int enc_gamedata; int readorders(const char *filename); @@ -72,23 +74,6 @@ extern "C" { void write_ship(struct gamedata *data, const struct ship *sh); struct ship *read_ship(struct gamedata *data); - int a_readint(struct attrib *a, void *owner, struct gamedata *); - void a_writeint(const struct attrib *a, const void *owner, - struct storage *store); - int a_readshorts(struct attrib *a, void *owner, struct gamedata *); - void a_writeshorts(const struct attrib *a, const void *owner, - struct storage *store); - int a_readchars(struct attrib *a, void *owner, struct gamedata *); - void a_writechars(const struct attrib *a, const void *owner, - struct storage *store); - int a_readvoid(struct attrib *a, void *owner, struct gamedata *); - void a_writevoid(const struct attrib *a, const void *owner, - struct storage *); - int a_readstring(struct attrib *a, void *owner, struct gamedata *); - void a_writestring(const struct attrib *a, const void *owner, - struct storage *); - void a_finalizestring(struct attrib *a); - void create_backup(char *file); int write_game(struct gamedata *data); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index f43ef53bc..28e95b941 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -34,7 +34,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "region.h" #include "spell.h" #include "spellbook.h" -#include "save.h" #include "ship.h" #include "skill.h" #include "terrain.h" diff --git a/src/laws.c b/src/laws.c index de87afeb1..0838ba6a2 100644 --- a/src/laws.c +++ b/src/laws.c @@ -57,7 +57,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include diff --git a/src/modules/arena.c b/src/modules/arena.c index d2b67d9af..a912d273a 100644 --- a/src/modules/arena.c +++ b/src/modules/arena.c @@ -38,7 +38,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include diff --git a/src/move.c b/src/move.c index e7148a521..0888b6fde 100644 --- a/src/move.c +++ b/src/move.c @@ -44,7 +44,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include diff --git a/src/report.c b/src/report.c index d41d567d7..23dcadb34 100644 --- a/src/report.c +++ b/src/report.c @@ -63,7 +63,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include @@ -85,6 +84,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include /* libc includes */ #include @@ -133,11 +133,11 @@ static char *gamedate_season(const struct locale *lang) return buf; } -void newline(stream *out) { +void newline(struct stream *out) { sputs("", out); } -void write_spaces(stream *out, size_t num) { +void write_spaces(struct stream *out, size_t num) { static const char spaces[REPORTWIDTH] = " "; while (num > 0) { size_t bytes = (num > REPORTWIDTH) ? REPORTWIDTH : num; @@ -146,7 +146,7 @@ void write_spaces(stream *out, size_t num) { } } -static void centre(stream *out, const char *s, bool breaking) +static void centre(struct stream *out, const char *s, bool breaking) { /* Bei Namen die genau 80 Zeichen lang sind, kann es hier Probleme * geben. Seltsamerweise wird i dann auf MAXINT oder aehnlich @@ -170,7 +170,7 @@ static void centre(stream *out, const char *s, bool breaking) } static void -paragraph(stream *out, const char *str, ptrdiff_t indent, int hanging_indent, +paragraph(struct stream *out, const char *str, ptrdiff_t indent, int hanging_indent, char marker) { size_t length = REPORTWIDTH; @@ -248,7 +248,7 @@ static size_t write_spell_modifier(spell * sp, int flag, const char * str, bool return 0; } -void nr_spell_syntax(stream *out, spellbook_entry * sbe, const struct locale *lang) +void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct locale *lang) { int bytes; char buf[4096]; @@ -436,7 +436,7 @@ void nr_spell_syntax(stream *out, spellbook_entry * sbe, const struct locale *la } -void nr_spell(stream *out, spellbook_entry * sbe, const struct locale *lang) +void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *lang) { int bytes, k, itemanz, costtyp; char buf[4096]; @@ -554,7 +554,7 @@ void nr_spell(stream *out, spellbook_entry * sbe, const struct locale *lang) } static void -nr_curses_i(stream *out, int indent, const faction *viewer, objtype_t typ, const void *obj, attrib *a, int self) +nr_curses_i(struct stream *out, int indent, const faction *viewer, objtype_t typ, const void *obj, attrib *a, int self) { for (; a; a = a->next) { char buf[4096]; @@ -582,7 +582,7 @@ nr_curses_i(stream *out, int indent, const faction *viewer, objtype_t typ, const } } -static void nr_curses(stream *out, int indent, const faction *viewer, objtype_t typ, const void *obj) +static void nr_curses(struct stream *out, int indent, const faction *viewer, objtype_t typ, const void *obj) { int self = 0; attrib *a = NULL; @@ -652,7 +652,7 @@ static void nr_curses(stream *out, int indent, const faction *viewer, objtype_t nr_curses_i(out, indent, viewer, typ, obj, a, self); } -static void rps_nowrap(stream *out, const char *s) +static void rps_nowrap(struct stream *out, const char *s) { const char *x = s; size_t indent = 0; @@ -675,7 +675,7 @@ static void rps_nowrap(stream *out, const char *s) } static void -nr_unit(stream *out, const faction * f, const unit * u, int indent, seen_mode mode) +nr_unit(struct stream *out, const faction * f, const unit * u, int indent, seen_mode mode) { attrib *a_otherfaction; char marker; @@ -717,7 +717,7 @@ nr_unit(stream *out, const faction * f, const unit * u, int indent, seen_mode mo } static void -rp_messages(stream *out, message_list * msgs, faction * viewer, int indent, +rp_messages(struct stream *out, message_list * msgs, faction * viewer, int indent, bool categorized) { nrsection *section; @@ -753,7 +753,7 @@ rp_messages(stream *out, message_list * msgs, faction * viewer, int indent, } } -static void rp_battles(stream *out, faction * f) +static void rp_battles(struct stream *out, faction * f) { if (f->battles != NULL) { struct bmsg *bm = f->battles; @@ -773,7 +773,7 @@ static void rp_battles(stream *out, faction * f) } } -static void prices(stream *out, const region * r, const faction * f) +static void prices(struct stream *out, const region * r, const faction * f) { const luxury_type *sale = NULL; struct demand *dmd; @@ -875,7 +875,7 @@ bool see_border(const connection * b, const faction * f, const region * r) return cs; } -static void describe(stream *out, const region * r, faction * f) +static void describe(struct stream *out, const region * r, faction * f) { int n; bool dh; @@ -1268,7 +1268,7 @@ static void describe(stream *out, const region * r, faction * f) } } -static void statistics(stream *out, const region * r, const faction * f) +static void statistics(struct stream *out, const region * r, const faction * f) { const unit *u; int number = 0, p = rpeasants(r); @@ -1620,7 +1620,7 @@ show_allies(const faction * f, const ally * allies, char *buf, size_t size) *bufp = 0; } -static void allies(stream *out, const faction * f) +static void allies(struct stream *out, const faction * f) { const group *g = f->groups; char buf[16384]; @@ -1649,7 +1649,7 @@ static void allies(stream *out, const faction * f) } } -static void guards(stream *out, const region * r, const faction * see) +static void guards(struct stream *out, const region * r, const faction * see) { /* die Partei see sieht dies; wegen * "unbekannte Partei", wenn man es selbst ist... */ @@ -1722,7 +1722,7 @@ static void guards(stream *out, const region * r, const faction * see) } } -static void rpline(stream *out) +static void rpline(struct stream *out) { static char line[REPORTWIDTH + 1]; if (line[0] != '-') { @@ -1732,7 +1732,7 @@ static void rpline(stream *out) swrite(line, sizeof(char), sizeof(line), out); } -static void list_address(stream *out, const faction * uf, quicklist * seenfactions) +static void list_address(struct stream *out, const faction * uf, quicklist * seenfactions) { int qi = 0; quicklist *flist = seenfactions; @@ -1763,7 +1763,7 @@ static void list_address(stream *out, const faction * uf, quicklist * seenfactio } static void -nr_ship(stream *out, const region *r, const ship * sh, const faction * f, +nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, const unit * captain) { char buffer[8192], *bufp = buffer; @@ -1836,7 +1836,7 @@ nr_ship(stream *out, const region *r, const ship * sh, const faction * f, } static void -nr_building(stream *out, const region *r, const building *b, const faction *f) +nr_building(struct stream *out, const region *r, const building *b, const faction *f) { int i, bytes; const char *name, *bname, *billusion = NULL; @@ -1908,7 +1908,7 @@ nr_building(stream *out, const region *r, const building *b, const faction *f) } } -static void nr_paragraph(stream *out, message * m, faction * f) +static void nr_paragraph(struct stream *out, message * m, faction * f) { int bytes; char buf[4096], *bufp = buf; @@ -1924,14 +1924,14 @@ static void nr_paragraph(stream *out, message * m, faction * f) } typedef struct cb_data { - stream *out; + struct stream *out; char *start, *writep; size_t size; const faction *f; int maxtravel, counter; } cb_data; -static void init_cb(cb_data *data, stream *out, char *buffer, size_t size, const faction *f) { +static void init_cb(cb_data *data, struct stream *out, char *buffer, size_t size, const faction *f) { data->out = out; data->writep = buffer; data->start = buffer; @@ -1996,7 +1996,7 @@ static void cb_write_travelthru(region *r, unit *u, void *cbdata) { } } -void write_travelthru(stream *out, region *r, const faction *f) +void write_travelthru(struct stream *out, region *r, const faction *f) { int maxtravel; char buf[8192]; diff --git a/src/spells.c b/src/spells.c index 46eda80bd..44bd07dec 100644 --- a/src/spells.c +++ b/src/spells.c @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -109,7 +108,7 @@ static double zero_effect = 0.0; attrib_type at_wdwpyramid = { - "wdwpyramid", NULL, NULL, NULL, a_writevoid, a_readvoid + "wdwpyramid", NULL, NULL, NULL, NULL, NULL }; /* ----------------------------------------------------------------------- */ diff --git a/src/spells/borders.c b/src/spells/borders.c index 474d37796..04f7e15f4 100644 --- a/src/spells/borders.c +++ b/src/spells/borders.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/src/summary.c b/src/summary.c index d28b75202..8e9dea65d 100644 --- a/src/summary.c +++ b/src/summary.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/src/triggers/changefaction.c b/src/triggers/changefaction.c index 13785dfb9..218a8461f 100644 --- a/src/triggers/changefaction.c +++ b/src/triggers/changefaction.c @@ -22,7 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* kernel includes */ #include -#include #include /* util includes */ diff --git a/src/util/attrib.c b/src/util/attrib.c index e6392aeeb..5e158f263 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -29,6 +29,88 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +int a_readint(attrib * a, void *owner, struct gamedata *data) +{ + int n; + READ_INT(data->store, &n); + if (a) a->data.i = n; + return AT_READ_OK; +} + +void a_writeint(const attrib * a, const void *owner, struct storage *store) +{ + WRITE_INT(store, a->data.i); +} + +int a_readshorts(attrib * a, void *owner, struct gamedata *data) +{ + int n; + READ_INT(data->store, &n); + a->data.sa[0] = (short)n; + READ_INT(data->store, &n); + a->data.sa[1] = (short)n; + return AT_READ_OK; +} + +void a_writeshorts(const attrib * a, const void *owner, struct storage *store) +{ + WRITE_INT(store, a->data.sa[0]); + WRITE_INT(store, a->data.sa[1]); +} + +int a_readchars(attrib * a, void *owner, struct gamedata *data) +{ + int i; + for (i = 0; i != 4; ++i) { + int n; + READ_INT(data->store, &n); + a->data.ca[i] = (char)n; + } + return AT_READ_OK; +} + +void a_writechars(const attrib * a, const void *owner, struct storage *store) +{ + int i; + + for (i = 0; i != 4; ++i) { + WRITE_INT(store, a->data.ca[i]); + } +} + +#define DISPLAYSIZE 8192 +int a_readstring(attrib * a, void *owner, struct gamedata *data) +{ + char buf[DISPLAYSIZE]; + char * result = 0; + int e; + size_t len = 0; + do { + e = READ_STR(data->store, buf, sizeof(buf)); + if (result) { + result = realloc(result, len + DISPLAYSIZE - 1); + strcpy(result + len, buf); + len += DISPLAYSIZE - 1; + } + else { + result = _strdup(buf); + } + } while (e == ENOMEM); + a->data.v = result; + return AT_READ_OK; +} + +void a_writestring(const attrib * a, const void *owner, struct storage *store) +{ + assert(a->data.v); + WRITE_STR(store, (const char *)a->data.v); +} + +void a_finalizestring(attrib * a) +{ + free(a->data.v); +} + #define MAXATHASH 61 static attrib_type *at_hash[MAXATHASH]; diff --git a/src/util/attrib.h b/src/util/attrib.h index b9378ab55..8b7a00e6a 100644 --- a/src/util/attrib.h +++ b/src/util/attrib.h @@ -81,6 +81,20 @@ extern "C" { int a_read(struct gamedata *data, attrib ** attribs, void *owner); void a_write(struct storage *store, const attrib * attribs, const void *owner); + int a_readint(struct attrib *a, void *owner, struct gamedata *); + void a_writeint(const struct attrib *a, const void *owner, + struct storage *store); + int a_readshorts(struct attrib *a, void *owner, struct gamedata *); + void a_writeshorts(const struct attrib *a, const void *owner, + struct storage *store); + int a_readchars(struct attrib *a, void *owner, struct gamedata *); + void a_writechars(const struct attrib *a, const void *owner, + struct storage *store); + int a_readstring(struct attrib *a, void *owner, struct gamedata *); + void a_writestring(const struct attrib *a, const void *owner, + struct storage *); + void a_finalizestring(struct attrib *a); + void attrib_done(void); #define DEFAULT_AGE NULL diff --git a/src/util/attrib.test.c b/src/util/attrib.test.c index 0f189015a..1d79bd6b8 100644 --- a/src/util/attrib.test.c +++ b/src/util/attrib.test.c @@ -1,6 +1,10 @@ #include #include "attrib.h" +#include + +#include +#include #include #include @@ -16,7 +20,6 @@ static void test_attrib_new(CuTest * tc) CuAssertPtrEquals(tc, 0, a); } - static void test_attrib_add(CuTest * tc) { attrib_type at_foo = { "foo" }; @@ -52,7 +55,6 @@ static void test_attrib_remove_self(CuTest * tc) { a_removeall(&alist, NULL); } - static void test_attrib_removeall(CuTest * tc) { const attrib_type at_foo = { "foo" }; const attrib_type at_bar = { "bar" }; @@ -110,6 +112,86 @@ static void test_attrib_nexttype(CuTest * tc) a_removeall(&alist, &at_bar); } +static void test_attrib_rwstring(CuTest *tc) { + gamedata data; + storage store; + attrib a = { 0 }; + + test_setup(); + a.data.v = _strdup("Hello World"); + mstream_init(&data.strm); + gamedata_init(&data, &store, RELEASE_VERSION); + a_writestring(&a, NULL, &store); + a_finalizestring(&a); + data.strm.api->rewind(data.strm.handle); + a_readstring(&a, NULL, &data); + CuAssertStrEquals(tc, "Hello World", (const char *)a.data.v); + mstream_done(&data.strm); + gamedata_done(&data); + test_cleanup(); +} + +static void test_attrib_rwint(CuTest *tc) { + gamedata data; + storage store; + attrib a = { 0 }; + + test_setup(); + a.data.i = 42; + mstream_init(&data.strm); + gamedata_init(&data, &store, RELEASE_VERSION); + a_writeint(&a, NULL, &store); + a.data.i = 0; + data.strm.api->rewind(data.strm.handle); + a_readint(&a, NULL, &data); + CuAssertIntEquals(tc, 42, a.data.i); + mstream_done(&data.strm); + gamedata_done(&data); + test_cleanup(); +} + +static void test_attrib_rwchars(CuTest *tc) { + gamedata data; + storage store; + attrib a = { 0 }; + + test_setup(); + a.data.ca[0] = 1; + a.data.ca[3] = 42; + mstream_init(&data.strm); + gamedata_init(&data, &store, RELEASE_VERSION); + a_writeint(&a, NULL, &store); + memset(a.data.ca, 42, 0); + data.strm.api->rewind(data.strm.handle); + a_readint(&a, NULL, &data); + CuAssertIntEquals(tc, 1, a.data.ca[0]); + CuAssertIntEquals(tc, 42, a.data.ca[3]); + mstream_done(&data.strm); + gamedata_done(&data); + test_cleanup(); +} + +static void test_attrib_rwshorts(CuTest *tc) { + gamedata data; + storage store; + attrib a = { 0 }; + a.data.sa[0] = -4; + a.data.sa[1] = 42; + + test_setup(); + mstream_init(&data.strm); + gamedata_init(&data, &store, RELEASE_VERSION); + a_writeint(&a, NULL, &store); + memset(a.data.ca, 42, 0); + data.strm.api->rewind(data.strm.handle); + a_readint(&a, NULL, &data); + CuAssertIntEquals(tc, -4, a.data.sa[0]); + CuAssertIntEquals(tc, 42, a.data.sa[1]); + mstream_done(&data.strm); + gamedata_done(&data); + test_cleanup(); +} + CuSuite *get_attrib_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -119,5 +201,9 @@ CuSuite *get_attrib_suite(void) SUITE_ADD_TEST(suite, test_attrib_removeall); SUITE_ADD_TEST(suite, test_attrib_remove_self); SUITE_ADD_TEST(suite, test_attrib_nexttype); + SUITE_ADD_TEST(suite, test_attrib_rwstring); + SUITE_ADD_TEST(suite, test_attrib_rwint); + SUITE_ADD_TEST(suite, test_attrib_rwchars); + SUITE_ADD_TEST(suite, test_attrib_rwshorts); return suite; } From 0eaa750ef4d6af7cd40d1bd1abb0e42f490082ab Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 19:47:36 +0100 Subject: [PATCH 211/675] move read/write_attribs to attrib.h, too --- src/guard.c | 1 - src/kernel/save.c | 30 ------------------------------ src/kernel/save.h | 3 --- src/util/attrib.c | 30 ++++++++++++++++++++++++++++++ src/util/attrib.h | 3 +++ 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/guard.c b/src/guard.c index adacd1bf6..ee26e467b 100644 --- a/src/guard.c +++ b/src/guard.c @@ -24,7 +24,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "monster.h" #include -#include #include #include #include diff --git a/src/kernel/save.c b/src/kernel/save.c index 4a1b7897e..80b8becc9 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -670,36 +670,6 @@ writeorder(struct gamedata *data, const struct order *ord, WRITE_STR(data->store, obuf); } -int read_attribs(gamedata *data, attrib **alist, void *owner) { - int result; - if (data->version < ATHASH_VERSION) { - result = a_read_orig(data, alist, owner); - } - else { - result = a_read(data, alist, owner); - } - if (result == AT_READ_DEPR) { - /* handle deprecated attributes */ - attrib *a = *alist; - while (a) { - if (a->type->upgrade) { - a->type->upgrade(alist, a); - } - a = a->nexttype; - } - } - return result; -} - -void write_attribs(storage *store, attrib *alist, const void *owner) -{ -#if RELEASE_VERSION < ATHASH_VERSION - a_write_orig(store, alist, owner); -#else - a_write(store, alist, owner); -#endif -} - unit *read_unit(struct gamedata *data) { unit *u; diff --git a/src/kernel/save.h b/src/kernel/save.h index aa11ac1ad..883df6ea8 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -56,9 +56,6 @@ extern "C" { void read_spellbook(struct spellbook **bookp, struct gamedata *data, int(*get_level)(const struct spell * sp, void *), void * cbdata); void write_spellbook(const struct spellbook *book, struct storage *store); - void write_attribs(struct storage *store, struct attrib *alist, const void *owner); - int read_attribs(struct gamedata *store, struct attrib **alist, void *owner); - void write_unit(struct gamedata *data, const struct unit *u); struct unit *read_unit(struct gamedata *data); diff --git a/src/util/attrib.c b/src/util/attrib.c index 5e158f263..6b39b56ae 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -29,6 +29,36 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +int read_attribs(gamedata *data, attrib **alist, void *owner) { + int result; + if (data->version < ATHASH_VERSION) { + result = a_read_orig(data, alist, owner); + } + else { + result = a_read(data, alist, owner); + } + if (result == AT_READ_DEPR) { + /* handle deprecated attributes */ + attrib *a = *alist; + while (a) { + if (a->type->upgrade) { + a->type->upgrade(alist, a); + } + a = a->nexttype; + } + } + return result; +} + +void write_attribs(storage *store, attrib *alist, const void *owner) +{ +#if RELEASE_VERSION < ATHASH_VERSION + a_write_orig(store, alist, owner); +#else + a_write(store, alist, owner); +#endif +} + int a_readint(attrib * a, void *owner, struct gamedata *data) { int n; diff --git a/src/util/attrib.h b/src/util/attrib.h index 8b7a00e6a..d93ce1240 100644 --- a/src/util/attrib.h +++ b/src/util/attrib.h @@ -66,6 +66,9 @@ extern "C" { extern void at_register(attrib_type * at); extern void at_deprecate(const char * name, int(*reader)(attrib *, void *, struct gamedata *)); + void write_attribs(struct storage *store, struct attrib *alist, const void *owner); + int read_attribs(struct gamedata *store, struct attrib **alist, void *owner); + extern attrib *a_select(attrib * a, const void *data, bool(*compare) (const attrib *, const void *)); extern attrib *a_find(attrib * a, const attrib_type * at); From 3cc719ba938a305cc44070427774551d4092d75a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 13 Nov 2016 19:51:41 +0100 Subject: [PATCH 212/675] fix gcc build --- src/util/attrib.c | 1 + src/util/attrib.test.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/util/attrib.c b/src/util/attrib.c index 6b39b56ae..4bdf35bfa 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -28,6 +28,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include int read_attribs(gamedata *data, attrib **alist, void *owner) { int result; diff --git a/src/util/attrib.test.c b/src/util/attrib.test.c index 1d79bd6b8..31c8a2d0d 100644 --- a/src/util/attrib.test.c +++ b/src/util/attrib.test.c @@ -7,6 +7,7 @@ #include #include #include +#include static void test_attrib_new(CuTest * tc) { From d28d3f4690ae1ac388612417da09cc049af1d963 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 01:00:48 +0100 Subject: [PATCH 213/675] move read/write_items to item.c. fix bad memset in attrib.test.c. --- src/kernel/item.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/kernel/item.h | 5 +++++ src/kernel/save.c | 40 ---------------------------------------- src/kernel/save.h | 3 --- src/modules/museum.c | 1 - src/util/attrib.test.c | 4 ++-- 6 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/kernel/item.c b/src/kernel/item.c index 64d01bce0..f9234368c 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -51,6 +51,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include + /* libc includes */ #include #include @@ -1189,6 +1191,46 @@ static item *default_spoil(const struct race *rc, int size) return itm; } +void read_items(struct storage *store, item ** ilist) +{ + for (;;) { + char ibuf[32]; + const item_type *itype; + int i; + READ_STR(store, ibuf, sizeof(ibuf)); + if (!strcmp("end", ibuf)) { + break; + } + itype = it_find(ibuf); + READ_INT(store, &i); + if (i <= 0) { + log_error("data contains an entry with %d %s", i, resourcename(itype->rtype, NMF_PLURAL)); + } + else { + if (itype && itype->rtype) { + i_change(ilist, itype, i); + } + else { + log_error("data contains unknown item type %s.", ibuf); + } + assert(itype && itype->rtype); + } + } +} + +void write_items(struct storage *store, item * ilist) +{ + item *itm; + for (itm = ilist; itm; itm = itm->next) { + assert(itm->number >= 0); + if (itm->number) { + WRITE_TOK(store, resourcename(itm->type->rtype, 0)); + WRITE_INT(store, itm->number); + } + } + WRITE_TOK(store, "end"); +} + static void free_itype(item_type *itype) { assert(itype); free(itype->construction); diff --git a/src/kernel/item.h b/src/kernel/item.h index 26231fa2e..c32f38057 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -35,6 +35,8 @@ extern "C" { struct troop; struct item; struct order; + struct storage; + struct gamedata; typedef struct item { struct item *next; @@ -247,6 +249,9 @@ extern "C" { void i_freeall(item ** i); item *i_new(const item_type * it, int number); + void read_items(struct storage *store, struct item **it); + void write_items(struct storage *store, struct item *it); + /* convenience: */ item *i_change(item ** items, const item_type * it, int delta); int i_get(const item * i, const item_type * it); diff --git a/src/kernel/save.c b/src/kernel/save.c index 80b8becc9..cefbf3cc5 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -394,33 +394,6 @@ void create_backup(char *file) #endif } -void read_items(struct storage *store, item ** ilist) -{ - for (;;) { - char ibuf[32]; - const item_type *itype; - int i; - READ_STR(store, ibuf, sizeof(ibuf)); - if (!strcmp("end", ibuf)) { - break; - } - itype = it_find(ibuf); - READ_INT(store, &i); - if (i <= 0) { - log_error("data contains an entry with %d %s", i, resourcename(itype->rtype, NMF_PLURAL)); - } - else { - if (itype && itype->rtype) { - i_change(ilist, itype, i); - } - else { - log_error("data contains unknown item type %s.", ibuf); - } - assert(itype && itype->rtype); - } - } -} - static void read_alliances(struct gamedata *data) { storage *store = data->store; @@ -553,19 +526,6 @@ void write_alliances(struct gamedata *data) WRITE_SECTION(data->store); } -void write_items(struct storage *store, item * ilist) -{ - item *itm; - for (itm = ilist; itm; itm = itm->next) { - assert(itm->number >= 0); - if (itm->number) { - WRITE_TOK(store, resourcename(itm->type->rtype, 0)); - WRITE_INT(store, itm->number); - } - } - WRITE_TOK(store, "end"); -} - static int resolve_owner(variant id, void *address) { region_owner *owner = (region_owner *)address; diff --git a/src/kernel/save.h b/src/kernel/save.h index 883df6ea8..4d310310c 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -50,9 +50,6 @@ extern "C" { int current_turn(void); - void read_items(struct storage *store, struct item **it); - void write_items(struct storage *store, struct item *it); - void read_spellbook(struct spellbook **bookp, struct gamedata *data, int(*get_level)(const struct spell * sp, void *), void * cbdata); void write_spellbook(const struct spellbook *book, struct storage *store); diff --git a/src/modules/museum.c b/src/modules/museum.c index 5ad9092a4..e934a71a4 100644 --- a/src/modules/museum.c +++ b/src/modules/museum.c @@ -32,7 +32,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include diff --git a/src/util/attrib.test.c b/src/util/attrib.test.c index 31c8a2d0d..7fa2ef82c 100644 --- a/src/util/attrib.test.c +++ b/src/util/attrib.test.c @@ -162,7 +162,7 @@ static void test_attrib_rwchars(CuTest *tc) { mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); a_writeint(&a, NULL, &store); - memset(a.data.ca, 42, 0); + memset(a.data.ca, 0, 4); data.strm.api->rewind(data.strm.handle); a_readint(&a, NULL, &data); CuAssertIntEquals(tc, 1, a.data.ca[0]); @@ -183,7 +183,7 @@ static void test_attrib_rwshorts(CuTest *tc) { mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); a_writeint(&a, NULL, &store); - memset(a.data.ca, 42, 0); + memset(a.data.ca, 0, 4); data.strm.api->rewind(data.strm.handle); a_readint(&a, NULL, &data); CuAssertIntEquals(tc, -4, a.data.sa[0]); From d0b4f162135906e20e9b4bbd2a82e91299892ca5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 01:05:10 +0100 Subject: [PATCH 214/675] reduce item.h include dependencies --- src/kernel/alliance.c | 1 - src/kernel/skills.c | 1 - 2 files changed, 2 deletions(-) diff --git a/src/kernel/alliance.c b/src/kernel/alliance.c index 7a65c4db5..36d054323 100644 --- a/src/kernel/alliance.c +++ b/src/kernel/alliance.c @@ -23,7 +23,6 @@ without prior permission by the authors of Eressea. #include #include #include -#include #include /* util includes */ diff --git a/src/kernel/skills.c b/src/kernel/skills.c index 17e1194c1..488800115 100644 --- a/src/kernel/skills.c +++ b/src/kernel/skills.c @@ -21,7 +21,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "skill.h" #include "curse.h" -#include "item.h" #include "race.h" #include "region.h" #include "terrain.h" From 0472ac761ea132c228da41b3bdecce4edc228b28 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 01:22:50 +0100 Subject: [PATCH 215/675] declutter save.h (items, spellbooks) --- src/kernel/save.c | 50 --------------------------------------- src/kernel/save.h | 3 --- src/kernel/spellbook.c | 53 ++++++++++++++++++++++++++++++++++++++++++ src/kernel/spellbook.h | 5 ++++ 4 files changed, 58 insertions(+), 53 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index cefbf3cc5..143912832 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1194,56 +1194,6 @@ int get_spell_level_faction(const spell * sp, void * cbdata) return 0; } -void read_spellbook(spellbook **bookp, gamedata *data, int(*get_level)(const spell * sp, void *), void * cbdata) -{ - for (;;) { - spell *sp = 0; - char spname[64]; - int level = 0; - - READ_TOK(data->store, spname, sizeof(spname)); - if (strcmp(spname, "end") == 0) - break; - if (bookp) { - sp = find_spell(spname); - if (!sp) { - log_error("read_spells: could not find spell '%s'", spname); - } - } - if (data->version >= SPELLBOOK_VERSION) { - READ_INT(data->store, &level); - } - if (sp) { - spellbook * sb = *bookp; - if (level <= 0 && get_level) { - level = get_level(sp, cbdata); - } - if (!sb) { - *bookp = create_spellbook(0); - sb = *bookp; - } - if (level > 0 && (data->version >= SPELLBOOK_VERSION || !spellbook_get(sb, sp))) { - spellbook_add(sb, sp, level); - } - } - } -} - -void write_spellbook(const struct spellbook *book, struct storage *store) -{ - quicklist *ql; - int qi; - - if (book) { - for (ql = book->spells, qi = 0; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi); - WRITE_TOK(store, sbe->sp->sname); - WRITE_INT(store, sbe->level); - } - } - WRITE_TOK(store, "end"); -} - static char * getpasswd(int fno) { const char *prefix = itoa36(fno); size_t len = strlen(prefix); diff --git a/src/kernel/save.h b/src/kernel/save.h index 4d310310c..acaf74a3b 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -50,9 +50,6 @@ extern "C" { int current_turn(void); - void read_spellbook(struct spellbook **bookp, struct gamedata *data, int(*get_level)(const struct spell * sp, void *), void * cbdata); - void write_spellbook(const struct spellbook *book, struct storage *store); - void write_unit(struct gamedata *data, const struct unit *u); struct unit *read_unit(struct gamedata *data); diff --git a/src/kernel/spellbook.c b/src/kernel/spellbook.c index 96410170b..da8fcd563 100644 --- a/src/kernel/spellbook.c +++ b/src/kernel/spellbook.c @@ -3,9 +3,12 @@ #include #include #include +#include #include "spellbook.h" +#include + #include #include #include @@ -18,6 +21,56 @@ spellbook * create_spellbook(const char * name) return result; } +void read_spellbook(spellbook **bookp, gamedata *data, int(*get_level)(const spell * sp, void *), void * cbdata) +{ + for (;;) { + spell *sp = 0; + char spname[64]; + int level = 0; + + READ_TOK(data->store, spname, sizeof(spname)); + if (strcmp(spname, "end") == 0) + break; + if (bookp) { + sp = find_spell(spname); + if (!sp) { + log_error("read_spells: could not find spell '%s'", spname); + } + } + if (data->version >= SPELLBOOK_VERSION) { + READ_INT(data->store, &level); + } + if (sp) { + spellbook * sb = *bookp; + if (level <= 0 && get_level) { + level = get_level(sp, cbdata); + } + if (!sb) { + *bookp = create_spellbook(0); + sb = *bookp; + } + if (level > 0 && (data->version >= SPELLBOOK_VERSION || !spellbook_get(sb, sp))) { + spellbook_add(sb, sp, level); + } + } + } +} + +void write_spellbook(const struct spellbook *book, struct storage *store) +{ + quicklist *ql; + int qi; + + if (book) { + for (ql = book->spells, qi = 0; ql; ql_advance(&ql, &qi, 1)) { + spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi); + WRITE_TOK(store, sbe->sp->sname); + WRITE_INT(store, sbe->level); + } + } + WRITE_TOK(store, "end"); +} + void spellbook_add(spellbook *sb, struct spell * sp, int level) { spellbook_entry * sbe; diff --git a/src/kernel/spellbook.h b/src/kernel/spellbook.h index d0e25da23..84ec0ce5f 100644 --- a/src/kernel/spellbook.h +++ b/src/kernel/spellbook.h @@ -24,6 +24,8 @@ extern "C" { #endif struct spell; + struct storage; + struct gamedata; struct quicklist; typedef struct spellbook_entry { @@ -39,6 +41,9 @@ extern "C" { spellbook * create_spellbook(const char * name); + void read_spellbook(struct spellbook **bookp, struct gamedata *data, int(*get_level)(const struct spell * sp, void *), void * cbdata); + void write_spellbook(const struct spellbook *book, struct storage *store); + void spellbook_add(spellbook *sbp, struct spell * sp, int level); int spellbook_foreach(spellbook *sb, int(*callback)(spellbook_entry *, void *), void * data); void spellbook_clear(spellbook *sb); From 2b07ae810c570aca6ef0f9d7e7e4593268707944 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 01:23:41 +0100 Subject: [PATCH 216/675] kil xmlreport files. remove unnecessary includes. --- src/kernel/connection.c | 1 - src/kernel/group.c | 1 - src/magic.c | 1 - src/modules/gmcmd.c | 1 - src/xmlreport.c | 800 ---------------------------------------- src/xmlreport.h | 26 -- 6 files changed, 830 deletions(-) delete mode 100644 src/xmlreport.c delete mode 100644 src/xmlreport.h diff --git a/src/kernel/connection.c b/src/kernel/connection.c index 9bbff5778..f10fbc53d 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -21,7 +21,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "connection.h" #include "region.h" -#include "save.h" #include "terrain.h" #include "unit.h" diff --git a/src/kernel/group.c b/src/kernel/group.c index 054cf44dc..8753531a3 100755 --- a/src/kernel/group.c +++ b/src/kernel/group.c @@ -23,7 +23,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* kernel includes */ #include "ally.h" #include "faction.h" -#include "save.h" #include "unit.h" /* attrib includes */ diff --git a/src/magic.c b/src/magic.c index 3f1008cc4..1ac2255c1 100644 --- a/src/magic.c +++ b/src/magic.c @@ -38,7 +38,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include diff --git a/src/modules/gmcmd.c b/src/modules/gmcmd.c index b9e1bc342..810867a21 100644 --- a/src/modules/gmcmd.c +++ b/src/modules/gmcmd.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include diff --git a/src/xmlreport.c b/src/xmlreport.c deleted file mode 100644 index fd2b5e464..000000000 --- a/src/xmlreport.c +++ /dev/null @@ -1,800 +0,0 @@ -/* -+-------------------+ Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -+-------------------+ -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - -#include -#include -#include "xmlreport.h" - -#define XML_ATL_NAMESPACE (const xmlChar *) "http://www.eressea.de/XML/2008/atlantis" -#define XML_XML_LANG (const xmlChar *) "lang" - -/* modules include */ -#include - -/* attributes include */ -#include -#include -#include -#include -#include - -/* gamecode includes */ -#include "laws.h" -#include "economy.h" -#include "move.h" - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* util includes */ -#include -#include -#include -#include -#include -#include -#include - -#ifdef USE_LIBXML2 -/* libxml2 includes */ -#include -#include -#ifdef USE_ICONV -#include -#endif -#endif - -/* libc includes */ -#include -#include -#include -#include -#include -#include - -#define L10N(x) x - -typedef struct xml_context { - xmlDocPtr doc; - xmlNsPtr ns_atl; - xmlNsPtr ns_xml; -} xml_context; - -static xmlNodePtr -xml_link(report_context * ctx, const xmlChar * rel, const xmlChar * ref) -{ - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr node = xmlNewNode(xct->ns_atl, BAD_CAST "link"); - - xmlNewNsProp(node, xct->ns_atl, BAD_CAST "rel", rel); - xmlNewNsProp(node, xct->ns_atl, BAD_CAST "ref", ref); - - return node; -} - -static const xmlChar *xml_ref_unit(const unit * u) -{ - static char idbuf[20]; - _snprintf(idbuf, sizeof(idbuf), "unit_%d", u->no); - return (const xmlChar *)idbuf; -} - -static const xmlChar *xml_ref_faction(const faction * f) -{ - static char idbuf[20]; - _snprintf(idbuf, sizeof(idbuf), "fctn_%d", f->no); - return (const xmlChar *)idbuf; -} - -static const xmlChar *xml_ref_group(const group * g) -{ - static char idbuf[20]; - _snprintf(idbuf, sizeof(idbuf), "grp_%d", g->gid); - return (const xmlChar *)idbuf; -} - -static const xmlChar *xml_ref_prefix(const char *str) -{ - static char idbuf[20]; - _snprintf(idbuf, sizeof(idbuf), "pref_%s", str); - return (const xmlChar *)idbuf; -} - -static const xmlChar *xml_ref_building(const building * b) -{ - static char idbuf[20]; - _snprintf(idbuf, sizeof(idbuf), "bldg_%d", b->no); - return (const xmlChar *)idbuf; -} - -static const xmlChar *xml_ref_ship(const ship * sh) -{ - static char idbuf[20]; - _snprintf(idbuf, sizeof(idbuf), "shp_%d", sh->no); - return (const xmlChar *)idbuf; -} - -static const xmlChar *xml_ref_region(const region * r) -{ - static char idbuf[20]; - _snprintf(idbuf, sizeof(idbuf), "rgn_%d", r->uid); - return (const xmlChar *)idbuf; -} - -static xmlNodePtr xml_inventory(report_context * ctx, item * items, unit * u) -{ - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr node = xmlNewNode(xct->ns_atl, BAD_CAST "items"); - item *itm; - - for (itm = items; itm; itm = itm->next) { - xmlNodePtr child; - const char *name; - int n; - - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "item")); - report_item(u, itm, ctx->f, NULL, &name, &n, true); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", (xmlChar *) name); - xmlNodeAddContent(child, (xmlChar *) itoab(n, 10)); - } - return node; -} - -#ifdef TODO /*spellbooks */ -static xmlNodePtr -xml_spells(report_context * ctx, quicklist * slist, int maxlevel) -{ - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr child, node = xmlNewNode(xct->ns_atl, BAD_CAST "spells"); - quicklist *ql; - int qi; - - for (ql = slist, qi = 0; ql; ql_advance(&ql, &qi, 1)) { - spell *sp = (spell *) ql_get(ql, qi); - - if (sp->level <= maxlevel) { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "spell")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "name", BAD_CAST sp->sname); - } - } - return node; -} -#endif - -static xmlNodePtr xml_skills(report_context * ctx, unit * u) -{ - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr child, node = xmlNewNode(xct->ns_atl, BAD_CAST "skills"); - skill *sv; - - for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) { - if (sv->level > 0) { - skill_t sk = sv->id; - int esk = eff_skill(u, sk, u->region); - - child = - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "skill", BAD_CAST itoab(esk, - 10)); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", BAD_CAST skillnames[sk]); - } - } - - return node; -} - -static xmlNodePtr xml_unit(report_context * ctx, unit * u, int mode) -{ - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr node = xmlNewNode(xct->ns_atl, BAD_CAST "unit"); - static const curse_type *itemcloak_ct = 0; - static bool init = false; - xmlNodePtr child; - const char *str, *rcname, *rcillusion; - bool disclosure = (ctx->f == u->faction || omniscient(ctx->f)); - - /* TODO: hitpoints, aura, combatspells, curses */ - - xmlNewNsProp(node, xct->ns_xml, XML_XML_ID, xml_ref_unit(u)); - xmlNewNsProp(node, xct->ns_atl, BAD_CAST "key", BAD_CAST itoa36(u->no)); - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "name", (const xmlChar *)u->name); - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "number", - (const xmlChar *)itoab(u->number, 10)); - - /* optional description */ - str = u_description(u, ctx->f->locale); - if (str) { - child = - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "text", (const xmlChar *)str); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "public"); - if (str != u->display) { - xmlNewNsProp(child, xct->ns_atl, XML_XML_LANG, - BAD_CAST locale_name(ctx->f->locale)); - } - } - - /* possible info */ - if (is_guard(u, GUARD_ALL) != 0) { - xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "guard")); - } - - /* siege */ - if (fval(u, UFL_SIEGE)) { - building *b = usiege(u); - if (b) { - xmlAddChild(node, xml_link(ctx, BAD_CAST "siege", xml_ref_building(b))); - } - } - - /* TODO: temp/alias */ - - /* race information */ - report_race(u, &rcname, &rcillusion); - if (disclosure) { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "race")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "true"); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", (const xmlChar *)rcname); - if (rcillusion) { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "race")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "stealth"); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", - (const xmlChar *)rcillusion); - } - } else { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "race")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", - (const xmlChar *)(rcillusion ? rcillusion : rcname)); - } - - /* group and prefix information. we only write the prefix if we really must */ - if (fval(u, UFL_GROUP)) { - attrib *a = a_find(u->attribs, &at_group); - if (a != NULL) { - const group *g = (const group *)a->data.v; - if (disclosure) { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "group")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", xml_ref_group(g)); - } else { - const char *prefix = get_prefix(g->attribs); - if (prefix) { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "prefix")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", - xml_ref_prefix(prefix)); - } - } - } - } - - if (disclosure) { - unit *mage; - - str = uprivate(u); - if (str) { - child = - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "text", - (const xmlChar *)str); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "private"); - } - - /* familiar info */ - mage = get_familiar_mage(u); - if (mage) - xmlAddChild(node, xml_link(ctx, BAD_CAST "familiar_of", - xml_ref_unit(mage))); - - /* combat status */ - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "status")); - xmlSetNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "combat"); - xmlSetNsProp(child, xct->ns_atl, BAD_CAST "value", - BAD_CAST combatstatus[u->status]); - - if (fval(u, UFL_NOAID)) { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "status")); - xmlSetNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "aid"); - xmlSetNsProp(child, xct->ns_atl, BAD_CAST "value", BAD_CAST "false"); - } - - if (fval(u, UFL_STEALTH)) { - int i = u_geteffstealth(u); - if (i >= 0) { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "status")); - xmlSetNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "stealth"); - xmlSetNsProp(child, xct->ns_atl, BAD_CAST "value", BAD_CAST itoab(i, - 10)); - } - } - if (fval(u, UFL_HERO)) { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "status")); - xmlSetNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "hero"); - xmlSetNsProp(child, xct->ns_atl, BAD_CAST "value", BAD_CAST "true"); - } - - if (fval(u, UFL_HUNGER)) { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "status")); - xmlSetNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "hunger"); - xmlSetNsProp(child, xct->ns_atl, BAD_CAST "value", BAD_CAST "true"); - } - - /* skills */ - if (u->skill_size) { - xmlAddChild(node, xml_skills(ctx, u)); - } - -#ifdef TODO /*spellbooks */ - /* spells */ - if (is_mage(u)) { - sc_mage *mage = get_mage(u); - quicklist *slist = mage->spells; - if (slist) { - xmlAddChild(node, xml_spells(ctx, slist, effskill(u, SK_MAGIC))); - } - } -#endif - } - - /* faction information w/ visibiility */ - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "faction")); - if (disclosure) { - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "true"); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", - xml_ref_faction(u->faction)); - - if (fval(u, UFL_ANON_FACTION)) { - const faction *sf = visible_faction(NULL, u); - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "faction")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "stealth"); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", xml_ref_faction(sf)); - } - } else { - const faction *sf = visible_faction(ctx->f, u); - if (sf == ctx->f) { - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "stealth"); - } - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", xml_ref_faction(sf)); - } - - /* the inventory */ - if (u->items) { - item result[MAX_INVENTORY]; - item *show = NULL; - - if (!init) { - init = true; - itemcloak_ct = ct_find("itemcloak"); - } - - if (disclosure) { - show = u->items; - } else { - bool see_items = (mode >= see_unit); - if (see_items) { - if (itemcloak_ct && curse_active(get_curse(u->attribs, itemcloak_ct))) { - see_items = false; - } else { - see_items = effskill(u, SK_STEALTH) < 3; - } - } - if (see_items) { - int n = report_items(u->items, result, MAX_INVENTORY, u, ctx->f); - assert(n >= 0); - if (n > 0) - show = result; - else - show = NULL; - } else { - show = NULL; - } - } - - if (show) { - xmlAddChild(node, xml_inventory(ctx, show, u)); - } - } - - return node; -} - -static xmlNodePtr xml_resources(report_context * ctx, const seen_region * sr) -{ - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr node = NULL; - resource_report result[MAX_RAWMATERIALS]; - int n, size = report_resources(sr, result, MAX_RAWMATERIALS, ctx->f); - - if (size) { - node = xmlNewNode(xct->ns_atl, BAD_CAST "resources"); - for (n = 0; n < size; ++n) { - if (result[n].number >= 0) { - xmlNodePtr child; - - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "resource")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", - (xmlChar *) result[n].name); - if (result[n].level >= 0) { - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "level", - (xmlChar *) itoab(result[n].level, 10)); - } - xmlNodeAddContent(child, (xmlChar *) itoab(result[n].number, 10)); - } - } - } - return node; -} - -static xmlNodePtr xml_diplomacy(report_context * ctx, const struct ally *allies) -{ - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr child, node = xmlNewNode(xct->ns_atl, BAD_CAST "diplomacy"); - const struct ally *sf; - - for (sf = allies; sf; sf = sf->next) { - int i, status = sf->status; - for (i = 0; helpmodes[i].name; ++i) { - if (sf->faction && (status & helpmodes[i].status) == helpmodes[i].status) { - status -= helpmodes[i].status; - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "status")); - xmlNewNsProp(child, xct->ns_xml, BAD_CAST "faction", - xml_ref_faction(sf->faction)); - xmlNewNsProp(child, xct->ns_xml, BAD_CAST "status", - (xmlChar *) helpmodes[i].name); - } - } - } - return node; -} - -static xmlNodePtr xml_groups(report_context * ctx, const group * groups) -{ - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr child, node = xmlNewNode(xct->ns_atl, BAD_CAST "faction"); - const group *g; - - for (g = groups; g; g = g->next) { - const char *prefix = get_prefix(g->attribs); - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "group")); - xmlNewNsProp(child, xct->ns_xml, XML_XML_ID, xml_ref_group(g)); - xmlNewTextChild(child, xct->ns_atl, BAD_CAST "name", - (const xmlChar *)g->name); - - if (g->allies) - xmlAddChild(child, xml_diplomacy(ctx, g->allies)); - - if (prefix) { - child = xmlAddChild(child, xmlNewNode(xct->ns_atl, BAD_CAST "prefix")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", xml_ref_prefix(prefix)); - } - } - - return node; -} - -static xmlNodePtr xml_faction(report_context * ctx, faction * f) -{ - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr child, node = xmlNewNode(xct->ns_atl, BAD_CAST "faction"); - - /* TODO: alliance, locale */ - - xmlNewNsProp(node, xct->ns_xml, XML_XML_ID, xml_ref_faction(f)); - xmlNewNsProp(node, xct->ns_atl, BAD_CAST "key", BAD_CAST itoa36(f->no)); - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "name", (const xmlChar *)f->name); - if (f->email) - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "email", - (const xmlChar *)f->email); - if (f->banner) { - child = - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "text", - (const xmlChar *)f->banner); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "public"); - } - - if (ctx->f == f) { - xmlAddChild(node, xml_link(ctx, BAD_CAST "race", - BAD_CAST f->race->_name[0])); - - if (f->items) - xmlAddChild(node, xml_inventory(ctx, f->items, NULL)); - if (f->allies) - xmlAddChild(node, xml_diplomacy(ctx, f->allies)); - if (f->groups) - xmlAddChild(node, xml_groups(ctx, f->groups)); - - /* TODO: age, options, score, prefix, magic, immigrants, heroes, nmr, groups */ - } - return node; -} - -static xmlNodePtr -xml_building(report_context * ctx, seen_region * sr, const building * b, - const unit * owner) -{ - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr node = xmlNewNode(xct->ns_atl, BAD_CAST "building"); - xmlNodePtr child; - const char *bname, *billusion; - - xmlNewNsProp(node, xct->ns_xml, XML_XML_ID, xml_ref_building(b)); - xmlNewNsProp(node, xct->ns_atl, BAD_CAST "key", BAD_CAST itoa36(b->no)); - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "name", (const xmlChar *)b->name); - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "size", - (const xmlChar *)itoab(b->size, 10)); - if (b->display && b->display[0]) { - child = - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "text", - (const xmlChar *)b->display); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "public"); - } - if (b->besieged) { - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "siege", - (const xmlChar *)itoab(b->besieged, 10)); - } - if (owner) - xmlAddChild(node, xml_link(ctx, BAD_CAST "owner", xml_ref_unit(owner))); - - report_building(b, &bname, &billusion); - if (owner && owner->faction == ctx->f) { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "type")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "true"); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", (const xmlChar *)bname); - if (billusion) { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "type")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "illusion"); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", - (const xmlChar *)billusion); - } - } else { - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "type")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", - (const xmlChar *)(billusion ? billusion : bname)); - } - - return node; -} - -static xmlNodePtr -xml_ship(report_context * ctx, const seen_region * sr, const ship * sh, - const unit * owner) -{ - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr child, node = xmlNewNode(xct->ns_atl, BAD_CAST "ship"); - - xmlNewNsProp(node, xct->ns_xml, XML_XML_ID, xml_ref_ship(sh)); - xmlNewNsProp(node, xct->ns_atl, BAD_CAST "key", BAD_CAST itoa36(sh->no)); - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "name", - (const xmlChar *)sh->name); - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "size", - (const xmlChar *)itoab(sh->size, 10)); - - if (sh->damage) { - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "damage", - (const xmlChar *)itoab(sh->damage, 10)); - } - - if (fval(sr->r->terrain, SEA_REGION) && sh->coast != NODIRECTION) { - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "coast", - BAD_CAST directions[sh->coast]); - } - - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "type")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", - (const xmlChar *)sh->type->name[0]); - - if (sh->display && sh->display[0]) { - child = - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "text", - (const xmlChar *)sh->display); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "public"); - } - - if (owner) - xmlAddChild(node, xml_link(ctx, BAD_CAST "owner", xml_ref_unit(owner))); - - if ((owner && owner->faction == ctx->f) || omniscient(ctx->f)) { - int n = 0, p = 0; - getshipweight(sh, &n, &p); - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "cargo", - (const xmlChar *)itoab(n, 10)); - } - return node; -} - -static xmlNodePtr xml_region(report_context * ctx, seen_region * sr) -{ - xml_context *xct = (xml_context *) ctx->userdata; - const region *r = sr->r; - xmlNodePtr node = xmlNewNode(xct->ns_atl, BAD_CAST "region"); - xmlNodePtr child; - int stealthmod = stealth_modifier(sr->mode); - unit *u; - ship *sh = r->ships; - building *b = r->buildings; - plane *pl = rplane(r); - int nx = r->x, ny = r->y; - - pnormalize(&nx, &ny, pl); - adjust_coordinates(ctx->f, &nx, &ny, pl, r); - - /* TODO: entertain-quota, recruits, salary, prices, curses, borders, apparitions (Schemen), spells, travelthru, messages */ - xmlNewNsProp(node, xct->ns_xml, XML_XML_ID, xml_ref_region(r)); - - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "coordinate")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "x", xml_i(nx)); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "y", xml_i(ny)); - if (pl && pl->name) { - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "plane", (xmlChar *) pl->name); - } - - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "terrain")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", (xmlChar *) terrain_name(r)); - - if (r->land != NULL) { - child = - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "name", - (const xmlChar *)r->land->name); - if (r->land->items) { - xmlAddChild(node, xml_inventory(ctx, r->land->items, NULL)); - } - } - if (r->display && r->display[0]) { - child = - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "text", - (const xmlChar *)r->display); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "public"); - } - child = xml_resources(ctx, sr); - if (child) - xmlAddChild(node, child); - - child = xmlNewNode(xct->ns_atl, BAD_CAST "terrain"); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", - (const xmlChar *)terrain_name(r)); - - if (sr->mode > see_neighbour) { - /* report all units. they are pre-sorted in an efficient manner */ - u = r->units; - while (b) { - while (b && (!u || u->building != b)) { - xmlAddChild(node, xml_building(ctx, sr, b, NULL)); - b = b->next; - } - if (b) { - child = xmlAddChild(node, xml_building(ctx, sr, b, u)); - while (u && u->building == b) { - xmlAddChild(child, xml_unit(ctx, u, sr->mode)); - u = u->next; - } - b = b->next; - } - } - while (u && !u->ship) { - if (stealthmod > INT_MIN) { - if (u->faction == ctx->f || cansee(ctx->f, r, u, stealthmod)) { - xmlAddChild(node, xml_unit(ctx, u, sr->mode)); - } - } - u = u->next; - } - while (sh) { - while (sh && (!u || u->ship != sh)) { - xmlAddChild(node, xml_ship(ctx, sr, sh, NULL)); - sh = sh->next; - } - if (sh) { - child = xmlAddChild(node, xml_ship(ctx, sr, sh, u)); - while (u && u->ship == sh) { - xmlAddChild(child, xml_unit(ctx, u, sr->mode)); - u = u->next; - } - sh = sh->next; - } - } - } - return node; -} - -static xmlNodePtr report_root(report_context * ctx) -{ - int qi; - quicklist *address; - region *r = ctx->first, *rend = ctx->last; - xml_context *xct = (xml_context *) ctx->userdata; - xmlNodePtr node, child, xmlReport = xmlNewNode(NULL, BAD_CAST "atlantis"); - const char *mailto = locale_string(ctx->f->locale, "mailto"); - const char *mailcmd = locale_string(ctx->f->locale, "mailcmd"); - char zText[128]; - /* TODO: locale, age, options, messages */ - - xct->ns_xml = xmlNewNs(xmlReport, XML_XML_NAMESPACE, BAD_CAST "xml"); - xct->ns_atl = xmlNewNs(xmlReport, XML_ATL_NAMESPACE, NULL); - xmlSetNs(xmlReport, xct->ns_atl); - - node = xmlAddChild(xmlReport, xmlNewNode(xct->ns_atl, BAD_CAST "server")); - if (mailto) { - _snprintf(zText, sizeof(zText), "mailto:%s?subject=%s", mailto, mailcmd); - child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "delivery")); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "method", BAD_CAST "mail"); - xmlNewNsProp(child, xct->ns_atl, BAD_CAST "href", BAD_CAST zText); - } - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "game", - (xmlChar *) global.gamename); - strftime(zText, sizeof(zText), "%Y-%m-%dT%H:%M:%SZ", - gmtime(&ctx->report_time)); - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "time", (xmlChar *) zText); - xmlNewTextChild(node, xct->ns_atl, BAD_CAST "turn", (xmlChar *) itoab(turn, - 10)); - - for (qi = 0, address = ctx->addresses; address; ql_advance(&address, &qi, 1)) { - faction *f = (faction *) ql_get(address, qi); - xmlAddChild(xmlReport, xml_faction(ctx, f)); - } - - for (; r != rend; r = r->next) { - seen_region *sr = find_seen(ctx->seen, r); - if (sr != NULL) - xmlAddChild(xmlReport, xml_region(ctx, sr)); - } - return xmlReport; -} - -/* main function of the xmlreport. creates the header and traverses all regions */ -static int -report_xml(const char *filename, report_context * ctx, const char *encoding) -{ - xml_context xct; - xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0"); - - xct.doc = doc; - assert(ctx->userdata == NULL); - ctx->userdata = &xct; - - xmlDocSetRootElement(doc, report_root(ctx)); - xmlKeepBlanksDefault(0); - xmlSaveFormatFileEnc(filename, doc, "utf-8", 1); - xmlFreeDoc(doc); - - ctx->userdata = NULL; - - return 0; -} - -void register_xr(void) -{ - register_reporttype("xml", &report_xml, 1 << O_XML); -#ifdef USE_ICONV - utf8 = iconv_open("UTF-8", ""); -#endif -} - -void xmlreport_cleanup(void) -{ -#ifdef USE_ICONV - iconv_close(utf8); -#endif -} diff --git a/src/xmlreport.h b/src/xmlreport.h deleted file mode 100644 index 676fbd1a2..000000000 --- a/src/xmlreport.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - +-------------------+ Christian Schlittchen - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2005 | Enno Rehling - +-------------------+ - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. -*/ -#ifndef H_GC_XMLREPORT -#define H_GC_XMLREPORT -#ifdef __cplusplus -extern "C" { -#endif - -#include - - extern void xmlreport_cleanup(void); - extern void register_xr(void); - - extern int crwritemap(const char *filename); - -#ifdef __cplusplus -} -#endif -#endif From 03a94d1264b0d18257e7e59d2958548a9852a61b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 01:35:45 +0100 Subject: [PATCH 217/675] remove unused and broken backup functionality --- src/bind_eressea.c | 2 +- src/gmtool.c | 4 +--- src/kernel/save.c | 22 +--------------------- src/kernel/save.h | 4 +--- src/kernel/save.test.c | 2 +- 5 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/bind_eressea.c b/src/bind_eressea.c index d7683ec18..279ce8f4e 100755 --- a/src/bind_eressea.c +++ b/src/bind_eressea.c @@ -19,7 +19,7 @@ void eressea_free_game(void) { } int eressea_read_game(const char * filename) { - return readgame(filename, false); + return readgame(filename); } int eressea_write_game(const char * filename) { diff --git a/src/gmtool.c b/src/gmtool.c index 608ad3c71..05997ed6e 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -823,8 +823,7 @@ void loaddata(state *st) { askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile)); if (strlen(datafile) > 0) { - create_backup(datafile); - readgame(datafile, false); + readgame(datafile); st->modified = 0; } } @@ -834,7 +833,6 @@ void savedata(state *st) { askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile)); if (strlen(datafile) > 0) { - create_backup(datafile); remove_empty_units(); writegame(datafile); st->modified = 0; diff --git a/src/kernel/save.c b/src/kernel/save.c index 143912832..fa2beabc6 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -378,22 +378,6 @@ race_t typus2race(unsigned char typus) return NORACE; } -void create_backup(char *file) -{ -#ifdef HAVE_LINK - char bfile[MAX_PATH]; - int c = 1; - - if (access(file, R_OK) == 0) - return; - do { - sprintf(bfile, "%s.backup%d", file, c); - c++; - } while (access(bfile, R_OK) == 0); - link(file, bfile); -#endif -} - static void read_alliances(struct gamedata *data) { storage *store = data->store; @@ -1476,7 +1460,7 @@ static int cb_sb_maxlevel(spellbook_entry *sbe, void *cbdata) { return 0; } -int readgame(const char *filename, bool backup) +int readgame(const char *filename) { int n; char path[MAX_PATH]; @@ -1490,10 +1474,6 @@ int readgame(const char *filename, bool backup) log_debug("- reading game data from %s", filename); join_path(datapath(), filename, path, sizeof(path)); - if (backup) { - create_backup(path); - } - F = fopen(path, "rb"); if (!F) { perror(path); diff --git a/src/kernel/save.h b/src/kernel/save.h index acaf74a3b..134fd8007 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -45,7 +45,7 @@ extern "C" { int readorders(const char *filename); int creategame(void); - int readgame(const char *filename, bool backup); + int readgame(const char *filename); int writegame(const char *filename); int current_turn(void); @@ -65,8 +65,6 @@ extern "C" { void write_ship(struct gamedata *data, const struct ship *sh); struct ship *read_ship(struct gamedata *data); - void create_backup(char *file); - int write_game(struct gamedata *data); int read_game(struct gamedata *data); diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index b4d79f4f8..6a2758a1d 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -38,7 +38,7 @@ static void test_readwrite_data(CuTest * tc) char path[MAX_PATH]; test_setup(); CuAssertIntEquals(tc, 0, writegame(filename)); - CuAssertIntEquals(tc, 0, readgame(filename, false)); + CuAssertIntEquals(tc, 0, readgame(filename)); join_path(datapath(), filename, path, sizeof(path)); CuAssertIntEquals(tc, 0, remove(path)); test_cleanup(); From 5e48eac26ac9db105c556ec53a2bc734c73c6383 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 02:21:49 +0100 Subject: [PATCH 218/675] coverity warning: NEGATIVE_RETURNS --- src/kernel/types.h | 2 +- src/keyword.c | 3 +++ src/keyword.h | 2 +- src/keyword.test.c | 4 +++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/kernel/types.h b/src/kernel/types.h index e0521635e..e2a3923b5 100644 --- a/src/kernel/types.h +++ b/src/kernel/types.h @@ -144,7 +144,7 @@ typedef enum { P_TREES, P_ALLIANCE, MAXPARAMS, - NOPARAM = -1 + NOPARAM } param_t; typedef enum { /* Fehler und Meldungen im Report */ diff --git a/src/keyword.c b/src/keyword.c index 0bd699836..199811669 100644 --- a/src/keyword.c +++ b/src/keyword.c @@ -14,6 +14,9 @@ const char * keyword(keyword_t kwd) { static char result[32]; // FIXME: static return value + if (kwd==NOKEYWORD) { + return NULL; + } if (!result[0]) { strcpy(result, "keyword::"); } diff --git a/src/keyword.h b/src/keyword.h index 9d5e20f64..e60d0731f 100644 --- a/src/keyword.h +++ b/src/keyword.h @@ -70,7 +70,7 @@ extern "C" K_PAY, K_LOOT, MAXKEYWORDS, - NOKEYWORD = -1 + NOKEYWORD } keyword_t; extern const char *keywords[MAXKEYWORDS]; diff --git a/src/keyword.test.c b/src/keyword.test.c index 903eb0c13..75c31904a 100644 --- a/src/keyword.test.c +++ b/src/keyword.test.c @@ -11,11 +11,13 @@ static void test_init_keywords(CuTest *tc) { struct locale *lang; - test_cleanup(); + test_setup(); lang = get_or_create_locale("en"); locale_setstring(lang, "keyword::move", "MOVE"); init_keywords(lang); CuAssertIntEquals(tc, K_MOVE, get_keyword("move", lang)); + CuAssertStrEquals(tc, "keyword::move", keyword(K_MOVE)); + CuAssertPtrEquals(tc, NULL, (void *)keyword(NOKEYWORD)); test_cleanup(); } From d73a629e79ed7a7af09792671c9021a43c044c31 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 20:01:44 +0100 Subject: [PATCH 219/675] add a test for regular give_cmd. also, speed up the function a little bit. --- src/give.c | 11 +++++--- src/give.test.c | 70 +++++++++++++++++++++++++++++++++++-------------- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/src/give.c b/src/give.c index 8f87cded3..b973b90f3 100644 --- a/src/give.c +++ b/src/give.c @@ -600,16 +600,19 @@ void give_cmd(unit * u, order * ord) } if (u2 && u_race(u2) == get_race(RC_SPELL)) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", - "")); + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, + "feedback_unit_not_found", "")); return; } - else if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) { cmistake(u, ord, 40, MSG_COMMERCE); return; } - + else if (p == NOKEYWORD) { + /* the most likely case: giving items to someone. + * let's catch this and save ourselves the rest of the param_t checks. + */ + } else if (p == P_HERBS) { bool given = false; if ((u_race(u)->ec_flags & ECF_KEEP_ITEM) && u2 != NULL) { diff --git a/src/give.test.c b/src/give.test.c index c719ddd5c..0d6149750 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -23,6 +23,7 @@ #include struct give { + struct locale * lang; struct unit *src, *dst; struct region *r; struct faction *f1, *f2; @@ -46,10 +47,15 @@ static void setup_give(struct give *env) { ally * al = ally_add(&env->f2->allies, env->f1); al->status = HELP_GIVE; } + if (env->lang) { + locale_setstring(env->lang, env->itype->rtype->_name, "SILBER"); + init_locale(env->lang); + env->f1->locale = env->lang; + } } static void test_give_unit_to_peasants(CuTest * tc) { - struct give env; + struct give env = { 0 }; test_setup(); env.f1 = test_create_faction(0); env.f2 = 0; @@ -62,7 +68,7 @@ static void test_give_unit_to_peasants(CuTest * tc) { } static void test_give_unit(CuTest * tc) { - struct give env; + struct give env = { 0 }; test_setup(); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); @@ -81,7 +87,7 @@ static void test_give_unit(CuTest * tc) { } static void test_give_unit_in_ocean(CuTest * tc) { - struct give env; + struct give env = { 0 }; test_setup(); env.f1 = test_create_faction(0); env.f2 = 0; @@ -93,7 +99,7 @@ static void test_give_unit_in_ocean(CuTest * tc) { } static void test_give_men(CuTest * tc) { - struct give env; + struct give env = { 0 }; test_setup(); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); @@ -104,7 +110,7 @@ static void test_give_men(CuTest * tc) { } static void test_give_men_magicians(CuTest * tc) { - struct give env; + struct give env = { 0 }; int p; message * msg; @@ -135,7 +141,7 @@ static void test_give_men_magicians(CuTest * tc) { } static void test_give_men_limit(CuTest * tc) { - struct give env; + struct give env = { 0 }; message *msg; test_setup(); env.f2 = test_create_faction(0); @@ -165,7 +171,7 @@ static void test_give_men_limit(CuTest * tc) { } static void test_give_men_in_ocean(CuTest * tc) { - struct give env; + struct give env = { 0 }; message * msg; test_setup(); @@ -181,7 +187,7 @@ static void test_give_men_in_ocean(CuTest * tc) { } static void test_give_men_too_many(CuTest * tc) { - struct give env; + struct give env = { 0 }; test_setup(); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); @@ -192,7 +198,7 @@ static void test_give_men_too_many(CuTest * tc) { } static void test_give_men_none(CuTest * tc) { - struct give env; + struct give env = { 0 }; message * msg; test_setup(); @@ -207,7 +213,7 @@ static void test_give_men_none(CuTest * tc) { } static void test_give_men_other_faction(CuTest * tc) { - struct give env; + struct give env = { 0 }; message * msg; test_setup(); @@ -224,7 +230,7 @@ static void test_give_men_other_faction(CuTest * tc) { } static void test_give_men_requires_contact(CuTest * tc) { - struct give env; + struct give env = { 0 }; message * msg; order *ord; char cmd[32]; @@ -251,7 +257,7 @@ static void test_give_men_requires_contact(CuTest * tc) { } static void test_give_men_not_to_self(CuTest * tc) { - struct give env; + struct give env = { 0 }; message * msg; test_setup(); env.f2 = env.f1 = test_create_faction(0); @@ -264,7 +270,7 @@ static void test_give_men_not_to_self(CuTest * tc) { } static void test_give_peasants(CuTest * tc) { - struct give env; + struct give env = { 0 }; message * msg; test_setup(); @@ -281,7 +287,7 @@ static void test_give_peasants(CuTest * tc) { } static void test_give(CuTest * tc) { - struct give env; + struct give env = { 0 }; test_setup(); env.f2 = env.f1 = test_create_faction(0); @@ -298,8 +304,31 @@ static void test_give(CuTest * tc) { test_cleanup(); } +static void test_give_cmd(CuTest * tc) { + struct give env = { 0 }; + struct order *ord; + char cmd[32]; + + test_setup(); + env.lang = test_create_locale(); + env.f2 = env.f1 = test_create_faction(0); + setup_give(&env); + + i_change(&env.src->items, env.itype, 10); + + _snprintf(cmd, sizeof(cmd), "%s 5 %s", itoa36(env.dst->no), LOC(env.f1->locale, env.itype->rtype->_name)); + ord = create_order(K_GIVE, env.f1->locale, cmd); + assert(ord); + give_cmd(env.src, ord); + CuAssertIntEquals(tc, 5, i_get(env.src->items, env.itype)); + CuAssertIntEquals(tc, 5, i_get(env.dst->items, env.itype)); + + free_order(ord); + test_cleanup(); +} + static void test_give_herbs(CuTest * tc) { - struct give env; + struct give env = { 0 }; struct order *ord; char cmd[32]; @@ -321,7 +350,7 @@ static void test_give_herbs(CuTest * tc) { } static void test_give_okay(CuTest * tc) { - struct give env; + struct give env = { 0 }; test_setup(); env.f2 = env.f1 = test_create_faction(0); @@ -333,7 +362,7 @@ static void test_give_okay(CuTest * tc) { } static void test_give_denied_by_rules(CuTest * tc) { - struct give env; + struct give env = { 0 }; struct message *msg; test_setup(); @@ -348,7 +377,7 @@ static void test_give_denied_by_rules(CuTest * tc) { } static void test_give_dead_unit(CuTest * tc) { - struct give env; + struct give env = { 0 }; struct message *msg; test_setup(); @@ -363,7 +392,7 @@ static void test_give_dead_unit(CuTest * tc) { } static void test_give_new_unit(CuTest * tc) { - struct give env; + struct give env = { 0 }; test_setup(); env.f1 = test_create_faction(0); @@ -377,7 +406,7 @@ static void test_give_new_unit(CuTest * tc) { static void test_give_invalid_target(CuTest *tc) { // bug https://bugs.eressea.de/view.php?id=1685 - struct give env; + struct give env = { 0 }; order *ord; test_setup(); @@ -400,6 +429,7 @@ CuSuite *get_give_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_give); + SUITE_ADD_TEST(suite, test_give_cmd); SUITE_ADD_TEST(suite, test_give_men); SUITE_ADD_TEST(suite, test_give_men_magicians); SUITE_ADD_TEST(suite, test_give_men_limit); From e2937419970e1af6998f342a0793a62dfc675e0e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 20:33:26 +0100 Subject: [PATCH 220/675] wrong enum, thanks gcc --- src/give.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/give.c b/src/give.c index b973b90f3..781f39ca6 100644 --- a/src/give.c +++ b/src/give.c @@ -608,7 +608,7 @@ void give_cmd(unit * u, order * ord) cmistake(u, ord, 40, MSG_COMMERCE); return; } - else if (p == NOKEYWORD) { + else if (p == NOPARAM) { /* the most likely case: giving items to someone. * let's catch this and save ourselves the rest of the param_t checks. */ From c512d180f84e6d8484188bb281964c177c1ec91a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 22:15:52 +0100 Subject: [PATCH 221/675] prevent atoip setting errno on mac. only call atoi when string starts with a digit --- src/util/parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/parser.c b/src/util/parser.c index 741fd573f..b13e266a6 100644 --- a/src/util/parser.c +++ b/src/util/parser.c @@ -250,7 +250,7 @@ unsigned int atoip(const char *s) int n; assert(s); - n = atoi(s); + n = isdigit(s[0]) ? atoi(s) : 0; if (n < 0) n = 0; From b48b80a1e96e486de7491cdcde5d0c5519e2b8a1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 22:21:32 +0100 Subject: [PATCH 222/675] verify errno in test_atoip --- src/util/parser.test.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/util/parser.test.c b/src/util/parser.test.c index da0d8dacb..c7ac0bb05 100644 --- a/src/util/parser.test.c +++ b/src/util/parser.test.c @@ -2,8 +2,16 @@ #include "parser.h" #include +#include #include +static void test_atoip(CuTest *tc) { + CuAssertIntEquals(tc, 0, atoip("ALLES")); + CuAssertIntEquals(tc, 0, errno); + CuAssertIntEquals(tc, 42, atoip("42")); + CuAssertIntEquals(tc, 0, atoip("-1")); +} + static void test_parse_token(CuTest *tc) { char lbuf[8]; const char *tok; @@ -103,12 +111,6 @@ static void test_getstrtoken(CuTest *tc) { CuAssertPtrEquals(tc, NULL, (void *)getstrtoken()); } -static void test_atoip(CuTest *tc) { - CuAssertIntEquals(tc, 42, atoip("42")); - CuAssertIntEquals(tc, 0, atoip("-42")); - CuAssertIntEquals(tc, 0, atoip("NOPE")); -} - CuSuite *get_parser_suite(void) { CuSuite *suite = CuSuiteNew(); From ce4a3c14b3d57e26ea94a27e82f2141de708470a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 22:27:44 +0100 Subject: [PATCH 223/675] convert from atoi to atoip. most numbers in commands cannot be negative. --- src/economy.c | 6 +++--- src/laws.c | 4 ++-- src/magic.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/economy.c b/src/economy.c index 36e8de109..bc0970ff2 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1278,7 +1278,7 @@ int make_cmd(unit * u, struct order *ord) s = gettoken(token, sizeof(token)); if (s) { - m = atoi((const char *)s); + m = atoip(s); sprintf(ibuf, "%d", m); if (!strcmp(ibuf, (const char *)s)) { /* a quantity was given */ @@ -1882,7 +1882,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) } } else { - n = s ? atoi(s) : 0; + n = s ? atoip(s) : 0; if (n == 0) { cmistake(u, ord, 27, MSG_COMMERCE); return false; @@ -2274,7 +2274,7 @@ static void breed_cmd(unit * u, struct order *ord) (void)init_order(ord); s = gettoken(token, sizeof(token)); - m = s ? atoi((const char *)s) : 0; + m = s ? atoip(s) : 0; if (m != 0) { /* first came a want-paramter */ s = gettoken(token, sizeof(token)); diff --git a/src/laws.c b/src/laws.c index 0838ba6a2..a2db8e4a0 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3693,7 +3693,7 @@ int use_cmd(unit * u, struct order *ord) cmistake(u, ord, 43, MSG_PRODUCE); return err; } - n = atoi((const char *)t); + n = atoip((const char *)t); if (n == 0) { if (isparam(t, u->faction->locale, P_ANY)) { /* BENUTZE ALLES Yanxspirit */ @@ -3841,7 +3841,7 @@ int claim_cmd(unit * u, struct order *ord) t = gettoken(token, sizeof(token)); if (t) { - n = atoi((const char *)t); + n = atoip((const char *)t); if (n == 0) { n = 1; } diff --git a/src/magic.c b/src/magic.c index 1ac2255c1..803f20c78 100644 --- a/src/magic.c +++ b/src/magic.c @@ -376,7 +376,7 @@ static int read_seenspell(attrib * a, void *owner, struct gamedata *data) char token[32]; READ_TOK(store, token, sizeof(token)); - i = atoi(token); + i = atoip(token); if (i != 0) { sp = find_spellbyid((unsigned int)i); } From 49e5b5b67e73120eaa5f960eb28facec297efdac Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Nov 2016 23:19:28 +0100 Subject: [PATCH 224/675] gcc missing include --- src/util/parser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/parser.c b/src/util/parser.c index b13e266a6..0fbde6769 100644 --- a/src/util/parser.c +++ b/src/util/parser.c @@ -6,6 +6,7 @@ #include #include +#include #include #include From c1f468ceb000ad69587a963ca6638a7401c4777c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 15 Nov 2016 20:43:36 +0100 Subject: [PATCH 225/675] begin to declutter config.c --- src/economy.c | 4 ++-- src/kernel/config.c | 7 ------- src/kernel/config.h | 1 - src/kernel/region.c | 9 ++++++++- src/kernel/region.h | 1 + src/kernel/types.h | 8 -------- src/keyword.h | 2 +- src/laws.c | 12 ++++++------ 8 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/economy.c b/src/economy.c index 36e8de109..1ee34fb9a 100644 --- a/src/economy.c +++ b/src/economy.c @@ -2908,7 +2908,7 @@ void auto_work(region * r) } } if (nextworker != workers) { - expandwork(r, workers, nextworker, maxworkingpeasants(r)); + expandwork(r, workers, nextworker, region_maxworkers(r)); } } @@ -3112,7 +3112,7 @@ void produce(struct region *r) if (entertaining) expandentertainment(r); if (!rule_autowork()) { - expandwork(r, workers, nextworker, maxworkingpeasants(r)); + expandwork(r, workers, nextworker, region_maxworkers(r)); } if (taxorders) expandtax(r, taxorders); diff --git a/src/kernel/config.c b/src/kernel/config.c index 42dcc5e09..78af1ad02 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -433,13 +433,6 @@ int newcontainerid(void) return random_no; } -int maxworkingpeasants(const struct region *r) -{ - int size = production(r); - int treespace = (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE; - return _max(size - treespace, _min(size / 10, 200)); -} - static const char * parameter_key(int i) { assert(i < MAXPARAMS && i >= 0); diff --git a/src/kernel/config.h b/src/kernel/config.h index 8c46e4185..0d0506b47 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -114,7 +114,6 @@ struct param; #define GF_PURE 64 /* untranslated */ - int maxworkingpeasants(const struct region *r); bool markets_module(void); int wage(const struct region *r, const struct faction *f, const struct race *rc, int in_turn); diff --git a/src/kernel/region.c b/src/kernel/region.c index e05bd76c1..d937f8b68 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -134,6 +134,13 @@ const char *regionname(const region * r, const faction * f) return write_regionname(r, f, buf[index], sizeof(buf[index])); } +int region_maxworkers(const region *r) +{ + int size = production(r); + int treespace = (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE; + return _max(size - treespace, _min(size / 10, 200)); +} + int deathcount(const region * r) { attrib *a = a_find(r->attribs, &at_deathcount); @@ -1207,7 +1214,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; + peasants = (region_maxworkers(r) * (20 + dice_rand("6d10"))) / 100; rsetpeasants(r, _max(100, peasants)); rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL, INT_MAX) + 1) + rng_int() % 5)); diff --git a/src/kernel/region.h b/src/kernel/region.h index eb7066cc6..fcc5f08b0 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -264,6 +264,7 @@ extern "C" { const char *regionname(const struct region *r, const struct faction *f); + int region_maxworkers(const struct region *r); const char *region_getname(const struct region *self); void region_setname(struct region *self, const char *name); const char *region_getinfo(const struct region *self); diff --git a/src/kernel/types.h b/src/kernel/types.h index e0521635e..5187f9aec 100644 --- a/src/kernel/types.h +++ b/src/kernel/types.h @@ -19,14 +19,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef ERESSEA_TYPES_H #define ERESSEA_TYPES_H -/* - * Features enabled: - * If you are lacking the settings.h, create a new file common/settings.h, - * and write #include (or whatever settings you want - * your game to use) in there. - * !!! DO NOT COMMIT THE SETTINGS.H FILE TO CVS !!! - * settings.h should always be the first thing you include (after platform.h). - */ #include #include diff --git a/src/keyword.h b/src/keyword.h index 9d5e20f64..e60d0731f 100644 --- a/src/keyword.h +++ b/src/keyword.h @@ -70,7 +70,7 @@ extern "C" K_PAY, K_LOOT, MAXKEYWORDS, - NOKEYWORD = -1 + NOKEYWORD } keyword_t; extern const char *keywords[MAXKEYWORDS]; diff --git a/src/laws.c b/src/laws.c index 0838ba6a2..f5d65efc5 100644 --- a/src/laws.c +++ b/src/laws.c @@ -221,7 +221,7 @@ static void live(region * r) static void calculate_emigration(region * r) { int i; - int maxp = maxworkingpeasants(r); + int maxp = region_maxworkers(r); int rp = rpeasants(r); int max_immigrants = MAX_IMMIGRATION(maxp - rp); @@ -236,7 +236,7 @@ static void calculate_emigration(region * r) if (rc != NULL && fval(rc->terrain, LAND_REGION)) { int rp2 = rpeasants(rc); - int maxp2 = maxworkingpeasants(rc); + int maxp2 = region_maxworkers(rc); int max_emigration = MAX_EMIGRATION(rp2 - maxp2); if (max_emigration > 0) { @@ -419,7 +419,7 @@ static void horses(region * r) direction_t n; /* Logistisches Wachstum, Optimum bei halbem Maximalbesatz. */ - maxhorses = maxworkingpeasants(r) / 10; + maxhorses = region_maxworkers(r) / 10; maxhorses = _max(0, maxhorses); horses = rhorses(r); if (horses > 0) { @@ -621,7 +621,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season) * verfügbaren Fläche ab. In Gletschern gibt es weniger * Möglichkeiten als in Ebenen. */ sprout = 0; - seedchance = (1000 * maxworkingpeasants(r2)) / r2->terrain->size; + seedchance = (1000 * region_maxworkers(r2)) / r2->terrain->size; for (i = 0; i < seeds / MAXDIRECTIONS; i++) { if (rng_int() % 10000 < seedchance) sprout++; @@ -720,7 +720,7 @@ void immigration(void) if (repopulate) { int peasants = rpeasants(r); int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL) + 1; - if (income >= 0 && r->land && (peasants < repopulate) && maxworkingpeasants(r) >(peasants + 30) * 2) { + if (income >= 0 && r->land && (peasants < repopulate) && region_maxworkers(r) >(peasants + 30) * 2) { int badunit = 0; unit *u; for (u = r->units; u; u = u->next) { @@ -816,7 +816,7 @@ void demographics(void) calculate_emigration(r); peasants(r); if (r->age > 20) { - double mwp = _max(maxworkingpeasants(r), 1); + double mwp = _max(region_maxworkers(r), 1); double prob = pow(rpeasants(r) / (mwp * wage(r, NULL, NULL, turn) * 0.13), 4.0) * PLAGUE_CHANCE; From 17365edff76824acc3c91796eb5090bf453e1005 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 15 Nov 2016 23:34:20 +0100 Subject: [PATCH 226/675] move renumber command to a separate module. --- scripts/tests/bindings.lua | 1 - scripts/tests/orders.lua | 2 +- src/CMakeLists.txt | 1 + src/bind_process.c | 5 - src/laws.c | 181 +-------------------------------- src/laws.h | 2 - src/process.pkg | 1 - src/process.pkg.c | 25 ----- src/renumber.c | 198 +++++++++++++++++++++++++++++++++++++ src/renumber.h | 12 +++ 10 files changed, 213 insertions(+), 215 deletions(-) create mode 100644 src/renumber.c create mode 100644 src/renumber.h diff --git a/scripts/tests/bindings.lua b/scripts/tests/bindings.lua index 189d34769..9aab6fd57 100644 --- a/scripts/tests/bindings.lua +++ b/scripts/tests/bindings.lua @@ -34,7 +34,6 @@ function test_process() assert_equal("function", _G.type(eressea.process.siege)) assert_equal("function", _G.type(eressea.process.leave)) assert_equal("function", _G.type(eressea.process.promote)) - assert_equal("function", _G.type(eressea.process.renumber)) assert_equal("function", _G.type(eressea.process.restack)) assert_equal("function", _G.type(eressea.process.set_spells)) assert_equal("function", _G.type(eressea.process.set_help)) diff --git a/scripts/tests/orders.lua b/scripts/tests/orders.lua index a0b03f825..dde9508e9 100644 --- a/scripts/tests/orders.lua +++ b/scripts/tests/orders.lua @@ -165,7 +165,7 @@ end function test_process_renumber() u:add_order("NUMMER EINHEIT 'ii'") - eressea.process.renumber() + process_orders() assert_equal(666, u.id) end diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b4e600e0d..4616fc8e3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -115,6 +115,7 @@ set (ERESSEA_SRC morale.c monster.c randenc.c + renumber.c volcano.c chaos.c spy.c diff --git a/src/bind_process.c b/src/bind_process.c index e8420c654..2b44eb19d 100755 --- a/src/bind_process.c +++ b/src/bind_process.c @@ -182,11 +182,6 @@ void process_promote(void) { process_cmd(K_PROMOTION, promotion_cmd, 0); } -void process_renumber(void) { - process_cmd(K_NUMBER, renumber_cmd, 0); - renumber_factions(); -} - void process_restack(void) { restack_units(); } diff --git a/src/laws.c b/src/laws.c index 33fd56779..cf365fc7a 100644 --- a/src/laws.c +++ b/src/laws.c @@ -32,6 +32,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "monster.h" #include "move.h" #include "randenc.h" +#include "renumber.h" #include "spy.h" #include "study.h" #include "wormhole.h" @@ -2742,74 +2743,6 @@ void sinkships(struct region * r) } } -static attrib_type at_number = { - "faction_renum", - NULL, NULL, NULL, NULL, NULL, NULL, - ATF_UNIQUE -}; - -void renumber_factions(void) -/* gibt parteien neue nummern */ -{ - struct renum { - struct renum *next; - int want; - faction *faction; - attrib *attrib; - } *renum = NULL, *rp; - faction *f; - for (f = factions; f; f = f->next) { - attrib *a = a_find(f->attribs, &at_number); - int want; - struct renum **rn; - faction *old; - - if (!a) - continue; - want = a->data.i; - if (fval(f, FFL_NEWID)) { - ADDMSG(&f->msgs, msg_message("renumber_twice", "id", want)); - continue; - } - old = findfaction(want); - if (old) { - a_remove(&f->attribs, a); - ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want)); - continue; - } - if (!faction_id_is_unused(want)) { - a_remove(&f->attribs, a); - ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want)); - continue; - } - for (rn = &renum; *rn; rn = &(*rn)->next) { - if ((*rn)->want >= want) - break; - } - if (*rn && (*rn)->want == want) { - ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want)); - } - else { - struct renum *r = calloc(sizeof(struct renum), 1); - r->next = *rn; - r->attrib = a; - r->faction = f; - r->want = want; - *rn = r; - } - } - for (rp = renum; rp; rp = rp->next) { - f = rp->faction; - a_remove(&f->attribs, rp->attrib); - renumber_faction(f, rp->want); - } - while (renum) { - rp = renum->next; - free(renum); - renum = rp; - } -} - void restack_units(void) { region *r; @@ -2897,118 +2830,6 @@ void restack_units(void) } } -int renumber_cmd(unit * u, order * ord) -{ - char token[128]; - const char *s; - int i = 0; - faction *f = u->faction; - - init_order(ord); - s = gettoken(token, sizeof(token)); - switch (findparam_ex(s, u->faction->locale)) { - - case P_FACTION: - s = gettoken(token, sizeof(token)); - if (s && *s) { - int id = atoi36((const char *)s); - attrib *a = a_find(f->attribs, &at_number); - if (!a) - a = a_add(&f->attribs, a_new(&at_number)); - a->data.i = id; - } - break; - - case P_UNIT: - s = gettoken(token, sizeof(token)); - if (s && *s) { - i = atoi36((const char *)s); - if (i <= 0 || i > MAX_UNIT_NR) { - cmistake(u, ord, 114, MSG_EVENT); - break; - } - - if (forbiddenid(i)) { - cmistake(u, ord, 116, MSG_EVENT); - break; - } - - if (findunitg(i, u->region)) { - cmistake(u, ord, 115, MSG_EVENT); - break; - } - } - renumber_unit(u, i); - break; - - case P_SHIP: - if (!u->ship) { - cmistake(u, ord, 144, MSG_EVENT); - break; - } - if (ship_owner(u->ship) != u) { - cmistake(u, ord, 146, MSG_EVENT); - break; - } - if (u->ship->coast != NODIRECTION) { - cmistake(u, ord, 116, MSG_EVENT); - break; - } - s = gettoken(token, sizeof(token)); - if (s == NULL || *s == 0) { - i = newcontainerid(); - } - else { - i = atoi36((const char *)s); - if (i <= 0 || i > MAX_CONTAINER_NR) { - cmistake(u, ord, 114, MSG_EVENT); - break; - } - if (findship(i) || findbuilding(i)) { - cmistake(u, ord, 115, MSG_EVENT); - break; - } - } - sunhash(u->ship); - u->ship->no = i; - shash(u->ship); - break; - case P_BUILDING: - case P_GEBAEUDE: - if (!u->building) { - cmistake(u, ord, 145, MSG_EVENT); - break; - } - if (building_owner(u->building) != u) { - cmistake(u, ord, 148, MSG_EVENT); - break; - } - s = gettoken(token, sizeof(token)); - if (*s == 0) { - i = newcontainerid(); - } - else { - i = atoi36((const char *)s); - if (i <= 0 || i > MAX_CONTAINER_NR) { - cmistake(u, ord, 114, MSG_EVENT); - break; - } - if (findship(i) || findbuilding(i)) { - cmistake(u, ord, 115, MSG_EVENT); - break; - } - } - bunhash(u->building); - u->building->no = i; - bhash(u->building); - break; - - default: - cmistake(u, ord, 239, MSG_EVENT); - } - return 0; -} - /* blesses stone circles create an astral protection in the astral region * above the shield, which prevents chaos suction and other spells. * The shield is created when a magician enters the blessed stone circle, diff --git a/src/laws.h b/src/laws.h index c5e9d573c..5406a50d4 100755 --- a/src/laws.h +++ b/src/laws.h @@ -59,7 +59,6 @@ extern "C" { void defaultorders(void); void quit(void); void monthly_healing(void); - void renumber_factions(void); void restack_units(void); void update_long_order(struct unit *u); void sinkships(struct region * r); @@ -83,7 +82,6 @@ extern "C" { int leave_cmd(struct unit *u, struct order *ord); int pay_cmd(struct unit *u, struct order *ord); int promotion_cmd(struct unit *u, struct order *ord); - int renumber_cmd(struct unit *u, struct order *ord); int combatspell_cmd(struct unit *u, struct order *ord); int contact_cmd(struct unit *u, struct order *ord); int guard_on_cmd(struct unit *u, struct order *ord); diff --git a/src/process.pkg b/src/process.pkg index 5db5c7344..a81917293 100755 --- a/src/process.pkg +++ b/src/process.pkg @@ -25,7 +25,6 @@ module eressea { void process_leave @ leave(void); /* LEAVE */ void process_maintenance @ maintenance(void); /* PAY */ void process_promote @ promote(void); /* PROMOTE */ - void process_renumber @ renumber(void); /* RENUMBER */ void process_restack @ restack(void); /* SORT */ void process_setspells @ set_spells(void); /* COMBATSPELL */ void process_sethelp @ set_help(void); /* HELP */ diff --git a/src/process.pkg.c b/src/process.pkg.c index 787258a96..42dff20ff 100644 --- a/src/process.pkg.c +++ b/src/process.pkg.c @@ -531,30 +531,6 @@ static int tolua_process_eressea_process_promote00(lua_State* tolua_S) #endif } -/* function: process_renumber */ -static int tolua_process_eressea_process_renumber00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isnoobj(tolua_S,1,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - { - process_renumber(); - } - } - return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'renumber'.",&tolua_err); - return 0; -#endif -} - /* function: process_restack */ static int tolua_process_eressea_process_restack00(lua_State* tolua_S) { @@ -1021,7 +997,6 @@ LUALIB_API int luaopen_process (lua_State* tolua_S) tolua_function(tolua_S,"leave",tolua_process_eressea_process_leave00); tolua_function(tolua_S,"maintenance",tolua_process_eressea_process_maintenance00); tolua_function(tolua_S,"promote",tolua_process_eressea_process_promote00); - tolua_function(tolua_S,"renumber",tolua_process_eressea_process_renumber00); tolua_function(tolua_S,"restack",tolua_process_eressea_process_restack00); tolua_function(tolua_S,"set_spells",tolua_process_eressea_process_set_spells00); tolua_function(tolua_S,"set_help",tolua_process_eressea_process_set_help00); diff --git a/src/renumber.c b/src/renumber.c new file mode 100644 index 000000000..259dfcc2b --- /dev/null +++ b/src/renumber.c @@ -0,0 +1,198 @@ +#include +#include "renumber.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +static attrib_type at_number = { + "faction_renum", + NULL, NULL, NULL, NULL, NULL, NULL, + ATF_UNIQUE +}; + +void renumber_factions(void) +/* gibt parteien neue nummern */ +{ + struct renum { + struct renum *next; + int want; + faction *faction; + attrib *attrib; + } *renum = NULL, *rp; + faction *f; + for (f = factions; f; f = f->next) { + attrib *a = a_find(f->attribs, &at_number); + int want; + struct renum **rn; + faction *old; + + if (!a) + continue; + want = a->data.i; + if (fval(f, FFL_NEWID)) { + ADDMSG(&f->msgs, msg_message("renumber_twice", "id", want)); + continue; + } + old = findfaction(want); + if (old) { + a_remove(&f->attribs, a); + ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want)); + continue; + } + if (!faction_id_is_unused(want)) { + a_remove(&f->attribs, a); + ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want)); + continue; + } + for (rn = &renum; *rn; rn = &(*rn)->next) { + if ((*rn)->want >= want) + break; + } + if (*rn && (*rn)->want == want) { + ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want)); + } + else { + struct renum *r = calloc(sizeof(struct renum), 1); + r->next = *rn; + r->attrib = a; + r->faction = f; + r->want = want; + *rn = r; + } + } + for (rp = renum; rp; rp = rp->next) { + f = rp->faction; + a_remove(&f->attribs, rp->attrib); + renumber_faction(f, rp->want); + } + while (renum) { + rp = renum->next; + free(renum); + renum = rp; + } +} + +int renumber_cmd(unit * u, order * ord) +{ + char token[128]; + const char *s; + int i = 0; + faction *f = u->faction; + + init_order(ord); + s = gettoken(token, sizeof(token)); + switch (findparam_ex(s, u->faction->locale)) { + + case P_FACTION: + s = gettoken(token, sizeof(token)); + if (s && *s) { + int id = atoi36((const char *)s); + attrib *a = a_find(f->attribs, &at_number); + if (!a) + a = a_add(&f->attribs, a_new(&at_number)); + a->data.i = id; + } + break; + + case P_UNIT: + s = gettoken(token, sizeof(token)); + if (s && *s) { + i = atoi36((const char *)s); + if (i <= 0 || i > MAX_UNIT_NR) { + cmistake(u, ord, 114, MSG_EVENT); + break; + } + + if (forbiddenid(i)) { + cmistake(u, ord, 116, MSG_EVENT); + break; + } + + if (findunitg(i, u->region)) { + cmistake(u, ord, 115, MSG_EVENT); + break; + } + } + renumber_unit(u, i); + break; + + case P_SHIP: + if (!u->ship) { + cmistake(u, ord, 144, MSG_EVENT); + break; + } + if (ship_owner(u->ship) != u) { + cmistake(u, ord, 146, MSG_EVENT); + break; + } + if (u->ship->coast != NODIRECTION) { + cmistake(u, ord, 116, MSG_EVENT); + break; + } + s = gettoken(token, sizeof(token)); + if (s == NULL || *s == 0) { + i = newcontainerid(); + } + else { + i = atoi36((const char *)s); + if (i <= 0 || i > MAX_CONTAINER_NR) { + cmistake(u, ord, 114, MSG_EVENT); + break; + } + if (findship(i) || findbuilding(i)) { + cmistake(u, ord, 115, MSG_EVENT); + break; + } + } + sunhash(u->ship); + u->ship->no = i; + shash(u->ship); + break; + case P_BUILDING: + case P_GEBAEUDE: + if (!u->building) { + cmistake(u, ord, 145, MSG_EVENT); + break; + } + if (building_owner(u->building) != u) { + cmistake(u, ord, 148, MSG_EVENT); + break; + } + s = gettoken(token, sizeof(token)); + if (*s == 0) { + i = newcontainerid(); + } + else { + i = atoi36((const char *)s); + if (i <= 0 || i > MAX_CONTAINER_NR) { + cmistake(u, ord, 114, MSG_EVENT); + break; + } + if (findship(i) || findbuilding(i)) { + cmistake(u, ord, 115, MSG_EVENT); + break; + } + } + bunhash(u->building); + u->building->no = i; + bhash(u->building); + break; + + default: + cmistake(u, ord, 239, MSG_EVENT); + } + return 0; +} + diff --git a/src/renumber.h b/src/renumber.h new file mode 100644 index 000000000..244b8043f --- /dev/null +++ b/src/renumber.h @@ -0,0 +1,12 @@ +#pragma once + +#ifndef H_RENUMBER +#define H_RENUMBER + + struct unit; + struct order; + + void renumber_factions(void); + int renumber_cmd(struct unit *u, struct order *ord); + +#endif From 83ea1077a3a7093456acc5f67e0ba7e72a528e6c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 15 Nov 2016 23:37:30 +0100 Subject: [PATCH 227/675] delete default terrain. github issue #538 --- conf/e3/terrains.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/conf/e3/terrains.json b/conf/e3/terrains.json index 7b5ea980d..5aa876950 100644 --- a/conf/e3/terrains.json +++ b/conf/e3/terrains.json @@ -223,13 +223,5 @@ } } }, - "default": { - "size": 0, - "herbs": [], - "seed": 0, - "road": 0, - "flags": [ "land", "walk", "sail", "fly" ], - "production": {} - } } } From 360776f8b987b81ba13d9e47af8843228de264c6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 15 Nov 2016 23:45:14 +0100 Subject: [PATCH 228/675] eliminate data_version variables, issue #479 --- src/kernel/config.h | 1 - src/kernel/save.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/kernel/config.h b/src/kernel/config.h index 0d0506b47..ca83be114 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -138,7 +138,6 @@ struct param; struct attrib *attribs; unsigned int data_turn; void *vm_state; - int data_version; /* TODO: eliminate in favor of gamedata.version */ struct _dictionary_ *inifile; struct global_functions { int(*wage) (const struct region * r, const struct faction * f, diff --git a/src/kernel/save.h b/src/kernel/save.h index 134fd8007..cfbcafd72 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -38,8 +38,6 @@ extern "C" { /* Nach MAX_INPUT_SIZE brechen wir das Einlesen der Zeile ab und nehmen an, * dass hier ein Fehler (fehlende ") vorliegt */ - extern int data_version; - // TODO: is this *really* still in use? extern int enc_gamedata; From e50dfbf42bd4b3bb8a8fecd5eb3bbbeaa81617b9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 15 Nov 2016 23:56:39 +0100 Subject: [PATCH 229/675] fix terrains.json, reduce config.h use --- conf/e3/terrains.json | 2 +- src/races/dragons.c | 1 - src/races/illusion.c | 1 - src/races/races.c | 1 - src/races/races.h | 1 + src/races/zombies.c | 2 +- 6 files changed, 3 insertions(+), 5 deletions(-) diff --git a/conf/e3/terrains.json b/conf/e3/terrains.json index 5aa876950..ee0eb0e37 100644 --- a/conf/e3/terrains.json +++ b/conf/e3/terrains.json @@ -222,6 +222,6 @@ "div": "100" } } - }, + } } } diff --git a/src/races/dragons.c b/src/races/dragons.c index 828e68c64..222d63c89 100644 --- a/src/races/dragons.c +++ b/src/races/dragons.c @@ -13,7 +13,6 @@ */ #include -#include /* kernel includes */ #include diff --git a/src/races/illusion.c b/src/races/illusion.c index e2a05cfd3..7411ae4d5 100644 --- a/src/races/illusion.c +++ b/src/races/illusion.c @@ -11,7 +11,6 @@ */ #include -#include /* kernel includes */ #include diff --git a/src/races/races.c b/src/races/races.c index 68b3c5ae2..2c6cfffa9 100644 --- a/src/races/races.c +++ b/src/races/races.c @@ -9,7 +9,6 @@ */ #include -#include #include "races.h" #include diff --git a/src/races/races.h b/src/races/races.h index c0a516430..ea7be1337 100644 --- a/src/races/races.h +++ b/src/races/races.h @@ -14,6 +14,7 @@ #ifdef __cplusplus extern "C" { #endif + struct unit; void register_races(void); void make_undead_unit(struct unit *); diff --git a/src/races/zombies.c b/src/races/zombies.c index d86074d26..ab4c89988 100644 --- a/src/races/zombies.c +++ b/src/races/zombies.c @@ -13,9 +13,9 @@ */ #include -#include /* kernel includes */ +#include #include #include #include From fbe846864d0b530f59c976e197715e4e9b106283 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 16 Nov 2016 18:08:10 +0100 Subject: [PATCH 230/675] arguments for test_setup that help debugging tests. --- src/give.test.c | 42 +++++++++++++++++++++--------------------- src/tests.c | 8 +++++++- src/tests.h | 5 ++++- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/give.test.c b/src/give.test.c index 0d6149750..f2b0d60a9 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -56,7 +56,7 @@ static void setup_give(struct give *env) { static void test_give_unit_to_peasants(CuTest * tc) { struct give env = { 0 }; - test_setup(); + test_setup_ex(tc); env.f1 = test_create_faction(0); env.f2 = 0; setup_give(&env); @@ -69,7 +69,7 @@ static void test_give_unit_to_peasants(CuTest * tc) { static void test_give_unit(CuTest * tc) { struct give env = { 0 }; - test_setup(); + test_setup_ex(tc); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -88,7 +88,7 @@ static void test_give_unit(CuTest * tc) { static void test_give_unit_in_ocean(CuTest * tc) { struct give env = { 0 }; - test_setup(); + test_setup_ex(tc); env.f1 = test_create_faction(0); env.f2 = 0; setup_give(&env); @@ -100,7 +100,7 @@ static void test_give_unit_in_ocean(CuTest * tc) { static void test_give_men(CuTest * tc) { struct give env = { 0 }; - test_setup(); + test_setup_ex(tc); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); CuAssertPtrEquals(tc, 0, give_men(1, env.src, env.dst, NULL)); @@ -114,7 +114,7 @@ static void test_give_men_magicians(CuTest * tc) { int p; message * msg; - test_setup(); + test_setup_ex(tc); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); set_level(env.src, SK_MAGIC, 1); @@ -143,7 +143,7 @@ static void test_give_men_magicians(CuTest * tc) { static void test_give_men_limit(CuTest * tc) { struct give env = { 0 }; message *msg; - test_setup(); + test_setup_ex(tc); env.f2 = test_create_faction(0); env.f1 = test_create_faction(0); setup_give(&env); @@ -174,7 +174,7 @@ static void test_give_men_in_ocean(CuTest * tc) { struct give env = { 0 }; message * msg; - test_setup(); + test_setup_ex(tc); env.f1 = test_create_faction(0); env.f2 = 0; setup_give(&env); @@ -188,7 +188,7 @@ static void test_give_men_in_ocean(CuTest * tc) { static void test_give_men_too_many(CuTest * tc) { struct give env = { 0 }; - test_setup(); + test_setup_ex(tc); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); CuAssertPtrEquals(tc, 0, give_men(2, env.src, env.dst, NULL)); @@ -201,7 +201,7 @@ static void test_give_men_none(CuTest * tc) { struct give env = { 0 }; message * msg; - test_setup(); + test_setup_ex(tc); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); msg = give_men(0, env.src, env.dst, NULL); @@ -216,7 +216,7 @@ static void test_give_men_other_faction(CuTest * tc) { struct give env = { 0 }; message * msg; - test_setup(); + test_setup_ex(tc); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -235,7 +235,7 @@ static void test_give_men_requires_contact(CuTest * tc) { order *ord; char cmd[32]; - test_setup(); + test_setup_ex(tc); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -259,7 +259,7 @@ static void test_give_men_requires_contact(CuTest * tc) { static void test_give_men_not_to_self(CuTest * tc) { struct give env = { 0 }; message * msg; - test_setup(); + test_setup_ex(tc); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); msg = give_men(1, env.src, env.src, NULL); @@ -273,7 +273,7 @@ static void test_give_peasants(CuTest * tc) { struct give env = { 0 }; message * msg; - test_setup(); + test_setup_ex(tc); env.f1 = test_create_faction(0); env.f2 = 0; setup_give(&env); @@ -289,7 +289,7 @@ static void test_give_peasants(CuTest * tc) { static void test_give(CuTest * tc) { struct give env = { 0 }; - test_setup(); + test_setup_ex(tc); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); @@ -309,7 +309,7 @@ static void test_give_cmd(CuTest * tc) { struct order *ord; char cmd[32]; - test_setup(); + test_setup_ex(tc); env.lang = test_create_locale(); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); @@ -332,7 +332,7 @@ static void test_give_herbs(CuTest * tc) { struct order *ord; char cmd[32]; - test_setup(); + test_setup_ex(tc); test_create_world(); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); @@ -352,7 +352,7 @@ static void test_give_herbs(CuTest * tc) { static void test_give_okay(CuTest * tc) { struct give env = { 0 }; - test_setup(); + test_setup_ex(tc); env.f2 = env.f1 = test_create_faction(0); setup_give(&env); @@ -365,7 +365,7 @@ static void test_give_denied_by_rules(CuTest * tc) { struct give env = { 0 }; struct message *msg; - test_setup(); + test_setup_ex(tc); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -380,7 +380,7 @@ static void test_give_dead_unit(CuTest * tc) { struct give env = { 0 }; struct message *msg; - test_setup(); + test_setup_ex(tc); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -394,7 +394,7 @@ static void test_give_dead_unit(CuTest * tc) { static void test_give_new_unit(CuTest * tc) { struct give env = { 0 }; - test_setup(); + test_setup_ex(tc); env.f1 = test_create_faction(0); env.f2 = test_create_faction(0); setup_give(&env); @@ -409,7 +409,7 @@ static void test_give_invalid_target(CuTest *tc) { struct give env = { 0 }; order *ord; - test_setup(); + test_setup_ex(tc); env.f1 = test_create_faction(0); env.f2 = 0; setup_give(&env); diff --git a/src/tests.c b/src/tests.c index 05855563a..15ae677fe 100644 --- a/src/tests.c +++ b/src/tests.c @@ -196,9 +196,15 @@ static void test_reset(void) { } } -void test_setup(void) { +void test_setup_test(CuTest *tc, const char *file, int line) { test_log_stderr(LOG_CPERROR); test_reset(); + if (tc) { + log_debug("start test: %s", tc->name); + } + else { + log_debug("start test in %s:%d", file, line); + } } void test_cleanup(void) diff --git a/src/tests.h b/src/tests.h index cbc2a2511..c99147e6a 100644 --- a/src/tests.h +++ b/src/tests.h @@ -31,7 +31,10 @@ extern "C" { struct CuTest; - void test_setup(void); + void test_setup_test(struct CuTest *tc, const char *file, int line); +#define test_setup() test_setup_test(NULL, __FILE__, __LINE__) +#define test_setup_ex(tc) test_setup_test(tc, __FILE__, __LINE__) + void test_cleanup(void); void test_log_stderr(int on); struct log_t * test_log_start(int flags, struct strlist **slist); From 251c7bb55966bb30a4c9bb556036d01440b5f1fc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 16 Nov 2016 19:43:06 +0100 Subject: [PATCH 231/675] re-enable snowglobe assert. --- scripts/tests/xmas.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tests/xmas.lua b/scripts/tests/xmas.lua index bbd4941f2..3667de0b6 100644 --- a/scripts/tests/xmas.lua +++ b/scripts/tests/xmas.lua @@ -52,7 +52,7 @@ function test_snowglobe() for k, v in pairs(xform) do r2.terrain = k process_orders() - -- TODO: re-enable! assert_equal(v, r2.terrain) + assert_equal(v, r2.terrain) if k~=v then have=have - 1 else From 264fc0cb6fa2a35e658c62ea385e32585a466802 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 16 Nov 2016 20:03:34 +0100 Subject: [PATCH 232/675] test renumbering units and factions. --- src/CMakeLists.txt | 1 + src/renumber.test.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ src/test_eressea.c | 3 ++- 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/renumber.test.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4616fc8e3..109a212f1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -219,6 +219,7 @@ set(TESTS_SRC move.test.c piracy.test.c prefix.test.c + renumber.test.c skill.test.c spells.test.c spy.test.c diff --git a/src/renumber.test.c b/src/renumber.test.c new file mode 100644 index 000000000..5b8dc5e2c --- /dev/null +++ b/src/renumber.test.c @@ -0,0 +1,53 @@ +#include "renumber.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +static void test_renumber_faction(CuTest *tc) { + unit *u; + int uno, no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + no = u->faction->no; + uno = (no > 1) ? no - 1 : no + 1; + lang = u->faction->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_FACTION]), itoa36(uno)); + renumber_cmd(u, u->thisorder); + renumber_factions(); + CuAssertIntEquals(tc, uno, u->faction->no); + test_cleanup(); +} + +static void test_renumber_unit(CuTest *tc) { + unit *u; + int uno, no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + no = u->no; + uno = (no > 1) ? no - 1 : no + 1; + lang = u->faction->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_UNIT]), itoa36(uno)); + renumber_cmd(u, u->thisorder); + CuAssertIntEquals(tc, uno, u->no); + CuAssertIntEquals(tc, -no, ualias(u)); // TODO: why is ualias negative? + test_cleanup(); +} + +CuSuite *get_renumber_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_renumber_unit); + SUITE_ADD_TEST(suite, test_renumber_faction); + return suite; +} diff --git a/src/test_eressea.c b/src/test_eressea.c index 39ec90be6..330afd5bc 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -114,7 +114,6 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(guard); ADD_SUITE(report); ADD_SUITE(creport); - ADD_SUITE(prefix); ADD_SUITE(summary); ADD_SUITE(names); ADD_SUITE(battle); @@ -130,6 +129,8 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(monsters); ADD_SUITE(move); ADD_SUITE(piracy); + ADD_SUITE(prefix); + ADD_SUITE(renumber); ADD_SUITE(key); ADD_SUITE(stealth); ADD_SUITE(otherfaction); From 4a667326371761c32ff0a9a1ec78f759727f5e2f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 16 Nov 2016 20:41:48 +0100 Subject: [PATCH 233/675] renumber tests for building, ship --- src/renumber.test.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/renumber.test.c b/src/renumber.test.c index 5b8dc5e2c..3fabaf4c1 100644 --- a/src/renumber.test.c +++ b/src/renumber.test.c @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include #include #include @@ -27,6 +29,40 @@ static void test_renumber_faction(CuTest *tc) { test_cleanup(); } +static void test_renumber_building(CuTest *tc) { + unit *u; + int uno, no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + u->building = test_create_building(u->region, 0); + no = u->building->no; + uno = (no > 1) ? no - 1 : no + 1; + lang = u->faction->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_BUILDING]), itoa36(uno)); + renumber_cmd(u, u->thisorder); + CuAssertIntEquals(tc, uno, u->building->no); + test_cleanup(); +} + +static void test_renumber_ship(CuTest *tc) { + unit *u; + int uno, no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + u->ship = test_create_ship(u->region, 0); + no = u->ship->no; + uno = (no > 1) ? no - 1 : no + 1; + lang = u->faction->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(uno)); + renumber_cmd(u, u->thisorder); + CuAssertIntEquals(tc, uno, u->ship->no); + test_cleanup(); +} + static void test_renumber_unit(CuTest *tc) { unit *u; int uno, no; @@ -48,6 +84,8 @@ CuSuite *get_renumber_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_renumber_unit); + SUITE_ADD_TEST(suite, test_renumber_building); + SUITE_ADD_TEST(suite, test_renumber_ship); SUITE_ADD_TEST(suite, test_renumber_faction); return suite; } From 413f70d1a1b429813bcc0e9b141ecaf4c5ed1cc7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 16 Nov 2016 22:30:59 +0100 Subject: [PATCH 234/675] move market function out of config.c --- src/creport.c | 1 + src/kernel/config.c | 5 ----- src/kernel/config.h | 1 - src/market.c | 5 +++++ src/market.h | 3 ++- src/modules/autoseed.c | 2 ++ src/report.c | 3 ++- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/creport.c b/src/creport.c index becee2cb0..b74c5cdef 100644 --- a/src/creport.c +++ b/src/creport.c @@ -11,6 +11,7 @@ without prior permission by the authors of Eressea. #include #include #include "creport.h" +#include "market.h" #include "guard.h" #include "travelthru.h" diff --git a/src/kernel/config.c b/src/kernel/config.c index 78af1ad02..d8be01ed9 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -1061,11 +1061,6 @@ int rule_give(void) return rule; } -bool markets_module(void) -{ - return (bool)config_get_int("modules.markets", 0); -} - static struct param *configuration; static int config_cache_key = 1; diff --git a/src/kernel/config.h b/src/kernel/config.h index ca83be114..9a0d1d1fb 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -114,7 +114,6 @@ struct param; #define GF_PURE 64 /* untranslated */ - bool markets_module(void); int wage(const struct region *r, const struct faction *f, const struct race *rc, int in_turn); diff --git a/src/market.c b/src/market.c index efcaf0d98..cef84b9b2 100644 --- a/src/market.c +++ b/src/market.c @@ -85,6 +85,11 @@ static int rc_herb_trade(const struct race *rc) #define MAX_MARKETS 128 #define MIN_PEASANTS 50 /* if there are at least this many peasants, you will get 1 good */ +bool markets_module(void) +{ + return (bool)config_get_int("modules.markets", 0); +} + void do_markets(void) { quicklist *traders = 0; diff --git a/src/market.h b/src/market.h index dd15253ef..a74c88391 100644 --- a/src/market.h +++ b/src/market.h @@ -17,7 +17,8 @@ extern "C" { #endif struct building; - extern void do_markets(void); + bool markets_module(void); + void do_markets(void); #ifdef __cplusplus } diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 3bcf36848..5420406c0 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -14,6 +14,8 @@ #include #include "autoseed.h" +#include "market.h" + /* kernel includes */ #include #include diff --git a/src/report.c b/src/report.c index 23dcadb34..80ac85974 100644 --- a/src/report.c +++ b/src/report.c @@ -25,8 +25,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "reports.h" #include "guard.h" #include "laws.h" -#include "travelthru.h" +#include "market.h" #include "monster.h" +#include "travelthru.h" /* modules includes */ #include From a88bfa7a9a4aa8f3c18a302bf627fde23307460d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 16 Nov 2016 22:46:01 +0100 Subject: [PATCH 235/675] decluttering config.c (rules go into laws.c) --- s/build | 2 +- src/kernel/config.c | 31 ------------------------------- src/kernel/config.h | 5 ----- src/laws.c | 26 ++++++++++++++++++++++++++ src/laws.h | 4 ++++ src/study.c | 13 ++++++++++++- 6 files changed, 43 insertions(+), 38 deletions(-) diff --git a/s/build b/s/build index b59804626..363e3e5a6 100755 --- a/s/build +++ b/s/build @@ -39,5 +39,5 @@ echo "build eressea" cd $ROOT/$BUILD VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//') cmake -DERESSEA_VERSION="$VERSION" .. -make $MAKEOPTS && make test +make -k $MAKEOPTS && make test cd $OLDPWD diff --git a/src/kernel/config.c b/src/kernel/config.c index d8be01ed9..7ca8a5ba7 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -105,37 +105,6 @@ FILE *logfile; bool battledebug = false; int turn = -1; -int NewbieImmunity(void) -{ - return config_get_int("NewbieImmunity", 0); -} - -bool IsImmune(const faction * f) -{ - return !fval(f, FFL_NPC) && f->age < NewbieImmunity(); -} - -bool ExpensiveMigrants(void) -{ - return config_get_int("study.expensivemigrants", 0) != 0; -} - -int LongHunger(const struct unit *u) -{ - if (u != NULL) { - if (!fval(u, UFL_HUNGER)) - return false; - if (u_race(u) == get_race(RC_DAEMON)) - return false; - } - return config_get_int("hunger.long", 0); -} - -int NMRTimeout(void) -{ - return config_get_int("nmr.timeout", 0); -} - helpmode helpmodes[] = { { "all", HELP_ALL } , diff --git a/src/kernel/config.h b/src/kernel/config.h index 9a0d1d1fb..84bc1ba75 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -164,11 +164,6 @@ struct param; bool config_changed(int *cache_key); char * join_path(const char *p1, const char *p2, char *dst, size_t len); - bool ExpensiveMigrants(void); - int NMRTimeout(void); - int LongHunger(const struct unit *u); - int NewbieImmunity(void); - bool IsImmune(const struct faction *f); struct order *default_order(const struct locale *lang); diff --git a/src/laws.c b/src/laws.c index cf365fc7a..0ba3f4077 100644 --- a/src/laws.c +++ b/src/laws.c @@ -117,6 +117,32 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* - exported global symbols ----------------------------------- */ +int NewbieImmunity(void) +{ + return config_get_int("NewbieImmunity", 0); +} + +bool IsImmune(const faction * f) +{ + return !fval(f, FFL_NPC) && f->age < NewbieImmunity(); +} + +int NMRTimeout(void) +{ + return config_get_int("nmr.timeout", 0); +} + +bool LongHunger(const struct unit *u) +{ + if (u != NULL) { + if (!fval(u, UFL_HUNGER)) + return false; + if (u_race(u) == get_race(RC_DAEMON)) + return false; + } + return config_get_int("hunger.long", 0) != 0; +} + static bool RemoveNMRNewbie(void) { int value = config_get_int("nmr.removenewbie", 0); diff --git a/src/laws.h b/src/laws.h index 5406a50d4..0adb010d2 100755 --- a/src/laws.h +++ b/src/laws.h @@ -108,6 +108,10 @@ extern "C" { #define FORCE_LEAVE_POSTCOMBAT 1 #define FORCE_LEAVE_ALL 2 bool rule_force_leave(int flag); + bool LongHunger(const struct unit *u); + int NMRTimeout(void); + int NewbieImmunity(void); + bool IsImmune(const struct faction *f); bool help_enter(struct unit *uo, struct unit *u); #ifdef __cplusplus diff --git a/src/study.c b/src/study.c index 59f1130ea..1cd8847be 100644 --- a/src/study.c +++ b/src/study.c @@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "study.h" +#include "laws.h" #include "move.h" #include "monster.h" #include "alchemy.h" @@ -531,6 +532,16 @@ static double study_speedup(unit * u, skill_t s, study_rule_t rule) return 1.0; } +static bool ExpensiveMigrants(void) +{ + static bool rule; + static int cache; + if (config_changed(&cache)) { + rule = config_get_int("study.expensivemigrants", 0) != 0; + } + return rule; +} + int study_cmd(unit * u, order * ord) { region *r = u->region; @@ -772,7 +783,7 @@ int study_cmd(unit * u, order * ord) a_remove(&u->attribs, a); a = NULL; } - fset(u, UFL_LONGACTION | UFL_NOTMOVING); + u->flags |= (UFL_LONGACTION | UFL_NOTMOVING); /* Anzeigen neuer Traenke */ /* Spruchlistenaktualiesierung ist in Regeneration */ From 6a75b20315fedb4e27d17fec7016fee71bb1466c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 16 Nov 2016 22:57:17 +0100 Subject: [PATCH 236/675] remove wdwpyramid --- src/spells.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/spells.c b/src/spells.c index 44bd07dec..da2b73c5e 100644 --- a/src/spells.c +++ b/src/spells.c @@ -107,10 +107,6 @@ static double zero_effect = 0.0; -attrib_type at_wdwpyramid = { - "wdwpyramid", NULL, NULL, NULL, NULL, NULL -}; - /* ----------------------------------------------------------------------- */ static void report_spell(unit * mage, region * r, message * msg) @@ -6722,7 +6718,6 @@ void register_spells(void) { register_borders(); - at_register(&at_wdwpyramid); at_register(&at_deathcloud_compat); /* init_firewall(); */ From 3a64a2f4048281e39373b5d2b01c05ef692a871d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 16 Nov 2016 23:09:07 +0100 Subject: [PATCH 237/675] stop spamming the log when using a listbox. --- src/listbox.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/listbox.c b/src/listbox.c index 3686cbba1..332041454 100644 --- a/src/listbox.c +++ b/src/listbox.c @@ -88,7 +88,6 @@ list_selection *do_selection(list_selection * sel, const char *title, width = (int)strlen(s->str); } ++height; - log_debug("s %s w %d h %d\n", s->str, width, height); } if (height == 0 || width == 0) return 0; @@ -97,8 +96,6 @@ list_selection *do_selection(list_selection * sel, const char *title, if (height + 2 > SY) height = SY - 2; - log_debug("w %d h %d\n", width, height); - wn = newwin(height + 2, width + 4, (SY - height - 2) / 2, (SX - width - 4) / 2); From 42eff95ec28e301c83714a9c042afe02fc98039a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 10:26:30 +0100 Subject: [PATCH 238/675] remove unused empty files --- src/bind_log.c | 0 src/bind_log.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/bind_log.c delete mode 100644 src/bind_log.h diff --git a/src/bind_log.c b/src/bind_log.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/bind_log.h b/src/bind_log.h deleted file mode 100644 index e69de29bb..000000000 From f371a0c5f32b03e97e4ed2771431891ca4603db6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 10:32:20 +0100 Subject: [PATCH 239/675] eliminate unused callback module. what was I thinking when I wrote this? --- src/CMakeLists.txt | 2 -- src/callback.c | 61 --------------------------------------------- src/callback.h | 16 ------------ src/callback.test.c | 51 ------------------------------------- src/test_eressea.c | 1 - 5 files changed, 131 deletions(-) delete mode 100644 src/callback.c delete mode 100644 src/callback.h delete mode 100644 src/callback.test.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 109a212f1..34cea4037 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -99,7 +99,6 @@ set (ERESSEA_SRC prefix.c donations.c eressea.c - callback.c direction.c keyword.c skill.c @@ -205,7 +204,6 @@ set(TESTS_SRC report.test.c summary.test.c travelthru.test.c - callback.test.c direction.test.c economy.test.c json.test.c diff --git a/src/callback.c b/src/callback.c deleted file mode 100644 index 79bd69b71..000000000 --- a/src/callback.c +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include "callback.h" -#include -#include - -static struct reg { - struct reg * next; - HCALLBACK cb; - char *name; -} *registry; - -HCALLBACK create_callback(void(*cbv)(va_list va)) { - HCALLBACK cb; - cb.cbv = cbv; - return cb; -} - -void reset_callbacks(void) { - while (registry) { - struct reg *r = registry; - registry = r->next; - free(r->name); - free(r); - } - registry = 0; -} - -HCALLBACK register_callback(const char *name, void(*cbv)(va_list va)) -{ - struct reg * r = (struct reg *)malloc(sizeof(struct reg)); - r->next = registry; - r->name = _strdup(name); - r->cb.cbv = cbv; - registry = r; - return r->cb; -} - -int find_callback(const char *name, HCALLBACK *result) { - if (result && name) { - struct reg *r; - for (r = registry; r; r = r->next) { - if (strcmp(r->name, name) == 0) { - *result = r->cb; - return 0; - } - } - } - return -1; -} - -int call_callback(HCALLBACK cb, const char *name, ...) { - va_list ap; - if (name) { - int err = find_callback(name, &cb); - if (err) return err; - } - va_start(ap, name); - cb.cbv(ap); - va_end(ap); - return 0; -} diff --git a/src/callback.h b/src/callback.h deleted file mode 100644 index 288a148e9..000000000 --- a/src/callback.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef H_CALLBACK_H -#define H_CALLBACK_H - -#include - -typedef struct { - void(*cbv)(va_list va); -} HCALLBACK; - -HCALLBACK register_callback(const char *name, void(*cbv)(va_list va)); -HCALLBACK create_callback(void(*cbv)(va_list va)); -int find_callback(const char *name, HCALLBACK *result); -int call_callback(HCALLBACK cb, const char *name, ...); -void reset_callbacks(void); - -#endif diff --git a/src/callback.test.c b/src/callback.test.c deleted file mode 100644 index 317cc6d50..000000000 --- a/src/callback.test.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "callback.h" -#include -#include - -void callback(va_list ap) { - int i = (int)va_arg(ap, int); - int *p = va_arg(ap, int *); - *p += i; -} - -static void test_find_callback(CuTest *tc) { - HCALLBACK cb; - reset_callbacks(); - CuAssertIntEquals(tc, -1, find_callback("test", &cb)); - cb = register_callback("test", callback); - CuAssertIntEquals(tc, 0, find_callback("test", &cb)); - reset_callbacks(); -} - -static void test_call_by_handle(CuTest *tc) { - HCALLBACK cb; - int x = 0; - reset_callbacks(); - cb = create_callback(callback); - CuAssertIntEquals(tc, 0, call_callback(cb, 0, 42, &x)); - CuAssertIntEquals(tc, 42, x); - reset_callbacks(); -} - -static void test_call_by_name(CuTest *tc) { - HCALLBACK cb = { 0 }; - HCALLBACK ca = { 0 }; - int x = 0; - reset_callbacks(); - CuAssertIntEquals(tc, -1, call_callback(cb, "test", 42, &x)); - cb = register_callback("test", callback); - CuAssertIntEquals(tc, 0, call_callback(cb, "test", 42, &x)); - CuAssertIntEquals(tc, 42, x); - CuAssertIntEquals(tc, 0, call_callback(ca, "test", 42, &x)); - CuAssertIntEquals(tc, 84, x); - reset_callbacks(); -} - -CuSuite *get_callback_suite(void) -{ - CuSuite *suite = CuSuiteNew(); - SUITE_ADD_TEST(suite, test_find_callback); - SUITE_ADD_TEST(suite, test_call_by_name); - SUITE_ADD_TEST(suite, test_call_by_handle); - return suite; -} diff --git a/src/test_eressea.c b/src/test_eressea.c index 330afd5bc..71cf008f2 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -60,7 +60,6 @@ int RunAllTests(int argc, char *argv[]) { /* self-test */ ADD_SUITE(tests); - ADD_SUITE(callback); ADD_SUITE(json); ADD_SUITE(jsonconf); ADD_SUITE(direction); From cbb18edb8fa074a0125e6014400071e3d85dc049 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 10:38:09 +0100 Subject: [PATCH 240/675] declutter config.h, use it sparingly. --- src/bind_faction.c | 18 +++++++++++- src/bind_message.c | 2 -- src/bind_order.c | 1 - src/bind_storage.c | 1 - src/chaos.c | 29 +++++++++---------- src/kernel/config.c | 67 ++++---------------------------------------- src/kernel/config.h | 25 ++++------------- src/kernel/faction.h | 8 ++++-- src/kernel/save.h | 2 ++ src/reports.c | 16 +++++++++++ src/reports.h | 1 + 11 files changed, 66 insertions(+), 104 deletions(-) diff --git a/src/bind_faction.c b/src/bind_faction.c index 688b093b5..36da798c1 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -19,7 +19,6 @@ without prior permission by the authors of Eressea. #include #include -#include #include #include #include @@ -38,6 +37,23 @@ without prior permission by the authors of Eressea. #include #include +typedef struct helpmode { + const char *name; + int status; +} helpmode; + +static helpmode helpmodes[] = { + { "all", HELP_ALL }, + { "money", HELP_MONEY }, + { "fight", HELP_FIGHT }, + { "observe", HELP_OBSERVE }, + { "give", HELP_GIVE }, + { "guard", HELP_GUARD }, + { "stealth", HELP_FSTEALTH }, + { "travel", HELP_TRAVEL }, + { NULL, 0 } +}; + int tolua_factionlist_next(lua_State * L) { faction **faction_ptr = (faction **)lua_touserdata(L, lua_upvalueindex(1)); diff --git a/src/bind_message.c b/src/bind_message.c index 15673f4f6..a3ab95d39 100644 --- a/src/bind_message.c +++ b/src/bind_message.c @@ -1,6 +1,4 @@ #include -#include - #include "spells.h" /* kernel includes */ diff --git a/src/bind_order.c b/src/bind_order.c index 90fc7d3b0..84399deec 100644 --- a/src/bind_order.c +++ b/src/bind_order.c @@ -1,5 +1,4 @@ #include -#include /* kernel includes */ #include diff --git a/src/bind_storage.c b/src/bind_storage.c index 489255d3f..a81a3baeb 100644 --- a/src/bind_storage.c +++ b/src/bind_storage.c @@ -11,7 +11,6 @@ without prior permission by the authors of Eressea. */ #include -#include #include "bind_storage.h" #include diff --git a/src/chaos.c b/src/chaos.c index 7a1be7e56..942fb87bc 100644 --- a/src/chaos.c +++ b/src/chaos.c @@ -85,7 +85,7 @@ static const terrain_type *chaosterrain(void) if (numtypes == 0) { const terrain_type *terrain; for (terrain = terrains(); terrain != NULL; terrain = terrain->next) { - if (fval(terrain, LAND_REGION) && terrain->herbs) { + if ((terrain->flags & LAND_REGION) && terrain->herbs) { ++numtypes; } } @@ -93,7 +93,7 @@ static const terrain_type *chaosterrain(void) types = malloc(sizeof(terrain_type *) * numtypes); numtypes = 0; for (terrain = terrains(); terrain != NULL; terrain = terrain->next) { - if (fval(terrain, LAND_REGION) && terrain->herbs) { + if ((terrain->flags & LAND_REGION) && terrain->herbs) { types[numtypes++] = terrain; } } @@ -139,7 +139,7 @@ static void chaos(region * r) if (rng_int() % 100 < 8) { switch (rng_int() % 3) { case 0: /* Untote */ - if (!fval(r->terrain, SEA_REGION)) { + if (!(r->terrain->flags & SEA_REGION)) { unit *u = random_unit(r); if (u && playerrace(u_race(u))) { ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u)); @@ -161,29 +161,28 @@ static void chaos(region * r) break; case 1: mfac = 500; - u = - create_unit(r, get_monsters(), rng_int() % 4 + 1, + u = create_unit(r, get_monsters(), rng_int() % 4 + 1, get_race(RC_DRAGON), 0, NULL, NULL); break; default: mfac = 1000; - u = - create_unit(r, get_monsters(), rng_int() % 2 + 1, + u = create_unit(r, get_monsters(), rng_int() % 2 + 1, get_race(RC_WYRM), 0, NULL, NULL); break; } - if (mfac) + if (mfac) { set_money(u, u->number * (rng_int() % mfac)); - fset(u, UFL_ISNEW | UFL_MOVED); + } + u->flags |= (UFL_ISNEW | UFL_MOVED); } break; - case 2: /* Terrainvernderung */ - if (!fval(r->terrain, FORBIDDEN_REGION)) { - if (!fval(r->terrain, SEA_REGION)) { + case 2: /* Terrainver�nderung */ + if (!(r->terrain->flags & FORBIDDEN_REGION)) { + if (!(r->terrain->flags & SEA_REGION)) { direction_t dir; for (dir = 0; dir != MAXDIRECTIONS; ++dir) { region *rn = rconnect(r, dir); - if (rn && fval(rn->terrain, SEA_REGION)) + if (rn && (rn->terrain->flags & SEA_REGION)) break; } if (dir != MAXDIRECTIONS) { @@ -224,7 +223,7 @@ static void chaos(region * r) direction_t dir; for (dir = 0; dir != MAXDIRECTIONS; ++dir) { region *rn = rconnect(r, dir); - if (rn && fval(rn->terrain, SEA_REGION)) + if (rn && (rn->terrain->flags & SEA_REGION)) break; } if (dir != MAXDIRECTIONS) { @@ -242,7 +241,7 @@ void chaos_update(void) { for (r = regions; r; r = r->next) { int i; - if (fval(r, RF_CHAOTIC)) { + if ((r->flags & RF_CHAOTIC)) { chaos(r); } i = get_chaoscount(r); diff --git a/src/kernel/config.c b/src/kernel/config.c index 7ca8a5ba7..10b35bce9 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -105,26 +105,6 @@ FILE *logfile; bool battledebug = false; int turn = -1; -helpmode helpmodes[] = { - { "all", HELP_ALL } - , - { "money", HELP_MONEY } - , - { "fight", HELP_FIGHT } - , - { "observe", HELP_OBSERVE } - , - { "give", HELP_GIVE } - , - { "guard", HELP_GUARD } - , - { "stealth", HELP_FSTEALTH } - , - { "travel", HELP_TRAVEL } - , - { NULL, 0 } -}; - const char *parameters[MAXPARAMS] = { "LOCALE", "ALLES", @@ -148,7 +128,7 @@ const char *parameters[MAXPARAMS] = { "TEMP", "FLIEHE", "GEBAEUDE", - "GIB", /* Fr HELFE */ + "GIB", /* F�r HELFE */ "KAEMPFE", "DURCHREISE", "BEWACHE", @@ -172,43 +152,6 @@ const char *parameters[MAXPARAMS] = { "ALLIANZ" }; -const char *report_options[MAX_MSG] = { - "Kampf", - "Ereignisse", - "Bewegung", - "Einkommen", - "Handel", - "Produktion", - "Orkvermehrung", - "Zauber", - "", - "" -}; - -const char *message_levels[ML_MAX] = { - "Wichtig", - "Debug", - "Fehler", - "Warnungen", - "Infos" -}; - -const char *options[MAXOPTIONS] = { - "AUSWERTUNG", - "COMPUTER", - "ZUGVORLAGE", - NULL, - "STATISTIK", - "DEBUG", - "ZIPPED", - "ZEITUNG", /* Option hat Sonderbehandlung! */ - NULL, - "ADRESSEN", - "BZIP2", - "PUNKTE", - "SHOWSKCHANGE" -}; - FILE *debug; void @@ -711,8 +654,8 @@ char *_strdup(const char *s) } #endif -/* Lohn bei den einzelnen Burgstufen fr Normale Typen, Orks, Bauern, - * Modifikation fr Stdter. */ +/* Lohn bei den einzelnen Burgstufen f�r Normale Typen, Orks, Bauern, + * Modifikation f�r St�dter. */ static const int wagetable[7][4] = { { 10, 10, 11, -7 }, /* Baustelle */ @@ -929,7 +872,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn) wage = _max(0, wage - 10); } - /* Bei einer Drre verdient man nur noch ein Viertel */ + /* Bei einer D�rre verdient man nur noch ein Viertel */ if (drought_ct) { curse *c = get_curse(r->attribs, drought_ct); if (curse_active(c)) @@ -953,7 +896,7 @@ minimum_wage(const region * r, const faction * f, const race * rc, int in_turn) return default_wage(r, f, rc, in_turn); } -/* Gibt Arbeitslohn fr entsprechende Rasse zurck, oder fr +/* Gibt Arbeitslohn f�r entsprechende Rasse zur�ck, oder f�r * die Bauern wenn f == NULL. */ int wage(const region * r, const faction * f, const race * rc, int in_turn) { diff --git a/src/kernel/config.h b/src/kernel/config.h index 84bc1ba75..ca2686a1b 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -27,17 +27,12 @@ extern "C" { #include "types.h" struct param; -#define DISPLAYSIZE 8192 /* max. Lnge einer Beschreibung, incl trailing 0 */ +#define DISPLAYSIZE 8192 /* max. L�nge einer Beschreibung, incl trailing 0 */ #define ORDERSIZE (DISPLAYSIZE*2) /* max. length of an order */ -#define NAMESIZE 128 /* max. Lnge eines Namens, incl trailing 0 */ -#define IDSIZE 16 /* max. Lnge einer no (als String), incl trailing 0 */ -#define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. Lnge der Strings, die - * von struct unitname, etc. zurckgegeben werden. ohne die 0 */ - - /* ----------------- Befehle ----------------------------------- */ - -#define want(option) (1<dh, u->dh, r->dh, etc... */ #define FFL_NOAID (1<<21) /* Hilfsflag Kampf */ -#define FFL_MARK (1<<23) /* fr markierende algorithmen, die das - * hinterher auch wieder lschen mssen! +#define FFL_MARK (1<<23) /* f�r markierende algorithmen, die das + * hinterher auch wieder l�schen m�ssen! * (FFL_SELECT muss man vorher initialisieren, - * FL_MARK hinterher lschen) */ + * FL_MARK hinterher l�schen) */ #define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */ #define FFL_NPC (1<<25) /* eine Partei mit Monstern */ #define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_NPC|FFL_NOIDLEOUT|FFL_CURSED) @@ -101,6 +101,8 @@ extern "C" { extern struct faction *factions; +#define want(option) (1< Date: Thu, 17 Nov 2016 10:42:20 +0100 Subject: [PATCH 241/675] reduce config.h even more. let's get all those global variables out of there. --- src/battle.c | 155 ++++++++++++++++++++++---------------------- src/battle.h | 19 +++--- src/kernel/config.c | 1 - src/kernel/config.h | 1 - src/main.c | 1 + 5 files changed, 89 insertions(+), 88 deletions(-) diff --git a/src/battle.c b/src/battle.c index 5ae215135..2facbb30f 100644 --- a/src/battle.c +++ b/src/battle.c @@ -76,16 +76,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -static FILE *bdebug; - #define TACTICS_BONUS 1 /* when undefined, we have a tactics round. else this is the bonus tactics give */ #define TACTICS_MODIFIER 1 /* modifier for generals in the front/rear */ #define CATAPULT_INITIAL_RELOAD 4 /* erster schuss in runde 1 + rng_int() % INITIAL */ #define CATAPULT_STRUCTURAL_DAMAGE -#define BASE_CHANCE 70 /* 70% Basis-berlebenschance */ -#define TDIFF_CHANGE 5 /* 5% hher pro Stufe */ +#define BASE_CHANCE 70 /* 70% Basis-�berlebenschance */ +#define TDIFF_CHANGE 5 /* 5% h�her pro Stufe */ #define DAMAGE_QUOTIENT 2 /* damage += skilldiff/DAMAGE_QUOTIENT */ #define DEBUG_SELECT /* should be disabled if select_enemy works */ @@ -96,7 +94,10 @@ typedef enum combatmagic { } combatmagic_t; /* globals */ +bool battledebug = false; + static int obs_count = 0; +static FILE *bdebug; #define MINSPELLRANGE 1 #define MAXSPELLRANGE 7 @@ -303,11 +304,11 @@ static int dead_fighters(const fighter * df) } fighter *select_corpse(battle * b, fighter * af) -/* Whlt eine Leiche aus, der af hilft. casualties ist die Anzahl der +/* W�hlt eine Leiche aus, der af hilft. casualties ist die Anzahl der * Toten auf allen Seiten (im Array). Wenn af == NULL, wird die - * Parteizugehrigkeit ignoriert, und irgendeine Leiche genommen. + * Parteizugeh�rigkeit ignoriert, und irgendeine Leiche genommen. * - * Untote werden nicht ausgewhlt (casualties, not dead) */ + * Untote werden nicht ausgew�hlt (casualties, not dead) */ { int si, maxcasualties = 0; fighter *df; @@ -323,7 +324,7 @@ fighter *select_corpse(battle * b, fighter * af) side *s; for (s = b->sides; s != b->sides + b->nsides; ++s) { for (df = s->fighters; df; df = df->next) { - /* Geflohene haben auch 0 hp, drfen hier aber nicht ausgewhlt + /* Geflohene haben auch 0 hp, d�rfen hier aber nicht ausgew�hlt * werden! */ int dead = dead_fighters(df); if (!playerrace(u_race(df->unit))) @@ -617,7 +618,7 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking) } } else { - /* der rassen-defaultwert kann hher sein als der Talentwert von + /* der rassen-defaultwert kann h�her sein als der Talentwert von * waffenloser kampf */ if (attacking) { if (skill < u_race(u)->at_default) @@ -705,7 +706,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type) static int weapon_effskill(troop t, troop enemy, const weapon * w, bool attacking, bool missile) -/* effektiver Waffenskill whrend des Kampfes */ +/* effektiver Waffenskill w�hrend des Kampfes */ { /* In dieser Runde alle die Modifier berechnen, die fig durch die * Waffen bekommt. */ @@ -770,16 +771,16 @@ bool missile) if (t.index < tf->elvenhorses) { /* Elfenpferde: Helfen dem Reiter, egal ob und welche Waffe. Das ist - * eleganter, und vor allem einfacher, sonst mu man noch ein + * eleganter, und vor allem einfacher, sonst mu� man noch ein * WMF_ELVENHORSE einbauen. */ skill += 2; } if (skill > 0 && !attacking && missile) { /* - * Wenn ich verteidige, und nicht direkt meinem Feind gegenberstehe, - * halbiert sich mein Skill: (z.B. gegen Fernkmpfer. Nahkmpfer - * knnen mich eh nicht treffen) + * Wenn ich verteidige, und nicht direkt meinem Feind gegen�berstehe, + * halbiert sich mein Skill: (z.B. gegen Fernk�mpfer. Nahk�mpfer + * k�nnen mich eh nicht treffen) */ skill /= 2; } @@ -815,9 +816,9 @@ static const armor_type *select_armor(troop t, bool shield) } /* Hier ist zu beachten, ob und wie sich Zauber und Artefakte, die - * Rstungschutz geben, addieren. - * - Artefakt "trollbelt" gibt Rstung +1 - * - Zauber Rindenhaut gibt Rstung +3 + * R�stungschutz geben, addieren. + * - Artefakt "trollbelt" gibt R�stung +1 + * - Zauber Rindenhaut gibt R�stung +3 */ static int trollbelts(const unit *u) { const struct resource_type *belt = rt_find("trollbelt"); @@ -835,7 +836,7 @@ int select_magicarmor(troop t) return ma; } -/* Sind side ds und Magier des meffect verbndet, dann return 1*/ +/* Sind side ds und Magier des meffect verb�ndet, dann return 1*/ bool meffect_protection(battle * b, meffect * s, side * ds) { if (!s->magician->alive) @@ -871,7 +872,7 @@ void rmfighter(fighter * df, int i) assert(df->alive >= i); assert(df->alive <= df->unit->number); - /* erst ziehen wir die Anzahl der Personen von den Kmpfern in der + /* erst ziehen wir die Anzahl der Personen von den K�mpfern in der * Schlacht, dann von denen auf dieser Seite ab*/ df->side->alive -= i; df->side->battle->alive -= i; @@ -1091,15 +1092,15 @@ int calculate_armor(troop dt, const weapon_type *dwtype, const weapon_type *awty } } - /* natrliche Rstung */ + /* nat�rliche R�stung */ an = natural_armor(du); - /* magische Rstung durch Artefakte oder Sprche */ - /* Momentan nur Trollgrtel und Werwolf-Eigenschaft */ + /* magische R�stung durch Artefakte oder Spr�che */ + /* Momentan nur Trollg�rtel und Werwolf-Eigenschaft */ am = select_magicarmor(dt); if (rule_nat_armor == 0) { - /* natrliche Rstung ist halbkumulativ */ + /* nat�rliche R�stung ist halbkumulativ */ if (ar > 0) { ar += an / 2; } @@ -1133,7 +1134,7 @@ int calculate_armor(troop dt, const weapon_type *dwtype, const weapon_type *awty res *= (1 - dwtype->magres); } - /* gegen Magie wirkt nur natrliche und magische Rstung */ + /* gegen Magie wirkt nur nat�rliche und magische R�stung */ ar = an + am; *magres = res > 0 ? res : 0; } @@ -1273,7 +1274,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) rda -= hp; me->duration -= hp; } - /* gibt Rstung +effect fr duration Treffer */ + /* gibt R�stung +effect f�r duration Treffer */ if (me->typ == SHIELD_ARMOR) { rda = _max(rda - me->effect, 0); me->duration--; @@ -1296,7 +1297,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) } } - if (df->person[dt.index].hp > 0) { /* Hat berlebt */ + if (df->person[dt.index].hp > 0) { /* Hat �berlebt */ if (bdebug) { fprintf(bdebug, "Damage %d, armor %d: %d -> %d HP\n", da, ar, df->person[dt.index].hp + rda, df->person[dt.index].hp); @@ -1702,7 +1703,7 @@ void do_combatmagic(battle * b, combatmagic_t was) unit *mage = fig->unit; if (fig->alive <= 0) - continue; /* fighter kann im Kampf gettet worden sein */ + continue; /* fighter kann im Kampf get�tet worden sein */ level = effskill(mage, SK_MAGIC, r); if (level > 0) { @@ -1811,12 +1812,12 @@ static void do_combatspell(troop at) sp = get_combatspell(caster, 1); if (sp == NULL) { - fi->magic = 0; /* Hat keinen Kampfzauber, kmpft nichtmagisch weiter */ + fi->magic = 0; /* Hat keinen Kampfzauber, k�mpft nichtmagisch weiter */ return; } ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); if (!cancast(caster, sp, 1, 1, ord)) { - fi->magic = 0; /* Kann nicht mehr Zaubern, kmpft nichtmagisch weiter */ + fi->magic = 0; /* Kann nicht mehr Zaubern, k�mpft nichtmagisch weiter */ return; } @@ -1840,7 +1841,7 @@ static void do_combatspell(troop at) } } - /* Antimagie die Fehlschlag erhht */ + /* Antimagie die Fehlschlag erh�ht */ if (rng_int() % 100 < fumblechance) { report_failed_spell(b, caster, sp); pay_spell(caster, sp, level, 1); @@ -1864,7 +1865,7 @@ static void do_combatspell(troop at) } /* Sonderattacken: Monster patzern nicht und zahlen auch keine - * Spruchkosten. Da die Spruchstrke direkt durch den Level bestimmt + * Spruchkosten. Da die Spruchst�rke direkt durch den Level bestimmt * wird, wirkt auch keine Antimagie (wird sonst in spellpower * gemacht) */ @@ -1916,7 +1917,7 @@ int skilldiff(troop at, troop dt, int dist) if (strongwall_ct) { curse *c = get_curse(df->building->attribs, strongwall_ct); if (curse_active(c)) { - /* wirkt auf alle Gebude */ + /* wirkt auf alle Geb�ude */ skdiff -= curse_geteffect_int(c); is_protected = 2; } @@ -2021,7 +2022,7 @@ int hits(troop at, troop dt, weapon * awp) } skdiff = skilldiff(at, dt, dist); - /* Verteidiger bekommt eine Rstung */ + /* Verteidiger bekommt eine R�stung */ armor = select_armor(dt, true); if (dwp == NULL || (dwp->type->flags & WTF_USESHIELD)) { shield = select_armor(dt, false); @@ -2065,7 +2066,7 @@ void damage_building(battle * b, building * bldg, int damage_abs) { bldg->size = _max(1, bldg->size - damage_abs); - /* Wenn Burg, dann gucken, ob die Leute alle noch in das Gebude passen. */ + /* Wenn Burg, dann gucken, ob die Leute alle noch in das Geb�ude passen. */ if (bldg->type->protection) { side *s; @@ -2123,7 +2124,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack) switch (a->type) { case AT_COMBATSPELL: /* Magier versuchen immer erstmal zu zaubern, erst wenn das - * fehlschlgt, wird af->magic == 0 und der Magier kmpft + * fehlschl�gt, wird af->magic == 0 und der Magier k�mpft * konventionell weiter */ if (numattack == 0 && af->magic > 0) { /* wenn der magier in die potenzielle Reichweite von Attacken des @@ -2135,7 +2136,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack) } } break; - case AT_STANDARD: /* Waffen, mag. Gegenstnde, Kampfzauber */ + case AT_STANDARD: /* Waffen, mag. Gegenst�nde, Kampfzauber */ if (numattack > 0 || af->magic <= 0) { weapon *wp = ta.fighter->person[ta.index].missile; int melee = @@ -2152,7 +2153,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack) bool standard_attack = true; bool reload = false; /* spezialattacken der waffe nur, wenn erste attacke in der runde. - * sonst helden mit feuerschwertern zu mchtig */ + * sonst helden mit feuerschwertern zu m�chtig */ if (numattack == 0 && wp && wp->type->attack) { int dead = 0; standard_attack = wp->type->attack(&ta, wp->type, &dead); @@ -2200,7 +2201,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack) } } break; - case AT_SPELL: /* Extra-Sprche. Kampfzauber in AT_COMBATSPELL! */ + case AT_SPELL: /* Extra-Spr�che. Kampfzauber in AT_COMBATSPELL! */ do_extra_spell(ta, a); break; case AT_NATURAL: @@ -2285,14 +2286,14 @@ void do_attack(fighter * af) assert(au && au->number); /* Da das Zuschlagen auf Einheiten und nicht auf den einzelnen - * Kmpfern beruht, darf die Reihenfolge und Gre der Einheit keine + * K�mpfern beruht, darf die Reihenfolge und Gr��e der Einheit keine * Rolle spielen, Das tut sie nur dann, wenn jeder, der am Anfang der - * Runde lebte, auch zuschlagen darf. Ansonsten ist der, der zufllig - * mit einer groen Einheit zuerst drankommt, extrem bevorteilt. */ + * Runde lebte, auch zuschlagen darf. Ansonsten ist der, der zuf�llig + * mit einer gro�en Einheit zuerst drankommt, extrem bevorteilt. */ ta.index = af->fighting; while (ta.index--) { - /* Wir suchen eine beliebige Feind-Einheit aus. An der knnen + /* Wir suchen eine beliebige Feind-Einheit aus. An der k�nnen * wir feststellen, ob noch jemand da ist. */ int apr, attacks = attacks_per_round(ta); if (!count_enemies(b, af, FIGHT_ROW, LAST_ROW, SELECT_FIND)) @@ -2317,7 +2318,7 @@ void do_attack(fighter * af) } } } - /* Der letzte Katapultschtze setzt die + /* Der letzte Katapultsch�tze setzt die * Ladezeit neu und generiert die Meldung. */ if (af->catmsg >= 0) { struct message *m = @@ -2391,7 +2392,7 @@ double fleechance(unit * u) { double c = 0.20; /* Fluchtwahrscheinlichkeit in % */ attrib *a = a_find(u->attribs, &at_fleechance); - /* Einheit u versucht, dem Getmmel zu entkommen */ + /* Einheit u versucht, dem Get�mmel zu entkommen */ c += (effskill(u, SK_STEALTH, 0) * 0.05); c += horse_fleeing_bonus(u); @@ -2679,7 +2680,7 @@ static void aftermath(battle * b) for (s = b->sides; s != b->sides + b->nsides; ++s) { int snumber = 0; fighter *df; - bool relevant = false; /* Kampf relevant fr diese Partei? */ + bool relevant = false; /* Kampf relevant f�r diese Partei? */ if (!fval(s, SIDE_HASGUARDS)) { relevant = true; } @@ -2719,7 +2720,7 @@ static void aftermath(battle * b) /* Report the casualties */ reportcasualties(b, df, dead); - /* Zuerst drfen die Feinde plndern, die mitgenommenen Items + /* Zuerst d�rfen die Feinde pl�ndern, die mitgenommenen Items * stehen in fig->run.items. Dann werden die Fliehenden auf * die leere (tote) alte Einheit gemapt */ if (!fval(df, FIG_NOLOOT)) { @@ -2754,7 +2755,7 @@ static void aftermath(battle * b) } else { if (df->alive == 0) { - /* alle sind tot, niemand geflohen. Einheit auflsen */ + /* alle sind tot, niemand geflohen. Einheit aufl�sen */ df->run.number = 0; df->run.hp = 0; @@ -2816,7 +2817,7 @@ static void aftermath(battle * b) /* Wir benutzen drifted, um uns zu merken, ob ein Schiff * schonmal Schaden genommen hat. (moved und drifted - * sollten in flags berfhrt werden */ + * sollten in flags �berf�hrt werden */ for (s = b->sides; s != b->sides + b->nsides; ++s) { fighter *df; @@ -2837,7 +2838,7 @@ static void aftermath(battle * b) } /* Wenn sich die Einheit auf einem Schiff befindet, wird - * dieses Schiff beschdigt. Andernfalls ein Schiff, welches + * dieses Schiff besch�digt. Andernfalls ein Schiff, welches * evt. zuvor verlassen wurde. */ if (ships_damaged) { if (du->ship) @@ -3210,8 +3211,8 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) else if (!stealthfaction) { s1->stealthfaction = NULL; } - /* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit fr noch - * keinen Kampf ausgewhlt wurde (sonst wrde ein fighter existieren) */ + /* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit f�r noch + * keinen Kampf ausgew�hlt wurde (sonst w�rde ein fighter existieren) */ } fig = (struct fighter*)calloc(1, sizeof(struct fighter)); @@ -3219,8 +3220,8 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) s1->fighters = fig; fig->unit = u; - /* In einer Burg mu man a) nicht Angreifer sein, und b) drin sein, und - * c) noch Platz finden. d) menschanhnlich sein */ + /* In einer Burg mu� man a) nicht Angreifer sein, und b) drin sein, und + * c) noch Platz finden. d) menschan�hnlich sein */ if (attack) { set_attacker(fig); } @@ -3246,7 +3247,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) assert(h); rest = u->hp % u->number; - /* Effekte von Sprchen */ + /* Effekte von Spr�chen */ if (u->attribs) { const curse_type *speed_ct; @@ -3267,7 +3268,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) /* Effekte von Artefakten */ strongmen = _min(fig->unit->number, trollbelts(u)); - /* Hitpoints, Attack- und Defence-Boni fr alle Personen */ + /* Hitpoints, Attack- und Defence-Boni f�r alle Personen */ for (i = 0; i < fig->alive; i++) { assert(i < fig->unit->number); fig->person[i].hp = h; @@ -3288,8 +3289,8 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) } } - /* Fr alle Waffengattungen wird bestimmt, wie viele der Personen mit - * ihr kmpfen knnten, und was ihr Wert darin ist. */ + /* F�r alle Waffengattungen wird bestimmt, wie viele der Personen mit + * ihr k�mpfen k�nnten, und was ihr Wert darin ist. */ if (u_race(u)->battle_flags & BF_EQUIPMENT) { int oi = 0, di = 0, w = 0; for (itm = u->items; itm && w != WMAX; itm = itm->next) { @@ -3407,12 +3408,12 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) } } - /* Jetzt mu noch geschaut werden, wo die Einheit die jeweils besten - * Werte hat, das kommt aber erst irgendwo spter. Ich entscheide - * wrend des Kampfes, welche ich nehme, je nach Gegner. Deswegen auch + /* Jetzt mu� noch geschaut werden, wo die Einheit die jeweils besten + * Werte hat, das kommt aber erst irgendwo sp�ter. Ich entscheide + * w�rend des Kampfes, welche ich nehme, je nach Gegner. Deswegen auch * keine addierten boni. */ - /* Zuerst mal die Spezialbehandlung gewisser Sonderflle. */ + /* Zuerst mal die Spezialbehandlung gewisser Sonderf�lle. */ fig->magic = effskill(u, SK_MAGIC, 0); if (fig->horses) { @@ -3577,7 +3578,7 @@ battle *make_battle(region * r) b->region = r; b->plane = getplane(r); - /* Finde alle Parteien, die den Kampf beobachten knnen: */ + /* Finde alle Parteien, die den Kampf beobachten k�nnen: */ for (u = r->units; u; u = u->next) { if (u->number > 0) { if (!fval(u->faction, FFL_MARK)) { @@ -3766,18 +3767,18 @@ static void join_allies(battle * b) for (s = b->sides; s != s_end; ++s) { side *se; - /* Wenn alle attackierten noch FFL_NOAID haben, dann kmpfe nicht mit. */ + /* Wenn alle attackierten noch FFL_NOAID haben, dann k�mpfe nicht mit. */ if (fval(s->faction, FFL_NOAID)) continue; if (s->faction != f) { /* Wenn wir attackiert haben, kommt niemand mehr hinzu: */ if (s->bf->attacker) continue; - /* alliiert mssen wir schon sein, sonst ist's eh egal : */ + /* alliiert m�ssen wir schon sein, sonst ist's eh egal : */ if (!alliedunit(u, s->faction, HELP_FIGHT)) continue; /* wenn die partei verborgen ist, oder gar eine andere - * vorgespiegelt wird, und er sich uns gegenber nicht zu + * vorgespiegelt wird, und er sich uns gegen�ber nicht zu * erkennen gibt, helfen wir ihm nicht */ if (s->stealthfaction) { if (!allysfm(s, u->faction, HELP_FSTEALTH)) { @@ -3785,7 +3786,7 @@ static void join_allies(battle * b) } } } - /* einen alliierten angreifen drfen sie nicht, es sei denn, der + /* einen alliierten angreifen d�rfen sie nicht, es sei denn, der * ist mit einem alliierten verfeindet, der nicht attackiert * hat: */ for (se = b->sides; se != s_end; ++se) { @@ -3799,7 +3800,7 @@ static void join_allies(battle * b) } if (se == s_end) continue; - /* Wenn die Einheit belagert ist, mu auch einer der Alliierten belagert sein: */ + /* Wenn die Einheit belagert ist, mu� auch einer der Alliierten belagert sein: */ if (besieged(u)) { fighter *ally; for (ally = s->fighters; ally; ally = ally->next) { @@ -3810,7 +3811,7 @@ static void join_allies(battle * b) if (ally == NULL) continue; } - /* keine Einwnde, also soll er mitmachen: */ + /* keine Einw�nde, also soll er mitmachen: */ if (c == NULL) { if (join_battle(b, u, false, &c)) { if (battledebug) { @@ -3926,7 +3927,7 @@ static bool start_battle(region * r, battle ** bp) continue; } - /* ist ein Flchtling aus einem andern Kampf */ + /* ist ein Fl�chtling aus einem andern Kampf */ if (fval(u, UFL_LONGACTION)) continue; @@ -3947,7 +3948,7 @@ static bool start_battle(region * r, battle ** bp) cmistake(u, ord, 234, MSG_BATTLE); } else { - /* Fehler: "Das Schiff mu erst verlassen werden" */ + /* Fehler: "Das Schiff mu� erst verlassen werden" */ cmistake(u, ord, 19, MSG_BATTLE); } continue; @@ -4032,8 +4033,8 @@ static bool start_battle(region * r, battle ** bp) freset(u2->faction, FFL_NOAID); if (c1 != NULL && c2 != NULL) { - /* Merken, wer Angreifer ist, fr die Rckzahlung der - * Prcombataura bei kurzem Kampf. */ + /* Merken, wer Angreifer ist, f�r die R�ckzahlung der + * Pr�combataura bei kurzem Kampf. */ c1->side->bf->attacker = true; if (set_enemy(c1->side, c2->side, true) && battledebug) { @@ -4066,7 +4067,7 @@ static void battle_attacks(battle * b) && get_tactics(s, NULL) == b->max_tactics)) { for (fig = s->fighters; fig; fig = fig->next) { - /* ist in dieser Einheit noch jemand handlungsfhig? */ + /* ist in dieser Einheit noch jemand handlungsf�hig? */ if (fig->fighting <= 0) continue; @@ -4110,7 +4111,7 @@ static void battle_flee(battle * b) unit *u = fig->unit; troop dt; int runners = 0; - /* Flucht nicht bei mehr als 600 HP. Damit Wyrme ttbar 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))); if (u->ship && fval(u->region->terrain, SEA_REGION)) { @@ -4230,7 +4231,7 @@ void do_battle(region * r) return; /* Bevor wir die alliierten hineinziehen, sollten wir schauen, * - * Ob jemand fliehen kann. Dann erbrigt sich das ganze ja + * Ob jemand fliehen kann. Dann er�brigt sich das ganze ja * vielleicht schon. */ print_header(b); if (!fighting) { @@ -4279,8 +4280,8 @@ void do_battle(region * r) if (rule_force_leave(FORCE_LEAVE_POSTCOMBAT)) { force_leave(b->region, b); } - /* Hier ist das Gefecht beendet, und wir knnen die - * Hilfsstrukturen * wieder lschen: */ + /* Hier ist das Gefecht beendet, und wir k�nnen die + * Hilfsstrukturen * wieder l�schen: */ if (b) { free_battle(b); diff --git a/src/battle.h b/src/battle.h index 3e156070d..6984a0d62 100644 --- a/src/battle.h +++ b/src/battle.h @@ -30,7 +30,7 @@ extern "C" { #define FS_HELP 2 /***** Verteidigungslinien. - * Eressea hat 4 Verteidigungslinien. 1 ist vorn, 5. enthlt Summen + * Eressea hat 4 Verteidigungslinien. 1 ist vorn, 5. enth�lt Summen */ #define NUMROWS 5 @@ -74,7 +74,7 @@ extern "C" { struct fighter *fighters; int index; /* Eintrag der Fraktion in b->matrix/b->enemies */ int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */ - int nonblockers[NUMROWS]; /* Anzahl nichtblockierender Kmpfer, z.B. Schattenritter. */ + int nonblockers[NUMROWS]; /* Anzahl nichtblockierender K�mpfer, z.B. Schattenritter. */ int alive; /* Die Partei hat den Kampf verlassen */ int removed; /* stoned */ int flee; @@ -131,7 +131,7 @@ extern "C" { /*** fighter::person::flags ***/ #define FL_TIRED 1 -#define FL_DAZZLED 2 /* durch Untote oder Dmonen eingeschchtert */ +#define FL_DAZZLED 2 /* durch Untote oder D�monen eingesch�chtert */ #define FL_PANICED 4 #define FL_COURAGE 8 /* Helden fliehen nie */ #define FL_SLEEPING 16 @@ -156,17 +156,17 @@ extern "C" { typedef struct fighter { struct fighter *next; struct side *side; - struct unit *unit; /* Die Einheit, die hier kmpft */ - struct building *building; /* Gebude, in dem die Einheit evtl. steht */ + struct unit *unit; /* Die Einheit, die hier k�mpft */ + struct building *building; /* Geb�ude, in dem die Einheit evtl. steht */ status_t status; /* Kampfstatus */ struct weapon *weapons; - struct armor *armors; /* Anzahl Rstungen jeden Typs */ + struct armor *armors; /* Anzahl R�stungen jeden Typs */ int alive; /* Anzahl der noch nicht Toten in der Einheit */ - int fighting; /* Anzahl der Kmpfer in der aktuellen Runde */ + int fighting; /* Anzahl der K�mpfer in der aktuellen Runde */ int removed; /* Anzahl Kaempfer, die nicht tot sind, aber aus dem Kampf raus sind (zB weil sie versteinert wurden). Diese werden auch - in alive noch mitgezhlt! */ + in alive noch mitgez�hlt! */ int magic; /* Magietalent der Einheit */ int horses; /* Anzahl brauchbarer Pferde der Einheit */ int elvenhorses; /* Anzahl brauchbarer Elfenpferde der Einheit */ @@ -179,7 +179,7 @@ extern "C" { int defence : 8; /* (Magie) Paradenbonus der Personen */ int damage : 8; /* (Magie) Schadensbonus der Personen im Nahkampf */ int damage_rear : 8; /* (Magie) Schadensbonus der Personen im Fernkampf */ - int flags : 8; /* (Magie) Diverse Flags auf Kmpfern */ + int flags : 8; /* (Magie) Diverse Flags auf K�mpfern */ int speed : 8; /* (Magie) Geschwindigkeitsmultiplkator. */ int reload : 4; /* Anzahl Runden, die die Waffe x noch laden muss. * dahinter steckt ein array[RL_MAX] wenn er min. eine hat. */ @@ -224,6 +224,7 @@ extern "C" { } meffect; extern const troop no_troop; + extern bool battledebug; /* BEGIN battle interface */ side * find_side(battle * b, const struct faction * f, const struct group * g, unsigned int flags, const struct faction * stealthfaction); diff --git a/src/kernel/config.c b/src/kernel/config.c index 10b35bce9..28147d509 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -102,7 +102,6 @@ struct settings global = { bool lomem = false; FILE *logfile; -bool battledebug = false; int turn = -1; const char *parameters[MAXPARAMS] = { diff --git a/src/kernel/config.h b/src/kernel/config.h index ca2686a1b..b9bb3f4d3 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -167,7 +167,6 @@ struct param; extern const char *localenames[]; extern settings global; - extern bool battledebug; extern bool sqlpatch; extern bool lomem; /* save memory */ extern int turn; diff --git a/src/main.c b/src/main.c index 5fd154b23..16f56bf57 100644 --- a/src/main.c +++ b/src/main.c @@ -25,6 +25,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "eressea.h" +#include "battle.h" #ifdef USE_CURSES #include "gmtool.h" #endif From d5218b99b8faeca61d7a7bca6e70e4cecccd4116 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 10:51:58 +0100 Subject: [PATCH 242/675] do not include config.h from util (also, wasn't needed) also remove it from monsters. --- src/util/language.test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/language.test.c b/src/util/language.test.c index d86f1b2a7..236eac497 100644 --- a/src/util/language.test.c +++ b/src/util/language.test.c @@ -1,5 +1,4 @@ #include -#include #include "language.h" #include From e3b7e197502943319c7eea6546259f98a1501b30 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 10:57:20 +0100 Subject: [PATCH 243/675] sometims we only include config.h for fval. I hate fval. --- src/items/seed.c | 8 +++----- src/monster.h | 2 +- src/races/zombies.c | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/items/seed.c b/src/items/seed.c index 0e4b54e98..f17e8ed29 100644 --- a/src/items/seed.c +++ b/src/items/seed.c @@ -17,13 +17,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "seed.h" /* kernel includes */ #include -#include #include #include @@ -42,7 +40,7 @@ static void produce_seeds(region * r, const resource_type * rtype, int norders) static int limit_seeds(const region * r, const resource_type * rtype) { - if (fval(r, RF_MALLORN)) { + if ((r->flags & RF_MALLORN)) { return 0; } return r->land ? r->land->trees[0] : 0; @@ -68,13 +66,13 @@ void init_seed(void) static void produce_mallornseeds(region * r, const resource_type * rtype, int norders) { - assert(fval(r, RF_MALLORN)); + assert(r->flags & RF_MALLORN); r->land->trees[0] -= norders; } static int limit_mallornseeds(const region * r, const resource_type * rtype) { - if (!fval(r, RF_MALLORN)) { + if (!(r->flags & RF_MALLORN)) { return 0; } return r->land ? r->land->trees[0] : 0; diff --git a/src/monster.h b/src/monster.h index 476bcb73e..0f936b17d 100644 --- a/src/monster.h +++ b/src/monster.h @@ -31,7 +31,7 @@ extern "C" { void make_zombie(struct unit * u); #define MONSTER_ID 666 -#define is_monsters(f) (fval(f, FFL_NPC) && f==get_monsters()) +#define is_monsters(f) ((f->flags & FFL_NPC) && f==get_monsters()) #ifdef __cplusplus } diff --git a/src/races/zombies.c b/src/races/zombies.c index ab4c89988..d7f871dac 100644 --- a/src/races/zombies.c +++ b/src/races/zombies.c @@ -15,7 +15,6 @@ #include /* kernel includes */ -#include #include #include #include @@ -40,7 +39,7 @@ void make_undead_unit(unit * u) { free_orders(&u->orders); name_unit(u); - fset(u, UFL_ISNEW); + u->flags |= UFL_ISNEW; } void age_undead(unit * u) From b24f8b28393ba68e482344356e5016951434302b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 11:25:02 +0100 Subject: [PATCH 244/675] remove config.h from items/ --- src/items/artrewards.c | 1 - src/items/demonseye.c | 1 - src/items/itemtypes.c | 1 - src/items/speedsail.c | 1 - src/items/weapons.c | 1 - src/items/xerewards.c | 1 - 6 files changed, 6 deletions(-) diff --git a/src/items/artrewards.c b/src/items/artrewards.c index 0965125fd..602841d23 100644 --- a/src/items/artrewards.c +++ b/src/items/artrewards.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "artrewards.h" /* kernel includes */ diff --git a/src/items/demonseye.c b/src/items/demonseye.c index 704e77f4c..ffc1c5179 100644 --- a/src/items/demonseye.c +++ b/src/items/demonseye.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "demonseye.h" /* kernel includes */ diff --git a/src/items/itemtypes.c b/src/items/itemtypes.c index ca56b1273..930829668 100644 --- a/src/items/itemtypes.c +++ b/src/items/itemtypes.c @@ -11,7 +11,6 @@ */ #include -#include #include "itemtypes.h" #include "xerewards.h" diff --git a/src/items/speedsail.c b/src/items/speedsail.c index 9d5aad747..8bdaa41ab 100644 --- a/src/items/speedsail.c +++ b/src/items/speedsail.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "speedsail.h" /* kernel includes */ diff --git a/src/items/weapons.c b/src/items/weapons.c index f5015e39a..1806e61a0 100644 --- a/src/items/weapons.c +++ b/src/items/weapons.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "weapons.h" #include "battle.h" diff --git a/src/items/xerewards.c b/src/items/xerewards.c index 98e099070..ab5226a32 100644 --- a/src/items/xerewards.c +++ b/src/items/xerewards.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "xerewards.h" #include "magic.h" From d1d1bee8f6e58c189d1bdd11a769a17fdc1a1554 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 11:27:20 +0100 Subject: [PATCH 245/675] missing struct declarations in curse.h remove config.h from spells and curses. --- src/kernel/curse.h | 2 ++ src/spells/buildingcurse.c | 1 - src/spells/magicresistance.c | 1 - src/spells/magicresistance.test.c | 1 - src/spells/regioncurse.c | 3 +-- src/spells/shipcurse.c | 1 - src/spells/unitcurse.c | 1 - 7 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/kernel/curse.h b/src/kernel/curse.h index 0de1211c7..29498f4d2 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -30,6 +30,8 @@ extern "C" { struct curse_type; struct gamedata; struct storage; + struct attrib; + struct faction; /* Sprueche in der struct region und auf Einheiten, Schiffen oder Burgen * (struct attribute) diff --git a/src/spells/buildingcurse.c b/src/spells/buildingcurse.c index d3b5ddf36..01b0435ab 100644 --- a/src/spells/buildingcurse.c +++ b/src/spells/buildingcurse.c @@ -12,7 +12,6 @@ */ #include -#include #include "buildingcurse.h" /* kernel includes */ diff --git a/src/spells/magicresistance.c b/src/spells/magicresistance.c index 3587a1be6..a897ea348 100644 --- a/src/spells/magicresistance.c +++ b/src/spells/magicresistance.c @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/src/spells/magicresistance.test.c b/src/spells/magicresistance.test.c index 4b0d69388..e9cc98e34 100644 --- a/src/spells/magicresistance.test.c +++ b/src/spells/magicresistance.test.c @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/src/spells/regioncurse.c b/src/spells/regioncurse.c index 382b13b86..3d7593484 100644 --- a/src/spells/regioncurse.c +++ b/src/spells/regioncurse.c @@ -12,7 +12,6 @@ */ #include -#include #include "regioncurse.h" #include "magic.h" @@ -50,7 +49,7 @@ static message *cinfo_cursed_by_the_gods(const void *obj, objtype_t typ, unused_arg(self); assert(typ == TYP_REGION); - if (fval(r->terrain, SEA_REGION)) { + if (r->terrain->flags & SEA_REGION) { return msg_message("curseinfo::godcurseocean", "id", c->no); } return msg_message("curseinfo::godcurse", "id", c->no); diff --git a/src/spells/shipcurse.c b/src/spells/shipcurse.c index 8da3c7c89..59cc534d4 100644 --- a/src/spells/shipcurse.c +++ b/src/spells/shipcurse.c @@ -12,7 +12,6 @@ */ #include -#include #include "shipcurse.h" /* kernel includes */ diff --git a/src/spells/unitcurse.c b/src/spells/unitcurse.c index 944db2032..6e769145e 100644 --- a/src/spells/unitcurse.c +++ b/src/spells/unitcurse.c @@ -12,7 +12,6 @@ */ #include -#include #include "unitcurse.h" /* kernel includes */ From 38f1d538287d953facd95b39fbac8729e2f53bf7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 11:39:36 +0100 Subject: [PATCH 246/675] temporarily enable osx builds --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 78aaf3648..92ac2a93d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ addons: - valgrind os: - linux + - osx notifications: slack: secure: F89aXLWaE125PaJIlETv12jT4EfH6wLXJmGCPZzrN3OcLn2ahDWqjwuzR7lOEDf2nAISmeMPyDZMhEHXLNHAE5qP6lg9yliYQw5hzGmDK9m1xUq/pPEne/b2Y7K3my1mkRZ6n3asbHgSmBWAfCIk1JN8R5Rv+rmbLuWLc+zofts= From 476c655cd35edad9e39a7c0f2d14c90444620df3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 12:43:37 +0100 Subject: [PATCH 247/675] disable osx builds again --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 92ac2a93d..78aaf3648 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,6 @@ addons: - valgrind os: - linux - - osx notifications: slack: secure: F89aXLWaE125PaJIlETv12jT4EfH6wLXJmGCPZzrN3OcLn2ahDWqjwuzR7lOEDf2nAISmeMPyDZMhEHXLNHAE5qP6lg9yliYQw5hzGmDK9m1xUq/pPEne/b2Y7K3my1mkRZ6n3asbHgSmBWAfCIk1JN8R5Rv+rmbLuWLc+zofts= From 6c9e1fb3453d8f8bc49bb644e75bccfced8513ab Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 17:06:31 +0100 Subject: [PATCH 248/675] more config.h removal. freset/fset/fval must die! --- src/kernel/config.c | 8 ----- src/kernel/config.h | 1 - src/kernel/race.h | 34 +++++++++--------- src/kernel/ship.h | 16 ++++----- src/spells.c | 32 ++++++++--------- src/spells/combatspells.c | 74 +++++++++++++++++++-------------------- src/spells/flyingship.c | 19 +++++----- src/util/rand.c | 8 +++++ src/util/rand.h | 11 +++--- tolua | 1 + 10 files changed, 102 insertions(+), 102 deletions(-) create mode 160000 tolua diff --git a/src/kernel/config.c b/src/kernel/config.c index 28147d509..e673dd31f 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -905,14 +905,6 @@ int wage(const region * r, const faction * f, const race * rc, int in_turn) return default_wage(r, f, rc, in_turn); } -int lovar(double xpct_x2) -{ - int n = (int)(xpct_x2 * 500) + 1; - if (n == 0) - return 0; - return (rng_int() % n + rng_int() % n) / 1000; -} - void kernel_init(void) { register_reports(); diff --git a/src/kernel/config.h b/src/kernel/config.h index b9bb3f4d3..a0a0d8588 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -56,7 +56,6 @@ struct param; const char * game_name(void); int game_id(void); - int lovar(double xpct_x2); /* returns a value between [0..xpct_2], generated with two dice */ void init_locale(struct locale *lang); diff --git a/src/kernel/race.h b/src/kernel/race.h index dc3becabb..80b09fbbf 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -117,7 +117,7 @@ extern "C" { float healing; double maxaura; /* Faktor auf Maximale Aura */ double regaura; /* Faktor auf Regeneration */ - double recruit_multi; /* Faktor fr Bauernverbrauch */ + double recruit_multi; /* Faktor f�r Bauernverbrauch */ int index; int recruitcost; int maintenance; @@ -132,8 +132,8 @@ extern "C" { int armor; int at_default; /* Angriffsskill Unbewaffnet (default: -2) */ int df_default; /* Verteidigungsskill Unbewaffnet (default: -2) */ - int at_bonus; /* Verndert den Angriffsskill (default: 0) */ - int df_bonus; /* Verndert den Verteidigungskill (default: 0) */ + int at_bonus; /* Ver�ndert den Angriffsskill (default: 0) */ + int df_bonus; /* Ver�ndert den Verteidigungskill (default: 0) */ struct param *parameters; // additional properties, for an example see natural_armor const struct spell *precombatspell; signed char *study_speed; /* study-speed-bonus in points/turn (0=30 Tage) */ @@ -190,20 +190,20 @@ extern "C" { #define RCF_LEARN (1<<6) /* Lernt automatisch wenn struct faction == 0 */ #define RCF_FLY (1<<7) /* kann fliegen */ #define RCF_SWIM (1<<8) /* kann schwimmen */ -#define RCF_WALK (1<<9) /* kann ber Land gehen */ +#define RCF_WALK (1<<9) /* kann �ber Land gehen */ #define RCF_NOLEARN (1<<10) /* kann nicht normal lernen */ #define RCF_NOTEACH (1<<11) /* kann nicht lehren */ #define RCF_HORSE (1<<12) /* Einheit ist Pferd, sozusagen */ #define RCF_DESERT (1<<13) /* 5% Chance, das Einheit desertiert */ #define RCF_ILLUSIONARY (1<<14) /* (Illusion & Spell) Does not drop items. */ -#define RCF_ABSORBPEASANTS (1<<15) /* Ttet und absorbiert Bauern */ +#define RCF_ABSORBPEASANTS (1<<15) /* T�tet und absorbiert Bauern */ #define RCF_NOHEAL (1<<16) /* Einheit kann nicht geheilt werden */ #define RCF_NOWEAPONS (1<<17) /* Einheit kann keine Waffen benutzen */ #define RCF_SHAPESHIFT (1<<18) /* Kann TARNE RASSE benutzen. */ #define RCF_SHAPESHIFTANY (1<<19) /* Kann TARNE RASSE "string" benutzen. */ #define RCF_UNDEAD (1<<20) /* Undead. */ -#define RCF_DRAGON (1<<21) /* Drachenart (fr Zauber) */ -#define RCF_COASTAL (1<<22) /* kann in Landregionen an der Kste sein */ +#define RCF_DRAGON (1<<21) /* Drachenart (f�r Zauber) */ +#define RCF_COASTAL (1<<22) /* kann in Landregionen an der K�ste sein */ #define RCF_UNARMEDGUARD (1<<23) /* kann ohne Waffen bewachen */ #define RCF_CANSAIL (1<<24) /* Einheit darf Schiffe betreten */ #define RCF_INVISIBLE (1<<25) /* not visible in any report */ @@ -213,16 +213,16 @@ extern "C" { #define RCF_ATTACK_MOVED (1<<29) /* may attack if it has moved */ /* Economic flags */ -#define ECF_KEEP_ITEM (1<<1) /* gibt Gegenstnde weg */ -#define GIVEPERSON (1<<2) /* bergibt Personen */ -#define GIVEUNIT (1<<3) /* Einheiten an andere Partei bergeben */ -#define GETITEM (1<<4) /* nimmt Gegenstnde an */ +#define ECF_KEEP_ITEM (1<<1) /* gibt Gegenst�nde weg */ +#define GIVEPERSON (1<<2) /* �bergibt Personen */ +#define GIVEUNIT (1<<3) /* Einheiten an andere Partei �bergeben */ +#define GETITEM (1<<4) /* nimmt Gegenst�nde an */ #define ECF_REC_ETHEREAL (1<<7) /* Rekrutiert aus dem Nichts */ #define ECF_REC_UNLIMITED (1<<8) /* Rekrutiert ohne Limit */ /* Battle-Flags */ -#define BF_EQUIPMENT (1<<0) /* Kann Ausrstung benutzen */ -#define BF_NOBLOCK (1<<1) /* Wird in die Rckzugsberechnung nicht einbezogen */ +#define BF_EQUIPMENT (1<<0) /* Kann Ausr�stung benutzen */ +#define BF_NOBLOCK (1<<1) /* Wird in die R�ckzugsberechnung nicht einbezogen */ #define BF_RES_PIERCE (1<<2) /* Halber Schaden durch PIERCE */ #define BF_RES_CUT (1<<3) /* Halber Schaden durch CUT */ #define BF_RES_BASH (1<<4) /* Halber Schaden durch BASH */ @@ -232,10 +232,10 @@ extern "C" { const char *racename(const struct locale *lang, const struct unit *u, const race * rc); -#define playerrace(rc) (!fval((rc), RCF_NPC)) -#define dragonrace(rc) (fval(rc, RCF_DRAGON)) -#define humanoidrace(rc) (fval((rc), RCF_UNDEAD) || (rc)==get_race(RC_DRACOID) || playerrace(rc)) -#define illusionaryrace(rc) (fval(rc, RCF_ILLUSIONARY)) +#define playerrace(rc) (!((rc)->flags & RCF_NPC)) +#define dragonrace(rc) ((rc)->flags & RCF_DRAGON) +#define humanoidrace(rc) (((rc)->flags & RCF_UNDEAD) || (rc)==get_race(RC_DRACOID) || playerrace(rc)) +#define illusionaryrace(rc) ((rc)->flags & RCF_ILLUSIONARY) bool allowed_dragon(const struct region *src, const struct region *target); diff --git a/src/kernel/ship.h b/src/kernel/ship.h index 73b8a9718..748315d44 100644 --- a/src/kernel/ship.h +++ b/src/kernel/ship.h @@ -51,8 +51,8 @@ extern "C" { int minskill; /* min. skill to sail this (crew) */ int sumskill; /* min. sum of crew+captain */ - int at_bonus; /* Verndert den Angriffsskill (default: 0) */ - int df_bonus; /* Verndert den Verteidigungskill (default: 0) */ + int at_bonus; /* Ver�ndert den Angriffsskill (default: 0) */ + int df_bonus; /* Ver�ndert den Verteidigungskill (default: 0) */ float tac_bonus; struct terrain_type ** coasts; /* coast that this ship can land on */ @@ -70,12 +70,12 @@ extern "C" { #define NOSHIP NULL -#define SF_DRIFTED 1<<0 -#define SF_MOVED 1<<1 -#define SF_DAMAGED 1<<2 /* for use in combat */ -#define SF_SELECT 1<<3 /* previously FL_DH */ -#define SF_FISHING 1<<4 /* was on an ocean, can fish */ -#define SF_FLYING 1<<5 /* the ship can fly */ +#define SF_DRIFTED (1<<0) +#define SF_MOVED (1<<1) +#define SF_DAMAGED (1<<2) /* for use in combat */ +#define SF_SELECT (1<<3) /* previously FL_DH */ +#define SF_FISHING (1<<4) /* was on an ocean, can fish */ +#define SF_FLYING (1<<5) /* the ship can fly */ #define SFL_SAVEMASK (SF_FLYING) #define INCOME_FISHING 10 diff --git a/src/spells.c b/src/spells.c index da2b73c5e..61e6e8b72 100644 --- a/src/spells.c +++ b/src/spells.c @@ -446,7 +446,7 @@ report_effect(region * r, unit * mage, message * seen, message * unseen) * Vertrauten sehen, und durch den Vertrauten zaubern, allerdings nur * mit seiner halben Stufe. Je nach Vertrautem erhaelt der Magier * evtl diverse Skillmodifikationen. Der Typ des Vertrauten ist - * zufaellig bestimmt, wird aber durch Magiegebiet und Rasse beeinflut. + * zufaellig bestimmt, wird aber durch Magiegebiet und Rasse beeinflu�t. * "Tierische" Vertraute brauchen keinen Unterhalt. * * Ein paar Moeglichkeiten: @@ -1599,7 +1599,7 @@ static int sp_create_stonegolem(castorder * co) } /* ------------------------------------------------------------- */ -/* Name: Groe Duerre +/* Name: Gro�e Duerre * Stufe: 17 * Kategorie: Region, negativ * Gebiet: Gwyrrd @@ -1907,7 +1907,7 @@ static int sp_treewalkexit(castorder * co) return 0; } - /* Koordinaten setzen und Region loeschen fuer berpruefung auf + /* Koordinaten setzen und Region loeschen fuer �berpruefung auf * Gueltigkeit */ rt = pa->param[0]->data.r; tax = rt->x; @@ -2194,7 +2194,7 @@ static int sp_ironkeeper(castorder * co) setstatus(keeper, ST_AVOID); /* kaempft nicht */ setguard(keeper, true); fset(keeper, UFL_ISNEW); - /* Parteitarnen, damit man nicht sofort wei, wer dahinter steckt */ + /* Parteitarnen, damit man nicht sofort wei�, wer dahinter steckt */ if (rule_stealth_anon()) { fset(keeper, UFL_ANON_FACTION); } @@ -2572,7 +2572,7 @@ void patzer_fumblecurse(const castorder * co) * * Wirkung: * In einer Wueste, Sumpf oder Gletscher gezaubert kann innerhalb der - * naechsten 6 Runden ein bis 6 Dracheneinheiten bis Groee Wyrm + * naechsten 6 Runden ein bis 6 Dracheneinheiten bis Groe�e Wyrm * entstehen. * * Mit Stufe 12-15 erscheinen Jung- oder normaler Drachen, mit Stufe @@ -2817,7 +2817,7 @@ static int change_hitpoints(unit * u, int value) hp += value; - /* Jede Person bentigt mindestens 1 HP */ + /* Jede Person ben�tigt mindestens 1 HP */ if (hp < u->number) { if (hp < 0) { /* Einheit tot */ hp = 0; @@ -3764,7 +3764,7 @@ static int sp_rallypeasantmob(castorder * co) * Gebiet: Cerddor * Wirkung: * Wiegelt 60% bis 90% der Bauern einer Region auf. Bauern werden ein - * groer Mob, der zur Monsterpartei gehoert und die Region bewacht. + * gro�er Mob, der zur Monsterpartei gehoert und die Region bewacht. * Regionssilber sollte auch nicht durch Unterhaltung gewonnen werden * koennen. * @@ -4025,7 +4025,7 @@ static int sp_recruit(castorder * co) return 0; } /* Immer noch zuviel auf niedrigen Stufen. Deshalb die Rekrutierungskosten - * mit einfliessen lassen und dafuer den Exponenten etwas groeer. + * mit einfliessen lassen und dafuer den Exponenten etwas groe�er. * Wenn die Rekrutierungskosten deutlich hoeher sind als der Faktor, * ist das Verhaeltniss von ausgegebene Aura pro Bauer bei Stufe 2 * ein mehrfaches von Stufe 1, denn in beiden Faellen gibt es nur 1 @@ -4056,7 +4056,7 @@ static int sp_recruit(castorder * co) } /* ------------------------------------------------------------- */ -/* Name: Wanderprediger - Groe Anwerbung +/* Name: Wanderprediger - Gro�e Anwerbung * Stufe: 14 * Gebiet: Cerddor * Wirkung: @@ -4112,8 +4112,8 @@ static int sp_bigrecruit(castorder * co) * Gebiet: Cerddor * Wirkung: * Erliegt die Einheit dem Zauber, so wird sie dem Magier alles - * erzaehlen, was sie ueber die gefragte Region wei. Ist in der Region - * niemand ihrer Partei, so wei sie nichts zu berichten. Auch kann + * erzaehlen, was sie ueber die gefragte Region wei�. Ist in der Region + * niemand ihrer Partei, so wei� sie nichts zu berichten. Auch kann * sie nur das erzaehlen, was sie selber sehen koennte. * Flags: * (UNITSPELL | TESTCANSEE) @@ -4176,7 +4176,7 @@ static int sp_pump(castorder * co) * Stufe: 6 * Gebiet: Cerddor * Wirkung: - * Betoert eine Einheit, so das sie ihm den groeten Teil ihres Bargelds + * 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) @@ -4333,7 +4333,7 @@ static int sp_headache(castorder * co) if (target->number == 0 || pa->param[0]->flag == TARGET_NOTFOUND) return 0; - /* finde das groete Talent: */ + /* finde das groe�te Talent: */ for (i = 0; i != target->skill_size; ++i) { skill *sv = target->skills + i; if (smax == NULL || skill_compare(sv, smax) > 0) { @@ -4479,7 +4479,7 @@ int sp_puttorest(castorder * co) return co->level; } -/* Name: Traumschloechen +/* Name: Traumschloe�chen * Stufe: 3 * Kategorie: Region, Gebaeude, positiv * Gebiet: Illaun @@ -4514,7 +4514,7 @@ int sp_icastle(castorder * co) b = new_building(bt_illusion, r, mage->faction->locale); - /* Groee festlegen. */ + /* Groe�e festlegen. */ if (type == bt_illusion) { b->size = (rng_int() % (int)((power * power) + 1) * 10); } @@ -4692,7 +4692,7 @@ int sp_baddreams(castorder * co) * Kategorie: * Wirkung: * Dieser Zauber ermoeglicht es dem Traeumer, den Schlaf aller aliierten - * Einheiten in der Region so zu beeinflussen, da sie fuer einige Zeit + * Einheiten in der Region so zu beeinflussen, da� sie fuer einige Zeit * einen Bonus von 1 Talentstufe in allen Talenten * bekommen. Der Zauber wirkt erst im Folgemonat. * Flags: diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index bf122729a..da7e7085a 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -10,7 +10,6 @@ without prior permission by the authors of Eressea. */ #include -#include #include "combatspells.h" /* kernel includes */ @@ -81,7 +80,7 @@ static const char *spell_damage(int sp) { switch (sp) { case 0: - /* meist tdlich 20-65 HP */ + /* meist t�dlich 20-65 HP */ return "5d10+15"; case 1: /* sehr variabel 4-48 HP */ @@ -90,7 +89,7 @@ static const char *spell_damage(int sp) /* leicht verwundet 4-18 HP */ return "2d8+2"; case 3: - /* fast immer tdlich 30-50 HP */ + /* fast immer t�dlich 30-50 HP */ return "5d5+25"; case 4: /* verwundet 11-26 HP */ @@ -382,11 +381,11 @@ int sp_combatrosthauch(struct castorder * co) ql_free(fgs); if (k == 0) { - /* keine Waffen mehr da, die zerstrt werden knnten */ + /* keine Waffen mehr da, die zerst�rt werden k�nnten */ message *msg = msg_message("rust_effect_1", "mage", fi->unit); message_all(b, msg); msg_release(msg); - fi->magic = 0; /* kmpft nichtmagisch weiter */ + fi->magic = 0; /* k�mpft nichtmagisch weiter */ level = 0; } else { @@ -453,7 +452,7 @@ int sp_speed(struct castorder * co) allies = count_allies(fi->side, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE, ALLY_ANY); - /* maximal 2*allies Versuche ein Opfer zu finden, ansonsten bestnde + /* maximal 2*allies Versuche ein Opfer zu finden, ansonsten best�nde * die Gefahr eine Endlosschleife*/ allies *= 2; @@ -546,7 +545,7 @@ int sp_mindblast_temp(struct castorder * co) assert(dt.fighter); du = dt.fighter->unit; - if (fval(du, UFL_MARK)) { + if (du->flags & UFL_MARK) { /* not this one again */ continue; } @@ -564,7 +563,7 @@ int sp_mindblast_temp(struct castorder * co) } force -= du->number; } - fset(du, UFL_MARK); + du->flags |= UFL_MARK; reset = 1; enemies -= du->number; } @@ -572,7 +571,7 @@ int sp_mindblast_temp(struct castorder * co) if (reset) { unit *u; for (u = b->region->units; u; u = u->next) { - freset(u, UFL_MARK); + u->flags &= ~UFL_MARK; } } @@ -612,7 +611,7 @@ int sp_mindblast(struct castorder * co) assert(dt.fighter); du = dt.fighter->unit; - if (fval(du, UFL_MARK)) { + if (du->flags & UFL_MARK) { /* not this one again */ continue; } @@ -640,7 +639,7 @@ int sp_mindblast(struct castorder * co) else { /* only works against humanoids, don't try others. but do remove them * from 'force' once or we may never terminate. */ - fset(du, UFL_MARK); + du->flags |= UFL_MARK; reset = 1; } enemies -= du->number; @@ -649,7 +648,7 @@ int sp_mindblast(struct castorder * co) if (reset) { unit *u; for (u = b->region->units; u; u = u->next) { - freset(u, UFL_MARK); + u->flags &= ~UFL_MARK; } } @@ -866,8 +865,8 @@ static fighter *summon_allies(const fighter *fi, const race *rc, int number) { u->hp = u->number * unit_max_hp(u); - if (fval(mage, UFL_ANON_FACTION)) { - fset(u, UFL_ANON_FACTION); + if (mage->flags & UFL_ANON_FACTION) { + u->flags |= UFL_ANON_FACTION; } a = a_new(&at_unitdissolve); @@ -932,8 +931,8 @@ int sp_shadowknights(struct castorder * co) u->hp = u->number * unit_max_hp(u); - if (fval(mage, UFL_ANON_FACTION)) { - fset(u, UFL_ANON_FACTION); + if (mage->flags & UFL_ANON_FACTION) { + u->flags |= UFL_ANON_FACTION; } a = a_new(&at_unitdissolve); @@ -1016,7 +1015,7 @@ int sp_chaosrow(struct castorder * co) continue; if (power <= 0.0) break; - /* force sollte wegen des _max(0,x) nicht unter 0 fallen knnen */ + /* force sollte wegen des _max(0,x) nicht unter 0 fallen k�nnen */ if (is_magic_resistant(mage, df->unit, 0)) continue; @@ -1068,7 +1067,7 @@ int sp_chaosrow(struct castorder * co) } /* Gesang der Furcht (Kampfzauber) */ -/* Panik (Prkampfzauber) */ +/* Panik (Pr�kampfzauber) */ int sp_flee(struct castorder * co) { @@ -1114,13 +1113,13 @@ int sp_flee(struct castorder * co) if (force < 0) break; - if (df->person[n].flags & FL_PANICED) { /* bei SPL_SONG_OF_FEAR mglich */ + if (df->person[n].flags & FL_PANICED) { /* bei SPL_SONG_OF_FEAR m�glich */ df->person[n].attack -= 1; --force; ++panik; } else if (!(df->person[n].flags & FL_COURAGE) - || !fval(u_race(df->unit), RCF_UNDEAD)) { + || !(u_race(df->unit)->flags & RCF_UNDEAD)) { if (!is_magic_resistant(mage, df->unit, 0)) { df->person[n].flags |= FL_PANICED; ++panik; @@ -1165,7 +1164,7 @@ int sp_hero(struct castorder * co) allies = count_allies(fi->side, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE, ALLY_ANY); - /* maximal 2*allies Versuche ein Opfer zu finden, ansonsten bestnde + /* maximal 2*allies Versuche ein Opfer zu finden, ansonsten best�nde * die Gefahr eine Endlosschleife*/ allies *= 2; @@ -1222,7 +1221,7 @@ int sp_berserk(struct castorder * co) allies = count_allies(fi->side, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE, ALLY_ANY); - /* maximal 2*allies Versuche ein Opfer zu finden, ansonsten bestnde + /* maximal 2*allies Versuche ein Opfer zu finden, ansonsten best�nde * die Gefahr eine Endlosschleife*/ allies *= 2; @@ -1419,7 +1418,7 @@ int sp_reeling_arrows(struct castorder * co) } /* Magier weicht dem Kampf aus. Wenn er sich bewegen kann, zieht er in - * eine Nachbarregion, wobei ein NACH bercksichtigt wird. Ansonsten + * eine Nachbarregion, wobei ein NACH ber�cksichtigt wird. Ansonsten * bleibt er stehen und nimmt nicht weiter am Kampf teil. */ int sp_denyattack(struct castorder * co) { @@ -1432,17 +1431,16 @@ int sp_denyattack(struct castorder * co) region *r = b->region; message *m; - /* Fliehende Einheiten verlassen auf jeden Fall Gebude und Schiffe. */ - if (!fval(r->terrain, SEA_REGION)) { + /* Fliehende Einheiten verlassen auf jeden Fall Geb�ude und Schiffe. */ + if (!(r->terrain->flags & SEA_REGION)) { leave(mage, false); } /* und bewachen nicht */ setguard(mage, false); /* irgendwie den langen befehl sperren */ - /* fset(fi, FIG_ATTACKED); */ - /* wir tun so, als wre die Person geflohen */ - fset(fi, FIG_NOLOOT); + /* wir tun so, als w�re die Person geflohen */ + fi->flags |= FIG_NOLOOT; fi->run.hp = mage->hp; fi->run.number = mage->number; /* fighter leeren */ @@ -1480,7 +1478,7 @@ int sp_armorshield(struct castorder * co) message_all(b, m); msg_release(m); - /* gibt Rstung +effect fr duration Treffer */ + /* gibt R�stung +effect f�r duration Treffer */ switch (sp->id) { case SPL_ARMORSHIELD: @@ -1539,7 +1537,7 @@ int sp_fumbleshield(struct castorder * co) message_all(b, m); msg_release(m); - /* der erste Zauber schlgt mit 100% fehl */ + /* der erste Zauber schl�gt mit 100% fehl */ switch (sp->id) { case SPL_DRAIG_FUMBLESHIELD: @@ -1605,7 +1603,7 @@ int sp_reanimate(struct castorder * co) && u_race(tf->unit) != get_race(RC_DAEMON) && (chance(c))) { assert(tf->alive < tf->unit->number); - /* t.fighter->person[].hp beginnt mit t.index = 0 zu zhlen, + /* t.fighter->person[].hp beginnt mit t.index = 0 zu z�hlen, * t.fighter->alive ist jedoch die Anzahl lebender in der Einheit, * also sind die hp von t.fighter->alive * t.fighter->hitpoints[t.fighter->alive-1] und der erste Tote @@ -1668,7 +1666,7 @@ static int heal_fighters(quicklist * fgs, int *power, bool heal_monsters) break; /* Untote kann man nicht heilen */ - if (df->unit->number == 0 || fval(u_race(df->unit), RCF_NOHEAL)) + if (df->unit->number == 0 || (u_race(df->unit)->flags & RCF_NOHEAL)) continue; /* wir heilen erstmal keine Monster */ @@ -1711,8 +1709,8 @@ int sp_healing(struct castorder * co) message *msg; bool use_item = has_ao_healing(mage); - /* bis zu 11 Personen pro Stufe (einen HP mssen sie ja noch - * haben, sonst wren sie tot) knnen geheilt werden */ + /* bis zu 11 Personen pro Stufe (einen HP m�ssen sie ja noch + * haben, sonst w�ren sie tot) k�nnen geheilt werden */ if (use_item) { healhp *= 2; @@ -1758,7 +1756,7 @@ int sp_undeadhero(struct castorder * co) int force = (int)get_force(power, 0); double c = 0.50 + 0.02 * power; - /* Liste aus allen Kmpfern */ + /* Liste aus allen K�mpfern */ fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY | FS_HELP); scramble_fighters(fgs); @@ -1776,7 +1774,7 @@ int sp_undeadhero(struct castorder * co) if (df->alive + df->run.number < du->number) { int j = 0; - /* Wieviele Untote knnen wir aus dieser Einheit wecken? */ + /* Wieviele Untote k�nnen wir aus dieser Einheit wecken? */ for (n = df->alive + df->run.number; n != du->number; n++) { if (chance(c)) { ++j; @@ -1818,8 +1816,8 @@ int sp_undeadhero(struct castorder * co) } /* inherit stealth from magician */ - if (fval(mage, UFL_ANON_FACTION)) { - fset(u, UFL_ANON_FACTION); + if (mage->flags & UFL_ANON_FACTION) { + u->flags |= UFL_ANON_FACTION; } /* transfer dead people to new unit, set hitpoints to those of old unit */ diff --git a/src/spells/flyingship.c b/src/spells/flyingship.c index 4a3c62e5e..2057b72e0 100644 --- a/src/spells/flyingship.c +++ b/src/spells/flyingship.c @@ -1,5 +1,4 @@ #include -#include #include "flyingship.h" #include @@ -27,8 +26,8 @@ * Stufe: 6 * * Wirkung: -* Laet ein Schiff eine Runde lang fliegen. Wirkt nur auf Boote -* bis Kapazitt 50. +* Lae�t ein Schiff eine Runde lang fliegen. Wirkt nur auf Boote +* bis Kapazit�t 50. * Kombinierbar mit "Guenstige Winde", aber nicht mit "Sturmwind". * * Flag: @@ -81,18 +80,20 @@ int sp_flying_ship(castorder * co) /* melden, 1x pro Partei */ for (u = r->units; u; u = u->next) - freset(u->faction, FFL_SELECT); + u->faction->flags &= ~FFL_SELECT; for (u = r->units; u; u = u->next) { /* das sehen natuerlich auch die Leute an Land */ - if (!fval(u->faction, FFL_SELECT)) { - fset(u->faction, FFL_SELECT); - if (!m) + if (!(u->faction->flags & FFL_SELECT)) { + u->faction->flags |= FFL_SELECT; + if (!m) { m = msg_message("flying_ship_result", "mage ship", mage, sh); + } add_message(&u->faction->msgs, m); } } - if (m) + if (m) { msg_release(m); + } return cast_level; } @@ -120,7 +121,7 @@ static int flyingship_age(curse * c) { ship *sh = (ship *)c->data.v; if (sh && c->duration == 1) { - freset(sh, SF_FLYING); + sh->flags &= ~SF_FLYING; return 1; } return 0; diff --git a/src/util/rand.c b/src/util/rand.c index d98b9b8f9..b92b4aff3 100644 --- a/src/util/rand.c +++ b/src/util/rand.c @@ -28,6 +28,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +int lovar(double xpct_x2) +{ + int n = (int)(xpct_x2 * 500) + 1; + if (n == 0) + return 0; + return (rng_int() % n + rng_int() % n) / 1000; +} + /* NormalRand aus python, random.py geklaut, dort ist Referenz auf * den Algorithmus. mu = Mittelwert, sigma = Standardabweichung. * http://de.wikipedia.org/wiki/Standardabweichung#Diskrete_Gleichverteilung.2C_W.C3.BCrfel diff --git a/src/util/rand.h b/src/util/rand.h index e9e5d19ee..9fb3f2f69 100644 --- a/src/util/rand.h +++ b/src/util/rand.h @@ -23,13 +23,14 @@ extern "C" { #endif /* in dice.c: */ - extern int dice_rand(const char *str); - extern int dice(int count, int value); + int dice_rand(const char *str); + int dice(int count, int value); /* in rand.c: */ - extern double normalvariate(double mu, double sigma); - extern int ntimespprob(int n, double p, double mod); - extern bool chance(double x); + int lovar(double xpct_x2); + double normalvariate(double mu, double sigma); + int ntimespprob(int n, double p, double mod); + bool chance(double x); /* a random source that generates numbers in [0, 1). By calling the random_source_inject... functions you can set a special random source, diff --git a/tolua b/tolua new file mode 160000 index 000000000..de289b60c --- /dev/null +++ b/tolua @@ -0,0 +1 @@ +Subproject commit de289b60c5009b6ac8e786f39432c08eadbb69b7 From 2f305f16d93ca28236a325d0e48faab9f1ee68b9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 21:08:35 +0100 Subject: [PATCH 249/675] additional testing for renumber. --- src/kernel/unit.c | 6 ++- src/renumber.c | 11 +--- src/renumber.test.c | 122 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 128 insertions(+), 11 deletions(-) diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 28e95b941..95c689ded 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -494,6 +494,10 @@ attrib_type at_alias = { NO_READ }; +/** remember old unit.no (for the creport, mostly) + * if alias is positive, then this unit was a TEMP + * if alias is negative, then this unit has been RENUMBERed + */ int ualias(const unit * u) { attrib *a = a_find(u->attribs, &at_alias); @@ -1716,7 +1720,7 @@ void renumber_unit(unit *u, int no) { uunhash(u); if (!ualias(u)) { attrib *a = a_add(&u->attribs, a_new(&at_alias)); - a->data.i = -u->no; // TODO: why is the alias negative? confusing! + a->data.i = -u->no; } u->no = no; uhash(u); diff --git a/src/renumber.c b/src/renumber.c index 259dfcc2b..de2b5a490 100644 --- a/src/renumber.c +++ b/src/renumber.c @@ -36,7 +36,6 @@ void renumber_factions(void) attrib *a = a_find(f->attribs, &at_number); int want; struct renum **rn; - faction *old; if (!a) continue; @@ -45,12 +44,6 @@ void renumber_factions(void) ADDMSG(&f->msgs, msg_message("renumber_twice", "id", want)); continue; } - old = findfaction(want); - if (old) { - a_remove(&f->attribs, a); - ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want)); - continue; - } if (!faction_id_is_unused(want)) { a_remove(&f->attribs, a); ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want)); @@ -151,7 +144,7 @@ int renumber_cmd(unit * u, order * ord) cmistake(u, ord, 114, MSG_EVENT); break; } - if (findship(i) || findbuilding(i)) { + if (findship(i)) { cmistake(u, ord, 115, MSG_EVENT); break; } @@ -180,7 +173,7 @@ int renumber_cmd(unit * u, order * ord) cmistake(u, ord, 114, MSG_EVENT); break; } - if (findship(i) || findbuilding(i)) { + if (findbuilding(i)) { cmistake(u, ord, 115, MSG_EVENT); break; } diff --git a/src/renumber.test.c b/src/renumber.test.c index 3fabaf4c1..9ab6b1e7b 100644 --- a/src/renumber.test.c +++ b/src/renumber.test.c @@ -29,6 +29,25 @@ static void test_renumber_faction(CuTest *tc) { test_cleanup(); } +static void test_renumber_faction_duplicate(CuTest *tc) { + unit *u; + faction *f, *f2; + int no; + const struct locale *lang; + + test_setup_ex(tc); + f2 = test_create_faction(0); + u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0)); + no = f->no; + lang = f->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_FACTION]), itoa36(f2->no)); + renumber_cmd(u, u->thisorder); + renumber_factions(); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "renumber_inuse")); + CuAssertIntEquals(tc, no, u->faction->no); + test_cleanup(); +} + static void test_renumber_building(CuTest *tc) { unit *u; int uno, no; @@ -46,6 +65,26 @@ static void test_renumber_building(CuTest *tc) { test_cleanup(); } +static void test_renumber_building_duplicate(CuTest *tc) { + unit *u; + faction *f; + int uno, no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0)); + u->building = test_create_building(u->region, 0); + uno = u->building->no; + u->building = test_create_building(u->region, 0); + no = u->building->no; + lang = f->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_BUILDING]), itoa36(uno)); + renumber_cmd(u, u->thisorder); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115")); + CuAssertIntEquals(tc, no, u->building->no); + test_cleanup(); +} + static void test_renumber_ship(CuTest *tc) { unit *u; int uno, no; @@ -63,6 +102,26 @@ static void test_renumber_ship(CuTest *tc) { test_cleanup(); } +static void test_renumber_ship_duplicate(CuTest *tc) { + unit *u; + faction *f; + int uno, no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0)); + u->ship = test_create_ship(u->region, 0); + uno = u->ship->no; + u->ship = test_create_ship(u->region, 0); + no = u->ship->no; + lang = f->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(uno)); + renumber_cmd(u, u->thisorder); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115")); + CuAssertIntEquals(tc, no, u->ship->no); + test_cleanup(); +} + static void test_renumber_unit(CuTest *tc) { unit *u; int uno, no; @@ -76,7 +135,62 @@ static void test_renumber_unit(CuTest *tc) { u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_UNIT]), itoa36(uno)); renumber_cmd(u, u->thisorder); CuAssertIntEquals(tc, uno, u->no); - CuAssertIntEquals(tc, -no, ualias(u)); // TODO: why is ualias negative? + CuAssertIntEquals(tc, -no, ualias(u)); + test_cleanup(); +} + +static void test_renumber_unit_duplicate(CuTest *tc) { + unit *u, *u2; + faction *f; + int no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0)); + no = u->no; + u2 = test_create_unit(f, u->region); + lang = f->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_UNIT]), itoa36(u2->no)); + renumber_cmd(u, u->thisorder); + CuAssertIntEquals(tc, no, u->no); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115")); + CuAssertIntEquals(tc, 0, ualias(u)); + test_cleanup(); +} + +static void test_renumber_unit_limit(CuTest *tc) { + unit *u; + faction *f; + int no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0)); + no = u->no; + lang = f->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s 10000", LOC(lang, parameters[P_UNIT])); + renumber_cmd(u, u->thisorder); + CuAssertIntEquals(tc, no, u->no); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error114")); + CuAssertIntEquals(tc, 0, ualias(u)); + test_cleanup(); +} + +static void test_renumber_unit_invalid(CuTest *tc) { + unit *u; + faction *f; + int no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0)); + no = u->no; + lang = f->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s TEMP", LOC(lang, parameters[P_UNIT])); + renumber_cmd(u, u->thisorder); + CuAssertIntEquals(tc, no, u->no); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error116")); + CuAssertIntEquals(tc, 0, ualias(u)); test_cleanup(); } @@ -84,8 +198,14 @@ CuSuite *get_renumber_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_renumber_unit); + SUITE_ADD_TEST(suite, test_renumber_unit_limit); + SUITE_ADD_TEST(suite, test_renumber_unit_duplicate); + SUITE_ADD_TEST(suite, test_renumber_unit_invalid); SUITE_ADD_TEST(suite, test_renumber_building); + SUITE_ADD_TEST(suite, test_renumber_building_duplicate); SUITE_ADD_TEST(suite, test_renumber_ship); + SUITE_ADD_TEST(suite, test_renumber_ship_duplicate); SUITE_ADD_TEST(suite, test_renumber_faction); + SUITE_ADD_TEST(suite, test_renumber_faction_duplicate); return suite; } From bc5e7443477fb7afe5dda2548975302ef4c9598d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 21:23:49 +0100 Subject: [PATCH 250/675] i2b is a bullshit macro. --- src/battle.c | 2 +- src/creport.c | 4 ++-- src/kernel/config.h | 2 -- src/magic.c | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/battle.c b/src/battle.c index 2facbb30f..34d4618a5 100644 --- a/src/battle.c +++ b/src/battle.c @@ -3130,7 +3130,7 @@ static void print_stats(battle * b) static int weapon_weight(const weapon * w, bool missile) { - if (missile == i2b(fval(w->type, WTF_MISSILE))) { + if (missile == !!(fval(w->type, WTF_MISSILE))) { return w->attackskill + w->defenseskill; } return 0; diff --git a/src/creport.c b/src/creport.c index b74c5cdef..b63a30ad4 100644 --- a/src/creport.c +++ b/src/creport.c @@ -782,7 +782,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f, if (sf != u->faction) stream_printf(out, "%d;Verkleidung\n", sf->no); if (fval(u, UFL_ANON_FACTION)) - stream_printf(out, "%d;Parteitarnung\n", i2b(fval(u, UFL_ANON_FACTION))); + stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION)!=0); if (otherfaction && otherfaction != u->faction) { stream_printf(out, "%d;Anderepartei\n", otherfaction->no); } @@ -794,7 +794,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f, else { if (fval(u, UFL_ANON_FACTION)) { /* faction info is hidden */ - stream_printf(out, "%d;Parteitarnung\n", i2b(fval(u, UFL_ANON_FACTION))); + stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION) != 0); } else { const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); diff --git a/src/kernel/config.h b/src/kernel/config.h index b9bb3f4d3..fd929e8f7 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -34,8 +34,6 @@ struct param; #define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. L�nge der Strings, die * von struct unitname, etc. zur�ckgegeben werden. ohne die 0 */ -#define i2b(i) ((bool)((i)?(true):(false))) - #define fval(u, i) ((u)->flags & (i)) #define fset(u, i) ((u)->flags |= (i)) #define freset(u, i) ((u)->flags &= ~(i)) diff --git a/src/magic.c b/src/magic.c index 803f20c78..d13be7c07 100644 --- a/src/magic.c +++ b/src/magic.c @@ -347,7 +347,7 @@ attrib_type at_mage = { bool is_mage(const unit * u) { - return i2b(get_mage(u) != NULL); + return get_mage(u) != NULL; } sc_mage *get_mage(const unit * u) @@ -2167,7 +2167,7 @@ typedef struct familiar_data { bool is_familiar(const unit * u) { attrib *a = a_find(u->attribs, &at_familiarmage); - return i2b(a != NULL); + return a != NULL; } static void From 434cf8fce6371942654945f14f4c7416e29213f6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 21:27:19 +0100 Subject: [PATCH 251/675] the unitid macro is boring. --- src/battle.c | 8 ++++---- src/kernel/config.h | 2 -- src/report.c | 2 +- src/spells.c | 4 ++-- src/study.c | 2 +- src/triggers/shock.c | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/battle.c b/src/battle.c index 34d4618a5..b5d767535 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1216,7 +1216,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) while (chance(kritchance)) { if (bdebug) { - fprintf(bdebug, "%s/%d lands a critical hit\n", unitid(au), at.index); + fprintf(bdebug, "%s/%d lands a critical hit\n", itoa36(au->no), at.index); } da += dice_rand(damage); } @@ -1980,10 +1980,10 @@ debug_hit(troop at, const weapon * awp, troop dt, const weapon * dwp, int skdiff, int dist, bool success) { fprintf(bdebug, "%.4s/%d [%6s/%d] %s %.4s/%d [%6s/%d] with %d, distance %d\n", - unitid(at.fighter->unit), at.index, + itoa36(at.fighter->unit->no), at.index, LOC(default_locale, awp ? resourcename(awp->type->itype->rtype, 0) : "unarmed"), weapon_effskill(at, dt, awp, true, dist > 1), - success ? "hits" : "misses", unitid(dt.fighter->unit), dt.index, + success ? "hits" : "misses", itoa36(dt.fighter->unit->no), dt.index, LOC(default_locale, dwp ? resourcename(dwp->type->itype->rtype, 0) : "unarmed"), weapon_effskill(dt, at, dwp, false, dist > 1), skdiff, dist); @@ -2194,7 +2194,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack) if (reload && wp && wp->type->reload && !getreload(ta)) { int i = setreload(ta); if (bdebug) { - fprintf(bdebug, "%s/%d reloading %d turns\n", unitid(au), + fprintf(bdebug, "%s/%d reloading %d turns\n", itoa36(au->no), ta.index, i); } } diff --git a/src/kernel/config.h b/src/kernel/config.h index fd929e8f7..2f36f6bc9 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -45,8 +45,6 @@ struct param; bool isparam(const char *s, const struct locale * lang, param_t param); param_t getparam(const struct locale *lang); -#define unitid(x) itoa36((x)->no) - #define buildingid(x) itoa36((x)->no) #define shipid(x) itoa36((x)->no) #define factionid(x) itoa36((x)->no) diff --git a/src/report.c b/src/report.c index 80ac85974..b3549302a 100644 --- a/src/report.c +++ b/src/report.c @@ -1453,7 +1453,7 @@ report_template(const char *filename, report_context * ctx, const char *charset) size = sizeof(buf) - 1; bytes = _snprintf(bufp, size, "%s %s; %s [%d,%d$", LOC(u->faction->locale, parameters[P_UNIT]), - unitid(u), unit_getname(u), u->number, get_money(u)); + itoa36(u->no), unit_getname(u), u->number, get_money(u)); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); if (u->building && building_owner(u->building) == u) { diff --git a/src/spells.c b/src/spells.c index da2b73c5e..369dab924 100644 --- a/src/spells.c +++ b/src/spells.c @@ -6291,7 +6291,7 @@ int sp_q_antimagie(castorder * co) { unit *u = pa->param[0]->data.u; ap = &u->attribs; - ts = unitid(u); + ts = itoa36(u->no); break; } case SPP_BUILDING: @@ -6384,7 +6384,7 @@ int sp_break_curse(castorder * co) { unit *u = pa->param[0]->data.u; ap = &u->attribs; - ts = unitid(u); + ts = itoa36(u->no); break; } case SPP_BUILDING: diff --git a/src/study.c b/src/study.c index 1cd8847be..1dd4da8b8 100644 --- a/src/study.c +++ b/src/study.c @@ -439,7 +439,7 @@ int teach_cmd(unit * u, struct order *ord) strncat(zOrder, " ", sz - 1); --sz; } - sz -= strlcpy(zOrder + 4096 - sz, unitid(u2), sz); + sz -= strlcpy(zOrder + 4096 - sz, itoa36(u2->no), sz); if (getkeyword(u2->thisorder) != K_STUDY) { ADDMSG(&u->faction->msgs, diff --git a/src/triggers/shock.c b/src/triggers/shock.c index 75904e346..f44219b5f 100644 --- a/src/triggers/shock.c +++ b/src/triggers/shock.c @@ -118,7 +118,7 @@ static void shock_write(const trigger * t, struct storage *store) next = next->next; } if (next && u) { - log_error("more than one shock-attribut for %s on a unit. FIXED.\n", unitid(u)); + log_error("more than one shock-attribut for %s on a unit. FIXED.\n", itoa36(u->no)); write_unit_reference(NULL, store); } else { From 303eb863998402c308c46dcfa4bc8bc1e9433885 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 21:29:15 +0100 Subject: [PATCH 252/675] factionid and curseid are also boring. --- src/kernel/config.h | 2 -- src/kernel/faction.c | 6 +++--- src/kernel/save.c | 2 +- src/laws.c | 2 +- src/modules/score.c | 2 +- src/report.c | 2 +- src/reports.c | 8 ++++---- src/summary.c | 4 ++-- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/kernel/config.h b/src/kernel/config.h index 2f36f6bc9..a15a77ba4 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -47,8 +47,6 @@ struct param; #define buildingid(x) itoa36((x)->no) #define shipid(x) itoa36((x)->no) -#define factionid(x) itoa36((x)->no) -#define curseid(x) itoa36((x)->no) const char * game_name(void); int game_id(void); diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 0172ea835..6d2430de4 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -273,11 +273,11 @@ faction *addfaction(const char *email, const char *password, addlist(&factions, f); fhash(f); - slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), factionid(f)); + slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), itoa36(f->no)); f->name = _strdup(buf); if (!f->race) { - log_warning("creating a faction that has no race", factionid(f)); + log_warning("creating a faction that has no race", itoa36(f->no)); } return f; @@ -828,7 +828,7 @@ int writepasswd(void) for (f = factions; f; f = f->next) { fprintf(F, "%s:%s:%s:%u\n", - factionid(f), f->email, f->_password, f->subscription); + itoa36(f->no), f->email, f->_password, f->subscription); } fclose(F); return 0; diff --git a/src/kernel/save.c b/src/kernel/save.c index fa2beabc6..83fa72f76 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1291,7 +1291,7 @@ faction *read_faction(struct gamedata * data) }; f->banner = _strdup(name); - log_debug(" - Lese Partei %s (%s)", f->name, factionid(f)); + log_debug(" - Lese Partei %s (%s)", f->name, itoa36(f->no)); READ_STR(data->store, name, sizeof(name)); if (set_email(&f->email, name) != 0) { diff --git a/src/laws.c b/src/laws.c index 0ba3f4077..fd4f50b78 100644 --- a/src/laws.c +++ b/src/laws.c @@ -997,7 +997,7 @@ int quit_cmd(unit * u, struct order *ord) char buffer[64]; write_order(ord, buffer, sizeof(buffer)); cmistake(u, ord, 86, MSG_EVENT); - log_warning("QUIT with illegal password for faction %s: %s\n", factionid(f), buffer); + log_warning("QUIT with illegal password for faction %s: %s\n", itoa36(f->no), buffer); } return 0; } diff --git a/src/modules/score.c b/src/modules/score.c index 89cf90655..8213b8985 100644 --- a/src/modules/score.c +++ b/src/modules/score.c @@ -169,7 +169,7 @@ void score(void) fprintf(scoreFP, "%30.30s (%3.3s) %5s (%3d)\n", f->name, f->race->_name, - factionid(f), + itoa36(f->no), f->age); } fclose(scoreFP); diff --git a/src/report.c b/src/report.c index b3549302a..569674403 100644 --- a/src/report.c +++ b/src/report.c @@ -1406,7 +1406,7 @@ report_template(const char *filename, report_context * ctx, const char *charset) newline(out); newline(out); - sprintf(buf, "%s %s \"password\"", LOC(f->locale, "ERESSEA"), factionid(f)); + sprintf(buf, "%s %s \"password\"", LOC(f->locale, "ERESSEA"), itoa36(f->no)); rps_nowrap(out, buf); newline(out); newline(out); diff --git a/src/reports.c b/src/reports.c index 837ea1a31..fa39f0a85 100644 --- a/src/reports.c +++ b/src/reports.c @@ -140,7 +140,7 @@ static char *groupid(const struct group *g, const struct faction *f) static name idbuf[8]; static int nextbuf = 0; char *buf = idbuf[(++nextbuf) % 8]; - sprintf(buf, "%s (%s)", g->name, factionid(f)); + sprintf(buf, "%s (%s)", g->name, itoa36(f->no)); return buf; } @@ -1418,7 +1418,7 @@ int write_reports(faction * f, time_t ltime) do { char filename[32]; char path[MAX_PATH]; - sprintf(filename, "%d-%s.%s", turn, factionid(f), + sprintf(filename, "%d-%s.%s", turn, itoa36(f->no), rtype->extension); join_path(reportpath(), filename, path, sizeof(path)); errno = 0; @@ -1441,7 +1441,7 @@ int write_reports(faction * f, time_t ltime) } } if (!gotit) { - log_warning("No report for faction %s!", factionid(f)); + log_warning("No report for faction %s!", itoa36(f->no)); } finish_reports(&ctx); return 0; @@ -1452,7 +1452,7 @@ static void write_script(FILE * F, const faction * f) report_type *rtype; char buf[1024]; - fprintf(F, "faction=%s:email=%s:lang=%s", factionid(f), f->email, + fprintf(F, "faction=%s:email=%s:lang=%s", itoa36(f->no), f->email, locale_name(f->locale)); if (f->options & (1 << O_BZIP2)) fputs(":compression=bz2", F); diff --git a/src/summary.c b/src/summary.c index 8e9dea65d..b82c3a50e 100644 --- a/src/summary.c +++ b/src/summary.c @@ -96,12 +96,12 @@ int update_nmrs(void) int nmr = turn - f->lastorders + 1; if (timeout>0) { if (nmr < 0 || nmr > timeout) { - log_error("faction %s has %d NMR", factionid(f), nmr); + log_error("faction %s has %d NMR", itoa36(f->no), nmr); nmr = _max(0, nmr); nmr = _min(nmr, timeout); } if (nmr > 0) { - log_debug("faction %s has %d NMR", factionid(f), nmr); + log_debug("faction %s has %d NMR", itoa36(f->no), nmr); } ++nmrs[nmr]; } From 27605f18baf4e7ed6a4451bf7f0a0e6acf08df68 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 21:31:11 +0100 Subject: [PATCH 253/675] more boring macros removed. --- src/kernel/building.c | 2 +- src/kernel/config.h | 3 --- src/kernel/ship.c | 2 +- src/report.c | 2 +- src/spells.c | 8 ++++---- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/kernel/building.c b/src/kernel/building.c index 8789e40b2..60fd420fb 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -426,7 +426,7 @@ building *new_building(const struct building_type * btype, region * r, bname = parameters[P_GEBAEUDE]; } assert(bname); - slprintf(buffer, sizeof(buffer), "%s %s", bname, buildingid(b)); + slprintf(buffer, sizeof(buffer), "%s %s", bname, itoa36(b->no)); b->name = _strdup(bname); return b; } diff --git a/src/kernel/config.h b/src/kernel/config.h index a15a77ba4..6e1059092 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -45,9 +45,6 @@ struct param; bool isparam(const char *s, const struct locale * lang, param_t param); param_t getparam(const struct locale *lang); -#define buildingid(x) itoa36((x)->no) -#define shipid(x) itoa36((x)->no) - const char * game_name(void); int game_id(void); int lovar(double xpct_x2); diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 02a980b68..d01d0a788 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -201,7 +201,7 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang) sname = parameters[P_SHIP]; } assert(sname); - slprintf(buffer, sizeof(buffer), "%s %s", sname, shipid(sh)); + slprintf(buffer, sizeof(buffer), "%s %s", sname, itoa36(sh->no)); sh->name = _strdup(buffer); shash(sh); if (r) { diff --git a/src/report.c b/src/report.c index 569674403..dc52c38a3 100644 --- a/src/report.c +++ b/src/report.c @@ -1479,7 +1479,7 @@ report_template(const char *filename, report_context * ctx, const char *charset) } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - bytes = (int)strlcpy(bufp, shipid(u->ship), size); + bytes = (int)strlcpy(bufp, itoa36(u->ship->no), size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } diff --git a/src/spells.c b/src/spells.c index 369dab924..941b50014 100644 --- a/src/spells.c +++ b/src/spells.c @@ -6298,14 +6298,14 @@ int sp_q_antimagie(castorder * co) { building *b = pa->param[0]->data.b; ap = &b->attribs; - ts = buildingid(b); + ts = itoa36(b->no); break; } case SPP_SHIP: { ship *sh = pa->param[0]->data.sh; ap = &sh->attribs; - ts = shipid(sh); + ts = itoa36(sh->no); break; } default: @@ -6391,14 +6391,14 @@ int sp_break_curse(castorder * co) { building *b = pa->param[0]->data.b; ap = &b->attribs; - ts = buildingid(b); + ts = itoa36(b->no); break; } case SPP_SHIP: { ship *sh = pa->param[0]->data.sh; ap = &sh->attribs; - ts = shipid(sh); + ts = itoa36(sh->no); break; } default: From cb6be542b9ec5d0c3a87f4372c27a0acc5ce8af0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 21:32:24 +0100 Subject: [PATCH 254/675] remove unused variables. --- src/kernel/config.c | 1 - src/kernel/config.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index 28147d509..7206c501f 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -101,7 +101,6 @@ struct settings global = { }; bool lomem = false; -FILE *logfile; int turn = -1; const char *parameters[MAXPARAMS] = { diff --git a/src/kernel/config.h b/src/kernel/config.h index 6e1059092..011c487b1 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -158,10 +158,8 @@ struct param; extern const char *localenames[]; extern settings global; - extern bool sqlpatch; extern bool lomem; /* save memory */ extern int turn; - extern bool getunitpeasants; #ifdef __cplusplus } From dc2452e2c1bbb2760e5522ebebb924469c9a5b24 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 17 Nov 2016 22:10:41 +0100 Subject: [PATCH 255/675] config.h globals cleanup. --- src/kernel/config.h | 1 - src/triggers/changefaction.c | 1 - src/triggers/changerace.c | 1 - src/triggers/clonedied.c | 1 - src/util/language.h | 29 +++++++++++++++-------------- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/kernel/config.h b/src/kernel/config.h index 011c487b1..3e3aa2c2b 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -155,7 +155,6 @@ struct param; void free_config(void); extern const char *parameters[]; - extern const char *localenames[]; extern settings global; extern bool lomem; /* save memory */ diff --git a/src/triggers/changefaction.c b/src/triggers/changefaction.c index 218a8461f..37d993f4a 100644 --- a/src/triggers/changefaction.c +++ b/src/triggers/changefaction.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "changefaction.h" /* kernel includes */ diff --git a/src/triggers/changerace.c b/src/triggers/changerace.c index 0e7fc997e..f38b7f3d5 100644 --- a/src/triggers/changerace.c +++ b/src/triggers/changerace.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "changerace.h" /* kernel includes */ diff --git a/src/triggers/clonedied.c b/src/triggers/clonedied.c index 37693fdbf..642b50ab0 100644 --- a/src/triggers/clonedied.c +++ b/src/triggers/clonedied.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "clonedied.h" #include "magic.h" diff --git a/src/util/language.h b/src/util/language.h index a8d9096e7..a90398cc0 100644 --- a/src/util/language.h +++ b/src/util/language.h @@ -30,33 +30,34 @@ extern "C" { struct locale; struct critbit_tree; + extern const char *localenames[]; + extern struct locale *default_locale; + extern struct locale *locales; + extern struct locale *nextlocale(const struct locale *lang); + /** managing multiple locales: **/ - extern struct locale *get_locale(const char *name); - extern struct locale *get_or_create_locale(const char *key); + struct locale *get_locale(const char *name); + struct locale *get_or_create_locale(const char *key); void init_locales(void); void free_locales(void); void reset_locales(void); /** operations on locales: **/ - extern void locale_setstring(struct locale *lang, const char *key, + void locale_setstring(struct locale *lang, const char *key, const char *value); - extern const char *locale_getstring(const struct locale *lang, + const char *locale_getstring(const struct locale *lang, const char *key); - extern const char *locale_string(const struct locale *lang, const char *key, bool warn); /* does fallback */ - extern unsigned int locale_index(const struct locale *lang); - extern const char *locale_name(const struct locale *lang); + const char *locale_string(const struct locale *lang, const char *key, bool warn); /* does fallback */ + unsigned int locale_index(const struct locale *lang); + const char *locale_name(const struct locale *lang); - extern const char *mkname(const char *namespc, const char *key); - extern char *mkname_buf(const char *namespc, const char *key, char *buffer); + const char *mkname(const char *namespc, const char *key); + char *mkname_buf(const char *namespc, const char *key, char *buffer); - extern void make_locales(const char *str); + void make_locales(const char *str); #define LOC(lang, s) (lang?locale_string(lang, s, true):s) - extern struct locale *default_locale; - extern struct locale *locales; - extern struct locale *nextlocale(const struct locale *lang); - enum { UT_PARAMS, UT_KEYWORDS, From 8b46e1323a119ec8c1c753758ab4163f23fb116f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 18 Nov 2016 11:11:21 +0100 Subject: [PATCH 256/675] declare struct before use --- src/triggers/changerace.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/triggers/changerace.h b/src/triggers/changerace.h index 1b08110b3..e6b19dcb0 100644 --- a/src/triggers/changerace.h +++ b/src/triggers/changerace.h @@ -26,6 +26,7 @@ extern "C" { struct trigger_type; struct trigger; struct unit; + struct race; extern struct trigger_type tt_changerace; From 4d5c00be901198fb6beaf6c3662ee34a85b7f803 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 18 Nov 2016 11:38:50 +0100 Subject: [PATCH 257/675] git rm --cached tolua, to fix travis builds? --- tolua | 1 - 1 file changed, 1 deletion(-) delete mode 160000 tolua diff --git a/tolua b/tolua deleted file mode 160000 index de289b60c..000000000 --- a/tolua +++ /dev/null @@ -1 +0,0 @@ -Subproject commit de289b60c5009b6ac8e786f39432c08eadbb69b7 From 7d874f16065a34df6e25935c9b9986b6ecc8cec8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 18 Nov 2016 13:24:50 +0100 Subject: [PATCH 258/675] fix clang builds --- src/CMakeLists.txt | 6 ++++-- src/kernel/messages.test.c | 3 ++- src/spells/flyingship.h | 3 ++- src/util/functions.c | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34cea4037..7d7fba859 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,10 +17,12 @@ set_source_files_properties(kernel/version.c PROPERTIES COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}") ENDIF() -IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) +IF (CMAKE_COMPILER_IS_GNUCC) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") +ENDIF() +IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") add_definitions(-DHAVE__BOOL) ELSEIF(MSVC) diff --git a/src/kernel/messages.test.c b/src/kernel/messages.test.c index fc6079dfe..c391c8720 100644 --- a/src/kernel/messages.test.c +++ b/src/kernel/messages.test.c @@ -74,4 +74,5 @@ CuSuite *get_messages_suite(void) { SUITE_ADD_TEST(suite, test_merge_split); SUITE_ADD_TEST(suite, test_message); return suite; -} \ No newline at end of file +} + diff --git a/src/spells/flyingship.h b/src/spells/flyingship.h index 087357b9e..8b7bf0874 100644 --- a/src/spells/flyingship.h +++ b/src/spells/flyingship.h @@ -22,4 +22,5 @@ extern "C" { } #endif -#endif \ No newline at end of file +#endif + diff --git a/src/util/functions.c b/src/util/functions.c index 82792faaf..3776820eb 100644 --- a/src/util/functions.c +++ b/src/util/functions.c @@ -51,4 +51,5 @@ void register_function(pf_generic fun, const char *name) void free_functions(void) { cb_clear(&cb_functions); -} \ No newline at end of file +} + From ecbd0ba83c113b8bf6f6b89b635317b224c48e8b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 18 Nov 2016 13:30:24 +0100 Subject: [PATCH 259/675] github issue #606 disable volcano terrain change for snowglobe test --- scripts/tests/xmas.lua | 1 + src/volcano.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/tests/xmas.lua b/scripts/tests/xmas.lua index 3667de0b6..153052d5a 100644 --- a/scripts/tests/xmas.lua +++ b/scripts/tests/xmas.lua @@ -7,6 +7,7 @@ function setup() eressea.settings.set("nmr.timeout", "0") eressea.settings.set("rules.grow.formula", "0") eressea.settings.set("rules.peasants.growth.factor", "0") + eressea.settings.set("volcano.active.percent", "4") end function test_snowglobe_fail() diff --git a/src/volcano.c b/src/volcano.c index bd8c56b30..60beeaed7 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -284,7 +284,8 @@ void volcano_update(void) } } else if (r->terrain == t_volcano) { - if (rng_int() % 100 < 4) { + int volcano_chance = config_get_int("volcano.active.percent", 4); + if (rng_int() % 100 < volcano_chance) { ADDMSG(&r->msgs, msg_message("volcanostartsmoke", "region", r)); r->terrain = t_active; } From 14b4ae5859245151c3416051a3c2e09c3749f968 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 18 Nov 2016 22:31:06 +0100 Subject: [PATCH 260/675] set volcano acitvation chance to 0 during test. should fix issue #606 for good. also: additional tests for renumbering ships, Xolgrim is wrong. --- scripts/tests/common.lua | 15 +++++++++++++++ scripts/tests/xmas.lua | 2 +- src/renumber.test.c | 22 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index c39f2ce30..670060816 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -380,6 +380,21 @@ function test_events() assert(fail==0) end +function test_renumber_ship() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply4@eressea.de", "human", "de") + local u = unit.create(f, r) + local s = ship.create(r, config.ships[1]) + u.ship = s + u:add_order("NUMMER SCHIFF 1") + process_orders() + assert_equal(1, s.id) + u:clear_orders() + u:add_order("NUMMER SCHIFF 2") + process_orders() + assert_equal(2, s.id) +end + function test_recruit2() local r = region.create(0, 0, "plain") local f = faction.create("noreply4@eressea.de", "human", "de") diff --git a/scripts/tests/xmas.lua b/scripts/tests/xmas.lua index 153052d5a..7ac4ce731 100644 --- a/scripts/tests/xmas.lua +++ b/scripts/tests/xmas.lua @@ -7,7 +7,7 @@ function setup() eressea.settings.set("nmr.timeout", "0") eressea.settings.set("rules.grow.formula", "0") eressea.settings.set("rules.peasants.growth.factor", "0") - eressea.settings.set("volcano.active.percent", "4") + eressea.settings.set("volcano.active.percent", "0") end function test_snowglobe_fail() diff --git a/src/renumber.test.c b/src/renumber.test.c index 9ab6b1e7b..6c3f0f17b 100644 --- a/src/renumber.test.c +++ b/src/renumber.test.c @@ -102,6 +102,27 @@ static void test_renumber_ship(CuTest *tc) { test_cleanup(); } +static void test_renumber_ship_twice(CuTest *tc) { + unit *u; + int uno, no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + u->ship = test_create_ship(u->region, 0); + no = u->ship->no; + uno = (no > 1) ? no - 1 : no + 1; + lang = u->faction->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(uno)); + renumber_cmd(u, u->thisorder); + CuAssertIntEquals(tc, uno, u->ship->no); + free_order(u->thisorder); + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(no)); + renumber_cmd(u, u->thisorder); + CuAssertIntEquals(tc, no, u->ship->no); + test_cleanup(); +} + static void test_renumber_ship_duplicate(CuTest *tc) { unit *u; faction *f; @@ -204,6 +225,7 @@ CuSuite *get_renumber_suite(void) SUITE_ADD_TEST(suite, test_renumber_building); SUITE_ADD_TEST(suite, test_renumber_building_duplicate); SUITE_ADD_TEST(suite, test_renumber_ship); + SUITE_ADD_TEST(suite, test_renumber_ship_twice); SUITE_ADD_TEST(suite, test_renumber_ship_duplicate); SUITE_ADD_TEST(suite, test_renumber_faction); SUITE_ADD_TEST(suite, test_renumber_faction_duplicate); From 531da88b2a4c8735a4cc204e58015709f8c6f4f1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 19 Nov 2016 15:19:23 +0100 Subject: [PATCH 261/675] squash some static analysis warnings. --- src/alchemy.c | 9 ++------- src/battle.c | 22 +++++++--------------- src/lighthouse.c | 4 ++-- src/move.c | 4 ++-- src/spells.c | 5 ++--- src/teleport.c | 4 +--- tolua | 1 + 7 files changed, 17 insertions(+), 32 deletions(-) create mode 160000 tolua diff --git a/src/alchemy.c b/src/alchemy.c index 7eac102fb..cd33feadb 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -181,7 +181,7 @@ static int potion_power(unit *u, int amount) { if (u->number % 10 > 0) ++use; amount = use; } - /* Verfnffacht 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; return amount; } @@ -241,11 +241,6 @@ static void init_potiondelay(attrib * a) a->data.v = malloc(sizeof(potiondelay)); } -static void free_potiondelay(attrib * a) -{ - free(a->data.v); -} - static int age_potiondelay(attrib * a, void *owner) { potiondelay *pd = (potiondelay *)a->data.v; @@ -257,7 +252,7 @@ static int age_potiondelay(attrib * a, void *owner) attrib_type at_potiondelay = { "potiondelay", init_potiondelay, - free_potiondelay, + a_finalizeeffect, age_potiondelay, 0, 0 }; diff --git a/src/battle.c b/src/battle.c index b5d767535..3cf7b685a 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1022,16 +1022,15 @@ static int armor_bonus(const race *rc) { int natural_armor(unit * du) { const race *rc = u_race(du); - int bonus, an = rc->armor; + int an; assert(rc); - bonus = armor_bonus(rc); - if (bonus > 0) { + an = armor_bonus(rc); + if (an > 0) { int sk = effskill(du, SK_STAMINA, 0); - sk /= bonus; - an += sk; + an = sk / an; } - return an; + return an + rc->armor; } static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_type *wtype) @@ -2042,19 +2041,12 @@ int hits(troop at, troop dt, weapon * awp) void dazzle(battle * b, troop * td) { /* Nicht kumulativ ! */ - if (td->fighter->person[td->index].flags & FL_DAZZLED) - return; - #ifdef TODO_RUNESWORD if (td->fighter->weapon[WP_RUNESWORD].count > td->index) { return; } #endif - if (td->fighter->person[td->index].flags & FL_COURAGE) { - return; - } - - if (td->fighter->person[td->index].flags & FL_DAZZLED) { + if (td->fighter->person[td->index].flags & (FL_COURAGE|FL_DAZZLED) { return; } @@ -2497,7 +2489,7 @@ static int loot_quota(const unit * src, const unit * dst, { if (dst && src && src->faction != dst->faction) { double divisor = config_get_flt("rules.items.loot_divisor", 1); - assert(divisor == 0 || divisor >= 1); + assert(divisor <= 0 || divisor >= 1); if (divisor >= 1) { double r = n / divisor; int x = (int)r; diff --git a/src/lighthouse.c b/src/lighthouse.c index dd1183558..d962b9b76 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -16,7 +16,7 @@ const attrib_type at_lighthouse = { "lighthouse" - /* Rest ist NULL; temporres, nicht alterndes Attribut */ + /* Rest ist NULL; tempor�res, nicht alterndes Attribut */ }; /* update_lighthouse: call this function whenever the size of a lighthouse changes @@ -127,7 +127,7 @@ bool check_leuchtturm(region * r, faction * f) c += u->number; if (c > buildingcapacity(b)) break; - if (f == NULL || u->faction == f) { + if (u->faction == f) { if (!d) d = distance(r, r2); if (maxd < d) diff --git a/src/move.c b/src/move.c index 0888b6fde..b6a908837 100644 --- a/src/move.c +++ b/src/move.c @@ -1240,9 +1240,9 @@ static bool roadto(const region * r, direction_t dir) if (!r || dir >= MAXDIRECTIONS || dir < 0) return false; r2 = rconnect(r, dir); - if (r == NULL || r2 == NULL) + if (!r2) { return false; - + } if (r->attribs || r2->attribs) { const curse_type *roads_ct = ct_find("magicstreet"); if (roads_ct != NULL) { diff --git a/src/spells.c b/src/spells.c index ed17b8f42..57b1da3a5 100644 --- a/src/spells.c +++ b/src/spells.c @@ -3237,8 +3237,7 @@ static int sp_magicboost(castorder * co) } effect = 6; - c = create_curse(mage, &mage->attribs, ct_magicboost, power, 10, effect, 1); - + create_curse(mage, &mage->attribs, ct_magicboost, power, 10, effect, 1); /* one aura boost with 200% aura now: */ effect = 200; c = create_curse(mage, &mage->attribs, ct_auraboost, power, 4, effect, 1); @@ -4031,7 +4030,7 @@ static int sp_recruit(castorder * co) * ein mehrfaches von Stufe 1, denn in beiden Faellen gibt es nur 1 * Bauer, nur die Kosten steigen. */ n = (pow(force, 1.6) * 100) / f->race->recruitcost; - if (rc->recruit_multi != 0) { + if (rc->recruit_multi > 0) { double multp = (double)maxp / rc->recruit_multi; n = _min(multp, n); n = _max(n, 1); diff --git a/src/teleport.c b/src/teleport.c index c7e775345..74176f6af 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -185,9 +185,7 @@ plane *get_astralplane(void) if (!rule_astralplane) { return NULL; } - if (!astralspace) { - astralspace = getplanebyname("Astralraum"); - } + astralspace = getplanebyname("Astralraum"); if (!astralspace) { astralspace = create_new_plane(1, "Astralraum", TE_CENTER_X - 500, TE_CENTER_X + 500, diff --git a/tolua b/tolua new file mode 160000 index 000000000..de289b60c --- /dev/null +++ b/tolua @@ -0,0 +1 @@ +Subproject commit de289b60c5009b6ac8e786f39432c08eadbb69b7 From eabaf8bebba7eb110f2e0f0229d99fd3006b7bec Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 19 Nov 2016 16:27:37 +0100 Subject: [PATCH 262/675] fix last commit. --- src/alchemy.c | 6 +++++- src/battle.c | 6 +++--- tolua | 1 - 3 files changed, 8 insertions(+), 5 deletions(-) delete mode 160000 tolua diff --git a/src/alchemy.c b/src/alchemy.c index cd33feadb..9f942fc5a 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -241,6 +241,10 @@ static void init_potiondelay(attrib * a) a->data.v = malloc(sizeof(potiondelay)); } +static void free_potiondelay(attrib * a) { + free(a->data.v); +} + static int age_potiondelay(attrib * a, void *owner) { potiondelay *pd = (potiondelay *)a->data.v; @@ -252,7 +256,7 @@ static int age_potiondelay(attrib * a, void *owner) attrib_type at_potiondelay = { "potiondelay", init_potiondelay, - a_finalizeeffect, + free_potiondelay, age_potiondelay, 0, 0 }; diff --git a/src/battle.c b/src/battle.c index 3cf7b685a..b4468e843 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1028,9 +1028,9 @@ int natural_armor(unit * du) an = armor_bonus(rc); if (an > 0) { int sk = effskill(du, SK_STAMINA, 0); - an = sk / an; + return rc->armor + sk / an; } - return an + rc->armor; + return rc->armor; } static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_type *wtype) @@ -2046,7 +2046,7 @@ void dazzle(battle * b, troop * td) return; } #endif - if (td->fighter->person[td->index].flags & (FL_COURAGE|FL_DAZZLED) { + if (td->fighter->person[td->index].flags & (FL_COURAGE|FL_DAZZLED)) { return; } diff --git a/tolua b/tolua deleted file mode 160000 index de289b60c..000000000 --- a/tolua +++ /dev/null @@ -1 +0,0 @@ -Subproject commit de289b60c5009b6ac8e786f39432c08eadbb69b7 From 19a0c2ddb32947d3a5480da90899fd1ebfd27f80 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 19 Nov 2016 20:57:10 +0100 Subject: [PATCH 263/675] quelling some static analysis complaints. --- src/kernel/connection.c | 11 ++++------- src/kernel/jsonconf.c | 2 +- src/kernel/ship.c | 6 +++--- src/move.test.c | 4 ++-- src/piracy.test.c | 4 ++-- src/reports.c | 7 ++++--- src/upkeep.test.c | 3 ++- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/kernel/connection.c b/src/kernel/connection.c index f10fbc53d..6eccf1f0c 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -211,7 +211,7 @@ border_type *find_bordertype(const char *name) { border_type *bt = bordertypes; - while (bt && strcmp(bt->__name, name)) + while (bt && strcmp(bt->__name, name)!=0) bt = bt->next; return bt; } @@ -620,7 +620,6 @@ int read_borders(gamedata *data) assert(type || !"connection type not registered"); } - READ_INT(store, &bid); if (data->version < UIDHASH_VERSION) { int fx, fy, tx, ty; @@ -639,9 +638,7 @@ int read_borders(gamedata *data) to = findregionbyid(tid); } if (!to || !from) { - if (!to || !from) { - log_error("%s connection %d has missing regions", zText, bid); - } + log_error("%s connection %d has missing regions", zText, bid); if (type->read) { // skip ahead connection dummy; @@ -650,7 +647,7 @@ int read_borders(gamedata *data) continue; } - if (to == from && type && from) { + if (to == from && from) { direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS); region *r = rconnect(from, dir); log_error("[read_borders] invalid %s in %s\n", type->__name, regionname(from, NULL)); @@ -659,7 +656,7 @@ int read_borders(gamedata *data) } if (type->read) { connection *b = new_border(type, from, to); - nextborder--; /* new_border erhht den Wert */ + nextborder--; /* new_border erh�ht den Wert */ b->id = bid; assert(bid <= nextborder); type->read(b, data); diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 6e60fc90c..d12238566 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -796,7 +796,7 @@ static void json_settings(cJSON *json) { else { char value[32]; if (child->type == cJSON_Number && child->valuedouble && child->valueintvaluedouble) { - _snprintf(value, sizeof(value), "%lf", child->valuedouble); + _snprintf(value, sizeof(value), "%f", child->valuedouble); } else { _snprintf(value, sizeof(value), "%d", child->valueint); diff --git a/src/kernel/ship.c b/src/kernel/ship.c index d01d0a788..6898630ff 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -297,10 +297,9 @@ int crew_skill(const ship *sh) { int shipspeed(const ship * sh, const unit * u) { - int k = sh->type->range; attrib *a; struct curse *c; - int bonus; + int k, bonus; assert(sh); if (!u) u = ship_owner(sh); @@ -310,6 +309,7 @@ int shipspeed(const ship * sh, const unit * u) assert(sh->type->construction); assert(sh->type->construction->improvement == NULL); /* sonst ist construction::size nicht ship_type::maxsize */ + k = sh->type->range; if (sh->size != sh->type->construction->maxsize) return 0; @@ -417,7 +417,7 @@ static unit * ship_owner_ex(const ship * sh, const struct faction * last_owner) { unit *u, *heir = 0; - /* Eigentmer tot oder kein Eigentmer vorhanden. Erste lebende Einheit + /* Eigent�mer tot oder kein Eigent�mer vorhanden. Erste lebende Einheit * nehmen. */ for (u = sh->region->units; u; u = u->next) { if (u->ship == sh) { diff --git a/src/move.test.c b/src/move.test.c index 5c89166c8..bc93ec124 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -273,10 +273,10 @@ void setup_drift (struct drift_fixture *fix) { fix->st_boat->cabins = 20000; fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r=findregion(-1,0)); - assert(fix->r); + assert(fix->r && fix->u && fix->f); set_level(fix->u, SK_SAILING, fix->st_boat->sumskill); u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat)); - assert(fix->f && fix->u && fix->sh); + assert(fix->sh); } static void test_ship_no_overload(CuTest *tc) { diff --git a/src/piracy.test.c b/src/piracy.test.c index affb6f5c4..82e4e55b7 100644 --- a/src/piracy.test.c +++ b/src/piracy.test.c @@ -83,12 +83,12 @@ static void test_piracy_cmd(CuTest * tc) { t_ocean = get_or_create_terrain("ocean"); st_boat = st_get_or_create("boat"); u2 = test_create_unit(test_create_faction(0), test_create_region(1, 0, t_ocean)); - u_set_ship(u2, test_create_ship(u2->region, st_boat)); assert(u2); + u_set_ship(u2, test_create_ship(u2->region, st_boat)); u = test_create_unit(f = test_create_faction(0), r = test_create_region(0, 0, t_ocean)); + assert(f && u); set_level(u, SK_SAILING, st_boat->sumskill); u_set_ship(u, test_create_ship(u->region, st_boat)); - assert(f && u); f->locale = get_or_create_locale("de"); u->thisorder = create_order(K_PIRACY, f->locale, "%s", itoa36(u2->faction->no)); diff --git a/src/reports.c b/src/reports.c index fa39f0a85..f4c38712c 100644 --- a/src/reports.c +++ b/src/reports.c @@ -489,13 +489,14 @@ size_t size) building *b; bool isbattle = (bool)(mode == seen_battle); item *itm, *show = NULL; - faction *fv = visible_faction(f, u); + faction *fv; char *bufp = buf; int result = 0; item results[MAX_INVENTORY]; + assert(f); bufp = STRLCPY(bufp, unitname(u), size); - + fv = visible_faction(f, u); if (!isbattle) { attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); if (u->faction == f) { @@ -770,7 +771,7 @@ size_t size) } dh = 0; - if (!getarnt && f) { + if (!getarnt) { if (alliedfaction(rplane(u->region), f, fv, HELP_ALL)) { dh = 1; } diff --git a/src/upkeep.test.c b/src/upkeep.test.c index b4f2ae412..e84402d4b 100644 --- a/src/upkeep.test.c +++ b/src/upkeep.test.c @@ -81,10 +81,11 @@ void test_upkeep_from_pool(CuTest * tc) i_silver = it_find("money"); assert(i_silver); r = findregion(0, 0); + assert(r); u1 = test_create_unit(test_create_faction(test_create_race("human")), r); assert(u1); u2 = test_create_unit(u1->faction, r); - assert(r && u1 && u2); + assert(u2); config_set("rules.food.flags", "0"); i_change(&u1->items, i_silver, 30); From 55a0388eb2ac71eebe33039f2aca132f6fdafee6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 20 Nov 2016 14:50:38 +0100 Subject: [PATCH 264/675] fix truncated names that split a utf8 sequence. --- src/util/unicode.c | 17 ++++++++++++----- src/util/unicode.test.c | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/util/unicode.c b/src/util/unicode.c index f9a6d48ec..161983ba7 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -40,12 +40,19 @@ int unicode_utf8_trim(utf8_t *buf) size_t size = 1; wint_t wc = *ip; if (wc & 0x80) { - ucs4_t ucs; - int ret = unicode_utf8_to_ucs4(&ucs, ip, &size); - if (ret != 0) { - return ret; + ucs4_t ucs = 0; + if (ip[1]) { + int ret = unicode_utf8_to_ucs4(&ucs, ip, &size); + if (ret != 0) { + return ret; + } + wc = (wint_t)ucs; + } + else { + wc = *op = '?'; + size = 1; + ++result; } - wc = (wint_t)ucs; } if (op == buf && iswspace(wc)) { ++result; diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index 679c19d6b..e16ec7f96 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -28,6 +28,10 @@ static void test_unicode_trim(CuTest * tc) strcpy(buffer, " \t Hello Word"); CuAssertIntEquals(tc, 3, unicode_utf8_trim(buffer)); CuAssertStrEquals(tc, "Hello Word", buffer); + + buffer[9] = 0xc3; + CuAssertIntEquals(tc, 1, unicode_utf8_trim(buffer)); + CuAssertStrEquals(tc, "Hello Wor?", buffer); } static void test_unicode_tolower(CuTest * tc) @@ -87,11 +91,21 @@ static void test_unicode_utf8_to_other(CuTest *tc) CuAssertIntEquals(tc, 'l', ch); } +static void test_unicode_utf8_to_ucs(CuTest *tc) { + ucs4_t ucs; + size_t sz; + + CuAssertIntEquals(tc, 0, unicode_utf8_to_ucs4(&ucs, "a", &sz)); + CuAssertIntEquals(tc, 'a', ucs); + CuAssertIntEquals(tc, 1, sz); +} + CuSuite *get_unicode_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_unicode_tolower); SUITE_ADD_TEST(suite, test_unicode_trim); SUITE_ADD_TEST(suite, test_unicode_utf8_to_other); + SUITE_ADD_TEST(suite, test_unicode_utf8_to_ucs); return suite; } From 9ac74ceecc951b29efde99b22d3c71817ff3c15e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 20 Nov 2016 15:14:03 +0100 Subject: [PATCH 265/675] fix constant conversion error --- src/util/unicode.test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index e16ec7f96..6eb3c4c52 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -29,7 +29,7 @@ static void test_unicode_trim(CuTest * tc) CuAssertIntEquals(tc, 3, unicode_utf8_trim(buffer)); CuAssertStrEquals(tc, "Hello Word", buffer); - buffer[9] = 0xc3; + buffer[9] = (char)0xc3; CuAssertIntEquals(tc, 1, unicode_utf8_trim(buffer)); CuAssertStrEquals(tc, "Hello Wor?", buffer); } From a8f3cad143c8cf174fc21e988f525064a7149a7a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 20 Nov 2016 18:09:08 +0100 Subject: [PATCH 266/675] remove bad umlaut encodings, make sources US-ASCII. --- src/battle.h | 18 +++++++++--------- src/settings.h | 13 ++++++------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/battle.h b/src/battle.h index 6984a0d62..45feb10a1 100644 --- a/src/battle.h +++ b/src/battle.h @@ -30,7 +30,7 @@ extern "C" { #define FS_HELP 2 /***** Verteidigungslinien. - * Eressea hat 4 Verteidigungslinien. 1 ist vorn, 5. enth�lt Summen + * Eressea hat 4 Verteidigungslinien. 1 ist vorn, 5. enthaelt Summen */ #define NUMROWS 5 @@ -74,7 +74,7 @@ extern "C" { struct fighter *fighters; int index; /* Eintrag der Fraktion in b->matrix/b->enemies */ int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */ - int nonblockers[NUMROWS]; /* Anzahl nichtblockierender K�mpfer, z.B. Schattenritter. */ + int nonblockers[NUMROWS]; /* Anzahl nichtblockierender Kaempfer, z.B. Schattenritter. */ int alive; /* Die Partei hat den Kampf verlassen */ int removed; /* stoned */ int flee; @@ -131,7 +131,7 @@ extern "C" { /*** fighter::person::flags ***/ #define FL_TIRED 1 -#define FL_DAZZLED 2 /* durch Untote oder D�monen eingesch�chtert */ +#define FL_DAZZLED 2 /* durch Untote oder Daemonen eingeschuechtert */ #define FL_PANICED 4 #define FL_COURAGE 8 /* Helden fliehen nie */ #define FL_SLEEPING 16 @@ -156,17 +156,17 @@ extern "C" { typedef struct fighter { struct fighter *next; struct side *side; - struct unit *unit; /* Die Einheit, die hier k�mpft */ - struct building *building; /* Geb�ude, in dem die Einheit evtl. steht */ + struct unit *unit; /* Die Einheit, die hier kaempft */ + struct building *building; /* Gebaeude, in dem die Einheit evtl. steht */ status_t status; /* Kampfstatus */ struct weapon *weapons; - struct armor *armors; /* Anzahl R�stungen jeden Typs */ + struct armor *armors; /* Anzahl Ruestungen jeden Typs */ int alive; /* Anzahl der noch nicht Toten in der Einheit */ - int fighting; /* Anzahl der K�mpfer in der aktuellen Runde */ + int fighting; /* Anzahl der Kaempfer in der aktuellen Runde */ int removed; /* Anzahl Kaempfer, die nicht tot sind, aber aus dem Kampf raus sind (zB weil sie versteinert wurden). Diese werden auch - in alive noch mitgez�hlt! */ + in alive noch mitgezaehlt! */ int magic; /* Magietalent der Einheit */ int horses; /* Anzahl brauchbarer Pferde der Einheit */ int elvenhorses; /* Anzahl brauchbarer Elfenpferde der Einheit */ @@ -179,7 +179,7 @@ extern "C" { int defence : 8; /* (Magie) Paradenbonus der Personen */ int damage : 8; /* (Magie) Schadensbonus der Personen im Nahkampf */ int damage_rear : 8; /* (Magie) Schadensbonus der Personen im Fernkampf */ - int flags : 8; /* (Magie) Diverse Flags auf K�mpfern */ + int flags : 8; /* (Magie) Diverse Flags auf Kaempfern */ int speed : 8; /* (Magie) Geschwindigkeitsmultiplkator. */ int reload : 4; /* Anzahl Runden, die die Waffe x noch laden muss. * dahinter steckt ein array[RL_MAX] wenn er min. eine hat. */ diff --git a/src/settings.h b/src/settings.h index ecf3df9f2..b77e4687a 100644 --- a/src/settings.h +++ b/src/settings.h @@ -20,7 +20,7 @@ #undef NEWATSROI /* Vermehrungsrate Bauern in 1/10000. -* TODO: Evt. Berechnungsfehler, reale Vermehrungsraten scheinen hher. */ +* TODO: Evt. Berechnungsfehler, reale Vermehrungsraten scheinen hoeher. */ #define PEASANTGROWTH 10 #define PEASANTLUCK 10 @@ -37,22 +37,21 @@ /* experimental gameplay features (that don't affect the savefile) */ /* TODO: move these settings to settings.h or into configuration files */ -#define GOBLINKILL /* Goblin-Spezialklau kann tdlich enden */ -#define INSECT_POTION /* Spezialtrank fr Insekten */ -#define ORCIFICATION /* giving snotlings to the peasants gets counted */ +#define GOBLINKILL /* Goblin-Spezialklau kann toedlich enden */ +#define INSECT_POTION /* Spezialtrank fuer Insekten */ #define TREESIZE (8) /* space used by trees (in #peasants) */ #define PEASANTFORCE 0.75 /* Chance einer Vermehrung trotz 90% Auslastung */ - /* Gebudegre = Minimalbelagerer */ + /* Gebaeudegroesse = Minimalbelagerer */ #define SIEGEFACTOR 2 /** Magic */ #define MAXMAGICIANS 3 #define MAXALCHEMISTS 3 -#define ENCCHANCE 10 /* %-Chance fr einmalige Zufallsbegegnung */ -#define BAGCAPACITY 20000 /* soviel pat in einen Bag of Holding */ +#define ENCCHANCE 10 /* %-Chance fuer einmalige Zufallsbegegnung */ +#define BAGCAPACITY 20000 /* soviel passt in einen Bag of Holding */ #define PERSON_WEIGHT 1000 /* weight of a "normal" human unit */ #define STAMINA_AFFECTS_HP 1<<0 From ec4060cb9a31d8effcd2bea344fd19405dcd0320 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 20 Nov 2016 19:08:39 +0100 Subject: [PATCH 267/675] fix curse-vigour calculation math. also fix a ton of small other niggles from pvs-studio. --- conf/e3/config.json | 6 +- conf/e4/config.json | 6 +- conf/keywords.json | 134 ++++++++++++++++++------------------- src/battle.c | 2 +- src/economy.c | 69 +++++++++---------- src/give.c | 4 +- src/items.c | 7 +- src/kernel/building.test.c | 2 +- src/kernel/config.c | 13 ++-- src/kernel/curse.c | 2 +- src/kernel/faction.c | 2 +- src/kernel/item.c | 4 +- src/kernel/pool.c | 4 +- src/kernel/resources.c | 2 +- src/kernel/unit.c | 5 -- src/kernel/unit.h | 2 - src/laws.c | 6 +- src/monster.c | 6 +- src/monsters.c | 2 +- src/report.c | 2 +- src/summary.c | 2 +- src/util/unicode.test.c | 2 +- 22 files changed, 139 insertions(+), 145 deletions(-) diff --git a/conf/e3/config.json b/conf/e3/config.json index c9a86c8da..30bc7e599 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -1,9 +1,9 @@ { - "include": [ - "keywords.json", + "include": [ + "keywords.json", "prefixes.json", "e3/terrains.json" - ], + ], "disabled": [ "herbalism", "alchemy", diff --git a/conf/e4/config.json b/conf/e4/config.json index 7a73de86f..cbe273af6 100644 --- a/conf/e4/config.json +++ b/conf/e4/config.json @@ -1,9 +1,9 @@ { - "include": [ - "keywords.json", + "include": [ + "keywords.json", "prefixes.json", "e3/terrains.json" - ], + ], "disabled": [ "herbalism", "alchemy", diff --git a/conf/keywords.json b/conf/keywords.json index 88ee6c2bd..7117217d7 100644 --- a/conf/keywords.json +++ b/conf/keywords.json @@ -1,69 +1,69 @@ { - "keywords": { - "en" : { - "grow": [ "GROW", "BREED", "PLANT" ], - "combat": [ "COMBAT", "FIGHT" ] - }, - "de": { - "//" : "//", - "banner": "BANNER", - "work": [ "ARBEITE", "ARBEITEN" ], - "attack": ["ATTACKIERE", "ATTACKIEREN"], - "steal": [ "BEKLAUE", "BEKLAUEN" ], - "besiege": ["BELAGERE", "BELAGERN" ], - "name": [ "BENENNE", "BENENNEN" ], - "use": [ "BENUTZE", "BENUTZEN" ], - "describe": [ "BESCHREIBE", "BESCHREIBEN" ], - "enter": ["BETRETE", "BETRETEN"], - "guard": ["BEWACHE", "BEWACHEN"], - "message": "BOTSCHAFT", - "end": "ENDE", - "ride": ["FAHRE", "FAHREN"], - "number": "NUMMER", - "follow": ["FOLGE","FOLGEN"], - "research": ["FORSCHE", "FORSCHEN"], - "give": "GIB", - "help": [ "HELFE", "HELFEN" ], - "combat": [ "KÄMPFE", "KÄMPFEN" ], - "ready" : "KAMPFZAUBER", - "buy" : [ "KAUFE", "KAUFEN"], - "contact": [ "KONTAKT", "KONTAKTIEREN"], - "teach": ["LEHRE", "LEHREN"], - "study": ["LERNE", "LERNEN"], - "make": ["MACHE", "MACHEN"], - "maketemp": ["MACHE TEMP", "MACHETEMP"], - "move" : "NACH", - "password" : "PASSWORT", - "loot" : ["PLÜNDERE", "PLÜNDERN"], - "recruit": ["REKRUTIERE", "REKRUTIEREN"], - "reserve": ["RESERVIERE", "RESERVIEREN"], - "route": "ROUTE", - "sabotage": ["SABOTIERE", "SABOTIEREN"], - "option": "OPTION", - "spy": ["SPIONIERE", "SPIONIEREN"], - "quit": "STIRB", - "hide": ["TARNE", "TARNEN"], - "carry": ["TRANSPORTIERE", "TRANSPORTIEREN"], - "tax": ["TREIBE", "TREIBEN", "STEUERN"], - "entertain": ["UNTERHALTE", "UNTERHALTEN"], - "sell": ["VERKAUFE", "VERKAUFEN"], - "leave": ["VERLASSE", "VERLASSEN"], - "forget": ["VERGISS", "VERGESSEN"], - "cast": ["ZAUBERE", "ZAUBERN"], - "show": ["ZEIGE", "ZEIGEN"], - "destroy": ["ZERSTÖRE", "ZERSTÖREN"], - "grow": ["ZÜCHTE", "PFLANZE", "ZÜCHTEN", "PFLANZEN"], - "default": "DEFAULT", - "origin": "URSPRUNG", - "email": "EMAIL", - "piracy": "PIRATERIE", - "group": "GRUPPE", - "sort": ["SORTIERE", "SORTIEREN"], - "prefix": "PRÄFIX", - "alliance": "ALLIANZ", - "claim": ["BEANSPRUCHE", "BEANSPRUCHEN"], - "promote": ["BEFÖRDERE", "BEFÖRDERUNG"], - "pay": ["BEZAHLE", "BEZAHLEN"] - } - } + "keywords": { + "en" : { + "grow": [ "GROW", "BREED", "PLANT" ], + "combat": [ "COMBAT", "FIGHT" ] + }, + "de": { + "//" : "//", + "banner": "BANNER", + "work": [ "ARBEITE", "ARBEITEN" ], + "attack": ["ATTACKIERE", "ATTACKIEREN"], + "steal": [ "BEKLAUE", "BEKLAUEN" ], + "besiege": ["BELAGERE", "BELAGERN" ], + "name": [ "BENENNE", "BENENNEN" ], + "use": [ "BENUTZE", "BENUTZEN" ], + "describe": [ "BESCHREIBE", "BESCHREIBEN" ], + "enter": ["BETRETE", "BETRETEN"], + "guard": ["BEWACHE", "BEWACHEN"], + "message": "BOTSCHAFT", + "end": "ENDE", + "ride": ["FAHRE", "FAHREN"], + "number": "NUMMER", + "follow": ["FOLGE","FOLGEN"], + "research": ["FORSCHE", "FORSCHEN"], + "give": "GIB", + "help": [ "HELFE", "HELFEN" ], + "combat": [ "KÄMPFE", "KÄMPFEN" ], + "ready" : "KAMPFZAUBER", + "buy" : [ "KAUFE", "KAUFEN"], + "contact": [ "KONTAKT", "KONTAKTIEREN"], + "teach": ["LEHRE", "LEHREN"], + "study": ["LERNE", "LERNEN"], + "make": ["MACHE", "MACHEN"], + "maketemp": ["MACHE TEMP", "MACHETEMP"], + "move" : "NACH", + "password" : "PASSWORT", + "loot" : ["PLÜNDERE", "PLÜNDERN"], + "recruit": ["REKRUTIERE", "REKRUTIEREN"], + "reserve": ["RESERVIERE", "RESERVIEREN"], + "route": "ROUTE", + "sabotage": ["SABOTIERE", "SABOTIEREN"], + "option": "OPTION", + "spy": ["SPIONIERE", "SPIONIEREN"], + "quit": "STIRB", + "hide": ["TARNE", "TARNEN"], + "carry": ["TRANSPORTIERE", "TRANSPORTIEREN"], + "tax": ["TREIBE", "TREIBEN", "STEUERN"], + "entertain": ["UNTERHALTE", "UNTERHALTEN"], + "sell": ["VERKAUFE", "VERKAUFEN"], + "leave": ["VERLASSE", "VERLASSEN"], + "forget": ["VERGISS", "VERGESSEN"], + "cast": ["ZAUBERE", "ZAUBERN"], + "show": ["ZEIGE", "ZEIGEN"], + "destroy": ["ZERSTÖRE", "ZERSTÖREN"], + "grow": ["ZÜCHTE", "PFLANZE", "ZÜCHTEN", "PFLANZEN"], + "default": "DEFAULT", + "origin": "URSPRUNG", + "email": "EMAIL", + "piracy": "PIRATERIE", + "group": "GRUPPE", + "sort": ["SORTIERE", "SORTIEREN"], + "prefix": "PRÄFIX", + "alliance": "ALLIANZ", + "claim": ["BEANSPRUCHE", "BEANSPRUCHEN"], + "promote": ["BEFÖRDERE", "BEFÖRDERUNG"], + "pay": ["BEZAHLE", "BEZAHLEN"] + } + } } diff --git a/src/battle.c b/src/battle.c index b4468e843..9e024c1af 100644 --- a/src/battle.c +++ b/src/battle.c @@ -765,7 +765,7 @@ bool missile) skill += CavalryBonus(tu, enemy, BONUS_SKILL); if (wtype) skill = - skillmod(urace(tu)->attribs, tu, tu->region, wtype->skill, skill, + skillmod(u_race(tu)->attribs, tu, tu->region, wtype->skill, skill, SMF_RIDING); } diff --git a/src/economy.c b/src/economy.c index 9d4c80ca0..a7d6740dd 100644 --- a/src/economy.c +++ b/src/economy.c @@ -97,7 +97,7 @@ static request *nextentertainer; static int entertaining; static unsigned int norders; -static request *oa; +static request *g_requests; #define RECRUIT_MERGE 1 static int rules_recruit = -1; @@ -154,21 +154,21 @@ static void expandorders(region * r, request * requests) if (norders > 0) { int i = 0; - oa = (request *)calloc(norders, sizeof(request)); + g_requests = (request *)calloc(norders, sizeof(request)); for (o = requests; o; o = o->next) { if (o->qty > 0) { unsigned int j; for (j = o->qty; j; j--) { - oa[i] = *o; - oa[i].unit->n = 0; + g_requests[i] = *o; + g_requests[i].unit->n = 0; i++; } } } - scramble(oa, norders, sizeof(request)); + scramble(g_requests, norders, sizeof(request)); } else { - oa = NULL; + g_requests = NULL; } while (requests) { request *o = requests->next; @@ -1458,16 +1458,16 @@ static void expandbuying(region * r, request * buyorders) for (j = 0; j != norders; j++) { int price, multi; - ltype = oa[j].type.ltype; + ltype = g_requests[j].type.ltype; trade = trades; while (trade->type != ltype) ++trade; multi = trade->multi; price = ltype->price * multi; - if (get_pooled(oa[j].unit, rsilver, GET_DEFAULT, + if (get_pooled(g_requests[j].unit, rsilver, GET_DEFAULT, price) >= price) { - unit *u = oa[j].unit; + unit *u = g_requests[j].unit; item *items; /* litems zhlt die Gter, die verkauft wurden, u->n das Geld, das @@ -1481,7 +1481,7 @@ static void expandbuying(region * r, request * buyorders) items = a->data.v; i_change(&items, ltype->itype, 1); a->data.v = items; - i_change(&oa[j].unit->items, ltype->itype, 1); + i_change(&g_requests[j].unit->items, ltype->itype, 1); use_pooled(u, rsilver, GET_DEFAULT, price); if (u->n < 0) u->n = 0; @@ -1499,7 +1499,7 @@ static void expandbuying(region * r, request * buyorders) fset(u, UFL_LONGACTION | UFL_NOTMOVING); } } - free(oa); + free(g_requests); /* Ausgabe an Einheiten */ @@ -1736,7 +1736,7 @@ static void expandselling(region * r, request * sellorders, int limit) for (j = 0; j != norders; j++) { const luxury_type *search = NULL; - const luxury_type *ltype = oa[j].type.ltype; + const luxury_type *ltype = g_requests[j].type.ltype; int multi = r_demand(r, ltype); int i; int use = 0; @@ -1753,7 +1753,7 @@ static void expandselling(region * r, request * sellorders, int limit) if (money >= price) { int abgezogenhafen = 0; int abgezogensteuer = 0; - unit *u = oa[j].unit; + unit *u = g_requests[j].unit; item *itm; attrib *a = a_find(u->attribs, &at_luxuries); if (a == NULL) @@ -1801,10 +1801,10 @@ static void expandselling(region * r, request * sellorders, int limit) } } if (use > 0) { - use_pooled(oa[j].unit, ltype->itype->rtype, GET_DEFAULT, use); + use_pooled(g_requests[j].unit, ltype->itype->rtype, GET_DEFAULT, use); } } - free(oa); + free(g_requests); /* Steuern. Hier werden die Steuern dem Besitzer der grten Burg gegeben. */ if (maxowner) { @@ -1928,7 +1928,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) s = gettoken(token, sizeof(token)); itype = s ? finditemtype(s, u->faction->locale) : 0; ltype = itype ? resource2luxury(itype->rtype) : 0; - if (ltype == NULL) { + if (ltype == NULL || itype == NULL) { cmistake(u, ord, 126, MSG_COMMERCE); return false; } @@ -2010,8 +2010,8 @@ static void expandstealing(region * r, request * stealorders) * u ist die beklaute unit. oa.unit ist die klauende unit. */ - for (j = 0; j != norders && oa[j].unit->n <= oa[j].unit->wants; j++) { - unit *u = findunitg(oa[j].no, r); + for (j = 0; j != norders && g_requests[j].unit->n <= g_requests[j].unit->wants; j++) { + unit *u = findunitg(g_requests[j].no, r); int n = 0; if (u && u->region == r) { n = get_pooled(u, rsilver, GET_ALL, INT_MAX); @@ -2035,17 +2035,17 @@ static void expandstealing(region * r, request * stealorders) n = 10; } if (n > 0) { - n = _min(n, oa[j].unit->wants); + n = _min(n, g_requests[j].unit->wants); use_pooled(u, rsilver, GET_ALL, n); - oa[j].unit->n = n; - change_money(oa[j].unit, n); + g_requests[j].unit->n = n; + change_money(g_requests[j].unit, n); ADDMSG(&u->faction->msgs, msg_message("stealeffect", "unit region amount", u, u->region, n)); } - add_income(oa[j].unit, IC_STEAL, oa[j].unit->wants, oa[j].unit->n); - fset(oa[j].unit, UFL_LONGACTION | UFL_NOTMOVING); + add_income(g_requests[j].unit, IC_STEAL, g_requests[j].unit->wants, g_requests[j].unit->n); + fset(g_requests[j].unit, UFL_LONGACTION | UFL_NOTMOVING); } - free(oa); + free(g_requests); } /* ------------------------------------------------------------- */ @@ -2060,14 +2060,14 @@ static void plant(unit * u, int raw) if (!fval(r->terrain, LAND_REGION)) { return; } - if (rherbtype(r) == NULL) { + itype = rherbtype(r); + if (itype == NULL) { cmistake(u, u->thisorder, 108, MSG_PRODUCE); return; } /* Skill prfen */ skill = effskill(u, SK_HERBALISM, 0); - itype = rherbtype(r); if (skill < 6) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "plant_skills", @@ -2702,13 +2702,13 @@ static void expandloot(region * r, request * lootorders) return; for (i = 0; i != norders && startmoney > looted + TAXFRACTION * 2; i++) { - change_money(oa[i].unit, TAXFRACTION); - oa[i].unit->n += TAXFRACTION; + change_money(g_requests[i].unit, TAXFRACTION); + g_requests[i].unit->n += TAXFRACTION; /*Looting destroys double the money*/ looted += TAXFRACTION * 2; } rsetmoney(r, startmoney - looted); - free(oa); + free(g_requests); /* Lowering morale by 1 depending on the looted money (+20%) */ if (rng_int() % 100 < 20 + (looted * 80) / startmoney) { @@ -2737,11 +2737,11 @@ void expandtax(region * r, request * taxorders) return; for (i = 0; i != norders && rmoney(r) > TAXFRACTION; i++) { - change_money(oa[i].unit, TAXFRACTION); - oa[i].unit->n += TAXFRACTION; + change_money(g_requests[i].unit, TAXFRACTION); + g_requests[i].unit->n += TAXFRACTION; rsetmoney(r, rmoney(r) - TAXFRACTION); } - free(oa); + free(g_requests); for (u = r->units; u; u = u->next) { if (u->n >= 0) { @@ -2939,9 +2939,10 @@ static void peasant_taxes(region * r) maxsize = buildingeffsize(b, false); if (maxsize > 0) { double taxfactor = money * b->type->taxes(b, maxsize); - double morale = money * region_get_morale(r) * MORALE_TAX_FACTOR; - if (taxfactor > morale) + double morale = MORALE_TAX_FACTOR * money * region_get_morale(r); + if (taxfactor > morale) { taxfactor = morale; + } if (taxfactor > 0) { int taxmoney = (int)taxfactor; change_money(u, taxmoney); diff --git a/src/give.c b/src/give.c index 781f39ca6..524a27017 100644 --- a/src/give.c +++ b/src/give.c @@ -137,7 +137,7 @@ int give_quota(const unit * src, const unit * dst, const item_type * type, } if (dst && src && src->faction != dst->faction) { divisor = config_get_flt("rules.items.give_divisor", 1); - assert(divisor == 0 || divisor >= 1); + assert(divisor <= 0 || divisor >= 1); if (divisor >= 1) { /* predictable > correct: */ int x = (int)(n / divisor); @@ -781,7 +781,7 @@ void give_cmd(unit * u, order * ord) } if (u2 != NULL) { - if ((u_race(u)->ec_flags & ECF_KEEP_ITEM) && u2 != NULL) { + if ((u_race(u)->ec_flags & ECF_KEEP_ITEM)) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "race_nogive", "race", u_race(u))); return; diff --git a/src/items.c b/src/items.c index 5e9a357e6..081f29c14 100644 --- a/src/items.c +++ b/src/items.c @@ -114,10 +114,9 @@ struct order *ord) const resource_type *rt_crystal = NULL; int i; - if (rt_crystal == NULL) { - rt_crystal = rt_find("antimagic"); - assert(rt_crystal != NULL); - } + rt_crystal = rt_find("antimagic"); + assert(rt_crystal != NULL); + for (i = 0; i != amount; ++i) { int effect, duration = 2; double force; diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index 755e9319f..d15c82c8e 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -405,8 +405,8 @@ static void test_buildingtype_exists(CuTest * tc) r = findregion(-1, 0); b = new_building(btype, r, default_locale); - b->size = 10; CuAssertPtrNotNull(tc, b); + b->size = 10; CuAssertTrue(tc, !buildingtype_exists(r, NULL, false)); CuAssertTrue(tc, !buildingtype_exists(r, btype2, false)); diff --git a/src/kernel/config.c b/src/kernel/config.c index db27d46be..d100dd40c 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -741,10 +741,15 @@ int cmp_current_owner(const building * b, const building * a) int oldsize = buildingeffsize(a, false); double oldtaxes = a->type->taxes(a, oldsize); - if (newtaxes != oldtaxes) - return (newtaxes > oldtaxes) ? 1 : -1; - if (newsize != oldsize) + if (newtaxes > oldtaxes) { + return 1; + } + if (newtaxes < oldtaxes) { + return -1; + } + if (newsize != oldsize) { return newsize - oldsize; + } return (b->size - a->size); } else { @@ -944,7 +949,7 @@ int entertainmoney(const region * r) return 0; } - n = rmoney(r) / ENTERTAINFRACTION; + n = rmoney(r) / (double)ENTERTAINFRACTION; if (is_cursed(r->attribs, C_GENEROUS, 0)) { n *= get_curseeffect(r->attribs, C_GENEROUS, 0); diff --git a/src/kernel/curse.c b/src/kernel/curse.c index 3ecf48899..2ee89799d 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -825,7 +825,7 @@ double destr_curse(curse * c, int cast_level, double force) c->type->change_vigour(c, -(cast_level + 1) / 2); } else { - c->vigour -= cast_level + 1 / 2; + c->vigour -= (cast_level + 1) / 2.0; } } } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 6d2430de4..d332bf604 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -827,7 +827,7 @@ int writepasswd(void) log_info("writing passwords..."); for (f = factions; f; f = f->next) { - fprintf(F, "%s:%s:%s:%u\n", + fprintf(F, "%s:%s:%s:%d\n", itoa36(f->no), f->email, f->_password, f->subscription); } fclose(F); diff --git a/src/kernel/item.c b/src/kernel/item.c index f9234368c..cedf15df0 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -973,7 +973,7 @@ void init_resources(void) { resource_type *rtype; - rtype = rt_get_or_create(resourcenames[R_PERSON]); // lousy hack + rt_get_or_create(resourcenames[R_PERSON]); // lousy hack rtype = rt_get_or_create(resourcenames[R_PEASANT]); rtype->uchange = res_changepeasants; @@ -1204,7 +1204,7 @@ void read_items(struct storage *store, item ** ilist) itype = it_find(ibuf); READ_INT(store, &i); if (i <= 0) { - log_error("data contains an entry with %d %s", i, resourcename(itype->rtype, NMF_PLURAL)); + log_error("data contains an entry with %d %s", i, ibuf); } else { if (itype && itype->rtype) { diff --git a/src/kernel/pool.c b/src/kernel/pool.c index 6ceeda63d..5609d211f 100644 --- a/src/kernel/pool.c +++ b/src/kernel/pool.c @@ -179,7 +179,7 @@ int count) if (u != v && (v->items || rtype->uget)) { int mask; - if ((urace(v)->ec_flags & ECF_KEEP_ITEM)) + if ((u_race(v)->ec_flags & ECF_KEEP_ITEM)) continue; if (v->faction == f) { @@ -232,7 +232,7 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count) for (v = r->units; use > 0 && v != NULL; v = v->next) { if (u != v) { int mask; - if ((urace(v)->ec_flags & ECF_KEEP_ITEM)) + if ((u_race(v)->ec_flags & ECF_KEEP_ITEM)) continue; if (v->items == NULL && rtype->uget == NULL) continue; diff --git a/src/kernel/resources.c b/src/kernel/resources.c index 658445c69..e064150e6 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -46,7 +46,7 @@ extern int dice_rand(const char *s); static void update_resource(struct rawmaterial *res, double modifier) { - double amount = 1 + (res->level - res->startlevel) * res->divisor / 100.0; + double amount = (res->level - res->startlevel) / 100.0 * res->divisor + 1; amount = ResourceFactor() * res->base * amount * modifier; if (amount < 1.0) res->amount = 1; diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 95c689ded..4aff7d118 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -917,11 +917,6 @@ bool leave(unit * u, bool force) return true; } -const struct race *urace(const struct unit *u) -{ - return u->_race; -} - bool can_survive(const unit * u, const region * r) { if ((fval(r->terrain, WALK_INTO) && (u_race(u)->flags & RCF_WALK)) diff --git a/src/kernel/unit.h b/src/kernel/unit.h index a360321a2..e81c43135 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -141,8 +141,6 @@ extern "C" { struct unit *utarget(const struct unit *u); void usettarget(struct unit *u, const struct unit *b); - extern const struct race *urace(const struct unit *u); - const char *uprivate(const struct unit *u); void usetprivate(struct unit *u, const char *c); diff --git a/src/laws.c b/src/laws.c index fd4f50b78..7ab6c7560 100644 --- a/src/laws.c +++ b/src/laws.c @@ -648,7 +648,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season) * verfügbaren Fläche ab. In Gletschern gibt es weniger * Möglichkeiten als in Ebenen. */ sprout = 0; - seedchance = (1000 * region_maxworkers(r2)) / r2->terrain->size; + seedchance = (1000 * region_maxworkers(r2)) / (double)r2->terrain->size; for (i = 0; i < seeds / MAXDIRECTIONS; i++) { if (rng_int() % 10000 < seedchance) sprout++; @@ -3636,7 +3636,7 @@ int pay_cmd(unit * u, struct order *ord) static int reserve_i(unit * u, struct order *ord, int flags) { char token[128]; - if (u->number > 0 && (urace(u)->ec_flags & GETITEM)) { + if (u->number > 0 && (u_race(u)->ec_flags & GETITEM)) { int use, count, para; const item_type *itype; const char *s; @@ -3945,7 +3945,7 @@ int armedmen(const unit * u, bool siege_weapons) { item *itm; int n = 0; - if (!(urace(u)->flags & RCF_NOWEAPONS)) { + if (!(u_race(u)->flags & RCF_NOWEAPONS)) { if (effskill(u, SK_WEAPONLESS, 0) >= 1) { /* kann ohne waffen bewachen: fuer drachen */ n = u->number; diff --git a/src/monster.c b/src/monster.c index 42e334fde..301b1b132 100644 --- a/src/monster.c +++ b/src/monster.c @@ -76,17 +76,13 @@ bool monster_is_waiting(const unit * u) static void eaten_by_monster(unit * u) { /* adjustment for smaller worlds */ - static double multi = 0.0; + double multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0; int n = 0; int horse = -1; const resource_type *rhorse = get_resourcetype(R_HORSE); const race *rc = u_race(u); attrib *a; - if (multi == 0.0) { - multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0; - } - a = a_find(rc->attribs, &at_scare); if (a) { n = rng_int() & a->data.i * u->number; diff --git a/src/monsters.c b/src/monsters.c index 9f49a2603..cea817589 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -695,7 +695,7 @@ static order *plan_dragon(unit * u) int attempts = 0; skill_t sk = SK_PERCEPTION; /* study perception (or a random useful skill) */ - while ((!skill_enabled(sk) || (attempts < MAXSKILLS && u_race(u)->bonus[sk] < (++attempts < 10?1:-5 )))) { + while (!skill_enabled(sk) || (attempts < MAXSKILLS && u_race(u)->bonus[sk] < (++attempts < 10?1:-5 ))) { sk = (skill_t)(rng_int() % MAXSKILLS); } long_order = create_order(K_STUDY, u->faction->locale, "'%s'", diff --git a/src/report.c b/src/report.c index dc52c38a3..e9b66c461 100644 --- a/src/report.c +++ b/src/report.c @@ -1730,7 +1730,7 @@ static void rpline(struct stream *out) memset(line, '-', sizeof(line)); line[REPORTWIDTH] = '\n'; } - swrite(line, sizeof(char), sizeof(line), out); + swrite(line, sizeof(line), 1, out); } static void list_address(struct stream *out, const faction * uf, quicklist * seenfactions) diff --git a/src/summary.c b/src/summary.c index b82c3a50e..2311b1994 100644 --- a/src/summary.c +++ b/src/summary.c @@ -220,7 +220,7 @@ void report_summary(summary * s, summary * o, bool full) fprintf(F, " Helden: %s\n", pcomp(s->heroes, o->heroes)); if (full) { - fprintf(F, "Regionen: %d\n", listlen(regions)); + fprintf(F, "Regionen: %d\n", (int)listlen(regions)); fprintf(F, "Bewohnte Regionen: %d\n", s->inhabitedregions); fprintf(F, "Landregionen: %d\n", s->landregionen); fprintf(F, "Spielerregionen: %d\n", s->regionen_mit_spielern); diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index 6eb3c4c52..ef07c944c 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -29,7 +29,7 @@ static void test_unicode_trim(CuTest * tc) CuAssertIntEquals(tc, 3, unicode_utf8_trim(buffer)); CuAssertStrEquals(tc, "Hello Word", buffer); - buffer[9] = (char)0xc3; + buffer[9] = -61; CuAssertIntEquals(tc, 1, unicode_utf8_trim(buffer)); CuAssertStrEquals(tc, "Hello Wor?", buffer); } From 925d65c206e37d70a2cf5e060d2e76d4bcb5434d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 22 Nov 2016 12:22:07 +0100 Subject: [PATCH 268/675] move entertainmoney to economy --- src/economy.c | 17 +++++++++++++++++ src/economy.h | 1 + src/items.c | 4 ++-- src/kernel/config.c | 17 ----------------- src/kernel/config.h | 1 - 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/economy.c b/src/economy.c index a7d6740dd..d3f6189fc 100644 --- a/src/economy.c +++ b/src/economy.c @@ -112,6 +112,23 @@ static void recruit_init(void) } } +int entertainmoney(const region * r) +{ + double n; + + if (is_cursed(r->attribs, C_DEPRESSION, 0)) { + return 0; + } + + n = rmoney(r) / (double)ENTERTAINFRACTION; + + if (is_cursed(r->attribs, C_GENEROUS, 0)) { + n *= get_curseeffect(r->attribs, C_GENEROUS, 0); + } + + return (int)n; +} + int income(const unit * u) { const race *rc = u_race(u); diff --git a/src/economy.h b/src/economy.h index 4bce314a9..5549e13cb 100644 --- a/src/economy.h +++ b/src/economy.h @@ -48,6 +48,7 @@ extern "C" { struct request; int income(const struct unit *u); + int entertainmoney(const struct region *r); void economics(struct region *r); void produce(struct region *r); diff --git a/src/items.c b/src/items.c index 081f29c14..6fbf957b3 100644 --- a/src/items.c +++ b/src/items.c @@ -1,8 +1,8 @@ #include -#include #include "items.h" #include "study.h" +#include "economy.h" #include "move.h" #include "magic.h" @@ -137,7 +137,7 @@ struct order *ord) while (*ap && force > 0) { curse *c; attrib *a = *ap; - if (!fval(a->type, ATF_CURSE)) { + if (!(a->type->flags & ATF_CURSE)) { do { ap = &(*ap)->next; } while (*ap && a->type == (*ap)->type); diff --git a/src/kernel/config.c b/src/kernel/config.c index d100dd40c..0047744af 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -941,23 +941,6 @@ order *default_order(const struct locale *lang) return result ? copy_order(result) : 0; } -int entertainmoney(const region * r) -{ - double n; - - if (is_cursed(r->attribs, C_DEPRESSION, 0)) { - return 0; - } - - n = rmoney(r) / (double)ENTERTAINFRACTION; - - if (is_cursed(r->attribs, C_GENEROUS, 0)) { - n *= get_curseeffect(r->attribs, C_GENEROUS, 0); - } - - return (int)n; -} - int rule_give(void) { static int config; diff --git a/src/kernel/config.h b/src/kernel/config.h index 1e6b7f743..61a5f2f64 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -147,7 +147,6 @@ struct param; struct order *default_order(const struct locale *lang); - int entertainmoney(const struct region *r); void init_parameters(struct locale *lang); void free_gamedata(void); From 09f22ba0bc992c11291a805172a86d77827b0d43 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 22 Nov 2016 12:32:28 +0100 Subject: [PATCH 269/675] move findrace into race.c --- src/kernel/config.c | 12 ------------ src/kernel/config.h | 2 -- src/kernel/race.c | 13 +++++++++++++ src/kernel/race.h | 2 ++ src/spy.c | 12 ++++++------ src/spy.h | 1 + 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index 0047744af..f9a63af49 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -183,18 +183,6 @@ parse(keyword_t kword, int(*dofun) (unit *, struct order *), bool thisorder) } } -const struct race *findrace(const char *s, const struct locale *lang) -{ - void **tokens = get_translations(lang, UT_RACES); - variant token; - - assert(lang); - if (tokens && findtoken(*tokens, s, &token) == E_TOK_SUCCESS) { - return (const struct race *)token.v; - } - return NULL; -} - int findoption(const char *s, const struct locale *lang) { void **tokens = get_translations(lang, UT_OPTIONS); diff --git a/src/kernel/config.h b/src/kernel/config.h index 61a5f2f64..4f84cc9ad 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -83,8 +83,6 @@ struct param; #define GIVE_DEFAULT (GIVE_SELF|GIVE_PEASANTS|GIVE_LUXURIES|GIVE_HERBS|GIVE_GOODS) int rule_give(void); - const struct race *findrace(const char *, const struct locale *); - /* grammatik-flags: */ #define GF_NONE 0 /* singular, ohne was dran */ diff --git a/src/kernel/race.c b/src/kernel/race.c index 5b991eca6..f28c5ed2f 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -39,6 +39,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include #include #include @@ -75,6 +76,18 @@ static const char *racenames[MAXRACES] = { "clone" }; +const struct race *findrace(const char *s, const struct locale *lang) +{ + void **tokens = get_translations(lang, UT_RACES); + variant token; + + assert(lang); + if (tokens && findtoken(*tokens, s, &token) == E_TOK_SUCCESS) { + return (const struct race *)token.v; + } + return NULL; +} + const struct race *get_race(race_t rt) { const char * name; diff --git a/src/kernel/race.h b/src/kernel/race.h index 80b09fbbf..c7dbe3669 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -44,6 +44,7 @@ extern "C" { struct param; struct spell; + struct locale; extern int num_races; @@ -163,6 +164,7 @@ extern "C" { void racelist_clear(struct race_list **rl); void racelist_insert(struct race_list **rl, const struct race *r); + const struct race *findrace(const char *, const struct locale *); struct race_list *get_familiarraces(void); struct race *races; diff --git a/src/spy.c b/src/spy.c index 3233fb563..6bb1a18e5 100644 --- a/src/spy.c +++ b/src/spy.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "spy.h" #include "guard.h" #include "laws.h" @@ -26,6 +25,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "study.h" /* kernel includes */ +#include #include #include #include @@ -297,7 +297,7 @@ int setstealth_cmd(unit * u, struct order *ord) break; } else if (findparam(s, u->faction->locale) == P_NOT) { - freset(u, UFL_ANON_FACTION); + u->flags |= ~UFL_ANON_FACTION; break; } } @@ -414,18 +414,18 @@ static void sink_ship(region * r, ship * sh, unit * saboteur) /* slight optimization to avoid dereferencing u->faction each time */ if (f != u->faction) { f = u->faction; - freset(f, FFL_SELECT); + f->flags |= ~FFL_SELECT; } } /* figure out what a unit's chances of survival are: */ - if (!fval(r->terrain, SEA_REGION)) { + if (!(r->terrain->flags & SEA_REGION)) { probability = CANAL_SWIMMER_CHANCE; } else { for (d = 0; d != MAXDIRECTIONS; ++d) { region *rn = rconnect(r, d); - if (rn && !fval(rn->terrain, SEA_REGION) && !move_blocked(NULL, r, rn)) { + if (rn && !(rn->terrain->flags & SEA_REGION) && !move_blocked(NULL, r, rn)) { safety = rn; probability = OCEAN_SWIMMER_CHANCE; break; @@ -436,7 +436,7 @@ static void sink_ship(region * r, ship * sh, unit * saboteur) unit *u = *ui; /* inform this faction about the sinking ship: */ - if (!fval(u->faction, FFL_SELECT)) { + if (!(u->faction->flags & FFL_SELECT)) { fset(u->faction, FFL_SELECT); if (sink_msg == NULL) { sink_msg = msg_message("sink_msg", "ship region", sh, r); diff --git a/src/spy.h b/src/spy.h index 72694d4b1..d3ee0c728 100644 --- a/src/spy.h +++ b/src/spy.h @@ -25,6 +25,7 @@ extern "C" { struct unit; struct region; struct strlist; + struct order; extern int setstealth_cmd(struct unit *u, struct order *ord); extern int spy_cmd(struct unit *u, struct order *ord); From 88f5bfaf47e89204c5b938a223799c50f986e413 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 23 Nov 2016 17:36:39 +0100 Subject: [PATCH 270/675] move wages and related functionality to buildin.c --- src/kernel/building.c | 244 +++++++++++++++++++++++++++++++++++++++--- src/kernel/building.h | 16 ++- src/kernel/config.c | 232 --------------------------------------- src/kernel/config.h | 14 --- 4 files changed, 244 insertions(+), 262 deletions(-) diff --git a/src/kernel/building.c b/src/kernel/building.c index 60fd420fb..8d76df030 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -22,12 +22,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "building.h" /* kernel includes */ +#include "curse.h" #include "item.h" #include "unit.h" #include "faction.h" #include "race.h" #include "region.h" #include "skill.h" +#include "terrain.h" #include "lighthouse.h" /* util includes */ @@ -52,6 +54,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include /* attributes includes */ +#include #include typedef struct building_typelist { @@ -359,16 +362,6 @@ static int building_protection(const building * b, const unit * u, building_bonu } } -void register_buildings(void) -{ - register_function((pf_generic)building_protection, - "building_protection"); - register_function((pf_generic)init_smithy, "init_smithy"); - register_function((pf_generic)castle_name, "castle_name"); - register_function((pf_generic)castle_name_2, "castle_name_2"); - register_function((pf_generic)fort_name, "fort_name"); -} - void write_building_reference(const struct building *b, struct storage *store) { WRITE_INT(store, (b && b->region) ? b->no : 0); @@ -456,8 +449,8 @@ void remove_building(building ** blist, building * b) update_lighthouse(b); bunhash(b); - /* Falls Karawanserei, Damm oder Tunnel einstrzen, wird die schon - * gebaute Strae zur Hlfte vernichtet */ + /* Falls Karawanserei, Damm oder Tunnel einst�rzen, wird die schon + * gebaute Stra�e zur H�lfte vernichtet */ // TODO: caravan, tunnel, dam modularization ? is_building_type ? if (b->type == bt_caravan || b->type == bt_dam || b->type == bt_tunnel) { region *r = b->region; @@ -570,7 +563,7 @@ void building_set_owner(struct unit * owner) static unit *building_owner_ex(const building * bld, const struct faction * last_owner) { unit *u, *heir = 0; - /* Eigentmer tot oder kein Eigentmer vorhanden. Erste lebende Einheit + /* Eigent�mer tot oder kein Eigent�mer vorhanden. Erste lebende Einheit * nehmen. */ for (u = bld->region->units; u; u = u->next) { if (u->building == bld) { @@ -702,3 +695,228 @@ bool is_building_type(const struct building_type *btype, const char *name) { assert(btype); return name && strcmp(btype->_name, name)==0; } + +building *largestbuilding(const region * r, cmp_building_cb cmp_gt, + bool imaginary) +{ + building *b, *best = NULL; + + for (b = rbuildings(r); b; b = b->next) { + if (cmp_gt(b, best) <= 0) + continue; + if (!imaginary) { + const attrib *a = a_find(b->attribs, &at_icastle); + if (a) + continue; + } + best = b; + } + return best; +} +/* Lohn bei den einzelnen Burgstufen f�r Normale Typen, Orks, Bauern, + * Modifikation f�r St�dter. */ + +static const int wagetable[7][4] = { + { 10, 10, 11, -7 }, /* Baustelle */ + { 10, 10, 11, -5 }, /* Handelsposten */ + { 11, 11, 12, -3 }, /* Befestigung */ + { 12, 11, 13, -1 }, /* Turm */ + { 13, 12, 14, 0 }, /* Burg */ + { 14, 12, 15, 1 }, /* Festung */ + { 15, 13, 16, 2 } /* Zitadelle */ +}; + +static int +default_wage(const region * r, const faction * f, const race * rc, int in_turn) +{ + building *b = largestbuilding(r, &cmp_wage, false); + int esize = 0; + double wage; + static int ct_cache; + static const struct curse_type *drought_ct; + + if (ct_changed(&ct_cache)) { + drought_ct = ct_find("drought"); + } + if (b != NULL) { + /* TODO: this reveals imaginary castles */ + esize = buildingeffsize(b, false); + } + + if (f != NULL) { + int index = 0; + if (rc == get_race(RC_ORC) || rc == get_race(RC_SNOTLING)) { + index = 1; + } + wage = wagetable[esize][index]; + } + else { + if (is_mourning(r, in_turn)) { + wage = 10; + } + else if (fval(r->terrain, SEA_REGION)) { + wage = 11; + } + else { + wage = wagetable[esize][2]; + } + if (rule_blessed_harvest() == HARVEST_WORK) { + /* E1 rules */ + wage += curse_geteffect(get_curse(r->attribs, ct_find("blessedharvest"))); + } + } + + /* Artsculpture: Income +5 */ + for (b = r->buildings; b; b = b->next) { + if (is_building_type(b->type, "artsculpture")) { + wage += 5; + } + } + + if (r->attribs) { + attrib *a; + const struct curse_type *ctype; + /* Godcurse: Income -10 */ + ctype = ct_find("godcursezone"); + if (ctype && curse_active(get_curse(r->attribs, ctype))) { + wage = _max(0, wage - 10); + } + + /* Bei einer D�rre verdient man nur noch ein Viertel */ + if (drought_ct) { + curse *c = get_curse(r->attribs, drought_ct); + if (curse_active(c)) + wage /= curse_geteffect(c); + } + + a = a_find(r->attribs, &at_reduceproduction); + if (a) { + wage = (wage * a->data.sa[0]) / 100; + } + } + return (int)wage; +} + +static int +minimum_wage(const region * r, const faction * f, const race * rc, int in_turn) +{ + if (f && rc) { + return rc->maintenance; + } + return default_wage(r, f, rc, in_turn); +} + +/* Gibt Arbeitslohn f�r entsprechende Rasse zur�ck, oder f�r +* die Bauern wenn f == NULL. */ +int wage(const region * r, const faction * f, const race * rc, int in_turn) +{ + if (global.functions.wage) { + return global.functions.wage(r, f, rc, in_turn); + } + return default_wage(r, f, rc, in_turn); +} + +int cmp_wage(const struct building *b, const building * a) +{ + if (is_building_type(b->type, "castle")) { + if (!a) + return 1; + if (b->size > a->size) + return 1; + if (b->size == a->size) + return 0; + } + return -1; +} + +bool is_owner_building(const struct building * b) +{ + region *r = b->region; + if (b->type->taxes && r->land && r->land->ownership) { + unit *u = building_owner(b); + return u && u->faction == r->land->ownership->owner; + } + return false; +} + +int cmp_taxes(const building * b, const building * a) +{ + faction *f = region_get_owner(b->region); + if (b->type->taxes) { + unit *u = building_owner(b); + if (!u) { + return -1; + } + else if (a) { + int newsize = buildingeffsize(b, false); + double newtaxes = b->type->taxes(b, newsize); + int oldsize = buildingeffsize(a, false); + double oldtaxes = a->type->taxes(a, oldsize); + + if (newtaxes < oldtaxes) + return -1; + else if (newtaxes > oldtaxes) + return 1; + else if (b->size < a->size) + return -1; + else if (b->size > a->size) + return 1; + else { + if (u && u->faction == f) { + u = building_owner(a); + if (u && u->faction == f) + return -1; + return 1; + } + } + } + else { + return 1; + } + } + return -1; +} + +int cmp_current_owner(const building * b, const building * a) +{ + faction *f = region_get_owner(b->region); + + assert(rule_region_owners()); + if (f && b->type->taxes) { + unit *u = building_owner(b); + if (!u || u->faction != f) + return -1; + if (a) { + int newsize = buildingeffsize(b, false); + double newtaxes = b->type->taxes(b, newsize); + int oldsize = buildingeffsize(a, false); + double oldtaxes = a->type->taxes(a, oldsize); + + if (newtaxes > oldtaxes) { + return 1; + } + if (newtaxes < oldtaxes) { + return -1; + } + if (newsize != oldsize) { + return newsize - oldsize; + } + return (b->size - a->size); + } + else { + return 1; + } + } + return -1; +} + +void register_buildings(void) +{ + register_function((pf_generic)minimum_wage, "minimum_wage"); + register_function((pf_generic)building_protection, + "building_protection"); + register_function((pf_generic)init_smithy, "init_smithy"); + register_function((pf_generic)castle_name, "castle_name"); + register_function((pf_generic)castle_name_2, "castle_name_2"); + register_function((pf_generic)fort_name, "fort_name"); +} diff --git a/src/kernel/building.h b/src/kernel/building.h index 1ea1836dc..aee387e7f 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -60,8 +60,8 @@ extern "C" { char *_name; int flags; /* flags */ - int capacity; /* Kapazitt pro Grenpunkt */ - int maxcapacity; /* Max. Kapazitt */ + int capacity; /* Kapazit�t pro Gr��enpunkt */ + int maxcapacity; /* Max. Kapazit�t */ int maxsize; /* how big can it get, with all the extensions? */ int magres; /* how well it resists against spells */ int magresbonus; /* bonus it gives the target against spells */ @@ -131,7 +131,17 @@ extern "C" { int id, int size, struct order *ord); bool building_finished(const struct building *b); - /* Alte Gebudetypen: */ + int wage(const struct region *r, const struct faction *f, + const struct race *rc, int in_turn); + + typedef int(*cmp_building_cb) (const struct building * b, + const struct building * a); + struct building *largestbuilding(const struct region *r, cmp_building_cb, + bool imaginary); + int cmp_wage(const struct building *b, const struct building *bother); + int cmp_taxes(const struct building *b, const struct building *bother); + int cmp_current_owner(const struct building *b, + const struct building *bother); /* old functions, still in build.c: */ int buildingeffsize(const building * b, int imaginary); diff --git a/src/kernel/config.c b/src/kernel/config.c index f9a63af49..80e949215 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -19,9 +19,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -/* attributes includes */ -#include - /* kernel includes */ #include "alliance.h" #include "ally.h" @@ -253,37 +250,6 @@ unit *getnewunit(const region * r, const faction * f) return findnewunit(r, f, n); } -/* - Namen der Strukturen -------------------------------------- */ -char *untilde(char *ibuf) -{ - char *p = ibuf; - - while (*p) { - if (*p == '~') { - *p = ' '; - } - ++p; - } - return ibuf; -} - -building *largestbuilding(const region * r, cmp_building_cb cmp_gt, - bool imaginary) -{ - building *b, *best = NULL; - - for (b = rbuildings(r); b; b = b->next) { - if (cmp_gt(b, best) <= 0) - continue; - if (!imaginary) { - const attrib *a = a_find(b->attribs, &at_icastle); - if (a) - continue; - } - best = b; - } - return best; -} /* -- Erschaffung neuer Einheiten ------------------------------ */ @@ -640,113 +606,6 @@ char *_strdup(const char *s) } #endif -/* Lohn bei den einzelnen Burgstufen f�r Normale Typen, Orks, Bauern, - * Modifikation f�r St�dter. */ - -static const int wagetable[7][4] = { - { 10, 10, 11, -7 }, /* Baustelle */ - { 10, 10, 11, -5 }, /* Handelsposten */ - { 11, 11, 12, -3 }, /* Befestigung */ - { 12, 11, 13, -1 }, /* Turm */ - { 13, 12, 14, 0 }, /* Burg */ - { 14, 12, 15, 1 }, /* Festung */ - { 15, 13, 16, 2 } /* Zitadelle */ -}; - -int cmp_wage(const struct building *b, const building * a) -{ - if (is_building_type(b->type, "castle")) { - if (!a) - return 1; - if (b->size > a->size) - return 1; - if (b->size == a->size) - return 0; - } - return -1; -} - -bool is_owner_building(const struct building * b) -{ - region *r = b->region; - if (b->type->taxes && r->land && r->land->ownership) { - unit *u = building_owner(b); - return u && u->faction == r->land->ownership->owner; - } - return false; -} - -int cmp_taxes(const building * b, const building * a) -{ - faction *f = region_get_owner(b->region); - if (b->type->taxes) { - unit *u = building_owner(b); - if (!u) { - return -1; - } - else if (a) { - int newsize = buildingeffsize(b, false); - double newtaxes = b->type->taxes(b, newsize); - int oldsize = buildingeffsize(a, false); - double oldtaxes = a->type->taxes(a, oldsize); - - if (newtaxes < oldtaxes) - return -1; - else if (newtaxes > oldtaxes) - return 1; - else if (b->size < a->size) - return -1; - else if (b->size > a->size) - return 1; - else { - if (u && u->faction == f) { - u = building_owner(a); - if (u && u->faction == f) - return -1; - return 1; - } - } - } - else { - return 1; - } - } - return -1; -} - -int cmp_current_owner(const building * b, const building * a) -{ - faction *f = region_get_owner(b->region); - - assert(rule_region_owners()); - if (f && b->type->taxes) { - unit *u = building_owner(b); - if (!u || u->faction != f) - return -1; - if (a) { - int newsize = buildingeffsize(b, false); - double newtaxes = b->type->taxes(b, newsize); - int oldsize = buildingeffsize(a, false); - double oldtaxes = a->type->taxes(a, oldsize); - - if (newtaxes > oldtaxes) { - return 1; - } - if (newtaxes < oldtaxes) { - return -1; - } - if (newsize != oldsize) { - return newsize - oldsize; - } - return (b->size - a->size); - } - else { - return 1; - } - } - return -1; -} - bool rule_stealth_other(void) { static int rule, config; @@ -807,102 +666,11 @@ int rule_faction_limit(void) return rule; } -static int -default_wage(const region * r, const faction * f, const race * rc, int in_turn) -{ - building *b = largestbuilding(r, &cmp_wage, false); - int esize = 0; - double wage; - static int ct_cache; - static const struct curse_type *drought_ct; - - if (ct_changed(&ct_cache)) { - drought_ct = ct_find("drought"); - } - if (b != NULL) { - /* TODO: this reveals imaginary castles */ - esize = buildingeffsize(b, false); - } - - if (f != NULL) { - int index = 0; - if (rc == get_race(RC_ORC) || rc == get_race(RC_SNOTLING)) { - index = 1; - } - wage = wagetable[esize][index]; - } - else { - if (is_mourning(r, in_turn)) { - wage = 10; - } - else if (fval(r->terrain, SEA_REGION)) { - wage = 11; - } - else { - wage = wagetable[esize][2]; - } - if (rule_blessed_harvest() == HARVEST_WORK) { - /* E1 rules */ - wage += curse_geteffect(get_curse(r->attribs, ct_find("blessedharvest"))); - } - } - - /* Artsculpture: Income +5 */ - for (b = r->buildings; b; b = b->next) { - if (is_building_type(b->type, "artsculpture")) { - wage += 5; - } - } - - if (r->attribs) { - attrib *a; - const struct curse_type *ctype; - /* Godcurse: Income -10 */ - ctype = ct_find("godcursezone"); - if (ctype && curse_active(get_curse(r->attribs, ctype))) { - wage = _max(0, wage - 10); - } - - /* Bei einer D�rre verdient man nur noch ein Viertel */ - if (drought_ct) { - curse *c = get_curse(r->attribs, drought_ct); - if (curse_active(c)) - wage /= curse_geteffect(c); - } - - a = a_find(r->attribs, &at_reduceproduction); - if (a) { - wage = (wage * a->data.sa[0]) / 100; - } - } - return (int)wage; -} - -static int -minimum_wage(const region * r, const faction * f, const race * rc, int in_turn) -{ - if (f && rc) { - return rc->maintenance; - } - return default_wage(r, f, rc, in_turn); -} - -/* Gibt Arbeitslohn f�r entsprechende Rasse zur�ck, oder f�r -* die Bauern wenn f == NULL. */ -int wage(const region * r, const faction * f, const race * rc, int in_turn) -{ - if (global.functions.wage) { - return global.functions.wage(r, f, rc, in_turn); - } - return default_wage(r, f, rc, in_turn); -} - void kernel_init(void) { register_reports(); mt_clear(); translation_init(); - register_function((pf_generic)minimum_wage, "minimum_wage"); } static order * defaults[MAXLOCALES]; diff --git a/src/kernel/config.h b/src/kernel/config.h index 4f84cc9ad..df0004e8b 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -54,17 +54,6 @@ struct param; int forbiddenid(int id); int newcontainerid(void); - char *untilde(char *s); - - typedef int(*cmp_building_cb) (const struct building * b, - const struct building * a); - struct building *largestbuilding(const struct region *r, cmp_building_cb, - bool imaginary); - int cmp_wage(const struct building *b, const struct building *bother); - int cmp_taxes(const struct building *b, const struct building *bother); - int cmp_current_owner(const struct building *b, - const struct building *bother); - bool rule_region_owners(void); bool rule_stealth_other(void); // units can pretend to be another faction, TARNE PARTEI bool rule_stealth_anon(void); // units can anonymize their faction, TARNE PARTEI [NICHT] @@ -97,9 +86,6 @@ struct param; #define GF_PURE 64 /* untranslated */ - int wage(const struct region *r, const struct faction *f, - const struct race *rc, int in_turn); - const char *datapath(void); void set_datapath(const char *path); From 13c29c136c9a3104e4ff3404a651066b1b82ebd6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 23 Nov 2016 17:52:57 +0100 Subject: [PATCH 271/675] eliminate config.h from triggers. was only used once, for a single fset macro --- src/triggers/createcurse.c | 1 - src/triggers/createunit.c | 1 - src/triggers/createunit.h | 1 + src/triggers/gate.c | 1 - src/triggers/giveitem.c | 1 - src/triggers/killunit.c | 1 - src/triggers/shock.c | 3 +-- src/triggers/timeout.c | 1 - src/triggers/triggers.c | 1 - src/triggers/unguard.c | 3 +-- src/triggers/unitmessage.c | 1 - 11 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/triggers/createcurse.c b/src/triggers/createcurse.c index fe39e8b7f..040a4e7b7 100644 --- a/src/triggers/createcurse.c +++ b/src/triggers/createcurse.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "createcurse.h" /* kernel includes */ diff --git a/src/triggers/createunit.c b/src/triggers/createunit.c index 2fec00ade..5952c88bc 100644 --- a/src/triggers/createunit.c +++ b/src/triggers/createunit.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "createunit.h" /* kernel includes */ diff --git a/src/triggers/createunit.h b/src/triggers/createunit.h index 31649b868..d2337d306 100644 --- a/src/triggers/createunit.h +++ b/src/triggers/createunit.h @@ -28,6 +28,7 @@ extern "C" { struct region; struct faction; struct unit; + struct race; extern struct trigger_type tt_createunit; diff --git a/src/triggers/gate.c b/src/triggers/gate.c index acf2bb5d4..e681efc04 100644 --- a/src/triggers/gate.c +++ b/src/triggers/gate.c @@ -10,7 +10,6 @@ without prior permission by the authors of Eressea. */ #include -#include #include "gate.h" /* kernel includes */ diff --git a/src/triggers/giveitem.c b/src/triggers/giveitem.c index d4a56162b..6b0e8f8c7 100644 --- a/src/triggers/giveitem.c +++ b/src/triggers/giveitem.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "giveitem.h" /* kernel includes */ diff --git a/src/triggers/killunit.c b/src/triggers/killunit.c index 23275a6af..22ad27896 100644 --- a/src/triggers/killunit.c +++ b/src/triggers/killunit.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "killunit.h" #include diff --git a/src/triggers/shock.c b/src/triggers/shock.c index f44219b5f..7c54676e0 100644 --- a/src/triggers/shock.c +++ b/src/triggers/shock.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "shock.h" #include "magic.h" @@ -84,7 +83,7 @@ static void do_shock(unit * u, const char *reason) } /* Dies ist ein Hack, um das skillmod und familiar-Attribut beim Mage - * zu lschen wenn der Familiar gettet wird. Da sollten wir ber eine + * zu l�schen wenn der Familiar get�tet wird. Da sollten wir �ber eine * saubere Implementation nachdenken. */ if (strcmp(reason, "trigger") == 0) { diff --git a/src/triggers/timeout.c b/src/triggers/timeout.c index 06fa18363..10e4d08be 100644 --- a/src/triggers/timeout.c +++ b/src/triggers/timeout.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include #include "timeout.h" /* util includes */ diff --git a/src/triggers/triggers.c b/src/triggers/triggers.c index 152fdcb58..d5ea7d3d4 100644 --- a/src/triggers/triggers.c +++ b/src/triggers/triggers.c @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include -#include /* triggers includes */ #include diff --git a/src/triggers/unguard.c b/src/triggers/unguard.c index e6471f977..72e611dcc 100644 --- a/src/triggers/unguard.c +++ b/src/triggers/unguard.c @@ -10,7 +10,6 @@ without prior permission by the authors of Eressea. */ #include -#include #include "unguard.h" /* kernel includes */ @@ -34,7 +33,7 @@ static int unguard_handle(trigger * t, void *data) building *b = (building *)t->data.v; if (b) { - fset(b, BLD_UNGUARDED); + b-> flags |= BLD_UNGUARDED; } else { log_error("could not perform unguard::handle()\n"); diff --git a/src/triggers/unitmessage.c b/src/triggers/unitmessage.c index 2d869fc49..0c1e80124 100644 --- a/src/triggers/unitmessage.c +++ b/src/triggers/unitmessage.c @@ -8,7 +8,6 @@ without prior permission by the authors of Eressea. */ #include -#include #include "unitmessage.h" /* kernel includes */ From ea6cd2ca32e44138a466b7e3135ea4bed6831cf7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 23 Nov 2016 17:55:44 +0100 Subject: [PATCH 272/675] remove unguard trigger. it is unused by the code --- src/modules/gmcmd.c | 1 - src/triggers/CMakeLists.txt | 1 - src/triggers/triggers.c | 2 - src/triggers/unguard.c | 75 ------------------------------------- src/triggers/unguard.h | 32 ---------------- 5 files changed, 111 deletions(-) delete mode 100644 src/triggers/unguard.c delete mode 100644 src/triggers/unguard.h diff --git a/src/modules/gmcmd.c b/src/modules/gmcmd.c index 810867a21..9a4e7ac47 100644 --- a/src/modules/gmcmd.c +++ b/src/modules/gmcmd.c @@ -19,7 +19,6 @@ #include #include #include -#include /* kernel includes */ #include diff --git a/src/triggers/CMakeLists.txt b/src/triggers/CMakeLists.txt index 18561f521..d6670a95b 100644 --- a/src/triggers/CMakeLists.txt +++ b/src/triggers/CMakeLists.txt @@ -11,7 +11,6 @@ killunit.c shock.c timeout.c triggers.c -unguard.c unitmessage.c ) FOREACH(_FILE ${_FILES}) diff --git a/src/triggers/triggers.c b/src/triggers/triggers.c index d5ea7d3d4..433201abd 100644 --- a/src/triggers/triggers.c +++ b/src/triggers/triggers.c @@ -24,7 +24,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include @@ -45,7 +44,6 @@ void register_triggers(void) tt_register(&tt_createcurse); tt_register(&tt_createunit); tt_register(&tt_gate); - tt_register(&tt_unguard); tt_register(&tt_giveitem); tt_register(&tt_killunit); tt_register(&tt_shock); diff --git a/src/triggers/unguard.c b/src/triggers/unguard.c deleted file mode 100644 index 72e611dcc..000000000 --- a/src/triggers/unguard.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ -#include -#include "unguard.h" - -/* kernel includes */ -#include -#include -#include -#include - -/* util includes */ -#include -#include -#include -#include -#include - -/* libc includes */ -#include - -static int unguard_handle(trigger * t, void *data) -{ - building *b = (building *)t->data.v; - - if (b) { - b-> flags |= BLD_UNGUARDED; - } - else { - log_error("could not perform unguard::handle()\n"); - return -1; - } - unused_arg(data); - return 0; -} - -static void unguard_write(const trigger * t, struct storage *store) -{ - write_building_reference((building *)t->data.v, store); -} - -static int unguard_read(trigger * t, gamedata *data) -{ - int rb = read_reference(&t->data.v, data, read_building_reference, - resolve_building); - if (rb == 0 && !t->data.v) { - return AT_READ_FAIL; - } - return AT_READ_OK; -} - -struct trigger_type tt_unguard = { - "building", - NULL, - NULL, - unguard_handle, - unguard_write, - unguard_read -}; - -trigger *trigger_unguard(building * b) -{ - trigger *t = t_new(&tt_unguard); - t->data.v = (void *)b; - return t; -} diff --git a/src/triggers/unguard.h b/src/triggers/unguard.h deleted file mode 100644 index f36f527f8..000000000 --- a/src/triggers/unguard.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. -*/ - -#ifndef UNGUARD_H -#define UNGUARD_H -#ifdef __cplusplus -extern "C" { -#endif - -/* all types we use are defined here to reduce dependencies */ - struct trigger_type; - struct trigger; - struct region; - struct building; - - extern struct trigger_type tt_unguard; - - extern struct trigger *trigger_unguard(struct building *b); - -#ifdef __cplusplus -} -#endif -#endif From 7f9313f1a7815fa46c753491d3d0afa7b4ce9797 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 23 Nov 2016 18:56:40 +0100 Subject: [PATCH 273/675] static analysis warnings. PVS-Studio warnings reduced or suppressed. --- src/alchemy.c | 2 +- src/battle.c | 6 ++---- src/battle.h | 2 +- src/json.c | 17 +++++++++++++---- src/laws.c | 9 ++++----- src/magic.c | 2 +- src/prefix.c | 13 +++++++++++-- src/prefix.h | 2 +- src/prefix.test.c | 4 ++-- src/randenc.c | 18 +++++++++--------- src/report.c | 12 ++++++------ src/reports.c | 23 +++++------------------ 12 files changed, 56 insertions(+), 54 deletions(-) diff --git a/src/alchemy.c b/src/alchemy.c index 9f942fc5a..9bc180700 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -295,7 +295,7 @@ static void a_initeffect(attrib * a) a->data.v = calloc(sizeof(effect_data), 1); } -static void a_finalizeeffect(attrib * a) +static void a_finalizeeffect(attrib * a) //-V524 { free(a->data.v); } diff --git a/src/battle.c b/src/battle.c index 9e024c1af..7aa3e4cfa 100644 --- a/src/battle.c +++ b/src/battle.c @@ -3984,7 +3984,7 @@ static bool start_battle(region * r, battle ** bp) while (a && a->type == &at_curse) { curse *c = (curse *)a->data.v; if (c->type == calm_ct - && curse_geteffect(c) == u2->faction->subscription) { + && curse_geteffect_int(c) == u2->faction->subscription) { if (curse_active(c)) { calm = true; break; @@ -4275,9 +4275,7 @@ void do_battle(region * r) /* Hier ist das Gefecht beendet, und wir k�nnen die * Hilfsstrukturen * wieder l�schen: */ - if (b) { - free_battle(b); - } + free_battle(b); } void do_battles(void) { diff --git a/src/battle.h b/src/battle.h index 45feb10a1..007bda008 100644 --- a/src/battle.h +++ b/src/battle.h @@ -72,7 +72,7 @@ extern "C" { unsigned char relations[MAXSIDES]; struct side *enemies[MAXSIDES]; struct fighter *fighters; - int index; /* Eintrag der Fraktion in b->matrix/b->enemies */ + unsigned int index; /* Eintrag der Fraktion in b->matrix/b->enemies */ int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */ int nonblockers[NUMROWS]; /* Anzahl nichtblockierender Kaempfer, z.B. Schattenritter. */ int alive; /* Die Partei hat den Kampf verlassen */ diff --git a/src/json.c b/src/json.c index 007c3aeda..10322fe3f 100644 --- a/src/json.c +++ b/src/json.c @@ -1,8 +1,9 @@ #include "platform.h" -#include #include "json.h" +#include +#include #include #include #include @@ -22,12 +23,20 @@ int json_import(struct stream * out) { 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); + char *tmp; + tmp = (char *)realloc(data, sz + len + 1); + if (!tmp) { + log_fatal("allocation failure in json_import"); + free(data); + return 1; + } + data = tmp; memcpy(data + sz, buffer, len); sz += len; data[sz] = 0; } json = cJSON_Parse(data); + free(data); child = cJSON_GetObjectItem(json, "regions"); if (child && child->type == cJSON_Object) { cJSON *j; @@ -64,7 +73,7 @@ int json_export(stream * out, int flags) { cJSON_AddItemToObject(root, "planes", json = cJSON_CreateObject()); for (p = planes; p; p = p->next) { cJSON *data; - _snprintf(id, sizeof(id), "%u", p->id); + _snprintf(id, sizeof(id), "%d", p->id); cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); cJSON_AddNumberToObject(data, "x", p->minx); cJSON_AddNumberToObject(data, "y", p->miny); @@ -76,7 +85,7 @@ int json_export(stream * out, int flags) { cJSON_AddItemToObject(root, "regions", json = cJSON_CreateObject()); for (r = regions; r; r = r->next) { cJSON *data; - _snprintf(id, sizeof(id), "%u", r->uid); + _snprintf(id, sizeof(id), "%d", r->uid); cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); cJSON_AddNumberToObject(data, "x", r->x); cJSON_AddNumberToObject(data, "y", r->y); diff --git a/src/laws.c b/src/laws.c index 7ab6c7560..3fe53237e 100644 --- a/src/laws.c +++ b/src/laws.c @@ -648,7 +648,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season) * verfügbaren Fläche ab. In Gletschern gibt es weniger * Möglichkeiten als in Ebenen. */ sprout = 0; - seedchance = (1000 * region_maxworkers(r2)) / (double)r2->terrain->size; + seedchance = (1000.0 * region_maxworkers(r2)) / r2->terrain->size; for (i = 0; i < seeds / MAXDIRECTIONS; i++) { if (rng_int() % 10000 < seedchance) sprout++; @@ -1269,7 +1269,6 @@ static void remove_idle_players(void) } else { if (fval(f, FFL_NOIDLEOUT)) { f->lastorders = turn; - fp = &f->next; } else if (turn != f->lastorders) { char info[256]; @@ -2995,9 +2994,9 @@ static void ageing(void) for (up = &r->units; *up;) { unit *u = *up; a_age(&u->attribs, u); - if (u == *up) + if (u == *up) handle_event(u->attribs, "timer", u); - if (u == *up) + if (u == *up) //-V581 up = &(*up)->next; } @@ -3007,7 +3006,7 @@ static void ageing(void) a_age(&s->attribs, s); if (s == *sp) handle_event(s->attribs, "timer", s); - if (s == *sp) + if (s == *sp) //-V581 sp = &(*sp)->next; } diff --git a/src/magic.c b/src/magic.c index d13be7c07..2299e6523 100644 --- a/src/magic.c +++ b/src/magic.c @@ -173,7 +173,7 @@ static void a_initicastle(struct attrib *a) a->data.v = calloc(sizeof(icastle_data), 1); } -static void a_finalizeicastle(struct attrib *a) +static void a_finalizeicastle(struct attrib *a) //-V524 { free(a->data.v); } diff --git a/src/prefix.c b/src/prefix.c index b6adb7c02..a6564b6e8 100644 --- a/src/prefix.c +++ b/src/prefix.c @@ -1,6 +1,8 @@ #include #include "prefix.h" +#include + #include #include #include @@ -10,7 +12,7 @@ char **race_prefixes = NULL; static size_t size = 4; static unsigned int next = 0; -void add_raceprefix(const char *prefix) +int add_raceprefix(const char *prefix) { assert(prefix); if (race_prefixes == NULL) { @@ -19,11 +21,18 @@ void add_raceprefix(const char *prefix) race_prefixes = malloc(size * sizeof(char *)); } if (next + 1 == size) { + char **tmp; + tmp = realloc(race_prefixes, 2 * size * sizeof(char *)); + if (!tmp) { + log_fatal("allocation failure"); + return 1; + } + race_prefixes = tmp; size *= 2; - race_prefixes = realloc(race_prefixes, size * sizeof(char *)); } race_prefixes[next++] = _strdup(prefix); race_prefixes[next] = NULL; + return 0; } void free_prefixes(void) { diff --git a/src/prefix.h b/src/prefix.h index 9c5b84907..aa04e505b 100644 --- a/src/prefix.h +++ b/src/prefix.h @@ -7,7 +7,7 @@ extern "C" { #endif - void add_raceprefix(const char *); + int add_raceprefix(const char *); char **race_prefixes; // zero-terminated array of valid prefixes void free_prefixes(void); diff --git a/src/prefix.test.c b/src/prefix.test.c index 222c19f85..a914426fa 100644 --- a/src/prefix.test.c +++ b/src/prefix.test.c @@ -8,11 +8,11 @@ static void test_add_prefix(CuTest *tc) { test_setup(); CuAssertPtrEquals(tc, 0, race_prefixes); - add_raceprefix("sea"); + CuAssertIntEquals(tc, 0, add_raceprefix("sea")); CuAssertPtrNotNull(tc, race_prefixes); CuAssertStrEquals(tc, "sea", race_prefixes[0]); CuAssertPtrEquals(tc, 0, race_prefixes[1]); - add_raceprefix("moon"); + CuAssertIntEquals(tc, 0, add_raceprefix("moon")); CuAssertStrEquals(tc, "sea", race_prefixes[0]); CuAssertStrEquals(tc, "moon", race_prefixes[1]); CuAssertPtrEquals(tc, 0, race_prefixes[2]); diff --git a/src/randenc.c b/src/randenc.c index ba51ab4e3..a3c5ce303 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -69,7 +69,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. extern struct attrib_type at_unitdissolve; /* In a->data.ca[1] steht der Prozentsatz mit dem sich die Einheit - * auflst, in a->data.ca[0] kann angegeben werden, wohin die Personen + * aufl�st, in a->data.ca[0] kann angegeben werden, wohin die Personen * verschwinden. Passiert bereits in der ersten Runde! */ static void dissolve_units(void) { @@ -442,12 +442,12 @@ static void melt_iceberg(region * r) ADDMSG(&u->faction->msgs, msg_message("iceberg_melt", "region", r)); } - /* driftrichtung lschen */ + /* driftrichtung l�schen */ a = a_find(r->attribs, &at_iceberg); if (a) a_remove(&r->attribs, a); - /* Gebude lschen */ + /* Geb�ude l�schen */ while (r->buildings) { remove_building(&r->buildings, r->buildings); } @@ -455,7 +455,7 @@ static void melt_iceberg(region * r) /* in Ozean wandeln */ terraform_region(r, newterrain(T_OCEAN)); - /* Einheiten, die nicht schwimmen knnen oder in Schiffen sind, + /* Einheiten, die nicht schwimmen k�nnen oder in Schiffen sind, * ertrinken */ drown(r); } @@ -519,13 +519,13 @@ static void move_iceberg(region * r) freset(sh, SF_SELECT); for (sh = r->ships; sh; sh = sh->next) { - /* Meldung an Kapitn */ + /* Meldung an Kapit�n */ double dmg = config_get_flt("rules.ship.damage.intoiceberg", 0.1); damage_ship(sh, dmg); fset(sh, SF_SELECT); } - /* Personen, Schiffe und Gebude verschieben */ + /* Personen, Schiffe und Geb�ude verschieben */ while (rc->buildings) { rc->buildings->region = r; translist(&rc->buildings, &r->buildings, rc->buildings); @@ -544,7 +544,7 @@ static void move_iceberg(region * r) u_set_building(u, b); /* undo leave-prevention */ } - /* Beschdigte Schiffe knnen sinken */ + /* Besch�digte Schiffe k�nnen sinken */ for (sh = r->ships; sh;) { shn = sh->next; @@ -725,7 +725,7 @@ static void orc_growth(void) } } -/** Talente von Dmonen verschieben sich. +/** Talente von D�monen verschieben sich. */ static void demon_skillchanges(void) { @@ -760,7 +760,7 @@ static void icebergs(void) } #define HERBS_ROT /* herbs owned by units have a chance to rot. */ -#define HERBROTCHANCE 5 /* Verrottchance fr Kruter (ifdef HERBS_ROT) */ +#define HERBROTCHANCE 5 /* Verrottchance f�r Kr�uter (ifdef HERBS_ROT) */ #ifdef HERBS_ROT static void rotting_herbs(void) { diff --git a/src/report.c b/src/report.c index e9b66c461..040c44db1 100644 --- a/src/report.c +++ b/src/report.c @@ -915,14 +915,16 @@ static void describe(struct stream *out, const region * r, faction * f) bool transparent = b->type->transparent(b, f); const char *name = border_name(b, r, f, GF_DETAILED | GF_ARTICLE); - if (!transparent) + if (!transparent) { see[d] = false; + } if (!see_border(b, f, r)) { b = b->next; continue; } - while (e && (e->transparent != transparent || strcmp(name, e->name))) + while (e && (e->transparent != transparent || strcmp(name, e->name)!=0)) { e = e->next; + } if (!e) { e = calloc(sizeof(struct edge), 1); e->name = _strdup(name); @@ -2248,10 +2250,8 @@ report_plaintext(const char *filename, report_context * ctx, *bufp = 0; centre(out, buf, true); newline(out); - if (description == NULL) { - const char *potiontext = mkname("potion", pname); - description = LOC(f->locale, potiontext); - } + description = mkname("potion", pname); + description = LOC(f->locale, description); centre(out, description, true); } } diff --git a/src/reports.c b/src/reports.c index f4c38712c..f0c82d024 100644 --- a/src/reports.c +++ b/src/reports.c @@ -720,7 +720,7 @@ size_t size) } } if (!isbattle) { - bool printed = 0; + int printed = 0; order *ord;; for (ord = u->old_orders; ord; ord = ord->next) { keyword_t kwd = getkeyword(ord); @@ -1587,7 +1587,7 @@ static void var_free_resources(variant x) x.v = 0; } -static void var_free_regions(variant x) +static void var_free_regions(variant x) //-V524 { free(x.v); } @@ -1716,18 +1716,6 @@ static void eval_curse(struct opstack **stack, const void *userdata) opush(stack, var); } -static void eval_unitname(struct opstack **stack, const void *userdata) -{ /* unit -> string */ - const struct faction *f = (const struct faction *)userdata; - const struct unit *u = (const struct unit *)opop(stack).v; - const char *c = u ? unit_getname(u) : LOC(f->locale, "an_unknown_unit"); - size_t len = strlen(c); - variant var; - - var.v = strcpy(balloc(len + 1), c); - opush(stack, var); -} - static void eval_unitid(struct opstack **stack, const void *userdata) { /* unit -> int */ const struct faction *f = (const struct faction *)userdata; @@ -1836,16 +1824,16 @@ static void eval_weight(struct opstack **stack, const void *userdata) sprintf(buffer, "1 %s", LOC(lang, "weight_unit")); } else { - sprintf(buffer, "%u %s", weight / SCALEWEIGHT, LOC(lang, + sprintf(buffer, "%d %s", weight / SCALEWEIGHT, LOC(lang, "weight_unit_p")); } } else { if (weight == 1) { - sprintf(buffer, "1 %s %u", LOC(lang, "weight_per"), SCALEWEIGHT); + sprintf(buffer, "1 %s %d", LOC(lang, "weight_per"), SCALEWEIGHT); } else { - sprintf(buffer, "%u %s %u", weight, LOC(lang, "weight_per_p"), + sprintf(buffer, "%d %s %d", weight, LOC(lang, "weight_per_p"), SCALEWEIGHT); } } @@ -2136,7 +2124,6 @@ void register_reports(void) add_function("ship", &eval_ship); add_function("unit", &eval_unit); add_function("unit.dative", &eval_unit_dative); - add_function("unit.name", &eval_unitname); add_function("unit.id", &eval_unitid); add_function("unit.size", &eval_unitsize); add_function("building", &eval_building); From 91adf420bc1102de2a090d0b0bc4c3053695f26e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 23 Nov 2016 19:04:17 +0100 Subject: [PATCH 274/675] strncat error V645 --- src/spy.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/spy.c b/src/spy.c index 6bb1a18e5..5fdd806cc 100644 --- a/src/spy.c +++ b/src/spy.c @@ -44,11 +44,13 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* util includes */ #include #include +#include #include -#include #include #include +#include + /* libc includes */ #include #include @@ -98,13 +100,13 @@ void spy_message(int spy, const unit * u, const unit * target) first = 0; } else { - strncat(buf, ", ", sizeof(buf) - 1); + strlcat(buf, ", ", sizeof(buf)); } - strncat(buf, (const char *)skillname((skill_t)sv->id, u->faction->locale), - sizeof(buf) - 1); - strncat(buf, " ", sizeof(buf) - 1); - strncat(buf, itoa10(eff_skill(target, sv, target->region)), - sizeof(buf) - 1); + strlcat(buf, (const char *)skillname((skill_t)sv->id, u->faction->locale), + sizeof(buf)); + strlcat(buf, " ", sizeof(buf)); + strlcat(buf, itoa10(eff_skill(target, sv, target->region)), + sizeof(buf)); } } if (found) { From ecd74c53f561277a6da6dbf9ddfc542802a45634 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 23 Nov 2016 19:19:04 +0100 Subject: [PATCH 275/675] More PVS-Studio warnings eliminated. --- src/bind_unit.c | 4 +--- src/gmtool.c | 6 +++--- src/kernel/build.c | 16 +++++++--------- src/kernel/group.test.c | 2 +- src/kernel/item.c | 1 - src/util/bsdstring.test.c | 2 +- src/util/event.c | 2 +- src/util/log.c | 2 +- src/util/rand.c | 11 ++++++----- 9 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/bind_unit.c b/src/bind_unit.c index 576678642..42fafae39 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -756,9 +756,7 @@ static int tolua_unit_get_spells(lua_State * L) quicklist *slist = 0; if (sb) { quicklist **slist_ptr = &sb->spells; - if (slist_ptr) { - slist = *slist_ptr; - } + slist = *slist_ptr; } return tolua_quicklist_push(L, "spellbook", "spell_entry", slist); } diff --git a/src/gmtool.c b/src/gmtool.c index 05997ed6e..7aab2fea7 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -184,7 +184,7 @@ map_region *mr_get(const view * vi, int xofs, int yofs) static point *coor2point(const coordinate * c, point * p) { assert(c && p); - p->x = c->x * TWIDTH + c->y * TWIDTH / 2; + p->x = c->x * TWIDTH + c->y * TWIDTH / 2; //-V537 p->y = c->y * THEIGHT; return p; } @@ -262,7 +262,7 @@ static chtype mr_tile(const map_region * mr, int highlight) const region *r = mr->r; switch (r->terrain->_name[0]) { case 'o': - return '.' | COLOR_PAIR(hl + COLOR_CYAN) | A_BOLD; + return '.' | COLOR_PAIR(hl + COLOR_CYAN) | A_BOLD; //-V525 case 'd': return 'D' | COLOR_PAIR(hl + COLOR_YELLOW) | A_BOLD; case 't': @@ -1167,7 +1167,7 @@ static void handlekey(state * st, int c) region *first = (mr && mr->r && mr->r->next) ? mr->r->next : regions; if (findmode == 'f') { - sprintf(sbuffer, "find-faction: %s", locate); + snprintf(sbuffer, sizeof(sbuffer), "find-faction: %s", locate); statusline(st->wnd_status->handle, sbuffer); f = findfaction(atoi36(locate)); if (f == NULL) { diff --git a/src/kernel/build.c b/src/kernel/build.c index 649679d93..b5a1b3417 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -249,7 +249,7 @@ int destroy_cmd(unit * u, struct order *ord) } if (con) { - /* TODO: Nicht an ZERSTRE mit Punktangabe angepasst! */ + /* TODO: Nicht an ZERST�RE mit Punktangabe angepasst! */ int c; for (c = 0; con->materials[c].number; ++c) { const requirement *rq = con->materials + c; @@ -513,8 +513,8 @@ int build(unit * u, const construction * ctype, int completed, int want) /* Hier ist entweder maxsize == -1, oder completed < maxsize. * Andernfalls ist das Datenfile oder sonstwas kaputt... - * (enno): Nein, das ist fr Dinge, bei denen die nchste Ausbaustufe - * die gleiche wie die vorherige ist. z.b. gegenstnde. + * (enno): Nein, das ist f�r Dinge, bei denen die n�chste Ausbaustufe + * die gleiche wie die vorherige ist. z.b. gegenst�nde. */ if (type->maxsize > 0) { completed = completed % type->maxsize; @@ -759,10 +759,8 @@ build_building(unit * u, const building_type * btype, int id, int want, order * return 0; } } - } - - if (b) built = b->size; + } if (n <= 0 || n == INT_MAX) { if (b == NULL) { if (btype->maxsize > 0) { @@ -817,11 +815,11 @@ build_building(unit * u, const building_type * btype, int id, int want, order * btname = LOC(lang, btype->_name); if (want - built <= 0) { - /* gebude fertig */ + /* geb�ude fertig */ new_order = default_order(lang); } else if (want != INT_MAX && btname) { - /* reduzierte restgre */ + /* reduzierte restgr��e */ const char *hasspace = strchr(btname, ' '); if (hasspace) { new_order = @@ -833,7 +831,7 @@ build_building(unit * u, const building_type * btype, int id, int want, order * } } else if (btname) { - /* Neues Haus, Befehl mit Gebudename */ + /* Neues Haus, Befehl mit Geb�udename */ const char *hasspace = strchr(btname, ' '); if (hasspace) { new_order = create_order(K_MAKE, lang, "\"%s\" %i", btname, b->no); diff --git a/src/kernel/group.test.c b/src/kernel/group.test.c index 22d55e36f..78ee6b24f 100644 --- a/src/kernel/group.test.c +++ b/src/kernel/group.test.c @@ -82,7 +82,7 @@ static void test_group_readwrite(CuTest * tc) mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); f = test_create_faction(0); - g = new_group(f, "NW", 42); + new_group(f, "NW", 42); g = new_group(f, "Egoisten", 43); key_set(&g->attribs, 44); al = ally_add(&g->allies, f); diff --git a/src/kernel/item.c b/src/kernel/item.c index cedf15df0..53fff79ab 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -239,7 +239,6 @@ item_type *it_get_or_create(resource_type *rtype) { item_type * itype; assert(rtype); itype = it_find(rtype->_name); - assert(!itype || !itype->rtype || itype->rtype == rtype); if (!itype) { itype = (item_type *)calloc(sizeof(item_type), 1); } diff --git a/src/util/bsdstring.test.c b/src/util/bsdstring.test.c index 0fffd187c..b5fe81156 100644 --- a/src/util/bsdstring.test.c +++ b/src/util/bsdstring.test.c @@ -32,7 +32,7 @@ static void test_strlcpy(CuTest * tc) CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 4)); CuAssertStrEquals(tc, "her", buffer); - CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 8)); + CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 8)); //-V666 CuAssertStrEquals(tc, "herp", buffer); CuAssertIntEquals(tc, 0x7f, buffer[5]); diff --git a/src/util/event.c b/src/util/event.c index ad5a9e725..cdf178aec 100644 --- a/src/util/event.c +++ b/src/util/event.c @@ -244,7 +244,7 @@ void tt_register(trigger_type * tt) trigger_type *tt_find(const char *name) { trigger_type *tt = triggertypes; - while (tt && strcmp(tt->name, name)) + while (tt && strcmp(tt->name, name)!=0) tt = tt->next; return tt; } diff --git a/src/util/log.c b/src/util/log.c index d394aa20d..759efba39 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -220,7 +220,7 @@ void log_fatal(const char *format, ...) va_end(args); } -void log_error(const char *format, ...) +void log_error(const char *format, ...) //-V524 { va_list args; va_start(args, format); diff --git a/src/util/rand.c b/src/util/rand.c index b92b4aff3..f5c8a28bc 100644 --- a/src/util/rand.c +++ b/src/util/rand.c @@ -103,13 +103,13 @@ void random_source_inject_constant(double value) { r_source = &constant_provider; } -static int i = 0; static double *values; -static int value_size = 0; +static int value_size; +static int value_index; static double array_source (void) { - assert(i 0); value_size = size; if (values) @@ -125,7 +126,7 @@ void random_source_inject_array(double inject[], int size) { for (i=0; i < size; ++i) { values[i] = inject[i]; } - i = 0; + value_index = 0; r_source = &array_provider; } From 78e63ed4c6c4908c0f8dcde15aa1a848b8e0e659 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 25 Nov 2016 09:48:38 +0000 Subject: [PATCH 276/675] misleading indentation --- src/kernel/save.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 83fa72f76..2f157af41 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -298,7 +298,7 @@ int readorders(const char *filename) * vermerkt. */ case P_UNIT: - if (!f || !unitorders(F, enc_gamedata, f)) + if (!f || !unitorders(F, enc_gamedata, f)) { do { b = getbuf(F, enc_gamedata); if (!b) { @@ -309,7 +309,8 @@ int readorders(const char *filename) p = (s && s[0] != '@') ? findparam(s, lang) : NOPARAM; } while ((p != P_UNIT || !f) && p != P_FACTION && p != P_NEXT && p != P_GAMENAME); - break; + } + break; /* Falls in unitorders() abgebrochen wird, steht dort entweder eine neue * Partei, eine neue Einheit oder das File-Ende. Das switch() wird erneut From c9c4f5dd3732606809f818a76e52814d327486fb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 25 Nov 2016 09:54:05 +0000 Subject: [PATCH 277/675] gcc complains about BSD_SOURCE now --- src/platform.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/platform.h b/src/platform.h index 77a767875..d813fab9d 100644 --- a/src/platform.h +++ b/src/platform.h @@ -81,17 +81,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif /* _MSC_VER_ */ #if defined __GNUC__ -# undef _BSD_SOURCE -# define _BSD_SOURCE +# undef _DEFAULT_SOURCE +# define _DEFAULT_SOURCE # undef __USE_BSD # define __USE_BSD #endif -#ifdef _BSD_SOURCE -# undef __EXTENSIONS__ -# define __EXTENSIONS__ -#endif - #ifdef SOLARIS # define _SYS_PROCSET_H #undef _XOPEN_SOURCE From 5e49ac6fdfac79021c2034be243274e7005a0788 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 25 Nov 2016 16:01:28 +0000 Subject: [PATCH 278/675] fix $MACHINE variable, update submodules --- s/cmake-init | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/s/cmake-init b/s/cmake-init index b1ea6759a..ea94afb7c 100755 --- a/s/cmake-init +++ b/s/cmake-init @@ -9,17 +9,18 @@ while [ ! -d $ROOT/.git ]; do done [ -z $BUILD ] && BUILD=Debug -MACHINE=`uname -m` [ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang" [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" [ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" [ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc" + +MACHINE=`$CC -dumpmachine` +[ -z $MACHINE ] && MACHINE=`uname -m` BIN_DIR="$ROOT/build-$MACHINE-$CC-$BUILD" mkdir -p $BIN_DIR rm -f $BUILD ln -sf $BIN_DIR $BUILD -MACHINE=$(gcc -dumpmachine) rm -f CMakeCache.txt # use anything installed in /opt or /usr @@ -41,6 +42,8 @@ ARGS=" -DCMAKE_MODULE_PATH=$ROOT/cmake/Modules \ -DCMAKE_PREFIX_PATH=$PREFIX_PATH \ -DCMAKE_INSTALL_PREFIX=$HOME/eressea/server" +git submodule update --init + path="$(which tolua)" if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then echo "tolua is not installed, building from source" From e52cf75c59de82cf6e316d87f12d9f3ae9d3d1d0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 25 Nov 2016 20:15:11 +0100 Subject: [PATCH 279/675] remove autoconf.h from platform.h, fix lots of includes --- src/attributes/fleechance.c | 2 + src/attributes/key.test.c | 1 + src/attributes/matmod.c | 1 + src/console.h | 3 ++ src/creport.c | 11 +++--- src/creport.test.c | 1 - src/game.pkg | 1 - src/game.pkg.c | 1 - src/kernel/building.h | 1 + src/kernel/config.h | 1 + src/kernel/curse.c | 2 +- src/kernel/order.h | 6 ++- src/kernel/order.test.c | 1 - src/kernel/race.h | 7 ++-- src/kernel/ship.h | 9 +++-- src/kernel/unit.h | 2 + src/main.c | 5 --- src/modules/score.h | 2 + src/names.h | 3 ++ src/platform.h | 76 ++++++++++++++++++++++++++++++++++-- src/report.c | 16 +++----- src/report.test.c | 1 - src/reports.c | 15 ++----- src/reports.test.c | 1 - src/spells/magicresistance.c | 2 + src/util/nrmessage.h | 3 ++ src/util/parser.h | 3 ++ src/util/strings.h | 3 ++ src/util/translation.h | 3 ++ 29 files changed, 131 insertions(+), 52 deletions(-) diff --git a/src/attributes/fleechance.c b/src/attributes/fleechance.c index 232037972..afba2d301 100644 --- a/src/attributes/fleechance.c +++ b/src/attributes/fleechance.c @@ -21,6 +21,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include +#include + attrib_type at_fleechance = { "fleechance", NULL, diff --git a/src/attributes/key.test.c b/src/attributes/key.test.c index 46343d19f..2b7632917 100644 --- a/src/attributes/key.test.c +++ b/src/attributes/key.test.c @@ -3,6 +3,7 @@ #include #include +#include static void test_get_set_keys(CuTest *tc) { attrib *a = 0; diff --git a/src/attributes/matmod.c b/src/attributes/matmod.c index f885de99b..0cf1955d8 100644 --- a/src/attributes/matmod.c +++ b/src/attributes/matmod.c @@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "matmod.h" #include +#include attrib_type at_matmod = { "matmod", diff --git a/src/console.h b/src/console.h index a00a3ad58..fdc869f11 100644 --- a/src/console.h +++ b/src/console.h @@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_LUA_CONSOLE #define H_LUA_CONSOLE + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/creport.c b/src/creport.c index b63a30ad4..c05377e2e 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1468,7 +1468,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r) /* main function of the creport. creates the header and traverses all regions */ static int -report_computer(const char *filename, report_context * ctx, const char *charset) +report_computer(const char *filename, report_context * ctx, const char *bom) { static int era = -1; int i; @@ -1488,9 +1488,8 @@ report_computer(const char *filename, report_context * ctx, const char *charset) perror(filename); return -1; } - else if (_strcmpl(charset, "utf-8") == 0 || _strcmpl(charset, "utf8") == 0) { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; - fwrite(utf8_bom, 1, 3, F); + else if (bom) { + fwrite(bom, 1, strlen(bom), F); } /* must call this to get all the neighbour regions */ @@ -1498,8 +1497,8 @@ report_computer(const char *filename, report_context * ctx, const char *charset) /* initialisations, header and lists */ fprintf(F, "VERSION %d\n", C_REPORT_VERSION); - fprintf(F, "\"%s\";charset\n", charset); - fprintf(F, "\"%s\";locale\n", locale_name(f->locale)); + fprintf(F, "\"utf-8\";charset\n\"%s\";locale\n", + locale_name(f->locale)); fprintf(F, "%d;noskillpoints\n", 1); fprintf(F, "%lld;date\n", (long long)ctx->report_time); fprintf(F, "\"%s\";Spiel\n", game_name()); diff --git a/src/creport.test.c b/src/creport.test.c index 3a84ea566..72669e99f 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -1,5 +1,4 @@ #include -#include #include "creport.h" #include "move.h" #include "travelthru.h" diff --git a/src/game.pkg b/src/game.pkg index 88b3bda9a..dc2b324e4 100644 --- a/src/game.pkg +++ b/src/game.pkg @@ -1,6 +1,5 @@ $#undef tolua_reg_types $#define tolua_reg_types tolua_reg_types_game -$#include "config.h" $#include "bind_eressea.h" module eressea { diff --git a/src/game.pkg.c b/src/game.pkg.c index abd7832ca..30671021d 100644 --- a/src/game.pkg.c +++ b/src/game.pkg.c @@ -20,7 +20,6 @@ LUALIB_API int luaopen_game (lua_State* tolua_S); #undef tolua_reg_types #define tolua_reg_types tolua_reg_types_game -#include "config.h" #include "bind_eressea.h" /* function to register type */ diff --git a/src/kernel/building.h b/src/kernel/building.h index aee387e7f..92b006b98 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/config.h b/src/kernel/config.h index df0004e8b..91d5d576f 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -24,6 +24,7 @@ extern "C" { #endif /* this should always be the first thing included after platform.h */ +#include #include "types.h" struct param; diff --git a/src/kernel/curse.c b/src/kernel/curse.c index 2ee89799d..123f858f5 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -349,7 +349,7 @@ const curse_type *ct_find(const char *c) } else { size_t k = _min(c_len, strlen(type->cname)); - if (!_memicmp(c, type->cname, k)) { + if (!memcmp(c, type->cname, k)) { return type; } } diff --git a/src/kernel/order.h b/src/kernel/order.h index 8ad5592b7..69cf1ea33 100644 --- a/src/kernel/order.h +++ b/src/kernel/order.h @@ -12,12 +12,14 @@ #ifndef KRNL_ORDER_H #define KRNL_ORDER_H + +#include "keyword.h" +#include + #ifdef __cplusplus extern "C" { #endif -#include "keyword.h" - /* Encapsulation of an order * * This structure contains one order given by a unit. These used to be diff --git a/src/kernel/order.test.c b/src/kernel/order.test.c index 635e6e078..f5eb51c6f 100644 --- a/src/kernel/order.test.c +++ b/src/kernel/order.test.c @@ -1,5 +1,4 @@ #include -#include #include #include "order.h" diff --git a/src/kernel/race.h b/src/kernel/race.h index c7dbe3669..022d09c86 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -18,13 +18,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_KRNL_RACE_H #define H_KRNL_RACE_H +#include +#include "magic.h" /* wegen MAXMAGIETYP */ +#include "skill.h" + #ifdef __cplusplus extern "C" { #endif -#include "magic.h" /* wegen MAXMAGIETYP */ -#include "skill.h" - #define AT_NONE 0 #define AT_STANDARD 1 #define AT_DRAIN_EXP 2 diff --git a/src/kernel/ship.h b/src/kernel/ship.h index 748315d44..964ee2124 100644 --- a/src/kernel/ship.h +++ b/src/kernel/ship.h @@ -18,13 +18,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_KRNL_SHIP #define H_KRNL_SHIP -#ifdef __cplusplus -extern "C" { -#endif #include "types.h" #include "direction.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + #define DAMAGE_SCALE 100 /* multiplier for sh->damage */ /* ship_type::flags */ diff --git a/src/kernel/unit.h b/src/kernel/unit.h index e81c43135..e846ca1f4 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "types.h" #include "skills.h" +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/main.c b/src/main.c index 16f56bf57..44c1b9e2d 100644 --- a/src/main.c +++ b/src/main.c @@ -70,11 +70,6 @@ static void load_inifile(dictionary * d) lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0; - str = iniparser_getstring(d, "eressea:encoding", NULL); - if (str && (_strcmpl(str, "utf8") == 0 || _strcmpl(str, "utf-8") == 0)) { - enc_gamedata = ENCODING_UTF8; - } - verbosity = iniparser_getint(d, "eressea:verbose", 2); battledebug = iniparser_getint(d, "eressea:debug", battledebug) ? 1 : 0; diff --git a/src/modules/score.h b/src/modules/score.h index b0f1b2a91..4fc1f52bb 100644 --- a/src/modules/score.h +++ b/src/modules/score.h @@ -18,6 +18,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef SCORE_H #define SCORE_H + +#include #ifdef __cplusplus extern "C" { #endif diff --git a/src/names.h b/src/names.h index 63e9c8628..d7ab417c1 100644 --- a/src/names.h +++ b/src/names.h @@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_KRNL_NAMES #define H_KRNL_NAMES + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/platform.h b/src/platform.h index d813fab9d..553f734c9 100644 --- a/src/platform.h +++ b/src/platform.h @@ -81,10 +81,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif /* _MSC_VER_ */ #if defined __GNUC__ +# define _POSIX_C_SOURCE 200809L # undef _DEFAULT_SOURCE # define _DEFAULT_SOURCE # undef __USE_BSD # define __USE_BSD +# define HAVE_SNPRINTF +# define HAVE_SYS_STAT_MKDIR +# define HAVE_STRDUP +# define HAVE_UNISTD_H #endif #ifdef SOLARIS @@ -104,10 +109,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define TOLUA_CAST (char*) -#ifdef USE_AUTOCONF -# include -#endif - #if !defined(MAX_PATH) #if defined(PATH_MAX) # define MAX_PATH PATH_MAX @@ -124,5 +125,72 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #endif +#if defined(HAVE_STDBOOL_H) +# include +#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) +#endif +#endif + +#if defined(HAVE_DIRECT__MKDIR) +#include +#elif defined(HAVE_DIRECT_MKDIR) +#include +#define _mkdir(a) mkdir(a) +#elif defined(HAVE_SYS_STAT_MKDIR) +#include +#define _mkdir(a) mkdir(a, 0777) +#endif + +#ifndef _min +#define _min(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef _max +#define _max(a,b) ((a) > (b) ? (a) : (b)) +#endif + +#if !defined(HAVE__STRDUP) +#if defined(HAVE_STRDUP) +#define _strdup(a) strdup(a) +#else +#define _strdup(a) lcp_strdup(a) +#endif +#endif + +#if !defined(HAVE__SNPRINTF) +#if defined(HAVE_SNPRINTF) +#define _snprintf snprintf +#endif +#endif + +#if !defined(HAVE__STRCMPL) +#if defined(HAVE_STRCMPL) +#define _strcmpl(a, b) strcmpl(a, b) +#elif defined(HAVE__STRICMP) +#define _strcmpl(a, b) _stricmp(a, b) +#elif defined(HAVE_STRICMP) +#define _strcmpl(a, b) stricmp(a, b) +#elif defined(HAVE_STRCASECMP) +#define _strcmpl(a, b) strcasecmp(a, b) +#else +#define _strcmpl(a, b) lcp_strcmpl(a, b) +#endif +#endif + #endif diff --git a/src/report.c b/src/report.c index 040c44db1..dd6b29525 100644 --- a/src/report.c +++ b/src/report.c @@ -1379,7 +1379,7 @@ static int buildingmaintenance(const building * b, const resource_type * rtype) } static int -report_template(const char *filename, report_context * ctx, const char *charset) +report_template(const char *filename, report_context * ctx, const char *bom) { const resource_type *rsilver = get_resourcetype(R_SILVER); faction *f = ctx->f; @@ -1389,7 +1389,6 @@ report_template(const char *filename, report_context * ctx, const char *charset) char buf[8192], *bufp; size_t size; int bytes; - bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0; const curse_type *nocost_ct = ct_find("nocostbuilding"); if (F == NULL) { @@ -1398,9 +1397,8 @@ report_template(const char *filename, report_context * ctx, const char *charset) } fstream_init(&strm, F); - if (utf8) { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; - swrite(utf8_bom, 1, 3, out); + if (bom) { + swrite(bom, 1, strlen(bom), out); } newline(out); @@ -2026,7 +2024,7 @@ void write_travelthru(struct stream *out, region *r, const faction *f) int report_plaintext(const char *filename, report_context * ctx, - const char *charset) + const char *bom) { int flag = 0; char ch; @@ -2044,7 +2042,6 @@ report_plaintext(const char *filename, report_context * ctx, stream strm = { 0 }, *out = &strm; char buf[8192]; char *bufp; - bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0; size_t size; int thisseason; int nextseason; @@ -2061,9 +2058,8 @@ report_plaintext(const char *filename, report_context * ctx, } fstream_init(&strm, F); - if (utf8) { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; - fwrite(utf8_bom, 1, 3, F); + if (bom) { + fwrite(bom, 1, strlen(bom), F); } strftime(pzTime, 64, "%A, %d. %B %Y, %H:%M", localtime(&ctx->report_time)); diff --git a/src/report.test.c b/src/report.test.c index cf074b284..202458db5 100644 --- a/src/report.test.c +++ b/src/report.test.c @@ -1,5 +1,4 @@ #include -#include #include "report.h" #include "move.h" #include "travelthru.h" diff --git a/src/reports.c b/src/reports.c index f0c82d024..a8b9e5cfb 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1401,12 +1401,10 @@ void finish_reports(report_context *ctx) { int write_reports(faction * f, time_t ltime) { - unsigned int backup = 1, maxbackup = 128 * 1000; bool gotit = false; struct report_context ctx; - const char *encoding = "UTF-8"; + const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; report_type *rtype; - if (noreports) { return false; } @@ -1423,19 +1421,12 @@ int write_reports(faction * f, time_t ltime) rtype->extension); join_path(reportpath(), filename, path, sizeof(path)); errno = 0; - if (rtype->write(path, &ctx, encoding) == 0) { + if (rtype->write(path, &ctx, (const char *)utf8_bom) == 0) { gotit = true; } if (errno) { - char zText[64]; - log_warning("retrying, error %d during %s report for faction %s", errno, rtype->extension, factionname(f)); - sprintf(zText, "waiting %u seconds before we retry", backup); - perror(zText); - _sleep(backup); - if (backup < maxbackup) { - backup *= 2; - } error = errno; + log_fatal("error %d during %s report for faction %s: %s", errno, rtype->extension, factionname(f), strerror(error)); errno = 0; } } while (error); diff --git a/src/reports.test.c b/src/reports.test.c index bc89bb4b4..c9fe39c19 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -1,5 +1,4 @@ #include -#include #include "reports.h" #include "move.h" diff --git a/src/spells/magicresistance.c b/src/spells/magicresistance.c index a897ea348..7b0c1413d 100644 --- a/src/spells/magicresistance.c +++ b/src/spells/magicresistance.c @@ -3,6 +3,8 @@ #include #include +#include + static struct message *cinfo_magicresistance(const void *obj, objtype_t typ, const struct curse * c, int self) { if (typ == TYP_UNIT) { diff --git a/src/util/nrmessage.h b/src/util/nrmessage.h index 5d775be9e..122b1f1a8 100644 --- a/src/util/nrmessage.h +++ b/src/util/nrmessage.h @@ -12,6 +12,9 @@ #ifndef H_UTIL_NRMESSAGE #define H_UTIL_NRMESSAGE + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/util/parser.h b/src/util/parser.h index 839968480..802fc56cb 100644 --- a/src/util/parser.h +++ b/src/util/parser.h @@ -10,6 +10,9 @@ #ifndef UTIL_PARSER_H #define UTIL_PARSER_H + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/util/strings.h b/src/util/strings.h index 7178cf179..05a435e2c 100644 --- a/src/util/strings.h +++ b/src/util/strings.h @@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef STRINGS_H #define STRINGS_H + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/util/translation.h b/src/util/translation.h index 01c19a72d..76206021b 100644 --- a/src/util/translation.h +++ b/src/util/translation.h @@ -12,6 +12,9 @@ #ifndef H_UTIL_TRANSLATION #define H_UTIL_TRANSLATION + +#include + #ifdef __cplusplus extern "C" { #endif From 0208304b0720f229c78782d4d36fb81e2c2cbacd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 25 Nov 2016 21:12:14 +0100 Subject: [PATCH 280/675] use autoconf when not MSCVER or GLIBC --- autoconf.h.in | 123 ------------------------------------------------- src/platform.h | 11 ++--- storage | 2 +- 3 files changed, 6 insertions(+), 130 deletions(-) diff --git a/autoconf.h.in b/autoconf.h.in index 1c151b6f9..f3f197db1 100644 --- a/autoconf.h.in +++ b/autoconf.h.in @@ -33,127 +33,4 @@ #cmakedefine HAVE_DIRECT_MKDIR 1 #cmakedefine HAVE_DIRECT__MKDIR 1 -#if defined(HAVE_STRINGS_H) -#include -#endif - -#if defined(HAVE_UNISTD_H) -#include -#endif - -#if defined(HAVE_IO_H) -#include -#endif - -#if defined(HAVE_WINDOWS_H) -#include -#endif - -#if defined(HAVE_STDBOOL_H) -# include -#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) -#endif -#endif - -#ifndef _A_RDONLY -#ifdef R_OK -#define _A_RDONLY R_OK -#endif -#endif - -#if !defined(HAVE__MEMICMP) -#if defined(HAVE_MEMICMP) -#define _memicmp(a, b, n) memicmp(a, b, n) -#elif defined(HAVE_STRNCASECMP) -#define _memicmp(a, b, n) strncasecmp(a, b, n) -#else -#define _memicmp(a, b, n) lcp_memicmp(a, b, n) -#endif -#endif - -#if !defined(HAVE__STRCMPL) -#if defined(HAVE_STRCMPL) -#define _strcmpl(a, b) strcmpl(a, b) -#elif defined(HAVE__STRICMP) -#define _strcmpl(a, b) _stricmp(a, b) -#elif defined(HAVE_STRICMP) -#define _strcmpl(a, b) stricmp(a, b) -#elif defined(HAVE_STRCASECMP) -#define _strcmpl(a, b) strcasecmp(a, b) -#else -#define _strcmpl(a, b) lcp_strcmpl(a, b) -#endif -#endif - -#if defined(HAVE_DIRECT__MKDIR) -#include -#elif defined(HAVE_DIRECT_MKDIR) -#include -#define _mkdir(a) mkdir(a) -#elif defined(HAVE_SYS_STAT_MKDIR) -#include -#define _mkdir(a) mkdir(a, 0777) -#endif - -#if !defined(HAVE__STRLWR) -#if defined(HAVE_STRLWR) -#define _strlwr(a) strlwr(a) -#else -#define _strlwr(a) lcp_strlwr(a) -#endif -#endif - -#if !defined(HAVE__STRDUP) -#if defined(HAVE_STRDUP) -#define _strdup(a) strdup(a) -#else -#define _strdup(a) lcp_strdup(a) -#endif -#endif - -#if !defined(HAVE__SLEEP) -#if defined(HAVE_USLEEP) -#define _sleep(a) usleep(a) -#elif defined(HAVE_SLEEP) -#define _sleep(a) sleep((a)/1000) -#else -#define _sleep(a) lcp_sleep(a) -#endif -#endif - -#if !defined(HAVE__SNPRINTF) -#if defined(HAVE_SNPRINTF) -#define _snprintf snprintf -#else -#define _snprintf lcp_snprintf -#endif -#endif - -#ifndef _min -#define _min(a,b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef _max -#define _max(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#if !defined(DBG_UNREFERENCED_PARAMETER) -#define DBG_UNREFERENCED_PARAMETER(x) x -#endif - #endif diff --git a/src/platform.h b/src/platform.h index 553f734c9..0a191d345 100644 --- a/src/platform.h +++ b/src/platform.h @@ -78,9 +78,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # define _CRTDBG_MAP_ALLOC #endif -#endif /* _MSC_VER_ */ - -#if defined __GNUC__ +#elif defined __GLIBC__ +#error gnuc # define _POSIX_C_SOURCE 200809L # undef _DEFAULT_SOURCE # define _DEFAULT_SOURCE @@ -90,12 +89,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # define HAVE_SYS_STAT_MKDIR # define HAVE_STRDUP # define HAVE_UNISTD_H -#endif - -#ifdef SOLARIS +#elif defined SOLARIS # define _SYS_PROCSET_H #undef _XOPEN_SOURCE # define _XOPEN_SOURCE +#else +#include #endif #define unused_arg (void) diff --git a/storage b/storage index 18cc3bb8f..2117191d4 160000 --- a/storage +++ b/storage @@ -1 +1 @@ -Subproject commit 18cc3bb8f8906237915eb31c9899f95340318087 +Subproject commit 2117191d4ad75e1eb14809878bc71d15b20a5d86 From 31ff07cbec79ee144bc83f8d125e54e83301ec62 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 25 Nov 2016 21:17:10 +0100 Subject: [PATCH 281/675] do not #error --- s/build | 2 +- src/platform.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/s/build b/s/build index 363e3e5a6..b59804626 100755 --- a/s/build +++ b/s/build @@ -39,5 +39,5 @@ echo "build eressea" cd $ROOT/$BUILD VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//') cmake -DERESSEA_VERSION="$VERSION" .. -make -k $MAKEOPTS && make test +make $MAKEOPTS && make test cd $OLDPWD diff --git a/src/platform.h b/src/platform.h index 0a191d345..ee19e0723 100644 --- a/src/platform.h +++ b/src/platform.h @@ -79,7 +79,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #elif defined __GLIBC__ -#error gnuc # define _POSIX_C_SOURCE 200809L # undef _DEFAULT_SOURCE # define _DEFAULT_SOURCE From 2f81dc16b2882388a04d2e0569c4e033614910fe Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 25 Nov 2016 21:57:35 +0100 Subject: [PATCH 282/675] fix autoconf usage, force my OSX build to use it --- src/platform.h | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/platform.h b/src/platform.h index ee19e0723..765b5c4a7 100644 --- a/src/platform.h +++ b/src/platform.h @@ -23,6 +23,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define LOMEM #endif +#undef USE_AUTOCONF +#define USE_AUTOCONF + #ifdef _MSC_VER # define VC_EXTRALEAN # define WIN32_LEAN_AND_MEAN @@ -78,7 +81,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # define _CRTDBG_MAP_ALLOC #endif -#elif defined __GLIBC__ +#undef USE_AUTOCONF +#elif __GNUC__ +#include +#if __GLIBC__ >= 2 # define _POSIX_C_SOURCE 200809L # undef _DEFAULT_SOURCE # define _DEFAULT_SOURCE @@ -88,11 +94,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # define HAVE_SYS_STAT_MKDIR # define HAVE_STRDUP # define HAVE_UNISTD_H -#elif defined SOLARIS -# define _SYS_PROCSET_H -#undef _XOPEN_SOURCE -# define _XOPEN_SOURCE -#else +# undef USE_AUTOCONF +#endif +#endif + +#ifdef USE_AUTOCONF #include #endif @@ -164,9 +170,8 @@ typedef unsigned char _Bool; #if !defined(HAVE__STRDUP) #if defined(HAVE_STRDUP) +#undef _strdup #define _strdup(a) strdup(a) -#else -#define _strdup(a) lcp_strdup(a) #endif #endif @@ -176,19 +181,5 @@ typedef unsigned char _Bool; #endif #endif -#if !defined(HAVE__STRCMPL) -#if defined(HAVE_STRCMPL) -#define _strcmpl(a, b) strcmpl(a, b) -#elif defined(HAVE__STRICMP) -#define _strcmpl(a, b) _stricmp(a, b) -#elif defined(HAVE_STRICMP) -#define _strcmpl(a, b) stricmp(a, b) -#elif defined(HAVE_STRCASECMP) -#define _strcmpl(a, b) strcasecmp(a, b) -#else -#define _strcmpl(a, b) lcp_strcmpl(a, b) -#endif -#endif - #endif From 14b5c0f922cce8b90480ae80b27a0194f3abb88e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 25 Nov 2016 22:19:59 +0100 Subject: [PATCH 283/675] mac builds using gcc do not need autoconf. need to find a differnt way to test autoconf. --- src/platform.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/platform.h b/src/platform.h index 765b5c4a7..9f4fca3db 100644 --- a/src/platform.h +++ b/src/platform.h @@ -83,8 +83,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #undef USE_AUTOCONF #elif __GNUC__ -#include -#if __GLIBC__ >= 2 # define _POSIX_C_SOURCE 200809L # undef _DEFAULT_SOURCE # define _DEFAULT_SOURCE @@ -96,7 +94,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # define HAVE_UNISTD_H # undef USE_AUTOCONF #endif -#endif #ifdef USE_AUTOCONF #include From 7870b636558b54edd1481cee2cf1e765e5edd278 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 26 Nov 2016 07:04:18 +0100 Subject: [PATCH 284/675] fix VS 2015 build --- src/kernel/config.c | 7 ------- src/platform.h | 5 ++++- storage | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index 80e949215..f33303ead 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -599,13 +599,6 @@ void kernel_done(void) translation_done(); } -#ifndef HAVE_STRDUP -char *_strdup(const char *s) -{ - return strcpy((char *)malloc(sizeof(char) * (strlen(s) + 1)), s); -} -#endif - bool rule_stealth_other(void) { static int rule, config; diff --git a/src/platform.h b/src/platform.h index 9f4fca3db..722ab0b5c 100644 --- a/src/platform.h +++ b/src/platform.h @@ -27,6 +27,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define USE_AUTOCONF #ifdef _MSC_VER +# define HAVE_STDBOOL_H +# define HAVE_DIRECT__MKDIR +# define HAVE__ACCESS # define VC_EXTRALEAN # define WIN32_LEAN_AND_MEAN #pragma warning(push) @@ -129,7 +132,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #if defined(HAVE_STDBOOL_H) # include #else -# if ! HAVE__BOOL +# ifndef HAVE__BOOL # ifdef __cplusplus typedef bool _Bool; # else diff --git a/storage b/storage index 2117191d4..18cc3bb8f 160000 --- a/storage +++ b/storage @@ -1 +1 @@ -Subproject commit 2117191d4ad75e1eb14809878bc71d15b20a5d86 +Subproject commit 18cc3bb8f8906237915eb31c9899f95340318087 From 68ce6907f3d776c70b587dca9c62accfc69dea18 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 26 Nov 2016 07:24:19 +0100 Subject: [PATCH 285/675] new storage module (without textstore and snprintf) --- storage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage b/storage index 18cc3bb8f..2117191d4 160000 --- a/storage +++ b/storage @@ -1 +1 @@ -Subproject commit 18cc3bb8f8906237915eb31c9899f95340318087 +Subproject commit 2117191d4ad75e1eb14809878bc71d15b20a5d86 From 43b8ff1ea8bf7e550cc25684ac0275aed8164e3a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 26 Nov 2016 16:21:41 +0100 Subject: [PATCH 286/675] fix strdup compilications when compiling with gcc and autoconf. --- CMakeLists.txt | 4 ++- src/CMakeLists.txt | 2 +- src/platform.h | 71 +++++++++++++++++++++---------------------- src/util/filereader.c | 2 +- src/vortex.c | 5 +-- 5 files changed, 43 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ad7b3528..d60d3d721 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,9 @@ CONFIGURE_FILE ( ${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in ${CMAKE_BINARY_DIR}/include/autoconf.h) INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include) -add_definitions(-DUSE_AUTOCONF) + +## skip compiler/libc detection and force cmake autoconf: +#add_definitions(-DUSE_AUTOCONF) add_subdirectory (cutest) add_subdirectory (cJSON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d7fba859..8a4445b55 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -84,6 +84,7 @@ TOLUA_BINDING(settings.pkg kenel/config.h) ENDIF() set (ERESSEA_SRC + vortex.c calendar.c move.c piracy.c @@ -92,7 +93,6 @@ set (ERESSEA_SRC alchemy.c academy.c upkeep.c - vortex.c names.c lighthouse.c reports.c diff --git a/src/platform.h b/src/platform.h index 722ab0b5c..d7a7e87e5 100644 --- a/src/platform.h +++ b/src/platform.h @@ -16,22 +16,39 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ -#ifndef CONFIG_H -#define CONFIG_H +#ifndef PLATFORM_H +#define PLATFORM_H #ifdef NDEBUG #define LOMEM #endif -#undef USE_AUTOCONF +// enable X/Open 7 extensions (like strdup): +#ifndef _XOPEN_SOURCE +#define _XOPEN_SOURCE 700 +#endif + +// enable bsd string extensions, prior to glibc 2.12: +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#endif + +// enable bsd string extensions, since glibc 2.12: +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#endif + +#ifndef USE_AUTOCONF #define USE_AUTOCONF #ifdef _MSC_VER -# define HAVE_STDBOOL_H -# define HAVE_DIRECT__MKDIR -# define HAVE__ACCESS -# define VC_EXTRALEAN -# define WIN32_LEAN_AND_MEAN +#undef USE_AUTOCONF +#define HAVE_STDBOOL_H +#define HAVE_DIRECT__MKDIR +#define HAVE__ACCESS + +#define VC_EXTRALEAN +#define WIN32_LEAN_AND_MEAN #pragma warning(push) #pragma warning(disable:4820 4255 4668) # include @@ -66,7 +83,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* warning C4100: was declared deprecated */ #ifndef _CRT_SECURE_NO_DEPRECATE -# define _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_DEPRECATE #endif /* @@ -75,39 +92,25 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * single-threaded I/O model and use the _nolock forms of the functions. */ #ifndef _CRT_DISABLE_PERFCRIT_LOCKS -# define _CRT_DISABLE_PERFCRIT_LOCKS +#define _CRT_DISABLE_PERFCRIT_LOCKS #endif -/* define CRTDBG to enable MSVC CRT Debug library functions */ -#if defined(_DEBUG) && defined(CRTDBG) -# include -# define _CRTDBG_MAP_ALLOC -#endif - -#undef USE_AUTOCONF #elif __GNUC__ -# define _POSIX_C_SOURCE 200809L -# undef _DEFAULT_SOURCE -# define _DEFAULT_SOURCE -# undef __USE_BSD -# define __USE_BSD -# define HAVE_SNPRINTF -# define HAVE_SYS_STAT_MKDIR -# define HAVE_STRDUP -# define HAVE_UNISTD_H -# undef USE_AUTOCONF +#undef USE_AUTOCONF +#define HAVE_SNPRINTF +#define HAVE_SYS_STAT_MKDIR +#define HAVE_STRDUP +#define HAVE_UNISTD_H +#endif #endif #ifdef USE_AUTOCONF +// unknown toolchain, using autoconf #include #endif #define unused_arg (void) -#ifndef INLINE_FUNCTION -# define INLINE_FUNCTION -#endif - #define iswxspace(c) (c==160 || iswspace(c)) #define isxspace(c) (c==160 || isspace(c)) @@ -125,10 +128,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #endif -#ifdef HAVE_STRINGS_H -#include -#endif - #if defined(HAVE_STDBOOL_H) # include #else @@ -171,7 +170,7 @@ typedef unsigned char _Bool; #if !defined(HAVE__STRDUP) #if defined(HAVE_STRDUP) #undef _strdup -#define _strdup(a) strdup(a) +#define _strdup strdup #endif #endif diff --git a/src/util/filereader.c b/src/util/filereader.c index ee5ec398c..3223ca2ab 100644 --- a/src/util/filereader.c +++ b/src/util/filereader.c @@ -18,7 +18,7 @@ static void unicode_warning(const char *bp) log_warning("invalid sequence in UTF-8 string: %s\n", bp); } -INLINE_FUNCTION int eatwhite(const char *ptr, size_t * total_size) +static int eatwhite(const char *ptr, size_t * total_size) { int ret = 0; diff --git a/src/vortex.c b/src/vortex.c index 244c83a29..725460ce2 100644 --- a/src/vortex.c +++ b/src/vortex.c @@ -14,8 +14,9 @@ #include #include -#include #include +#include + typedef struct dir_lookup { char *name; @@ -32,7 +33,7 @@ void register_special_direction(struct locale *lang, const char *name) if (token) { void **tokens = get_translations(lang, UT_SPECDIR); variant var; - char *str = _strdup(name); + char *str = strdup(name); var.v = str; addtoken((struct tnode **)tokens, token, var); From 6079293feaa95bbf532dd75004c936566fc498f7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 26 Nov 2016 16:54:19 +0100 Subject: [PATCH 287/675] the _BSD_SOURCE macro was deprecated with glibc 2.12 --- src/platform.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/platform.h b/src/platform.h index d7a7e87e5..c781021ae 100644 --- a/src/platform.h +++ b/src/platform.h @@ -28,12 +28,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define _XOPEN_SOURCE 700 #endif -// enable bsd string extensions, prior to glibc 2.12: -#ifndef _BSD_SOURCE -#define _BSD_SOURCE -#endif - -// enable bsd string extensions, since glibc 2.12: +// enable bsd string extensions, since glibc 2.12 (_BSD_SOURCE is dead): #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200809L #endif From 06ba427a779558e7f79c64060c822f3c545ecaa4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 26 Nov 2016 17:17:14 +0100 Subject: [PATCH 288/675] fix VS2015 build: config.h not found --- src/creport.test.c | 1 - src/game.pkg | 1 - src/game.pkg.c | 1 - src/kernel/order.test.c | 1 - src/report.test.c | 1 - src/reports.test.c | 1 - 6 files changed, 6 deletions(-) diff --git a/src/creport.test.c b/src/creport.test.c index 3a84ea566..72669e99f 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -1,5 +1,4 @@ #include -#include #include "creport.h" #include "move.h" #include "travelthru.h" diff --git a/src/game.pkg b/src/game.pkg index 88b3bda9a..dc2b324e4 100644 --- a/src/game.pkg +++ b/src/game.pkg @@ -1,6 +1,5 @@ $#undef tolua_reg_types $#define tolua_reg_types tolua_reg_types_game -$#include "config.h" $#include "bind_eressea.h" module eressea { diff --git a/src/game.pkg.c b/src/game.pkg.c index abd7832ca..30671021d 100644 --- a/src/game.pkg.c +++ b/src/game.pkg.c @@ -20,7 +20,6 @@ LUALIB_API int luaopen_game (lua_State* tolua_S); #undef tolua_reg_types #define tolua_reg_types tolua_reg_types_game -#include "config.h" #include "bind_eressea.h" /* function to register type */ diff --git a/src/kernel/order.test.c b/src/kernel/order.test.c index 635e6e078..f5eb51c6f 100644 --- a/src/kernel/order.test.c +++ b/src/kernel/order.test.c @@ -1,5 +1,4 @@ #include -#include #include #include "order.h" diff --git a/src/report.test.c b/src/report.test.c index cf074b284..202458db5 100644 --- a/src/report.test.c +++ b/src/report.test.c @@ -1,5 +1,4 @@ #include -#include #include "report.h" #include "move.h" #include "travelthru.h" diff --git a/src/reports.test.c b/src/reports.test.c index bc89bb4b4..c9fe39c19 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -1,5 +1,4 @@ #include -#include #include "reports.h" #include "move.h" From bf70792da61e21fd85f5b74cd5f314b1358923ec Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 27 Nov 2016 16:07:46 +0100 Subject: [PATCH 289/675] make kn-bremen.de official email address --- conf/e2/config.xml | 8 ++++---- conf/e3/config.xml | 8 ++++---- conf/e4/config.xml | 8 ++++---- process/orders-accept | 6 +++--- process/orders-process | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index f7f227824..0441a46f6 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -54,14 +54,14 @@ - eressea-server@eressea.de - eressea-server@eressea.de + eressea-server@eressea.kn-bremen.de + eressea-server@eressea.kn-bremen.de Bitte denke daran, deine Befehle mit dem Betreff - ERESSEA 2 BEFEHLE an eressea-server@eressea.de zu senden. + ERESSEA 2 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. Remember to send your orders to - eressea-server@eressea.de with the subject ERESSEA 2 ORDERS. + eressea-server@eressea.kn-bremen.de with the subject ERESSEA 2 ORDERS. ERESSEA 2 BEFEHLE diff --git a/conf/e3/config.xml b/conf/e3/config.xml index d337ead42..c8c5dbb06 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -46,14 +46,14 @@ - eressea-server@eressea.de - eressea-server@eressea.de + eressea-server@eressea.kn-bremen.de + eressea-server@eressea.kn-bremen.de Bitte denke daran, deine Befehle mit dem Betreff - ERESSEA 3 BEFEHLE an eressea-server@eressea.de zu senden. + ERESSEA 3 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. Remember to send your orders to - eressea-server@eressea.de with the subject E3 ORDERS. + eressea-server@eressea.kn-bremen.de with the subject E3 ORDERS. ERESSEA 3 BEFEHLE diff --git a/conf/e4/config.xml b/conf/e4/config.xml index 5c99f7d7e..b188f7d79 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -47,14 +47,14 @@ - eressea-server@eressea.de - eressea-server@eressea.de + eressea-server@eressea.kn-bremen.de + eressea-server@eressea.kn-bremen.de Bitte denke daran, deine Befehle mit dem Betreff - ERESSEA 4 BEFEHLE an eressea-server@eressea.de zu senden. + ERESSEA 4 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. Remember to send your orders to - eressea-server@eressea.de with the subject ERESSEA 4 ORDERS. + eressea-server@eressea.kn-bremen.de with the subject ERESSEA 4 ORDERS. ERESSEA 4 BEFEHLE diff --git a/process/orders-accept b/process/orders-accept index e90c3d48f..151f0b196 100755 --- a/process/orders-accept +++ b/process/orders-accept @@ -30,15 +30,15 @@ rejecthtml = True games = [ { - "from" : "Eressea Server ", + "from" : "Eressea Server ", "prefix" : "Eressea" }, { - "from" : "Eressea Server ", + "from" : "Eressea Server ", "prefix": "E3" }, { - "from" : "Eressea Server ", + "from" : "Eressea Server ", "prefix": "E4" }, ] diff --git a/process/orders-process b/process/orders-process index a4d932648..753385e2e 100755 --- a/process/orders-process +++ b/process/orders-process @@ -65,7 +65,7 @@ messages = { # base directory for all your games: rootdir = "/home/eressea/eressea" -frommail = "Eressea Server " +frommail = "Eressea Server " orderbase = "orders.dir" sendmail = True maxlines = 25 From 2de3c3179a1be88f83e0415187f23976791ab866 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 28 Nov 2016 08:39:07 +0100 Subject: [PATCH 290/675] develop branch is now base for 3.11 --- src/kernel/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/version.c b/src/kernel/version.c index 6de6ddb40..8add29ccc 100644 --- a/src/kernel/version.c +++ b/src/kernel/version.c @@ -5,7 +5,7 @@ #ifndef ERESSEA_VERSION // the version number, if it was not passed to make with -D -#define ERESSEA_VERSION "3.10.0-devel" +#define ERESSEA_VERSION "3.11.0-devel" #endif const char *eressea_version(void) { From afac66e213f3b292b39cbd382ace38f31473f9c8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 3 Dec 2016 23:38:53 +0100 Subject: [PATCH 291/675] fix bug 2261: bit manipulation error in STEALTH FACTION. https://bugs.eressea.de/view.php?id=2261 --- src/spy.c | 6 +++--- src/spy.test.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/spy.c b/src/spy.c index 5fdd806cc..22c548d68 100644 --- a/src/spy.c +++ b/src/spy.c @@ -295,11 +295,11 @@ int setstealth_cmd(unit * u, struct order *ord) s = gettoken(token, sizeof(token)); if (rule_stealth_anon()) { if (!s || *s == 0) { - fset(u, UFL_ANON_FACTION); + u->flags |= UFL_ANON_FACTION; break; } else if (findparam(s, u->faction->locale) == P_NOT) { - u->flags |= ~UFL_ANON_FACTION; + u->flags &= ~UFL_ANON_FACTION; break; } } @@ -416,7 +416,7 @@ static void sink_ship(region * r, ship * sh, unit * saboteur) /* slight optimization to avoid dereferencing u->faction each time */ if (f != u->faction) { f = u->faction; - f->flags |= ~FFL_SELECT; + f->flags &= ~FFL_SELECT; } } diff --git a/src/spy.test.c b/src/spy.test.c index 299e4b3a6..34f6e5067 100644 --- a/src/spy.test.c +++ b/src/spy.test.c @@ -146,6 +146,26 @@ static void test_sabotage_other_fail(CuTest *tc) { test_cleanup(); } +static void test_setstealth_cmd(CuTest *tc) { + unit *u; + const struct locale *lang; + + test_setup(); + u = test_create_unit(test_create_faction(0), test_create_region(0,0,0)); + lang = u->faction->locale; + u->flags = UFL_ANON_FACTION|UFL_SIEGE; + u->thisorder = create_order(K_SETSTEALTH, lang, "%s %s", + LOC(lang, parameters[P_FACTION]), + LOC(lang, parameters[P_NOT])); + setstealth_cmd(u, u->thisorder); + CuAssertIntEquals(tc, UFL_SIEGE, u->flags); + free_order(u->thisorder); + u->thisorder = create_order(K_SETSTEALTH, lang, "%s", + LOC(lang, parameters[P_FACTION])); + setstealth_cmd(u, u->thisorder); + CuAssertIntEquals(tc, UFL_SIEGE|UFL_ANON_FACTION, u->flags); + test_cleanup(); +} static void test_sabotage_other_success(CuTest *tc) { unit *u, *u2; @@ -178,6 +198,7 @@ CuSuite *get_spy_suite(void) SUITE_ADD_TEST(suite, test_simple_spy_message); SUITE_ADD_TEST(suite, test_all_spy_message); SUITE_ADD_TEST(suite, test_sabotage_self); + SUITE_ADD_TEST(suite, test_setstealth_cmd); SUITE_ADD_TEST(suite, test_sabotage_other_fail); SUITE_ADD_TEST(suite, test_sabotage_other_success); return suite; From 01233c4f82912ee65b86d7c57b4b1b5e0326faf8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 5 Dec 2016 07:54:43 +0100 Subject: [PATCH 292/675] =?UTF-8?q?UTF-8=20statt=20utf-8.=20Auf=20besonder?= =?UTF-8?q?en=20Wunsch=20werden=20einheitlich=20Gro=C3=9Fbuchstaben=20verw?= =?UTF-8?q?endet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/creport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/creport.c b/src/creport.c index c05377e2e..eeb2a1202 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1497,7 +1497,7 @@ report_computer(const char *filename, report_context * ctx, const char *bom) /* initialisations, header and lists */ fprintf(F, "VERSION %d\n", C_REPORT_VERSION); - fprintf(F, "\"utf-8\";charset\n\"%s\";locale\n", + fprintf(F, "\"UTF-8\";charset\n\"%s\";locale\n", locale_name(f->locale)); fprintf(F, "%d;noskillpoints\n", 1); fprintf(F, "%lld;date\n", (long long)ctx->report_time); From 31b3f2b2de970d5f45302a41381fa34b9797932e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 10 Dec 2016 16:22:57 +0100 Subject: [PATCH 293/675] remove Umlaut from Lua script --- scripts/eressea/ents.lua | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/scripts/eressea/ents.lua b/scripts/eressea/ents.lua index c764d8e0a..7808917fa 100644 --- a/scripts/eressea/ents.lua +++ b/scripts/eressea/ents.lua @@ -2,7 +2,7 @@ local function create_ents(r, number) local f = get_faction(666) if f~=nil and number>0 then u = unit.create(f, r, number, "ent") - u.name = "Wütende Ents" + u.name = "Rasende Ents" u:set_skill("perception", 2) msg = message.create("entrise") @@ -13,21 +13,11 @@ local function create_ents(r, number) return nil end -local function repair_ents(r) - for u in r.units do - if u.faction.id==666 and u.race == "undead" and u.name == "Wütende Ents" then - eressea.log.info("ent repair: " .. tostring(u)) - u.race = "ent" - end - end -end - local ents = {} function ents.update() local r for r in regions() do - repair_ents(r) if r:get_flag(0) then -- RF_CHAOTIC if r.terrain == "plain" and r:get_resource("tree")==0 then if math.random(3)==1 then From 0197fce9a10b64c6f1af12e3873476ea522ae65f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 11 Dec 2016 21:21:50 +0100 Subject: [PATCH 294/675] add a test for teach-messages. vheck that they are generated for students and teachers. --- src/study.test.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/study.test.c b/src/study.test.c index 47976930d..54e32bf28 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -2,6 +2,7 @@ #include "study.h" +#include #include #include #include @@ -10,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -483,6 +485,7 @@ static void test_teach_one_to_many(CuTest *tc) { static void test_teach_many_to_one(CuTest *tc) { unit *u, *u1, *u2; + test_setup(); init_resources(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); @@ -505,6 +508,47 @@ static void test_teach_many_to_one(CuTest *tc) { test_cleanup(); } +static void test_teach_message(CuTest *tc) { + unit *u, *u1, *u2; + attrib *a; + ally *al; + teaching_info *teach; + + test_setup(); + init_resources(); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + scale_number(u, 20); + u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW"); + u1 = test_create_unit(test_create_faction(0), u->region); + set_level(u1, SK_CROSSBOW, TEACHDIFFERENCE); + u1->thisorder = create_order(K_TEACH, u->faction->locale, itoa36(u->no)); + u2 = test_create_unit(test_create_faction(0), u->region); + al = ally_add(&u->faction->allies, u2->faction); + al->status = HELP_GUARD; + set_level(u2, SK_CROSSBOW, TEACHDIFFERENCE); + u2->thisorder = create_order(K_TEACH, u->faction->locale, itoa36(u->no)); + CuAssertTrue(tc, !alliedunit(u, u1->faction, HELP_GUARD)); + CuAssertTrue(tc, alliedunit(u, u2->faction, HELP_GUARD)); + teach_cmd(u1, u1->thisorder); + teach_cmd(u2, u2->thisorder); + a = a_find(u->attribs, &at_learning); + CuAssertPtrNotNull(tc, a); + CuAssertPtrNotNull(tc, a->data.v); + teach = (teaching_info *)a->data.v; + CuAssertPtrNotNull(tc, teach->teachers); + CuAssertIntEquals(tc, 600, teach->value); + CuAssertPtrEquals(tc, u1, teach->teachers[0]); + CuAssertPtrEquals(tc, u2, teach->teachers[1]); + CuAssertPtrEquals(tc, NULL, teach->teachers[2]); + study_cmd(u, u->thisorder); + CuAssertPtrEquals(tc, NULL, test_find_messagetype(u1->faction->msgs, "teach_teacher")); + CuAssertPtrNotNull(tc, test_find_messagetype(u2->faction->msgs, "teach_teacher")); + CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "teach_student")); + a = a_find(u->attribs, &at_learning); + CuAssertPtrEquals(tc, NULL, a); + test_cleanup(); +} + static void test_teach_many_to_many(CuTest *tc) { unit *s1, *s2, *t1, *t2; region *r; @@ -554,6 +598,7 @@ CuSuite *get_study_suite(void) SUITE_ADD_TEST(suite, test_teach_one_to_many); SUITE_ADD_TEST(suite, test_teach_many_to_one); SUITE_ADD_TEST(suite, test_teach_many_to_many); + SUITE_ADD_TEST(suite, test_teach_message); SUITE_ADD_TEST(suite, test_teach_two_skills); SUITE_ADD_TEST(suite, test_learn_skill_single); SUITE_ADD_TEST(suite, test_learn_skill_multi); From ccb179972605496c54ab02a4b96a99571d45c16c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 11 Dec 2016 21:29:07 +0100 Subject: [PATCH 295/675] unlimited teachers. quicklist replaces fixed array. --- src/study.c | 25 +++++++------------------ src/study.h | 4 ++-- src/study.test.c | 10 ++++++---- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/study.c b/src/study.c index 1dd4da8b8..f3372334a 100644 --- a/src/study.c +++ b/src/study.c @@ -53,6 +53,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include + /* libc includes */ #include #include @@ -216,24 +218,11 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk, n = _min(n, nteaching); if (n != 0) { - int index = 0; - if (teach == NULL) { a = a_add(&student->attribs, a_new(&at_learning)); teach = (teaching_info *)a->data.v; } - else { - while (teach->teachers[index] && index != MAXTEACHERS) - ++index; - } - if (index < MAXTEACHERS) - teach->teachers[index++] = teacher; - if (index < MAXTEACHERS) { - teach->teachers[index] = NULL; - } - else { - log_error("MAXTEACHERS=%d is too low for student %s, teacher %s", MAXTEACHERS, unitname(student), unitname(teacher)); - } + ql_push(&teach->teachers, teacher); teach->value += n; if (student->building && teacher->building == student->building) { @@ -717,7 +706,7 @@ int study_cmd(unit * u, order * ord) a = a_add(&u->attribs, a_new(&at_learning)); teach = (teaching_info *)a->data.v; assert(teach); - teach->teachers[0] = 0; + teach->teachers = NULL; } if (money > 0) { use_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT, money); @@ -766,9 +755,9 @@ int study_cmd(unit * u, order * ord) learn_skill(u, sk, days); if (a != NULL) { - int index = 0; - while (teach->teachers[index] && index != MAXTEACHERS) { - unit *teacher = teach->teachers[index++]; + ql_iter qli = qli_init(&teach->teachers); + while (qli_more(qli)) { + unit *teacher = (unit *)qli_next(&qli); if (teacher->faction != u->faction) { bool feedback = alliedunit(u, teacher->faction, HELP_GUARD); if (feedback) { diff --git a/src/study.h b/src/study.h index 20903583a..8067bc9bd 100644 --- a/src/study.h +++ b/src/study.h @@ -27,6 +27,7 @@ extern "C" { #endif struct unit; + struct quicklist; int teach_cmd(struct unit *u, struct order *ord); int study_cmd(struct unit *u, struct order *ord); @@ -45,10 +46,9 @@ extern "C" { void demon_skillchange(struct unit *u); -#define MAXTEACHERS 32 #define TEACHNUMBER 10 typedef struct teaching_info { - struct unit *teachers[MAXTEACHERS]; + struct quicklist *teachers; int value; } teaching_info; diff --git a/src/study.test.c b/src/study.test.c index 54e32bf28..4c1e5f171 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -18,9 +18,11 @@ #include #include +#include +#include + #include -#include #define MAXLOG 4 typedef struct log_entry { @@ -537,9 +539,9 @@ static void test_teach_message(CuTest *tc) { teach = (teaching_info *)a->data.v; CuAssertPtrNotNull(tc, teach->teachers); CuAssertIntEquals(tc, 600, teach->value); - CuAssertPtrEquals(tc, u1, teach->teachers[0]); - CuAssertPtrEquals(tc, u2, teach->teachers[1]); - CuAssertPtrEquals(tc, NULL, teach->teachers[2]); + CuAssertIntEquals(tc, 2, ql_length(teach->teachers)); + CuAssertPtrEquals(tc, u1, ql_get(teach->teachers, 0)); + CuAssertPtrEquals(tc, u2, ql_get(teach->teachers, 1)); study_cmd(u, u->thisorder); CuAssertPtrEquals(tc, NULL, test_find_messagetype(u1->faction->msgs, "teach_teacher")); CuAssertPtrNotNull(tc, test_find_messagetype(u2->faction->msgs, "teach_teacher")); From a72b29610cc157535679043603a07a4936175b8f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 11 Dec 2016 22:40:06 +0100 Subject: [PATCH 296/675] small edit (int->bool) --- src/guard.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/guard.c b/src/guard.c index ee26e467b..4b0c63e22 100644 --- a/src/guard.c +++ b/src/guard.c @@ -128,7 +128,7 @@ bool is_guard(const struct unit * u) unit *is_guarded(region * r, unit * u) { unit *u2; - int noguards = 1; + bool noguards = true; if (!fval(r, RF_GUARDED)) { return NULL; @@ -140,7 +140,7 @@ unit *is_guarded(region * r, unit * u) for (u2 = r->units; u2; u2 = u2->next) { if (is_guardian_r(u2)) { - noguards = 0; + noguards = false; if (is_guardian_u(u2, u)) { /* u2 is our guard. stop processing (we might have to go further next time) */ return u2; From 95954fb386f0e25595882bc77306f703541e0895 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Dec 2016 07:29:43 +0100 Subject: [PATCH 297/675] start writing a test (WIP). --- src/move.c | 2 +- src/move.h | 2 ++ src/move.test.c | 26 +++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/move.c b/src/move.c index b6a908837..e6469cc4a 100644 --- a/src/move.c +++ b/src/move.c @@ -571,7 +571,7 @@ direction_t reldirection(const region * from, const region * to) return NODIRECTION; } -static void leave_trail(ship * sh, region * from, region_list * route) +void leave_trail(ship * sh, region * from, region_list * route) { region *r = from; diff --git a/src/move.h b/src/move.h index 6363fe2f9..14c040493 100644 --- a/src/move.h +++ b/src/move.h @@ -63,6 +63,8 @@ extern "C" { int enoughsailors(const struct ship *sh, int sumskill); bool canswim(struct unit *u); bool canfly(struct unit *u); + void leave_trail(struct ship *sh, struct region *from, + struct region_list *route); struct ship *move_ship(struct ship *sh, struct region *from, struct region *to, struct region_list *route); int walkingcapacity(const struct unit *u); diff --git a/src/move.test.c b/src/move.test.c index bc93ec124..bdd4a62a8 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -478,7 +478,7 @@ static void test_drifting_ships(CuTest *tc) { region *r1, *r2, *r3; terrain_type *t_ocean, *t_plain; ship_type *st_boat; - test_cleanup(); + test_setup(); t_ocean = test_create_terrain("ocean", SEA_REGION); t_plain = test_create_terrain("plain", LAND_REGION); r1 = test_create_region(0, 0, t_ocean); @@ -491,11 +491,35 @@ static void test_drifting_ships(CuTest *tc) { test_cleanup(); } +static void test_ship_leave_trail(CuTest *tc) { + ship *s1, *s2; + region *r1, *r2; + terrain_type *t_ocean; + ship_type *st_boat; + region_list *route = NULL; + + test_setup(); + t_ocean = test_create_terrain("ocean", SEA_REGION); + r1 = test_create_region(0, 0, t_ocean); + add_regionlist(&route, r2 = test_create_region(1, 0, t_ocean)); + add_regionlist(&route, test_create_region(2, 0, t_ocean)); + st_boat = test_create_shiptype("boat"); + s1 = test_create_ship(r1, st_boat); + s2 = test_create_ship(r1, st_boat); + leave_trail(s1, r1, route); + leave_trail(s2, r1, route); +// CuAssertPtrNotNull(tc, r1->attribs); + CuAssertPtrNotNull(tc, r2->attribs); + free_regionlist(route); + test_cleanup(); +} + CuSuite *get_move_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_walkingcapacity); SUITE_ADD_TEST(suite, test_ship_not_allowed_in_coast); + SUITE_ADD_TEST(suite, test_ship_leave_trail); SUITE_ADD_TEST(suite, test_ship_allowed_without_harbormaster); SUITE_ADD_TEST(suite, test_ship_blocked_by_harbormaster); SUITE_ADD_TEST(suite, test_ship_has_harbormaster_contact); From ddc7707cdece29b4b509d9e8173379ef0c3d2a3b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Dec 2016 17:16:10 +0100 Subject: [PATCH 298/675] add a failing test for bug 2266 --- src/lighthouse.c | 2 +- src/lighthouse.h | 2 +- src/move.test.c | 13 ++++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/lighthouse.c b/src/lighthouse.c index d962b9b76..09c9b7d11 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -14,7 +14,7 @@ #include #include -const attrib_type at_lighthouse = { +attrib_type at_lighthouse = { "lighthouse" /* Rest ist NULL; tempor�res, nicht alterndes Attribut */ }; diff --git a/src/lighthouse.h b/src/lighthouse.h index 518b05b5a..3bf970bf1 100644 --- a/src/lighthouse.h +++ b/src/lighthouse.h @@ -29,7 +29,7 @@ extern "C" { struct building; struct attrib; - extern const struct attrib_type at_lighthouse; + extern struct attrib_type at_lighthouse; /* leuchtturm */ bool check_leuchtturm(struct region *r, struct faction *f); void update_lighthouse(struct building *lh); diff --git a/src/move.test.c b/src/move.test.c index bdd4a62a8..6a2a0e7db 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -3,6 +3,7 @@ #include "move.h" #include "keyword.h" +#include "lighthouse.h" #include #include @@ -501,15 +502,21 @@ static void test_ship_leave_trail(CuTest *tc) { test_setup(); t_ocean = test_create_terrain("ocean", SEA_REGION); r1 = test_create_region(0, 0, t_ocean); - add_regionlist(&route, r2 = test_create_region(1, 0, t_ocean)); add_regionlist(&route, test_create_region(2, 0, t_ocean)); + add_regionlist(&route, r2 = test_create_region(1, 0, t_ocean)); st_boat = test_create_shiptype("boat"); s1 = test_create_ship(r1, st_boat); s2 = test_create_ship(r1, st_boat); leave_trail(s1, r1, route); + a_add(&r1->attribs, a_new(&at_lighthouse)); leave_trail(s2, r1, route); -// CuAssertPtrNotNull(tc, r1->attribs); - CuAssertPtrNotNull(tc, r2->attribs); + a_add(&r2->attribs, a_new(&at_lighthouse)); + CuAssertPtrEquals(tc, &at_shiptrail, (void *)r1->attribs->type); + CuAssertPtrEquals(tc, &at_shiptrail, (void *)r1->attribs->next->type); + CuAssertPtrEquals(tc, &at_lighthouse, (void *)r1->attribs->next->next->type); + CuAssertPtrEquals(tc, &at_shiptrail, (void *)r2->attribs->type); + CuAssertPtrEquals(tc, &at_shiptrail, (void *)r2->attribs->next->type); + CuAssertPtrEquals(tc, &at_lighthouse, (void *)r2->attribs->next->next->type); free_regionlist(route); test_cleanup(); } From 72ac8017346afd74676c2cff2aa15586dd32fe1c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Dec 2016 17:17:04 +0100 Subject: [PATCH 299/675] fix bug 2266 --- src/move.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/move.c b/src/move.c index e6469cc4a..f1b2311f1 100644 --- a/src/move.c +++ b/src/move.c @@ -595,7 +595,7 @@ void leave_trail(ship * sh, region * from, region_list * route) a = a->next; } - if (a == NULL) { + if (a == NULL || a->type != &at_shiptrail) { a = a_add(&(r->attribs), a_new(&at_shiptrail)); td = (traveldir *)a->data.v; td->no = sh->no; From 752b6526bd8a7bb77668ef285a4ff00791007358 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Dec 2016 20:55:36 +0100 Subject: [PATCH 300/675] replace submodules --- .gitmodules | 9 +++------ clibs | 1 + critbit | 1 - quicklist | 1 - 4 files changed, 4 insertions(+), 8 deletions(-) create mode 160000 clibs delete mode 160000 critbit delete mode 160000 quicklist diff --git a/.gitmodules b/.gitmodules index 2242a8068..e9ea1e3ed 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,12 +4,6 @@ [submodule "cmake"] path = cmake url = https://github.com/ennorehling/cmake.git -[submodule "quicklist"] - path = quicklist - url = https://github.com/ennorehling/quicklist.git -[submodule "critbit"] - path = critbit - url = https://github.com/ennorehling/critbit.git [submodule "dlmalloc"] path = dlmalloc url = https://github.com/ennorehling/dlmalloc.git @@ -26,3 +20,6 @@ path = storage url = https://github.com/ennorehling/storage.git branch = master +[submodule "clibs"] + path = clibs + url = https://github.com/ennorehling/clibs diff --git a/clibs b/clibs new file mode 160000 index 000000000..f44b3e4e5 --- /dev/null +++ b/clibs @@ -0,0 +1 @@ +Subproject commit f44b3e4e5f08633e21e701b9af70927b707f38ab diff --git a/critbit b/critbit deleted file mode 160000 index 971836241..000000000 --- a/critbit +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 971836241277e37274aa3110344836499816ff21 diff --git a/quicklist b/quicklist deleted file mode 160000 index f837dd31e..000000000 --- a/quicklist +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f837dd31e5fcf13c706db1ac2c86b7de3e706578 From 20fe039b1622e05b55563019c6c0f54afba86606 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Dec 2016 21:35:02 +0100 Subject: [PATCH 301/675] use joint clibs directory instead of quicklist/critbit. --- CMakeLists.txt | 3 +-- clibs | 2 +- src/CMakeLists.txt | 9 +++------ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d60d3d721..cc7e8173d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,8 +68,7 @@ add_subdirectory (cutest) add_subdirectory (cJSON) add_subdirectory (storage) add_subdirectory (iniparser) -add_subdirectory (quicklist) -add_subdirectory (critbit) +add_subdirectory (clibs) add_subdirectory (process) add_subdirectory (src eressea) install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.xml") diff --git a/clibs b/clibs index f44b3e4e5..67e60390a 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f44b3e4e5f08633e21e701b9af70927b707f38ab +Subproject commit 67e60390a2e324c4b0a015bda3ca9a956c98343f diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a4445b55..ea76d4dbb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,10 +2,9 @@ cmake_minimum_required(VERSION 2.8) project (server C) include_directories (${CMAKE_CURRENT_SOURCE_DIR}) -include_directories (${CRITBIT_INCLUDE_DIR}) include_directories (${CJSON_INCLUDE_DIR}) +include_directories (${CLIBS_INCLUDE_DIR}) include_directories (${STORAGE_INCLUDE_DIR}) -include_directories (${QUICKLIST_INCLUDE_DIR}) include_directories (${CUTEST_INCLUDE_DIR}) include_directories (${LUA_INCLUDE_DIR}) include_directories (${TOLUA_INCLUDE_DIR}) @@ -181,9 +180,8 @@ target_link_libraries(eressea game ${TOLUA_LIBRARIES} ${LUA_LIBRARIES} - ${QUICKLIST_LIBRARIES} ${STORAGE_LIBRARIES} - ${CRITBIT_LIBRARIES} + ${CLIBS_LIBRARIES} ${CJSON_LIBRARIES} ${INIPARSER_LIBRARIES} ) @@ -239,9 +237,8 @@ target_link_libraries(test_eressea game ${CUTEST_LIBRARIES} ${LUA_LIBRARIES} - ${QUICKLIST_LIBRARIES} + ${CLIBS_LIBRARIES} ${STORAGE_LIBRARIES} - ${CRITBIT_LIBRARIES} ${CJSON_LIBRARIES} ${INIPARSER_LIBRARIES} ) From 2f52c226f0a2d9a01f98a2aabacda0bd593b28ab Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Dec 2016 07:07:06 +0100 Subject: [PATCH 302/675] clibs MSVC compilation --- clibs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clibs b/clibs index 67e60390a..bce9b6568 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit 67e60390a2e324c4b0a015bda3ca9a956c98343f +Subproject commit bce9b6568d4e9ace26c95a7740140cd71029b21f From cc227fb7070b9877c130061ba882c26794751eef Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 23 Dec 2016 18:05:38 +0100 Subject: [PATCH 303/675] merge monster.c and monsters.c move RCF_DESERT handling to monsters.c --- src/CMakeLists.txt | 1 - src/battle.c | 2 +- src/bind_monsters.c | 1 - src/bindings.c | 2 +- src/chaos.c | 2 +- src/economy.c | 2 +- src/guard.c | 2 +- src/guard.test.c | 2 +- src/kernel/faction.test.c | 2 +- src/laws.c | 2 +- src/laws.test.c | 2 +- src/monster.c | 224 -------------------------------------- src/monster.h | 39 ------- src/monsters.c | 193 +++++++++++++++++++++++++++++++- src/monsters.h | 49 ++++++++- src/monsters.test.c | 1 - src/move.c | 2 +- src/races/zombies.c | 2 +- src/randenc.c | 19 +--- src/report.c | 2 +- src/spells.c | 2 +- src/study.c | 2 +- src/summary.c | 2 +- src/teleport.c | 2 +- src/upkeep.c | 2 +- 25 files changed, 249 insertions(+), 312 deletions(-) delete mode 100644 src/monster.c delete mode 100644 src/monster.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a4445b55..81a43e002 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -114,7 +114,6 @@ set (ERESSEA_SRC magic.c market.c morale.c - monster.c randenc.c renumber.c volcano.c diff --git a/src/battle.c b/src/battle.c index 7aa3e4cfa..ed83871ec 100644 --- a/src/battle.c +++ b/src/battle.c @@ -23,7 +23,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "chaos.h" #include "guard.h" #include "laws.h" -#include "monster.h" +#include "monsters.h" #include "move.h" #include "skill.h" diff --git a/src/bind_monsters.c b/src/bind_monsters.c index 3e3f24bee..d7a3daab2 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -1,6 +1,5 @@ #include #include "spells/shipcurse.h" -#include "monster.h" #include "monsters.h" #include diff --git a/src/bindings.c b/src/bindings.c index aa2e177c1..f17ccc3a1 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -54,7 +54,7 @@ without prior permission by the authors of Eressea. #include "summary.h" #include "teleport.h" #include "laws.h" -#include "monster.h" +#include "monsters.h" #include "market.h" #include diff --git a/src/chaos.c b/src/chaos.c index 942fb87bc..58cd7af73 100644 --- a/src/chaos.c +++ b/src/chaos.c @@ -19,7 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "chaos.h" -#include "monster.h" +#include "monsters.h" #include "move.h" #include diff --git a/src/economy.c b/src/economy.c index d3f6189fc..01954ff54 100644 --- a/src/economy.c +++ b/src/economy.c @@ -31,7 +31,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "spy.h" #include "study.h" #include "move.h" -#include "monster.h" +#include "monsters.h" #include "morale.h" #include "reports.h" #include "calendar.h" diff --git a/src/guard.c b/src/guard.c index ee26e467b..ec87ea46c 100644 --- a/src/guard.c +++ b/src/guard.c @@ -21,7 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "guard.h" #include "laws.h" -#include "monster.h" +#include "monsters.h" #include #include diff --git a/src/guard.test.c b/src/guard.test.c index 60e5453c6..c5bffeab5 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -2,7 +2,7 @@ #include "guard.h" #include "laws.h" -#include "monster.h" +#include "monsters.h" #include #include diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 75ced96df..3d81b5d3c 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -10,7 +10,7 @@ #include #include -#include "monster.h" +#include "monsters.h" #include #include #include diff --git a/src/laws.c b/src/laws.c index 3fe53237e..e0bae8e41 100644 --- a/src/laws.c +++ b/src/laws.c @@ -29,7 +29,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "keyword.h" #include "market.h" #include "morale.h" -#include "monster.h" +#include "monsters.h" #include "move.h" #include "randenc.h" #include "renumber.h" diff --git a/src/laws.test.c b/src/laws.test.c index 69e9f5e04..1bec0e6b4 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -2,7 +2,7 @@ #include "laws.h" #include "battle.h" #include "guard.h" -#include "monster.h" +#include "monsters.h" #include #include diff --git a/src/monster.c b/src/monster.c deleted file mode 100644 index 301b1b132..000000000 --- a/src/monster.c +++ /dev/null @@ -1,224 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#include -#include -#include "monster.h" - -/* gamecode includes */ -#include "economy.h" -#include "give.h" -#include "move.h" - -/* attributes includes */ -#include -#include -#include - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* util includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* libc includes */ -#include -#include -#include - -#define MOVECHANCE 25 /* chance fuer bewegung */ - -#define MAXILLUSION_TEXTS 3 - -bool monster_is_waiting(const unit * u) -{ - int test = fval(u_race(u), RCF_ATTACK_MOVED) ? UFL_ISNEW : UFL_ISNEW | UFL_MOVED; - if (fval(u, test)) - return true; - return false; -} - -static void eaten_by_monster(unit * u) -{ - /* adjustment for smaller worlds */ - double multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0; - int n = 0; - int horse = -1; - const resource_type *rhorse = get_resourcetype(R_HORSE); - const race *rc = u_race(u); - attrib *a; - - a = a_find(rc->attribs, &at_scare); - if (a) { - n = rng_int() & a->data.i * u->number; - } else { - n = rng_int() % (u->number / 20 + 1); - horse = 0; - } - horse = horse ? i_get(u->items, rhorse->itype) : 0; - - n = (int)(n * multi); - if (n > 0) { - n = lovar(n); - n = _min(rpeasants(u->region), n); - - if (n > 0) { - deathcounts(u->region, n); - rsetpeasants(u->region, rpeasants(u->region) - n); - ADDMSG(&u->region->msgs, msg_message("eatpeasants", "unit amount", u, n)); - } - } - if (horse > 0) { - i_change(&u->items, rhorse->itype, -horse); - ADDMSG(&u->region->msgs, msg_message("eathorse", "unit amount", u, horse)); - } -} - -static void absorbed_by_monster(unit * u) -{ - int n = rng_int() % (u->number / 20 + 1); - - if (n > 0) { - n = lovar(n); - n = _min(rpeasants(u->region), n); - if (n > 0) { - rsetpeasants(u->region, rpeasants(u->region) - n); - scale_number(u, u->number + n); - ADDMSG(&u->region->msgs, msg_message("absorbpeasants", - "unit race amount", u, u_race(u), n)); - } - } -} - -static int scareaway(region * r, int anzahl) -{ - int n, p, diff = 0, emigrants[MAXDIRECTIONS]; - direction_t d; - - 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. - * emigrants[] ist local, weil r->newpeasants durch die Monster - * vielleicht schon hochgezaehlt worden ist. */ - - for (d = 0; d != MAXDIRECTIONS; d++) - emigrants[d] = 0; - - p = rpeasants(r); - assert(p >= 0 && anzahl >= 0); - for (n = _min(p, anzahl); n; n--) { - direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS); - region *rc = rconnect(r, dir); - - if (rc && fval(rc->terrain, LAND_REGION)) { - ++diff; - rc->land->newpeasants++; - emigrants[dir]++; - } - } - rsetpeasants(r, p - diff); - assert(p >= diff); - return diff; -} - -static void scared_by_monster(unit * u) -{ - int n; - const race *rc = u_race(u); - attrib *a; - a = a_find(rc->attribs, &at_scare); - if (a) { - n = rng_int() & a->data.i * u->number; - } else { - n = rng_int() % (u->number / 4 + 1); - } - if (n > 0) { - n = lovar(n); - n = _min(rpeasants(u->region), n); - if (n > 0) { - n = scareaway(u->region, n); - if (n > 0) { - ADDMSG(&u->region->msgs, msg_message("fleescared", - "amount unit", n, u)); - } - } - } -} - -void monster_kills_peasants(unit * u) -{ - if (!monster_is_waiting(u)) { - if (u_race(u)->flags & RCF_SCAREPEASANTS) { - scared_by_monster(u); - } - if (u_race(u)->flags & RCF_KILLPEASANTS) { - eaten_by_monster(u); - } - if (u_race(u)->flags & RCF_ABSORBPEASANTS) { - absorbed_by_monster(u); - } - } -} - -faction *get_or_create_monsters(void) -{ - faction *f = findfaction(MONSTER_ID); - if (!f) { - const race *rc = rc_get_or_create("dragon"); - const char *email = config_get("monster.email"); - f = addfaction(email ? email : "noreply@eressea.de", NULL, rc, default_locale, 0); - renumber_faction(f, MONSTER_ID); - faction_setname(f, "Monster"); - fset(f, FFL_NPC | FFL_NOIDLEOUT); - } - return f; -} - -faction *get_monsters(void) { - return get_or_create_monsters(); -} - -void make_zombie(unit * u) -{ - u_setfaction(u, get_monsters()); - scale_number(u, 1); - u->hp = unit_max_hp(u) * u->number; - u_setrace(u, get_race(RC_ZOMBIE)); - u->irace = NULL; -} diff --git a/src/monster.h b/src/monster.h deleted file mode 100644 index 0f936b17d..000000000 --- a/src/monster.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef H_GC_MONSTER -#define H_GC_MONSTER -#ifdef __cplusplus -extern "C" { -#endif - - struct unit; - - void monster_kills_peasants(struct unit *u); - bool monster_is_waiting(const struct unit *u); - struct faction *get_monsters(void); - struct faction *get_or_create_monsters(void); - void make_zombie(struct unit * u); - -#define MONSTER_ID 666 -#define is_monsters(f) ((f->flags & FFL_NPC) && f==get_monsters()) - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/monsters.c b/src/monsters.c index cea817589..f1064b7fe 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -26,12 +26,12 @@ #include "chaos.h" #include "give.h" #include "guard.h" -#include "monster.h" #include "laws.h" #include "keyword.h" #include "study.h" /* attributes includes */ +#include #include #include @@ -72,8 +72,8 @@ #include #include -#define MOVECHANCE .25 /* chance fuer bewegung */ -#define DRAGON_RANGE 20 /* Max. Distanz zum nchsten Drachenziel */ +#define DRAGON_RANGE 20 /* max. Distanz zum nchsten Drachenziel */ +#define MOVE_PERCENT 25 /* chance fuer bewegung */ #define MAXILLUSION_TEXTS 3 static double attack_chance; /* rules.monsters.attack_chance, or default 0.4 */ @@ -85,12 +85,12 @@ static void give_peasants(unit *u, const item_type *itype, int reduce) { } static double random_move_chance(void) { - static double rule; + static int rule; static int config; if (config_changed(&config)) { - rule = config_get_flt("rules.monsters.random_move_chance", MOVECHANCE); + rule = config_get_flt("rules.monsters.random_move_percent", MOVE_PERCENT); } - return rule; + return rule * 0.01; } static void reduce_weight(unit * u) @@ -165,6 +165,29 @@ static order *monster_attack(unit * u, const unit * target) return create_order(K_ATTACK, u->faction->locale, "%i", target->no); } +void monsters_desert(struct faction *monsters) +{ + region *r; + + assert(monsters!=NULL); + for (r = regions; r; r = r->next) { + unit *u; + + for (u = r->units; u; u = u->next) { + if (u->faction!=monsters + && (u_race(u)->flags & RCF_DESERT)) { + if (fval(u, UFL_ISNEW)) + continue; + if (rng_int() % 100 < 5) { + ADDMSG(&u->faction->msgs, msg_message("desertion", + "unit region", u, r)); + u_setfaction(u, monsters); + } + } + } + } +} + int monster_attacks(unit * monster, bool respect_buildings, bool rich_only) { region *r = monster->region; @@ -973,3 +996,161 @@ void spawn_undead(void) } } } + +bool monster_is_waiting(const unit * u) +{ + int test = fval(u_race(u), RCF_ATTACK_MOVED) ? UFL_ISNEW : UFL_ISNEW | UFL_MOVED; + if (fval(u, test)) + return true; + return false; +} + +static void eaten_by_monster(unit * u) +{ + /* adjustment for smaller worlds */ + double multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0; + int n = 0; + int horse = -1; + const resource_type *rhorse = get_resourcetype(R_HORSE); + const race *rc = u_race(u); + attrib *a; + + a = a_find(rc->attribs, &at_scare); + if (a) { + n = rng_int() & a->data.i * u->number; + } else { + n = rng_int() % (u->number / 20 + 1); + horse = 0; + } + horse = horse ? i_get(u->items, rhorse->itype) : 0; + + n = (int)(n * multi); + if (n > 0) { + n = lovar(n); + n = _min(rpeasants(u->region), n); + + if (n > 0) { + deathcounts(u->region, n); + rsetpeasants(u->region, rpeasants(u->region) - n); + ADDMSG(&u->region->msgs, msg_message("eatpeasants", "unit amount", u, n)); + } + } + if (horse > 0) { + i_change(&u->items, rhorse->itype, -horse); + ADDMSG(&u->region->msgs, msg_message("eathorse", "unit amount", u, horse)); + } +} + +static void absorbed_by_monster(unit * u) +{ + int n = rng_int() % (u->number / 20 + 1); + + if (n > 0) { + n = lovar(n); + n = _min(rpeasants(u->region), n); + if (n > 0) { + rsetpeasants(u->region, rpeasants(u->region) - n); + scale_number(u, u->number + n); + ADDMSG(&u->region->msgs, msg_message("absorbpeasants", + "unit race amount", u, u_race(u), n)); + } + } +} + +static int scareaway(region * r, int anzahl) +{ + int n, p, diff = 0, emigrants[MAXDIRECTIONS]; + direction_t d; + + 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. + * emigrants[] ist local, weil r->newpeasants durch die Monster + * vielleicht schon hochgezaehlt worden ist. */ + + for (d = 0; d != MAXDIRECTIONS; d++) + emigrants[d] = 0; + + p = rpeasants(r); + assert(p >= 0 && anzahl >= 0); + for (n = _min(p, anzahl); n; n--) { + direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS); + region *rc = rconnect(r, dir); + + if (rc && fval(rc->terrain, LAND_REGION)) { + ++diff; + rc->land->newpeasants++; + emigrants[dir]++; + } + } + rsetpeasants(r, p - diff); + assert(p >= diff); + return diff; +} + +static void scared_by_monster(unit * u) +{ + int n; + const race *rc = u_race(u); + attrib *a; + a = a_find(rc->attribs, &at_scare); + if (a) { + n = rng_int() & a->data.i * u->number; + } else { + n = rng_int() % (u->number / 4 + 1); + } + if (n > 0) { + n = lovar(n); + n = _min(rpeasants(u->region), n); + if (n > 0) { + n = scareaway(u->region, n); + if (n > 0) { + ADDMSG(&u->region->msgs, msg_message("fleescared", + "amount unit", n, u)); + } + } + } +} + +void monster_kills_peasants(unit * u) +{ + if (!monster_is_waiting(u)) { + if (u_race(u)->flags & RCF_SCAREPEASANTS) { + scared_by_monster(u); + } + if (u_race(u)->flags & RCF_KILLPEASANTS) { + eaten_by_monster(u); + } + if (u_race(u)->flags & RCF_ABSORBPEASANTS) { + absorbed_by_monster(u); + } + } +} + +faction *get_or_create_monsters(void) +{ + faction *f = findfaction(MONSTER_ID); + if (!f) { + const race *rc = rc_get_or_create("dragon"); + const char *email = config_get("monster.email"); + f = addfaction(email ? email : "noreply@eressea.de", NULL, rc, default_locale, 0); + renumber_faction(f, MONSTER_ID); + faction_setname(f, "Monster"); + fset(f, FFL_NPC | FFL_NOIDLEOUT); + } + return f; +} + +faction *get_monsters(void) { + return get_or_create_monsters(); +} + +void make_zombie(unit * u) +{ + u_setfaction(u, get_monsters()); + scale_number(u, 1); + u->hp = unit_max_hp(u) * u->number; + u_setrace(u, get_race(RC_ZOMBIE)); + u->irace = NULL; +} diff --git a/src/monsters.h b/src/monsters.h index 02e41c0a4..52e9ebf37 100644 --- a/src/monsters.h +++ b/src/monsters.h @@ -1,8 +1,45 @@ -#pragma once +/* +Copyright (c) 1998-2015, Enno Rehling +Katja Zedel -struct unit; -struct region; -struct faction; +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. -struct unit *spawn_seaserpent(struct region *r, struct faction *f); -void spawn_dragons(void); +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +**/ + +#ifndef H_GC_MONSTER +#define H_GC_MONSTER +#ifdef __cplusplus +extern "C" { +#endif + + struct unit; + struct region; + struct faction; + + struct unit *spawn_seaserpent(struct region *r, struct faction *f); + void spawn_dragons(void); + void monsters_desert(struct faction *monsters); + + void monster_kills_peasants(struct unit *u); + bool monster_is_waiting(const struct unit *u); + struct faction *get_monsters(void); + struct faction *get_or_create_monsters(void); + void make_zombie(struct unit * u); + +#define MONSTER_ID 666 +#define is_monsters(f) ((f->flags & FFL_NPC) && f==get_monsters()) + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/monsters.test.c b/src/monsters.test.c index ca793891c..e0eaa3ccc 100644 --- a/src/monsters.test.c +++ b/src/monsters.test.c @@ -10,7 +10,6 @@ #include #include -#include "monster.h" #include "monsters.h" #include "guard.h" #include "reports.h" diff --git a/src/move.c b/src/move.c index b6a908837..29e3a2ed5 100644 --- a/src/move.c +++ b/src/move.c @@ -27,7 +27,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "alchemy.h" #include "travelthru.h" #include "vortex.h" -#include "monster.h" +#include "monsters.h" #include "lighthouse.h" #include "piracy.h" diff --git a/src/races/zombies.c b/src/races/zombies.c index d7f871dac..3e9303b38 100644 --- a/src/races/zombies.c +++ b/src/races/zombies.c @@ -24,7 +24,7 @@ /* util iclude */ #include -#include "monster.h" +#include "monsters.h" /* libc includes */ #include diff --git a/src/randenc.c b/src/randenc.c index a3c5ce303..536210b1f 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -22,7 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "volcano.h" #include "economy.h" -#include "monster.h" +#include "monsters.h" #include "move.h" #include "chaos.h" #include "study.h" @@ -826,22 +826,7 @@ void randomevents(void) /* monster-einheiten desertieren */ if (monsters) { - for (r = regions; r; r = r->next) { - unit *u; - - for (u = r->units; u; u = u->next) { - if (u->faction && !is_monsters(u->faction) - && (u_race(u)->flags & RCF_DESERT)) { - if (fval(u, UFL_ISNEW)) - continue; - if (rng_int() % 100 < 5) { - ADDMSG(&u->faction->msgs, msg_message("desertion", - "unit region", u, r)); - u_setfaction(u, monsters); - } - } - } - } + monsters_desert(monsters); } chaos_update(); diff --git a/src/report.c b/src/report.c index dd6b29525..7f9ede7e6 100644 --- a/src/report.c +++ b/src/report.c @@ -26,7 +26,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "guard.h" #include "laws.h" #include "market.h" -#include "monster.h" +#include "monsters.h" #include "travelthru.h" /* modules includes */ diff --git a/src/spells.c b/src/spells.c index 57b1da3a5..7e7b5669a 100644 --- a/src/spells.c +++ b/src/spells.c @@ -22,7 +22,7 @@ #include "spells.h" #include "direction.h" #include "randenc.h" -#include "monster.h" +#include "monsters.h" #include "teleport.h" #include diff --git a/src/study.c b/src/study.c index 1dd4da8b8..2531c864a 100644 --- a/src/study.c +++ b/src/study.c @@ -24,7 +24,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "study.h" #include "laws.h" #include "move.h" -#include "monster.h" +#include "monsters.h" #include "alchemy.h" #include "academy.h" diff --git a/src/summary.c b/src/summary.c index 2311b1994..8a3ee3c41 100644 --- a/src/summary.c +++ b/src/summary.c @@ -14,7 +14,7 @@ #include "summary.h" #include "laws.h" -#include "monster.h" +#include "monsters.h" #include "calendar.h" #include diff --git a/src/teleport.c b/src/teleport.c index 74176f6af..f81f2f9f0 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -34,7 +34,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "skill.h" -#include "monster.h" +#include "monsters.h" /* libc includes */ #include diff --git a/src/upkeep.c b/src/upkeep.c index 198ce73df..1cf41011f 100644 --- a/src/upkeep.c +++ b/src/upkeep.c @@ -16,7 +16,7 @@ #include "alchemy.h" #include "economy.h" -#include "monster.h" +#include "monsters.h" #include "donations.h" #include From 44652bae80295744f4cc7cf87bb09e711c43d3d4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 23 Dec 2016 23:58:24 +0100 Subject: [PATCH 304/675] fix flt/int compilation bug. --- src/monsters.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monsters.c b/src/monsters.c index f1064b7fe..db34bff2c 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -88,7 +88,7 @@ static double random_move_chance(void) { static int rule; static int config; if (config_changed(&config)) { - rule = config_get_flt("rules.monsters.random_move_percent", MOVE_PERCENT); + rule = config_get_int("rules.monsters.random_move_percent", MOVE_PERCENT); } return rule * 0.01; } From a7f8ad052db201971e851d820aac9b93bae427c9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 31 Dec 2016 19:56:55 +0100 Subject: [PATCH 305/675] failing test for name_unit. --- src/kernel/unit.test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index c4b1f46ed..752627144 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -468,6 +468,24 @@ static void test_renumber_unit(CuTest *tc) { test_cleanup(); } +static void gen_name(unit *u) +{ + unit_setname(u, "Hodor"); +} + +static void test_name_unit(CuTest *tc) { + race *rc; + unit * u; + + test_setup(); + rc = test_create_race("skeleton"); + u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); + rc->generate_name = gen_name; + name_unit(u); + CuAssertStrEquals(tc, "Hodor", unit_getname(u)); + test_cleanup(); +} + CuSuite *get_unit_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -491,5 +509,6 @@ CuSuite *get_unit_suite(void) SUITE_ADD_TEST(suite, test_inside_building); SUITE_ADD_TEST(suite, test_limited_skills); SUITE_ADD_TEST(suite, test_renumber_unit); + SUITE_ADD_TEST(suite, test_name_unit); return suite; } From 4a802be67c7677d00ee2c109a67289effdac6670 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 31 Dec 2016 20:03:50 +0100 Subject: [PATCH 306/675] fix undead name generation. --- src/kernel/race.c | 7 ------- src/kernel/race.h | 1 - src/kernel/unit.c | 12 +++--------- src/names.test.c | 2 +- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/kernel/race.c b/src/kernel/race.c index f28c5ed2f..decc3b7bb 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -369,10 +369,3 @@ void register_race_description_function(race_desc_func func, const char *name) { void register_race_name_function(race_name_func func, const char *name) { register_function((pf_generic)func, name); } - -char * race_namegen(const struct race *rc, struct unit *u) { - if (rc->generate_name) { - rc->generate_name(u); - } - return NULL; -} diff --git a/src/kernel/race.h b/src/kernel/race.h index 022d09c86..6673676bd 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -252,7 +252,6 @@ extern "C" { const char *raceprefix(const struct unit *u); void register_race_name_function(race_name_func, const char *); void register_race_description_function(race_desc_func, const char *); - char * race_namegen(const struct race *rc, struct unit *u); #ifdef __cplusplus } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 4aff7d118..f06c4c252 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1480,15 +1480,9 @@ void default_name(const unit *u, char name[], int len) { void name_unit(unit * u) { - if (u_race(u)->generate_name) { - char *gen_name = race_namegen(u_race(u), u); - if (gen_name) { - free(u->_name); - u->_name = gen_name; - } - else { - unit_setname(u, racename(u->faction->locale, u, u_race(u))); - } + const race *rc = u_race(u); + if (rc->generate_name) { + rc->generate_name(u); } else { char name[32]; diff --git a/src/names.test.c b/src/names.test.c index f50937f17..1fc41f340 100644 --- a/src/names.test.c +++ b/src/names.test.c @@ -24,7 +24,7 @@ static void test_names(CuTest * tc) locale_setstring(default_locale, "undead_postfix_0", "Kobolde"); CuAssertPtrNotNull(tc, foo = (race_name_func)get_function("nameundead")); rc->generate_name = foo; - race_namegen(rc, u); + rc->generate_name(u); CuAssertStrEquals(tc, "Graue Kobolde", u->_name); CuAssertPtrNotNull(tc, get_function("nameskeleton")); CuAssertPtrNotNull(tc, get_function("namezombie")); From 065439e9676a010994f4e28bb25cb3dd006132ac Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 31 Dec 2016 20:12:13 +0100 Subject: [PATCH 307/675] test that monsters with "namegeneric" hook get a NULL name (WIP) --- src/names.test.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/names.test.c b/src/names.test.c index 1fc41f340..176a12a68 100644 --- a/src/names.test.c +++ b/src/names.test.c @@ -36,9 +36,25 @@ static void test_names(CuTest * tc) test_cleanup(); } +static void test_monster_names(CuTest *tc) { + unit *u; + race *rc; + + test_setup(); + register_names(); + rc = test_create_race("irongolem"); + u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); + CuAssertPtrNotNull(tc, u->_name); + rc->generate_name = (race_name_func)get_function("namegeneric"); + rc->generate_name(u); + CuAssertPtrEquals(tc, 0, u->_name); + test_cleanup(); +} + CuSuite *get_names_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_names); + SUITE_ADD_TEST(suite, test_monster_names); return suite; } From 5b7cdc4d482f011719303e22a1499c0af1684066 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 31 Dec 2016 20:17:02 +0100 Subject: [PATCH 308/675] monster name pluralization changes with u->number. --- src/names.c | 6 +----- src/names.test.c | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/names.c b/src/names.c index 99c21a05e..cf1cdb910 100644 --- a/src/names.c +++ b/src/names.c @@ -221,11 +221,7 @@ const char *silbe3[SIL3] = { static void generic_name(unit * u) { - const char * name = rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL); - name = LOC(u->faction->locale, name); - if (name) { - unit_setname(u, name); - } + unit_setname(u, NULL); } static void dragon_name(unit * u) diff --git a/src/names.test.c b/src/names.test.c index 176a12a68..8109fc2d4 100644 --- a/src/names.test.c +++ b/src/names.test.c @@ -42,12 +42,18 @@ static void test_monster_names(CuTest *tc) { test_setup(); register_names(); + default_locale = test_create_locale(); + locale_setstring(default_locale, "race::irongolem", "Eisengolem"); + locale_setstring(default_locale, "race::irongolem_p", "Eisengolems"); rc = test_create_race("irongolem"); u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); CuAssertPtrNotNull(tc, u->_name); rc->generate_name = (race_name_func)get_function("namegeneric"); rc->generate_name(u); CuAssertPtrEquals(tc, 0, u->_name); + CuAssertStrEquals(tc, "Eisengolem", unit_getname(u)); + u->number = 2; + CuAssertStrEquals(tc, "Eisengolems", unit_getname(u)); test_cleanup(); } From ce17d7f2d73f3d80f89e542e49fa59cc4035d403 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 31 Dec 2016 21:21:23 +0100 Subject: [PATCH 309/675] enable PAY NOT in E2 --- conf/e2/config.json | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index 217cfffe9..ce823a33d 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -5,7 +5,6 @@ "e2/terrains.json" ], "disabled": [ - "pay", "jsreport" ], "settings": { From f9fbe607663052f47a2179b89f6c96ca716995c3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 6 Jan 2017 20:54:57 +0100 Subject: [PATCH 310/675] add a happy test for mt_new. refactor to not use strncpy. --- src/test_eressea.c | 1 + src/util/CMakeLists.txt | 2 +- src/util/message.c | 20 +++++++++++--------- src/util/message.test.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 src/util/message.test.c diff --git a/src/test_eressea.c b/src/test_eressea.c index 71cf008f2..6d2dead3f 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -65,6 +65,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(direction); ADD_SUITE(skill); ADD_SUITE(keyword); + ADD_SUITE(message); ADD_SUITE(order); ADD_SUITE(race); /* util */ diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 7eda87132..842bcf58c 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -14,7 +14,7 @@ gamedata.test.c language.test.c # lists.test.c # log.test.c -# message.test.c +message.test.c # nrmessage.test.c parser.test.c password.test.c diff --git a/src/util/message.c b/src/util/message.c index f19fc3313..5b6f12eb8 100644 --- a/src/util/message.c +++ b/src/util/message.c @@ -87,19 +87,21 @@ message_type *mt_new(const char *name, const char *args[]) for (i = 0; args[i]; ++i) { const char *x = args[i]; const char *spos = strchr(x, ':'); - if (spos == NULL) { - mtype->pnames[i] = _strdup(x); - mtype->types[i] = NULL; + struct arg_type *atype = NULL; + if (spos != NULL) { + atype = find_argtype(spos + 1); + } + if (!atype) { + log_error("unknown argument type %s for message type %s\n", spos + 1, mtype->name); + assert(atype); } else { - char *cp = strncpy((char *)malloc(spos - x + 1), x, spos - x); + char *cp; + cp = malloc(spos - x + 1); + memcpy(cp, x, spos - x); cp[spos - x] = '\0'; mtype->pnames[i] = cp; - mtype->types[i] = find_argtype(spos + 1); - if (mtype->types[i] == NULL) { - log_error("unknown argument type %s for message type %s\n", spos + 1, mtype->name); - } - assert(mtype->types[i]); + mtype->types[i] = atype; } } } diff --git a/src/util/message.test.c b/src/util/message.test.c new file mode 100644 index 000000000..d114e33f2 --- /dev/null +++ b/src/util/message.test.c @@ -0,0 +1,29 @@ +#include +#include "message.h" + +#include +#include + +static void test_mt_new(CuTest *tc) +{ + message_type *mt; + test_setup(); + mt = mt_new_va("test", "name:string", "number:int", NULL); + CuAssertPtrNotNull(tc, mt); + CuAssertStrEquals(tc, "test", mt->name); + CuAssertIntEquals(tc, 2, mt->nparameters); + CuAssertPtrNotNull(tc, mt->pnames); + CuAssertStrEquals(tc, "name", mt->pnames[0]); + CuAssertStrEquals(tc, "number", mt->pnames[1]); + CuAssertPtrNotNull(tc, mt->types); + CuAssertStrEquals(tc, "string", mt->types[0]->name); + CuAssertStrEquals(tc, "int", mt->types[1]->name); + test_cleanup(); +} + +CuSuite *get_message_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_mt_new); + return suite; +} From 946364268738ad3ad37af5014b594e789b17d2cd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 6 Jan 2017 21:08:49 +0100 Subject: [PATCH 311/675] eliminate unnecessary strncpy use. --- src/report.c | 3 ++- src/reports.c | 6 +----- src/util/language.c | 25 ++++++++++++++++--------- src/util/language.test.c | 11 +++++++++++ 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/report.c b/src/report.c index 7f9ede7e6..0d6d283dd 100644 --- a/src/report.c +++ b/src/report.c @@ -413,7 +413,8 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc } else { char substr[32]; - strncpy(substr, syntaxp, cstr - syntaxp); + assert(sizeof(substr) > (cstr - syntaxp)); + memcpy(substr, syntaxp, cstr - syntaxp); substr[cstr - syntaxp] = 0; locp = LOC(lang, mkname("spellpar", substr)); syntaxp = substr + 1; diff --git a/src/reports.c b/src/reports.c index a8b9e5cfb..52278d270 100644 --- a/src/reports.c +++ b/src/reports.c @@ -849,10 +849,6 @@ const struct unit * u, struct skill * sv, int *dh, int days) void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned int width, char mark) { - - /* Die Liste SP wird mit dem String s aufgefuellt, mit indent und einer - * mark, falls angegeben. SP wurde also auf 0 gesetzt vor dem Aufruf. - * Vgl. spunit (). */ bool firstline; static char buf[REPORTWIDTH + 1]; // FIXME: static buffer, artificial limit size_t len = strlen(s); @@ -883,7 +879,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned if (!cut) { cut = s + _min(len, REPORTWIDTH); } - strncpy(buf + indent, s, cut - s); + memcpy(buf + indent, s, cut - s); buf[indent + (cut - s)] = 0; addstrlist(SP, buf); // TODO: too much string copying, cut out this function while (*cut == ' ') { diff --git a/src/util/language.c b/src/util/language.c index d8b899742..cb91d7419 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -101,16 +101,23 @@ locale *get_or_create_locale(const char *name) void make_locales(const char *str) { const char *tok = str; - while (*tok) { - char zText[32]; - while (*tok && *tok != ',') - ++tok; - strncpy(zText, str, tok - str); - zText[tok - str] = 0; - get_or_create_locale(zText); - if (*tok) { - str = ++tok; + while (tok) { + char zText[16]; + size_t len; + + tok = strchr(str, ','); + if (tok) { + len = tok - str; + assert(sizeof(zText) > len); + memcpy(zText, str, len); + str = tok + 1; } + else { + len = strlen(str); + memcpy(zText, str, len); + } + zText[len] = 0; + get_or_create_locale(zText); } } diff --git a/src/util/language.test.c b/src/util/language.test.c index 236eac497..40a6775fa 100644 --- a/src/util/language.test.c +++ b/src/util/language.test.c @@ -16,9 +16,20 @@ static void test_language(CuTest *tc) test_cleanup(); } +static void test_make_locales(CuTest *tc) +{ + test_setup(); + make_locales("aa,bb,cc"); + CuAssertPtrNotNull(tc, get_locale("aa")); + CuAssertPtrNotNull(tc, get_locale("bb")); + CuAssertPtrNotNull(tc, get_locale("cc")); + test_cleanup(); +} + CuSuite *get_language_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_language); + SUITE_ADD_TEST(suite, test_make_locales); return suite; } From 8d02d5a5aa23b3260cd4e83569ad9ee09bb73ff7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 6 Jan 2017 21:24:31 +0100 Subject: [PATCH 312/675] never use strncpy, anywhere. --- src/bind_config.c | 3 ++- src/helpers.c | 2 +- src/util/log.test.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bind_config.c b/src/bind_config.c index 3959cc22c..929e4cca0 100644 --- a/src/bind_config.c +++ b/src/bind_config.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,7 @@ int config_parse(const char *json) if (xp >= ep) break; } xp = (ep > json + 10) ? ep - 10 : json; - strncpy(buffer, xp, sizeof(buffer)); + strlcpy(buffer, xp, sizeof(buffer)); buffer[9] = 0; log_error("json parse error in line %d, position %d, near `%s`\n", line, ep - lp, buffer); } diff --git a/src/helpers.c b/src/helpers.c index aa9bc12eb..e9502e075 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -167,7 +167,7 @@ static int lua_callspell(castorder * co) if (hashpos != NULL) { ptrdiff_t len = hashpos - fname; assert(len < (ptrdiff_t) sizeof(fbuf)); - strncpy(fbuf, fname, len); + memcpy(fbuf, fname, len); fbuf[len] = '\0'; fname = fbuf; } diff --git a/src/util/log.test.c b/src/util/log.test.c index 95cbefa96..55616c026 100644 --- a/src/util/log.test.c +++ b/src/util/log.test.c @@ -12,7 +12,7 @@ void log_string(void *data, int level, const char *module, const char *format, v unused_arg(format); unused_arg(module); unused_arg(level); - strncpy(str, arg, 32); + strcpy(str, arg); } static void test_logging(CuTest * tc) From 262580f1d5d70b258138926e1304d5d0c7e5f77d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 6 Jan 2017 21:37:52 +0100 Subject: [PATCH 313/675] gcc warning eliminated --- src/report.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/report.c b/src/report.c index 0d6d283dd..0c7697fe5 100644 --- a/src/report.c +++ b/src/report.c @@ -413,9 +413,10 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc } else { char substr[32]; - assert(sizeof(substr) > (cstr - syntaxp)); - memcpy(substr, syntaxp, cstr - syntaxp); - substr[cstr - syntaxp] = 0; + size_t len = cstr - syntaxp; + assert(sizeof(substr) > len); + memcpy(substr, syntaxp, len); + substr[len] = 0; locp = LOC(lang, mkname("spellpar", substr)); syntaxp = substr + 1; } From f5419a7f456b6491d5482ef696e8c6f3ea0bdf48 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 6 Jan 2017 22:47:50 +0100 Subject: [PATCH 314/675] remove superfluous quicklist includes. --- src/bind_faction.c | 2 -- src/bind_monsters.c | 2 -- src/creport.test.c | 1 - src/kernel/config.c | 1 - src/kernel/equipment.test.c | 2 -- src/kernel/spell.test.c | 1 - src/kernel/spellbook.test.c | 1 - src/report.test.c | 1 - src/spy.c | 2 -- 9 files changed, 13 deletions(-) diff --git a/src/bind_faction.c b/src/bind_faction.c index 36da798c1..109814717 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -32,8 +32,6 @@ without prior permission by the authors of Eressea. #include #include -#include - #include #include diff --git a/src/bind_monsters.c b/src/bind_monsters.c index 3e3f24bee..54a9d0ba6 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -12,8 +12,6 @@ #include -#include - #include #include diff --git a/src/creport.test.c b/src/creport.test.c index 72669e99f..21a6c09b7 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -18,7 +18,6 @@ #include #include -#include #include #include diff --git a/src/kernel/config.c b/src/kernel/config.c index f33303ead..2b1ae678d 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -63,7 +63,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include diff --git a/src/kernel/equipment.test.c b/src/kernel/equipment.test.c index 2911af1ea..a82f86674 100644 --- a/src/kernel/equipment.test.c +++ b/src/kernel/equipment.test.c @@ -7,8 +7,6 @@ #include #include -#include - #include #include diff --git a/src/kernel/spell.test.c b/src/kernel/spell.test.c index f61c0fffe..6bb2ac449 100644 --- a/src/kernel/spell.test.c +++ b/src/kernel/spell.test.c @@ -6,7 +6,6 @@ #include #include -#include #include #include diff --git a/src/kernel/spellbook.test.c b/src/kernel/spellbook.test.c index 2f78fd87d..8b997557b 100644 --- a/src/kernel/spellbook.test.c +++ b/src/kernel/spellbook.test.c @@ -2,7 +2,6 @@ #include #include -#include #include #include diff --git a/src/report.test.c b/src/report.test.c index 202458db5..555d39408 100644 --- a/src/report.test.c +++ b/src/report.test.c @@ -18,7 +18,6 @@ #include #include -#include #include #include diff --git a/src/spy.c b/src/spy.c index 22c548d68..86476bec7 100644 --- a/src/spy.c +++ b/src/spy.c @@ -49,8 +49,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#include - /* libc includes */ #include #include From 494643d65f399b1e7df8307e731382f92d52657e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jan 2017 20:20:13 +0100 Subject: [PATCH 315/675] remove old & unused fix_famililar repair code. --- src/bind_monsters.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/bind_monsters.c b/src/bind_monsters.c index d7a3daab2..fd1130053 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -58,34 +58,6 @@ static int tolua_spawn_undead(lua_State * L) return 0; } -static int fix_familiars(struct lua_State *L) -{ - faction *f; - for (f = factions; f; f = f->next) { - unit *u; - for (u = f->units; u; u = u->nextF) { - struct sc_mage *mage = get_mage(u); - if (mage && is_familiar(u)) { - if (mage->spellbook && mage->magietyp == M_GRAY) { - equipment *eq; - char buffer[64]; - - spellbook_clear(mage->spellbook); - free(mage->spellbook); - mage->spellbook = 0; - - _snprintf(buffer, sizeof(buffer), "%s_familiar", u_race(u)->_name); - eq = get_equipment(buffer); - if (eq) { - equip_unit_mask(u, eq, EQUIP_SPELLS); - } - } - } - } - } - return 0; -} - void bind_monsters(struct lua_State *L) { tolua_module(L, NULL, 0); @@ -95,7 +67,6 @@ void bind_monsters(struct lua_State *L) tolua_function(L, TOLUA_CAST "plan_monsters", tolua_planmonsters); tolua_function(L, TOLUA_CAST "spawn_undead", tolua_spawn_undead); tolua_function(L, TOLUA_CAST "spawn_dragons", tolua_spawn_dragons); - tolua_function(L, TOLUA_CAST "fix_familiars", fix_familiars); tolua_function(L, TOLUA_CAST "get_monsters", tolua_get_monsters); } tolua_endmodule(L); From 3fb12d8f1ef0ee1a026d6d3ac76c393c89461d55 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jan 2017 21:09:39 +0100 Subject: [PATCH 316/675] replace snprintf and the like. you cannot trust _snprintf in MSVC (no zero-termination). --- src/bind_storage.c | 4 +++- src/gmtool.c | 2 +- src/json.c | 6 +++--- src/kernel/item.c | 5 ++++- src/kernel/jsonconf.c | 7 ++++++- src/util/bsdstring.c | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/bind_storage.c b/src/bind_storage.c index a81a3baeb..6b582e815 100644 --- a/src/bind_storage.c +++ b/src/bind_storage.c @@ -100,7 +100,9 @@ static int tolua_storage_tostring(lua_State * L) { gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0); char name[64]; - _snprintf(name, sizeof(name), "", (void *)data, data->version); + // safe to use sprintf here, because: + // %p is at most 16 characters, %d 20, text is 16, comes to 53 with \0 + sprintf(name, "", (void *)data, data->version); lua_pushstring(L, name); return 1; } diff --git a/src/gmtool.c b/src/gmtool.c index 7aab2fea7..b1b9a1bc1 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -1167,7 +1167,7 @@ static void handlekey(state * st, int c) region *first = (mr && mr->r && mr->r->next) ? mr->r->next : regions; if (findmode == 'f') { - snprintf(sbuffer, sizeof(sbuffer), "find-faction: %s", locate); + slprintf(sbuffer, sizeof(sbuffer), "find-faction: %s", locate); statusline(st->wnd_status->handle, sbuffer); f = findfaction(atoi36(locate)); if (f == NULL) { diff --git a/src/json.c b/src/json.c index 10322fe3f..2c27b9947 100644 --- a/src/json.c +++ b/src/json.c @@ -67,13 +67,13 @@ int json_export(stream * out, int flags) { cJSON *json, *root = cJSON_CreateObject(); assert(out && out->api); if (regions && (flags & EXPORT_REGIONS)) { - char id[32]; + char id[32]; // TODO: static_assert(INT_MAX < 10^32) region * r; plane * p; cJSON_AddItemToObject(root, "planes", json = cJSON_CreateObject()); for (p = planes; p; p = p->next) { cJSON *data; - _snprintf(id, sizeof(id), "%d", p->id); + sprintf(id, "%d", p->id); // safe, unless int is bigger than 64 bit cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); cJSON_AddNumberToObject(data, "x", p->minx); cJSON_AddNumberToObject(data, "y", p->miny); @@ -85,7 +85,7 @@ int json_export(stream * out, int flags) { cJSON_AddItemToObject(root, "regions", json = cJSON_CreateObject()); for (r = regions; r; r = r->next) { cJSON *data; - _snprintf(id, sizeof(id), "%d", r->uid); + sprintf(id, "%d", r->uid); // safe, unless int is bigger than 64 bit cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); cJSON_AddNumberToObject(data, "x", r->x); cJSON_AddNumberToObject(data, "y", r->y); diff --git a/src/kernel/item.c b/src/kernel/item.c index 53fff79ab..9956f2a4a 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -156,7 +156,10 @@ const char *resourcename(const resource_type * rtype, int flags) } if (flags & NMF_PLURAL) { static char name[64]; // FIXME: static return value - _snprintf(name, sizeof(name), "%s_p", rtype->_name); + size_t len = strlen(rtype->_name); + assert(len <= sizeof(name) - 3); + memcpy(name, rtype->_name, len); + strcpy(name + len, "_p"); return name; } return rtype->_name; diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index d12238566..dccfbb68a 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -523,6 +523,8 @@ static void disable_feature(const char *str) { char name[32]; int k; skill_t sk; + size_t len; + sk = findskill(str); if (sk != NOSKILL) { enable_skill(sk, false); @@ -534,7 +536,10 @@ static void disable_feature(const char *str) { enable_keyword(k, false); return; } - _snprintf(name, sizeof(name), "%s.enabled", str); + len = strlen(str); + assert(len <= sizeof(name) - 9); + memcpy(name, str, len); + strcpy(name+len, ".enabled"); log_info("disable feature %s\n", name); config_set(name, "0"); } diff --git a/src/util/bsdstring.c b/src/util/bsdstring.c index 98d2d00f5..4fc56ce4e 100644 --- a/src/util/bsdstring.c +++ b/src/util/bsdstring.c @@ -13,7 +13,7 @@ int wrptr(char **ptr, size_t * size, int result) { size_t bytes = (size_t)result; if (result < 0) { - // _snprintf buffer was too small + // buffer was too small if (*size > 0) { **ptr = 0; *size = 0; From 6d60b48b3f95985aad55721bf275d309d84ac46d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jan 2017 21:19:58 +0100 Subject: [PATCH 317/675] create_order takes variable arguments! more snprintf removal. --- src/give.test.c | 12 +++--------- src/kernel/jsonconf.c | 4 ++-- src/kernel/unit.test.c | 13 +++++-------- src/laws.test.c | 4 +--- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/give.test.c b/src/give.test.c index f2b0d60a9..029ee7c44 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -233,7 +233,6 @@ static void test_give_men_requires_contact(CuTest * tc) { struct give env = { 0 }; message * msg; order *ord; - char cmd[32]; test_setup_ex(tc); env.f1 = test_create_faction(0); @@ -244,8 +243,7 @@ static void test_give_men_requires_contact(CuTest * tc) { CuAssertIntEquals(tc, 1, env.dst->number); CuAssertIntEquals(tc, 1, env.src->number); - _snprintf(cmd, sizeof(cmd), "%s ALLES PERSONEN", itoa36(env.dst->no)); - ord = create_order(K_GIVE, env.f1->locale, cmd); + ord = create_order(K_GIVE, env.f1->locale, "%s ALLES PERSONEN", itoa36(env.dst->no)); test_clear_messages(env.f1); give_cmd(env.src, ord); CuAssertPtrEquals(tc, 0, test_find_messagetype(env.f1->msgs, "give_person")); @@ -307,7 +305,6 @@ static void test_give(CuTest * tc) { static void test_give_cmd(CuTest * tc) { struct give env = { 0 }; struct order *ord; - char cmd[32]; test_setup_ex(tc); env.lang = test_create_locale(); @@ -316,8 +313,7 @@ static void test_give_cmd(CuTest * tc) { i_change(&env.src->items, env.itype, 10); - _snprintf(cmd, sizeof(cmd), "%s 5 %s", itoa36(env.dst->no), LOC(env.f1->locale, env.itype->rtype->_name)); - ord = create_order(K_GIVE, env.f1->locale, cmd); + ord = create_order(K_GIVE, env.f1->locale, "%s 5 %s", itoa36(env.dst->no), LOC(env.f1->locale, env.itype->rtype->_name)); assert(ord); give_cmd(env.src, ord); CuAssertIntEquals(tc, 5, i_get(env.src->items, env.itype)); @@ -330,7 +326,6 @@ static void test_give_cmd(CuTest * tc) { static void test_give_herbs(CuTest * tc) { struct give env = { 0 }; struct order *ord; - char cmd[32]; test_setup_ex(tc); test_create_world(); @@ -338,8 +333,7 @@ static void test_give_herbs(CuTest * tc) { setup_give(&env); i_change(&env.src->items, env.itype, 10); - _snprintf(cmd, sizeof(cmd), "%s %s", itoa36(env.dst->no), LOC(env.f1->locale, parameters[P_HERBS])); - ord = create_order(K_GIVE, env.f1->locale, cmd); + ord = create_order(K_GIVE, env.f1->locale, "%s %s", itoa36(env.dst->no), LOC(env.f1->locale, parameters[P_HERBS])); assert(ord); give_cmd(env.src, ord); diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index dccfbb68a..69e02c3a0 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -801,10 +801,10 @@ static void json_settings(cJSON *json) { else { char value[32]; if (child->type == cJSON_Number && child->valuedouble && child->valueintvaluedouble) { - _snprintf(value, sizeof(value), "%f", child->valuedouble); + sprintf(value, "%f", child->valuedouble); } else { - _snprintf(value, sizeof(value), "%d", child->valueint); + sprintf(value, "%d", child->valueint); } config_set(child->string, value); } diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index 752627144..1a481960d 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -140,37 +140,34 @@ static void test_scale_number(CuTest *tc) { static void test_unit_name(CuTest *tc) { unit *u; - char name[32]; test_cleanup(); test_create_world(); u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0)); + renumber_unit(u, 666); unit_setname(u, "Hodor"); - _snprintf(name, sizeof(name), "Hodor (%s)", itoa36(u->no)); - CuAssertStrEquals(tc, name, unitname(u)); + CuAssertStrEquals(tc, "Hodor (ii)", unitname(u)); test_cleanup(); } static void test_unit_name_from_race(CuTest *tc) { unit *u; - char name[32]; struct locale *lang; test_cleanup(); test_create_world(); u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0)); + renumber_unit(u, 666); unit_setname(u, NULL); lang = get_or_create_locale("de"); locale_setstring(lang, rc_name_s(u->_race, NAME_SINGULAR), "Mensch"); locale_setstring(lang, rc_name_s(u->_race, NAME_PLURAL), "Menschen"); - _snprintf(name, sizeof(name), "Mensch (%s)", itoa36(u->no)); - CuAssertStrEquals(tc, name, unitname(u)); + CuAssertStrEquals(tc, "Mensch (ii)", unitname(u)); CuAssertStrEquals(tc, "Mensch", unit_getname(u)); u->number = 2; - _snprintf(name, sizeof(name), "Menschen (%s)", itoa36(u->no)); - CuAssertStrEquals(tc, name, unitname(u)); + CuAssertStrEquals(tc, "Menschen (ii)", unitname(u)); CuAssertStrEquals(tc, "Menschen", unit_getname(u)); test_cleanup(); diff --git a/src/laws.test.c b/src/laws.test.c index 1bec0e6b4..d4753ec19 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -521,7 +521,6 @@ static void test_pay_cmd_other_building(CuTest *tc) { order *ord; faction *f; building *b; - char cmd[32]; test_setup(); setup_pay_cmd(&fix); @@ -531,8 +530,7 @@ static void test_pay_cmd_other_building(CuTest *tc) { config_set("rules.region_owner_pay_building", "lighthouse"); update_owners(b->region); - _snprintf(cmd, sizeof(cmd), "NOT %s", itoa36(b->no)); - ord = create_order(K_PAY, f->locale, cmd); + ord = create_order(K_PAY, f->locale, "NOT %s", itoa36(b->no)); assert(ord); CuAssertPtrEquals(tc, fix.u1, building_owner(b)); CuAssertIntEquals(tc, 0, pay_cmd(fix.u1, ord)); From 3ff5a3155e5a058a415a46e7b77a5143ef947d03 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Jan 2017 12:54:49 +0100 Subject: [PATCH 318/675] do not update submodules before each build. add tolua to .gitignore, it's not a proper submodule. --- .gitignore | 81 +++++++++++++++++++++++++++--------------------------- s/build | 2 -- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 24219490f..4e63f5d9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,40 +1,41 @@ -.vscode/ -*.orig -eressea.ini -Debug -Release - -# SlickEdit -*.vtg -*.vpwhistu - -# Microsoft Visual Studio build artefacts -src/Debug/ -src/Release/ -src/*.vcproj.*.user -Debug/ -Release/ -ipch/ -*.ipch -*.ncb -*.opensdf -*.pdb -*.sdf -*.suo -*.user - -*~ -*.bak -bin/ -build*/ -*.log -*.log.* -tags -Thumbs.db -.gdb_history -*.cfg -*.cmd -tmp/ -tests/config.lua -tests/reports/ -tests/data/185.dat +tolua/ +.vscode/ +*.orig +eressea.ini +Debug +Release + +# SlickEdit +*.vtg +*.vpwhistu + +# Microsoft Visual Studio build artefacts +src/Debug/ +src/Release/ +src/*.vcproj.*.user +Debug/ +Release/ +ipch/ +*.ipch +*.ncb +*.opensdf +*.pdb +*.sdf +*.suo +*.user + +*~ +*.bak +bin/ +build*/ +*.log +*.log.* +tags +Thumbs.db +.gdb_history +*.cfg +*.cmd +tmp/ +tests/config.lua +tests/reports/ +tests/data/185.dat diff --git a/s/build b/s/build index b59804626..01acc1ae2 100755 --- a/s/build +++ b/s/build @@ -33,8 +33,6 @@ if [ ! -d $ROOT/$BUILD ]; then exit fi -git submodule update - echo "build eressea" cd $ROOT/$BUILD VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//') From 8b7dae6977d643cdfc422c4e08b717e0261d33cc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Jan 2017 16:31:05 +0100 Subject: [PATCH 319/675] kill autoconf.h, replace platform.h for C99 compatibility work --- CMakeLists.txt | 50 ---------- autoconf.h.in | 36 ------- src/academy.c | 2 +- src/alchemy.c | 10 +- src/attributes/dict.c | 8 +- src/attributes/hate.c | 2 +- src/attributes/moved.c | 2 +- src/attributes/movement.c | 2 +- src/attributes/racename.c | 4 +- src/attributes/raceprefix.c | 4 +- src/battle.c | 66 ++++++------- src/battle.h | 1 + src/bind_building.c | 2 +- src/bind_dict.c | 2 +- src/bind_gmtool.c | 6 +- src/bind_monsters.c | 2 +- src/bind_region.c | 2 +- src/bind_ship.c | 2 +- src/bind_storage.c | 2 +- src/building_action.c | 10 +- src/creport.c | 8 +- src/economy.c | 64 ++++++------- src/give.c | 4 +- src/give.test.c | 6 +- src/gmtool.c | 4 +- src/guard.h | 3 + src/items.c | 2 +- src/items/artrewards.c | 2 +- src/items/demonseye.c | 4 +- src/items/speedsail.c | 4 +- src/items/weapons.c | 2 +- src/items/xerewards.c | 2 +- src/json.c | 4 +- src/kernel/alliance.c | 4 +- src/kernel/ally.c | 6 +- src/kernel/build.c | 34 +++---- src/kernel/building.c | 10 +- src/kernel/building.h | 2 + src/kernel/building.test.c | 2 +- src/kernel/config.c | 13 +-- src/kernel/config.h | 1 + src/kernel/connection.c | 68 ++++++------- src/kernel/connection.h | 2 +- src/kernel/curse.c | 20 ++-- src/kernel/curse.h | 2 + src/kernel/equipment.c | 8 +- src/kernel/faction.c | 10 +- src/kernel/faction.h | 2 + src/kernel/group.c | 4 +- src/kernel/item.c | 24 ++--- src/kernel/jsonconf.c | 12 +-- src/kernel/messages.c | 4 +- src/kernel/order.c | 2 +- src/kernel/plane.c | 2 +- src/kernel/pool.c | 10 +- src/kernel/race.c | 4 +- src/kernel/region.c | 16 ++-- src/kernel/region.h | 1 + src/kernel/resources.c | 4 +- src/kernel/save.c | 24 ++--- src/kernel/save.test.c | 8 +- src/kernel/ship.c | 10 +- src/kernel/spell.c | 2 +- src/kernel/spellbook.c | 2 +- src/kernel/terrain.c | 2 +- src/kernel/unit.c | 18 ++-- src/kernel/unit.test.c | 14 +-- src/kernel/xmlreader.c | 24 ++--- src/laws.c | 86 ++++++++--------- src/laws.h | 1 + src/laws.test.c | 2 +- src/lighthouse.c | 4 +- src/lighthouse.h | 2 + src/listbox.c | 2 +- src/magic.c | 42 ++++---- src/magic.h | 1 + src/market.test.c | 2 +- src/modules/arena.c | 14 +-- src/modules/autoseed.c | 10 +- src/modules/museum.c | 8 +- src/modules/score.c | 2 +- src/monsters.c | 16 ++-- src/morale.c | 2 +- src/move.c | 24 ++--- src/move.h | 5 +- src/names.c | 6 +- src/platform.h | 180 ++--------------------------------- src/prefix.c | 2 +- src/races/dragons.c | 2 +- src/races/races.c | 2 +- src/races/zombies.c | 8 +- src/randenc.c | 4 +- src/report.c | 80 ++++++++-------- src/report.test.c | 6 +- src/reports.c | 44 ++++----- src/skill.h | 2 +- src/spells.c | 103 ++++++++++---------- src/spells/borders.c | 8 +- src/spells/borders.h | 3 + src/spells/buildingcurse.c | 2 +- src/spells/combatspells.c | 30 +++--- src/spells/flyingship.h | 2 + src/spells/regioncurse.c | 28 +++--- src/spells/shipcurse.c | 6 +- src/spells/unitcurse.c | 16 ++-- src/spy.c | 6 +- src/sqlite.c | 4 +- src/study.c | 18 ++-- src/summary.c | 8 +- src/test_eressea.c | 2 +- src/travelthru.test.c | 2 +- src/triggers/changefaction.c | 2 +- src/triggers/changerace.c | 2 +- src/triggers/clonedied.c | 2 +- src/triggers/createcurse.c | 2 +- src/triggers/createunit.c | 2 +- src/triggers/gate.c | 2 +- src/triggers/giveitem.c | 2 +- src/triggers/killunit.c | 2 +- src/triggers/shock.c | 6 +- src/triggers/timeout.c | 2 +- src/triggers/unitmessage.c | 6 +- src/upkeep.c | 12 +-- src/util/attrib.c | 2 +- src/util/attrib.h | 2 + src/util/attrib.test.c | 2 +- src/util/crmessage.c | 10 +- src/util/event.c | 4 +- src/util/goodies.c | 2 +- src/util/language.c | 8 +- src/util/language.h | 2 +- src/util/lists.c | 2 +- src/util/log.test.c | 6 +- src/util/message.c | 2 +- src/util/nrmessage.c | 6 +- src/util/translation.c | 12 +-- src/vortex.c | 14 +-- src/vortex.h | 5 + src/wormhole.c | 2 +- 139 files changed, 698 insertions(+), 917 deletions(-) delete mode 100644 autoconf.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index d60d3d721..9b26ecb6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,56 +14,6 @@ find_package (Curses) find_package (Lua REQUIRED) find_package (ToLua REQUIRED) -INCLUDE (CheckIncludeFiles) -INCLUDE (CheckSymbolExists) -CHECK_INCLUDE_FILES (stdbool.h HAVE_STDBOOL_H) -CHECK_INCLUDE_FILES (windows.h HAVE_WINDOWS_H) -CHECK_INCLUDE_FILES (io.h HAVE_IO_H) -CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H) -CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H) -IF (HAVE_IO_H) -CHECK_SYMBOL_EXISTS (_access "io.h" HAVE__ACCESS) -ENDIF (HAVE_IO_H) -IF (HAVE_WINDOWS_H) -CHECK_SYMBOL_EXISTS (_sleep "windows.h" HAVE__SLEEP) -ENDIF(HAVE_WINDOWS_H) -IF(HAVE_STDBOOL_H) -CHECK_SYMBOL_EXISTS (_Bool "stdbool.h" HAVE__BOOL) -ENDIF(HAVE_STDBOOL_H) -IF(HAVE_UNISTD_H) -CHECK_SYMBOL_EXISTS (sleep "unistd.h" HAVE_SLEEP) -CHECK_SYMBOL_EXISTS (usleep "unistd.h" HAVE_USLEEP) -CHECK_SYMBOL_EXISTS (access "unistd.h" HAVE_ACCESS) -ENDIF(HAVE_UNISTD_H) -CHECK_SYMBOL_EXISTS (strlcpy "string.h" HAVE_STRLCPY) -CHECK_SYMBOL_EXISTS (strlcat "string.h" HAVE_STRLCAT) -CHECK_SYMBOL_EXISTS (slprintf "string.h" HAVE_SLPRINTF) -CHECK_SYMBOL_EXISTS (strcasecmp "string.h" HAVE_STRCASECMP) -CHECK_SYMBOL_EXISTS (strncasecmp "string.h" HAVE_STRNCASECMP) -CHECK_SYMBOL_EXISTS (_strlwr "string.h" HAVE__STRLWR) -CHECK_SYMBOL_EXISTS (_strcmpl "string.h" HAVE__STRCMPL) -CHECK_SYMBOL_EXISTS (_strdup "string.h" HAVE__STRDUP) -CHECK_SYMBOL_EXISTS (_stricmp "string.h" HAVE__STRICMP) -CHECK_SYMBOL_EXISTS (_memicmp "string.h" HAVE__MEMICMP) -CHECK_SYMBOL_EXISTS (strcmpl "string.h" HAVE_STRCMPL) -CHECK_SYMBOL_EXISTS (strdup "string.h" HAVE_STRDUP) -CHECK_SYMBOL_EXISTS (stricmp "string.h" HAVE_STRICMP) -CHECK_SYMBOL_EXISTS (memicmp "string.h" HAVE_MEMICMP) -CHECK_SYMBOL_EXISTS (strlwr "string.h" HAVE_STRLWR) -CHECK_SYMBOL_EXISTS (snprintf "stdio.h" HAVE_SNPRINTF) -CHECK_SYMBOL_EXISTS (_snprintf "stdio.h" HAVE__SNPRINTF) -CHECK_SYMBOL_EXISTS (mkdir "sys/stat.h" HAVE_SYS_STAT_MKDIR) -CHECK_SYMBOL_EXISTS (mkdir "direct.h" HAVE_DIRECT_MKDIR) -CHECK_SYMBOL_EXISTS (_mkdir "direct.h" HAVE_DIRECT__MKDIR) - -CONFIGURE_FILE ( - ${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in - ${CMAKE_BINARY_DIR}/include/autoconf.h) -INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include) - -## skip compiler/libc detection and force cmake autoconf: -#add_definitions(-DUSE_AUTOCONF) - add_subdirectory (cutest) add_subdirectory (cJSON) add_subdirectory (storage) diff --git a/autoconf.h.in b/autoconf.h.in deleted file mode 100644 index f3f197db1..000000000 --- a/autoconf.h.in +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#ifndef CMAKE_AUTOCONF_H -#define CMAKE_AUTOCONF_H -#cmakedefine HAVE_STDBOOL_H 1 -#cmakedefine HAVE_STRINGS_H 1 -#cmakedefine HAVE_WINDOWS_H 1 -#cmakedefine HAVE_IO_H 1 -#cmakedefine HAVE_UNISTD_H 1 -#cmakedefine HAVE__BOOL 1 -#cmakedefine HAVE_STRCASECMP 1 -#cmakedefine HAVE_STRNCASECMP 1 -#cmakedefine HAVE__STRICMP 1 -#cmakedefine HAVE_SNPRINTF 1 -#cmakedefine HAVE__SNPRINTF 1 -#cmakedefine HAVE_ACCESS 1 -#cmakedefine HAVE__ACCESS 1 -#cmakedefine HAVE_SLEEP 1 -#cmakedefine HAVE_USLEEP 1 -#cmakedefine HAVE__SLEEP 1 -#cmakedefine HAVE_STRDUP 1 -#cmakedefine HAVE__STRDUP 1 -#cmakedefine HAVE_STRICMP 1 -#cmakedefine HAVE__STRCMPL 1 -#cmakedefine HAVE_STRCMPL 1 -#cmakedefine HAVE__MEMICMP 1 -#cmakedefine HAVE_MEMICMP 1 -#cmakedefine HAVE__STRLWR 1 -#cmakedefine HAVE_STRLWR 1 -#cmakedefine HAVE_STRLCPY 1 -#cmakedefine HAVE_STRLCAT 1 -#cmakedefine HAVE_SLPRINTF 1 -#cmakedefine HAVE_SYS_STAT_MKDIR 1 -#cmakedefine HAVE_DIRECT_MKDIR 1 -#cmakedefine HAVE_DIRECT__MKDIR 1 - -#endif diff --git a/src/academy.c b/src/academy.c index f6b70873e..496c1ef8e 100644 --- a/src/academy.c +++ b/src/academy.c @@ -35,7 +35,7 @@ bool academy_can_teach(unit *teacher, unit *student, skill_t sk) { const struct building_type *btype = bt_find("academy"); if (active_building(teacher, btype) && active_building(student, btype)) { int j = study_cost(student, sk); - j = _max(50, j * 2); + j = MAX(50, j * 2); /* kann Einheit das zahlen? */ return get_pooled(student, get_resourcetype(R_SILVER), GET_DEFAULT, j) >= j; /* sonst nehmen sie nicht am Unterricht teil */ diff --git a/src/alchemy.c b/src/alchemy.c index 9bc180700..ddbe46b8e 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -73,12 +73,12 @@ void herbsearch(unit * u, int max) } if (max) - max = _min(max, rherbs(r)); + max = MIN(max, rherbs(r)); else max = rherbs(r); herbsfound = ntimespprob(effsk * u->number, (double)rherbs(r) / 100.0F, -0.01F); - herbsfound = _min(herbsfound, max); + herbsfound = MIN(herbsfound, max); rsetherbs(r, (short) (rherbs(r) - herbsfound)); if (herbsfound) { @@ -156,7 +156,7 @@ static int potion_water_of_life(unit * u, region *r, int amount) { } static int potion_healing(unit * u, int amount) { - 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); return amount; } @@ -182,7 +182,7 @@ static int potion_power(unit *u, int amount) { amount = use; } /* 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; return amount; } @@ -248,7 +248,7 @@ static void free_potiondelay(attrib * a) { static int age_potiondelay(attrib * a, void *owner) { potiondelay *pd = (potiondelay *)a->data.v; - unused_arg(owner); + UNUSED_ARG(owner); pd->amount = do_potion(pd->u, pd->r, pd->ptype, pd->amount); return AT_AGE_REMOVE; } diff --git a/src/attributes/dict.c b/src/attributes/dict.c index 2bba9ea7b..a3f034145 100644 --- a/src/attributes/dict.c +++ b/src/attributes/dict.c @@ -103,7 +103,7 @@ static int dict_read(attrib * a, void *owner, gamedata *data) float flt; READ_STR(store, name, sizeof(name)); - dd->name = _strdup(name); + dd->name = strdup(name); READ_INT(store, &n); dd->type = (dict_type)n; switch (dd->type) { @@ -122,7 +122,7 @@ static int dict_read(attrib * a, void *owner, gamedata *data) break; case TSTRING: READ_STR(store, name, sizeof(name)); - dd->data.str = _strdup(name); + dd->data.str = strdup(name); break; case TBUILDING: result = @@ -199,7 +199,7 @@ struct attrib *dict_create(const char *name, dict_type type, variant value) { attrib *a = a_new(&at_dict); dict_data *data = (dict_data *)a->data.v; - data->name = _strdup(name); + data->name = strdup(name); dict_set(a, type, value); return a; @@ -214,7 +214,7 @@ void dict_set(attrib * a, dict_type type, variant value) data->type = type; switch (type) { case TSTRING: - data->data.str = value.v ? _strdup(value.v) : NULL; + data->data.str = value.v ? strdup(value.v) : NULL; break; case TINTEGER: data->data.i = value.i; diff --git a/src/attributes/hate.c b/src/attributes/hate.c index 98a36a029..17155fc71 100644 --- a/src/attributes/hate.c +++ b/src/attributes/hate.c @@ -30,7 +30,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static int verify_hate(attrib * a, void *owner) { - unused_arg(owner); + UNUSED_ARG(owner); if (a->data.v == NULL) { return 0; } diff --git a/src/attributes/moved.c b/src/attributes/moved.c index 3da2a4c3b..c66a5489c 100644 --- a/src/attributes/moved.c +++ b/src/attributes/moved.c @@ -27,7 +27,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static int age_moved(attrib * a, void *owner) { - unused_arg(owner); + UNUSED_ARG(owner); --a->data.i; return a->data.i > 0; } diff --git a/src/attributes/movement.c b/src/attributes/movement.c index 874da5eb3..4d79039ef 100644 --- a/src/attributes/movement.c +++ b/src/attributes/movement.c @@ -67,7 +67,7 @@ void set_movement(attrib ** alist, int type) static int age_speedup(attrib * a, void *owner) { - unused_arg(owner); + UNUSED_ARG(owner); if (a->data.sa[0] > 0) { assert(a->data.sa[0] - a->data.sa[1] >= SHRT_MIN); assert(a->data.sa[0] - a->data.sa[1] <= SHRT_MAX); diff --git a/src/attributes/racename.c b/src/attributes/racename.c index b408cbf6a..c45fa3815 100644 --- a/src/attributes/racename.c +++ b/src/attributes/racename.c @@ -43,7 +43,7 @@ void set_racename(attrib ** palist, const char *name) attrib *a = a_find(*palist, &at_racename); if (!a && name) { a = a_add(palist, a_new(&at_racename)); - a->data.v = _strdup(name); + a->data.v = strdup(name); } else if (a && !name) { a_remove(palist, a); @@ -51,7 +51,7 @@ void set_racename(attrib ** palist, const char *name) else if (a) { if (strcmp(a->data.v, name) != 0) { free(a->data.v); - a->data.v = _strdup(name); + a->data.v = strdup(name); } } } diff --git a/src/attributes/raceprefix.c b/src/attributes/raceprefix.c index 15f0036c1..a87edfb80 100644 --- a/src/attributes/raceprefix.c +++ b/src/attributes/raceprefix.c @@ -41,7 +41,7 @@ void set_prefix(attrib ** ap, const char *str) free(a->data.v); } assert(a->type == &at_raceprefix); - a->data.v = _strdup(str); + a->data.v = strdup(str); } const char *get_prefix(attrib * a) @@ -53,7 +53,7 @@ const char *get_prefix(attrib * a) str = (char *)a->data.v; /* conversion of old prefixes */ if (strncmp(str, "prefix_", 7) == 0) { - ((attrib *)a)->data.v = _strdup(str + 7); + ((attrib *)a)->data.v = strdup(str + 7); free(str); str = (char *)a->data.v; } diff --git a/src/battle.c b/src/battle.c index ed83871ec..3b34cd162 100644 --- a/src/battle.c +++ b/src/battle.c @@ -440,7 +440,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; } @@ -600,12 +600,12 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking) if (u_race(u) == get_race(RC_ORC)) { int sword = effskill(u, SK_MELEE, 0); int spear = effskill(u, SK_SPEAR, 0); - 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 { @@ -685,7 +685,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type) /* only half against trolls */ if (skl > 0) { if (type == BONUS_SKILL) { - int dmg = _min(skl, 8); + int dmg = MIN(skl, 8); if (u_race(enemy.fighter->unit) == get_race(RC_TROLL)) { dmg = dmg / 4; } @@ -696,7 +696,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type) } else { skl = skl / 2; - return _min(skl, 4); + return MIN(skl, 4); } } } @@ -1008,7 +1008,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); } } } @@ -1203,15 +1203,15 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) /* TODO not sure if res could be > 1 here */ if (magic) { - da = (int)(_max(da * res, 0)); + da = (int)(MAX(da * res, 0)); } if (type != AT_COMBATSPELL && type != AT_SPELL) { if (rule_damage & 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) { @@ -1238,11 +1238,11 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) /* Skilldifferenzbonus */ if (rule_damage & DAMAGE_SKILL_BONUS) { - da += _max(0, (sk - sd) / DAMAGE_QUOTIENT); + da += MAX(0, (sk - sd) / DAMAGE_QUOTIENT); } } - rda = _max(da - ar, 0); + rda = MAX(da - ar, 0); if ((u_race(du)->battle_flags & BF_INV_NONMAGIC) && !magic) rda = 0; @@ -1275,7 +1275,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--; } } @@ -1474,7 +1474,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); @@ -1574,7 +1574,7 @@ static troop select_opponent(battle * b, troop at, int mindist, int maxdist) 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); } @@ -1735,7 +1735,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); @@ -1822,7 +1822,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); @@ -2056,7 +2056,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. */ @@ -2332,7 +2332,7 @@ void do_regenerate(fighter * af) while (ta.index--) { struct person *p = af->person + ta.index; p->hp += effskill(au, SK_STAMINA, 0); - p->hp = _min(unit_max_hp(au), p->hp); + p->hp = MIN(unit_max_hp(au), p->hp); } } @@ -2391,10 +2391,10 @@ double fleechance(unit * u) if (u_race(u) == get_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) @@ -2518,7 +2518,7 @@ static void loot_items(fighter * corpse) float lootfactor = (float)dead / (float)u->number; /* only loot the dead! */ int maxloot = (int)((float)itm->number * lootfactor); if (maxloot > 0) { - int i = _min(10, maxloot); + int i = MIN(10, maxloot); for (; i != 0; --i) { int loot = maxloot / i; @@ -2599,7 +2599,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); add_chaoscount(r, dead_peasants / 2); @@ -3092,7 +3092,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); } } @@ -3258,7 +3258,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, trollbelts(u)); + strongmen = MIN(fig->unit->number, trollbelts(u)); /* Hitpoints, Attack- und Defence-Boni f�r alle Personen */ for (i = 0; i < fig->alive; i++) { @@ -3448,7 +3448,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; } @@ -3519,11 +3519,11 @@ static const char *simplename(region * r) const char *cp = rname(r, default_locale); for (i = 0; *cp && i != 16; ++i, ++cp) { int c = *(unsigned char *)cp; - while (c && !isalpha(c) && !isxspace(c)) { + while (c && !isalpha(c) && !isspace(c)) { ++cp; c = *(unsigned char *)cp; } - if (isxspace(c)) + if (isspace(c)) name[i] = '_'; else name[i] = *cp; @@ -3546,10 +3546,10 @@ battle *make_battle(region * r) bld->sizeleft = bld->size; if (battledebug) { - char zText[MAX_PATH]; - char zFilename[MAX_PATH]; + char zText[4096]; + char zFilename[4096]; join_path(basepath(), "battles", zText, sizeof(zText)); - if (_mkdir(zText) != 0) { + if (mkdir(zText, 0777) != 0) { log_error("could not create subdirectory for battle logs: %s", zText); battledebug = false; } @@ -4104,7 +4104,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 */ @@ -4147,7 +4147,7 @@ static void battle_flee(battle * b) if (fig->person[dt.index].flags & FL_PANICED) { ispaniced = EFFECT_PANIC_SPELL; } - if (chance(_min(fleechance(u) + ispaniced, 0.90))) { + if (chance(MIN(fleechance(u) + ispaniced, 0.90))) { ++runners; flee(dt); } diff --git a/src/battle.h b/src/battle.h index 007bda008..060906958 100644 --- a/src/battle.h +++ b/src/battle.h @@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define H_KRNL_BATTLE #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/bind_building.c b/src/bind_building.c index 3724d4db5..f8cf4e6df 100644 --- a/src/bind_building.c +++ b/src/bind_building.c @@ -92,7 +92,7 @@ static int tolua_building_set_info(lua_State * L) const char *info = tolua_tostring(L, 2, 0); free(self->display); if (info) - self->display = _strdup(info); + self->display = strdup(info); else self->display = NULL; return 0; diff --git a/src/bind_dict.c b/src/bind_dict.c index 32d3c498d..40f73690f 100644 --- a/src/bind_dict.c +++ b/src/bind_dict.c @@ -106,7 +106,7 @@ static int tolua_dict_set_string(lua_State * L) attrib *a = a_find(*self, &at_dict); variant val; - val.v = _strdup(value); + val.v = strdup(value); for (; a && a->type == &at_dict; a = a->next) { if (strcmp(dict_name(a), name) == 0) { diff --git a/src/bind_gmtool.c b/src/bind_gmtool.c index 3c07bb3b7..e4ae939f9 100644 --- a/src/bind_gmtool.c +++ b/src/bind_gmtool.c @@ -133,14 +133,14 @@ static int tolua_selected_regions(lua_State * L) static int tolua_state_open(lua_State * L) { - unused_arg(L); + UNUSED_ARG(L); state_open(); return 0; } static int tolua_state_close(lua_State * L) { - unused_arg(L); + UNUSED_ARG(L); state_close(current_state); return 0; } @@ -188,7 +188,7 @@ static void lua_paint_info(struct window *wnd, const struct state *st) break; else { size_t len = end - str; - int bytes = _min((int)len, size); + int bytes = MIN((int)len, size); mvwaddnstr(win, line++, 1, str, bytes); wclrtoeol(win); str = end + 1; diff --git a/src/bind_monsters.c b/src/bind_monsters.c index d7a3daab2..bd0ef39e3 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -74,7 +74,7 @@ static int fix_familiars(struct lua_State *L) free(mage->spellbook); mage->spellbook = 0; - _snprintf(buffer, sizeof(buffer), "%s_familiar", u_race(u)->_name); + snprintf(buffer, sizeof(buffer), "%s_familiar", u_race(u)->_name); eq = get_equipment(buffer); if (eq) { equip_unit_mask(u, eq, EQUIP_SPELLS); diff --git a/src/bind_region.c b/src/bind_region.c index 1296e4a65..2e328dc96 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -615,7 +615,7 @@ static int tolua_plane_set_name(lua_State * L) const char *str = tolua_tostring(L, 2, 0); free(self->name); if (str) - self->name = _strdup(str); + self->name = strdup(str); else self->name = 0; return 0; diff --git a/src/bind_ship.c b/src/bind_ship.c index f1c1c412a..95006cf5f 100644 --- a/src/bind_ship.c +++ b/src/bind_ship.c @@ -94,7 +94,7 @@ static int tolua_ship_set_display(lua_State * L) { ship *self = (ship *)tolua_tousertype(L, 1, 0); free(self->display); - self->display = _strdup(tolua_tostring(L, 2, 0)); + self->display = strdup(tolua_tostring(L, 2, 0)); return 0; } diff --git a/src/bind_storage.c b/src/bind_storage.c index a81a3baeb..d2b66f03d 100644 --- a/src/bind_storage.c +++ b/src/bind_storage.c @@ -100,7 +100,7 @@ static int tolua_storage_tostring(lua_State * L) { gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0); char name[64]; - _snprintf(name, sizeof(name), "", (void *)data, data->version); + snprintf(name, sizeof(name), "", (void *)data, data->version); lua_pushstring(L, name); return 1; } diff --git a/src/building_action.c b/src/building_action.c index 5c533f4d0..f72af4412 100644 --- a/src/building_action.c +++ b/src/building_action.c @@ -93,7 +93,7 @@ lc_write(const struct attrib *a, const void *owner, struct storage *store) const char *fname = data->fname; const char *fparam = data->param; - unused_arg(owner); + UNUSED_ARG(owner); WRITE_TOK(store, fname); WRITE_TOK(store, fparam ? fparam : NULLSTRING); } @@ -116,7 +116,7 @@ static int lc_read(struct attrib *a, void *owner, gamedata *data) b = 0; } else { - bd->fname = _strdup(name); + bd->fname = strdup(name); } READ_TOK(store, name, sizeof(name)); if (strcmp(name, "tnnL") == 0) { @@ -127,7 +127,7 @@ static int lc_read(struct attrib *a, void *owner, gamedata *data) if (strcmp(name, NULLSTRING) == 0) bd->param = 0; else { - bd->param = _strdup(name); + bd->param = strdup(name); } if (result == 0 && !b) { return AT_READ_FAIL; @@ -146,8 +146,8 @@ void building_addaction(building * b, const char *fname, const char *param) { attrib *a = a_add(&b->attribs, a_new(&at_building_action)); building_action *data = (building_action *)a->data.v; - data->fname = _strdup(fname); + data->fname = strdup(fname); if (param) { - data->param = _strdup(param); + data->param = strdup(param); } } diff --git a/src/creport.c b/src/creport.c index eeb2a1202..bd9c97ec6 100644 --- a/src/creport.c +++ b/src/creport.c @@ -125,7 +125,7 @@ static const char *translate(const char *key, const char *value) } else t = malloc(sizeof(translation)); - t->key = _strdup(key); + t->key = strdup(key); t->value = value; t->next = translation_table[kk]; translation_table[kk] = t; @@ -361,7 +361,7 @@ static int cr_race(variant var, char *buffer, const void *userdata) static int cr_alliance(variant var, char *buffer, const void *userdata) { const alliance *al = (const alliance *)var.v; - unused_arg(userdata); + UNUSED_ARG(userdata); if (al != NULL) { sprintf(buffer, "%d", al->id); } @@ -372,7 +372,7 @@ static int cr_skill(variant var, char *buffer, const void *userdata) { const faction *report = (const faction *)userdata; skill_t sk = (skill_t)var.i; - unused_arg(userdata); + UNUSED_ARG(userdata); if (sk != NOSKILL) sprintf(buffer, "\"%s\"", translate(mkname("skill", skillnames[sk]), skillname(sk, @@ -385,7 +385,7 @@ static int cr_skill(variant var, char *buffer, const void *userdata) static int cr_order(variant var, char *buffer, const void *userdata) { order *ord = (order *)var.v; - unused_arg(userdata); + UNUSED_ARG(userdata); if (ord != NULL) { char cmd[ORDERSIZE]; char *wp = buffer; diff --git a/src/economy.c b/src/economy.c index 01954ff54..7edbbcb12 100644 --- a/src/economy.c +++ b/src/economy.c @@ -337,11 +337,11 @@ static int do_recruiting(recruitment * recruits, int available) int number, dec; double multi = 2.0 * 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, get_resourcetype(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", @@ -551,7 +551,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders) if (recruitcost > 0) { int pooled = get_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT, recruitcost * n); - n = _min(n, pooled / recruitcost); + n = MIN(n, pooled / recruitcost); } u->wants = n; @@ -990,12 +990,12 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) rring = get_resourcetype(R_RING_OF_NIMBLEFINGER); if (rring) { int dm = i_get(u->items, rring->itype); - amount += skill * _min(u->number, dm) * (roqf_factor() - 1); + amount += skill * MIN(u->number, dm) * (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 */ } @@ -1091,7 +1091,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) @@ -1106,7 +1106,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) { @@ -1139,7 +1139,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); @@ -1149,7 +1149,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) @@ -1625,7 +1625,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); @@ -1936,7 +1936,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) /* Ein Hndler kann nur 10 Gter pro Talentpunkt verkaufen. */ - n = _min(n, u->number * 10 * effskill(u, SK_TRADE, 0)); + n = MIN(n, u->number * 10 * effskill(u, SK_TRADE, 0)); if (!n) { cmistake(u, ord, 54, MSG_COMMERCE); @@ -1966,11 +1966,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); @@ -1995,7 +1995,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 Gter merken */ a->data.i += n; @@ -2052,7 +2052,7 @@ static void expandstealing(region * r, request * stealorders) n = 10; } if (n > 0) { - n = _min(n, g_requests[j].unit->wants); + n = MIN(n, g_requests[j].unit->wants); use_pooled(u, rsilver, GET_ALL, n); g_requests[j].unit->n = n; change_money(g_requests[j].unit, n); @@ -2106,8 +2106,8 @@ static void plant(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); /* Fr jedes Kraut Talent*10% Erfolgschance. */ for (i = n; i > 0; i--) { if (rng_int() % 10 < skill) @@ -2152,14 +2152,14 @@ static void planttrees(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); /* Fr jeden Samen Talent*10% Erfolgschance. */ for (i = n; i > 0; i--) { @@ -2209,7 +2209,7 @@ static void breedtrees(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 prfen */ if (n == 0) { @@ -2217,7 +2217,7 @@ static void breedtrees(unit * u, int raw) msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype)); return; } - n = _min(raw, n); + n = MIN(raw, n); /* Fr jeden Samen Talent*5% Erfolgschance. */ for (i = n; i > 0; i--) { @@ -2259,7 +2259,7 @@ static void breedhorses(unit * u) } effsk = effskill(u, SK_HORSE_TRAINING, 0); n = u->number * effsk; - n = _min(n, horses); + n = MIN(n, horses); for (c = 0; c < n; c++) { if (rng_int() % 100 < effsk) { @@ -2508,7 +2508,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders) } } - i = _min(u->number, i_get(u->items, rring->itype)); + i = MIN(u->number, i_get(u->items, rring->itype)); if (i > 0) { n *= STEALINCOME * (u->number + i * (roqf_factor() - 1)); } @@ -2530,7 +2530,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)); } /* ------------------------------------------------------------- */ @@ -2554,7 +2554,7 @@ static void expandentertainment(region * r) entertaining -= o->qty; /* Nur soviel PRODUCEEXP wie auch tatschlich 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); } @@ -2605,7 +2605,7 @@ void entertain_cmd(unit * u, struct order *ord) 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; @@ -2665,7 +2665,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork) if (blessedharvest_ct) { int happy = (int)curse_geteffect(get_curse(r->attribs, blessedharvest_ct)); - happy = _min(happy, jobs); + happy = MIN(happy, jobs); earnings += happy; } } @@ -2819,10 +2819,10 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders) 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 * effskill(u, SK_TAXING, 0) * taxperlevel, max); + u->wants = MIN(n * effskill(u, SK_TAXING, 0) * taxperlevel, max); } u2 = is_guarded(r, u); @@ -2893,12 +2893,12 @@ void loot_cmd(unit * u, struct order *ord, request ** lootorders) max = INT_MAX; } if (!playerrace(u_race(u))) { - u->wants = _min(income(u), max); + u->wants = MIN(income(u), max); } else { /* For player start with 20 Silver +10 every 5 level of close combat skill*/ - int skbonus = (_max(effskill(u, SK_MELEE, 0), effskill(u, SK_SPEAR, 0)) * 2 / 10) + 2; - u->wants = _min(n * skbonus * 10, max); + int skbonus = (MAX(effskill(u, SK_MELEE, 0), effskill(u, SK_SPEAR, 0)) * 2 / 10) + 2; + u->wants = MIN(n * skbonus * 10, max); } o = (request *)calloc(1, sizeof(request)); diff --git a/src/give.c b/src/give.c index 524a27017..4f8417bf2 100644 --- a/src/give.c +++ b/src/give.c @@ -156,7 +156,7 @@ struct order *ord) assert(itype != NULL); n = get_pooled(src, item2resource(itype), GET_SLACK | GET_POOLED_SLACK, want); - n = _min(want, n); + n = MIN(want, n); r = n; if (dest && src->faction != dest->faction && src->faction->age < GiveRestriction()) { @@ -772,7 +772,7 @@ void give_cmd(unit * u, order * ord) msg_feedback(u, ord, "race_noregroup", "race", u_race(u))); return; } - n = _min(u->number, n); + n = MIN(u->number, n); msg = u2 ? give_men(n, u, u2, ord) : disband_men(n, u, ord); if (msg) { ADDMSG(&u->faction->msgs, msg); diff --git a/src/give.test.c b/src/give.test.c index f2b0d60a9..b6c845450 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -244,7 +244,7 @@ static void test_give_men_requires_contact(CuTest * tc) { CuAssertIntEquals(tc, 1, env.dst->number); CuAssertIntEquals(tc, 1, env.src->number); - _snprintf(cmd, sizeof(cmd), "%s ALLES PERSONEN", itoa36(env.dst->no)); + snprintf(cmd, sizeof(cmd), "%s ALLES PERSONEN", itoa36(env.dst->no)); ord = create_order(K_GIVE, env.f1->locale, cmd); test_clear_messages(env.f1); give_cmd(env.src, ord); @@ -316,7 +316,7 @@ static void test_give_cmd(CuTest * tc) { i_change(&env.src->items, env.itype, 10); - _snprintf(cmd, sizeof(cmd), "%s 5 %s", itoa36(env.dst->no), LOC(env.f1->locale, env.itype->rtype->_name)); + snprintf(cmd, sizeof(cmd), "%s 5 %s", itoa36(env.dst->no), LOC(env.f1->locale, env.itype->rtype->_name)); ord = create_order(K_GIVE, env.f1->locale, cmd); assert(ord); give_cmd(env.src, ord); @@ -338,7 +338,7 @@ static void test_give_herbs(CuTest * tc) { setup_give(&env); i_change(&env.src->items, env.itype, 10); - _snprintf(cmd, sizeof(cmd), "%s %s", itoa36(env.dst->no), LOC(env.f1->locale, parameters[P_HERBS])); + snprintf(cmd, sizeof(cmd), "%s %s", itoa36(env.dst->no), LOC(env.f1->locale, parameters[P_HERBS])); ord = create_order(K_GIVE, env.f1->locale, cmd); assert(ord); diff --git a/src/gmtool.c b/src/gmtool.c index 7aab2fea7..a8881abd9 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -427,7 +427,7 @@ static void paint_info_region(window * wnd, const state * st) int line = 0, maxline = getmaxy(win) - 2; map_region *mr = cursor_region(&st->display, &st->cursor); - unused_arg(st); + UNUSED_ARG(st); werase(win); wxborder(win); if (mr && mr->r) { @@ -1398,7 +1398,7 @@ int curses_readline(struct lua_State *L, char *buffer, size_t size, const char *prompt) { - unused_arg(L); + UNUSED_ARG(L); askstring(hstatus, prompt, buffer, size); return buffer[0] != 0; } diff --git a/src/guard.h b/src/guard.h index 4fb6cbf56..101369f40 100644 --- a/src/guard.h +++ b/src/guard.h @@ -2,6 +2,9 @@ #ifndef H_GUARD #define H_GUARD + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/items.c b/src/items.c index 6fbf957b3..6e995edaa 100644 --- a/src/items.c +++ b/src/items.c @@ -122,7 +122,7 @@ struct order *ord) double force; spell *sp = find_spell("antimagiczone"); attrib **ap = &r->attribs; - unused_arg(ord); + UNUSED_ARG(ord); assert(sp); /* Reduziert die Strke jedes Spruchs um effect */ diff --git a/src/items/artrewards.c b/src/items/artrewards.c index 602841d23..23ab2119e 100644 --- a/src/items/artrewards.c +++ b/src/items/artrewards.c @@ -45,7 +45,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static int age_peaceimmune(attrib * a, void *owner) { - unused_arg(owner); + UNUSED_ARG(owner); return (--a->data.i > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } diff --git a/src/items/demonseye.c b/src/items/demonseye.c index ffc1c5179..563a16047 100644 --- a/src/items/demonseye.c +++ b/src/items/demonseye.c @@ -38,8 +38,8 @@ summon_igjarjuk(struct unit *u, const struct item_type *itype, int amount, struct order *ord) { struct plane *p = rplane(u->region); - unused_arg(amount); - unused_arg(itype); + UNUSED_ARG(amount); + UNUSED_ARG(itype); if (p != NULL) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", "")); return EUNUSABLE; diff --git a/src/items/speedsail.c b/src/items/speedsail.c index 8bdaa41ab..cb40e9a8c 100644 --- a/src/items/speedsail.c +++ b/src/items/speedsail.c @@ -42,8 +42,8 @@ use_speedsail(struct unit *u, const struct item_type *itype, int amount, struct order *ord) { struct plane *p = rplane(u->region); - unused_arg(amount); - unused_arg(itype); + UNUSED_ARG(amount); + UNUSED_ARG(itype); if (p != NULL) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", "")); } diff --git a/src/items/weapons.c b/src/items/weapons.c index 1806e61a0..a23110a81 100644 --- a/src/items/weapons.c +++ b/src/items/weapons.c @@ -106,7 +106,7 @@ int *casualties) } enemies = count_enemies(b, af, FIGHT_ROW, FIGHT_ROW, SELECT_ADVANCE); - enemies = _min(enemies, CATAPULT_ATTACKS); + enemies = MIN(enemies, CATAPULT_ATTACKS); if (enemies == 0) { return true; /* allow further attacks */ } diff --git a/src/items/xerewards.c b/src/items/xerewards.c index ab5226a32..a6d1ad2ea 100644 --- a/src/items/xerewards.c +++ b/src/items/xerewards.c @@ -72,7 +72,7 @@ struct order *ord) } for (i = 0; i != amount; ++i) { - sp += _max(25, max_spellpoints(u->region, u) / 2); + sp += MAX(25, max_spellpoints(u->region, u) / 2); change_spellpoints(u, sp); } diff --git a/src/json.c b/src/json.c index 10322fe3f..0a78a3fa9 100644 --- a/src/json.c +++ b/src/json.c @@ -73,7 +73,7 @@ int json_export(stream * out, int flags) { cJSON_AddItemToObject(root, "planes", json = cJSON_CreateObject()); for (p = planes; p; p = p->next) { cJSON *data; - _snprintf(id, sizeof(id), "%d", p->id); + snprintf(id, sizeof(id), "%d", p->id); cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); cJSON_AddNumberToObject(data, "x", p->minx); cJSON_AddNumberToObject(data, "y", p->miny); @@ -85,7 +85,7 @@ int json_export(stream * out, int flags) { cJSON_AddItemToObject(root, "regions", json = cJSON_CreateObject()); for (r = regions; r; r = r->next) { cJSON *data; - _snprintf(id, sizeof(id), "%d", r->uid); + snprintf(id, sizeof(id), "%d", r->uid); cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); cJSON_AddNumberToObject(data, "x", r->x); cJSON_AddNumberToObject(data, "y", r->y); diff --git a/src/kernel/alliance.c b/src/kernel/alliance.c index 36d054323..b53c46dc7 100644 --- a/src/kernel/alliance.c +++ b/src/kernel/alliance.c @@ -82,7 +82,7 @@ alliance *new_alliance(int id, const char *name) { al = calloc(1, sizeof(alliance)); al->id = id; if (name) { - al->name = _strdup(name); + al->name = strdup(name); } else { al->flags |= ALF_NON_ALLIED; @@ -446,7 +446,7 @@ void alliance_setname(alliance * self, const char *name) { free(self->name); if (name) - self->name = _strdup(name); + self->name = strdup(name); else self->name = NULL; } diff --git a/src/kernel/ally.c b/src/kernel/ally.c index 5a5a5b1c3..759d556f4 100644 --- a/src/kernel/ally.c +++ b/src/kernel/ally.c @@ -76,7 +76,7 @@ int AllianceAuto(void) const char *str = config_get("alliance.auto"); value = 0; if (str != NULL) { - char *sstr = _strdup(str); + char *sstr = strdup(str); char *tok = strtok(sstr, " "); while (tok) { value |= ally_flag(tok, -1); @@ -136,7 +136,7 @@ int HelpMask(void) if (config_changed(&config)) { const char *str = config_get("rules.help.mask"); if (str != NULL) { - char *sstr = _strdup(str); + char *sstr = strdup(str); char *tok = strtok(sstr, " "); while (tok) { rule |= ally_flag(tok, -1); @@ -156,7 +156,7 @@ static int AllianceRestricted(void) const char *str = config_get("alliance.restricted"); int rule = 0; if (str != NULL) { - char *sstr = _strdup(str); + char *sstr = strdup(str); char *tok = strtok(sstr, " "); while (tok) { rule |= ally_flag(tok, -1); diff --git a/src/kernel/build.c b/src/kernel/build.c index b5a1b3417..dff51cf6c 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -123,11 +123,11 @@ static void destroy_road(unit * u, int nmax, struct order *ord) } road = rroad(r, d); - n = _min(n, road); + n = MIN(n, road); if (n != 0) { region *r2 = rconnect(r, d); int willdo = effskill(u, SK_ROAD_BUILDING, 0) * u->number; - willdo = _min(willdo, n); + willdo = MIN(willdo, n); if (willdo == 0) { /* TODO: error message */ } @@ -327,7 +327,7 @@ void build_road(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) == get_race(RC_STONEGOLEM)) { n = u->number * GOLEM_STONE; @@ -339,7 +339,7 @@ void build_road(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 * effsk; @@ -347,7 +347,7 @@ void build_road(unit * u, int size, direction_t d) const resource_type *ring = get_resourcetype(R_RING_OF_NIMBLEFINGER); item *itm = ring ? *i_find(&u->items, ring->itype) : 0; 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; } } @@ -355,15 +355,15 @@ void build_road(unit * u, int size, direction_t d) int dm = get_effect(u, oldpotiontype[P_DOMORE]); if (dm != 0) { int todo = (left - n + effsk - 1) / effsk; - 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 * effsk; } /* 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 @@ -380,7 +380,7 @@ void build_road(unit * u, int size, direction_t d) else { use_pooled(u, get_resourcetype(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)); @@ -486,7 +486,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; } @@ -545,7 +545,7 @@ int build(unit * u, const construction * ctype, int completed, int want) item *itm = ring ? *i_find(&u->items, ring->itype) : 0; int i = itm ? itm->number : 0; 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; } } @@ -553,7 +553,7 @@ int build(unit * u, const construction * ctype, int completed, int want) if (want < n) n = want; if (type->maxsize > 0) { - n = _min(type->maxsize - completed, n); + n = MIN(type->maxsize - completed, n); if (type->improvement == NULL) { want = n; } @@ -626,7 +626,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; } @@ -671,7 +671,7 @@ int maxbuild(const unit * u, const construction * cons) return 0; } else - maximum = _min(maximum, have / need); + maximum = MIN(maximum, have / need); } return maximum; } @@ -879,7 +879,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; @@ -923,7 +923,7 @@ order * ord) return; } if (want > 0) - want = _min(want, msize); + want = MIN(want, msize); else want = msize; @@ -982,7 +982,7 @@ void continue_ship(unit * u, int want) return; } if (want > 0) - want = _min(want, msize); + want = MIN(want, msize); else want = msize; diff --git a/src/kernel/building.c b/src/kernel/building.c index 8d76df030..fa7fe8688 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -127,7 +127,7 @@ building_type *bt_get_or_create(const char *name) building_type *btype = bt_find_i(name); if (btype == NULL) { btype = calloc(sizeof(building_type), 1); - btype->_name = _strdup(name); + btype->_name = strdup(name); btype->auraregen = 1.0; btype->maxsize = -1; btype->capacity = 1; @@ -143,7 +143,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; } @@ -420,7 +420,7 @@ building *new_building(const struct building_type * btype, region * r, } assert(bname); slprintf(buffer, sizeof(buffer), "%s %s", bname, itoa36(b->no)); - b->name = _strdup(bname); + b->name = strdup(bname); return b; } @@ -619,7 +619,7 @@ void building_setname(building * self, const char *name) { free(self->name); if (name) - self->name = _strdup(name); + self->name = strdup(name); else self->name = NULL; } @@ -779,7 +779,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn) /* Godcurse: Income -10 */ ctype = ct_find("godcursezone"); if (ctype && curse_active(get_curse(r->attribs, ctype))) { - wage = _max(0, wage - 10); + wage = MAX(0, wage - 10); } /* Bei einer D�rre verdient man nur noch ein Viertel */ diff --git a/src/kernel/building.h b/src/kernel/building.h index 92b006b98..235c2d806 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -23,6 +23,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index d15c82c8e..3b296a6fe 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -22,7 +22,7 @@ static void test_register_building(CuTest * tc) test_cleanup(); btype = (building_type *)calloc(sizeof(building_type), 1); - btype->_name = _strdup("herp"); + btype->_name = strdup("herp"); CuAssertIntEquals(tc, true, bt_changed(&cache)); CuAssertIntEquals(tc, false, bt_changed(&cache)); bt_register(btype); diff --git a/src/kernel/config.c b/src/kernel/config.c index f33303ead..1f3cd92b2 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -92,6 +92,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include struct settings global = { "Eressea", /* gamename */ @@ -362,7 +363,7 @@ void init_locale(struct locale *lang) str = "gwyrrd illaun draig cerddor tybied"; } - sstr = _strdup(str); + sstr = strdup(str); tok = strtok(sstr, " "); while (tok) { const char *name; @@ -473,7 +474,7 @@ int check_param(const struct param *p, const char *key, const char *searchvalue) if (!value) { return 0; } - char *p_value = _strdup(value); + char *p_value = strdup(value); const char *delimiter = " ,;"; char *v = strtok(p_value, delimiter); @@ -536,7 +537,7 @@ static const char * relpath(char *buf, size_t sz, const char *path) { static const char *g_datadir; const char *datapath(void) { - static char zText[MAX_PATH]; + static char zText[4096]; if (g_datadir) return g_datadir; return relpath(zText, sizeof(zText), "data"); @@ -550,7 +551,7 @@ void set_datapath(const char *path) static const char *g_reportdir; const char *reportpath(void) { - static char zText[MAX_PATH]; + static char zText[4096]; if (g_reportdir) return g_reportdir; return relpath(zText, sizeof(zText), "reports"); @@ -563,12 +564,12 @@ void set_reportpath(const char *path) int create_directories(void) { int err; - err = _mkdir(datapath()); + err = mkdir(datapath(), 0777); if (err) { if (errno == EEXIST) errno = 0; else return err; } - err = _mkdir(reportpath()); + err = mkdir(reportpath(), 0777); if (err && errno == EEXIST) { errno = 0; } diff --git a/src/kernel/config.h b/src/kernel/config.h index 91d5d576f..096d54da4 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -25,6 +25,7 @@ extern "C" { /* this should always be the first thing included after platform.h */ #include +#include #include "types.h" struct param; diff --git a/src/kernel/connection.c b/src/kernel/connection.c index 6eccf1f0c..405b013ee 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -131,7 +131,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; @@ -258,31 +258,31 @@ void b_write(const connection * b, storage * store) bool b_transparent(const connection * b, const struct faction *f) { - unused_arg(b); - unused_arg(f); + UNUSED_ARG(b); + UNUSED_ARG(f); return true; } bool b_opaque(const connection * b, const struct faction * f) { - unused_arg(b); - unused_arg(f); + UNUSED_ARG(b); + UNUSED_ARG(f); return false; } bool b_blockall(const connection * b, const unit * u, const region * r) { - unused_arg(u); - unused_arg(r); - unused_arg(b); + UNUSED_ARG(u); + UNUSED_ARG(r); + UNUSED_ARG(b); return true; } bool b_blocknone(const connection * b, const unit * u, const region * r) { - unused_arg(u); - unused_arg(r); - unused_arg(b); + UNUSED_ARG(u); + UNUSED_ARG(r); + UNUSED_ARG(b); return false; } @@ -294,39 +294,39 @@ bool b_rvisible(const connection * b, const region * r) bool b_fvisible(const connection * b, const struct faction * f, const region * r) { - unused_arg(r); - unused_arg(f); - unused_arg(b); + UNUSED_ARG(r); + UNUSED_ARG(f); + UNUSED_ARG(b); return true; } bool b_uvisible(const connection * b, const unit * u) { - unused_arg(u); - unused_arg(b); + UNUSED_ARG(u); + UNUSED_ARG(b); return true; } bool b_rinvisible(const connection * b, const region * r) { - unused_arg(r); - unused_arg(b); + UNUSED_ARG(r); + UNUSED_ARG(b); return false; } bool b_finvisible(const connection * b, const struct faction * f, const region * r) { - unused_arg(r); - unused_arg(f); - unused_arg(b); + UNUSED_ARG(r); + UNUSED_ARG(f); + UNUSED_ARG(b); return false; } bool b_uinvisible(const connection * b, const unit * u) { - unused_arg(u); - unused_arg(b); + UNUSED_ARG(u); + UNUSED_ARG(b); return false; } @@ -380,9 +380,9 @@ static const char *b_namewall(const connection * b, const region * r, { const char *bname = "wall"; - unused_arg(f); - unused_arg(r); - unused_arg(b); + UNUSED_ARG(f); + UNUSED_ARG(r); + UNUSED_ARG(b); if (gflags & GF_ARTICLE) bname = "a_wall"; if (gflags & GF_PURE) @@ -421,9 +421,9 @@ border_type bt_noway = { static const char *b_namefogwall(const connection * b, const region * r, const struct faction *f, int gflags) { - unused_arg(f); - unused_arg(b); - unused_arg(r); + UNUSED_ARG(f); + UNUSED_ARG(b); + UNUSED_ARG(r); if (gflags & GF_PURE) return "fogwall"; if (gflags & GF_ARTICLE) @@ -434,7 +434,7 @@ static const char *b_namefogwall(const connection * b, const region * r, static bool b_blockfogwall(const connection * b, const unit * u, const region * r) { - unused_arg(b); + UNUSED_ARG(b); if (!u) return true; return (bool)(effskill(u, SK_PERCEPTION, r) > 4); /* Das ist die alte Nebelwand */ @@ -459,8 +459,8 @@ static const char *b_nameillusionwall(const connection * b, const region * r, const struct faction *f, int gflags) { int fno = b->data.i; - unused_arg(b); - unused_arg(r); + UNUSED_ARG(b); + UNUSED_ARG(r); if (gflags & GF_PURE) return (f && fno == f->no) ? "illusionwall" : "wall"; if (gflags & GF_ARTICLE) { @@ -496,7 +496,7 @@ static const char *b_nameroad(const connection * b, const region * r, int local = (r == b->from) ? b->data.sa[0] : b->data.sa[1]; static char buffer[64]; - unused_arg(f); + UNUSED_ARG(f); if (gflags & GF_PURE) return "road"; if (gflags & GF_ARTICLE) { @@ -512,7 +512,7 @@ static const char *b_nameroad(const connection * b, const region * r, } } else { - int percent = _max(1, 100 * local / r->terrain->max_road); + int percent = MAX(1, 100 * local / r->terrain->max_road); if (local) { slprintf(buffer, sizeof(buffer), LOC(f->locale, mkname("border", "a_road_percent")), percent); diff --git a/src/kernel/connection.h b/src/kernel/connection.h index 7eef0f52a..80177c638 100644 --- a/src/kernel/connection.h +++ b/src/kernel/connection.h @@ -20,7 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define H_KRNL_BORDER #include - +#include #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/curse.c b/src/kernel/curse.c index 123f858f5..22b87e738 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -109,7 +109,7 @@ int curse_age(attrib * a, void *owner) curse *c = (curse *)a->data.v; int result = 0; - unused_arg(owner); + UNUSED_ARG(owner); c_clearflag(c, CURSE_ISNEW); if (c_flags(c) & CURSE_NOAGE) { @@ -122,7 +122,7 @@ int curse_age(attrib * a, void *owner) 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 > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } @@ -348,7 +348,7 @@ const curse_type *ct_find(const char *c) return type; } else { - size_t k = _min(c_len, strlen(type->cname)); + size_t k = MIN(c_len, strlen(type->cname)); if (!memcmp(c, type->cname, k)) { return type; } @@ -507,7 +507,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 */ @@ -596,7 +596,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; @@ -605,10 +605,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; @@ -792,9 +792,9 @@ message *cinfo_simple(const void *obj, objtype_t typ, const struct curse * c, { struct message *msg; - unused_arg(typ); - unused_arg(self); - unused_arg(obj); + UNUSED_ARG(typ); + UNUSED_ARG(self); + UNUSED_ARG(obj); msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no); if (msg == NULL) { diff --git a/src/kernel/curse.h b/src/kernel/curse.h index 29498f4d2..4cff4f9a1 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "objtypes.h" +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index 8266ada9a..1587e7531 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -47,7 +47,7 @@ equipment *create_equipment(const char *eqname) int i = eq ? strcmp(eq->name, eqname) : 1; if (i > 0) { eq = (equipment *)calloc(1, sizeof(equipment)); - eq->name = _strdup(eqname); + eq->name = strdup(eqname); eq->next = *eqp; memset(eq->skills, 0, sizeof(eq->skills)); *eqp = eq; @@ -78,7 +78,7 @@ void equipment_setskill(equipment * eq, skill_t sk, const char *value) { if (eq != NULL) { if (value != NULL) { - eq->skills[sk] = _strdup(value); + eq->skills[sk] = strdup(value); } else if (eq->skills[sk]) { free(eq->skills[sk]); @@ -98,7 +98,7 @@ void equipment_addspell(equipment * eq, const char * name, int level) lazy_spell *ls = malloc(sizeof(lazy_spell)); ls->sp = NULL; ls->level = level; - ls->name = _strdup(name); + ls->name = strdup(name); ql_push(&eq->spells, ls); } } @@ -115,7 +115,7 @@ equipment_setitem(equipment * eq, const item_type * itype, const char *value) if (idata == NULL) { idata = (itemdata *)malloc(sizeof(itemdata)); idata->itype = itype; - idata->value = _strdup(value); + idata->value = strdup(value); idata->next = eq->items; eq->items = idata; } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index d332bf604..2c6d4d244 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -274,7 +274,7 @@ faction *addfaction(const char *email, const char *password, fhash(f); slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), itoa36(f->no)); - f->name = _strdup(buf); + f->name = strdup(buf); if (!f->race) { log_warning("creating a faction that has no race", itoa36(f->no)); @@ -523,7 +523,7 @@ void faction_setname(faction * self, const char *name) { free(self->name); if (name) - self->name = _strdup(name); + self->name = strdup(name); } const char *faction_getemail(const faction * self) @@ -535,7 +535,7 @@ void faction_setemail(faction * self, const char *email) { free(self->email); if (email) - self->email = _strdup(email); + self->email = strdup(email); } const char *faction_getbanner(const faction * self) @@ -547,7 +547,7 @@ void faction_setbanner(faction * self, const char *banner) { free(self->banner); if (banner) - self->banner = _strdup(banner); + self->banner = strdup(banner); } void faction_setpassword(faction * f, const char *pwhash) @@ -555,7 +555,7 @@ void faction_setpassword(faction * f, const char *pwhash) assert(pwhash); // && pwhash[0] == '$'); free(f->_password); - f->_password = _strdup(pwhash); + f->_password = strdup(pwhash); } bool valid_race(const struct faction *f, const struct race *rc) diff --git a/src/kernel/faction.h b/src/kernel/faction.h index 82ae89ea4..de55ad1fe 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "skill.h" #include "types.h" #include +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/group.c b/src/kernel/group.c index 8753531a3..06f2f9f49 100755 --- a/src/kernel/group.c +++ b/src/kernel/group.c @@ -57,8 +57,8 @@ group *new_group(faction * f, const char *name, int gid) gp = &(*gp)->next; *gp = g; - maxgid = _max(gid, maxgid); - g->name = _strdup(name); + maxgid = MAX(gid, maxgid); + g->name = strdup(name); g->gid = gid; g->nexthash = ghash[index]; diff --git a/src/kernel/item.c b/src/kernel/item.c index 53fff79ab..441346be8 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -156,7 +156,7 @@ const char *resourcename(const resource_type * rtype, int flags) } if (flags & NMF_PLURAL) { static char name[64]; // FIXME: static return value - _snprintf(name, sizeof(name), "%s_p", rtype->_name); + snprintf(name, sizeof(name), "%s_p", rtype->_name); return name; } return rtype->_name; @@ -186,7 +186,7 @@ resource_type *rt_get_or_create(const char *name) { perror("resource_type allocation failed"); } else { - rtype->_name = _strdup(name); + rtype->_name = strdup(name); rt_register(rtype); return rt_find(name); } @@ -282,8 +282,8 @@ weapon_type *new_weapontype(item_type * itype, wtype = calloc(sizeof(weapon_type), 1); if (damage) { - wtype->damage[0] = _strdup(damage[0]); - wtype->damage[1] = _strdup(damage[1]); + wtype->damage[0] = strdup(damage[0]); + wtype->damage[1] = strdup(damage[1]); } wtype->defmod = defmod; wtype->flags |= wflags; @@ -342,7 +342,7 @@ void it_set_appearance(item_type *itype, const char *appearance) { assert(itype); assert(itype->rtype); if (appearance) { - itype->_appearance[0] = _strdup(appearance); + itype->_appearance[0] = strdup(appearance); itype->_appearance[1] = strcat(strcpy((char *)malloc(strlen((char *)appearance) + 3), (char *)appearance), "_p"); } else { itype->_appearance[0] = 0; @@ -676,9 +676,9 @@ struct order *ord) direction_t d; message *msg = msg_message("meow", ""); - unused_arg(ord); - unused_arg(amount); - unused_arg(itype); + UNUSED_ARG(ord); + UNUSED_ARG(amount); + UNUSED_ARG(itype); add_message(&u->region->msgs, msg); for (d = 0; d < MAXDIRECTIONS; d++) { @@ -717,7 +717,7 @@ struct order *ord) c = create_curse(u, &u->attribs, ct_find("skillmod"), power, duration, effect, u->number); c->data.i = SK_TACTICS; - unused_arg(ord); + UNUSED_ARG(ord); } use_pooled(u, itype->rtype, GET_DEFAULT, amount); ADDMSG(&u->faction->msgs, msg_message("use_tacticcrystal", @@ -746,14 +746,14 @@ mod_elves_only(const unit * u, const region * r, skill_t sk, int value) { if (u_race(u) == get_race(RC_ELF)) return value; - unused_arg(r); + UNUSED_ARG(r); return -118; } static int mod_dwarves_only(const unit * u, const region * r, skill_t sk, int value) { - unused_arg(r); + UNUSED_ARG(r); if (u_race(u) == get_race(RC_DWARF) || (u_race(u)->flags & RCF_IRONGOLEM)) { return value; } @@ -764,7 +764,7 @@ static int heal(unit * user, int effect) { int req = unit_max_hp(user) * user->number - user->hp; if (req > 0) { - req = _min(req, effect); + req = MIN(req, effect); effect -= req; user->hp += req; } diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index d12238566..509470406 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -224,7 +224,7 @@ static void json_terrain_production(cJSON *json, terrain_production *prod) { if (dst) { free(*dst); assert(child->type == cJSON_String); - *dst = _strdup(child->valuestring); + *dst = strdup(child->valuestring); } } } @@ -453,7 +453,7 @@ static void json_race(cJSON *json, race *rc) { switch (child->type) { case cJSON_String: if (strcmp(child->string, "damage") == 0) { - rc->def_damage = _strdup(child->valuestring); + rc->def_damage = strdup(child->valuestring); } break; case cJSON_Number: @@ -534,7 +534,7 @@ static void disable_feature(const char *str) { enable_keyword(k, false); return; } - _snprintf(name, sizeof(name), "%s.enabled", str); + snprintf(name, sizeof(name), "%s.enabled", str); log_info("disable feature %s\n", name); config_set(name, "0"); } @@ -594,7 +594,7 @@ static void json_spells(cJSON *json) { sp->fumble = (fumble_f)get_function(item->valuestring); } else if (strcmp(item->string, "syntax") == 0) { - sp->syntax = _strdup(item->valuestring); + sp->syntax = strdup(item->valuestring); } } } @@ -796,10 +796,10 @@ static void json_settings(cJSON *json) { else { char value[32]; if (child->type == cJSON_Number && child->valuedouble && child->valueintvaluedouble) { - _snprintf(value, sizeof(value), "%f", child->valuedouble); + snprintf(value, sizeof(value), "%f", child->valuedouble); } else { - _snprintf(value, sizeof(value), "%d", child->valueint); + snprintf(value, sizeof(value), "%d", child->valueint); } config_set(child->string, value); } diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 566e9bdef..89278624f 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -212,7 +212,7 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level) { message *m = NULL; - unused_arg(level); + UNUSED_ARG(level); switch (mtype) { case MSG_INCOME: assert(f); @@ -275,7 +275,7 @@ message * msg_error(const unit * u, struct order *ord, int mno) { message * cmistake(const unit * u, struct order *ord, int mno, int mtype) { message * result; - unused_arg(mtype); + UNUSED_ARG(mtype); result = msg_error(u, ord, mno); ADDMSG(&u->faction->msgs, result); return result; diff --git a/src/kernel/order.c b/src/kernel/order.c index 3fd1dc92f..776190b67 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -405,7 +405,7 @@ order *parse_order(const char *s, const struct locale * lang) } } if (kwd != NOKEYWORD) { - while (isxspace(*(unsigned char *)sptr)) ++sptr; + while (isspace(*(unsigned char *)sptr)) ++sptr; s = sptr; return create_order_i(kwd, s, persistent, lang); } diff --git a/src/kernel/plane.c b/src/kernel/plane.c index 7e9650d13..0b2fdc0d3 100644 --- a/src/kernel/plane.c +++ b/src/kernel/plane.c @@ -234,7 +234,7 @@ plane *create_new_plane(int id, const char *name, int minx, int maxx, int miny, pl->next = NULL; pl->id = id; if (name) - pl->name = _strdup(name); + pl->name = strdup(name); pl->minx = minx; pl->maxx = maxx; pl->miny = miny; diff --git a/src/kernel/pool.c b/src/kernel/pool.c index 5609d211f..702f86e0f 100644 --- a/src/kernel/pool.c +++ b/src/kernel/pool.c @@ -168,7 +168,7 @@ int count) use = have; else if (rtype->itype && mode & (GET_SLACK | GET_RESERVE)) { int reserve = get_reservation(u, rtype->itype); - int slack = _max(0, have - reserve); + int slack = MAX(0, have - reserve); if (mode & GET_RESERVE) use = have - slack; else if (mode & GET_SLACK) @@ -209,18 +209,18 @@ 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 if (rtype->itype) { int reserve = get_reservation(u, rtype->itype); - 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->itype, -n); } else if (mode & GET_SLACK) { - n = _min(use, slack); + n = MIN(use, slack); } } if (n > 0) { diff --git a/src/kernel/race.c b/src/kernel/race.c index decc3b7bb..a78a9e340 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -241,7 +241,7 @@ race *rc_create(const char *zName) log_error("race '%s' has an invalid name. remove spaces\n", zName); assert(strchr(zName, ' ') == NULL); } - rc->_name = _strdup(zName); + rc->_name = strdup(zName); rc->precombatspell = NULL; rc->attack[0].type = AT_COMBATSPELL; @@ -288,7 +288,7 @@ const char* rc_name(const race * rc, name_t n, char *name, size_t size) { default: assert(!"invalid name_t enum in rc_name_s"); } if (postfix) { - _snprintf(name, size, "race::%s%s", rc->_name, postfix); + snprintf(name, size, "race::%s%s", rc->_name, postfix); return name; } return NULL; diff --git a/src/kernel/region.c b/src/kernel/region.c index d937f8b68..cade135c7 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -138,7 +138,7 @@ int region_maxworkers(const region *r) { int size = production(r); int treespace = (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE; - return _max(size - treespace, _min(size / 10, 200)); + return MAX(size - treespace, MIN(size / 10, 200)); } int deathcount(const region * r) @@ -403,7 +403,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 @@ -426,13 +426,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; @@ -1215,7 +1215,7 @@ void terraform_region(region * r, const terrain_type * terrain) if (!fval(r, RF_CHAOTIC)) { int peasants; peasants = (region_maxworkers(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)); } @@ -1395,7 +1395,7 @@ faction *update_owners(region * r) else if (f || new_owner->faction != region_get_last_owner(r)) { alliance *al = region_get_alliance(r); if (al && new_owner->faction->alliance == al) { - int morale = _max(0, region_get_morale(r) - MORALE_TRANSFER); + int morale = MAX(0, region_get_morale(r) - MORALE_TRANSFER); region_set_morale(r, morale, turn); } else { @@ -1418,7 +1418,7 @@ faction *update_owners(region * r) void region_setinfo(struct region *r, const char *info) { free(r->display); - r->display = info ? _strdup(info) : 0; + r->display = info ? strdup(info) : 0; } const char *region_getinfo(const region * r) @@ -1430,7 +1430,7 @@ void region_setname(struct region *r, const char *name) { if (r->land) { free(r->land->name); - r->land->name = name ? _strdup(name) : 0; + r->land->name = name ? strdup(name) : 0; } } diff --git a/src/kernel/region.h b/src/kernel/region.h index fcc5f08b0..9fa1a2daa 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define H_KRNL_REGION #include +#include #include "types.h" #include "direction.h" diff --git a/src/kernel/resources.c b/src/kernel/resources.c index e064150e6..e32c7ad55 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -111,7 +111,7 @@ static void terraform_default(struct rawmaterial *res, const region * r) res->amount = (int)(res->amount * modifier); /* random adjustment, +/- 91% */ if (res->amount < 1) res->amount = 1; - unused_arg(r); + UNUSED_ARG(r); } #ifdef RANDOM_CHANGE @@ -205,7 +205,7 @@ struct rawmaterial_type *rmt_create(const struct resource_type *rtype, const char *name) { rawmaterial_type *rmtype = malloc(sizeof(rawmaterial_type)); - rmtype->name = _strdup(name); + rmtype->name = strdup(name); rmtype->rtype = rtype; rmtype->terraform = terraform_default; rmtype->update = NULL; diff --git a/src/kernel/save.c b/src/kernel/save.c index 2f157af41..de6f8aac1 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -436,7 +436,7 @@ void read_planes(gamedata *data) { } pl->id = id; READ_STR(store, name, sizeof(name)); - pl->name = _strdup(name); + pl->name = strdup(name); READ_INT(store, &pl->minx); READ_INT(store, &pl->maxx); READ_INT(store, &pl->miny); @@ -668,7 +668,7 @@ unit *read_unit(struct gamedata *data) if (unicode_utf8_trim(obuf)!=0) { log_warning("trim unit %s name to '%s'", itoa36(u->no), obuf); } - u->_name = obuf[0] ? _strdup(obuf) : 0; + u->_name = obuf[0] ? strdup(obuf) : 0; if (lomem) { READ_STR(data->store, NULL, 0); } @@ -677,7 +677,7 @@ unit *read_unit(struct gamedata *data) if (unicode_utf8_trim(obuf)!=0) { log_warning("trim unit %s info to '%s'", itoa36(u->no), obuf); } - u->display = obuf[0] ? _strdup(obuf) : 0; + u->display = obuf[0] ? strdup(obuf) : 0; } READ_INT(data->store, &number); set_number(u, number); @@ -933,7 +933,7 @@ static region *readregion(struct gamedata *data, int x, int y) if (unicode_utf8_trim(name)!=0) { log_warning("trim region %d name to '%s'", uid, name); }; - r->land->name = _strdup(name); + r->land->name = strdup(name); } if (r->land) { int i; @@ -1034,7 +1034,7 @@ static region *readregion(struct gamedata *data, int x, int y) read_items(data->store, &r->land->items); if (data->version >= REGIONOWNER_VERSION) { READ_INT(data->store, &n); - region_set_morale(r, _max(0, (short)n), -1); + region_set_morale(r, MAX(0, (short)n), -1); read_owner(data, &r->land->ownership); } } @@ -1192,7 +1192,7 @@ static char * getpasswd(int fno) { assert(line[slen] == '\n'); line[slen] = 0; fclose(F); - return _strdup(line + len + 1); + return strdup(line + len + 1); } } fclose(F); @@ -1285,12 +1285,12 @@ faction *read_faction(struct gamedata * data) if (unicode_utf8_trim(name)!=0) { log_warning("trim faction %s name to '%s'", itoa36(f->no), name); }; - f->name = _strdup(name); + f->name = strdup(name); READ_STR(data->store, name, sizeof(name)); if (unicode_utf8_trim(name)!=0) { log_warning("trim faction %s banner to '%s'", itoa36(f->no), name); }; - f->banner = _strdup(name); + f->banner = strdup(name); log_debug(" - Lese Partei %s (%s)", f->name, itoa36(f->no)); @@ -1528,7 +1528,7 @@ struct building *read_building(gamedata *data) { if (unicode_utf8_trim(name)!=0) { log_warning("trim building %s name to '%s'", itoa36(b->no), name); } - b->name = _strdup(name); + b->name = strdup(name); if (lomem) { READ_STR(store, NULL, 0); } @@ -1537,7 +1537,7 @@ struct building *read_building(gamedata *data) { if (unicode_utf8_trim(name)!=0) { log_warning("trim building %s info to '%s'", itoa36(b->no), name); } - b->display = _strdup(name); + b->display = strdup(name); } READ_INT(store, &b->size); READ_STR(store, name, sizeof(name)); @@ -1581,7 +1581,7 @@ ship *read_ship(struct gamedata *data) if (unicode_utf8_trim(name)!=0) { log_warning("trim ship %s name to '%s'", itoa36(sh->no), name); } - sh->name = _strdup(name); + sh->name = strdup(name); if (lomem) { READ_STR(store, NULL, 0); } @@ -1590,7 +1590,7 @@ ship *read_ship(struct gamedata *data) if (unicode_utf8_trim(name)!=0) { log_warning("trim ship %s info to '%s'", itoa36(sh->no), name); } - sh->display = _strdup(name); + sh->display = strdup(name); } READ_STR(store, name, sizeof(name)); sh->type = st_find(name); diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index 6a2758a1d..c05ce4455 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -91,7 +91,7 @@ static void test_readwrite_faction(CuTest * tc) test_setup(); f = test_create_faction(0); free(f->name); - f->name = _strdup(" Hodor "); + f->name = strdup(" Hodor "); CuAssertStrEquals(tc, " Hodor ", f->name); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); @@ -120,7 +120,7 @@ static void test_readwrite_region(CuTest * tc) test_setup(); r = test_create_region(0, 0, 0); free(r->land->name); - r->land->name = _strdup(" Hodor "); + r->land->name = strdup(" Hodor "); CuAssertStrEquals(tc, " Hodor ", r->land->name); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); @@ -150,7 +150,7 @@ static void test_readwrite_building(CuTest * tc) r = test_create_region(0, 0, 0); b = test_create_building(r, 0); free(b->name); - b->name = _strdup(" Hodor "); + b->name = strdup(" Hodor "); CuAssertStrEquals(tc, " Hodor ", b->name); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); @@ -183,7 +183,7 @@ static void test_readwrite_ship(CuTest * tc) r = test_create_region(0, 0, 0); sh = test_create_ship(r, 0); free(sh->name); - sh->name = _strdup(" Hodor "); + sh->name = strdup(" Hodor "); CuAssertStrEquals(tc, " Hodor ", sh->name); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 6898630ff..817d54970 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -109,7 +109,7 @@ ship_type *st_get_or_create(const char * name) { ship_type * st = st_find_i(name); if (!st) { st = (ship_type *)calloc(sizeof(ship_type), 1); - st->_name = _strdup(name); + st->_name = strdup(name); st->storm = 1.0; ql_push(&shiptypes, (void *)st); } @@ -202,7 +202,7 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang) } assert(sname); slprintf(buffer, sizeof(buffer), "%s %s", sname, itoa36(sh->no)); - sh->name = _strdup(buffer); + sh->name = strdup(buffer); shash(sh); if (r) { addlist(&r->ships, sh); @@ -333,8 +333,8 @@ int shipspeed(const ship * sh, const unit * u) int crew = crew_skill(sh); int crew_bonus = (crew / sh->type->sumskill / 2) - 1; if (crew_bonus > 0) { - bonus = _min(bonus, crew_bonus); - bonus = _min(bonus, sh->type->range_max - sh->type->range); + bonus = MIN(bonus, crew_bonus); + bonus = MIN(bonus, sh->type->range_max - sh->type->range); } else { bonus = 0; @@ -458,7 +458,7 @@ void write_ship_reference(const struct ship *sh, struct storage *store) void ship_setname(ship * self, const char *name) { free(self->name); - self->name = name ? _strdup(name) : 0; + self->name = name ? strdup(name) : 0; } const char *ship_getname(const ship * self) diff --git a/src/kernel/spell.c b/src/kernel/spell.c index 8e14ec2c0..3201a6677 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -78,7 +78,7 @@ spell * create_spell(const char * name, unsigned int id) len = cb_new_kv(name, len, &sp, sizeof(sp), buffer); if (cb_insert(&cb_spells, buffer, len) == CB_SUCCESS) { sp->id = id ? id : hashstring(name); - sp->sname = _strdup(name); + sp->sname = strdup(name); add_spell(&spells, sp); return sp; } diff --git a/src/kernel/spellbook.c b/src/kernel/spellbook.c index da8fcd563..13f8a04f7 100644 --- a/src/kernel/spellbook.c +++ b/src/kernel/spellbook.c @@ -16,7 +16,7 @@ spellbook * create_spellbook(const char * name) { spellbook *result = (spellbook *)malloc(sizeof(spellbook)); - result->name = name ? _strdup(name) : 0; + result->name = name ? strdup(name) : 0; result->spells = 0; return result; } diff --git a/src/kernel/terrain.c b/src/kernel/terrain.c index ac4a49fe9..ca72e3060 100644 --- a/src/kernel/terrain.c +++ b/src/kernel/terrain.c @@ -110,7 +110,7 @@ terrain_type * get_or_create_terrain(const char *name) { if (!terrain) { terrain = (terrain_type *)calloc(sizeof(terrain_type), 1); if (terrain) { - terrain->_name = _strdup(name); + terrain->_name = strdup(name); terrain->next = registered_terrains; registered_terrains = terrain; if (strcmp("plain", name) == 0) { diff --git a/src/kernel/unit.c b/src/kernel/unit.c index f06c4c252..29766d4ef 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -123,7 +123,7 @@ unit *findunitr(const region * r, int n) // TODO: deprecated, replace with findunit(n) unit *findunitg(int n, const region * hint) { - unused_arg(hint); + UNUSED_ARG(hint); /* Abfangen von Syntaxfehlern. */ if (n <= 0) return NULL; @@ -511,7 +511,7 @@ int a_readprivate(attrib * a, void *owner, gamedata *data) struct storage *store = data->store; char lbuf[DISPLAYSIZE]; READ_STR(store, lbuf, sizeof(lbuf)); - a->data.v = _strdup(lbuf); + a->data.v = strdup(lbuf); return (a->data.v) ? AT_READ_OK : AT_READ_FAIL; } @@ -562,7 +562,7 @@ void usetprivate(unit * u, const char *str) if (a->data.v) { free(a->data.v); } - a->data.v = _strdup(str); + a->data.v = strdup(str); } /*********************/ @@ -809,8 +809,8 @@ void set_level(unit * u, skill_t sk, int value) static int leftship_age(struct attrib *a, void *owner) { /* must be aged, so it doesn't affect report generation (cansee) */ - unused_arg(a); - unused_arg(owner); + UNUSED_ARG(a); + UNUSED_ARG(owner); return AT_AGE_REMOVE; /* remove me */ } @@ -1390,7 +1390,7 @@ int invisible(const unit * target, const unit * viewer) else { int hidden = item_invis(target); if (hidden) { - hidden = _min(hidden, target->number); + hidden = MIN(hidden, target->number); if (viewer) { const resource_type *rtype = get_resourcetype(R_AMULET_OF_TRUE_SEEING); hidden -= i_get(viewer->items, rtype->itype); @@ -1533,7 +1533,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace, u->hp = unit_max_hp(u) * number; if (dname) { - u->_name = _strdup(dname); + u->_name = strdup(dname); } else if (urace->generate_name || playerrace(urace)) { name_unit(u); @@ -1640,7 +1640,7 @@ void unit_setname(unit * u, const char *name) { free(u->_name); if (name && name[0]) - u->_name = _strdup(name); + u->_name = strdup(name); else u->_name = NULL; } @@ -1654,7 +1654,7 @@ void unit_setinfo(unit * u, const char *info) { free(u->display); if (info) - u->display = _strdup(info); + u->display = strdup(info); else u->display = NULL; } diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index 752627144..f242dbb1c 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -146,7 +146,7 @@ static void test_unit_name(CuTest *tc) { test_create_world(); u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0)); unit_setname(u, "Hodor"); - _snprintf(name, sizeof(name), "Hodor (%s)", itoa36(u->no)); + snprintf(name, sizeof(name), "Hodor (%s)", itoa36(u->no)); CuAssertStrEquals(tc, name, unitname(u)); test_cleanup(); } @@ -164,12 +164,12 @@ static void test_unit_name_from_race(CuTest *tc) { locale_setstring(lang, rc_name_s(u->_race, NAME_SINGULAR), "Mensch"); locale_setstring(lang, rc_name_s(u->_race, NAME_PLURAL), "Menschen"); - _snprintf(name, sizeof(name), "Mensch (%s)", itoa36(u->no)); + snprintf(name, sizeof(name), "Mensch (%s)", itoa36(u->no)); CuAssertStrEquals(tc, name, unitname(u)); CuAssertStrEquals(tc, "Mensch", unit_getname(u)); u->number = 2; - _snprintf(name, sizeof(name), "Menschen (%s)", itoa36(u->no)); + snprintf(name, sizeof(name), "Menschen (%s)", itoa36(u->no)); CuAssertStrEquals(tc, name, unitname(u)); CuAssertStrEquals(tc, "Menschen", unit_getname(u)); @@ -243,9 +243,9 @@ static void test_default_name(CuTest *tc) { } static int cb_skillmod(const unit *u, const region *r, skill_t sk, int level) { - unused_arg(u); - unused_arg(r); - unused_arg(sk); + UNUSED_ARG(u); + UNUSED_ARG(r); + UNUSED_ARG(sk); return level + 3; } @@ -398,7 +398,7 @@ static void test_unit_description(CuTest *tc) { u = test_create_unit(test_create_faction(rc), test_create_region(0,0,0)); CuAssertPtrEquals(tc, 0, u->display); CuAssertStrEquals(tc, 0, u_description(u, u->faction->locale)); - u->display = _strdup("Hodor"); + u->display = strdup("Hodor"); CuAssertStrEquals(tc, "Hodor", u_description(u, NULL)); CuAssertStrEquals(tc, "Hodor", u_description(u, u->faction->locale)); test_cleanup(); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 640a28940..2f38cdab3 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -94,8 +94,8 @@ static xmlChar *xml_cleanup_string(xmlChar * str) while (*read) { /* eat leading whitespace */ - if (*read && isxspace(*read)) { - while (*read && isxspace(*read)) { + if (*read && isspace(*read)) { + while (*read && isspace(*read)) { ++read; } *write++ = ' '; @@ -379,7 +379,7 @@ static int parse_calendar(xmlDocPtr doc) first_turn = xml_ivalue(calendar, "start", first_turn); if (propValue) { free(agename); - agename = _strdup(mkname("calendar", (const char *)propValue)); + agename = strdup(mkname("calendar", (const char *)propValue)); xmlFree(propValue); } @@ -398,7 +398,7 @@ static int parse_calendar(xmlDocPtr doc) xmlNodePtr week = nsetWeeks->nodeTab[i]; xmlChar *propValue = xmlGetProp(week, BAD_CAST "name"); if (propValue) { - weeknames[i] = _strdup(mkname("calendar", (const char *)propValue)); + weeknames[i] = strdup(mkname("calendar", (const char *)propValue)); weeknames2[i] = malloc(strlen(weeknames[i]) + 3); sprintf(weeknames2[i], "%s_d", weeknames[i]); xmlFree(propValue); @@ -421,7 +421,7 @@ static int parse_calendar(xmlDocPtr doc) xmlChar *propValue = xmlGetProp(season, BAD_CAST "name"); if (propValue) { seasonnames[i] = - _strdup(mkname("calendar", (const char *)propValue)); + strdup(mkname("calendar", (const char *)propValue)); xmlFree(propValue); } } @@ -451,7 +451,7 @@ static int parse_calendar(xmlDocPtr doc) xmlFree(newyear); newyear = NULL; } - monthnames[i] = _strdup(mkname("calendar", (const char *)propValue)); + monthnames[i] = strdup(mkname("calendar", (const char *)propValue)); xmlFree(propValue); } if (nsetSeasons) { @@ -663,7 +663,7 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype) xmlFree(propValue); propValue = xmlGetProp(node, BAD_CAST "value"); - wtype->damage[pos] = _strdup((const char *)propValue); // TODO: this is a memory leak + wtype->damage[pos] = strdup((const char *)propValue); // TODO: this is a memory leak if (k == 0) wtype->damage[1 - pos] = wtype->damage[pos]; xmlFree(propValue); @@ -1426,13 +1426,13 @@ static int parse_spells(xmlDocPtr doc) propValue = xmlGetProp(node, BAD_CAST "parameters"); if (propValue) { - sp->parameter = _strdup((const char *)propValue); + sp->parameter = strdup((const char *)propValue); xmlFree(propValue); } propValue = xmlGetProp(node, BAD_CAST "syntax"); if (propValue) { - sp->syntax = _strdup((const char *)propValue); + sp->syntax = strdup((const char *)propValue); xmlFree(propValue); } #ifdef TODO /* no longer need it, spellbooks! */ @@ -1628,7 +1628,7 @@ static int parse_races(xmlDocPtr doc) propValue = xmlGetProp(node, BAD_CAST "damage"); assert(propValue != NULL); - rc->def_damage = _strdup((const char *)propValue); + rc->def_damage = strdup((const char *)propValue); xmlFree(propValue); rc->magres = (float)xml_fvalue(node, "magres", rc->magres); @@ -1869,7 +1869,7 @@ static int parse_races(xmlDocPtr doc) propValue = xmlGetProp(node, BAD_CAST "damage"); if (propValue != NULL) { - attack->data.dice = _strdup((const char *)propValue); + attack->data.dice = strdup((const char *)propValue); xmlFree(propValue); } else { @@ -1932,7 +1932,7 @@ static int parse_messages(xmlDocPtr doc) (const char *)propType); xmlFree(propName); xmlFree(propType); - argv[k] = _strdup(zBuffer); + argv[k] = strdup(zBuffer); } argv[result->nodesetval->nodeNr] = NULL; } diff --git a/src/laws.c b/src/laws.c index e0bae8e41..7baadcf29 100644 --- a/src/laws.c +++ b/src/laws.c @@ -209,7 +209,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)); @@ -267,7 +267,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; @@ -318,7 +318,7 @@ int peasant_luck_effect(int peasants, int luck, int maxp, double variance) double mean; if (luck == 0) return 0; - mean = peasant_luck_factor() * peasant_growth_factor() * _min(luck, peasants); + mean = peasant_luck_factor() * peasant_growth_factor() * MIN(luck, peasants); mean *= ((peasants / (double)maxp < .9) ? 1 : PEASANTFORCE); births = RAND_ROUND(normalvariate(mean, variance * mean)); @@ -357,7 +357,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 @@ -366,7 +366,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.5 + n * PEASANT_STARVATION_CHANCE); if (dead > 0) { @@ -447,7 +447,7 @@ static void horses(region * r) /* Logistisches Wachstum, Optimum bei halbem Maximalbesatz. */ maxhorses = region_maxworkers(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)) { @@ -481,7 +481,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 { @@ -594,7 +594,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 */ @@ -614,7 +614,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) / 8); + elves = MIN(elves, production(r) / 8); if (elves) { seedchance += 1.0 - pow(0.99999, elves * RESOURCE_QUANTITY); } @@ -680,7 +680,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++) { @@ -700,7 +700,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++) { @@ -740,7 +740,7 @@ void immigration(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)); } /* Genereate some (0-6 depending on the income) peasants out of nothing */ /* if less than 50 are in the region and there is space and no monster or demon units in the region */ @@ -843,7 +843,7 @@ void demographics(void) calculate_emigration(r); peasants(r); if (r->age > 20) { - double mwp = _max(region_maxworkers(r), 1); + double mwp = MAX(region_maxworkers(r), 1); double prob = pow(rpeasants(r) / (mwp * wage(r, NULL, NULL, turn) * 0.13), 4.0) * PLAGUE_CHANCE; @@ -1280,7 +1280,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 (fp = &factions; *fp;) { faction *f = *fp; if (!is_monsters(f)) { @@ -1621,7 +1621,7 @@ int display_cmd(unit * u, struct order *ord) free(*s); if (s2) { - *s = _strdup(s2); + *s = strdup(s2); if (strlen(s2) >= DISPLAYSIZE) { (*s)[DISPLAYSIZE] = 0; } @@ -1665,7 +1665,7 @@ static int rename_cmd(unit * u, order * ord, char **s, const char *s2) unicode_utf8_trim(name); free(*s); - *s = _strdup(name); + *s = strdup(name); return 0; } @@ -2154,7 +2154,7 @@ int banner_cmd(unit * u, struct order *ord) const char * s = getstrtoken(); free(u->faction->banner); - u->faction->banner = s ? _strdup(s) : 0; + u->faction->banner = s ? strdup(s) : 0; add_message(&u->faction->msgs, msg_message("changebanner", "value", u->faction->banner)); @@ -2356,23 +2356,23 @@ static void display_race(unit * u, const race * rc) } } if (rc->battle_flags & BF_EQUIPMENT) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment"))) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment"))) != 0) WARN_STATIC_BUFFER(); } if (rc->battle_flags & BF_RES_PIERCE) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce"))) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce"))) != 0) WARN_STATIC_BUFFER(); } if (rc->battle_flags & BF_RES_CUT) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut"))) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut"))) != 0) WARN_STATIC_BUFFER(); } if (rc->battle_flags & BF_RES_BASH) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash"))) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash"))) != 0) WARN_STATIC_BUFFER(); } - if (wrptr(&bufp, &size, _snprintf(bufp, size, " %d %s", at_count, LOC(f->locale, (at_count == 1) ? "stat_attack" : "stat_attacks"))) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " %d %s", at_count, LOC(f->locale, (at_count == 1) ? "stat_attack" : "stat_attacks"))) != 0) WARN_STATIC_BUFFER(); for (a = 0; a < RACE_ATTACKS; a++) { @@ -2385,12 +2385,12 @@ static void display_race(unit * u, const race * rc) switch (rc->attack[a].type) { case AT_STANDARD: bytes = - (size_t)_snprintf(bufp, size, "%s (%s)", + (size_t)snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_standard"), rc->def_damage); break; case AT_NATURAL: bytes = - (size_t)_snprintf(bufp, size, "%s (%s)", + (size_t)snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_natural"), rc->attack[a].data.dice); break; case AT_SPELL: @@ -2398,11 +2398,11 @@ static void display_race(unit * u, const race * rc) case AT_DRAIN_ST: case AT_DRAIN_EXP: case AT_DAZZLE: - bytes = (size_t)_snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical")); + bytes = (size_t)snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical")); break; case AT_STRUCTURAL: bytes = - (size_t)_snprintf(bufp, size, "%s (%s)", + (size_t)snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_structural"), rc->attack[a].data.dice); break; default: @@ -2670,7 +2670,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 = gettoken(token, sizeof(token)); } @@ -2903,14 +2903,14 @@ static void age_stonecircle(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 { int sk = effskill(mage, SK_MAGIC, 0); - c->duration = _max(c->duration, sk / 2); - c->vigour = _max(c->vigour, (float)sk); + c->duration = MAX(c->duration, sk / 2); + c->vigour = MAX(c->vigour, (float)sk); } } } @@ -2955,12 +2955,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)) { @@ -3034,7 +3034,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) @@ -3130,7 +3130,7 @@ void new_units(void) s = gettoken(token, sizeof(token)); if (s && s[0]) { - name = _strdup(s); + name = strdup(s); } u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u); if (name != NULL) @@ -3361,7 +3361,7 @@ void monthly_healing(void) p *= heal_factor(u); if (u->hp < umhp) { - double maxheal = _max(u->number, umhp / 20.0); + double maxheal = MAX(u->number, umhp / 20.0); int addhp; if (active_building(u, bt_find("inn"))) { p *= 1.5; @@ -3376,7 +3376,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); @@ -3701,7 +3701,7 @@ int claim_cmd(unit * u, struct order *ord) if (itype) { item **iclaim = i_find(&u->faction->items, itype); if (iclaim && *iclaim) { - n = _min(n, (*iclaim)->number); + n = MIN(n, (*iclaim)->number); i_change(iclaim, itype, -n); i_change(&u->items, itype, n); } @@ -3962,7 +3962,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; @@ -3998,9 +3998,9 @@ int siege_cmd(unit * u, order * ord) rt_catapult = rt_find("catapult"); d = i_get(u->items, rt_catapult->itype); - d = _min(u->number, d); + d = MIN(u->number, d); pooled = get_pooled(u, rt_catapultammo, GET_DEFAULT, d); - d = _min(pooled, d); + d = MIN(pooled, d); if (effskill(u, SK_CATAPULT, 0) >= 1) { katapultiere = d; d *= effskill(u, SK_CATAPULT, 0); @@ -4027,11 +4027,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))) { @@ -4270,7 +4270,7 @@ void processorders(void) void update_subscriptions(void) { FILE *F; - char zText[MAX_PATH]; + char zText[4096]; join_path(basepath(), "subscriptions", zText, sizeof(zText)); F = fopen(zText, "r"); diff --git a/src/laws.h b/src/laws.h index 0adb010d2..f05c11ab4 100755 --- a/src/laws.h +++ b/src/laws.h @@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define H_GC_LAWS #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/laws.test.c b/src/laws.test.c index 1bec0e6b4..b5471243a 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -531,7 +531,7 @@ static void test_pay_cmd_other_building(CuTest *tc) { config_set("rules.region_owner_pay_building", "lighthouse"); update_owners(b->region); - _snprintf(cmd, sizeof(cmd), "NOT %s", itoa36(b->no)); + snprintf(cmd, sizeof(cmd), "NOT %s", itoa36(b->no)); ord = create_order(K_PAY, f->locale, cmd); assert(ord); CuAssertPtrEquals(tc, fix.u1, building_owner(b)); diff --git a/src/lighthouse.c b/src/lighthouse.c index 09c9b7d11..d29d58b71 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -83,8 +83,8 @@ int lighthouse_range(const building * b, const faction * f) } else if (f == NULL || u->faction == f) { int sk = effskill(u, SK_PERCEPTION, 0) / 3; - d = _max(d, sk); - d = _min(maxd, d); + d = MAX(d, sk); + d = MIN(maxd, d); if (d == maxd) break; } diff --git a/src/lighthouse.h b/src/lighthouse.h index 3bf970bf1..f2974ddf1 100644 --- a/src/lighthouse.h +++ b/src/lighthouse.h @@ -19,6 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef LIGHTHOUSE_H #define LIGHTHOUSE_H +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/listbox.c b/src/listbox.c index 332041454..057240fad 100644 --- a/src/listbox.c +++ b/src/listbox.c @@ -27,7 +27,7 @@ insert_selection(list_selection ** p_sel, list_selection * prev, const char *str, void *payload) { list_selection *sel = calloc(sizeof(list_selection), 1); - sel->str = _strdup(str); + sel->str = strdup(str); sel->data = payload; if (*p_sel) { list_selection *s; diff --git a/src/magic.c b/src/magic.c index 2299e6523..dc56ad5ff 100644 --- a/src/magic.c +++ b/src/magic.c @@ -118,7 +118,7 @@ static double MagicPower(double force) if (force > 0) { const char *str = config_get("magic.power"); double value = str ? atof(str) : 1.0; - return _max(value * force, 1.0f); + return MAX(value * force, 1.0f); } return 0; } @@ -146,7 +146,7 @@ static void a_writeicastle(const attrib * a, const void *owner, struct storage *store) { icastle_data *data = (icastle_data *)a->data.v; - unused_arg(owner); + UNUSED_ARG(owner); WRITE_TOK(store, data->type->_name); WRITE_INT(store, data->time); } @@ -543,7 +543,7 @@ int get_combatspelllevel(const unit * u, int nr) assert(nr < MAXCOMBATSPELLS); if (m) { int level = effskill(u, SK_MAGIC, 0); - return _min(m->combatspells[nr].level, level); + return MIN(m->combatspells[nr].level, level); } return -1; } @@ -679,7 +679,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; @@ -739,7 +739,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) @@ -774,7 +774,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; } @@ -867,7 +867,7 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range) } 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 */ } @@ -885,7 +885,7 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range) if (sb) { spellbook_entry * sbe = spellbook_get(sb, 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)); @@ -1103,7 +1103,7 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order } } } - return _max(force, 0); + return MAX(force, 0); } /* ------------------------------------------------------------- */ @@ -1278,8 +1278,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 @@ -1421,7 +1421,7 @@ static void do_fumble(castorder * co) case 2: /* temporary skill loss */ - duration = _max(rng_int() % level / 2, 2); + duration = MAX(rng_int() % level / 2, 2); effect = level / -2.0; c = create_curse(u, &u->attribs, ct_find("skillmod"), level, duration, effect, 1); @@ -1529,14 +1529,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)); } } } @@ -1853,7 +1853,7 @@ static int addparam_string(const char *const param[], spllprm ** spobjp) spobj->flag = 0; spobj->typ = SPP_STRING; - spobj->data.xs = _strdup(param[0]); + spobj->data.xs = strdup(param[0]); return 1; } @@ -2428,7 +2428,7 @@ static int age_unit(attrib * a, void *owner) /* if unit is gone or dead, remove the attribute */ { unit *u = (unit *)a->data.v; - unused_arg(owner); + UNUSED_ARG(owner); return (u != NULL && u->number > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } @@ -2567,7 +2567,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" */ syntax_error(u, ord); @@ -2597,7 +2597,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" */ syntax_error(u, ord); @@ -2728,7 +2728,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, effskill(caster, SK_MAGIC, 0) / 2); + level = MIN(level, effskill(caster, SK_MAGIC, 0) / 2); } } /* Weitere Argumente zusammenbasteln */ @@ -2751,7 +2751,7 @@ static castorder *cast_cmd(unit * u, order * ord) break; } } - params[p++] = _strdup(s); + params[p++] = strdup(s); } params[p] = 0; args = diff --git a/src/magic.h b/src/magic.h index 59ef92475..964783c32 100644 --- a/src/magic.h +++ b/src/magic.h @@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define H_KRNL_MAGIC #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/market.test.c b/src/market.test.c index 43e070b5e..6f1d74b88 100644 --- a/src/market.test.c +++ b/src/market.test.c @@ -46,7 +46,7 @@ static void test_market_curse(CuTest * tc) config_set("rules.region_owners", "1"); btype = (building_type *)calloc(1, sizeof(building_type)); - btype->_name = _strdup("market"); + btype->_name = strdup("market"); bt_register(btype); terrain = get_terrain("plain"); diff --git a/src/modules/arena.c b/src/modules/arena.c index a912d273a..fbc3f0673 100644 --- a/src/modules/arena.c +++ b/src/modules/arena.c @@ -99,9 +99,9 @@ order * ord) if (u->building != arena_tower(u->faction->magiegebiet) && leave_fail(u)) { return -1; } - unused_arg(amount); - unused_arg(ord); - unused_arg(itype); + UNUSED_ARG(amount); + UNUSED_ARG(ord); + UNUSED_ARG(itype); assert(!"not implemented"); return 0; } @@ -120,9 +120,9 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord) region *r = u->region; unit *u2; int fee = 2000; - unused_arg(ord); - unused_arg(amount); - unused_arg(itype); + UNUSED_ARG(ord); + UNUSED_ARG(amount); + UNUSED_ARG(itype); if (u->faction->score > fee * 5) { score_t score = u->faction->score / 5; if (score < INT_MAX) { @@ -212,7 +212,7 @@ static int caldera_handle(trigger * t, void *data) else { log_error("could not perform caldera::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 5420406c0..54fd7411e 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -199,7 +199,7 @@ newfaction *read_newfactions(const char *filename) free(nf); continue; } - nf->password = _strdup(password); + nf->password = strdup(password); nf->race = rc_find(race); nf->subscription = subscription; if (alliances != NULL) { @@ -962,8 +962,8 @@ int build_island_e3(newfaction ** players, int x, int y, int numfactions, int mi q = region_quality(r, rn); if (q >= MIN_QUALITY && nfactions < numfactions && *players) { starting_region(players, r, rn); - minq = _min(minq, q); - maxq = _max(maxq, q); + minq = MIN(minq, q); + maxq = MAX(maxq, q); ++nfactions; } } @@ -977,8 +977,8 @@ int build_island_e3(newfaction ** players, int x, int y, int numfactions, int mi q = region_quality(r, rn); if (q >= MIN_QUALITY * 4 / 3 && nfactions < numfactions && *players) { starting_region(players, r, rn); - minq = _min(minq, q); - maxq = _max(maxq, q); + minq = MIN(minq, q); + maxq = MAX(maxq, q); ++nfactions; } } diff --git a/src/modules/museum.c b/src/modules/museum.c index e934a71a4..af37019d0 100644 --- a/src/modules/museum.c +++ b/src/modules/museum.c @@ -310,7 +310,7 @@ order * ord) unit *warden = findunit(atoi36("mwar")); int unit_cookie; - unused_arg(amount); + UNUSED_ARG(amount); /* Prfen ob in Eingangshalle */ if (u->region->x != 9525 || u->region->y != 9525) { @@ -365,7 +365,7 @@ order * ord) region *r = u->region; plane *pl = rplane(r); - unused_arg(amount); + UNUSED_ARG(amount); /* Pruefen ob in normaler Plane und nur eine Person */ if (pl != get_homeplane()) { @@ -417,8 +417,8 @@ static const char *b_namequestportal(const connection * b, const region * r, { const char *bname; int lock = b->data.i; - unused_arg(b); - unused_arg(r); + UNUSED_ARG(b); + UNUSED_ARG(r); if (gflags & GF_ARTICLE) { if (lock > 0) { diff --git a/src/modules/score.c b/src/modules/score.c index 8213b8985..0776d6507 100644 --- a/src/modules/score.c +++ b/src/modules/score.c @@ -67,7 +67,7 @@ void score(void) region *r; faction *fc; score_t allscores = 0; - char path[MAX_PATH]; + char path[4096]; for (fc = factions; fc; fc = fc->next) fc->score = 0; diff --git a/src/monsters.c b/src/monsters.c index db34bff2c..b613f48cc 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -100,7 +100,7 @@ static void reduce_weight(unit * u) int horses = get_resource(u, get_resourcetype(R_HORSE)); if (horses > 0) { - horses = _min(horses, (u->number * 2)); + horses = MIN(horses, (u->number * 2)); change_resource(u, get_resourcetype(R_HORSE), -horses); } @@ -129,7 +129,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_peasants(u, itm->type, reduce); weight -= reduce * itype->weight; } @@ -144,7 +144,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_peasants(u, itm->type, reduce); weight -= reduce * itype->weight; } @@ -1027,7 +1027,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); @@ -1047,7 +1047,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); @@ -1062,7 +1062,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. @@ -1074,7 +1074,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); @@ -1102,7 +1102,7 @@ static void scared_by_monster(unit * u) } if (n > 0) { n = lovar(n); - n = _min(rpeasants(u->region), n); + n = MIN(rpeasants(u->region), n); if (n > 0) { n = scareaway(u->region, n); if (n > 0) { diff --git a/src/morale.c b/src/morale.c index 8dc22ccb5..1bdf2363d 100644 --- a/src/morale.c +++ b/src/morale.c @@ -73,7 +73,7 @@ void morale_update(region *r) { void morale_change(region *r, int value) { int morale = region_get_morale(r); if (morale > 0) { - morale = _max(0, morale - value); + morale = MAX(0, morale - value); region_set_morale(r, morale, turn); } } diff --git a/src/move.c b/src/move.c index 126557d58..62300beb1 100644 --- a/src/move.c +++ b/src/move.c @@ -151,8 +151,8 @@ static void shiptrail_finalize(attrib * a) static int shiptrail_age(attrib * a, void *owner) { traveldir *t = (traveldir *)(a->data.v); - unused_arg(owner); + (void)owner; t->age--; return (t->age > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } @@ -267,12 +267,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, 0) * u->number * 2); + animals = MIN(animals, effskill(u, SK_RIDING, 0) * 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; } @@ -291,7 +291,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, 0) * u->number * 4); + pferde_fuer_wagen = MIN(animals, effskill(u, SK_RIDING, 0) * u->number * 4); if (fval(u_race(u), RCF_HORSE)) { animals += u->number; people = 0; @@ -301,7 +301,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; @@ -311,7 +311,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; @@ -335,7 +335,7 @@ int walkingcapacity(const struct unit *u) int belts = i_get(u->items, rbelt->itype); if (belts) { int multi = config_get_int("rules.trollbelt.multiplier", STRENGTHMULTIPLIER); - n += _min(people, belts) * (multi - 1) * u_race(u)->capacity; + n += MIN(people, belts) * (multi - 1) * u_race(u)->capacity; } } @@ -366,7 +366,7 @@ static int canwalk(unit * u) effsk = effskill(u, SK_RIDING, 0); maxwagen = effsk * u->number * 2; if (u_race(u) == get_race(RC_TROLL)) { - maxwagen = _max(maxwagen, u->number / 4); + maxwagen = MAX(maxwagen, u->number / 4); } maxpferde = effsk * u->number * 4 + u->number; @@ -505,7 +505,7 @@ static double overload(const region * r, ship * sh) double ovl = n / (double)sh->type->cargo; if (mcabins) - ovl = _max(ovl, p / (double)mcabins); + ovl = MAX(ovl, p / (double)mcabins); return ovl; } } @@ -752,7 +752,7 @@ double damage_overload(double overload) badness = overload - overload_worse(); if (badness >= 0) { assert(overload_worst() > overload_worse() || !"overload.worst must be > overload.worse"); - damage += _min(badness, overload_worst() - overload_worse()) * + damage += MIN(badness, overload_worst() - overload_worse()) * (overload_max_damage() - damage) / (overload_worst() - overload_worse()); } @@ -946,7 +946,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r) guard_count += u->number; double prob_u = (sk - stealth) * skill_prob; /* amulet counts at most once */ - prob_u += _min(1, _min(u->number, i_get(u->items, ramulet->itype))) * amulet_prob; + prob_u += MIN(1, MIN(u->number, i_get(u->items, ramulet->itype))) * amulet_prob; if (u->building && (u->building->type == castle_bt) && u == building_owner(u->building)) prob_u += castle_prob*buildingeffsize(u->building, 0); if (prob_u >= prob) { @@ -1985,7 +1985,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) const luxury_type *ltype = resource2luxury(itm->type->rtype); if (ltype != NULL && itm->number > 0) { int st = itm->number * effskill(harbourmaster, SK_TRADE, 0) / 50; - st = _min(itm->number, st); + st = MIN(itm->number, st); if (st > 0) { i_change(&u2->items, itm->type, -st); diff --git a/src/move.h b/src/move.h index 14c040493..4d0b4e9f2 100644 --- a/src/move.h +++ b/src/move.h @@ -16,11 +16,12 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ +#include "direction.h" +#include + #ifndef H_KRNL_MOVEMENT #define H_KRNL_MOVEMENT -#include "direction.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/src/names.c b/src/names.c index cf1cdb910..248084828 100644 --- a/src/names.c +++ b/src/names.c @@ -365,7 +365,7 @@ static void dracoid_name(unit * u) size_t sz; /* ignore u */ - unused_arg(u); + UNUSED_ARG(u); /* Wieviele Mittelteile? */ mid_syllabels = rng_int() % 4; @@ -425,8 +425,8 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) } } - /* Buchstaben pro Teilkrzel = _max(1,max/AnzWort) */ - bpt = (c > 0) ? _max(1, maxchars / c) : 1; + /* Buchstaben pro Teilkrzel = MAX(1,max/AnzWort) */ + bpt = (c > 0) ? MAX(1, maxchars / c) : 1; /* Einzelne Wrter anspringen und jeweils die ersten BpT kopieren */ diff --git a/src/platform.h b/src/platform.h index c781021ae..2f114cec5 100644 --- a/src/platform.h +++ b/src/platform.h @@ -1,179 +1,15 @@ -/* -Copyright (c) 1998-2015, Enno Rehling - Katja Zedel +#pragma once -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. +#ifndef UNILIB_H +#define UNILIB_H -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef PLATFORM_H -#define PLATFORM_H - -#ifdef NDEBUG -#define LOMEM +#ifndef MAX_PATH +# define MAX_PATH 4096 #endif -// enable X/Open 7 extensions (like strdup): -#ifndef _XOPEN_SOURCE -#define _XOPEN_SOURCE 700 -#endif +#define UNUSED_ARG(a) (void)(a) -// enable bsd string extensions, since glibc 2.12 (_BSD_SOURCE is dead): -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200809L -#endif - -#ifndef USE_AUTOCONF -#define USE_AUTOCONF - -#ifdef _MSC_VER -#undef USE_AUTOCONF -#define HAVE_STDBOOL_H -#define HAVE_DIRECT__MKDIR -#define HAVE__ACCESS - -#define VC_EXTRALEAN -#define WIN32_LEAN_AND_MEAN -#pragma warning(push) -#pragma warning(disable:4820 4255 4668) -# include -# include -#pragma warning(pop) -# undef MOUSE_MOVED -# define STDIO_CP 1252 /* log.c, convert to console character set */ -# pragma warning (disable: 4201 4214 4514 4115 4711) -#if _MSC_VER >= 1900 -# pragma warning(disable: 4710) -/* warning C4710: function not inlined */ -# pragma warning(disable: 4456) -/* warning C4456 : declaration of hides previous local declaration */ -# pragma warning(disable: 4457) -/* warning C4457: declaration of hides function parameter */ -# pragma warning(disable: 4459) -/* warning C4459: declaration of hides global declaration */ -#endif -# pragma warning(disable: 4056) -/* warning C4056: overflow in floating point constant arithmetic */ -# pragma warning(disable: 4201) -/* warning C4201: nonstandard extension used : nameless struct/union */ -# pragma warning(disable: 4214) -/* warning C4214: nonstandard extension used : bit field types other than int */ -# pragma warning(disable: 4100) -/* warning C4100: : unreferenced formal parameter */ -# pragma warning(disable: 4996) -/* is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' */ -# pragma warning(disable: 4668) -/* : bytes padding after data member */ -# pragma warning(disable: 4820) - -/* warning C4100: was declared deprecated */ -#ifndef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_DEPRECATE -#endif - -/* - * http://msdn2.microsoft.com/en-us/library/ms235505(VS.80).aspx - * Defining _CRT_DISABLE_PERFCRIT_LOCKS forces all I/O operations to assume a - * single-threaded I/O model and use the _nolock forms of the functions. - */ -#ifndef _CRT_DISABLE_PERFCRIT_LOCKS -#define _CRT_DISABLE_PERFCRIT_LOCKS -#endif - -#elif __GNUC__ -#undef USE_AUTOCONF -#define HAVE_SNPRINTF -#define HAVE_SYS_STAT_MKDIR -#define HAVE_STRDUP -#define HAVE_UNISTD_H -#endif -#endif - -#ifdef USE_AUTOCONF -// unknown toolchain, using autoconf -#include -#endif - -#define unused_arg (void) - -#define iswxspace(c) (c==160 || iswspace(c)) -#define isxspace(c) (c==160 || isspace(c)) - -#define TOLUA_CAST (char*) - -#if !defined(MAX_PATH) -#if defined(PATH_MAX) -# define MAX_PATH PATH_MAX -#else -# define MAX_PATH 256 -#endif -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - -#if defined(HAVE_STDBOOL_H) -# include -#else -# ifndef 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) -#endif -#endif - -#if defined(HAVE_DIRECT__MKDIR) -#include -#elif defined(HAVE_DIRECT_MKDIR) -#include -#define _mkdir(a) mkdir(a) -#elif defined(HAVE_SYS_STAT_MKDIR) -#include -#define _mkdir(a) mkdir(a, 0777) -#endif - -#ifndef _min -#define _min(a,b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef _max -#define _max(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#if !defined(HAVE__STRDUP) -#if defined(HAVE_STRDUP) -#undef _strdup -#define _strdup strdup -#endif -#endif - -#if !defined(HAVE__SNPRINTF) -#if defined(HAVE_SNPRINTF) -#define _snprintf snprintf -#endif -#endif +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif - diff --git a/src/prefix.c b/src/prefix.c index a6564b6e8..1a22e6982 100644 --- a/src/prefix.c +++ b/src/prefix.c @@ -30,7 +30,7 @@ int add_raceprefix(const char *prefix) race_prefixes = tmp; size *= 2; } - race_prefixes[next++] = _strdup(prefix); + race_prefixes[next++] = strdup(prefix); race_prefixes[next] = NULL; return 0; } diff --git a/src/races/dragons.c b/src/races/dragons.c index 222d63c89..aa79a783a 100644 --- a/src/races/dragons.c +++ b/src/races/dragons.c @@ -22,7 +22,7 @@ /* util includes */ #include -#define age_chance(a,b,p) (_max(0,a-b)*p) +#define age_chance(a,b,p) (MAX(0,a-b)*p) #define DRAGONAGE 27 #define WYRMAGE 68 diff --git a/src/races/races.c b/src/races/races.c index 2c6cfffa9..8af9cf2ed 100644 --- a/src/races/races.c +++ b/src/races/races.c @@ -42,7 +42,7 @@ static void oldfamiliars(unit * u) char fname[64]; /* these familiars have no special skills. */ - _snprintf(fname, sizeof(fname), "%s_familiar", u_race(u)->_name); + snprintf(fname, sizeof(fname), "%s_familiar", u_race(u)->_name); create_mage(u, M_GRAY); equip_unit(u, get_equipment(fname)); } diff --git a/src/races/zombies.c b/src/races/zombies.c index 3e9303b38..ea26298b2 100644 --- a/src/races/zombies.c +++ b/src/races/zombies.c @@ -33,7 +33,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 make_undead_unit(unit * u) { @@ -70,7 +70,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, get_race(RC_SKELETON_LORD)); u->irace = NULL; @@ -82,7 +82,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, get_race(RC_ZOMBIE_LORD)); u->irace = NULL; @@ -94,7 +94,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, get_race(RC_GHOUL_LORD)); u->irace = NULL; diff --git a/src/randenc.c b/src/randenc.c index 536210b1f..ab51d64b1 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -785,7 +785,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)) { continue; } @@ -814,7 +814,7 @@ void randomevents(void) while (*blist) { building *b = *blist; if (fval(b->type, BTF_DECAY) && !building_owner(b)) { - b->size -= _max(1, (b->size * 20) / 100); + b->size -= MAX(1, (b->size * 20) / 100); if (b->size == 0) { remove_building(blist, r->buildings); } diff --git a/src/report.c b/src/report.c index 0c7697fe5..9b5e243b4 100644 --- a/src/report.c +++ b/src/report.c @@ -269,17 +269,17 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc /* Reihenfolge beachten: Erst REGION, dann STUFE! */ if (sp->sptyp & FARCASTING) { - bytes = _snprintf(bufp, size, " [%s x y]", LOC(lang, parameters[P_REGION])); + bytes = snprintf(bufp, size, " [%s x y]", LOC(lang, parameters[P_REGION])); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } if (sp->sptyp & SPELLLEVEL) { - bytes = _snprintf(bufp, size, " [%s n]", LOC(lang, parameters[P_LEVEL])); + bytes = snprintf(bufp, size, " [%s n]", LOC(lang, parameters[P_LEVEL])); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } - bytes = (int)_snprintf(bufp, size, " \"%s\"", spell_name(sp, lang)); + bytes = (int)snprintf(bufp, size, " \"%s\"", spell_name(sp, lang)); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -305,12 +305,12 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc if (cp == 'u') { targetp = targets + 1; locp = LOC(lang, targetp->vars); - bytes = (int)_snprintf(bufp, size, " <%s>", locp); + bytes = (int)snprintf(bufp, size, " <%s>", locp); if (*params == '+') { ++params; if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp); + bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -318,12 +318,12 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc else if (cp == 's') { targetp = targets + 2; locp = LOC(lang, targetp->vars); - bytes = (int)_snprintf(bufp, size, " <%s>", locp); + bytes = (int)snprintf(bufp, size, " <%s>", locp); if (*params == '+') { ++params; if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp); + bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -342,12 +342,12 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc else if (cp == 'b') { targetp = targets + 3; locp = LOC(lang, targetp->vars); - bytes = (int)_snprintf(bufp, size, " <%s>", locp); + bytes = (int)snprintf(bufp, size, " <%s>", locp); if (*params == '+') { ++params; if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp); + bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -382,17 +382,17 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc if (targetp->param && targetp->vars) { locp = LOC(lang, targetp->vars); bytes = - (int)_snprintf(bufp, size, " %s <%s>", parameters[targetp->param], + (int)snprintf(bufp, size, " %s <%s>", parameters[targetp->param], locp); if (multi) { if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp); + bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); } } else { bytes = - (int)_snprintf(bufp, size, " %s", parameters[targetp->param]); + (int)snprintf(bufp, size, " %s", parameters[targetp->param]); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -422,10 +422,10 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc } if (*params == '?') { ++params; - bytes = (int)_snprintf(bufp, size, " [<%s>]", locp); + bytes = (int)snprintf(bufp, size, " [<%s>]", locp); } else { - bytes = (int)_snprintf(bufp, size, " <%s>", locp); + bytes = (int)snprintf(bufp, size, " <%s>", locp); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -494,18 +494,18 @@ void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *la bufp = buf; if (sp->sptyp & SPELLLEVEL) { bytes = - _snprintf(bufp, size, " %d %s", itemanz, LOC(lang, resourcename(rtype, + snprintf(bufp, size, " %d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1))); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR) { - bytes = _snprintf(bufp, size, " * %s", LOC(lang, "nr_level")); + bytes = snprintf(bufp, size, " * %s", LOC(lang, "nr_level")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } } else { - bytes = _snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1))); + bytes = snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1))); if (wrptr(&bufp, &size, bytes) != 0) { WARN_STATIC_BUFFER(); } @@ -929,7 +929,7 @@ static void describe(struct stream *out, const region * r, faction * f) } if (!e) { e = calloc(sizeof(struct edge), 1); - e->name = _strdup(name); + e->name = strdup(name); e->transparent = transparent; e->next = edges; edges = e; @@ -945,13 +945,13 @@ static void describe(struct stream *out, const region * r, faction * f) WARN_STATIC_BUFFER(); if (r->seen.mode == seen_travel) { - bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel")); + bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel")); } else if (r->seen.mode == seen_neighbour) { - bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour")); + bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour")); } else if (r->seen.mode == seen_lighthouse) { - bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse")); + bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse")); } else { bytes = 0; @@ -974,7 +974,7 @@ static void describe(struct stream *out, const region * r, faction * f) saplings = rtrees(r, 1); if (production(r)) { if (trees > 0 || saplings > 0) { - bytes = _snprintf(bufp, size, ", %d/%d ", trees, saplings); + bytes = snprintf(bufp, size, ", %d/%d ", trees, saplings); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1004,7 +1004,7 @@ static void describe(struct stream *out, const region * r, faction * f) for (n = 0; n < numresults; ++n) { if (result[n].number >= 0 && result[n].level >= 0) { - bytes = _snprintf(bufp, size, ", %d %s/%d", result[n].number, + bytes = snprintf(bufp, size, ", %d %s/%d", result[n].number, LOC(f->locale, result[n].name), result[n].level); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1015,14 +1015,14 @@ static void describe(struct stream *out, const region * r, faction * f) /* peasants & silver */ if (rpeasants(r)) { int n = rpeasants(r); - bytes = _snprintf(bufp, size, ", %d", n); + bytes = snprintf(bufp, size, ", %d", n); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); if (r->land->ownership) { const char *str = LOC(f->locale, mkname("morale", itoa10(region_get_morale(r)))); - bytes = _snprintf(bufp, size, " %s", str); + bytes = snprintf(bufp, size, " %s", str); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } @@ -1041,7 +1041,7 @@ static void describe(struct stream *out, const region * r, faction * f) } } if (rmoney(r) && r->seen.mode >= seen_travel) { - bytes = _snprintf(bufp, size, ", %d ", rmoney(r)); + bytes = snprintf(bufp, size, ", %d ", rmoney(r)); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); bytes = @@ -1053,7 +1053,7 @@ static void describe(struct stream *out, const region * r, faction * f) /* Pferde */ if (rhorses(r)) { - bytes = _snprintf(bufp, size, ", %d ", rhorses(r)); + bytes = snprintf(bufp, size, ", %d ", rhorses(r)); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); bytes = @@ -1141,7 +1141,7 @@ static void describe(struct stream *out, const region * r, faction * f) if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); f_regionid(r2, f, regname, sizeof(regname)); - bytes = _snprintf(bufp, size, trailinto(r2, f->locale), regname); + bytes = snprintf(bufp, size, trailinto(r2, f->locale), regname); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } @@ -1453,7 +1453,7 @@ report_template(const char *filename, report_context * ctx, const char *bom) bufp = buf; size = sizeof(buf) - 1; - bytes = _snprintf(bufp, size, "%s %s; %s [%d,%d$", + bytes = snprintf(bufp, size, "%s %s; %s [%d,%d$", LOC(u->faction->locale, parameters[P_UNIT]), itoa36(u->no), unit_getname(u), u->number, get_money(u)); if (wrptr(&bufp, &size, bytes) != 0) @@ -1631,7 +1631,7 @@ static void allies(struct stream *out, const faction * f) if (f->allies) { int bytes; size_t size = sizeof(buf); - bytes = _snprintf(buf, size, "%s ", LOC(f->locale, "faction_help")); + bytes = snprintf(buf, size, "%s ", LOC(f->locale, "faction_help")); size -= bytes; show_allies(f, f->allies, buf + bytes, size); paragraph(out, buf, 0, 0, 0); @@ -1642,7 +1642,7 @@ static void allies(struct stream *out, const faction * f) if (g->allies) { int bytes; size_t size = sizeof(buf); - bytes = _snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help")); + bytes = snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help")); size -= bytes; show_allies(f, g->allies, buf + bytes, size); paragraph(out, buf, 0, 0, 0); @@ -1781,12 +1781,12 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, getshipweight(sh, &n, &p); n = (n + 99) / 100; /* 1 Silber = 1 GE */ - bytes = _snprintf(bufp, size, "%s, %s, (%d/%d)", shipname(sh), + bytes = snprintf(bufp, size, "%s, %s, (%d/%d)", shipname(sh), LOC(f->locale, sh->type->_name), n, shipcapacity(sh) / 100); } else { bytes = - _snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale, + snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale, sh->type->_name)); } if (wrptr(&bufp, &size, bytes) != 0) @@ -1794,7 +1794,7 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, assert(sh->type->construction->improvement == NULL); /* sonst ist construction::size nicht ship_type::maxsize */ if (sh->size != sh->type->construction->maxsize) { - bytes = _snprintf(bufp, size, ", %s (%d/%d)", + bytes = snprintf(bufp, size, ", %s (%d/%d)", LOC(f->locale, "nr_undercons"), sh->size, sh->type->construction->maxsize); if (wrptr(&bufp, &size, bytes) != 0) @@ -1803,7 +1803,7 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, if (sh->damage) { int percent = ship_damage_percent(sh); bytes = - _snprintf(bufp, size, ", %d%% %s", percent, LOC(f->locale, "nr_damaged")); + snprintf(bufp, size, ", %d%% %s", percent, LOC(f->locale, "nr_damaged")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } @@ -1852,7 +1852,7 @@ nr_building(struct stream *out, const region *r, const building *b, const factio lang = f->locale; newline(out); bytes = - _snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang, + snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang, "nr_size"), b->size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1867,7 +1867,7 @@ nr_building(struct stream *out, const region *r, const building *b, const factio if (owner && owner->faction == f) { /* illusion. report real type */ name = LOC(lang, bname); - bytes = _snprintf(bufp, size, " (%s)", name); + bytes = snprintf(bufp, size, " (%s)", name); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } @@ -2168,7 +2168,7 @@ report_plaintext(const char *filename, report_context * ctx, bufp = buf; size = sizeof(buf) - 1; - bytes = _snprintf(buf, size, "%s:", LOC(f->locale, "nr_options")); + bytes = snprintf(buf, size, "%s:", LOC(f->locale, "nr_options")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); for (op = 0; op != MAXOPTIONS; op++) { @@ -2220,14 +2220,14 @@ report_plaintext(const char *filename, report_context * ctx, newline(out); centre(out, LOC(f->locale, pname), true); - _snprintf(buf, sizeof(buf), "%s %d", LOC(f->locale, "nr_level"), + snprintf(buf, sizeof(buf), "%s %d", LOC(f->locale, "nr_level"), ptype->level); centre(out, buf, true); newline(out); bufp = buf; size = sizeof(buf) - 1; - bytes = _snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired")); + bytes = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); diff --git a/src/report.test.c b/src/report.test.c index 202458db5..ab7c377ce 100644 --- a/src/report.test.c +++ b/src/report.test.c @@ -140,7 +140,7 @@ static void cleanup_spell_fixture(spell_fixture *spf) { static void set_parameter(spell_fixture spell, char *value) { free(spell.sp->parameter); - spell.sp->parameter = _strdup(value); + spell.sp->parameter = strdup(value); } static void check_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char *syntax) { @@ -211,14 +211,14 @@ static void test_write_spell_syntax(CuTest *tc) { set_parameter(spell, "bc"); free(spell.sp->syntax); - spell.sp->syntax = _strdup("hodor"); + spell.sp->syntax = strdup("hodor"); check_spell_syntax(tc, "bc hodor", &spell, " ZAUBERE \"Testzauber\" "); free(spell.sp->syntax); spell.sp->syntax = 0; set_parameter(spell, "c?"); free(spell.sp->syntax); - spell.sp->syntax = _strdup("hodor"); + spell.sp->syntax = strdup("hodor"); check_spell_syntax(tc, "c?", &spell, " ZAUBERE \"Testzauber\" []"); free(spell.sp->syntax); spell.sp->syntax = 0; diff --git a/src/reports.c b/src/reports.c index 52278d270..b31ecac19 100644 --- a/src/reports.c +++ b/src/reports.c @@ -529,7 +529,7 @@ size_t size) if (a_otherfaction && alliedunit(u, f, HELP_FSTEALTH)) { faction *f = get_otherfaction(a_otherfaction); int result = - _snprintf(bufp, size, ", %s (%s)", factionname(f), + snprintf(bufp, size, ", %s (%s)", factionname(f), factionname(u->faction)); if (wrptr(&bufp, &size, result) != 0) WARN_STATIC_BUFFER(); @@ -544,7 +544,7 @@ size_t size) bufp = STRLCPY(bufp, ", ", size); - if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d ", u->number))) + if (wrptr(&bufp, &size, snprintf(bufp, size, "%d ", u->number))) WARN_STATIC_BUFFER(); pzTmp = get_racename(u->attribs); @@ -641,7 +641,7 @@ size_t size) bufp = STRLCPY(bufp, ", ", size); if (!dh) { - result = _snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_inventory")); + result = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_inventory")); if (wrptr(&bufp, &size, result) != 0) WARN_STATIC_BUFFER(); dh = 1; @@ -650,7 +650,7 @@ size_t size) bufp = STRLCPY(bufp, ic, size); } else { - if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d %s", in, ic))) + if (wrptr(&bufp, &size, snprintf(bufp, size, "%d %s", in, ic))) WARN_STATIC_BUFFER(); } } @@ -661,7 +661,7 @@ size_t size) if (book) { quicklist *ql = book->spells; int qi, header, maxlevel = effskill(u, SK_MAGIC, 0); - int result = _snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u)); + int result = snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u)); if (wrptr(&bufp, &size, result) != 0) { WARN_STATIC_BUFFER(); } @@ -671,7 +671,7 @@ size_t size) if (sbe->level <= maxlevel) { int result = 0; if (!header) { - result = _snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells")); + result = snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells")); header = 1; } else { @@ -690,7 +690,7 @@ size_t size) } if (i != MAXCOMBATSPELLS) { int result = - _snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_combatspells")); + snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_combatspells")); if (wrptr(&bufp, &size, result) != 0) WARN_STATIC_BUFFER(); @@ -708,7 +708,7 @@ size_t size) int sl = get_combatspelllevel(u, i); bufp = STRLCPY(bufp, spell_name(sp, u->faction->locale), size); if (sl > 0) { - result = _snprintf(bufp, size, " (%d)", sl); + result = snprintf(bufp, size, " (%d)", sl); if (wrptr(&bufp, &size, result) != 0) WARN_STATIC_BUFFER(); } @@ -819,13 +819,13 @@ const struct unit * u, struct skill * sv, int *dh, int days) if (sv->id == SK_STEALTH && fval(u, UFL_STEALTH)) { i = u_geteffstealth(u); if (i >= 0) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d/", i)) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, "%d/", i)) != 0) WARN_STATIC_BUFFER(); } } effsk = eff_skill(u, sv, 0); - if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d", effsk)) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, "%d", effsk)) != 0) WARN_STATIC_BUFFER(); if (u->faction->options & want(O_SHOWSKCHANGE)) { @@ -836,11 +836,11 @@ const struct unit * u, struct skill * sv, int *dh, int days) 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) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, " (%s%d)", (diff > 0) ? "+" : "", diff)) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " (%s%d)", (diff > 0) ? "+" : "", diff)) != 0) WARN_STATIC_BUFFER(); } } @@ -877,7 +877,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned firstline = false; } if (!cut) { - cut = s + _min(len, REPORTWIDTH); + cut = s + MIN(len, REPORTWIDTH); } memcpy(buf + indent, s, cut - s); buf[indent + (cut - s)] = 0; @@ -1412,7 +1412,7 @@ int write_reports(faction * f, time_t ltime) int error = 0; do { char filename[32]; - char path[MAX_PATH]; + char path[4096]; sprintf(filename, "%d-%s.%s", turn, itoa36(f->no), rtype->extension); join_path(reportpath(), filename, path, sizeof(path)); @@ -1482,7 +1482,7 @@ int reports(void) FILE *mailit; time_t ltime = time(NULL); int retval = 0; - char path[MAX_PATH]; + char path[4096]; const char * rpath = reportpath(); log_info("Writing reports for turn %d:", turn); @@ -1509,7 +1509,7 @@ int reports(void) static variant var_copy_string(variant x) { - x.v = x.v ? _strdup((const char *)x.v) : 0; + x.v = x.v ? strdup((const char *)x.v) : 0; return x; } @@ -1613,7 +1613,7 @@ f_regionid(const region * r, const faction * f, char *buffer, size_t size) pnormalize(&nx, &ny, pl); adjust_coordinates(f, &nx, &ny, pl); len = strlcpy(buffer, rname(r, f ? f->locale : 0), size); - _snprintf(buffer + len, size - len, " (%d,%d%s%s)", nx, ny, named ? "," : "", (named) ? name : ""); + snprintf(buffer + len, size - len, " (%d,%d%s%s)", nx, ny, named ? "," : "", (named) ? name : ""); buffer[size - 1] = 0; len = strlen(buffer); } @@ -1864,7 +1864,7 @@ static void eval_order(struct opstack **stack, const void *userdata) size_t len; variant var; - unused_arg(userdata); + UNUSED_ARG(userdata); write_order(ord, buf, sizeof(buf)); len = strlen(buf); var.v = strcpy(balloc(len + 1), buf); @@ -1884,7 +1884,7 @@ static void eval_resources(struct opstack **stack, const void *userdata) while (res != NULL && size > 4) { const char *rname = resourcename(res->type, (res->number != 1) ? NMF_PLURAL : 0); - int result = _snprintf(bufp, size, "%d %s", res->number, LOC(lang, rname)); + int result = snprintf(bufp, size, "%d %s", res->number, LOC(lang, rname)); if (wrptr(&bufp, &size, result) != 0 || size < sizeof(buf) / 2) { WARN_STATIC_BUFFER(); break; @@ -1948,7 +1948,7 @@ static void eval_trail(struct opstack **stack, const void *userdata) variant var; char *bufp = buf; #ifdef _SECURECRT_ERRCODE_VALUES_DEFINED - /* stupid MS broke _snprintf */ + /* stupid MS broke snprintf */ int eold = errno; #endif @@ -1959,7 +1959,7 @@ static void eval_trail(struct opstack **stack, const void *userdata) const char *trail = trailinto(r, lang); const char *rn = f_regionid_s(r, report); - if (wrptr(&bufp, &size, _snprintf(bufp, size, trail, rn)) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, trail, rn)) != 0) WARN_STATIC_BUFFER(); if (i + 2 < end) { @@ -2015,7 +2015,7 @@ static void eval_int36(struct opstack **stack, const void *userdata) var.v = strcpy(balloc(len + 1), c); opush(stack, var); - unused_arg(userdata); + UNUSED_ARG(userdata); } /*** END MESSAGE RENDERING ***/ diff --git a/src/skill.h b/src/skill.h index 8b0c0c155..24f96a844 100644 --- a/src/skill.h +++ b/src/skill.h @@ -3,7 +3,7 @@ #ifndef H_SKILL_H #define H_SKILL_H -#include +#include struct locale; typedef enum { diff --git a/src/spells.c b/src/spells.c index 7e7b5669a..6ed38d022 100644 --- a/src/spells.c +++ b/src/spells.c @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -149,7 +150,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 */ @@ -190,7 +191,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) { @@ -231,7 +232,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) { @@ -272,7 +273,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) { @@ -704,7 +705,7 @@ static int sp_destroy_magic(castorder * co) "unit region command", mage, mage->region, co->order)); } - return _max(succ, 1); + return MAX(succ, 1); } /* ------------------------------------------------------------- */ @@ -773,7 +774,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; @@ -912,7 +913,7 @@ static int sp_summonent(castorder * co) return 0; } - ents = _min((int)(power * power), rtrees(r, 2)); + ents = MIN((int)(power * power), rtrees(r, 2)); u = create_unit(r, mage->faction, ents, get_race(RC_TREEMAN), 0, NULL, mage); @@ -1304,7 +1305,7 @@ static int sp_rosthauch(castorder * co) for (; iweapon != NULL; iweapon = iweapon->next) { item **ip = i_find(&u->items, iweapon->type); if (*ip) { - float chance = (float)_min((*ip)->number, force); + float chance = (float)MIN((*ip)->number, force); if (iweapon->chance < 1.0) { chance *= iweapon->chance; } @@ -1343,7 +1344,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); } /* ------------------------------------------------------------- */ @@ -1373,7 +1374,7 @@ static int sp_kaelteschutz(castorder * co) unit *mage = co->magician.u; int cast_level = co->level; double force = co->force; - int duration = _max(cast_level, (int)force) + 1; + int duration = MAX(cast_level, (int)force) + 1; spellparameter *pa = co->par; double effect; @@ -2137,8 +2138,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 { double effect = 4.0; @@ -2335,8 +2336,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? */ @@ -2501,7 +2502,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 * @@ -2529,7 +2530,7 @@ static int sp_fumblecurse(castorder * co) rx = rng_int() % 3; sx = cast_level - effskill(target, SK_MAGIC, 0); - duration = _max(sx, rx) + 1; + duration = MAX(sx, rx) + 1; effect = force / 2; c = create_curse(mage, &target->attribs, ct_find("fumble"), @@ -2695,8 +2696,8 @@ static int sp_firewall(castorder * co) } 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 */ @@ -2938,7 +2939,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 @@ -3361,7 +3362,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 = get_race(RC_SKELETON); @@ -3409,7 +3410,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)) { @@ -3792,8 +3793,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); @@ -4032,13 +4033,13 @@ static int sp_recruit(castorder * co) n = (pow(force, 1.6) * 100) / f->race->recruitcost; if (rc->recruit_multi > 0) { double multp = (double)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); } @@ -4083,13 +4084,13 @@ static int sp_bigrecruit(castorder * co) n = (int)force + lovar((force * force * 1000) / (float)f->race->recruitcost); if (f->race == get_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); } @@ -4178,7 +4179,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 * @@ -4215,8 +4216,8 @@ static int sp_seduce(castorder * co) int loot; if (itm->type->rtype == rsilver) { 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; @@ -4224,7 +4225,7 @@ static int sp_seduce(castorder * co) loot += rng_int() % 2; } if (loot > 0) { - loot = _min(loot, (int)(force * 5)); + loot = MIN(loot, (int)(force * 5)); } } if (loot > 0) { @@ -4341,7 +4342,7 @@ static int sp_headache(castorder * co) } if (smax != NULL) { /* wirkt auf maximal 10 Personen */ - unsigned int change = _min(10, target->number) * (rng_uint() % 2 + 1) / target->number; + unsigned int change = MIN(10, target->number) * (rng_uint() % 2 + 1) / target->number; reduce_skill(target, smax, change); } set_order(&target->thisorder, NULL); @@ -4385,7 +4386,7 @@ static int sp_raisepeasants(castorder * co) "error_nopeasants", "")); return 0; } - bauern = _min(rpeasants(r), (int)(power * 250)); + bauern = MIN(rpeasants(r), (int)(power * 250)); rsetpeasants(r, rpeasants(r) - bauern); u2 = @@ -4468,7 +4469,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); @@ -4713,7 +4714,7 @@ static int sp_gbdreams(castorder * co, const char *curse_name, int effect) /* 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. */ @@ -4752,7 +4753,7 @@ int sp_clonecopy(castorder * co) return 0; } - _snprintf(name, sizeof(name), (const char *)LOC(mage->faction->locale, + slprintf(name, sizeof(name), (const char *)LOC(mage->faction->locale, "clone_of"), unitname(mage)); clone = create_unit(target_region, mage->faction, 1, get_race(RC_CLONE), 0, name, @@ -4855,7 +4856,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. */ @@ -4969,7 +4970,7 @@ int sp_itemcloak(castorder * co) spellparameter *pa = co->par; int cast_level = co->level; double 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) @@ -5027,7 +5028,7 @@ int sp_resist_magic_bonus(castorder * co) u = pa->param[n]->data.u; - m = _min(u->number, victims); + m = MIN(u->number, victims); victims -= m; create_curse(mage, &u->attribs, ct_find("magicresistance"), @@ -5043,8 +5044,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'. @@ -5656,7 +5657,7 @@ int sp_showastral(castorder * co) free_regionlist(rl); return cast_level; - unused_arg(co); + UNUSED_ARG(co); return 0; } #endif @@ -5907,7 +5908,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); @@ -6216,7 +6217,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++) { double effect; @@ -6230,7 +6231,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; @@ -6241,7 +6242,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); } /* ------------------------------------------------------------- */ @@ -6324,7 +6325,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); } /* ------------------------------------------------------------- */ diff --git a/src/spells/borders.c b/src/spells/borders.c index 04f7e15f4..00019e92c 100644 --- a/src/spells/borders.c +++ b/src/spells/borders.c @@ -206,7 +206,7 @@ struct region *from, struct region *to, bool routing) 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", @@ -227,9 +227,9 @@ static const char *b_namefirewall(const connection * b, const region * r, const faction * f, int gflags) { const char *bname; - unused_arg(f); - unused_arg(r); - unused_arg(b); + UNUSED_ARG(f); + UNUSED_ARG(r); + UNUSED_ARG(b); if (gflags & GF_ARTICLE) bname = "a_firewall"; else diff --git a/src/spells/borders.h b/src/spells/borders.h index 31823df94..b14661b9f 100644 --- a/src/spells/borders.h +++ b/src/spells/borders.h @@ -1,5 +1,8 @@ #ifndef H_KRNL_CURSES #define H_KRNL_CURSES + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/spells/buildingcurse.c b/src/spells/buildingcurse.c index 01b0435ab..158383fd2 100644 --- a/src/spells/buildingcurse.c +++ b/src/spells/buildingcurse.c @@ -36,7 +36,7 @@ message *cinfo_building(const void *obj, objtype_t typ, const curse * c, int self) { const building *b = (const building *)obj; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_BUILDING); assert(obj); assert(c); diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index da7e7085a..0e1a27e75 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -337,14 +337,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; @@ -921,7 +921,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 = @@ -1015,7 +1015,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; @@ -1050,7 +1050,7 @@ int sp_chaosrow(struct castorder * co) } k += df->alive; } - power = _max(0, power - n); + power = MAX(0, power - n); } ql_free(fgs); @@ -1154,12 +1154,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 = @@ -1208,7 +1208,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; @@ -1264,7 +1264,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); @@ -1545,7 +1545,7 @@ int sp_fumbleshield(struct castorder * co) case SPL_CERDDOR_FUMBLESHIELD: case SPL_TYBIED_FUMBLESHIELD: duration = 100; - effect = _max(1, 25 - level); + effect = MAX(1, 25 - level); break; default: @@ -1596,7 +1596,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 @@ -1649,7 +1649,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; } @@ -1680,10 +1680,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; @@ -1834,7 +1834,7 @@ int sp_undeadhero(struct castorder * co) } ql_free(fgs); - level = _min(level, undead); + level = MIN(level, undead); if (undead == 0) { msg = msg_message("summonundead_effect_0", "mage region", mage, mage->region); diff --git a/src/spells/flyingship.h b/src/spells/flyingship.h index 8b7bf0874..52013ac13 100644 --- a/src/spells/flyingship.h +++ b/src/spells/flyingship.h @@ -3,6 +3,8 @@ #ifndef FLYINGSHIP_H #define FLYINGSHIP_H +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/spells/regioncurse.c b/src/spells/regioncurse.c index 3d7593484..b10f3046f 100644 --- a/src/spells/regioncurse.c +++ b/src/spells/regioncurse.c @@ -45,8 +45,8 @@ static message *cinfo_cursed_by_the_gods(const void *obj, objtype_t typ, { region *r = (region *)obj; - unused_arg(typ); - unused_arg(self); + UNUSED_ARG(typ); + UNUSED_ARG(self); assert(typ == TYP_REGION); if (r->terrain->flags & SEA_REGION) { @@ -68,9 +68,9 @@ static struct curse_type ct_godcursezone = { static message *cinfo_dreamcurse(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(self); - unused_arg(typ); - unused_arg(obj); + UNUSED_ARG(self); + UNUSED_ARG(typ); + UNUSED_ARG(obj); assert(typ == TYP_REGION); if (c->effect > 0) { @@ -94,9 +94,9 @@ static struct curse_type ct_gbdream = { static message *cinfo_magicstreet(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); - unused_arg(self); - unused_arg(obj); + UNUSED_ARG(typ); + UNUSED_ARG(self); + UNUSED_ARG(obj); assert(typ == TYP_REGION); /* Warnung vor Auflsung */ @@ -117,9 +117,9 @@ static struct curse_type ct_magicstreet = { static message *cinfo_antimagiczone(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); - unused_arg(self); - unused_arg(obj); + UNUSED_ARG(typ); + UNUSED_ARG(self); + UNUSED_ARG(obj); assert(typ == TYP_REGION); /* Magier spren eine Antimagiezone */ @@ -139,7 +139,7 @@ const curse * c, int self) unit *u = NULL; unit *mage = c->magician; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_REGION); r = (region *)obj; @@ -167,8 +167,8 @@ static struct curse_type ct_antimagiczone = { static message *cinfo_farvision(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); - unused_arg(obj); + UNUSED_ARG(typ); + UNUSED_ARG(obj); assert(typ == TYP_REGION); diff --git a/src/spells/shipcurse.c b/src/spells/shipcurse.c index 59cc534d4..b6a722ad3 100644 --- a/src/spells/shipcurse.c +++ b/src/spells/shipcurse.c @@ -38,8 +38,8 @@ message *cinfo_ship(const void *obj, objtype_t typ, const curse * c, int self) { message *msg; - unused_arg(typ); - unused_arg(obj); + UNUSED_ARG(typ); + UNUSED_ARG(obj); assert(typ == TYP_SHIP); if (self != 0) { /* owner or inside */ @@ -62,7 +62,7 @@ static message *cinfo_shipnodrift(const void *obj, objtype_t typ, const curse * { ship *sh = (ship *)obj; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_SHIP); if (self != 0) { diff --git a/src/spells/unitcurse.c b/src/spells/unitcurse.c index 6e769145e..ded4a1676 100644 --- a/src/spells/unitcurse.c +++ b/src/spells/unitcurse.c @@ -46,7 +46,7 @@ static message *cinfo_auraboost(const void *obj, objtype_t typ, const curse * c, int self) { struct unit *u = (struct unit *)obj; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); if (self != 0) { @@ -80,7 +80,7 @@ static message *cinfo_slave(const void *obj, objtype_t typ, const curse * c, int self) { unit *u; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); u = (unit *)obj; @@ -104,7 +104,7 @@ cinfo_slave static message *cinfo_calm(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); if (c->magician && c->magician->faction) { @@ -133,7 +133,7 @@ static struct curse_type ct_calmmonster = { static message *cinfo_speed(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); if (self != 0) { @@ -156,7 +156,7 @@ static struct curse_type ct_speed = { */ message *cinfo_unit(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); assert(obj); @@ -181,7 +181,7 @@ static struct curse_type ct_orcish = { static message *cinfo_kaelteschutz(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); if (self != 0) { @@ -233,7 +233,7 @@ static message *cinfo_sparkle(const void *obj, objtype_t typ, const curse * c, }; int m, begin = 0, end = 0; unit *u; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); u = (unit *)obj; @@ -324,7 +324,7 @@ write_skill(struct storage *store, const curse * c, const void *target) static message *cinfo_skillmod(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); + UNUSED_ARG(typ); if (self != 0) { unit *u = (unit *)obj; diff --git a/src/spy.c b/src/spy.c index 22c548d68..a7d08d42e 100644 --- a/src/spy.c +++ b/src/spy.c @@ -148,7 +148,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 = effskill(u, SK_SPY, 0) - effskill(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); @@ -164,7 +164,7 @@ int spy_cmd(unit * u, struct order *ord) - (effskill(u, SK_STEALTH, 0) + effskill(u, SK_SPY, 0) / 2); if (invisible(u, target) >= u->number) { - observe = _min(observe, 0); + observe = MIN(observe, 0); } /* Anschliessend wird - unabhaengig vom Erfolg - gewuerfelt, ob der @@ -354,7 +354,7 @@ static int top_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 = effskill(u, sk, 0); - value = _max(s, value); + value = MAX(s, value); } } return value; diff --git a/src/sqlite.c b/src/sqlite.c index 42bfdb3b5..aea0f5d20 100644 --- a/src/sqlite.c +++ b/src/sqlite.c @@ -94,9 +94,9 @@ read_factions(sqlite3 * db, int game_id) { text = (const char *)sqlite3_column_text(stmt, 1); if (text) dbf->no = atoi36(text); text = (const char *)sqlite3_column_text(stmt, 2); - if (text) dbf->name = _strdup(text); + if (text) dbf->name = strdup(text); text = (const char *)sqlite3_column_text(stmt, 3); - if (text) dbf->email = _strdup(text); + if (text) dbf->email = strdup(text); ql_push(&result, dbf); res = sqlite3_step(stmt); } diff --git a/src/study.c b/src/study.c index 58cd068f2..b69b4359f 100644 --- a/src/study.c +++ b/src/study.c @@ -201,7 +201,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); @@ -215,7 +215,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) { if (teach == NULL) { @@ -267,7 +267,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; @@ -303,7 +303,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); @@ -604,7 +604,7 @@ int study_cmd(unit * u, order * ord) } /* Akademie: */ if (active_building(u, bt_find("academy"))) { - studycost = _max(50, studycost * 2); + studycost = MAX(50, studycost * 2); } if (sk == SK_MAGIC) { @@ -691,11 +691,11 @@ int study_cmd(unit * u, order * ord) if (studycost) { int cost = studycost * u->number; money = get_pooled(u, get_resourcetype(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); @@ -715,12 +715,12 @@ int study_cmd(unit * u, order * ord) } if (get_effect(u, oldpotiontype[P_WISE])) { - l = _min(u->number, get_effect(u, oldpotiontype[P_WISE])); + l = MIN(u->number, get_effect(u, oldpotiontype[P_WISE])); teach->value += l * 10; change_effect(u, oldpotiontype[P_WISE], -l); } if (get_effect(u, oldpotiontype[P_FOOL])) { - l = _min(u->number, get_effect(u, oldpotiontype[P_FOOL])); + l = MIN(u->number, get_effect(u, oldpotiontype[P_FOOL])); teach->value -= l * 30; change_effect(u, oldpotiontype[P_FOOL], -l); } diff --git a/src/summary.c b/src/summary.c index 8a3ee3c41..32416a263 100644 --- a/src/summary.c +++ b/src/summary.c @@ -97,8 +97,8 @@ int update_nmrs(void) if (timeout>0) { if (nmr < 0 || nmr > timeout) { log_error("faction %s has %d NMR", itoa36(f->no), nmr); - nmr = _max(0, nmr); - nmr = _min(nmr, timeout); + nmr = MAX(0, nmr); + nmr = MIN(nmr, timeout); } if (nmr > 0) { log_debug("faction %s has %d NMR", itoa36(f->no), nmr); @@ -164,7 +164,7 @@ static char *gamedate2(const struct locale *lang) static void writeturn(void) { - char zText[MAX_PATH]; + char zText[4096]; FILE *f; join_path(basepath(), "datum", zText, sizeof(zText)); @@ -190,7 +190,7 @@ void report_summary(summary * s, summary * o, bool full) FILE *F = NULL; int i, newplayers = 0; faction *f; - char zText[MAX_PATH]; + char zText[4096]; int timeout = NMRTimeout(); if (full) { diff --git a/src/test_eressea.c b/src/test_eressea.c index 6d2dead3f..02d52c5ed 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -33,7 +33,7 @@ static void add_suite(CuSuite *(*csuite)(void), const char *name, int argc, char } if (s) { s->next = suites; - s->name = _strdup(name); + s->name = strdup(name); s->csuite = csuite(); suites = s; } diff --git a/src/travelthru.test.c b/src/travelthru.test.c index be87743d2..09d807674 100644 --- a/src/travelthru.test.c +++ b/src/travelthru.test.c @@ -15,7 +15,7 @@ struct attrib; static void count_travelers(region *r, unit *u, void *cbdata) { int *n = (int *)cbdata; - unused_arg(r); + UNUSED_ARG(r); *n += u->number; } diff --git a/src/triggers/changefaction.c b/src/triggers/changefaction.c index 37d993f4a..3de537c7b 100644 --- a/src/triggers/changefaction.c +++ b/src/triggers/changefaction.c @@ -70,7 +70,7 @@ static int changefaction_handle(trigger * t, void *data) else { log_error("could not perform changefaction::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/changerace.c b/src/triggers/changerace.c index f38b7f3d5..a9f282698 100644 --- a/src/triggers/changerace.c +++ b/src/triggers/changerace.c @@ -74,7 +74,7 @@ static int changerace_handle(trigger * t, void *data) else { log_error("could not perform changerace::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/clonedied.c b/src/triggers/clonedied.c index 642b50ab0..f3d1fc00b 100644 --- a/src/triggers/clonedied.c +++ b/src/triggers/clonedied.c @@ -58,7 +58,7 @@ static int clonedied_handle(trigger * t, void *data) } else log_error("could not perform clonedied::handle()\n"); - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/createcurse.c b/src/triggers/createcurse.c index 040a4e7b7..3eb0891ca 100644 --- a/src/triggers/createcurse.c +++ b/src/triggers/createcurse.c @@ -76,7 +76,7 @@ static int createcurse_handle(trigger * t, void *data) else { log_error("could not perform createcurse::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/createunit.c b/src/triggers/createunit.c index 5952c88bc..41573d86b 100644 --- a/src/triggers/createunit.c +++ b/src/triggers/createunit.c @@ -74,7 +74,7 @@ static int createunit_handle(trigger * t, void *data) else { log_error("could not perform createunit::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/gate.c b/src/triggers/gate.c index e681efc04..c70163a14 100644 --- a/src/triggers/gate.c +++ b/src/triggers/gate.c @@ -57,7 +57,7 @@ static int gate_handle(trigger * t, void *data) log_error("could not perform gate::handle()\n"); return -1; } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/giveitem.c b/src/triggers/giveitem.c index 6b0e8f8c7..9bc2c56e1 100644 --- a/src/triggers/giveitem.c +++ b/src/triggers/giveitem.c @@ -70,7 +70,7 @@ static int giveitem_handle(trigger * t, void *data) else { log_error("could not perform giveitem::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/killunit.c b/src/triggers/killunit.c index 22ad27896..3e6c9defe 100644 --- a/src/triggers/killunit.c +++ b/src/triggers/killunit.c @@ -48,7 +48,7 @@ static int killunit_handle(trigger * t, void *data) /* we can't remove_unit() here, because that's what's calling us. */ set_number(u, 0); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/shock.c b/src/triggers/shock.c index 7c54676e0..31424e979 100644 --- a/src/triggers/shock.c +++ b/src/triggers/shock.c @@ -60,8 +60,8 @@ static void do_shock(unit * u, const char *reason) if (u->number > 0) { /* HP - Verlust */ int hp = (unit_max_hp(u) * u->number) / 10; - hp = _min(u->hp, hp); - u->hp = _max(1, hp); + hp = MIN(u->hp, hp); + u->hp = MAX(1, hp); } /* Aura - Verlust */ @@ -102,7 +102,7 @@ static int shock_handle(trigger * t, void *data) if (u && u->number) { do_shock(u, "trigger"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/timeout.c b/src/triggers/timeout.c index 10e4d08be..43bb061c8 100644 --- a/src/triggers/timeout.c +++ b/src/triggers/timeout.c @@ -61,7 +61,7 @@ static int timeout_handle(trigger * t, void *data) handle_triggers(&td->triggers, NULL); return -1; } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/unitmessage.c b/src/triggers/unitmessage.c index 0c1e80124..7ba97d9bc 100644 --- a/src/triggers/unitmessage.c +++ b/src/triggers/unitmessage.c @@ -71,7 +71,7 @@ static int unitmessage_handle(trigger * t, void *data) td->level); } } - unused_arg(data); + UNUSED_ARG(data); return 0; } @@ -92,7 +92,7 @@ static int unitmessage_read(trigger * t, gamedata *data) int result = read_reference(&td->target, data, read_unit_reference, resolve_unit); READ_TOK(data->store, zText, sizeof(zText)); - td->string = _strdup(zText); + td->string = strdup(zText); READ_INT(data->store, &td->type); READ_INT(data->store, &td->level); @@ -117,7 +117,7 @@ trigger *trigger_unitmessage(unit * target, const char *string, int type, trigger *t = t_new(&tt_unitmessage); unitmessage_data *td = (unitmessage_data *)t->data.v; td->target = target; - td->string = _strdup(string); + td->string = strdup(string); td->type = type; td->level = level; return t; diff --git a/src/upkeep.c b/src/upkeep.c index 1cf41011f..94cbc341d 100644 --- a/src/upkeep.c +++ b/src/upkeep.c @@ -47,7 +47,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); @@ -161,7 +161,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; } @@ -174,7 +174,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); @@ -191,7 +191,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; @@ -247,7 +247,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); if (blut) { change_effect(donor, pt_blood, -blut); hungry -= blut; @@ -295,7 +295,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); } } diff --git a/src/util/attrib.c b/src/util/attrib.c index 4bdf35bfa..a99a70ba3 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -124,7 +124,7 @@ int a_readstring(attrib * a, void *owner, struct gamedata *data) len += DISPLAYSIZE - 1; } else { - result = _strdup(buf); + result = strdup(buf); } } while (e == ENOMEM); a->data.v = result; diff --git a/src/util/attrib.h b/src/util/attrib.h index d93ce1240..45dc9b942 100644 --- a/src/util/attrib.h +++ b/src/util/attrib.h @@ -19,6 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef ATTRIB_H #define ATTRIB_H +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/util/attrib.test.c b/src/util/attrib.test.c index 7fa2ef82c..b44afeec2 100644 --- a/src/util/attrib.test.c +++ b/src/util/attrib.test.c @@ -119,7 +119,7 @@ static void test_attrib_rwstring(CuTest *tc) { attrib a = { 0 }; test_setup(); - a.data.v = _strdup("Hello World"); + a.data.v = strdup("Hello World"); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); a_writestring(&a, NULL, &store); diff --git a/src/util/crmessage.c b/src/util/crmessage.c index 98afe0f05..47bb6bf7d 100644 --- a/src/util/crmessage.c +++ b/src/util/crmessage.c @@ -145,21 +145,21 @@ int cr_render(const message * msg, char *buffer, const void *userdata) int cr_string(variant var, char *buffer, const void *userdata) { sprintf(buffer, "\"%s\"", (const char *)var.v); - unused_arg(userdata); + UNUSED_ARG(userdata); return 0; } int cr_int(variant var, char *buffer, const void *userdata) { sprintf(buffer, "%d", var.i); - unused_arg(userdata); + UNUSED_ARG(userdata); return 0; } int cr_ignore(variant var, char *buffer, const void *userdata) { - unused_arg(var); - unused_arg(buffer); - unused_arg(userdata); + UNUSED_ARG(var); + UNUSED_ARG(buffer); + UNUSED_ARG(userdata); return -1; } diff --git a/src/util/event.c b/src/util/event.c index cdf178aec..78a6d6fbc 100644 --- a/src/util/event.c +++ b/src/util/event.c @@ -153,7 +153,7 @@ static int read_handler(attrib * a, void *owner, gamedata *data) handler_info *hi = (handler_info *)a->data.v; READ_TOK(store, zText, sizeof(zText)); - hi->event = _strdup(zText); + hi->event = strdup(zText); read_triggers(data, &hi->triggers); if (hi->triggers != NULL) { return AT_READ_OK; @@ -200,7 +200,7 @@ void add_trigger(struct attrib **ap, const char *eventname, struct trigger *t) if (a == NULL || a->type != &at_eventhandler) { a = a_add(ap, a_new(&at_eventhandler)); td = (handler_info *)a->data.v; - td->event = _strdup(eventname); + td->event = strdup(eventname); } tp = &td->triggers; while (*tp) diff --git a/src/util/goodies.c b/src/util/goodies.c index 2444d0f47..c478bcf83 100644 --- a/src/util/goodies.c +++ b/src/util/goodies.c @@ -113,7 +113,7 @@ int set_email(char **pemail, const char *newmail) free(*pemail); *pemail = 0; if (newmail) { - *pemail = _strdup(newmail); + *pemail = strdup(newmail); } return 0; } diff --git a/src/util/language.c b/src/util/language.c index cb91d7419..efd5cd5f7 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -86,7 +86,7 @@ locale *get_or_create_locale(const char *name) *lp = l = (locale *)calloc(sizeof(locale), 1); assert_alloc(l); l->hashkey = hkey; - l->name = _strdup(name); + l->name = strdup(name); l->index = nextlocaleindex++; assert(nextlocaleindex <= MAXLOCALES); if (default_locale == NULL) default_locale = l; @@ -209,15 +209,15 @@ void locale_setstring(locale * lang, const char *key, const char *value) find->nexthash = lang->strings[id]; lang->strings[id] = find; find->hashkey = hkey; - find->key = _strdup(key); - find->str = _strdup(value); + find->key = strdup(key); + find->str = strdup(value); } else { if (strcmp(find->str, value) != 0) { log_warning("multiple translations for key %s\n", key); } free(find->str); - find->str = _strdup(value); + find->str = strdup(value); } } diff --git a/src/util/language.h b/src/util/language.h index a90398cc0..36bc58378 100644 --- a/src/util/language.h +++ b/src/util/language.h @@ -19,7 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef MY_LOCALE_H #define MY_LOCALE_H -#include +#include #ifdef __cplusplus extern "C" { diff --git a/src/util/lists.c b/src/util/lists.c index d61327fa0..be3deeffd 100644 --- a/src/util/lists.c +++ b/src/util/lists.c @@ -127,7 +127,7 @@ void addstrlist(strlist ** SP, const char *s) { strlist *slist = malloc(sizeof(strlist)); slist->next = NULL; - slist->s = _strdup(s); + slist->s = strdup(s); addlist(SP, slist); } diff --git a/src/util/log.test.c b/src/util/log.test.c index 55616c026..1558ee3e3 100644 --- a/src/util/log.test.c +++ b/src/util/log.test.c @@ -9,9 +9,9 @@ void log_string(void *data, int level, const char *module, const char *format, va_list args) { char *str = (char *)data; const char *arg = va_arg(args, const char *); - unused_arg(format); - unused_arg(module); - unused_arg(level); + UNUSED_ARG(format); + UNUSED_ARG(module); + UNUSED_ARG(level); strcpy(str, arg); } diff --git a/src/util/message.c b/src/util/message.c index 5b6f12eb8..b5a9592bd 100644 --- a/src/util/message.c +++ b/src/util/message.c @@ -73,7 +73,7 @@ message_type *mt_new(const char *name, const char *args[]) while (args[nparameters]) ++nparameters; } mtype->key = 0; - mtype->name = _strdup(name); + mtype->name = strdup(name); mtype->nparameters = nparameters; if (nparameters > 0) { mtype->pnames = (char **)malloc(sizeof(char *) * nparameters); diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index e3b0bcc0b..8156b9784 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -91,7 +91,7 @@ const nrsection *section_add(const char *name) } if (!*mcp) { nrsection *mc = calloc(sizeof(nrsection), 1); - mc->name = _strdup(name); + mc->name = strdup(name); *mcp = mc; } return *mcp; @@ -130,14 +130,14 @@ const char *string, int level, const char *section) nrt->section = NULL; nrtypes[hash] = nrt; assert(string && *string); - nrt->string = _strdup(string); + nrt->string = strdup(string); *c = '\0'; for (i = 0; i != mtype->nparameters; ++i) { if (i != 0) *c++ = ' '; c += strlcpy(c, mtype->pnames[i], sizeof(zNames)-(c-zNames)); } - nrt->vars = _strdup(zNames); + nrt->vars = strdup(zNames); } } diff --git a/src/util/translation.c b/src/util/translation.c index 829a1fe05..b0933d322 100644 --- a/src/util/translation.c +++ b/src/util/translation.c @@ -414,7 +414,7 @@ static void eval_lt(opstack ** stack, const void *userdata) int b = opop_i(stack); int rval = (b < a) ? 1 : 0; opush_i(stack, rval); - unused_arg(userdata); + UNUSED_ARG(userdata); } static void eval_eq(opstack ** stack, const void *userdata) @@ -423,7 +423,7 @@ static void eval_eq(opstack ** stack, const void *userdata) int b = opop_i(stack); int rval = (a == b) ? 1 : 0; opush_i(stack, rval); - unused_arg(userdata); + UNUSED_ARG(userdata); } static void eval_add(opstack ** stack, const void *userdata) @@ -431,14 +431,14 @@ static void eval_add(opstack ** stack, const void *userdata) int a = opop_i(stack); int b = opop_i(stack); opush_i(stack, a + b); - unused_arg(userdata); + UNUSED_ARG(userdata); } static void eval_isnull(opstack ** stack, const void *userdata) { /* (int, int) -> int */ void *a = opop_v(stack); opush_i(stack, (a == NULL) ? 1 : 0); - unused_arg(userdata); + UNUSED_ARG(userdata); } static void eval_if(opstack ** stack, const void *userdata) @@ -447,14 +447,14 @@ static void eval_if(opstack ** stack, const void *userdata) void *b = opop_v(stack); int cond = opop_i(stack); opush_v(stack, cond ? b : a); - unused_arg(userdata); + UNUSED_ARG(userdata); } static void eval_strlen(opstack ** stack, const void *userdata) { /* string -> int */ const char *c = (const char *)opop_v(stack); opush_i(stack, c ? (int)strlen(c) : 0); - unused_arg(userdata); + UNUSED_ARG(userdata); } #include "base36.h" diff --git a/src/vortex.c b/src/vortex.c index 725460ce2..7b6206d03 100644 --- a/src/vortex.c +++ b/src/vortex.c @@ -70,7 +70,7 @@ static void a_freedirection(attrib * a) static int a_agedirection(attrib * a, void *owner) { spec_direction *d = (spec_direction *)(a->data.v); - unused_arg(owner); + (void)owner; --d->duration; return (d->duration > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } @@ -81,14 +81,14 @@ static int a_readdirection(attrib * a, void *owner, struct gamedata *data) spec_direction *d = (spec_direction *)(a->data.v); char lbuf[32]; - unused_arg(owner); + (void)owner; READ_INT(store, &d->x); READ_INT(store, &d->y); READ_INT(store, &d->duration); READ_TOK(store, lbuf, sizeof(lbuf)); - d->desc = _strdup(lbuf); + d->desc = strdup(lbuf); READ_TOK(store, lbuf, sizeof(lbuf)); - d->keyword = _strdup(lbuf); + d->keyword = strdup(lbuf); d->active = true; return AT_READ_OK; } @@ -98,7 +98,7 @@ a_writedirection(const attrib * a, const void *owner, struct storage *store) { spec_direction *d = (spec_direction *)(a->data.v); - unused_arg(owner); + (void)owner; WRITE_INT(store, d->x); WRITE_INT(store, d->y); WRITE_INT(store, d->duration); @@ -143,8 +143,8 @@ attrib *create_special_direction(region * r, region * rt, int duration, d->x = rt->x; d->y = rt->y; d->duration = duration; - d->desc = _strdup(desc); - d->keyword = _strdup(keyword); + d->desc = strdup(desc); + d->keyword = strdup(keyword); return a; } diff --git a/src/vortex.h b/src/vortex.h index af41b6111..993f5cdab 100644 --- a/src/vortex.h +++ b/src/vortex.h @@ -1,5 +1,10 @@ +#pragma once + #ifndef H_VORTEX #define H_VORTEX + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/wormhole.c b/src/wormhole.c index 6a115a9f7..46425a0c1 100644 --- a/src/wormhole.c +++ b/src/wormhole.c @@ -63,7 +63,7 @@ static int wormhole_age(struct attrib *a, void *owner) region *r = entry->region; unit *u = r->units; - unused_arg(owner); + UNUSED_ARG(owner); for (; u != NULL && maxtransport != 0; u = u->next) { if (u->building == entry) { message *m = NULL; From ddd074f393f3203feb1d3fc236f6af610c6d02d9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Jan 2017 18:05:48 +0100 Subject: [PATCH 320/675] continue fixing compilation (gcc/clang) --- src/bind_faction.c | 1 + src/kernel/alliance.h | 3 +++ src/kernel/order.h | 1 + src/keyword.h | 2 ++ src/platform.h | 3 +++ src/util/filereader.c | 15 ++++++++------- src/util/parser.c | 8 ++++---- src/util/parser.h | 1 + src/util/password.h | 1 + src/util/rand.h | 4 ++++ src/util/translation.c | 1 + 11 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/bind_faction.c b/src/bind_faction.c index 36da798c1..2ace2ae52 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -36,6 +36,7 @@ without prior permission by the authors of Eressea. #include #include +#include typedef struct helpmode { const char *name; diff --git a/src/kernel/alliance.h b/src/kernel/alliance.h index 907fc65f7..4be05b871 100644 --- a/src/kernel/alliance.h +++ b/src/kernel/alliance.h @@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_KRNL_ALLIANCE #define H_KRNL_ALLIANCE + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/order.h b/src/kernel/order.h index 69cf1ea33..7f4b00a5e 100644 --- a/src/kernel/order.h +++ b/src/kernel/order.h @@ -15,6 +15,7 @@ #include "keyword.h" #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/keyword.h b/src/keyword.h index e60d0731f..1d8f04bb2 100644 --- a/src/keyword.h +++ b/src/keyword.h @@ -2,6 +2,8 @@ #define H_KEYWORD_H #include "kernel/types.h" +#include + #ifdef __cplusplus extern "C" { diff --git a/src/platform.h b/src/platform.h index 2f114cec5..7f82f46a8 100644 --- a/src/platform.h +++ b/src/platform.h @@ -3,6 +3,8 @@ #ifndef UNILIB_H #define UNILIB_H +#define _POSIX_C_SOURCE 200809L + #ifndef MAX_PATH # define MAX_PATH 4096 #endif @@ -12,4 +14,5 @@ #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define TOLUA_CAST (char*) #endif diff --git a/src/util/filereader.c b/src/util/filereader.c index 3223ca2ab..d36d3ca71 100644 --- a/src/util/filereader.c +++ b/src/util/filereader.c @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -30,7 +31,7 @@ static int eatwhite(const char *ptr, size_t * total_size) ret = unicode_utf8_to_ucs4(&ucs, ptr, &size); if (ret != 0) break; - if (!iswxspace((wint_t)ucs)) + if (!iswspace((wint_t)ucs)) break; *total_size += size; ptr += size; @@ -52,7 +53,7 @@ static const char *getbuf_latin1(FILE * F) if (bp == NULL) return NULL; - while (*bp && isxspace(*(unsigned char *)bp)) + while (*bp && isspace(*(unsigned char *)bp)) ++bp; /* eatwhite */ comment = (bool)(comment && cont); @@ -113,15 +114,15 @@ static const char *getbuf_latin1(FILE * F) if (iscntrl(c)) { if (!comment && cp < fbuf + MAXLINE) { - *cp++ = isxspace(c) ? ' ' : '?'; + *cp++ = isspace(c) ? ' ' : '?'; } ++bp; continue; } - else if (isxspace(c)) { + else if (isspace(c)) { if (!quote) { ++bp; - while (*bp && isxspace(*(unsigned char *)bp)) + while (*bp && isspace(*(unsigned char *)bp)) ++bp; /* eatwhite */ if (!comment && *bp && *bp != COMMENT_CHAR && cp < fbuf + MAXLINE) *(cp++) = ' '; @@ -136,7 +137,7 @@ static const char *getbuf_latin1(FILE * F) } else if (c == CONTINUE_CHAR) { const char *end = ++bp; - while (*end && isxspace(*(unsigned char *)end)) + while (*end && isspace(*(unsigned char *)end)) ++end; /* eatwhite */ if (*end == '\0') { bp = end; @@ -269,7 +270,7 @@ static const char *getbuf_utf8(FILE * F) break; } - if (iswxspace((wint_t)ucs)) { + if (iswspace((wint_t)ucs)) { if (!quote) { bp += size; ret = eatwhite(bp, &size); diff --git a/src/util/parser.c b/src/util/parser.c index 0fbde6769..bbdb5ac7e 100644 --- a/src/util/parser.c +++ b/src/util/parser.c @@ -32,7 +32,7 @@ static int eatwhitespace_c(const char **str_p) for (;;) { unsigned char utf8_character = (unsigned char)*str; if (~utf8_character & 0x80) { - if (!iswxspace(utf8_character)) + if (!iswspace(utf8_character)) break; ++str; } @@ -42,7 +42,7 @@ static int eatwhitespace_c(const char **str_p) log_warning("illegal character sequence in UTF8 string: %s\n", str); break; } - if (!iswxspace((wint_t)ucs)) + if (!iswspace((wint_t)ucs)) break; str += len; } @@ -106,7 +106,7 @@ void skip_token(void) log_warning("illegal character sequence in UTF8 string: %s\n", states->current_token); } } - if (iswxspace((wint_t)ucs) && quotechar == 0) { + if (iswspace((wint_t)ucs) && quotechar == 0) { return; } else { @@ -163,7 +163,7 @@ char *parse_token(const char **str, char *lbuf, size_t buflen) copy = true; escape = false; } - else if (iswxspace((wint_t)ucs)) { + else if (iswspace((wint_t)ucs)) { if (quotechar == 0) break; copy = true; diff --git a/src/util/parser.h b/src/util/parser.h index 802fc56cb..0c8306931 100644 --- a/src/util/parser.h +++ b/src/util/parser.h @@ -12,6 +12,7 @@ #define UTIL_PARSER_H #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/util/password.h b/src/util/password.h index e1d49fb6d..b83d544a6 100644 --- a/src/util/password.h +++ b/src/util/password.h @@ -1,5 +1,6 @@ #pragma once +#include #define PASSWORD_PLAINTEXT 0 #define PASSWORD_DEFAULT PASSWORD_PLAINTEXT diff --git a/src/util/rand.h b/src/util/rand.h index 9fb3f2f69..e9d9062b7 100644 --- a/src/util/rand.h +++ b/src/util/rand.h @@ -1,3 +1,4 @@ +#pragma once /* Copyright (c) 1998-2015, Enno Rehling Katja Zedel + #ifdef __cplusplus extern "C" { #endif diff --git a/src/util/translation.c b/src/util/translation.c index b0933d322..c733cc272 100644 --- a/src/util/translation.c +++ b/src/util/translation.c @@ -21,6 +21,7 @@ /* libc includes */ #include #include +#include #include #include From b27e1a01aab35c0c1c185cafae488e3312ea3018 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Jan 2017 18:07:36 +0100 Subject: [PATCH 321/675] continued work for MSVC compilation --- src/alchemy.c | 4 ++++ src/battle.c | 11 +++++++++-- src/donations.c | 1 + src/economy.c | 38 +++++++++++++++++++------------------- src/kernel/messages.h | 2 +- src/move.c | 11 +++++++++-- src/names.c | 2 +- src/platform.h | 23 +++++++++++++++++++++++ src/reports.c | 16 ++++++++-------- src/spells.c | 8 +++++++- src/spells/combatspells.c | 4 ++-- src/util/rand.h | 3 +++ 12 files changed, 87 insertions(+), 36 deletions(-) diff --git a/src/alchemy.c b/src/alchemy.c index ddbe46b8e..81244eba1 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -162,6 +162,7 @@ static int potion_healing(unit * u, int amount) { static int potion_luck(unit *u, region *r, attrib_type *atype, int amount) { attrib *a = (attrib *)a_find(r->attribs, atype); + UNUSED_ARG(u); if (!a) { a = a_add(&r->attribs, a_new(atype)); } @@ -170,6 +171,7 @@ static int potion_luck(unit *u, region *r, attrib_type *atype, int amount) { } static int potion_truth(unit *u) { + UNUSED_ARG(u); // TODO: this potion does nothing! // fset(u, UFL_DISBELIEVES); return 1; @@ -304,6 +306,7 @@ static void a_writeeffect(const attrib * a, const void *owner, struct storage *store) { effect_data *edata = (effect_data *)a->data.v; + UNUSED_ARG(owner); WRITE_TOK(store, resourcename(edata->type->itype->rtype, 0)); WRITE_INT(store, edata->value); } @@ -316,6 +319,7 @@ static int a_readeffect(attrib * a, void *owner, struct gamedata *data) effect_data *edata = (effect_data *)a->data.v; char zText[32]; + UNUSED_ARG(owner); READ_TOK(store, zText, sizeof(zText)); rtype = rt_find(zText); diff --git a/src/battle.c b/src/battle.c index 3b34cd162..7e5c4b9d8 100644 --- a/src/battle.c +++ b/src/battle.c @@ -509,6 +509,9 @@ contest_new(int skilldiff, const troop dt, const armor_type * ar, const armor_type * sh) { double tohit = 0.5 + skilldiff * 0.1; + + UNUSED_ARG(sh); + UNUSED_ARG(ar); if (tohit < 0.5) tohit = 0.5; if (chance(tohit)) { @@ -839,6 +842,7 @@ int select_magicarmor(troop t) /* Sind side ds und Magier des meffect verb�ndet, dann return 1*/ bool meffect_protection(battle * b, meffect * s, side * ds) { + UNUSED_ARG(b); if (!s->magician->alive) return false; if (s->duration <= 0) @@ -853,6 +857,7 @@ bool meffect_protection(battle * b, meffect * s, side * ds) /* Sind side as und Magier des meffect verfeindet, dann return 1*/ bool meffect_blocked(battle * b, meffect * s, side * as) { + UNUSED_ARG(b); if (!s->magician->alive) return false; if (s->duration <= 0) @@ -1763,8 +1768,8 @@ void do_combatmagic(battle * b, combatmagic_t was) for (co = spellranks[rank].begin; co; co = co->next) { fighter *fig = co->magician.fig; const spell *sp = co->sp; - int level = co->level; + level = co->level; if (!sp->cast) { log_error("spell '%s' has no function.\n", sp->sname); } @@ -2040,6 +2045,7 @@ int hits(troop at, troop dt, weapon * awp) void dazzle(battle * b, troop * td) { + UNUSED_ARG(b); /* Nicht kumulativ ! */ #ifdef TODO_RUNESWORD if (td->fighter->weapon[WP_RUNESWORD].count > td->index) { @@ -2487,6 +2493,7 @@ troop select_ally(fighter * af, int minrow, int maxrow, int allytype) static int loot_quota(const unit * src, const unit * dst, const item_type * type, int n) { + UNUSED_ARG(type); if (dst && src && src->faction != dst->faction) { double divisor = config_get_flt("rules.items.loot_divisor", 1); assert(divisor <= 0 || divisor >= 1); @@ -2636,7 +2643,6 @@ static void reorder_fleeing(region * r) static void aftermath(battle * b) { region *r = b->region; - ship *sh; side *s; int dead_players = 0; bfaction *bf; @@ -2833,6 +2839,7 @@ static void aftermath(battle * b) * dieses Schiff besch�digt. Andernfalls ein Schiff, welches * evt. zuvor verlassen wurde. */ if (ships_damaged) { + ship *sh; if (du->ship) sh = du->ship; else diff --git a/src/donations.c b/src/donations.c index 8f820df2b..7d2f15816 100644 --- a/src/donations.c +++ b/src/donations.c @@ -1,3 +1,4 @@ +#include #include #include "donations.h" diff --git a/src/economy.c b/src/economy.c index 7edbbcb12..16b201555 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1041,10 +1041,10 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) static int required(int want, double save) { - int norders = (int)(want * save); - if (norders < want * save) - ++norders; - return norders; + int req = (int)(want * save); + if (req < want * save) + ++req; + return req; } static void @@ -1058,7 +1058,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) if (rm != NULL) { do { int avail = rm->amount; - int norders = 0; + int nreq = 0; allocation *al; if (avail <= 0) { @@ -1077,7 +1077,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) if (effskill(al->unit, itype->construction->skill, 0) >= rm->level + itype->construction->minskill - 1) { if (req) { - norders += req; + nreq += req; } else { fset(al, AFL_DONE); @@ -1089,22 +1089,22 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) fset(al, AFL_LOWSKILL); } } - need = norders; + need = nreq; - avail = MIN(avail, norders); + avail = MIN(avail, nreq); if (need > 0) { int use = 0; for (al = alist; al; al = al->next) if (!fval(al, AFL_DONE)) { if (avail > 0) { int want = required(al->want - al->get, al->save); - int x = avail * want / norders; + int x = avail * want / nreq; /* Wenn Rest, dann wrfeln, ob ich was bekomme: */ - if (rng_int() % norders < (avail * want) % norders) + if (rng_int() % nreq < (avail * want) % nreq) ++x; avail -= x; use += x; - norders -= want; + nreq -= want; need -= x; al->get = MIN(al->want, al->get + (int)(x / al->save)); } @@ -1113,7 +1113,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) assert(use <= rm->amount); rm->type->use(rm, r, use); } - assert(avail == 0 || norders == 0); + assert(avail == 0 || nreq == 0); } first = false; } while (need > 0); @@ -1124,13 +1124,13 @@ static void attrib_allocation(const resource_type * rtype, region * r, allocation * alist) { allocation *al; - int norders = 0; + int nreq = 0; attrib *a = a_find(rtype->attribs, &at_resourcelimit); resource_limit *rdata = (resource_limit *)a->data.v; int avail = rdata->value; for (al = alist; al; al = al->next) { - norders += required(al->want, al->save); + nreq += required(al->want, al->save); } if (rdata->limit) { @@ -1139,16 +1139,16 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) avail = 0; } - avail = MIN(avail, norders); + avail = MIN(avail, nreq); for (al = alist; al; al = al->next) { if (avail > 0) { int want = required(al->want, al->save); - int x = avail * want / norders; + int x = avail * want / nreq; /* Wenn Rest, dann wrfeln, ob ich was bekomme: */ - if (rng_int() % norders < (avail * want) % norders) + if (rng_int() % nreq < (avail * want) % nreq) ++x; avail -= x; - norders -= want; + nreq -= want; al->get = MIN(al->want, (int)(x / al->save)); if (rdata->produce) { int use = required(al->get, al->save); @@ -1157,7 +1157,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) } } } - assert(avail == 0 || norders == 0); + assert(avail == 0 || nreq == 0); } typedef void(*allocate_function) (const resource_type *, struct region *, diff --git a/src/kernel/messages.h b/src/kernel/messages.h index 866eecba7..a42342153 100644 --- a/src/kernel/messages.h +++ b/src/kernel/messages.h @@ -57,7 +57,7 @@ extern "C" { struct mlist ** merge_messages(message_list *mlist, message_list *append); void split_messages(message_list *mlist, struct mlist **split); -#define ADDMSG(msgs, mcreate) { message * m = mcreate; if (m) { assert(m->refcount>=1); add_message(msgs, m); msg_release(m); } } +#define ADDMSG(msgs, mcreate) { message * mx = mcreate; if (mx) { assert(mx->refcount>=1); add_message(msgs, mx); msg_release(mx); } } void syntax_error(const struct unit *u, struct order *ord); struct message * cmistake(const struct unit *u, struct order *ord, int mno, int mtype); diff --git a/src/move.c b/src/move.c index 62300beb1..0184d22ca 100644 --- a/src/move.c +++ b/src/move.c @@ -163,6 +163,7 @@ static int shiptrail_read(attrib * a, void *owner, struct gamedata *data) int n; traveldir *t = (traveldir *)(a->data.v); + UNUSED_ARG(owner); READ_INT(store, &t->no); READ_INT(store, &n); t->dir = (direction_t)n; @@ -174,6 +175,8 @@ static void shiptrail_write(const attrib * a, const void *owner, struct storage *store) { traveldir *t = (traveldir *)(a->data.v); + + UNUSED_ARG(owner); WRITE_INT(store, t->no); WRITE_INT(store, t->dir); WRITE_INT(store, t->age); @@ -204,6 +207,8 @@ static bool entrance_allowed(const struct unit *u, const struct region *r) return true; return false; #else + UNUSED_ARG(u); + UNUSED_ARG(r); return true; #endif } @@ -466,6 +471,8 @@ static int canride(unit * u) static bool cansail(const region * r, ship * sh) { + UNUSED_ARG(r); + /* sonst ist construction:: size nicht ship_type::maxsize */ assert(!sh->type->construction || sh->type->construction->improvement == NULL); @@ -490,6 +497,8 @@ static bool cansail(const region * r, ship * sh) static double overload(const region * r, ship * sh) { + UNUSED_ARG(r); + /* sonst ist construction:: size nicht ship_type::maxsize */ assert(!sh->type->construction || sh->type->construction->improvement == NULL); @@ -1761,8 +1770,6 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) * befahrene Region. */ while (next_point && current_point != next_point && step < k) { - const char *token; - int error; const terrain_type *tthis = current_point->terrain; /* these values need to be updated if next_point changes (due to storms): */ const terrain_type *tnext = next_point->terrain; diff --git a/src/names.c b/src/names.c index 248084828..969e278d8 100644 --- a/src/names.c +++ b/src/names.c @@ -394,8 +394,8 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) size_t size; int result; + UNUSED_ARG(buflen); /* Prfen, ob Kurz genug */ - if (strlen(s) <= maxchars) { return s; } diff --git a/src/platform.h b/src/platform.h index 2f114cec5..57f4cd720 100644 --- a/src/platform.h +++ b/src/platform.h @@ -3,6 +3,21 @@ #ifndef UNILIB_H #define UNILIB_H +#ifdef _MSC_VER +#ifndef __STDC__ +#define __STDC__ 1 // equivalent to /Za +#endif +#define NO_STRDUP +#define NO_MKDIR +#define mkdir(d, a) _mkdir(d) +#define _CRT_SECURE_NO_WARNINGS +#pragma warning(disable: 4710 4820) +#pragma warning(disable: 4100) // unreferenced formal parameter +#pragma warning(disable: 4456) // declaration hides previous +#pragma warning(disable: 4457) // declaration hides function parameter +#pragma warning(disable: 4459) // declaration hides global +#endif + #ifndef MAX_PATH # define MAX_PATH 4096 #endif @@ -12,4 +27,12 @@ #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#ifdef NO_STRDUP +char * strdup(const char *s); +#endif + +#ifdef NO_MKDIR +int mkdir(const char *pathname, int mode); +#endif + #endif diff --git a/src/reports.c b/src/reports.c index b31ecac19..6d0aaba37 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1907,23 +1907,23 @@ static void eval_regions(struct opstack **stack, const void *userdata) const faction *report = (const faction *)userdata; int i = opop(stack).i; int end, begin = opop(stack).i; - const arg_regions *regions = (const arg_regions *)opop(stack).v; + const arg_regions *aregs = (const arg_regions *)opop(stack).v; char buf[256]; size_t size = sizeof(buf) - 1; variant var; char *bufp = buf; - if (regions == NULL) { + if (aregs == NULL) { end = begin; } else { if (i >= 0) end = begin + i; else - end = regions->nregions + i; + end = aregs->nregions + i; } for (i = begin; i < end; ++i) { - const char *rname = (const char *)regionname(regions->regions[i], report); + const char *rname = (const char *)regionname(aregs->regions[i], report); bufp = STRLCPY(bufp, rname, size); if (i + 1 < end && size > 2) { @@ -1942,7 +1942,7 @@ static void eval_trail(struct opstack **stack, const void *userdata) const faction *report = (const faction *)userdata; const struct locale *lang = report ? report->locale : default_locale; int i, end = 0, begin = 0; - const arg_regions *regions = (const arg_regions *)opop(stack).v; + const arg_regions *aregs = (const arg_regions *)opop(stack).v; char buf[512]; size_t size = sizeof(buf) - 1; variant var; @@ -1952,10 +1952,10 @@ static void eval_trail(struct opstack **stack, const void *userdata) int eold = errno; #endif - if (regions != NULL) { - end = regions->nregions; + if (aregs != NULL) { + end = aregs->nregions; for (i = begin; i < end; ++i) { - region *r = regions->regions[i]; + region *r = aregs->regions[i]; const char *trail = trailinto(r, lang); const char *rn = f_regionid_s(r, report); diff --git a/src/spells.c b/src/spells.c index 6ed38d022..0bb6df5af 100644 --- a/src/spells.c +++ b/src/spells.c @@ -398,6 +398,7 @@ static void report_effect(region * r, unit * mage, message * seen, message * unseen) { int err = report_action(r, mage, seen, ACTION_RESET | ACTION_CANSEE); + UNUSED_ARG(unseen); if (err) { report_action(r, mage, seen, ACTION_CANNOTSEE); } @@ -2895,6 +2896,8 @@ static int dc_read_compat(struct attrib *a, void *target, gamedata *data) float strength; int rx, ry; + UNUSED_ARG(a); + UNUSED_ARG(target); READ_INT(store, &duration); READ_FLT(store, &strength); READ_INT(store, &var.i); @@ -3119,8 +3122,10 @@ static bool chaosgate_valid(const connection * b) } static struct region *chaosgate_move(const connection * b, struct unit *u, -struct region *from, struct region *to, bool routing) + struct region *from, struct region *to, bool routing) { + UNUSED_ARG(from); + UNUSED_ARG(b); if (!routing) { int maxhp = u->hp / 4; if (maxhp < u->number) @@ -6438,6 +6443,7 @@ int sp_break_curse(castorder * co) /* ------------------------------------------------------------- */ int sp_becomewyrm(castorder * co) { + UNUSED_ARG(co); return 0; } diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index 0e1a27e75..227d94858 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -826,8 +826,8 @@ int sp_shadowcall(struct castorder * co) attrib *a; int force = (int)(get_force(power, 3) / 2); unit *u; - const char *races[3] = { "shadowbat", "nightmare", "vampunicorn" }; - const race *rc = rc_find(races[rng_int() % 3]); + const char *rcnames[3] = { "shadowbat", "nightmare", "vampunicorn" }; + const race *rc = rc_find(rcnames[rng_int() % 3]); message *msg; u = create_unit(r, mage->faction, force, rc, 0, NULL, mage); diff --git a/src/util/rand.h b/src/util/rand.h index 9fb3f2f69..2aabb8571 100644 --- a/src/util/rand.h +++ b/src/util/rand.h @@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef RAND_H #define RAND_H + +#include + #ifdef __cplusplus extern "C" { #endif From ba2f35e44f26ac9e42466048fc90b2470a197692 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Jan 2017 18:20:47 +0100 Subject: [PATCH 322/675] more stbool.h includes, MSVC has no unlink --- src/attributes/key.h | 3 +++ src/donations.test.c | 1 + src/give.h | 3 +++ src/kernel/command.test.c | 2 ++ src/market.h | 3 +++ src/monsters.h | 3 +++ src/platform.h | 5 ++++- src/renumber.test.c | 1 + src/reports.h | 2 +- src/summary.h | 2 ++ src/util/xml.h | 2 ++ 11 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/attributes/key.h b/src/attributes/key.h index 89292db1d..d2cea1ff0 100644 --- a/src/attributes/key.h +++ b/src/attributes/key.h @@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_ATTRIBUTE_KEY #define H_ATTRIBUTE_KEY + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/donations.test.c b/src/donations.test.c index 068aba74a..09cd31977 100644 --- a/src/donations.test.c +++ b/src/donations.test.c @@ -1,3 +1,4 @@ +#include #include "donations.h" #include diff --git a/src/give.h b/src/give.h index 9c06e89ca..94eee729c 100644 --- a/src/give.h +++ b/src/give.h @@ -12,6 +12,9 @@ */ #ifndef H_GC_GIVE #define H_GC_GIVE + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/command.test.c b/src/kernel/command.test.c index f38c7e443..25e75fdc3 100644 --- a/src/kernel/command.test.c +++ b/src/kernel/command.test.c @@ -10,7 +10,9 @@ without prior permission by the authors of Eressea. */ +#include #include "command.h" + #include "unit.h" #include "order.h" diff --git a/src/market.h b/src/market.h index a74c88391..74dc8db17 100644 --- a/src/market.h +++ b/src/market.h @@ -12,6 +12,9 @@ without prior permission by the authors of Eressea. */ #ifndef H_GC_MARKET #define H_GC_MARKET + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/monsters.h b/src/monsters.h index 52e9ebf37..a5a3ccd15 100644 --- a/src/monsters.h +++ b/src/monsters.h @@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_GC_MONSTER #define H_GC_MONSTER + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/platform.h b/src/platform.h index f3fd9fbae..88bff8ad5 100644 --- a/src/platform.h +++ b/src/platform.h @@ -9,7 +9,7 @@ #endif #define NO_STRDUP #define NO_MKDIR -#define mkdir(d, a) _mkdir(d) +#define NO_UNLINK #define _CRT_SECURE_NO_WARNINGS #pragma warning(disable: 4710 4820) #pragma warning(disable: 4100) // unreferenced formal parameter @@ -38,4 +38,7 @@ char * strdup(const char *s); int mkdir(const char *pathname, int mode); #endif +#ifdef NO_UNLINK +int unlink(const char *pathname); +#endif #endif diff --git a/src/renumber.test.c b/src/renumber.test.c index 6c3f0f17b..8f6f91a59 100644 --- a/src/renumber.test.c +++ b/src/renumber.test.c @@ -1,3 +1,4 @@ +#include #include "renumber.h" #include diff --git a/src/reports.h b/src/reports.h index e5fd976e3..99dd7ebf6 100644 --- a/src/reports.h +++ b/src/reports.h @@ -20,10 +20,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_KRNL_REPORTS #define H_KRNL_REPORTS -#include #include #include #include +#include struct stream; struct seen_region; diff --git a/src/summary.h b/src/summary.h index ea8daeee1..b12d74009 100644 --- a/src/summary.h +++ b/src/summary.h @@ -11,6 +11,8 @@ #ifndef H_GC_SUMMARY #define H_GC_SUMMARY +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/util/xml.h b/src/util/xml.h index 921cd3f53..bd22e3e0a 100644 --- a/src/util/xml.h +++ b/src/util/xml.h @@ -13,6 +13,8 @@ #ifndef H_UTIL_XML #define H_UTIL_XML +#include + #ifdef __cplusplus extern "C" { #endif From f8ff9ffda5613b4b85d9e7412d3a40710baeaf75 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Jan 2017 18:40:01 +0100 Subject: [PATCH 323/675] compiles with gcc on rpi --- src/kernel/jsonconf.test.c | 2 +- src/kernel/save.c | 2 +- src/platform.h | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 76784ed56..950868046 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -448,7 +448,7 @@ static void test_configs(CuTest * tc) CuAssertPtrEquals(tc, 0, buildingtypes); json_config(json); CuAssertPtrNotNull(tc, buildingtypes); - if (unlink("test.json")!=0 && errno==ENOENT) { + if (remove("test.json")!=0 && errno==ENOENT) { errno = 0; } cJSON_Delete(json); diff --git a/src/kernel/save.c b/src/kernel/save.c index de6f8aac1..9825a5b55 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1830,7 +1830,7 @@ int writegame(const char *filename) join_path(datapath(), filename, path, sizeof(path)); #ifdef HAVE_UNISTD_H /* make sure we don't overwrite an existing file (hard links) */ - if (unlink(path)!=0) { + if (remove(path)!=0) { if (errno==ENOENT) { errno = 0; } diff --git a/src/platform.h b/src/platform.h index 88bff8ad5..355b995d2 100644 --- a/src/platform.h +++ b/src/platform.h @@ -9,7 +9,6 @@ #endif #define NO_STRDUP #define NO_MKDIR -#define NO_UNLINK #define _CRT_SECURE_NO_WARNINGS #pragma warning(disable: 4710 4820) #pragma warning(disable: 4100) // unreferenced formal parameter @@ -38,7 +37,4 @@ char * strdup(const char *s); int mkdir(const char *pathname, int mode); #endif -#ifdef NO_UNLINK -int unlink(const char *pathname); -#endif #endif From 281cfbd0094b3057eb9c4c5b774ec390653be9b3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 11 Jan 2017 10:57:42 +0100 Subject: [PATCH 324/675] fix the install script, issue #623 --- s/install | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/s/install b/s/install index 18cc2393f..416d07f9a 100755 --- a/s/install +++ b/s/install @@ -10,12 +10,11 @@ done DEST=$(dirname $ROOT)/server -MACHINE=`uname -m` [ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang" [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" [ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" [ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc" -BIN_DIR="build-$MACHINE-$CC-Debug" +BIN_DIR="Debug" cd $ROOT/$BIN_DIR make install From a4d8d36aec81317d108c6648d26856e34b87e19a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 11 Jan 2017 14:53:35 +0100 Subject: [PATCH 325/675] issue #621: delete battledebug code --- src/battle.c | 156 ++------------------------------------------------- src/battle.h | 1 - src/main.c | 3 - 3 files changed, 6 insertions(+), 154 deletions(-) diff --git a/src/battle.c b/src/battle.c index 7e5c4b9d8..d802c0785 100644 --- a/src/battle.c +++ b/src/battle.c @@ -93,12 +93,6 @@ typedef enum combatmagic { DO_POSTCOMBATSPELL } combatmagic_t; -/* globals */ -bool battledebug = false; - -static int obs_count = 0; -static FILE *bdebug; - #define MINSPELLRANGE 1 #define MAXSPELLRANGE 7 @@ -1219,9 +1213,6 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) kritchance = MIN(0.9, kritchance); while (chance(kritchance)) { - if (bdebug) { - fprintf(bdebug, "%s/%d lands a critical hit\n", itoa36(au->no), at.index); - } da += dice_rand(damage); } } @@ -1302,10 +1293,6 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) } if (df->person[dt.index].hp > 0) { /* Hat �berlebt */ - if (bdebug) { - fprintf(bdebug, "Damage %d, armor %d: %d -> %d HP\n", - da, ar, df->person[dt.index].hp + rda, df->person[dt.index].hp); - } if (u_race(au) == get_race(RC_DAEMON)) { if (!(df->person[dt.index].flags & (FL_COURAGE | FL_DAZZLED))) { df->person[dt.index].flags |= FL_DAZZLED; @@ -1334,10 +1321,6 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) } ++at.fighter->kills; - if (bdebug) { - fprintf(bdebug, "Damage %d, armor %d, type %d: %d -> %d HP, tot.\n", - da, ar, type, df->person[dt.index].hp + rda, df->person[dt.index].hp); - } for (pitm = &du->items; *pitm;) { item *itm = *pitm; const item_type *itype = itm->type; @@ -1979,20 +1962,6 @@ int getreload(troop at) return at.fighter->person[at.index].reload; } -static void -debug_hit(troop at, const weapon * awp, troop dt, const weapon * dwp, -int skdiff, int dist, bool success) -{ - fprintf(bdebug, "%.4s/%d [%6s/%d] %s %.4s/%d [%6s/%d] with %d, distance %d\n", - itoa36(at.fighter->unit->no), at.index, - LOC(default_locale, awp ? resourcename(awp->type->itype->rtype, - 0) : "unarmed"), weapon_effskill(at, dt, awp, true, dist > 1), - success ? "hits" : "misses", itoa36(dt.fighter->unit->no), dt.index, - LOC(default_locale, dwp ? resourcename(dwp->type->itype->rtype, - 0) : "unarmed"), weapon_effskill(dt, at, dwp, false, dist > 1), skdiff, - dist); -} - int hits(troop at, troop dt, weapon * awp) { fighter *af = at.fighter, *df = dt.fighter; @@ -2032,14 +2001,8 @@ int hits(troop at, troop dt, weapon * awp) shield = select_armor(dt, false); } if (contest(skdiff, dt, armor, shield)) { - if (bdebug) { - debug_hit(at, awp, dt, dwp, skdiff, dist, true); - } return 1; } - if (bdebug) { - debug_hit(at, awp, dt, dwp, skdiff, dist, false); - } return 0; } @@ -2190,11 +2153,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack) } } if (reload && wp && wp->type->reload && !getreload(ta)) { - int i = setreload(ta); - if (bdebug) { - fprintf(bdebug, "%s/%d reloading %d turns\n", itoa36(au->no), - ta.index, i); - } + setreload(ta); } } } @@ -2874,13 +2833,6 @@ static void aftermath(battle * b) } reorder_fleeing(r); - - if (bdebug) { - fprintf(bdebug, "The battle lasted %d turns, %s and %s.\n", - b->turn, - b->has_tactics_turn ? "had a tactic turn" : "had no tactic turn", - ships_damaged ? "was relevant" : "was not relevant."); - } } static void battle_punit(unit * u, battle * b) @@ -2894,10 +2846,6 @@ static void battle_punit(unit * u, battle * b) spunit(&S, f, u, 4, seen_battle); for (x = S; x; x = x->next) { fbattlerecord(b, f, x->s); - if (bdebug && u->faction == f) { - fputs(x->s, bdebug); - fputc('\n', bdebug); - } } if (S) freestrlist(S); @@ -3077,17 +3025,6 @@ static void print_stats(battle * b) fbattlerecord(b, f, buf); } - if (bdebug && s->faction) { - if (f_get_alliance(s->faction)) { - fprintf(bdebug, "##### %s (%s/%d)\n", s->faction->name, - itoa36(s->faction->no), - s->faction->alliance ? s->faction->alliance->id : 0); - } - else { - fprintf(bdebug, "##### %s (%s)\n", s->faction->name, - itoa36(s->faction->no)); - } - } print_fighters(b, s); } @@ -3519,28 +3456,6 @@ static int join_battle(battle * b, unit * u, bool attack, fighter ** cp) return false; } -static const char *simplename(region * r) -{ - int i; - static char name[17]; - const char *cp = rname(r, default_locale); - for (i = 0; *cp && i != 16; ++i, ++cp) { - int c = *(unsigned char *)cp; - while (c && !isalpha(c) && !isspace(c)) { - ++cp; - c = *(unsigned char *)cp; - } - if (isspace(c)) - name[i] = '_'; - else - name[i] = *cp; - if (c == 0) - break; - } - name[i] = 0; - return name; -} - battle *make_battle(region * r) { battle *b = (battle *)calloc(1, sizeof(battle)); @@ -3552,29 +3467,6 @@ battle *make_battle(region * r) for (bld = r->buildings; bld != NULL; bld = bld->next) bld->sizeleft = bld->size; - if (battledebug) { - char zText[4096]; - char zFilename[4096]; - join_path(basepath(), "battles", zText, sizeof(zText)); - if (mkdir(zText, 0777) != 0) { - log_error("could not create subdirectory for battle logs: %s", zText); - battledebug = false; - } - else { - sprintf(zFilename, "battle-%d-%s.log", obs_count++, simplename(r)); - join_path(zText, zFilename, zText, sizeof(zText)); - bdebug = fopen(zText, "w"); - if (!bdebug) - log_error("battles cannot be debugged"); - else { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; - fwrite(utf8_bom, 1, 3, bdebug); - fprintf(bdebug, "In %s findet ein Kampf statt:\n", rname(r, - default_locale)); - } - } - } - b->region = r; b->plane = getplane(r); /* Finde alle Parteien, die den Kampf beobachten k�nnen: */ @@ -3644,10 +3536,6 @@ static void battle_free(battle * b) { void free_battle(battle * b) { - if (bdebug) { - fclose(bdebug); - } - while (b->factions) { bfaction *bf = b->factions; b->factions = bf->next; @@ -3812,13 +3700,7 @@ static void join_allies(battle * b) } /* keine Einw�nde, also soll er mitmachen: */ if (c == NULL) { - if (join_battle(b, u, false, &c)) { - if (battledebug) { - fprintf(bdebug, "%s joins to help %s against %s.\n", - unitname(u), factionname(s->faction), factionname(se->faction)); - } - } - else if (c == NULL) { + if (!join_battle(b, u, false, &c)) { continue; } } @@ -3826,12 +3708,7 @@ static void join_allies(battle * b) /* the enemy of my friend is my enemy: */ for (se = b->sides; se != s_end; ++se) { if (se->faction != u->faction && enemy(s, se)) { - if (set_enemy(se, c->side, false) && battledebug) { - fprintf(bdebug, - "%u/%s hates %u/%s because they are enemies with %u/%s.\n", - c->side->index, sidename(c->side), se->index, sidename(se), - s->index, sidename(s)); - } + set_enemy(se, c->side, false); } } } @@ -4012,18 +3889,8 @@ static bool start_battle(region * r, battle ** bp) } b = make_battle(r); } - if (join_battle(b, u, true, &c1)) { - if (battledebug) { - fprintf(bdebug, "%s joins by attacking %s.\n", - unitname(u), unitname(u2)); - } - } - if (join_battle(b, u2, false, &c2)) { - if (battledebug) { - fprintf(bdebug, "%s joins because of an attack from %s.\n", - unitname(u2), unitname(u)); - } - } + join_battle(b, u, true, &c1); + join_battle(b, u2, false, &c2); /* Hat die attackierte Einheit keinen Noaid-Status, * wird das Flag von der Faction genommen, andere @@ -4036,11 +3903,7 @@ static bool start_battle(region * r, battle ** bp) * Pr�combataura bei kurzem Kampf. */ c1->side->bf->attacker = true; - if (set_enemy(c1->side, c2->side, true) && battledebug) { - fprintf(bdebug, "%u/%s hates %u/%s because they attacked them.\n", - c2->side->index, sidename(c2->side), - c1->side->index, sidename(c1->side)); - } + set_enemy(c1->side, c2->side, true); fighting = true; } } @@ -4159,10 +4022,6 @@ static void battle_flee(battle * b) flee(dt); } } - if (bdebug && runners > 0) { - fprintf(bdebug, "Fleeing: %d from %s\n", runners, - itoa36(fig->unit->no)); - } } } } @@ -4265,9 +4124,6 @@ void do_battle(region * r) log_debug("battle in %s (%d, %d) : ", regionname(r, 0), r->x, r->y); for (; battle_report(b) && b->turn <= max_turns; ++b->turn) { - if (bdebug) { - fprintf(bdebug, "*** Turn: %d\n", b->turn); - } battle_flee(b); battle_update(b); battle_attacks(b); diff --git a/src/battle.h b/src/battle.h index 060906958..4d29f1a7f 100644 --- a/src/battle.h +++ b/src/battle.h @@ -225,7 +225,6 @@ extern "C" { } meffect; extern const troop no_troop; - extern bool battledebug; /* BEGIN battle interface */ side * find_side(battle * b, const struct faction * f, const struct group * g, unsigned int flags, const struct faction * stealthfaction); diff --git a/src/main.c b/src/main.c index 44c1b9e2d..5e998f835 100644 --- a/src/main.c +++ b/src/main.c @@ -25,7 +25,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "eressea.h" -#include "battle.h" #ifdef USE_CURSES #include "gmtool.h" #endif @@ -71,8 +70,6 @@ static void load_inifile(dictionary * d) lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0; verbosity = iniparser_getint(d, "eressea:verbose", 2); - battledebug = iniparser_getint(d, "eressea:debug", battledebug) ? 1 : 0; - str = iniparser_getstring(d, "eressea:locales", "de,en"); make_locales(str); From d8e6e80b03f615ec3b92cfba1b8cfe62b95c14b3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 11 Jan 2017 14:55:03 +0100 Subject: [PATCH 326/675] issue #478: re-enable -Werror --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 81a43e002..cc7087635 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,7 +18,7 @@ COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}") ENDIF() IF (CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wno-error=unused-but-set-variable") ENDIF() IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") From d73c7609498016d025378a08c12b3fd42311887c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 11 Jan 2017 15:09:02 +0100 Subject: [PATCH 327/675] do not set -Werror twice --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cc7087635..81a43e002 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,7 +18,7 @@ COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}") ENDIF() IF (CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wno-error=unused-but-set-variable") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") ENDIF() IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") From 084b4ed3878c4aa3d36898ba5c0898e74da8256d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 14 Jan 2017 17:19:08 +0100 Subject: [PATCH 328/675] github issue #626: installing in non-standard paths --- s/cmake-init | 3 ++- s/install | 2 -- s/setup | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/s/cmake-init b/s/cmake-init index ea94afb7c..84a1d9cdb 100755 --- a/s/cmake-init +++ b/s/cmake-init @@ -35,12 +35,13 @@ if [ -d $HOME/usr ]; then PREFIX_PATH=$HOME/usr:$HOME/usr/local:$PREFIX_PATH fi +DEST=$(dirname $ROOT)/server ARGS=" -DCMAKE_MODULE_PATH=$ROOT/cmake/Modules \ -DCMAKE_BUILD_TYPE=$BUILD \ -DCMAKE_LIBRARY_PATH=$LIBRARY_PATH \ -DCMAKE_INCLUDE_PATH=$INCLUDE_PATH \ -DCMAKE_PREFIX_PATH=$PREFIX_PATH \ - -DCMAKE_INSTALL_PREFIX=$HOME/eressea/server" + -DCMAKE_INSTALL_PREFIX=$DEST" git submodule update --init diff --git a/s/install b/s/install index 416d07f9a..962961063 100755 --- a/s/install +++ b/s/install @@ -8,8 +8,6 @@ while [ ! -d $ROOT/.git ]; do fi done -DEST=$(dirname $ROOT)/server - [ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang" [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" [ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" diff --git a/s/setup b/s/setup index 0839d5b8f..fc5fb9874 100755 --- a/s/setup +++ b/s/setup @@ -1,5 +1,15 @@ #!/bin/bash +ROOT=$(pwd) +while [ ! -d $ROOT/.git ]; do + ROOT=$(dirname $ROOT) + if [ "/" = "$ROOT" ]; then + echo "could not find root, are you in the git repository?" + exit + fi +done +ERESSEA=$(dirname $ROOT) + function abort() { echo $1 [ -z $2 ] && exit -1 @@ -37,7 +47,6 @@ while getopts :d:g:r:s:hfn o; do done [ $game -gt 0 ] || abort "must use a positive integer for game id" -[ -d $ERESSEA ] || abort "invalid or missing env variable ERESSEA ($ERESSEA)" [ -z $SOURCE ] && SOURCE=$ERESSEA/$src [ -d $SOURCE ] || abort "invalid source directory $SOURCE" [ -z $rules ] && rules=e$game @@ -46,7 +55,8 @@ done [ -e $TOOLS ] || TOOLS=$SOURCE/bin [ -z $INIFILE ] && INIFILE=$TOOLS/inifile [ -e $INIFILE ] || INIFILE=$TOOLS/iniparser/inifile -#[ -e $INIFILE ] || abort "tool is not installed: $INIFILE" + +[ -e $SOURCE/conf/$rules/config.xml ] || abort "cannot find conf/$rules/config.xml" cd $ERESSEA if [ -d $dir ] ; then From 0261cb45c1389e0d0c571362cd8afb92b8d42e18 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 Jan 2017 08:32:31 +0100 Subject: [PATCH 329/675] move orders-accept configuration to eressea.ini install lunit, too --- CMakeLists.txt | 1 + conf/eressea.ini | 3 ++ process/orders-accept | 111 ++++++++++++++++++++++-------------------- 3 files changed, 61 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b26ecb6e..15629bf4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,4 +25,5 @@ add_subdirectory (src eressea) install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.xml") install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.json") install(DIRECTORY scripts DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.lua") +install(DIRECTORY lunit DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.lua") install(DIRECTORY share DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/conf/eressea.ini b/conf/eressea.ini index e14d0af50..c2f7bbb7f 100644 --- a/conf/eressea.ini +++ b/conf/eressea.ini @@ -1,3 +1,6 @@ +[game] +email = Eressea Server +name = Eressea [eressea] base = . diff --git a/process/orders-accept b/process/orders-accept index 151f0b196..49bdc3cb0 100755 --- a/process/orders-accept +++ b/process/orders-accept @@ -3,22 +3,50 @@ from email.Utils import parseaddr from email.Parser import Parser -from os import mkdir, rename, stat, utime, unlink, symlink -from os.path import exists +import os +import os.path +import ConfigParser from re import compile, IGNORECASE from stat import ST_MTIME from string import upper, split, replace import logging -from sys import argv, stdin, exit +import sys +from sys import stdin from time import ctime, sleep, time from socket import gethostname from rfc822 import parsedate_tz, mktime_tz -LOG_FILENAME='/home/eressea/log/orders.log' +if 'ERESSEA' in os.environ: + dir = os.environ['ERESSEA'] +elif 'HOME' in os.environ: + dir = os.path.join(os.environ['HOME'], '/eressea') +else: # WTF? No HOME? + dir = "/home/eressea/eressea" +if not os.path.isdir(dir): + print "please set the ERESSEA environment variable to the install path" + sys.exit(1) +rootdir = dir + +try: + game = int(sys.argv[1]) +except: + game = sys.argv[1] +gamedir = os.path.join(rootdir, "game-%d" % (game, )) +frommail = 'Eressea Server ' +gamename = 'Eressea' +inifile = os.path.join(gamedir, 'eressea.ini') +if not os.path.exists(inifile): + print "no such file: " . inifile +else: + config = ConfigParser.ConfigParser() + config.read(inifile) + if config.has_option('game', 'email'): + frommail = config.get('game', 'email') + if config.has_option('game', 'name'): + gamename = config.get('game', 'name') + config = None prefix = 'turn-' hostname = gethostname() -# base directory for all your games: -rootdir = "/home/eressea" orderbase = "orders.dir" sendmail = True # maximum number of reports per sender: @@ -28,36 +56,21 @@ writeheaders = True # reject all html email? rejecthtml = True -games = [ - { - "from" : "Eressea Server ", - "prefix" : "Eressea" - }, - { - "from" : "Eressea Server ", - "prefix": "E3" - }, - { - "from" : "Eressea Server ", - "prefix": "E4" - }, -] - def unlock_file(filename): try: - unlink(filename+".lock") + os.unlink(filename+".lock") except: print "could not unlock %s.lock, file not found" % filename def lock_file(filename): i = 0 wait = 1 - if not exists(filename): + if not os.path.exists(filename): file=open(filename, "w") file.close() while True: try: - symlink(filename, filename+".lock") + os.symlink(filename, filename+".lock") return except: i = i+1 @@ -74,17 +87,17 @@ messages = { "software and re-send the orders.", "multipart-de" : - "FEHLER: Die von dir eingeschickte Mail enthlt keinen " \ + "FEHLER: Die von dir eingeschickte Mail enth�lt keinen " \ "Text. Evtl. hast Du den Zug als HTML oder als anderweitig " \ - "ungltig formatierte Mail ingeschickt. Wir knnen ihn " \ - "deshalb nicht bercksichtigen. Schicke den Zug nochmals " \ + "ung�ltig formatierte Mail ingeschickt. Wir k�nnen ihn " \ + "deshalb nicht ber�cksichtigen. Schicke den Zug nochmals " \ "als reinen Text ohne Formatierungen ein.", "maildate-de": - "Es erreichte uns bereits ein Zug mit einem spteren " \ + "Es erreichte uns bereits ein Zug mit einem sp�teren " \ "Absendedatum (%s > %s). Entweder ist deine " \ "Systemzeit verstellt, oder ein Zug hat einen anderen Zug von " \ - "dir auf dem Transportweg berholt. Entscheidend fr die " \ + "dir auf dem Transportweg �berholt. Entscheidend f�r die " \ "Auswertungsreihenfolge ist das Absendedatum, d.h. der Date:-Header " \ "deiner Mail.", @@ -173,8 +186,8 @@ def available_file(dirname, basename): ver = 0 maxdate = 0 filename = "%s/%s,%s,%d" % (dirname, basename, hostname, ver) - while exists(filename): - maxdate = max(stat(filename)[ST_MTIME], maxdate) + while os.path.exists(filename): + maxdate = max(os.stat(filename)[ST_MTIME], maxdate) ver = ver + 1 filename = "%s/%s,%s,%d" % (dirname, basename, hostname, ver) if ver >= maxfiles: @@ -234,7 +247,7 @@ def copy_orders(message, filename, sender): from os.path import split dirname, basename = split(filename) dirname = dirname + '/headers' - if not exists(dirname): mkdir(dirname) + if not os.path.exists(dirname): os.mkdir(dirname) outfile = open(dirname + '/' + basename, "w") for name, value in message.items(): outfile.write(name + ": " + value + "\n") @@ -265,16 +278,14 @@ def copy_orders(message, filename, sender): # create a file, containing: # game=0 locale=de file=/path/to/filename email=rcpt@domain.to def accept(game, locale, stream, extend=None): - global rootdir, orderbase + global rootdir, orderbase, gamedir, gamename, frommail if extend is not None: orderbase = orderbase + ".pre-" + extend - gamename = games[game-2]["prefix"] - gamedir = rootdir+"/eressea/game-%d" % (game, ) - savedir = gamedir+"/"+orderbase + savedir = os.path.join(gamedir, orderbase) # check if it's one of the pre-sent orders. # create the save-directories if they don't exist - if not exists(gamedir): mkdir(gamedir) - if not exists(savedir): mkdir(savedir) + if not os.path.exists(gamedir): os.mkdir(gamedir) + if not os.path.exists(savedir): os.mkdir(savedir) # parse message message = Parser().parse(stream) sender = get_sender(message) @@ -298,7 +309,7 @@ def accept(game, locale, stream, extend=None): maildate = message.get("Date") if maildate != None: turndate = mktime_tz(parsedate_tz(maildate)) - utime(filename, (turndate, turndate)) + os.utime(filename, (turndate, turndate)) logger.debug("mail date is '%s' (%d)" % (maildate, turndate)) if turndate < maxdate: logger.warning("inconsistent message date " + sender) @@ -313,9 +324,9 @@ def accept(game, locale, stream, extend=None): warning = " (" + messages["error-" + locale] + ")" msg = msg + formatpar(messages["multipart-" + locale], 76, 2) + "\n" logger.warning("rejected - no text/plain in orders from " + sender) - unlink(filename) + os.unlink(filename) savedir = savedir + "/rejected" - if not exists(savedir): mkdir(savedir) + if not os.path.exists(savedir): os.mkdir(savedir) lock_file(gamedir + "/orders.queue") maxdate, filename = available_file(savedir, prefix + sender) store_message(message, filename) @@ -323,7 +334,6 @@ def accept(game, locale, stream, extend=None): fail = True if sendmail and warning is not None: - frommail = games[key]["from"] subject = gamename + " " + messages["subject-"+locale] + warning mail = "Subject: %s\nFrom: %s\nTo: %s\n\n" % (subject, frommail, sender) + msg from smtplib import SMTP @@ -347,22 +357,15 @@ def accept(game, locale, stream, extend=None): return 0 # the main body of the script: +LOG_FILENAME=os.path.join(rootdir, 'log/orders.log') logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME) logger = logging delay=None # TODO: parse the turn delay -try: - game = int(argv[1]) -except: - game = argv[1] - if game[:3]=='e3a': - game = 3 - elif game[:7]=='eressea': - game = 2 -locale = argv[2] +locale = sys.argv[2] infile = stdin -if len(argv)>3: - infile = open(argv[3], "r") +if len(sys.argv)>3: + infile = open(sys.argv[3], "r") retval = accept(game, locale, infile, delay) if infile!=stdin: infile.close() -exit(retval) +sys.exit(retval) From 1b2bfc79952c38b1886e3d38be6de8951b57a72c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 Jan 2017 18:44:58 +0100 Subject: [PATCH 330/675] rename [eressea] section to [game] --- conf/eressea.ini | 5 +- process/orders-accept | 49 ++++++++++--------- process/orders-process | 107 +++++++++++++++++++++++++---------------- s/setup | 4 +- src/main.c | 14 +++--- 5 files changed, 102 insertions(+), 77 deletions(-) diff --git a/conf/eressea.ini b/conf/eressea.ini index c2f7bbb7f..b6db180ca 100644 --- a/conf/eressea.ini +++ b/conf/eressea.ini @@ -1,8 +1,7 @@ [game] -email = Eressea Server +email = eressea-server@kn-bremen.de +sender = Eressea Server name = Eressea - -[eressea] base = . report = reports verbose = 0 diff --git a/process/orders-accept b/process/orders-accept index 49bdc3cb0..78af0a056 100755 --- a/process/orders-accept +++ b/process/orders-accept @@ -27,13 +27,12 @@ if not os.path.isdir(dir): sys.exit(1) rootdir = dir -try: - game = int(sys.argv[1]) -except: - game = sys.argv[1] +game = int(sys.argv[1]) gamedir = os.path.join(rootdir, "game-%d" % (game, )) -frommail = 'Eressea Server ' +frommail = 'eressea-server@kn-bremen.de' gamename = 'Eressea' +sender = '%s Server <%s>' % (gamename, frommail) + inifile = os.path.join(gamedir, 'eressea.ini') if not os.path.exists(inifile): print "no such file: " . inifile @@ -44,6 +43,10 @@ else: frommail = config.get('game', 'email') if config.has_option('game', 'name'): gamename = config.get('game', 'name') + if config.has_option('game', 'sender'): + sender = config.get('game', 'sender') + else: + sender = "%s Server <%s>" % (gamename, frommail) config = None prefix = 'turn-' hostname = gethostname() @@ -278,7 +281,7 @@ def copy_orders(message, filename, sender): # create a file, containing: # game=0 locale=de file=/path/to/filename email=rcpt@domain.to def accept(game, locale, stream, extend=None): - global rootdir, orderbase, gamedir, gamename, frommail + global rootdir, orderbase, gamedir, gamename, sender if extend is not None: orderbase = orderbase + ".pre-" + extend savedir = os.path.join(gamedir, orderbase) @@ -288,21 +291,21 @@ def accept(game, locale, stream, extend=None): if not os.path.exists(savedir): os.mkdir(savedir) # parse message message = Parser().parse(stream) - sender = get_sender(message) - logger = logging.getLogger(sender) + email = get_sender(message) + logger = logging.getLogger(email) # write syslog - if sender is None or valid_email(sender)==0: - logger.warning("invalid email address: " + str(sender)) + if email is None or valid_email(email)==0: + logger.warning("invalid email address: " + str(email)) return -1 - logger.info("received orders from " + sender) + logger.info("received orders from " + email) # get an available filename lock_file(gamedir + "/orders.queue") - maxdate, filename = available_file(savedir, prefix + sender) + maxdate, filename = available_file(savedir, prefix + email) if filename is None: - logger.warning("more than " + str(maxfiles) + " orders from " + sender) + logger.warning("more than " + str(maxfiles) + " orders from " + email) return -1 # copy the orders to the file - text_ok = copy_orders(message, filename, sender) + text_ok = copy_orders(message, filename, email) unlock_file(gamedir + "/orders.queue") warning, msg, fail = None, "", False @@ -312,47 +315,47 @@ def accept(game, locale, stream, extend=None): os.utime(filename, (turndate, turndate)) logger.debug("mail date is '%s' (%d)" % (maildate, turndate)) if turndate < maxdate: - logger.warning("inconsistent message date " + sender) + logger.warning("inconsistent message date " + email) warning = " (" + messages["warning-" + locale] + ")" msg = msg + formatpar(messages["maildate-" + locale] % (ctime(maxdate),ctime(turndate)), 76, 2) + "\n" else: - logger.warning("missing message date " + sender) + logger.warning("missing message date " + email) warning = " (" + messages["warning-" + locale] + ")" msg = msg + formatpar(messages["nodate-" + locale], 76, 2) + "\n" if not text_ok: warning = " (" + messages["error-" + locale] + ")" msg = msg + formatpar(messages["multipart-" + locale], 76, 2) + "\n" - logger.warning("rejected - no text/plain in orders from " + sender) + logger.warning("rejected - no text/plain in orders from " + email) os.unlink(filename) savedir = savedir + "/rejected" if not os.path.exists(savedir): os.mkdir(savedir) lock_file(gamedir + "/orders.queue") - maxdate, filename = available_file(savedir, prefix + sender) + maxdate, filename = available_file(savedir, prefix + email) store_message(message, filename) unlock_file(gamedir + "/orders.queue") fail = True if sendmail and warning is not None: subject = gamename + " " + messages["subject-"+locale] + warning - mail = "Subject: %s\nFrom: %s\nTo: %s\n\n" % (subject, frommail, sender) + msg + mail = "Subject: %s\nFrom: %s\nTo: %s\n\n" % (subject, sender, email) + msg from smtplib import SMTP server = SMTP("localhost") - server.sendmail(frommail, sender, mail) + server.sendmail(sender, email, mail) server.close() if not sendmail: - print text_ok, fail, sender + print text_ok, fail, email print filename if not fail: lock_file(gamedir + "/orders.queue") queue = open(gamedir + "/orders.queue", "a") - queue.write("email=%s file=%s locale=%s game=%s\n" % (sender, filename, locale, game)) + queue.write("email=%s file=%s locale=%s game=%s\n" % (email, filename, locale, game)) queue.close() unlock_file(gamedir + "/orders.queue") - logger.info("done - accepted orders from " + sender) + logger.info("done - accepted orders from " + email) return 0 diff --git a/process/orders-process b/process/orders-process index 753385e2e..b33cc05bf 100755 --- a/process/orders-process +++ b/process/orders-process @@ -2,7 +2,9 @@ # -*- coding: iso-8859-1 -*- from os import unlink, symlink, rename, popen, tmpfile -from os.path import exists +import os +import os.path +import ConfigParser from re import compile, IGNORECASE from string import split, join, upper, strip from sys import argv, exit @@ -14,9 +16,8 @@ from epasswd import EPasswd def pwd_get_email(faction, pwd, pwdfile=None): return None -def splitfilename(filename): - from os.path import split - return split(filename) +def split_filename(filename): + return os.path.split(filename) def unlock_file(filename): try: @@ -28,7 +29,7 @@ def unlock_file(filename): def lock_file(filename): i = 0 wait = 1 - if not exists(filename): + if not os.path.exists(filename): file=open(filename, "w") file.close() while True: @@ -62,17 +63,47 @@ messages = { "error-en": "Error", } +game = int(sys.argv[1]) +echeck_cmd = "/home/eressea/echeck/echeck.sh" +maxlines = 25 # base directory for all your games: -rootdir = "/home/eressea/eressea" -frommail = "Eressea Server " -orderbase = "orders.dir" -sendmail = True -maxlines = 25 -echeck_cmd = "/home/eressea/echeck/echeck.sh" +install_dir = "/home/eressea/eressea" +if 'ERESSEA' in os.environ: + install_dir = os.environ['ERESSEA'] +elif 'HOME' in os.environ: + install_dir = os.path.join(os.environ['HOME'], '/eressea') +if not os.path.isdir(install_dir): + print "please set the ERESSEA environment variable to the install path" + sys.exit(1) + +game_dir = os.path.join(install_dir, "game-%d" % (game, )) +frommail = 'eressea-server@kn-bremen.de' +gamename = 'Eressea' +sender = '%s Server <%s>' % (gamename, frommail) + +inifile = os.path.join(gamedir, 'eressea.ini') +if not os.path.exists(inifile): + print "no such file: " . inifile +else: + config = ConfigParser.ConfigParser() + config.read(inifile) + if config.has_option('game', 'email'): + frommail = config.get('game', 'email') + if config.has_option('game', 'name'): + gamename = config.get('game', 'name') + if config.has_option('game', 'sender'): + sender = config.get('game', 'sender') + else: + sender = "%s Server <%s>" % (gamename, frommail) + config = None + +queue_file = os.path.join(game_dir, "orders.queue") +if not os.path.exists(queue_file): + exit(0) # regular expression that finds the start of a faction -fact_re = compile("^\s*(eressea|vinyambar|partei|faction)\s+([a-zA-Z0-9]+)\s+\"?([^\"]*)\"?", IGNORECASE) +fact_re = compile("^\s*(eressea|partei|faction)\s+([a-zA-Z0-9]+)\s+\"?([^\"]*)\"?", IGNORECASE) def check_pwd(filename, email, pw_data): results = [] @@ -98,7 +129,7 @@ def check_pwd(filename, email, pw_data): return results def echeck(filename, locale, rules): - dirname, filename = splitfilename(filename) + dirname, filename = split_filename(filename) stream = popen("%s %s %s %s %s" % (echeck_cmd, locale, filename, dirname, rules), 'r') lines = stream.readlines() if len(lines)==0: @@ -111,14 +142,6 @@ def echeck(filename, locale, rules): stream.close() return mail -## the main body of the script -game = int(argv[1]) - -basedir = rootdir + "/game-%d" % (game, ) -queuename = basedir + "/orders.queue" -if not exists(queuename): - exit(0) - # parse the queue file - #print "connecting to SMTP..." from smtplib import SMTP @@ -127,16 +150,17 @@ try: except: print "could not connect to SMTP server" exit(0) + #print "reading password file..." -pw_data = EPasswd(basedir + "/passwd") +pw_data = EPasswd(os.path.join(game_dir,"passwd")) #print "reading orders.queue..." # move the queue file to a save space while locking it: try: - lock_file(queuename) + lock_file(queue_file) except: exit(0) -queuefile = open(queuename, "r") +queuefile = open(queue_file, "r") lines = queuefile.readlines() queuefile.close() @@ -154,9 +178,9 @@ tmpfile.close() openlog("orders") -unlink(queuename) +unlink(queue_file) try: - unlock_file(queuename) + unlock_file(queue_file) except: pass @@ -170,15 +194,15 @@ for line in lines: email = dict["email"] locale = dict["locale"] game = int(dict["game"]) - file = dict["file"] + infile = dict["file"] gamename='[E%d]' % game rules='e%d' % game warning = "" failed = True - results = check_pwd(file, email, pw_data) - logfile = open(basedir+"/zug.log", "a") - dirname, filename = splitfilename(file) - msg = messages["validate-"+locale] + " " + filename + "\n\n" + results = check_pwd(infile, email, pw_data) + logfile = open(os.path.join(game_dir, "zug.log"), "a") + dirname, filename = split_filename(infile) + msg = messages["validate-"+locale] + " " + infilename + "\n\n" for faction, game_email, success, pwd in results: msg = msg + messages["faction-"+locale] + " " + faction + "\n" if success: failed = False @@ -189,25 +213,24 @@ for line in lines: if failed: warning = " (" + messages["warning-" + locale] + ")" - syslog("failed - no valid password in " + file) + syslog("failed - no valid password in " + infile) else: - result = echeck(file, locale, rules) - if email=='eressea': - print result - continue - elif result is None: + result = None + if os.path.exists(echeck_cmd): + result = echeck(infile, locale, rules) + if result is None: # echeck did not finish - msg = msg + "Echeck was killed. Your turn was accepted, but could not be verified.\n" + msg = msg + "Echeck is broken. Your turn was accepted, but could not be verified.\n" warning = " (" + messages["warning-" + locale] + ")" - syslog("process - echeck got killed, " + file) + syslog("process - echeck broken, " + infile) else: msg = msg + result - syslog("process - checked orders in " + file) + syslog("process - checked orders in " + infile) subject = gamename + " " + messages["subject-" + locale] + warning - msg = "Subject: %s\nFrom: %s\nTo: %s\nContent-Type: text/plain; charset=utf-8\n\n" % (subject, frommail, email) + msg + msg = "Subject: %s\nFrom: %s\nTo: %s\nContent-Type: text/plain; charset=utf-8\n\n" % (subject, sender, email) + msg try: - server.sendmail(frommail, email, msg) + server.sendmail(sender, email, msg) except: syslog("failed - cannot send to " + email) diff --git a/s/setup b/s/setup index fc5fb9874..d8ffa74ad 100755 --- a/s/setup +++ b/s/setup @@ -94,8 +94,8 @@ touch eressea.ini } ini_start -ini_sec eressea -ini_add eressea locales de,en +ini_sec game +ini_add game locales de,en ini_sec lua ini_add lua install $SOURCE ini_add lua paths $SOURCE/scripts:$SOURCE/lunit diff --git a/src/main.c b/src/main.c index 5e998f835..2d81041ec 100644 --- a/src/main.c +++ b/src/main.c @@ -54,23 +54,23 @@ static void load_inifile(dictionary * d) assert(d); - str = iniparser_getstring(d, "eressea:base", basedir); + str = iniparser_getstring(d, "game:base", basedir); if (str != basedir) { set_basepath(str); } - str = iniparser_getstring(d, "eressea:report", reportdir); + str = iniparser_getstring(d, "game:report", reportdir); if (str != reportdir) { set_reportpath(str); } - str = iniparser_getstring(d, "eressea:data", datadir); + str = iniparser_getstring(d, "game:data", datadir); if (str != datadir) { set_datapath(str); } - lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0; + lomem = iniparser_getint(d, "game:lomem", lomem) ? 1 : 0; - verbosity = iniparser_getint(d, "eressea:verbose", 2); - str = iniparser_getstring(d, "eressea:locales", "de,en"); + verbosity = iniparser_getint(d, "game:verbose", 2); + str = iniparser_getstring(d, "game:locales", "de,en"); make_locales(str); if (global.inifile) iniparser_freedict(global.inifile); @@ -84,7 +84,7 @@ static void parse_config(const char *filename) load_inifile(d); log_debug("reading from configuration file %s\n", filename); - memdebug = iniparser_getint(d, "eressea:memcheck", memdebug); + memdebug = iniparser_getint(d, "game:memcheck", memdebug); #ifdef USE_CURSES /* only one value in the [editor] section */ force_color = iniparser_getint(d, "editor:color", force_color); From 0909b0b8405e965826cd4348d65ae6c6559bfc5c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 Jan 2017 20:05:33 +0100 Subject: [PATCH 331/675] we do not need eressea.conf --- process/send-bz2-report | 1 - process/sendreport.sh | 1 - process/sendreports.sh | 1 - 3 files changed, 3 deletions(-) diff --git a/process/send-bz2-report b/process/send-bz2-report index e9962d539..983564bea 100755 --- a/process/send-bz2-report +++ b/process/send-bz2-report @@ -8,7 +8,6 @@ if [ ! -f reports.txt ]; then exit -2 fi source $HOME/bin/functions.sh -source $ERESSEA/etc/eressea.conf TEMPLATE=report-mail.txt if [ "$1" == "-Lde" ] diff --git a/process/sendreport.sh b/process/sendreport.sh index 1b9af1d35..93d52f0b4 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -8,7 +8,6 @@ if [ -z $ERESSEA ]; then exit -2 fi source $HOME/bin/functions.sh -source $HOME/etc/eressea.conf GAME=$1 EMAIL=$2 diff --git a/process/sendreports.sh b/process/sendreports.sh index fc24200b6..c2bfa741c 100755 --- a/process/sendreports.sh +++ b/process/sendreports.sh @@ -8,7 +8,6 @@ if [ -z $ERESSEA ]; then exit -2 fi source $HOME/bin/functions.sh -source $ERESSEA/etc/eressea.conf if [ ! -z $1 ]; then GAME=$ERESSEA/game-$1 From 9c699634779c355179224976ec232ab6498683fd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 Jan 2017 22:39:38 +0100 Subject: [PATCH 332/675] change error message categories. also removing some unused messages and code that supports them. https://bugs.eressea.de/view.php?id=2270 --- res/core/messages.xml | 117 +++++++--------------------------------- src/kernel/messages.c | 18 ------- src/kernel/types.h | 2 - src/util/unicode.test.c | 17 ++++++ 4 files changed, 36 insertions(+), 118 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 260f76c70..41569d9f3 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -1804,7 +1804,7 @@ "$unit($unit) in $region($region): '$order($command)' - Der Magier erschafft ein Traumgebäude." "$unit($unit) in $region($region): '$order($command)' - The magician creates an illusionary building." - + @@ -2402,7 +2402,7 @@ "Eine Botschaft von $unit.dative($unit) in $region($region): 'Ups! Quack, Quack!'" "A message from $unit($unit) in $region($region): 'Oops! Croak, Croak!'" - + @@ -2412,7 +2412,7 @@ "$unit($unit) in $region($region): '$order($command)' - $unit($mage) kann Zauber, die durch $unit($unit) gewirkt werden, nicht zusätzlich in die Ferne richten." "$unit($unit) in $region($region): '$order($command)' - $unit($mage) cannot direct spells that are channeled through $unit($unit) into distant regions." - + @@ -2552,13 +2552,6 @@ "$unit($unit) in $region($region) regeneriert $int($amount) Aura." "$unit($unit) regenerates $int($amount) aura in $region($region)." - - - - - "$string" - "$string" - @@ -2596,13 +2589,6 @@ "$unit($teacher) lehrt $unit($student) $skill($skill)." "$unit($teacher) teaches $unit($student) $skill($skill)." - - - - - "$string" - "$string" - @@ -2834,13 +2820,6 @@ "$unit($unit) baut für $int($size) an $ship($ship) weiter." "$unit($unit) builds $int($size) more on $ship($ship)." - - - - - "$string" - "$string" - @@ -2878,15 +2857,7 @@ "$unit($unit) $if($eq($mode,1),"reitet", "wandert") von $region($start) nach $region($end).$if($isnull($regions),""," Dabei wurde $trail($regions) durchquert.")" "$unit($unit) $if($eq($mode,1),"rides", "walks") from $region($start) to $region($end)$if($isnull($regions),""," by way of $trail($regions)")." - - - - - - "$unit($unit) entdeckt dass im $direction($direction) $terrain($region) ist." - "$unit($unit) discovered that $terrain($region) lies in the $direction($direction)." - - + @@ -2895,7 +2866,7 @@ "$unit($unit) entdeckt, dass $region($region) $localize($terrain) ist." "$unit($unit) discovered that $region($region) is $localize($terrain)." - + @@ -2903,7 +2874,7 @@ "$unit($unit) ist in dieser Runde gelandet und kann nicht weiter ins Landesinnere nach $region($region) vorstossen." "$unit($unit) has just landed and cannot continue moving to $region($region)." - + @@ -2911,7 +2882,7 @@ "Die Mannschaft der $ship($ship) kann in letzter Sekunde verhindern, dass das Schiff in $region($region) auf Land aufläuft." "At the very last moment, the crew of the $ship($ship) saved the ship from running aground in $region($region)." - + @@ -2919,7 +2890,7 @@ "Die $ship($ship) konnte in $region($region) nicht einreisen, die Küste ist zu gefährlich für das Schiff." "The $ship($ship) could not berth in $region($region). The coast is too dangerous for the vessel." - + @@ -2927,7 +2898,7 @@ "Die Mannschaft der $ship($ship) weigert sich, nach $direction($direction) zu reisen." "The crew of the $ship($ship) refuses to travel to the $direction($direction)." - + @@ -2935,7 +2906,7 @@ "Die Mannschaft der $ship($ship) weigert sich, nach $region($region) zu reisen." "The crew of the $ship($ship) refuses to travel to $region($region)." - + @@ -2943,7 +2914,7 @@ "$unit($unit) weigert sich, nach $direction($direction) zu reisen." "$unit($unit) refuses to travel to the $direction($direction)." - + @@ -2951,7 +2922,7 @@ "$unit($unit) weigert sich, nach $region($region) zu reisen." "$unit($unit) refuses to travel to $region($region)." - + @@ -2959,7 +2930,7 @@ "Die $ship($ship) konnte $region($region) nicht verlassen." "The $ship($ship) could not leave $region($region)." - + @@ -2968,35 +2939,7 @@ "$unit($unit) wurde in $region($region) von $unit.dative($guard) aufgehalten." "$unit($unit) was kept in $region($region) by $unit($guard)." - - - - - "Wir haben den Krieg mit $faction($faction) beendet." - "We declared peace with $faction($faction)." - - - - - - "$faction($faction) hat den Krieg mit uns beendet." - "$faction($faction) has declared peace with us." - - - - - - "Wir haben $faction($faction) den Krieg erklärt." - "We declared war on $faction($faction)." - - - - - - "$faction($faction) hat uns den Krieg erklärt." - "$faction($faction) has declared war on us." - - + @@ -3005,7 +2948,7 @@ "$unit($unit) konnte nicht von $region($region) nach $region($target) reisen, da der Besitzer der Region es verhinderte." "$unit($unit) could not travel from $region($region) to $region($target) because the owner denied entrance." - + @@ -3029,7 +2972,7 @@ "$unit($follower) konnte $unit($unit) nicht folgen." "$unit($follower) could not follow $unit($unit)." - + @@ -3037,7 +2980,7 @@ "$unit($unit) entdeckt, dass es keinen Weg nach $direction($direction) gibt." "$unit($unit) discovers that there is no route going $direction($direction)." - + @@ -3046,13 +2989,6 @@ "$unit($unit) konnte von $region($region) nicht nach $direction($direction) ausreisen, der Nebel war zu dicht." "$unit($unit) could not travel $direction($direction) from $region($region), the fog was too dense." - - - - - "$string" - "$string" - @@ -6945,13 +6881,6 @@ "$unit($unit) in $region($region): '$order($command)' - Man benötigt mindestens $int($minskill) $skill($skill), um $resource($product,0) zu produzieren." "$unit($unit) in $region($region): '$order($command)' - You need at least $int($minskill) $skill($skill), to produce $resource($product,0)." - - - - - "$string" - "$string" - @@ -6959,13 +6888,6 @@ "$string" "$string" - - - - - "$string" - "$string" - @@ -6997,7 +6919,6 @@ "$unit($target) erhält $int($amount) $resource($resource,$amount) von $unit($unit)." "$unit($target) receives $int($amount) $resource($resource,$amount) from $unit($unit)." - @@ -7200,7 +7121,7 @@ "$unit($unit) in $region($region): '$order($command)' - No pyramids may be build in this region. The closest region to build a pyramid in is between $int($mindist) and $int($maxdist) regions away." - + @@ -7621,7 +7542,7 @@ "Heer $int($index)($abbrev): $int($dead) Tote, $int($fled) Geflohene, $int($survived) Überlebende." "Army $int($index)($abbrev): $int($dead) dead, $int($fled) fled, $int($survived) survivors." - + diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 89278624f..cb859df96 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -214,29 +214,11 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level) UNUSED_ARG(level); switch (mtype) { - case MSG_INCOME: - assert(f); - m = add_message(&f->msgs, msg_message("msg_economy", "string", s)); - break; case MSG_BATTLE: assert(0 || !"battle messages must not use addmessage"); break; - case MSG_MOVE: - assert(f); - m = add_message(&f->msgs, msg_message("msg_movement", "string", s)); - break; - case MSG_COMMERCE: - assert(f); - m = add_message(&f->msgs, msg_message("msg_economy", "string", s)); - break; - case MSG_PRODUCE: - assert(f); - m = add_message(&f->msgs, msg_message("msg_production", "string", s)); - break; case MSG_MAGIC: - case MSG_COMMENT: case MSG_MESSAGE: - case MSG_ORCVERMEHRUNG: case MSG_EVENT: /* Botschaften an REGION oder einzelne PARTEI */ m = msg_message("msg_event", "string", s); diff --git a/src/kernel/types.h b/src/kernel/types.h index da4fefecf..92f471688 100644 --- a/src/kernel/types.h +++ b/src/kernel/types.h @@ -146,9 +146,7 @@ typedef enum { /* Fehler und Meldungen im Report */ MSG_INCOME, MSG_COMMERCE, MSG_PRODUCE, - MSG_ORCVERMEHRUNG, MSG_MESSAGE, - MSG_COMMENT, MSG_MAGIC, MAX_MSG } msg_t; diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index ef07c944c..a6268186e 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -100,9 +100,26 @@ static void test_unicode_utf8_to_ucs(CuTest *tc) { CuAssertIntEquals(tc, 1, sz); } +static void test_unicode_bug2262(CuTest *tc) { + char name[7]; + ucs4_t ucs; + size_t sz; + + strcpy(name, "utende"); + CuAssertIntEquals(tc, 0, unicode_utf8_to_ucs4(&ucs, name, &sz)); + CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 'u', ucs); + CuAssertIntEquals(tc, 0, unicode_utf8_trim(name)); + + name[0] = -4; // latin1: ü should fail to decode + CuAssertIntEquals(tc, EILSEQ, unicode_utf8_to_ucs4(&ucs, name, &sz)); + CuAssertIntEquals(tc, EILSEQ, unicode_utf8_trim(name)); +} + CuSuite *get_unicode_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_unicode_bug2262); SUITE_ADD_TEST(suite, test_unicode_tolower); SUITE_ADD_TEST(suite, test_unicode_trim); SUITE_ADD_TEST(suite, test_unicode_utf8_to_other); From 23e0943baa70204f7dc9523e849e96f1c7420411 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Jan 2017 18:53:11 +0100 Subject: [PATCH 333/675] read game configuration data from .ini file --- src/kernel/config.c | 34 ++++++++++++++++++++++++++++++++++ src/kernel/config.h | 1 + src/main.c | 1 + 3 files changed, 36 insertions(+) diff --git a/src/kernel/config.c b/src/kernel/config.c index 1f3cd92b2..955a9d598 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -713,6 +713,40 @@ bool config_changed(int *cache_key) { return false; } +#define MAXKEYS 16 +void config_set_from(const dictionary *d) +{ + int s, nsec = iniparser_getnsec(d); + for (s=0;s!=nsec;++s) { + char key[128]; + const char *sec = iniparser_getsecname(d, s); + int k, nkeys = iniparser_getsecnkeys(d, sec); + const char *akeys[MAXKEYS]; + const char ** keys = akeys; + size_t slen = strlen(sec); + assert(slenMAXKEYS) { + keys = malloc(sizeof(const char *) * nkeys); + } + iniparser_getseckeys(d, sec, keys); + for (k=0;k!=nkeys;++k) { + const char *val; + size_t klen = strlen(keys[k]); + assert(klen+slen+1 Date: Sat, 21 Jan 2017 19:53:47 +0100 Subject: [PATCH 334/675] issue #629: fix eressea.ini config fixed reading of ini data into config (keys have a . here, not a :). added a test. removed obsolete global.inifile variable. --- src/bindings.c | 10 +++++----- src/bindings.h | 6 +++--- src/kernel/config.c | 10 +++++----- src/kernel/config.h | 5 +++-- src/kernel/config.test.c | 17 +++++++++++++++++ src/main.c | 17 ++++++++--------- 6 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index f17ccc3a1..94e78fb70 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -978,7 +978,7 @@ static int tolua_report_unit(lua_State * L) return 1; } -static void parse_inifile(lua_State * L, dictionary * d, const char *section) +static void parse_inifile(lua_State * L, const dictionary * d, const char *section) { int i; const char *arg; @@ -1018,7 +1018,7 @@ static void parse_inifile(lua_State * L, dictionary * d, const char *section) void tolua_bind_open(lua_State * L); -int tolua_bindings_open(lua_State * L) +int tolua_bindings_open(lua_State * L, const dictionary *inifile) { tolua_open(L); @@ -1072,7 +1072,7 @@ int tolua_bindings_open(lua_State * L) tolua_module(L, TOLUA_CAST "config", 1); tolua_beginmodule(L, TOLUA_CAST "config"); { - parse_inifile(L, global.inifile, "lua"); + parse_inifile(L, inifile, "lua"); tolua_variable(L, TOLUA_CAST "locales", &config_get_locales, 0); tolua_function(L, TOLUA_CAST "get_resource", &config_get_resource); tolua_variable(L, TOLUA_CAST "buildings", &config_get_buildings, 0); @@ -1142,12 +1142,12 @@ void lua_done(lua_State * L) { lua_close(L); } -lua_State *lua_init(void) { +lua_State *lua_init(const dictionary *inifile) { lua_State *L = luaL_newstate(); openlibs(L); register_tolua_helpers(); - tolua_bindings_open(L); + tolua_bindings_open(L, inifile); tolua_eressea_open(L); #ifdef USE_SQLITE tolua_sqlite_open(L); diff --git a/src/bindings.h b/src/bindings.h index 6c71ecf94..2db83248d 100755 --- a/src/bindings.h +++ b/src/bindings.h @@ -16,10 +16,10 @@ extern "C" { struct lua_State; struct quicklist; + struct _dictionary_; int tolua_sqlite_open(struct lua_State *L); - int tolua_bindings_open(struct lua_State *L); - int tolua_spelllist_next(struct lua_State *L); + int tolua_bindings_open(struct lua_State *L, const struct _dictionary_ *d); int tolua_itemlist_next(struct lua_State *L); int tolua_orderlist_next(struct lua_State *L); int tolua_quicklist_push(struct lua_State *L, const char *list_type, @@ -28,7 +28,7 @@ extern "C" { int log_lua_error(struct lua_State *L); void lua_done(struct lua_State *L); - struct lua_State *lua_init(void); + struct lua_State *lua_init(const struct _dictionary_ *d); int eressea_run(struct lua_State *L, const char *luafile); #ifdef __cplusplus diff --git a/src/kernel/config.c b/src/kernel/config.c index 955a9d598..4b8bc7e72 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -721,12 +721,12 @@ void config_set_from(const dictionary *d) char key[128]; const char *sec = iniparser_getsecname(d, s); int k, nkeys = iniparser_getsecnkeys(d, sec); - const char *akeys[MAXKEYS]; - const char ** keys = akeys; + char *akeys[MAXKEYS]; + char ** keys = akeys; size_t slen = strlen(sec); assert(slenMAXKEYS) { keys = malloc(sizeof(const char *) * nkeys); } @@ -735,8 +735,8 @@ void config_set_from(const dictionary *d) const char *val; size_t klen = strlen(keys[k]); assert(klen+slen+1 #include #include "types.h" -struct param; + + struct param; + struct _dictionary_; #define DISPLAYSIZE 8192 /* max. L�nge einer Beschreibung, incl trailing 0 */ #define ORDERSIZE (DISPLAYSIZE*2) /* max. length of an order */ @@ -108,7 +110,6 @@ struct param; struct attrib *attribs; unsigned int data_turn; void *vm_state; - struct _dictionary_ *inifile; struct global_functions { int(*wage) (const struct region * r, const struct faction * f, const struct race * rc, int in_turn); diff --git a/src/kernel/config.test.c b/src/kernel/config.test.c index 405587443..719ff840e 100644 --- a/src/kernel/config.test.c +++ b/src/kernel/config.test.c @@ -9,6 +9,8 @@ #include #include +#include + #include #include @@ -233,9 +235,24 @@ static void test_rules(CuTest *tc) { CuAssertIntEquals(tc, 1000, rule_faction_limit()); } +static void test_config_inifile(CuTest *tc) { + dictionary *ini; + test_setup(); + ini = dictionary_new(0); + dictionary_set(ini, "game", NULL); + iniparser_set(ini, "game:id", "42"); + iniparser_set(ini, "game:name", "Eressea"); + config_set_from(ini); + CuAssertStrEquals(tc, "Eressea", config_get("game.name")); + CuAssertIntEquals(tc, 42, game_id()); + iniparser_freedict(ini); + test_cleanup(); +} + CuSuite *get_config_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_config_inifile); SUITE_ADD_TEST(suite, test_config_cache); SUITE_ADD_TEST(suite, test_get_set_param); SUITE_ADD_TEST(suite, test_param_int); diff --git a/src/main.c b/src/main.c index 97c84dffe..777770f0a 100644 --- a/src/main.c +++ b/src/main.c @@ -72,12 +72,9 @@ static void load_inifile(dictionary * d) verbosity = iniparser_getint(d, "game:verbose", 2); str = iniparser_getstring(d, "game:locales", "de,en"); make_locales(str); - - if (global.inifile) iniparser_freedict(global.inifile); - global.inifile = d; } -static void parse_config(const char *filename) +static dictionary *parse_config(const char *filename) { dictionary *d = iniparser_load(filename); if (d) { @@ -92,6 +89,7 @@ static void parse_config(const char *filename) gm_codepage = iniparser_getint(d, "editor:codepage", gm_codepage); #endif } + return d; } static int usage(const char *prog, const char *arg) @@ -272,10 +270,11 @@ int main(int argc, char **argv) { int err = 0; lua_State *L; + dictionary *d; setup_signal_handler(); /* ini file sets defaults for arguments*/ - parse_config(inifile); - if (!global.inifile) { + d = parse_config(inifile); + if (!d) { log_error("could not open ini configuration %s\n", inifile); } /* parse arguments again, to override ini file */ @@ -283,7 +282,7 @@ int main(int argc, char **argv) locale_init(); - L = lua_init(); + L = lua_init(d); game_init(); bind_monsters(L); err = eressea_run(L, luafile); @@ -294,8 +293,8 @@ int main(int argc, char **argv) game_done(); lua_done(L); log_close(); - if (global.inifile) { - iniparser_freedict(global.inifile); + if (d) { + iniparser_freedict(d); } return 0; } From 75a97c2977bcb68ff1f3d5fb5e7f8d99e1d789b5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Jan 2017 20:39:46 +0100 Subject: [PATCH 335/675] fix gcc build, introduce a hard limit on ini section size --- src/kernel/config.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index 4b8bc7e72..4459ce44a 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -721,15 +721,12 @@ void config_set_from(const dictionary *d) char key[128]; const char *sec = iniparser_getsecname(d, s); int k, nkeys = iniparser_getsecnkeys(d, sec); - char *akeys[MAXKEYS]; - char ** keys = akeys; + const char *keys[MAXKEYS]; size_t slen = strlen(sec); + assert(nkeys <= MAXKEYS); assert(slenMAXKEYS) { - keys = malloc(sizeof(const char *) * nkeys); - } iniparser_getseckeys(d, sec, keys); for (k=0;k!=nkeys;++k) { const char *val; @@ -741,9 +738,6 @@ void config_set_from(const dictionary *d) config_set(key, val); } } - if (keys!=akeys) { - free(keys); - } } } From 8c4cccbc65a9bdf8668a31a341c25d3e1548b9a6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Jan 2017 20:51:08 +0100 Subject: [PATCH 336/675] fix valgrind error. I did not understand what keys look like, then effed up when fixing that. --- src/kernel/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index 4459ce44a..88130056b 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -732,7 +732,7 @@ void config_set_from(const dictionary *d) const char *val; size_t klen = strlen(keys[k]); assert(klen+slen+1 Date: Sat, 21 Jan 2017 20:59:16 +0100 Subject: [PATCH 337/675] config.json settings shall not override eressea.ini --- src/kernel/jsonconf.c | 4 +++- src/kernel/jsonconf.test.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 414704309..03e210ce0 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -806,7 +806,9 @@ static void json_settings(cJSON *json) { else { sprintf(value, "%d", child->valueint); } - config_set(child->string, value); + if (config_get(child->string) == NULL) { + config_set(child->string, value); + } } } } diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 950868046..93fcd8d10 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -69,12 +69,15 @@ static void test_settings(CuTest * tc) "\"string\" : \"1d4\"," "\"integer\" : 14," "\"true\": true," + "\"game.id\": 4," "\"false\": false," "\"float\" : 1.5 }}"; cJSON *json = cJSON_Parse(data); test_cleanup(); + config_set("game.id", "42"); // should not be replaced json_config(json); + CuAssertStrEquals(tc, "42", config_get("game.id")); CuAssertStrEquals(tc, "1", config_get("true")); CuAssertStrEquals(tc, "0", config_get("false")); CuAssertStrEquals(tc, "1d4", config_get("string")); From f633099b97aef8f119d2af56146df3a16d4e3336 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Jan 2017 21:03:48 +0100 Subject: [PATCH 338/675] add game id to eressea.ini --- s/setup | 1 + 1 file changed, 1 insertion(+) diff --git a/s/setup b/s/setup index d8ffa74ad..848175ddc 100755 --- a/s/setup +++ b/s/setup @@ -96,6 +96,7 @@ touch eressea.ini ini_start ini_sec game ini_add game locales de,en +ini_add id $game ini_sec lua ini_add lua install $SOURCE ini_add lua paths $SOURCE/scripts:$SOURCE/lunit From 446e58c3831bfbcd49cf2b61caed466ef528133e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 04:46:36 +0100 Subject: [PATCH 339/675] use the email address from eressea.ini in CR mailto --- conf/e2/config.xml | 4 ---- conf/e3/config.xml | 4 ---- conf/e4/config.xml | 4 ---- src/creport.c | 7 +++++-- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 0441a46f6..9e32218da 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -53,10 +53,6 @@ - - eressea-server@eressea.kn-bremen.de - eressea-server@eressea.kn-bremen.de - Bitte denke daran, deine Befehle mit dem Betreff ERESSEA 2 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. diff --git a/conf/e3/config.xml b/conf/e3/config.xml index c8c5dbb06..6a5b18b84 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -45,10 +45,6 @@ - - eressea-server@eressea.kn-bremen.de - eressea-server@eressea.kn-bremen.de - Bitte denke daran, deine Befehle mit dem Betreff ERESSEA 3 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. diff --git a/conf/e4/config.xml b/conf/e4/config.xml index b188f7d79..3209c8eed 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -46,10 +46,6 @@ - - eressea-server@eressea.kn-bremen.de - eressea-server@eressea.kn-bremen.de - Bitte denke daran, deine Befehle mit dem Betreff ERESSEA 4 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. diff --git a/src/creport.c b/src/creport.c index bd9c97ec6..34cff9de3 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1475,7 +1475,7 @@ report_computer(const char *filename, report_context * ctx, const char *bom) faction *f = ctx->f; const char *prefix; region *r; - const char *mailto = LOC(f->locale, "mailto"); + const char *mailto = config_get("game.email"); const attrib *a; FILE *F = fopen(filename, "w"); static const race *rc_human; @@ -1510,8 +1510,11 @@ report_computer(const char *filename, report_context * ctx, const char *bom) fprintf(F, "%d;Zeitalter\n", era); fprintf(F, "\"%s\";Build\n", eressea_version()); if (mailto != NULL) { + // char mailcmd[64]; + // snprintf(mailcmd, sizeof(mailcmd), "%s %d, %s", game_name(), game_id(), LOC(f->locale, "mailcmd")); + const char * mailcmd = LOC(f->locale, "mailcmd"); fprintf(F, "\"%s\";mailto\n", mailto); - fprintf(F, "\"%s\";mailcmd\n", LOC(f->locale, "mailcmd")); + fprintf(F, "\"%s\";mailcmd\n", mailcmd); } show_alliances_cr(F, f); From 1a20d6e5c6036be83a18c6eec5bf4a2f5994c2a0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 04:55:19 +0100 Subject: [PATCH 340/675] use FACTION in text template, not ERESSEA --- src/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/report.c b/src/report.c index 9b5e243b4..3c15f54f4 100644 --- a/src/report.c +++ b/src/report.c @@ -1408,7 +1408,7 @@ report_template(const char *filename, report_context * ctx, const char *bom) newline(out); newline(out); - sprintf(buf, "%s %s \"password\"", LOC(f->locale, "ERESSEA"), itoa36(f->no)); + sprintf(buf, "%s %s \"password\"", LOC(f->locale, parameters[P_FACTION]), itoa36(f->no)); rps_nowrap(out, buf); newline(out); newline(out); From cacb4505671dd43bf32f980b1a4536d4a459df93 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 05:13:44 +0100 Subject: [PATCH 341/675] game.start in eressea.ini overrides calendar --- s/setup | 3 ++- src/bindings.c | 2 +- src/calendar.c | 9 +++++++-- src/calendar.h | 6 +++--- src/kernel/xmlreader.c | 7 ++++++- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/s/setup b/s/setup index 848175ddc..e3e8e113d 100755 --- a/s/setup +++ b/s/setup @@ -96,7 +96,8 @@ touch eressea.ini ini_start ini_sec game ini_add game locales de,en -ini_add id $game +ini_add game id $game +ini_add game start 1 ini_sec lua ini_add lua install $SOURCE ini_add lua paths $SOURCE/scripts:$SOURCE/lunit diff --git a/src/bindings.c b/src/bindings.c index 94e78fb70..14eae1c56 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -948,7 +948,7 @@ static int init_data(const char *filename, const char *catalog) return l; } if (turn < 0) { - turn = first_turn; + turn = first_turn(); } return 0; } diff --git a/src/calendar.c b/src/calendar.c index 7a27328a7..2099b6631 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -1,10 +1,10 @@ #include #include "calendar.h" +#include #include #include -int first_turn = 0; int first_month = 0; int weeks_per_month = 4; int months_per_year = 12; @@ -16,10 +16,15 @@ int *month_season = NULL; char *agename = NULL; int seasons = 0; +int first_turn(void) +{ + return config_get_int("game.start", 1); +} + const gamedate *get_gamedate(int turn, gamedate * gd) { int weeks_per_year = months_per_year * weeks_per_month; - int t = turn - first_turn; + int t = turn - first_turn(); assert(gd); if (t < 0) diff --git a/src/calendar.h b/src/calendar.h index 86f665c1a..d398cd77c 100644 --- a/src/calendar.h +++ b/src/calendar.h @@ -13,7 +13,6 @@ extern "C" { }; extern char *agename; - extern int first_turn; extern int first_month; extern int seasons; @@ -35,8 +34,9 @@ extern "C" { int week; } gamedate; - extern const gamedate *get_gamedate(int turn, gamedate * gd); - extern void calendar_cleanup(void); +const gamedate *get_gamedate(int turn, gamedate * gd); +void calendar_cleanup(void); +int first_turn(void); #ifdef __cplusplus } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 2f38cdab3..2ba9d785a 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -375,8 +375,13 @@ static int parse_calendar(xmlDocPtr doc) xmlNodeSetPtr nsetWeeks, nsetMonths, nsetSeasons; xmlChar *propValue = xmlGetProp(calendar, BAD_CAST "name"); xmlChar *newyear = xmlGetProp(calendar, BAD_CAST "newyear"); + xmlChar *start; - first_turn = xml_ivalue(calendar, "start", first_turn); + start = xmlGetProp(calendar, BAD_CAST "start"); + if (start && config_get("game.start")==NULL) { + config_set("game.start", (const char *)start); + xmlFree(start); + } if (propValue) { free(agename); agename = strdup(mkname("calendar", (const char *)propValue)); From d29fd96f59f38ef0c91414356660935406c3612a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 08:03:12 +0100 Subject: [PATCH 342/675] no starting equipment. do not let the addplayer function give equipment. rename equipment for autoseed. --- conf/e2/config.xml | 2 +- conf/e3/config.xml | 8 -------- conf/e4/config.xml | 9 --------- res/eressea/equipment.xml | 22 +++++++++++----------- scripts/eressea/autoseed.lua | 6 +++--- src/kernel/faction.c | 6 ------ 6 files changed, 15 insertions(+), 38 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 9e32218da..5affea141 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -42,7 +42,7 @@ - + diff --git a/conf/e3/config.xml b/conf/e3/config.xml index 6a5b18b84..35716f332 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -28,14 +28,6 @@ - - - - - - - - diff --git a/conf/e4/config.xml b/conf/e4/config.xml index 3209c8eed..ac962202c 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -27,15 +27,6 @@ - - - - - - - - - diff --git a/res/eressea/equipment.xml b/res/eressea/equipment.xml index bf7e38376..efd4f2a3b 100644 --- a/res/eressea/equipment.xml +++ b/res/eressea/equipment.xml @@ -2,18 +2,18 @@ - + - + - + @@ -21,30 +21,30 @@ - + - + - + - + - + - + @@ -58,12 +58,12 @@ - + - + diff --git a/scripts/eressea/autoseed.lua b/scripts/eressea/autoseed.lua index 562c39361..822725804 100644 --- a/scripts/eressea/autoseed.lua +++ b/scripts/eressea/autoseed.lua @@ -64,9 +64,9 @@ local function seed(r, email, race, lang) assert(f) local u = unit.create(f, r) assert(u) - equip_unit(u, "new_faction") - equip_unit(u, "first_unit") - equip_unit(u, "first_" .. race, 7) -- disable old callbacks + equip_unit(u, "autoseed_faction") + equip_unit(u, "autoseed_unit") + equip_unit(u, "autoseed_" .. race, 7) unit.create(f, r, 5):set_skill("mining", 30) unit.create(f, r, 5):set_skill("quarrying", 30) f:set_origin(r) diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 2c6d4d244..e3b80566d 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -22,7 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "alliance.h" #include "ally.h" #include "curse.h" -#include "equipment.h" #include "group.h" #include "item.h" #include "messages.h" @@ -286,15 +285,10 @@ faction *addfaction(const char *email, const char *password, unit *addplayer(region * r, faction * f) { unit *u; - char buffer[32]; assert(f->units == NULL); faction_setorigin(f, 0, r->x, r->y); u = create_unit(r, f, 1, f->race, 0, NULL, NULL); - equip_items(&u->faction->items, get_equipment("new_faction")); - equip_unit(u, get_equipment("first_unit")); - sprintf(buffer, "first_%s", u_race(u)->_name); - equip_unit(u, get_equipment(buffer)); u->hp = unit_max_hp(u) * u->number; fset(u, UFL_ISNEW); if (f->race == get_race(RC_DAEMON)) { From 8d4a83d1b4fc5255104e68ac27d357c09fc75000 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 11:38:01 +0100 Subject: [PATCH 343/675] make these modules optional --- scripts/eressea/autoseed.lua | 1 + scripts/eressea/embassy.lua | 8 +++++--- scripts/eressea/eternath.lua | 2 +- scripts/eressea/ponnuki.lua | 1 + scripts/eressea/wedding.lua | 1 + scripts/eressea/xmas.lua | 2 ++ 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/eressea/autoseed.lua b/scripts/eressea/autoseed.lua index 822725804..9e5060f85 100644 --- a/scripts/eressea/autoseed.lua +++ b/scripts/eressea/autoseed.lua @@ -1,3 +1,4 @@ +if not config.autoseed then return nil end local autoseed = {} -- minimum required resources in the 7-hex neighborhood: diff --git a/scripts/eressea/embassy.lua b/scripts/eressea/embassy.lua index efbe248b7..82bce62c2 100644 --- a/scripts/eressea/embassy.lua +++ b/scripts/eressea/embassy.lua @@ -1,8 +1,5 @@ -- Muschelplateau -local embassy = {} -local home = nil - -- global exports (use item) function use_seashell(u, amount) -- Muschelplateau... @@ -17,6 +14,11 @@ function use_seashell(u, amount) return -4 end +if not config.embassy then return nil end + +local embassy = {} +local home = nil + function embassy.init() home = get_region(165,30) if home==nil then diff --git a/scripts/eressea/eternath.lua b/scripts/eressea/eternath.lua index 858a8d462..063577b74 100644 --- a/scripts/eressea/eternath.lua +++ b/scripts/eressea/eternath.lua @@ -1,5 +1,5 @@ -- DEPRECATED - +if not config.eternath then return nil end -- implements parts of a quest in E2 -- this module is deprecated, because it puts functions in the global environment for at_building_action diff --git a/scripts/eressea/ponnuki.lua b/scripts/eressea/ponnuki.lua index 994a16ff0..96bb0b5f1 100644 --- a/scripts/eressea/ponnuki.lua +++ b/scripts/eressea/ponnuki.lua @@ -1,3 +1,4 @@ +if not config.ponnuki then return nil end local ponnuki = {} local directions = { "NW", "NO", "O", "SO", "SW", "W" } diff --git a/scripts/eressea/wedding.lua b/scripts/eressea/wedding.lua index 812bd3269..2c06d9891 100644 --- a/scripts/eressea/wedding.lua +++ b/scripts/eressea/wedding.lua @@ -1,4 +1,5 @@ -- DEPRECATED +if not config.wedding then return nil end -- this script contains the action functions for the two portals -- used on the jadee/wildente wedding island. the two _action functions diff --git a/scripts/eressea/xmas.lua b/scripts/eressea/xmas.lua index 36e755f45..0316e6265 100644 --- a/scripts/eressea/xmas.lua +++ b/scripts/eressea/xmas.lua @@ -1,3 +1,5 @@ +if not config.xmas then return nil end + local gifts = { e2 = { { year = 2015, turn = 959, item = 'snowglobe', msg='santa_f' }, From 1c7f3fab4440b0c8bd34a7806ec07a269886681a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 12:38:41 +0100 Subject: [PATCH 344/675] emit a password message for newbie factions --- src/kernel/faction.c | 1 + src/kernel/faction.h | 5 +++-- src/laws.c | 1 + src/reports.c | 8 ++++++++ src/reports.test.c | 18 ++++++++++++++++++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/kernel/faction.c b/src/kernel/faction.c index e3b80566d..e884a2d9b 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -249,6 +249,7 @@ faction *addfaction(const char *email, const char *password, if (!password) password = itoa36(rng_int()); faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT)); ADDMSG(&f->msgs, msg_message("changepasswd", "value", password)); + f->flags |= FFL_PWMSG; f->alliance_joindate = turn; f->lastorders = turn; diff --git a/src/kernel/faction.h b/src/kernel/faction.h index de55ad1fe..b4768e982 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -37,10 +37,11 @@ extern "C" { extern struct attrib_type at_maxmagicians; /* faction flags */ -#define FFL_NEWID (1<<0) /* Die Partei hat bereits einmal ihre no gewechselt */ +#define FFL_NEWID (1<<0) // Die Partei hat bereits einmal ihre no gewechselt #define FFL_ISNEW (1<<1) +#define FFL_PWMSG (1<<2) // received a "new password" message #define FFL_QUIT (1<<3) -#define FFL_CURSED (1<<4) /* you're going to have a bad time */ +#define FFL_CURSED (1<<4) // you're going to have a bad time #define FFL_DEFENDER (1<<10) #define FFL_SELECT (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */ #define FFL_NOAID (1<<21) /* Hilfsflag Kampf */ diff --git a/src/laws.c b/src/laws.c index 7baadcf29..112d15fd2 100644 --- a/src/laws.c +++ b/src/laws.c @@ -2214,6 +2214,7 @@ int password_cmd(unit * u, struct order *ord) faction_setpassword(u->faction, password_encode(pwbuf, PASSWORD_DEFAULT)); ADDMSG(&u->faction->msgs, msg_message("changepasswd", "value", pwbuf)); + u->faction->flags |= FFL_PWMSG; return 0; } diff --git a/src/reports.c b/src/reports.c index 6d0aaba37..0da8aed94 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1336,6 +1336,14 @@ void prepare_report(report_context *ctx, faction *f) rule_region_owners = config_token("rules.region_owner_pay_building", bt_lighthouse->_name); } + if (f->age<=2) { + if ((f->flags&FFL_PWMSG)==0) { + // TODO: this assumes unencrypted passwords + f->flags |= FFL_PWMSG; + ADDMSG(&f->msgs, msg_message("changepasswd", "value", f->_password)); + } + } + ctx->f = f; ctx->report_time = time(NULL); ctx->addresses = NULL; diff --git a/src/reports.test.c b/src/reports.test.c index c9fe39c19..389d9c130 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -226,6 +226,23 @@ static void test_arg_resources(CuTest *tc) { test_cleanup(); } +static void test_newbie_password_message(CuTest *tc) { + report_context ctx; + faction *f; + test_setup(); + f = test_create_faction(0); + f->age = 5; + CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG); + prepare_report(&ctx, f); + CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "changepasswd")); + f->age=2; + prepare_report(&ctx, f); + CuAssertIntEquals(tc, FFL_PWMSG, f->flags&FFL_PWMSG); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "changepasswd")); + test_cleanup(); +} + static void test_prepare_travelthru(CuTest *tc) { report_context ctx; faction *f, *f2; @@ -465,6 +482,7 @@ static void test_seen_travelthru(CuTest *tc) { CuSuite *get_reports_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_newbie_password_message); SUITE_ADD_TEST(suite, test_prepare_report); SUITE_ADD_TEST(suite, test_seen_neighbours); SUITE_ADD_TEST(suite, test_seen_travelthru); From 2c6ae9baef473bd4f7e08ba00be3a3b16a595e16 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 12:43:48 +0100 Subject: [PATCH 345/675] remove ERESSEA keyword from "bad password" message. --- res/core/messages.xml | 5 ++--- src/kernel/save.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 41569d9f3..130b58d03 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -3306,11 +3306,10 @@ - - "ERESSEA $int36($faction) \"${password}\" - Deine Befehle hatten ein falsches Passwort." - "ERESSEA $int36($faction) \"${password}\" - Your orders had the wrong password." + "Deine Befehle hatten ein falsches Passwort (${password})." + "Your orders had the wrong password (${password})." diff --git a/src/kernel/save.c b/src/kernel/save.c index 9825a5b55..5b5a5898f 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -235,8 +235,7 @@ static faction *factionorders(void) if (!checkpasswd(f, (const char *)pass)) { log_debug("Invalid password for faction %s", itoa36(fid)); - ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password", - f->no, pass)); + ADDMSG(&f->msgs, msg_message("wrongpasswd", "password", pass)); return 0; } /* Die Partei hat sich zumindest gemeldet, so dass sie noch From 7b55a57610b3e8d54ad2b1a6d6f8642ca9ae391f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 12:51:32 +0100 Subject: [PATCH 346/675] remove sqlite3 code and dependency --- CMakeLists.txt | 1 - process/sendreport.sh | 6 -- src/CMakeLists.txt | 12 --- src/bind_sqlite.c | 95 -------------------- src/bindings.c | 3 - src/bindings.h | 1 - src/sqlite.c | 204 ------------------------------------------ 7 files changed, 322 deletions(-) delete mode 100644 src/bind_sqlite.c delete mode 100644 src/sqlite.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 15629bf4c..8f6953b7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,6 @@ project (eressea-server C) enable_testing() find_package (LibXml2) -find_package (SQLite3) find_package (Curses) find_package (Lua REQUIRED) find_package (ToLua REQUIRED) diff --git a/process/sendreport.sh b/process/sendreport.sh index 93d52f0b4..81d16813c 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -39,9 +39,3 @@ fi source ${FACTION}.sh $EMAIL || reply "Unbekannte Partei $FACTION" -if [ -e $ERESSEA/game-$GAME/eressea.db ]; then - SQL="select email from faction f left join faction_data fd on fd.faction_id=f.id where f.game_id=$GAME AND fd.code='$FACTION' and fd.turn=(select max(turn) from faction_data fx where fx.faction_id=f.id)" - OWNER=$(sqlite3 $ERESSEA/game-$GAME/eressea.db "$SQL") - echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ - | mutt -s "Reportnachforderung Partei ${FACTION}" $OWNER -fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 81a43e002..499b36409 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -157,13 +157,6 @@ set(SERVER_SRC bind_unit.c ) -if (SQLITE3_FOUND) -set (SERVER_SRC ${SERVER_SRC} - sqlite.c - bind_sqlite.c -) -endif (SQLITE3_FOUND) - if (CURSES_FOUND) set (SERVER_SRC ${SERVER_SRC} gmtool.c @@ -255,11 +248,6 @@ add_test(server test_eressea) install(TARGETS eressea DESTINATION "bin") -if (SQLITE3_FOUND) -target_link_libraries(eressea ${SQLITE3_LIBRARIES}) -add_definitions(-DUSE_SQLITE) -endif(SQLITE3_FOUND) - if (CURSES_FOUND) include_directories (${CURSES_INCLUDE_DIR}) target_link_libraries(eressea ${CURSES_LIBRARIES}) diff --git a/src/bind_sqlite.c b/src/bind_sqlite.c deleted file mode 100644 index e8c9b7565..000000000 --- a/src/bind_sqlite.c +++ /dev/null @@ -1,95 +0,0 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - -#include - -#include "bind_unit.h" -#include "bindings.h" - -#include -#include -#include - -#define LTYPE_DB TOLUA_CAST "db" - -extern int db_update_factions(sqlite3 * db, bool force, int game); -static int tolua_db_update_factions(lua_State * L) -{ - sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); - db_update_factions(db, tolua_toboolean(L, 2, 0), game_id()); - return 0; -} - -extern int db_update_scores(sqlite3 * db, bool force); -static int tolua_db_update_scores(lua_State * L) -{ - sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); - db_update_scores(db, tolua_toboolean(L, 2, 0)); - return 0; -} - -static int tolua_db_execute(lua_State * L) -{ - sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); - const char *sql = tolua_tostring(L, 2, 0); - - int res = sqlite3_exec(db, sql, 0, 0, 0); - - lua_pushinteger(L, res); - return 1; -} - -static int tolua_db_close(lua_State * L) -{ - sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); - sqlite3_close(db); - return 0; -} - -static int tolua_db_create(lua_State * L) -{ - sqlite3 *db; - const char *dbname = tolua_tostring(L, 1, 0); - int result = sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READWRITE, 0); - if (result == SQLITE_OK) { - tolua_pushusertype(L, (void *)db, LTYPE_DB); - return 1; - } - return 0; -} - -int tolua_sqlite_open(lua_State * L) -{ - /* register user types */ - - tolua_usertype(L, LTYPE_DB); - - tolua_module(L, NULL, 0); - tolua_beginmodule(L, NULL); - { - tolua_cclass(L, LTYPE_DB, LTYPE_DB, TOLUA_CAST "", NULL); - tolua_beginmodule(L, LTYPE_DB); - { - tolua_function(L, TOLUA_CAST "open", &tolua_db_create); - tolua_function(L, TOLUA_CAST "close", &tolua_db_close); - - tolua_function(L, TOLUA_CAST "update_factions", - &tolua_db_update_factions); - tolua_function(L, TOLUA_CAST "update_scores", &tolua_db_update_scores); - tolua_function(L, TOLUA_CAST "execute", &tolua_db_execute); - } - tolua_endmodule(L); - - } - tolua_endmodule(L); - return 0; -} diff --git a/src/bindings.c b/src/bindings.c index 14eae1c56..b466ce35f 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -1149,9 +1149,6 @@ lua_State *lua_init(const dictionary *inifile) { register_tolua_helpers(); tolua_bindings_open(L, inifile); tolua_eressea_open(L); -#ifdef USE_SQLITE - tolua_sqlite_open(L); -#endif tolua_unit_open(L); tolua_building_open(L); tolua_ship_open(L); diff --git a/src/bindings.h b/src/bindings.h index 2db83248d..be60102a2 100755 --- a/src/bindings.h +++ b/src/bindings.h @@ -18,7 +18,6 @@ extern "C" { struct quicklist; struct _dictionary_; - int tolua_sqlite_open(struct lua_State *L); int tolua_bindings_open(struct lua_State *L, const struct _dictionary_ *d); int tolua_itemlist_next(struct lua_State *L); int tolua_orderlist_next(struct lua_State *L); diff --git a/src/sqlite.c b/src/sqlite.c deleted file mode 100644 index aea0f5d20..000000000 --- a/src/sqlite.c +++ /dev/null @@ -1,204 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -faction *get_faction_by_id(int uid) -{ - faction *f; - for (f = factions; f; f = f->next) { - if (f->subscription == uid) { - return f; - } - } - return NULL; -} - -/* -typedef struct stmt_cache { -sqlite3 *db; -sqlite3_stmt *stmt; -const char *sql; -int inuse; -} stmt_cache; - -#define MAX_STMT_CACHE 64 -static stmt_cache cache[MAX_STMT_CACHE]; -static int cache_insert; - -static sqlite3_stmt *stmt_cache_get(sqlite3 * db, const char *sql) -{ -int i; -sqlite3_stmt *stmt; - -for (i = 0; i != MAX_STMT_CACHE && cache[i].db; ++i) { -if (cache[i].sql == sql && cache[i].db == db) { -cache[i].inuse = 1; -stmt = cache[i].stmt; -sqlite3_reset(stmt); -sqlite3_clear_bindings(stmt); -return stmt; -} -} -if (i == MAX_STMT_CACHE) { -while (cache[cache_insert].inuse) { -cache[cache_insert].inuse = 0; -cache_insert = (cache_insert + 1) & (MAX_STMT_CACHE - 1); -} -i = cache_insert; -stmt = cache[i].stmt; -sqlite3_finalize(stmt); -} -cache[i].inuse = 1; -cache[i].db = db; -cache[i].sql = sql; -sqlite3_prepare_v2(db, sql, -1, &cache[i].stmt, NULL); -return cache[i].stmt; -} -*/ -typedef struct db_faction { - int uid; - int no; - char *email; - char *name; -} db_faction; - -static struct quicklist * -read_factions(sqlite3 * db, int game_id) { - int res; - quicklist *result = 0; - const char * sql = - "SELECT f.id, fd.code, fd.name, fd.email FROM faction f" - " LEFT OUTER JOIN faction_data fd" - " WHERE f.id=fd.faction_id AND f.game_id=? AND" - " fd.turn=(SELECT MAX(turn) FROM faction_data fx WHERE fx.faction_id=f.id)" - " ORDER BY f.id"; - sqlite3_stmt *stmt = 0; - sqlite3_prepare_v2(db, sql, -1, &stmt, 0); - sqlite3_bind_int(stmt, 1, game_id); - - res = sqlite3_step(stmt); - while (res == SQLITE_ROW) { - const char * text; - db_faction * dbf = (db_faction*)calloc(1, sizeof(db_faction)); - dbf->uid = (int)sqlite3_column_int64(stmt, 0); - text = (const char *)sqlite3_column_text(stmt, 1); - if (text) dbf->no = atoi36(text); - text = (const char *)sqlite3_column_text(stmt, 2); - if (text) dbf->name = strdup(text); - text = (const char *)sqlite3_column_text(stmt, 3); - if (text) dbf->email = strdup(text); - ql_push(&result, dbf); - res = sqlite3_step(stmt); - } - sqlite3_finalize(stmt); - return result; -} - -static int insert_faction(sqlite3 *db, int game_id, faction *f) { - const char *sql = "INSERT INTO faction (game_id, race) VALUES (?, ?)"; - sqlite3_stmt *stmt = 0; - sqlite3_prepare_v2(db, sql, -1, &stmt, 0); - sqlite3_bind_int(stmt, 1, game_id); - sqlite3_bind_text(stmt, 2, f->race->_name, -1, SQLITE_STATIC); - sqlite3_step(stmt); - sqlite3_finalize(stmt); - return (int)sqlite3_last_insert_rowid(db); -} - -static void update_faction(sqlite3 *db, const faction *f) { - char code[5]; - const char *sql = - "INSERT INTO faction_data (faction_id, code, name, email, lang, turn)" - " VALUES (?, ?, ?, ?, ?, ?)"; - sqlite3_stmt *stmt = 0; - strcpy(code, itoa36(f->no)); - sqlite3_prepare_v2(db, sql, -1, &stmt, 0); - sqlite3_bind_int(stmt, 1, f->subscription); - sqlite3_bind_text(stmt, 2, code, -1, SQLITE_STATIC); - sqlite3_bind_text(stmt, 3, f->name, -1, SQLITE_STATIC); - sqlite3_bind_text(stmt, 4, f->email, -1, SQLITE_STATIC); - sqlite3_bind_text(stmt, 5, locale_name(f->locale), -1, SQLITE_STATIC); - sqlite3_bind_int(stmt, 6, turn); - sqlite3_step(stmt); - sqlite3_finalize(stmt); -} - -int db_update_factions(sqlite3 * db, bool force, int game_id) { - quicklist *ql = read_factions(db, game_id); - faction *f; - sqlite3_exec(db, "BEGIN", 0, 0, 0); - for (f = factions; f; f = f->next) { - bool update = force; - db_faction *dbf = 0; - ql_iter it = qli_init(&ql); - while (qli_more(it)) { - db_faction *df = (db_faction*)qli_next(&it); - if (f->no == df->no || strcmp(f->email, df->email) == 0 || strcmp(f->name, df->name) == 0) { - dbf = df; - } - if (f->subscription == df->uid) { - dbf = df; - break; - } - } - if (dbf) { - if (dbf->uid != f->subscription) { - log_warning("faction %s(%d) not found in database, but matches %d\n", itoa36(f->no), f->subscription, dbf->uid); - f->subscription = dbf->uid; - } - update = (dbf->no != f->no) || (strcmp(f->email, dbf->email) != 0) || (strcmp(f->name, dbf->name) != 0); - } - else { - f->subscription = insert_faction(db, game_id, f); - log_warning("faction %s not found in database, created as %d\n", itoa36(f->no), f->subscription); - update = true; - } - if (update) { - update_faction(db, f); - log_debug("faction %s updated\n", itoa36(f->no)); - } - } - sqlite3_exec(db, "COMMIT", 0, 0, 0); - return SQLITE_OK; -} - -int db_update_scores(sqlite3 * db, bool force) -{ - /* - const char *sql_ins = - "INSERT OR FAIL INTO score (value,faction_id,turn) VALUES (?,?,?)"; - sqlite3_stmt *stmt_ins = stmt_cache_get(db, sql_ins); - const char *sql_upd = - "UPDATE score set value=? WHERE faction_id=? AND turn=?"; - sqlite3_stmt *stmt_upd = stmt_cache_get(db, sql_upd); - faction *f; - sqlite3_exec(db, "BEGIN", 0, 0, 0); - for (f = factions; f; f = f->next) { - int res; - sqlite3_bind_int(stmt_ins, 1, f->score); - sqlite3_bind_int64(stmt_ins, 2, f->subscription); - sqlite3_bind_int(stmt_ins, 3, turn); - res = sqlite3_step(stmt_ins); - if (res == SQLITE_CONSTRAINT) { - sqlite3_bind_int(stmt_upd, 1, f->score); - sqlite3_bind_int64(stmt_upd, 2, f->subscription); - sqlite3_bind_int(stmt_upd, 3, turn); - res = sqlite3_step(stmt_upd); - sqlite3_reset(stmt_upd); - } - sqlite3_reset(stmt_ins); - } - sqlite3_exec(db, "COMMIT", 0, 0, 0); - */ - return SQLITE_OK; -} From baa210d1a9d1055f62ff14cd2533a4b908be22db Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 12:57:25 +0100 Subject: [PATCH 347/675] Revert "remove sqlite3 code and dependency" This reverts commit 7b55a57610b3e8d54ad2b1a6d6f8642ca9ae391f. --- CMakeLists.txt | 1 + process/sendreport.sh | 6 ++ src/CMakeLists.txt | 12 +++ src/bind_sqlite.c | 95 ++++++++++++++++++++ src/bindings.c | 3 + src/bindings.h | 1 + src/sqlite.c | 204 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 322 insertions(+) create mode 100644 src/bind_sqlite.c create mode 100644 src/sqlite.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f6953b7f..15629bf4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ project (eressea-server C) enable_testing() find_package (LibXml2) +find_package (SQLite3) find_package (Curses) find_package (Lua REQUIRED) find_package (ToLua REQUIRED) diff --git a/process/sendreport.sh b/process/sendreport.sh index 81d16813c..93d52f0b4 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -39,3 +39,9 @@ fi source ${FACTION}.sh $EMAIL || reply "Unbekannte Partei $FACTION" +if [ -e $ERESSEA/game-$GAME/eressea.db ]; then + SQL="select email from faction f left join faction_data fd on fd.faction_id=f.id where f.game_id=$GAME AND fd.code='$FACTION' and fd.turn=(select max(turn) from faction_data fx where fx.faction_id=f.id)" + OWNER=$(sqlite3 $ERESSEA/game-$GAME/eressea.db "$SQL") + echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ + | mutt -s "Reportnachforderung Partei ${FACTION}" $OWNER +fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 499b36409..81a43e002 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -157,6 +157,13 @@ set(SERVER_SRC bind_unit.c ) +if (SQLITE3_FOUND) +set (SERVER_SRC ${SERVER_SRC} + sqlite.c + bind_sqlite.c +) +endif (SQLITE3_FOUND) + if (CURSES_FOUND) set (SERVER_SRC ${SERVER_SRC} gmtool.c @@ -248,6 +255,11 @@ add_test(server test_eressea) install(TARGETS eressea DESTINATION "bin") +if (SQLITE3_FOUND) +target_link_libraries(eressea ${SQLITE3_LIBRARIES}) +add_definitions(-DUSE_SQLITE) +endif(SQLITE3_FOUND) + if (CURSES_FOUND) include_directories (${CURSES_INCLUDE_DIR}) target_link_libraries(eressea ${CURSES_LIBRARIES}) diff --git a/src/bind_sqlite.c b/src/bind_sqlite.c new file mode 100644 index 000000000..e8c9b7565 --- /dev/null +++ b/src/bind_sqlite.c @@ -0,0 +1,95 @@ +/* ++-------------------+ +| | Enno Rehling +| Eressea PBEM host | Christian Schlittchen +| (c) 1998 - 2008 | Katja Zedel +| | Henning Peters ++-------------------+ + +This program may not be used, modified or distributed +without prior permission by the authors of Eressea. +*/ + +#include + +#include "bind_unit.h" +#include "bindings.h" + +#include +#include +#include + +#define LTYPE_DB TOLUA_CAST "db" + +extern int db_update_factions(sqlite3 * db, bool force, int game); +static int tolua_db_update_factions(lua_State * L) +{ + sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); + db_update_factions(db, tolua_toboolean(L, 2, 0), game_id()); + return 0; +} + +extern int db_update_scores(sqlite3 * db, bool force); +static int tolua_db_update_scores(lua_State * L) +{ + sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); + db_update_scores(db, tolua_toboolean(L, 2, 0)); + return 0; +} + +static int tolua_db_execute(lua_State * L) +{ + sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); + const char *sql = tolua_tostring(L, 2, 0); + + int res = sqlite3_exec(db, sql, 0, 0, 0); + + lua_pushinteger(L, res); + return 1; +} + +static int tolua_db_close(lua_State * L) +{ + sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); + sqlite3_close(db); + return 0; +} + +static int tolua_db_create(lua_State * L) +{ + sqlite3 *db; + const char *dbname = tolua_tostring(L, 1, 0); + int result = sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READWRITE, 0); + if (result == SQLITE_OK) { + tolua_pushusertype(L, (void *)db, LTYPE_DB); + return 1; + } + return 0; +} + +int tolua_sqlite_open(lua_State * L) +{ + /* register user types */ + + tolua_usertype(L, LTYPE_DB); + + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); + { + tolua_cclass(L, LTYPE_DB, LTYPE_DB, TOLUA_CAST "", NULL); + tolua_beginmodule(L, LTYPE_DB); + { + tolua_function(L, TOLUA_CAST "open", &tolua_db_create); + tolua_function(L, TOLUA_CAST "close", &tolua_db_close); + + tolua_function(L, TOLUA_CAST "update_factions", + &tolua_db_update_factions); + tolua_function(L, TOLUA_CAST "update_scores", &tolua_db_update_scores); + tolua_function(L, TOLUA_CAST "execute", &tolua_db_execute); + } + tolua_endmodule(L); + + } + tolua_endmodule(L); + return 0; +} diff --git a/src/bindings.c b/src/bindings.c index b466ce35f..14eae1c56 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -1149,6 +1149,9 @@ lua_State *lua_init(const dictionary *inifile) { register_tolua_helpers(); tolua_bindings_open(L, inifile); tolua_eressea_open(L); +#ifdef USE_SQLITE + tolua_sqlite_open(L); +#endif tolua_unit_open(L); tolua_building_open(L); tolua_ship_open(L); diff --git a/src/bindings.h b/src/bindings.h index be60102a2..2db83248d 100755 --- a/src/bindings.h +++ b/src/bindings.h @@ -18,6 +18,7 @@ extern "C" { struct quicklist; struct _dictionary_; + int tolua_sqlite_open(struct lua_State *L); int tolua_bindings_open(struct lua_State *L, const struct _dictionary_ *d); int tolua_itemlist_next(struct lua_State *L); int tolua_orderlist_next(struct lua_State *L); diff --git a/src/sqlite.c b/src/sqlite.c new file mode 100644 index 000000000..aea0f5d20 --- /dev/null +++ b/src/sqlite.c @@ -0,0 +1,204 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +faction *get_faction_by_id(int uid) +{ + faction *f; + for (f = factions; f; f = f->next) { + if (f->subscription == uid) { + return f; + } + } + return NULL; +} + +/* +typedef struct stmt_cache { +sqlite3 *db; +sqlite3_stmt *stmt; +const char *sql; +int inuse; +} stmt_cache; + +#define MAX_STMT_CACHE 64 +static stmt_cache cache[MAX_STMT_CACHE]; +static int cache_insert; + +static sqlite3_stmt *stmt_cache_get(sqlite3 * db, const char *sql) +{ +int i; +sqlite3_stmt *stmt; + +for (i = 0; i != MAX_STMT_CACHE && cache[i].db; ++i) { +if (cache[i].sql == sql && cache[i].db == db) { +cache[i].inuse = 1; +stmt = cache[i].stmt; +sqlite3_reset(stmt); +sqlite3_clear_bindings(stmt); +return stmt; +} +} +if (i == MAX_STMT_CACHE) { +while (cache[cache_insert].inuse) { +cache[cache_insert].inuse = 0; +cache_insert = (cache_insert + 1) & (MAX_STMT_CACHE - 1); +} +i = cache_insert; +stmt = cache[i].stmt; +sqlite3_finalize(stmt); +} +cache[i].inuse = 1; +cache[i].db = db; +cache[i].sql = sql; +sqlite3_prepare_v2(db, sql, -1, &cache[i].stmt, NULL); +return cache[i].stmt; +} +*/ +typedef struct db_faction { + int uid; + int no; + char *email; + char *name; +} db_faction; + +static struct quicklist * +read_factions(sqlite3 * db, int game_id) { + int res; + quicklist *result = 0; + const char * sql = + "SELECT f.id, fd.code, fd.name, fd.email FROM faction f" + " LEFT OUTER JOIN faction_data fd" + " WHERE f.id=fd.faction_id AND f.game_id=? AND" + " fd.turn=(SELECT MAX(turn) FROM faction_data fx WHERE fx.faction_id=f.id)" + " ORDER BY f.id"; + sqlite3_stmt *stmt = 0; + sqlite3_prepare_v2(db, sql, -1, &stmt, 0); + sqlite3_bind_int(stmt, 1, game_id); + + res = sqlite3_step(stmt); + while (res == SQLITE_ROW) { + const char * text; + db_faction * dbf = (db_faction*)calloc(1, sizeof(db_faction)); + dbf->uid = (int)sqlite3_column_int64(stmt, 0); + text = (const char *)sqlite3_column_text(stmt, 1); + if (text) dbf->no = atoi36(text); + text = (const char *)sqlite3_column_text(stmt, 2); + if (text) dbf->name = strdup(text); + text = (const char *)sqlite3_column_text(stmt, 3); + if (text) dbf->email = strdup(text); + ql_push(&result, dbf); + res = sqlite3_step(stmt); + } + sqlite3_finalize(stmt); + return result; +} + +static int insert_faction(sqlite3 *db, int game_id, faction *f) { + const char *sql = "INSERT INTO faction (game_id, race) VALUES (?, ?)"; + sqlite3_stmt *stmt = 0; + sqlite3_prepare_v2(db, sql, -1, &stmt, 0); + sqlite3_bind_int(stmt, 1, game_id); + sqlite3_bind_text(stmt, 2, f->race->_name, -1, SQLITE_STATIC); + sqlite3_step(stmt); + sqlite3_finalize(stmt); + return (int)sqlite3_last_insert_rowid(db); +} + +static void update_faction(sqlite3 *db, const faction *f) { + char code[5]; + const char *sql = + "INSERT INTO faction_data (faction_id, code, name, email, lang, turn)" + " VALUES (?, ?, ?, ?, ?, ?)"; + sqlite3_stmt *stmt = 0; + strcpy(code, itoa36(f->no)); + sqlite3_prepare_v2(db, sql, -1, &stmt, 0); + sqlite3_bind_int(stmt, 1, f->subscription); + sqlite3_bind_text(stmt, 2, code, -1, SQLITE_STATIC); + sqlite3_bind_text(stmt, 3, f->name, -1, SQLITE_STATIC); + sqlite3_bind_text(stmt, 4, f->email, -1, SQLITE_STATIC); + sqlite3_bind_text(stmt, 5, locale_name(f->locale), -1, SQLITE_STATIC); + sqlite3_bind_int(stmt, 6, turn); + sqlite3_step(stmt); + sqlite3_finalize(stmt); +} + +int db_update_factions(sqlite3 * db, bool force, int game_id) { + quicklist *ql = read_factions(db, game_id); + faction *f; + sqlite3_exec(db, "BEGIN", 0, 0, 0); + for (f = factions; f; f = f->next) { + bool update = force; + db_faction *dbf = 0; + ql_iter it = qli_init(&ql); + while (qli_more(it)) { + db_faction *df = (db_faction*)qli_next(&it); + if (f->no == df->no || strcmp(f->email, df->email) == 0 || strcmp(f->name, df->name) == 0) { + dbf = df; + } + if (f->subscription == df->uid) { + dbf = df; + break; + } + } + if (dbf) { + if (dbf->uid != f->subscription) { + log_warning("faction %s(%d) not found in database, but matches %d\n", itoa36(f->no), f->subscription, dbf->uid); + f->subscription = dbf->uid; + } + update = (dbf->no != f->no) || (strcmp(f->email, dbf->email) != 0) || (strcmp(f->name, dbf->name) != 0); + } + else { + f->subscription = insert_faction(db, game_id, f); + log_warning("faction %s not found in database, created as %d\n", itoa36(f->no), f->subscription); + update = true; + } + if (update) { + update_faction(db, f); + log_debug("faction %s updated\n", itoa36(f->no)); + } + } + sqlite3_exec(db, "COMMIT", 0, 0, 0); + return SQLITE_OK; +} + +int db_update_scores(sqlite3 * db, bool force) +{ + /* + const char *sql_ins = + "INSERT OR FAIL INTO score (value,faction_id,turn) VALUES (?,?,?)"; + sqlite3_stmt *stmt_ins = stmt_cache_get(db, sql_ins); + const char *sql_upd = + "UPDATE score set value=? WHERE faction_id=? AND turn=?"; + sqlite3_stmt *stmt_upd = stmt_cache_get(db, sql_upd); + faction *f; + sqlite3_exec(db, "BEGIN", 0, 0, 0); + for (f = factions; f; f = f->next) { + int res; + sqlite3_bind_int(stmt_ins, 1, f->score); + sqlite3_bind_int64(stmt_ins, 2, f->subscription); + sqlite3_bind_int(stmt_ins, 3, turn); + res = sqlite3_step(stmt_ins); + if (res == SQLITE_CONSTRAINT) { + sqlite3_bind_int(stmt_upd, 1, f->score); + sqlite3_bind_int64(stmt_upd, 2, f->subscription); + sqlite3_bind_int(stmt_upd, 3, turn); + res = sqlite3_step(stmt_upd); + sqlite3_reset(stmt_upd); + } + sqlite3_reset(stmt_ins); + } + sqlite3_exec(db, "COMMIT", 0, 0, 0); + */ + return SQLITE_OK; +} From 2c38883362690c333f88238cc2da9d0eabfae82a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 13:09:32 +0100 Subject: [PATCH 348/675] configure dbname in eressea.ini (or don't use DB if not --- scripts/run-turn.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/run-turn.lua b/scripts/run-turn.lua index 7ee9165ca..92efa8a14 100644 --- a/scripts/run-turn.lua +++ b/scripts/run-turn.lua @@ -26,15 +26,17 @@ function callbacks(rules, name, ...) end local function dbupdate() - update_scores() - dbname = config.dbname or 'eressea.db' - edb = db.open(config.basepath..'/'..dbname) - if edb~=nil then - edb:update_factions() - edb:update_scores() - else - eressea.log.error("could not open "..config.basepath..'/'..dbname) - end + update_scores() + if config.dbname then + dbname = config.basepath..'/'..config.dbname + edb = db.open(dbame) + if edb~=nil then + edb:update_factions() + edb:update_scores() + else + eressea.log.error("could not open "..dbname) + end + end end local function write_emails(locales) From 9e9cd6ae79faf2f0b388b55273b5d2ca942562ff Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 18:01:09 +0100 Subject: [PATCH 349/675] try loading config.lua and custom.lua files, if they exist. --- src/bindings.c | 68 ++++++++++++++++++++++++++++++++--------------- src/kernel/save.h | 1 - 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index 14eae1c56..cce07c33e 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -1168,32 +1168,56 @@ lua_State *lua_init(const dictionary *inifile) { return L; } +static int run_script(lua_State *L, const char *luafile) { + int err; + FILE *F; + + F = fopen(luafile, "r"); + if (!F) { + log_debug("dofile('%s'): %s", luafile, strerror(errno)); + return errno; + } + fclose(F); + + log_debug("executing script %s", luafile); + lua_getglobal(L, "dofile"); + lua_pushstring(L, luafile); + err = lua_pcall(L, 1, 1, -3); /* error handler (debug.traceback) is now at stack -3 */ + if (err != 0) { + log_lua_error(L); + assert(!"Lua syntax error? check log."); + } + else { + if (lua_isnumber(L, -1)) { + err = (int)lua_tonumber(L, -1); + } + lua_pop(L, 1); + } + return err; +} + int eressea_run(lua_State *L, const char *luafile) { - int err = 0; - + int err; global.vm_state = L; + + /* push an error handling function on the stack: */ + lua_getglobal(L, "debug"); + lua_getfield(L, -1, "traceback"); + lua_remove(L, -2); + + /* try to run configuration scripts: */ + err = run_script(L, "config.lua"); + err = run_script(L, "custom.lua"); + /* run the main script */ if (luafile) { - log_debug("executing script %s\n", luafile); - - lua_getglobal(L, "debug"); - lua_getfield(L, -1, "traceback"); - lua_remove(L, -2); - lua_getglobal(L, "dofile"); - lua_pushstring(L, luafile); - err = lua_pcall(L, 1, 1, -3); - if (err != 0) { - log_lua_error(L); - assert(!"Lua syntax error? check log."); - } - else { - if (lua_isnumber(L, -1)) { - err = (int)lua_tonumber(L, -1); - } - lua_pop(L, 1); - } - return err; + err = run_script(L, luafile); } - return lua_console(L); + else { + err = lua_console(L); + } + /* pop error handler off the stack: */ + lua_pop(L, 1); + return err; } diff --git a/src/kernel/save.h b/src/kernel/save.h index be78b9c68..4ead34efe 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -44,7 +44,6 @@ extern "C" { extern int enc_gamedata; int readorders(const char *filename); - int creategame(void); int readgame(const char *filename); int writegame(const char *filename); From 09d4316568c5aa720d654bbc7013d637f3482256 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 18:03:46 +0100 Subject: [PATCH 350/675] missing includE --- src/bindings.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bindings.c b/src/bindings.c index cce07c33e..aae564478 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -80,6 +80,7 @@ without prior permission by the authors of Eressea. #include #include +#include #include #define TOLUA_PKG(NAME) extern void tolua_##NAME##_open(lua_State * L) From 0270b3fb8a16d08d4b00b002d0a11aa402d7e5fb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 18:28:04 +0100 Subject: [PATCH 351/675] rename create_equipment function --- src/bindings.c | 6 +++--- src/kernel/equipment.c | 2 +- src/kernel/equipment.h | 2 +- src/kernel/equipment.test.c | 2 +- src/kernel/xmlreader.c | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index aae564478..fad958cd4 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -83,7 +83,7 @@ without prior permission by the authors of Eressea. #include #include -#define TOLUA_PKG(NAME) extern void tolua_##NAME##_open(lua_State * L) +#define TOLUA_PKG(NAME) void tolua_##NAME##_open(lua_State * L) TOLUA_PKG(eressea); TOLUA_PKG(process); @@ -328,7 +328,7 @@ static int tolua_addequipment(lua_State * L) if (iname != NULL) { const struct item_type *itype = it_find(iname); if (itype != NULL) { - equipment_setitem(create_equipment(eqname), itype, value); + equipment_setitem(get_or_create_equipment(eqname), itype, value); result = 0; } } @@ -461,7 +461,7 @@ static int tolua_equipment_setitem(lua_State * L) if (iname != NULL) { const struct item_type *itype = it_find(iname); if (itype != NULL) { - equipment_setitem(create_equipment(eqname), itype, value); + equipment_setitem(get_or_create_equipment(eqname), itype, value); result = 0; } } diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index 1587e7531..7874a2c32 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -39,7 +39,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static equipment *equipment_sets; -equipment *create_equipment(const char *eqname) +equipment *get_or_create_equipment(const char *eqname) { equipment **eqp = &equipment_sets; for (;;) { diff --git a/src/kernel/equipment.h b/src/kernel/equipment.h index 5c7b3407b..84fe55722 100644 --- a/src/kernel/equipment.h +++ b/src/kernel/equipment.h @@ -56,7 +56,7 @@ extern "C" { void equipment_done(void); - struct equipment *create_equipment(const char *eqname); + struct equipment *get_or_create_equipment(const char *eqname); struct equipment *get_equipment(const char *eqname); void equipment_setitem(struct equipment *eq, diff --git a/src/kernel/equipment.test.c b/src/kernel/equipment.test.c index 2911af1ea..ad69bec10 100644 --- a/src/kernel/equipment.test.c +++ b/src/kernel/equipment.test.c @@ -29,7 +29,7 @@ void test_equipment(CuTest * tc) CuAssertPtrNotNull(tc, sp); CuAssertPtrEquals(tc, 0, get_equipment("herpderp")); - eq = create_equipment("herpderp"); + eq = get_or_create_equipment("herpderp"); CuAssertPtrEquals(tc, eq, get_equipment("herpderp")); equipment_setitem(eq, it_horses, "1"); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 2ba9d785a..cba01bc7b 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1266,7 +1266,7 @@ add_subsets(xmlDocPtr doc, equipment * eq, xmlNodeSetPtr nsetSubsets) assert(propValue != NULL); eq->subsets[i].sets[set].chance = chance; eq->subsets[i].sets[set].set = - create_equipment((const char *)propValue); + get_or_create_equipment((const char *)propValue); xmlFree(propValue); } } @@ -1296,7 +1296,7 @@ static int parse_equipment(xmlDocPtr doc) xmlChar *propName = xmlGetProp(node, BAD_CAST "name"); if (propName != NULL) { - equipment *eq = create_equipment((const char *)propName); + equipment *eq = get_or_create_equipment((const char *)propName); xmlXPathObjectPtr xpathResult; xpath->node = node; From 4cbeb03590a87cb86275c08bd69eb11fe33ec9c1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 18:35:54 +0100 Subject: [PATCH 352/675] clean the quipment interface for lua a little bit. --- conf/e2/config.xml | 2 +- src/bindings.c | 18 ------------------ src/kernel/faction.c | 6 ++++++ 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 5affea141..8389ba470 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -29,7 +29,7 @@ - + diff --git a/src/bindings.c b/src/bindings.c index fad958cd4..b6be1ccba 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -319,23 +319,6 @@ static int tolua_dice_rand(lua_State * L) return 1; } -static int tolua_addequipment(lua_State * L) -{ - const char *eqname = tolua_tostring(L, 1, 0); - const char *iname = tolua_tostring(L, 2, 0); - const char *value = tolua_tostring(L, 3, 0); - int result = -1; - if (iname != NULL) { - const struct item_type *itype = it_find(iname); - if (itype != NULL) { - equipment_setitem(get_or_create_equipment(eqname), itype, value); - result = 0; - } - } - lua_pushinteger(L, result); - return 1; -} - static int tolua_get_season(lua_State * L) { int turnno = (int)tolua_tonumber(L, 1, 0); @@ -1112,7 +1095,6 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile) tolua_function(L, TOLUA_CAST "get_season", tolua_get_season); tolua_function(L, TOLUA_CAST "equipment_setitem", tolua_equipment_setitem); tolua_function(L, TOLUA_CAST "equip_unit", tolua_equipunit); - tolua_function(L, TOLUA_CAST "add_equipment", tolua_addequipment); tolua_function(L, TOLUA_CAST "atoi36", tolua_atoi36); tolua_function(L, TOLUA_CAST "itoa36", tolua_itoa36); tolua_function(L, TOLUA_CAST "dice_roll", tolua_dice_rand); diff --git a/src/kernel/faction.c b/src/kernel/faction.c index e884a2d9b..d67619752 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "alliance.h" #include "ally.h" #include "curse.h" +#include "equipment.h" #include "group.h" #include "item.h" #include "messages.h" @@ -286,10 +287,15 @@ faction *addfaction(const char *email, const char *password, unit *addplayer(region * r, faction * f) { unit *u; + const struct equipment* eq; assert(f->units == NULL); faction_setorigin(f, 0, r->x, r->y); u = create_unit(r, f, 1, f->race, 0, NULL, NULL); + eq = get_equipment("first_unit"); + if (eq) { + equip_items(&u->items, eq); + } u->hp = unit_max_hp(u) * u->number; fset(u, UFL_ISNEW); if (f->race == get_race(RC_DAEMON)) { From f09259f2b3a7d057ec0d742661d8e4cad83cbf45 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 18:51:20 +0100 Subject: [PATCH 353/675] eliminate duplicate password message --- scripts/tests/faction.lua | 2 +- src/kernel/faction.c | 11 +++++------ src/kernel/faction.test.c | 2 +- src/reports.test.c | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/tests/faction.lua b/scripts/tests/faction.lua index 38fdc4eb7..87a6b5100 100644 --- a/scripts/tests/faction.lua +++ b/scripts/tests/faction.lua @@ -17,7 +17,7 @@ function setup() end function test_faction_flags() - assert_equal(2, f.flags) -- FFL_ISNEW + assert_equal(6, f.flags) -- FFL_ISNEW|FFL_PWMSG f.flags = 42 assert_equal(42, f.flags) end diff --git a/src/kernel/faction.c b/src/kernel/faction.c index d67619752..6b601f002 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -247,11 +247,6 @@ faction *addfaction(const char *email, const char *password, log_warning("Invalid email address for faction %s: %s\n", itoa36(f->no), email); } - if (!password) password = itoa36(rng_int()); - faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT)); - ADDMSG(&f->msgs, msg_message("changepasswd", "value", password)); - f->flags |= FFL_PWMSG; - f->alliance_joindate = turn; f->lastorders = turn; f->_alive = true; @@ -260,7 +255,11 @@ faction *addfaction(const char *email, const char *password, f->magiegebiet = 0; f->locale = loc; f->subscription = subscription; - f->flags = FFL_ISNEW; + f->flags = FFL_ISNEW|FFL_PWMSG; + + if (!password) password = itoa36(rng_int()); + faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT)); + ADDMSG(&f->msgs, msg_message("changepasswd", "value", password)); f->options = want(O_REPORT) | want(O_ZUGVORLAGE) | want(O_COMPUTER) | want(O_COMPRESS) | diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 3d81b5d3c..441ca5038 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -117,7 +117,7 @@ static void test_addfaction(CuTest *tc) { CuAssertTrue(tc, checkpasswd(f, "hurrdurr")); CuAssertPtrEquals(tc, (void *)lang, (void *)f->locale); CuAssertIntEquals(tc, 1234, f->subscription); - CuAssertIntEquals(tc, FFL_ISNEW, f->flags); + CuAssertIntEquals(tc, FFL_ISNEW|FFL_PWMSG, f->flags); CuAssertIntEquals(tc, 0, f->age); CuAssertTrue(tc, faction_alive(f)); CuAssertIntEquals(tc, M_GRAY, f->magiegebiet); diff --git a/src/reports.test.c b/src/reports.test.c index 389d9c130..728145758 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -232,7 +232,7 @@ static void test_newbie_password_message(CuTest *tc) { test_setup(); f = test_create_faction(0); f->age = 5; - CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG); + f->flags = 0; prepare_report(&ctx, f); CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG); CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "changepasswd")); From aa66e5d39f3f78f73a7e84ef961e2f65029172b3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 19:06:37 +0100 Subject: [PATCH 354/675] remove unused equipment sets (from an unrealized feature). --- res/e3a/equipment.xml | 69 ------------------------------------------- 1 file changed, 69 deletions(-) diff --git a/res/e3a/equipment.xml b/res/e3a/equipment.xml index bbd2ac5b7..9fe133f48 100644 --- a/res/e3a/equipment.xml +++ b/res/e3a/equipment.xml @@ -1,78 +1,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 94fcef2fac2146cb19b30a4fdd8bbc73d3be8d05 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 19:32:03 +0100 Subject: [PATCH 355/675] the locales module is deprecated. let's do this in custom.lua from now on. --- scripts/eressea/e2/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/eressea/e2/init.lua b/scripts/eressea/e2/init.lua index ed996c395..722078741 100644 --- a/scripts/eressea/e2/init.lua +++ b/scripts/eressea/e2/init.lua @@ -11,7 +11,7 @@ return { require('eressea.tunnels'), require('eressea.ponnuki'), require('eressea.astral'), - require('eressea.locales'), +-- require('eressea.locales'), require('eressea.jsreport'), require('eressea.ents'), require('eressea.cursed') From 9ccaab6516cbec55f6bff76fcce2be586994ff5d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 20:19:32 +0100 Subject: [PATCH 356/675] Korrekte Email-Subject und Adresse, auch im NR. Eliminate crufty per-game strings. --- conf/e2/config.xml | 12 ------------ conf/e3/config.xml | 12 ------------ conf/e4/config.xml | 12 ------------ res/core/de/strings.xml | 6 ++++++ res/core/messages.xml | 10 ++++++++++ src/creport.c | 4 +--- src/kernel/config.c | 17 +++++++++++++++-- src/kernel/config.h | 1 + src/kernel/config.test.c | 2 ++ src/report.c | 17 +++++++++++------ src/reports.c | 7 +++++++ src/reports.h | 1 + 12 files changed, 54 insertions(+), 47 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 8389ba470..56c622d04 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -52,16 +52,4 @@ - - - Bitte denke daran, deine Befehle mit dem Betreff - ERESSEA 2 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. - Remember to send your orders to - eressea-server@eressea.kn-bremen.de with the subject ERESSEA 2 ORDERS. - - - ERESSEA 2 BEFEHLE - ERESSEA 2 ORDERS - - diff --git a/conf/e3/config.xml b/conf/e3/config.xml index 35716f332..ac05d5a5a 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -36,16 +36,4 @@ - - - Bitte denke daran, deine Befehle mit dem Betreff - ERESSEA 3 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. - Remember to send your orders to - eressea-server@eressea.kn-bremen.de with the subject E3 ORDERS. - - - ERESSEA 3 BEFEHLE - ERESSEA 3 ORDERS - - diff --git a/conf/e4/config.xml b/conf/e4/config.xml index ac962202c..f9ede1a27 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -36,16 +36,4 @@ - - - Bitte denke daran, deine Befehle mit dem Betreff - ERESSEA 4 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. - Remember to send your orders to - eressea-server@eressea.kn-bremen.de with the subject ERESSEA 4 ORDERS. - - - ERESSEA 4 BEFEHLE - ERESSEA 4 ORDERS - - diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index b23d44ffb..7d31fc678 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -6,6 +6,12 @@ _x: preposition (15 /Schlumpf/schwerter) _a: including article (ein Schlumpf, a smurf) --> + + + BEFEHLE + ORDERS + + Wirbel vortex diff --git a/res/core/messages.xml b/res/core/messages.xml index 130b58d03..6892ec4e5 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -1,5 +1,15 @@ + + + + + + Bitte denke daran, deine Befehle mit dem Betreff + $subject an $email zu senden. + Remember to send your orders to + $email with the subject ${subject}. + diff --git a/src/creport.c b/src/creport.c index 34cff9de3..e8e401190 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1510,9 +1510,7 @@ report_computer(const char *filename, report_context * ctx, const char *bom) fprintf(F, "%d;Zeitalter\n", era); fprintf(F, "\"%s\";Build\n", eressea_version()); if (mailto != NULL) { - // char mailcmd[64]; - // snprintf(mailcmd, sizeof(mailcmd), "%s %d, %s", game_name(), game_id(), LOC(f->locale, "mailcmd")); - const char * mailcmd = LOC(f->locale, "mailcmd"); + const char * mailcmd = get_mailcmd(f->locale); fprintf(F, "\"%s\";mailto\n", mailto); fprintf(F, "\"%s\";mailcmd\n", mailcmd); } diff --git a/src/kernel/config.c b/src/kernel/config.c index 88130056b..80a78df36 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -803,12 +803,25 @@ void free_gamedata(void) } } -const char * game_name(void) { +const char * game_name(void) +{ const char * param = config_get("game.name"); return param ? param : global.gamename; } +const char * game_name_upper(void) +{ + static char result[32]; // FIXME: static result + char *r = result; + const char *param = game_name(); + const char *c = param; + while (*c && (r-result)age <= 2) { - const char *s; - s = locale_getstring(f->locale, "newbie_info_game"); - if (s) { - newline(out); - centre(out, s, true); + const char *email; + const char *subject; + email = config_get("game.email"); + subject = get_mailcmd(f->locale); + m = msg_message("newbie_info_game", "email subject", email, subject); + if (m) { + nr_render(m, f->locale, buf, sizeof(buf), f); + msg_release(m); + centre(out, buf, true); } if ((f->options & want(O_COMPUTER)) == 0) { - f->options |= want(O_COMPUTER); + const char *s; s = locale_getstring(f->locale, "newbie_info_cr"); if (s) { newline(out); centre(out, s, true); } + f->options |= want(O_COMPUTER); } } newline(out); diff --git a/src/reports.c b/src/reports.c index 0da8aed94..c6df944a3 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1945,6 +1945,13 @@ static void eval_regions(struct opstack **stack, const void *userdata) opush(stack, var); } +const char *get_mailcmd(const struct locale *loc) +{ + static char result[64]; // FIXME: static return buffer + snprintf(result, sizeof(result), "%s %d %s", game_name_upper(), game_id(), LOC(loc, "mailcmd")); + return result; +} + static void eval_trail(struct opstack **stack, const void *userdata) { /* order -> string */ const faction *report = (const faction *)userdata; diff --git a/src/reports.h b/src/reports.h index 99dd7ebf6..cc197bed4 100644 --- a/src/reports.h +++ b/src/reports.h @@ -129,6 +129,7 @@ extern "C" { int stream_printf(struct stream * out, const char *format, ...); int count_travelthru(struct region *r, const struct faction *f); + const char *get_mailcmd(const struct locale *loc); #define GR_PLURAL 0x01 /* grammar: plural */ #define MAX_INVENTORY 128 /* maimum number of different items in an inventory */ From 30665f874a23f2c02b89096d27a3a58e21061839 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 20:32:54 +0100 Subject: [PATCH 357/675] fix game_name, remove it from rules --- conf/e2/config.json | 2 -- conf/e3/config.json | 2 -- conf/e4/config.json | 2 -- res/core/de/strings.xml | 2 -- src/kernel/config.c | 2 +- 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index ce823a33d..ca157f501 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -8,8 +8,6 @@ "jsreport" ], "settings": { - "game.id": 2, - "game.name": "Eressea", "orders.default": "work", "NewbieImmunity": 8, "modules.wormholes": true, diff --git a/conf/e3/config.json b/conf/e3/config.json index 30bc7e599..fd533070e 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -25,8 +25,6 @@ "jsreport" ], "settings": { - "game.id": 3, - "game.name": "E3", "orders.default": "work", "database.gameid": 7, "NewbieImmunity": 4, diff --git a/conf/e4/config.json b/conf/e4/config.json index cbe273af6..91961258a 100644 --- a/conf/e4/config.json +++ b/conf/e4/config.json @@ -25,8 +25,6 @@ "jsreport" ], "settings": { - "game.id": 4, - "game.name": "Deveron", "orders.default": "work", "database.gameid": 7, "NewbieImmunity": 4, diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 7d31fc678..bccfdd165 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -6,12 +6,10 @@ _x: preposition (15 /Schlumpf/schwerter) _a: including article (ein Schlumpf, a smurf) --> - BEFEHLE ORDERS - Wirbel vortex diff --git a/src/kernel/config.c b/src/kernel/config.c index 80a78df36..403c80050 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -815,7 +815,7 @@ const char * game_name_upper(void) char *r = result; const char *param = game_name(); const char *c = param; - while (*c && (r-result)r) { *r++ = (char)toupper(*c++); } *r = '\0'; From 3a07d43321c12958d4d4a73cbfe11de3054aa18f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 21:02:15 +0100 Subject: [PATCH 358/675] specify a game id, because there is one in the data --- tests/eressea.ini | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/eressea.ini b/tests/eressea.ini index e84171d45..faf4b1b9e 100644 --- a/tests/eressea.ini +++ b/tests/eressea.ini @@ -1,10 +1,8 @@ -[eressea] -base = . -report = reports +[game] +name = Eressea +id = 2 +email = eressea-server@kn-bremen.de verbose = 0 -lomem = 0 -debug = 0 -memcheck = 0 locales = de,en [lua] From 23d1355fa1f871a2e23f1272c0f97e43a65e41de Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Jan 2017 09:22:29 +0100 Subject: [PATCH 359/675] FACTION and PARTEI should both start orders. --- src/kernel/save.c | 24 ++++++++++++++++++++++-- tests/orders.184 | 5 +++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 5b5a5898f..402ffac8d 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -252,6 +252,26 @@ static faction *factionorders(void) return f; } +static param_t next_param(const char *s, const struct locale *lang) { + param_t p; + if (!s || s[0] == '@') { + return NOPARAM; + } + p = findparam(s, lang); + if (p==NOPARAM) { + const struct locale *loc; + for (loc=locales;loc;loc=nextlocale(loc)) { + if (loc!=lang) { + p = findparam(s, lang); + if (p==P_FACTION || p==P_GAMENAME) { + break; + } + } + } + } + return p; +} + int readorders(const char *filename) { FILE *F = NULL; @@ -279,7 +299,7 @@ int readorders(const char *filename) const char *s; init_tokens_str(b); s = gettoken(token, sizeof(token)); - p = (s && s[0] != '@') ? findparam(s, lang) : NOPARAM; + p = next_param(s, lang); switch (p) { case P_GAMENAME: case P_FACTION: @@ -308,7 +328,7 @@ int readorders(const char *filename) p = (s && s[0] != '@') ? findparam(s, lang) : NOPARAM; } while ((p != P_UNIT || !f) && p != P_FACTION && p != P_NEXT && p != P_GAMENAME); - } + } break; /* Falls in unitorders() abgebrochen wird, steht dort entweder eine neue diff --git a/tests/orders.184 b/tests/orders.184 index 980993481..315c180d5 100644 --- a/tests/orders.184 +++ b/tests/orders.184 @@ -1,4 +1,4 @@ -ERESSEA 6rLo "6rLo" +PARTEI 6rLo "6rLo" EINHEIT 7Lgf NACH NW NW NAECHSTER @@ -6,7 +6,8 @@ ERESSEA w86y "w86y" EINHEIT uc3u STIRB "mrqa" NAECHSTER -ERESSEA ngij "ngij" + +FACTION ngij "ngij" EINHEIT iwbz HELFE w86y ALLES EINHEIT j536 From e19f0ad381def077d6550c2c3f68e14061f102cd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Jan 2017 10:47:49 +0100 Subject: [PATCH 360/675] issue #633: parse FACTION/PARTEI in any language. added a test since the first fix did not work. --- src/kernel/config.c | 21 +++++++++++++++++++++ src/kernel/config.h | 1 + src/kernel/config.test.c | 24 ++++++++++++++++++++++++ src/kernel/save.c | 22 +--------------------- src/util/language.c | 7 ++++--- 5 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index 403c80050..acf762638 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -214,6 +214,27 @@ param_t findparam(const char *s, const struct locale * lang) return result; } +param_t findparam_block(const char *s, const struct locale *lang, bool any_locale) +{ + param_t p; + if (!s || s[0] == '@') { + return NOPARAM; + } + p = findparam(s, lang); + if (any_locale && p==NOPARAM) { + const struct locale *loc; + for (loc=locales;loc;loc=nextlocale(loc)) { + if (loc!=lang) { + p = findparam(s, loc); + if (p==P_FACTION || p==P_GAMENAME) { + break; + } + } + } + } + return p; +} + param_t findparam_ex(const char *s, const struct locale * lang) { param_t result = findparam(s, lang); diff --git a/src/kernel/config.h b/src/kernel/config.h index 43189400c..b51ba2725 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -45,6 +45,7 @@ extern "C" { int findoption(const char *s, const struct locale *lang); param_t findparam(const char *s, const struct locale *lang); + param_t findparam_block(const char *s, const struct locale *lang, bool any_locale); param_t findparam_ex(const char *s, const struct locale * lang); bool isparam(const char *s, const struct locale * lang, param_t param); param_t getparam(const struct locale *lang); diff --git a/src/kernel/config.test.c b/src/kernel/config.test.c index ca362d6a1..72b2387ac 100644 --- a/src/kernel/config.test.c +++ b/src/kernel/config.test.c @@ -251,9 +251,33 @@ static void test_config_inifile(CuTest *tc) { test_cleanup(); } +static void test_findparam(CuTest *tc) { + struct locale *en, *de; + test_setup(); + en = get_or_create_locale("en"); + locale_setstring(en, parameters[P_FACTION], "FACTION"); + CuAssertIntEquals(tc, NOPARAM, findparam("FACTION", en)); + init_parameters(en); + CuAssertIntEquals(tc, P_FACTION, findparam("FACTION", en)); + de = get_or_create_locale("de"); + locale_setstring(de, parameters[P_FACTION], "PARTEI"); + CuAssertIntEquals(tc, NOPARAM, findparam("PARTEI", de)); + init_parameters(de); + CuAssertIntEquals(tc, P_FACTION, findparam("PARTEI", de)); + CuAssertIntEquals(tc, NOPARAM, findparam("HODOR", de)); + + CuAssertIntEquals(tc, NOPARAM, findparam("PARTEI", en)); + CuAssertIntEquals(tc, NOPARAM, findparam_block("HODOR", de, false)); + CuAssertIntEquals(tc, P_FACTION, findparam_block("PARTEI", de, true)); + CuAssertIntEquals(tc, NOPARAM, findparam_block("PARTEI", en, false)); + CuAssertIntEquals(tc, P_FACTION, findparam_block("PARTEI", en, true)); + test_cleanup(); +} + CuSuite *get_config_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_findparam); SUITE_ADD_TEST(suite, test_config_inifile); SUITE_ADD_TEST(suite, test_config_cache); SUITE_ADD_TEST(suite, test_get_set_param); diff --git a/src/kernel/save.c b/src/kernel/save.c index 402ffac8d..66c680476 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -252,26 +252,6 @@ static faction *factionorders(void) return f; } -static param_t next_param(const char *s, const struct locale *lang) { - param_t p; - if (!s || s[0] == '@') { - return NOPARAM; - } - p = findparam(s, lang); - if (p==NOPARAM) { - const struct locale *loc; - for (loc=locales;loc;loc=nextlocale(loc)) { - if (loc!=lang) { - p = findparam(s, lang); - if (p==P_FACTION || p==P_GAMENAME) { - break; - } - } - } - } - return p; -} - int readorders(const char *filename) { FILE *F = NULL; @@ -299,7 +279,7 @@ int readorders(const char *filename) const char *s; init_tokens_str(b); s = gettoken(token, sizeof(token)); - p = next_param(s, lang); + p = findparam_block(s, lang, true); switch (p) { case P_GAMENAME: case P_FACTION: diff --git a/src/util/language.c b/src/util/language.c index efd5cd5f7..300e69103 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -295,10 +295,11 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_ // TODO: swap the name of s and key const char * s = string_cb(i); if (s) { - struct critbit_tree ** cb = (struct critbit_tree **)tokens; const char * key = locale_string(lang, s, false); - if (!key) key = s; - add_translation(cb, key, i); + if (key) { + struct critbit_tree ** cb = (struct critbit_tree **)tokens; + add_translation(cb, key, i); + } } } } From 646e6f7197477787337cccb00165cc962cbfdc27 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Jan 2017 11:13:01 +0100 Subject: [PATCH 361/675] refactor and annotate volcano outbreaks. add configuration options to control volcano behavior. --- src/volcano.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/volcano.c b/src/volcano.c index 60beeaed7..a9a4f0ba7 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -55,7 +55,7 @@ static int nb_armor(const unit * u, int index) if (!(u_race(u)->battle_flags & BF_EQUIPMENT)) return 0; - /* Normale Rstung */ + /* Normale R�stung */ for (itm = u->items; itm; itm = itm->next) { const armor_type *atype = itm->type->rtype->atype; @@ -169,11 +169,11 @@ static region *rrandneighbour(region * r) for (i = 0; i != MAXDIRECTIONS; i++) { c++; } - /* Zufllig eine auswhlen */ + /* Zuf�llig eine ausw�hlen */ rr = rng_int() % c; - /* Durchzhlen */ + /* Durchz�hlen */ c = -1; for (i = 0; i != MAXDIRECTIONS; i++) { @@ -204,7 +204,7 @@ volcano_destruction(region * volcano, region * r, const char *damage) else { /* Produktion vierteln ... */ a->data.sa[0] = (short)percent; - /* Fr 6-17 Runden */ + /* F�r 6-17 Runden */ a->data.sa[1] = (short)(a->data.sa[1] + time); } @@ -255,6 +255,14 @@ void volcano_outbreak(region * r, region *rn) } } +static bool stop_smoke_chance(void) { + return rng_int() % 100 < 12; +} + +static bool outbreak_chance(void) { + return rng_int() % 100 < 8; +} + void volcano_update(void) { region *r; @@ -270,13 +278,16 @@ void volcano_update(void) r->terrain = t_volcano; } else { - if (rng_int() % 100 < 12) { + if (stop_smoke_chance()) { ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r)); r->terrain = t_volcano; } - else if (r->uid == 1246051340 || (r->age > 20 && rng_int() % 100 < 8)) { + else if (r->uid == 1246051340 || outbreak_chance()) { + // HACK: a fixed E4-only region-uid in Code. + // FIXME: In E4 gibt es eine Ebene #1246051340, die Smalland heisst. + // da das kein aktiver Vulkan ist, ist dieser Test da nicht idiotisch? + // das sollte bestimmt rn betreffen? region *rn; - /* Zufllige Nachbarregion verwsten */ rn = rrandneighbour(r); volcano_outbreak(r, rn); r->terrain = t_volcano; From 6d9d920f81ed39f7a37cfef560782f48b8ea1252 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Jan 2017 11:44:34 +0100 Subject: [PATCH 362/675] fix issue #477 (intermittent volcano) --- scripts/tests/xmas.lua | 2 ++ src/volcano.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/tests/xmas.lua b/scripts/tests/xmas.lua index 7ac4ce731..5477e08ab 100644 --- a/scripts/tests/xmas.lua +++ b/scripts/tests/xmas.lua @@ -8,6 +8,8 @@ function setup() eressea.settings.set("rules.grow.formula", "0") eressea.settings.set("rules.peasants.growth.factor", "0") eressea.settings.set("volcano.active.percent", "0") + eressea.settings.set("volcano.outbreak.percent", "0") + eressea.settings.set("volcano.stop.percent", "0") end function test_snowglobe_fail() diff --git a/src/volcano.c b/src/volcano.c index a9a4f0ba7..89a865017 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -256,11 +256,19 @@ void volcano_outbreak(region * r, region *rn) } static bool stop_smoke_chance(void) { - return rng_int() % 100 < 12; + static int cache, percent = 0; + if (config_changed(&cache)) { + percent = config_get_int("volcano.stop.percent", 12); + } + return percent!=0 && (rng_int() % 100) < percent; } static bool outbreak_chance(void) { - return rng_int() % 100 < 8; + static int cache, percent = 0; + if (config_changed(&cache)) { + percent = config_get_int("volcano.outbreak.percent", 8); + } + return percent!=0 && (rng_int() % 100) < percent; } void volcano_update(void) From 99274e3ab16e4e514dd926618d2b80911f0177dd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Jan 2017 21:35:01 +0100 Subject: [PATCH 363/675] make runtests.bat not crash. disable auto-load of config.lua (sob). free messages and config in config.reset(). --- scripts/tests/laws.lua | 2 ++ src/bind_config.c | 3 +++ src/bindings.c | 2 +- src/laws.c | 3 ++- src/util/nrmessage.c | 13 +++++++++++++ src/util/nrmessage.h | 16 +++++++++------- src/util/nrmessage_struct.h | 4 ++-- 7 files changed, 32 insertions(+), 11 deletions(-) diff --git a/scripts/tests/laws.lua b/scripts/tests/laws.lua index f0fef15a9..6f41fc54b 100644 --- a/scripts/tests/laws.lua +++ b/scripts/tests/laws.lua @@ -95,6 +95,7 @@ function test_force_leave_postcombat() u1.building = b1 u2.building = b1 eressea.settings.set("rules.owners.force_leave", "1") + eressea.settings.set("NewbieImmunity", "0") u1:clear_orders() u1:add_order("ATTACKIERE " .. itoa36(u2.id)) u2:clear_orders() @@ -109,6 +110,7 @@ function test_force_leave_postcombat() end end assert_not_equal(nil, u3) + assert_equal(nil, u2.building) assert_equal(nil, u3.building) assert_equal(1, u3.number) end diff --git a/src/bind_config.c b/src/bind_config.c index 929e4cca0..faf543f47 100644 --- a/src/bind_config.c +++ b/src/bind_config.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -20,7 +21,9 @@ void config_reset(void) { default_locale = 0; + free_config(); free_locales(); + free_nrmesssages(); free_spells(); free_buildingtypes(); free_shiptypes(); diff --git a/src/bindings.c b/src/bindings.c index b6be1ccba..80021f01e 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -1190,7 +1190,7 @@ int eressea_run(lua_State *L, const char *luafile) lua_remove(L, -2); /* try to run configuration scripts: */ - err = run_script(L, "config.lua"); + // err = run_script(L, "config.lua"); err = run_script(L, "custom.lua"); /* run the main script */ diff --git a/src/laws.c b/src/laws.c index 112d15fd2..62ec2665d 100644 --- a/src/laws.c +++ b/src/laws.c @@ -119,7 +119,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. int NewbieImmunity(void) { - return config_get_int("NewbieImmunity", 0); + int result = config_get_int("NewbieImmunity", 0); + return result; } bool IsImmune(const faction * f) diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index 8156b9784..717c4dc1f 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -178,3 +178,16 @@ const char *nrt_section(const nrmessage_type * nrt) { return nrt ? nrt->section : NULL; } + +void free_nrmesssages(void) { + int i; + for (i = 0; i != NRT_MAXHASH; ++i) { + while (nrtypes[i]) { + nrmessage_type *nr = nrtypes[i]; + nrtypes[i] = nr->next; + free(nr->string); + free(nr->vars); + free(nr); + } + } +} diff --git a/src/util/nrmessage.h b/src/util/nrmessage.h index 122b1f1a8..6cc02bfe2 100644 --- a/src/util/nrmessage.h +++ b/src/util/nrmessage.h @@ -31,18 +31,20 @@ extern "C" { extern nrsection *sections; - extern void nrt_register(const struct message_type *mtype, + void free_nrmesssages(void); + + void nrt_register(const struct message_type *mtype, const struct locale *lang, const char *script, int level, const char *section); - extern struct nrmessage_type *nrt_find(const struct locale *, + struct nrmessage_type *nrt_find(const struct locale *, const struct message_type *); - extern const char *nrt_string(const struct nrmessage_type *type); - extern const char *nrt_section(const struct nrmessage_type *mt); + const char *nrt_string(const struct nrmessage_type *type); + const char *nrt_section(const struct nrmessage_type *mt); - extern size_t nr_render(const struct message *msg, const struct locale *lang, + size_t nr_render(const struct message *msg, const struct locale *lang, char *buffer, size_t size, const void *userdata); - extern int nr_level(const struct message *msg); - extern const char *nr_section(const struct message *msg); + int nr_level(const struct message *msg); + const char *nr_section(const struct message *msg); /* before: * fogblock;movement:0;de;{unit} konnte von {region} nicht nach {$dir direction} ausreisen, der Nebel war zu dicht. diff --git a/src/util/nrmessage_struct.h b/src/util/nrmessage_struct.h index 6a3a1d9b0..57f8e644d 100644 --- a/src/util/nrmessage_struct.h +++ b/src/util/nrmessage_struct.h @@ -8,8 +8,8 @@ typedef struct nrmessage_type { const struct message_type *mtype; const struct locale *lang; - const char *string; - const char *vars; + char *string; + char *vars; struct nrmessage_type *next; int level; const char *section; From 404ac546faced49442cd75404ac3cbedf51b4431 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 24 Jan 2017 10:36:27 +0100 Subject: [PATCH 364/675] BUG 2273: runtests.bat fails when config is auto-loaded. run rules tests with the correct configuration, ignore .ini file setting. still not enabling auto-load again, use custom.lua instead. --- scripts/tests/e3/castles.lua | 2 +- tests/runtests.bat | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/tests/e3/castles.lua b/scripts/tests/e3/castles.lua index 1fd4e13e9..df395ed3d 100644 --- a/scripts/tests/e3/castles.lua +++ b/scripts/tests/e3/castles.lua @@ -46,7 +46,7 @@ end function test_build_packice() local r = region.create(0, 0, "packice") - local f = faction.create("noreply@eressea.de", "human", "de") + local f = faction.create("packice@eressea.de", "human", "de") local u = unit.create(f, r, 1) u:clear_orders() u:add_item("stone", 10) diff --git a/tests/runtests.bat b/tests/runtests.bat index e79d27baa..996fb47b7 100644 --- a/tests/runtests.bat +++ b/tests/runtests.bat @@ -6,9 +6,9 @@ IF EXIST ..\build-vs14 SET BUILD=..\build-vs14\eressea\Debug SET SERVER=%BUILD%\eressea.exe %BUILD%\test_eressea.exe %SERVER% ..\scripts\run-tests.lua -%SERVER% ..\scripts\run-tests-e2.lua -%SERVER% ..\scripts\run-tests-e3.lua -%SERVER% ..\scripts\run-tests-e4.lua +%SERVER% -re2 ..\scripts\run-tests-e2.lua +%SERVER% -re3 ..\scripts\run-tests-e3.lua +%SERVER% -re4 ..\scripts\run-tests-e4.lua PAUSE RMDIR /s /q reports DEL score score.alliances datum turn From b170a30faa13acc20d40af97d9b5e5c90b58f7ea Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 25 Jan 2017 18:17:19 +0100 Subject: [PATCH 365/675] add a function to compare size of occupied castles --- src/kernel/building.c | 13 ++++++++++++- src/kernel/building.h | 2 ++ src/kernel/building.test.c | 26 ++++++++++++++++++++++++++ src/kernel/region.c | 14 +++++++++++--- src/kernel/region.test.c | 25 +++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 4 deletions(-) diff --git a/src/kernel/building.c b/src/kernel/building.c index fa7fe8688..9f6a8a421 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -335,7 +335,18 @@ const building_type *findbuildingtype(const char *name, return (const building_type *)type.v; } -static int building_protection(const building * b, const unit * u, building_bonus bonus) +int cmp_castle_size(const building * b, const building * a) +{ + if (!b || !b->type->protection || !building_owner(b)) { + return -1; + } + if (!a || !a->type->protection || !building_owner(a)) { + return 1; + } + return b->size - a->size; +} + +int building_protection(const building * b, const unit * u, building_bonus bonus) { int i = 0; int bsize = buildingeffsize(b, false); diff --git a/src/kernel/building.h b/src/kernel/building.h index 235c2d806..673675348 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -85,6 +85,8 @@ extern "C" { extern struct quicklist *buildingtypes; extern struct attrib_type at_building_action; + int cmp_castle_size(const struct building * b, const struct building * a); + int building_protection(const struct building * b, const struct unit * u, building_bonus bonus); building_type *bt_get_or_create(const char *name); bool bt_changed(int *cache); const building_type *bt_find(const char *name); diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index 3b296a6fe..89e2b978c 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -493,9 +493,35 @@ static void test_building_type(CuTest *tc) { test_cleanup(); } +static void test_cmp_castle_size(CuTest *tc) { + region *r; + building *b1, *b2; + building_type *bt_castle; + unit *u1, *u2; + + test_setup(); + bt_castle = test_create_buildingtype("castle"); + bt_castle->protection = building_protection; + r = test_create_region(0, 0, 0); + b1 = test_create_building(r, bt_castle); + b2 = test_create_building(r, bt_castle); + u1 = test_create_unit(test_create_faction(0), r); + u_set_building(u1, b1); + u2 = test_create_unit(test_create_faction(0), r); + u_set_building(u2, b2); + b1->size = 5; + b2->size = 10; + CuAssertTrue(tc, cmp_castle_size(b1, b2)<0); + CuAssertTrue(tc, cmp_castle_size(b2, b1)>0); + CuAssertTrue(tc, cmp_castle_size(b1, NULL)>0); + CuAssertTrue(tc, cmp_castle_size(NULL, b1)<0); + test_cleanup(); +} + CuSuite *get_building_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_cmp_castle_size); SUITE_ADD_TEST(suite, test_register_building); SUITE_ADD_TEST(suite, test_btype_defaults); SUITE_ADD_TEST(suite, test_building_set_owner); diff --git a/src/kernel/region.c b/src/kernel/region.c index cade135c7..06d2d9d7c 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -1324,9 +1324,17 @@ struct message *msg) struct faction *region_get_owner(const struct region *r) { - assert(rule_region_owners()); - if (r->land && r->land->ownership) { - return r->land->ownership->owner; + if (r->land) { + if (rule_region_owners()) { + if (r->land->ownership) { + return r->land->ownership->owner; + } + } + else { + building *b = largestbuilding(r, cmp_castle_size, false); + unit * u = b ? building_owner(b) : NULL; + return u ? u->faction : NULL; + } } return NULL; } diff --git a/src/kernel/region.test.c b/src/kernel/region.test.c index 01ecae2a8..8cf08a62c 100644 --- a/src/kernel/region.test.c +++ b/src/kernel/region.test.c @@ -1,6 +1,8 @@ #include #include "region.h" +#include "building.h" +#include "unit.h" #include "terrain.h" #include "item.h" @@ -31,9 +33,32 @@ void test_terraform(CuTest *tc) { test_cleanup(); } +static void test_region_get_owner(CuTest *tc) { + region *r; + building *b1, *b2; + building_type *bt_castle; + unit *u1, *u2; + + test_setup(); + bt_castle = test_create_buildingtype("castle"); + bt_castle->protection = building_protection; + r = test_create_region(0, 0, 0); + b1 = test_create_building(r, bt_castle); + b2 = test_create_building(r, bt_castle); + b1->size = 5; + b2->size = 10; + u1 = test_create_unit(test_create_faction(0), r); + u_set_building(u1, b1); + u2 = test_create_unit(test_create_faction(0), r); + u_set_building(u2, b2); + CuAssertPtrEquals(tc, u2->faction, region_get_owner(r)); + test_cleanup(); +} + CuSuite *get_region_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_terraform); + SUITE_ADD_TEST(suite, test_region_get_owner); return suite; } From 77cbd04cfac763fc1a4793c6ab6b07a450ce822d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 25 Jan 2017 20:57:54 +0100 Subject: [PATCH 366/675] BENENNE REGION ist jeder Einheit des Regionsbesitzers erlaubt --- src/kernel/building.test.c | 7 ++----- src/kernel/config.c | 2 +- src/kernel/region.test.c | 7 ++----- src/laws.c | 11 +---------- src/laws.test.c | 39 +++++++++++++++++++++++++++++++++----- src/tests.c | 9 +++++++-- 6 files changed, 47 insertions(+), 28 deletions(-) diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index 89e2b978c..e02d16556 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -496,15 +496,12 @@ static void test_building_type(CuTest *tc) { static void test_cmp_castle_size(CuTest *tc) { region *r; building *b1, *b2; - building_type *bt_castle; unit *u1, *u2; test_setup(); - bt_castle = test_create_buildingtype("castle"); - bt_castle->protection = building_protection; r = test_create_region(0, 0, 0); - b1 = test_create_building(r, bt_castle); - b2 = test_create_building(r, bt_castle); + b1 = test_create_building(r, NULL); + b2 = test_create_building(r, NULL); u1 = test_create_unit(test_create_faction(0), r); u_set_building(u1, b1); u2 = test_create_unit(test_create_faction(0), r); diff --git a/src/kernel/config.c b/src/kernel/config.c index acf762638..efe66b2f1 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -204,7 +204,7 @@ param_t findparam(const char *s, const struct locale * lang) void **tokens = get_translations(lang, UT_PARAMS); critbit_tree *cb = (critbit_tree *)*tokens; if (!cb) { - log_error("no parameters defined in locale %s", locale_name(lang)); + log_warning("no parameters defined in locale %s", locale_name(lang)); } else if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) { cb_get_kv(match, &i, sizeof(int)); diff --git a/src/kernel/region.test.c b/src/kernel/region.test.c index 8cf08a62c..892b37a8e 100644 --- a/src/kernel/region.test.c +++ b/src/kernel/region.test.c @@ -36,15 +36,12 @@ void test_terraform(CuTest *tc) { static void test_region_get_owner(CuTest *tc) { region *r; building *b1, *b2; - building_type *bt_castle; unit *u1, *u2; test_setup(); - bt_castle = test_create_buildingtype("castle"); - bt_castle->protection = building_protection; r = test_create_region(0, 0, 0); - b1 = test_create_building(r, bt_castle); - b2 = test_create_building(r, bt_castle); + b1 = test_create_building(r, NULL); + b2 = test_create_building(r, NULL); b1->size = 5; b2->size = 10; u1 = test_create_unit(test_create_faction(0), r); diff --git a/src/laws.c b/src/laws.c index 62ec2665d..59bf9efc8 100644 --- a/src/laws.c +++ b/src/laws.c @@ -1892,16 +1892,7 @@ int name_cmd(struct unit *u, struct order *ord) break; case P_REGION: - if (!b) { - cmistake(u, ord, 145, MSG_EVENT); - break; - } - if (building_owner(b) != u) { - cmistake(u, ord, 148, MSG_EVENT); - break; - } - - if (b != largestbuilding(r, get_cmp_region_owner(), false)) { + if (u->faction != region_get_owner(r)) { cmistake(u, ord, 147, MSG_EVENT); break; } diff --git a/src/laws.test.c b/src/laws.test.c index d4753ec19..67a9bb810 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -812,10 +812,7 @@ static void test_name_region(CuTest *tc) { f = u->faction; ord = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_REGION])); - name_cmd(u, ord); - CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error145")); - - u->building = test_create_building(u->region, 0); + u_set_building(u, test_create_building(u->region, 0)); name_cmd(u, ord); CuAssertStrEquals(tc, "Hodor", u->region->land->name); free_order(ord); @@ -1060,7 +1057,7 @@ static void test_name_cmd(CuTest *tc) { free_order(ord); ord = create_order(K_NAME, f->locale, "%s ' Ho\tdor '", LOC(f->locale, parameters[P_BUILDING])); - u->building = test_create_building(u->region, 0); + u_set_building(u, test_create_building(u->region, 0)); name_cmd(u, ord); CuAssertStrEquals(tc, "Hodor", u->building->name); free_order(ord); @@ -1073,6 +1070,37 @@ static void test_name_cmd(CuTest *tc) { test_cleanup(); } +static void test_name_cmd_2274(CuTest *tc) { + unit *u1, *u2, *u3; + faction *f; + region *r; + + test_setup(); + r = test_create_region(0, 0, 0); + u1 = test_create_unit(test_create_faction(0), r); + u2 = test_create_unit(test_create_faction(0), r); + u3 = test_create_unit(u2->faction, r); + u_set_building(u1, test_create_building(r, NULL)); + u1->building->size = 10; + u_set_building(u2, test_create_building(r, NULL)); + u2->building->size = 20; + + f = u2->faction; + u2->thisorder = create_order(K_NAME, f->locale, "%s Heimat", LOC(f->locale, parameters[P_REGION])); + name_cmd(u2, u2->thisorder); + CuAssertStrEquals(tc, "Heimat", r->land->name); + f = u3->faction; + u3->thisorder = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_REGION])); + name_cmd(u3, u3->thisorder); + CuAssertStrEquals(tc, "Hodor", r->land->name); + f = u1->faction; + u1->thisorder = create_order(K_NAME, f->locale, "%s notallowed", LOC(f->locale, parameters[P_REGION])); + name_cmd(u1, u1->thisorder); + CuAssertStrEquals(tc, "Hodor", r->land->name); + + test_cleanup(); +} + static void test_ally_cmd(CuTest *tc) { unit *u; faction * f; @@ -1481,6 +1509,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_nmr_warnings); SUITE_ADD_TEST(suite, test_ally_cmd); SUITE_ADD_TEST(suite, test_name_cmd); + SUITE_ADD_TEST(suite, test_name_cmd_2274); SUITE_ADD_TEST(suite, test_ally_cmd_errors); SUITE_ADD_TEST(suite, test_long_order_normal); SUITE_ADD_TEST(suite, test_long_order_none); diff --git a/src/tests.c b/src/tests.c index 15ae677fe..eb2631afe 100644 --- a/src/tests.c +++ b/src/tests.c @@ -225,8 +225,13 @@ building * test_create_building(region * r, const building_type * btype) { building * b; assert(r); - b = new_building(btype ? btype : test_create_buildingtype("castle"), r, default_locale); - b->size = b->type->maxsize > 0 ? b->type->maxsize : 1; + if (!btype) { + building_type *bt_castle = test_create_buildingtype("castle"); + bt_castle->protection = building_protection; + btype = bt_castle; + } + b = new_building(btype, r, default_locale); + b->size = btype->maxsize > 0 ? btype->maxsize : 1; return b; } From 30fc6f3e919b2ebfc31af6480d63b24b24e6cdeb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 25 Jan 2017 21:03:08 +0100 Subject: [PATCH 367/675] BESCHREIBE REGION ist jeder Einheit des Regionsbesitzers erlaubt --- src/laws.c | 20 +------------------- src/laws.test.c | 5 +++++ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/laws.c b/src/laws.c index 59bf9efc8..b99b2d3f2 100644 --- a/src/laws.c +++ b/src/laws.c @@ -1538,16 +1538,6 @@ int prefix_cmd(unit * u, struct order *ord) return 0; } -static cmp_building_cb get_cmp_region_owner(void) -{ - if (rule_region_owners()) { - return &cmp_current_owner; - } - else { - return &cmp_wage; - } -} - int display_cmd(unit * u, struct order *ord) { char token[128]; @@ -1597,15 +1587,7 @@ int display_cmd(unit * u, struct order *ord) break; case P_REGION: - if (!u->building) { - cmistake(u, ord, 145, MSG_EVENT); - break; - } - if (building_owner(u->building) != u) { - cmistake(u, ord, 148, MSG_EVENT); - break; - } - if (u->building != largestbuilding(r, get_cmp_region_owner(), false)) { + if (u->faction != region_get_owner(r)) { cmistake(u, ord, 147, MSG_EVENT); break; } diff --git a/src/laws.test.c b/src/laws.test.c index 67a9bb810..5eb742809 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -229,6 +229,11 @@ static void test_display_cmd(CuTest *tc) { CuAssertPtrEquals(tc, NULL, u->display); free_order(ord); + ord = create_order(K_DISPLAY, f->locale, "%s Hodor", LOC(f->locale, parameters[P_REGION])); + CuAssertIntEquals(tc, 0, display_cmd(u, ord)); + CuAssertPtrEquals(tc, NULL, r->display); + free_order(ord); + test_cleanup(); } From 78e43bd62e0e8bc9bf29eff0a2e1faa714c506db Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 25 Jan 2017 21:26:30 +0100 Subject: [PATCH 368/675] hack compress to not use /home/enno/bin script --- process/compress.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/compress.sh b/process/compress.sh index ff152b9f1..e50cf1940 100755 --- a/process/compress.sh +++ b/process/compress.sh @@ -20,5 +20,5 @@ if [ ! -d $GAME/reports ]; then fi cd $GAME/reports -$HOME/bin/compress.py $TURN "$GAME_NAME" +$ERESSEA/server/bin/compress.py $TURN "$GAME_NAME" cd - From 955997d58c66cd21775f6b99573cd9c76a69ea8a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 06:00:01 +0100 Subject: [PATCH 369/675] WIP: use latest clibs with selist. adding a transitional quicklist.c module to reduce work. --- clibs | 2 +- src/CMakeLists.txt | 1 + src/donations.c | 4 ++-- src/quicklist.c | 4 ++++ src/quicklist.h | 14 ++++++++++++++ 5 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/quicklist.c create mode 100644 src/quicklist.h diff --git a/clibs b/clibs index bce9b6568..339ac5680 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit bce9b6568d4e9ace26c95a7740140cd71029b21f +Subproject commit 339ac5680ec9027c88c4516c72b9da8233b6f3e3 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea76d4dbb..06af86c8b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -88,6 +88,7 @@ set (ERESSEA_SRC move.c piracy.c spells.c + quicklist.c battle.c alchemy.c academy.c diff --git a/src/donations.c b/src/donations.c index 8f820df2b..c6e4308ac 100644 --- a/src/donations.c +++ b/src/donations.c @@ -54,8 +54,8 @@ void add_donation(faction * f1, faction * f2, int amount, region * r) } void free_donations(void) { - ql_foreach(transfers, free); - ql_free(transfers); + selist_foreach(transfers, free); + selist_free(transfers); transfers = 0; } diff --git a/src/quicklist.c b/src/quicklist.c new file mode 100644 index 000000000..75d7b8641 --- /dev/null +++ b/src/quicklist.c @@ -0,0 +1,4 @@ +#include "quicklist.h" + +bool ql_set_insert_ex(struct quicklist **qlp, void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); +bool ql_set_find_ex(struct quicklist **qlp, int *qip, const void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); diff --git a/src/quicklist.h b/src/quicklist.h new file mode 100644 index 000000000..fe2f26991 --- /dev/null +++ b/src/quicklist.h @@ -0,0 +1,14 @@ +#pragma once + +#define selist quicklist +#define selist_free ql_free +#define selist_get ql_get +#define selist_push ql_push +#define selist_empty ql_empty +#define selist_advance ql_advance +#include +#include + +typedef void(*ql_cb)(void *); +bool ql_set_insert_ex(struct quicklist **qlp, void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); +bool ql_set_find_ex(struct quicklist **qlp, int *qip, const void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); From d9213c8f253decc10ea788569bd6365f8ad5d932 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 10:12:12 +0100 Subject: [PATCH 370/675] WIP: still converting to clibs/selist --- clibs | 2 +- src/donations.c | 24 ++++++++++-------------- src/kernel/curse.c | 2 +- src/kernel/spell.c | 2 +- src/quicklist.c | 30 ++++++++++++++++++++++++++++-- src/quicklist.h | 5 +++++ src/travelthru.c | 28 ++++++++++++++++++++-------- src/util/message.c | 2 +- 8 files changed, 67 insertions(+), 28 deletions(-) diff --git a/clibs b/clibs index 339ac5680..daa9de083 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit 339ac5680ec9027c88c4516c72b9da8233b6f3e3 +Subproject commit daa9de08314a75a4d77ef4e08c713088a96a5ca5 diff --git a/src/donations.c b/src/donations.c index c6e4308ac..0b1413a5f 100644 --- a/src/donations.c +++ b/src/donations.c @@ -59,22 +59,18 @@ void free_donations(void) { transfers = 0; } -static void report_transfer(faction *f1, faction *f2, region *r, int amount) { - struct message *msg = msg_message("donation", - "from to amount", f1, f2, amount); - r_addmessage(r, f1, msg); - r_addmessage(r, f2, msg); - msg_release(msg); +static void report_transfer(void *data) { + transfer *tf = (transfer *)data; + if (tf->amount > 0) { + struct message *msg = msg_message("donation", + "from to amount", tf->f1, tf->f2, tf->amount); + r_addmessage(tf->r, tf->f1, msg); + r_addmessage(tf->r, tf->f2, msg); + msg_release(msg); + } } void report_donations(void) { - ql_iter qli = qli_init(&transfers); - - while (qli_more(qli)) { - transfer *tf = (transfer *)qli_next(&qli); - if (tf->amount > 0) { - report_transfer(tf->f1, tf->f2, tf->r, tf->amount); - } - } + selist_foreach(transfers, report_transfer); } diff --git a/src/kernel/curse.c b/src/kernel/curse.c index 123f858f5..5e2086476 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -308,7 +308,7 @@ void ct_register(const curse_type * ct) unsigned int hash = tolower(ct->cname[0]) & 0xFF; quicklist **ctlp = cursetypes + hash; - ql_set_insert(ctlp, (void *)ct); + selist_set_insert(ctlp, (void *)ct, NULL); ++ct_changes; } diff --git a/src/kernel/spell.c b/src/kernel/spell.c index 8e14ec2c0..2644f341f 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -57,7 +57,7 @@ void free_spells(void) { void add_spell(struct quicklist **slistp, spell * sp) { - if (!ql_set_insert(slistp, sp)) { + if (!selist_set_insert(slistp, sp, NULL)) { log_error("add_spell: the list already contains the spell '%s'.\n", sp->sname); } } diff --git a/src/quicklist.c b/src/quicklist.c index 75d7b8641..2b760019c 100644 --- a/src/quicklist.c +++ b/src/quicklist.c @@ -1,4 +1,30 @@ #include "quicklist.h" +#include -bool ql_set_insert_ex(struct quicklist **qlp, void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); -bool ql_set_find_ex(struct quicklist **qlp, int *qip, const void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); +bool ql_set_remove(struct quicklist **qlp, const void *data) +{ + int qi, qn; + quicklist *ql = *qlp; + + if (!ql) + return false; + + qn = selist_length(ql); + for (qi = 0; qi != qn; ++qi) { + void *qd = selist_get(ql, qi); + if (qd == data) { + return selist_delete(qlp, qi) == 0; + } + } + return false; +} + +bool ql_set_insert(struct quicklist **qlp, void *data) +{ + return selist_set_insert(qlp, data, NULL); +} + +bool ql_set_find(struct quicklist **qlp, int *qip, const void *data) +{ + return selist_set_find(qlp, qip, data, NULL); +} diff --git a/src/quicklist.h b/src/quicklist.h index fe2f26991..c0446b471 100644 --- a/src/quicklist.h +++ b/src/quicklist.h @@ -2,7 +2,11 @@ #define selist quicklist #define selist_free ql_free +#define selist_delete ql_delete +#define selist_foreach ql_foreach #define selist_get ql_get +#define selist_replace ql_replace +#define selist_length ql_length #define selist_push ql_push #define selist_empty ql_empty #define selist_advance ql_advance @@ -12,3 +16,4 @@ typedef void(*ql_cb)(void *); bool ql_set_insert_ex(struct quicklist **qlp, void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); bool ql_set_find_ex(struct quicklist **qlp, int *qip, const void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); + diff --git a/src/travelthru.c b/src/travelthru.c index 5e6cac41b..04ca6cee5 100644 --- a/src/travelthru.c +++ b/src/travelthru.c @@ -99,18 +99,30 @@ bool travelthru_cansee(const struct region *r, const struct faction *f, const st return false; } -void travelthru_map(region * r, void(*cb)(region *, struct unit *, void *), void *cbdata) +struct cb_data { + void(*call)(region *, struct unit *, void *); + void *data; + struct region *r; +}; + +void cb_map(void *data, void *ex) { + struct cb_data *cb = (struct cb_data *)ex; + struct unit *u = (struct unit *)data; + cb->call(cb->r, u, cb->data); +} + +void travelthru_map(region * r, void(*cb)(region *, struct unit *, void *), void *data) { attrib *a; + struct cb_data cbdata; + assert(r); + cbdata.call = cb; + cbdata.data = data; + cbdata.r = r; a = a_find(r->attribs, &at_travelunit); if (a) { - quicklist *ql; - ql_iter qi; - ql = (quicklist *)a->data.v; - for (qi = qli_init(&ql); qli_more(qi);) { - unit *u = (unit *)qli_next(&qi); - cb(r, u, cbdata); - } + quicklist *ql = (quicklist *)a->data.v; + selist_foreach_ex(ql, cb_map, &cbdata); } } diff --git a/src/util/message.c b/src/util/message.c index f19fc3313..46bfec969 100644 --- a/src/util/message.c +++ b/src/util/message.c @@ -215,7 +215,7 @@ const message_type *mt_register(message_type * type) unsigned int hash = hashstring(type->name) % MT_MAXHASH; quicklist **qlp = messagetypes + hash; - if (ql_set_insert(qlp, type)) { + if (selist_set_insert(qlp, type, NULL)) { type->key = mt_id(type); } return type; From 138258310968652cab4a6a7b0da14047902f5597 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 10:15:26 +0100 Subject: [PATCH 371/675] fix compilation (but not linking). --- src/sqlite.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sqlite.c b/src/sqlite.c index 42bfdb3b5..99c72d9ec 100644 --- a/src/sqlite.c +++ b/src/sqlite.c @@ -136,10 +136,12 @@ static void update_faction(sqlite3 *db, const faction *f) { int db_update_factions(sqlite3 * db, bool force, int game_id) { quicklist *ql = read_factions(db, game_id); faction *f; + if (!ql) return SQLITE_OK; sqlite3_exec(db, "BEGIN", 0, 0, 0); for (f = factions; f; f = f->next) { bool update = force; db_faction *dbf = 0; +#ifdef SELIST_TODO ql_iter it = qli_init(&ql); while (qli_more(it)) { db_faction *df = (db_faction*)qli_next(&it); @@ -151,6 +153,7 @@ int db_update_factions(sqlite3 * db, bool force, int game_id) { break; } } +#endif if (dbf) { if (dbf->uid != f->subscription) { log_warning("faction %s(%d) not found in database, but matches %d\n", itoa36(f->no), f->subscription, dbf->uid); From c72b050a4235ea0aa84f0cdc8e67a7704beed06c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 10:53:52 +0100 Subject: [PATCH 372/675] WIP: quicklist->selist shim can compile and link, but tests crash --- src/donations.c | 12 ++++++------ src/quicklist.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/quicklist.h | 19 +++++++++---------- src/reports.c | 2 +- 4 files changed, 61 insertions(+), 17 deletions(-) diff --git a/src/donations.c b/src/donations.c index 0b1413a5f..4dee36444 100644 --- a/src/donations.c +++ b/src/donations.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include @@ -15,7 +15,7 @@ typedef struct transfer { int amount; } transfer; -static quicklist *transfers = 0; +static selist *transfers = 0; int cmp_transfer(const void *v1, const void *v2) { const transfer *t1 = (const transfer *)v1; @@ -35,22 +35,22 @@ int cmp_transfer(const void *v1, const void *v2) { void add_donation(faction * f1, faction * f2, int amount, region * r) { transfer tr, *tf; - quicklist *ql = transfers; + selist *ql = transfers; int qi = 0; tr.r = r; tr.f1 = f1; tr.f2 = f2; tr.amount = amount; - if (ql_set_find_ex(&ql, &qi, &tr, cmp_transfer)) { - tf = (transfer *)ql_get(ql, qi); + if (selist_set_find(&ql, &qi, &tr, cmp_transfer)) { + tf = (transfer *)selist_get(ql, qi); tf->amount += amount; } else { tf = malloc(sizeof(transfer)); memcpy(tf, &tr, sizeof(transfer)); } - ql_set_insert_ex(&transfers, tf, cmp_transfer); + selist_set_insert(&transfers, tf, cmp_transfer); } void free_donations(void) { diff --git a/src/quicklist.c b/src/quicklist.c index 2b760019c..6fb567a64 100644 --- a/src/quicklist.c +++ b/src/quicklist.c @@ -1,6 +1,51 @@ #include "quicklist.h" #include +void ql_push(struct quicklist **qlp, void *el) +{ + selist_push(qlp, el); +} + +int ql_length(const struct quicklist *ql) +{ + return selist_length(ql); +} + +void * ql_replace(struct quicklist *ql, int index, void *el) +{ + return selist_replace(ql, index, el); +} + +void *ql_get(struct quicklist *ql, int index) +{ + return selist_get(ql, index); +} + +int ql_delete(struct quicklist **qlp, int index) +{ + return selist_delete(qlp, index); +} + +bool ql_empty(const struct quicklist *ql) +{ + return selist_empty(ql); +} + +void ql_foreach(struct quicklist *ql, selist_cb cb) +{ + selist_foreach(ql, cb); +} + +int ql_advance(struct quicklist **qlp, int *index, int stride) +{ + return selist_advance(qlp, index, stride); +} + +void ql_free(struct quicklist *ql) +{ + selist_free(ql); +} + bool ql_set_remove(struct quicklist **qlp, const void *data) { int qi, qn; diff --git a/src/quicklist.h b/src/quicklist.h index c0446b471..f5a85a354 100644 --- a/src/quicklist.h +++ b/src/quicklist.h @@ -1,18 +1,17 @@ #pragma once #define selist quicklist -#define selist_free ql_free -#define selist_delete ql_delete -#define selist_foreach ql_foreach -#define selist_get ql_get -#define selist_replace ql_replace -#define selist_length ql_length -#define selist_push ql_push -#define selist_empty ql_empty -#define selist_advance ql_advance #include -#include +int ql_advance(struct quicklist **qlp, int *index, int stride); +void ql_foreach(struct quicklist *ql, selist_cb cb); +void ql_free(struct quicklist *ql); +int ql_delete(struct quicklist **qlp, int index); +void ql_push(struct quicklist **qlp, void *el); +int ql_length(const struct quicklist *ql); +void * ql_replace(struct quicklist *ql, int index, void *el); +void *ql_get(struct quicklist *ql, int index); +bool ql_empty(const struct quicklist *ql); typedef void(*ql_cb)(void *); bool ql_set_insert_ex(struct quicklist **qlp, void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); bool ql_set_find_ex(struct quicklist **qlp, int *qip, const void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); diff --git a/src/reports.c b/src/reports.c index a8b9e5cfb..3e139fdda 100644 --- a/src/reports.c +++ b/src/reports.c @@ -989,7 +989,7 @@ int cmp_faction(const void *lhs, const void *rhs) { } static void add_seen_faction_i(struct quicklist **flist, faction *f) { - ql_set_insert_ex(flist, f, cmp_faction); + selist_set_insert(flist, f, cmp_faction); } void add_seen_faction(faction *self, faction *seen) { From 2ace44d385ab00cfb0c5f1d91e1ea719781a9e30 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 16:05:44 +0100 Subject: [PATCH 373/675] fix duplicate cutest library conflict and crash --- .gitmodules | 3 --- CMakeLists.txt | 1 - clibs | 2 +- cutest | 1 - src/CMakeLists.txt | 3 +-- 5 files changed, 2 insertions(+), 8 deletions(-) delete mode 160000 cutest diff --git a/.gitmodules b/.gitmodules index e9ea1e3ed..7dff5ab6a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,9 +7,6 @@ [submodule "dlmalloc"] path = dlmalloc url = https://github.com/ennorehling/dlmalloc.git -[submodule "cutest"] - path = cutest - url = https://github.com/ennorehling/cutest.git [submodule "iniparser"] path = iniparser url = https://github.com/ennorehling/iniparser.git diff --git a/CMakeLists.txt b/CMakeLists.txt index cc7e8173d..f6b931e61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,6 @@ INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include) ## skip compiler/libc detection and force cmake autoconf: #add_definitions(-DUSE_AUTOCONF) -add_subdirectory (cutest) add_subdirectory (cJSON) add_subdirectory (storage) add_subdirectory (iniparser) diff --git a/clibs b/clibs index daa9de083..1052905e0 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit daa9de08314a75a4d77ef4e08c713088a96a5ca5 +Subproject commit 1052905e08314de8778750d7585474182723111e diff --git a/cutest b/cutest deleted file mode 160000 index 6e268687d..000000000 --- a/cutest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6e268687dbf6ae55afb63210c3753530d216a622 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06af86c8b..6eacaae0b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,6 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}) include_directories (${CJSON_INCLUDE_DIR}) include_directories (${CLIBS_INCLUDE_DIR}) include_directories (${STORAGE_INCLUDE_DIR}) -include_directories (${CUTEST_INCLUDE_DIR}) include_directories (${LUA_INCLUDE_DIR}) include_directories (${TOLUA_INCLUDE_DIR}) include_directories (${BSON_INCLUDE_DIR}) @@ -236,7 +235,7 @@ set(TESTS_SRC add_executable(test_eressea ${TESTS_SRC}) target_link_libraries(test_eressea game - ${CUTEST_LIBRARIES} + cutest ${LUA_LIBRARIES} ${CLIBS_LIBRARIES} ${STORAGE_LIBRARIES} From a4badc0a75695d044b8ed5be798a525cab28f0a6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 17:41:21 +0100 Subject: [PATCH 374/675] remove quicklist shim, use selist everywhere --- src/CMakeLists.txt | 1 - src/battle.c | 44 +++++++++++----------- src/battle.h | 12 +++--- src/bind_unit.c | 8 ++-- src/bindings.c | 42 ++++++++++----------- src/bindings.h | 6 +-- src/creport.c | 16 ++++---- src/kernel/alliance.c | 19 +++++----- src/kernel/alliance.h | 3 +- src/kernel/alliance.test.c | 6 +-- src/kernel/building.c | 22 +++++------ src/kernel/building.h | 2 +- src/kernel/connection.c | 12 +++--- src/kernel/curse.c | 28 +++++++------- src/kernel/equipment.c | 14 +++---- src/kernel/equipment.h | 2 +- src/kernel/faction.c | 12 +++--- src/kernel/faction.h | 3 +- src/kernel/faction.test.c | 6 +-- src/kernel/pathfinder.c | 8 ++-- src/kernel/pathfinder.h | 2 +- src/kernel/save.c | 4 +- src/kernel/ship.c | 22 +++++------ src/kernel/ship.h | 2 +- src/kernel/spell.c | 20 +++++----- src/kernel/spell.h | 6 +-- src/kernel/spellbook.c | 30 +++++++-------- src/kernel/spellbook.h | 4 +- src/kernel/types.h | 2 +- src/laws.c | 8 ++-- src/magic.c | 30 +++++++-------- src/magic.h | 4 +- src/magic.test.c | 12 +++--- src/market.c | 16 ++++---- src/modules/autoseed.c | 42 ++++++++++----------- src/monsters.c | 10 ++--- src/quicklist.c | 75 -------------------------------------- src/quicklist.h | 18 --------- src/report.c | 10 ++--- src/reports.c | 53 +++++++++++++-------------- src/reports.h | 8 ++-- src/reports.test.c | 14 +++---- src/spells/combatspells.c | 66 ++++++++++++++++----------------- src/sqlite.c | 20 +++++----- src/travelthru.c | 14 +++---- src/util/message.c | 18 ++++----- src/wormhole.c | 20 +++++----- src/wormhole.test.c | 12 +++--- 48 files changed, 360 insertions(+), 448 deletions(-) delete mode 100644 src/quicklist.c delete mode 100644 src/quicklist.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6eacaae0b..a3f81e1a2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,7 +87,6 @@ set (ERESSEA_SRC move.c piracy.c spells.c - quicklist.c battle.c alchemy.c academy.c diff --git a/src/battle.c b/src/battle.c index 7aa3e4cfa..28a08c6f3 100644 --- a/src/battle.c +++ b/src/battle.c @@ -64,7 +64,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include #include #include @@ -1248,7 +1248,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) rda = 0; else { int qi; - quicklist *ql; + selist *ql; unsigned int i = 0; if (u_race(du)->battle_flags & BF_RES_PIERCE) @@ -1262,8 +1262,8 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) rda /= 2; /* Schilde */ - for (qi = 0, ql = b->meffects; ql; ql_advance(&ql, &qi, 1)) { - meffect *me = (meffect *)ql_get(ql, qi); + for (qi = 0, ql = b->meffects; ql; selist_advance(&ql, &qi, 1)) { + meffect *me = (meffect *)selist_get(ql, qi); if (meffect_protection(b, me, ds) != 0) { assert(0 <= rda); /* rda sollte hier immer mindestens 0 sein */ /* jeder Schaden wird um effect% reduziert bis der Schild duration @@ -1603,11 +1603,11 @@ static troop select_opponent(battle * b, troop at, int mindist, int maxdist) return dt; } -quicklist *fighters(battle * b, const side * vs, int minrow, int maxrow, +selist *fighters(battle * b, const side * vs, int minrow, int maxrow, int mask) { side *s; - quicklist *fightervp = 0; + selist *fightervp = 0; assert(vs != NULL); @@ -1629,7 +1629,7 @@ quicklist *fighters(battle * b, const side * vs, int minrow, int maxrow, for (fig = s->fighters; fig; fig = fig->next) { int row = get_unitrow(fig, vs); if (row >= minrow && row <= maxrow) { - ql_push(&fightervp, fig); + selist_push(&fightervp, fig); } } } @@ -1801,7 +1801,7 @@ static void do_combatspell(troop at) unit *caster = fi->unit; battle *b = fi->side->battle; region *r = b->region; - quicklist *ql; + selist *ql; int level, qi; double power; int fumblechance = 0; @@ -1830,8 +1830,8 @@ static void do_combatspell(troop at) return; } - for (qi = 0, ql = b->meffects; ql; ql_advance(&ql, &qi, 1)) { - meffect *mblock = (meffect *)ql_get(ql, qi); + for (qi = 0, ql = b->meffects; ql; selist_advance(&ql, &qi, 1)) { + meffect *mblock = (meffect *)selist_get(ql, qi); if (mblock->typ == SHIELD_BLOCK) { if (meffect_blocked(b, mblock, fi->side) != 0) { fumblechance += mblock->duration; @@ -2341,11 +2341,11 @@ static void add_tactics(tactics * ta, fighter * fig, int value) if (value == 0 || value < ta->value) return; if (value > ta->value) { - ql_free(ta->fighters); + selist_free(ta->fighters); ta->fighters = 0; } - ql_push(&ta->fighters, fig); - ql_push(&fig->side->battle->leaders, fig); + selist_push(&ta->fighters, fig); + selist_push(&fig->side->battle->leaders, fig); ta->value = value; } @@ -3091,7 +3091,7 @@ static void print_stats(battle * b) b->max_tactics = 0; for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (!ql_empty(s->leader.fighters)) { + if (!selist_empty(s->leader.fighters)) { b->max_tactics = _max(b->max_tactics, s->leader.value); } } @@ -3099,11 +3099,11 @@ static void print_stats(battle * b) if (b->max_tactics > 0) { for (s = b->sides; s != b->sides + b->nsides; ++s) { if (s->leader.value == b->max_tactics) { - quicklist *ql; + selist *ql; int qi; - for (qi = 0, ql = s->leader.fighters; ql; ql_advance(&ql, &qi, 1)) { - fighter *tf = (fighter *)ql_get(ql, qi); + for (qi = 0, ql = s->leader.fighters; ql; selist_advance(&ql, &qi, 1)) { + fighter *tf = (fighter *)selist_get(ql, qi); unit *u = tf->unit; message *m = NULL; if (!is_attacker(tf)) { @@ -3599,7 +3599,7 @@ battle *make_battle(region * r) static void free_side(side * si) { - ql_free(si->leader.fighters); + selist_free(si->leader.fighters); } static void free_fighter(fighter * fig) @@ -3647,9 +3647,9 @@ void free_battle(battle * b) free(bf); } - ql_free(b->leaders); - ql_foreach(b->meffects, free); - ql_free(b->meffects); + selist_free(b->leaders); + selist_foreach(b->meffects, free); + selist_free(b->meffects); battle_free(b); } @@ -4242,7 +4242,7 @@ void do_battle(region * r) freset(sh, SF_DAMAGED); /* Gibt es eine Taktikrunde ? */ - if (!ql_empty(b->leaders)) { + if (!selist_empty(b->leaders)) { b->turn = 0; b->has_tactics_turn = true; } diff --git a/src/battle.h b/src/battle.h index 007bda008..cee894b6c 100644 --- a/src/battle.h +++ b/src/battle.h @@ -25,6 +25,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. extern "C" { #endif + struct message; + struct selist; + /** more defines **/ #define FS_ENEMY 1 #define FS_HELP 2 @@ -43,7 +46,6 @@ extern "C" { #define LAST_ROW FLEE_ROW #define MAXSIDES 192 /* if there are ever more than this, we're fucked. */ - struct message; typedef struct bfaction { struct bfaction *next; @@ -53,7 +55,7 @@ extern "C" { } bfaction; typedef struct tactics { - struct quicklist *fighters; + struct selist *fighters; int value; } tactics; @@ -86,7 +88,7 @@ extern "C" { } side; typedef struct battle { - struct quicklist *leaders; + struct selist *leaders; struct region *region; struct plane *plane; bfaction *factions; @@ -94,7 +96,7 @@ extern "C" { int nfighters; side sides[MAXSIDES]; int nsides; - struct quicklist *meffects; + struct selist *meffects; int max_tactics; int turn; bool has_tactics_turn; @@ -253,7 +255,7 @@ extern "C" { extern int hits(troop at, troop dt, weapon * awp); extern void damage_building(struct battle *b, struct building *bldg, int damage_abs); - struct quicklist *fighters(struct battle *b, const struct side *vs, + struct selist *fighters(struct battle *b, const struct side *vs, int minrow, int maxrow, int mask); int count_allies(const struct side *as, int minrow, int maxrow, int select, int allytype); diff --git a/src/bind_unit.c b/src/bind_unit.c index 42fafae39..1983e0f62 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -46,7 +46,7 @@ without prior permission by the authors of Eressea. #include #include #include -#include +#include #include @@ -753,12 +753,12 @@ static int tolua_unit_get_spells(lua_State * L) unit *self = (unit *) tolua_tousertype(L, 1, 0); sc_mage *mage = self ? get_mage(self) : 0; spellbook *sb = mage ? mage->spellbook : 0; - quicklist *slist = 0; + selist *slist = 0; if (sb) { - quicklist **slist_ptr = &sb->spells; + selist **slist_ptr = &sb->spells; slist = *slist_ptr; } - return tolua_quicklist_push(L, "spellbook", "spell_entry", slist); + return tolua_selist_push(L, "spellbook", "spell_entry", slist); } static int tolua_unit_get_orders(lua_State * L) diff --git a/src/bindings.c b/src/bindings.c index aa2e177c1..53eafdcb4 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -66,7 +66,7 @@ without prior permission by the authors of Eressea. #include #include #include -#include +#include #include #include #include @@ -114,16 +114,16 @@ int tolua_orderlist_next(lua_State * L) return 0; } -static int tolua_quicklist_iter(lua_State * L) +static int tolua_selist_iter(lua_State * L) { - quicklist **qlp = (quicklist **)lua_touserdata(L, lua_upvalueindex(1)); - quicklist *ql = *qlp; + selist **qlp = (selist **)lua_touserdata(L, lua_upvalueindex(1)); + selist *ql = *qlp; if (ql != NULL) { int index = (int)lua_tointeger(L, lua_upvalueindex(2)); const char *type = lua_tostring(L, lua_upvalueindex(3)); - void *data = ql_get(ql, index); + void *data = selist_get(ql, index); tolua_pushusertype(L, data, TOLUA_CAST type); - ql_advance(qlp, &index, 1); + selist_advance(qlp, &index, 1); lua_pushinteger(L, index); lua_replace(L, lua_upvalueindex(2)); return 1; @@ -131,18 +131,18 @@ static int tolua_quicklist_iter(lua_State * L) return 0; } -int tolua_quicklist_push(struct lua_State *L, const char *list_type, - const char *elem_type, struct quicklist *list) +int tolua_selist_push(struct lua_State *L, const char *list_type, + const char *elem_type, struct selist *list) { if (list) { - quicklist **qlist_ptr = - (quicklist **)lua_newuserdata(L, sizeof(quicklist *)); + selist **qlist_ptr = + (selist **)lua_newuserdata(L, sizeof(selist *)); *qlist_ptr = list; luaL_getmetatable(L, list_type); lua_setmetatable(L, -2); lua_pushinteger(L, 0); lua_pushstring(L, elem_type); - lua_pushcclosure(L, tolua_quicklist_iter, 3); /* OBS: this closure has multiple upvalues (list, index, type_name) */ + lua_pushcclosure(L, tolua_selist_iter, 3); /* OBS: this closure has multiple upvalues (list, index, type_name) */ } else { lua_pushnil(L); @@ -671,7 +671,7 @@ static int tolua_get_factions(lua_State * L) static int tolua_get_alliance_factions(lua_State * L) { alliance *self = (alliance *)tolua_tousertype(L, 1, 0); - return tolua_quicklist_push(L, "faction_list", "faction", self->members); + return tolua_selist_push(L, "faction_list", "faction", self->members); } static int tolua_get_alliance_id(lua_State * L) @@ -697,11 +697,11 @@ static int tolua_set_alliance_name(lua_State * L) static int config_get_ships(lua_State * L) { - quicklist *ql; + selist *ql; int qi, i = 0; - lua_createtable(L, ql_length(shiptypes), 0); - for (qi = 0, ql = shiptypes; ql; ql_advance(&ql, &qi, 1)) { - ship_type *stype = (ship_type *)ql_get(ql, qi); + lua_createtable(L, selist_length(shiptypes), 0); + for (qi = 0, ql = shiptypes; ql; selist_advance(&ql, &qi, 1)) { + ship_type *stype = (ship_type *)selist_get(ql, qi); tolua_pushstring(L, TOLUA_CAST stype->_name); lua_rawseti(L, -2, ++i); } @@ -710,11 +710,11 @@ static int config_get_ships(lua_State * L) static int config_get_buildings(lua_State * L) { - quicklist *ql; + selist *ql; int qi, i = 0; - lua_createtable(L, ql_length(buildingtypes), 0); - for (qi = 0, ql = buildingtypes; ql; ql_advance(&ql, &qi, 1)) { - building_type *btype = (building_type *)ql_get(ql, qi); + lua_createtable(L, selist_length(buildingtypes), 0); + for (qi = 0, ql = buildingtypes; ql; selist_advance(&ql, &qi, 1)) { + building_type *btype = (building_type *)selist_get(ql, qi); tolua_pushstring(L, TOLUA_CAST btype->_name); lua_rawseti(L, -2, ++i); } @@ -936,7 +936,7 @@ static int tolua_get_spell_entry_level(lua_State * L) static int tolua_get_spells(lua_State * L) { - return tolua_quicklist_push(L, "spell_list", "spell", spells); + return tolua_selist_push(L, "spell_list", "spell", spells); } static int init_data(const char *filename, const char *catalog) diff --git a/src/bindings.h b/src/bindings.h index 6c71ecf94..8eda1178b 100755 --- a/src/bindings.h +++ b/src/bindings.h @@ -15,15 +15,15 @@ extern "C" { #endif struct lua_State; - struct quicklist; + struct selist; int tolua_sqlite_open(struct lua_State *L); int tolua_bindings_open(struct lua_State *L); int tolua_spelllist_next(struct lua_State *L); int tolua_itemlist_next(struct lua_State *L); int tolua_orderlist_next(struct lua_State *L); - int tolua_quicklist_push(struct lua_State *L, const char *list_type, - const char *elem_type, struct quicklist *list); + int tolua_selist_push(struct lua_State *L, const char *list_type, + const char *elem_type, struct selist *list); int log_lua_error(struct lua_State *L); diff --git a/src/creport.c b/src/creport.c index eeb2a1202..6cd9b7a27 100644 --- a/src/creport.c +++ b/src/creport.c @@ -68,7 +68,7 @@ without prior permission by the authors of Eressea. #include #include #include -#include +#include #include #include @@ -712,11 +712,11 @@ static void cr_output_spells(stream *out, const unit * u, int maxlevel) if (book) { const faction * f = u->faction; - quicklist *ql; + selist *ql; int qi, header = 0; - for (ql = book->spells, qi = 0; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry * sbe = (spellbook_entry *)ql_get(ql, qi); + for (ql = book->spells, qi = 0; ql; selist_advance(&ql, &qi, 1)) { + spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= maxlevel) { spell * sp = sbe->sp; const char *name = translate(mkname("spell", sp->sname), spell_name(sp, f->locale)); @@ -1027,12 +1027,12 @@ static void show_alliances_cr(FILE * F, const faction * f) /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ /* this is a copy of laws.c->find_address output changed. */ -static void cr_find_address(FILE * F, const faction * uf, quicklist * addresses) +static void cr_find_address(FILE * F, const faction * uf, selist * addresses) { int i = 0; - quicklist *flist = addresses; + selist *flist = addresses; while (flist) { - const faction *f = (const faction *)ql_get(flist, i); + const faction *f = (const faction *)selist_get(flist, i); if (uf != f) { fprintf(F, "PARTEI %d\n", f->no); fprintf(F, "\"%s\";Parteiname\n", f->name); @@ -1045,7 +1045,7 @@ static void cr_find_address(FILE * F, const faction * uf, quicklist * addresses) fprintf(F, "%d;alliance\n", f->alliance->id); } } - ql_advance(&flist, &i, 1); + selist_advance(&flist, &i, 1); } } diff --git a/src/kernel/alliance.c b/src/kernel/alliance.c index 36d054323..32c58e246 100644 --- a/src/kernel/alliance.c +++ b/src/kernel/alliance.c @@ -31,10 +31,11 @@ without prior permission by the authors of Eressea. #include #include #include -#include #include #include +#include + /* libc includes */ #include #include @@ -49,7 +50,7 @@ void free_alliances(void) alliances = al->next; free(al->name); if (al->members) { - ql_free(al->members); + selist_free(al->members); } free(al); } @@ -115,7 +116,7 @@ faction *alliance_get_leader(alliance * al) { if (!al->_leader) { if (al->members) { - al->_leader = (faction *)ql_get(al->members, 0); + al->_leader = (faction *)selist_get(al->members, 0); } } return al->_leader; @@ -356,19 +357,19 @@ void setalliance(faction * f, alliance * al) return; if (f->alliance != NULL) { int qi; - quicklist **flistp = &f->alliance->members; + selist **flistp = &f->alliance->members; - for (qi = 0; *flistp; ql_advance(flistp, &qi, 1)) { - faction *data = (faction *)ql_get(*flistp, qi); + for (qi = 0; *flistp; selist_advance(flistp, &qi, 1)) { + faction *data = (faction *)selist_get(*flistp, qi); if (data == f) { - ql_delete(flistp, qi); + selist_delete(flistp, qi); break; } } if (f->alliance->_leader == f) { if (f->alliance->members) { - f->alliance->_leader = (faction *)ql_get(f->alliance->members, 0); + f->alliance->_leader = (faction *)selist_get(f->alliance->members, 0); } else { f->alliance->_leader = NULL; @@ -378,7 +379,7 @@ void setalliance(faction * f, alliance * al) f->alliance = al; f->alliance_joindate = turn; if (al != NULL) { - ql_push(&al->members, f); + selist_push(&al->members, f); if (al->_leader == NULL) { al->_leader = f; } diff --git a/src/kernel/alliance.h b/src/kernel/alliance.h index 907fc65f7..fac2dfd38 100644 --- a/src/kernel/alliance.h +++ b/src/kernel/alliance.h @@ -27,6 +27,7 @@ extern "C" { struct unit; struct faction; struct region; + struct selist; enum { ALLIANCE_KICK, @@ -46,7 +47,7 @@ extern "C" { typedef struct alliance { struct alliance *next; struct faction *_leader; - struct quicklist *members; + struct selist *members; int flags; int id; char *name; diff --git a/src/kernel/alliance.test.c b/src/kernel/alliance.test.c index 72a31a42c..c0ec03fbc 100644 --- a/src/kernel/alliance.test.c +++ b/src/kernel/alliance.test.c @@ -7,7 +7,7 @@ #include "alliance.h" #include #include -#include +#include #include @@ -76,10 +76,10 @@ static void test_alliance_dead_faction(CuTest *tc) { setalliance(f, al); setalliance(f2, al); CuAssertPtrEquals(tc, f, alliance_get_leader(al)); - CuAssertIntEquals(tc, 2, ql_length(al->members)); + CuAssertIntEquals(tc, 2, selist_length(al->members)); CuAssertPtrEquals(tc, al, f->alliance); destroyfaction(&factions); - CuAssertIntEquals(tc, 1, ql_length(al->members)); + CuAssertIntEquals(tc, 1, selist_length(al->members)); CuAssertPtrEquals(tc, f2, alliance_get_leader(al)); CuAssertPtrEquals(tc, NULL, f->alliance); CuAssertTrue(tc, !f->_alive); diff --git a/src/kernel/building.c b/src/kernel/building.c index 8d76df030..b445019de 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -41,7 +41,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include #include #include @@ -62,18 +62,18 @@ typedef struct building_typelist { building_type *type; } building_typelist; -quicklist *buildingtypes = NULL; +selist *buildingtypes = NULL; /* Returns a building type for the (internal) name */ static building_type *bt_find_i(const char *name) { - quicklist *ql; + selist *ql; int qi; assert(name); - for (qi = 0, ql = buildingtypes; ql; ql_advance(&ql, &qi, 1)) { - building_type *btype = (building_type *)ql_get(ql, qi); + for (qi = 0, ql = buildingtypes; ql; selist_advance(&ql, &qi, 1)) { + building_type *btype = (building_type *)selist_get(ql, qi); if (strcmp(btype->_name, name) == 0) return btype; } @@ -102,7 +102,7 @@ void bt_register(building_type * type) if (type->init) { type->init(type); } - ql_push(&buildingtypes, (void *)type); + selist_push(&buildingtypes, (void *)type); ++bt_changes; } @@ -115,8 +115,8 @@ static void free_buildingtype(void *ptr) { } void free_buildingtypes(void) { - ql_foreach(buildingtypes, free_buildingtype); - ql_free(buildingtypes); + selist_foreach(buildingtypes, free_buildingtype); + selist_free(buildingtypes); buildingtypes = 0; ++bt_changes; } @@ -314,15 +314,15 @@ const building_type *findbuildingtype(const char *name, bn = bn->next; } if (!bn) { - quicklist *ql = buildingtypes; + selist *ql = buildingtypes; int qi; bn = (local_names *)calloc(sizeof(local_names), 1); bn->next = bnames; bn->lang = lang; - for (qi = 0, ql = buildingtypes; ql; ql_advance(&ql, &qi, 1)) { - building_type *btype = (building_type *)ql_get(ql, qi); + for (qi = 0, ql = buildingtypes; ql; selist_advance(&ql, &qi, 1)) { + building_type *btype = (building_type *)selist_get(ql, qi); const char *n = LOC(lang, btype->_name); type.v = (void *)btype; diff --git a/src/kernel/building.h b/src/kernel/building.h index 92b006b98..754f38f07 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -80,7 +80,7 @@ extern "C" { struct attrib *attribs; } building_type; - extern struct quicklist *buildingtypes; + extern struct selist *buildingtypes; extern struct attrib_type at_building_action; building_type *bt_get_or_create(const char *name); diff --git a/src/kernel/connection.c b/src/kernel/connection.c index 6eccf1f0c..082039f1b 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -29,7 +29,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include #include #include @@ -345,7 +345,7 @@ attrib_type at_countdown = { void age_borders(void) { - quicklist *deleted = NULL, *ql; + selist *deleted = NULL, *ql; int i; for (i = 0; i != BORDER_MAXHASH; ++i) { @@ -355,17 +355,17 @@ void age_borders(void) for (; b; b = b->next) { if (b->type->age) { if (b->type->age(b) == AT_AGE_REMOVE) { - ql_push(&deleted, b); + selist_push(&deleted, b); } } } } } - for (ql = deleted, i = 0; ql; ql_advance(&ql, &i, 1)) { - connection *b = (connection *)ql_get(ql, i); + for (ql = deleted, i = 0; ql; selist_advance(&ql, &i, 1)) { + connection *b = (connection *)selist_get(ql, i); erase_border(b); } - ql_free(deleted); + selist_free(deleted); } /******** diff --git a/src/kernel/curse.c b/src/kernel/curse.c index 5e2086476..c0e353b4f 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -287,10 +287,10 @@ attrib_type at_curse = { /* Spruch identifizieren */ #include -#include +#include #define MAXCTHASH 128 -static quicklist *cursetypes[MAXCTHASH]; +static selist *cursetypes[MAXCTHASH]; static int ct_changes = 1; bool ct_changed(int *cache) @@ -306,7 +306,7 @@ bool ct_changed(int *cache) void ct_register(const curse_type * ct) { unsigned int hash = tolower(ct->cname[0]) & 0xFF; - quicklist **ctlp = cursetypes + hash; + selist **ctlp = cursetypes + hash; selist_set_insert(ctlp, (void *)ct, NULL); ++ct_changes; @@ -315,16 +315,16 @@ void ct_register(const curse_type * ct) void ct_remove(const char *c) { unsigned int hash = tolower(c[0]); - quicklist *ctl = cursetypes[hash]; + selist *ctl = cursetypes[hash]; if (ctl) { int qi; - for (qi = 0; ctl; ql_advance(&ctl, &qi, 1)) { - curse_type *type = (curse_type *)ql_get(ctl, qi); + for (qi = 0; ctl; selist_advance(&ctl, &qi, 1)) { + curse_type *type = (curse_type *)selist_get(ctl, qi); if (strcmp(c, type->cname) == 0) { - ql_delete(&ctl, qi); + selist_delete(&ctl, qi); ++ct_changes; break; } @@ -335,14 +335,14 @@ void ct_remove(const char *c) const curse_type *ct_find(const char *c) { unsigned int hash = tolower(c[0]); - quicklist *ctl = cursetypes[hash]; + selist *ctl = cursetypes[hash]; if (ctl) { size_t c_len = strlen(c); int qi; - for (qi = 0; ctl; ql_advance(&ctl, &qi, 1)) { - curse_type *type = (curse_type *)ql_get(ctl, qi); + for (qi = 0; ctl; selist_advance(&ctl, &qi, 1)) { + curse_type *type = (curse_type *)selist_get(ctl, qi); if (strcmp(c, type->cname) == 0) { return type; @@ -360,12 +360,12 @@ const curse_type *ct_find(const char *c) void ct_checknames(void) { int i, qi; - quicklist *ctl; + selist *ctl; for (i = 0; i < MAXCTHASH; ++i) { ctl = cursetypes[i]; - for (qi = 0; ctl; ql_advance(&ctl, &qi, 1)) { - curse_type *type = (curse_type *)ql_get(ctl, qi); + for (qi = 0; ctl; selist_advance(&ctl, &qi, 1)) { + curse_type *type = (curse_type *)selist_get(ctl, qi); curse_name(type, default_locale); } @@ -847,7 +847,7 @@ double destr_curse(curse * c, int cast_level, double force) void curses_done(void) { int i; for (i = 0; i != MAXCTHASH; ++i) { - ql_free(cursetypes[i]); + selist_free(cursetypes[i]); cursetypes[i] = 0; } ++ct_changes; diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index 8266ada9a..de539223f 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -28,7 +28,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "spell.h" /* util includes */ -#include +#include #include #include @@ -99,7 +99,7 @@ void equipment_addspell(equipment * eq, const char * name, int level) ls->sp = NULL; ls->level = level; ls->name = _strdup(name); - ql_push(&eq->spells, ls); + selist_push(&eq->spells, ls); } } @@ -156,12 +156,12 @@ void equip_unit_mask(struct unit *u, const struct equipment *eq, int mask) if (mask & EQUIP_SPELLS) { if (eq->spells) { - quicklist * ql = eq->spells; + selist * ql = eq->spells; int qi; sc_mage * mage = get_mage(u); - for (qi = 0; ql; ql_advance(&ql, &qi, 1)) { - lazy_spell *sbe = (lazy_spell *)ql_get(ql, qi); + for (qi = 0; ql; selist_advance(&ql, &qi, 1)) { + lazy_spell *sbe = (lazy_spell *)selist_get(ql, qi); if (!sbe->sp) { sbe->sp = find_spell(sbe->name); free(sbe->name); @@ -250,8 +250,8 @@ void equipment_done(void) { *eqp = eq->next; free(eq->name); if (eq->spells) { - ql_foreach(eq->spells, free_ls); - ql_free(eq->spells); + selist_foreach(eq->spells, free_ls); + selist_free(eq->spells); } while (eq->items) { itemdata *next = eq->items->next; diff --git a/src/kernel/equipment.h b/src/kernel/equipment.h index 5c7b3407b..4081ab748 100644 --- a/src/kernel/equipment.h +++ b/src/kernel/equipment.h @@ -48,7 +48,7 @@ extern "C" { char *name; struct itemdata *items; char *skills[MAXSKILLS]; - struct quicklist *spells; + struct selist *spells; struct subset *subsets; struct equipment *next; void(*callback) (const struct equipment *, struct unit *); diff --git a/src/kernel/faction.c b/src/kernel/faction.c index d332bf604..4d2e6ae7b 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -51,7 +51,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include -#include +#include #include /* libc includes */ @@ -102,7 +102,7 @@ static void free_faction(faction * f) free(f->_password); free(f->name); if (f->seen_factions) { - ql_free(f->seen_factions); + selist_free(f->seen_factions); f->seen_factions = 0; } @@ -366,7 +366,7 @@ void destroyfaction(faction ** fp) } if (f->seen_factions) { - ql_free(f->seen_factions); + selist_free(f->seen_factions); f->seen_factions = 0; } @@ -593,11 +593,11 @@ static int allied_skillcount(const faction * f, skill_t sk) { int num = 0; alliance *a = f_get_alliance(f); - quicklist *members = a->members; + selist *members = a->members; int qi; - for (qi = 0; members; ql_advance(&members, &qi, 1)) { - faction *m = (faction *)ql_get(members, qi); + for (qi = 0; members; selist_advance(&members, &qi, 1)) { + faction *m = (faction *)selist_get(members, qi); num += count_skill(m, sk); } return num; diff --git a/src/kernel/faction.h b/src/kernel/faction.h index 82ae89ea4..d6419dd2f 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -31,6 +31,7 @@ extern "C" { struct seen_region; struct attrib_type; struct gamedata; + struct selist; extern struct attrib_type at_maxmagicians; @@ -95,7 +96,7 @@ extern "C" { struct message_list *msgs; } *battles; struct item *items; /* items this faction can claim */ - struct quicklist *seen_factions; + struct selist *seen_factions; bool _alive; /* enno: sollte ein flag werden */ } faction; diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 75ced96df..596c92907 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -13,7 +13,7 @@ #include "monster.h" #include #include -#include +#include #include #include @@ -47,10 +47,10 @@ static void test_remove_empty_factions_alliance(CuTest *tc) { al = makealliance(0, "Hodor"); setalliance(f, al); CuAssertPtrEquals(tc, f, alliance_get_leader(al)); - CuAssertIntEquals(tc, 1, ql_length(al->members)); + CuAssertIntEquals(tc, 1, selist_length(al->members)); remove_empty_factions(); CuAssertPtrEquals(tc, 0, al->_leader); - CuAssertIntEquals(tc, 0, ql_length(al->members)); + CuAssertIntEquals(tc, 0, selist_length(al->members)); test_cleanup(); } diff --git a/src/kernel/pathfinder.c b/src/kernel/pathfinder.c index 8ae9bf128..ba45f926c 100644 --- a/src/kernel/pathfinder.c +++ b/src/kernel/pathfinder.c @@ -18,7 +18,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#include +#include #include "pathfinder.h" #include "region.h" @@ -102,10 +102,10 @@ static void free_nodes(node * root) } } -struct quicklist *regions_in_range(struct region *start, int maxdist, +struct selist *regions_in_range(struct region *start, int maxdist, bool(*allowed) (const struct region *, const struct region *)) { - quicklist * rlist = NULL; + selist * rlist = NULL; node *root = new_node(start, 0, NULL); node **end = &root->next; node *n = root; @@ -127,7 +127,7 @@ struct quicklist *regions_in_range(struct region *start, int maxdist, continue; /* can't go there */ /* add the region to the list of available ones. */ - ql_push(&rlist, rn); + selist_push(&rlist, rn); /* make sure we don't go here again, and put the region into the set for further BFS'ing */ diff --git a/src/kernel/pathfinder.h b/src/kernel/pathfinder.h index 81692e835..682fa4d25 100644 --- a/src/kernel/pathfinder.h +++ b/src/kernel/pathfinder.h @@ -34,7 +34,7 @@ extern "C" { const struct region *target); extern bool allowed_walk(const struct region *src, const struct region *target); - extern struct quicklist *regions_in_range(struct region *src, int maxdist, + extern struct selist *regions_in_range(struct region *src, int maxdist, bool(*allowed) (const struct region *, const struct region *)); extern void pathfinder_cleanup(void); diff --git a/src/kernel/save.c b/src/kernel/save.c index 2f157af41..68c89070c 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -71,7 +71,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#include +#include #include #include #include @@ -1266,7 +1266,7 @@ faction *read_faction(struct gamedata * data) assert(!al->members || !"non-allied dummy-alliance has more than one member"); } - ql_push(&al->members, f); + selist_push(&al->members, f); } else if (rule_region_owners()) { /* compat fix for non-allied factions */ diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 6898630ff..1790afb5d 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -38,7 +38,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include #include #include @@ -51,7 +51,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -quicklist *shiptypes = NULL; +selist *shiptypes = NULL; static local_names *snames; @@ -66,15 +66,15 @@ const ship_type *findshiptype(const char *name, const struct locale *lang) sn = sn->next; } if (!sn) { - quicklist *ql; + selist *ql; int qi; sn = (local_names *)calloc(sizeof(local_names), 1); sn->next = snames; sn->lang = lang; - for (qi = 0, ql = shiptypes; ql; ql_advance(&ql, &qi, 1)) { - ship_type *stype = (ship_type *)ql_get(ql, qi); + for (qi = 0, ql = shiptypes; ql; selist_advance(&ql, &qi, 1)) { + ship_type *stype = (ship_type *)selist_get(ql, qi); variant var2; const char *n = LOC(lang, stype->_name); var2.v = (void *)stype; @@ -89,11 +89,11 @@ const ship_type *findshiptype(const char *name, const struct locale *lang) static ship_type *st_find_i(const char *name) { - quicklist *ql; + selist *ql; int qi; - for (qi = 0, ql = shiptypes; ql; ql_advance(&ql, &qi, 1)) { - ship_type *stype = (ship_type *)ql_get(ql, qi); + for (qi = 0, ql = shiptypes; ql; selist_advance(&ql, &qi, 1)) { + ship_type *stype = (ship_type *)selist_get(ql, qi); if (strcmp(stype->_name, name) == 0) { return stype; } @@ -111,7 +111,7 @@ ship_type *st_get_or_create(const char * name) { st = (ship_type *)calloc(sizeof(ship_type), 1); st->_name = _strdup(name); st->storm = 1.0; - ql_push(&shiptypes, (void *)st); + selist_push(&shiptypes, (void *)st); } return st; } @@ -250,8 +250,8 @@ static void free_shiptype(void *ptr) { } void free_shiptypes(void) { - ql_foreach(shiptypes, free_shiptype); - ql_free(shiptypes); + selist_foreach(shiptypes, free_shiptype); + selist_free(shiptypes); shiptypes = 0; } diff --git a/src/kernel/ship.h b/src/kernel/ship.h index 964ee2124..285c29cc0 100644 --- a/src/kernel/ship.h +++ b/src/kernel/ship.h @@ -63,7 +63,7 @@ extern "C" { struct construction *construction; /* how to build a ship */ } ship_type; - extern struct quicklist *shiptypes; + extern struct selist *shiptypes; /* Alte Schiffstypen: */ diff --git a/src/kernel/spell.c b/src/kernel/spell.c index 2644f341f..4540029e2 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -26,7 +26,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include /* libc includes */ #include @@ -34,7 +34,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include static critbit_tree cb_spells; -quicklist * spells; +selist * spells; static void free_spell(spell *sp) { free(sp->syntax); @@ -50,12 +50,12 @@ static void free_spell_cb(void *cbdata) { void free_spells(void) { cb_clear(&cb_spells); - ql_foreach(spells, free_spell_cb); - ql_free(spells); + selist_foreach(spells, free_spell_cb); + selist_free(spells); spells = 0; } -void add_spell(struct quicklist **slistp, spell * sp) +void add_spell(struct selist **slistp, spell * sp) { if (!selist_set_insert(slistp, sp, NULL)) { log_error("add_spell: the list already contains the spell '%s'.\n", sp->sname); @@ -123,19 +123,19 @@ spell *find_spell(const char *name) spell *find_spellbyid(unsigned int id) { - quicklist *ql; + selist *ql; int qi; if (id == 0) return NULL; - for (qi = 0, ql = spells; ql; ql_advance(&ql, &qi, 1)) { - spell *sp = (spell *)ql_get(ql, qi); + for (qi = 0, ql = spells; ql; selist_advance(&ql, &qi, 1)) { + spell *sp = (spell *)selist_get(ql, qi); if (sp->id == id) { return sp; } } - for (qi = 0, ql = spells; ql; ql_advance(&ql, &qi, 1)) { - spell *sp = (spell *)ql_get(ql, qi); + for (qi = 0, ql = spells; ql; selist_advance(&ql, &qi, 1)) { + spell *sp = (spell *)selist_get(ql, qi); unsigned int hashid = hashstring(sp->sname); if (hashid == id) { return sp; diff --git a/src/kernel/spell.h b/src/kernel/spell.h index b447f51d4..f74fda6e2 100644 --- a/src/kernel/spell.h +++ b/src/kernel/spell.h @@ -27,7 +27,7 @@ extern "C" { struct region; struct spell; struct spell_component; - struct quicklist; + struct selist; struct attrib_type; typedef int(*spell_f)(struct castorder * co); @@ -50,13 +50,13 @@ extern "C" { struct spell * create_spell(const char * name, unsigned int id); struct spell * find_spell(const char *name); struct spell * find_spellbyid(unsigned int i); - void add_spell(struct quicklist **slistp, spell * sp); + void add_spell(struct selist **slistp, spell * sp); void free_spells(void); /** globals **/ extern struct attrib_type at_unitdissolve; extern struct attrib_type at_wdwpyramid; - extern struct quicklist * spells; + extern struct selist * spells; #ifdef __cplusplus } #endif diff --git a/src/kernel/spellbook.c b/src/kernel/spellbook.c index da8fcd563..7673324f8 100644 --- a/src/kernel/spellbook.c +++ b/src/kernel/spellbook.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -58,12 +58,12 @@ void read_spellbook(spellbook **bookp, gamedata *data, int(*get_level)(const spe void write_spellbook(const struct spellbook *book, struct storage *store) { - quicklist *ql; + selist *ql; int qi; if (book) { - for (ql = book->spells, qi = 0; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi); + for (ql = book->spells, qi = 0; ql; selist_advance(&ql, &qi, 1)) { + spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); WRITE_TOK(store, sbe->sp->sname); WRITE_INT(store, sbe->level); } @@ -84,30 +84,30 @@ void spellbook_add(spellbook *sb, struct spell * sp, int level) sbe = (spellbook_entry *)malloc(sizeof(spellbook_entry)); sbe->sp = sp; sbe->level = level; - ql_push(&sb->spells, sbe); + selist_push(&sb->spells, sbe); } void spellbook_clear(spellbook *sb) { - quicklist *ql; + selist *ql; int qi; assert(sb); - for (qi = 0, ql = sb->spells; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi); + for (qi = 0, ql = sb->spells; ql; selist_advance(&ql, &qi, 1)) { + spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); free(sbe); } - ql_free(sb->spells); + selist_free(sb->spells); free(sb->name); } int spellbook_foreach(spellbook *sb, int(*callback)(spellbook_entry *, void *), void * data) { - quicklist *ql; + selist *ql; int qi; - for (qi = 0, ql = sb->spells; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi); + for (qi = 0, ql = sb->spells; ql; selist_advance(&ql, &qi, 1)) { + spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); int result = callback(sbe, data); if (result) { return result; @@ -119,11 +119,11 @@ int spellbook_foreach(spellbook *sb, int(*callback)(spellbook_entry *, void *), spellbook_entry * spellbook_get(spellbook *sb, const struct spell * sp) { if (sb) { - quicklist *ql; + selist *ql; int qi; - for (qi = 0, ql = sb->spells; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi); + for (qi = 0, ql = sb->spells; ql; selist_advance(&ql, &qi, 1)) { + spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); if (sp == sbe->sp) { return sbe; } diff --git a/src/kernel/spellbook.h b/src/kernel/spellbook.h index 84ec0ce5f..75a420c06 100644 --- a/src/kernel/spellbook.h +++ b/src/kernel/spellbook.h @@ -26,7 +26,7 @@ extern "C" { struct spell; struct storage; struct gamedata; - struct quicklist; + struct selist; typedef struct spellbook_entry { struct spell * sp; @@ -36,7 +36,7 @@ extern "C" { typedef struct spellbook { char * name; - struct quicklist * spells; + struct selist * spells; } spellbook; spellbook * create_spellbook(const char * name); diff --git a/src/kernel/types.h b/src/kernel/types.h index da4fefecf..2b63f7e07 100644 --- a/src/kernel/types.h +++ b/src/kernel/types.h @@ -43,7 +43,7 @@ struct luxury_type; struct order; struct plane; struct potion_type; -struct quicklist; +struct selist; struct race; struct region; struct region_list; diff --git a/src/laws.c b/src/laws.c index 3fe53237e..5a68c72f0 100644 --- a/src/laws.c +++ b/src/laws.c @@ -89,7 +89,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include -#include +#include #include /* libc includes */ #include @@ -3478,10 +3478,10 @@ static void copy_spells(const spellbook * src, spellbook * dst, int maxlevel) { assert(dst); if (src && src->spells) { - quicklist *ql; + selist *ql; int qi; - for (qi = 0, ql = src->spells; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry * sbe = (spellbook_entry *)ql_get(ql, qi); + for (qi = 0, ql = src->spells; ql; selist_advance(&ql, &qi, 1)) { + spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= maxlevel) { if (!spellbook_get(dst, sbe->sp)) { spellbook_add(dst, sbe->sp, sbe->level); diff --git a/src/magic.c b/src/magic.c index 2299e6523..dbdc1abe8 100644 --- a/src/magic.c +++ b/src/magic.c @@ -58,7 +58,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include #include #include #include @@ -231,7 +231,7 @@ bool FactionSpells(void) return rule != 0; } -void read_spells(struct quicklist **slistp, magic_t mtype, +void read_spells(struct selist **slistp, magic_t mtype, struct storage *store) { for (;;) { @@ -305,13 +305,13 @@ static int read_mage(attrib * a, void *owner, struct gamedata *data) return AT_READ_OK; } -void write_spells(struct quicklist *slist, struct storage *store) +void write_spells(struct selist *slist, struct storage *store) { - quicklist *ql; + selist *ql; int qi; - for (ql = slist, qi = 0; ql; ql_advance(&ql, &qi, 1)) { - spell *sp = (spell *)ql_get(ql, qi); + for (ql = slist, qi = 0; ql; selist_advance(&ql, &qi, 1)) { + spell *sp = (spell *)selist_get(ql, qi); WRITE_TOK(store, sp->sname); } WRITE_TOK(store, "end"); @@ -424,11 +424,11 @@ static bool already_seen(const faction * f, const spell * sp) void show_new_spells(faction * f, int level, const spellbook *book) { if (book) { - quicklist *ql = book->spells; + selist *ql = book->spells; int qi; - for (qi = 0; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi); + for (qi = 0; ql; selist_advance(&ql, &qi, 1)) { + spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= level) { if (!already_seen(f, sbe->sp)) { @@ -451,14 +451,14 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells { spellbook_entry *commonspells[MAXSPELLS]; int qi, numspells = 0; - quicklist *ql; + selist *ql; if (level <= f->max_spelllevel) { return; } - for (qi = 0, ql = book->spells; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry * sbe = (spellbook_entry *)ql_get(ql, qi); + for (qi = 0, ql = book->spells; ql; selist_advance(&ql, &qi, 1)) { + spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= level) { commonspells[numspells++] = sbe; } @@ -2956,14 +2956,14 @@ const char *curse_name(const curse_type * ctype, const struct locale *lang) } static void select_spellbook(void **tokens, spellbook *sb, const struct locale * lang) { - quicklist * ql; + selist * ql; int qi; assert(sb); assert(lang); - for (qi = 0, ql = sb->spells; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi); + for (qi = 0, ql = sb->spells; ql; selist_advance(&ql, &qi, 1)) { + spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); spell *sp = sbe->sp; const char *n = spell_name(sp, lang); diff --git a/src/magic.h b/src/magic.h index 59ef92475..d1ae286d0 100644 --- a/src/magic.h +++ b/src/magic.h @@ -348,8 +348,8 @@ extern "C" { struct order *ord, const struct spllprm *spobj); bool FactionSpells(void); - void write_spells(struct quicklist *slist, struct storage *store); - void read_spells(struct quicklist **slistp, magic_t mtype, + void write_spells(struct selist *slist, struct storage *store); + void read_spells(struct selist **slistp, magic_t mtype, struct storage *store); struct spellbook * get_spellbook(const char * name); diff --git a/src/magic.test.c b/src/magic.test.c index 4ba867b96..befd1986d 100644 --- a/src/magic.test.c +++ b/src/magic.test.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -41,7 +41,7 @@ void test_updatespells(CuTest * tc) CuAssertPtrEquals(tc, 0, f->spellbook); pick_random_spells(f, 1, book, 1); CuAssertPtrNotNull(tc, f->spellbook); - CuAssertIntEquals(tc, 1, ql_length(f->spellbook->spells)); + CuAssertIntEquals(tc, 1, selist_length(f->spellbook->spells)); CuAssertPtrNotNull(tc, spellbook_get(f->spellbook, sp)); free_spellbook(book); test_cleanup(); @@ -370,10 +370,10 @@ void test_hasspell(CuTest * tc) test_cleanup(); } -static quicklist * casts; +static selist * casts; static int cast_fireball(struct castorder * co) { - ql_push(&casts, co); + selist_push(&casts, co); return 0; } @@ -401,8 +401,8 @@ void test_multi_cast(CuTest *tc) { CuAssertPtrEquals(tc, casts, 0); magic(); CuAssertPtrNotNull(tc, casts); - CuAssertIntEquals(tc, 2, ql_length(casts)); - ql_free(casts); + CuAssertIntEquals(tc, 2, selist_length(casts)); + selist_free(casts); test_cleanup(); } diff --git a/src/market.c b/src/market.c index cef84b9b2..42819325f 100644 --- a/src/market.c +++ b/src/market.c @@ -17,7 +17,7 @@ without prior permission by the authors of Eressea. #include #include -#include +#include #include #include @@ -92,7 +92,7 @@ bool markets_module(void) void do_markets(void) { - quicklist *traders = 0; + selist *traders = 0; unit *markets[MAX_MARKETS]; region *r; for (r = regions; r; r = r->next) { @@ -124,7 +124,7 @@ void do_markets(void) attrib *a = a_find(u->attribs, &at_market); if (a == NULL) { a = a_add(&u->attribs, a_new(&at_market)); - ql_push(&traders, u); + selist_push(&traders, u); } items = (item *)a->data.v; i_change(&items, lux, 1); @@ -138,7 +138,7 @@ void do_markets(void) attrib *a = a_find(u->attribs, &at_market); if (a == NULL) { a = a_add(&u->attribs, a_new(&at_market)); - ql_push(&traders, u); + selist_push(&traders, u); } items = (item *)a->data.v; i_change(&items, herb, 1); @@ -151,10 +151,10 @@ void do_markets(void) } if (traders) { - quicklist *qliter = traders; + selist *qliter = traders; int qli = 0; - for (qli = 0; qliter; ql_advance(&qliter, &qli, 1)) { - unit *u = (unit *)ql_get(qliter, qli); + for (qli = 0; qliter; selist_advance(&qliter, &qli, 1)) { + unit *u = (unit *)selist_get(qliter, qli); attrib *a = a_find(u->attribs, &at_market); item *items = (item *)a->data.v; @@ -176,6 +176,6 @@ void do_markets(void) a_remove(&u->attribs, a); } - ql_free(traders); + selist_free(traders); } } diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 5420406c0..925fae349 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include @@ -295,17 +295,17 @@ static bool virgin_region(const region * r) return true; } -static quicklist * get_island(region * root) +static selist * get_island(region * root) { - quicklist * ql, *result = 0; + selist * ql, *result = 0; int qi = 0; fset(root, RF_MARK); - ql_push(&result, root); + selist_push(&result, root); - for (ql = result, qi = 0; ql; ql_advance(&ql, &qi, 1)) { + for (ql = result, qi = 0; ql; selist_advance(&ql, &qi, 1)) { int dir; - region *r = (region *)ql_get(ql, qi); + region *r = (region *)selist_get(ql, qi); region * next[MAXDIRECTIONS]; get_neighbours(r, next); @@ -314,13 +314,13 @@ static quicklist * get_island(region * root) region *rn = next[dir]; if (rn != NULL && rn->land && !fval(rn, RF_MARK)) { fset(rn, RF_MARK); - ql_push(&result, rn); + selist_push(&result, rn); } } } - for (ql = result, qi = 0; ql; ql_advance(&ql, &qi, 1)) { - region *r = (region *)ql_get(ql, qi); + for (ql = result, qi = 0; ql; selist_advance(&ql, &qi, 1)) { + region *r = (region *)selist_get(ql, qi); freset(r, RF_MARK); } return result; @@ -330,14 +330,14 @@ static void get_island_info(region * root, int *size_p, int *inhabited_p, int *maxage_p) { int qi, size = 0, maxage = 0, inhabited = 0; - quicklist *ql, *island = NULL; + selist *ql, *island = NULL; - ql_push(&island, root); + selist_push(&island, root); fset(root, RF_MARK); - for (ql = island, qi = 0; ql; ql_advance(&ql, &qi, 1)) { + for (ql = island, qi = 0; ql; selist_advance(&ql, &qi, 1)) { int d; - region *r = (region *)ql_get(ql, qi); + region *r = (region *)selist_get(ql, qi); if (r->units) { unit *u; for (u = r->units; u; u = u->next) { @@ -351,16 +351,16 @@ get_island_info(region * root, int *size_p, int *inhabited_p, int *maxage_p) for (d = 0; d != MAXDIRECTIONS; ++d) { region *rn = rconnect(r, d); if (rn && !fval(rn, RF_MARK) && rn->land) { - ql_push(&island, rn); + selist_push(&island, rn); fset(rn, RF_MARK); } } } - for (ql = island, qi = 0; ql; ql_advance(&ql, &qi, 1)) { - region *r = (region *)ql_get(ql, qi); + for (ql = island, qi = 0; ql; selist_advance(&ql, &qi, 1)) { + region *r = (region *)selist_get(ql, qi); freset(r, RF_MARK); } - ql_free(island); + selist_free(island); if (size_p) *size_p = size; if (inhabited_p) @@ -502,11 +502,11 @@ int autoseed(newfaction ** players, int nsize, int max_agediff) } if (rmin != NULL) { faction *f; - quicklist *ql, *rlist = get_island(rmin); + selist *ql, *rlist = get_island(rmin); int qi; - for (ql = rlist, qi = 0; ql; ql_advance(&ql, &qi, 1)) { - region *r = (region *)ql_get(ql, qi); + for (ql = rlist, qi = 0; ql; selist_advance(&ql, &qi, 1)) { + region *r = (region *)selist_get(ql, qi); unit *u; for (u = r->units; u; u = u->next) { f = u->faction; @@ -516,7 +516,7 @@ int autoseed(newfaction ** players, int nsize, int max_agediff) } } } - ql_free(rlist); + selist_free(rlist); if (psize > 0) { for (f = factions; f; f = f->next) { freset(f, FFL_MARK); diff --git a/src/monsters.c b/src/monsters.c index cea817589..6e6630fe8 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -65,7 +65,7 @@ #include #include -#include +#include /* libc includes */ #include @@ -428,11 +428,11 @@ static attrib *set_new_dragon_target(unit * u, region * r, int range) { int max_affinity = 0; region *max_region = NULL; - quicklist *ql, *rlist = regions_in_range(r, range, allowed_dragon); + selist *ql, *rlist = regions_in_range(r, range, allowed_dragon); int qi; - for (qi = 0, ql = rlist; ql; ql_advance(&ql, &qi, 1)) { - region *r2 = (region *)ql_get(ql, qi); + for (qi = 0, ql = rlist; ql; selist_advance(&ql, &qi, 1)) { + region *r2 = (region *)selist_get(ql, qi); int affinity = dragon_affinity_value(r2, u); if (affinity > max_affinity) { max_affinity = affinity; @@ -440,7 +440,7 @@ static attrib *set_new_dragon_target(unit * u, region * r, int range) } } - ql_free(rlist); + selist_free(rlist); if (max_region && max_region != r) { attrib *a = a_find(u->attribs, &at_targetregion); diff --git a/src/quicklist.c b/src/quicklist.c deleted file mode 100644 index 6fb567a64..000000000 --- a/src/quicklist.c +++ /dev/null @@ -1,75 +0,0 @@ -#include "quicklist.h" -#include - -void ql_push(struct quicklist **qlp, void *el) -{ - selist_push(qlp, el); -} - -int ql_length(const struct quicklist *ql) -{ - return selist_length(ql); -} - -void * ql_replace(struct quicklist *ql, int index, void *el) -{ - return selist_replace(ql, index, el); -} - -void *ql_get(struct quicklist *ql, int index) -{ - return selist_get(ql, index); -} - -int ql_delete(struct quicklist **qlp, int index) -{ - return selist_delete(qlp, index); -} - -bool ql_empty(const struct quicklist *ql) -{ - return selist_empty(ql); -} - -void ql_foreach(struct quicklist *ql, selist_cb cb) -{ - selist_foreach(ql, cb); -} - -int ql_advance(struct quicklist **qlp, int *index, int stride) -{ - return selist_advance(qlp, index, stride); -} - -void ql_free(struct quicklist *ql) -{ - selist_free(ql); -} - -bool ql_set_remove(struct quicklist **qlp, const void *data) -{ - int qi, qn; - quicklist *ql = *qlp; - - if (!ql) - return false; - - qn = selist_length(ql); - for (qi = 0; qi != qn; ++qi) { - void *qd = selist_get(ql, qi); - if (qd == data) { - return selist_delete(qlp, qi) == 0; - } - } - return false; -} - -bool ql_set_insert(struct quicklist **qlp, void *data) -{ - return selist_set_insert(qlp, data, NULL); -} - -bool ql_set_find(struct quicklist **qlp, int *qip, const void *data) -{ - return selist_set_find(qlp, qip, data, NULL); -} diff --git a/src/quicklist.h b/src/quicklist.h deleted file mode 100644 index f5a85a354..000000000 --- a/src/quicklist.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#define selist quicklist -#include - -int ql_advance(struct quicklist **qlp, int *index, int stride); -void ql_foreach(struct quicklist *ql, selist_cb cb); -void ql_free(struct quicklist *ql); -int ql_delete(struct quicklist **qlp, int index); -void ql_push(struct quicklist **qlp, void *el); -int ql_length(const struct quicklist *ql); -void * ql_replace(struct quicklist *ql, int index, void *el); -void *ql_get(struct quicklist *ql, int index); -bool ql_empty(const struct quicklist *ql); -typedef void(*ql_cb)(void *); -bool ql_set_insert_ex(struct quicklist **qlp, void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); -bool ql_set_find_ex(struct quicklist **qlp, int *qip, const void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); - diff --git a/src/report.c b/src/report.c index dd6b29525..e754c3fb2 100644 --- a/src/report.c +++ b/src/report.c @@ -82,7 +82,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include #include #include #include @@ -1733,16 +1733,16 @@ static void rpline(struct stream *out) swrite(line, sizeof(line), 1, out); } -static void list_address(struct stream *out, const faction * uf, quicklist * seenfactions) +static void list_address(struct stream *out, const faction * uf, selist * seenfactions) { int qi = 0; - quicklist *flist = seenfactions; + selist *flist = seenfactions; centre(out, LOC(uf->locale, "nr_addresses"), false); newline(out); while (flist != NULL) { - const faction *f = (const faction *)ql_get(flist, qi); + const faction *f = (const faction *)selist_get(flist, qi); if (!is_monsters(f)) { char buf[8192]; char label = '-'; @@ -1757,7 +1757,7 @@ static void list_address(struct stream *out, const faction * uf, quicklist * see label = '+'; paragraph(out, buf, 4, 0, label); } - ql_advance(&flist, &qi, 1); + selist_advance(&flist, &qi, 1); } newline(out); rpline(out); diff --git a/src/reports.c b/src/reports.c index 3e139fdda..8ffb823a5 100644 --- a/src/reports.c +++ b/src/reports.c @@ -57,7 +57,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include /* libc includes */ #include @@ -659,15 +659,15 @@ size_t size) spellbook *book = unit_get_spellbook(u); if (book) { - quicklist *ql = book->spells; + selist *ql = book->spells; int qi, header, maxlevel = effskill(u, SK_MAGIC, 0); int result = _snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u)); if (wrptr(&bufp, &size, result) != 0) { WARN_STATIC_BUFFER(); } - for (header = 0, qi = 0; ql; ql_advance(&ql, &qi, 1)) { - spellbook_entry * sbe = (spellbook_entry *)ql_get(ql, qi); + for (header = 0, qi = 0; ql; selist_advance(&ql, &qi, 1)) { + spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= maxlevel) { int result = 0; if (!header) { @@ -973,8 +973,7 @@ int stealth_modifier(seen_mode mode) } } -void transfer_seen(quicklist ** dst, quicklist ** src) -{ +static void transfer_seen(selist ** dst, selist ** src) { assert(!*dst); *dst = *src; *src = NULL; @@ -988,7 +987,7 @@ int cmp_faction(const void *lhs, const void *rhs) { return -1; } -static void add_seen_faction_i(struct quicklist **flist, faction *f) { +static void add_seen_faction_i(struct selist **flist, faction *f) { selist_set_insert(flist, f, cmp_faction); } @@ -998,7 +997,7 @@ void add_seen_faction(faction *self, faction *seen) { typedef struct address_data { faction *f, *lastf; - quicklist **flist; + selist **flist; int stealthmod; } address_data; @@ -1020,7 +1019,7 @@ static void cb_add_address(region *r, unit *ut, void *cbdata) { } } -static void add_travelthru_addresses(region *r, faction *f, quicklist **flist, int stealthmod) { +static void add_travelthru_addresses(region *r, faction *f, selist **flist, int stealthmod) { // for each traveling unit: add the faction of any unit is can see address_data cbdata = { 0 }; cbdata.f = f; @@ -1034,18 +1033,18 @@ static void get_addresses(report_context * ctx) /* "TODO: travelthru" */ region *r; const faction *lastf = NULL; - quicklist *flist = 0; + selist *flist = 0; transfer_seen(&flist, &ctx->f->seen_factions); ctx->f->seen_factions = NULL; /* do not delete it twice */ - ql_push(&flist, ctx->f); + selist_push(&flist, ctx->f); if (f_get_alliance(ctx->f)) { - quicklist *ql = ctx->f->alliance->members; + selist *ql = ctx->f->alliance->members; int qi; - for (qi = 0; ql; ql_advance(&ql, &qi, 1)) { - add_seen_faction_i(&flist, (faction *)ql_get(ql, qi)); + for (qi = 0; ql; selist_advance(&ql, &qi, 1)) { + add_seen_faction_i(&flist, (faction *)selist_get(ql, qi)); } } @@ -1130,31 +1129,31 @@ void reports_done(void) { } } -static quicklist *get_regions_distance(region * root, int radius) +static selist *get_regions_distance(region * root, int radius) { - quicklist *ql, *rlist = NULL; + selist *ql, *rlist = NULL; int qi = 0; - ql_push(&rlist, root); + selist_push(&rlist, root); fset(root, RF_MARK); ql = rlist; while (ql) { - region *r = (region *)ql_get(ql, qi); + region *r = (region *)selist_get(ql, qi); region * next[MAXDIRECTIONS]; int d; get_neighbours(r, next); for (d = 0; d != MAXDIRECTIONS; ++d) { if (next[d] && !fval(next[d], RF_MARK) && distance(next[d], root) <= radius) { - ql_push(&rlist, next[d]); + selist_push(&rlist, next[d]); fset(next[d], RF_MARK); } } - ql_advance(&ql, &qi, 1); + selist_advance(&ql, &qi, 1); } - for (ql = rlist, qi = 0; ql; ql_advance(&ql, &qi, 1)) { - region *r = (region *)ql_get(ql, qi); + for (ql = rlist, qi = 0; ql; selist_advance(&ql, &qi, 1)) { + region *r = (region *)selist_get(ql, qi); freset(r, RF_MARK); } return rlist; @@ -1190,16 +1189,16 @@ static void add_seen_nb(faction *f, region *r, seen_mode mode) { */ static void prepare_lighthouse(faction *f, region *r, int range) { - quicklist *ql, *rlist = get_regions_distance(r, range); + selist *ql, *rlist = get_regions_distance(r, range); int qi; - for (ql = rlist, qi = 0; ql; ql_advance(&ql, &qi, 1)) { - region *rl = (region *)ql_get(ql, qi); + for (ql = rlist, qi = 0; ql; selist_advance(&ql, &qi, 1)) { + region *rl = (region *)selist_get(ql, qi); if (!fval(rl->terrain, FORBIDDEN_REGION)) { add_seen_nb(f, rl, seen_lighthouse); } } - ql_free(rlist); + selist_free(rlist); } void reorder_units(region * r) @@ -1393,7 +1392,7 @@ void prepare_report(report_context *ctx, faction *f) void finish_reports(report_context *ctx) { region *r; - ql_free(ctx->addresses); + selist_free(ctx->addresses); for (r = ctx->first; r != ctx->last; r = r->next) { r->seen.mode = seen_none; } diff --git a/src/reports.h b/src/reports.h index e5fd976e3..d69b9a88b 100644 --- a/src/reports.h +++ b/src/reports.h @@ -25,12 +25,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -struct stream; -struct seen_region; #ifdef __cplusplus extern "C" { #endif + struct selist; + struct stream; + struct seen_region; + /* Alter, ab dem der Score angezeigt werden soll: */ #define DISPLAYSCORE 12 /* Breite einer Reportzeile: */ @@ -71,7 +73,7 @@ extern "C" { typedef struct report_context { struct faction *f; - struct quicklist *addresses; + struct selist *addresses; struct region *first, *last; void *userdata; time_t report_time; diff --git a/src/reports.test.c b/src/reports.test.c index c9fe39c19..1794f1cff 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -108,14 +108,14 @@ static void test_seen_faction(CuTest *tc) { f1 = test_create_faction(rc); f2 = test_create_faction(rc); add_seen_faction(f1, f2); - CuAssertPtrEquals(tc, f2, ql_get(f1->seen_factions, 0)); - CuAssertIntEquals(tc, 1, ql_length(f1->seen_factions)); + CuAssertPtrEquals(tc, f2, selist_get(f1->seen_factions, 0)); + CuAssertIntEquals(tc, 1, selist_length(f1->seen_factions)); add_seen_faction(f1, f2); - CuAssertIntEquals(tc, 1, ql_length(f1->seen_factions)); + CuAssertIntEquals(tc, 1, selist_length(f1->seen_factions)); add_seen_faction(f1, f1); - CuAssertIntEquals(tc, 2, ql_length(f1->seen_factions)); - f2 = (faction *)ql_get(f1->seen_factions, 1); - f1 = (faction *)ql_get(f1->seen_factions, 0); + CuAssertIntEquals(tc, 2, selist_length(f1->seen_factions)); + f2 = (faction *)selist_get(f1->seen_factions, 1); + f1 = (faction *)selist_get(f1->seen_factions, 0); CuAssertTrue(tc, f1->no < f2->no); test_cleanup(); } diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index da7e7085a..10f1711ef 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -38,7 +38,7 @@ #include #include -#include +#include /* libc includes */ #include @@ -295,15 +295,15 @@ int sp_stun(struct castorder * co) /** randomly shuffle an array * for correctness, see Donald E. Knuth, The Art of Computer Programming */ -static void scramble_fighters(quicklist * ql) +static void scramble_fighters(selist * ql) { - int qi, qlen = ql_length(ql); + int qi, qlen = selist_length(ql); for (qi = 0; qi != qlen; ++qi) { int qj = qi + (rng_int() % (qlen - qi)); - void *a = ql_get(ql, qi); - void *b = ql_replace(ql, qj, a); - ql_replace(ql, qi, b); + void *a = selist_get(ql, qi); + void *b = selist_replace(ql, qj, a); + selist_replace(ql, qi, b); } } @@ -314,7 +314,7 @@ int sp_combatrosthauch(struct castorder * co) int level = co->level; double power = co->force; battle *b = fi->side->battle; - quicklist *ql, *fgs; + selist *ql, *fgs; int force = lovar(power * 15); int qi, k = 0; @@ -329,8 +329,8 @@ int sp_combatrosthauch(struct castorder * co) fgs = fighters(b, fi->side, FIGHT_ROW, BEHIND_ROW - 1, FS_ENEMY); scramble_fighters(fgs); - for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) { - fighter *df = (fighter *)ql_get(ql, qi); + for (qi = 0, ql = fgs; ql; selist_advance(&ql, &qi, 1)) { + fighter *df = (fighter *)selist_get(ql, qi); if (df->alive == 0) continue; @@ -378,7 +378,7 @@ int sp_combatrosthauch(struct castorder * co) } } } - ql_free(fgs); + selist_free(fgs); if (k == 0) { /* keine Waffen mehr da, die zerst�rt werden k�nnten */ @@ -720,7 +720,7 @@ int sp_immolation(struct castorder * co) troop at; int force, qi, killed = 0; const char *damage; - quicklist *fgs, *ql; + selist *fgs, *ql; message *m; /* 2d4 HP */ @@ -740,8 +740,8 @@ int sp_immolation(struct castorder * co) at.index = 0; fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY); - for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) { - fighter *df = (fighter *)ql_get(ql, qi); + for (qi = 0, ql = fgs; ql; selist_advance(&ql, &qi, 1)) { + fighter *df = (fighter *)selist_get(ql, qi); int n = df->alive - df->removed; troop dt; @@ -755,7 +755,7 @@ int sp_immolation(struct castorder * co) if (force == 0) break; } - ql_free(fgs); + selist_free(fgs); m = msg_message("battle::combatspell", "mage spell killed", fi->unit, sp, @@ -987,7 +987,7 @@ int sp_chaosrow(struct castorder * co) const spell * sp = co->sp; battle *b = fi->side->battle; unit *mage = fi->unit; - quicklist *fgs, *ql; + selist *fgs, *ql; message *m; const char *mtype; int qi, k = 0; @@ -1007,8 +1007,8 @@ int sp_chaosrow(struct castorder * co) fgs = fighters(b, fi->side, FIGHT_ROW, NUMROWS, FS_ENEMY); scramble_fighters(fgs); - for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) { - fighter *df = (fighter *)ql_get(ql, qi); + for (qi = 0, ql = fgs; ql; selist_advance(&ql, &qi, 1)) { + fighter *df = (fighter *)selist_get(ql, qi); int n = df->unit->number; if (df->alive == 0) @@ -1052,7 +1052,7 @@ int sp_chaosrow(struct castorder * co) } power = _max(0, power - n); } - ql_free(fgs); + selist_free(fgs); if (sp->id == SPL_CHAOSROW) { mtype = (k > 0) ? "sp_chaosrow_effect_1" : "sp_chaosrow_effect_0"; @@ -1077,7 +1077,7 @@ int sp_flee(struct castorder * co) const spell * sp = co->sp; battle *b = fi->side->battle; unit *mage = fi->unit; - quicklist *fgs, *ql; + selist *fgs, *ql; int force, n, qi; int panik = 0; message *msg; @@ -1106,8 +1106,8 @@ int sp_flee(struct castorder * co) fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY); scramble_fighters(fgs); - for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) { - fighter *df = (fighter *)ql_get(ql, qi); + for (qi = 0, ql = fgs; ql; selist_advance(&ql, &qi, 1)) { + fighter *df = (fighter *)selist_get(ql, qi); for (n = 0; n != df->alive; ++n) { if (force < 0) @@ -1128,7 +1128,7 @@ int sp_flee(struct castorder * co) } } } - ql_free(fgs); + selist_free(fgs); msg = msg_message("sp_flee_effect_1", "mage spell amount", mage, sp, panik); message_all(b, msg); @@ -1457,7 +1457,7 @@ static void do_meffect(fighter * af, int typ, int effect, int duration) { battle *b = af->side->battle; meffect *me = (meffect *)malloc(sizeof(struct meffect)); - ql_push(&b->meffects, me); + selist_push(&b->meffects, me); me->magician = af; me->typ = typ; me->effect = effect; @@ -1654,13 +1654,13 @@ int sp_keeploot(struct castorder * co) return level; } -static int heal_fighters(quicklist * fgs, int *power, bool heal_monsters) +static int heal_fighters(selist * fgs, int *power, bool heal_monsters) { int healhp = *power, healed = 0, qi; - quicklist *ql; + selist *ql; - for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) { - fighter *df = (fighter *)ql_get(ql, qi); + for (qi = 0, ql = fgs; ql; selist_advance(&ql, &qi, 1)) { + fighter *df = (fighter *)selist_get(ql, qi); if (healhp <= 0) break; @@ -1705,7 +1705,7 @@ int sp_healing(struct castorder * co) unit *mage = fi->unit; int j = 0; int healhp = (int)power * 200; - quicklist *fgs; + selist *fgs; message *msg; bool use_item = has_ao_healing(mage); @@ -1723,7 +1723,7 @@ int sp_healing(struct castorder * co) scramble_fighters(fgs); j += heal_fighters(fgs, &healhp, false); j += heal_fighters(fgs, &healhp, true); - ql_free(fgs); + selist_free(fgs); if (j <= 0) { level = j; @@ -1750,7 +1750,7 @@ int sp_undeadhero(struct castorder * co) battle *b = fi->side->battle; unit *mage = fi->unit; region *r = b->region; - quicklist *fgs, *ql; + selist *fgs, *ql; int qi, n, undead = 0; message *msg; int force = (int)get_force(power, 0); @@ -1760,8 +1760,8 @@ int sp_undeadhero(struct castorder * co) fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY | FS_HELP); scramble_fighters(fgs); - for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) { - fighter *df = (fighter *)ql_get(ql, qi); + for (qi = 0, ql = fgs; ql; selist_advance(&ql, &qi, 1)) { + fighter *df = (fighter *)selist_get(ql, qi); unit *du = df->unit; if (force <= 0) @@ -1832,7 +1832,7 @@ int sp_undeadhero(struct castorder * co) } } } - ql_free(fgs); + selist_free(fgs); level = _min(level, undead); if (undead == 0) { diff --git a/src/sqlite.c b/src/sqlite.c index 99c72d9ec..6acaf4116 100644 --- a/src/sqlite.c +++ b/src/sqlite.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -72,10 +72,10 @@ typedef struct db_faction { char *name; } db_faction; -static struct quicklist * +static struct selist * read_factions(sqlite3 * db, int game_id) { int res; - quicklist *result = 0; + selist *result = 0; const char * sql = "SELECT f.id, fd.code, fd.name, fd.email FROM faction f" " LEFT OUTER JOIN faction_data fd" @@ -97,7 +97,7 @@ read_factions(sqlite3 * db, int game_id) { if (text) dbf->name = _strdup(text); text = (const char *)sqlite3_column_text(stmt, 3); if (text) dbf->email = _strdup(text); - ql_push(&result, dbf); + selist_push(&result, dbf); res = sqlite3_step(stmt); } sqlite3_finalize(stmt); @@ -134,7 +134,7 @@ static void update_faction(sqlite3 *db, const faction *f) { } int db_update_factions(sqlite3 * db, bool force, int game_id) { - quicklist *ql = read_factions(db, game_id); + selist *ql = read_factions(db, game_id); faction *f; if (!ql) return SQLITE_OK; sqlite3_exec(db, "BEGIN", 0, 0, 0); @@ -142,7 +142,7 @@ int db_update_factions(sqlite3 * db, bool force, int game_id) { bool update = force; db_faction *dbf = 0; #ifdef SELIST_TODO - ql_iter it = qli_init(&ql); + selist_iter it = qli_init(&ql); while (qli_more(it)) { db_faction *df = (db_faction*)qli_next(&it); if (f->no == df->no || strcmp(f->email, df->email) == 0 || strcmp(f->name, df->name) == 0) { @@ -178,12 +178,12 @@ int db_update_factions(sqlite3 * db, bool force, int game_id) { int db_update_scores(sqlite3 * db, bool force) { /* - const char *sql_ins = + const char *sselist_ins = "INSERT OR FAIL INTO score (value,faction_id,turn) VALUES (?,?,?)"; - sqlite3_stmt *stmt_ins = stmt_cache_get(db, sql_ins); - const char *sql_upd = + sqlite3_stmt *stmt_ins = stmt_cache_get(db, sselist_ins); + const char *sselist_upd = "UPDATE score set value=? WHERE faction_id=? AND turn=?"; - sqlite3_stmt *stmt_upd = stmt_cache_get(db, sql_upd); + sqlite3_stmt *stmt_upd = stmt_cache_get(db, sselist_upd); faction *f; sqlite3_exec(db, "BEGIN", 0, 0, 0); for (f = factions; f; f = f->next) { diff --git a/src/travelthru.c b/src/travelthru.c index 04ca6cee5..a546c976c 100644 --- a/src/travelthru.c +++ b/src/travelthru.c @@ -33,14 +33,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#include +#include #include #include static void travel_done(attrib *a) { - quicklist *ql = (quicklist *)a->data.v; - ql_free(ql); + selist *ql = (selist *)a->data.v; + selist_free(ql); } /*********************/ @@ -67,7 +67,7 @@ void travelthru_add(region * r, unit * u) region *next[MAXDIRECTIONS]; int d; attrib *a; - quicklist *ql; + selist *ql; assert(r); assert(u); @@ -76,10 +76,10 @@ void travelthru_add(region * r, unit * u) if (!a) { a = a_add(&r->attribs, a_new(&at_travelunit)); } - ql = (quicklist *)a->data.v; + ql = (selist *)a->data.v; fset(r, RF_TRAVELUNIT); - ql_push(&ql, u); + selist_push(&ql, u); a->data.v = ql; /* the first and last region of the faction gets reset, because travelthrough @@ -122,7 +122,7 @@ void travelthru_map(region * r, void(*cb)(region *, struct unit *, void *), void cbdata.r = r; a = a_find(r->attribs, &at_travelunit); if (a) { - quicklist *ql = (quicklist *)a->data.v; + selist *ql = (selist *)a->data.v; selist_foreach_ex(ql, cb_map, &cbdata); } } diff --git a/src/util/message.c b/src/util/message.c index 46bfec969..f76409e53 100644 --- a/src/util/message.c +++ b/src/util/message.c @@ -16,7 +16,7 @@ #include "strings.h" #include "log.h" -#include "quicklist.h" +#include "selist.h" /* libc includes */ #include @@ -160,7 +160,7 @@ message *msg_create(const struct message_type *mtype, variant args[]) } #define MT_MAXHASH 1021 -static quicklist *messagetypes[MT_MAXHASH]; +static selist *messagetypes[MT_MAXHASH]; static void mt_free(void *val) { message_type *mtype = (message_type *)val; @@ -177,9 +177,9 @@ static void mt_free(void *val) { void mt_clear(void) { int i; for (i = 0; i != MT_MAXHASH; ++i) { - quicklist *ql = messagetypes[i]; - ql_foreach(ql, mt_free); - ql_free(ql); + selist *ql = messagetypes[i]; + selist_foreach(ql, mt_free); + selist_free(ql); messagetypes[i] = 0; } } @@ -187,11 +187,11 @@ void mt_clear(void) { const message_type *mt_find(const char *name) { unsigned int hash = hashstring(name) % MT_MAXHASH; - quicklist *ql = messagetypes[hash]; + selist *ql = messagetypes[hash]; int qi; - for (qi = 0; ql; ql_advance(&ql, &qi, 1)) { - message_type *data = (message_type *)ql_get(ql, qi); + for (qi = 0; ql; selist_advance(&ql, &qi, 1)) { + message_type *data = (message_type *)selist_get(ql, qi); if (strcmp(data->name, name) == 0) { return data; } @@ -213,7 +213,7 @@ static unsigned int mt_id(const message_type * mtype) const message_type *mt_register(message_type * type) { unsigned int hash = hashstring(type->name) % MT_MAXHASH; - quicklist **qlp = messagetypes + hash; + selist **qlp = messagetypes + hash; if (selist_set_insert(qlp, type, NULL)) { type->key = mt_id(type); diff --git a/src/wormhole.c b/src/wormhole.c index 6a115a9f7..dd105b302 100644 --- a/src/wormhole.c +++ b/src/wormhole.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include @@ -155,8 +155,8 @@ make_wormhole(const building_type * bt_wormhole, region * r1, region * r2) #define WORMHOLE_CHANCE 10000 -static void select_wormhole_regions(quicklist **rlistp, int *countp) { - quicklist *rlist = 0; +static void select_wormhole_regions(selist **rlistp, int *countp) { + selist *rlist = 0; region *r = regions; int count = 0; @@ -170,7 +170,7 @@ static void select_wormhole_regions(quicklist **rlistp, int *countp) { } if (r == NULL) break; - ql_push(&rlist, r); + selist_push(&rlist, r); ++count; r = r->next; } @@ -179,12 +179,12 @@ static void select_wormhole_regions(quicklist **rlistp, int *countp) { *rlistp = rlist; } -void sort_wormhole_regions(quicklist *rlist, region **match, int count) { - quicklist *ql; +void sort_wormhole_regions(selist *rlist, region **match, int count) { + selist *ql; int qi, i = 0; - for (ql = rlist, qi = 0; i != count; ql_advance(&ql, &qi, 1)) { - match[i++] = (region *)ql_get(ql, qi); + for (ql = rlist, qi = 0; i != count; selist_advance(&ql, &qi, 1)) { + match[i++] = (region *)selist_get(ql, qi); } qsort(match, count, sizeof(region *), cmp_age); } @@ -200,7 +200,7 @@ void make_wormholes(region **match, int count, const building_type *bt_wormhole) void wormholes_update(void) { const building_type *bt_wormhole = bt_find("wormhole"); - quicklist *rlist = 0; + selist *rlist = 0; int count = 0; region **match; @@ -214,7 +214,7 @@ void wormholes_update(void) } match = (region **)malloc(sizeof(region *) * count); sort_wormhole_regions(rlist, match, count); - ql_free(rlist); + selist_free(rlist); make_wormholes(match, count, bt_wormhole); free(match); } diff --git a/src/wormhole.test.c b/src/wormhole.test.c index ec93c5b4c..4f3036200 100644 --- a/src/wormhole.test.c +++ b/src/wormhole.test.c @@ -10,11 +10,11 @@ #include -#include +#include #include -void sort_wormhole_regions(quicklist *rlist, region **match, int count); +void sort_wormhole_regions(selist *rlist, region **match, int count); void make_wormholes(region **match, int count, const building_type *bt_wormhole); static void test_make_wormholes(CuTest *tc) { @@ -42,7 +42,7 @@ static void test_make_wormholes(CuTest *tc) { static void test_sort_wormhole_regions(CuTest *tc) { region *r1, *r2, *match[2]; terrain_type *t_plain; - quicklist *rlist = 0; + selist *rlist = 0; test_setup(); t_plain = test_create_terrain("plain", LAND_REGION); @@ -50,12 +50,12 @@ static void test_sort_wormhole_regions(CuTest *tc) { r2 = test_create_region(1, 0, t_plain); r1->age = 4; r2->age = 2; - ql_push(&rlist, r1); - ql_push(&rlist, r2); + selist_push(&rlist, r1); + selist_push(&rlist, r2); sort_wormhole_regions(rlist, match, 2); CuAssertPtrEquals(tc, r2, match[0]); CuAssertPtrEquals(tc, r1, match[1]); - ql_free(rlist); + selist_free(rlist); test_cleanup(); } From d42f1767ff67be1d7dec0000847ad708dc389d2f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 11 Dec 2016 21:21:50 +0100 Subject: [PATCH 375/675] add a test for teach-messages. vheck that they are generated for students and teachers. --- src/study.test.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/study.test.c b/src/study.test.c index 47976930d..54e32bf28 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -2,6 +2,7 @@ #include "study.h" +#include #include #include #include @@ -10,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -483,6 +485,7 @@ static void test_teach_one_to_many(CuTest *tc) { static void test_teach_many_to_one(CuTest *tc) { unit *u, *u1, *u2; + test_setup(); init_resources(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); @@ -505,6 +508,47 @@ static void test_teach_many_to_one(CuTest *tc) { test_cleanup(); } +static void test_teach_message(CuTest *tc) { + unit *u, *u1, *u2; + attrib *a; + ally *al; + teaching_info *teach; + + test_setup(); + init_resources(); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + scale_number(u, 20); + u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW"); + u1 = test_create_unit(test_create_faction(0), u->region); + set_level(u1, SK_CROSSBOW, TEACHDIFFERENCE); + u1->thisorder = create_order(K_TEACH, u->faction->locale, itoa36(u->no)); + u2 = test_create_unit(test_create_faction(0), u->region); + al = ally_add(&u->faction->allies, u2->faction); + al->status = HELP_GUARD; + set_level(u2, SK_CROSSBOW, TEACHDIFFERENCE); + u2->thisorder = create_order(K_TEACH, u->faction->locale, itoa36(u->no)); + CuAssertTrue(tc, !alliedunit(u, u1->faction, HELP_GUARD)); + CuAssertTrue(tc, alliedunit(u, u2->faction, HELP_GUARD)); + teach_cmd(u1, u1->thisorder); + teach_cmd(u2, u2->thisorder); + a = a_find(u->attribs, &at_learning); + CuAssertPtrNotNull(tc, a); + CuAssertPtrNotNull(tc, a->data.v); + teach = (teaching_info *)a->data.v; + CuAssertPtrNotNull(tc, teach->teachers); + CuAssertIntEquals(tc, 600, teach->value); + CuAssertPtrEquals(tc, u1, teach->teachers[0]); + CuAssertPtrEquals(tc, u2, teach->teachers[1]); + CuAssertPtrEquals(tc, NULL, teach->teachers[2]); + study_cmd(u, u->thisorder); + CuAssertPtrEquals(tc, NULL, test_find_messagetype(u1->faction->msgs, "teach_teacher")); + CuAssertPtrNotNull(tc, test_find_messagetype(u2->faction->msgs, "teach_teacher")); + CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "teach_student")); + a = a_find(u->attribs, &at_learning); + CuAssertPtrEquals(tc, NULL, a); + test_cleanup(); +} + static void test_teach_many_to_many(CuTest *tc) { unit *s1, *s2, *t1, *t2; region *r; @@ -554,6 +598,7 @@ CuSuite *get_study_suite(void) SUITE_ADD_TEST(suite, test_teach_one_to_many); SUITE_ADD_TEST(suite, test_teach_many_to_one); SUITE_ADD_TEST(suite, test_teach_many_to_many); + SUITE_ADD_TEST(suite, test_teach_message); SUITE_ADD_TEST(suite, test_teach_two_skills); SUITE_ADD_TEST(suite, test_learn_skill_single); SUITE_ADD_TEST(suite, test_learn_skill_multi); From 61f3585ad7ba9f1d91aaeb74e3c4b34def4debc7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 11 Dec 2016 21:29:07 +0100 Subject: [PATCH 376/675] unlimited teachers. quicklist replaces fixed array. --- src/study.c | 25 +++++++------------------ src/study.h | 4 ++-- src/study.test.c | 10 ++++++---- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/study.c b/src/study.c index 1dd4da8b8..f3372334a 100644 --- a/src/study.c +++ b/src/study.c @@ -53,6 +53,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include + /* libc includes */ #include #include @@ -216,24 +218,11 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk, n = _min(n, nteaching); if (n != 0) { - int index = 0; - if (teach == NULL) { a = a_add(&student->attribs, a_new(&at_learning)); teach = (teaching_info *)a->data.v; } - else { - while (teach->teachers[index] && index != MAXTEACHERS) - ++index; - } - if (index < MAXTEACHERS) - teach->teachers[index++] = teacher; - if (index < MAXTEACHERS) { - teach->teachers[index] = NULL; - } - else { - log_error("MAXTEACHERS=%d is too low for student %s, teacher %s", MAXTEACHERS, unitname(student), unitname(teacher)); - } + ql_push(&teach->teachers, teacher); teach->value += n; if (student->building && teacher->building == student->building) { @@ -717,7 +706,7 @@ int study_cmd(unit * u, order * ord) a = a_add(&u->attribs, a_new(&at_learning)); teach = (teaching_info *)a->data.v; assert(teach); - teach->teachers[0] = 0; + teach->teachers = NULL; } if (money > 0) { use_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT, money); @@ -766,9 +755,9 @@ int study_cmd(unit * u, order * ord) learn_skill(u, sk, days); if (a != NULL) { - int index = 0; - while (teach->teachers[index] && index != MAXTEACHERS) { - unit *teacher = teach->teachers[index++]; + ql_iter qli = qli_init(&teach->teachers); + while (qli_more(qli)) { + unit *teacher = (unit *)qli_next(&qli); if (teacher->faction != u->faction) { bool feedback = alliedunit(u, teacher->faction, HELP_GUARD); if (feedback) { diff --git a/src/study.h b/src/study.h index 20903583a..8067bc9bd 100644 --- a/src/study.h +++ b/src/study.h @@ -27,6 +27,7 @@ extern "C" { #endif struct unit; + struct quicklist; int teach_cmd(struct unit *u, struct order *ord); int study_cmd(struct unit *u, struct order *ord); @@ -45,10 +46,9 @@ extern "C" { void demon_skillchange(struct unit *u); -#define MAXTEACHERS 32 #define TEACHNUMBER 10 typedef struct teaching_info { - struct unit *teachers[MAXTEACHERS]; + struct quicklist *teachers; int value; } teaching_info; diff --git a/src/study.test.c b/src/study.test.c index 54e32bf28..4c1e5f171 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -18,9 +18,11 @@ #include #include +#include +#include + #include -#include #define MAXLOG 4 typedef struct log_entry { @@ -537,9 +539,9 @@ static void test_teach_message(CuTest *tc) { teach = (teaching_info *)a->data.v; CuAssertPtrNotNull(tc, teach->teachers); CuAssertIntEquals(tc, 600, teach->value); - CuAssertPtrEquals(tc, u1, teach->teachers[0]); - CuAssertPtrEquals(tc, u2, teach->teachers[1]); - CuAssertPtrEquals(tc, NULL, teach->teachers[2]); + CuAssertIntEquals(tc, 2, ql_length(teach->teachers)); + CuAssertPtrEquals(tc, u1, ql_get(teach->teachers, 0)); + CuAssertPtrEquals(tc, u2, ql_get(teach->teachers, 1)); study_cmd(u, u->thisorder); CuAssertPtrEquals(tc, NULL, test_find_messagetype(u1->faction->msgs, "teach_teacher")); CuAssertPtrNotNull(tc, test_find_messagetype(u2->faction->msgs, "teach_teacher")); From 70dfe20e6208f8c9d9b7feceb2128760ece8d09a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 11 Dec 2016 22:40:06 +0100 Subject: [PATCH 377/675] small edit (int->bool) --- src/guard.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/guard.c b/src/guard.c index ee26e467b..4b0c63e22 100644 --- a/src/guard.c +++ b/src/guard.c @@ -128,7 +128,7 @@ bool is_guard(const struct unit * u) unit *is_guarded(region * r, unit * u) { unit *u2; - int noguards = 1; + bool noguards = true; if (!fval(r, RF_GUARDED)) { return NULL; @@ -140,7 +140,7 @@ unit *is_guarded(region * r, unit * u) for (u2 = r->units; u2; u2 = u2->next) { if (is_guardian_r(u2)) { - noguards = 0; + noguards = false; if (is_guardian_u(u2, u)) { /* u2 is our guard. stop processing (we might have to go further next time) */ return u2; From 5cb67e1da09a016fe9a9bf994522248a94ecf658 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Dec 2016 07:29:43 +0100 Subject: [PATCH 378/675] start writing a test (WIP). --- src/move.c | 2 +- src/move.h | 2 ++ src/move.test.c | 26 +++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/move.c b/src/move.c index b6a908837..e6469cc4a 100644 --- a/src/move.c +++ b/src/move.c @@ -571,7 +571,7 @@ direction_t reldirection(const region * from, const region * to) return NODIRECTION; } -static void leave_trail(ship * sh, region * from, region_list * route) +void leave_trail(ship * sh, region * from, region_list * route) { region *r = from; diff --git a/src/move.h b/src/move.h index 6363fe2f9..14c040493 100644 --- a/src/move.h +++ b/src/move.h @@ -63,6 +63,8 @@ extern "C" { int enoughsailors(const struct ship *sh, int sumskill); bool canswim(struct unit *u); bool canfly(struct unit *u); + void leave_trail(struct ship *sh, struct region *from, + struct region_list *route); struct ship *move_ship(struct ship *sh, struct region *from, struct region *to, struct region_list *route); int walkingcapacity(const struct unit *u); diff --git a/src/move.test.c b/src/move.test.c index bc93ec124..bdd4a62a8 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -478,7 +478,7 @@ static void test_drifting_ships(CuTest *tc) { region *r1, *r2, *r3; terrain_type *t_ocean, *t_plain; ship_type *st_boat; - test_cleanup(); + test_setup(); t_ocean = test_create_terrain("ocean", SEA_REGION); t_plain = test_create_terrain("plain", LAND_REGION); r1 = test_create_region(0, 0, t_ocean); @@ -491,11 +491,35 @@ static void test_drifting_ships(CuTest *tc) { test_cleanup(); } +static void test_ship_leave_trail(CuTest *tc) { + ship *s1, *s2; + region *r1, *r2; + terrain_type *t_ocean; + ship_type *st_boat; + region_list *route = NULL; + + test_setup(); + t_ocean = test_create_terrain("ocean", SEA_REGION); + r1 = test_create_region(0, 0, t_ocean); + add_regionlist(&route, r2 = test_create_region(1, 0, t_ocean)); + add_regionlist(&route, test_create_region(2, 0, t_ocean)); + st_boat = test_create_shiptype("boat"); + s1 = test_create_ship(r1, st_boat); + s2 = test_create_ship(r1, st_boat); + leave_trail(s1, r1, route); + leave_trail(s2, r1, route); +// CuAssertPtrNotNull(tc, r1->attribs); + CuAssertPtrNotNull(tc, r2->attribs); + free_regionlist(route); + test_cleanup(); +} + CuSuite *get_move_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_walkingcapacity); SUITE_ADD_TEST(suite, test_ship_not_allowed_in_coast); + SUITE_ADD_TEST(suite, test_ship_leave_trail); SUITE_ADD_TEST(suite, test_ship_allowed_without_harbormaster); SUITE_ADD_TEST(suite, test_ship_blocked_by_harbormaster); SUITE_ADD_TEST(suite, test_ship_has_harbormaster_contact); From 13128be0aa6db3803081cd0f9e182febb67fb946 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Dec 2016 17:16:10 +0100 Subject: [PATCH 379/675] add a failing test for bug 2266 --- src/lighthouse.c | 2 +- src/lighthouse.h | 2 +- src/move.test.c | 13 ++++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/lighthouse.c b/src/lighthouse.c index d962b9b76..09c9b7d11 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -14,7 +14,7 @@ #include #include -const attrib_type at_lighthouse = { +attrib_type at_lighthouse = { "lighthouse" /* Rest ist NULL; tempor�res, nicht alterndes Attribut */ }; diff --git a/src/lighthouse.h b/src/lighthouse.h index 518b05b5a..3bf970bf1 100644 --- a/src/lighthouse.h +++ b/src/lighthouse.h @@ -29,7 +29,7 @@ extern "C" { struct building; struct attrib; - extern const struct attrib_type at_lighthouse; + extern struct attrib_type at_lighthouse; /* leuchtturm */ bool check_leuchtturm(struct region *r, struct faction *f); void update_lighthouse(struct building *lh); diff --git a/src/move.test.c b/src/move.test.c index bdd4a62a8..6a2a0e7db 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -3,6 +3,7 @@ #include "move.h" #include "keyword.h" +#include "lighthouse.h" #include #include @@ -501,15 +502,21 @@ static void test_ship_leave_trail(CuTest *tc) { test_setup(); t_ocean = test_create_terrain("ocean", SEA_REGION); r1 = test_create_region(0, 0, t_ocean); - add_regionlist(&route, r2 = test_create_region(1, 0, t_ocean)); add_regionlist(&route, test_create_region(2, 0, t_ocean)); + add_regionlist(&route, r2 = test_create_region(1, 0, t_ocean)); st_boat = test_create_shiptype("boat"); s1 = test_create_ship(r1, st_boat); s2 = test_create_ship(r1, st_boat); leave_trail(s1, r1, route); + a_add(&r1->attribs, a_new(&at_lighthouse)); leave_trail(s2, r1, route); -// CuAssertPtrNotNull(tc, r1->attribs); - CuAssertPtrNotNull(tc, r2->attribs); + a_add(&r2->attribs, a_new(&at_lighthouse)); + CuAssertPtrEquals(tc, &at_shiptrail, (void *)r1->attribs->type); + CuAssertPtrEquals(tc, &at_shiptrail, (void *)r1->attribs->next->type); + CuAssertPtrEquals(tc, &at_lighthouse, (void *)r1->attribs->next->next->type); + CuAssertPtrEquals(tc, &at_shiptrail, (void *)r2->attribs->type); + CuAssertPtrEquals(tc, &at_shiptrail, (void *)r2->attribs->next->type); + CuAssertPtrEquals(tc, &at_lighthouse, (void *)r2->attribs->next->next->type); free_regionlist(route); test_cleanup(); } From 129f6fb68af8651008bd14e542bff5774846561b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 16 Dec 2016 17:17:04 +0100 Subject: [PATCH 380/675] fix bug 2266 --- src/move.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/move.c b/src/move.c index e6469cc4a..f1b2311f1 100644 --- a/src/move.c +++ b/src/move.c @@ -595,7 +595,7 @@ void leave_trail(ship * sh, region * from, region_list * route) a = a->next; } - if (a == NULL) { + if (a == NULL || a->type != &at_shiptrail) { a = a_add(&(r->attribs), a_new(&at_shiptrail)); td = (traveldir *)a->data.v; td->no = sh->no; From f297d89958ed5c59a9b668320e9befc2765b1e26 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 23 Dec 2016 18:05:38 +0100 Subject: [PATCH 381/675] merge monster.c and monsters.c move RCF_DESERT handling to monsters.c --- src/CMakeLists.txt | 1 - src/battle.c | 2 +- src/bind_monsters.c | 1 - src/bindings.c | 2 +- src/chaos.c | 2 +- src/economy.c | 2 +- src/guard.c | 2 +- src/guard.test.c | 2 +- src/kernel/faction.test.c | 2 +- src/laws.c | 2 +- src/laws.test.c | 2 +- src/monster.c | 224 -------------------------------------- src/monster.h | 39 ------- src/monsters.c | 193 +++++++++++++++++++++++++++++++- src/monsters.h | 49 ++++++++- src/monsters.test.c | 1 - src/move.c | 2 +- src/races/zombies.c | 2 +- src/randenc.c | 19 +--- src/report.c | 2 +- src/spells.c | 2 +- src/study.c | 2 +- src/summary.c | 2 +- src/teleport.c | 2 +- src/upkeep.c | 2 +- 25 files changed, 249 insertions(+), 312 deletions(-) delete mode 100644 src/monster.c delete mode 100644 src/monster.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a3f81e1a2..39d290560 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -112,7 +112,6 @@ set (ERESSEA_SRC magic.c market.c morale.c - monster.c randenc.c renumber.c volcano.c diff --git a/src/battle.c b/src/battle.c index 28a08c6f3..9d2d09cc0 100644 --- a/src/battle.c +++ b/src/battle.c @@ -23,7 +23,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "chaos.h" #include "guard.h" #include "laws.h" -#include "monster.h" +#include "monsters.h" #include "move.h" #include "skill.h" diff --git a/src/bind_monsters.c b/src/bind_monsters.c index 54a9d0ba6..53a569311 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -1,6 +1,5 @@ #include #include "spells/shipcurse.h" -#include "monster.h" #include "monsters.h" #include diff --git a/src/bindings.c b/src/bindings.c index 53eafdcb4..13b562af6 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -54,7 +54,7 @@ without prior permission by the authors of Eressea. #include "summary.h" #include "teleport.h" #include "laws.h" -#include "monster.h" +#include "monsters.h" #include "market.h" #include diff --git a/src/chaos.c b/src/chaos.c index 942fb87bc..58cd7af73 100644 --- a/src/chaos.c +++ b/src/chaos.c @@ -19,7 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "chaos.h" -#include "monster.h" +#include "monsters.h" #include "move.h" #include diff --git a/src/economy.c b/src/economy.c index d3f6189fc..01954ff54 100644 --- a/src/economy.c +++ b/src/economy.c @@ -31,7 +31,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "spy.h" #include "study.h" #include "move.h" -#include "monster.h" +#include "monsters.h" #include "morale.h" #include "reports.h" #include "calendar.h" diff --git a/src/guard.c b/src/guard.c index 4b0c63e22..07640452c 100644 --- a/src/guard.c +++ b/src/guard.c @@ -21,7 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "guard.h" #include "laws.h" -#include "monster.h" +#include "monsters.h" #include #include diff --git a/src/guard.test.c b/src/guard.test.c index 60e5453c6..c5bffeab5 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -2,7 +2,7 @@ #include "guard.h" #include "laws.h" -#include "monster.h" +#include "monsters.h" #include #include diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 596c92907..3bfc36ca8 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -10,7 +10,7 @@ #include #include -#include "monster.h" +#include "monsters.h" #include #include #include diff --git a/src/laws.c b/src/laws.c index 5a68c72f0..d311f698e 100644 --- a/src/laws.c +++ b/src/laws.c @@ -29,7 +29,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "keyword.h" #include "market.h" #include "morale.h" -#include "monster.h" +#include "monsters.h" #include "move.h" #include "randenc.h" #include "renumber.h" diff --git a/src/laws.test.c b/src/laws.test.c index 69e9f5e04..1bec0e6b4 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -2,7 +2,7 @@ #include "laws.h" #include "battle.h" #include "guard.h" -#include "monster.h" +#include "monsters.h" #include #include diff --git a/src/monster.c b/src/monster.c deleted file mode 100644 index 301b1b132..000000000 --- a/src/monster.c +++ /dev/null @@ -1,224 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#include -#include -#include "monster.h" - -/* gamecode includes */ -#include "economy.h" -#include "give.h" -#include "move.h" - -/* attributes includes */ -#include -#include -#include - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* util includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* libc includes */ -#include -#include -#include - -#define MOVECHANCE 25 /* chance fuer bewegung */ - -#define MAXILLUSION_TEXTS 3 - -bool monster_is_waiting(const unit * u) -{ - int test = fval(u_race(u), RCF_ATTACK_MOVED) ? UFL_ISNEW : UFL_ISNEW | UFL_MOVED; - if (fval(u, test)) - return true; - return false; -} - -static void eaten_by_monster(unit * u) -{ - /* adjustment for smaller worlds */ - double multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0; - int n = 0; - int horse = -1; - const resource_type *rhorse = get_resourcetype(R_HORSE); - const race *rc = u_race(u); - attrib *a; - - a = a_find(rc->attribs, &at_scare); - if (a) { - n = rng_int() & a->data.i * u->number; - } else { - n = rng_int() % (u->number / 20 + 1); - horse = 0; - } - horse = horse ? i_get(u->items, rhorse->itype) : 0; - - n = (int)(n * multi); - if (n > 0) { - n = lovar(n); - n = _min(rpeasants(u->region), n); - - if (n > 0) { - deathcounts(u->region, n); - rsetpeasants(u->region, rpeasants(u->region) - n); - ADDMSG(&u->region->msgs, msg_message("eatpeasants", "unit amount", u, n)); - } - } - if (horse > 0) { - i_change(&u->items, rhorse->itype, -horse); - ADDMSG(&u->region->msgs, msg_message("eathorse", "unit amount", u, horse)); - } -} - -static void absorbed_by_monster(unit * u) -{ - int n = rng_int() % (u->number / 20 + 1); - - if (n > 0) { - n = lovar(n); - n = _min(rpeasants(u->region), n); - if (n > 0) { - rsetpeasants(u->region, rpeasants(u->region) - n); - scale_number(u, u->number + n); - ADDMSG(&u->region->msgs, msg_message("absorbpeasants", - "unit race amount", u, u_race(u), n)); - } - } -} - -static int scareaway(region * r, int anzahl) -{ - int n, p, diff = 0, emigrants[MAXDIRECTIONS]; - direction_t d; - - 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. - * emigrants[] ist local, weil r->newpeasants durch die Monster - * vielleicht schon hochgezaehlt worden ist. */ - - for (d = 0; d != MAXDIRECTIONS; d++) - emigrants[d] = 0; - - p = rpeasants(r); - assert(p >= 0 && anzahl >= 0); - for (n = _min(p, anzahl); n; n--) { - direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS); - region *rc = rconnect(r, dir); - - if (rc && fval(rc->terrain, LAND_REGION)) { - ++diff; - rc->land->newpeasants++; - emigrants[dir]++; - } - } - rsetpeasants(r, p - diff); - assert(p >= diff); - return diff; -} - -static void scared_by_monster(unit * u) -{ - int n; - const race *rc = u_race(u); - attrib *a; - a = a_find(rc->attribs, &at_scare); - if (a) { - n = rng_int() & a->data.i * u->number; - } else { - n = rng_int() % (u->number / 4 + 1); - } - if (n > 0) { - n = lovar(n); - n = _min(rpeasants(u->region), n); - if (n > 0) { - n = scareaway(u->region, n); - if (n > 0) { - ADDMSG(&u->region->msgs, msg_message("fleescared", - "amount unit", n, u)); - } - } - } -} - -void monster_kills_peasants(unit * u) -{ - if (!monster_is_waiting(u)) { - if (u_race(u)->flags & RCF_SCAREPEASANTS) { - scared_by_monster(u); - } - if (u_race(u)->flags & RCF_KILLPEASANTS) { - eaten_by_monster(u); - } - if (u_race(u)->flags & RCF_ABSORBPEASANTS) { - absorbed_by_monster(u); - } - } -} - -faction *get_or_create_monsters(void) -{ - faction *f = findfaction(MONSTER_ID); - if (!f) { - const race *rc = rc_get_or_create("dragon"); - const char *email = config_get("monster.email"); - f = addfaction(email ? email : "noreply@eressea.de", NULL, rc, default_locale, 0); - renumber_faction(f, MONSTER_ID); - faction_setname(f, "Monster"); - fset(f, FFL_NPC | FFL_NOIDLEOUT); - } - return f; -} - -faction *get_monsters(void) { - return get_or_create_monsters(); -} - -void make_zombie(unit * u) -{ - u_setfaction(u, get_monsters()); - scale_number(u, 1); - u->hp = unit_max_hp(u) * u->number; - u_setrace(u, get_race(RC_ZOMBIE)); - u->irace = NULL; -} diff --git a/src/monster.h b/src/monster.h deleted file mode 100644 index 0f936b17d..000000000 --- a/src/monster.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef H_GC_MONSTER -#define H_GC_MONSTER -#ifdef __cplusplus -extern "C" { -#endif - - struct unit; - - void monster_kills_peasants(struct unit *u); - bool monster_is_waiting(const struct unit *u); - struct faction *get_monsters(void); - struct faction *get_or_create_monsters(void); - void make_zombie(struct unit * u); - -#define MONSTER_ID 666 -#define is_monsters(f) ((f->flags & FFL_NPC) && f==get_monsters()) - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/monsters.c b/src/monsters.c index 6e6630fe8..ea80b9740 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -26,12 +26,12 @@ #include "chaos.h" #include "give.h" #include "guard.h" -#include "monster.h" #include "laws.h" #include "keyword.h" #include "study.h" /* attributes includes */ +#include #include #include @@ -72,8 +72,8 @@ #include #include -#define MOVECHANCE .25 /* chance fuer bewegung */ -#define DRAGON_RANGE 20 /* Max. Distanz zum nchsten Drachenziel */ +#define DRAGON_RANGE 20 /* max. Distanz zum nchsten Drachenziel */ +#define MOVE_PERCENT 25 /* chance fuer bewegung */ #define MAXILLUSION_TEXTS 3 static double attack_chance; /* rules.monsters.attack_chance, or default 0.4 */ @@ -85,12 +85,12 @@ static void give_peasants(unit *u, const item_type *itype, int reduce) { } static double random_move_chance(void) { - static double rule; + static int rule; static int config; if (config_changed(&config)) { - rule = config_get_flt("rules.monsters.random_move_chance", MOVECHANCE); + rule = config_get_flt("rules.monsters.random_move_percent", MOVE_PERCENT); } - return rule; + return rule * 0.01; } static void reduce_weight(unit * u) @@ -165,6 +165,29 @@ static order *monster_attack(unit * u, const unit * target) return create_order(K_ATTACK, u->faction->locale, "%i", target->no); } +void monsters_desert(struct faction *monsters) +{ + region *r; + + assert(monsters!=NULL); + for (r = regions; r; r = r->next) { + unit *u; + + for (u = r->units; u; u = u->next) { + if (u->faction!=monsters + && (u_race(u)->flags & RCF_DESERT)) { + if (fval(u, UFL_ISNEW)) + continue; + if (rng_int() % 100 < 5) { + ADDMSG(&u->faction->msgs, msg_message("desertion", + "unit region", u, r)); + u_setfaction(u, monsters); + } + } + } + } +} + int monster_attacks(unit * monster, bool respect_buildings, bool rich_only) { region *r = monster->region; @@ -973,3 +996,161 @@ void spawn_undead(void) } } } + +bool monster_is_waiting(const unit * u) +{ + int test = fval(u_race(u), RCF_ATTACK_MOVED) ? UFL_ISNEW : UFL_ISNEW | UFL_MOVED; + if (fval(u, test)) + return true; + return false; +} + +static void eaten_by_monster(unit * u) +{ + /* adjustment for smaller worlds */ + double multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0; + int n = 0; + int horse = -1; + const resource_type *rhorse = get_resourcetype(R_HORSE); + const race *rc = u_race(u); + attrib *a; + + a = a_find(rc->attribs, &at_scare); + if (a) { + n = rng_int() & a->data.i * u->number; + } else { + n = rng_int() % (u->number / 20 + 1); + horse = 0; + } + horse = horse ? i_get(u->items, rhorse->itype) : 0; + + n = (int)(n * multi); + if (n > 0) { + n = lovar(n); + n = _min(rpeasants(u->region), n); + + if (n > 0) { + deathcounts(u->region, n); + rsetpeasants(u->region, rpeasants(u->region) - n); + ADDMSG(&u->region->msgs, msg_message("eatpeasants", "unit amount", u, n)); + } + } + if (horse > 0) { + i_change(&u->items, rhorse->itype, -horse); + ADDMSG(&u->region->msgs, msg_message("eathorse", "unit amount", u, horse)); + } +} + +static void absorbed_by_monster(unit * u) +{ + int n = rng_int() % (u->number / 20 + 1); + + if (n > 0) { + n = lovar(n); + n = _min(rpeasants(u->region), n); + if (n > 0) { + rsetpeasants(u->region, rpeasants(u->region) - n); + scale_number(u, u->number + n); + ADDMSG(&u->region->msgs, msg_message("absorbpeasants", + "unit race amount", u, u_race(u), n)); + } + } +} + +static int scareaway(region * r, int anzahl) +{ + int n, p, diff = 0, emigrants[MAXDIRECTIONS]; + direction_t d; + + 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. + * emigrants[] ist local, weil r->newpeasants durch die Monster + * vielleicht schon hochgezaehlt worden ist. */ + + for (d = 0; d != MAXDIRECTIONS; d++) + emigrants[d] = 0; + + p = rpeasants(r); + assert(p >= 0 && anzahl >= 0); + for (n = _min(p, anzahl); n; n--) { + direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS); + region *rc = rconnect(r, dir); + + if (rc && fval(rc->terrain, LAND_REGION)) { + ++diff; + rc->land->newpeasants++; + emigrants[dir]++; + } + } + rsetpeasants(r, p - diff); + assert(p >= diff); + return diff; +} + +static void scared_by_monster(unit * u) +{ + int n; + const race *rc = u_race(u); + attrib *a; + a = a_find(rc->attribs, &at_scare); + if (a) { + n = rng_int() & a->data.i * u->number; + } else { + n = rng_int() % (u->number / 4 + 1); + } + if (n > 0) { + n = lovar(n); + n = _min(rpeasants(u->region), n); + if (n > 0) { + n = scareaway(u->region, n); + if (n > 0) { + ADDMSG(&u->region->msgs, msg_message("fleescared", + "amount unit", n, u)); + } + } + } +} + +void monster_kills_peasants(unit * u) +{ + if (!monster_is_waiting(u)) { + if (u_race(u)->flags & RCF_SCAREPEASANTS) { + scared_by_monster(u); + } + if (u_race(u)->flags & RCF_KILLPEASANTS) { + eaten_by_monster(u); + } + if (u_race(u)->flags & RCF_ABSORBPEASANTS) { + absorbed_by_monster(u); + } + } +} + +faction *get_or_create_monsters(void) +{ + faction *f = findfaction(MONSTER_ID); + if (!f) { + const race *rc = rc_get_or_create("dragon"); + const char *email = config_get("monster.email"); + f = addfaction(email ? email : "noreply@eressea.de", NULL, rc, default_locale, 0); + renumber_faction(f, MONSTER_ID); + faction_setname(f, "Monster"); + fset(f, FFL_NPC | FFL_NOIDLEOUT); + } + return f; +} + +faction *get_monsters(void) { + return get_or_create_monsters(); +} + +void make_zombie(unit * u) +{ + u_setfaction(u, get_monsters()); + scale_number(u, 1); + u->hp = unit_max_hp(u) * u->number; + u_setrace(u, get_race(RC_ZOMBIE)); + u->irace = NULL; +} diff --git a/src/monsters.h b/src/monsters.h index 02e41c0a4..52e9ebf37 100644 --- a/src/monsters.h +++ b/src/monsters.h @@ -1,8 +1,45 @@ -#pragma once +/* +Copyright (c) 1998-2015, Enno Rehling +Katja Zedel -struct unit; -struct region; -struct faction; +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. -struct unit *spawn_seaserpent(struct region *r, struct faction *f); -void spawn_dragons(void); +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +**/ + +#ifndef H_GC_MONSTER +#define H_GC_MONSTER +#ifdef __cplusplus +extern "C" { +#endif + + struct unit; + struct region; + struct faction; + + struct unit *spawn_seaserpent(struct region *r, struct faction *f); + void spawn_dragons(void); + void monsters_desert(struct faction *monsters); + + void monster_kills_peasants(struct unit *u); + bool monster_is_waiting(const struct unit *u); + struct faction *get_monsters(void); + struct faction *get_or_create_monsters(void); + void make_zombie(struct unit * u); + +#define MONSTER_ID 666 +#define is_monsters(f) ((f->flags & FFL_NPC) && f==get_monsters()) + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/monsters.test.c b/src/monsters.test.c index ca793891c..e0eaa3ccc 100644 --- a/src/monsters.test.c +++ b/src/monsters.test.c @@ -10,7 +10,6 @@ #include #include -#include "monster.h" #include "monsters.h" #include "guard.h" #include "reports.h" diff --git a/src/move.c b/src/move.c index f1b2311f1..126557d58 100644 --- a/src/move.c +++ b/src/move.c @@ -27,7 +27,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "alchemy.h" #include "travelthru.h" #include "vortex.h" -#include "monster.h" +#include "monsters.h" #include "lighthouse.h" #include "piracy.h" diff --git a/src/races/zombies.c b/src/races/zombies.c index d7f871dac..3e9303b38 100644 --- a/src/races/zombies.c +++ b/src/races/zombies.c @@ -24,7 +24,7 @@ /* util iclude */ #include -#include "monster.h" +#include "monsters.h" /* libc includes */ #include diff --git a/src/randenc.c b/src/randenc.c index a3c5ce303..536210b1f 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -22,7 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "volcano.h" #include "economy.h" -#include "monster.h" +#include "monsters.h" #include "move.h" #include "chaos.h" #include "study.h" @@ -826,22 +826,7 @@ void randomevents(void) /* monster-einheiten desertieren */ if (monsters) { - for (r = regions; r; r = r->next) { - unit *u; - - for (u = r->units; u; u = u->next) { - if (u->faction && !is_monsters(u->faction) - && (u_race(u)->flags & RCF_DESERT)) { - if (fval(u, UFL_ISNEW)) - continue; - if (rng_int() % 100 < 5) { - ADDMSG(&u->faction->msgs, msg_message("desertion", - "unit region", u, r)); - u_setfaction(u, monsters); - } - } - } - } + monsters_desert(monsters); } chaos_update(); diff --git a/src/report.c b/src/report.c index e754c3fb2..34da143de 100644 --- a/src/report.c +++ b/src/report.c @@ -26,7 +26,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "guard.h" #include "laws.h" #include "market.h" -#include "monster.h" +#include "monsters.h" #include "travelthru.h" /* modules includes */ diff --git a/src/spells.c b/src/spells.c index 57b1da3a5..7e7b5669a 100644 --- a/src/spells.c +++ b/src/spells.c @@ -22,7 +22,7 @@ #include "spells.h" #include "direction.h" #include "randenc.h" -#include "monster.h" +#include "monsters.h" #include "teleport.h" #include diff --git a/src/study.c b/src/study.c index f3372334a..58cd068f2 100644 --- a/src/study.c +++ b/src/study.c @@ -24,7 +24,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "study.h" #include "laws.h" #include "move.h" -#include "monster.h" +#include "monsters.h" #include "alchemy.h" #include "academy.h" diff --git a/src/summary.c b/src/summary.c index 2311b1994..8a3ee3c41 100644 --- a/src/summary.c +++ b/src/summary.c @@ -14,7 +14,7 @@ #include "summary.h" #include "laws.h" -#include "monster.h" +#include "monsters.h" #include "calendar.h" #include diff --git a/src/teleport.c b/src/teleport.c index 74176f6af..f81f2f9f0 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -34,7 +34,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "skill.h" -#include "monster.h" +#include "monsters.h" /* libc includes */ #include diff --git a/src/upkeep.c b/src/upkeep.c index 198ce73df..1cf41011f 100644 --- a/src/upkeep.c +++ b/src/upkeep.c @@ -16,7 +16,7 @@ #include "alchemy.h" #include "economy.h" -#include "monster.h" +#include "monsters.h" #include "donations.h" #include From 8c045d7a78263394fff96c7f4bd9f181adad0aa3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 23 Dec 2016 23:58:24 +0100 Subject: [PATCH 382/675] fix flt/int compilation bug. --- src/monsters.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monsters.c b/src/monsters.c index ea80b9740..829c1ed35 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -88,7 +88,7 @@ static double random_move_chance(void) { static int rule; static int config; if (config_changed(&config)) { - rule = config_get_flt("rules.monsters.random_move_percent", MOVE_PERCENT); + rule = config_get_int("rules.monsters.random_move_percent", MOVE_PERCENT); } return rule * 0.01; } From 0c865dca57337b18d141402a2e300e5cb863a245 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 31 Dec 2016 19:56:55 +0100 Subject: [PATCH 383/675] failing test for name_unit. --- src/kernel/unit.test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index c4b1f46ed..752627144 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -468,6 +468,24 @@ static void test_renumber_unit(CuTest *tc) { test_cleanup(); } +static void gen_name(unit *u) +{ + unit_setname(u, "Hodor"); +} + +static void test_name_unit(CuTest *tc) { + race *rc; + unit * u; + + test_setup(); + rc = test_create_race("skeleton"); + u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); + rc->generate_name = gen_name; + name_unit(u); + CuAssertStrEquals(tc, "Hodor", unit_getname(u)); + test_cleanup(); +} + CuSuite *get_unit_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -491,5 +509,6 @@ CuSuite *get_unit_suite(void) SUITE_ADD_TEST(suite, test_inside_building); SUITE_ADD_TEST(suite, test_limited_skills); SUITE_ADD_TEST(suite, test_renumber_unit); + SUITE_ADD_TEST(suite, test_name_unit); return suite; } From 51bebfdb6b9592bd666d844f474084d171f85bc9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 31 Dec 2016 20:03:50 +0100 Subject: [PATCH 384/675] fix undead name generation. --- src/kernel/race.c | 7 ------- src/kernel/race.h | 1 - src/kernel/unit.c | 12 +++--------- src/names.test.c | 2 +- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/kernel/race.c b/src/kernel/race.c index f28c5ed2f..decc3b7bb 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -369,10 +369,3 @@ void register_race_description_function(race_desc_func func, const char *name) { void register_race_name_function(race_name_func func, const char *name) { register_function((pf_generic)func, name); } - -char * race_namegen(const struct race *rc, struct unit *u) { - if (rc->generate_name) { - rc->generate_name(u); - } - return NULL; -} diff --git a/src/kernel/race.h b/src/kernel/race.h index 022d09c86..6673676bd 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -252,7 +252,6 @@ extern "C" { const char *raceprefix(const struct unit *u); void register_race_name_function(race_name_func, const char *); void register_race_description_function(race_desc_func, const char *); - char * race_namegen(const struct race *rc, struct unit *u); #ifdef __cplusplus } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 4aff7d118..f06c4c252 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1480,15 +1480,9 @@ void default_name(const unit *u, char name[], int len) { void name_unit(unit * u) { - if (u_race(u)->generate_name) { - char *gen_name = race_namegen(u_race(u), u); - if (gen_name) { - free(u->_name); - u->_name = gen_name; - } - else { - unit_setname(u, racename(u->faction->locale, u, u_race(u))); - } + const race *rc = u_race(u); + if (rc->generate_name) { + rc->generate_name(u); } else { char name[32]; diff --git a/src/names.test.c b/src/names.test.c index f50937f17..1fc41f340 100644 --- a/src/names.test.c +++ b/src/names.test.c @@ -24,7 +24,7 @@ static void test_names(CuTest * tc) locale_setstring(default_locale, "undead_postfix_0", "Kobolde"); CuAssertPtrNotNull(tc, foo = (race_name_func)get_function("nameundead")); rc->generate_name = foo; - race_namegen(rc, u); + rc->generate_name(u); CuAssertStrEquals(tc, "Graue Kobolde", u->_name); CuAssertPtrNotNull(tc, get_function("nameskeleton")); CuAssertPtrNotNull(tc, get_function("namezombie")); From e49d350348e754f24ba3a57bdde119829b56633c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 31 Dec 2016 20:12:13 +0100 Subject: [PATCH 385/675] test that monsters with "namegeneric" hook get a NULL name (WIP) --- src/names.test.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/names.test.c b/src/names.test.c index 1fc41f340..176a12a68 100644 --- a/src/names.test.c +++ b/src/names.test.c @@ -36,9 +36,25 @@ static void test_names(CuTest * tc) test_cleanup(); } +static void test_monster_names(CuTest *tc) { + unit *u; + race *rc; + + test_setup(); + register_names(); + rc = test_create_race("irongolem"); + u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); + CuAssertPtrNotNull(tc, u->_name); + rc->generate_name = (race_name_func)get_function("namegeneric"); + rc->generate_name(u); + CuAssertPtrEquals(tc, 0, u->_name); + test_cleanup(); +} + CuSuite *get_names_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_names); + SUITE_ADD_TEST(suite, test_monster_names); return suite; } From b8bccd723845ea0d55e670dbd9487ea861004e76 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 31 Dec 2016 20:17:02 +0100 Subject: [PATCH 386/675] monster name pluralization changes with u->number. --- src/names.c | 6 +----- src/names.test.c | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/names.c b/src/names.c index 99c21a05e..cf1cdb910 100644 --- a/src/names.c +++ b/src/names.c @@ -221,11 +221,7 @@ const char *silbe3[SIL3] = { static void generic_name(unit * u) { - const char * name = rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL); - name = LOC(u->faction->locale, name); - if (name) { - unit_setname(u, name); - } + unit_setname(u, NULL); } static void dragon_name(unit * u) diff --git a/src/names.test.c b/src/names.test.c index 176a12a68..8109fc2d4 100644 --- a/src/names.test.c +++ b/src/names.test.c @@ -42,12 +42,18 @@ static void test_monster_names(CuTest *tc) { test_setup(); register_names(); + default_locale = test_create_locale(); + locale_setstring(default_locale, "race::irongolem", "Eisengolem"); + locale_setstring(default_locale, "race::irongolem_p", "Eisengolems"); rc = test_create_race("irongolem"); u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); CuAssertPtrNotNull(tc, u->_name); rc->generate_name = (race_name_func)get_function("namegeneric"); rc->generate_name(u); CuAssertPtrEquals(tc, 0, u->_name); + CuAssertStrEquals(tc, "Eisengolem", unit_getname(u)); + u->number = 2; + CuAssertStrEquals(tc, "Eisengolems", unit_getname(u)); test_cleanup(); } From d4dd9b4bc62147e5bc2aaf7d44704dec84beec98 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 31 Dec 2016 21:21:23 +0100 Subject: [PATCH 387/675] enable PAY NOT in E2 --- conf/e2/config.json | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index 217cfffe9..ce823a33d 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -5,7 +5,6 @@ "e2/terrains.json" ], "disabled": [ - "pay", "jsreport" ], "settings": { From 47c8b20f680fd208b5dbe696f778ef7c562a158a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 6 Jan 2017 20:54:57 +0100 Subject: [PATCH 388/675] add a happy test for mt_new. refactor to not use strncpy. --- src/test_eressea.c | 1 + src/util/CMakeLists.txt | 2 +- src/util/message.c | 20 +++++++++++--------- src/util/message.test.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 src/util/message.test.c diff --git a/src/test_eressea.c b/src/test_eressea.c index 71cf008f2..6d2dead3f 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -65,6 +65,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(direction); ADD_SUITE(skill); ADD_SUITE(keyword); + ADD_SUITE(message); ADD_SUITE(order); ADD_SUITE(race); /* util */ diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 7eda87132..842bcf58c 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -14,7 +14,7 @@ gamedata.test.c language.test.c # lists.test.c # log.test.c -# message.test.c +message.test.c # nrmessage.test.c parser.test.c password.test.c diff --git a/src/util/message.c b/src/util/message.c index f76409e53..23f81e095 100644 --- a/src/util/message.c +++ b/src/util/message.c @@ -87,19 +87,21 @@ message_type *mt_new(const char *name, const char *args[]) for (i = 0; args[i]; ++i) { const char *x = args[i]; const char *spos = strchr(x, ':'); - if (spos == NULL) { - mtype->pnames[i] = _strdup(x); - mtype->types[i] = NULL; + struct arg_type *atype = NULL; + if (spos != NULL) { + atype = find_argtype(spos + 1); + } + if (!atype) { + log_error("unknown argument type %s for message type %s\n", spos + 1, mtype->name); + assert(atype); } else { - char *cp = strncpy((char *)malloc(spos - x + 1), x, spos - x); + char *cp; + cp = malloc(spos - x + 1); + memcpy(cp, x, spos - x); cp[spos - x] = '\0'; mtype->pnames[i] = cp; - mtype->types[i] = find_argtype(spos + 1); - if (mtype->types[i] == NULL) { - log_error("unknown argument type %s for message type %s\n", spos + 1, mtype->name); - } - assert(mtype->types[i]); + mtype->types[i] = atype; } } } diff --git a/src/util/message.test.c b/src/util/message.test.c new file mode 100644 index 000000000..d114e33f2 --- /dev/null +++ b/src/util/message.test.c @@ -0,0 +1,29 @@ +#include +#include "message.h" + +#include +#include + +static void test_mt_new(CuTest *tc) +{ + message_type *mt; + test_setup(); + mt = mt_new_va("test", "name:string", "number:int", NULL); + CuAssertPtrNotNull(tc, mt); + CuAssertStrEquals(tc, "test", mt->name); + CuAssertIntEquals(tc, 2, mt->nparameters); + CuAssertPtrNotNull(tc, mt->pnames); + CuAssertStrEquals(tc, "name", mt->pnames[0]); + CuAssertStrEquals(tc, "number", mt->pnames[1]); + CuAssertPtrNotNull(tc, mt->types); + CuAssertStrEquals(tc, "string", mt->types[0]->name); + CuAssertStrEquals(tc, "int", mt->types[1]->name); + test_cleanup(); +} + +CuSuite *get_message_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_mt_new); + return suite; +} From d71d5e413a1eeba0e509397a1ba97969fd233fc9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 6 Jan 2017 21:08:49 +0100 Subject: [PATCH 389/675] eliminate unnecessary strncpy use. --- src/report.c | 3 ++- src/reports.c | 6 +----- src/util/language.c | 25 ++++++++++++++++--------- src/util/language.test.c | 11 +++++++++++ 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/report.c b/src/report.c index 34da143de..4e12f1261 100644 --- a/src/report.c +++ b/src/report.c @@ -413,7 +413,8 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc } else { char substr[32]; - strncpy(substr, syntaxp, cstr - syntaxp); + assert(sizeof(substr) > (cstr - syntaxp)); + memcpy(substr, syntaxp, cstr - syntaxp); substr[cstr - syntaxp] = 0; locp = LOC(lang, mkname("spellpar", substr)); syntaxp = substr + 1; diff --git a/src/reports.c b/src/reports.c index 8ffb823a5..fa8a722d9 100644 --- a/src/reports.c +++ b/src/reports.c @@ -849,10 +849,6 @@ const struct unit * u, struct skill * sv, int *dh, int days) void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned int width, char mark) { - - /* Die Liste SP wird mit dem String s aufgefuellt, mit indent und einer - * mark, falls angegeben. SP wurde also auf 0 gesetzt vor dem Aufruf. - * Vgl. spunit (). */ bool firstline; static char buf[REPORTWIDTH + 1]; // FIXME: static buffer, artificial limit size_t len = strlen(s); @@ -883,7 +879,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned if (!cut) { cut = s + _min(len, REPORTWIDTH); } - strncpy(buf + indent, s, cut - s); + memcpy(buf + indent, s, cut - s); buf[indent + (cut - s)] = 0; addstrlist(SP, buf); // TODO: too much string copying, cut out this function while (*cut == ' ') { diff --git a/src/util/language.c b/src/util/language.c index d8b899742..cb91d7419 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -101,16 +101,23 @@ locale *get_or_create_locale(const char *name) void make_locales(const char *str) { const char *tok = str; - while (*tok) { - char zText[32]; - while (*tok && *tok != ',') - ++tok; - strncpy(zText, str, tok - str); - zText[tok - str] = 0; - get_or_create_locale(zText); - if (*tok) { - str = ++tok; + while (tok) { + char zText[16]; + size_t len; + + tok = strchr(str, ','); + if (tok) { + len = tok - str; + assert(sizeof(zText) > len); + memcpy(zText, str, len); + str = tok + 1; } + else { + len = strlen(str); + memcpy(zText, str, len); + } + zText[len] = 0; + get_or_create_locale(zText); } } diff --git a/src/util/language.test.c b/src/util/language.test.c index 236eac497..40a6775fa 100644 --- a/src/util/language.test.c +++ b/src/util/language.test.c @@ -16,9 +16,20 @@ static void test_language(CuTest *tc) test_cleanup(); } +static void test_make_locales(CuTest *tc) +{ + test_setup(); + make_locales("aa,bb,cc"); + CuAssertPtrNotNull(tc, get_locale("aa")); + CuAssertPtrNotNull(tc, get_locale("bb")); + CuAssertPtrNotNull(tc, get_locale("cc")); + test_cleanup(); +} + CuSuite *get_language_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_language); + SUITE_ADD_TEST(suite, test_make_locales); return suite; } From 2422e63af21aa44cb4d27f9119365bdbb08cc860 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 6 Jan 2017 21:24:31 +0100 Subject: [PATCH 390/675] never use strncpy, anywhere. --- src/bind_config.c | 3 ++- src/helpers.c | 2 +- src/util/log.test.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bind_config.c b/src/bind_config.c index 3959cc22c..929e4cca0 100644 --- a/src/bind_config.c +++ b/src/bind_config.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,7 @@ int config_parse(const char *json) if (xp >= ep) break; } xp = (ep > json + 10) ? ep - 10 : json; - strncpy(buffer, xp, sizeof(buffer)); + strlcpy(buffer, xp, sizeof(buffer)); buffer[9] = 0; log_error("json parse error in line %d, position %d, near `%s`\n", line, ep - lp, buffer); } diff --git a/src/helpers.c b/src/helpers.c index aa9bc12eb..e9502e075 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -167,7 +167,7 @@ static int lua_callspell(castorder * co) if (hashpos != NULL) { ptrdiff_t len = hashpos - fname; assert(len < (ptrdiff_t) sizeof(fbuf)); - strncpy(fbuf, fname, len); + memcpy(fbuf, fname, len); fbuf[len] = '\0'; fname = fbuf; } diff --git a/src/util/log.test.c b/src/util/log.test.c index 95cbefa96..55616c026 100644 --- a/src/util/log.test.c +++ b/src/util/log.test.c @@ -12,7 +12,7 @@ void log_string(void *data, int level, const char *module, const char *format, v unused_arg(format); unused_arg(module); unused_arg(level); - strncpy(str, arg, 32); + strcpy(str, arg); } static void test_logging(CuTest * tc) From 9351a1960e973ce414dd1a25fec897dcb2875805 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 6 Jan 2017 21:37:52 +0100 Subject: [PATCH 391/675] gcc warning eliminated --- src/report.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/report.c b/src/report.c index 4e12f1261..553e6cb94 100644 --- a/src/report.c +++ b/src/report.c @@ -413,9 +413,10 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc } else { char substr[32]; - assert(sizeof(substr) > (cstr - syntaxp)); - memcpy(substr, syntaxp, cstr - syntaxp); - substr[cstr - syntaxp] = 0; + size_t len = cstr - syntaxp; + assert(sizeof(substr) > len); + memcpy(substr, syntaxp, len); + substr[len] = 0; locp = LOC(lang, mkname("spellpar", substr)); syntaxp = substr + 1; } From fd759e7ff69e06b32e67fe4e103ebd21e56e4ed1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jan 2017 20:20:13 +0100 Subject: [PATCH 392/675] remove old & unused fix_famililar repair code. --- src/bind_monsters.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/bind_monsters.c b/src/bind_monsters.c index 53a569311..4ac15aa24 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -56,34 +56,6 @@ static int tolua_spawn_undead(lua_State * L) return 0; } -static int fix_familiars(struct lua_State *L) -{ - faction *f; - for (f = factions; f; f = f->next) { - unit *u; - for (u = f->units; u; u = u->nextF) { - struct sc_mage *mage = get_mage(u); - if (mage && is_familiar(u)) { - if (mage->spellbook && mage->magietyp == M_GRAY) { - equipment *eq; - char buffer[64]; - - spellbook_clear(mage->spellbook); - free(mage->spellbook); - mage->spellbook = 0; - - _snprintf(buffer, sizeof(buffer), "%s_familiar", u_race(u)->_name); - eq = get_equipment(buffer); - if (eq) { - equip_unit_mask(u, eq, EQUIP_SPELLS); - } - } - } - } - } - return 0; -} - void bind_monsters(struct lua_State *L) { tolua_module(L, NULL, 0); @@ -93,7 +65,6 @@ void bind_monsters(struct lua_State *L) tolua_function(L, TOLUA_CAST "plan_monsters", tolua_planmonsters); tolua_function(L, TOLUA_CAST "spawn_undead", tolua_spawn_undead); tolua_function(L, TOLUA_CAST "spawn_dragons", tolua_spawn_dragons); - tolua_function(L, TOLUA_CAST "fix_familiars", fix_familiars); tolua_function(L, TOLUA_CAST "get_monsters", tolua_get_monsters); } tolua_endmodule(L); From 03def6ae5e552278ed5619ec7d74f81db3bb264a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jan 2017 21:09:39 +0100 Subject: [PATCH 393/675] replace snprintf and the like. you cannot trust _snprintf in MSVC (no zero-termination). --- src/bind_storage.c | 4 +++- src/gmtool.c | 2 +- src/json.c | 6 +++--- src/kernel/item.c | 5 ++++- src/kernel/jsonconf.c | 7 ++++++- src/util/bsdstring.c | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/bind_storage.c b/src/bind_storage.c index a81a3baeb..6b582e815 100644 --- a/src/bind_storage.c +++ b/src/bind_storage.c @@ -100,7 +100,9 @@ static int tolua_storage_tostring(lua_State * L) { gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0); char name[64]; - _snprintf(name, sizeof(name), "", (void *)data, data->version); + // safe to use sprintf here, because: + // %p is at most 16 characters, %d 20, text is 16, comes to 53 with \0 + sprintf(name, "", (void *)data, data->version); lua_pushstring(L, name); return 1; } diff --git a/src/gmtool.c b/src/gmtool.c index 7aab2fea7..b1b9a1bc1 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -1167,7 +1167,7 @@ static void handlekey(state * st, int c) region *first = (mr && mr->r && mr->r->next) ? mr->r->next : regions; if (findmode == 'f') { - snprintf(sbuffer, sizeof(sbuffer), "find-faction: %s", locate); + slprintf(sbuffer, sizeof(sbuffer), "find-faction: %s", locate); statusline(st->wnd_status->handle, sbuffer); f = findfaction(atoi36(locate)); if (f == NULL) { diff --git a/src/json.c b/src/json.c index 10322fe3f..2c27b9947 100644 --- a/src/json.c +++ b/src/json.c @@ -67,13 +67,13 @@ int json_export(stream * out, int flags) { cJSON *json, *root = cJSON_CreateObject(); assert(out && out->api); if (regions && (flags & EXPORT_REGIONS)) { - char id[32]; + char id[32]; // TODO: static_assert(INT_MAX < 10^32) region * r; plane * p; cJSON_AddItemToObject(root, "planes", json = cJSON_CreateObject()); for (p = planes; p; p = p->next) { cJSON *data; - _snprintf(id, sizeof(id), "%d", p->id); + sprintf(id, "%d", p->id); // safe, unless int is bigger than 64 bit cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); cJSON_AddNumberToObject(data, "x", p->minx); cJSON_AddNumberToObject(data, "y", p->miny); @@ -85,7 +85,7 @@ int json_export(stream * out, int flags) { cJSON_AddItemToObject(root, "regions", json = cJSON_CreateObject()); for (r = regions; r; r = r->next) { cJSON *data; - _snprintf(id, sizeof(id), "%d", r->uid); + sprintf(id, "%d", r->uid); // safe, unless int is bigger than 64 bit cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); cJSON_AddNumberToObject(data, "x", r->x); cJSON_AddNumberToObject(data, "y", r->y); diff --git a/src/kernel/item.c b/src/kernel/item.c index 53fff79ab..9956f2a4a 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -156,7 +156,10 @@ const char *resourcename(const resource_type * rtype, int flags) } if (flags & NMF_PLURAL) { static char name[64]; // FIXME: static return value - _snprintf(name, sizeof(name), "%s_p", rtype->_name); + size_t len = strlen(rtype->_name); + assert(len <= sizeof(name) - 3); + memcpy(name, rtype->_name, len); + strcpy(name + len, "_p"); return name; } return rtype->_name; diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index d12238566..dccfbb68a 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -523,6 +523,8 @@ static void disable_feature(const char *str) { char name[32]; int k; skill_t sk; + size_t len; + sk = findskill(str); if (sk != NOSKILL) { enable_skill(sk, false); @@ -534,7 +536,10 @@ static void disable_feature(const char *str) { enable_keyword(k, false); return; } - _snprintf(name, sizeof(name), "%s.enabled", str); + len = strlen(str); + assert(len <= sizeof(name) - 9); + memcpy(name, str, len); + strcpy(name+len, ".enabled"); log_info("disable feature %s\n", name); config_set(name, "0"); } diff --git a/src/util/bsdstring.c b/src/util/bsdstring.c index 98d2d00f5..4fc56ce4e 100644 --- a/src/util/bsdstring.c +++ b/src/util/bsdstring.c @@ -13,7 +13,7 @@ int wrptr(char **ptr, size_t * size, int result) { size_t bytes = (size_t)result; if (result < 0) { - // _snprintf buffer was too small + // buffer was too small if (*size > 0) { **ptr = 0; *size = 0; From ae3bfc952b06f3d538d5f1cc7539cf64bb847e42 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jan 2017 21:19:58 +0100 Subject: [PATCH 394/675] create_order takes variable arguments! more snprintf removal. --- src/give.test.c | 12 +++--------- src/kernel/jsonconf.c | 4 ++-- src/kernel/unit.test.c | 13 +++++-------- src/laws.test.c | 4 +--- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/give.test.c b/src/give.test.c index f2b0d60a9..029ee7c44 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -233,7 +233,6 @@ static void test_give_men_requires_contact(CuTest * tc) { struct give env = { 0 }; message * msg; order *ord; - char cmd[32]; test_setup_ex(tc); env.f1 = test_create_faction(0); @@ -244,8 +243,7 @@ static void test_give_men_requires_contact(CuTest * tc) { CuAssertIntEquals(tc, 1, env.dst->number); CuAssertIntEquals(tc, 1, env.src->number); - _snprintf(cmd, sizeof(cmd), "%s ALLES PERSONEN", itoa36(env.dst->no)); - ord = create_order(K_GIVE, env.f1->locale, cmd); + ord = create_order(K_GIVE, env.f1->locale, "%s ALLES PERSONEN", itoa36(env.dst->no)); test_clear_messages(env.f1); give_cmd(env.src, ord); CuAssertPtrEquals(tc, 0, test_find_messagetype(env.f1->msgs, "give_person")); @@ -307,7 +305,6 @@ static void test_give(CuTest * tc) { static void test_give_cmd(CuTest * tc) { struct give env = { 0 }; struct order *ord; - char cmd[32]; test_setup_ex(tc); env.lang = test_create_locale(); @@ -316,8 +313,7 @@ static void test_give_cmd(CuTest * tc) { i_change(&env.src->items, env.itype, 10); - _snprintf(cmd, sizeof(cmd), "%s 5 %s", itoa36(env.dst->no), LOC(env.f1->locale, env.itype->rtype->_name)); - ord = create_order(K_GIVE, env.f1->locale, cmd); + ord = create_order(K_GIVE, env.f1->locale, "%s 5 %s", itoa36(env.dst->no), LOC(env.f1->locale, env.itype->rtype->_name)); assert(ord); give_cmd(env.src, ord); CuAssertIntEquals(tc, 5, i_get(env.src->items, env.itype)); @@ -330,7 +326,6 @@ static void test_give_cmd(CuTest * tc) { static void test_give_herbs(CuTest * tc) { struct give env = { 0 }; struct order *ord; - char cmd[32]; test_setup_ex(tc); test_create_world(); @@ -338,8 +333,7 @@ static void test_give_herbs(CuTest * tc) { setup_give(&env); i_change(&env.src->items, env.itype, 10); - _snprintf(cmd, sizeof(cmd), "%s %s", itoa36(env.dst->no), LOC(env.f1->locale, parameters[P_HERBS])); - ord = create_order(K_GIVE, env.f1->locale, cmd); + ord = create_order(K_GIVE, env.f1->locale, "%s %s", itoa36(env.dst->no), LOC(env.f1->locale, parameters[P_HERBS])); assert(ord); give_cmd(env.src, ord); diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index dccfbb68a..69e02c3a0 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -801,10 +801,10 @@ static void json_settings(cJSON *json) { else { char value[32]; if (child->type == cJSON_Number && child->valuedouble && child->valueintvaluedouble) { - _snprintf(value, sizeof(value), "%f", child->valuedouble); + sprintf(value, "%f", child->valuedouble); } else { - _snprintf(value, sizeof(value), "%d", child->valueint); + sprintf(value, "%d", child->valueint); } config_set(child->string, value); } diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index 752627144..1a481960d 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -140,37 +140,34 @@ static void test_scale_number(CuTest *tc) { static void test_unit_name(CuTest *tc) { unit *u; - char name[32]; test_cleanup(); test_create_world(); u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0)); + renumber_unit(u, 666); unit_setname(u, "Hodor"); - _snprintf(name, sizeof(name), "Hodor (%s)", itoa36(u->no)); - CuAssertStrEquals(tc, name, unitname(u)); + CuAssertStrEquals(tc, "Hodor (ii)", unitname(u)); test_cleanup(); } static void test_unit_name_from_race(CuTest *tc) { unit *u; - char name[32]; struct locale *lang; test_cleanup(); test_create_world(); u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0)); + renumber_unit(u, 666); unit_setname(u, NULL); lang = get_or_create_locale("de"); locale_setstring(lang, rc_name_s(u->_race, NAME_SINGULAR), "Mensch"); locale_setstring(lang, rc_name_s(u->_race, NAME_PLURAL), "Menschen"); - _snprintf(name, sizeof(name), "Mensch (%s)", itoa36(u->no)); - CuAssertStrEquals(tc, name, unitname(u)); + CuAssertStrEquals(tc, "Mensch (ii)", unitname(u)); CuAssertStrEquals(tc, "Mensch", unit_getname(u)); u->number = 2; - _snprintf(name, sizeof(name), "Menschen (%s)", itoa36(u->no)); - CuAssertStrEquals(tc, name, unitname(u)); + CuAssertStrEquals(tc, "Menschen (ii)", unitname(u)); CuAssertStrEquals(tc, "Menschen", unit_getname(u)); test_cleanup(); diff --git a/src/laws.test.c b/src/laws.test.c index 1bec0e6b4..d4753ec19 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -521,7 +521,6 @@ static void test_pay_cmd_other_building(CuTest *tc) { order *ord; faction *f; building *b; - char cmd[32]; test_setup(); setup_pay_cmd(&fix); @@ -531,8 +530,7 @@ static void test_pay_cmd_other_building(CuTest *tc) { config_set("rules.region_owner_pay_building", "lighthouse"); update_owners(b->region); - _snprintf(cmd, sizeof(cmd), "NOT %s", itoa36(b->no)); - ord = create_order(K_PAY, f->locale, cmd); + ord = create_order(K_PAY, f->locale, "NOT %s", itoa36(b->no)); assert(ord); CuAssertPtrEquals(tc, fix.u1, building_owner(b)); CuAssertIntEquals(tc, 0, pay_cmd(fix.u1, ord)); From d94cde67a4e3ca32fc65c3f1832a74280354b8c2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Jan 2017 16:31:05 +0100 Subject: [PATCH 395/675] kill autoconf.h, replace platform.h for C99 compatibility work --- CMakeLists.txt | 50 ---------- autoconf.h.in | 36 ------- src/academy.c | 2 +- src/alchemy.c | 10 +- src/attributes/dict.c | 8 +- src/attributes/hate.c | 2 +- src/attributes/moved.c | 2 +- src/attributes/movement.c | 2 +- src/attributes/racename.c | 4 +- src/attributes/raceprefix.c | 4 +- src/battle.c | 66 ++++++------- src/battle.h | 1 + src/bind_building.c | 2 +- src/bind_dict.c | 2 +- src/bind_gmtool.c | 6 +- src/bind_region.c | 2 +- src/bind_ship.c | 2 +- src/building_action.c | 10 +- src/creport.c | 8 +- src/economy.c | 64 ++++++------- src/give.c | 4 +- src/gmtool.c | 4 +- src/guard.h | 3 + src/items.c | 2 +- src/items/artrewards.c | 2 +- src/items/demonseye.c | 4 +- src/items/speedsail.c | 4 +- src/items/weapons.c | 2 +- src/items/xerewards.c | 2 +- src/kernel/alliance.c | 4 +- src/kernel/ally.c | 6 +- src/kernel/build.c | 34 +++---- src/kernel/building.c | 10 +- src/kernel/building.h | 2 + src/kernel/building.test.c | 2 +- src/kernel/config.c | 13 +-- src/kernel/config.h | 1 + src/kernel/connection.c | 68 ++++++------- src/kernel/connection.h | 2 +- src/kernel/curse.c | 20 ++-- src/kernel/curse.h | 2 + src/kernel/equipment.c | 8 +- src/kernel/faction.c | 10 +- src/kernel/faction.h | 2 + src/kernel/group.c | 4 +- src/kernel/item.c | 22 ++--- src/kernel/jsonconf.c | 6 +- src/kernel/messages.c | 4 +- src/kernel/order.c | 2 +- src/kernel/plane.c | 2 +- src/kernel/pool.c | 10 +- src/kernel/race.c | 4 +- src/kernel/region.c | 16 ++-- src/kernel/region.h | 1 + src/kernel/resources.c | 4 +- src/kernel/save.c | 24 ++--- src/kernel/save.test.c | 8 +- src/kernel/ship.c | 10 +- src/kernel/spell.c | 2 +- src/kernel/spellbook.c | 2 +- src/kernel/terrain.c | 2 +- src/kernel/unit.c | 18 ++-- src/kernel/unit.test.c | 8 +- src/kernel/xmlreader.c | 24 ++--- src/laws.c | 86 ++++++++--------- src/laws.h | 1 + src/lighthouse.c | 4 +- src/lighthouse.h | 2 + src/listbox.c | 2 +- src/magic.c | 42 ++++---- src/magic.h | 1 + src/market.test.c | 2 +- src/modules/arena.c | 14 +-- src/modules/autoseed.c | 10 +- src/modules/museum.c | 8 +- src/modules/score.c | 2 +- src/monsters.c | 16 ++-- src/morale.c | 2 +- src/move.c | 24 ++--- src/move.h | 5 +- src/names.c | 6 +- src/platform.h | 180 ++--------------------------------- src/prefix.c | 2 +- src/races/dragons.c | 2 +- src/races/races.c | 2 +- src/races/zombies.c | 8 +- src/randenc.c | 4 +- src/report.c | 80 ++++++++-------- src/report.test.c | 6 +- src/reports.c | 44 ++++----- src/skill.h | 2 +- src/spells.c | 103 ++++++++++---------- src/spells/borders.c | 8 +- src/spells/borders.h | 3 + src/spells/buildingcurse.c | 2 +- src/spells/combatspells.c | 30 +++--- src/spells/flyingship.h | 2 + src/spells/regioncurse.c | 28 +++--- src/spells/shipcurse.c | 6 +- src/spells/unitcurse.c | 16 ++-- src/spy.c | 6 +- src/sqlite.c | 4 +- src/study.c | 18 ++-- src/summary.c | 8 +- src/test_eressea.c | 2 +- src/travelthru.test.c | 2 +- src/triggers/changefaction.c | 2 +- src/triggers/changerace.c | 2 +- src/triggers/clonedied.c | 2 +- src/triggers/createcurse.c | 2 +- src/triggers/createunit.c | 2 +- src/triggers/gate.c | 2 +- src/triggers/giveitem.c | 2 +- src/triggers/killunit.c | 2 +- src/triggers/shock.c | 6 +- src/triggers/timeout.c | 2 +- src/triggers/unitmessage.c | 6 +- src/upkeep.c | 12 +-- src/util/attrib.c | 2 +- src/util/attrib.h | 2 + src/util/attrib.test.c | 2 +- src/util/crmessage.c | 10 +- src/util/event.c | 4 +- src/util/goodies.c | 2 +- src/util/language.c | 8 +- src/util/language.h | 2 +- src/util/lists.c | 2 +- src/util/log.test.c | 6 +- src/util/message.c | 2 +- src/util/nrmessage.c | 6 +- src/util/translation.c | 12 +-- src/vortex.c | 14 +-- src/vortex.h | 5 + src/wormhole.c | 2 +- 134 files changed, 683 insertions(+), 902 deletions(-) delete mode 100644 autoconf.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index f6b931e61..c08e16c20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,56 +14,6 @@ find_package (Curses) find_package (Lua REQUIRED) find_package (ToLua REQUIRED) -INCLUDE (CheckIncludeFiles) -INCLUDE (CheckSymbolExists) -CHECK_INCLUDE_FILES (stdbool.h HAVE_STDBOOL_H) -CHECK_INCLUDE_FILES (windows.h HAVE_WINDOWS_H) -CHECK_INCLUDE_FILES (io.h HAVE_IO_H) -CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H) -CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H) -IF (HAVE_IO_H) -CHECK_SYMBOL_EXISTS (_access "io.h" HAVE__ACCESS) -ENDIF (HAVE_IO_H) -IF (HAVE_WINDOWS_H) -CHECK_SYMBOL_EXISTS (_sleep "windows.h" HAVE__SLEEP) -ENDIF(HAVE_WINDOWS_H) -IF(HAVE_STDBOOL_H) -CHECK_SYMBOL_EXISTS (_Bool "stdbool.h" HAVE__BOOL) -ENDIF(HAVE_STDBOOL_H) -IF(HAVE_UNISTD_H) -CHECK_SYMBOL_EXISTS (sleep "unistd.h" HAVE_SLEEP) -CHECK_SYMBOL_EXISTS (usleep "unistd.h" HAVE_USLEEP) -CHECK_SYMBOL_EXISTS (access "unistd.h" HAVE_ACCESS) -ENDIF(HAVE_UNISTD_H) -CHECK_SYMBOL_EXISTS (strlcpy "string.h" HAVE_STRLCPY) -CHECK_SYMBOL_EXISTS (strlcat "string.h" HAVE_STRLCAT) -CHECK_SYMBOL_EXISTS (slprintf "string.h" HAVE_SLPRINTF) -CHECK_SYMBOL_EXISTS (strcasecmp "string.h" HAVE_STRCASECMP) -CHECK_SYMBOL_EXISTS (strncasecmp "string.h" HAVE_STRNCASECMP) -CHECK_SYMBOL_EXISTS (_strlwr "string.h" HAVE__STRLWR) -CHECK_SYMBOL_EXISTS (_strcmpl "string.h" HAVE__STRCMPL) -CHECK_SYMBOL_EXISTS (_strdup "string.h" HAVE__STRDUP) -CHECK_SYMBOL_EXISTS (_stricmp "string.h" HAVE__STRICMP) -CHECK_SYMBOL_EXISTS (_memicmp "string.h" HAVE__MEMICMP) -CHECK_SYMBOL_EXISTS (strcmpl "string.h" HAVE_STRCMPL) -CHECK_SYMBOL_EXISTS (strdup "string.h" HAVE_STRDUP) -CHECK_SYMBOL_EXISTS (stricmp "string.h" HAVE_STRICMP) -CHECK_SYMBOL_EXISTS (memicmp "string.h" HAVE_MEMICMP) -CHECK_SYMBOL_EXISTS (strlwr "string.h" HAVE_STRLWR) -CHECK_SYMBOL_EXISTS (snprintf "stdio.h" HAVE_SNPRINTF) -CHECK_SYMBOL_EXISTS (_snprintf "stdio.h" HAVE__SNPRINTF) -CHECK_SYMBOL_EXISTS (mkdir "sys/stat.h" HAVE_SYS_STAT_MKDIR) -CHECK_SYMBOL_EXISTS (mkdir "direct.h" HAVE_DIRECT_MKDIR) -CHECK_SYMBOL_EXISTS (_mkdir "direct.h" HAVE_DIRECT__MKDIR) - -CONFIGURE_FILE ( - ${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in - ${CMAKE_BINARY_DIR}/include/autoconf.h) -INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include) - -## skip compiler/libc detection and force cmake autoconf: -#add_definitions(-DUSE_AUTOCONF) - add_subdirectory (cJSON) add_subdirectory (storage) add_subdirectory (iniparser) diff --git a/autoconf.h.in b/autoconf.h.in deleted file mode 100644 index f3f197db1..000000000 --- a/autoconf.h.in +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#ifndef CMAKE_AUTOCONF_H -#define CMAKE_AUTOCONF_H -#cmakedefine HAVE_STDBOOL_H 1 -#cmakedefine HAVE_STRINGS_H 1 -#cmakedefine HAVE_WINDOWS_H 1 -#cmakedefine HAVE_IO_H 1 -#cmakedefine HAVE_UNISTD_H 1 -#cmakedefine HAVE__BOOL 1 -#cmakedefine HAVE_STRCASECMP 1 -#cmakedefine HAVE_STRNCASECMP 1 -#cmakedefine HAVE__STRICMP 1 -#cmakedefine HAVE_SNPRINTF 1 -#cmakedefine HAVE__SNPRINTF 1 -#cmakedefine HAVE_ACCESS 1 -#cmakedefine HAVE__ACCESS 1 -#cmakedefine HAVE_SLEEP 1 -#cmakedefine HAVE_USLEEP 1 -#cmakedefine HAVE__SLEEP 1 -#cmakedefine HAVE_STRDUP 1 -#cmakedefine HAVE__STRDUP 1 -#cmakedefine HAVE_STRICMP 1 -#cmakedefine HAVE__STRCMPL 1 -#cmakedefine HAVE_STRCMPL 1 -#cmakedefine HAVE__MEMICMP 1 -#cmakedefine HAVE_MEMICMP 1 -#cmakedefine HAVE__STRLWR 1 -#cmakedefine HAVE_STRLWR 1 -#cmakedefine HAVE_STRLCPY 1 -#cmakedefine HAVE_STRLCAT 1 -#cmakedefine HAVE_SLPRINTF 1 -#cmakedefine HAVE_SYS_STAT_MKDIR 1 -#cmakedefine HAVE_DIRECT_MKDIR 1 -#cmakedefine HAVE_DIRECT__MKDIR 1 - -#endif diff --git a/src/academy.c b/src/academy.c index f6b70873e..496c1ef8e 100644 --- a/src/academy.c +++ b/src/academy.c @@ -35,7 +35,7 @@ bool academy_can_teach(unit *teacher, unit *student, skill_t sk) { const struct building_type *btype = bt_find("academy"); if (active_building(teacher, btype) && active_building(student, btype)) { int j = study_cost(student, sk); - j = _max(50, j * 2); + j = MAX(50, j * 2); /* kann Einheit das zahlen? */ return get_pooled(student, get_resourcetype(R_SILVER), GET_DEFAULT, j) >= j; /* sonst nehmen sie nicht am Unterricht teil */ diff --git a/src/alchemy.c b/src/alchemy.c index 9bc180700..ddbe46b8e 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -73,12 +73,12 @@ void herbsearch(unit * u, int max) } if (max) - max = _min(max, rherbs(r)); + max = MIN(max, rherbs(r)); else max = rherbs(r); herbsfound = ntimespprob(effsk * u->number, (double)rherbs(r) / 100.0F, -0.01F); - herbsfound = _min(herbsfound, max); + herbsfound = MIN(herbsfound, max); rsetherbs(r, (short) (rherbs(r) - herbsfound)); if (herbsfound) { @@ -156,7 +156,7 @@ static int potion_water_of_life(unit * u, region *r, int amount) { } static int potion_healing(unit * u, int amount) { - 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); return amount; } @@ -182,7 +182,7 @@ static int potion_power(unit *u, int amount) { amount = use; } /* 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; return amount; } @@ -248,7 +248,7 @@ static void free_potiondelay(attrib * a) { static int age_potiondelay(attrib * a, void *owner) { potiondelay *pd = (potiondelay *)a->data.v; - unused_arg(owner); + UNUSED_ARG(owner); pd->amount = do_potion(pd->u, pd->r, pd->ptype, pd->amount); return AT_AGE_REMOVE; } diff --git a/src/attributes/dict.c b/src/attributes/dict.c index 2bba9ea7b..a3f034145 100644 --- a/src/attributes/dict.c +++ b/src/attributes/dict.c @@ -103,7 +103,7 @@ static int dict_read(attrib * a, void *owner, gamedata *data) float flt; READ_STR(store, name, sizeof(name)); - dd->name = _strdup(name); + dd->name = strdup(name); READ_INT(store, &n); dd->type = (dict_type)n; switch (dd->type) { @@ -122,7 +122,7 @@ static int dict_read(attrib * a, void *owner, gamedata *data) break; case TSTRING: READ_STR(store, name, sizeof(name)); - dd->data.str = _strdup(name); + dd->data.str = strdup(name); break; case TBUILDING: result = @@ -199,7 +199,7 @@ struct attrib *dict_create(const char *name, dict_type type, variant value) { attrib *a = a_new(&at_dict); dict_data *data = (dict_data *)a->data.v; - data->name = _strdup(name); + data->name = strdup(name); dict_set(a, type, value); return a; @@ -214,7 +214,7 @@ void dict_set(attrib * a, dict_type type, variant value) data->type = type; switch (type) { case TSTRING: - data->data.str = value.v ? _strdup(value.v) : NULL; + data->data.str = value.v ? strdup(value.v) : NULL; break; case TINTEGER: data->data.i = value.i; diff --git a/src/attributes/hate.c b/src/attributes/hate.c index 98a36a029..17155fc71 100644 --- a/src/attributes/hate.c +++ b/src/attributes/hate.c @@ -30,7 +30,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static int verify_hate(attrib * a, void *owner) { - unused_arg(owner); + UNUSED_ARG(owner); if (a->data.v == NULL) { return 0; } diff --git a/src/attributes/moved.c b/src/attributes/moved.c index 3da2a4c3b..c66a5489c 100644 --- a/src/attributes/moved.c +++ b/src/attributes/moved.c @@ -27,7 +27,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static int age_moved(attrib * a, void *owner) { - unused_arg(owner); + UNUSED_ARG(owner); --a->data.i; return a->data.i > 0; } diff --git a/src/attributes/movement.c b/src/attributes/movement.c index 874da5eb3..4d79039ef 100644 --- a/src/attributes/movement.c +++ b/src/attributes/movement.c @@ -67,7 +67,7 @@ void set_movement(attrib ** alist, int type) static int age_speedup(attrib * a, void *owner) { - unused_arg(owner); + UNUSED_ARG(owner); if (a->data.sa[0] > 0) { assert(a->data.sa[0] - a->data.sa[1] >= SHRT_MIN); assert(a->data.sa[0] - a->data.sa[1] <= SHRT_MAX); diff --git a/src/attributes/racename.c b/src/attributes/racename.c index b408cbf6a..c45fa3815 100644 --- a/src/attributes/racename.c +++ b/src/attributes/racename.c @@ -43,7 +43,7 @@ void set_racename(attrib ** palist, const char *name) attrib *a = a_find(*palist, &at_racename); if (!a && name) { a = a_add(palist, a_new(&at_racename)); - a->data.v = _strdup(name); + a->data.v = strdup(name); } else if (a && !name) { a_remove(palist, a); @@ -51,7 +51,7 @@ void set_racename(attrib ** palist, const char *name) else if (a) { if (strcmp(a->data.v, name) != 0) { free(a->data.v); - a->data.v = _strdup(name); + a->data.v = strdup(name); } } } diff --git a/src/attributes/raceprefix.c b/src/attributes/raceprefix.c index 15f0036c1..a87edfb80 100644 --- a/src/attributes/raceprefix.c +++ b/src/attributes/raceprefix.c @@ -41,7 +41,7 @@ void set_prefix(attrib ** ap, const char *str) free(a->data.v); } assert(a->type == &at_raceprefix); - a->data.v = _strdup(str); + a->data.v = strdup(str); } const char *get_prefix(attrib * a) @@ -53,7 +53,7 @@ const char *get_prefix(attrib * a) str = (char *)a->data.v; /* conversion of old prefixes */ if (strncmp(str, "prefix_", 7) == 0) { - ((attrib *)a)->data.v = _strdup(str + 7); + ((attrib *)a)->data.v = strdup(str + 7); free(str); str = (char *)a->data.v; } diff --git a/src/battle.c b/src/battle.c index 9d2d09cc0..550449ddd 100644 --- a/src/battle.c +++ b/src/battle.c @@ -440,7 +440,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; } @@ -600,12 +600,12 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking) if (u_race(u) == get_race(RC_ORC)) { int sword = effskill(u, SK_MELEE, 0); int spear = effskill(u, SK_SPEAR, 0); - 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 { @@ -685,7 +685,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type) /* only half against trolls */ if (skl > 0) { if (type == BONUS_SKILL) { - int dmg = _min(skl, 8); + int dmg = MIN(skl, 8); if (u_race(enemy.fighter->unit) == get_race(RC_TROLL)) { dmg = dmg / 4; } @@ -696,7 +696,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type) } else { skl = skl / 2; - return _min(skl, 4); + return MIN(skl, 4); } } } @@ -1008,7 +1008,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); } } } @@ -1203,15 +1203,15 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) /* TODO not sure if res could be > 1 here */ if (magic) { - da = (int)(_max(da * res, 0)); + da = (int)(MAX(da * res, 0)); } if (type != AT_COMBATSPELL && type != AT_SPELL) { if (rule_damage & 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) { @@ -1238,11 +1238,11 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) /* Skilldifferenzbonus */ if (rule_damage & DAMAGE_SKILL_BONUS) { - da += _max(0, (sk - sd) / DAMAGE_QUOTIENT); + da += MAX(0, (sk - sd) / DAMAGE_QUOTIENT); } } - rda = _max(da - ar, 0); + rda = MAX(da - ar, 0); if ((u_race(du)->battle_flags & BF_INV_NONMAGIC) && !magic) rda = 0; @@ -1275,7 +1275,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--; } } @@ -1474,7 +1474,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); @@ -1574,7 +1574,7 @@ static troop select_opponent(battle * b, troop at, int mindist, int maxdist) 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); } @@ -1735,7 +1735,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); @@ -1822,7 +1822,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); @@ -2056,7 +2056,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. */ @@ -2332,7 +2332,7 @@ void do_regenerate(fighter * af) while (ta.index--) { struct person *p = af->person + ta.index; p->hp += effskill(au, SK_STAMINA, 0); - p->hp = _min(unit_max_hp(au), p->hp); + p->hp = MIN(unit_max_hp(au), p->hp); } } @@ -2391,10 +2391,10 @@ double fleechance(unit * u) if (u_race(u) == get_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) @@ -2518,7 +2518,7 @@ static void loot_items(fighter * corpse) float lootfactor = (float)dead / (float)u->number; /* only loot the dead! */ int maxloot = (int)((float)itm->number * lootfactor); if (maxloot > 0) { - int i = _min(10, maxloot); + int i = MIN(10, maxloot); for (; i != 0; --i) { int loot = maxloot / i; @@ -2599,7 +2599,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); add_chaoscount(r, dead_peasants / 2); @@ -3092,7 +3092,7 @@ static void print_stats(battle * b) for (s = b->sides; s != b->sides + b->nsides; ++s) { if (!selist_empty(s->leader.fighters)) { - b->max_tactics = _max(b->max_tactics, s->leader.value); + b->max_tactics = MAX(b->max_tactics, s->leader.value); } } @@ -3258,7 +3258,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, trollbelts(u)); + strongmen = MIN(fig->unit->number, trollbelts(u)); /* Hitpoints, Attack- und Defence-Boni f�r alle Personen */ for (i = 0; i < fig->alive; i++) { @@ -3448,7 +3448,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; } @@ -3519,11 +3519,11 @@ static const char *simplename(region * r) const char *cp = rname(r, default_locale); for (i = 0; *cp && i != 16; ++i, ++cp) { int c = *(unsigned char *)cp; - while (c && !isalpha(c) && !isxspace(c)) { + while (c && !isalpha(c) && !isspace(c)) { ++cp; c = *(unsigned char *)cp; } - if (isxspace(c)) + if (isspace(c)) name[i] = '_'; else name[i] = *cp; @@ -3546,10 +3546,10 @@ battle *make_battle(region * r) bld->sizeleft = bld->size; if (battledebug) { - char zText[MAX_PATH]; - char zFilename[MAX_PATH]; + char zText[4096]; + char zFilename[4096]; join_path(basepath(), "battles", zText, sizeof(zText)); - if (_mkdir(zText) != 0) { + if (mkdir(zText, 0777) != 0) { log_error("could not create subdirectory for battle logs: %s", zText); battledebug = false; } @@ -4104,7 +4104,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 */ @@ -4147,7 +4147,7 @@ static void battle_flee(battle * b) if (fig->person[dt.index].flags & FL_PANICED) { ispaniced = EFFECT_PANIC_SPELL; } - if (chance(_min(fleechance(u) + ispaniced, 0.90))) { + if (chance(MIN(fleechance(u) + ispaniced, 0.90))) { ++runners; flee(dt); } diff --git a/src/battle.h b/src/battle.h index cee894b6c..dbdc7e1cb 100644 --- a/src/battle.h +++ b/src/battle.h @@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define H_KRNL_BATTLE #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/bind_building.c b/src/bind_building.c index 3724d4db5..f8cf4e6df 100644 --- a/src/bind_building.c +++ b/src/bind_building.c @@ -92,7 +92,7 @@ static int tolua_building_set_info(lua_State * L) const char *info = tolua_tostring(L, 2, 0); free(self->display); if (info) - self->display = _strdup(info); + self->display = strdup(info); else self->display = NULL; return 0; diff --git a/src/bind_dict.c b/src/bind_dict.c index 32d3c498d..40f73690f 100644 --- a/src/bind_dict.c +++ b/src/bind_dict.c @@ -106,7 +106,7 @@ static int tolua_dict_set_string(lua_State * L) attrib *a = a_find(*self, &at_dict); variant val; - val.v = _strdup(value); + val.v = strdup(value); for (; a && a->type == &at_dict; a = a->next) { if (strcmp(dict_name(a), name) == 0) { diff --git a/src/bind_gmtool.c b/src/bind_gmtool.c index 3c07bb3b7..e4ae939f9 100644 --- a/src/bind_gmtool.c +++ b/src/bind_gmtool.c @@ -133,14 +133,14 @@ static int tolua_selected_regions(lua_State * L) static int tolua_state_open(lua_State * L) { - unused_arg(L); + UNUSED_ARG(L); state_open(); return 0; } static int tolua_state_close(lua_State * L) { - unused_arg(L); + UNUSED_ARG(L); state_close(current_state); return 0; } @@ -188,7 +188,7 @@ static void lua_paint_info(struct window *wnd, const struct state *st) break; else { size_t len = end - str; - int bytes = _min((int)len, size); + int bytes = MIN((int)len, size); mvwaddnstr(win, line++, 1, str, bytes); wclrtoeol(win); str = end + 1; diff --git a/src/bind_region.c b/src/bind_region.c index 1296e4a65..2e328dc96 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -615,7 +615,7 @@ static int tolua_plane_set_name(lua_State * L) const char *str = tolua_tostring(L, 2, 0); free(self->name); if (str) - self->name = _strdup(str); + self->name = strdup(str); else self->name = 0; return 0; diff --git a/src/bind_ship.c b/src/bind_ship.c index f1c1c412a..95006cf5f 100644 --- a/src/bind_ship.c +++ b/src/bind_ship.c @@ -94,7 +94,7 @@ static int tolua_ship_set_display(lua_State * L) { ship *self = (ship *)tolua_tousertype(L, 1, 0); free(self->display); - self->display = _strdup(tolua_tostring(L, 2, 0)); + self->display = strdup(tolua_tostring(L, 2, 0)); return 0; } diff --git a/src/building_action.c b/src/building_action.c index 5c533f4d0..f72af4412 100644 --- a/src/building_action.c +++ b/src/building_action.c @@ -93,7 +93,7 @@ lc_write(const struct attrib *a, const void *owner, struct storage *store) const char *fname = data->fname; const char *fparam = data->param; - unused_arg(owner); + UNUSED_ARG(owner); WRITE_TOK(store, fname); WRITE_TOK(store, fparam ? fparam : NULLSTRING); } @@ -116,7 +116,7 @@ static int lc_read(struct attrib *a, void *owner, gamedata *data) b = 0; } else { - bd->fname = _strdup(name); + bd->fname = strdup(name); } READ_TOK(store, name, sizeof(name)); if (strcmp(name, "tnnL") == 0) { @@ -127,7 +127,7 @@ static int lc_read(struct attrib *a, void *owner, gamedata *data) if (strcmp(name, NULLSTRING) == 0) bd->param = 0; else { - bd->param = _strdup(name); + bd->param = strdup(name); } if (result == 0 && !b) { return AT_READ_FAIL; @@ -146,8 +146,8 @@ void building_addaction(building * b, const char *fname, const char *param) { attrib *a = a_add(&b->attribs, a_new(&at_building_action)); building_action *data = (building_action *)a->data.v; - data->fname = _strdup(fname); + data->fname = strdup(fname); if (param) { - data->param = _strdup(param); + data->param = strdup(param); } } diff --git a/src/creport.c b/src/creport.c index 6cd9b7a27..5e01433d4 100644 --- a/src/creport.c +++ b/src/creport.c @@ -125,7 +125,7 @@ static const char *translate(const char *key, const char *value) } else t = malloc(sizeof(translation)); - t->key = _strdup(key); + t->key = strdup(key); t->value = value; t->next = translation_table[kk]; translation_table[kk] = t; @@ -361,7 +361,7 @@ static int cr_race(variant var, char *buffer, const void *userdata) static int cr_alliance(variant var, char *buffer, const void *userdata) { const alliance *al = (const alliance *)var.v; - unused_arg(userdata); + UNUSED_ARG(userdata); if (al != NULL) { sprintf(buffer, "%d", al->id); } @@ -372,7 +372,7 @@ static int cr_skill(variant var, char *buffer, const void *userdata) { const faction *report = (const faction *)userdata; skill_t sk = (skill_t)var.i; - unused_arg(userdata); + UNUSED_ARG(userdata); if (sk != NOSKILL) sprintf(buffer, "\"%s\"", translate(mkname("skill", skillnames[sk]), skillname(sk, @@ -385,7 +385,7 @@ static int cr_skill(variant var, char *buffer, const void *userdata) static int cr_order(variant var, char *buffer, const void *userdata) { order *ord = (order *)var.v; - unused_arg(userdata); + UNUSED_ARG(userdata); if (ord != NULL) { char cmd[ORDERSIZE]; char *wp = buffer; diff --git a/src/economy.c b/src/economy.c index 01954ff54..7edbbcb12 100644 --- a/src/economy.c +++ b/src/economy.c @@ -337,11 +337,11 @@ static int do_recruiting(recruitment * recruits, int available) int number, dec; double multi = 2.0 * 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, get_resourcetype(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", @@ -551,7 +551,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders) if (recruitcost > 0) { int pooled = get_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT, recruitcost * n); - n = _min(n, pooled / recruitcost); + n = MIN(n, pooled / recruitcost); } u->wants = n; @@ -990,12 +990,12 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) rring = get_resourcetype(R_RING_OF_NIMBLEFINGER); if (rring) { int dm = i_get(u->items, rring->itype); - amount += skill * _min(u->number, dm) * (roqf_factor() - 1); + amount += skill * MIN(u->number, dm) * (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 */ } @@ -1091,7 +1091,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) @@ -1106,7 +1106,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) { @@ -1139,7 +1139,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); @@ -1149,7 +1149,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) @@ -1625,7 +1625,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); @@ -1936,7 +1936,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) /* Ein Hndler kann nur 10 Gter pro Talentpunkt verkaufen. */ - n = _min(n, u->number * 10 * effskill(u, SK_TRADE, 0)); + n = MIN(n, u->number * 10 * effskill(u, SK_TRADE, 0)); if (!n) { cmistake(u, ord, 54, MSG_COMMERCE); @@ -1966,11 +1966,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); @@ -1995,7 +1995,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 Gter merken */ a->data.i += n; @@ -2052,7 +2052,7 @@ static void expandstealing(region * r, request * stealorders) n = 10; } if (n > 0) { - n = _min(n, g_requests[j].unit->wants); + n = MIN(n, g_requests[j].unit->wants); use_pooled(u, rsilver, GET_ALL, n); g_requests[j].unit->n = n; change_money(g_requests[j].unit, n); @@ -2106,8 +2106,8 @@ static void plant(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); /* Fr jedes Kraut Talent*10% Erfolgschance. */ for (i = n; i > 0; i--) { if (rng_int() % 10 < skill) @@ -2152,14 +2152,14 @@ static void planttrees(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); /* Fr jeden Samen Talent*10% Erfolgschance. */ for (i = n; i > 0; i--) { @@ -2209,7 +2209,7 @@ static void breedtrees(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 prfen */ if (n == 0) { @@ -2217,7 +2217,7 @@ static void breedtrees(unit * u, int raw) msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype)); return; } - n = _min(raw, n); + n = MIN(raw, n); /* Fr jeden Samen Talent*5% Erfolgschance. */ for (i = n; i > 0; i--) { @@ -2259,7 +2259,7 @@ static void breedhorses(unit * u) } effsk = effskill(u, SK_HORSE_TRAINING, 0); n = u->number * effsk; - n = _min(n, horses); + n = MIN(n, horses); for (c = 0; c < n; c++) { if (rng_int() % 100 < effsk) { @@ -2508,7 +2508,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders) } } - i = _min(u->number, i_get(u->items, rring->itype)); + i = MIN(u->number, i_get(u->items, rring->itype)); if (i > 0) { n *= STEALINCOME * (u->number + i * (roqf_factor() - 1)); } @@ -2530,7 +2530,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)); } /* ------------------------------------------------------------- */ @@ -2554,7 +2554,7 @@ static void expandentertainment(region * r) entertaining -= o->qty; /* Nur soviel PRODUCEEXP wie auch tatschlich 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); } @@ -2605,7 +2605,7 @@ void entertain_cmd(unit * u, struct order *ord) 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; @@ -2665,7 +2665,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork) if (blessedharvest_ct) { int happy = (int)curse_geteffect(get_curse(r->attribs, blessedharvest_ct)); - happy = _min(happy, jobs); + happy = MIN(happy, jobs); earnings += happy; } } @@ -2819,10 +2819,10 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders) 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 * effskill(u, SK_TAXING, 0) * taxperlevel, max); + u->wants = MIN(n * effskill(u, SK_TAXING, 0) * taxperlevel, max); } u2 = is_guarded(r, u); @@ -2893,12 +2893,12 @@ void loot_cmd(unit * u, struct order *ord, request ** lootorders) max = INT_MAX; } if (!playerrace(u_race(u))) { - u->wants = _min(income(u), max); + u->wants = MIN(income(u), max); } else { /* For player start with 20 Silver +10 every 5 level of close combat skill*/ - int skbonus = (_max(effskill(u, SK_MELEE, 0), effskill(u, SK_SPEAR, 0)) * 2 / 10) + 2; - u->wants = _min(n * skbonus * 10, max); + int skbonus = (MAX(effskill(u, SK_MELEE, 0), effskill(u, SK_SPEAR, 0)) * 2 / 10) + 2; + u->wants = MIN(n * skbonus * 10, max); } o = (request *)calloc(1, sizeof(request)); diff --git a/src/give.c b/src/give.c index 524a27017..4f8417bf2 100644 --- a/src/give.c +++ b/src/give.c @@ -156,7 +156,7 @@ struct order *ord) assert(itype != NULL); n = get_pooled(src, item2resource(itype), GET_SLACK | GET_POOLED_SLACK, want); - n = _min(want, n); + n = MIN(want, n); r = n; if (dest && src->faction != dest->faction && src->faction->age < GiveRestriction()) { @@ -772,7 +772,7 @@ void give_cmd(unit * u, order * ord) msg_feedback(u, ord, "race_noregroup", "race", u_race(u))); return; } - n = _min(u->number, n); + n = MIN(u->number, n); msg = u2 ? give_men(n, u, u2, ord) : disband_men(n, u, ord); if (msg) { ADDMSG(&u->faction->msgs, msg); diff --git a/src/gmtool.c b/src/gmtool.c index b1b9a1bc1..3db673731 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -427,7 +427,7 @@ static void paint_info_region(window * wnd, const state * st) int line = 0, maxline = getmaxy(win) - 2; map_region *mr = cursor_region(&st->display, &st->cursor); - unused_arg(st); + UNUSED_ARG(st); werase(win); wxborder(win); if (mr && mr->r) { @@ -1398,7 +1398,7 @@ int curses_readline(struct lua_State *L, char *buffer, size_t size, const char *prompt) { - unused_arg(L); + UNUSED_ARG(L); askstring(hstatus, prompt, buffer, size); return buffer[0] != 0; } diff --git a/src/guard.h b/src/guard.h index 4fb6cbf56..101369f40 100644 --- a/src/guard.h +++ b/src/guard.h @@ -2,6 +2,9 @@ #ifndef H_GUARD #define H_GUARD + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/items.c b/src/items.c index 6fbf957b3..6e995edaa 100644 --- a/src/items.c +++ b/src/items.c @@ -122,7 +122,7 @@ struct order *ord) double force; spell *sp = find_spell("antimagiczone"); attrib **ap = &r->attribs; - unused_arg(ord); + UNUSED_ARG(ord); assert(sp); /* Reduziert die Strke jedes Spruchs um effect */ diff --git a/src/items/artrewards.c b/src/items/artrewards.c index 602841d23..23ab2119e 100644 --- a/src/items/artrewards.c +++ b/src/items/artrewards.c @@ -45,7 +45,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static int age_peaceimmune(attrib * a, void *owner) { - unused_arg(owner); + UNUSED_ARG(owner); return (--a->data.i > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } diff --git a/src/items/demonseye.c b/src/items/demonseye.c index ffc1c5179..563a16047 100644 --- a/src/items/demonseye.c +++ b/src/items/demonseye.c @@ -38,8 +38,8 @@ summon_igjarjuk(struct unit *u, const struct item_type *itype, int amount, struct order *ord) { struct plane *p = rplane(u->region); - unused_arg(amount); - unused_arg(itype); + UNUSED_ARG(amount); + UNUSED_ARG(itype); if (p != NULL) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", "")); return EUNUSABLE; diff --git a/src/items/speedsail.c b/src/items/speedsail.c index 8bdaa41ab..cb40e9a8c 100644 --- a/src/items/speedsail.c +++ b/src/items/speedsail.c @@ -42,8 +42,8 @@ use_speedsail(struct unit *u, const struct item_type *itype, int amount, struct order *ord) { struct plane *p = rplane(u->region); - unused_arg(amount); - unused_arg(itype); + UNUSED_ARG(amount); + UNUSED_ARG(itype); if (p != NULL) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", "")); } diff --git a/src/items/weapons.c b/src/items/weapons.c index 1806e61a0..a23110a81 100644 --- a/src/items/weapons.c +++ b/src/items/weapons.c @@ -106,7 +106,7 @@ int *casualties) } enemies = count_enemies(b, af, FIGHT_ROW, FIGHT_ROW, SELECT_ADVANCE); - enemies = _min(enemies, CATAPULT_ATTACKS); + enemies = MIN(enemies, CATAPULT_ATTACKS); if (enemies == 0) { return true; /* allow further attacks */ } diff --git a/src/items/xerewards.c b/src/items/xerewards.c index ab5226a32..a6d1ad2ea 100644 --- a/src/items/xerewards.c +++ b/src/items/xerewards.c @@ -72,7 +72,7 @@ struct order *ord) } for (i = 0; i != amount; ++i) { - sp += _max(25, max_spellpoints(u->region, u) / 2); + sp += MAX(25, max_spellpoints(u->region, u) / 2); change_spellpoints(u, sp); } diff --git a/src/kernel/alliance.c b/src/kernel/alliance.c index 32c58e246..0feb8407d 100644 --- a/src/kernel/alliance.c +++ b/src/kernel/alliance.c @@ -83,7 +83,7 @@ alliance *new_alliance(int id, const char *name) { al = calloc(1, sizeof(alliance)); al->id = id; if (name) { - al->name = _strdup(name); + al->name = strdup(name); } else { al->flags |= ALF_NON_ALLIED; @@ -447,7 +447,7 @@ void alliance_setname(alliance * self, const char *name) { free(self->name); if (name) - self->name = _strdup(name); + self->name = strdup(name); else self->name = NULL; } diff --git a/src/kernel/ally.c b/src/kernel/ally.c index 5a5a5b1c3..759d556f4 100644 --- a/src/kernel/ally.c +++ b/src/kernel/ally.c @@ -76,7 +76,7 @@ int AllianceAuto(void) const char *str = config_get("alliance.auto"); value = 0; if (str != NULL) { - char *sstr = _strdup(str); + char *sstr = strdup(str); char *tok = strtok(sstr, " "); while (tok) { value |= ally_flag(tok, -1); @@ -136,7 +136,7 @@ int HelpMask(void) if (config_changed(&config)) { const char *str = config_get("rules.help.mask"); if (str != NULL) { - char *sstr = _strdup(str); + char *sstr = strdup(str); char *tok = strtok(sstr, " "); while (tok) { rule |= ally_flag(tok, -1); @@ -156,7 +156,7 @@ static int AllianceRestricted(void) const char *str = config_get("alliance.restricted"); int rule = 0; if (str != NULL) { - char *sstr = _strdup(str); + char *sstr = strdup(str); char *tok = strtok(sstr, " "); while (tok) { rule |= ally_flag(tok, -1); diff --git a/src/kernel/build.c b/src/kernel/build.c index b5a1b3417..dff51cf6c 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -123,11 +123,11 @@ static void destroy_road(unit * u, int nmax, struct order *ord) } road = rroad(r, d); - n = _min(n, road); + n = MIN(n, road); if (n != 0) { region *r2 = rconnect(r, d); int willdo = effskill(u, SK_ROAD_BUILDING, 0) * u->number; - willdo = _min(willdo, n); + willdo = MIN(willdo, n); if (willdo == 0) { /* TODO: error message */ } @@ -327,7 +327,7 @@ void build_road(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) == get_race(RC_STONEGOLEM)) { n = u->number * GOLEM_STONE; @@ -339,7 +339,7 @@ void build_road(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 * effsk; @@ -347,7 +347,7 @@ void build_road(unit * u, int size, direction_t d) const resource_type *ring = get_resourcetype(R_RING_OF_NIMBLEFINGER); item *itm = ring ? *i_find(&u->items, ring->itype) : 0; 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; } } @@ -355,15 +355,15 @@ void build_road(unit * u, int size, direction_t d) int dm = get_effect(u, oldpotiontype[P_DOMORE]); if (dm != 0) { int todo = (left - n + effsk - 1) / effsk; - 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 * effsk; } /* 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 @@ -380,7 +380,7 @@ void build_road(unit * u, int size, direction_t d) else { use_pooled(u, get_resourcetype(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)); @@ -486,7 +486,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; } @@ -545,7 +545,7 @@ int build(unit * u, const construction * ctype, int completed, int want) item *itm = ring ? *i_find(&u->items, ring->itype) : 0; int i = itm ? itm->number : 0; 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; } } @@ -553,7 +553,7 @@ int build(unit * u, const construction * ctype, int completed, int want) if (want < n) n = want; if (type->maxsize > 0) { - n = _min(type->maxsize - completed, n); + n = MIN(type->maxsize - completed, n); if (type->improvement == NULL) { want = n; } @@ -626,7 +626,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; } @@ -671,7 +671,7 @@ int maxbuild(const unit * u, const construction * cons) return 0; } else - maximum = _min(maximum, have / need); + maximum = MIN(maximum, have / need); } return maximum; } @@ -879,7 +879,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; @@ -923,7 +923,7 @@ order * ord) return; } if (want > 0) - want = _min(want, msize); + want = MIN(want, msize); else want = msize; @@ -982,7 +982,7 @@ void continue_ship(unit * u, int want) return; } if (want > 0) - want = _min(want, msize); + want = MIN(want, msize); else want = msize; diff --git a/src/kernel/building.c b/src/kernel/building.c index b445019de..f2c9c9fd2 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -127,7 +127,7 @@ building_type *bt_get_or_create(const char *name) building_type *btype = bt_find_i(name); if (btype == NULL) { btype = calloc(sizeof(building_type), 1); - btype->_name = _strdup(name); + btype->_name = strdup(name); btype->auraregen = 1.0; btype->maxsize = -1; btype->capacity = 1; @@ -143,7 +143,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; } @@ -420,7 +420,7 @@ building *new_building(const struct building_type * btype, region * r, } assert(bname); slprintf(buffer, sizeof(buffer), "%s %s", bname, itoa36(b->no)); - b->name = _strdup(bname); + b->name = strdup(bname); return b; } @@ -619,7 +619,7 @@ void building_setname(building * self, const char *name) { free(self->name); if (name) - self->name = _strdup(name); + self->name = strdup(name); else self->name = NULL; } @@ -779,7 +779,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn) /* Godcurse: Income -10 */ ctype = ct_find("godcursezone"); if (ctype && curse_active(get_curse(r->attribs, ctype))) { - wage = _max(0, wage - 10); + wage = MAX(0, wage - 10); } /* Bei einer D�rre verdient man nur noch ein Viertel */ diff --git a/src/kernel/building.h b/src/kernel/building.h index 754f38f07..a6936d90d 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -23,6 +23,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index d15c82c8e..3b296a6fe 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -22,7 +22,7 @@ static void test_register_building(CuTest * tc) test_cleanup(); btype = (building_type *)calloc(sizeof(building_type), 1); - btype->_name = _strdup("herp"); + btype->_name = strdup("herp"); CuAssertIntEquals(tc, true, bt_changed(&cache)); CuAssertIntEquals(tc, false, bt_changed(&cache)); bt_register(btype); diff --git a/src/kernel/config.c b/src/kernel/config.c index 2b1ae678d..d369d0ecd 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -91,6 +91,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include struct settings global = { "Eressea", /* gamename */ @@ -361,7 +362,7 @@ void init_locale(struct locale *lang) str = "gwyrrd illaun draig cerddor tybied"; } - sstr = _strdup(str); + sstr = strdup(str); tok = strtok(sstr, " "); while (tok) { const char *name; @@ -472,7 +473,7 @@ int check_param(const struct param *p, const char *key, const char *searchvalue) if (!value) { return 0; } - char *p_value = _strdup(value); + char *p_value = strdup(value); const char *delimiter = " ,;"; char *v = strtok(p_value, delimiter); @@ -535,7 +536,7 @@ static const char * relpath(char *buf, size_t sz, const char *path) { static const char *g_datadir; const char *datapath(void) { - static char zText[MAX_PATH]; + static char zText[4096]; if (g_datadir) return g_datadir; return relpath(zText, sizeof(zText), "data"); @@ -549,7 +550,7 @@ void set_datapath(const char *path) static const char *g_reportdir; const char *reportpath(void) { - static char zText[MAX_PATH]; + static char zText[4096]; if (g_reportdir) return g_reportdir; return relpath(zText, sizeof(zText), "reports"); @@ -562,12 +563,12 @@ void set_reportpath(const char *path) int create_directories(void) { int err; - err = _mkdir(datapath()); + err = mkdir(datapath(), 0777); if (err) { if (errno == EEXIST) errno = 0; else return err; } - err = _mkdir(reportpath()); + err = mkdir(reportpath(), 0777); if (err && errno == EEXIST) { errno = 0; } diff --git a/src/kernel/config.h b/src/kernel/config.h index 91d5d576f..096d54da4 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -25,6 +25,7 @@ extern "C" { /* this should always be the first thing included after platform.h */ #include +#include #include "types.h" struct param; diff --git a/src/kernel/connection.c b/src/kernel/connection.c index 082039f1b..5b2615bcc 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -131,7 +131,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; @@ -258,31 +258,31 @@ void b_write(const connection * b, storage * store) bool b_transparent(const connection * b, const struct faction *f) { - unused_arg(b); - unused_arg(f); + UNUSED_ARG(b); + UNUSED_ARG(f); return true; } bool b_opaque(const connection * b, const struct faction * f) { - unused_arg(b); - unused_arg(f); + UNUSED_ARG(b); + UNUSED_ARG(f); return false; } bool b_blockall(const connection * b, const unit * u, const region * r) { - unused_arg(u); - unused_arg(r); - unused_arg(b); + UNUSED_ARG(u); + UNUSED_ARG(r); + UNUSED_ARG(b); return true; } bool b_blocknone(const connection * b, const unit * u, const region * r) { - unused_arg(u); - unused_arg(r); - unused_arg(b); + UNUSED_ARG(u); + UNUSED_ARG(r); + UNUSED_ARG(b); return false; } @@ -294,39 +294,39 @@ bool b_rvisible(const connection * b, const region * r) bool b_fvisible(const connection * b, const struct faction * f, const region * r) { - unused_arg(r); - unused_arg(f); - unused_arg(b); + UNUSED_ARG(r); + UNUSED_ARG(f); + UNUSED_ARG(b); return true; } bool b_uvisible(const connection * b, const unit * u) { - unused_arg(u); - unused_arg(b); + UNUSED_ARG(u); + UNUSED_ARG(b); return true; } bool b_rinvisible(const connection * b, const region * r) { - unused_arg(r); - unused_arg(b); + UNUSED_ARG(r); + UNUSED_ARG(b); return false; } bool b_finvisible(const connection * b, const struct faction * f, const region * r) { - unused_arg(r); - unused_arg(f); - unused_arg(b); + UNUSED_ARG(r); + UNUSED_ARG(f); + UNUSED_ARG(b); return false; } bool b_uinvisible(const connection * b, const unit * u) { - unused_arg(u); - unused_arg(b); + UNUSED_ARG(u); + UNUSED_ARG(b); return false; } @@ -380,9 +380,9 @@ static const char *b_namewall(const connection * b, const region * r, { const char *bname = "wall"; - unused_arg(f); - unused_arg(r); - unused_arg(b); + UNUSED_ARG(f); + UNUSED_ARG(r); + UNUSED_ARG(b); if (gflags & GF_ARTICLE) bname = "a_wall"; if (gflags & GF_PURE) @@ -421,9 +421,9 @@ border_type bt_noway = { static const char *b_namefogwall(const connection * b, const region * r, const struct faction *f, int gflags) { - unused_arg(f); - unused_arg(b); - unused_arg(r); + UNUSED_ARG(f); + UNUSED_ARG(b); + UNUSED_ARG(r); if (gflags & GF_PURE) return "fogwall"; if (gflags & GF_ARTICLE) @@ -434,7 +434,7 @@ static const char *b_namefogwall(const connection * b, const region * r, static bool b_blockfogwall(const connection * b, const unit * u, const region * r) { - unused_arg(b); + UNUSED_ARG(b); if (!u) return true; return (bool)(effskill(u, SK_PERCEPTION, r) > 4); /* Das ist die alte Nebelwand */ @@ -459,8 +459,8 @@ static const char *b_nameillusionwall(const connection * b, const region * r, const struct faction *f, int gflags) { int fno = b->data.i; - unused_arg(b); - unused_arg(r); + UNUSED_ARG(b); + UNUSED_ARG(r); if (gflags & GF_PURE) return (f && fno == f->no) ? "illusionwall" : "wall"; if (gflags & GF_ARTICLE) { @@ -496,7 +496,7 @@ static const char *b_nameroad(const connection * b, const region * r, int local = (r == b->from) ? b->data.sa[0] : b->data.sa[1]; static char buffer[64]; - unused_arg(f); + UNUSED_ARG(f); if (gflags & GF_PURE) return "road"; if (gflags & GF_ARTICLE) { @@ -512,7 +512,7 @@ static const char *b_nameroad(const connection * b, const region * r, } } else { - int percent = _max(1, 100 * local / r->terrain->max_road); + int percent = MAX(1, 100 * local / r->terrain->max_road); if (local) { slprintf(buffer, sizeof(buffer), LOC(f->locale, mkname("border", "a_road_percent")), percent); diff --git a/src/kernel/connection.h b/src/kernel/connection.h index 7eef0f52a..80177c638 100644 --- a/src/kernel/connection.h +++ b/src/kernel/connection.h @@ -20,7 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define H_KRNL_BORDER #include - +#include #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/curse.c b/src/kernel/curse.c index c0e353b4f..7df567940 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -109,7 +109,7 @@ int curse_age(attrib * a, void *owner) curse *c = (curse *)a->data.v; int result = 0; - unused_arg(owner); + UNUSED_ARG(owner); c_clearflag(c, CURSE_ISNEW); if (c_flags(c) & CURSE_NOAGE) { @@ -122,7 +122,7 @@ int curse_age(attrib * a, void *owner) 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 > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } @@ -348,7 +348,7 @@ const curse_type *ct_find(const char *c) return type; } else { - size_t k = _min(c_len, strlen(type->cname)); + size_t k = MIN(c_len, strlen(type->cname)); if (!memcmp(c, type->cname, k)) { return type; } @@ -507,7 +507,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 */ @@ -596,7 +596,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; @@ -605,10 +605,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; @@ -792,9 +792,9 @@ message *cinfo_simple(const void *obj, objtype_t typ, const struct curse * c, { struct message *msg; - unused_arg(typ); - unused_arg(self); - unused_arg(obj); + UNUSED_ARG(typ); + UNUSED_ARG(self); + UNUSED_ARG(obj); msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no); if (msg == NULL) { diff --git a/src/kernel/curse.h b/src/kernel/curse.h index 29498f4d2..4cff4f9a1 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "objtypes.h" +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index de539223f..349a87448 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -47,7 +47,7 @@ equipment *create_equipment(const char *eqname) int i = eq ? strcmp(eq->name, eqname) : 1; if (i > 0) { eq = (equipment *)calloc(1, sizeof(equipment)); - eq->name = _strdup(eqname); + eq->name = strdup(eqname); eq->next = *eqp; memset(eq->skills, 0, sizeof(eq->skills)); *eqp = eq; @@ -78,7 +78,7 @@ void equipment_setskill(equipment * eq, skill_t sk, const char *value) { if (eq != NULL) { if (value != NULL) { - eq->skills[sk] = _strdup(value); + eq->skills[sk] = strdup(value); } else if (eq->skills[sk]) { free(eq->skills[sk]); @@ -98,7 +98,7 @@ void equipment_addspell(equipment * eq, const char * name, int level) lazy_spell *ls = malloc(sizeof(lazy_spell)); ls->sp = NULL; ls->level = level; - ls->name = _strdup(name); + ls->name = strdup(name); selist_push(&eq->spells, ls); } } @@ -115,7 +115,7 @@ equipment_setitem(equipment * eq, const item_type * itype, const char *value) if (idata == NULL) { idata = (itemdata *)malloc(sizeof(itemdata)); idata->itype = itype; - idata->value = _strdup(value); + idata->value = strdup(value); idata->next = eq->items; eq->items = idata; } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 4d2e6ae7b..811321f14 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -274,7 +274,7 @@ faction *addfaction(const char *email, const char *password, fhash(f); slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), itoa36(f->no)); - f->name = _strdup(buf); + f->name = strdup(buf); if (!f->race) { log_warning("creating a faction that has no race", itoa36(f->no)); @@ -523,7 +523,7 @@ void faction_setname(faction * self, const char *name) { free(self->name); if (name) - self->name = _strdup(name); + self->name = strdup(name); } const char *faction_getemail(const faction * self) @@ -535,7 +535,7 @@ void faction_setemail(faction * self, const char *email) { free(self->email); if (email) - self->email = _strdup(email); + self->email = strdup(email); } const char *faction_getbanner(const faction * self) @@ -547,7 +547,7 @@ void faction_setbanner(faction * self, const char *banner) { free(self->banner); if (banner) - self->banner = _strdup(banner); + self->banner = strdup(banner); } void faction_setpassword(faction * f, const char *pwhash) @@ -555,7 +555,7 @@ void faction_setpassword(faction * f, const char *pwhash) assert(pwhash); // && pwhash[0] == '$'); free(f->_password); - f->_password = _strdup(pwhash); + f->_password = strdup(pwhash); } bool valid_race(const struct faction *f, const struct race *rc) diff --git a/src/kernel/faction.h b/src/kernel/faction.h index d6419dd2f..757449bd8 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "skill.h" #include "types.h" #include +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/group.c b/src/kernel/group.c index 8753531a3..06f2f9f49 100755 --- a/src/kernel/group.c +++ b/src/kernel/group.c @@ -57,8 +57,8 @@ group *new_group(faction * f, const char *name, int gid) gp = &(*gp)->next; *gp = g; - maxgid = _max(gid, maxgid); - g->name = _strdup(name); + maxgid = MAX(gid, maxgid); + g->name = strdup(name); g->gid = gid; g->nexthash = ghash[index]; diff --git a/src/kernel/item.c b/src/kernel/item.c index 9956f2a4a..34a0e1875 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -189,7 +189,7 @@ resource_type *rt_get_or_create(const char *name) { perror("resource_type allocation failed"); } else { - rtype->_name = _strdup(name); + rtype->_name = strdup(name); rt_register(rtype); return rt_find(name); } @@ -285,8 +285,8 @@ weapon_type *new_weapontype(item_type * itype, wtype = calloc(sizeof(weapon_type), 1); if (damage) { - wtype->damage[0] = _strdup(damage[0]); - wtype->damage[1] = _strdup(damage[1]); + wtype->damage[0] = strdup(damage[0]); + wtype->damage[1] = strdup(damage[1]); } wtype->defmod = defmod; wtype->flags |= wflags; @@ -345,7 +345,7 @@ void it_set_appearance(item_type *itype, const char *appearance) { assert(itype); assert(itype->rtype); if (appearance) { - itype->_appearance[0] = _strdup(appearance); + itype->_appearance[0] = strdup(appearance); itype->_appearance[1] = strcat(strcpy((char *)malloc(strlen((char *)appearance) + 3), (char *)appearance), "_p"); } else { itype->_appearance[0] = 0; @@ -679,9 +679,9 @@ struct order *ord) direction_t d; message *msg = msg_message("meow", ""); - unused_arg(ord); - unused_arg(amount); - unused_arg(itype); + UNUSED_ARG(ord); + UNUSED_ARG(amount); + UNUSED_ARG(itype); add_message(&u->region->msgs, msg); for (d = 0; d < MAXDIRECTIONS; d++) { @@ -720,7 +720,7 @@ struct order *ord) c = create_curse(u, &u->attribs, ct_find("skillmod"), power, duration, effect, u->number); c->data.i = SK_TACTICS; - unused_arg(ord); + UNUSED_ARG(ord); } use_pooled(u, itype->rtype, GET_DEFAULT, amount); ADDMSG(&u->faction->msgs, msg_message("use_tacticcrystal", @@ -749,14 +749,14 @@ mod_elves_only(const unit * u, const region * r, skill_t sk, int value) { if (u_race(u) == get_race(RC_ELF)) return value; - unused_arg(r); + UNUSED_ARG(r); return -118; } static int mod_dwarves_only(const unit * u, const region * r, skill_t sk, int value) { - unused_arg(r); + UNUSED_ARG(r); if (u_race(u) == get_race(RC_DWARF) || (u_race(u)->flags & RCF_IRONGOLEM)) { return value; } @@ -767,7 +767,7 @@ static int heal(unit * user, int effect) { int req = unit_max_hp(user) * user->number - user->hp; if (req > 0) { - req = _min(req, effect); + req = MIN(req, effect); effect -= req; user->hp += req; } diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 69e02c3a0..414704309 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -224,7 +224,7 @@ static void json_terrain_production(cJSON *json, terrain_production *prod) { if (dst) { free(*dst); assert(child->type == cJSON_String); - *dst = _strdup(child->valuestring); + *dst = strdup(child->valuestring); } } } @@ -453,7 +453,7 @@ static void json_race(cJSON *json, race *rc) { switch (child->type) { case cJSON_String: if (strcmp(child->string, "damage") == 0) { - rc->def_damage = _strdup(child->valuestring); + rc->def_damage = strdup(child->valuestring); } break; case cJSON_Number: @@ -599,7 +599,7 @@ static void json_spells(cJSON *json) { sp->fumble = (fumble_f)get_function(item->valuestring); } else if (strcmp(item->string, "syntax") == 0) { - sp->syntax = _strdup(item->valuestring); + sp->syntax = strdup(item->valuestring); } } } diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 566e9bdef..89278624f 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -212,7 +212,7 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level) { message *m = NULL; - unused_arg(level); + UNUSED_ARG(level); switch (mtype) { case MSG_INCOME: assert(f); @@ -275,7 +275,7 @@ message * msg_error(const unit * u, struct order *ord, int mno) { message * cmistake(const unit * u, struct order *ord, int mno, int mtype) { message * result; - unused_arg(mtype); + UNUSED_ARG(mtype); result = msg_error(u, ord, mno); ADDMSG(&u->faction->msgs, result); return result; diff --git a/src/kernel/order.c b/src/kernel/order.c index 3fd1dc92f..776190b67 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -405,7 +405,7 @@ order *parse_order(const char *s, const struct locale * lang) } } if (kwd != NOKEYWORD) { - while (isxspace(*(unsigned char *)sptr)) ++sptr; + while (isspace(*(unsigned char *)sptr)) ++sptr; s = sptr; return create_order_i(kwd, s, persistent, lang); } diff --git a/src/kernel/plane.c b/src/kernel/plane.c index 7e9650d13..0b2fdc0d3 100644 --- a/src/kernel/plane.c +++ b/src/kernel/plane.c @@ -234,7 +234,7 @@ plane *create_new_plane(int id, const char *name, int minx, int maxx, int miny, pl->next = NULL; pl->id = id; if (name) - pl->name = _strdup(name); + pl->name = strdup(name); pl->minx = minx; pl->maxx = maxx; pl->miny = miny; diff --git a/src/kernel/pool.c b/src/kernel/pool.c index 5609d211f..702f86e0f 100644 --- a/src/kernel/pool.c +++ b/src/kernel/pool.c @@ -168,7 +168,7 @@ int count) use = have; else if (rtype->itype && mode & (GET_SLACK | GET_RESERVE)) { int reserve = get_reservation(u, rtype->itype); - int slack = _max(0, have - reserve); + int slack = MAX(0, have - reserve); if (mode & GET_RESERVE) use = have - slack; else if (mode & GET_SLACK) @@ -209,18 +209,18 @@ 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 if (rtype->itype) { int reserve = get_reservation(u, rtype->itype); - 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->itype, -n); } else if (mode & GET_SLACK) { - n = _min(use, slack); + n = MIN(use, slack); } } if (n > 0) { diff --git a/src/kernel/race.c b/src/kernel/race.c index decc3b7bb..a78a9e340 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -241,7 +241,7 @@ race *rc_create(const char *zName) log_error("race '%s' has an invalid name. remove spaces\n", zName); assert(strchr(zName, ' ') == NULL); } - rc->_name = _strdup(zName); + rc->_name = strdup(zName); rc->precombatspell = NULL; rc->attack[0].type = AT_COMBATSPELL; @@ -288,7 +288,7 @@ const char* rc_name(const race * rc, name_t n, char *name, size_t size) { default: assert(!"invalid name_t enum in rc_name_s"); } if (postfix) { - _snprintf(name, size, "race::%s%s", rc->_name, postfix); + snprintf(name, size, "race::%s%s", rc->_name, postfix); return name; } return NULL; diff --git a/src/kernel/region.c b/src/kernel/region.c index d937f8b68..cade135c7 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -138,7 +138,7 @@ int region_maxworkers(const region *r) { int size = production(r); int treespace = (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE; - return _max(size - treespace, _min(size / 10, 200)); + return MAX(size - treespace, MIN(size / 10, 200)); } int deathcount(const region * r) @@ -403,7 +403,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 @@ -426,13 +426,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; @@ -1215,7 +1215,7 @@ void terraform_region(region * r, const terrain_type * terrain) if (!fval(r, RF_CHAOTIC)) { int peasants; peasants = (region_maxworkers(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)); } @@ -1395,7 +1395,7 @@ faction *update_owners(region * r) else if (f || new_owner->faction != region_get_last_owner(r)) { alliance *al = region_get_alliance(r); if (al && new_owner->faction->alliance == al) { - int morale = _max(0, region_get_morale(r) - MORALE_TRANSFER); + int morale = MAX(0, region_get_morale(r) - MORALE_TRANSFER); region_set_morale(r, morale, turn); } else { @@ -1418,7 +1418,7 @@ faction *update_owners(region * r) void region_setinfo(struct region *r, const char *info) { free(r->display); - r->display = info ? _strdup(info) : 0; + r->display = info ? strdup(info) : 0; } const char *region_getinfo(const region * r) @@ -1430,7 +1430,7 @@ void region_setname(struct region *r, const char *name) { if (r->land) { free(r->land->name); - r->land->name = name ? _strdup(name) : 0; + r->land->name = name ? strdup(name) : 0; } } diff --git a/src/kernel/region.h b/src/kernel/region.h index fcc5f08b0..9fa1a2daa 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define H_KRNL_REGION #include +#include #include "types.h" #include "direction.h" diff --git a/src/kernel/resources.c b/src/kernel/resources.c index e064150e6..e32c7ad55 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -111,7 +111,7 @@ static void terraform_default(struct rawmaterial *res, const region * r) res->amount = (int)(res->amount * modifier); /* random adjustment, +/- 91% */ if (res->amount < 1) res->amount = 1; - unused_arg(r); + UNUSED_ARG(r); } #ifdef RANDOM_CHANGE @@ -205,7 +205,7 @@ struct rawmaterial_type *rmt_create(const struct resource_type *rtype, const char *name) { rawmaterial_type *rmtype = malloc(sizeof(rawmaterial_type)); - rmtype->name = _strdup(name); + rmtype->name = strdup(name); rmtype->rtype = rtype; rmtype->terraform = terraform_default; rmtype->update = NULL; diff --git a/src/kernel/save.c b/src/kernel/save.c index 68c89070c..1139b5f1f 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -436,7 +436,7 @@ void read_planes(gamedata *data) { } pl->id = id; READ_STR(store, name, sizeof(name)); - pl->name = _strdup(name); + pl->name = strdup(name); READ_INT(store, &pl->minx); READ_INT(store, &pl->maxx); READ_INT(store, &pl->miny); @@ -668,7 +668,7 @@ unit *read_unit(struct gamedata *data) if (unicode_utf8_trim(obuf)!=0) { log_warning("trim unit %s name to '%s'", itoa36(u->no), obuf); } - u->_name = obuf[0] ? _strdup(obuf) : 0; + u->_name = obuf[0] ? strdup(obuf) : 0; if (lomem) { READ_STR(data->store, NULL, 0); } @@ -677,7 +677,7 @@ unit *read_unit(struct gamedata *data) if (unicode_utf8_trim(obuf)!=0) { log_warning("trim unit %s info to '%s'", itoa36(u->no), obuf); } - u->display = obuf[0] ? _strdup(obuf) : 0; + u->display = obuf[0] ? strdup(obuf) : 0; } READ_INT(data->store, &number); set_number(u, number); @@ -933,7 +933,7 @@ static region *readregion(struct gamedata *data, int x, int y) if (unicode_utf8_trim(name)!=0) { log_warning("trim region %d name to '%s'", uid, name); }; - r->land->name = _strdup(name); + r->land->name = strdup(name); } if (r->land) { int i; @@ -1034,7 +1034,7 @@ static region *readregion(struct gamedata *data, int x, int y) read_items(data->store, &r->land->items); if (data->version >= REGIONOWNER_VERSION) { READ_INT(data->store, &n); - region_set_morale(r, _max(0, (short)n), -1); + region_set_morale(r, MAX(0, (short)n), -1); read_owner(data, &r->land->ownership); } } @@ -1192,7 +1192,7 @@ static char * getpasswd(int fno) { assert(line[slen] == '\n'); line[slen] = 0; fclose(F); - return _strdup(line + len + 1); + return strdup(line + len + 1); } } fclose(F); @@ -1285,12 +1285,12 @@ faction *read_faction(struct gamedata * data) if (unicode_utf8_trim(name)!=0) { log_warning("trim faction %s name to '%s'", itoa36(f->no), name); }; - f->name = _strdup(name); + f->name = strdup(name); READ_STR(data->store, name, sizeof(name)); if (unicode_utf8_trim(name)!=0) { log_warning("trim faction %s banner to '%s'", itoa36(f->no), name); }; - f->banner = _strdup(name); + f->banner = strdup(name); log_debug(" - Lese Partei %s (%s)", f->name, itoa36(f->no)); @@ -1528,7 +1528,7 @@ struct building *read_building(gamedata *data) { if (unicode_utf8_trim(name)!=0) { log_warning("trim building %s name to '%s'", itoa36(b->no), name); } - b->name = _strdup(name); + b->name = strdup(name); if (lomem) { READ_STR(store, NULL, 0); } @@ -1537,7 +1537,7 @@ struct building *read_building(gamedata *data) { if (unicode_utf8_trim(name)!=0) { log_warning("trim building %s info to '%s'", itoa36(b->no), name); } - b->display = _strdup(name); + b->display = strdup(name); } READ_INT(store, &b->size); READ_STR(store, name, sizeof(name)); @@ -1581,7 +1581,7 @@ ship *read_ship(struct gamedata *data) if (unicode_utf8_trim(name)!=0) { log_warning("trim ship %s name to '%s'", itoa36(sh->no), name); } - sh->name = _strdup(name); + sh->name = strdup(name); if (lomem) { READ_STR(store, NULL, 0); } @@ -1590,7 +1590,7 @@ ship *read_ship(struct gamedata *data) if (unicode_utf8_trim(name)!=0) { log_warning("trim ship %s info to '%s'", itoa36(sh->no), name); } - sh->display = _strdup(name); + sh->display = strdup(name); } READ_STR(store, name, sizeof(name)); sh->type = st_find(name); diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index 6a2758a1d..c05ce4455 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -91,7 +91,7 @@ static void test_readwrite_faction(CuTest * tc) test_setup(); f = test_create_faction(0); free(f->name); - f->name = _strdup(" Hodor "); + f->name = strdup(" Hodor "); CuAssertStrEquals(tc, " Hodor ", f->name); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); @@ -120,7 +120,7 @@ static void test_readwrite_region(CuTest * tc) test_setup(); r = test_create_region(0, 0, 0); free(r->land->name); - r->land->name = _strdup(" Hodor "); + r->land->name = strdup(" Hodor "); CuAssertStrEquals(tc, " Hodor ", r->land->name); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); @@ -150,7 +150,7 @@ static void test_readwrite_building(CuTest * tc) r = test_create_region(0, 0, 0); b = test_create_building(r, 0); free(b->name); - b->name = _strdup(" Hodor "); + b->name = strdup(" Hodor "); CuAssertStrEquals(tc, " Hodor ", b->name); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); @@ -183,7 +183,7 @@ static void test_readwrite_ship(CuTest * tc) r = test_create_region(0, 0, 0); sh = test_create_ship(r, 0); free(sh->name); - sh->name = _strdup(" Hodor "); + sh->name = strdup(" Hodor "); CuAssertStrEquals(tc, " Hodor ", sh->name); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 1790afb5d..b9ac0b170 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -109,7 +109,7 @@ ship_type *st_get_or_create(const char * name) { ship_type * st = st_find_i(name); if (!st) { st = (ship_type *)calloc(sizeof(ship_type), 1); - st->_name = _strdup(name); + st->_name = strdup(name); st->storm = 1.0; selist_push(&shiptypes, (void *)st); } @@ -202,7 +202,7 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang) } assert(sname); slprintf(buffer, sizeof(buffer), "%s %s", sname, itoa36(sh->no)); - sh->name = _strdup(buffer); + sh->name = strdup(buffer); shash(sh); if (r) { addlist(&r->ships, sh); @@ -333,8 +333,8 @@ int shipspeed(const ship * sh, const unit * u) int crew = crew_skill(sh); int crew_bonus = (crew / sh->type->sumskill / 2) - 1; if (crew_bonus > 0) { - bonus = _min(bonus, crew_bonus); - bonus = _min(bonus, sh->type->range_max - sh->type->range); + bonus = MIN(bonus, crew_bonus); + bonus = MIN(bonus, sh->type->range_max - sh->type->range); } else { bonus = 0; @@ -458,7 +458,7 @@ void write_ship_reference(const struct ship *sh, struct storage *store) void ship_setname(ship * self, const char *name) { free(self->name); - self->name = name ? _strdup(name) : 0; + self->name = name ? strdup(name) : 0; } const char *ship_getname(const ship * self) diff --git a/src/kernel/spell.c b/src/kernel/spell.c index 4540029e2..5415c4a0e 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -78,7 +78,7 @@ spell * create_spell(const char * name, unsigned int id) len = cb_new_kv(name, len, &sp, sizeof(sp), buffer); if (cb_insert(&cb_spells, buffer, len) == CB_SUCCESS) { sp->id = id ? id : hashstring(name); - sp->sname = _strdup(name); + sp->sname = strdup(name); add_spell(&spells, sp); return sp; } diff --git a/src/kernel/spellbook.c b/src/kernel/spellbook.c index 7673324f8..bb060eaee 100644 --- a/src/kernel/spellbook.c +++ b/src/kernel/spellbook.c @@ -16,7 +16,7 @@ spellbook * create_spellbook(const char * name) { spellbook *result = (spellbook *)malloc(sizeof(spellbook)); - result->name = name ? _strdup(name) : 0; + result->name = name ? strdup(name) : 0; result->spells = 0; return result; } diff --git a/src/kernel/terrain.c b/src/kernel/terrain.c index ac4a49fe9..ca72e3060 100644 --- a/src/kernel/terrain.c +++ b/src/kernel/terrain.c @@ -110,7 +110,7 @@ terrain_type * get_or_create_terrain(const char *name) { if (!terrain) { terrain = (terrain_type *)calloc(sizeof(terrain_type), 1); if (terrain) { - terrain->_name = _strdup(name); + terrain->_name = strdup(name); terrain->next = registered_terrains; registered_terrains = terrain; if (strcmp("plain", name) == 0) { diff --git a/src/kernel/unit.c b/src/kernel/unit.c index f06c4c252..29766d4ef 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -123,7 +123,7 @@ unit *findunitr(const region * r, int n) // TODO: deprecated, replace with findunit(n) unit *findunitg(int n, const region * hint) { - unused_arg(hint); + UNUSED_ARG(hint); /* Abfangen von Syntaxfehlern. */ if (n <= 0) return NULL; @@ -511,7 +511,7 @@ int a_readprivate(attrib * a, void *owner, gamedata *data) struct storage *store = data->store; char lbuf[DISPLAYSIZE]; READ_STR(store, lbuf, sizeof(lbuf)); - a->data.v = _strdup(lbuf); + a->data.v = strdup(lbuf); return (a->data.v) ? AT_READ_OK : AT_READ_FAIL; } @@ -562,7 +562,7 @@ void usetprivate(unit * u, const char *str) if (a->data.v) { free(a->data.v); } - a->data.v = _strdup(str); + a->data.v = strdup(str); } /*********************/ @@ -809,8 +809,8 @@ void set_level(unit * u, skill_t sk, int value) static int leftship_age(struct attrib *a, void *owner) { /* must be aged, so it doesn't affect report generation (cansee) */ - unused_arg(a); - unused_arg(owner); + UNUSED_ARG(a); + UNUSED_ARG(owner); return AT_AGE_REMOVE; /* remove me */ } @@ -1390,7 +1390,7 @@ int invisible(const unit * target, const unit * viewer) else { int hidden = item_invis(target); if (hidden) { - hidden = _min(hidden, target->number); + hidden = MIN(hidden, target->number); if (viewer) { const resource_type *rtype = get_resourcetype(R_AMULET_OF_TRUE_SEEING); hidden -= i_get(viewer->items, rtype->itype); @@ -1533,7 +1533,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace, u->hp = unit_max_hp(u) * number; if (dname) { - u->_name = _strdup(dname); + u->_name = strdup(dname); } else if (urace->generate_name || playerrace(urace)) { name_unit(u); @@ -1640,7 +1640,7 @@ void unit_setname(unit * u, const char *name) { free(u->_name); if (name && name[0]) - u->_name = _strdup(name); + u->_name = strdup(name); else u->_name = NULL; } @@ -1654,7 +1654,7 @@ void unit_setinfo(unit * u, const char *info) { free(u->display); if (info) - u->display = _strdup(info); + u->display = strdup(info); else u->display = NULL; } diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index 1a481960d..b0a2891c5 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -240,9 +240,9 @@ static void test_default_name(CuTest *tc) { } static int cb_skillmod(const unit *u, const region *r, skill_t sk, int level) { - unused_arg(u); - unused_arg(r); - unused_arg(sk); + UNUSED_ARG(u); + UNUSED_ARG(r); + UNUSED_ARG(sk); return level + 3; } @@ -395,7 +395,7 @@ static void test_unit_description(CuTest *tc) { u = test_create_unit(test_create_faction(rc), test_create_region(0,0,0)); CuAssertPtrEquals(tc, 0, u->display); CuAssertStrEquals(tc, 0, u_description(u, u->faction->locale)); - u->display = _strdup("Hodor"); + u->display = strdup("Hodor"); CuAssertStrEquals(tc, "Hodor", u_description(u, NULL)); CuAssertStrEquals(tc, "Hodor", u_description(u, u->faction->locale)); test_cleanup(); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 640a28940..2f38cdab3 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -94,8 +94,8 @@ static xmlChar *xml_cleanup_string(xmlChar * str) while (*read) { /* eat leading whitespace */ - if (*read && isxspace(*read)) { - while (*read && isxspace(*read)) { + if (*read && isspace(*read)) { + while (*read && isspace(*read)) { ++read; } *write++ = ' '; @@ -379,7 +379,7 @@ static int parse_calendar(xmlDocPtr doc) first_turn = xml_ivalue(calendar, "start", first_turn); if (propValue) { free(agename); - agename = _strdup(mkname("calendar", (const char *)propValue)); + agename = strdup(mkname("calendar", (const char *)propValue)); xmlFree(propValue); } @@ -398,7 +398,7 @@ static int parse_calendar(xmlDocPtr doc) xmlNodePtr week = nsetWeeks->nodeTab[i]; xmlChar *propValue = xmlGetProp(week, BAD_CAST "name"); if (propValue) { - weeknames[i] = _strdup(mkname("calendar", (const char *)propValue)); + weeknames[i] = strdup(mkname("calendar", (const char *)propValue)); weeknames2[i] = malloc(strlen(weeknames[i]) + 3); sprintf(weeknames2[i], "%s_d", weeknames[i]); xmlFree(propValue); @@ -421,7 +421,7 @@ static int parse_calendar(xmlDocPtr doc) xmlChar *propValue = xmlGetProp(season, BAD_CAST "name"); if (propValue) { seasonnames[i] = - _strdup(mkname("calendar", (const char *)propValue)); + strdup(mkname("calendar", (const char *)propValue)); xmlFree(propValue); } } @@ -451,7 +451,7 @@ static int parse_calendar(xmlDocPtr doc) xmlFree(newyear); newyear = NULL; } - monthnames[i] = _strdup(mkname("calendar", (const char *)propValue)); + monthnames[i] = strdup(mkname("calendar", (const char *)propValue)); xmlFree(propValue); } if (nsetSeasons) { @@ -663,7 +663,7 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype) xmlFree(propValue); propValue = xmlGetProp(node, BAD_CAST "value"); - wtype->damage[pos] = _strdup((const char *)propValue); // TODO: this is a memory leak + wtype->damage[pos] = strdup((const char *)propValue); // TODO: this is a memory leak if (k == 0) wtype->damage[1 - pos] = wtype->damage[pos]; xmlFree(propValue); @@ -1426,13 +1426,13 @@ static int parse_spells(xmlDocPtr doc) propValue = xmlGetProp(node, BAD_CAST "parameters"); if (propValue) { - sp->parameter = _strdup((const char *)propValue); + sp->parameter = strdup((const char *)propValue); xmlFree(propValue); } propValue = xmlGetProp(node, BAD_CAST "syntax"); if (propValue) { - sp->syntax = _strdup((const char *)propValue); + sp->syntax = strdup((const char *)propValue); xmlFree(propValue); } #ifdef TODO /* no longer need it, spellbooks! */ @@ -1628,7 +1628,7 @@ static int parse_races(xmlDocPtr doc) propValue = xmlGetProp(node, BAD_CAST "damage"); assert(propValue != NULL); - rc->def_damage = _strdup((const char *)propValue); + rc->def_damage = strdup((const char *)propValue); xmlFree(propValue); rc->magres = (float)xml_fvalue(node, "magres", rc->magres); @@ -1869,7 +1869,7 @@ static int parse_races(xmlDocPtr doc) propValue = xmlGetProp(node, BAD_CAST "damage"); if (propValue != NULL) { - attack->data.dice = _strdup((const char *)propValue); + attack->data.dice = strdup((const char *)propValue); xmlFree(propValue); } else { @@ -1932,7 +1932,7 @@ static int parse_messages(xmlDocPtr doc) (const char *)propType); xmlFree(propName); xmlFree(propType); - argv[k] = _strdup(zBuffer); + argv[k] = strdup(zBuffer); } argv[result->nodesetval->nodeNr] = NULL; } diff --git a/src/laws.c b/src/laws.c index d311f698e..bbf1a200b 100644 --- a/src/laws.c +++ b/src/laws.c @@ -209,7 +209,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)); @@ -267,7 +267,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; @@ -318,7 +318,7 @@ int peasant_luck_effect(int peasants, int luck, int maxp, double variance) double mean; if (luck == 0) return 0; - mean = peasant_luck_factor() * peasant_growth_factor() * _min(luck, peasants); + mean = peasant_luck_factor() * peasant_growth_factor() * MIN(luck, peasants); mean *= ((peasants / (double)maxp < .9) ? 1 : PEASANTFORCE); births = RAND_ROUND(normalvariate(mean, variance * mean)); @@ -357,7 +357,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 @@ -366,7 +366,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.5 + n * PEASANT_STARVATION_CHANCE); if (dead > 0) { @@ -447,7 +447,7 @@ static void horses(region * r) /* Logistisches Wachstum, Optimum bei halbem Maximalbesatz. */ maxhorses = region_maxworkers(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)) { @@ -481,7 +481,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 { @@ -594,7 +594,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 */ @@ -614,7 +614,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) / 8); + elves = MIN(elves, production(r) / 8); if (elves) { seedchance += 1.0 - pow(0.99999, elves * RESOURCE_QUANTITY); } @@ -680,7 +680,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++) { @@ -700,7 +700,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++) { @@ -740,7 +740,7 @@ void immigration(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)); } /* Genereate some (0-6 depending on the income) peasants out of nothing */ /* if less than 50 are in the region and there is space and no monster or demon units in the region */ @@ -843,7 +843,7 @@ void demographics(void) calculate_emigration(r); peasants(r); if (r->age > 20) { - double mwp = _max(region_maxworkers(r), 1); + double mwp = MAX(region_maxworkers(r), 1); double prob = pow(rpeasants(r) / (mwp * wage(r, NULL, NULL, turn) * 0.13), 4.0) * PLAGUE_CHANCE; @@ -1280,7 +1280,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 (fp = &factions; *fp;) { faction *f = *fp; if (!is_monsters(f)) { @@ -1621,7 +1621,7 @@ int display_cmd(unit * u, struct order *ord) free(*s); if (s2) { - *s = _strdup(s2); + *s = strdup(s2); if (strlen(s2) >= DISPLAYSIZE) { (*s)[DISPLAYSIZE] = 0; } @@ -1665,7 +1665,7 @@ static int rename_cmd(unit * u, order * ord, char **s, const char *s2) unicode_utf8_trim(name); free(*s); - *s = _strdup(name); + *s = strdup(name); return 0; } @@ -2154,7 +2154,7 @@ int banner_cmd(unit * u, struct order *ord) const char * s = getstrtoken(); free(u->faction->banner); - u->faction->banner = s ? _strdup(s) : 0; + u->faction->banner = s ? strdup(s) : 0; add_message(&u->faction->msgs, msg_message("changebanner", "value", u->faction->banner)); @@ -2356,23 +2356,23 @@ static void display_race(unit * u, const race * rc) } } if (rc->battle_flags & BF_EQUIPMENT) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment"))) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment"))) != 0) WARN_STATIC_BUFFER(); } if (rc->battle_flags & BF_RES_PIERCE) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce"))) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce"))) != 0) WARN_STATIC_BUFFER(); } if (rc->battle_flags & BF_RES_CUT) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut"))) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut"))) != 0) WARN_STATIC_BUFFER(); } if (rc->battle_flags & BF_RES_BASH) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash"))) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash"))) != 0) WARN_STATIC_BUFFER(); } - if (wrptr(&bufp, &size, _snprintf(bufp, size, " %d %s", at_count, LOC(f->locale, (at_count == 1) ? "stat_attack" : "stat_attacks"))) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " %d %s", at_count, LOC(f->locale, (at_count == 1) ? "stat_attack" : "stat_attacks"))) != 0) WARN_STATIC_BUFFER(); for (a = 0; a < RACE_ATTACKS; a++) { @@ -2385,12 +2385,12 @@ static void display_race(unit * u, const race * rc) switch (rc->attack[a].type) { case AT_STANDARD: bytes = - (size_t)_snprintf(bufp, size, "%s (%s)", + (size_t)snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_standard"), rc->def_damage); break; case AT_NATURAL: bytes = - (size_t)_snprintf(bufp, size, "%s (%s)", + (size_t)snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_natural"), rc->attack[a].data.dice); break; case AT_SPELL: @@ -2398,11 +2398,11 @@ static void display_race(unit * u, const race * rc) case AT_DRAIN_ST: case AT_DRAIN_EXP: case AT_DAZZLE: - bytes = (size_t)_snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical")); + bytes = (size_t)snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical")); break; case AT_STRUCTURAL: bytes = - (size_t)_snprintf(bufp, size, "%s (%s)", + (size_t)snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_structural"), rc->attack[a].data.dice); break; default: @@ -2670,7 +2670,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 = gettoken(token, sizeof(token)); } @@ -2903,14 +2903,14 @@ static void age_stonecircle(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 { int sk = effskill(mage, SK_MAGIC, 0); - c->duration = _max(c->duration, sk / 2); - c->vigour = _max(c->vigour, (float)sk); + c->duration = MAX(c->duration, sk / 2); + c->vigour = MAX(c->vigour, (float)sk); } } } @@ -2955,12 +2955,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)) { @@ -3034,7 +3034,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) @@ -3130,7 +3130,7 @@ void new_units(void) s = gettoken(token, sizeof(token)); if (s && s[0]) { - name = _strdup(s); + name = strdup(s); } u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u); if (name != NULL) @@ -3361,7 +3361,7 @@ void monthly_healing(void) p *= heal_factor(u); if (u->hp < umhp) { - double maxheal = _max(u->number, umhp / 20.0); + double maxheal = MAX(u->number, umhp / 20.0); int addhp; if (active_building(u, bt_find("inn"))) { p *= 1.5; @@ -3376,7 +3376,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); @@ -3701,7 +3701,7 @@ int claim_cmd(unit * u, struct order *ord) if (itype) { item **iclaim = i_find(&u->faction->items, itype); if (iclaim && *iclaim) { - n = _min(n, (*iclaim)->number); + n = MIN(n, (*iclaim)->number); i_change(iclaim, itype, -n); i_change(&u->items, itype, n); } @@ -3962,7 +3962,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; @@ -3998,9 +3998,9 @@ int siege_cmd(unit * u, order * ord) rt_catapult = rt_find("catapult"); d = i_get(u->items, rt_catapult->itype); - d = _min(u->number, d); + d = MIN(u->number, d); pooled = get_pooled(u, rt_catapultammo, GET_DEFAULT, d); - d = _min(pooled, d); + d = MIN(pooled, d); if (effskill(u, SK_CATAPULT, 0) >= 1) { katapultiere = d; d *= effskill(u, SK_CATAPULT, 0); @@ -4027,11 +4027,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))) { @@ -4270,7 +4270,7 @@ void processorders(void) void update_subscriptions(void) { FILE *F; - char zText[MAX_PATH]; + char zText[4096]; join_path(basepath(), "subscriptions", zText, sizeof(zText)); F = fopen(zText, "r"); diff --git a/src/laws.h b/src/laws.h index 0adb010d2..f05c11ab4 100755 --- a/src/laws.h +++ b/src/laws.h @@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define H_GC_LAWS #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/lighthouse.c b/src/lighthouse.c index 09c9b7d11..d29d58b71 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -83,8 +83,8 @@ int lighthouse_range(const building * b, const faction * f) } else if (f == NULL || u->faction == f) { int sk = effskill(u, SK_PERCEPTION, 0) / 3; - d = _max(d, sk); - d = _min(maxd, d); + d = MAX(d, sk); + d = MIN(maxd, d); if (d == maxd) break; } diff --git a/src/lighthouse.h b/src/lighthouse.h index 3bf970bf1..f2974ddf1 100644 --- a/src/lighthouse.h +++ b/src/lighthouse.h @@ -19,6 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef LIGHTHOUSE_H #define LIGHTHOUSE_H +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/listbox.c b/src/listbox.c index 332041454..057240fad 100644 --- a/src/listbox.c +++ b/src/listbox.c @@ -27,7 +27,7 @@ insert_selection(list_selection ** p_sel, list_selection * prev, const char *str, void *payload) { list_selection *sel = calloc(sizeof(list_selection), 1); - sel->str = _strdup(str); + sel->str = strdup(str); sel->data = payload; if (*p_sel) { list_selection *s; diff --git a/src/magic.c b/src/magic.c index dbdc1abe8..f2992538c 100644 --- a/src/magic.c +++ b/src/magic.c @@ -118,7 +118,7 @@ static double MagicPower(double force) if (force > 0) { const char *str = config_get("magic.power"); double value = str ? atof(str) : 1.0; - return _max(value * force, 1.0f); + return MAX(value * force, 1.0f); } return 0; } @@ -146,7 +146,7 @@ static void a_writeicastle(const attrib * a, const void *owner, struct storage *store) { icastle_data *data = (icastle_data *)a->data.v; - unused_arg(owner); + UNUSED_ARG(owner); WRITE_TOK(store, data->type->_name); WRITE_INT(store, data->time); } @@ -543,7 +543,7 @@ int get_combatspelllevel(const unit * u, int nr) assert(nr < MAXCOMBATSPELLS); if (m) { int level = effskill(u, SK_MAGIC, 0); - return _min(m->combatspells[nr].level, level); + return MIN(m->combatspells[nr].level, level); } return -1; } @@ -679,7 +679,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; @@ -739,7 +739,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) @@ -774,7 +774,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; } @@ -867,7 +867,7 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range) } 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 */ } @@ -885,7 +885,7 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range) if (sb) { spellbook_entry * sbe = spellbook_get(sb, 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)); @@ -1103,7 +1103,7 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order } } } - return _max(force, 0); + return MAX(force, 0); } /* ------------------------------------------------------------- */ @@ -1278,8 +1278,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 @@ -1421,7 +1421,7 @@ static void do_fumble(castorder * co) case 2: /* temporary skill loss */ - duration = _max(rng_int() % level / 2, 2); + duration = MAX(rng_int() % level / 2, 2); effect = level / -2.0; c = create_curse(u, &u->attribs, ct_find("skillmod"), level, duration, effect, 1); @@ -1529,14 +1529,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)); } } } @@ -1853,7 +1853,7 @@ static int addparam_string(const char *const param[], spllprm ** spobjp) spobj->flag = 0; spobj->typ = SPP_STRING; - spobj->data.xs = _strdup(param[0]); + spobj->data.xs = strdup(param[0]); return 1; } @@ -2428,7 +2428,7 @@ static int age_unit(attrib * a, void *owner) /* if unit is gone or dead, remove the attribute */ { unit *u = (unit *)a->data.v; - unused_arg(owner); + UNUSED_ARG(owner); return (u != NULL && u->number > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } @@ -2567,7 +2567,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" */ syntax_error(u, ord); @@ -2597,7 +2597,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" */ syntax_error(u, ord); @@ -2728,7 +2728,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, effskill(caster, SK_MAGIC, 0) / 2); + level = MIN(level, effskill(caster, SK_MAGIC, 0) / 2); } } /* Weitere Argumente zusammenbasteln */ @@ -2751,7 +2751,7 @@ static castorder *cast_cmd(unit * u, order * ord) break; } } - params[p++] = _strdup(s); + params[p++] = strdup(s); } params[p] = 0; args = diff --git a/src/magic.h b/src/magic.h index d1ae286d0..f62c533bd 100644 --- a/src/magic.h +++ b/src/magic.h @@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define H_KRNL_MAGIC #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/market.test.c b/src/market.test.c index 43e070b5e..6f1d74b88 100644 --- a/src/market.test.c +++ b/src/market.test.c @@ -46,7 +46,7 @@ static void test_market_curse(CuTest * tc) config_set("rules.region_owners", "1"); btype = (building_type *)calloc(1, sizeof(building_type)); - btype->_name = _strdup("market"); + btype->_name = strdup("market"); bt_register(btype); terrain = get_terrain("plain"); diff --git a/src/modules/arena.c b/src/modules/arena.c index a912d273a..fbc3f0673 100644 --- a/src/modules/arena.c +++ b/src/modules/arena.c @@ -99,9 +99,9 @@ order * ord) if (u->building != arena_tower(u->faction->magiegebiet) && leave_fail(u)) { return -1; } - unused_arg(amount); - unused_arg(ord); - unused_arg(itype); + UNUSED_ARG(amount); + UNUSED_ARG(ord); + UNUSED_ARG(itype); assert(!"not implemented"); return 0; } @@ -120,9 +120,9 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord) region *r = u->region; unit *u2; int fee = 2000; - unused_arg(ord); - unused_arg(amount); - unused_arg(itype); + UNUSED_ARG(ord); + UNUSED_ARG(amount); + UNUSED_ARG(itype); if (u->faction->score > fee * 5) { score_t score = u->faction->score / 5; if (score < INT_MAX) { @@ -212,7 +212,7 @@ static int caldera_handle(trigger * t, void *data) else { log_error("could not perform caldera::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 925fae349..1e2d2d23f 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -199,7 +199,7 @@ newfaction *read_newfactions(const char *filename) free(nf); continue; } - nf->password = _strdup(password); + nf->password = strdup(password); nf->race = rc_find(race); nf->subscription = subscription; if (alliances != NULL) { @@ -962,8 +962,8 @@ int build_island_e3(newfaction ** players, int x, int y, int numfactions, int mi q = region_quality(r, rn); if (q >= MIN_QUALITY && nfactions < numfactions && *players) { starting_region(players, r, rn); - minq = _min(minq, q); - maxq = _max(maxq, q); + minq = MIN(minq, q); + maxq = MAX(maxq, q); ++nfactions; } } @@ -977,8 +977,8 @@ int build_island_e3(newfaction ** players, int x, int y, int numfactions, int mi q = region_quality(r, rn); if (q >= MIN_QUALITY * 4 / 3 && nfactions < numfactions && *players) { starting_region(players, r, rn); - minq = _min(minq, q); - maxq = _max(maxq, q); + minq = MIN(minq, q); + maxq = MAX(maxq, q); ++nfactions; } } diff --git a/src/modules/museum.c b/src/modules/museum.c index e934a71a4..af37019d0 100644 --- a/src/modules/museum.c +++ b/src/modules/museum.c @@ -310,7 +310,7 @@ order * ord) unit *warden = findunit(atoi36("mwar")); int unit_cookie; - unused_arg(amount); + UNUSED_ARG(amount); /* Prfen ob in Eingangshalle */ if (u->region->x != 9525 || u->region->y != 9525) { @@ -365,7 +365,7 @@ order * ord) region *r = u->region; plane *pl = rplane(r); - unused_arg(amount); + UNUSED_ARG(amount); /* Pruefen ob in normaler Plane und nur eine Person */ if (pl != get_homeplane()) { @@ -417,8 +417,8 @@ static const char *b_namequestportal(const connection * b, const region * r, { const char *bname; int lock = b->data.i; - unused_arg(b); - unused_arg(r); + UNUSED_ARG(b); + UNUSED_ARG(r); if (gflags & GF_ARTICLE) { if (lock > 0) { diff --git a/src/modules/score.c b/src/modules/score.c index 8213b8985..0776d6507 100644 --- a/src/modules/score.c +++ b/src/modules/score.c @@ -67,7 +67,7 @@ void score(void) region *r; faction *fc; score_t allscores = 0; - char path[MAX_PATH]; + char path[4096]; for (fc = factions; fc; fc = fc->next) fc->score = 0; diff --git a/src/monsters.c b/src/monsters.c index 829c1ed35..bba1cbd50 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -100,7 +100,7 @@ static void reduce_weight(unit * u) int horses = get_resource(u, get_resourcetype(R_HORSE)); if (horses > 0) { - horses = _min(horses, (u->number * 2)); + horses = MIN(horses, (u->number * 2)); change_resource(u, get_resourcetype(R_HORSE), -horses); } @@ -129,7 +129,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_peasants(u, itm->type, reduce); weight -= reduce * itype->weight; } @@ -144,7 +144,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_peasants(u, itm->type, reduce); weight -= reduce * itype->weight; } @@ -1027,7 +1027,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); @@ -1047,7 +1047,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); @@ -1062,7 +1062,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. @@ -1074,7 +1074,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); @@ -1102,7 +1102,7 @@ static void scared_by_monster(unit * u) } if (n > 0) { n = lovar(n); - n = _min(rpeasants(u->region), n); + n = MIN(rpeasants(u->region), n); if (n > 0) { n = scareaway(u->region, n); if (n > 0) { diff --git a/src/morale.c b/src/morale.c index 8dc22ccb5..1bdf2363d 100644 --- a/src/morale.c +++ b/src/morale.c @@ -73,7 +73,7 @@ void morale_update(region *r) { void morale_change(region *r, int value) { int morale = region_get_morale(r); if (morale > 0) { - morale = _max(0, morale - value); + morale = MAX(0, morale - value); region_set_morale(r, morale, turn); } } diff --git a/src/move.c b/src/move.c index 126557d58..62300beb1 100644 --- a/src/move.c +++ b/src/move.c @@ -151,8 +151,8 @@ static void shiptrail_finalize(attrib * a) static int shiptrail_age(attrib * a, void *owner) { traveldir *t = (traveldir *)(a->data.v); - unused_arg(owner); + (void)owner; t->age--; return (t->age > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } @@ -267,12 +267,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, 0) * u->number * 2); + animals = MIN(animals, effskill(u, SK_RIDING, 0) * 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; } @@ -291,7 +291,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, 0) * u->number * 4); + pferde_fuer_wagen = MIN(animals, effskill(u, SK_RIDING, 0) * u->number * 4); if (fval(u_race(u), RCF_HORSE)) { animals += u->number; people = 0; @@ -301,7 +301,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; @@ -311,7 +311,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; @@ -335,7 +335,7 @@ int walkingcapacity(const struct unit *u) int belts = i_get(u->items, rbelt->itype); if (belts) { int multi = config_get_int("rules.trollbelt.multiplier", STRENGTHMULTIPLIER); - n += _min(people, belts) * (multi - 1) * u_race(u)->capacity; + n += MIN(people, belts) * (multi - 1) * u_race(u)->capacity; } } @@ -366,7 +366,7 @@ static int canwalk(unit * u) effsk = effskill(u, SK_RIDING, 0); maxwagen = effsk * u->number * 2; if (u_race(u) == get_race(RC_TROLL)) { - maxwagen = _max(maxwagen, u->number / 4); + maxwagen = MAX(maxwagen, u->number / 4); } maxpferde = effsk * u->number * 4 + u->number; @@ -505,7 +505,7 @@ static double overload(const region * r, ship * sh) double ovl = n / (double)sh->type->cargo; if (mcabins) - ovl = _max(ovl, p / (double)mcabins); + ovl = MAX(ovl, p / (double)mcabins); return ovl; } } @@ -752,7 +752,7 @@ double damage_overload(double overload) badness = overload - overload_worse(); if (badness >= 0) { assert(overload_worst() > overload_worse() || !"overload.worst must be > overload.worse"); - damage += _min(badness, overload_worst() - overload_worse()) * + damage += MIN(badness, overload_worst() - overload_worse()) * (overload_max_damage() - damage) / (overload_worst() - overload_worse()); } @@ -946,7 +946,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r) guard_count += u->number; double prob_u = (sk - stealth) * skill_prob; /* amulet counts at most once */ - prob_u += _min(1, _min(u->number, i_get(u->items, ramulet->itype))) * amulet_prob; + prob_u += MIN(1, MIN(u->number, i_get(u->items, ramulet->itype))) * amulet_prob; if (u->building && (u->building->type == castle_bt) && u == building_owner(u->building)) prob_u += castle_prob*buildingeffsize(u->building, 0); if (prob_u >= prob) { @@ -1985,7 +1985,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) const luxury_type *ltype = resource2luxury(itm->type->rtype); if (ltype != NULL && itm->number > 0) { int st = itm->number * effskill(harbourmaster, SK_TRADE, 0) / 50; - st = _min(itm->number, st); + st = MIN(itm->number, st); if (st > 0) { i_change(&u2->items, itm->type, -st); diff --git a/src/move.h b/src/move.h index 14c040493..4d0b4e9f2 100644 --- a/src/move.h +++ b/src/move.h @@ -16,11 +16,12 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ +#include "direction.h" +#include + #ifndef H_KRNL_MOVEMENT #define H_KRNL_MOVEMENT -#include "direction.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/src/names.c b/src/names.c index cf1cdb910..248084828 100644 --- a/src/names.c +++ b/src/names.c @@ -365,7 +365,7 @@ static void dracoid_name(unit * u) size_t sz; /* ignore u */ - unused_arg(u); + UNUSED_ARG(u); /* Wieviele Mittelteile? */ mid_syllabels = rng_int() % 4; @@ -425,8 +425,8 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) } } - /* Buchstaben pro Teilkrzel = _max(1,max/AnzWort) */ - bpt = (c > 0) ? _max(1, maxchars / c) : 1; + /* Buchstaben pro Teilkrzel = MAX(1,max/AnzWort) */ + bpt = (c > 0) ? MAX(1, maxchars / c) : 1; /* Einzelne Wrter anspringen und jeweils die ersten BpT kopieren */ diff --git a/src/platform.h b/src/platform.h index c781021ae..2f114cec5 100644 --- a/src/platform.h +++ b/src/platform.h @@ -1,179 +1,15 @@ -/* -Copyright (c) 1998-2015, Enno Rehling - Katja Zedel +#pragma once -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. +#ifndef UNILIB_H +#define UNILIB_H -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef PLATFORM_H -#define PLATFORM_H - -#ifdef NDEBUG -#define LOMEM +#ifndef MAX_PATH +# define MAX_PATH 4096 #endif -// enable X/Open 7 extensions (like strdup): -#ifndef _XOPEN_SOURCE -#define _XOPEN_SOURCE 700 -#endif +#define UNUSED_ARG(a) (void)(a) -// enable bsd string extensions, since glibc 2.12 (_BSD_SOURCE is dead): -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200809L -#endif - -#ifndef USE_AUTOCONF -#define USE_AUTOCONF - -#ifdef _MSC_VER -#undef USE_AUTOCONF -#define HAVE_STDBOOL_H -#define HAVE_DIRECT__MKDIR -#define HAVE__ACCESS - -#define VC_EXTRALEAN -#define WIN32_LEAN_AND_MEAN -#pragma warning(push) -#pragma warning(disable:4820 4255 4668) -# include -# include -#pragma warning(pop) -# undef MOUSE_MOVED -# define STDIO_CP 1252 /* log.c, convert to console character set */ -# pragma warning (disable: 4201 4214 4514 4115 4711) -#if _MSC_VER >= 1900 -# pragma warning(disable: 4710) -/* warning C4710: function not inlined */ -# pragma warning(disable: 4456) -/* warning C4456 : declaration of hides previous local declaration */ -# pragma warning(disable: 4457) -/* warning C4457: declaration of hides function parameter */ -# pragma warning(disable: 4459) -/* warning C4459: declaration of hides global declaration */ -#endif -# pragma warning(disable: 4056) -/* warning C4056: overflow in floating point constant arithmetic */ -# pragma warning(disable: 4201) -/* warning C4201: nonstandard extension used : nameless struct/union */ -# pragma warning(disable: 4214) -/* warning C4214: nonstandard extension used : bit field types other than int */ -# pragma warning(disable: 4100) -/* warning C4100: : unreferenced formal parameter */ -# pragma warning(disable: 4996) -/* is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' */ -# pragma warning(disable: 4668) -/* : bytes padding after data member */ -# pragma warning(disable: 4820) - -/* warning C4100: was declared deprecated */ -#ifndef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_DEPRECATE -#endif - -/* - * http://msdn2.microsoft.com/en-us/library/ms235505(VS.80).aspx - * Defining _CRT_DISABLE_PERFCRIT_LOCKS forces all I/O operations to assume a - * single-threaded I/O model and use the _nolock forms of the functions. - */ -#ifndef _CRT_DISABLE_PERFCRIT_LOCKS -#define _CRT_DISABLE_PERFCRIT_LOCKS -#endif - -#elif __GNUC__ -#undef USE_AUTOCONF -#define HAVE_SNPRINTF -#define HAVE_SYS_STAT_MKDIR -#define HAVE_STRDUP -#define HAVE_UNISTD_H -#endif -#endif - -#ifdef USE_AUTOCONF -// unknown toolchain, using autoconf -#include -#endif - -#define unused_arg (void) - -#define iswxspace(c) (c==160 || iswspace(c)) -#define isxspace(c) (c==160 || isspace(c)) - -#define TOLUA_CAST (char*) - -#if !defined(MAX_PATH) -#if defined(PATH_MAX) -# define MAX_PATH PATH_MAX -#else -# define MAX_PATH 256 -#endif -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - -#if defined(HAVE_STDBOOL_H) -# include -#else -# ifndef 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) -#endif -#endif - -#if defined(HAVE_DIRECT__MKDIR) -#include -#elif defined(HAVE_DIRECT_MKDIR) -#include -#define _mkdir(a) mkdir(a) -#elif defined(HAVE_SYS_STAT_MKDIR) -#include -#define _mkdir(a) mkdir(a, 0777) -#endif - -#ifndef _min -#define _min(a,b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef _max -#define _max(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#if !defined(HAVE__STRDUP) -#if defined(HAVE_STRDUP) -#undef _strdup -#define _strdup strdup -#endif -#endif - -#if !defined(HAVE__SNPRINTF) -#if defined(HAVE_SNPRINTF) -#define _snprintf snprintf -#endif -#endif +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif - diff --git a/src/prefix.c b/src/prefix.c index a6564b6e8..1a22e6982 100644 --- a/src/prefix.c +++ b/src/prefix.c @@ -30,7 +30,7 @@ int add_raceprefix(const char *prefix) race_prefixes = tmp; size *= 2; } - race_prefixes[next++] = _strdup(prefix); + race_prefixes[next++] = strdup(prefix); race_prefixes[next] = NULL; return 0; } diff --git a/src/races/dragons.c b/src/races/dragons.c index 222d63c89..aa79a783a 100644 --- a/src/races/dragons.c +++ b/src/races/dragons.c @@ -22,7 +22,7 @@ /* util includes */ #include -#define age_chance(a,b,p) (_max(0,a-b)*p) +#define age_chance(a,b,p) (MAX(0,a-b)*p) #define DRAGONAGE 27 #define WYRMAGE 68 diff --git a/src/races/races.c b/src/races/races.c index 2c6cfffa9..8af9cf2ed 100644 --- a/src/races/races.c +++ b/src/races/races.c @@ -42,7 +42,7 @@ static void oldfamiliars(unit * u) char fname[64]; /* these familiars have no special skills. */ - _snprintf(fname, sizeof(fname), "%s_familiar", u_race(u)->_name); + snprintf(fname, sizeof(fname), "%s_familiar", u_race(u)->_name); create_mage(u, M_GRAY); equip_unit(u, get_equipment(fname)); } diff --git a/src/races/zombies.c b/src/races/zombies.c index 3e9303b38..ea26298b2 100644 --- a/src/races/zombies.c +++ b/src/races/zombies.c @@ -33,7 +33,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 make_undead_unit(unit * u) { @@ -70,7 +70,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, get_race(RC_SKELETON_LORD)); u->irace = NULL; @@ -82,7 +82,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, get_race(RC_ZOMBIE_LORD)); u->irace = NULL; @@ -94,7 +94,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, get_race(RC_GHOUL_LORD)); u->irace = NULL; diff --git a/src/randenc.c b/src/randenc.c index 536210b1f..ab51d64b1 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -785,7 +785,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)) { continue; } @@ -814,7 +814,7 @@ void randomevents(void) while (*blist) { building *b = *blist; if (fval(b->type, BTF_DECAY) && !building_owner(b)) { - b->size -= _max(1, (b->size * 20) / 100); + b->size -= MAX(1, (b->size * 20) / 100); if (b->size == 0) { remove_building(blist, r->buildings); } diff --git a/src/report.c b/src/report.c index 553e6cb94..503f12732 100644 --- a/src/report.c +++ b/src/report.c @@ -269,17 +269,17 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc /* Reihenfolge beachten: Erst REGION, dann STUFE! */ if (sp->sptyp & FARCASTING) { - bytes = _snprintf(bufp, size, " [%s x y]", LOC(lang, parameters[P_REGION])); + bytes = snprintf(bufp, size, " [%s x y]", LOC(lang, parameters[P_REGION])); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } if (sp->sptyp & SPELLLEVEL) { - bytes = _snprintf(bufp, size, " [%s n]", LOC(lang, parameters[P_LEVEL])); + bytes = snprintf(bufp, size, " [%s n]", LOC(lang, parameters[P_LEVEL])); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } - bytes = (int)_snprintf(bufp, size, " \"%s\"", spell_name(sp, lang)); + bytes = (int)snprintf(bufp, size, " \"%s\"", spell_name(sp, lang)); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -305,12 +305,12 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc if (cp == 'u') { targetp = targets + 1; locp = LOC(lang, targetp->vars); - bytes = (int)_snprintf(bufp, size, " <%s>", locp); + bytes = (int)snprintf(bufp, size, " <%s>", locp); if (*params == '+') { ++params; if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp); + bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -318,12 +318,12 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc else if (cp == 's') { targetp = targets + 2; locp = LOC(lang, targetp->vars); - bytes = (int)_snprintf(bufp, size, " <%s>", locp); + bytes = (int)snprintf(bufp, size, " <%s>", locp); if (*params == '+') { ++params; if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp); + bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -342,12 +342,12 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc else if (cp == 'b') { targetp = targets + 3; locp = LOC(lang, targetp->vars); - bytes = (int)_snprintf(bufp, size, " <%s>", locp); + bytes = (int)snprintf(bufp, size, " <%s>", locp); if (*params == '+') { ++params; if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp); + bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -382,17 +382,17 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc if (targetp->param && targetp->vars) { locp = LOC(lang, targetp->vars); bytes = - (int)_snprintf(bufp, size, " %s <%s>", parameters[targetp->param], + (int)snprintf(bufp, size, " %s <%s>", parameters[targetp->param], locp); if (multi) { if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp); + bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); } } else { bytes = - (int)_snprintf(bufp, size, " %s", parameters[targetp->param]); + (int)snprintf(bufp, size, " %s", parameters[targetp->param]); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -422,10 +422,10 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc } if (*params == '?') { ++params; - bytes = (int)_snprintf(bufp, size, " [<%s>]", locp); + bytes = (int)snprintf(bufp, size, " [<%s>]", locp); } else { - bytes = (int)_snprintf(bufp, size, " <%s>", locp); + bytes = (int)snprintf(bufp, size, " <%s>", locp); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -494,18 +494,18 @@ void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *la bufp = buf; if (sp->sptyp & SPELLLEVEL) { bytes = - _snprintf(bufp, size, " %d %s", itemanz, LOC(lang, resourcename(rtype, + snprintf(bufp, size, " %d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1))); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR) { - bytes = _snprintf(bufp, size, " * %s", LOC(lang, "nr_level")); + bytes = snprintf(bufp, size, " * %s", LOC(lang, "nr_level")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } } else { - bytes = _snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1))); + bytes = snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1))); if (wrptr(&bufp, &size, bytes) != 0) { WARN_STATIC_BUFFER(); } @@ -929,7 +929,7 @@ static void describe(struct stream *out, const region * r, faction * f) } if (!e) { e = calloc(sizeof(struct edge), 1); - e->name = _strdup(name); + e->name = strdup(name); e->transparent = transparent; e->next = edges; edges = e; @@ -945,13 +945,13 @@ static void describe(struct stream *out, const region * r, faction * f) WARN_STATIC_BUFFER(); if (r->seen.mode == seen_travel) { - bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel")); + bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel")); } else if (r->seen.mode == seen_neighbour) { - bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour")); + bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour")); } else if (r->seen.mode == seen_lighthouse) { - bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse")); + bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse")); } else { bytes = 0; @@ -974,7 +974,7 @@ static void describe(struct stream *out, const region * r, faction * f) saplings = rtrees(r, 1); if (production(r)) { if (trees > 0 || saplings > 0) { - bytes = _snprintf(bufp, size, ", %d/%d ", trees, saplings); + bytes = snprintf(bufp, size, ", %d/%d ", trees, saplings); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1004,7 +1004,7 @@ static void describe(struct stream *out, const region * r, faction * f) for (n = 0; n < numresults; ++n) { if (result[n].number >= 0 && result[n].level >= 0) { - bytes = _snprintf(bufp, size, ", %d %s/%d", result[n].number, + bytes = snprintf(bufp, size, ", %d %s/%d", result[n].number, LOC(f->locale, result[n].name), result[n].level); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1015,14 +1015,14 @@ static void describe(struct stream *out, const region * r, faction * f) /* peasants & silver */ if (rpeasants(r)) { int n = rpeasants(r); - bytes = _snprintf(bufp, size, ", %d", n); + bytes = snprintf(bufp, size, ", %d", n); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); if (r->land->ownership) { const char *str = LOC(f->locale, mkname("morale", itoa10(region_get_morale(r)))); - bytes = _snprintf(bufp, size, " %s", str); + bytes = snprintf(bufp, size, " %s", str); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } @@ -1041,7 +1041,7 @@ static void describe(struct stream *out, const region * r, faction * f) } } if (rmoney(r) && r->seen.mode >= seen_travel) { - bytes = _snprintf(bufp, size, ", %d ", rmoney(r)); + bytes = snprintf(bufp, size, ", %d ", rmoney(r)); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); bytes = @@ -1053,7 +1053,7 @@ static void describe(struct stream *out, const region * r, faction * f) /* Pferde */ if (rhorses(r)) { - bytes = _snprintf(bufp, size, ", %d ", rhorses(r)); + bytes = snprintf(bufp, size, ", %d ", rhorses(r)); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); bytes = @@ -1141,7 +1141,7 @@ static void describe(struct stream *out, const region * r, faction * f) if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); f_regionid(r2, f, regname, sizeof(regname)); - bytes = _snprintf(bufp, size, trailinto(r2, f->locale), regname); + bytes = snprintf(bufp, size, trailinto(r2, f->locale), regname); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } @@ -1453,7 +1453,7 @@ report_template(const char *filename, report_context * ctx, const char *bom) bufp = buf; size = sizeof(buf) - 1; - bytes = _snprintf(bufp, size, "%s %s; %s [%d,%d$", + bytes = snprintf(bufp, size, "%s %s; %s [%d,%d$", LOC(u->faction->locale, parameters[P_UNIT]), itoa36(u->no), unit_getname(u), u->number, get_money(u)); if (wrptr(&bufp, &size, bytes) != 0) @@ -1631,7 +1631,7 @@ static void allies(struct stream *out, const faction * f) if (f->allies) { int bytes; size_t size = sizeof(buf); - bytes = _snprintf(buf, size, "%s ", LOC(f->locale, "faction_help")); + bytes = snprintf(buf, size, "%s ", LOC(f->locale, "faction_help")); size -= bytes; show_allies(f, f->allies, buf + bytes, size); paragraph(out, buf, 0, 0, 0); @@ -1642,7 +1642,7 @@ static void allies(struct stream *out, const faction * f) if (g->allies) { int bytes; size_t size = sizeof(buf); - bytes = _snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help")); + bytes = snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help")); size -= bytes; show_allies(f, g->allies, buf + bytes, size); paragraph(out, buf, 0, 0, 0); @@ -1781,12 +1781,12 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, getshipweight(sh, &n, &p); n = (n + 99) / 100; /* 1 Silber = 1 GE */ - bytes = _snprintf(bufp, size, "%s, %s, (%d/%d)", shipname(sh), + bytes = snprintf(bufp, size, "%s, %s, (%d/%d)", shipname(sh), LOC(f->locale, sh->type->_name), n, shipcapacity(sh) / 100); } else { bytes = - _snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale, + snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale, sh->type->_name)); } if (wrptr(&bufp, &size, bytes) != 0) @@ -1794,7 +1794,7 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, assert(sh->type->construction->improvement == NULL); /* sonst ist construction::size nicht ship_type::maxsize */ if (sh->size != sh->type->construction->maxsize) { - bytes = _snprintf(bufp, size, ", %s (%d/%d)", + bytes = snprintf(bufp, size, ", %s (%d/%d)", LOC(f->locale, "nr_undercons"), sh->size, sh->type->construction->maxsize); if (wrptr(&bufp, &size, bytes) != 0) @@ -1803,7 +1803,7 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, if (sh->damage) { int percent = ship_damage_percent(sh); bytes = - _snprintf(bufp, size, ", %d%% %s", percent, LOC(f->locale, "nr_damaged")); + snprintf(bufp, size, ", %d%% %s", percent, LOC(f->locale, "nr_damaged")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } @@ -1852,7 +1852,7 @@ nr_building(struct stream *out, const region *r, const building *b, const factio lang = f->locale; newline(out); bytes = - _snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang, + snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang, "nr_size"), b->size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1867,7 +1867,7 @@ nr_building(struct stream *out, const region *r, const building *b, const factio if (owner && owner->faction == f) { /* illusion. report real type */ name = LOC(lang, bname); - bytes = _snprintf(bufp, size, " (%s)", name); + bytes = snprintf(bufp, size, " (%s)", name); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } @@ -2168,7 +2168,7 @@ report_plaintext(const char *filename, report_context * ctx, bufp = buf; size = sizeof(buf) - 1; - bytes = _snprintf(buf, size, "%s:", LOC(f->locale, "nr_options")); + bytes = snprintf(buf, size, "%s:", LOC(f->locale, "nr_options")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); for (op = 0; op != MAXOPTIONS; op++) { @@ -2220,14 +2220,14 @@ report_plaintext(const char *filename, report_context * ctx, newline(out); centre(out, LOC(f->locale, pname), true); - _snprintf(buf, sizeof(buf), "%s %d", LOC(f->locale, "nr_level"), + snprintf(buf, sizeof(buf), "%s %d", LOC(f->locale, "nr_level"), ptype->level); centre(out, buf, true); newline(out); bufp = buf; size = sizeof(buf) - 1; - bytes = _snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired")); + bytes = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); diff --git a/src/report.test.c b/src/report.test.c index 555d39408..aa3c52695 100644 --- a/src/report.test.c +++ b/src/report.test.c @@ -139,7 +139,7 @@ static void cleanup_spell_fixture(spell_fixture *spf) { static void set_parameter(spell_fixture spell, char *value) { free(spell.sp->parameter); - spell.sp->parameter = _strdup(value); + spell.sp->parameter = strdup(value); } static void check_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char *syntax) { @@ -210,14 +210,14 @@ static void test_write_spell_syntax(CuTest *tc) { set_parameter(spell, "bc"); free(spell.sp->syntax); - spell.sp->syntax = _strdup("hodor"); + spell.sp->syntax = strdup("hodor"); check_spell_syntax(tc, "bc hodor", &spell, " ZAUBERE \"Testzauber\" "); free(spell.sp->syntax); spell.sp->syntax = 0; set_parameter(spell, "c?"); free(spell.sp->syntax); - spell.sp->syntax = _strdup("hodor"); + spell.sp->syntax = strdup("hodor"); check_spell_syntax(tc, "c?", &spell, " ZAUBERE \"Testzauber\" []"); free(spell.sp->syntax); spell.sp->syntax = 0; diff --git a/src/reports.c b/src/reports.c index fa8a722d9..a9695145b 100644 --- a/src/reports.c +++ b/src/reports.c @@ -529,7 +529,7 @@ size_t size) if (a_otherfaction && alliedunit(u, f, HELP_FSTEALTH)) { faction *f = get_otherfaction(a_otherfaction); int result = - _snprintf(bufp, size, ", %s (%s)", factionname(f), + snprintf(bufp, size, ", %s (%s)", factionname(f), factionname(u->faction)); if (wrptr(&bufp, &size, result) != 0) WARN_STATIC_BUFFER(); @@ -544,7 +544,7 @@ size_t size) bufp = STRLCPY(bufp, ", ", size); - if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d ", u->number))) + if (wrptr(&bufp, &size, snprintf(bufp, size, "%d ", u->number))) WARN_STATIC_BUFFER(); pzTmp = get_racename(u->attribs); @@ -641,7 +641,7 @@ size_t size) bufp = STRLCPY(bufp, ", ", size); if (!dh) { - result = _snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_inventory")); + result = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_inventory")); if (wrptr(&bufp, &size, result) != 0) WARN_STATIC_BUFFER(); dh = 1; @@ -650,7 +650,7 @@ size_t size) bufp = STRLCPY(bufp, ic, size); } else { - if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d %s", in, ic))) + if (wrptr(&bufp, &size, snprintf(bufp, size, "%d %s", in, ic))) WARN_STATIC_BUFFER(); } } @@ -661,7 +661,7 @@ size_t size) if (book) { selist *ql = book->spells; int qi, header, maxlevel = effskill(u, SK_MAGIC, 0); - int result = _snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u)); + int result = snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u)); if (wrptr(&bufp, &size, result) != 0) { WARN_STATIC_BUFFER(); } @@ -671,7 +671,7 @@ size_t size) if (sbe->level <= maxlevel) { int result = 0; if (!header) { - result = _snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells")); + result = snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells")); header = 1; } else { @@ -690,7 +690,7 @@ size_t size) } if (i != MAXCOMBATSPELLS) { int result = - _snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_combatspells")); + snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_combatspells")); if (wrptr(&bufp, &size, result) != 0) WARN_STATIC_BUFFER(); @@ -708,7 +708,7 @@ size_t size) int sl = get_combatspelllevel(u, i); bufp = STRLCPY(bufp, spell_name(sp, u->faction->locale), size); if (sl > 0) { - result = _snprintf(bufp, size, " (%d)", sl); + result = snprintf(bufp, size, " (%d)", sl); if (wrptr(&bufp, &size, result) != 0) WARN_STATIC_BUFFER(); } @@ -819,13 +819,13 @@ const struct unit * u, struct skill * sv, int *dh, int days) if (sv->id == SK_STEALTH && fval(u, UFL_STEALTH)) { i = u_geteffstealth(u); if (i >= 0) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d/", i)) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, "%d/", i)) != 0) WARN_STATIC_BUFFER(); } } effsk = eff_skill(u, sv, 0); - if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d", effsk)) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, "%d", effsk)) != 0) WARN_STATIC_BUFFER(); if (u->faction->options & want(O_SHOWSKCHANGE)) { @@ -836,11 +836,11 @@ const struct unit * u, struct skill * sv, int *dh, int days) 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) { - if (wrptr(&bufp, &size, _snprintf(bufp, size, " (%s%d)", (diff > 0) ? "+" : "", diff)) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, " (%s%d)", (diff > 0) ? "+" : "", diff)) != 0) WARN_STATIC_BUFFER(); } } @@ -877,7 +877,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned firstline = false; } if (!cut) { - cut = s + _min(len, REPORTWIDTH); + cut = s + MIN(len, REPORTWIDTH); } memcpy(buf + indent, s, cut - s); buf[indent + (cut - s)] = 0; @@ -1411,7 +1411,7 @@ int write_reports(faction * f, time_t ltime) int error = 0; do { char filename[32]; - char path[MAX_PATH]; + char path[4096]; sprintf(filename, "%d-%s.%s", turn, itoa36(f->no), rtype->extension); join_path(reportpath(), filename, path, sizeof(path)); @@ -1481,7 +1481,7 @@ int reports(void) FILE *mailit; time_t ltime = time(NULL); int retval = 0; - char path[MAX_PATH]; + char path[4096]; const char * rpath = reportpath(); log_info("Writing reports for turn %d:", turn); @@ -1508,7 +1508,7 @@ int reports(void) static variant var_copy_string(variant x) { - x.v = x.v ? _strdup((const char *)x.v) : 0; + x.v = x.v ? strdup((const char *)x.v) : 0; return x; } @@ -1612,7 +1612,7 @@ f_regionid(const region * r, const faction * f, char *buffer, size_t size) pnormalize(&nx, &ny, pl); adjust_coordinates(f, &nx, &ny, pl); len = strlcpy(buffer, rname(r, f ? f->locale : 0), size); - _snprintf(buffer + len, size - len, " (%d,%d%s%s)", nx, ny, named ? "," : "", (named) ? name : ""); + snprintf(buffer + len, size - len, " (%d,%d%s%s)", nx, ny, named ? "," : "", (named) ? name : ""); buffer[size - 1] = 0; len = strlen(buffer); } @@ -1863,7 +1863,7 @@ static void eval_order(struct opstack **stack, const void *userdata) size_t len; variant var; - unused_arg(userdata); + UNUSED_ARG(userdata); write_order(ord, buf, sizeof(buf)); len = strlen(buf); var.v = strcpy(balloc(len + 1), buf); @@ -1883,7 +1883,7 @@ static void eval_resources(struct opstack **stack, const void *userdata) while (res != NULL && size > 4) { const char *rname = resourcename(res->type, (res->number != 1) ? NMF_PLURAL : 0); - int result = _snprintf(bufp, size, "%d %s", res->number, LOC(lang, rname)); + int result = snprintf(bufp, size, "%d %s", res->number, LOC(lang, rname)); if (wrptr(&bufp, &size, result) != 0 || size < sizeof(buf) / 2) { WARN_STATIC_BUFFER(); break; @@ -1947,7 +1947,7 @@ static void eval_trail(struct opstack **stack, const void *userdata) variant var; char *bufp = buf; #ifdef _SECURECRT_ERRCODE_VALUES_DEFINED - /* stupid MS broke _snprintf */ + /* stupid MS broke snprintf */ int eold = errno; #endif @@ -1958,7 +1958,7 @@ static void eval_trail(struct opstack **stack, const void *userdata) const char *trail = trailinto(r, lang); const char *rn = f_regionid_s(r, report); - if (wrptr(&bufp, &size, _snprintf(bufp, size, trail, rn)) != 0) + if (wrptr(&bufp, &size, snprintf(bufp, size, trail, rn)) != 0) WARN_STATIC_BUFFER(); if (i + 2 < end) { @@ -2014,7 +2014,7 @@ static void eval_int36(struct opstack **stack, const void *userdata) var.v = strcpy(balloc(len + 1), c); opush(stack, var); - unused_arg(userdata); + UNUSED_ARG(userdata); } /*** END MESSAGE RENDERING ***/ diff --git a/src/skill.h b/src/skill.h index 8b0c0c155..24f96a844 100644 --- a/src/skill.h +++ b/src/skill.h @@ -3,7 +3,7 @@ #ifndef H_SKILL_H #define H_SKILL_H -#include +#include struct locale; typedef enum { diff --git a/src/spells.c b/src/spells.c index 7e7b5669a..6ed38d022 100644 --- a/src/spells.c +++ b/src/spells.c @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -149,7 +150,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 */ @@ -190,7 +191,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) { @@ -231,7 +232,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) { @@ -272,7 +273,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) { @@ -704,7 +705,7 @@ static int sp_destroy_magic(castorder * co) "unit region command", mage, mage->region, co->order)); } - return _max(succ, 1); + return MAX(succ, 1); } /* ------------------------------------------------------------- */ @@ -773,7 +774,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; @@ -912,7 +913,7 @@ static int sp_summonent(castorder * co) return 0; } - ents = _min((int)(power * power), rtrees(r, 2)); + ents = MIN((int)(power * power), rtrees(r, 2)); u = create_unit(r, mage->faction, ents, get_race(RC_TREEMAN), 0, NULL, mage); @@ -1304,7 +1305,7 @@ static int sp_rosthauch(castorder * co) for (; iweapon != NULL; iweapon = iweapon->next) { item **ip = i_find(&u->items, iweapon->type); if (*ip) { - float chance = (float)_min((*ip)->number, force); + float chance = (float)MIN((*ip)->number, force); if (iweapon->chance < 1.0) { chance *= iweapon->chance; } @@ -1343,7 +1344,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); } /* ------------------------------------------------------------- */ @@ -1373,7 +1374,7 @@ static int sp_kaelteschutz(castorder * co) unit *mage = co->magician.u; int cast_level = co->level; double force = co->force; - int duration = _max(cast_level, (int)force) + 1; + int duration = MAX(cast_level, (int)force) + 1; spellparameter *pa = co->par; double effect; @@ -2137,8 +2138,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 { double effect = 4.0; @@ -2335,8 +2336,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? */ @@ -2501,7 +2502,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 * @@ -2529,7 +2530,7 @@ static int sp_fumblecurse(castorder * co) rx = rng_int() % 3; sx = cast_level - effskill(target, SK_MAGIC, 0); - duration = _max(sx, rx) + 1; + duration = MAX(sx, rx) + 1; effect = force / 2; c = create_curse(mage, &target->attribs, ct_find("fumble"), @@ -2695,8 +2696,8 @@ static int sp_firewall(castorder * co) } 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 */ @@ -2938,7 +2939,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 @@ -3361,7 +3362,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 = get_race(RC_SKELETON); @@ -3409,7 +3410,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)) { @@ -3792,8 +3793,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); @@ -4032,13 +4033,13 @@ static int sp_recruit(castorder * co) n = (pow(force, 1.6) * 100) / f->race->recruitcost; if (rc->recruit_multi > 0) { double multp = (double)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); } @@ -4083,13 +4084,13 @@ static int sp_bigrecruit(castorder * co) n = (int)force + lovar((force * force * 1000) / (float)f->race->recruitcost); if (f->race == get_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); } @@ -4178,7 +4179,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 * @@ -4215,8 +4216,8 @@ static int sp_seduce(castorder * co) int loot; if (itm->type->rtype == rsilver) { 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; @@ -4224,7 +4225,7 @@ static int sp_seduce(castorder * co) loot += rng_int() % 2; } if (loot > 0) { - loot = _min(loot, (int)(force * 5)); + loot = MIN(loot, (int)(force * 5)); } } if (loot > 0) { @@ -4341,7 +4342,7 @@ static int sp_headache(castorder * co) } if (smax != NULL) { /* wirkt auf maximal 10 Personen */ - unsigned int change = _min(10, target->number) * (rng_uint() % 2 + 1) / target->number; + unsigned int change = MIN(10, target->number) * (rng_uint() % 2 + 1) / target->number; reduce_skill(target, smax, change); } set_order(&target->thisorder, NULL); @@ -4385,7 +4386,7 @@ static int sp_raisepeasants(castorder * co) "error_nopeasants", "")); return 0; } - bauern = _min(rpeasants(r), (int)(power * 250)); + bauern = MIN(rpeasants(r), (int)(power * 250)); rsetpeasants(r, rpeasants(r) - bauern); u2 = @@ -4468,7 +4469,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); @@ -4713,7 +4714,7 @@ static int sp_gbdreams(castorder * co, const char *curse_name, int effect) /* 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. */ @@ -4752,7 +4753,7 @@ int sp_clonecopy(castorder * co) return 0; } - _snprintf(name, sizeof(name), (const char *)LOC(mage->faction->locale, + slprintf(name, sizeof(name), (const char *)LOC(mage->faction->locale, "clone_of"), unitname(mage)); clone = create_unit(target_region, mage->faction, 1, get_race(RC_CLONE), 0, name, @@ -4855,7 +4856,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. */ @@ -4969,7 +4970,7 @@ int sp_itemcloak(castorder * co) spellparameter *pa = co->par; int cast_level = co->level; double 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) @@ -5027,7 +5028,7 @@ int sp_resist_magic_bonus(castorder * co) u = pa->param[n]->data.u; - m = _min(u->number, victims); + m = MIN(u->number, victims); victims -= m; create_curse(mage, &u->attribs, ct_find("magicresistance"), @@ -5043,8 +5044,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'. @@ -5656,7 +5657,7 @@ int sp_showastral(castorder * co) free_regionlist(rl); return cast_level; - unused_arg(co); + UNUSED_ARG(co); return 0; } #endif @@ -5907,7 +5908,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); @@ -6216,7 +6217,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++) { double effect; @@ -6230,7 +6231,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; @@ -6241,7 +6242,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); } /* ------------------------------------------------------------- */ @@ -6324,7 +6325,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); } /* ------------------------------------------------------------- */ diff --git a/src/spells/borders.c b/src/spells/borders.c index 04f7e15f4..00019e92c 100644 --- a/src/spells/borders.c +++ b/src/spells/borders.c @@ -206,7 +206,7 @@ struct region *from, struct region *to, bool routing) 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", @@ -227,9 +227,9 @@ static const char *b_namefirewall(const connection * b, const region * r, const faction * f, int gflags) { const char *bname; - unused_arg(f); - unused_arg(r); - unused_arg(b); + UNUSED_ARG(f); + UNUSED_ARG(r); + UNUSED_ARG(b); if (gflags & GF_ARTICLE) bname = "a_firewall"; else diff --git a/src/spells/borders.h b/src/spells/borders.h index 31823df94..b14661b9f 100644 --- a/src/spells/borders.h +++ b/src/spells/borders.h @@ -1,5 +1,8 @@ #ifndef H_KRNL_CURSES #define H_KRNL_CURSES + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/spells/buildingcurse.c b/src/spells/buildingcurse.c index 01b0435ab..158383fd2 100644 --- a/src/spells/buildingcurse.c +++ b/src/spells/buildingcurse.c @@ -36,7 +36,7 @@ message *cinfo_building(const void *obj, objtype_t typ, const curse * c, int self) { const building *b = (const building *)obj; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_BUILDING); assert(obj); assert(c); diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index 10f1711ef..ccfc2346f 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -337,14 +337,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; @@ -921,7 +921,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 = @@ -1015,7 +1015,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; @@ -1050,7 +1050,7 @@ int sp_chaosrow(struct castorder * co) } k += df->alive; } - power = _max(0, power - n); + power = MAX(0, power - n); } selist_free(fgs); @@ -1154,12 +1154,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 = @@ -1208,7 +1208,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; @@ -1264,7 +1264,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); @@ -1545,7 +1545,7 @@ int sp_fumbleshield(struct castorder * co) case SPL_CERDDOR_FUMBLESHIELD: case SPL_TYBIED_FUMBLESHIELD: duration = 100; - effect = _max(1, 25 - level); + effect = MAX(1, 25 - level); break; default: @@ -1596,7 +1596,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 @@ -1649,7 +1649,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; } @@ -1680,10 +1680,10 @@ static int heal_fighters(selist * 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; @@ -1834,7 +1834,7 @@ int sp_undeadhero(struct castorder * co) } selist_free(fgs); - level = _min(level, undead); + level = MIN(level, undead); if (undead == 0) { msg = msg_message("summonundead_effect_0", "mage region", mage, mage->region); diff --git a/src/spells/flyingship.h b/src/spells/flyingship.h index 8b7bf0874..52013ac13 100644 --- a/src/spells/flyingship.h +++ b/src/spells/flyingship.h @@ -3,6 +3,8 @@ #ifndef FLYINGSHIP_H #define FLYINGSHIP_H +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/spells/regioncurse.c b/src/spells/regioncurse.c index 3d7593484..b10f3046f 100644 --- a/src/spells/regioncurse.c +++ b/src/spells/regioncurse.c @@ -45,8 +45,8 @@ static message *cinfo_cursed_by_the_gods(const void *obj, objtype_t typ, { region *r = (region *)obj; - unused_arg(typ); - unused_arg(self); + UNUSED_ARG(typ); + UNUSED_ARG(self); assert(typ == TYP_REGION); if (r->terrain->flags & SEA_REGION) { @@ -68,9 +68,9 @@ static struct curse_type ct_godcursezone = { static message *cinfo_dreamcurse(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(self); - unused_arg(typ); - unused_arg(obj); + UNUSED_ARG(self); + UNUSED_ARG(typ); + UNUSED_ARG(obj); assert(typ == TYP_REGION); if (c->effect > 0) { @@ -94,9 +94,9 @@ static struct curse_type ct_gbdream = { static message *cinfo_magicstreet(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); - unused_arg(self); - unused_arg(obj); + UNUSED_ARG(typ); + UNUSED_ARG(self); + UNUSED_ARG(obj); assert(typ == TYP_REGION); /* Warnung vor Auflsung */ @@ -117,9 +117,9 @@ static struct curse_type ct_magicstreet = { static message *cinfo_antimagiczone(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); - unused_arg(self); - unused_arg(obj); + UNUSED_ARG(typ); + UNUSED_ARG(self); + UNUSED_ARG(obj); assert(typ == TYP_REGION); /* Magier spren eine Antimagiezone */ @@ -139,7 +139,7 @@ const curse * c, int self) unit *u = NULL; unit *mage = c->magician; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_REGION); r = (region *)obj; @@ -167,8 +167,8 @@ static struct curse_type ct_antimagiczone = { static message *cinfo_farvision(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); - unused_arg(obj); + UNUSED_ARG(typ); + UNUSED_ARG(obj); assert(typ == TYP_REGION); diff --git a/src/spells/shipcurse.c b/src/spells/shipcurse.c index 59cc534d4..b6a722ad3 100644 --- a/src/spells/shipcurse.c +++ b/src/spells/shipcurse.c @@ -38,8 +38,8 @@ message *cinfo_ship(const void *obj, objtype_t typ, const curse * c, int self) { message *msg; - unused_arg(typ); - unused_arg(obj); + UNUSED_ARG(typ); + UNUSED_ARG(obj); assert(typ == TYP_SHIP); if (self != 0) { /* owner or inside */ @@ -62,7 +62,7 @@ static message *cinfo_shipnodrift(const void *obj, objtype_t typ, const curse * { ship *sh = (ship *)obj; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_SHIP); if (self != 0) { diff --git a/src/spells/unitcurse.c b/src/spells/unitcurse.c index 6e769145e..ded4a1676 100644 --- a/src/spells/unitcurse.c +++ b/src/spells/unitcurse.c @@ -46,7 +46,7 @@ static message *cinfo_auraboost(const void *obj, objtype_t typ, const curse * c, int self) { struct unit *u = (struct unit *)obj; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); if (self != 0) { @@ -80,7 +80,7 @@ static message *cinfo_slave(const void *obj, objtype_t typ, const curse * c, int self) { unit *u; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); u = (unit *)obj; @@ -104,7 +104,7 @@ cinfo_slave static message *cinfo_calm(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); if (c->magician && c->magician->faction) { @@ -133,7 +133,7 @@ static struct curse_type ct_calmmonster = { static message *cinfo_speed(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); if (self != 0) { @@ -156,7 +156,7 @@ static struct curse_type ct_speed = { */ message *cinfo_unit(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); assert(obj); @@ -181,7 +181,7 @@ static struct curse_type ct_orcish = { static message *cinfo_kaelteschutz(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); if (self != 0) { @@ -233,7 +233,7 @@ static message *cinfo_sparkle(const void *obj, objtype_t typ, const curse * c, }; int m, begin = 0, end = 0; unit *u; - unused_arg(typ); + UNUSED_ARG(typ); assert(typ == TYP_UNIT); u = (unit *)obj; @@ -324,7 +324,7 @@ write_skill(struct storage *store, const curse * c, const void *target) static message *cinfo_skillmod(const void *obj, objtype_t typ, const curse * c, int self) { - unused_arg(typ); + UNUSED_ARG(typ); if (self != 0) { unit *u = (unit *)obj; diff --git a/src/spy.c b/src/spy.c index 86476bec7..eb58f792a 100644 --- a/src/spy.c +++ b/src/spy.c @@ -146,7 +146,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 = effskill(u, SK_SPY, 0) - effskill(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); @@ -162,7 +162,7 @@ int spy_cmd(unit * u, struct order *ord) - (effskill(u, SK_STEALTH, 0) + effskill(u, SK_SPY, 0) / 2); if (invisible(u, target) >= u->number) { - observe = _min(observe, 0); + observe = MIN(observe, 0); } /* Anschliessend wird - unabhaengig vom Erfolg - gewuerfelt, ob der @@ -352,7 +352,7 @@ static int top_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 = effskill(u, sk, 0); - value = _max(s, value); + value = MAX(s, value); } } return value; diff --git a/src/sqlite.c b/src/sqlite.c index 6acaf4116..9379faa4f 100644 --- a/src/sqlite.c +++ b/src/sqlite.c @@ -94,9 +94,9 @@ read_factions(sqlite3 * db, int game_id) { text = (const char *)sqlite3_column_text(stmt, 1); if (text) dbf->no = atoi36(text); text = (const char *)sqlite3_column_text(stmt, 2); - if (text) dbf->name = _strdup(text); + if (text) dbf->name = strdup(text); text = (const char *)sqlite3_column_text(stmt, 3); - if (text) dbf->email = _strdup(text); + if (text) dbf->email = strdup(text); selist_push(&result, dbf); res = sqlite3_step(stmt); } diff --git a/src/study.c b/src/study.c index 58cd068f2..b69b4359f 100644 --- a/src/study.c +++ b/src/study.c @@ -201,7 +201,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); @@ -215,7 +215,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) { if (teach == NULL) { @@ -267,7 +267,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; @@ -303,7 +303,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); @@ -604,7 +604,7 @@ int study_cmd(unit * u, order * ord) } /* Akademie: */ if (active_building(u, bt_find("academy"))) { - studycost = _max(50, studycost * 2); + studycost = MAX(50, studycost * 2); } if (sk == SK_MAGIC) { @@ -691,11 +691,11 @@ int study_cmd(unit * u, order * ord) if (studycost) { int cost = studycost * u->number; money = get_pooled(u, get_resourcetype(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); @@ -715,12 +715,12 @@ int study_cmd(unit * u, order * ord) } if (get_effect(u, oldpotiontype[P_WISE])) { - l = _min(u->number, get_effect(u, oldpotiontype[P_WISE])); + l = MIN(u->number, get_effect(u, oldpotiontype[P_WISE])); teach->value += l * 10; change_effect(u, oldpotiontype[P_WISE], -l); } if (get_effect(u, oldpotiontype[P_FOOL])) { - l = _min(u->number, get_effect(u, oldpotiontype[P_FOOL])); + l = MIN(u->number, get_effect(u, oldpotiontype[P_FOOL])); teach->value -= l * 30; change_effect(u, oldpotiontype[P_FOOL], -l); } diff --git a/src/summary.c b/src/summary.c index 8a3ee3c41..32416a263 100644 --- a/src/summary.c +++ b/src/summary.c @@ -97,8 +97,8 @@ int update_nmrs(void) if (timeout>0) { if (nmr < 0 || nmr > timeout) { log_error("faction %s has %d NMR", itoa36(f->no), nmr); - nmr = _max(0, nmr); - nmr = _min(nmr, timeout); + nmr = MAX(0, nmr); + nmr = MIN(nmr, timeout); } if (nmr > 0) { log_debug("faction %s has %d NMR", itoa36(f->no), nmr); @@ -164,7 +164,7 @@ static char *gamedate2(const struct locale *lang) static void writeturn(void) { - char zText[MAX_PATH]; + char zText[4096]; FILE *f; join_path(basepath(), "datum", zText, sizeof(zText)); @@ -190,7 +190,7 @@ void report_summary(summary * s, summary * o, bool full) FILE *F = NULL; int i, newplayers = 0; faction *f; - char zText[MAX_PATH]; + char zText[4096]; int timeout = NMRTimeout(); if (full) { diff --git a/src/test_eressea.c b/src/test_eressea.c index 6d2dead3f..02d52c5ed 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -33,7 +33,7 @@ static void add_suite(CuSuite *(*csuite)(void), const char *name, int argc, char } if (s) { s->next = suites; - s->name = _strdup(name); + s->name = strdup(name); s->csuite = csuite(); suites = s; } diff --git a/src/travelthru.test.c b/src/travelthru.test.c index be87743d2..09d807674 100644 --- a/src/travelthru.test.c +++ b/src/travelthru.test.c @@ -15,7 +15,7 @@ struct attrib; static void count_travelers(region *r, unit *u, void *cbdata) { int *n = (int *)cbdata; - unused_arg(r); + UNUSED_ARG(r); *n += u->number; } diff --git a/src/triggers/changefaction.c b/src/triggers/changefaction.c index 37d993f4a..3de537c7b 100644 --- a/src/triggers/changefaction.c +++ b/src/triggers/changefaction.c @@ -70,7 +70,7 @@ static int changefaction_handle(trigger * t, void *data) else { log_error("could not perform changefaction::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/changerace.c b/src/triggers/changerace.c index f38b7f3d5..a9f282698 100644 --- a/src/triggers/changerace.c +++ b/src/triggers/changerace.c @@ -74,7 +74,7 @@ static int changerace_handle(trigger * t, void *data) else { log_error("could not perform changerace::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/clonedied.c b/src/triggers/clonedied.c index 642b50ab0..f3d1fc00b 100644 --- a/src/triggers/clonedied.c +++ b/src/triggers/clonedied.c @@ -58,7 +58,7 @@ static int clonedied_handle(trigger * t, void *data) } else log_error("could not perform clonedied::handle()\n"); - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/createcurse.c b/src/triggers/createcurse.c index 040a4e7b7..3eb0891ca 100644 --- a/src/triggers/createcurse.c +++ b/src/triggers/createcurse.c @@ -76,7 +76,7 @@ static int createcurse_handle(trigger * t, void *data) else { log_error("could not perform createcurse::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/createunit.c b/src/triggers/createunit.c index 5952c88bc..41573d86b 100644 --- a/src/triggers/createunit.c +++ b/src/triggers/createunit.c @@ -74,7 +74,7 @@ static int createunit_handle(trigger * t, void *data) else { log_error("could not perform createunit::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/gate.c b/src/triggers/gate.c index e681efc04..c70163a14 100644 --- a/src/triggers/gate.c +++ b/src/triggers/gate.c @@ -57,7 +57,7 @@ static int gate_handle(trigger * t, void *data) log_error("could not perform gate::handle()\n"); return -1; } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/giveitem.c b/src/triggers/giveitem.c index 6b0e8f8c7..9bc2c56e1 100644 --- a/src/triggers/giveitem.c +++ b/src/triggers/giveitem.c @@ -70,7 +70,7 @@ static int giveitem_handle(trigger * t, void *data) else { log_error("could not perform giveitem::handle()\n"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/killunit.c b/src/triggers/killunit.c index 22ad27896..3e6c9defe 100644 --- a/src/triggers/killunit.c +++ b/src/triggers/killunit.c @@ -48,7 +48,7 @@ static int killunit_handle(trigger * t, void *data) /* we can't remove_unit() here, because that's what's calling us. */ set_number(u, 0); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/shock.c b/src/triggers/shock.c index 7c54676e0..31424e979 100644 --- a/src/triggers/shock.c +++ b/src/triggers/shock.c @@ -60,8 +60,8 @@ static void do_shock(unit * u, const char *reason) if (u->number > 0) { /* HP - Verlust */ int hp = (unit_max_hp(u) * u->number) / 10; - hp = _min(u->hp, hp); - u->hp = _max(1, hp); + hp = MIN(u->hp, hp); + u->hp = MAX(1, hp); } /* Aura - Verlust */ @@ -102,7 +102,7 @@ static int shock_handle(trigger * t, void *data) if (u && u->number) { do_shock(u, "trigger"); } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/timeout.c b/src/triggers/timeout.c index 10e4d08be..43bb061c8 100644 --- a/src/triggers/timeout.c +++ b/src/triggers/timeout.c @@ -61,7 +61,7 @@ static int timeout_handle(trigger * t, void *data) handle_triggers(&td->triggers, NULL); return -1; } - unused_arg(data); + UNUSED_ARG(data); return 0; } diff --git a/src/triggers/unitmessage.c b/src/triggers/unitmessage.c index 0c1e80124..7ba97d9bc 100644 --- a/src/triggers/unitmessage.c +++ b/src/triggers/unitmessage.c @@ -71,7 +71,7 @@ static int unitmessage_handle(trigger * t, void *data) td->level); } } - unused_arg(data); + UNUSED_ARG(data); return 0; } @@ -92,7 +92,7 @@ static int unitmessage_read(trigger * t, gamedata *data) int result = read_reference(&td->target, data, read_unit_reference, resolve_unit); READ_TOK(data->store, zText, sizeof(zText)); - td->string = _strdup(zText); + td->string = strdup(zText); READ_INT(data->store, &td->type); READ_INT(data->store, &td->level); @@ -117,7 +117,7 @@ trigger *trigger_unitmessage(unit * target, const char *string, int type, trigger *t = t_new(&tt_unitmessage); unitmessage_data *td = (unitmessage_data *)t->data.v; td->target = target; - td->string = _strdup(string); + td->string = strdup(string); td->type = type; td->level = level; return t; diff --git a/src/upkeep.c b/src/upkeep.c index 1cf41011f..94cbc341d 100644 --- a/src/upkeep.c +++ b/src/upkeep.c @@ -47,7 +47,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); @@ -161,7 +161,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; } @@ -174,7 +174,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); @@ -191,7 +191,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; @@ -247,7 +247,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); if (blut) { change_effect(donor, pt_blood, -blut); hungry -= blut; @@ -295,7 +295,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); } } diff --git a/src/util/attrib.c b/src/util/attrib.c index 4bdf35bfa..a99a70ba3 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -124,7 +124,7 @@ int a_readstring(attrib * a, void *owner, struct gamedata *data) len += DISPLAYSIZE - 1; } else { - result = _strdup(buf); + result = strdup(buf); } } while (e == ENOMEM); a->data.v = result; diff --git a/src/util/attrib.h b/src/util/attrib.h index d93ce1240..45dc9b942 100644 --- a/src/util/attrib.h +++ b/src/util/attrib.h @@ -19,6 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef ATTRIB_H #define ATTRIB_H +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/util/attrib.test.c b/src/util/attrib.test.c index 7fa2ef82c..b44afeec2 100644 --- a/src/util/attrib.test.c +++ b/src/util/attrib.test.c @@ -119,7 +119,7 @@ static void test_attrib_rwstring(CuTest *tc) { attrib a = { 0 }; test_setup(); - a.data.v = _strdup("Hello World"); + a.data.v = strdup("Hello World"); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); a_writestring(&a, NULL, &store); diff --git a/src/util/crmessage.c b/src/util/crmessage.c index 98afe0f05..47bb6bf7d 100644 --- a/src/util/crmessage.c +++ b/src/util/crmessage.c @@ -145,21 +145,21 @@ int cr_render(const message * msg, char *buffer, const void *userdata) int cr_string(variant var, char *buffer, const void *userdata) { sprintf(buffer, "\"%s\"", (const char *)var.v); - unused_arg(userdata); + UNUSED_ARG(userdata); return 0; } int cr_int(variant var, char *buffer, const void *userdata) { sprintf(buffer, "%d", var.i); - unused_arg(userdata); + UNUSED_ARG(userdata); return 0; } int cr_ignore(variant var, char *buffer, const void *userdata) { - unused_arg(var); - unused_arg(buffer); - unused_arg(userdata); + UNUSED_ARG(var); + UNUSED_ARG(buffer); + UNUSED_ARG(userdata); return -1; } diff --git a/src/util/event.c b/src/util/event.c index cdf178aec..78a6d6fbc 100644 --- a/src/util/event.c +++ b/src/util/event.c @@ -153,7 +153,7 @@ static int read_handler(attrib * a, void *owner, gamedata *data) handler_info *hi = (handler_info *)a->data.v; READ_TOK(store, zText, sizeof(zText)); - hi->event = _strdup(zText); + hi->event = strdup(zText); read_triggers(data, &hi->triggers); if (hi->triggers != NULL) { return AT_READ_OK; @@ -200,7 +200,7 @@ void add_trigger(struct attrib **ap, const char *eventname, struct trigger *t) if (a == NULL || a->type != &at_eventhandler) { a = a_add(ap, a_new(&at_eventhandler)); td = (handler_info *)a->data.v; - td->event = _strdup(eventname); + td->event = strdup(eventname); } tp = &td->triggers; while (*tp) diff --git a/src/util/goodies.c b/src/util/goodies.c index 2444d0f47..c478bcf83 100644 --- a/src/util/goodies.c +++ b/src/util/goodies.c @@ -113,7 +113,7 @@ int set_email(char **pemail, const char *newmail) free(*pemail); *pemail = 0; if (newmail) { - *pemail = _strdup(newmail); + *pemail = strdup(newmail); } return 0; } diff --git a/src/util/language.c b/src/util/language.c index cb91d7419..efd5cd5f7 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -86,7 +86,7 @@ locale *get_or_create_locale(const char *name) *lp = l = (locale *)calloc(sizeof(locale), 1); assert_alloc(l); l->hashkey = hkey; - l->name = _strdup(name); + l->name = strdup(name); l->index = nextlocaleindex++; assert(nextlocaleindex <= MAXLOCALES); if (default_locale == NULL) default_locale = l; @@ -209,15 +209,15 @@ void locale_setstring(locale * lang, const char *key, const char *value) find->nexthash = lang->strings[id]; lang->strings[id] = find; find->hashkey = hkey; - find->key = _strdup(key); - find->str = _strdup(value); + find->key = strdup(key); + find->str = strdup(value); } else { if (strcmp(find->str, value) != 0) { log_warning("multiple translations for key %s\n", key); } free(find->str); - find->str = _strdup(value); + find->str = strdup(value); } } diff --git a/src/util/language.h b/src/util/language.h index a90398cc0..36bc58378 100644 --- a/src/util/language.h +++ b/src/util/language.h @@ -19,7 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef MY_LOCALE_H #define MY_LOCALE_H -#include +#include #ifdef __cplusplus extern "C" { diff --git a/src/util/lists.c b/src/util/lists.c index d61327fa0..be3deeffd 100644 --- a/src/util/lists.c +++ b/src/util/lists.c @@ -127,7 +127,7 @@ void addstrlist(strlist ** SP, const char *s) { strlist *slist = malloc(sizeof(strlist)); slist->next = NULL; - slist->s = _strdup(s); + slist->s = strdup(s); addlist(SP, slist); } diff --git a/src/util/log.test.c b/src/util/log.test.c index 55616c026..1558ee3e3 100644 --- a/src/util/log.test.c +++ b/src/util/log.test.c @@ -9,9 +9,9 @@ void log_string(void *data, int level, const char *module, const char *format, va_list args) { char *str = (char *)data; const char *arg = va_arg(args, const char *); - unused_arg(format); - unused_arg(module); - unused_arg(level); + UNUSED_ARG(format); + UNUSED_ARG(module); + UNUSED_ARG(level); strcpy(str, arg); } diff --git a/src/util/message.c b/src/util/message.c index 23f81e095..c5285835e 100644 --- a/src/util/message.c +++ b/src/util/message.c @@ -73,7 +73,7 @@ message_type *mt_new(const char *name, const char *args[]) while (args[nparameters]) ++nparameters; } mtype->key = 0; - mtype->name = _strdup(name); + mtype->name = strdup(name); mtype->nparameters = nparameters; if (nparameters > 0) { mtype->pnames = (char **)malloc(sizeof(char *) * nparameters); diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index e3b0bcc0b..8156b9784 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -91,7 +91,7 @@ const nrsection *section_add(const char *name) } if (!*mcp) { nrsection *mc = calloc(sizeof(nrsection), 1); - mc->name = _strdup(name); + mc->name = strdup(name); *mcp = mc; } return *mcp; @@ -130,14 +130,14 @@ const char *string, int level, const char *section) nrt->section = NULL; nrtypes[hash] = nrt; assert(string && *string); - nrt->string = _strdup(string); + nrt->string = strdup(string); *c = '\0'; for (i = 0; i != mtype->nparameters; ++i) { if (i != 0) *c++ = ' '; c += strlcpy(c, mtype->pnames[i], sizeof(zNames)-(c-zNames)); } - nrt->vars = _strdup(zNames); + nrt->vars = strdup(zNames); } } diff --git a/src/util/translation.c b/src/util/translation.c index 829a1fe05..b0933d322 100644 --- a/src/util/translation.c +++ b/src/util/translation.c @@ -414,7 +414,7 @@ static void eval_lt(opstack ** stack, const void *userdata) int b = opop_i(stack); int rval = (b < a) ? 1 : 0; opush_i(stack, rval); - unused_arg(userdata); + UNUSED_ARG(userdata); } static void eval_eq(opstack ** stack, const void *userdata) @@ -423,7 +423,7 @@ static void eval_eq(opstack ** stack, const void *userdata) int b = opop_i(stack); int rval = (a == b) ? 1 : 0; opush_i(stack, rval); - unused_arg(userdata); + UNUSED_ARG(userdata); } static void eval_add(opstack ** stack, const void *userdata) @@ -431,14 +431,14 @@ static void eval_add(opstack ** stack, const void *userdata) int a = opop_i(stack); int b = opop_i(stack); opush_i(stack, a + b); - unused_arg(userdata); + UNUSED_ARG(userdata); } static void eval_isnull(opstack ** stack, const void *userdata) { /* (int, int) -> int */ void *a = opop_v(stack); opush_i(stack, (a == NULL) ? 1 : 0); - unused_arg(userdata); + UNUSED_ARG(userdata); } static void eval_if(opstack ** stack, const void *userdata) @@ -447,14 +447,14 @@ static void eval_if(opstack ** stack, const void *userdata) void *b = opop_v(stack); int cond = opop_i(stack); opush_v(stack, cond ? b : a); - unused_arg(userdata); + UNUSED_ARG(userdata); } static void eval_strlen(opstack ** stack, const void *userdata) { /* string -> int */ const char *c = (const char *)opop_v(stack); opush_i(stack, c ? (int)strlen(c) : 0); - unused_arg(userdata); + UNUSED_ARG(userdata); } #include "base36.h" diff --git a/src/vortex.c b/src/vortex.c index 725460ce2..7b6206d03 100644 --- a/src/vortex.c +++ b/src/vortex.c @@ -70,7 +70,7 @@ static void a_freedirection(attrib * a) static int a_agedirection(attrib * a, void *owner) { spec_direction *d = (spec_direction *)(a->data.v); - unused_arg(owner); + (void)owner; --d->duration; return (d->duration > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } @@ -81,14 +81,14 @@ static int a_readdirection(attrib * a, void *owner, struct gamedata *data) spec_direction *d = (spec_direction *)(a->data.v); char lbuf[32]; - unused_arg(owner); + (void)owner; READ_INT(store, &d->x); READ_INT(store, &d->y); READ_INT(store, &d->duration); READ_TOK(store, lbuf, sizeof(lbuf)); - d->desc = _strdup(lbuf); + d->desc = strdup(lbuf); READ_TOK(store, lbuf, sizeof(lbuf)); - d->keyword = _strdup(lbuf); + d->keyword = strdup(lbuf); d->active = true; return AT_READ_OK; } @@ -98,7 +98,7 @@ a_writedirection(const attrib * a, const void *owner, struct storage *store) { spec_direction *d = (spec_direction *)(a->data.v); - unused_arg(owner); + (void)owner; WRITE_INT(store, d->x); WRITE_INT(store, d->y); WRITE_INT(store, d->duration); @@ -143,8 +143,8 @@ attrib *create_special_direction(region * r, region * rt, int duration, d->x = rt->x; d->y = rt->y; d->duration = duration; - d->desc = _strdup(desc); - d->keyword = _strdup(keyword); + d->desc = strdup(desc); + d->keyword = strdup(keyword); return a; } diff --git a/src/vortex.h b/src/vortex.h index af41b6111..993f5cdab 100644 --- a/src/vortex.h +++ b/src/vortex.h @@ -1,5 +1,10 @@ +#pragma once + #ifndef H_VORTEX #define H_VORTEX + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/wormhole.c b/src/wormhole.c index dd105b302..462f4e637 100644 --- a/src/wormhole.c +++ b/src/wormhole.c @@ -63,7 +63,7 @@ static int wormhole_age(struct attrib *a, void *owner) region *r = entry->region; unit *u = r->units; - unused_arg(owner); + UNUSED_ARG(owner); for (; u != NULL && maxtransport != 0; u = u->next) { if (u->building == entry) { message *m = NULL; From 5ddd511aa8701242a4c940e1bf60e545d12783a5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Jan 2017 18:05:48 +0100 Subject: [PATCH 396/675] continue fixing compilation (gcc/clang) --- src/bind_faction.c | 1 + src/kernel/alliance.h | 3 +++ src/kernel/order.h | 1 + src/keyword.h | 2 ++ src/platform.h | 3 +++ src/util/filereader.c | 15 ++++++++------- src/util/parser.c | 8 ++++---- src/util/parser.h | 1 + src/util/password.h | 1 + src/util/rand.h | 4 ++++ src/util/translation.c | 1 + 11 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/bind_faction.c b/src/bind_faction.c index 109814717..f5c393de6 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -34,6 +34,7 @@ without prior permission by the authors of Eressea. #include #include +#include typedef struct helpmode { const char *name; diff --git a/src/kernel/alliance.h b/src/kernel/alliance.h index fac2dfd38..8e112e8c9 100644 --- a/src/kernel/alliance.h +++ b/src/kernel/alliance.h @@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_KRNL_ALLIANCE #define H_KRNL_ALLIANCE + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/order.h b/src/kernel/order.h index 69cf1ea33..7f4b00a5e 100644 --- a/src/kernel/order.h +++ b/src/kernel/order.h @@ -15,6 +15,7 @@ #include "keyword.h" #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/keyword.h b/src/keyword.h index e60d0731f..1d8f04bb2 100644 --- a/src/keyword.h +++ b/src/keyword.h @@ -2,6 +2,8 @@ #define H_KEYWORD_H #include "kernel/types.h" +#include + #ifdef __cplusplus extern "C" { diff --git a/src/platform.h b/src/platform.h index 2f114cec5..7f82f46a8 100644 --- a/src/platform.h +++ b/src/platform.h @@ -3,6 +3,8 @@ #ifndef UNILIB_H #define UNILIB_H +#define _POSIX_C_SOURCE 200809L + #ifndef MAX_PATH # define MAX_PATH 4096 #endif @@ -12,4 +14,5 @@ #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define TOLUA_CAST (char*) #endif diff --git a/src/util/filereader.c b/src/util/filereader.c index 3223ca2ab..d36d3ca71 100644 --- a/src/util/filereader.c +++ b/src/util/filereader.c @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -30,7 +31,7 @@ static int eatwhite(const char *ptr, size_t * total_size) ret = unicode_utf8_to_ucs4(&ucs, ptr, &size); if (ret != 0) break; - if (!iswxspace((wint_t)ucs)) + if (!iswspace((wint_t)ucs)) break; *total_size += size; ptr += size; @@ -52,7 +53,7 @@ static const char *getbuf_latin1(FILE * F) if (bp == NULL) return NULL; - while (*bp && isxspace(*(unsigned char *)bp)) + while (*bp && isspace(*(unsigned char *)bp)) ++bp; /* eatwhite */ comment = (bool)(comment && cont); @@ -113,15 +114,15 @@ static const char *getbuf_latin1(FILE * F) if (iscntrl(c)) { if (!comment && cp < fbuf + MAXLINE) { - *cp++ = isxspace(c) ? ' ' : '?'; + *cp++ = isspace(c) ? ' ' : '?'; } ++bp; continue; } - else if (isxspace(c)) { + else if (isspace(c)) { if (!quote) { ++bp; - while (*bp && isxspace(*(unsigned char *)bp)) + while (*bp && isspace(*(unsigned char *)bp)) ++bp; /* eatwhite */ if (!comment && *bp && *bp != COMMENT_CHAR && cp < fbuf + MAXLINE) *(cp++) = ' '; @@ -136,7 +137,7 @@ static const char *getbuf_latin1(FILE * F) } else if (c == CONTINUE_CHAR) { const char *end = ++bp; - while (*end && isxspace(*(unsigned char *)end)) + while (*end && isspace(*(unsigned char *)end)) ++end; /* eatwhite */ if (*end == '\0') { bp = end; @@ -269,7 +270,7 @@ static const char *getbuf_utf8(FILE * F) break; } - if (iswxspace((wint_t)ucs)) { + if (iswspace((wint_t)ucs)) { if (!quote) { bp += size; ret = eatwhite(bp, &size); diff --git a/src/util/parser.c b/src/util/parser.c index 0fbde6769..bbdb5ac7e 100644 --- a/src/util/parser.c +++ b/src/util/parser.c @@ -32,7 +32,7 @@ static int eatwhitespace_c(const char **str_p) for (;;) { unsigned char utf8_character = (unsigned char)*str; if (~utf8_character & 0x80) { - if (!iswxspace(utf8_character)) + if (!iswspace(utf8_character)) break; ++str; } @@ -42,7 +42,7 @@ static int eatwhitespace_c(const char **str_p) log_warning("illegal character sequence in UTF8 string: %s\n", str); break; } - if (!iswxspace((wint_t)ucs)) + if (!iswspace((wint_t)ucs)) break; str += len; } @@ -106,7 +106,7 @@ void skip_token(void) log_warning("illegal character sequence in UTF8 string: %s\n", states->current_token); } } - if (iswxspace((wint_t)ucs) && quotechar == 0) { + if (iswspace((wint_t)ucs) && quotechar == 0) { return; } else { @@ -163,7 +163,7 @@ char *parse_token(const char **str, char *lbuf, size_t buflen) copy = true; escape = false; } - else if (iswxspace((wint_t)ucs)) { + else if (iswspace((wint_t)ucs)) { if (quotechar == 0) break; copy = true; diff --git a/src/util/parser.h b/src/util/parser.h index 802fc56cb..0c8306931 100644 --- a/src/util/parser.h +++ b/src/util/parser.h @@ -12,6 +12,7 @@ #define UTIL_PARSER_H #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/util/password.h b/src/util/password.h index e1d49fb6d..b83d544a6 100644 --- a/src/util/password.h +++ b/src/util/password.h @@ -1,5 +1,6 @@ #pragma once +#include #define PASSWORD_PLAINTEXT 0 #define PASSWORD_DEFAULT PASSWORD_PLAINTEXT diff --git a/src/util/rand.h b/src/util/rand.h index 9fb3f2f69..e9d9062b7 100644 --- a/src/util/rand.h +++ b/src/util/rand.h @@ -1,3 +1,4 @@ +#pragma once /* Copyright (c) 1998-2015, Enno Rehling Katja Zedel + #ifdef __cplusplus extern "C" { #endif diff --git a/src/util/translation.c b/src/util/translation.c index b0933d322..c733cc272 100644 --- a/src/util/translation.c +++ b/src/util/translation.c @@ -21,6 +21,7 @@ /* libc includes */ #include #include +#include #include #include From 774fa12a5a2a59b6cf42903842bae8d38c6a7211 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Jan 2017 18:07:36 +0100 Subject: [PATCH 397/675] continued work for MSVC compilation --- src/alchemy.c | 4 ++++ src/battle.c | 11 +++++++++-- src/donations.c | 1 + src/economy.c | 38 +++++++++++++++++++------------------- src/kernel/messages.h | 2 +- src/move.c | 11 +++++++++-- src/names.c | 2 +- src/platform.h | 23 +++++++++++++++++++++++ src/reports.c | 16 ++++++++-------- src/spells.c | 8 +++++++- src/spells/combatspells.c | 4 ++-- 11 files changed, 84 insertions(+), 36 deletions(-) diff --git a/src/alchemy.c b/src/alchemy.c index ddbe46b8e..81244eba1 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -162,6 +162,7 @@ static int potion_healing(unit * u, int amount) { static int potion_luck(unit *u, region *r, attrib_type *atype, int amount) { attrib *a = (attrib *)a_find(r->attribs, atype); + UNUSED_ARG(u); if (!a) { a = a_add(&r->attribs, a_new(atype)); } @@ -170,6 +171,7 @@ static int potion_luck(unit *u, region *r, attrib_type *atype, int amount) { } static int potion_truth(unit *u) { + UNUSED_ARG(u); // TODO: this potion does nothing! // fset(u, UFL_DISBELIEVES); return 1; @@ -304,6 +306,7 @@ static void a_writeeffect(const attrib * a, const void *owner, struct storage *store) { effect_data *edata = (effect_data *)a->data.v; + UNUSED_ARG(owner); WRITE_TOK(store, resourcename(edata->type->itype->rtype, 0)); WRITE_INT(store, edata->value); } @@ -316,6 +319,7 @@ static int a_readeffect(attrib * a, void *owner, struct gamedata *data) effect_data *edata = (effect_data *)a->data.v; char zText[32]; + UNUSED_ARG(owner); READ_TOK(store, zText, sizeof(zText)); rtype = rt_find(zText); diff --git a/src/battle.c b/src/battle.c index 550449ddd..402f61ed5 100644 --- a/src/battle.c +++ b/src/battle.c @@ -509,6 +509,9 @@ contest_new(int skilldiff, const troop dt, const armor_type * ar, const armor_type * sh) { double tohit = 0.5 + skilldiff * 0.1; + + UNUSED_ARG(sh); + UNUSED_ARG(ar); if (tohit < 0.5) tohit = 0.5; if (chance(tohit)) { @@ -839,6 +842,7 @@ int select_magicarmor(troop t) /* Sind side ds und Magier des meffect verb�ndet, dann return 1*/ bool meffect_protection(battle * b, meffect * s, side * ds) { + UNUSED_ARG(b); if (!s->magician->alive) return false; if (s->duration <= 0) @@ -853,6 +857,7 @@ bool meffect_protection(battle * b, meffect * s, side * ds) /* Sind side as und Magier des meffect verfeindet, dann return 1*/ bool meffect_blocked(battle * b, meffect * s, side * as) { + UNUSED_ARG(b); if (!s->magician->alive) return false; if (s->duration <= 0) @@ -1763,8 +1768,8 @@ void do_combatmagic(battle * b, combatmagic_t was) for (co = spellranks[rank].begin; co; co = co->next) { fighter *fig = co->magician.fig; const spell *sp = co->sp; - int level = co->level; + level = co->level; if (!sp->cast) { log_error("spell '%s' has no function.\n", sp->sname); } @@ -2040,6 +2045,7 @@ int hits(troop at, troop dt, weapon * awp) void dazzle(battle * b, troop * td) { + UNUSED_ARG(b); /* Nicht kumulativ ! */ #ifdef TODO_RUNESWORD if (td->fighter->weapon[WP_RUNESWORD].count > td->index) { @@ -2487,6 +2493,7 @@ troop select_ally(fighter * af, int minrow, int maxrow, int allytype) static int loot_quota(const unit * src, const unit * dst, const item_type * type, int n) { + UNUSED_ARG(type); if (dst && src && src->faction != dst->faction) { double divisor = config_get_flt("rules.items.loot_divisor", 1); assert(divisor <= 0 || divisor >= 1); @@ -2636,7 +2643,6 @@ static void reorder_fleeing(region * r) static void aftermath(battle * b) { region *r = b->region; - ship *sh; side *s; int dead_players = 0; bfaction *bf; @@ -2833,6 +2839,7 @@ static void aftermath(battle * b) * dieses Schiff besch�digt. Andernfalls ein Schiff, welches * evt. zuvor verlassen wurde. */ if (ships_damaged) { + ship *sh; if (du->ship) sh = du->ship; else diff --git a/src/donations.c b/src/donations.c index 4dee36444..b923df73b 100644 --- a/src/donations.c +++ b/src/donations.c @@ -1,3 +1,4 @@ +#include #include #include "donations.h" diff --git a/src/economy.c b/src/economy.c index 7edbbcb12..16b201555 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1041,10 +1041,10 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) static int required(int want, double save) { - int norders = (int)(want * save); - if (norders < want * save) - ++norders; - return norders; + int req = (int)(want * save); + if (req < want * save) + ++req; + return req; } static void @@ -1058,7 +1058,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) if (rm != NULL) { do { int avail = rm->amount; - int norders = 0; + int nreq = 0; allocation *al; if (avail <= 0) { @@ -1077,7 +1077,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) if (effskill(al->unit, itype->construction->skill, 0) >= rm->level + itype->construction->minskill - 1) { if (req) { - norders += req; + nreq += req; } else { fset(al, AFL_DONE); @@ -1089,22 +1089,22 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) fset(al, AFL_LOWSKILL); } } - need = norders; + need = nreq; - avail = MIN(avail, norders); + avail = MIN(avail, nreq); if (need > 0) { int use = 0; for (al = alist; al; al = al->next) if (!fval(al, AFL_DONE)) { if (avail > 0) { int want = required(al->want - al->get, al->save); - int x = avail * want / norders; + int x = avail * want / nreq; /* Wenn Rest, dann wrfeln, ob ich was bekomme: */ - if (rng_int() % norders < (avail * want) % norders) + if (rng_int() % nreq < (avail * want) % nreq) ++x; avail -= x; use += x; - norders -= want; + nreq -= want; need -= x; al->get = MIN(al->want, al->get + (int)(x / al->save)); } @@ -1113,7 +1113,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) assert(use <= rm->amount); rm->type->use(rm, r, use); } - assert(avail == 0 || norders == 0); + assert(avail == 0 || nreq == 0); } first = false; } while (need > 0); @@ -1124,13 +1124,13 @@ static void attrib_allocation(const resource_type * rtype, region * r, allocation * alist) { allocation *al; - int norders = 0; + int nreq = 0; attrib *a = a_find(rtype->attribs, &at_resourcelimit); resource_limit *rdata = (resource_limit *)a->data.v; int avail = rdata->value; for (al = alist; al; al = al->next) { - norders += required(al->want, al->save); + nreq += required(al->want, al->save); } if (rdata->limit) { @@ -1139,16 +1139,16 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) avail = 0; } - avail = MIN(avail, norders); + avail = MIN(avail, nreq); for (al = alist; al; al = al->next) { if (avail > 0) { int want = required(al->want, al->save); - int x = avail * want / norders; + int x = avail * want / nreq; /* Wenn Rest, dann wrfeln, ob ich was bekomme: */ - if (rng_int() % norders < (avail * want) % norders) + if (rng_int() % nreq < (avail * want) % nreq) ++x; avail -= x; - norders -= want; + nreq -= want; al->get = MIN(al->want, (int)(x / al->save)); if (rdata->produce) { int use = required(al->get, al->save); @@ -1157,7 +1157,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) } } } - assert(avail == 0 || norders == 0); + assert(avail == 0 || nreq == 0); } typedef void(*allocate_function) (const resource_type *, struct region *, diff --git a/src/kernel/messages.h b/src/kernel/messages.h index 866eecba7..a42342153 100644 --- a/src/kernel/messages.h +++ b/src/kernel/messages.h @@ -57,7 +57,7 @@ extern "C" { struct mlist ** merge_messages(message_list *mlist, message_list *append); void split_messages(message_list *mlist, struct mlist **split); -#define ADDMSG(msgs, mcreate) { message * m = mcreate; if (m) { assert(m->refcount>=1); add_message(msgs, m); msg_release(m); } } +#define ADDMSG(msgs, mcreate) { message * mx = mcreate; if (mx) { assert(mx->refcount>=1); add_message(msgs, mx); msg_release(mx); } } void syntax_error(const struct unit *u, struct order *ord); struct message * cmistake(const struct unit *u, struct order *ord, int mno, int mtype); diff --git a/src/move.c b/src/move.c index 62300beb1..0184d22ca 100644 --- a/src/move.c +++ b/src/move.c @@ -163,6 +163,7 @@ static int shiptrail_read(attrib * a, void *owner, struct gamedata *data) int n; traveldir *t = (traveldir *)(a->data.v); + UNUSED_ARG(owner); READ_INT(store, &t->no); READ_INT(store, &n); t->dir = (direction_t)n; @@ -174,6 +175,8 @@ static void shiptrail_write(const attrib * a, const void *owner, struct storage *store) { traveldir *t = (traveldir *)(a->data.v); + + UNUSED_ARG(owner); WRITE_INT(store, t->no); WRITE_INT(store, t->dir); WRITE_INT(store, t->age); @@ -204,6 +207,8 @@ static bool entrance_allowed(const struct unit *u, const struct region *r) return true; return false; #else + UNUSED_ARG(u); + UNUSED_ARG(r); return true; #endif } @@ -466,6 +471,8 @@ static int canride(unit * u) static bool cansail(const region * r, ship * sh) { + UNUSED_ARG(r); + /* sonst ist construction:: size nicht ship_type::maxsize */ assert(!sh->type->construction || sh->type->construction->improvement == NULL); @@ -490,6 +497,8 @@ static bool cansail(const region * r, ship * sh) static double overload(const region * r, ship * sh) { + UNUSED_ARG(r); + /* sonst ist construction:: size nicht ship_type::maxsize */ assert(!sh->type->construction || sh->type->construction->improvement == NULL); @@ -1761,8 +1770,6 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) * befahrene Region. */ while (next_point && current_point != next_point && step < k) { - const char *token; - int error; const terrain_type *tthis = current_point->terrain; /* these values need to be updated if next_point changes (due to storms): */ const terrain_type *tnext = next_point->terrain; diff --git a/src/names.c b/src/names.c index 248084828..969e278d8 100644 --- a/src/names.c +++ b/src/names.c @@ -394,8 +394,8 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) size_t size; int result; + UNUSED_ARG(buflen); /* Prfen, ob Kurz genug */ - if (strlen(s) <= maxchars) { return s; } diff --git a/src/platform.h b/src/platform.h index 7f82f46a8..dca251b7e 100644 --- a/src/platform.h +++ b/src/platform.h @@ -4,6 +4,20 @@ #define UNILIB_H #define _POSIX_C_SOURCE 200809L +#ifdef _MSC_VER +#ifndef __STDC__ +#define __STDC__ 1 // equivalent to /Za +#endif +#define NO_STRDUP +#define NO_MKDIR +#define mkdir(d, a) _mkdir(d) +#define _CRT_SECURE_NO_WARNINGS +#pragma warning(disable: 4710 4820) +#pragma warning(disable: 4100) // unreferenced formal parameter +#pragma warning(disable: 4456) // declaration hides previous +#pragma warning(disable: 4457) // declaration hides function parameter +#pragma warning(disable: 4459) // declaration hides global +#endif #ifndef MAX_PATH # define MAX_PATH 4096 @@ -15,4 +29,13 @@ #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define TOLUA_CAST (char*) + +#ifdef NO_STRDUP +char * strdup(const char *s); +#endif + +#ifdef NO_MKDIR +int mkdir(const char *pathname, int mode); +#endif + #endif diff --git a/src/reports.c b/src/reports.c index a9695145b..395547734 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1906,23 +1906,23 @@ static void eval_regions(struct opstack **stack, const void *userdata) const faction *report = (const faction *)userdata; int i = opop(stack).i; int end, begin = opop(stack).i; - const arg_regions *regions = (const arg_regions *)opop(stack).v; + const arg_regions *aregs = (const arg_regions *)opop(stack).v; char buf[256]; size_t size = sizeof(buf) - 1; variant var; char *bufp = buf; - if (regions == NULL) { + if (aregs == NULL) { end = begin; } else { if (i >= 0) end = begin + i; else - end = regions->nregions + i; + end = aregs->nregions + i; } for (i = begin; i < end; ++i) { - const char *rname = (const char *)regionname(regions->regions[i], report); + const char *rname = (const char *)regionname(aregs->regions[i], report); bufp = STRLCPY(bufp, rname, size); if (i + 1 < end && size > 2) { @@ -1941,7 +1941,7 @@ static void eval_trail(struct opstack **stack, const void *userdata) const faction *report = (const faction *)userdata; const struct locale *lang = report ? report->locale : default_locale; int i, end = 0, begin = 0; - const arg_regions *regions = (const arg_regions *)opop(stack).v; + const arg_regions *aregs = (const arg_regions *)opop(stack).v; char buf[512]; size_t size = sizeof(buf) - 1; variant var; @@ -1951,10 +1951,10 @@ static void eval_trail(struct opstack **stack, const void *userdata) int eold = errno; #endif - if (regions != NULL) { - end = regions->nregions; + if (aregs != NULL) { + end = aregs->nregions; for (i = begin; i < end; ++i) { - region *r = regions->regions[i]; + region *r = aregs->regions[i]; const char *trail = trailinto(r, lang); const char *rn = f_regionid_s(r, report); diff --git a/src/spells.c b/src/spells.c index 6ed38d022..0bb6df5af 100644 --- a/src/spells.c +++ b/src/spells.c @@ -398,6 +398,7 @@ static void report_effect(region * r, unit * mage, message * seen, message * unseen) { int err = report_action(r, mage, seen, ACTION_RESET | ACTION_CANSEE); + UNUSED_ARG(unseen); if (err) { report_action(r, mage, seen, ACTION_CANNOTSEE); } @@ -2895,6 +2896,8 @@ static int dc_read_compat(struct attrib *a, void *target, gamedata *data) float strength; int rx, ry; + UNUSED_ARG(a); + UNUSED_ARG(target); READ_INT(store, &duration); READ_FLT(store, &strength); READ_INT(store, &var.i); @@ -3119,8 +3122,10 @@ static bool chaosgate_valid(const connection * b) } static struct region *chaosgate_move(const connection * b, struct unit *u, -struct region *from, struct region *to, bool routing) + struct region *from, struct region *to, bool routing) { + UNUSED_ARG(from); + UNUSED_ARG(b); if (!routing) { int maxhp = u->hp / 4; if (maxhp < u->number) @@ -6438,6 +6443,7 @@ int sp_break_curse(castorder * co) /* ------------------------------------------------------------- */ int sp_becomewyrm(castorder * co) { + UNUSED_ARG(co); return 0; } diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index ccfc2346f..76fd605ff 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -826,8 +826,8 @@ int sp_shadowcall(struct castorder * co) attrib *a; int force = (int)(get_force(power, 3) / 2); unit *u; - const char *races[3] = { "shadowbat", "nightmare", "vampunicorn" }; - const race *rc = rc_find(races[rng_int() % 3]); + const char *rcnames[3] = { "shadowbat", "nightmare", "vampunicorn" }; + const race *rc = rc_find(rcnames[rng_int() % 3]); message *msg; u = create_unit(r, mage->faction, force, rc, 0, NULL, mage); From 7b25ed282df8878a4603c7c16426b6aa9d50b103 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Jan 2017 18:20:47 +0100 Subject: [PATCH 398/675] more stbool.h includes, MSVC has no unlink --- src/attributes/key.h | 3 +++ src/donations.test.c | 1 + src/give.h | 3 +++ src/kernel/command.test.c | 2 ++ src/market.h | 3 +++ src/monsters.h | 3 +++ src/platform.h | 5 ++++- src/renumber.test.c | 1 + src/reports.h | 2 +- src/summary.h | 2 ++ src/util/xml.h | 2 ++ 11 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/attributes/key.h b/src/attributes/key.h index 89292db1d..d2cea1ff0 100644 --- a/src/attributes/key.h +++ b/src/attributes/key.h @@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_ATTRIBUTE_KEY #define H_ATTRIBUTE_KEY + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/donations.test.c b/src/donations.test.c index 068aba74a..09cd31977 100644 --- a/src/donations.test.c +++ b/src/donations.test.c @@ -1,3 +1,4 @@ +#include #include "donations.h" #include diff --git a/src/give.h b/src/give.h index 9c06e89ca..94eee729c 100644 --- a/src/give.h +++ b/src/give.h @@ -12,6 +12,9 @@ */ #ifndef H_GC_GIVE #define H_GC_GIVE + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/kernel/command.test.c b/src/kernel/command.test.c index f38c7e443..25e75fdc3 100644 --- a/src/kernel/command.test.c +++ b/src/kernel/command.test.c @@ -10,7 +10,9 @@ without prior permission by the authors of Eressea. */ +#include #include "command.h" + #include "unit.h" #include "order.h" diff --git a/src/market.h b/src/market.h index a74c88391..74dc8db17 100644 --- a/src/market.h +++ b/src/market.h @@ -12,6 +12,9 @@ without prior permission by the authors of Eressea. */ #ifndef H_GC_MARKET #define H_GC_MARKET + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/monsters.h b/src/monsters.h index 52e9ebf37..a5a3ccd15 100644 --- a/src/monsters.h +++ b/src/monsters.h @@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_GC_MONSTER #define H_GC_MONSTER + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/platform.h b/src/platform.h index dca251b7e..682bcc1c2 100644 --- a/src/platform.h +++ b/src/platform.h @@ -10,7 +10,7 @@ #endif #define NO_STRDUP #define NO_MKDIR -#define mkdir(d, a) _mkdir(d) +#define NO_UNLINK #define _CRT_SECURE_NO_WARNINGS #pragma warning(disable: 4710 4820) #pragma warning(disable: 4100) // unreferenced formal parameter @@ -38,4 +38,7 @@ char * strdup(const char *s); int mkdir(const char *pathname, int mode); #endif +#ifdef NO_UNLINK +int unlink(const char *pathname); +#endif #endif diff --git a/src/renumber.test.c b/src/renumber.test.c index 6c3f0f17b..8f6f91a59 100644 --- a/src/renumber.test.c +++ b/src/renumber.test.c @@ -1,3 +1,4 @@ +#include #include "renumber.h" #include diff --git a/src/reports.h b/src/reports.h index d69b9a88b..625048de9 100644 --- a/src/reports.h +++ b/src/reports.h @@ -20,10 +20,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef H_KRNL_REPORTS #define H_KRNL_REPORTS -#include #include #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/summary.h b/src/summary.h index ea8daeee1..b12d74009 100644 --- a/src/summary.h +++ b/src/summary.h @@ -11,6 +11,8 @@ #ifndef H_GC_SUMMARY #define H_GC_SUMMARY +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/util/xml.h b/src/util/xml.h index 921cd3f53..bd22e3e0a 100644 --- a/src/util/xml.h +++ b/src/util/xml.h @@ -13,6 +13,8 @@ #ifndef H_UTIL_XML #define H_UTIL_XML +#include + #ifdef __cplusplus extern "C" { #endif From d1b5daf83341e59e3dee36031560fddfc5ce2cd1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Jan 2017 18:40:01 +0100 Subject: [PATCH 399/675] compiles with gcc on rpi --- src/kernel/jsonconf.test.c | 2 +- src/kernel/save.c | 2 +- src/platform.h | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 76784ed56..950868046 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -448,7 +448,7 @@ static void test_configs(CuTest * tc) CuAssertPtrEquals(tc, 0, buildingtypes); json_config(json); CuAssertPtrNotNull(tc, buildingtypes); - if (unlink("test.json")!=0 && errno==ENOENT) { + if (remove("test.json")!=0 && errno==ENOENT) { errno = 0; } cJSON_Delete(json); diff --git a/src/kernel/save.c b/src/kernel/save.c index 1139b5f1f..bbbd77fd1 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1830,7 +1830,7 @@ int writegame(const char *filename) join_path(datapath(), filename, path, sizeof(path)); #ifdef HAVE_UNISTD_H /* make sure we don't overwrite an existing file (hard links) */ - if (unlink(path)!=0) { + if (remove(path)!=0) { if (errno==ENOENT) { errno = 0; } diff --git a/src/platform.h b/src/platform.h index 682bcc1c2..21c459a74 100644 --- a/src/platform.h +++ b/src/platform.h @@ -10,7 +10,6 @@ #endif #define NO_STRDUP #define NO_MKDIR -#define NO_UNLINK #define _CRT_SECURE_NO_WARNINGS #pragma warning(disable: 4710 4820) #pragma warning(disable: 4100) // unreferenced formal parameter @@ -38,7 +37,4 @@ char * strdup(const char *s); int mkdir(const char *pathname, int mode); #endif -#ifdef NO_UNLINK -int unlink(const char *pathname); -#endif #endif From c38cd41194e179d46e8fcfbf17bc1ef7629c1c15 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 11 Jan 2017 10:57:42 +0100 Subject: [PATCH 400/675] fix the install script, issue #623 --- s/install | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/s/install b/s/install index 18cc2393f..416d07f9a 100755 --- a/s/install +++ b/s/install @@ -10,12 +10,11 @@ done DEST=$(dirname $ROOT)/server -MACHINE=`uname -m` [ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang" [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" [ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" [ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc" -BIN_DIR="build-$MACHINE-$CC-Debug" +BIN_DIR="Debug" cd $ROOT/$BIN_DIR make install From 94737375f5b11d4f0471fa3ca74643d0705fe17b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 11 Jan 2017 14:53:35 +0100 Subject: [PATCH 401/675] issue #621: delete battledebug code --- src/battle.c | 156 ++------------------------------------------------- src/battle.h | 1 - src/main.c | 3 - 3 files changed, 6 insertions(+), 154 deletions(-) diff --git a/src/battle.c b/src/battle.c index 402f61ed5..4105cf73f 100644 --- a/src/battle.c +++ b/src/battle.c @@ -93,12 +93,6 @@ typedef enum combatmagic { DO_POSTCOMBATSPELL } combatmagic_t; -/* globals */ -bool battledebug = false; - -static int obs_count = 0; -static FILE *bdebug; - #define MINSPELLRANGE 1 #define MAXSPELLRANGE 7 @@ -1219,9 +1213,6 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) kritchance = MIN(0.9, kritchance); while (chance(kritchance)) { - if (bdebug) { - fprintf(bdebug, "%s/%d lands a critical hit\n", itoa36(au->no), at.index); - } da += dice_rand(damage); } } @@ -1302,10 +1293,6 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) } if (df->person[dt.index].hp > 0) { /* Hat �berlebt */ - if (bdebug) { - fprintf(bdebug, "Damage %d, armor %d: %d -> %d HP\n", - da, ar, df->person[dt.index].hp + rda, df->person[dt.index].hp); - } if (u_race(au) == get_race(RC_DAEMON)) { if (!(df->person[dt.index].flags & (FL_COURAGE | FL_DAZZLED))) { df->person[dt.index].flags |= FL_DAZZLED; @@ -1334,10 +1321,6 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) } ++at.fighter->kills; - if (bdebug) { - fprintf(bdebug, "Damage %d, armor %d, type %d: %d -> %d HP, tot.\n", - da, ar, type, df->person[dt.index].hp + rda, df->person[dt.index].hp); - } for (pitm = &du->items; *pitm;) { item *itm = *pitm; const item_type *itype = itm->type; @@ -1979,20 +1962,6 @@ int getreload(troop at) return at.fighter->person[at.index].reload; } -static void -debug_hit(troop at, const weapon * awp, troop dt, const weapon * dwp, -int skdiff, int dist, bool success) -{ - fprintf(bdebug, "%.4s/%d [%6s/%d] %s %.4s/%d [%6s/%d] with %d, distance %d\n", - itoa36(at.fighter->unit->no), at.index, - LOC(default_locale, awp ? resourcename(awp->type->itype->rtype, - 0) : "unarmed"), weapon_effskill(at, dt, awp, true, dist > 1), - success ? "hits" : "misses", itoa36(dt.fighter->unit->no), dt.index, - LOC(default_locale, dwp ? resourcename(dwp->type->itype->rtype, - 0) : "unarmed"), weapon_effskill(dt, at, dwp, false, dist > 1), skdiff, - dist); -} - int hits(troop at, troop dt, weapon * awp) { fighter *af = at.fighter, *df = dt.fighter; @@ -2032,14 +2001,8 @@ int hits(troop at, troop dt, weapon * awp) shield = select_armor(dt, false); } if (contest(skdiff, dt, armor, shield)) { - if (bdebug) { - debug_hit(at, awp, dt, dwp, skdiff, dist, true); - } return 1; } - if (bdebug) { - debug_hit(at, awp, dt, dwp, skdiff, dist, false); - } return 0; } @@ -2190,11 +2153,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack) } } if (reload && wp && wp->type->reload && !getreload(ta)) { - int i = setreload(ta); - if (bdebug) { - fprintf(bdebug, "%s/%d reloading %d turns\n", itoa36(au->no), - ta.index, i); - } + setreload(ta); } } } @@ -2874,13 +2833,6 @@ static void aftermath(battle * b) } reorder_fleeing(r); - - if (bdebug) { - fprintf(bdebug, "The battle lasted %d turns, %s and %s.\n", - b->turn, - b->has_tactics_turn ? "had a tactic turn" : "had no tactic turn", - ships_damaged ? "was relevant" : "was not relevant."); - } } static void battle_punit(unit * u, battle * b) @@ -2894,10 +2846,6 @@ static void battle_punit(unit * u, battle * b) spunit(&S, f, u, 4, seen_battle); for (x = S; x; x = x->next) { fbattlerecord(b, f, x->s); - if (bdebug && u->faction == f) { - fputs(x->s, bdebug); - fputc('\n', bdebug); - } } if (S) freestrlist(S); @@ -3077,17 +3025,6 @@ static void print_stats(battle * b) fbattlerecord(b, f, buf); } - if (bdebug && s->faction) { - if (f_get_alliance(s->faction)) { - fprintf(bdebug, "##### %s (%s/%d)\n", s->faction->name, - itoa36(s->faction->no), - s->faction->alliance ? s->faction->alliance->id : 0); - } - else { - fprintf(bdebug, "##### %s (%s)\n", s->faction->name, - itoa36(s->faction->no)); - } - } print_fighters(b, s); } @@ -3519,28 +3456,6 @@ static int join_battle(battle * b, unit * u, bool attack, fighter ** cp) return false; } -static const char *simplename(region * r) -{ - int i; - static char name[17]; - const char *cp = rname(r, default_locale); - for (i = 0; *cp && i != 16; ++i, ++cp) { - int c = *(unsigned char *)cp; - while (c && !isalpha(c) && !isspace(c)) { - ++cp; - c = *(unsigned char *)cp; - } - if (isspace(c)) - name[i] = '_'; - else - name[i] = *cp; - if (c == 0) - break; - } - name[i] = 0; - return name; -} - battle *make_battle(region * r) { battle *b = (battle *)calloc(1, sizeof(battle)); @@ -3552,29 +3467,6 @@ battle *make_battle(region * r) for (bld = r->buildings; bld != NULL; bld = bld->next) bld->sizeleft = bld->size; - if (battledebug) { - char zText[4096]; - char zFilename[4096]; - join_path(basepath(), "battles", zText, sizeof(zText)); - if (mkdir(zText, 0777) != 0) { - log_error("could not create subdirectory for battle logs: %s", zText); - battledebug = false; - } - else { - sprintf(zFilename, "battle-%d-%s.log", obs_count++, simplename(r)); - join_path(zText, zFilename, zText, sizeof(zText)); - bdebug = fopen(zText, "w"); - if (!bdebug) - log_error("battles cannot be debugged"); - else { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; - fwrite(utf8_bom, 1, 3, bdebug); - fprintf(bdebug, "In %s findet ein Kampf statt:\n", rname(r, - default_locale)); - } - } - } - b->region = r; b->plane = getplane(r); /* Finde alle Parteien, die den Kampf beobachten k�nnen: */ @@ -3644,10 +3536,6 @@ static void battle_free(battle * b) { void free_battle(battle * b) { - if (bdebug) { - fclose(bdebug); - } - while (b->factions) { bfaction *bf = b->factions; b->factions = bf->next; @@ -3812,13 +3700,7 @@ static void join_allies(battle * b) } /* keine Einw�nde, also soll er mitmachen: */ if (c == NULL) { - if (join_battle(b, u, false, &c)) { - if (battledebug) { - fprintf(bdebug, "%s joins to help %s against %s.\n", - unitname(u), factionname(s->faction), factionname(se->faction)); - } - } - else if (c == NULL) { + if (!join_battle(b, u, false, &c)) { continue; } } @@ -3826,12 +3708,7 @@ static void join_allies(battle * b) /* the enemy of my friend is my enemy: */ for (se = b->sides; se != s_end; ++se) { if (se->faction != u->faction && enemy(s, se)) { - if (set_enemy(se, c->side, false) && battledebug) { - fprintf(bdebug, - "%u/%s hates %u/%s because they are enemies with %u/%s.\n", - c->side->index, sidename(c->side), se->index, sidename(se), - s->index, sidename(s)); - } + set_enemy(se, c->side, false); } } } @@ -4012,18 +3889,8 @@ static bool start_battle(region * r, battle ** bp) } b = make_battle(r); } - if (join_battle(b, u, true, &c1)) { - if (battledebug) { - fprintf(bdebug, "%s joins by attacking %s.\n", - unitname(u), unitname(u2)); - } - } - if (join_battle(b, u2, false, &c2)) { - if (battledebug) { - fprintf(bdebug, "%s joins because of an attack from %s.\n", - unitname(u2), unitname(u)); - } - } + join_battle(b, u, true, &c1); + join_battle(b, u2, false, &c2); /* Hat die attackierte Einheit keinen Noaid-Status, * wird das Flag von der Faction genommen, andere @@ -4036,11 +3903,7 @@ static bool start_battle(region * r, battle ** bp) * Pr�combataura bei kurzem Kampf. */ c1->side->bf->attacker = true; - if (set_enemy(c1->side, c2->side, true) && battledebug) { - fprintf(bdebug, "%u/%s hates %u/%s because they attacked them.\n", - c2->side->index, sidename(c2->side), - c1->side->index, sidename(c1->side)); - } + set_enemy(c1->side, c2->side, true); fighting = true; } } @@ -4159,10 +4022,6 @@ static void battle_flee(battle * b) flee(dt); } } - if (bdebug && runners > 0) { - fprintf(bdebug, "Fleeing: %d from %s\n", runners, - itoa36(fig->unit->no)); - } } } } @@ -4265,9 +4124,6 @@ void do_battle(region * r) log_debug("battle in %s (%d, %d) : ", regionname(r, 0), r->x, r->y); for (; battle_report(b) && b->turn <= max_turns; ++b->turn) { - if (bdebug) { - fprintf(bdebug, "*** Turn: %d\n", b->turn); - } battle_flee(b); battle_update(b); battle_attacks(b); diff --git a/src/battle.h b/src/battle.h index dbdc7e1cb..1b4cf2588 100644 --- a/src/battle.h +++ b/src/battle.h @@ -227,7 +227,6 @@ extern "C" { } meffect; extern const troop no_troop; - extern bool battledebug; /* BEGIN battle interface */ side * find_side(battle * b, const struct faction * f, const struct group * g, unsigned int flags, const struct faction * stealthfaction); diff --git a/src/main.c b/src/main.c index 44c1b9e2d..5e998f835 100644 --- a/src/main.c +++ b/src/main.c @@ -25,7 +25,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "eressea.h" -#include "battle.h" #ifdef USE_CURSES #include "gmtool.h" #endif @@ -71,8 +70,6 @@ static void load_inifile(dictionary * d) lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0; verbosity = iniparser_getint(d, "eressea:verbose", 2); - battledebug = iniparser_getint(d, "eressea:debug", battledebug) ? 1 : 0; - str = iniparser_getstring(d, "eressea:locales", "de,en"); make_locales(str); From 1921fa4ec1deb4e1242c90d253025000dbb0f770 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 11 Jan 2017 14:55:03 +0100 Subject: [PATCH 402/675] issue #478: re-enable -Werror --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 39d290560..1b9cc82dc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,7 +16,7 @@ COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}") ENDIF() IF (CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wno-error=unused-but-set-variable") ENDIF() IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") From 437d959d97b9b8222ade0bbcb5e022f691cbe0e8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 11 Jan 2017 15:09:02 +0100 Subject: [PATCH 403/675] do not set -Werror twice --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1b9cc82dc..39d290560 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,7 +16,7 @@ COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}") ENDIF() IF (CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wno-error=unused-but-set-variable") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") ENDIF() IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") From 5b78578939fdada743c1106ac5881a4afab3af11 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 14 Jan 2017 17:19:08 +0100 Subject: [PATCH 404/675] github issue #626: installing in non-standard paths --- s/cmake-init | 3 ++- s/install | 2 -- s/setup | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/s/cmake-init b/s/cmake-init index ea94afb7c..84a1d9cdb 100755 --- a/s/cmake-init +++ b/s/cmake-init @@ -35,12 +35,13 @@ if [ -d $HOME/usr ]; then PREFIX_PATH=$HOME/usr:$HOME/usr/local:$PREFIX_PATH fi +DEST=$(dirname $ROOT)/server ARGS=" -DCMAKE_MODULE_PATH=$ROOT/cmake/Modules \ -DCMAKE_BUILD_TYPE=$BUILD \ -DCMAKE_LIBRARY_PATH=$LIBRARY_PATH \ -DCMAKE_INCLUDE_PATH=$INCLUDE_PATH \ -DCMAKE_PREFIX_PATH=$PREFIX_PATH \ - -DCMAKE_INSTALL_PREFIX=$HOME/eressea/server" + -DCMAKE_INSTALL_PREFIX=$DEST" git submodule update --init diff --git a/s/install b/s/install index 416d07f9a..962961063 100755 --- a/s/install +++ b/s/install @@ -8,8 +8,6 @@ while [ ! -d $ROOT/.git ]; do fi done -DEST=$(dirname $ROOT)/server - [ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang" [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" [ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" diff --git a/s/setup b/s/setup index 0839d5b8f..fc5fb9874 100755 --- a/s/setup +++ b/s/setup @@ -1,5 +1,15 @@ #!/bin/bash +ROOT=$(pwd) +while [ ! -d $ROOT/.git ]; do + ROOT=$(dirname $ROOT) + if [ "/" = "$ROOT" ]; then + echo "could not find root, are you in the git repository?" + exit + fi +done +ERESSEA=$(dirname $ROOT) + function abort() { echo $1 [ -z $2 ] && exit -1 @@ -37,7 +47,6 @@ while getopts :d:g:r:s:hfn o; do done [ $game -gt 0 ] || abort "must use a positive integer for game id" -[ -d $ERESSEA ] || abort "invalid or missing env variable ERESSEA ($ERESSEA)" [ -z $SOURCE ] && SOURCE=$ERESSEA/$src [ -d $SOURCE ] || abort "invalid source directory $SOURCE" [ -z $rules ] && rules=e$game @@ -46,7 +55,8 @@ done [ -e $TOOLS ] || TOOLS=$SOURCE/bin [ -z $INIFILE ] && INIFILE=$TOOLS/inifile [ -e $INIFILE ] || INIFILE=$TOOLS/iniparser/inifile -#[ -e $INIFILE ] || abort "tool is not installed: $INIFILE" + +[ -e $SOURCE/conf/$rules/config.xml ] || abort "cannot find conf/$rules/config.xml" cd $ERESSEA if [ -d $dir ] ; then From d7dd281a6a0e9a99f09c93d087a7bfac3413d893 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 Jan 2017 08:32:31 +0100 Subject: [PATCH 405/675] move orders-accept configuration to eressea.ini install lunit, too --- CMakeLists.txt | 1 + conf/eressea.ini | 3 ++ process/orders-accept | 111 ++++++++++++++++++++++-------------------- 3 files changed, 61 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c08e16c20..8fd15f201 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,4 +23,5 @@ add_subdirectory (src eressea) install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.xml") install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.json") install(DIRECTORY scripts DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.lua") +install(DIRECTORY lunit DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.lua") install(DIRECTORY share DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/conf/eressea.ini b/conf/eressea.ini index e14d0af50..c2f7bbb7f 100644 --- a/conf/eressea.ini +++ b/conf/eressea.ini @@ -1,3 +1,6 @@ +[game] +email = Eressea Server +name = Eressea [eressea] base = . diff --git a/process/orders-accept b/process/orders-accept index 151f0b196..49bdc3cb0 100755 --- a/process/orders-accept +++ b/process/orders-accept @@ -3,22 +3,50 @@ from email.Utils import parseaddr from email.Parser import Parser -from os import mkdir, rename, stat, utime, unlink, symlink -from os.path import exists +import os +import os.path +import ConfigParser from re import compile, IGNORECASE from stat import ST_MTIME from string import upper, split, replace import logging -from sys import argv, stdin, exit +import sys +from sys import stdin from time import ctime, sleep, time from socket import gethostname from rfc822 import parsedate_tz, mktime_tz -LOG_FILENAME='/home/eressea/log/orders.log' +if 'ERESSEA' in os.environ: + dir = os.environ['ERESSEA'] +elif 'HOME' in os.environ: + dir = os.path.join(os.environ['HOME'], '/eressea') +else: # WTF? No HOME? + dir = "/home/eressea/eressea" +if not os.path.isdir(dir): + print "please set the ERESSEA environment variable to the install path" + sys.exit(1) +rootdir = dir + +try: + game = int(sys.argv[1]) +except: + game = sys.argv[1] +gamedir = os.path.join(rootdir, "game-%d" % (game, )) +frommail = 'Eressea Server ' +gamename = 'Eressea' +inifile = os.path.join(gamedir, 'eressea.ini') +if not os.path.exists(inifile): + print "no such file: " . inifile +else: + config = ConfigParser.ConfigParser() + config.read(inifile) + if config.has_option('game', 'email'): + frommail = config.get('game', 'email') + if config.has_option('game', 'name'): + gamename = config.get('game', 'name') + config = None prefix = 'turn-' hostname = gethostname() -# base directory for all your games: -rootdir = "/home/eressea" orderbase = "orders.dir" sendmail = True # maximum number of reports per sender: @@ -28,36 +56,21 @@ writeheaders = True # reject all html email? rejecthtml = True -games = [ - { - "from" : "Eressea Server ", - "prefix" : "Eressea" - }, - { - "from" : "Eressea Server ", - "prefix": "E3" - }, - { - "from" : "Eressea Server ", - "prefix": "E4" - }, -] - def unlock_file(filename): try: - unlink(filename+".lock") + os.unlink(filename+".lock") except: print "could not unlock %s.lock, file not found" % filename def lock_file(filename): i = 0 wait = 1 - if not exists(filename): + if not os.path.exists(filename): file=open(filename, "w") file.close() while True: try: - symlink(filename, filename+".lock") + os.symlink(filename, filename+".lock") return except: i = i+1 @@ -74,17 +87,17 @@ messages = { "software and re-send the orders.", "multipart-de" : - "FEHLER: Die von dir eingeschickte Mail enthlt keinen " \ + "FEHLER: Die von dir eingeschickte Mail enth�lt keinen " \ "Text. Evtl. hast Du den Zug als HTML oder als anderweitig " \ - "ungltig formatierte Mail ingeschickt. Wir knnen ihn " \ - "deshalb nicht bercksichtigen. Schicke den Zug nochmals " \ + "ung�ltig formatierte Mail ingeschickt. Wir k�nnen ihn " \ + "deshalb nicht ber�cksichtigen. Schicke den Zug nochmals " \ "als reinen Text ohne Formatierungen ein.", "maildate-de": - "Es erreichte uns bereits ein Zug mit einem spteren " \ + "Es erreichte uns bereits ein Zug mit einem sp�teren " \ "Absendedatum (%s > %s). Entweder ist deine " \ "Systemzeit verstellt, oder ein Zug hat einen anderen Zug von " \ - "dir auf dem Transportweg berholt. Entscheidend fr die " \ + "dir auf dem Transportweg �berholt. Entscheidend f�r die " \ "Auswertungsreihenfolge ist das Absendedatum, d.h. der Date:-Header " \ "deiner Mail.", @@ -173,8 +186,8 @@ def available_file(dirname, basename): ver = 0 maxdate = 0 filename = "%s/%s,%s,%d" % (dirname, basename, hostname, ver) - while exists(filename): - maxdate = max(stat(filename)[ST_MTIME], maxdate) + while os.path.exists(filename): + maxdate = max(os.stat(filename)[ST_MTIME], maxdate) ver = ver + 1 filename = "%s/%s,%s,%d" % (dirname, basename, hostname, ver) if ver >= maxfiles: @@ -234,7 +247,7 @@ def copy_orders(message, filename, sender): from os.path import split dirname, basename = split(filename) dirname = dirname + '/headers' - if not exists(dirname): mkdir(dirname) + if not os.path.exists(dirname): os.mkdir(dirname) outfile = open(dirname + '/' + basename, "w") for name, value in message.items(): outfile.write(name + ": " + value + "\n") @@ -265,16 +278,14 @@ def copy_orders(message, filename, sender): # create a file, containing: # game=0 locale=de file=/path/to/filename email=rcpt@domain.to def accept(game, locale, stream, extend=None): - global rootdir, orderbase + global rootdir, orderbase, gamedir, gamename, frommail if extend is not None: orderbase = orderbase + ".pre-" + extend - gamename = games[game-2]["prefix"] - gamedir = rootdir+"/eressea/game-%d" % (game, ) - savedir = gamedir+"/"+orderbase + savedir = os.path.join(gamedir, orderbase) # check if it's one of the pre-sent orders. # create the save-directories if they don't exist - if not exists(gamedir): mkdir(gamedir) - if not exists(savedir): mkdir(savedir) + if not os.path.exists(gamedir): os.mkdir(gamedir) + if not os.path.exists(savedir): os.mkdir(savedir) # parse message message = Parser().parse(stream) sender = get_sender(message) @@ -298,7 +309,7 @@ def accept(game, locale, stream, extend=None): maildate = message.get("Date") if maildate != None: turndate = mktime_tz(parsedate_tz(maildate)) - utime(filename, (turndate, turndate)) + os.utime(filename, (turndate, turndate)) logger.debug("mail date is '%s' (%d)" % (maildate, turndate)) if turndate < maxdate: logger.warning("inconsistent message date " + sender) @@ -313,9 +324,9 @@ def accept(game, locale, stream, extend=None): warning = " (" + messages["error-" + locale] + ")" msg = msg + formatpar(messages["multipart-" + locale], 76, 2) + "\n" logger.warning("rejected - no text/plain in orders from " + sender) - unlink(filename) + os.unlink(filename) savedir = savedir + "/rejected" - if not exists(savedir): mkdir(savedir) + if not os.path.exists(savedir): os.mkdir(savedir) lock_file(gamedir + "/orders.queue") maxdate, filename = available_file(savedir, prefix + sender) store_message(message, filename) @@ -323,7 +334,6 @@ def accept(game, locale, stream, extend=None): fail = True if sendmail and warning is not None: - frommail = games[key]["from"] subject = gamename + " " + messages["subject-"+locale] + warning mail = "Subject: %s\nFrom: %s\nTo: %s\n\n" % (subject, frommail, sender) + msg from smtplib import SMTP @@ -347,22 +357,15 @@ def accept(game, locale, stream, extend=None): return 0 # the main body of the script: +LOG_FILENAME=os.path.join(rootdir, 'log/orders.log') logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME) logger = logging delay=None # TODO: parse the turn delay -try: - game = int(argv[1]) -except: - game = argv[1] - if game[:3]=='e3a': - game = 3 - elif game[:7]=='eressea': - game = 2 -locale = argv[2] +locale = sys.argv[2] infile = stdin -if len(argv)>3: - infile = open(argv[3], "r") +if len(sys.argv)>3: + infile = open(sys.argv[3], "r") retval = accept(game, locale, infile, delay) if infile!=stdin: infile.close() -exit(retval) +sys.exit(retval) From 6d5749308dd3479077685588fe273a4b5ba01127 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 Jan 2017 18:44:58 +0100 Subject: [PATCH 406/675] rename [eressea] section to [game] --- conf/eressea.ini | 5 +- process/orders-accept | 49 ++++++++++--------- process/orders-process | 107 +++++++++++++++++++++++++---------------- s/setup | 4 +- src/main.c | 14 +++--- 5 files changed, 102 insertions(+), 77 deletions(-) diff --git a/conf/eressea.ini b/conf/eressea.ini index c2f7bbb7f..b6db180ca 100644 --- a/conf/eressea.ini +++ b/conf/eressea.ini @@ -1,8 +1,7 @@ [game] -email = Eressea Server +email = eressea-server@kn-bremen.de +sender = Eressea Server name = Eressea - -[eressea] base = . report = reports verbose = 0 diff --git a/process/orders-accept b/process/orders-accept index 49bdc3cb0..78af0a056 100755 --- a/process/orders-accept +++ b/process/orders-accept @@ -27,13 +27,12 @@ if not os.path.isdir(dir): sys.exit(1) rootdir = dir -try: - game = int(sys.argv[1]) -except: - game = sys.argv[1] +game = int(sys.argv[1]) gamedir = os.path.join(rootdir, "game-%d" % (game, )) -frommail = 'Eressea Server ' +frommail = 'eressea-server@kn-bremen.de' gamename = 'Eressea' +sender = '%s Server <%s>' % (gamename, frommail) + inifile = os.path.join(gamedir, 'eressea.ini') if not os.path.exists(inifile): print "no such file: " . inifile @@ -44,6 +43,10 @@ else: frommail = config.get('game', 'email') if config.has_option('game', 'name'): gamename = config.get('game', 'name') + if config.has_option('game', 'sender'): + sender = config.get('game', 'sender') + else: + sender = "%s Server <%s>" % (gamename, frommail) config = None prefix = 'turn-' hostname = gethostname() @@ -278,7 +281,7 @@ def copy_orders(message, filename, sender): # create a file, containing: # game=0 locale=de file=/path/to/filename email=rcpt@domain.to def accept(game, locale, stream, extend=None): - global rootdir, orderbase, gamedir, gamename, frommail + global rootdir, orderbase, gamedir, gamename, sender if extend is not None: orderbase = orderbase + ".pre-" + extend savedir = os.path.join(gamedir, orderbase) @@ -288,21 +291,21 @@ def accept(game, locale, stream, extend=None): if not os.path.exists(savedir): os.mkdir(savedir) # parse message message = Parser().parse(stream) - sender = get_sender(message) - logger = logging.getLogger(sender) + email = get_sender(message) + logger = logging.getLogger(email) # write syslog - if sender is None or valid_email(sender)==0: - logger.warning("invalid email address: " + str(sender)) + if email is None or valid_email(email)==0: + logger.warning("invalid email address: " + str(email)) return -1 - logger.info("received orders from " + sender) + logger.info("received orders from " + email) # get an available filename lock_file(gamedir + "/orders.queue") - maxdate, filename = available_file(savedir, prefix + sender) + maxdate, filename = available_file(savedir, prefix + email) if filename is None: - logger.warning("more than " + str(maxfiles) + " orders from " + sender) + logger.warning("more than " + str(maxfiles) + " orders from " + email) return -1 # copy the orders to the file - text_ok = copy_orders(message, filename, sender) + text_ok = copy_orders(message, filename, email) unlock_file(gamedir + "/orders.queue") warning, msg, fail = None, "", False @@ -312,47 +315,47 @@ def accept(game, locale, stream, extend=None): os.utime(filename, (turndate, turndate)) logger.debug("mail date is '%s' (%d)" % (maildate, turndate)) if turndate < maxdate: - logger.warning("inconsistent message date " + sender) + logger.warning("inconsistent message date " + email) warning = " (" + messages["warning-" + locale] + ")" msg = msg + formatpar(messages["maildate-" + locale] % (ctime(maxdate),ctime(turndate)), 76, 2) + "\n" else: - logger.warning("missing message date " + sender) + logger.warning("missing message date " + email) warning = " (" + messages["warning-" + locale] + ")" msg = msg + formatpar(messages["nodate-" + locale], 76, 2) + "\n" if not text_ok: warning = " (" + messages["error-" + locale] + ")" msg = msg + formatpar(messages["multipart-" + locale], 76, 2) + "\n" - logger.warning("rejected - no text/plain in orders from " + sender) + logger.warning("rejected - no text/plain in orders from " + email) os.unlink(filename) savedir = savedir + "/rejected" if not os.path.exists(savedir): os.mkdir(savedir) lock_file(gamedir + "/orders.queue") - maxdate, filename = available_file(savedir, prefix + sender) + maxdate, filename = available_file(savedir, prefix + email) store_message(message, filename) unlock_file(gamedir + "/orders.queue") fail = True if sendmail and warning is not None: subject = gamename + " " + messages["subject-"+locale] + warning - mail = "Subject: %s\nFrom: %s\nTo: %s\n\n" % (subject, frommail, sender) + msg + mail = "Subject: %s\nFrom: %s\nTo: %s\n\n" % (subject, sender, email) + msg from smtplib import SMTP server = SMTP("localhost") - server.sendmail(frommail, sender, mail) + server.sendmail(sender, email, mail) server.close() if not sendmail: - print text_ok, fail, sender + print text_ok, fail, email print filename if not fail: lock_file(gamedir + "/orders.queue") queue = open(gamedir + "/orders.queue", "a") - queue.write("email=%s file=%s locale=%s game=%s\n" % (sender, filename, locale, game)) + queue.write("email=%s file=%s locale=%s game=%s\n" % (email, filename, locale, game)) queue.close() unlock_file(gamedir + "/orders.queue") - logger.info("done - accepted orders from " + sender) + logger.info("done - accepted orders from " + email) return 0 diff --git a/process/orders-process b/process/orders-process index 753385e2e..b33cc05bf 100755 --- a/process/orders-process +++ b/process/orders-process @@ -2,7 +2,9 @@ # -*- coding: iso-8859-1 -*- from os import unlink, symlink, rename, popen, tmpfile -from os.path import exists +import os +import os.path +import ConfigParser from re import compile, IGNORECASE from string import split, join, upper, strip from sys import argv, exit @@ -14,9 +16,8 @@ from epasswd import EPasswd def pwd_get_email(faction, pwd, pwdfile=None): return None -def splitfilename(filename): - from os.path import split - return split(filename) +def split_filename(filename): + return os.path.split(filename) def unlock_file(filename): try: @@ -28,7 +29,7 @@ def unlock_file(filename): def lock_file(filename): i = 0 wait = 1 - if not exists(filename): + if not os.path.exists(filename): file=open(filename, "w") file.close() while True: @@ -62,17 +63,47 @@ messages = { "error-en": "Error", } +game = int(sys.argv[1]) +echeck_cmd = "/home/eressea/echeck/echeck.sh" +maxlines = 25 # base directory for all your games: -rootdir = "/home/eressea/eressea" -frommail = "Eressea Server " -orderbase = "orders.dir" -sendmail = True -maxlines = 25 -echeck_cmd = "/home/eressea/echeck/echeck.sh" +install_dir = "/home/eressea/eressea" +if 'ERESSEA' in os.environ: + install_dir = os.environ['ERESSEA'] +elif 'HOME' in os.environ: + install_dir = os.path.join(os.environ['HOME'], '/eressea') +if not os.path.isdir(install_dir): + print "please set the ERESSEA environment variable to the install path" + sys.exit(1) + +game_dir = os.path.join(install_dir, "game-%d" % (game, )) +frommail = 'eressea-server@kn-bremen.de' +gamename = 'Eressea' +sender = '%s Server <%s>' % (gamename, frommail) + +inifile = os.path.join(gamedir, 'eressea.ini') +if not os.path.exists(inifile): + print "no such file: " . inifile +else: + config = ConfigParser.ConfigParser() + config.read(inifile) + if config.has_option('game', 'email'): + frommail = config.get('game', 'email') + if config.has_option('game', 'name'): + gamename = config.get('game', 'name') + if config.has_option('game', 'sender'): + sender = config.get('game', 'sender') + else: + sender = "%s Server <%s>" % (gamename, frommail) + config = None + +queue_file = os.path.join(game_dir, "orders.queue") +if not os.path.exists(queue_file): + exit(0) # regular expression that finds the start of a faction -fact_re = compile("^\s*(eressea|vinyambar|partei|faction)\s+([a-zA-Z0-9]+)\s+\"?([^\"]*)\"?", IGNORECASE) +fact_re = compile("^\s*(eressea|partei|faction)\s+([a-zA-Z0-9]+)\s+\"?([^\"]*)\"?", IGNORECASE) def check_pwd(filename, email, pw_data): results = [] @@ -98,7 +129,7 @@ def check_pwd(filename, email, pw_data): return results def echeck(filename, locale, rules): - dirname, filename = splitfilename(filename) + dirname, filename = split_filename(filename) stream = popen("%s %s %s %s %s" % (echeck_cmd, locale, filename, dirname, rules), 'r') lines = stream.readlines() if len(lines)==0: @@ -111,14 +142,6 @@ def echeck(filename, locale, rules): stream.close() return mail -## the main body of the script -game = int(argv[1]) - -basedir = rootdir + "/game-%d" % (game, ) -queuename = basedir + "/orders.queue" -if not exists(queuename): - exit(0) - # parse the queue file - #print "connecting to SMTP..." from smtplib import SMTP @@ -127,16 +150,17 @@ try: except: print "could not connect to SMTP server" exit(0) + #print "reading password file..." -pw_data = EPasswd(basedir + "/passwd") +pw_data = EPasswd(os.path.join(game_dir,"passwd")) #print "reading orders.queue..." # move the queue file to a save space while locking it: try: - lock_file(queuename) + lock_file(queue_file) except: exit(0) -queuefile = open(queuename, "r") +queuefile = open(queue_file, "r") lines = queuefile.readlines() queuefile.close() @@ -154,9 +178,9 @@ tmpfile.close() openlog("orders") -unlink(queuename) +unlink(queue_file) try: - unlock_file(queuename) + unlock_file(queue_file) except: pass @@ -170,15 +194,15 @@ for line in lines: email = dict["email"] locale = dict["locale"] game = int(dict["game"]) - file = dict["file"] + infile = dict["file"] gamename='[E%d]' % game rules='e%d' % game warning = "" failed = True - results = check_pwd(file, email, pw_data) - logfile = open(basedir+"/zug.log", "a") - dirname, filename = splitfilename(file) - msg = messages["validate-"+locale] + " " + filename + "\n\n" + results = check_pwd(infile, email, pw_data) + logfile = open(os.path.join(game_dir, "zug.log"), "a") + dirname, filename = split_filename(infile) + msg = messages["validate-"+locale] + " " + infilename + "\n\n" for faction, game_email, success, pwd in results: msg = msg + messages["faction-"+locale] + " " + faction + "\n" if success: failed = False @@ -189,25 +213,24 @@ for line in lines: if failed: warning = " (" + messages["warning-" + locale] + ")" - syslog("failed - no valid password in " + file) + syslog("failed - no valid password in " + infile) else: - result = echeck(file, locale, rules) - if email=='eressea': - print result - continue - elif result is None: + result = None + if os.path.exists(echeck_cmd): + result = echeck(infile, locale, rules) + if result is None: # echeck did not finish - msg = msg + "Echeck was killed. Your turn was accepted, but could not be verified.\n" + msg = msg + "Echeck is broken. Your turn was accepted, but could not be verified.\n" warning = " (" + messages["warning-" + locale] + ")" - syslog("process - echeck got killed, " + file) + syslog("process - echeck broken, " + infile) else: msg = msg + result - syslog("process - checked orders in " + file) + syslog("process - checked orders in " + infile) subject = gamename + " " + messages["subject-" + locale] + warning - msg = "Subject: %s\nFrom: %s\nTo: %s\nContent-Type: text/plain; charset=utf-8\n\n" % (subject, frommail, email) + msg + msg = "Subject: %s\nFrom: %s\nTo: %s\nContent-Type: text/plain; charset=utf-8\n\n" % (subject, sender, email) + msg try: - server.sendmail(frommail, email, msg) + server.sendmail(sender, email, msg) except: syslog("failed - cannot send to " + email) diff --git a/s/setup b/s/setup index fc5fb9874..d8ffa74ad 100755 --- a/s/setup +++ b/s/setup @@ -94,8 +94,8 @@ touch eressea.ini } ini_start -ini_sec eressea -ini_add eressea locales de,en +ini_sec game +ini_add game locales de,en ini_sec lua ini_add lua install $SOURCE ini_add lua paths $SOURCE/scripts:$SOURCE/lunit diff --git a/src/main.c b/src/main.c index 5e998f835..2d81041ec 100644 --- a/src/main.c +++ b/src/main.c @@ -54,23 +54,23 @@ static void load_inifile(dictionary * d) assert(d); - str = iniparser_getstring(d, "eressea:base", basedir); + str = iniparser_getstring(d, "game:base", basedir); if (str != basedir) { set_basepath(str); } - str = iniparser_getstring(d, "eressea:report", reportdir); + str = iniparser_getstring(d, "game:report", reportdir); if (str != reportdir) { set_reportpath(str); } - str = iniparser_getstring(d, "eressea:data", datadir); + str = iniparser_getstring(d, "game:data", datadir); if (str != datadir) { set_datapath(str); } - lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0; + lomem = iniparser_getint(d, "game:lomem", lomem) ? 1 : 0; - verbosity = iniparser_getint(d, "eressea:verbose", 2); - str = iniparser_getstring(d, "eressea:locales", "de,en"); + verbosity = iniparser_getint(d, "game:verbose", 2); + str = iniparser_getstring(d, "game:locales", "de,en"); make_locales(str); if (global.inifile) iniparser_freedict(global.inifile); @@ -84,7 +84,7 @@ static void parse_config(const char *filename) load_inifile(d); log_debug("reading from configuration file %s\n", filename); - memdebug = iniparser_getint(d, "eressea:memcheck", memdebug); + memdebug = iniparser_getint(d, "game:memcheck", memdebug); #ifdef USE_CURSES /* only one value in the [editor] section */ force_color = iniparser_getint(d, "editor:color", force_color); From e6f676c30c2a93924169d07ad9a4e1815c1b2895 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 Jan 2017 20:05:33 +0100 Subject: [PATCH 407/675] we do not need eressea.conf --- process/send-bz2-report | 1 - process/sendreport.sh | 1 - process/sendreports.sh | 1 - 3 files changed, 3 deletions(-) diff --git a/process/send-bz2-report b/process/send-bz2-report index e9962d539..983564bea 100755 --- a/process/send-bz2-report +++ b/process/send-bz2-report @@ -8,7 +8,6 @@ if [ ! -f reports.txt ]; then exit -2 fi source $HOME/bin/functions.sh -source $ERESSEA/etc/eressea.conf TEMPLATE=report-mail.txt if [ "$1" == "-Lde" ] diff --git a/process/sendreport.sh b/process/sendreport.sh index 1b9af1d35..93d52f0b4 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -8,7 +8,6 @@ if [ -z $ERESSEA ]; then exit -2 fi source $HOME/bin/functions.sh -source $HOME/etc/eressea.conf GAME=$1 EMAIL=$2 diff --git a/process/sendreports.sh b/process/sendreports.sh index fc24200b6..c2bfa741c 100755 --- a/process/sendreports.sh +++ b/process/sendreports.sh @@ -8,7 +8,6 @@ if [ -z $ERESSEA ]; then exit -2 fi source $HOME/bin/functions.sh -source $ERESSEA/etc/eressea.conf if [ ! -z $1 ]; then GAME=$ERESSEA/game-$1 From b51349df6bc1afe7667dd33062abc15263b59464 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 Jan 2017 22:39:38 +0100 Subject: [PATCH 408/675] change error message categories. also removing some unused messages and code that supports them. https://bugs.eressea.de/view.php?id=2270 --- res/core/messages.xml | 117 +++++++--------------------------------- src/kernel/messages.c | 18 ------- src/kernel/types.h | 2 - src/util/unicode.test.c | 17 ++++++ 4 files changed, 36 insertions(+), 118 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 260f76c70..41569d9f3 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -1804,7 +1804,7 @@ "$unit($unit) in $region($region): '$order($command)' - Der Magier erschafft ein Traumgebäude." "$unit($unit) in $region($region): '$order($command)' - The magician creates an illusionary building." - + @@ -2402,7 +2402,7 @@ "Eine Botschaft von $unit.dative($unit) in $region($region): 'Ups! Quack, Quack!'" "A message from $unit($unit) in $region($region): 'Oops! Croak, Croak!'" - + @@ -2412,7 +2412,7 @@ "$unit($unit) in $region($region): '$order($command)' - $unit($mage) kann Zauber, die durch $unit($unit) gewirkt werden, nicht zusätzlich in die Ferne richten." "$unit($unit) in $region($region): '$order($command)' - $unit($mage) cannot direct spells that are channeled through $unit($unit) into distant regions." - + @@ -2552,13 +2552,6 @@ "$unit($unit) in $region($region) regeneriert $int($amount) Aura." "$unit($unit) regenerates $int($amount) aura in $region($region)." - - - - - "$string" - "$string" - @@ -2596,13 +2589,6 @@ "$unit($teacher) lehrt $unit($student) $skill($skill)." "$unit($teacher) teaches $unit($student) $skill($skill)." - - - - - "$string" - "$string" - @@ -2834,13 +2820,6 @@ "$unit($unit) baut für $int($size) an $ship($ship) weiter." "$unit($unit) builds $int($size) more on $ship($ship)." - - - - - "$string" - "$string" - @@ -2878,15 +2857,7 @@ "$unit($unit) $if($eq($mode,1),"reitet", "wandert") von $region($start) nach $region($end).$if($isnull($regions),""," Dabei wurde $trail($regions) durchquert.")" "$unit($unit) $if($eq($mode,1),"rides", "walks") from $region($start) to $region($end)$if($isnull($regions),""," by way of $trail($regions)")." - - - - - - "$unit($unit) entdeckt dass im $direction($direction) $terrain($region) ist." - "$unit($unit) discovered that $terrain($region) lies in the $direction($direction)." - - + @@ -2895,7 +2866,7 @@ "$unit($unit) entdeckt, dass $region($region) $localize($terrain) ist." "$unit($unit) discovered that $region($region) is $localize($terrain)." - + @@ -2903,7 +2874,7 @@ "$unit($unit) ist in dieser Runde gelandet und kann nicht weiter ins Landesinnere nach $region($region) vorstossen." "$unit($unit) has just landed and cannot continue moving to $region($region)." - + @@ -2911,7 +2882,7 @@ "Die Mannschaft der $ship($ship) kann in letzter Sekunde verhindern, dass das Schiff in $region($region) auf Land aufläuft." "At the very last moment, the crew of the $ship($ship) saved the ship from running aground in $region($region)." - + @@ -2919,7 +2890,7 @@ "Die $ship($ship) konnte in $region($region) nicht einreisen, die Küste ist zu gefährlich für das Schiff." "The $ship($ship) could not berth in $region($region). The coast is too dangerous for the vessel." - + @@ -2927,7 +2898,7 @@ "Die Mannschaft der $ship($ship) weigert sich, nach $direction($direction) zu reisen." "The crew of the $ship($ship) refuses to travel to the $direction($direction)." - + @@ -2935,7 +2906,7 @@ "Die Mannschaft der $ship($ship) weigert sich, nach $region($region) zu reisen." "The crew of the $ship($ship) refuses to travel to $region($region)." - + @@ -2943,7 +2914,7 @@ "$unit($unit) weigert sich, nach $direction($direction) zu reisen." "$unit($unit) refuses to travel to the $direction($direction)." - + @@ -2951,7 +2922,7 @@ "$unit($unit) weigert sich, nach $region($region) zu reisen." "$unit($unit) refuses to travel to $region($region)." - + @@ -2959,7 +2930,7 @@ "Die $ship($ship) konnte $region($region) nicht verlassen." "The $ship($ship) could not leave $region($region)." - + @@ -2968,35 +2939,7 @@ "$unit($unit) wurde in $region($region) von $unit.dative($guard) aufgehalten." "$unit($unit) was kept in $region($region) by $unit($guard)." - - - - - "Wir haben den Krieg mit $faction($faction) beendet." - "We declared peace with $faction($faction)." - - - - - - "$faction($faction) hat den Krieg mit uns beendet." - "$faction($faction) has declared peace with us." - - - - - - "Wir haben $faction($faction) den Krieg erklärt." - "We declared war on $faction($faction)." - - - - - - "$faction($faction) hat uns den Krieg erklärt." - "$faction($faction) has declared war on us." - - + @@ -3005,7 +2948,7 @@ "$unit($unit) konnte nicht von $region($region) nach $region($target) reisen, da der Besitzer der Region es verhinderte." "$unit($unit) could not travel from $region($region) to $region($target) because the owner denied entrance." - + @@ -3029,7 +2972,7 @@ "$unit($follower) konnte $unit($unit) nicht folgen." "$unit($follower) could not follow $unit($unit)." - + @@ -3037,7 +2980,7 @@ "$unit($unit) entdeckt, dass es keinen Weg nach $direction($direction) gibt." "$unit($unit) discovers that there is no route going $direction($direction)." - + @@ -3046,13 +2989,6 @@ "$unit($unit) konnte von $region($region) nicht nach $direction($direction) ausreisen, der Nebel war zu dicht." "$unit($unit) could not travel $direction($direction) from $region($region), the fog was too dense." - - - - - "$string" - "$string" - @@ -6945,13 +6881,6 @@ "$unit($unit) in $region($region): '$order($command)' - Man benötigt mindestens $int($minskill) $skill($skill), um $resource($product,0) zu produzieren." "$unit($unit) in $region($region): '$order($command)' - You need at least $int($minskill) $skill($skill), to produce $resource($product,0)." - - - - - "$string" - "$string" - @@ -6959,13 +6888,6 @@ "$string" "$string" - - - - - "$string" - "$string" - @@ -6997,7 +6919,6 @@ "$unit($target) erhält $int($amount) $resource($resource,$amount) von $unit($unit)." "$unit($target) receives $int($amount) $resource($resource,$amount) from $unit($unit)." - @@ -7200,7 +7121,7 @@ "$unit($unit) in $region($region): '$order($command)' - No pyramids may be build in this region. The closest region to build a pyramid in is between $int($mindist) and $int($maxdist) regions away." - + @@ -7621,7 +7542,7 @@ "Heer $int($index)($abbrev): $int($dead) Tote, $int($fled) Geflohene, $int($survived) Überlebende." "Army $int($index)($abbrev): $int($dead) dead, $int($fled) fled, $int($survived) survivors." - + diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 89278624f..cb859df96 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -214,29 +214,11 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level) UNUSED_ARG(level); switch (mtype) { - case MSG_INCOME: - assert(f); - m = add_message(&f->msgs, msg_message("msg_economy", "string", s)); - break; case MSG_BATTLE: assert(0 || !"battle messages must not use addmessage"); break; - case MSG_MOVE: - assert(f); - m = add_message(&f->msgs, msg_message("msg_movement", "string", s)); - break; - case MSG_COMMERCE: - assert(f); - m = add_message(&f->msgs, msg_message("msg_economy", "string", s)); - break; - case MSG_PRODUCE: - assert(f); - m = add_message(&f->msgs, msg_message("msg_production", "string", s)); - break; case MSG_MAGIC: - case MSG_COMMENT: case MSG_MESSAGE: - case MSG_ORCVERMEHRUNG: case MSG_EVENT: /* Botschaften an REGION oder einzelne PARTEI */ m = msg_message("msg_event", "string", s); diff --git a/src/kernel/types.h b/src/kernel/types.h index 2b63f7e07..b9faefce7 100644 --- a/src/kernel/types.h +++ b/src/kernel/types.h @@ -146,9 +146,7 @@ typedef enum { /* Fehler und Meldungen im Report */ MSG_INCOME, MSG_COMMERCE, MSG_PRODUCE, - MSG_ORCVERMEHRUNG, MSG_MESSAGE, - MSG_COMMENT, MSG_MAGIC, MAX_MSG } msg_t; diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index ef07c944c..a6268186e 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -100,9 +100,26 @@ static void test_unicode_utf8_to_ucs(CuTest *tc) { CuAssertIntEquals(tc, 1, sz); } +static void test_unicode_bug2262(CuTest *tc) { + char name[7]; + ucs4_t ucs; + size_t sz; + + strcpy(name, "utende"); + CuAssertIntEquals(tc, 0, unicode_utf8_to_ucs4(&ucs, name, &sz)); + CuAssertIntEquals(tc, 1, sz); + CuAssertIntEquals(tc, 'u', ucs); + CuAssertIntEquals(tc, 0, unicode_utf8_trim(name)); + + name[0] = -4; // latin1: ü should fail to decode + CuAssertIntEquals(tc, EILSEQ, unicode_utf8_to_ucs4(&ucs, name, &sz)); + CuAssertIntEquals(tc, EILSEQ, unicode_utf8_trim(name)); +} + CuSuite *get_unicode_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_unicode_bug2262); SUITE_ADD_TEST(suite, test_unicode_tolower); SUITE_ADD_TEST(suite, test_unicode_trim); SUITE_ADD_TEST(suite, test_unicode_utf8_to_other); From e511bf76b57e164252d8a83fe13afe3666bf9aa1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Jan 2017 18:53:11 +0100 Subject: [PATCH 409/675] read game configuration data from .ini file --- src/kernel/config.c | 34 ++++++++++++++++++++++++++++++++++ src/kernel/config.h | 1 + src/main.c | 1 + 3 files changed, 36 insertions(+) diff --git a/src/kernel/config.c b/src/kernel/config.c index d369d0ecd..0e1f159eb 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -712,6 +712,40 @@ bool config_changed(int *cache_key) { return false; } +#define MAXKEYS 16 +void config_set_from(const dictionary *d) +{ + int s, nsec = iniparser_getnsec(d); + for (s=0;s!=nsec;++s) { + char key[128]; + const char *sec = iniparser_getsecname(d, s); + int k, nkeys = iniparser_getsecnkeys(d, sec); + const char *akeys[MAXKEYS]; + const char ** keys = akeys; + size_t slen = strlen(sec); + assert(slenMAXKEYS) { + keys = malloc(sizeof(const char *) * nkeys); + } + iniparser_getseckeys(d, sec, keys); + for (k=0;k!=nkeys;++k) { + const char *val; + size_t klen = strlen(keys[k]); + assert(klen+slen+1 Date: Sat, 21 Jan 2017 19:53:47 +0100 Subject: [PATCH 410/675] issue #629: fix eressea.ini config fixed reading of ini data into config (keys have a . here, not a :). added a test. removed obsolete global.inifile variable. --- src/bindings.c | 10 +++++----- src/bindings.h | 6 +++--- src/kernel/config.c | 10 +++++----- src/kernel/config.h | 5 +++-- src/kernel/config.test.c | 17 +++++++++++++++++ src/main.c | 17 ++++++++--------- 6 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index 13b562af6..99155613a 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -978,7 +978,7 @@ static int tolua_report_unit(lua_State * L) return 1; } -static void parse_inifile(lua_State * L, dictionary * d, const char *section) +static void parse_inifile(lua_State * L, const dictionary * d, const char *section) { int i; const char *arg; @@ -1018,7 +1018,7 @@ static void parse_inifile(lua_State * L, dictionary * d, const char *section) void tolua_bind_open(lua_State * L); -int tolua_bindings_open(lua_State * L) +int tolua_bindings_open(lua_State * L, const dictionary *inifile) { tolua_open(L); @@ -1072,7 +1072,7 @@ int tolua_bindings_open(lua_State * L) tolua_module(L, TOLUA_CAST "config", 1); tolua_beginmodule(L, TOLUA_CAST "config"); { - parse_inifile(L, global.inifile, "lua"); + parse_inifile(L, inifile, "lua"); tolua_variable(L, TOLUA_CAST "locales", &config_get_locales, 0); tolua_function(L, TOLUA_CAST "get_resource", &config_get_resource); tolua_variable(L, TOLUA_CAST "buildings", &config_get_buildings, 0); @@ -1142,12 +1142,12 @@ void lua_done(lua_State * L) { lua_close(L); } -lua_State *lua_init(void) { +lua_State *lua_init(const dictionary *inifile) { lua_State *L = luaL_newstate(); openlibs(L); register_tolua_helpers(); - tolua_bindings_open(L); + tolua_bindings_open(L, inifile); tolua_eressea_open(L); #ifdef USE_SQLITE tolua_sqlite_open(L); diff --git a/src/bindings.h b/src/bindings.h index 8eda1178b..b4523e582 100755 --- a/src/bindings.h +++ b/src/bindings.h @@ -16,10 +16,10 @@ extern "C" { struct lua_State; struct selist; + struct _dictionary_; int tolua_sqlite_open(struct lua_State *L); - int tolua_bindings_open(struct lua_State *L); - int tolua_spelllist_next(struct lua_State *L); + int tolua_bindings_open(struct lua_State *L, const struct _dictionary_ *d); int tolua_itemlist_next(struct lua_State *L); int tolua_orderlist_next(struct lua_State *L); int tolua_selist_push(struct lua_State *L, const char *list_type, @@ -28,7 +28,7 @@ extern "C" { int log_lua_error(struct lua_State *L); void lua_done(struct lua_State *L); - struct lua_State *lua_init(void); + struct lua_State *lua_init(const struct _dictionary_ *d); int eressea_run(struct lua_State *L, const char *luafile); #ifdef __cplusplus diff --git a/src/kernel/config.c b/src/kernel/config.c index 0e1f159eb..d05c29d1b 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -720,12 +720,12 @@ void config_set_from(const dictionary *d) char key[128]; const char *sec = iniparser_getsecname(d, s); int k, nkeys = iniparser_getsecnkeys(d, sec); - const char *akeys[MAXKEYS]; - const char ** keys = akeys; + char *akeys[MAXKEYS]; + char ** keys = akeys; size_t slen = strlen(sec); assert(slenMAXKEYS) { keys = malloc(sizeof(const char *) * nkeys); } @@ -734,8 +734,8 @@ void config_set_from(const dictionary *d) const char *val; size_t klen = strlen(keys[k]); assert(klen+slen+1 #include #include "types.h" -struct param; + + struct param; + struct _dictionary_; #define DISPLAYSIZE 8192 /* max. L�nge einer Beschreibung, incl trailing 0 */ #define ORDERSIZE (DISPLAYSIZE*2) /* max. length of an order */ @@ -108,7 +110,6 @@ struct param; struct attrib *attribs; unsigned int data_turn; void *vm_state; - struct _dictionary_ *inifile; struct global_functions { int(*wage) (const struct region * r, const struct faction * f, const struct race * rc, int in_turn); diff --git a/src/kernel/config.test.c b/src/kernel/config.test.c index 405587443..719ff840e 100644 --- a/src/kernel/config.test.c +++ b/src/kernel/config.test.c @@ -9,6 +9,8 @@ #include #include +#include + #include #include @@ -233,9 +235,24 @@ static void test_rules(CuTest *tc) { CuAssertIntEquals(tc, 1000, rule_faction_limit()); } +static void test_config_inifile(CuTest *tc) { + dictionary *ini; + test_setup(); + ini = dictionary_new(0); + dictionary_set(ini, "game", NULL); + iniparser_set(ini, "game:id", "42"); + iniparser_set(ini, "game:name", "Eressea"); + config_set_from(ini); + CuAssertStrEquals(tc, "Eressea", config_get("game.name")); + CuAssertIntEquals(tc, 42, game_id()); + iniparser_freedict(ini); + test_cleanup(); +} + CuSuite *get_config_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_config_inifile); SUITE_ADD_TEST(suite, test_config_cache); SUITE_ADD_TEST(suite, test_get_set_param); SUITE_ADD_TEST(suite, test_param_int); diff --git a/src/main.c b/src/main.c index 97c84dffe..777770f0a 100644 --- a/src/main.c +++ b/src/main.c @@ -72,12 +72,9 @@ static void load_inifile(dictionary * d) verbosity = iniparser_getint(d, "game:verbose", 2); str = iniparser_getstring(d, "game:locales", "de,en"); make_locales(str); - - if (global.inifile) iniparser_freedict(global.inifile); - global.inifile = d; } -static void parse_config(const char *filename) +static dictionary *parse_config(const char *filename) { dictionary *d = iniparser_load(filename); if (d) { @@ -92,6 +89,7 @@ static void parse_config(const char *filename) gm_codepage = iniparser_getint(d, "editor:codepage", gm_codepage); #endif } + return d; } static int usage(const char *prog, const char *arg) @@ -272,10 +270,11 @@ int main(int argc, char **argv) { int err = 0; lua_State *L; + dictionary *d; setup_signal_handler(); /* ini file sets defaults for arguments*/ - parse_config(inifile); - if (!global.inifile) { + d = parse_config(inifile); + if (!d) { log_error("could not open ini configuration %s\n", inifile); } /* parse arguments again, to override ini file */ @@ -283,7 +282,7 @@ int main(int argc, char **argv) locale_init(); - L = lua_init(); + L = lua_init(d); game_init(); bind_monsters(L); err = eressea_run(L, luafile); @@ -294,8 +293,8 @@ int main(int argc, char **argv) game_done(); lua_done(L); log_close(); - if (global.inifile) { - iniparser_freedict(global.inifile); + if (d) { + iniparser_freedict(d); } return 0; } From dbc6a17e66d38f11f8acce5d153ac054e603aec8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Jan 2017 20:39:46 +0100 Subject: [PATCH 411/675] fix gcc build, introduce a hard limit on ini section size --- src/kernel/config.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index d05c29d1b..57874f118 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -720,15 +720,12 @@ void config_set_from(const dictionary *d) char key[128]; const char *sec = iniparser_getsecname(d, s); int k, nkeys = iniparser_getsecnkeys(d, sec); - char *akeys[MAXKEYS]; - char ** keys = akeys; + const char *keys[MAXKEYS]; size_t slen = strlen(sec); + assert(nkeys <= MAXKEYS); assert(slenMAXKEYS) { - keys = malloc(sizeof(const char *) * nkeys); - } iniparser_getseckeys(d, sec, keys); for (k=0;k!=nkeys;++k) { const char *val; @@ -740,9 +737,6 @@ void config_set_from(const dictionary *d) config_set(key, val); } } - if (keys!=akeys) { - free(keys); - } } } From 82193864c54efbf31eadbc481e8590defb51ed12 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Jan 2017 20:51:08 +0100 Subject: [PATCH 412/675] fix valgrind error. I did not understand what keys look like, then effed up when fixing that. --- src/kernel/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index 57874f118..a07c36aba 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -731,7 +731,7 @@ void config_set_from(const dictionary *d) const char *val; size_t klen = strlen(keys[k]); assert(klen+slen+1 Date: Sat, 21 Jan 2017 20:59:16 +0100 Subject: [PATCH 413/675] config.json settings shall not override eressea.ini --- src/kernel/jsonconf.c | 4 +++- src/kernel/jsonconf.test.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 414704309..03e210ce0 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -806,7 +806,9 @@ static void json_settings(cJSON *json) { else { sprintf(value, "%d", child->valueint); } - config_set(child->string, value); + if (config_get(child->string) == NULL) { + config_set(child->string, value); + } } } } diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 950868046..93fcd8d10 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -69,12 +69,15 @@ static void test_settings(CuTest * tc) "\"string\" : \"1d4\"," "\"integer\" : 14," "\"true\": true," + "\"game.id\": 4," "\"false\": false," "\"float\" : 1.5 }}"; cJSON *json = cJSON_Parse(data); test_cleanup(); + config_set("game.id", "42"); // should not be replaced json_config(json); + CuAssertStrEquals(tc, "42", config_get("game.id")); CuAssertStrEquals(tc, "1", config_get("true")); CuAssertStrEquals(tc, "0", config_get("false")); CuAssertStrEquals(tc, "1d4", config_get("string")); From a6dd02c11198356b0b03f4a1ea2a21d8412d5b51 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Jan 2017 21:03:48 +0100 Subject: [PATCH 414/675] add game id to eressea.ini --- s/setup | 1 + 1 file changed, 1 insertion(+) diff --git a/s/setup b/s/setup index d8ffa74ad..848175ddc 100755 --- a/s/setup +++ b/s/setup @@ -96,6 +96,7 @@ touch eressea.ini ini_start ini_sec game ini_add game locales de,en +ini_add id $game ini_sec lua ini_add lua install $SOURCE ini_add lua paths $SOURCE/scripts:$SOURCE/lunit From 39375e8d4a0dba73618144bf611539f774ab20dd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 04:46:36 +0100 Subject: [PATCH 415/675] use the email address from eressea.ini in CR mailto --- conf/e2/config.xml | 4 ---- conf/e3/config.xml | 4 ---- conf/e4/config.xml | 4 ---- src/creport.c | 7 +++++-- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 0441a46f6..9e32218da 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -53,10 +53,6 @@ - - eressea-server@eressea.kn-bremen.de - eressea-server@eressea.kn-bremen.de - Bitte denke daran, deine Befehle mit dem Betreff ERESSEA 2 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. diff --git a/conf/e3/config.xml b/conf/e3/config.xml index c8c5dbb06..6a5b18b84 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -45,10 +45,6 @@ - - eressea-server@eressea.kn-bremen.de - eressea-server@eressea.kn-bremen.de - Bitte denke daran, deine Befehle mit dem Betreff ERESSEA 3 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. diff --git a/conf/e4/config.xml b/conf/e4/config.xml index b188f7d79..3209c8eed 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -46,10 +46,6 @@ - - eressea-server@eressea.kn-bremen.de - eressea-server@eressea.kn-bremen.de - Bitte denke daran, deine Befehle mit dem Betreff ERESSEA 4 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. diff --git a/src/creport.c b/src/creport.c index 5e01433d4..fc944779f 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1475,7 +1475,7 @@ report_computer(const char *filename, report_context * ctx, const char *bom) faction *f = ctx->f; const char *prefix; region *r; - const char *mailto = LOC(f->locale, "mailto"); + const char *mailto = config_get("game.email"); const attrib *a; FILE *F = fopen(filename, "w"); static const race *rc_human; @@ -1510,8 +1510,11 @@ report_computer(const char *filename, report_context * ctx, const char *bom) fprintf(F, "%d;Zeitalter\n", era); fprintf(F, "\"%s\";Build\n", eressea_version()); if (mailto != NULL) { + // char mailcmd[64]; + // snprintf(mailcmd, sizeof(mailcmd), "%s %d, %s", game_name(), game_id(), LOC(f->locale, "mailcmd")); + const char * mailcmd = LOC(f->locale, "mailcmd"); fprintf(F, "\"%s\";mailto\n", mailto); - fprintf(F, "\"%s\";mailcmd\n", LOC(f->locale, "mailcmd")); + fprintf(F, "\"%s\";mailcmd\n", mailcmd); } show_alliances_cr(F, f); From 0496c660287cb6a9bb3db80c4d70d084142012f4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 04:55:19 +0100 Subject: [PATCH 416/675] use FACTION in text template, not ERESSEA --- src/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/report.c b/src/report.c index 503f12732..bbbdb2fb6 100644 --- a/src/report.c +++ b/src/report.c @@ -1408,7 +1408,7 @@ report_template(const char *filename, report_context * ctx, const char *bom) newline(out); newline(out); - sprintf(buf, "%s %s \"password\"", LOC(f->locale, "ERESSEA"), itoa36(f->no)); + sprintf(buf, "%s %s \"password\"", LOC(f->locale, parameters[P_FACTION]), itoa36(f->no)); rps_nowrap(out, buf); newline(out); newline(out); From 847cfb54258356f4f9cb778f7677173a1ff72db3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 05:13:44 +0100 Subject: [PATCH 417/675] game.start in eressea.ini overrides calendar --- s/setup | 3 ++- src/bindings.c | 2 +- src/calendar.c | 9 +++++++-- src/calendar.h | 6 +++--- src/kernel/xmlreader.c | 7 ++++++- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/s/setup b/s/setup index 848175ddc..e3e8e113d 100755 --- a/s/setup +++ b/s/setup @@ -96,7 +96,8 @@ touch eressea.ini ini_start ini_sec game ini_add game locales de,en -ini_add id $game +ini_add game id $game +ini_add game start 1 ini_sec lua ini_add lua install $SOURCE ini_add lua paths $SOURCE/scripts:$SOURCE/lunit diff --git a/src/bindings.c b/src/bindings.c index 99155613a..576c54939 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -948,7 +948,7 @@ static int init_data(const char *filename, const char *catalog) return l; } if (turn < 0) { - turn = first_turn; + turn = first_turn(); } return 0; } diff --git a/src/calendar.c b/src/calendar.c index 7a27328a7..2099b6631 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -1,10 +1,10 @@ #include #include "calendar.h" +#include #include #include -int first_turn = 0; int first_month = 0; int weeks_per_month = 4; int months_per_year = 12; @@ -16,10 +16,15 @@ int *month_season = NULL; char *agename = NULL; int seasons = 0; +int first_turn(void) +{ + return config_get_int("game.start", 1); +} + const gamedate *get_gamedate(int turn, gamedate * gd) { int weeks_per_year = months_per_year * weeks_per_month; - int t = turn - first_turn; + int t = turn - first_turn(); assert(gd); if (t < 0) diff --git a/src/calendar.h b/src/calendar.h index 86f665c1a..d398cd77c 100644 --- a/src/calendar.h +++ b/src/calendar.h @@ -13,7 +13,6 @@ extern "C" { }; extern char *agename; - extern int first_turn; extern int first_month; extern int seasons; @@ -35,8 +34,9 @@ extern "C" { int week; } gamedate; - extern const gamedate *get_gamedate(int turn, gamedate * gd); - extern void calendar_cleanup(void); +const gamedate *get_gamedate(int turn, gamedate * gd); +void calendar_cleanup(void); +int first_turn(void); #ifdef __cplusplus } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 2f38cdab3..2ba9d785a 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -375,8 +375,13 @@ static int parse_calendar(xmlDocPtr doc) xmlNodeSetPtr nsetWeeks, nsetMonths, nsetSeasons; xmlChar *propValue = xmlGetProp(calendar, BAD_CAST "name"); xmlChar *newyear = xmlGetProp(calendar, BAD_CAST "newyear"); + xmlChar *start; - first_turn = xml_ivalue(calendar, "start", first_turn); + start = xmlGetProp(calendar, BAD_CAST "start"); + if (start && config_get("game.start")==NULL) { + config_set("game.start", (const char *)start); + xmlFree(start); + } if (propValue) { free(agename); agename = strdup(mkname("calendar", (const char *)propValue)); From d3d72d17e8a708839b87af6a0d718d86ccf429f9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 08:03:12 +0100 Subject: [PATCH 418/675] no starting equipment. do not let the addplayer function give equipment. rename equipment for autoseed. --- conf/e2/config.xml | 2 +- conf/e3/config.xml | 8 -------- conf/e4/config.xml | 9 --------- res/eressea/equipment.xml | 22 +++++++++++----------- scripts/eressea/autoseed.lua | 6 +++--- src/kernel/faction.c | 6 ------ 6 files changed, 15 insertions(+), 38 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 9e32218da..5affea141 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -42,7 +42,7 @@ - + diff --git a/conf/e3/config.xml b/conf/e3/config.xml index 6a5b18b84..35716f332 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -28,14 +28,6 @@ - - - - - - - - diff --git a/conf/e4/config.xml b/conf/e4/config.xml index 3209c8eed..ac962202c 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -27,15 +27,6 @@ - - - - - - - - - diff --git a/res/eressea/equipment.xml b/res/eressea/equipment.xml index bf7e38376..efd4f2a3b 100644 --- a/res/eressea/equipment.xml +++ b/res/eressea/equipment.xml @@ -2,18 +2,18 @@ - + - + - + @@ -21,30 +21,30 @@ - + - + - + - + - + - + @@ -58,12 +58,12 @@ - + - + diff --git a/scripts/eressea/autoseed.lua b/scripts/eressea/autoseed.lua index 562c39361..822725804 100644 --- a/scripts/eressea/autoseed.lua +++ b/scripts/eressea/autoseed.lua @@ -64,9 +64,9 @@ local function seed(r, email, race, lang) assert(f) local u = unit.create(f, r) assert(u) - equip_unit(u, "new_faction") - equip_unit(u, "first_unit") - equip_unit(u, "first_" .. race, 7) -- disable old callbacks + equip_unit(u, "autoseed_faction") + equip_unit(u, "autoseed_unit") + equip_unit(u, "autoseed_" .. race, 7) unit.create(f, r, 5):set_skill("mining", 30) unit.create(f, r, 5):set_skill("quarrying", 30) f:set_origin(r) diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 811321f14..b0aa83efd 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -22,7 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "alliance.h" #include "ally.h" #include "curse.h" -#include "equipment.h" #include "group.h" #include "item.h" #include "messages.h" @@ -286,15 +285,10 @@ faction *addfaction(const char *email, const char *password, unit *addplayer(region * r, faction * f) { unit *u; - char buffer[32]; assert(f->units == NULL); faction_setorigin(f, 0, r->x, r->y); u = create_unit(r, f, 1, f->race, 0, NULL, NULL); - equip_items(&u->faction->items, get_equipment("new_faction")); - equip_unit(u, get_equipment("first_unit")); - sprintf(buffer, "first_%s", u_race(u)->_name); - equip_unit(u, get_equipment(buffer)); u->hp = unit_max_hp(u) * u->number; fset(u, UFL_ISNEW); if (f->race == get_race(RC_DAEMON)) { From d4a81ebd736c38fc7b6cf5ac7f99348e1b30b8dc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 11:38:01 +0100 Subject: [PATCH 419/675] make these modules optional --- scripts/eressea/autoseed.lua | 1 + scripts/eressea/embassy.lua | 8 +++++--- scripts/eressea/eternath.lua | 2 +- scripts/eressea/ponnuki.lua | 1 + scripts/eressea/wedding.lua | 1 + scripts/eressea/xmas.lua | 2 ++ 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/eressea/autoseed.lua b/scripts/eressea/autoseed.lua index 822725804..9e5060f85 100644 --- a/scripts/eressea/autoseed.lua +++ b/scripts/eressea/autoseed.lua @@ -1,3 +1,4 @@ +if not config.autoseed then return nil end local autoseed = {} -- minimum required resources in the 7-hex neighborhood: diff --git a/scripts/eressea/embassy.lua b/scripts/eressea/embassy.lua index efbe248b7..82bce62c2 100644 --- a/scripts/eressea/embassy.lua +++ b/scripts/eressea/embassy.lua @@ -1,8 +1,5 @@ -- Muschelplateau -local embassy = {} -local home = nil - -- global exports (use item) function use_seashell(u, amount) -- Muschelplateau... @@ -17,6 +14,11 @@ function use_seashell(u, amount) return -4 end +if not config.embassy then return nil end + +local embassy = {} +local home = nil + function embassy.init() home = get_region(165,30) if home==nil then diff --git a/scripts/eressea/eternath.lua b/scripts/eressea/eternath.lua index 858a8d462..063577b74 100644 --- a/scripts/eressea/eternath.lua +++ b/scripts/eressea/eternath.lua @@ -1,5 +1,5 @@ -- DEPRECATED - +if not config.eternath then return nil end -- implements parts of a quest in E2 -- this module is deprecated, because it puts functions in the global environment for at_building_action diff --git a/scripts/eressea/ponnuki.lua b/scripts/eressea/ponnuki.lua index 994a16ff0..96bb0b5f1 100644 --- a/scripts/eressea/ponnuki.lua +++ b/scripts/eressea/ponnuki.lua @@ -1,3 +1,4 @@ +if not config.ponnuki then return nil end local ponnuki = {} local directions = { "NW", "NO", "O", "SO", "SW", "W" } diff --git a/scripts/eressea/wedding.lua b/scripts/eressea/wedding.lua index 812bd3269..2c06d9891 100644 --- a/scripts/eressea/wedding.lua +++ b/scripts/eressea/wedding.lua @@ -1,4 +1,5 @@ -- DEPRECATED +if not config.wedding then return nil end -- this script contains the action functions for the two portals -- used on the jadee/wildente wedding island. the two _action functions diff --git a/scripts/eressea/xmas.lua b/scripts/eressea/xmas.lua index 36e755f45..0316e6265 100644 --- a/scripts/eressea/xmas.lua +++ b/scripts/eressea/xmas.lua @@ -1,3 +1,5 @@ +if not config.xmas then return nil end + local gifts = { e2 = { { year = 2015, turn = 959, item = 'snowglobe', msg='santa_f' }, From 48ae12b629e42caffadd21a2cd88387d221b4feb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 12:38:41 +0100 Subject: [PATCH 420/675] emit a password message for newbie factions --- src/kernel/faction.c | 1 + src/kernel/faction.h | 5 +++-- src/laws.c | 1 + src/reports.c | 8 ++++++++ src/reports.test.c | 18 ++++++++++++++++++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/kernel/faction.c b/src/kernel/faction.c index b0aa83efd..146ae06a4 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -249,6 +249,7 @@ faction *addfaction(const char *email, const char *password, if (!password) password = itoa36(rng_int()); faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT)); ADDMSG(&f->msgs, msg_message("changepasswd", "value", password)); + f->flags |= FFL_PWMSG; f->alliance_joindate = turn; f->lastorders = turn; diff --git a/src/kernel/faction.h b/src/kernel/faction.h index 757449bd8..1bab9101c 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -38,10 +38,11 @@ extern "C" { extern struct attrib_type at_maxmagicians; /* faction flags */ -#define FFL_NEWID (1<<0) /* Die Partei hat bereits einmal ihre no gewechselt */ +#define FFL_NEWID (1<<0) // Die Partei hat bereits einmal ihre no gewechselt #define FFL_ISNEW (1<<1) +#define FFL_PWMSG (1<<2) // received a "new password" message #define FFL_QUIT (1<<3) -#define FFL_CURSED (1<<4) /* you're going to have a bad time */ +#define FFL_CURSED (1<<4) // you're going to have a bad time #define FFL_DEFENDER (1<<10) #define FFL_SELECT (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */ #define FFL_NOAID (1<<21) /* Hilfsflag Kampf */ diff --git a/src/laws.c b/src/laws.c index bbf1a200b..d6e005ff8 100644 --- a/src/laws.c +++ b/src/laws.c @@ -2214,6 +2214,7 @@ int password_cmd(unit * u, struct order *ord) faction_setpassword(u->faction, password_encode(pwbuf, PASSWORD_DEFAULT)); ADDMSG(&u->faction->msgs, msg_message("changepasswd", "value", pwbuf)); + u->faction->flags |= FFL_PWMSG; return 0; } diff --git a/src/reports.c b/src/reports.c index 395547734..77682a23a 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1335,6 +1335,14 @@ void prepare_report(report_context *ctx, faction *f) rule_region_owners = config_token("rules.region_owner_pay_building", bt_lighthouse->_name); } + if (f->age<=2) { + if ((f->flags&FFL_PWMSG)==0) { + // TODO: this assumes unencrypted passwords + f->flags |= FFL_PWMSG; + ADDMSG(&f->msgs, msg_message("changepasswd", "value", f->_password)); + } + } + ctx->f = f; ctx->report_time = time(NULL); ctx->addresses = NULL; diff --git a/src/reports.test.c b/src/reports.test.c index 1794f1cff..18ce468bb 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -226,6 +226,23 @@ static void test_arg_resources(CuTest *tc) { test_cleanup(); } +static void test_newbie_password_message(CuTest *tc) { + report_context ctx; + faction *f; + test_setup(); + f = test_create_faction(0); + f->age = 5; + CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG); + prepare_report(&ctx, f); + CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "changepasswd")); + f->age=2; + prepare_report(&ctx, f); + CuAssertIntEquals(tc, FFL_PWMSG, f->flags&FFL_PWMSG); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "changepasswd")); + test_cleanup(); +} + static void test_prepare_travelthru(CuTest *tc) { report_context ctx; faction *f, *f2; @@ -465,6 +482,7 @@ static void test_seen_travelthru(CuTest *tc) { CuSuite *get_reports_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_newbie_password_message); SUITE_ADD_TEST(suite, test_prepare_report); SUITE_ADD_TEST(suite, test_seen_neighbours); SUITE_ADD_TEST(suite, test_seen_travelthru); From 6e515702296f60fc13a9888ff92d784ca0d98235 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 12:43:48 +0100 Subject: [PATCH 421/675] remove ERESSEA keyword from "bad password" message. --- res/core/messages.xml | 5 ++--- src/kernel/save.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 41569d9f3..130b58d03 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -3306,11 +3306,10 @@ - - "ERESSEA $int36($faction) \"${password}\" - Deine Befehle hatten ein falsches Passwort." - "ERESSEA $int36($faction) \"${password}\" - Your orders had the wrong password." + "Deine Befehle hatten ein falsches Passwort (${password})." + "Your orders had the wrong password (${password})." diff --git a/src/kernel/save.c b/src/kernel/save.c index bbbd77fd1..84914127a 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -235,8 +235,7 @@ static faction *factionorders(void) if (!checkpasswd(f, (const char *)pass)) { log_debug("Invalid password for faction %s", itoa36(fid)); - ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password", - f->no, pass)); + ADDMSG(&f->msgs, msg_message("wrongpasswd", "password", pass)); return 0; } /* Die Partei hat sich zumindest gemeldet, so dass sie noch From 59916d1d5c57c58f0ef53ca418a3720ea96c8bea Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 12:51:32 +0100 Subject: [PATCH 422/675] remove sqlite3 code and dependency --- CMakeLists.txt | 1 - process/sendreport.sh | 6 -- src/CMakeLists.txt | 12 --- src/bind_sqlite.c | 95 ------------------- src/bindings.c | 3 - src/bindings.h | 1 - src/sqlite.c | 207 ------------------------------------------ 7 files changed, 325 deletions(-) delete mode 100644 src/bind_sqlite.c delete mode 100644 src/sqlite.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fd15f201..5cf75771b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,6 @@ project (eressea-server C) enable_testing() find_package (LibXml2) -find_package (SQLite3) find_package (Curses) find_package (Lua REQUIRED) find_package (ToLua REQUIRED) diff --git a/process/sendreport.sh b/process/sendreport.sh index 93d52f0b4..81d16813c 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -39,9 +39,3 @@ fi source ${FACTION}.sh $EMAIL || reply "Unbekannte Partei $FACTION" -if [ -e $ERESSEA/game-$GAME/eressea.db ]; then - SQL="select email from faction f left join faction_data fd on fd.faction_id=f.id where f.game_id=$GAME AND fd.code='$FACTION' and fd.turn=(select max(turn) from faction_data fx where fx.faction_id=f.id)" - OWNER=$(sqlite3 $ERESSEA/game-$GAME/eressea.db "$SQL") - echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ - | mutt -s "Reportnachforderung Partei ${FACTION}" $OWNER -fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 39d290560..2545115fc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -155,13 +155,6 @@ set(SERVER_SRC bind_unit.c ) -if (SQLITE3_FOUND) -set (SERVER_SRC ${SERVER_SRC} - sqlite.c - bind_sqlite.c -) -endif (SQLITE3_FOUND) - if (CURSES_FOUND) set (SERVER_SRC ${SERVER_SRC} gmtool.c @@ -251,11 +244,6 @@ add_test(server test_eressea) install(TARGETS eressea DESTINATION "bin") -if (SQLITE3_FOUND) -target_link_libraries(eressea ${SQLITE3_LIBRARIES}) -add_definitions(-DUSE_SQLITE) -endif(SQLITE3_FOUND) - if (CURSES_FOUND) include_directories (${CURSES_INCLUDE_DIR}) target_link_libraries(eressea ${CURSES_LIBRARIES}) diff --git a/src/bind_sqlite.c b/src/bind_sqlite.c deleted file mode 100644 index e8c9b7565..000000000 --- a/src/bind_sqlite.c +++ /dev/null @@ -1,95 +0,0 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - -#include - -#include "bind_unit.h" -#include "bindings.h" - -#include -#include -#include - -#define LTYPE_DB TOLUA_CAST "db" - -extern int db_update_factions(sqlite3 * db, bool force, int game); -static int tolua_db_update_factions(lua_State * L) -{ - sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); - db_update_factions(db, tolua_toboolean(L, 2, 0), game_id()); - return 0; -} - -extern int db_update_scores(sqlite3 * db, bool force); -static int tolua_db_update_scores(lua_State * L) -{ - sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); - db_update_scores(db, tolua_toboolean(L, 2, 0)); - return 0; -} - -static int tolua_db_execute(lua_State * L) -{ - sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); - const char *sql = tolua_tostring(L, 2, 0); - - int res = sqlite3_exec(db, sql, 0, 0, 0); - - lua_pushinteger(L, res); - return 1; -} - -static int tolua_db_close(lua_State * L) -{ - sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); - sqlite3_close(db); - return 0; -} - -static int tolua_db_create(lua_State * L) -{ - sqlite3 *db; - const char *dbname = tolua_tostring(L, 1, 0); - int result = sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READWRITE, 0); - if (result == SQLITE_OK) { - tolua_pushusertype(L, (void *)db, LTYPE_DB); - return 1; - } - return 0; -} - -int tolua_sqlite_open(lua_State * L) -{ - /* register user types */ - - tolua_usertype(L, LTYPE_DB); - - tolua_module(L, NULL, 0); - tolua_beginmodule(L, NULL); - { - tolua_cclass(L, LTYPE_DB, LTYPE_DB, TOLUA_CAST "", NULL); - tolua_beginmodule(L, LTYPE_DB); - { - tolua_function(L, TOLUA_CAST "open", &tolua_db_create); - tolua_function(L, TOLUA_CAST "close", &tolua_db_close); - - tolua_function(L, TOLUA_CAST "update_factions", - &tolua_db_update_factions); - tolua_function(L, TOLUA_CAST "update_scores", &tolua_db_update_scores); - tolua_function(L, TOLUA_CAST "execute", &tolua_db_execute); - } - tolua_endmodule(L); - - } - tolua_endmodule(L); - return 0; -} diff --git a/src/bindings.c b/src/bindings.c index 576c54939..936d588e5 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -1149,9 +1149,6 @@ lua_State *lua_init(const dictionary *inifile) { register_tolua_helpers(); tolua_bindings_open(L, inifile); tolua_eressea_open(L); -#ifdef USE_SQLITE - tolua_sqlite_open(L); -#endif tolua_unit_open(L); tolua_building_open(L); tolua_ship_open(L); diff --git a/src/bindings.h b/src/bindings.h index b4523e582..6fa91741b 100755 --- a/src/bindings.h +++ b/src/bindings.h @@ -18,7 +18,6 @@ extern "C" { struct selist; struct _dictionary_; - int tolua_sqlite_open(struct lua_State *L); int tolua_bindings_open(struct lua_State *L, const struct _dictionary_ *d); int tolua_itemlist_next(struct lua_State *L); int tolua_orderlist_next(struct lua_State *L); diff --git a/src/sqlite.c b/src/sqlite.c deleted file mode 100644 index 9379faa4f..000000000 --- a/src/sqlite.c +++ /dev/null @@ -1,207 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -faction *get_faction_by_id(int uid) -{ - faction *f; - for (f = factions; f; f = f->next) { - if (f->subscription == uid) { - return f; - } - } - return NULL; -} - -/* -typedef struct stmt_cache { -sqlite3 *db; -sqlite3_stmt *stmt; -const char *sql; -int inuse; -} stmt_cache; - -#define MAX_STMT_CACHE 64 -static stmt_cache cache[MAX_STMT_CACHE]; -static int cache_insert; - -static sqlite3_stmt *stmt_cache_get(sqlite3 * db, const char *sql) -{ -int i; -sqlite3_stmt *stmt; - -for (i = 0; i != MAX_STMT_CACHE && cache[i].db; ++i) { -if (cache[i].sql == sql && cache[i].db == db) { -cache[i].inuse = 1; -stmt = cache[i].stmt; -sqlite3_reset(stmt); -sqlite3_clear_bindings(stmt); -return stmt; -} -} -if (i == MAX_STMT_CACHE) { -while (cache[cache_insert].inuse) { -cache[cache_insert].inuse = 0; -cache_insert = (cache_insert + 1) & (MAX_STMT_CACHE - 1); -} -i = cache_insert; -stmt = cache[i].stmt; -sqlite3_finalize(stmt); -} -cache[i].inuse = 1; -cache[i].db = db; -cache[i].sql = sql; -sqlite3_prepare_v2(db, sql, -1, &cache[i].stmt, NULL); -return cache[i].stmt; -} -*/ -typedef struct db_faction { - int uid; - int no; - char *email; - char *name; -} db_faction; - -static struct selist * -read_factions(sqlite3 * db, int game_id) { - int res; - selist *result = 0; - const char * sql = - "SELECT f.id, fd.code, fd.name, fd.email FROM faction f" - " LEFT OUTER JOIN faction_data fd" - " WHERE f.id=fd.faction_id AND f.game_id=? AND" - " fd.turn=(SELECT MAX(turn) FROM faction_data fx WHERE fx.faction_id=f.id)" - " ORDER BY f.id"; - sqlite3_stmt *stmt = 0; - sqlite3_prepare_v2(db, sql, -1, &stmt, 0); - sqlite3_bind_int(stmt, 1, game_id); - - res = sqlite3_step(stmt); - while (res == SQLITE_ROW) { - const char * text; - db_faction * dbf = (db_faction*)calloc(1, sizeof(db_faction)); - dbf->uid = (int)sqlite3_column_int64(stmt, 0); - text = (const char *)sqlite3_column_text(stmt, 1); - if (text) dbf->no = atoi36(text); - text = (const char *)sqlite3_column_text(stmt, 2); - if (text) dbf->name = strdup(text); - text = (const char *)sqlite3_column_text(stmt, 3); - if (text) dbf->email = strdup(text); - selist_push(&result, dbf); - res = sqlite3_step(stmt); - } - sqlite3_finalize(stmt); - return result; -} - -static int insert_faction(sqlite3 *db, int game_id, faction *f) { - const char *sql = "INSERT INTO faction (game_id, race) VALUES (?, ?)"; - sqlite3_stmt *stmt = 0; - sqlite3_prepare_v2(db, sql, -1, &stmt, 0); - sqlite3_bind_int(stmt, 1, game_id); - sqlite3_bind_text(stmt, 2, f->race->_name, -1, SQLITE_STATIC); - sqlite3_step(stmt); - sqlite3_finalize(stmt); - return (int)sqlite3_last_insert_rowid(db); -} - -static void update_faction(sqlite3 *db, const faction *f) { - char code[5]; - const char *sql = - "INSERT INTO faction_data (faction_id, code, name, email, lang, turn)" - " VALUES (?, ?, ?, ?, ?, ?)"; - sqlite3_stmt *stmt = 0; - strcpy(code, itoa36(f->no)); - sqlite3_prepare_v2(db, sql, -1, &stmt, 0); - sqlite3_bind_int(stmt, 1, f->subscription); - sqlite3_bind_text(stmt, 2, code, -1, SQLITE_STATIC); - sqlite3_bind_text(stmt, 3, f->name, -1, SQLITE_STATIC); - sqlite3_bind_text(stmt, 4, f->email, -1, SQLITE_STATIC); - sqlite3_bind_text(stmt, 5, locale_name(f->locale), -1, SQLITE_STATIC); - sqlite3_bind_int(stmt, 6, turn); - sqlite3_step(stmt); - sqlite3_finalize(stmt); -} - -int db_update_factions(sqlite3 * db, bool force, int game_id) { - selist *ql = read_factions(db, game_id); - faction *f; - if (!ql) return SQLITE_OK; - sqlite3_exec(db, "BEGIN", 0, 0, 0); - for (f = factions; f; f = f->next) { - bool update = force; - db_faction *dbf = 0; -#ifdef SELIST_TODO - selist_iter it = qli_init(&ql); - while (qli_more(it)) { - db_faction *df = (db_faction*)qli_next(&it); - if (f->no == df->no || strcmp(f->email, df->email) == 0 || strcmp(f->name, df->name) == 0) { - dbf = df; - } - if (f->subscription == df->uid) { - dbf = df; - break; - } - } -#endif - if (dbf) { - if (dbf->uid != f->subscription) { - log_warning("faction %s(%d) not found in database, but matches %d\n", itoa36(f->no), f->subscription, dbf->uid); - f->subscription = dbf->uid; - } - update = (dbf->no != f->no) || (strcmp(f->email, dbf->email) != 0) || (strcmp(f->name, dbf->name) != 0); - } - else { - f->subscription = insert_faction(db, game_id, f); - log_warning("faction %s not found in database, created as %d\n", itoa36(f->no), f->subscription); - update = true; - } - if (update) { - update_faction(db, f); - log_debug("faction %s updated\n", itoa36(f->no)); - } - } - sqlite3_exec(db, "COMMIT", 0, 0, 0); - return SQLITE_OK; -} - -int db_update_scores(sqlite3 * db, bool force) -{ - /* - const char *sselist_ins = - "INSERT OR FAIL INTO score (value,faction_id,turn) VALUES (?,?,?)"; - sqlite3_stmt *stmt_ins = stmt_cache_get(db, sselist_ins); - const char *sselist_upd = - "UPDATE score set value=? WHERE faction_id=? AND turn=?"; - sqlite3_stmt *stmt_upd = stmt_cache_get(db, sselist_upd); - faction *f; - sqlite3_exec(db, "BEGIN", 0, 0, 0); - for (f = factions; f; f = f->next) { - int res; - sqlite3_bind_int(stmt_ins, 1, f->score); - sqlite3_bind_int64(stmt_ins, 2, f->subscription); - sqlite3_bind_int(stmt_ins, 3, turn); - res = sqlite3_step(stmt_ins); - if (res == SQLITE_CONSTRAINT) { - sqlite3_bind_int(stmt_upd, 1, f->score); - sqlite3_bind_int64(stmt_upd, 2, f->subscription); - sqlite3_bind_int(stmt_upd, 3, turn); - res = sqlite3_step(stmt_upd); - sqlite3_reset(stmt_upd); - } - sqlite3_reset(stmt_ins); - } - sqlite3_exec(db, "COMMIT", 0, 0, 0); - */ - return SQLITE_OK; -} From f86d86d4c6758cec983cb3cf187c773396a97000 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 12:57:25 +0100 Subject: [PATCH 423/675] Revert "remove sqlite3 code and dependency" This reverts commit 7b55a57610b3e8d54ad2b1a6d6f8642ca9ae391f. --- CMakeLists.txt | 1 + process/sendreport.sh | 6 ++ src/CMakeLists.txt | 12 +++ src/bind_sqlite.c | 95 ++++++++++++++++++++ src/bindings.c | 3 + src/bindings.h | 1 + src/sqlite.c | 204 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 322 insertions(+) create mode 100644 src/bind_sqlite.c create mode 100644 src/sqlite.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cf75771b..8fd15f201 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ project (eressea-server C) enable_testing() find_package (LibXml2) +find_package (SQLite3) find_package (Curses) find_package (Lua REQUIRED) find_package (ToLua REQUIRED) diff --git a/process/sendreport.sh b/process/sendreport.sh index 81d16813c..93d52f0b4 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -39,3 +39,9 @@ fi source ${FACTION}.sh $EMAIL || reply "Unbekannte Partei $FACTION" +if [ -e $ERESSEA/game-$GAME/eressea.db ]; then + SQL="select email from faction f left join faction_data fd on fd.faction_id=f.id where f.game_id=$GAME AND fd.code='$FACTION' and fd.turn=(select max(turn) from faction_data fx where fx.faction_id=f.id)" + OWNER=$(sqlite3 $ERESSEA/game-$GAME/eressea.db "$SQL") + echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ + | mutt -s "Reportnachforderung Partei ${FACTION}" $OWNER +fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2545115fc..39d290560 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -155,6 +155,13 @@ set(SERVER_SRC bind_unit.c ) +if (SQLITE3_FOUND) +set (SERVER_SRC ${SERVER_SRC} + sqlite.c + bind_sqlite.c +) +endif (SQLITE3_FOUND) + if (CURSES_FOUND) set (SERVER_SRC ${SERVER_SRC} gmtool.c @@ -244,6 +251,11 @@ add_test(server test_eressea) install(TARGETS eressea DESTINATION "bin") +if (SQLITE3_FOUND) +target_link_libraries(eressea ${SQLITE3_LIBRARIES}) +add_definitions(-DUSE_SQLITE) +endif(SQLITE3_FOUND) + if (CURSES_FOUND) include_directories (${CURSES_INCLUDE_DIR}) target_link_libraries(eressea ${CURSES_LIBRARIES}) diff --git a/src/bind_sqlite.c b/src/bind_sqlite.c new file mode 100644 index 000000000..e8c9b7565 --- /dev/null +++ b/src/bind_sqlite.c @@ -0,0 +1,95 @@ +/* ++-------------------+ +| | Enno Rehling +| Eressea PBEM host | Christian Schlittchen +| (c) 1998 - 2008 | Katja Zedel +| | Henning Peters ++-------------------+ + +This program may not be used, modified or distributed +without prior permission by the authors of Eressea. +*/ + +#include + +#include "bind_unit.h" +#include "bindings.h" + +#include +#include +#include + +#define LTYPE_DB TOLUA_CAST "db" + +extern int db_update_factions(sqlite3 * db, bool force, int game); +static int tolua_db_update_factions(lua_State * L) +{ + sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); + db_update_factions(db, tolua_toboolean(L, 2, 0), game_id()); + return 0; +} + +extern int db_update_scores(sqlite3 * db, bool force); +static int tolua_db_update_scores(lua_State * L) +{ + sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); + db_update_scores(db, tolua_toboolean(L, 2, 0)); + return 0; +} + +static int tolua_db_execute(lua_State * L) +{ + sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); + const char *sql = tolua_tostring(L, 2, 0); + + int res = sqlite3_exec(db, sql, 0, 0, 0); + + lua_pushinteger(L, res); + return 1; +} + +static int tolua_db_close(lua_State * L) +{ + sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0); + sqlite3_close(db); + return 0; +} + +static int tolua_db_create(lua_State * L) +{ + sqlite3 *db; + const char *dbname = tolua_tostring(L, 1, 0); + int result = sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READWRITE, 0); + if (result == SQLITE_OK) { + tolua_pushusertype(L, (void *)db, LTYPE_DB); + return 1; + } + return 0; +} + +int tolua_sqlite_open(lua_State * L) +{ + /* register user types */ + + tolua_usertype(L, LTYPE_DB); + + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); + { + tolua_cclass(L, LTYPE_DB, LTYPE_DB, TOLUA_CAST "", NULL); + tolua_beginmodule(L, LTYPE_DB); + { + tolua_function(L, TOLUA_CAST "open", &tolua_db_create); + tolua_function(L, TOLUA_CAST "close", &tolua_db_close); + + tolua_function(L, TOLUA_CAST "update_factions", + &tolua_db_update_factions); + tolua_function(L, TOLUA_CAST "update_scores", &tolua_db_update_scores); + tolua_function(L, TOLUA_CAST "execute", &tolua_db_execute); + } + tolua_endmodule(L); + + } + tolua_endmodule(L); + return 0; +} diff --git a/src/bindings.c b/src/bindings.c index 936d588e5..576c54939 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -1149,6 +1149,9 @@ lua_State *lua_init(const dictionary *inifile) { register_tolua_helpers(); tolua_bindings_open(L, inifile); tolua_eressea_open(L); +#ifdef USE_SQLITE + tolua_sqlite_open(L); +#endif tolua_unit_open(L); tolua_building_open(L); tolua_ship_open(L); diff --git a/src/bindings.h b/src/bindings.h index 6fa91741b..b4523e582 100755 --- a/src/bindings.h +++ b/src/bindings.h @@ -18,6 +18,7 @@ extern "C" { struct selist; struct _dictionary_; + int tolua_sqlite_open(struct lua_State *L); int tolua_bindings_open(struct lua_State *L, const struct _dictionary_ *d); int tolua_itemlist_next(struct lua_State *L); int tolua_orderlist_next(struct lua_State *L); diff --git a/src/sqlite.c b/src/sqlite.c new file mode 100644 index 000000000..aea0f5d20 --- /dev/null +++ b/src/sqlite.c @@ -0,0 +1,204 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +faction *get_faction_by_id(int uid) +{ + faction *f; + for (f = factions; f; f = f->next) { + if (f->subscription == uid) { + return f; + } + } + return NULL; +} + +/* +typedef struct stmt_cache { +sqlite3 *db; +sqlite3_stmt *stmt; +const char *sql; +int inuse; +} stmt_cache; + +#define MAX_STMT_CACHE 64 +static stmt_cache cache[MAX_STMT_CACHE]; +static int cache_insert; + +static sqlite3_stmt *stmt_cache_get(sqlite3 * db, const char *sql) +{ +int i; +sqlite3_stmt *stmt; + +for (i = 0; i != MAX_STMT_CACHE && cache[i].db; ++i) { +if (cache[i].sql == sql && cache[i].db == db) { +cache[i].inuse = 1; +stmt = cache[i].stmt; +sqlite3_reset(stmt); +sqlite3_clear_bindings(stmt); +return stmt; +} +} +if (i == MAX_STMT_CACHE) { +while (cache[cache_insert].inuse) { +cache[cache_insert].inuse = 0; +cache_insert = (cache_insert + 1) & (MAX_STMT_CACHE - 1); +} +i = cache_insert; +stmt = cache[i].stmt; +sqlite3_finalize(stmt); +} +cache[i].inuse = 1; +cache[i].db = db; +cache[i].sql = sql; +sqlite3_prepare_v2(db, sql, -1, &cache[i].stmt, NULL); +return cache[i].stmt; +} +*/ +typedef struct db_faction { + int uid; + int no; + char *email; + char *name; +} db_faction; + +static struct quicklist * +read_factions(sqlite3 * db, int game_id) { + int res; + quicklist *result = 0; + const char * sql = + "SELECT f.id, fd.code, fd.name, fd.email FROM faction f" + " LEFT OUTER JOIN faction_data fd" + " WHERE f.id=fd.faction_id AND f.game_id=? AND" + " fd.turn=(SELECT MAX(turn) FROM faction_data fx WHERE fx.faction_id=f.id)" + " ORDER BY f.id"; + sqlite3_stmt *stmt = 0; + sqlite3_prepare_v2(db, sql, -1, &stmt, 0); + sqlite3_bind_int(stmt, 1, game_id); + + res = sqlite3_step(stmt); + while (res == SQLITE_ROW) { + const char * text; + db_faction * dbf = (db_faction*)calloc(1, sizeof(db_faction)); + dbf->uid = (int)sqlite3_column_int64(stmt, 0); + text = (const char *)sqlite3_column_text(stmt, 1); + if (text) dbf->no = atoi36(text); + text = (const char *)sqlite3_column_text(stmt, 2); + if (text) dbf->name = strdup(text); + text = (const char *)sqlite3_column_text(stmt, 3); + if (text) dbf->email = strdup(text); + ql_push(&result, dbf); + res = sqlite3_step(stmt); + } + sqlite3_finalize(stmt); + return result; +} + +static int insert_faction(sqlite3 *db, int game_id, faction *f) { + const char *sql = "INSERT INTO faction (game_id, race) VALUES (?, ?)"; + sqlite3_stmt *stmt = 0; + sqlite3_prepare_v2(db, sql, -1, &stmt, 0); + sqlite3_bind_int(stmt, 1, game_id); + sqlite3_bind_text(stmt, 2, f->race->_name, -1, SQLITE_STATIC); + sqlite3_step(stmt); + sqlite3_finalize(stmt); + return (int)sqlite3_last_insert_rowid(db); +} + +static void update_faction(sqlite3 *db, const faction *f) { + char code[5]; + const char *sql = + "INSERT INTO faction_data (faction_id, code, name, email, lang, turn)" + " VALUES (?, ?, ?, ?, ?, ?)"; + sqlite3_stmt *stmt = 0; + strcpy(code, itoa36(f->no)); + sqlite3_prepare_v2(db, sql, -1, &stmt, 0); + sqlite3_bind_int(stmt, 1, f->subscription); + sqlite3_bind_text(stmt, 2, code, -1, SQLITE_STATIC); + sqlite3_bind_text(stmt, 3, f->name, -1, SQLITE_STATIC); + sqlite3_bind_text(stmt, 4, f->email, -1, SQLITE_STATIC); + sqlite3_bind_text(stmt, 5, locale_name(f->locale), -1, SQLITE_STATIC); + sqlite3_bind_int(stmt, 6, turn); + sqlite3_step(stmt); + sqlite3_finalize(stmt); +} + +int db_update_factions(sqlite3 * db, bool force, int game_id) { + quicklist *ql = read_factions(db, game_id); + faction *f; + sqlite3_exec(db, "BEGIN", 0, 0, 0); + for (f = factions; f; f = f->next) { + bool update = force; + db_faction *dbf = 0; + ql_iter it = qli_init(&ql); + while (qli_more(it)) { + db_faction *df = (db_faction*)qli_next(&it); + if (f->no == df->no || strcmp(f->email, df->email) == 0 || strcmp(f->name, df->name) == 0) { + dbf = df; + } + if (f->subscription == df->uid) { + dbf = df; + break; + } + } + if (dbf) { + if (dbf->uid != f->subscription) { + log_warning("faction %s(%d) not found in database, but matches %d\n", itoa36(f->no), f->subscription, dbf->uid); + f->subscription = dbf->uid; + } + update = (dbf->no != f->no) || (strcmp(f->email, dbf->email) != 0) || (strcmp(f->name, dbf->name) != 0); + } + else { + f->subscription = insert_faction(db, game_id, f); + log_warning("faction %s not found in database, created as %d\n", itoa36(f->no), f->subscription); + update = true; + } + if (update) { + update_faction(db, f); + log_debug("faction %s updated\n", itoa36(f->no)); + } + } + sqlite3_exec(db, "COMMIT", 0, 0, 0); + return SQLITE_OK; +} + +int db_update_scores(sqlite3 * db, bool force) +{ + /* + const char *sql_ins = + "INSERT OR FAIL INTO score (value,faction_id,turn) VALUES (?,?,?)"; + sqlite3_stmt *stmt_ins = stmt_cache_get(db, sql_ins); + const char *sql_upd = + "UPDATE score set value=? WHERE faction_id=? AND turn=?"; + sqlite3_stmt *stmt_upd = stmt_cache_get(db, sql_upd); + faction *f; + sqlite3_exec(db, "BEGIN", 0, 0, 0); + for (f = factions; f; f = f->next) { + int res; + sqlite3_bind_int(stmt_ins, 1, f->score); + sqlite3_bind_int64(stmt_ins, 2, f->subscription); + sqlite3_bind_int(stmt_ins, 3, turn); + res = sqlite3_step(stmt_ins); + if (res == SQLITE_CONSTRAINT) { + sqlite3_bind_int(stmt_upd, 1, f->score); + sqlite3_bind_int64(stmt_upd, 2, f->subscription); + sqlite3_bind_int(stmt_upd, 3, turn); + res = sqlite3_step(stmt_upd); + sqlite3_reset(stmt_upd); + } + sqlite3_reset(stmt_ins); + } + sqlite3_exec(db, "COMMIT", 0, 0, 0); + */ + return SQLITE_OK; +} From abeb7e344e122a5f9f2a3c2ac4611db69ad560e7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 13:09:32 +0100 Subject: [PATCH 424/675] configure dbname in eressea.ini (or don't use DB if not --- scripts/run-turn.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/run-turn.lua b/scripts/run-turn.lua index 7ee9165ca..92efa8a14 100644 --- a/scripts/run-turn.lua +++ b/scripts/run-turn.lua @@ -26,15 +26,17 @@ function callbacks(rules, name, ...) end local function dbupdate() - update_scores() - dbname = config.dbname or 'eressea.db' - edb = db.open(config.basepath..'/'..dbname) - if edb~=nil then - edb:update_factions() - edb:update_scores() - else - eressea.log.error("could not open "..config.basepath..'/'..dbname) - end + update_scores() + if config.dbname then + dbname = config.basepath..'/'..config.dbname + edb = db.open(dbame) + if edb~=nil then + edb:update_factions() + edb:update_scores() + else + eressea.log.error("could not open "..dbname) + end + end end local function write_emails(locales) From f4e25fe20e625dc6b8cbf71b4e8ae8a7246785c9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 18:01:09 +0100 Subject: [PATCH 425/675] try loading config.lua and custom.lua files, if they exist. --- src/bindings.c | 68 ++++++++++++++++++++++++++++++++--------------- src/kernel/save.h | 1 - 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index 576c54939..e7c4859b4 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -1168,32 +1168,56 @@ lua_State *lua_init(const dictionary *inifile) { return L; } +static int run_script(lua_State *L, const char *luafile) { + int err; + FILE *F; + + F = fopen(luafile, "r"); + if (!F) { + log_debug("dofile('%s'): %s", luafile, strerror(errno)); + return errno; + } + fclose(F); + + log_debug("executing script %s", luafile); + lua_getglobal(L, "dofile"); + lua_pushstring(L, luafile); + err = lua_pcall(L, 1, 1, -3); /* error handler (debug.traceback) is now at stack -3 */ + if (err != 0) { + log_lua_error(L); + assert(!"Lua syntax error? check log."); + } + else { + if (lua_isnumber(L, -1)) { + err = (int)lua_tonumber(L, -1); + } + lua_pop(L, 1); + } + return err; +} + int eressea_run(lua_State *L, const char *luafile) { - int err = 0; - + int err; global.vm_state = L; + + /* push an error handling function on the stack: */ + lua_getglobal(L, "debug"); + lua_getfield(L, -1, "traceback"); + lua_remove(L, -2); + + /* try to run configuration scripts: */ + err = run_script(L, "config.lua"); + err = run_script(L, "custom.lua"); + /* run the main script */ if (luafile) { - log_debug("executing script %s\n", luafile); - - lua_getglobal(L, "debug"); - lua_getfield(L, -1, "traceback"); - lua_remove(L, -2); - lua_getglobal(L, "dofile"); - lua_pushstring(L, luafile); - err = lua_pcall(L, 1, 1, -3); - if (err != 0) { - log_lua_error(L); - assert(!"Lua syntax error? check log."); - } - else { - if (lua_isnumber(L, -1)) { - err = (int)lua_tonumber(L, -1); - } - lua_pop(L, 1); - } - return err; + err = run_script(L, luafile); } - return lua_console(L); + else { + err = lua_console(L); + } + /* pop error handler off the stack: */ + lua_pop(L, 1); + return err; } diff --git a/src/kernel/save.h b/src/kernel/save.h index be78b9c68..4ead34efe 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -44,7 +44,6 @@ extern "C" { extern int enc_gamedata; int readorders(const char *filename); - int creategame(void); int readgame(const char *filename); int writegame(const char *filename); From e7a41a20178831aed58a12841179b2d7ea6a49fd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 18:03:46 +0100 Subject: [PATCH 426/675] missing includE --- src/bindings.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bindings.c b/src/bindings.c index e7c4859b4..62d9064b4 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -80,6 +80,7 @@ without prior permission by the authors of Eressea. #include #include +#include #include #define TOLUA_PKG(NAME) extern void tolua_##NAME##_open(lua_State * L) From 64e45248dcb7ebac4b832a1a1dbec5a2ae7bd100 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 18:28:04 +0100 Subject: [PATCH 427/675] rename create_equipment function --- src/bindings.c | 6 +++--- src/kernel/equipment.c | 2 +- src/kernel/equipment.h | 2 +- src/kernel/equipment.test.c | 2 +- src/kernel/xmlreader.c | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index 62d9064b4..7fb894ebb 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -83,7 +83,7 @@ without prior permission by the authors of Eressea. #include #include -#define TOLUA_PKG(NAME) extern void tolua_##NAME##_open(lua_State * L) +#define TOLUA_PKG(NAME) void tolua_##NAME##_open(lua_State * L) TOLUA_PKG(eressea); TOLUA_PKG(process); @@ -328,7 +328,7 @@ static int tolua_addequipment(lua_State * L) if (iname != NULL) { const struct item_type *itype = it_find(iname); if (itype != NULL) { - equipment_setitem(create_equipment(eqname), itype, value); + equipment_setitem(get_or_create_equipment(eqname), itype, value); result = 0; } } @@ -461,7 +461,7 @@ static int tolua_equipment_setitem(lua_State * L) if (iname != NULL) { const struct item_type *itype = it_find(iname); if (itype != NULL) { - equipment_setitem(create_equipment(eqname), itype, value); + equipment_setitem(get_or_create_equipment(eqname), itype, value); result = 0; } } diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index 349a87448..00f8c2f95 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -39,7 +39,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static equipment *equipment_sets; -equipment *create_equipment(const char *eqname) +equipment *get_or_create_equipment(const char *eqname) { equipment **eqp = &equipment_sets; for (;;) { diff --git a/src/kernel/equipment.h b/src/kernel/equipment.h index 4081ab748..53475b510 100644 --- a/src/kernel/equipment.h +++ b/src/kernel/equipment.h @@ -56,7 +56,7 @@ extern "C" { void equipment_done(void); - struct equipment *create_equipment(const char *eqname); + struct equipment *get_or_create_equipment(const char *eqname); struct equipment *get_equipment(const char *eqname); void equipment_setitem(struct equipment *eq, diff --git a/src/kernel/equipment.test.c b/src/kernel/equipment.test.c index a82f86674..afd53849e 100644 --- a/src/kernel/equipment.test.c +++ b/src/kernel/equipment.test.c @@ -27,7 +27,7 @@ void test_equipment(CuTest * tc) CuAssertPtrNotNull(tc, sp); CuAssertPtrEquals(tc, 0, get_equipment("herpderp")); - eq = create_equipment("herpderp"); + eq = get_or_create_equipment("herpderp"); CuAssertPtrEquals(tc, eq, get_equipment("herpderp")); equipment_setitem(eq, it_horses, "1"); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 2ba9d785a..cba01bc7b 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1266,7 +1266,7 @@ add_subsets(xmlDocPtr doc, equipment * eq, xmlNodeSetPtr nsetSubsets) assert(propValue != NULL); eq->subsets[i].sets[set].chance = chance; eq->subsets[i].sets[set].set = - create_equipment((const char *)propValue); + get_or_create_equipment((const char *)propValue); xmlFree(propValue); } } @@ -1296,7 +1296,7 @@ static int parse_equipment(xmlDocPtr doc) xmlChar *propName = xmlGetProp(node, BAD_CAST "name"); if (propName != NULL) { - equipment *eq = create_equipment((const char *)propName); + equipment *eq = get_or_create_equipment((const char *)propName); xmlXPathObjectPtr xpathResult; xpath->node = node; From 76af048fed26d039c41f9794c91b0e3ecd429849 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 18:35:54 +0100 Subject: [PATCH 428/675] clean the quipment interface for lua a little bit. --- conf/e2/config.xml | 2 +- src/bindings.c | 18 ------------------ src/kernel/faction.c | 6 ++++++ 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 5affea141..8389ba470 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -29,7 +29,7 @@ - + diff --git a/src/bindings.c b/src/bindings.c index 7fb894ebb..0986ffb37 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -319,23 +319,6 @@ static int tolua_dice_rand(lua_State * L) return 1; } -static int tolua_addequipment(lua_State * L) -{ - const char *eqname = tolua_tostring(L, 1, 0); - const char *iname = tolua_tostring(L, 2, 0); - const char *value = tolua_tostring(L, 3, 0); - int result = -1; - if (iname != NULL) { - const struct item_type *itype = it_find(iname); - if (itype != NULL) { - equipment_setitem(get_or_create_equipment(eqname), itype, value); - result = 0; - } - } - lua_pushinteger(L, result); - return 1; -} - static int tolua_get_season(lua_State * L) { int turnno = (int)tolua_tonumber(L, 1, 0); @@ -1112,7 +1095,6 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile) tolua_function(L, TOLUA_CAST "get_season", tolua_get_season); tolua_function(L, TOLUA_CAST "equipment_setitem", tolua_equipment_setitem); tolua_function(L, TOLUA_CAST "equip_unit", tolua_equipunit); - tolua_function(L, TOLUA_CAST "add_equipment", tolua_addequipment); tolua_function(L, TOLUA_CAST "atoi36", tolua_atoi36); tolua_function(L, TOLUA_CAST "itoa36", tolua_itoa36); tolua_function(L, TOLUA_CAST "dice_roll", tolua_dice_rand); diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 146ae06a4..040cd5fb0 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "alliance.h" #include "ally.h" #include "curse.h" +#include "equipment.h" #include "group.h" #include "item.h" #include "messages.h" @@ -286,10 +287,15 @@ faction *addfaction(const char *email, const char *password, unit *addplayer(region * r, faction * f) { unit *u; + const struct equipment* eq; assert(f->units == NULL); faction_setorigin(f, 0, r->x, r->y); u = create_unit(r, f, 1, f->race, 0, NULL, NULL); + eq = get_equipment("first_unit"); + if (eq) { + equip_items(&u->items, eq); + } u->hp = unit_max_hp(u) * u->number; fset(u, UFL_ISNEW); if (f->race == get_race(RC_DAEMON)) { From 98be6bb8aeb5db1f7e63e524add0d491eb787ec8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 18:51:20 +0100 Subject: [PATCH 429/675] eliminate duplicate password message --- scripts/tests/faction.lua | 2 +- src/kernel/faction.c | 11 +++++------ src/kernel/faction.test.c | 2 +- src/reports.test.c | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/tests/faction.lua b/scripts/tests/faction.lua index 38fdc4eb7..87a6b5100 100644 --- a/scripts/tests/faction.lua +++ b/scripts/tests/faction.lua @@ -17,7 +17,7 @@ function setup() end function test_faction_flags() - assert_equal(2, f.flags) -- FFL_ISNEW + assert_equal(6, f.flags) -- FFL_ISNEW|FFL_PWMSG f.flags = 42 assert_equal(42, f.flags) end diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 040cd5fb0..b7115c62f 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -247,11 +247,6 @@ faction *addfaction(const char *email, const char *password, log_warning("Invalid email address for faction %s: %s\n", itoa36(f->no), email); } - if (!password) password = itoa36(rng_int()); - faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT)); - ADDMSG(&f->msgs, msg_message("changepasswd", "value", password)); - f->flags |= FFL_PWMSG; - f->alliance_joindate = turn; f->lastorders = turn; f->_alive = true; @@ -260,7 +255,11 @@ faction *addfaction(const char *email, const char *password, f->magiegebiet = 0; f->locale = loc; f->subscription = subscription; - f->flags = FFL_ISNEW; + f->flags = FFL_ISNEW|FFL_PWMSG; + + if (!password) password = itoa36(rng_int()); + faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT)); + ADDMSG(&f->msgs, msg_message("changepasswd", "value", password)); f->options = want(O_REPORT) | want(O_ZUGVORLAGE) | want(O_COMPUTER) | want(O_COMPRESS) | diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 3bfc36ca8..b18121e2d 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -117,7 +117,7 @@ static void test_addfaction(CuTest *tc) { CuAssertTrue(tc, checkpasswd(f, "hurrdurr")); CuAssertPtrEquals(tc, (void *)lang, (void *)f->locale); CuAssertIntEquals(tc, 1234, f->subscription); - CuAssertIntEquals(tc, FFL_ISNEW, f->flags); + CuAssertIntEquals(tc, FFL_ISNEW|FFL_PWMSG, f->flags); CuAssertIntEquals(tc, 0, f->age); CuAssertTrue(tc, faction_alive(f)); CuAssertIntEquals(tc, M_GRAY, f->magiegebiet); diff --git a/src/reports.test.c b/src/reports.test.c index 18ce468bb..e3ca5c89b 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -232,7 +232,7 @@ static void test_newbie_password_message(CuTest *tc) { test_setup(); f = test_create_faction(0); f->age = 5; - CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG); + f->flags = 0; prepare_report(&ctx, f); CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG); CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "changepasswd")); From 963713b1894049637979e61ac4563b96353561a8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 19:06:37 +0100 Subject: [PATCH 430/675] remove unused equipment sets (from an unrealized feature). --- res/e3a/equipment.xml | 69 ------------------------------------------- 1 file changed, 69 deletions(-) diff --git a/res/e3a/equipment.xml b/res/e3a/equipment.xml index bbd2ac5b7..9fe133f48 100644 --- a/res/e3a/equipment.xml +++ b/res/e3a/equipment.xml @@ -1,78 +1,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From ef10c607145d0494994d1495498cf85739d38b28 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 19:32:03 +0100 Subject: [PATCH 431/675] the locales module is deprecated. let's do this in custom.lua from now on. --- scripts/eressea/e2/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/eressea/e2/init.lua b/scripts/eressea/e2/init.lua index ed996c395..722078741 100644 --- a/scripts/eressea/e2/init.lua +++ b/scripts/eressea/e2/init.lua @@ -11,7 +11,7 @@ return { require('eressea.tunnels'), require('eressea.ponnuki'), require('eressea.astral'), - require('eressea.locales'), +-- require('eressea.locales'), require('eressea.jsreport'), require('eressea.ents'), require('eressea.cursed') From ee88c13732ddec3a3c9cb6beeecb0cf26698658a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 20:19:32 +0100 Subject: [PATCH 432/675] Korrekte Email-Subject und Adresse, auch im NR. Eliminate crufty per-game strings. --- conf/e2/config.xml | 12 ------------ conf/e3/config.xml | 12 ------------ conf/e4/config.xml | 12 ------------ res/core/de/strings.xml | 6 ++++++ res/core/messages.xml | 10 ++++++++++ src/creport.c | 4 +--- src/kernel/config.c | 17 +++++++++++++++-- src/kernel/config.h | 1 + src/kernel/config.test.c | 2 ++ src/report.c | 17 +++++++++++------ src/reports.c | 7 +++++++ src/reports.h | 1 + 12 files changed, 54 insertions(+), 47 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 8389ba470..56c622d04 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -52,16 +52,4 @@ - - - Bitte denke daran, deine Befehle mit dem Betreff - ERESSEA 2 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. - Remember to send your orders to - eressea-server@eressea.kn-bremen.de with the subject ERESSEA 2 ORDERS. - - - ERESSEA 2 BEFEHLE - ERESSEA 2 ORDERS - - diff --git a/conf/e3/config.xml b/conf/e3/config.xml index 35716f332..ac05d5a5a 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -36,16 +36,4 @@ - - - Bitte denke daran, deine Befehle mit dem Betreff - ERESSEA 3 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. - Remember to send your orders to - eressea-server@eressea.kn-bremen.de with the subject E3 ORDERS. - - - ERESSEA 3 BEFEHLE - ERESSEA 3 ORDERS - - diff --git a/conf/e4/config.xml b/conf/e4/config.xml index ac962202c..f9ede1a27 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -36,16 +36,4 @@ - - - Bitte denke daran, deine Befehle mit dem Betreff - ERESSEA 4 BEFEHLE an eressea-server@eressea.kn-bremen.de zu senden. - Remember to send your orders to - eressea-server@eressea.kn-bremen.de with the subject ERESSEA 4 ORDERS. - - - ERESSEA 4 BEFEHLE - ERESSEA 4 ORDERS - - diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index b23d44ffb..7d31fc678 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -6,6 +6,12 @@ _x: preposition (15 /Schlumpf/schwerter) _a: including article (ein Schlumpf, a smurf) --> + + + BEFEHLE + ORDERS + + Wirbel vortex diff --git a/res/core/messages.xml b/res/core/messages.xml index 130b58d03..6892ec4e5 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -1,5 +1,15 @@ + + + + + + Bitte denke daran, deine Befehle mit dem Betreff + $subject an $email zu senden. + Remember to send your orders to + $email with the subject ${subject}. + diff --git a/src/creport.c b/src/creport.c index fc944779f..106f34545 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1510,9 +1510,7 @@ report_computer(const char *filename, report_context * ctx, const char *bom) fprintf(F, "%d;Zeitalter\n", era); fprintf(F, "\"%s\";Build\n", eressea_version()); if (mailto != NULL) { - // char mailcmd[64]; - // snprintf(mailcmd, sizeof(mailcmd), "%s %d, %s", game_name(), game_id(), LOC(f->locale, "mailcmd")); - const char * mailcmd = LOC(f->locale, "mailcmd"); + const char * mailcmd = get_mailcmd(f->locale); fprintf(F, "\"%s\";mailto\n", mailto); fprintf(F, "\"%s\";mailcmd\n", mailcmd); } diff --git a/src/kernel/config.c b/src/kernel/config.c index a07c36aba..c7bc71cdf 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -802,12 +802,25 @@ void free_gamedata(void) } } -const char * game_name(void) { +const char * game_name(void) +{ const char * param = config_get("game.name"); return param ? param : global.gamename; } +const char * game_name_upper(void) +{ + static char result[32]; // FIXME: static result + char *r = result; + const char *param = game_name(); + const char *c = param; + while (*c && (r-result)age <= 2) { - const char *s; - s = locale_getstring(f->locale, "newbie_info_game"); - if (s) { - newline(out); - centre(out, s, true); + const char *email; + const char *subject; + email = config_get("game.email"); + subject = get_mailcmd(f->locale); + m = msg_message("newbie_info_game", "email subject", email, subject); + if (m) { + nr_render(m, f->locale, buf, sizeof(buf), f); + msg_release(m); + centre(out, buf, true); } if ((f->options & want(O_COMPUTER)) == 0) { - f->options |= want(O_COMPUTER); + const char *s; s = locale_getstring(f->locale, "newbie_info_cr"); if (s) { newline(out); centre(out, s, true); } + f->options |= want(O_COMPUTER); } } newline(out); diff --git a/src/reports.c b/src/reports.c index 77682a23a..5a47acfed 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1944,6 +1944,13 @@ static void eval_regions(struct opstack **stack, const void *userdata) opush(stack, var); } +const char *get_mailcmd(const struct locale *loc) +{ + static char result[64]; // FIXME: static return buffer + snprintf(result, sizeof(result), "%s %d %s", game_name_upper(), game_id(), LOC(loc, "mailcmd")); + return result; +} + static void eval_trail(struct opstack **stack, const void *userdata) { /* order -> string */ const faction *report = (const faction *)userdata; diff --git a/src/reports.h b/src/reports.h index 625048de9..4fab104ef 100644 --- a/src/reports.h +++ b/src/reports.h @@ -131,6 +131,7 @@ extern "C" { int stream_printf(struct stream * out, const char *format, ...); int count_travelthru(struct region *r, const struct faction *f); + const char *get_mailcmd(const struct locale *loc); #define GR_PLURAL 0x01 /* grammar: plural */ #define MAX_INVENTORY 128 /* maimum number of different items in an inventory */ From 21b617c973d59184e70c3a44c8d78d5b8da5a4e8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 20:32:54 +0100 Subject: [PATCH 433/675] fix game_name, remove it from rules --- conf/e2/config.json | 2 -- conf/e3/config.json | 2 -- conf/e4/config.json | 2 -- res/core/de/strings.xml | 2 -- src/kernel/config.c | 2 +- 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index ce823a33d..ca157f501 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -8,8 +8,6 @@ "jsreport" ], "settings": { - "game.id": 2, - "game.name": "Eressea", "orders.default": "work", "NewbieImmunity": 8, "modules.wormholes": true, diff --git a/conf/e3/config.json b/conf/e3/config.json index 30bc7e599..fd533070e 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -25,8 +25,6 @@ "jsreport" ], "settings": { - "game.id": 3, - "game.name": "E3", "orders.default": "work", "database.gameid": 7, "NewbieImmunity": 4, diff --git a/conf/e4/config.json b/conf/e4/config.json index cbe273af6..91961258a 100644 --- a/conf/e4/config.json +++ b/conf/e4/config.json @@ -25,8 +25,6 @@ "jsreport" ], "settings": { - "game.id": 4, - "game.name": "Deveron", "orders.default": "work", "database.gameid": 7, "NewbieImmunity": 4, diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 7d31fc678..bccfdd165 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -6,12 +6,10 @@ _x: preposition (15 /Schlumpf/schwerter) _a: including article (ein Schlumpf, a smurf) --> - BEFEHLE ORDERS - Wirbel vortex diff --git a/src/kernel/config.c b/src/kernel/config.c index c7bc71cdf..c2db29f22 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -814,7 +814,7 @@ const char * game_name_upper(void) char *r = result; const char *param = game_name(); const char *c = param; - while (*c && (r-result)r) { *r++ = (char)toupper(*c++); } *r = '\0'; From b2e6c481863308f912b50a58e9025502c5b1d0cc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 21:02:15 +0100 Subject: [PATCH 434/675] specify a game id, because there is one in the data --- tests/eressea.ini | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/eressea.ini b/tests/eressea.ini index e84171d45..faf4b1b9e 100644 --- a/tests/eressea.ini +++ b/tests/eressea.ini @@ -1,10 +1,8 @@ -[eressea] -base = . -report = reports +[game] +name = Eressea +id = 2 +email = eressea-server@kn-bremen.de verbose = 0 -lomem = 0 -debug = 0 -memcheck = 0 locales = de,en [lua] From 1bd6ab11ea2617f38f38036737e5a12985ab4c74 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Jan 2017 09:22:29 +0100 Subject: [PATCH 435/675] FACTION and PARTEI should both start orders. --- src/kernel/save.c | 24 ++++++++++++++++++++++-- tests/orders.184 | 5 +++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 84914127a..be461e27c 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -252,6 +252,26 @@ static faction *factionorders(void) return f; } +static param_t next_param(const char *s, const struct locale *lang) { + param_t p; + if (!s || s[0] == '@') { + return NOPARAM; + } + p = findparam(s, lang); + if (p==NOPARAM) { + const struct locale *loc; + for (loc=locales;loc;loc=nextlocale(loc)) { + if (loc!=lang) { + p = findparam(s, lang); + if (p==P_FACTION || p==P_GAMENAME) { + break; + } + } + } + } + return p; +} + int readorders(const char *filename) { FILE *F = NULL; @@ -279,7 +299,7 @@ int readorders(const char *filename) const char *s; init_tokens_str(b); s = gettoken(token, sizeof(token)); - p = (s && s[0] != '@') ? findparam(s, lang) : NOPARAM; + p = next_param(s, lang); switch (p) { case P_GAMENAME: case P_FACTION: @@ -308,7 +328,7 @@ int readorders(const char *filename) p = (s && s[0] != '@') ? findparam(s, lang) : NOPARAM; } while ((p != P_UNIT || !f) && p != P_FACTION && p != P_NEXT && p != P_GAMENAME); - } + } break; /* Falls in unitorders() abgebrochen wird, steht dort entweder eine neue diff --git a/tests/orders.184 b/tests/orders.184 index 980993481..315c180d5 100644 --- a/tests/orders.184 +++ b/tests/orders.184 @@ -1,4 +1,4 @@ -ERESSEA 6rLo "6rLo" +PARTEI 6rLo "6rLo" EINHEIT 7Lgf NACH NW NW NAECHSTER @@ -6,7 +6,8 @@ ERESSEA w86y "w86y" EINHEIT uc3u STIRB "mrqa" NAECHSTER -ERESSEA ngij "ngij" + +FACTION ngij "ngij" EINHEIT iwbz HELFE w86y ALLES EINHEIT j536 From af1ce9b84e6e47d1c6ea060032b14f4acf9c63e4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Jan 2017 10:47:49 +0100 Subject: [PATCH 436/675] issue #633: parse FACTION/PARTEI in any language. added a test since the first fix did not work. --- src/kernel/config.c | 21 +++++++++++++++++++++ src/kernel/config.h | 1 + src/kernel/config.test.c | 24 ++++++++++++++++++++++++ src/kernel/save.c | 22 +--------------------- src/util/language.c | 7 ++++--- 5 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index c2db29f22..109913560 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -213,6 +213,27 @@ param_t findparam(const char *s, const struct locale * lang) return result; } +param_t findparam_block(const char *s, const struct locale *lang, bool any_locale) +{ + param_t p; + if (!s || s[0] == '@') { + return NOPARAM; + } + p = findparam(s, lang); + if (any_locale && p==NOPARAM) { + const struct locale *loc; + for (loc=locales;loc;loc=nextlocale(loc)) { + if (loc!=lang) { + p = findparam(s, loc); + if (p==P_FACTION || p==P_GAMENAME) { + break; + } + } + } + } + return p; +} + param_t findparam_ex(const char *s, const struct locale * lang) { param_t result = findparam(s, lang); diff --git a/src/kernel/config.h b/src/kernel/config.h index 43189400c..b51ba2725 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -45,6 +45,7 @@ extern "C" { int findoption(const char *s, const struct locale *lang); param_t findparam(const char *s, const struct locale *lang); + param_t findparam_block(const char *s, const struct locale *lang, bool any_locale); param_t findparam_ex(const char *s, const struct locale * lang); bool isparam(const char *s, const struct locale * lang, param_t param); param_t getparam(const struct locale *lang); diff --git a/src/kernel/config.test.c b/src/kernel/config.test.c index ca362d6a1..72b2387ac 100644 --- a/src/kernel/config.test.c +++ b/src/kernel/config.test.c @@ -251,9 +251,33 @@ static void test_config_inifile(CuTest *tc) { test_cleanup(); } +static void test_findparam(CuTest *tc) { + struct locale *en, *de; + test_setup(); + en = get_or_create_locale("en"); + locale_setstring(en, parameters[P_FACTION], "FACTION"); + CuAssertIntEquals(tc, NOPARAM, findparam("FACTION", en)); + init_parameters(en); + CuAssertIntEquals(tc, P_FACTION, findparam("FACTION", en)); + de = get_or_create_locale("de"); + locale_setstring(de, parameters[P_FACTION], "PARTEI"); + CuAssertIntEquals(tc, NOPARAM, findparam("PARTEI", de)); + init_parameters(de); + CuAssertIntEquals(tc, P_FACTION, findparam("PARTEI", de)); + CuAssertIntEquals(tc, NOPARAM, findparam("HODOR", de)); + + CuAssertIntEquals(tc, NOPARAM, findparam("PARTEI", en)); + CuAssertIntEquals(tc, NOPARAM, findparam_block("HODOR", de, false)); + CuAssertIntEquals(tc, P_FACTION, findparam_block("PARTEI", de, true)); + CuAssertIntEquals(tc, NOPARAM, findparam_block("PARTEI", en, false)); + CuAssertIntEquals(tc, P_FACTION, findparam_block("PARTEI", en, true)); + test_cleanup(); +} + CuSuite *get_config_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_findparam); SUITE_ADD_TEST(suite, test_config_inifile); SUITE_ADD_TEST(suite, test_config_cache); SUITE_ADD_TEST(suite, test_get_set_param); diff --git a/src/kernel/save.c b/src/kernel/save.c index be461e27c..ac236d5bf 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -252,26 +252,6 @@ static faction *factionorders(void) return f; } -static param_t next_param(const char *s, const struct locale *lang) { - param_t p; - if (!s || s[0] == '@') { - return NOPARAM; - } - p = findparam(s, lang); - if (p==NOPARAM) { - const struct locale *loc; - for (loc=locales;loc;loc=nextlocale(loc)) { - if (loc!=lang) { - p = findparam(s, lang); - if (p==P_FACTION || p==P_GAMENAME) { - break; - } - } - } - } - return p; -} - int readorders(const char *filename) { FILE *F = NULL; @@ -299,7 +279,7 @@ int readorders(const char *filename) const char *s; init_tokens_str(b); s = gettoken(token, sizeof(token)); - p = next_param(s, lang); + p = findparam_block(s, lang, true); switch (p) { case P_GAMENAME: case P_FACTION: diff --git a/src/util/language.c b/src/util/language.c index efd5cd5f7..300e69103 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -295,10 +295,11 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_ // TODO: swap the name of s and key const char * s = string_cb(i); if (s) { - struct critbit_tree ** cb = (struct critbit_tree **)tokens; const char * key = locale_string(lang, s, false); - if (!key) key = s; - add_translation(cb, key, i); + if (key) { + struct critbit_tree ** cb = (struct critbit_tree **)tokens; + add_translation(cb, key, i); + } } } } From a79e5ef2a5ef25d7df3b81b6af57724d6f75dadd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Jan 2017 11:13:01 +0100 Subject: [PATCH 437/675] refactor and annotate volcano outbreaks. add configuration options to control volcano behavior. --- src/volcano.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/volcano.c b/src/volcano.c index 60beeaed7..a9a4f0ba7 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -55,7 +55,7 @@ static int nb_armor(const unit * u, int index) if (!(u_race(u)->battle_flags & BF_EQUIPMENT)) return 0; - /* Normale Rstung */ + /* Normale R�stung */ for (itm = u->items; itm; itm = itm->next) { const armor_type *atype = itm->type->rtype->atype; @@ -169,11 +169,11 @@ static region *rrandneighbour(region * r) for (i = 0; i != MAXDIRECTIONS; i++) { c++; } - /* Zufllig eine auswhlen */ + /* Zuf�llig eine ausw�hlen */ rr = rng_int() % c; - /* Durchzhlen */ + /* Durchz�hlen */ c = -1; for (i = 0; i != MAXDIRECTIONS; i++) { @@ -204,7 +204,7 @@ volcano_destruction(region * volcano, region * r, const char *damage) else { /* Produktion vierteln ... */ a->data.sa[0] = (short)percent; - /* Fr 6-17 Runden */ + /* F�r 6-17 Runden */ a->data.sa[1] = (short)(a->data.sa[1] + time); } @@ -255,6 +255,14 @@ void volcano_outbreak(region * r, region *rn) } } +static bool stop_smoke_chance(void) { + return rng_int() % 100 < 12; +} + +static bool outbreak_chance(void) { + return rng_int() % 100 < 8; +} + void volcano_update(void) { region *r; @@ -270,13 +278,16 @@ void volcano_update(void) r->terrain = t_volcano; } else { - if (rng_int() % 100 < 12) { + if (stop_smoke_chance()) { ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r)); r->terrain = t_volcano; } - else if (r->uid == 1246051340 || (r->age > 20 && rng_int() % 100 < 8)) { + else if (r->uid == 1246051340 || outbreak_chance()) { + // HACK: a fixed E4-only region-uid in Code. + // FIXME: In E4 gibt es eine Ebene #1246051340, die Smalland heisst. + // da das kein aktiver Vulkan ist, ist dieser Test da nicht idiotisch? + // das sollte bestimmt rn betreffen? region *rn; - /* Zufllige Nachbarregion verwsten */ rn = rrandneighbour(r); volcano_outbreak(r, rn); r->terrain = t_volcano; From d8770932f01fc99341380f23c73d2f22a0b3807c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Jan 2017 11:44:34 +0100 Subject: [PATCH 438/675] fix issue #477 (intermittent volcano) --- scripts/tests/xmas.lua | 2 ++ src/volcano.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/tests/xmas.lua b/scripts/tests/xmas.lua index 7ac4ce731..5477e08ab 100644 --- a/scripts/tests/xmas.lua +++ b/scripts/tests/xmas.lua @@ -8,6 +8,8 @@ function setup() eressea.settings.set("rules.grow.formula", "0") eressea.settings.set("rules.peasants.growth.factor", "0") eressea.settings.set("volcano.active.percent", "0") + eressea.settings.set("volcano.outbreak.percent", "0") + eressea.settings.set("volcano.stop.percent", "0") end function test_snowglobe_fail() diff --git a/src/volcano.c b/src/volcano.c index a9a4f0ba7..89a865017 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -256,11 +256,19 @@ void volcano_outbreak(region * r, region *rn) } static bool stop_smoke_chance(void) { - return rng_int() % 100 < 12; + static int cache, percent = 0; + if (config_changed(&cache)) { + percent = config_get_int("volcano.stop.percent", 12); + } + return percent!=0 && (rng_int() % 100) < percent; } static bool outbreak_chance(void) { - return rng_int() % 100 < 8; + static int cache, percent = 0; + if (config_changed(&cache)) { + percent = config_get_int("volcano.outbreak.percent", 8); + } + return percent!=0 && (rng_int() % 100) < percent; } void volcano_update(void) From c0692986b27236912a8646f692a4c6e4f16da87b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Jan 2017 21:35:01 +0100 Subject: [PATCH 439/675] make runtests.bat not crash. disable auto-load of config.lua (sob). free messages and config in config.reset(). --- scripts/tests/laws.lua | 2 ++ src/bind_config.c | 3 +++ src/bindings.c | 2 +- src/laws.c | 3 ++- src/util/nrmessage.c | 13 +++++++++++++ src/util/nrmessage.h | 16 +++++++++------- src/util/nrmessage_struct.h | 4 ++-- 7 files changed, 32 insertions(+), 11 deletions(-) diff --git a/scripts/tests/laws.lua b/scripts/tests/laws.lua index f0fef15a9..6f41fc54b 100644 --- a/scripts/tests/laws.lua +++ b/scripts/tests/laws.lua @@ -95,6 +95,7 @@ function test_force_leave_postcombat() u1.building = b1 u2.building = b1 eressea.settings.set("rules.owners.force_leave", "1") + eressea.settings.set("NewbieImmunity", "0") u1:clear_orders() u1:add_order("ATTACKIERE " .. itoa36(u2.id)) u2:clear_orders() @@ -109,6 +110,7 @@ function test_force_leave_postcombat() end end assert_not_equal(nil, u3) + assert_equal(nil, u2.building) assert_equal(nil, u3.building) assert_equal(1, u3.number) end diff --git a/src/bind_config.c b/src/bind_config.c index 929e4cca0..faf543f47 100644 --- a/src/bind_config.c +++ b/src/bind_config.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -20,7 +21,9 @@ void config_reset(void) { default_locale = 0; + free_config(); free_locales(); + free_nrmesssages(); free_spells(); free_buildingtypes(); free_shiptypes(); diff --git a/src/bindings.c b/src/bindings.c index 0986ffb37..7bf30202a 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -1190,7 +1190,7 @@ int eressea_run(lua_State *L, const char *luafile) lua_remove(L, -2); /* try to run configuration scripts: */ - err = run_script(L, "config.lua"); + // err = run_script(L, "config.lua"); err = run_script(L, "custom.lua"); /* run the main script */ diff --git a/src/laws.c b/src/laws.c index d6e005ff8..74e572a78 100644 --- a/src/laws.c +++ b/src/laws.c @@ -119,7 +119,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. int NewbieImmunity(void) { - return config_get_int("NewbieImmunity", 0); + int result = config_get_int("NewbieImmunity", 0); + return result; } bool IsImmune(const faction * f) diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index 8156b9784..717c4dc1f 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -178,3 +178,16 @@ const char *nrt_section(const nrmessage_type * nrt) { return nrt ? nrt->section : NULL; } + +void free_nrmesssages(void) { + int i; + for (i = 0; i != NRT_MAXHASH; ++i) { + while (nrtypes[i]) { + nrmessage_type *nr = nrtypes[i]; + nrtypes[i] = nr->next; + free(nr->string); + free(nr->vars); + free(nr); + } + } +} diff --git a/src/util/nrmessage.h b/src/util/nrmessage.h index 122b1f1a8..6cc02bfe2 100644 --- a/src/util/nrmessage.h +++ b/src/util/nrmessage.h @@ -31,18 +31,20 @@ extern "C" { extern nrsection *sections; - extern void nrt_register(const struct message_type *mtype, + void free_nrmesssages(void); + + void nrt_register(const struct message_type *mtype, const struct locale *lang, const char *script, int level, const char *section); - extern struct nrmessage_type *nrt_find(const struct locale *, + struct nrmessage_type *nrt_find(const struct locale *, const struct message_type *); - extern const char *nrt_string(const struct nrmessage_type *type); - extern const char *nrt_section(const struct nrmessage_type *mt); + const char *nrt_string(const struct nrmessage_type *type); + const char *nrt_section(const struct nrmessage_type *mt); - extern size_t nr_render(const struct message *msg, const struct locale *lang, + size_t nr_render(const struct message *msg, const struct locale *lang, char *buffer, size_t size, const void *userdata); - extern int nr_level(const struct message *msg); - extern const char *nr_section(const struct message *msg); + int nr_level(const struct message *msg); + const char *nr_section(const struct message *msg); /* before: * fogblock;movement:0;de;{unit} konnte von {region} nicht nach {$dir direction} ausreisen, der Nebel war zu dicht. diff --git a/src/util/nrmessage_struct.h b/src/util/nrmessage_struct.h index 6a3a1d9b0..57f8e644d 100644 --- a/src/util/nrmessage_struct.h +++ b/src/util/nrmessage_struct.h @@ -8,8 +8,8 @@ typedef struct nrmessage_type { const struct message_type *mtype; const struct locale *lang; - const char *string; - const char *vars; + char *string; + char *vars; struct nrmessage_type *next; int level; const char *section; From dcdb5354d9b99d0711f3ddbf6bc5ad0cd86ec89d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 24 Jan 2017 10:36:27 +0100 Subject: [PATCH 440/675] BUG 2273: runtests.bat fails when config is auto-loaded. run rules tests with the correct configuration, ignore .ini file setting. still not enabling auto-load again, use custom.lua instead. --- scripts/tests/e3/castles.lua | 2 +- tests/runtests.bat | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/tests/e3/castles.lua b/scripts/tests/e3/castles.lua index 1fd4e13e9..df395ed3d 100644 --- a/scripts/tests/e3/castles.lua +++ b/scripts/tests/e3/castles.lua @@ -46,7 +46,7 @@ end function test_build_packice() local r = region.create(0, 0, "packice") - local f = faction.create("noreply@eressea.de", "human", "de") + local f = faction.create("packice@eressea.de", "human", "de") local u = unit.create(f, r, 1) u:clear_orders() u:add_item("stone", 10) diff --git a/tests/runtests.bat b/tests/runtests.bat index e79d27baa..996fb47b7 100644 --- a/tests/runtests.bat +++ b/tests/runtests.bat @@ -6,9 +6,9 @@ IF EXIST ..\build-vs14 SET BUILD=..\build-vs14\eressea\Debug SET SERVER=%BUILD%\eressea.exe %BUILD%\test_eressea.exe %SERVER% ..\scripts\run-tests.lua -%SERVER% ..\scripts\run-tests-e2.lua -%SERVER% ..\scripts\run-tests-e3.lua -%SERVER% ..\scripts\run-tests-e4.lua +%SERVER% -re2 ..\scripts\run-tests-e2.lua +%SERVER% -re3 ..\scripts\run-tests-e3.lua +%SERVER% -re4 ..\scripts\run-tests-e4.lua PAUSE RMDIR /s /q reports DEL score score.alliances datum turn From 044953e4ab2a462fe6d1434201aa88f60d4aa00e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 25 Jan 2017 18:17:19 +0100 Subject: [PATCH 441/675] add a function to compare size of occupied castles --- src/kernel/building.c | 13 ++++++++++++- src/kernel/building.h | 2 ++ src/kernel/building.test.c | 26 ++++++++++++++++++++++++++ src/kernel/region.c | 14 +++++++++++--- src/kernel/region.test.c | 25 +++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 4 deletions(-) diff --git a/src/kernel/building.c b/src/kernel/building.c index f2c9c9fd2..98caad07a 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -335,7 +335,18 @@ const building_type *findbuildingtype(const char *name, return (const building_type *)type.v; } -static int building_protection(const building * b, const unit * u, building_bonus bonus) +int cmp_castle_size(const building * b, const building * a) +{ + if (!b || !b->type->protection || !building_owner(b)) { + return -1; + } + if (!a || !a->type->protection || !building_owner(a)) { + return 1; + } + return b->size - a->size; +} + +int building_protection(const building * b, const unit * u, building_bonus bonus) { int i = 0; int bsize = buildingeffsize(b, false); diff --git a/src/kernel/building.h b/src/kernel/building.h index a6936d90d..8b1a5b05b 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -85,6 +85,8 @@ extern "C" { extern struct selist *buildingtypes; extern struct attrib_type at_building_action; + int cmp_castle_size(const struct building * b, const struct building * a); + int building_protection(const struct building * b, const struct unit * u, building_bonus bonus); building_type *bt_get_or_create(const char *name); bool bt_changed(int *cache); const building_type *bt_find(const char *name); diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index 3b296a6fe..89e2b978c 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -493,9 +493,35 @@ static void test_building_type(CuTest *tc) { test_cleanup(); } +static void test_cmp_castle_size(CuTest *tc) { + region *r; + building *b1, *b2; + building_type *bt_castle; + unit *u1, *u2; + + test_setup(); + bt_castle = test_create_buildingtype("castle"); + bt_castle->protection = building_protection; + r = test_create_region(0, 0, 0); + b1 = test_create_building(r, bt_castle); + b2 = test_create_building(r, bt_castle); + u1 = test_create_unit(test_create_faction(0), r); + u_set_building(u1, b1); + u2 = test_create_unit(test_create_faction(0), r); + u_set_building(u2, b2); + b1->size = 5; + b2->size = 10; + CuAssertTrue(tc, cmp_castle_size(b1, b2)<0); + CuAssertTrue(tc, cmp_castle_size(b2, b1)>0); + CuAssertTrue(tc, cmp_castle_size(b1, NULL)>0); + CuAssertTrue(tc, cmp_castle_size(NULL, b1)<0); + test_cleanup(); +} + CuSuite *get_building_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_cmp_castle_size); SUITE_ADD_TEST(suite, test_register_building); SUITE_ADD_TEST(suite, test_btype_defaults); SUITE_ADD_TEST(suite, test_building_set_owner); diff --git a/src/kernel/region.c b/src/kernel/region.c index cade135c7..06d2d9d7c 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -1324,9 +1324,17 @@ struct message *msg) struct faction *region_get_owner(const struct region *r) { - assert(rule_region_owners()); - if (r->land && r->land->ownership) { - return r->land->ownership->owner; + if (r->land) { + if (rule_region_owners()) { + if (r->land->ownership) { + return r->land->ownership->owner; + } + } + else { + building *b = largestbuilding(r, cmp_castle_size, false); + unit * u = b ? building_owner(b) : NULL; + return u ? u->faction : NULL; + } } return NULL; } diff --git a/src/kernel/region.test.c b/src/kernel/region.test.c index 01ecae2a8..8cf08a62c 100644 --- a/src/kernel/region.test.c +++ b/src/kernel/region.test.c @@ -1,6 +1,8 @@ #include #include "region.h" +#include "building.h" +#include "unit.h" #include "terrain.h" #include "item.h" @@ -31,9 +33,32 @@ void test_terraform(CuTest *tc) { test_cleanup(); } +static void test_region_get_owner(CuTest *tc) { + region *r; + building *b1, *b2; + building_type *bt_castle; + unit *u1, *u2; + + test_setup(); + bt_castle = test_create_buildingtype("castle"); + bt_castle->protection = building_protection; + r = test_create_region(0, 0, 0); + b1 = test_create_building(r, bt_castle); + b2 = test_create_building(r, bt_castle); + b1->size = 5; + b2->size = 10; + u1 = test_create_unit(test_create_faction(0), r); + u_set_building(u1, b1); + u2 = test_create_unit(test_create_faction(0), r); + u_set_building(u2, b2); + CuAssertPtrEquals(tc, u2->faction, region_get_owner(r)); + test_cleanup(); +} + CuSuite *get_region_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_terraform); + SUITE_ADD_TEST(suite, test_region_get_owner); return suite; } From 2a1ead6506e7d0cb6033adefbbde727580716b5e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 25 Jan 2017 20:57:54 +0100 Subject: [PATCH 442/675] BENENNE REGION ist jeder Einheit des Regionsbesitzers erlaubt --- src/kernel/building.test.c | 7 ++----- src/kernel/config.c | 2 +- src/kernel/region.test.c | 7 ++----- src/laws.c | 11 +---------- src/laws.test.c | 39 +++++++++++++++++++++++++++++++++----- src/tests.c | 9 +++++++-- 6 files changed, 47 insertions(+), 28 deletions(-) diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index 89e2b978c..e02d16556 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -496,15 +496,12 @@ static void test_building_type(CuTest *tc) { static void test_cmp_castle_size(CuTest *tc) { region *r; building *b1, *b2; - building_type *bt_castle; unit *u1, *u2; test_setup(); - bt_castle = test_create_buildingtype("castle"); - bt_castle->protection = building_protection; r = test_create_region(0, 0, 0); - b1 = test_create_building(r, bt_castle); - b2 = test_create_building(r, bt_castle); + b1 = test_create_building(r, NULL); + b2 = test_create_building(r, NULL); u1 = test_create_unit(test_create_faction(0), r); u_set_building(u1, b1); u2 = test_create_unit(test_create_faction(0), r); diff --git a/src/kernel/config.c b/src/kernel/config.c index 109913560..83d0808da 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -203,7 +203,7 @@ param_t findparam(const char *s, const struct locale * lang) void **tokens = get_translations(lang, UT_PARAMS); critbit_tree *cb = (critbit_tree *)*tokens; if (!cb) { - log_error("no parameters defined in locale %s", locale_name(lang)); + log_warning("no parameters defined in locale %s", locale_name(lang)); } else if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) { cb_get_kv(match, &i, sizeof(int)); diff --git a/src/kernel/region.test.c b/src/kernel/region.test.c index 8cf08a62c..892b37a8e 100644 --- a/src/kernel/region.test.c +++ b/src/kernel/region.test.c @@ -36,15 +36,12 @@ void test_terraform(CuTest *tc) { static void test_region_get_owner(CuTest *tc) { region *r; building *b1, *b2; - building_type *bt_castle; unit *u1, *u2; test_setup(); - bt_castle = test_create_buildingtype("castle"); - bt_castle->protection = building_protection; r = test_create_region(0, 0, 0); - b1 = test_create_building(r, bt_castle); - b2 = test_create_building(r, bt_castle); + b1 = test_create_building(r, NULL); + b2 = test_create_building(r, NULL); b1->size = 5; b2->size = 10; u1 = test_create_unit(test_create_faction(0), r); diff --git a/src/laws.c b/src/laws.c index 74e572a78..769bfc9d3 100644 --- a/src/laws.c +++ b/src/laws.c @@ -1892,16 +1892,7 @@ int name_cmd(struct unit *u, struct order *ord) break; case P_REGION: - if (!b) { - cmistake(u, ord, 145, MSG_EVENT); - break; - } - if (building_owner(b) != u) { - cmistake(u, ord, 148, MSG_EVENT); - break; - } - - if (b != largestbuilding(r, get_cmp_region_owner(), false)) { + if (u->faction != region_get_owner(r)) { cmistake(u, ord, 147, MSG_EVENT); break; } diff --git a/src/laws.test.c b/src/laws.test.c index d4753ec19..67a9bb810 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -812,10 +812,7 @@ static void test_name_region(CuTest *tc) { f = u->faction; ord = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_REGION])); - name_cmd(u, ord); - CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error145")); - - u->building = test_create_building(u->region, 0); + u_set_building(u, test_create_building(u->region, 0)); name_cmd(u, ord); CuAssertStrEquals(tc, "Hodor", u->region->land->name); free_order(ord); @@ -1060,7 +1057,7 @@ static void test_name_cmd(CuTest *tc) { free_order(ord); ord = create_order(K_NAME, f->locale, "%s ' Ho\tdor '", LOC(f->locale, parameters[P_BUILDING])); - u->building = test_create_building(u->region, 0); + u_set_building(u, test_create_building(u->region, 0)); name_cmd(u, ord); CuAssertStrEquals(tc, "Hodor", u->building->name); free_order(ord); @@ -1073,6 +1070,37 @@ static void test_name_cmd(CuTest *tc) { test_cleanup(); } +static void test_name_cmd_2274(CuTest *tc) { + unit *u1, *u2, *u3; + faction *f; + region *r; + + test_setup(); + r = test_create_region(0, 0, 0); + u1 = test_create_unit(test_create_faction(0), r); + u2 = test_create_unit(test_create_faction(0), r); + u3 = test_create_unit(u2->faction, r); + u_set_building(u1, test_create_building(r, NULL)); + u1->building->size = 10; + u_set_building(u2, test_create_building(r, NULL)); + u2->building->size = 20; + + f = u2->faction; + u2->thisorder = create_order(K_NAME, f->locale, "%s Heimat", LOC(f->locale, parameters[P_REGION])); + name_cmd(u2, u2->thisorder); + CuAssertStrEquals(tc, "Heimat", r->land->name); + f = u3->faction; + u3->thisorder = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_REGION])); + name_cmd(u3, u3->thisorder); + CuAssertStrEquals(tc, "Hodor", r->land->name); + f = u1->faction; + u1->thisorder = create_order(K_NAME, f->locale, "%s notallowed", LOC(f->locale, parameters[P_REGION])); + name_cmd(u1, u1->thisorder); + CuAssertStrEquals(tc, "Hodor", r->land->name); + + test_cleanup(); +} + static void test_ally_cmd(CuTest *tc) { unit *u; faction * f; @@ -1481,6 +1509,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_nmr_warnings); SUITE_ADD_TEST(suite, test_ally_cmd); SUITE_ADD_TEST(suite, test_name_cmd); + SUITE_ADD_TEST(suite, test_name_cmd_2274); SUITE_ADD_TEST(suite, test_ally_cmd_errors); SUITE_ADD_TEST(suite, test_long_order_normal); SUITE_ADD_TEST(suite, test_long_order_none); diff --git a/src/tests.c b/src/tests.c index 15ae677fe..eb2631afe 100644 --- a/src/tests.c +++ b/src/tests.c @@ -225,8 +225,13 @@ building * test_create_building(region * r, const building_type * btype) { building * b; assert(r); - b = new_building(btype ? btype : test_create_buildingtype("castle"), r, default_locale); - b->size = b->type->maxsize > 0 ? b->type->maxsize : 1; + if (!btype) { + building_type *bt_castle = test_create_buildingtype("castle"); + bt_castle->protection = building_protection; + btype = bt_castle; + } + b = new_building(btype, r, default_locale); + b->size = btype->maxsize > 0 ? btype->maxsize : 1; return b; } From 21514f3bfe6e177906807d5bc090979a79342718 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 25 Jan 2017 21:03:08 +0100 Subject: [PATCH 443/675] BESCHREIBE REGION ist jeder Einheit des Regionsbesitzers erlaubt --- src/laws.c | 20 +------------------- src/laws.test.c | 5 +++++ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/laws.c b/src/laws.c index 769bfc9d3..6b0bfda8d 100644 --- a/src/laws.c +++ b/src/laws.c @@ -1538,16 +1538,6 @@ int prefix_cmd(unit * u, struct order *ord) return 0; } -static cmp_building_cb get_cmp_region_owner(void) -{ - if (rule_region_owners()) { - return &cmp_current_owner; - } - else { - return &cmp_wage; - } -} - int display_cmd(unit * u, struct order *ord) { char token[128]; @@ -1597,15 +1587,7 @@ int display_cmd(unit * u, struct order *ord) break; case P_REGION: - if (!u->building) { - cmistake(u, ord, 145, MSG_EVENT); - break; - } - if (building_owner(u->building) != u) { - cmistake(u, ord, 148, MSG_EVENT); - break; - } - if (u->building != largestbuilding(r, get_cmp_region_owner(), false)) { + if (u->faction != region_get_owner(r)) { cmistake(u, ord, 147, MSG_EVENT); break; } diff --git a/src/laws.test.c b/src/laws.test.c index 67a9bb810..5eb742809 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -229,6 +229,11 @@ static void test_display_cmd(CuTest *tc) { CuAssertPtrEquals(tc, NULL, u->display); free_order(ord); + ord = create_order(K_DISPLAY, f->locale, "%s Hodor", LOC(f->locale, parameters[P_REGION])); + CuAssertIntEquals(tc, 0, display_cmd(u, ord)); + CuAssertPtrEquals(tc, NULL, r->display); + free_order(ord); + test_cleanup(); } From e4a58b2e62763926b46fec4e54807f0070932cdc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 25 Jan 2017 21:26:30 +0100 Subject: [PATCH 444/675] hack compress to not use /home/enno/bin script --- process/compress.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/compress.sh b/process/compress.sh index ff152b9f1..e50cf1940 100755 --- a/process/compress.sh +++ b/process/compress.sh @@ -20,5 +20,5 @@ if [ ! -d $GAME/reports ]; then fi cd $GAME/reports -$HOME/bin/compress.py $TURN "$GAME_NAME" +$ERESSEA/server/bin/compress.py $TURN "$GAME_NAME" cd - From 350357120adc3d7014ce97f0a1d66cf9209a9854 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 16:05:44 +0100 Subject: [PATCH 445/675] fix duplicate cutest library conflict and crash --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fd15f201..405b86a03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,6 @@ endif(WIN32) project (eressea-server C) - enable_testing() find_package (LibXml2) find_package (SQLite3) From 57f6c56e890fdd857d1acb9f313f35581c47d700 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 17:41:21 +0100 Subject: [PATCH 446/675] remove quicklist shim, use selist everywhere --- src/bindings.h | 2 +- src/sqlite.c | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/bindings.h b/src/bindings.h index b4523e582..354bb199a 100755 --- a/src/bindings.h +++ b/src/bindings.h @@ -15,8 +15,8 @@ extern "C" { #endif struct lua_State; - struct selist; struct _dictionary_; + struct selist; int tolua_sqlite_open(struct lua_State *L); int tolua_bindings_open(struct lua_State *L, const struct _dictionary_ *d); diff --git a/src/sqlite.c b/src/sqlite.c index aea0f5d20..2f23d41d5 100644 --- a/src/sqlite.c +++ b/src/sqlite.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -72,10 +72,10 @@ typedef struct db_faction { char *name; } db_faction; -static struct quicklist * +static struct selist * read_factions(sqlite3 * db, int game_id) { int res; - quicklist *result = 0; + selist *result = 0; const char * sql = "SELECT f.id, fd.code, fd.name, fd.email FROM faction f" " LEFT OUTER JOIN faction_data fd" @@ -97,7 +97,7 @@ read_factions(sqlite3 * db, int game_id) { if (text) dbf->name = strdup(text); text = (const char *)sqlite3_column_text(stmt, 3); if (text) dbf->email = strdup(text); - ql_push(&result, dbf); + selist_push(&result, dbf); res = sqlite3_step(stmt); } sqlite3_finalize(stmt); @@ -134,13 +134,18 @@ static void update_faction(sqlite3 *db, const faction *f) { } int db_update_factions(sqlite3 * db, bool force, int game_id) { - quicklist *ql = read_factions(db, game_id); + selist *ql = read_factions(db, game_id); faction *f; sqlite3_exec(db, "BEGIN", 0, 0, 0); for (f = factions; f; f = f->next) { bool update = force; db_faction *dbf = 0; +<<<<<<< HEAD ql_iter it = qli_init(&ql); +======= +#ifdef SELIST_TODO + selist_iter it = qli_init(&ql); +>>>>>>> remove quicklist shim, use selist everywhere while (qli_more(it)) { db_faction *df = (db_faction*)qli_next(&it); if (f->no == df->no || strcmp(f->email, df->email) == 0 || strcmp(f->name, df->name) == 0) { @@ -175,12 +180,12 @@ int db_update_factions(sqlite3 * db, bool force, int game_id) { int db_update_scores(sqlite3 * db, bool force) { /* - const char *sql_ins = + const char *sselist_ins = "INSERT OR FAIL INTO score (value,faction_id,turn) VALUES (?,?,?)"; - sqlite3_stmt *stmt_ins = stmt_cache_get(db, sql_ins); - const char *sql_upd = + sqlite3_stmt *stmt_ins = stmt_cache_get(db, sselist_ins); + const char *sselist_upd = "UPDATE score set value=? WHERE faction_id=? AND turn=?"; - sqlite3_stmt *stmt_upd = stmt_cache_get(db, sql_upd); + sqlite3_stmt *stmt_upd = stmt_cache_get(db, sselist_upd); faction *f; sqlite3_exec(db, "BEGIN", 0, 0, 0); for (f = factions; f; f = f->next) { From 23b211d9e483243a50ec6fd16826b9362f57e1ee Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 18:58:29 +0100 Subject: [PATCH 447/675] fix study.c teacher messaging --- clibs | 2 +- src/sqlite.c | 82 +++++++++++++++++++++++++++--------------------- src/study.c | 50 +++++++++++++++++++---------- src/study.h | 4 +-- src/study.test.c | 8 ++--- src/travelthru.c | 3 +- 6 files changed, 90 insertions(+), 59 deletions(-) diff --git a/clibs b/clibs index 1052905e0..f91ef37f0 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit 1052905e08314de8778750d7585474182723111e +Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c diff --git a/src/sqlite.c b/src/sqlite.c index 2f23d41d5..edb5bfc62 100644 --- a/src/sqlite.c +++ b/src/sqlite.c @@ -133,47 +133,59 @@ static void update_faction(sqlite3 *db, const faction *f) { sqlite3_finalize(stmt); } +struct cb_data { + const faction *f; + sqlite3 *db; + db_faction *dbf; +}; + +static bool db_faction_cb(void *el, void *arg) { + db_faction *df = (db_faction *)el; + struct cb_data *cb = (struct cb_data *)arg; + const faction *f = cb->f; + + if (f->no == df->no || strcmp(f->email, df->email) == 0 || strcmp(f->name, df->name) == 0) { + cb->dbf = df; + } + if (f->subscription == df->uid) { + cb->dbf = df; + return false; + } + return true; +} + int db_update_factions(sqlite3 * db, bool force, int game_id) { selist *ql = read_factions(db, game_id); - faction *f; - sqlite3_exec(db, "BEGIN", 0, 0, 0); - for (f = factions; f; f = f->next) { - bool update = force; - db_faction *dbf = 0; -<<<<<<< HEAD - ql_iter it = qli_init(&ql); -======= -#ifdef SELIST_TODO - selist_iter it = qli_init(&ql); ->>>>>>> remove quicklist shim, use selist everywhere - while (qli_more(it)) { - db_faction *df = (db_faction*)qli_next(&it); - if (f->no == df->no || strcmp(f->email, df->email) == 0 || strcmp(f->name, df->name) == 0) { - dbf = df; + if (ql) { + faction *f; + struct cb_data cbdata; + cbdata.db = db; + cbdata.dbf = NULL; + sqlite3_exec(db, "BEGIN", 0, 0, 0); + for (f = factions; f; f = f->next) { + bool update = force; + cbdata.f = f; + selist_foreach_ex(ql, db_faction_cb, &cbdata); + if (cbdata.dbf) { + const db_faction *dbf = cbdata.dbf; + if (dbf->uid != f->subscription) { + log_warning("faction %s(%d) not found in database, but matches %d\n", itoa36(f->no), f->subscription, dbf->uid); + f->subscription = dbf->uid; + } + update = (dbf->no != f->no) || (strcmp(f->email, dbf->email) != 0) || (strcmp(f->name, dbf->name) != 0); } - if (f->subscription == df->uid) { - dbf = df; - break; + else { + f->subscription = insert_faction(db, game_id, f); + log_warning("faction %s not found in database, created as %d\n", itoa36(f->no), f->subscription); + update = true; + } + if (update) { + update_faction(db, f); + log_debug("faction %s updated\n", itoa36(f->no)); } } - if (dbf) { - if (dbf->uid != f->subscription) { - log_warning("faction %s(%d) not found in database, but matches %d\n", itoa36(f->no), f->subscription, dbf->uid); - f->subscription = dbf->uid; - } - update = (dbf->no != f->no) || (strcmp(f->email, dbf->email) != 0) || (strcmp(f->name, dbf->name) != 0); - } - else { - f->subscription = insert_faction(db, game_id, f); - log_warning("faction %s not found in database, created as %d\n", itoa36(f->no), f->subscription); - update = true; - } - if (update) { - update_faction(db, f); - log_debug("faction %s updated\n", itoa36(f->no)); - } + sqlite3_exec(db, "COMMIT", 0, 0, 0); } - sqlite3_exec(db, "COMMIT", 0, 0, 0); return SQLITE_OK; } diff --git a/src/study.c b/src/study.c index b69b4359f..c6dc3b260 100644 --- a/src/study.c +++ b/src/study.c @@ -52,8 +52,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include - -#include +#include /* libc includes */ #include @@ -222,7 +221,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk, a = a_add(&student->attribs, a_new(&at_learning)); teach = (teaching_info *)a->data.v; } - ql_push(&teach->teachers, teacher); + selist_push(&teach->teachers, teacher); teach->value += n; if (student->building && teacher->building == student->building) { @@ -531,6 +530,36 @@ static bool ExpensiveMigrants(void) return rule; } +struct teach_data { + unit *u; + skill_t sk; +}; + +static bool cb_msg_teach(void *el, void *arg) { + struct teach_data *td = (struct teach_data *)arg; + unit *ut = (unit *)el; + unit * u = td->u; + skill_t sk = td->sk; + if (ut->faction != u->faction) { + bool feedback = alliedunit(u, ut->faction, HELP_GUARD); + if (feedback) { + ADDMSG(&ut->faction->msgs, msg_message("teach_teacher", + "teacher student skill level", ut, u, sk, + effskill(u, sk, 0))); + } + ADDMSG(&u->faction->msgs, msg_message("teach_student", + "teacher student skill", ut, u, sk)); + } + return true; +} + +static void msg_teachers(struct selist *teachers, struct unit *u, skill_t sk) { + struct teach_data cbdata; + cbdata.sk = sk; + cbdata.u = u; + selist_foreach_ex(teachers, cb_msg_teach, &cbdata); +} + int study_cmd(unit * u, order * ord) { region *r = u->region; @@ -755,19 +784,8 @@ int study_cmd(unit * u, order * ord) learn_skill(u, sk, days); if (a != NULL) { - ql_iter qli = qli_init(&teach->teachers); - while (qli_more(qli)) { - unit *teacher = (unit *)qli_next(&qli); - if (teacher->faction != u->faction) { - bool feedback = alliedunit(u, teacher->faction, HELP_GUARD); - if (feedback) { - ADDMSG(&teacher->faction->msgs, msg_message("teach_teacher", - "teacher student skill level", teacher, u, sk, - effskill(u, sk, 0))); - } - ADDMSG(&u->faction->msgs, msg_message("teach_student", - "teacher student skill", teacher, u, sk)); - } + if (teach->teachers) { + msg_teachers(teach->teachers, u, sk); } a_remove(&u->attribs, a); a = NULL; diff --git a/src/study.h b/src/study.h index 8067bc9bd..0f8ae70f5 100644 --- a/src/study.h +++ b/src/study.h @@ -27,7 +27,7 @@ extern "C" { #endif struct unit; - struct quicklist; + struct selist; int teach_cmd(struct unit *u, struct order *ord); int study_cmd(struct unit *u, struct order *ord); @@ -48,7 +48,7 @@ extern "C" { #define TEACHNUMBER 10 typedef struct teaching_info { - struct quicklist *teachers; + struct selist *teachers; int value; } teaching_info; diff --git a/src/study.test.c b/src/study.test.c index 4c1e5f171..594ca600c 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -19,7 +19,7 @@ #include #include -#include +#include #include @@ -539,9 +539,9 @@ static void test_teach_message(CuTest *tc) { teach = (teaching_info *)a->data.v; CuAssertPtrNotNull(tc, teach->teachers); CuAssertIntEquals(tc, 600, teach->value); - CuAssertIntEquals(tc, 2, ql_length(teach->teachers)); - CuAssertPtrEquals(tc, u1, ql_get(teach->teachers, 0)); - CuAssertPtrEquals(tc, u2, ql_get(teach->teachers, 1)); + CuAssertIntEquals(tc, 2, selist_length(teach->teachers)); + CuAssertPtrEquals(tc, u1, selist_get(teach->teachers, 0)); + CuAssertPtrEquals(tc, u2, selist_get(teach->teachers, 1)); study_cmd(u, u->thisorder); CuAssertPtrEquals(tc, NULL, test_find_messagetype(u1->faction->msgs, "teach_teacher")); CuAssertPtrNotNull(tc, test_find_messagetype(u2->faction->msgs, "teach_teacher")); diff --git a/src/travelthru.c b/src/travelthru.c index a546c976c..73aa97757 100644 --- a/src/travelthru.c +++ b/src/travelthru.c @@ -105,10 +105,11 @@ struct cb_data { struct region *r; }; -void cb_map(void *data, void *ex) { +static bool cb_map(void *data, void *ex) { struct cb_data *cb = (struct cb_data *)ex; struct unit *u = (struct unit *)data; cb->call(cb->r, u, cb->data); + return true; } void travelthru_map(region * r, void(*cb)(region *, struct unit *, void *), void *data) From 146cb9b00d3f5ca9320eb4f0725e65ea1eef7b2f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 19:19:40 +0100 Subject: [PATCH 448/675] fix merge conflict --- src/study.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/study.c b/src/study.c index fb87987fa..c6dc3b260 100644 --- a/src/study.c +++ b/src/study.c @@ -54,8 +54,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#include - /* libc includes */ #include #include From f941fceed4df187e69e7f6d7bc26d36eb483332a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 21:34:45 +0100 Subject: [PATCH 449/675] new cmake modules (expat) --- cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake b/cmake index f1fb3943a..d88983c7f 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit f1fb3943ace59994d90d71a891b80033dc2700a2 +Subproject commit d88983c7ff4bc3a4884a7c3f74e8190bac5eab23 From 0913336ef8dfc6ea0a0ee321e7cad26bd4ed1064 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jan 2017 21:47:59 +0100 Subject: [PATCH 450/675] Use MSVC fixes for clibs compilation. --- clibs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clibs b/clibs index f91ef37f0..27c8b3202 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c +Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 From d4e5e5f478f1c90589b86b0a6e18eb62f0446367 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 27 Jan 2017 20:20:20 +0100 Subject: [PATCH 451/675] add a simple upgrade script for non-developers. --- s/upgrade | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 s/upgrade diff --git a/s/upgrade b/s/upgrade new file mode 100755 index 000000000..9d9d5a313 --- /dev/null +++ b/s/upgrade @@ -0,0 +1,14 @@ +#!/bin/sh +set -e + +ROOT=`pwd` +while [ ! -d $ROOT/.git ]; do + ROOT=`dirname $ROOT` +done + +cd $ROOT +git pull +git submodule update +s/build +s/runtests +s/install From 6d15767a1896bc2f03f4b9c4b6b1dd1a2fc7cb61 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 28 Jan 2017 19:42:20 +0100 Subject: [PATCH 452/675] create a spellref structure. use this when referring to spells that may not (yet) exist. use it for race::precombatspell (rare use case). --- clibs | 2 +- src/kernel/race.c | 2 ++ src/kernel/race.h | 3 ++- src/kernel/spell.c | 29 +++++++++++++++++++++++++++++ src/kernel/spell.h | 9 +++++++++ src/kernel/spell.test.c | 17 +++++++++++++++++ src/kernel/xmlreader.c | 15 +++++++++++++-- src/magic.c | 7 +++++-- 8 files changed, 78 insertions(+), 6 deletions(-) diff --git a/clibs b/clibs index 27c8b3202..f91ef37f0 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 +Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c diff --git a/src/kernel/race.c b/src/kernel/race.c index a78a9e340..c18761dcd 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -32,6 +32,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "region.h" #include "ship.h" #include "skill.h" +#include "spell.h" #include "terrain.h" #include "unit.h" @@ -182,6 +183,7 @@ void racelist_insert(struct race_list **rl, const struct race *r) void free_races(void) { while (races) { race * rc = races->next; + spellref_free(races->precombatspell); free_params(&races->parameters); free(xrefs); xrefs = 0; diff --git a/src/kernel/race.h b/src/kernel/race.h index 6673676bd..496dfa763 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -45,6 +45,7 @@ extern "C" { struct param; struct spell; + struct spellref; struct locale; extern int num_races; @@ -137,7 +138,7 @@ extern "C" { int at_bonus; /* Ver�ndert den Angriffsskill (default: 0) */ int df_bonus; /* Ver�ndert den Verteidigungskill (default: 0) */ struct param *parameters; // additional properties, for an example see natural_armor - const struct spell *precombatspell; + struct spellref *precombatspell; signed char *study_speed; /* study-speed-bonus in points/turn (0=30 Tage) */ int flags; int battle_flags; diff --git a/src/kernel/spell.c b/src/kernel/spell.c index 5415c4a0e..5e4a57e86 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -145,3 +145,32 @@ spell *find_spellbyid(unsigned int id) log_warning("cannot find spell by id: %u\n", id); return NULL; } + +struct spellref *spellref_create(const char *name) +{ + spellref *spref = malloc(sizeof(spellref)); + + spref->name = strdup(name); + spref->sp = NULL; + return spref; +} + +void spellref_free(spellref *spref) +{ + if (spref) { + free(spref->name); + free(spref); + } +} + +struct spell *spellref_get(struct spellref *spref) +{ + if (!spref->sp) { + spref->sp = find_spell(spref->name); + if (spref->sp) { + free(spref->name); + spref->name = NULL; + } + } + return spref->sp; +} diff --git a/src/kernel/spell.h b/src/kernel/spell.h index f74fda6e2..b5b227b50 100644 --- a/src/kernel/spell.h +++ b/src/kernel/spell.h @@ -45,6 +45,15 @@ extern "C" { fumble_f fumble; } spell; + typedef struct spellref { + char * name; + struct spell *sp; + } spellref; + + struct spellref *spellref_create(const char *name); + void spellref_free(struct spellref *spref); + struct spell *spellref_get(struct spellref *spref); + int sp_antimagiczone(struct castorder *co); struct spell * create_spell(const char * name, unsigned int id); diff --git a/src/kernel/spell.test.c b/src/kernel/spell.test.c index 6bb2ac449..4a8cd617a 100644 --- a/src/kernel/spell.test.c +++ b/src/kernel/spell.test.c @@ -69,9 +69,26 @@ static void test_create_spell_with_id(CuTest * tc) test_cleanup(); } +static void test_spellref(CuTest *tc) +{ + spellref *ref; + spell *sp; + test_setup(); + ref = spellref_create("hodor"); + CuAssertPtrNotNull(tc, ref); + CuAssertPtrEquals(tc, NULL, spellref_get(ref)); + sp = create_spell("hodor", 0); + CuAssertPtrNotNull(tc, sp); + CuAssertPtrEquals(tc, sp, spellref_get(ref)); + CuAssertPtrEquals(tc, NULL, ref->name); + spellref_free(ref); + test_cleanup(); +} + CuSuite *get_spell_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_spellref); SUITE_ADD_TEST(suite, test_create_a_spell); SUITE_ADD_TEST(suite, test_create_duplicate_spell); SUITE_ADD_TEST(suite, test_create_spell_with_id); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index cba01bc7b..238b04227 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -87,6 +87,17 @@ static const spell *xml_spell(xmlNode * node, const char *name) return sp; } +static spellref *xml_spellref(xmlNode * node, const char *name) +{ + xmlChar *propValue = xmlGetProp(node, BAD_CAST name); + if (propValue != NULL) { + spellref *ref = spellref_create((const char *)propValue); + xmlFree(propValue); + return ref; + } + return NULL; +} + static xmlChar *xml_cleanup_string(xmlChar * str) { xmlChar *read = str; @@ -1853,7 +1864,7 @@ static int parse_races(xmlDocPtr doc) || !"precombatspell is already initialized"); for (k = 0; k != result->nodesetval->nodeNr; ++k) { xmlNodePtr node = result->nodesetval->nodeTab[k]; - rc->precombatspell = xml_spell(node, "spell"); + rc->precombatspell = xml_spellref(node, "spell"); } xmlXPathFreeObject(result); @@ -2076,10 +2087,10 @@ void register_xmlreader(void) xml_register_callback(parse_buildings); /* requires resources */ xml_register_callback(parse_ships); /* requires terrains */ + xml_register_callback(parse_races); /* requires spells */ xml_register_callback(parse_spells); /* requires resources */ xml_register_callback(parse_spellbooks); /* requires spells */ xml_register_callback(parse_equipment); /* requires spells */ - xml_register_callback(parse_races); /* requires spells */ xml_register_callback(parse_calendar); } #endif diff --git a/src/magic.c b/src/magic.c index f2992538c..7969253e0 100644 --- a/src/magic.c +++ b/src/magic.c @@ -560,8 +560,11 @@ const spell *get_combatspell(const unit * u, int nr) if (m) { return m->combatspells[nr].sp; } - else if (u_race(u)->precombatspell != NULL) { - return u_race(u)->precombatspell; + else { + const race * rc = u_race(u); + if (rc->precombatspell) { + return spellref_get(rc->precombatspell); + } } return NULL; From 11c0330de1fe4f8b9efd58aaa6a59e5bff7252f7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 28 Jan 2017 19:52:28 +0100 Subject: [PATCH 453/675] make race::attack use spellref, too. --- src/battle.c | 9 ++++++--- src/kernel/race.c | 5 +++++ src/kernel/race.h | 2 +- src/kernel/xmlreader.c | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/battle.c b/src/battle.c index 4105cf73f..ad613a69f 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1858,10 +1858,13 @@ static void do_combatspell(troop at) static void do_extra_spell(troop at, const att * a) { - const spell *sp = a->data.sp; + const spell *sp = spellref_get(a->data.sp); - if (sp->cast == NULL) { - log_error("spell '%s' has no function.\n", sp->sname); + if (!sp) { + log_error("no such spell: '%s'", a->data.sp->name); + } + else if (sp->cast == NULL) { + log_error("spell '%s' has no function.", sp->sname); } else { assert(a->level > 0); diff --git a/src/kernel/race.c b/src/kernel/race.c index c18761dcd..1bdba8a1b 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -182,7 +182,12 @@ void racelist_insert(struct race_list **rl, const struct race *r) void free_races(void) { while (races) { + int i; race * rc = races->next; + + for (i = 0; races->attack[i].type!=AT_NONE; ++i) { + spellref_free(races->attack[i].data.sp); + } spellref_free(races->precombatspell); free_params(&races->parameters); free(xrefs); diff --git a/src/kernel/race.h b/src/kernel/race.h index 496dfa763..19b7b7ad3 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -105,7 +105,7 @@ extern "C" { int type; union { const char *dice; - const struct spell *sp; + struct spellref *sp; } data; int flags; int level; diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 238b04227..36fe2d7f8 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1889,11 +1889,11 @@ static int parse_races(xmlDocPtr doc) xmlFree(propValue); } else { - attack->data.sp = xml_spell(node, "spell"); + attack->data.sp = xml_spellref(node, "spell"); if (attack->data.sp) { attack->level = xml_ivalue(node, "level", 0); if (attack->level <= 0) { - log_error("magical attack '%s' for race '%s' needs a level: %d\n", attack->data.sp->sname, rc->_name, attack->level); + log_error("magical attack '%s' for race '%s' needs a level: %d\n", attack->data.sp->name, rc->_name, attack->level); } } } From d794ad4433f0c58fe3240a1eb417af71ec89f513 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 28 Jan 2017 20:02:15 +0100 Subject: [PATCH 454/675] Eressea config requires game.id At home, I am running all games from the same directory for testing, and cannot use eressea.ini for setting game.id Override it in eressea.ini for other games. --- conf/e2/config.json | 2 ++ conf/e3/config.json | 2 ++ conf/e4/config.json | 2 ++ 3 files changed, 6 insertions(+) diff --git a/conf/e2/config.json b/conf/e2/config.json index ca157f501..f9f9b2df0 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -8,6 +8,8 @@ "jsreport" ], "settings": { + "game.name" : "Eressea", + "game.id" : 2, "orders.default": "work", "NewbieImmunity": 8, "modules.wormholes": true, diff --git a/conf/e3/config.json b/conf/e3/config.json index fd533070e..8783055b8 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -25,6 +25,8 @@ "jsreport" ], "settings": { + "game.name" : "Eressea", + "game.id" : 3, "orders.default": "work", "database.gameid": 7, "NewbieImmunity": 4, diff --git a/conf/e4/config.json b/conf/e4/config.json index 91961258a..e11b13a1c 100644 --- a/conf/e4/config.json +++ b/conf/e4/config.json @@ -25,6 +25,8 @@ "jsreport" ], "settings": { + "game.name" : "Eressea", + "game.id" : 4, "orders.default": "work", "database.gameid": 7, "NewbieImmunity": 4, From 2016a9ef20a6762dfd1df867ebc352c1f631d58d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 28 Jan 2017 20:07:31 +0100 Subject: [PATCH 455/675] unused function --- cmake | 2 +- src/kernel/xmlreader.c | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/cmake b/cmake index d88983c7f..f1fb3943a 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit d88983c7ff4bc3a4884a7c3f74e8190bac5eab23 +Subproject commit f1fb3943ace59994d90d71a891b80033dc2700a2 diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 36fe2d7f8..959872920 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -75,18 +75,6 @@ static void xml_readtext(xmlNodePtr node, struct locale **lang, xmlChar ** text) *text = xmlNodeListGetString(node->doc, node->children, 1); } -static const spell *xml_spell(xmlNode * node, const char *name) -{ - const spell *sp = NULL; - xmlChar *propValue = xmlGetProp(node, BAD_CAST name); - if (propValue != NULL) { - sp = find_spell((const char *)propValue); - assert(sp); - xmlFree(propValue); - } - return sp; -} - static spellref *xml_spellref(xmlNode * node, const char *name) { xmlChar *propValue = xmlGetProp(node, BAD_CAST name); From 7437ebb36a5eb2c7a13ba911884b629163e5470d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Jan 2017 10:45:22 +0100 Subject: [PATCH 456/675] WIP: make all spell configuration use spellref. does not pass tests. --- src/kernel/xmlreader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 36fe2d7f8..cad8780c7 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -2088,9 +2088,9 @@ void register_xmlreader(void) xml_register_callback(parse_buildings); /* requires resources */ xml_register_callback(parse_ships); /* requires terrains */ xml_register_callback(parse_races); /* requires spells */ - xml_register_callback(parse_spells); /* requires resources */ xml_register_callback(parse_spellbooks); /* requires spells */ xml_register_callback(parse_equipment); /* requires spells */ + xml_register_callback(parse_spells); /* requires resources */ xml_register_callback(parse_calendar); } #endif From 36d884143ee406b3045350ac6f44395d45f2d05c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Jan 2017 11:06:08 +0100 Subject: [PATCH 457/675] =?UTF-8?q?Bug=202278:=20Neue=20Magier=20k=C3=B6nn?= =?UTF-8?q?en=20nicht=20gelehrt=20werden.=20http://bugs.eressea.de/view.ph?= =?UTF-8?q?p=3Fid=3D2278?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/study.c | 4 ++-- src/study.test.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/study.c b/src/study.c index 1dd4da8b8..89be92bbd 100644 --- a/src/study.c +++ b/src/study.c @@ -473,8 +473,8 @@ int teach_cmd(unit * u, struct order *ord) * Lehrer seines Gebietes */ sc_mage *mage1 = get_mage(u); sc_mage *mage2 = get_mage(u2); - if (!mage2 || !mage1 || (mage2->magietyp != M_GRAY - && mage1->magietyp != mage2->magietyp)) { + if (mage2 && mage1 && mage2->magietyp != M_GRAY + && mage1->magietyp != mage2->magietyp) { if (feedback) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_different_magic", "target", u2)); diff --git a/src/study.test.c b/src/study.test.c index 47976930d..83628a123 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -381,6 +381,34 @@ static void test_study_cost(CuTest *tc) { test_cleanup(); } +static void test_teach_magic(CuTest *tc) { + unit *u, *ut; + faction *f; + const struct item_type *itype; + + test_setup(); + init_resources(); + itype = get_resourcetype(R_SILVER)->itype; + f = test_create_faction(0); + f->magiegebiet = M_GWYRRD; + u = test_create_unit(f, test_create_region(0, 0, 0)); + u->thisorder = create_order(K_STUDY, f->locale, "%s", skillnames[SK_MAGIC]); + i_change(&u->items, itype, study_cost(u, SK_MAGIC)); + ut = test_create_unit(f, u->region); + set_level(ut, SK_MAGIC, TEACHDIFFERENCE); + create_mage(ut, M_GWYRRD); + ut->thisorder = create_order(K_TEACH, f->locale, "%s", itoa36(u->no)); + learn_inject(); + teach_cmd(ut, ut->thisorder); + study_cmd(u, u->thisorder); + learn_reset(); + CuAssertPtrEquals(tc, u, log_learners[0].u); + CuAssertIntEquals(tc, SK_MAGIC, log_learners[0].sk); + CuAssertIntEquals(tc, STUDYDAYS*2, log_learners[0].days); + CuAssertIntEquals(tc, 0, i_get(u->items, itype)); + test_cleanup(); +} + static void test_teach_cmd(CuTest *tc) { unit *u, *ut; test_setup(); @@ -550,6 +578,7 @@ CuSuite *get_study_suite(void) SUITE_ADD_TEST(suite, test_study_cost); SUITE_ADD_TEST(suite, test_study_magic); SUITE_ADD_TEST(suite, test_teach_cmd); + SUITE_ADD_TEST(suite, test_teach_magic); SUITE_ADD_TEST(suite, test_teach_two); SUITE_ADD_TEST(suite, test_teach_one_to_many); SUITE_ADD_TEST(suite, test_teach_many_to_one); From bf22cbc2ef49369781b713a5aa8838ad888c2408 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Jan 2017 11:30:22 +0100 Subject: [PATCH 458/675] increase MAXTEACHERS again (permament fix in 3.11) --- src/study.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/study.h b/src/study.h index 20903583a..9d053dd5e 100644 --- a/src/study.h +++ b/src/study.h @@ -45,7 +45,7 @@ extern "C" { void demon_skillchange(struct unit *u); -#define MAXTEACHERS 32 +#define MAXTEACHERS 64 #define TEACHNUMBER 10 typedef struct teaching_info { struct unit *teachers[MAXTEACHERS]; From f58db3f729a49abf8a72a963e93c2fce2acc1df4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Jan 2017 12:59:09 +0100 Subject: [PATCH 459/675] Bug 2276: hacking a band-aid fix for compress.sh aka the game.name related mailpocalypse http://bugs.eressea.de/view.php?id=2276 --- process/compress.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/compress.sh b/process/compress.sh index ff152b9f1..23b0929dd 100755 --- a/process/compress.sh +++ b/process/compress.sh @@ -6,7 +6,7 @@ if [ -z $ERESSEA ]; then fi GAME=$ERESSEA/game-$1 -GAME_NAME=$(grep name $GAME/eressea.ini | sed 's/.*=\s*//') +GAME_NAME=$(grep -w name $GAME/eressea.ini | sed 's/.*=\s*//') TURN=$2 if [ -z $TURN ] From 3d8d091207494a65785feb2f61e1c2fe69486f9e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 30 Jan 2017 10:26:08 +0100 Subject: [PATCH 460/675] new build scripts, new versioning system --- s/build | 11 +++++++---- s/cmake-init | 9 +-------- s/runtests | 6 +----- src/kernel/version.c | 2 +- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/s/build b/s/build index b59804626..f471229b8 100755 --- a/s/build +++ b/s/build @@ -1,8 +1,5 @@ #!/bin/sh -ROOT=`pwd` -while [ ! -d $ROOT/.git ]; do - ROOT=`dirname $ROOT` -done +ROOT=$(git rev-parse --show-toplevel) [ -z "$BUILD" ] && BUILD=Debug if [ -z "$JOBS" ] ; then @@ -37,7 +34,13 @@ git submodule update echo "build eressea" cd $ROOT/$BUILD +BRANCH=$(git status -s -b | head -1 | cut -d\ -f 2 | sed 's/\..*//') +if [ "$BRANCH" == "master" ] ; then VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//') cmake -DERESSEA_VERSION="$VERSION" .. +else +REV=$(git rev-parse --short HEAD) +cmake -DERESSEA_BUILDNO="$REV-$BUILD" .. +fi make $MAKEOPTS && make test cd $OLDPWD diff --git a/s/cmake-init b/s/cmake-init index ea94afb7c..370725a4d 100755 --- a/s/cmake-init +++ b/s/cmake-init @@ -1,13 +1,6 @@ #!/bin/sh -ROOT=$(pwd) -while [ ! -d $ROOT/.git ]; do - ROOT=$(dirname $ROOT) - if [ "$ROOT" == "/" ; then - echo "could not find root, are you in the git repository?" - exit - fi -done +ROOT=$(git rev-parse --show-toplevel) [ -z $BUILD ] && BUILD=Debug [ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang" [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" diff --git a/s/runtests b/s/runtests index e0e20b5c7..58498436f 100755 --- a/s/runtests +++ b/s/runtests @@ -1,11 +1,7 @@ #!/bin/bash set -e -ROOT=$(pwd) -while [ ! -d $ROOT/.git ]; do - ROOT=$(dirname $ROOT) -done - +ROOT=$(git rev-parse --show-toplevel) [ -z $BUILD ] && BUILD=Debug ; export BUILD if [ ! -e $ROOT/$BUILD ]; then diff --git a/src/kernel/version.c b/src/kernel/version.c index 6de6ddb40..45b9815bc 100644 --- a/src/kernel/version.c +++ b/src/kernel/version.c @@ -5,7 +5,7 @@ #ifndef ERESSEA_VERSION // the version number, if it was not passed to make with -D -#define ERESSEA_VERSION "3.10.0-devel" +#define ERESSEA_VERSION "3.10.0" #endif const char *eressea_version(void) { From ae83448e4aea90dc0913155adb1aaa92703f97d8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Feb 2017 10:10:21 +0100 Subject: [PATCH 461/675] Deveron is now just E3 with a different name. remove a lot of duplication. add a -c option to specify a path for eressea.ini --- conf/e4/catalog.xml | 16 ------- conf/e4/config.json | 95 ------------------------------------- conf/e4/config.xml | 39 --------------- s/runtests | 1 - scripts/eressea/e4/init.lua | 11 ----- scripts/run-tests-e4.lua | 23 --------- src/kernel/config.c | 13 +++-- src/kernel/save.c | 7 --- src/main.c | 26 +++++++--- tests/runtests.bat | 1 - 10 files changed, 29 insertions(+), 203 deletions(-) delete mode 100644 conf/e4/catalog.xml delete mode 100644 conf/e4/config.json delete mode 100644 conf/e4/config.xml delete mode 100644 scripts/eressea/e4/init.lua delete mode 100644 scripts/run-tests-e4.lua diff --git a/conf/e4/catalog.xml b/conf/e4/catalog.xml deleted file mode 100644 index 9987e72c8..000000000 --- a/conf/e4/catalog.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - diff --git a/conf/e4/config.json b/conf/e4/config.json deleted file mode 100644 index e11b13a1c..000000000 --- a/conf/e4/config.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "include": [ - "keywords.json", - "prefixes.json", - "e3/terrains.json" - ], - "disabled": [ - "herbalism", - "alchemy", - "entertainment", - "espionage", - "perception", - "stealth", - "taxation", - "trade", - "besiege", - "steal", - "buy", - "teach", - "sabotage", - "spy", - "tax", - "entertain", - "sell", - "jsreport" - ], - "settings": { - "game.name" : "Eressea", - "game.id" : 4, - "orders.default": "work", - "database.gameid": 7, - "NewbieImmunity": 4, - "modules.astralspace": false, - "modules.wormholes": false, - "modules.markets": true, - "magic.regeneration": 0.75, - "magic.power": 0.5, - "resource.factor": 0.25, - "skills.cost.tactics": 500, - "entertain.base": 0, - "entertain.perlevel": 20, - "nmr.timeout": 5, - "nmr.removenewbie": 0, - "GiveRestriction": 3, - "hunger.long": false, - "hunger.damage": "1d9+9", - "hunger.demons.skill": true, - "hunger.demons.peasant_tolerance": true, - "init_spells": 0, - "recruit.allow_merge": true, - "study.expensivemigrants": true, - "study.speedup": 2, - "study.produceexp": 12, - "world.era": 3, - "rules.reserve.twophase": true, - "rules.owners.force_leave": false, - "rules.transfermen": false, - "stealth.faction.other": false, - "rules.stealth.anon_battle": false, - "rules.check_overload": false, - "rules.combat.goblinbonus": 3, - "rules.alliances": true, - "rules.combat.herospeed": 3, - "rules.combat.demon_vampire": 5, - "rules.combat.skill_bonus": 0, - "rules.combat.nat_armor": 1, - "rules.items.loot_divisor": 2, - "rules.items.give_divisor": 2, - "rules.move.owner_leave": true, - "rules.region_owners": true, - "rules.cavalry.skill": 2, - "rules.cavalry.mode": 1, - "rules.magic.multipotion": true, - "rules.magic.wol_effect": 5, - "rules.magic.factionlist": true, - "rules.magic.wol_type": 2, - "rules.blessed_harvest.flags": 1, - "rules.magic.elfpower": true, - "rules.magic.playerschools": "gwyrrd illaun draig cerddor", - "rules.build.other_buildings": true, - "rules.economy.taxation": 1, - "rules.food.flags": 2, - "rules.economy.roqf": 5, - "rules.economy.herbrot": 0, - "rules.region_owner_pay_building": "market harbour lighthouse", - "rules.dwarf_castles": true, - "rules.limit.faction": 250, - "rules.grow.formula": 1, - "rules.tactics.formula": 1, - "rules.help.mask": "fight guard money give", - "movement.shipspeed.skillbonus": 6, - "alliance.auto": "fight", - "alliance.restricted": "fight" - } -} diff --git a/conf/e4/config.xml b/conf/e4/config.xml deleted file mode 100644 index f9ede1a27..000000000 --- a/conf/e4/config.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/s/runtests b/s/runtests index 58498436f..e42640de1 100755 --- a/s/runtests +++ b/s/runtests @@ -15,7 +15,6 @@ cd $ROOT $ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests.lua $ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests-e2.lua $ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests-e3.lua -$ROOT/$BUILD/eressea/eressea -v1 scripts/run-tests-e4.lua rm -rf data reports orders.txt score score.alliances datum turn cd $OLDWPD diff --git a/scripts/eressea/e4/init.lua b/scripts/eressea/e4/init.lua deleted file mode 100644 index 32c0b8498..000000000 --- a/scripts/eressea/e4/init.lua +++ /dev/null @@ -1,11 +0,0 @@ -require 'eressea.e3.rules' -require 'eressea.spells' - -eressea.log.debug("rules for game E4") - -return { - require('eressea'), - -- require('eressea.markets'), - require('eressea.frost'), - require('eressea.ents') -} diff --git a/scripts/run-tests-e4.lua b/scripts/run-tests-e4.lua deleted file mode 100644 index f827baec0..000000000 --- a/scripts/run-tests-e4.lua +++ /dev/null @@ -1,23 +0,0 @@ --- Tests that work in E3. With game config of E3. --- Tests are under scripts/test/e3 and all files must be in scripts/test/e3/init.lua - -path = 'scripts' -if config.install then - path = config.install .. '/' .. path - package.path = package.path .. ';' .. config.install .. '/lunit/?.lua' - --needed to find lunit if not run form eressea root. Needs right [lua] install setting in eressea.ini (point to eressea root from the start folder) -end -package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' - -config.rules = 'e4' - -require 'eressea' -require 'eressea.path' -require 'eressea.xmlconf' -require 'tests.e3' -require 'lunit' - -eressea.settings.set("rules.alliances", "0") -rules = require('eressea.' .. config.rules) -result = lunit.main() -return result.errors + result.failed diff --git a/src/kernel/config.c b/src/kernel/config.c index 83d0808da..b1894cdff 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -749,13 +749,18 @@ void config_set_from(const dictionary *d) key[slen] = '.'; iniparser_getseckeys(d, sec, keys); for (k=0;k!=nkeys;++k) { - const char *val; + const char *val, *orig; size_t klen = strlen(keys[k]); assert(klen+slen+1 Date: Thu, 2 Feb 2017 10:19:39 +0100 Subject: [PATCH 462/675] uninitialized variable. --- src/kernel/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index b1894cdff..ca23a5bc9 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -754,8 +754,8 @@ void config_set_from(const dictionary *d) assert(klen+slen+1 Date: Thu, 2 Feb 2017 16:52:32 +0100 Subject: [PATCH 463/675] WIP: spellref everywhere --- src/creport.c | 5 +++-- src/kernel/spell.c | 13 +++++++++---- src/kernel/spell.h | 41 +++++++++++++++++++++-------------------- src/kernel/spellbook.c | 32 +++++++++++++++++++++++++------- src/kernel/spellbook.h | 5 +++-- src/kernel/xmlreader.c | 2 +- src/laws.c | 4 ++-- src/magic.c | 28 ++++++++++++++++------------ src/report.c | 6 +++--- src/reports.c | 3 ++- 10 files changed, 85 insertions(+), 54 deletions(-) diff --git a/src/creport.c b/src/creport.c index 106f34545..53c542470 100644 --- a/src/creport.c +++ b/src/creport.c @@ -718,7 +718,8 @@ static void cr_output_spells(stream *out, const unit * u, int maxlevel) for (ql = book->spells, qi = 0; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= maxlevel) { - spell * sp = sbe->sp; + // TODO: no need to deref spref here, spref->name == sp->sname + spell * sp = spellref_get(sbe->spref); const char *name = translate(mkname("spell", sp->sname), spell_name(sp, f->locale)); if (!header) { stream_printf(out, "SPRUECHE\n"); @@ -1621,7 +1622,7 @@ report_computer(const char *filename, report_context * ctx, const char *bom) a = a_find(f->attribs, &at_reportspell); while (a && a->type == &at_reportspell) { spellbook_entry *sbe = (spellbook_entry *)a->data.v; - cr_reportspell(F, sbe->sp, sbe->level, f->locale); + cr_reportspell(F, spellref_get(sbe->spref), sbe->level, f->locale); a = a->next; } for (a = a_find(f->attribs, &at_showitem); a && a->type == &at_showitem; diff --git a/src/kernel/spell.c b/src/kernel/spell.c index 5e4a57e86..f950918e0 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -167,10 +167,15 @@ struct spell *spellref_get(struct spellref *spref) { if (!spref->sp) { spref->sp = find_spell(spref->name); - if (spref->sp) { - free(spref->name); - spref->name = NULL; - } } return spref->sp; } + +spellref *spellref_copy(spellref *spref) +{ + spellref *result = spellref_create(spref->name); + if (spref->sp) { + result->sp = spref->sp; + } + return result; +} diff --git a/src/kernel/spell.h b/src/kernel/spell.h index b5b227b50..116816e26 100644 --- a/src/kernel/spell.h +++ b/src/kernel/spell.h @@ -52,6 +52,7 @@ extern "C" { struct spellref *spellref_create(const char *name); void spellref_free(struct spellref *spref); + struct spellref *spellref_copy(struct spellref *spref); struct spell *spellref_get(struct spellref *spref); int sp_antimagiczone(struct castorder *co); @@ -70,7 +71,7 @@ extern "C" { } #endif #endif -/* ------------------------------------------------------------- *//* Erluterungen zu den Spruchdefinitionen +/* ------------------------------------------------------------- *//* Erl�uterungen zu den Spruchdefinitionen * * Spruchstukturdefinition: * spell{ @@ -88,35 +89,35 @@ extern "C" { * id: * SPL_NOSPELL muss der letzte Spruch in der Liste spelldaten sein, * denn nicht auf die Reihenfolge in der Liste sondern auf die id wird - * geprft + * gepr�ft * * sptyp: * besondere Spruchtypen und Flags * (Regionszauber, Kampfzauber, Farcastbar, Stufe variable, ..) * * rank: - * gibt die Prioritt und damit die Reihenfolge an, in der der Spruch + * gibt die Priorit�t und damit die Reihenfolge an, in der der Spruch * gezaubert wird. - * 1: Aura bertragen + * 1: Aura �bertragen * 2: Antimagie - * 3: Magierverndernde Sprche (Magic Boost, ..) + * 3: Magierver�ndernde Spr�che (Magic Boost, ..) * 4: Monster erschaffen * 5: Standartlevel * 7: Teleport * - * Komponenten[Anzahl mgl. Items][Art:Anzahl:Kostentyp] + * Komponenten[Anzahl m�gl. Items][Art:Anzahl:Kostentyp] * * R_AURA: - * Grundkosten fr einen Zauber. Soviel Mp mssen mindestens investiert - * werden, um den Spruch zu wirken. Zustzliche Mp knnen unterschiedliche + * Grundkosten f�r einen Zauber. Soviel Mp m�ssen mindestens investiert + * werden, um den Spruch zu wirken. Zus�tzliche Mp k�nnen unterschiedliche * Auswirkungen haben, die in der Spruchfunktionsroutine definiert werden. * * R_PERMAURA: * Kosten an permantenter Aura * * Komponenten Kostentyp: - * SPC_LEVEL == Spruch mit Levelabhngigen Magiekosten. Die angegeben - * Kosten mssen fr Stufe 1 berechnet sein. + * SPC_LEVEL == Spruch mit Levelabh�ngigen Magiekosten. Die angegeben + * Kosten m�ssen f�r Stufe 1 berechnet sein. * SPC_FIX == Feste Kosten * * Wenn keine spezielle Syntax angegeben ist, wird die @@ -137,34 +138,34 @@ extern "C" { * * u : eine Einheitennummer * r : hier kommen zwei Regionskoordinaten x y - * b : Gebude- oder Burgnummer + * b : Geb�ude- oder Burgnummer * s : Schiffsnummer - * c : String, wird ohne Weiterverarbeitung bergeben - * i : Zahl (int), wird ohne Weiterverarbeitung bergeben + * c : String, wird ohne Weiterverarbeitung �bergeben + * i : Zahl (int), wird ohne Weiterverarbeitung �bergeben * k : Keywort - dieser String gibt den Paramter an, der folgt. Der * Parameter wird mit findparam() identifiziert. - * k muss immer von einem c als Platzhalter fr das Objekt gefolgt + * k muss immer von einem c als Platzhalter f�r das Objekt gefolgt * werden. - * Ein gutes Beispiel sind hierfr die Sprche zur Magieanalyse. + * Ein gutes Beispiel sind hierf�r die Spr�che zur Magieanalyse. * + : gibt an, das der vorherige Parameter mehrfach vorkommen kann. Da * ein Ende nicht definiert werden kann, muss dies immer am Schluss * kommen. * - * Flags fr das Parsing: + * Flags f�r das Parsing: * TESTRESISTANCE : alle Zielobjekte, also alle Parameter vom Typ Unit, * Burg, Schiff oder Region, werden auf ihre - * Magieresistenz berprft + * Magieresistenz �berpr�ft * TESTCANSEE : jedes Objekt vom Typ Einheit wird auf seine - * Sichtbarkeit berprft + * Sichtbarkeit �berpr�ft * SEARCHLOCAL : die Zielobjekte werden nur regional gesucht * REGIONSPELL : Ziel ist die Region, auch wenn kein Zielobjekt * angegeben wird. Ist TESTRESISTANCE gesetzt, so wird - * die Magieresistenz der Region berprft + * die Magieresistenz der Region �berpr�ft * * Bei fehlendem Ziel oder wenn dieses dem Zauber widersteht, wird die * Spruchfunktion nicht aufgerufen. * Sind zu wenig Parameter vorhanden, wird der Zauber ebenfalls nicht - * ausgefhrt. + * ausgef�hrt. * Ist eins von mehreren Zielobjekten resistent, so wird das Flag * pa->param[n]->flag == TARGET_RESISTS * Ist eins von mehreren Zielobjekten nicht gefunden worden, so ist diff --git a/src/kernel/spellbook.c b/src/kernel/spellbook.c index bb060eaee..919142585 100644 --- a/src/kernel/spellbook.c +++ b/src/kernel/spellbook.c @@ -50,7 +50,7 @@ void read_spellbook(spellbook **bookp, gamedata *data, int(*get_level)(const spe sb = *bookp; } if (level > 0 && (data->version >= SPELLBOOK_VERSION || !spellbook_get(sb, sp))) { - spellbook_add(sb, sp, level); + spellbook_add_spell(sb, sp, level); } } } @@ -64,25 +64,43 @@ void write_spellbook(const struct spellbook *book, struct storage *store) if (book) { for (ql = book->spells, qi = 0; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); - WRITE_TOK(store, sbe->sp->sname); + WRITE_TOK(store, sbe->spref->name); WRITE_INT(store, sbe->level); } } WRITE_TOK(store, "end"); } -void spellbook_add(spellbook *sb, struct spell * sp, int level) +void spellbook_add(spellbook *sb, spellref *spref, int level) { spellbook_entry * sbe; - assert(sb && sp && level > 0); + assert(sb && spref && level > 0); +#ifndef NDEBUG + if (spellbook_get(sb, spellref_get(spref))) { + log_error("duplicate spell in spellbook '%s': '%s'\n", sb->name, spref->name); + } +#endif + sbe = (spellbook_entry *)malloc(sizeof(spellbook_entry)); + sbe->spref = spellref_copy(spref); + sbe->level = level; + selist_push(&sb->spells, sbe); +} + +void spellbook_add_spell(spellbook *sb, spell *sp, int level) +{ + spellbook_entry * sbe; + + assert(sb && sp->sname && level > 0); #ifndef NDEBUG if (spellbook_get(sb, sp)) { log_error("duplicate spell in spellbook '%s': '%s'\n", sb->name, sp->sname); } #endif sbe = (spellbook_entry *)malloc(sizeof(spellbook_entry)); - sbe->sp = sp; + // FIXME: create a better API to create spellref from spell + sbe->spref = spellref_create(sp->sname); + sbe->spref->sp = sp; sbe->level = level; selist_push(&sb->spells, sbe); } @@ -95,6 +113,7 @@ void spellbook_clear(spellbook *sb) assert(sb); for (qi = 0, ql = sb->spells; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); + spellref_free(sbe->spref); free(sbe); } selist_free(sb->spells); @@ -124,11 +143,10 @@ spellbook_entry * spellbook_get(spellbook *sb, const struct spell * sp) for (qi = 0, ql = sb->spells; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); - if (sp == sbe->sp) { + if (sp == spellref_get(sbe->spref)) { return sbe; } } } return 0; } - diff --git a/src/kernel/spellbook.h b/src/kernel/spellbook.h index 75a420c06..858240f54 100644 --- a/src/kernel/spellbook.h +++ b/src/kernel/spellbook.h @@ -29,7 +29,7 @@ extern "C" { struct selist; typedef struct spellbook_entry { - struct spell * sp; + struct spellref * spref; int level; } spellbook_entry; @@ -44,7 +44,8 @@ extern "C" { void read_spellbook(struct spellbook **bookp, struct gamedata *data, int(*get_level)(const struct spell * sp, void *), void * cbdata); void write_spellbook(const struct spellbook *book, struct storage *store); - void spellbook_add(spellbook *sbp, struct spell * sp, int level); + void spellbook_add(spellbook *sbp, struct spellref *spref, int level); + void spellbook_add_spell(spellbook *sb, struct spell *sp, int level); int spellbook_foreach(spellbook *sb, int(*callback)(spellbook_entry *, void *), void * data); void spellbook_clear(spellbook *sb); spellbook_entry * spellbook_get(spellbook *sb, const struct spell * sp); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 959872920..f9d0912da 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -2076,9 +2076,9 @@ void register_xmlreader(void) xml_register_callback(parse_buildings); /* requires resources */ xml_register_callback(parse_ships); /* requires terrains */ xml_register_callback(parse_races); /* requires spells */ - xml_register_callback(parse_spells); /* requires resources */ xml_register_callback(parse_spellbooks); /* requires spells */ xml_register_callback(parse_equipment); /* requires spells */ + xml_register_callback(parse_spells); /* requires resources */ xml_register_callback(parse_calendar); } #endif diff --git a/src/laws.c b/src/laws.c index 6b0bfda8d..f543fc78f 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3458,8 +3458,8 @@ static void copy_spells(const spellbook * src, spellbook * dst, int maxlevel) for (qi = 0, ql = src->spells; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= maxlevel) { - if (!spellbook_get(dst, sbe->sp)) { - spellbook_add(dst, sbe->sp, sbe->level); + if (!spellbook_get(dst, spellref_get(sbe->spref))) { + spellbook_add(dst, sbe->spref, sbe->level); } } } diff --git a/src/magic.c b/src/magic.c index 7969253e0..bdac11df8 100644 --- a/src/magic.c +++ b/src/magic.c @@ -430,14 +430,14 @@ void show_new_spells(faction * f, int level, const spellbook *book) for (qi = 0; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= level) { - - if (!already_seen(f, sbe->sp)) { + spell *sp = spellref_get(sbe->spref); + if (!already_seen(f, sp)) { attrib * a = a_new(&at_reportspell); spellbook_entry * entry = (spellbook_entry *)a->data.v; entry->level = sbe->level; - entry->sp = sbe->sp; + entry->spref = spellref_copy(sbe->spref); a_add(&f->attribs, a); - a_add(&f->attribs, a_new(&at_seenspell))->data.v = sbe->sp; + a_add(&f->attribs, a_new(&at_seenspell))->data.v = sp; } } } @@ -481,13 +481,16 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells commonspells[maxspell] = sbe; sbe = 0; } - else if (f->spellbook && spellbook_get(f->spellbook, sbe->sp)) { - // already have this spell, remove it from the list of candidates - commonspells[spellno] = commonspells[--numspells]; - if (maxspell > numspells) { - maxspell = numspells; + else { + spell *sp = spellref_get(sbe->spref); + if (f->spellbook && spellbook_get(f->spellbook, sp)) { + // already have this spell, remove it from the list of candidates + commonspells[spellno] = commonspells[--numspells]; + if (maxspell > numspells) { + maxspell = numspells; + } + sbe = 0; } - sbe = 0; } } @@ -495,7 +498,7 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells if (!f->spellbook) { f->spellbook = create_spellbook(0); } - spellbook_add(f->spellbook, sbe->sp, sbe->level); + spellbook_add(f->spellbook, sbe->spref, sbe->level); commonspells[spellno] = commonspells[--numspells]; } } @@ -2948,6 +2951,7 @@ const char *spell_info(const spell * sp, const struct locale *lang) return LOC(lang, mkname("spellinfo", sp->sname)); } +// TODO: should take the name, not the spell (spellref optimizations) const char *spell_name(const spell * sp, const struct locale *lang) { return LOC(lang, mkname("spell", sp->sname)); @@ -2967,7 +2971,7 @@ static void select_spellbook(void **tokens, spellbook *sb, const struct locale * for (qi = 0, ql = sb->spells; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); - spell *sp = sbe->sp; + spell *sp = spellref_get(sbe->spref); const char *n = spell_name(sp, lang); if (!n) { diff --git a/src/report.c b/src/report.c index 1282789fa..fa1222f90 100644 --- a/src/report.c +++ b/src/report.c @@ -234,7 +234,7 @@ paragraph(struct stream *out, const char *str, ptrdiff_t indent, int hanging_ind } while (*begin); } -static size_t write_spell_modifier(spell * sp, int flag, const char * str, bool cont, char * bufp, size_t size) { +static size_t write_spell_modifier(const spell * sp, int flag, const char * str, bool cont, char * bufp, size_t size) { if (sp->sptyp & flag) { size_t bytes = 0; if (cont) { @@ -255,7 +255,7 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc char buf[4096]; char *bufp = buf; size_t size = sizeof(buf) - 1; - spell * sp = sbe->sp; + const spell * sp = spellref_get(sbe->spref); const char *params = sp->parameter; if (sp->sptyp & ISCOMBATSPELL) { @@ -445,7 +445,7 @@ void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *la char buf[4096]; char *startp, *bufp = buf; size_t size = sizeof(buf) - 1; - spell * sp = sbe->sp; + const spell * sp = spellref_get(sbe->spref); newline(out); centre(out, spell_name(sp, lang), true); diff --git a/src/reports.c b/src/reports.c index 5a47acfed..bb727083e 100644 --- a/src/reports.c +++ b/src/reports.c @@ -680,7 +680,8 @@ size_t size) if (wrptr(&bufp, &size, result) != 0) { WARN_STATIC_BUFFER(); } - bufp = STRLCPY(bufp, spell_name(sbe->sp, f->locale), size); + // TODO: no need to deref the spellref here (spref->name is good) + bufp = STRLCPY(bufp, spell_name(spellref_get(sbe->spref), f->locale), size); } } From b08b1544f4a4c89e851df41eee1025036b5ce0af Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Feb 2017 16:55:07 +0100 Subject: [PATCH 464/675] snotling is not a player race --- res/eressea/races.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 7c3a5ab0c..e31283fc3 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -1150,7 +1150,7 @@ - + From 0c08a644950fbead4a917798e6237cf20776efb4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Feb 2017 17:10:53 +0100 Subject: [PATCH 465/675] new clibs module, fixed MSVC settings --- clibs | 2 +- cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clibs b/clibs index f91ef37f0..27c8b3202 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c +Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 diff --git a/cmake b/cmake index f1fb3943a..d88983c7f 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit f1fb3943ace59994d90d71a891b80033dc2700a2 +Subproject commit d88983c7ff4bc3a4884a7c3f74e8190bac5eab23 From 784a934c47c8c9c47f671fb69c736e5d24f8b44b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Feb 2017 19:17:01 +0100 Subject: [PATCH 466/675] Fix snotling XML (no recruiting). --- clibs | 2 +- res/eressea/races.xml | 5 +++-- src/kernel/xmlreader.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/clibs b/clibs index f91ef37f0..27c8b3202 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c +Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 diff --git a/res/eressea/races.xml b/res/eressea/races.xml index e31283fc3..2ef5950c9 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -1150,7 +1150,9 @@ - + + @@ -1180,7 +1182,6 @@ - diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index f9d0912da..35a682649 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -2074,11 +2074,11 @@ void register_xmlreader(void) xml_register_callback(parse_rules); xml_register_callback(parse_buildings); /* requires resources */ + xml_register_callback(parse_spells); /* requires resources */ xml_register_callback(parse_ships); /* requires terrains */ xml_register_callback(parse_races); /* requires spells */ xml_register_callback(parse_spellbooks); /* requires spells */ xml_register_callback(parse_equipment); /* requires spells */ - xml_register_callback(parse_spells); /* requires resources */ xml_register_callback(parse_calendar); } #endif From e9a5a79c652aa7f63584c1f77b5ab0c525216670 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Feb 2017 19:28:46 +0100 Subject: [PATCH 467/675] make my visual studio debugging experience the same as before (-r is like -c) --- src/main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index a3bcdb866..9bfd1448f 100644 --- a/src/main.c +++ b/src/main.c @@ -186,14 +186,11 @@ static int parse_args(int argc, char **argv, int *exitcode) else { const char *arg; switch (argi[1]) { + case 'r': case 'c': i = get_arg(argc, argv, 2, i, &arg, 0); config_set("config.path", arg); break; - case 'r': - i = get_arg(argc, argv, 2, i, &arg, 0); - config_set("config.rules", arg); - break; case 'f': i = get_arg(argc, argv, 2, i, &luafile, 0); break; From 9f3f1bf41df000a24621404fca3513fd2ccf2357 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Feb 2017 19:30:29 +0100 Subject: [PATCH 468/675] fix runtests.bat experience (doh!) --- src/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 9bfd1448f..a3bcdb866 100644 --- a/src/main.c +++ b/src/main.c @@ -186,11 +186,14 @@ static int parse_args(int argc, char **argv, int *exitcode) else { const char *arg; switch (argi[1]) { - case 'r': case 'c': i = get_arg(argc, argv, 2, i, &arg, 0); config_set("config.path", arg); break; + case 'r': + i = get_arg(argc, argv, 2, i, &arg, 0); + config_set("config.rules", arg); + break; case 'f': i = get_arg(argc, argv, 2, i, &luafile, 0); break; From 456d1bd1967fb66d0e354d45df57019489501461 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Feb 2017 20:08:04 +0100 Subject: [PATCH 469/675] spellbooks should not use spellref, it's unnecessary. --- src/creport.c | 4 ++-- src/kernel/spell.c | 26 ++++++++++++++------------ src/kernel/spell.h | 3 +-- src/kernel/spell.test.c | 5 +++-- src/kernel/spellbook.c | 33 +++++++-------------------------- src/kernel/spellbook.h | 7 +++---- src/kernel/xmlreader.c | 10 +++++----- src/laws.c | 4 ++-- src/magic.c | 19 ++++++++----------- src/report.c | 4 ++-- src/reports.c | 2 +- 11 files changed, 48 insertions(+), 69 deletions(-) diff --git a/src/creport.c b/src/creport.c index 53c542470..345aaf0bc 100644 --- a/src/creport.c +++ b/src/creport.c @@ -719,7 +719,7 @@ static void cr_output_spells(stream *out, const unit * u, int maxlevel) spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= maxlevel) { // TODO: no need to deref spref here, spref->name == sp->sname - spell * sp = spellref_get(sbe->spref); + spell * sp = sbe->sp; const char *name = translate(mkname("spell", sp->sname), spell_name(sp, f->locale)); if (!header) { stream_printf(out, "SPRUECHE\n"); @@ -1622,7 +1622,7 @@ report_computer(const char *filename, report_context * ctx, const char *bom) a = a_find(f->attribs, &at_reportspell); while (a && a->type == &at_reportspell) { spellbook_entry *sbe = (spellbook_entry *)a->data.v; - cr_reportspell(F, spellref_get(sbe->spref), sbe->level, f->locale); + cr_reportspell(F, sbe->sp, sbe->level, f->locale); a = a->next; } for (a = a_find(f->attribs, &at_showitem); a && a->type == &at_showitem; diff --git a/src/kernel/spell.c b/src/kernel/spell.c index f950918e0..212b0a7d2 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -146,12 +146,18 @@ spell *find_spellbyid(unsigned int id) return NULL; } -struct spellref *spellref_create(const char *name) +struct spellref *spellref_create(spell *sp, const char *name) { spellref *spref = malloc(sizeof(spellref)); - spref->name = strdup(name); - spref->sp = NULL; + if (sp) { + spref->sp = sp; + spref->name = strdup(sp->sname); + } + else if (name) { + spref->name = strdup(name); + spref->sp = NULL; + } return spref; } @@ -166,16 +172,12 @@ void spellref_free(spellref *spref) struct spell *spellref_get(struct spellref *spref) { if (!spref->sp) { + assert(spref->name); spref->sp = find_spell(spref->name); + if (spref->sp) { + free(spref->name); + spref->name = NULL; + } } return spref->sp; } - -spellref *spellref_copy(spellref *spref) -{ - spellref *result = spellref_create(spref->name); - if (spref->sp) { - result->sp = spref->sp; - } - return result; -} diff --git a/src/kernel/spell.h b/src/kernel/spell.h index 116816e26..e7592f082 100644 --- a/src/kernel/spell.h +++ b/src/kernel/spell.h @@ -50,9 +50,8 @@ extern "C" { struct spell *sp; } spellref; - struct spellref *spellref_create(const char *name); + struct spellref *spellref_create(struct spell *sp, const char *name); void spellref_free(struct spellref *spref); - struct spellref *spellref_copy(struct spellref *spref); struct spell *spellref_get(struct spellref *spref); int sp_antimagiczone(struct castorder *co); diff --git a/src/kernel/spell.test.c b/src/kernel/spell.test.c index 4a8cd617a..b500f94cc 100644 --- a/src/kernel/spell.test.c +++ b/src/kernel/spell.test.c @@ -74,13 +74,14 @@ static void test_spellref(CuTest *tc) spellref *ref; spell *sp; test_setup(); - ref = spellref_create("hodor"); + ref = spellref_create(NULL, "hodor"); CuAssertPtrNotNull(tc, ref); + CuAssertPtrEquals(tc, NULL, ref->sp); + CuAssertStrEquals(tc, "hodor", ref->name); CuAssertPtrEquals(tc, NULL, spellref_get(ref)); sp = create_spell("hodor", 0); CuAssertPtrNotNull(tc, sp); CuAssertPtrEquals(tc, sp, spellref_get(ref)); - CuAssertPtrEquals(tc, NULL, ref->name); spellref_free(ref); test_cleanup(); } diff --git a/src/kernel/spellbook.c b/src/kernel/spellbook.c index 919142585..b7f65420c 100644 --- a/src/kernel/spellbook.c +++ b/src/kernel/spellbook.c @@ -50,7 +50,7 @@ void read_spellbook(spellbook **bookp, gamedata *data, int(*get_level)(const spe sb = *bookp; } if (level > 0 && (data->version >= SPELLBOOK_VERSION || !spellbook_get(sb, sp))) { - spellbook_add_spell(sb, sp, level); + spellbook_add(sb, sp, level); } } } @@ -64,43 +64,25 @@ void write_spellbook(const struct spellbook *book, struct storage *store) if (book) { for (ql = book->spells, qi = 0; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); - WRITE_TOK(store, sbe->spref->name); + WRITE_TOK(store, sbe->sp->sname); WRITE_INT(store, sbe->level); } } WRITE_TOK(store, "end"); } -void spellbook_add(spellbook *sb, spellref *spref, int level) +void spellbook_add(spellbook *sb, spell *sp, int level) { spellbook_entry * sbe; - assert(sb && spref && level > 0); -#ifndef NDEBUG - if (spellbook_get(sb, spellref_get(spref))) { - log_error("duplicate spell in spellbook '%s': '%s'\n", sb->name, spref->name); - } -#endif - sbe = (spellbook_entry *)malloc(sizeof(spellbook_entry)); - sbe->spref = spellref_copy(spref); - sbe->level = level; - selist_push(&sb->spells, sbe); -} - -void spellbook_add_spell(spellbook *sb, spell *sp, int level) -{ - spellbook_entry * sbe; - - assert(sb && sp->sname && level > 0); + assert(sb && sp && level > 0); #ifndef NDEBUG if (spellbook_get(sb, sp)) { log_error("duplicate spell in spellbook '%s': '%s'\n", sb->name, sp->sname); } #endif sbe = (spellbook_entry *)malloc(sizeof(spellbook_entry)); - // FIXME: create a better API to create spellref from spell - sbe->spref = spellref_create(sp->sname); - sbe->spref->sp = sp; + sbe->sp = sp; sbe->level = level; selist_push(&sb->spells, sbe); } @@ -113,7 +95,6 @@ void spellbook_clear(spellbook *sb) assert(sb); for (qi = 0, ql = sb->spells; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); - spellref_free(sbe->spref); free(sbe); } selist_free(sb->spells); @@ -135,7 +116,7 @@ int spellbook_foreach(spellbook *sb, int(*callback)(spellbook_entry *, void *), return 0; } -spellbook_entry * spellbook_get(spellbook *sb, const struct spell * sp) +spellbook_entry * spellbook_get(spellbook *sb, const struct spell *sp) { if (sb) { selist *ql; @@ -143,7 +124,7 @@ spellbook_entry * spellbook_get(spellbook *sb, const struct spell * sp) for (qi = 0, ql = sb->spells; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); - if (sp == spellref_get(sbe->spref)) { + if (sbe->sp==sp) { return sbe; } } diff --git a/src/kernel/spellbook.h b/src/kernel/spellbook.h index 858240f54..fb3438a8b 100644 --- a/src/kernel/spellbook.h +++ b/src/kernel/spellbook.h @@ -29,7 +29,7 @@ extern "C" { struct selist; typedef struct spellbook_entry { - struct spellref * spref; + struct spell *sp; int level; } spellbook_entry; @@ -44,11 +44,10 @@ extern "C" { void read_spellbook(struct spellbook **bookp, struct gamedata *data, int(*get_level)(const struct spell * sp, void *), void * cbdata); void write_spellbook(const struct spellbook *book, struct storage *store); - void spellbook_add(spellbook *sbp, struct spellref *spref, int level); - void spellbook_add_spell(spellbook *sb, struct spell *sp, int level); + void spellbook_add(spellbook *sbp, struct spell *sp, int level); int spellbook_foreach(spellbook *sb, int(*callback)(spellbook_entry *, void *), void * data); void spellbook_clear(spellbook *sb); - spellbook_entry * spellbook_get(spellbook *sb, const struct spell * sp); + spellbook_entry * spellbook_get(spellbook *sb, const struct spell *sp); #ifdef __cplusplus } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index f9d0912da..4225858ee 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -79,7 +79,7 @@ static spellref *xml_spellref(xmlNode * node, const char *name) { xmlChar *propValue = xmlGetProp(node, BAD_CAST name); if (propValue != NULL) { - spellref *ref = spellref_create((const char *)propValue); + spellref *ref = spellref_create(NULL, (const char *)propValue); xmlFree(propValue); return ref; } @@ -2075,10 +2075,10 @@ void register_xmlreader(void) xml_register_callback(parse_buildings); /* requires resources */ xml_register_callback(parse_ships); /* requires terrains */ - xml_register_callback(parse_races); /* requires spells */ - xml_register_callback(parse_spellbooks); /* requires spells */ - xml_register_callback(parse_equipment); /* requires spells */ - xml_register_callback(parse_spells); /* requires resources */ + xml_register_callback(parse_races); xml_register_callback(parse_calendar); + xml_register_callback(parse_spells); /* requires resources */ + xml_register_callback(parse_equipment); /* requires spells */ + xml_register_callback(parse_spellbooks); /* requires spells */ } #endif diff --git a/src/laws.c b/src/laws.c index f543fc78f..6b0bfda8d 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3458,8 +3458,8 @@ static void copy_spells(const spellbook * src, spellbook * dst, int maxlevel) for (qi = 0, ql = src->spells; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= maxlevel) { - if (!spellbook_get(dst, spellref_get(sbe->spref))) { - spellbook_add(dst, sbe->spref, sbe->level); + if (!spellbook_get(dst, sbe->sp)) { + spellbook_add(dst, sbe->sp, sbe->level); } } } diff --git a/src/magic.c b/src/magic.c index bdac11df8..7e820f9c3 100644 --- a/src/magic.c +++ b/src/magic.c @@ -430,14 +430,13 @@ void show_new_spells(faction * f, int level, const spellbook *book) for (qi = 0; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= level) { - spell *sp = spellref_get(sbe->spref); - if (!already_seen(f, sp)) { + if (!already_seen(f, sbe->sp)) { attrib * a = a_new(&at_reportspell); spellbook_entry * entry = (spellbook_entry *)a->data.v; entry->level = sbe->level; - entry->spref = spellref_copy(sbe->spref); + entry->sp = sbe->sp; a_add(&f->attribs, a); - a_add(&f->attribs, a_new(&at_seenspell))->data.v = sp; + a_add(&f->attribs, a_new(&at_seenspell))->data.v = sbe->sp; } } } @@ -482,8 +481,7 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells sbe = 0; } else { - spell *sp = spellref_get(sbe->spref); - if (f->spellbook && spellbook_get(f->spellbook, sp)) { + if (f->spellbook && spellbook_get(f->spellbook, sbe->sp)) { // already have this spell, remove it from the list of candidates commonspells[spellno] = commonspells[--numspells]; if (maxspell > numspells) { @@ -498,7 +496,7 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells if (!f->spellbook) { f->spellbook = create_spellbook(0); } - spellbook_add(f->spellbook, sbe->spref, sbe->level); + spellbook_add(f->spellbook, sbe->sp, sbe->level); commonspells[spellno] = commonspells[--numspells]; } } @@ -2971,15 +2969,14 @@ static void select_spellbook(void **tokens, spellbook *sb, const struct locale * for (qi = 0, ql = sb->spells; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry *sbe = (spellbook_entry *)selist_get(ql, qi); - spell *sp = spellref_get(sbe->spref); - const char *n = spell_name(sp, lang); + const char *n = spell_name(sbe->sp, lang); if (!n) { - log_error("no translation in locale %s for spell %s\n", locale_name(lang), sp->sname); + log_error("no translation in locale %s for spell %s\n", locale_name(lang), sbe->sp->sname); } else { variant token; - token.v = sp; + token.v = sbe->sp; addtoken((struct tnode **)tokens, n, token); } } diff --git a/src/report.c b/src/report.c index fa1222f90..06244c70c 100644 --- a/src/report.c +++ b/src/report.c @@ -255,7 +255,7 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc char buf[4096]; char *bufp = buf; size_t size = sizeof(buf) - 1; - const spell * sp = spellref_get(sbe->spref); + const spell * sp = sbe->sp; const char *params = sp->parameter; if (sp->sptyp & ISCOMBATSPELL) { @@ -445,7 +445,7 @@ void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *la char buf[4096]; char *startp, *bufp = buf; size_t size = sizeof(buf) - 1; - const spell * sp = spellref_get(sbe->spref); + const spell * sp = sbe->sp; newline(out); centre(out, spell_name(sp, lang), true); diff --git a/src/reports.c b/src/reports.c index bb727083e..318660024 100644 --- a/src/reports.c +++ b/src/reports.c @@ -681,7 +681,7 @@ size_t size) WARN_STATIC_BUFFER(); } // TODO: no need to deref the spellref here (spref->name is good) - bufp = STRLCPY(bufp, spell_name(spellref_get(sbe->spref), f->locale), size); + bufp = STRLCPY(bufp, spell_name(sbe->sp, f->locale), size); } } From 0224620ca332048a11d05c3d12197bdcb7efb822 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Feb 2017 20:12:52 +0100 Subject: [PATCH 470/675] code duplication, lazy_spell was almost the same as spellref. --- src/kernel/equipment.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index 00f8c2f95..6b74121ff 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -87,8 +87,7 @@ void equipment_setskill(equipment * eq, skill_t sk, const char *value) } typedef struct lazy_spell { - char *name; - struct spell *sp; + struct spellref *spref; int level; } lazy_spell; @@ -96,9 +95,8 @@ void equipment_addspell(equipment * eq, const char * name, int level) { if (eq) { lazy_spell *ls = malloc(sizeof(lazy_spell)); - ls->sp = NULL; + ls->spref = spellref_create(NULL, name); ls->level = level; - ls->name = strdup(name); selist_push(&eq->spells, ls); } } @@ -162,12 +160,8 @@ void equip_unit_mask(struct unit *u, const struct equipment *eq, int mask) for (qi = 0; ql; selist_advance(&ql, &qi, 1)) { lazy_spell *sbe = (lazy_spell *)selist_get(ql, qi); - if (!sbe->sp) { - sbe->sp = find_spell(sbe->name); - free(sbe->name); - sbe->name = NULL; - } - unit_add_spell(u, mage, sbe->sp, sbe->level); + spell *sp = spellref_get(sbe->spref); + unit_add_spell(u, mage, sp, sbe->level); } } } @@ -238,7 +232,7 @@ void equip_items(struct item **items, const struct equipment *eq) void free_ls(void *arg) { lazy_spell *ls = (lazy_spell*)arg; - free(ls->name); + spellref_free(ls->spref); free(ls); } From 7009f26ee51652eb352574d7455162a68d8554e0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Feb 2017 20:12:52 +0100 Subject: [PATCH 471/675] code duplication, lazy_spell was almost the same as spellref. --- src/kernel/equipment.c | 16 +++++----------- src/kernel/xmlreader.c | 17 ++++++++++------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index 00f8c2f95..6b74121ff 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -87,8 +87,7 @@ void equipment_setskill(equipment * eq, skill_t sk, const char *value) } typedef struct lazy_spell { - char *name; - struct spell *sp; + struct spellref *spref; int level; } lazy_spell; @@ -96,9 +95,8 @@ void equipment_addspell(equipment * eq, const char * name, int level) { if (eq) { lazy_spell *ls = malloc(sizeof(lazy_spell)); - ls->sp = NULL; + ls->spref = spellref_create(NULL, name); ls->level = level; - ls->name = strdup(name); selist_push(&eq->spells, ls); } } @@ -162,12 +160,8 @@ void equip_unit_mask(struct unit *u, const struct equipment *eq, int mask) for (qi = 0; ql; selist_advance(&ql, &qi, 1)) { lazy_spell *sbe = (lazy_spell *)selist_get(ql, qi); - if (!sbe->sp) { - sbe->sp = find_spell(sbe->name); - free(sbe->name); - sbe->name = NULL; - } - unit_add_spell(u, mage, sbe->sp, sbe->level); + spell *sp = spellref_get(sbe->spref); + unit_add_spell(u, mage, sp, sbe->level); } } } @@ -238,7 +232,7 @@ void equip_items(struct item **items, const struct equipment *eq) void free_ls(void *arg) { lazy_spell *ls = (lazy_spell*)arg; - free(ls->name); + spellref_free(ls->spref); free(ls); } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 4225858ee..854a6dd4c 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -2068,17 +2068,20 @@ static int parse_strings(xmlDocPtr doc) void register_xmlreader(void) { - xml_register_callback(parse_strings); - xml_register_callback(parse_messages); - xml_register_callback(parse_resources); xml_register_callback(parse_rules); - xml_register_callback(parse_buildings); /* requires resources */ - xml_register_callback(parse_ships); /* requires terrains */ xml_register_callback(parse_races); xml_register_callback(parse_calendar); - xml_register_callback(parse_spells); /* requires resources */ - xml_register_callback(parse_equipment); /* requires spells */ + xml_register_callback(parse_resources); + + xml_register_callback(parse_buildings); /* requires resources */ + xml_register_callback(parse_ships); /* requires resources, terrains */ + xml_register_callback(parse_equipment); /* requires resources */ + + xml_register_callback(parse_spells); /* requires resources */ xml_register_callback(parse_spellbooks); /* requires spells */ + + xml_register_callback(parse_strings); + xml_register_callback(parse_messages); } #endif From 7750297dc2a340a256bf773a39697f0cfacb1ef1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 10:57:32 +0100 Subject: [PATCH 472/675] express race.magres as percentage, not probability (double->int) --- res/e3a/races.xml | 102 ++++++++++++++--------------- res/eressea/races.xml | 130 ++++++++++++++++++------------------- res/races/aquarian.xml | 2 +- res/races/cat.xml | 2 +- res/races/demon.xml | 2 +- res/races/dragon.xml | 2 +- res/races/dwarf.xml | 2 +- res/races/elf.xml | 2 +- res/races/goblin-2.xml | 2 +- res/races/goblin-3.xml | 2 +- res/races/goblin.xml | 2 +- res/races/halfling.xml | 2 +- res/races/human.xml | 2 +- res/races/insect.xml | 2 +- res/races/orc.xml | 2 +- res/races/troll.xml | 2 +- res/races/wyrm.xml | 2 +- res/races/youngdragon.xml | 2 +- res/races/zombie.xml | 2 +- src/battle.test.c | 4 +- src/kernel/jsonconf.c | 2 +- src/kernel/jsonconf.test.c | 5 +- src/kernel/race.c | 4 ++ src/kernel/race.h | 3 +- src/kernel/race.test.c | 3 +- src/kernel/xmlreader.c | 2 +- src/magic.c | 2 +- src/magic.test.c | 6 +- 28 files changed, 152 insertions(+), 145 deletions(-) diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 2b0f68b9d..3402fdb73 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -8,7 +8,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -47,7 +47,7 @@ - + @@ -76,7 +76,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -124,7 +124,7 @@ - + @@ -144,7 +144,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -192,7 +192,7 @@ - + @@ -219,7 +219,7 @@ - + @@ -241,7 +241,7 @@ - + @@ -263,7 +263,7 @@ - + @@ -287,7 +287,7 @@ - + @@ -311,7 +311,7 @@ - + @@ -334,7 +334,7 @@ - + @@ -361,7 +361,7 @@ - + @@ -384,7 +384,7 @@ - + @@ -409,7 +409,7 @@ - + @@ -435,7 +435,7 @@ - + @@ -460,7 +460,7 @@ - + @@ -484,7 +484,7 @@ - + @@ -507,7 +507,7 @@ - + @@ -535,7 +535,7 @@ - + @@ -559,7 +559,7 @@ - + @@ -582,7 +582,7 @@ - + @@ -607,16 +607,16 @@ - + - + - + @@ -624,7 +624,7 @@ - + @@ -672,47 +672,47 @@ - + - + - + - + - + - + - + - + @@ -720,21 +720,21 @@ - + - + - + @@ -742,7 +742,7 @@ - + @@ -768,7 +768,7 @@ - + @@ -787,7 +787,7 @@ - + @@ -806,7 +806,7 @@ - + @@ -823,7 +823,7 @@ - + @@ -839,7 +839,7 @@ - + @@ -855,7 +855,7 @@ - + @@ -871,13 +871,13 @@ - + - + @@ -890,7 +890,7 @@ - + @@ -898,7 +898,7 @@ - + diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 2ef5950c9..e4e22d0c3 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -1,7 +1,7 @@ - - + @@ -27,7 +27,7 @@ - + @@ -61,7 +61,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -118,7 +118,7 @@ - + @@ -148,7 +148,7 @@ - + @@ -178,7 +178,7 @@ - + @@ -209,7 +209,7 @@ - + @@ -244,7 +244,7 @@ - + @@ -275,7 +275,7 @@ - + @@ -308,7 +308,7 @@ - + @@ -339,7 +339,7 @@ - + @@ -370,7 +370,7 @@ - + @@ -401,7 +401,7 @@ - + @@ -431,7 +431,7 @@ - + @@ -463,7 +463,7 @@ - + @@ -495,7 +495,7 @@ - + @@ -525,7 +525,7 @@ - + @@ -558,7 +558,7 @@ - + @@ -589,16 +589,16 @@ - + - + - @@ -607,7 +607,7 @@ - + @@ -671,66 +671,66 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -742,7 +742,7 @@ - + @@ -755,7 +755,7 @@ - + @@ -769,20 +769,20 @@ - + - + - + @@ -801,7 +801,7 @@ - + @@ -827,7 +827,7 @@ - + @@ -860,7 +860,7 @@ - + @@ -889,7 +889,7 @@ - + @@ -921,7 +921,7 @@ - + @@ -978,7 +978,7 @@ - + @@ -1011,11 +1011,11 @@ - + - + @@ -1023,7 +1023,7 @@ - + @@ -1037,7 +1037,7 @@ - + @@ -1055,7 +1055,7 @@ - + @@ -1073,7 +1073,7 @@ - + @@ -1089,7 +1089,7 @@ - + @@ -1104,7 +1104,7 @@ - + @@ -1119,7 +1119,7 @@ - + @@ -1134,12 +1134,12 @@ - + - + @@ -1151,7 +1151,7 @@ - @@ -1182,7 +1182,7 @@ - + @@ -1209,7 +1209,7 @@ - + @@ -1241,7 +1241,7 @@ - + @@ -1271,7 +1271,7 @@ - + @@ -1285,13 +1285,13 @@ - + - + @@ -1300,7 +1300,7 @@ - + diff --git a/res/races/aquarian.xml b/res/races/aquarian.xml index 776f17e93..a0e1189b7 100644 --- a/res/races/aquarian.xml +++ b/res/races/aquarian.xml @@ -1,5 +1,5 @@ - + diff --git a/res/races/cat.xml b/res/races/cat.xml index 818b24b36..75bc8019a 100644 --- a/res/races/cat.xml +++ b/res/races/cat.xml @@ -1,5 +1,5 @@ - + diff --git a/res/races/demon.xml b/res/races/demon.xml index a350fef4a..0ce4c86ff 100644 --- a/res/races/demon.xml +++ b/res/races/demon.xml @@ -1,5 +1,5 @@ - - + diff --git a/res/races/elf.xml b/res/races/elf.xml index dfbd2f2ec..ee1278a26 100644 --- a/res/races/elf.xml +++ b/res/races/elf.xml @@ -1,5 +1,5 @@ - + diff --git a/res/races/goblin-2.xml b/res/races/goblin-2.xml index 9a9c265be..ae90c1918 100644 --- a/res/races/goblin-2.xml +++ b/res/races/goblin-2.xml @@ -1,5 +1,5 @@ - - - - + diff --git a/res/races/human.xml b/res/races/human.xml index 2e4b94af2..8f1ad5cb4 100644 --- a/res/races/human.xml +++ b/res/races/human.xml @@ -1,5 +1,5 @@ - + diff --git a/res/races/insect.xml b/res/races/insect.xml index cecbf0193..dc9faa06d 100644 --- a/res/races/insect.xml +++ b/res/races/insect.xml @@ -1,5 +1,5 @@ - + diff --git a/res/races/orc.xml b/res/races/orc.xml index d9d26ab25..4f4d96ed5 100644 --- a/res/races/orc.xml +++ b/res/races/orc.xml @@ -1,5 +1,5 @@ - + diff --git a/res/races/troll.xml b/res/races/troll.xml index a2341851b..c70020fa2 100644 --- a/res/races/troll.xml +++ b/res/races/troll.xml @@ -1,5 +1,5 @@ - -magres = 0.5; /* gets added to skill bonus */ + rc->_magres = 50; /* percentage, gets added to skill bonus */ calculate_armor(dt, 0, 0, &magres); CuAssertDblEquals_Msg(tc, "race bonus", 0.6, magic_resistance(du), 0.01); CuAssertDblEquals_Msg(tc, "race reduction", 0.4, magres, 0.01); - rc->magres = 1.5; /* should not cause negative damage multiplier */ + rc->_magres = 150; /* should not cause negative damage multiplier */ CuAssertDblEquals_Msg(tc, "magic resistance is never > 0.9", 0.9, magic_resistance(du), 0.01); calculate_armor(dt, 0, 0, &magres); CuAssertDblEquals_Msg(tc, "damage reduction is never < 0.1", 0.1, magres, 0.01); diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 03e210ce0..0cfba4e34 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -458,7 +458,7 @@ static void json_race(cJSON *json, race *rc) { break; case cJSON_Number: if (strcmp(child->string, "magres") == 0) { - rc->magres = (float)child->valuedouble; + rc->_magres = child->valueint; } else if (strcmp(child->string, "maxaura") == 0) { rc->maxaura = (float)child->valuedouble; diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 93fcd8d10..7ac6a93cc 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -136,7 +136,7 @@ static void test_races(CuTest * tc) { const char * data = "{\"races\": { \"orc\" : { " "\"damage\" : \"1d4\"," - "\"magres\" : 1.0," + "\"magres\" : 100," "\"maxaura\" : 2.0," "\"regaura\" : 3.0," "\"speed\" : 4.0," @@ -163,7 +163,8 @@ static void test_races(CuTest * tc) CuAssertPtrNotNull(tc, rc); CuAssertIntEquals(tc, RCF_NPC | RCF_WALK | RCF_UNDEAD, rc->flags); CuAssertStrEquals(tc, "1d4", rc->def_damage); - CuAssertDblEquals(tc, 1.0, rc->magres, 0.0); + CuAssertIntEquals(tc, 100, rc->_magres); + CuAssertDblEquals(tc, 1.0, rc_magres(rc), 0.0); CuAssertDblEquals(tc, 2.0, rc->maxaura, 0.0); CuAssertDblEquals(tc, 3.0, rc->regaura, 0.0); CuAssertDblEquals(tc, 4.0, rc->speed, 0.0); diff --git a/src/kernel/race.c b/src/kernel/race.c index 1bdba8a1b..3dc708ed1 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -282,6 +282,10 @@ bool r_insectstalled(const region * r) return fval(r->terrain, ARCTIC_REGION); } +double rc_magres(const struct race *rc) { + return rc->_magres / 100.0; +} + const char* rc_name(const race * rc, name_t n, char *name, size_t size) { const char * postfix = 0; if (!rc) { diff --git a/src/kernel/race.h b/src/kernel/race.h index 19b7b7ad3..72e1269c9 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -116,7 +116,7 @@ extern "C" { typedef struct race { char *_name; - float magres; + int _magres; float healing; double maxaura; /* Faktor auf Maximale Aura */ double regaura; /* Faktor auf Regeneration */ @@ -184,6 +184,7 @@ extern "C" { const char * rc_name_s(const race *rc, name_t n); const char * rc_name(const race *rc, name_t n, char *name, size_t size); + double rc_magres(const struct race *rc); /* Flags. Do not reorder these without changing json_race() in jsonconf.c */ #define RCF_NPC (1<<0) /* cannot be the race for a player faction (and other limits?) */ #define RCF_KILLPEASANTS (1<<1) /* a monster that eats peasants */ diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index 663a538ee..d40f252bc 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -23,7 +23,8 @@ static void test_rc_defaults(CuTest *tc) { test_setup(); rc = rc_get_or_create("human"); CuAssertStrEquals(tc, "human", rc->_name); - CuAssertDblEquals(tc, 0.0, rc->magres, 0.0); + CuAssertIntEquals(tc, 0, rc->_magres); + CuAssertDblEquals(tc, 0.0, rc_magres(rc), 0.0); CuAssertDblEquals(tc, 0.0, rc->maxaura, 0.0); CuAssertDblEquals(tc, 1.0, rc->recruit_multi, 0.0); CuAssertDblEquals(tc, 1.0, rc->regaura, 0.0); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 854a6dd4c..3d7276bf3 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1635,7 +1635,7 @@ static int parse_races(xmlDocPtr doc) rc->def_damage = strdup((const char *)propValue); xmlFree(propValue); - rc->magres = (float)xml_fvalue(node, "magres", rc->magres); + rc->_magres = xml_ivalue(node, "magres", rc->_magres); rc->healing = (float)xml_fvalue(node, "healing", rc->healing); rc->maxaura = (float)xml_fvalue(node, "maxaura", rc->maxaura); rc->regaura = (float)xml_fvalue(node, "regaura", rc->regaura); diff --git a/src/magic.c b/src/magic.c index 7e820f9c3..e48ec6d5d 100644 --- a/src/magic.c +++ b/src/magic.c @@ -1149,7 +1149,7 @@ double magic_resistance(unit * target) const curse_type * ct_goodresist = 0, *ct_badresist = 0; const resource_type *rtype; const race *rc = u_race(target); - double probability = rc->magres; + double probability = rc_magres(rc); const plane *pl = rplane(target->region); if (rc == get_race(RC_HIRNTOETER) && !pl) { diff --git a/src/magic.test.c b/src/magic.test.c index befd1986d..29534b33b 100644 --- a/src/magic.test.c +++ b/src/magic.test.c @@ -413,11 +413,11 @@ static void test_magic_resistance(CuTest *tc) { test_setup(); rc = test_create_race("human"); u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); - CuAssertDblEquals(tc, rc->magres, magic_resistance(u), 0.01); - rc->magres = 1.0; + CuAssertDblEquals(tc, rc->_magres/100.0, magic_resistance(u), 0.01); + rc->_magres = 100; CuAssertDblEquals_Msg(tc, "magic resistance is capped at 0.9", 0.9, magic_resistance(u), 0.01); rc = test_create_race("braineater"); - rc->magres = 1.0; + rc->_magres = 100; u_setrace(u, rc); CuAssertDblEquals_Msg(tc, "brain eaters outside astral space have 50% magres", 0.5, magic_resistance(u), 0.01); u->region->_plane = get_astralplane(); From fd9583df3d5b72715344fd80fa732c6a9368ce13 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 17:43:40 +0100 Subject: [PATCH 473/675] fix healing for elves in a forest. rename _magres back to magres. rc->parameters is not linked to config_changed invalidation. add tests. --- src/battle.test.c | 4 ++-- src/kernel/jsonconf.c | 2 +- src/kernel/jsonconf.test.c | 2 +- src/kernel/race.c | 2 +- src/kernel/race.h | 2 +- src/kernel/race.test.c | 3 ++- src/kernel/unit.c | 22 ++++++++++++++++++++++ src/kernel/unit.h | 1 + src/kernel/unit.test.c | 28 ++++++++++++++++++++++++++++ src/kernel/xmlreader.c | 2 +- src/laws.c | 26 +------------------------- src/magic.test.c | 6 +++--- src/tests.c | 3 +++ 13 files changed, 67 insertions(+), 36 deletions(-) diff --git a/src/battle.test.c b/src/battle.test.c index 155b3ae0c..03535e16e 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -352,12 +352,12 @@ static void test_magic_resistance(CuTest *tc) calculate_armor(dt, 0, 0, &magres); CuAssertDblEquals_Msg(tc, "skill bonus", 0.1, magic_resistance(du), 0.01); CuAssertDblEquals_Msg(tc, "skill reduction", 0.9, magres, 0.01); - rc->_magres = 50; /* percentage, gets added to skill bonus */ + rc->magres = 50; /* percentage, gets added to skill bonus */ calculate_armor(dt, 0, 0, &magres); CuAssertDblEquals_Msg(tc, "race bonus", 0.6, magic_resistance(du), 0.01); CuAssertDblEquals_Msg(tc, "race reduction", 0.4, magres, 0.01); - rc->_magres = 150; /* should not cause negative damage multiplier */ + rc->magres = 150; /* should not cause negative damage multiplier */ CuAssertDblEquals_Msg(tc, "magic resistance is never > 0.9", 0.9, magic_resistance(du), 0.01); calculate_armor(dt, 0, 0, &magres); CuAssertDblEquals_Msg(tc, "damage reduction is never < 0.1", 0.1, magres, 0.01); diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 0cfba4e34..dcc4c9c0c 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -458,7 +458,7 @@ static void json_race(cJSON *json, race *rc) { break; case cJSON_Number: if (strcmp(child->string, "magres") == 0) { - rc->_magres = child->valueint; + rc->magres = child->valueint; } else if (strcmp(child->string, "maxaura") == 0) { rc->maxaura = (float)child->valuedouble; diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 7ac6a93cc..5b0590bf8 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -163,7 +163,7 @@ static void test_races(CuTest * tc) CuAssertPtrNotNull(tc, rc); CuAssertIntEquals(tc, RCF_NPC | RCF_WALK | RCF_UNDEAD, rc->flags); CuAssertStrEquals(tc, "1d4", rc->def_damage); - CuAssertIntEquals(tc, 100, rc->_magres); + CuAssertIntEquals(tc, 100, rc->magres); CuAssertDblEquals(tc, 1.0, rc_magres(rc), 0.0); CuAssertDblEquals(tc, 2.0, rc->maxaura, 0.0); CuAssertDblEquals(tc, 3.0, rc->regaura, 0.0); diff --git a/src/kernel/race.c b/src/kernel/race.c index 3dc708ed1..16eff8695 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -283,7 +283,7 @@ bool r_insectstalled(const region * r) } double rc_magres(const struct race *rc) { - return rc->_magres / 100.0; + return rc->magres / 100.0; } const char* rc_name(const race * rc, name_t n, char *name, size_t size) { diff --git a/src/kernel/race.h b/src/kernel/race.h index 72e1269c9..853e1041f 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -116,7 +116,7 @@ extern "C" { typedef struct race { char *_name; - int _magres; + int magres; float healing; double maxaura; /* Faktor auf Maximale Aura */ double regaura; /* Faktor auf Regeneration */ diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index d40f252bc..c07808099 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -23,8 +23,9 @@ static void test_rc_defaults(CuTest *tc) { test_setup(); rc = rc_get_or_create("human"); CuAssertStrEquals(tc, "human", rc->_name); - CuAssertIntEquals(tc, 0, rc->_magres); + CuAssertIntEquals(tc, 0, rc->magres); CuAssertDblEquals(tc, 0.0, rc_magres(rc), 0.0); + CuAssertDblEquals(tc, 0.0, rc->healing, 0.0); CuAssertDblEquals(tc, 0.0, rc->maxaura, 0.0); CuAssertDblEquals(tc, 1.0, rc->recruit_multi, 0.0); CuAssertDblEquals(tc, 1.0, rc->regaura, 0.0); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 29766d4ef..354a52a06 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -2047,3 +2047,25 @@ bool has_limited_skills(const struct unit * u) return false; } +double u_heal_factor(const unit * u) +{ + const race * rc = u_race(u); + if (rc->healing>0) { + return rc->healing; + } + if (r_isforest(u->region)) { + static int rc_cache; + static const race *rc_elf; + if (rc_changed(&rc_cache)) { + rc_elf = get_race(RC_ELF); + } + if (rc == rc_elf) { + double elf_regen = 1.0; + if (rc->parameters) { + elf_regen = get_param_flt(rc->parameters, "regen.forest", elf_regen); + } + return elf_regen; + } + } + return 1.0; +} diff --git a/src/kernel/unit.h b/src/kernel/unit.h index e846ca1f4..14096c872 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -190,6 +190,7 @@ extern "C" { bool leave(struct unit *u, bool force); bool can_leave(struct unit *u); + double u_heal_factor(const struct unit * u); void u_set_building(struct unit * u, struct building * b); void u_set_ship(struct unit * u, struct ship * sh); void leave_ship(struct unit * u); diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index b0a2891c5..ad4e1761a 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -483,6 +484,32 @@ static void test_name_unit(CuTest *tc) { test_cleanup(); } +static void test_heal_factor(CuTest *tc) { + unit * u; + region *r; + race *rc; + terrain_type *t_plain; + + test_setup(); + t_plain = test_create_terrain("plain", LAND_REGION|FOREST_REGION); + rc = rc_get_or_create("human"); + u = test_create_unit(test_create_faction(rc), r = test_create_region(0, 0, t_plain)); + rsettrees(r, 1, r->terrain->size / TREESIZE); + rsettrees(r, 2, 0); + CuAssertTrue(tc, r_isforest(r)); + CuAssertDblEquals(tc, 1.0, u_heal_factor(u), 0.0); + rc->healing = 2.0; + CuAssertDblEquals(tc, 2.0, u_heal_factor(u), 0.0); + rc->healing = 0.0; + rc = rc_get_or_create("elf"); + CuAssertPtrEquals(tc, (void *)rc, (void *)get_race(RC_ELF)); + u_setrace(u, get_race(RC_ELF)); + CuAssertDblEquals(tc, 1.0, u_heal_factor(u), 0.0); + set_param(&rc->parameters, "regen.forest", "1.5"); + CuAssertDblEquals(tc, 1.5, u_heal_factor(u), 0.0); + test_cleanup(); +} + CuSuite *get_unit_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -507,5 +534,6 @@ CuSuite *get_unit_suite(void) SUITE_ADD_TEST(suite, test_limited_skills); SUITE_ADD_TEST(suite, test_renumber_unit); SUITE_ADD_TEST(suite, test_name_unit); + SUITE_ADD_TEST(suite, test_heal_factor); return suite; } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 3d7276bf3..87771ba6b 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1635,7 +1635,7 @@ static int parse_races(xmlDocPtr doc) rc->def_damage = strdup((const char *)propValue); xmlFree(propValue); - rc->_magres = xml_ivalue(node, "magres", rc->_magres); + rc->magres = xml_ivalue(node, "magres", rc->magres); rc->healing = (float)xml_fvalue(node, "healing", rc->healing); rc->maxaura = (float)xml_fvalue(node, "maxaura", rc->maxaura); rc->regaura = (float)xml_fvalue(node, "regaura", rc->regaura); diff --git a/src/laws.c b/src/laws.c index 6b0bfda8d..98ff5d9f6 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3271,30 +3271,6 @@ static int use_item(unit * u, const item_type * itype, int amount, struct order } } -static double heal_factor(const unit * u) -{ - const race * rc = u_race(u); - if (rc->healing>0) { - return rc->healing; - } - if (r_isforest(u->region)) { - static int rc_cache; - static const race *rc_elf; - if (rc_changed(&rc_cache)) { - rc_elf = get_race(RC_ELF); - } - if (rc==rc_elf) { - static int config; - static double elf_regen = 1.0; - if (config_changed(&config)) { - elf_regen = get_param_flt(u_race(u)->parameters, "regen.forest", 1.0F); - } - return elf_regen; - } - } - return 1.0; -} - void monthly_healing(void) { region *r; @@ -3334,7 +3310,7 @@ void monthly_healing(void) continue; } - p *= heal_factor(u); + p *= u_heal_factor(u); if (u->hp < umhp) { double maxheal = MAX(u->number, umhp / 20.0); int addhp; diff --git a/src/magic.test.c b/src/magic.test.c index 29534b33b..b32211fd4 100644 --- a/src/magic.test.c +++ b/src/magic.test.c @@ -413,11 +413,11 @@ static void test_magic_resistance(CuTest *tc) { test_setup(); rc = test_create_race("human"); u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); - CuAssertDblEquals(tc, rc->_magres/100.0, magic_resistance(u), 0.01); - rc->_magres = 100; + CuAssertDblEquals(tc, rc->magres/100.0, magic_resistance(u), 0.01); + rc->magres = 100; CuAssertDblEquals_Msg(tc, "magic resistance is capped at 0.9", 0.9, magic_resistance(u), 0.01); rc = test_create_race("braineater"); - rc->_magres = 100; + rc->magres = 100; u_setrace(u, rc); CuAssertDblEquals_Msg(tc, "brain eaters outside astral space have 50% magres", 0.5, magic_resistance(u), 0.01); u->region->_plane = get_astralplane(); diff --git a/src/tests.c b/src/tests.c index eb2631afe..5c9ce821d 100644 --- a/src/tests.c +++ b/src/tests.c @@ -217,6 +217,9 @@ terrain_type * test_create_terrain(const char * name, unsigned int flags) { terrain_type * t = get_or_create_terrain(name); + if (flags & LAND_REGION) { + t->size = 1000; + } t->flags = flags; return t; } From 1c347ca5ba8e765246435d361e44f9451ddbc94b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 18:18:55 +0100 Subject: [PATCH 474/675] race.healing is now an int percentage, not a float multiplier --- src/kernel/race.h | 2 +- src/kernel/race.test.c | 2 +- src/kernel/unit.c | 2 +- src/kernel/unit.test.c | 4 ++-- src/kernel/xmlreader.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/kernel/race.h b/src/kernel/race.h index 853e1041f..a7d495f6b 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -117,7 +117,7 @@ extern "C" { typedef struct race { char *_name; int magres; - float healing; + int healing; double maxaura; /* Faktor auf Maximale Aura */ double regaura; /* Faktor auf Regeneration */ double recruit_multi; /* Faktor f�r Bauernverbrauch */ diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index c07808099..01ce41443 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -25,7 +25,7 @@ static void test_rc_defaults(CuTest *tc) { CuAssertStrEquals(tc, "human", rc->_name); CuAssertIntEquals(tc, 0, rc->magres); CuAssertDblEquals(tc, 0.0, rc_magres(rc), 0.0); - CuAssertDblEquals(tc, 0.0, rc->healing, 0.0); + CuAssertIntEquals(tc, 0, rc->healing); CuAssertDblEquals(tc, 0.0, rc->maxaura, 0.0); CuAssertDblEquals(tc, 1.0, rc->recruit_multi, 0.0); CuAssertDblEquals(tc, 1.0, rc->regaura, 0.0); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 354a52a06..329a523c6 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -2051,7 +2051,7 @@ double u_heal_factor(const unit * u) { const race * rc = u_race(u); if (rc->healing>0) { - return rc->healing; + return rc->healing / 100.0; } if (r_isforest(u->region)) { static int rc_cache; diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index ad4e1761a..bf4e9a389 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -498,9 +498,9 @@ static void test_heal_factor(CuTest *tc) { rsettrees(r, 2, 0); CuAssertTrue(tc, r_isforest(r)); CuAssertDblEquals(tc, 1.0, u_heal_factor(u), 0.0); - rc->healing = 2.0; + rc->healing = 200; CuAssertDblEquals(tc, 2.0, u_heal_factor(u), 0.0); - rc->healing = 0.0; + rc->healing = 0; rc = rc_get_or_create("elf"); CuAssertPtrEquals(tc, (void *)rc, (void *)get_race(RC_ELF)); u_setrace(u, get_race(RC_ELF)); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 87771ba6b..638dae189 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1636,7 +1636,7 @@ static int parse_races(xmlDocPtr doc) xmlFree(propValue); rc->magres = xml_ivalue(node, "magres", rc->magres); - rc->healing = (float)xml_fvalue(node, "healing", rc->healing); + rc->healing = (int)(xml_fvalue(node, "healing", rc->healing) * 100); // TODO: store as int in XML rc->maxaura = (float)xml_fvalue(node, "maxaura", rc->maxaura); rc->regaura = (float)xml_fvalue(node, "regaura", rc->regaura); rc->recruitcost = xml_ivalue(node, "recruitcost", rc->recruitcost); From f22cc3b419bb1349f46eedd9e35a85e138842c6f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 19:47:30 +0100 Subject: [PATCH 475/675] add a test for max_spellpoints --- src/magic.test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/magic.test.c b/src/magic.test.c index b32211fd4..e2c25bf81 100644 --- a/src/magic.test.c +++ b/src/magic.test.c @@ -425,6 +425,29 @@ static void test_magic_resistance(CuTest *tc) { test_cleanup(); } +static void test_max_spellpoints(CuTest *tc) { + unit *u; + race *rc; + + test_setup(); + rc = test_create_race("human"); + u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); + CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u)); + rc->maxaura = 1.0; + CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u)); + rc->maxaura = 2.0; + CuAssertIntEquals(tc, 2, max_spellpoints(u->region, u)); + create_mage(u, M_GRAY); + set_level(u, SK_MAGIC, 1); + CuAssertIntEquals(tc, 3, max_spellpoints(u->region, u)); + set_level(u, SK_MAGIC, 2); + CuAssertIntEquals(tc, 9, max_spellpoints(u->region, u)); + // permanent aura loss: + CuAssertIntEquals(tc, 7, change_maxspellpoints(u, -2)); + CuAssertIntEquals(tc, 7, max_spellpoints(u->region, u)); + test_cleanup(); +} + CuSuite *get_magic_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -441,5 +464,6 @@ CuSuite *get_magic_suite(void) SUITE_ADD_TEST(suite, test_set_post_combatspell); SUITE_ADD_TEST(suite, test_hasspell); SUITE_ADD_TEST(suite, test_magic_resistance); + SUITE_ADD_TEST(suite, test_max_spellpoints); return suite; } From e51742da9052b018c0fb0020d4652b4045c69940 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 19:50:48 +0100 Subject: [PATCH 476/675] use rc_maxaura wrapper everywhere. --- src/kernel/race.c | 6 +++++- src/kernel/race.h | 1 + src/kernel/race.test.c | 2 +- src/magic.c | 6 +++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/kernel/race.c b/src/kernel/race.c index 16eff8695..75ff16436 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -282,10 +282,14 @@ bool r_insectstalled(const region * r) return fval(r->terrain, ARCTIC_REGION); } -double rc_magres(const struct race *rc) { +double rc_magres(const race *rc) { return rc->magres / 100.0; } +double rc_maxaura(const race *rc) { + return rc->maxaura; +} + const char* rc_name(const race * rc, name_t n, char *name, size_t size) { const char * postfix = 0; if (!rc) { diff --git a/src/kernel/race.h b/src/kernel/race.h index a7d495f6b..7acc7fea5 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -185,6 +185,7 @@ extern "C" { const char * rc_name(const race *rc, name_t n, char *name, size_t size); double rc_magres(const struct race *rc); + double rc_maxaura(const struct race *rc); /* Flags. Do not reorder these without changing json_race() in jsonconf.c */ #define RCF_NPC (1<<0) /* cannot be the race for a player faction (and other limits?) */ #define RCF_KILLPEASANTS (1<<1) /* a monster that eats peasants */ diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index 01ce41443..eaf497168 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -26,7 +26,7 @@ static void test_rc_defaults(CuTest *tc) { CuAssertIntEquals(tc, 0, rc->magres); CuAssertDblEquals(tc, 0.0, rc_magres(rc), 0.0); CuAssertIntEquals(tc, 0, rc->healing); - CuAssertDblEquals(tc, 0.0, rc->maxaura, 0.0); + CuAssertDblEquals(tc, 0.0, rc_maxaura(rc), 0.0); CuAssertDblEquals(tc, 1.0, rc->recruit_multi, 0.0); CuAssertDblEquals(tc, 1.0, rc->regaura, 0.0); CuAssertDblEquals(tc, 1.0, rc->speed, 0.0); diff --git a/src/magic.c b/src/magic.c index e48ec6d5d..89774e96a 100644 --- a/src/magic.c +++ b/src/magic.c @@ -719,7 +719,7 @@ static int use_item_aura(const region * r, const unit * u) int sk, n; sk = effskill(u, SK_MAGIC, r); - n = (int)(sk * sk * u_race(u)->maxaura / 4); + n = (int)(sk * sk * rc_maxaura(u_race(u)) / 4); return n; } @@ -727,13 +727,13 @@ static int use_item_aura(const region * r, const unit * u) int max_spellpoints(const region * r, const unit * u) { int sk; - double n, msp; + double n, msp = 0; double potenz = 2.1; double divisor = 1.2; const struct resource_type *rtype; sk = effskill(u, SK_MAGIC, r); - msp = u_race(u)->maxaura * (pow(sk, potenz) / divisor + 1) + get_spchange(u); + msp = rc_maxaura(u_race(u)) * (pow(sk, potenz) / divisor + 1) + get_spchange(u); rtype = rt_find("aurafocus"); if (rtype && i_get(u->items, rtype->itype) > 0) { From 250227cad245707c8ed17857eabb9143c6b6ca07 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 20:06:01 +0100 Subject: [PATCH 477/675] store maxaura as an integer, not a float. --- src/kernel/jsonconf.c | 2 +- src/kernel/jsonconf.test.c | 5 +++-- src/kernel/race.c | 2 +- src/kernel/race.h | 2 +- src/kernel/xmlreader.c | 2 +- src/magic.test.c | 4 ++-- src/tests.c | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index dcc4c9c0c..7a074a410 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -461,7 +461,7 @@ static void json_race(cJSON *json, race *rc) { rc->magres = child->valueint; } else if (strcmp(child->string, "maxaura") == 0) { - rc->maxaura = (float)child->valuedouble; + rc->maxaura = child->valueint; } else if (strcmp(child->string, "regaura") == 0) { rc->regaura = (float)child->valuedouble; diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 5b0590bf8..7c591f075 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -137,7 +137,7 @@ static void test_races(CuTest * tc) const char * data = "{\"races\": { \"orc\" : { " "\"damage\" : \"1d4\"," "\"magres\" : 100," - "\"maxaura\" : 2.0," + "\"maxaura\" : 200," "\"regaura\" : 3.0," "\"speed\" : 4.0," "\"recruitcost\" : 1," @@ -165,7 +165,8 @@ static void test_races(CuTest * tc) CuAssertStrEquals(tc, "1d4", rc->def_damage); CuAssertIntEquals(tc, 100, rc->magres); CuAssertDblEquals(tc, 1.0, rc_magres(rc), 0.0); - CuAssertDblEquals(tc, 2.0, rc->maxaura, 0.0); + CuAssertIntEquals(tc, 200, rc->maxaura); + CuAssertDblEquals(tc, 2.0, rc_maxaura(rc), 0.0); CuAssertDblEquals(tc, 3.0, rc->regaura, 0.0); CuAssertDblEquals(tc, 4.0, rc->speed, 0.0); CuAssertIntEquals(tc, 1, rc->recruitcost); diff --git a/src/kernel/race.c b/src/kernel/race.c index 75ff16436..59d263108 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -287,7 +287,7 @@ double rc_magres(const race *rc) { } double rc_maxaura(const race *rc) { - return rc->maxaura; + return rc->maxaura / 100.0; } const char* rc_name(const race * rc, name_t n, char *name, size_t size) { diff --git a/src/kernel/race.h b/src/kernel/race.h index 7acc7fea5..82d8cdf69 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -118,7 +118,7 @@ extern "C" { char *_name; int magres; int healing; - double maxaura; /* Faktor auf Maximale Aura */ + int maxaura; /* Faktor auf Maximale Aura */ double regaura; /* Faktor auf Regeneration */ double recruit_multi; /* Faktor f�r Bauernverbrauch */ int index; diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 638dae189..d75a6583f 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1637,7 +1637,7 @@ static int parse_races(xmlDocPtr doc) rc->magres = xml_ivalue(node, "magres", rc->magres); rc->healing = (int)(xml_fvalue(node, "healing", rc->healing) * 100); // TODO: store as int in XML - rc->maxaura = (float)xml_fvalue(node, "maxaura", rc->maxaura); + rc->maxaura = (int)(xml_fvalue(node, "maxaura", rc->maxaura) * 100); // TODO: store as int in XML rc->regaura = (float)xml_fvalue(node, "regaura", rc->regaura); rc->recruitcost = xml_ivalue(node, "recruitcost", rc->recruitcost); rc->maintenance = xml_ivalue(node, "maintenance", rc->maintenance); diff --git a/src/magic.test.c b/src/magic.test.c index e2c25bf81..4a6078589 100644 --- a/src/magic.test.c +++ b/src/magic.test.c @@ -433,9 +433,9 @@ static void test_max_spellpoints(CuTest *tc) { rc = test_create_race("human"); u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u)); - rc->maxaura = 1.0; + rc->maxaura = 100; CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u)); - rc->maxaura = 2.0; + rc->maxaura = 200; CuAssertIntEquals(tc, 2, max_spellpoints(u->region, u)); create_mage(u, M_GRAY); set_level(u, SK_MAGIC, 1); diff --git a/src/tests.c b/src/tests.c index 5c9ce821d..6a43e6e79 100644 --- a/src/tests.c +++ b/src/tests.c @@ -40,7 +40,7 @@ struct race *test_create_race(const char *name) race *rc = rc_get_or_create(name); rc->maintenance = 10; rc->hitpoints = 20; - rc->maxaura = 1.0; + rc->maxaura = 100; rc->ec_flags |= GETITEM; rc->battle_flags = BF_EQUIPMENT; return rc; From 70b12ae6ca9fc34ed124db53d8e1b41a78736e16 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 20:16:44 +0100 Subject: [PATCH 478/675] refactor handling of race.param in XML --- src/kernel/faction.c | 2 +- src/kernel/xmlreader.c | 23 +++++++++++------------ src/upkeep.c | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/kernel/faction.c b/src/kernel/faction.c index b7115c62f..e3cb4508a 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -758,7 +758,7 @@ int count_migrants(const faction * f) int count_maxmigrants(const faction * f) { - int formula = get_param_int(f->race->parameters, "migrants.formula", 0); + int formula = f->race->parameters ? get_param_int(f->race->parameters, "migrants.formula", MIGRANTS_NONE) : MIGRANTS_NONE; if (formula == MIGRANTS_LOG10) { int nsize = count_all(f); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index d75a6583f..9b1f5532c 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1573,17 +1573,6 @@ static int parse_spells(xmlDocPtr doc) return 0; } -static void parse_param(struct param **params, xmlNodePtr node) -{ - xmlChar *propName = xmlGetProp(node, BAD_CAST "name"); - xmlChar *propValue = xmlGetProp(node, BAD_CAST "value"); - - set_param(params, (const char *)propName, (const char *)propValue); - - xmlFree(propName); - xmlFree(propValue); -} - static void parse_ai(race * rc, xmlNodePtr node) { int n; @@ -1737,12 +1726,22 @@ static int parse_races(xmlDocPtr doc) if (xml_bvalue(node, "noattack", false)) rc->battle_flags |= BF_NO_ATTACK; + rc->recruit_multi = 1.0; for (child = node->children; child; child = child->next) { if (strcmp((const char *)child->name, "ai") == 0) { parse_ai(rc, child); } else if (strcmp((const char *)child->name, "param") == 0) { - parse_param(&rc->parameters, child); + xmlChar *propName = xmlGetProp(child, BAD_CAST "name"); + xmlChar *propValue = xmlGetProp(child, BAD_CAST "value"); + if (strcmp((const char *)propName, "recruit_multi")==0) { + rc->recruit_multi = atof((const char *)propValue); + } + else { + set_param(&rc->parameters, (const char *)propName, (const char *)propValue); + } + xmlFree(propName); + xmlFree(propValue); } } rc->recruit_multi = get_param_flt(rc->parameters, "recruit_multi", 1.0); diff --git a/src/upkeep.c b/src/upkeep.c index 94cbc341d..c53c321d0 100644 --- a/src/upkeep.c +++ b/src/upkeep.c @@ -59,7 +59,7 @@ static void help_feed(unit * donor, unit * u, int *need_p) } static const char *hunger_damage(const race *rc) { - const char * damage = get_param(rc->parameters, "hunger.damage"); + const char * damage = rc->parameters ? get_param(rc->parameters, "hunger.damage") : NULL; if (!damage) { damage = config_get("hunger.damage"); } From bb37e423e1f434d2b8c707d9e4b5f16d8cc7c0de Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 20:35:15 +0100 Subject: [PATCH 479/675] use UFL_FOLLOWED for optimization. --- src/move.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/move.c b/src/move.c index 0184d22ca..f06a0b901 100644 --- a/src/move.c +++ b/src/move.c @@ -2061,7 +2061,9 @@ static const region_list *travel_i(unit * u, const region_list * route_begin, route_end = cap_route(r, route_begin, route_end, movement_speed(u)); route_end = travel_route(u, route_begin, route_end, ord, mode); - get_followers(u, r, route_end, followers); + if (u->flags&UFL_FOLLOWED) { + get_followers(u, r, route_end, followers); + } /* transportation */ for (ord = u->orders; ord; ord = ord->next) { From 644a6019a62382246aee125c15f8d702acf0f094 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 21:19:39 +0100 Subject: [PATCH 480/675] do not call isdigit with a negative value. http://bugs.eressea.de/view.php?id=1987#c6941 --- src/spy.c | 2 +- src/util/base36.c | 4 ++-- src/util/dice.c | 2 +- src/util/parser.c | 4 ++-- src/util/translation.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/spy.c b/src/spy.c index eb58f792a..0ca3050c2 100644 --- a/src/spy.c +++ b/src/spy.c @@ -229,7 +229,7 @@ int setstealth_cmd(unit * u, struct order *ord) return 0; } - if (isdigit(s[0])) { + if (isdigit(*(const unsigned char *)s)) { /* Tarnungslevel setzen */ level = atoi((const char *)s); if (level > effskill(u, SK_STEALTH, 0)) { diff --git a/src/util/base36.c b/src/util/base36.c index 7edb46027..285e9760e 100644 --- a/src/util/base36.c +++ b/src/util/base36.c @@ -39,9 +39,9 @@ int atoi36(const char *str) while (isalnum(*(unsigned char *)s)) { if (isupper(*(unsigned char *)s)) i = i * 36 + (*s) - 'A' + 10; - else if (islower(*(unsigned char *)s)) + else if (islower(*s)) i = i * 36 + (*s) - 'a' + 10; - else if (isdigit(*(unsigned char *)s)) + else if (isdigit(*s)) i = i * 36 + (*s) - '0'; else break; diff --git a/src/util/dice.c b/src/util/dice.c index e28a4bccd..6fa50261d 100644 --- a/src/util/dice.c +++ b/src/util/dice.c @@ -49,7 +49,7 @@ static int term_eval(const char **sptr) int state = 1; for (;;) { - if (isdigit(*(unsigned char *)c)) { + if (isdigit(*(const unsigned char *)c)) { k = k * 10 + (*c - '0'); } else if (*c == '+' || *c == '-' || *c == 0 || *c == '*' || *c == ')' diff --git a/src/util/parser.c b/src/util/parser.c index bbdb5ac7e..fca066cb1 100644 --- a/src/util/parser.c +++ b/src/util/parser.c @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -251,7 +250,8 @@ unsigned int atoip(const char *s) int n; assert(s); - n = isdigit(s[0]) ? atoi(s) : 0; + n = (s[0] >='0' && s[0]<='9'); + n = n ? atoi(s) : 0; if (n < 0) n = 0; diff --git a/src/util/translation.c b/src/util/translation.c index c733cc272..fb89a5af9 100644 --- a/src/util/translation.c +++ b/src/util/translation.c @@ -354,7 +354,7 @@ static const char *parse(opstack ** stack, const char *inn, return parse_symbol(stack, ++b, userdata); break; default: - if (isdigit(*(unsigned char *)b) || *b == '-' || *b == '+') { + if (isdigit(*(const unsigned char *)b) || *b == '-' || *b == '+') { return parse_int(stack, b); } else From 2be1868ff0471a9278abf510f6ac02756178286a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 21:48:03 +0100 Subject: [PATCH 481/675] Antiemagiekristall Meldung geht an die Region. Nicht nur an die Partei, die es zaubert. http://bugs.eressea.de/view.php?id=1987 --- res/core/messages.xml | 5 ++--- src/items.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 6892ec4e5..c28670d65 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -1910,10 +1910,9 @@ - - "$unit($unit) benutzt in $region($region) einen Antimagiekristall." - "$unit($unit) uses an antimagic crystal in $region($region)." + "$unit($unit) benutzt einen Antimagiekristall." + "$unit($unit) uses an antimagic crystal." diff --git a/src/items.c b/src/items.c index 6e995edaa..bb5009038 100644 --- a/src/items.c +++ b/src/items.c @@ -167,8 +167,7 @@ struct order *ord) } } use_pooled(u, rt_crystal, GET_DEFAULT, amount); - ADDMSG(&u->faction->msgs, msg_message("use_antimagiccrystal", - "unit region", u, r)); + ADDMSG(&u->region->msgs, msg_message("use_antimagiccrystal", "unit", u)); return 0; } From 2ecbf89f1a6e4145956e416007a8d22e771aaed3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 4 Feb 2017 23:16:16 +0100 Subject: [PATCH 482/675] clean up and test various race.parameters --- src/battle.c | 6 +----- src/battle.test.c | 3 +++ src/kernel/faction.c | 5 +---- src/kernel/faction.test.c | 21 ++++++++++++++++++++- src/kernel/race.c | 9 +++++++++ src/kernel/race.h | 6 ++++++ src/kernel/race.test.c | 1 + src/market.c | 4 ++-- src/market.h | 4 ++++ src/market.test.c | 14 ++++++++++++++ 10 files changed, 61 insertions(+), 12 deletions(-) diff --git a/src/battle.c b/src/battle.c index ad613a69f..9316d35dd 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1014,17 +1014,13 @@ static void vampirism(troop at, int damage) #define MAXRACES 128 -static int armor_bonus(const race *rc) { - return get_param_int(rc->parameters, "armor.stamina", -1); -} - int natural_armor(unit * du) { const race *rc = u_race(du); int an; assert(rc); - an = armor_bonus(rc); + an = rc_armor_bonus(rc); if (an > 0) { int sk = effskill(du, SK_STAMINA, 0); return rc->armor + sk / an; diff --git a/src/battle.test.c b/src/battle.test.c index 03535e16e..e8187c772 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -223,10 +223,13 @@ static void test_natural_armor(CuTest * tc) rc = test_create_race("human"); u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); set_level(u, SK_STAMINA, 2); + CuAssertIntEquals(tc, 0, rc_armor_bonus(rc)); CuAssertIntEquals(tc, 0, natural_armor(u)); set_param(&rc->parameters, "armor.stamina", "1"); + CuAssertIntEquals(tc, 1, rc_armor_bonus(rc)); CuAssertIntEquals(tc, 2, natural_armor(u)); set_param(&rc->parameters, "armor.stamina", "2"); + CuAssertIntEquals(tc, 2, rc_armor_bonus(rc)); CuAssertIntEquals(tc, 1, natural_armor(u)); test_cleanup(); } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index e3cb4508a..1c8ff4cb8 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -753,12 +753,9 @@ int count_migrants(const faction * f) return count_faction(f, COUNT_MIGRANTS); } -#define MIGRANTS_NONE 0 -#define MIGRANTS_LOG10 1 - int count_maxmigrants(const faction * f) { - int formula = f->race->parameters ? get_param_int(f->race->parameters, "migrants.formula", MIGRANTS_NONE) : MIGRANTS_NONE; + int formula = rc_migrants_formula(f->race); if (formula == MIGRANTS_LOG10) { int nsize = count_all(f); diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index b18121e2d..43956df59 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -3,9 +3,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include @@ -191,9 +192,27 @@ static void test_set_origin_bug(CuTest *tc) { test_cleanup(); } +static void test_max_migrants(CuTest *tc) { + faction *f; + unit *u; + race *rc; + + test_setup(); + rc = test_create_race("human"); + f = test_create_faction(rc); + u = test_create_unit(f, test_create_region(0, 0, 0)); + CuAssertIntEquals(tc, 0, count_maxmigrants(f)); + set_param(&rc->parameters, "migrants.formula", "1"); + CuAssertIntEquals(tc, 0, count_maxmigrants(f)); + scale_number(u, 250); + CuAssertIntEquals(tc, 13, count_maxmigrants(f)); + test_cleanup(); +} + CuSuite *get_faction_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_max_migrants); SUITE_ADD_TEST(suite, test_addfaction); SUITE_ADD_TEST(suite, test_remove_empty_factions); SUITE_ADD_TEST(suite, test_destroyfaction_allies); diff --git a/src/kernel/race.c b/src/kernel/race.c index 59d263108..123d64022 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -290,6 +290,15 @@ double rc_maxaura(const race *rc) { return rc->maxaura / 100.0; } +int rc_armor_bonus(const race *rc) { + return get_param_int(rc->parameters, "armor.stamina", 0); +} + +int rc_migrants_formula(const race *rc) +{ + return rc->parameters ? get_param_int(rc->parameters, "migrants.formula", MIGRANTS_NONE) : MIGRANTS_NONE; +} + const char* rc_name(const race * rc, name_t n, char *name, size_t size) { const char * postfix = 0; if (!rc) { diff --git a/src/kernel/race.h b/src/kernel/race.h index 82d8cdf69..7c4600ae5 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -186,6 +186,12 @@ extern "C" { double rc_magres(const struct race *rc); double rc_maxaura(const struct race *rc); + int rc_armor_bonus(const struct race *rc); + +#define MIGRANTS_NONE 0 +#define MIGRANTS_LOG10 1 + int rc_migrants_formula(const race *rc); + /* Flags. Do not reorder these without changing json_race() in jsonconf.c */ #define RCF_NPC (1<<0) /* cannot be the race for a player faction (and other limits?) */ #define RCF_KILLPEASANTS (1<<1) /* a monster that eats peasants */ diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index eaf497168..b730676a4 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -23,6 +23,7 @@ static void test_rc_defaults(CuTest *tc) { test_setup(); rc = rc_get_or_create("human"); CuAssertStrEquals(tc, "human", rc->_name); + CuAssertIntEquals(tc, 0, rc_armor_bonus(rc)); CuAssertIntEquals(tc, 0, rc->magres); CuAssertDblEquals(tc, 0.0, rc_magres(rc), 0.0); CuAssertIntEquals(tc, 0, rc->healing); diff --git a/src/market.c b/src/market.c index 42819325f..254d3a483 100644 --- a/src/market.c +++ b/src/market.c @@ -66,7 +66,7 @@ attrib_type at_market = { NULL, NULL, NULL, ATF_UNIQUE }; -static int rc_luxury_trade(const struct race *rc) +int rc_luxury_trade(const struct race *rc) { if (rc) { return get_param_int(rc->parameters, "luxury_trade", 1000); @@ -74,7 +74,7 @@ static int rc_luxury_trade(const struct race *rc) return 1000; } -static int rc_herb_trade(const struct race *rc) +int rc_herb_trade(const struct race *rc) { if (rc) { return get_param_int(rc->parameters, "herb_trade", 500); diff --git a/src/market.h b/src/market.h index 74dc8db17..8f1d39eb4 100644 --- a/src/market.h +++ b/src/market.h @@ -19,10 +19,14 @@ without prior permission by the authors of Eressea. extern "C" { #endif struct building; + struct race; bool markets_module(void); void do_markets(void); + int rc_luxury_trade(const struct race *rc); + int rc_herb_trade(const struct race *rc); + #ifdef __cplusplus } #endif diff --git a/src/market.test.c b/src/market.test.c index 6f1d74b88..1e0195a57 100644 --- a/src/market.test.c +++ b/src/market.test.c @@ -80,9 +80,23 @@ static void test_market_curse(CuTest * tc) CuAssertIntEquals(tc, 35, i_get(u->items, ltype)); } +static void test_rc_trade(CuTest *tc) { + race *rc; + test_setup(); + rc = test_create_race("human"); + CuAssertIntEquals(tc, 1000, rc_luxury_trade(rc)); + CuAssertIntEquals(tc, 500, rc_herb_trade(rc)); + set_param(&rc->parameters, "luxury_trade", "100"); + set_param(&rc->parameters, "herb_trade", "50"); + CuAssertIntEquals(tc, 100, rc_luxury_trade(rc)); + CuAssertIntEquals(tc, 50, rc_herb_trade(rc)); + test_cleanup(); +} + CuSuite *get_market_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_market_curse); + SUITE_ADD_TEST(suite, test_rc_trade); return suite; } From 3b3e39a3192953e63281b5c7ce00972d20a6930f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 4 Feb 2017 23:21:36 +0100 Subject: [PATCH 483/675] optimization: elf-special "regen.forest" is now a config. this is an E3 feature eliminates rc.parameters for elves allows use of a local cached static --- conf/e3/config.json | 1 + res/e3a/races.xml | 1 - src/kernel/unit.c | 7 ++++--- src/kernel/unit.test.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/conf/e3/config.json b/conf/e3/config.json index 8783055b8..1cecc89d2 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -42,6 +42,7 @@ "nmr.timeout": 5, "nmr.removenewbie": 0, "GiveRestriction": 3, + "healing.forest": 2.0, "hunger.long": false, "hunger.damage": "1d9+9", "hunger.demons.skill": true, diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 3402fdb73..4fcc76e4f 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -127,7 +127,6 @@ - diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 329a523c6..27a296a15 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -2060,9 +2060,10 @@ double u_heal_factor(const unit * u) rc_elf = get_race(RC_ELF); } if (rc == rc_elf) { - double elf_regen = 1.0; - if (rc->parameters) { - elf_regen = get_param_flt(rc->parameters, "regen.forest", elf_regen); + static int cache; + static double elf_regen; + if (config_changed(&cache)) { + elf_regen = config_get_flt("healing.forest", 1.0); } return elf_regen; } diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index bf4e9a389..1ddf6282e 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -505,7 +505,7 @@ static void test_heal_factor(CuTest *tc) { CuAssertPtrEquals(tc, (void *)rc, (void *)get_race(RC_ELF)); u_setrace(u, get_race(RC_ELF)); CuAssertDblEquals(tc, 1.0, u_heal_factor(u), 0.0); - set_param(&rc->parameters, "regen.forest", "1.5"); + config_set("healing.forest", "1.5"); CuAssertDblEquals(tc, 1.5, u_heal_factor(u), 0.0); test_cleanup(); } From bdb50eab7545e76c686416ed8579ad8b391f809c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 4 Feb 2017 23:42:50 +0100 Subject: [PATCH 484/675] make migrants.formula a flag. lookup in race.parameters was slow. there is only one formula, anyhow. --- src/kernel/faction.c | 2 +- src/kernel/faction.test.c | 2 +- src/kernel/race.c | 2 +- src/kernel/race.h | 1 + src/kernel/xmlreader.c | 5 +++++ 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 1c8ff4cb8..28ac2e203 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -565,7 +565,7 @@ bool valid_race(const struct faction *f, const struct race *rc) else { const char *str = get_param(f->race->parameters, "other_race"); if (str) - return (bool)(rc_find(str) == rc); + return rc_find(str) == rc; return false; } } diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 43956df59..1b1a0236b 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -202,7 +202,7 @@ static void test_max_migrants(CuTest *tc) { f = test_create_faction(rc); u = test_create_unit(f, test_create_region(0, 0, 0)); CuAssertIntEquals(tc, 0, count_maxmigrants(f)); - set_param(&rc->parameters, "migrants.formula", "1"); + rc->flags |= RCF_MIGRANTS; CuAssertIntEquals(tc, 0, count_maxmigrants(f)); scale_number(u, 250); CuAssertIntEquals(tc, 13, count_maxmigrants(f)); diff --git a/src/kernel/race.c b/src/kernel/race.c index 123d64022..7f6fe15c2 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -296,7 +296,7 @@ int rc_armor_bonus(const race *rc) { int rc_migrants_formula(const race *rc) { - return rc->parameters ? get_param_int(rc->parameters, "migrants.formula", MIGRANTS_NONE) : MIGRANTS_NONE; + return (rc->flags&RCF_MIGRANTS) ? MIGRANTS_LOG10 : MIGRANTS_NONE; } const char* rc_name(const race * rc, name_t n, char *name, size_t size) { diff --git a/src/kernel/race.h b/src/kernel/race.h index 7c4600ae5..67eea00f4 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -223,6 +223,7 @@ extern "C" { #define RCF_STONEGOLEM (1<<27) /* race gets stonegolem properties */ #define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */ #define RCF_ATTACK_MOVED (1<<29) /* may attack if it has moved */ +#define RCF_MIGRANTS (1<<30) /* may have migrant units (human bonus) */ /* Economic flags */ #define ECF_KEEP_ITEM (1<<1) /* gibt Gegenst�nde weg */ diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 9b1f5532c..a0172313a 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1737,6 +1737,11 @@ static int parse_races(xmlDocPtr doc) if (strcmp((const char *)propName, "recruit_multi")==0) { rc->recruit_multi = atof((const char *)propValue); } + else if (strcmp((const char *)propName, "migrants.formula") == 0) { + if (propValue[0] == '1') { + rc->flags |= RCF_MIGRANTS; + } + } else { set_param(&rc->parameters, (const char *)propName, (const char *)propValue); } From 0b3d15f4b3deb5f6d62df40ef9176eb28359f5fa Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 4 Feb 2017 23:46:26 +0100 Subject: [PATCH 485/675] eliminate unused other_cost parameter. cost of other races is defined by their recruitcost. --- res/e3a/races.xml | 3 --- res/races/goblin-2.xml | 1 - res/races/goblin-3.xml | 1 - src/economy.c | 1 - 4 files changed, 6 deletions(-) diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 4fcc76e4f..7e75f3fd4 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -36,7 +36,6 @@ - @@ -51,7 +50,6 @@ - @@ -80,7 +78,6 @@ - diff --git a/res/races/goblin-2.xml b/res/races/goblin-2.xml index ae90c1918..f8964d7c0 100644 --- a/res/races/goblin-2.xml +++ b/res/races/goblin-2.xml @@ -8,7 +8,6 @@ getitem="yes" equipment="yes" healing="2.0"> - diff --git a/res/races/goblin-3.xml b/res/races/goblin-3.xml index aa0c8fddb..4ad83967d 100644 --- a/res/races/goblin-3.xml +++ b/res/races/goblin-3.xml @@ -8,7 +8,6 @@ getitem="yes" equipment="yes" healing="2.0"> - diff --git a/src/economy.c b/src/economy.c index 16b201555..2d9fe6666 100644 --- a/src/economy.c +++ b/src/economy.c @@ -427,7 +427,6 @@ static int recruit_cost(const faction * f, const race * rc) } else if (valid_race(f, rc)) { return rc->recruitcost; - /* return get_param_int(f->race->parameters, "other_cost", -1); */ } return -1; } From 117d37e2ea61040f63d6766b73952c522d7c59ac Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Feb 2017 14:48:43 +0100 Subject: [PATCH 486/675] do not specify rules at command line. it is in eressea.ini --- s/preview | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s/preview b/s/preview index 1e5d0db48..0c1467627 100755 --- a/s/preview +++ b/s/preview @@ -81,7 +81,7 @@ VALGRIND=$(which valgrind) if [ ! -z $VALGRIND ]; then SERVER="$VALGRIND --suppressions=$SUPP --error-exitcode=1 --leak-check=no $SERVER" fi -$SERVER -v$verbose -t$turn -re$game $SOURCE/scripts/run-turn.lua +$SERVER -v$verbose -t$turn $SOURCE/scripts/run-turn.lua let turn=$turn+1 [ -e data/$turn.dat ] || abort "no data file created" } From bd836b76e10f2e4dbd8d913d4129b94c32026866 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Feb 2017 16:55:51 +0100 Subject: [PATCH 487/675] channel XML race.parameters through a single, tested, function --- src/battle.test.c | 4 ++-- src/economy.c | 5 +---- src/kernel/faction.c | 13 +++++++++---- src/kernel/faction.test.c | 17 +++++++++++++++++ src/kernel/race.c | 14 ++++++++++++++ src/kernel/race.h | 2 ++ src/kernel/race.test.c | 16 ++++++++++++++++ src/kernel/xmlreader.c | 12 +----------- src/market.test.c | 4 ++-- 9 files changed, 64 insertions(+), 23 deletions(-) diff --git a/src/battle.test.c b/src/battle.test.c index e8187c772..946d5fcee 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -225,10 +225,10 @@ static void test_natural_armor(CuTest * tc) set_level(u, SK_STAMINA, 2); CuAssertIntEquals(tc, 0, rc_armor_bonus(rc)); CuAssertIntEquals(tc, 0, natural_armor(u)); - set_param(&rc->parameters, "armor.stamina", "1"); + rc_set_param(rc, "armor.stamina", "1"); CuAssertIntEquals(tc, 1, rc_armor_bonus(rc)); CuAssertIntEquals(tc, 2, natural_armor(u)); - set_param(&rc->parameters, "armor.stamina", "2"); + rc_set_param(rc, "armor.stamina", "2"); CuAssertIntEquals(tc, 2, rc_armor_bonus(rc)); CuAssertIntEquals(tc, 1, natural_armor(u)); test_cleanup(); diff --git a/src/economy.c b/src/economy.c index 2d9fe6666..dcbc7431e 100644 --- a/src/economy.c +++ b/src/economy.c @@ -422,10 +422,7 @@ static void expandrecruit(region * r, request * recruitorders) static int recruit_cost(const faction * f, const race * rc) { - if (is_monsters(f) || f->race == rc) { - return rc->recruitcost; - } - else if (valid_race(f, rc)) { + if (is_monsters(f) || valid_race(f, rc)) { return rc->recruitcost; } return -1; diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 28ac2e203..30a623e44 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -558,15 +558,20 @@ void faction_setpassword(faction * f, const char *pwhash) f->_password = strdup(pwhash); } +const race *other_race(const race *rc) { + if (rc->parameters) { + const char *str = get_param(rc->parameters, "other_race"); + return str ? rc_find(str) : NULL; + } + return NULL; +} + bool valid_race(const struct faction *f, const struct race *rc) { if (f->race == rc) return true; else { - const char *str = get_param(f->race->parameters, "other_race"); - if (str) - return rc_find(str) == rc; - return false; + return other_race(f->race) == rc; } } diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 1b1a0236b..c01731964 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -209,6 +209,22 @@ static void test_max_migrants(CuTest *tc) { test_cleanup(); } +static void test_valid_race(CuTest *tc) { + race * rc1, *rc2; + faction *f; + + test_setup(); + rc1 = test_create_race("human"); + rc2 = test_create_race("elf"); + f = test_create_faction(rc1); + CuAssertTrue(tc, valid_race(f, rc1)); + CuAssertTrue(tc, !valid_race(f, rc2)); + rc_set_param(rc1, "other_race", "elf"); + CuAssertTrue(tc, valid_race(f, rc1)); + CuAssertTrue(tc, valid_race(f, rc2)); + test_cleanup(); +} + CuSuite *get_faction_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -222,5 +238,6 @@ CuSuite *get_faction_suite(void) SUITE_ADD_TEST(suite, test_set_origin); SUITE_ADD_TEST(suite, test_set_origin_bug); SUITE_ADD_TEST(suite, test_check_passwd); + SUITE_ADD_TEST(suite, test_valid_race); return suite; } diff --git a/src/kernel/race.c b/src/kernel/race.c index 7f6fe15c2..0e9371e39 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -299,6 +299,20 @@ int rc_migrants_formula(const race *rc) return (rc->flags&RCF_MIGRANTS) ? MIGRANTS_LOG10 : MIGRANTS_NONE; } +void rc_set_param(struct race *rc, const char *key, const char *value) { + if (strcmp(key, "recruit_multi") == 0) { + rc->recruit_multi = atof(value); + } + else if (strcmp(key, "migrants.formula") == 0) { + if (value[0] == '1') { + rc->flags |= RCF_MIGRANTS; + } + } + else { + set_param(&rc->parameters, key, value); + } +} + const char* rc_name(const race * rc, name_t n, char *name, size_t size) { const char * postfix = 0; if (!rc) { diff --git a/src/kernel/race.h b/src/kernel/race.h index 67eea00f4..b500ed6a1 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -184,6 +184,8 @@ extern "C" { const char * rc_name_s(const race *rc, name_t n); const char * rc_name(const race *rc, name_t n, char *name, size_t size); + void rc_set_param(struct race *rc, const char *key, const char *value); + double rc_magres(const struct race *rc); double rc_maxaura(const struct race *rc); int rc_armor_bonus(const struct race *rc); diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index b730676a4..132457cb4 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -84,6 +84,21 @@ static void test_old_race(CuTest *tc) test_cleanup(); } +static void test_rc_set_param(CuTest *tc) { + race *rc; + test_setup(); + rc = test_create_race("human"); + CuAssertPtrEquals(tc, NULL, rc->parameters); + rc_set_param(rc, "hodor", "HODOR"); + CuAssertStrEquals(tc, "HODOR", get_param(rc->parameters, "hodor")); + rc_set_param(rc, "recruit_multi", "0.5"); + CuAssertDblEquals(tc, 0.5, rc->recruit_multi, 0.0); + rc_set_param(rc, "migrants.formula", "1"); + CuAssertIntEquals(tc, RCF_MIGRANTS, rc->flags&RCF_MIGRANTS); + CuAssertIntEquals(tc, MIGRANTS_LOG10, rc_migrants_formula(rc)); + test_cleanup(); +} + CuSuite *get_race_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -92,6 +107,7 @@ CuSuite *get_race_suite(void) SUITE_ADD_TEST(suite, test_rc_name); SUITE_ADD_TEST(suite, test_rc_defaults); SUITE_ADD_TEST(suite, test_rc_find); + SUITE_ADD_TEST(suite, test_rc_set_param); return suite; } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index a0172313a..c07e19809 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1734,17 +1734,7 @@ static int parse_races(xmlDocPtr doc) else if (strcmp((const char *)child->name, "param") == 0) { xmlChar *propName = xmlGetProp(child, BAD_CAST "name"); xmlChar *propValue = xmlGetProp(child, BAD_CAST "value"); - if (strcmp((const char *)propName, "recruit_multi")==0) { - rc->recruit_multi = atof((const char *)propValue); - } - else if (strcmp((const char *)propName, "migrants.formula") == 0) { - if (propValue[0] == '1') { - rc->flags |= RCF_MIGRANTS; - } - } - else { - set_param(&rc->parameters, (const char *)propName, (const char *)propValue); - } + rc_set_param(rc, (const char *)propName, (const char *)propValue); xmlFree(propName); xmlFree(propValue); } diff --git a/src/market.test.c b/src/market.test.c index 1e0195a57..b4d5f05f5 100644 --- a/src/market.test.c +++ b/src/market.test.c @@ -86,8 +86,8 @@ static void test_rc_trade(CuTest *tc) { rc = test_create_race("human"); CuAssertIntEquals(tc, 1000, rc_luxury_trade(rc)); CuAssertIntEquals(tc, 500, rc_herb_trade(rc)); - set_param(&rc->parameters, "luxury_trade", "100"); - set_param(&rc->parameters, "herb_trade", "50"); + rc_set_param(rc, "luxury_trade", "100"); + rc_set_param(rc, "herb_trade", "50"); CuAssertIntEquals(tc, 100, rc_luxury_trade(rc)); CuAssertIntEquals(tc, 50, rc_herb_trade(rc)); test_cleanup(); From f2ed2c892ab535b2567a39009d3825cbd0a1a0e6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Feb 2017 18:38:53 +0100 Subject: [PATCH 488/675] bugfix: Drachen "scare" attribut muss mit MOD, nicht AND angewendet werden. rng_int() & 400 ist eine bekloppte Rechnung. --- src/kernel/race.c | 10 +++++++++- src/kernel/race.h | 1 + src/monsters.c | 18 +++++++++--------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/kernel/race.c b/src/kernel/race.c index 0e9371e39..4dc347751 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -48,6 +48,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include /* attrib includes */ +#include #include /* libc includes */ @@ -290,10 +291,17 @@ double rc_maxaura(const race *rc) { return rc->maxaura / 100.0; } -int rc_armor_bonus(const race *rc) { +int rc_armor_bonus(const race *rc) +{ return get_param_int(rc->parameters, "armor.stamina", 0); } +int rc_scare(const struct race *rc) +{ + attrib *a = a_find(rc->attribs, &at_scare); + return a ? a->data.i : 0; +} + int rc_migrants_formula(const race *rc) { return (rc->flags&RCF_MIGRANTS) ? MIGRANTS_LOG10 : MIGRANTS_NONE; diff --git a/src/kernel/race.h b/src/kernel/race.h index b500ed6a1..6a4feb269 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -189,6 +189,7 @@ extern "C" { double rc_magres(const struct race *rc); double rc_maxaura(const struct race *rc); int rc_armor_bonus(const struct race *rc); + int rc_scare(const struct race *rc); #define MIGRANTS_NONE 0 #define MIGRANTS_LOG10 1 diff --git a/src/monsters.c b/src/monsters.c index bba1cbd50..a7678c701 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -31,7 +31,6 @@ #include "study.h" /* attributes includes */ -#include #include #include @@ -1013,11 +1012,11 @@ static void eaten_by_monster(unit * u) int horse = -1; const resource_type *rhorse = get_resourcetype(R_HORSE); const race *rc = u_race(u); - attrib *a; + int scare; - a = a_find(rc->attribs, &at_scare); - if (a) { - n = rng_int() & a->data.i * u->number; + scare = rc_scare(rc); + if (scare>0) { + n = rng_int() % scare * u->number; } else { n = rng_int() % (u->number / 20 + 1); horse = 0; @@ -1093,10 +1092,11 @@ static void scared_by_monster(unit * u) { int n; const race *rc = u_race(u); - attrib *a; - a = a_find(rc->attribs, &at_scare); - if (a) { - n = rng_int() & a->data.i * u->number; + int scare; + + scare = rc_scare(rc); + if (scare>0) { + n = rng_int() % scare * u->number; } else { n = rng_int() % (u->number / 4 + 1); } From 67414f29ebf6af99a084e315d086bf429cd646cd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Feb 2017 19:26:07 +0100 Subject: [PATCH 489/675] wrap ai.scare and at_scare in rc_set_param --- src/kernel/race.c | 5 +++++ src/kernel/race.test.c | 2 ++ src/kernel/xmlreader.c | 13 ++++++------- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/kernel/race.c b/src/kernel/race.c index 4dc347751..b7c52d169 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -311,6 +311,11 @@ void rc_set_param(struct race *rc, const char *key, const char *value) { if (strcmp(key, "recruit_multi") == 0) { rc->recruit_multi = atof(value); } + else if (strcmp(key, "ai.scare") == 0) { + attrib *a = a_new(&at_scare); + a->data.i = atoi(value); + a_add(&rc->attribs, a); + } else if (strcmp(key, "migrants.formula") == 0) { if (value[0] == '1') { rc->flags |= RCF_MIGRANTS; diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index 132457cb4..857e8696a 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -96,6 +96,8 @@ static void test_rc_set_param(CuTest *tc) { rc_set_param(rc, "migrants.formula", "1"); CuAssertIntEquals(tc, RCF_MIGRANTS, rc->flags&RCF_MIGRANTS); CuAssertIntEquals(tc, MIGRANTS_LOG10, rc_migrants_formula(rc)); + rc_set_param(rc, "ai.scare", "400"); + CuAssertIntEquals(tc, 400, rc_scare(rc)); test_cleanup(); } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index c07e19809..0864df9a6 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1575,13 +1575,12 @@ static int parse_spells(xmlDocPtr doc) static void parse_ai(race * rc, xmlNodePtr node) { - int n; - - n = xml_ivalue(node, "scare", 0); - if (n>0) { - attrib *a = a_new(&at_scare); - a->data.i = n; - a_add(&rc->attribs, a); + xmlChar *propValue; + + propValue = xmlGetProp(node, BAD_CAST "scare"); + if (propValue) { + rc_set_param(rc, "ai.scare", (const char *)propValue); + xmlFree(propValue); } rc->splitsize = xml_ivalue(node, "splitsize", 0); rc->aggression = (float)xml_fvalue(node, "aggression", 0.04); From 492aba543bb79847268d54c7d4247d9a4a8d0a8e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Feb 2017 19:30:09 +0100 Subject: [PATCH 490/675] delete at_scare delete dead code (race.attribs has no at_skillmod) delete race.attribs --- src/attributes/attributes.c | 5 ----- src/attributes/attributes.h | 1 - src/battle.c | 4 ---- src/kernel/race.c | 9 +-------- src/kernel/race.h | 1 - 5 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index 8e9b22139..42f5247fe 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -58,10 +58,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include -attrib_type at_scare = { // monster scares peasants - "scare", NULL, NULL, NULL, a_writeint, a_readint -}; - attrib_type at_unitdissolve = { "unitdissolve", NULL, NULL, NULL, a_writechars, a_readchars }; @@ -78,7 +74,6 @@ static int read_ext(attrib * a, void *owner, gamedata *data) void register_attributes(void) { /* Alle speicherbaren Attribute mssen hier registriert werden */ - at_register(&at_scare); at_register(&at_shiptrail); at_register(&at_familiar); at_register(&at_familiarmage); diff --git a/src/attributes/attributes.h b/src/attributes/attributes.h index 91184ad98..4ec3150ec 100644 --- a/src/attributes/attributes.h +++ b/src/attributes/attributes.h @@ -23,7 +23,6 @@ extern "C" { #endif struct attrib_type; - extern struct attrib_type at_scare; extern void register_attributes(void); #ifdef __cplusplus diff --git a/src/battle.c b/src/battle.c index 9316d35dd..04e72d92c 100644 --- a/src/battle.c +++ b/src/battle.c @@ -760,10 +760,6 @@ bool missile) if (is_riding(t) && (wtype == NULL || (fval(wtype, WTF_HORSEBONUS) && !fval(wtype, WTF_MISSILE)))) { skill += CavalryBonus(tu, enemy, BONUS_SKILL); - if (wtype) - skill = - skillmod(u_race(tu)->attribs, tu, tu->region, wtype->skill, skill, - SMF_RIDING); } if (t.index < tf->elvenhorses) { diff --git a/src/kernel/race.c b/src/kernel/race.c index b7c52d169..9a5ce84c2 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -48,7 +48,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include /* attrib includes */ -#include #include /* libc includes */ @@ -298,8 +297,7 @@ int rc_armor_bonus(const race *rc) int rc_scare(const struct race *rc) { - attrib *a = a_find(rc->attribs, &at_scare); - return a ? a->data.i : 0; + return get_param_int(rc->parameters, "ai.scare", 0); } int rc_migrants_formula(const race *rc) @@ -311,11 +309,6 @@ void rc_set_param(struct race *rc, const char *key, const char *value) { if (strcmp(key, "recruit_multi") == 0) { rc->recruit_multi = atof(value); } - else if (strcmp(key, "ai.scare") == 0) { - attrib *a = a_new(&at_scare); - a->data.i = atoi(value); - a_add(&rc->attribs, a); - } else if (strcmp(key, "migrants.formula") == 0) { if (value[0] == '1') { rc->flags |= RCF_MIGRANTS; diff --git a/src/kernel/race.h b/src/kernel/race.h index 6a4feb269..906b56808 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -154,7 +154,6 @@ extern "C" { void(*init_familiar) (struct unit *); const struct race *familiars[MAXMAGIETYP]; - struct attrib *attribs; struct race *next; } race; From de10a8ad65a3fcafccd9e34de3938dc4172a350a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Feb 2017 20:48:44 +0100 Subject: [PATCH 491/675] reduce side-effects in snowglobe tests. should no longer be intermittent. --- clibs | 2 +- cmake | 2 +- scripts/tests/xmas.lua | 12 +++--------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/clibs b/clibs index 27c8b3202..f91ef37f0 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 +Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c diff --git a/cmake b/cmake index d88983c7f..f1fb3943a 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit d88983c7ff4bc3a4884a7c3f74e8190bac5eab23 +Subproject commit f1fb3943ace59994d90d71a891b80033dc2700a2 diff --git a/scripts/tests/xmas.lua b/scripts/tests/xmas.lua index 5477e08ab..459984901 100644 --- a/scripts/tests/xmas.lua +++ b/scripts/tests/xmas.lua @@ -46,23 +46,17 @@ function test_snowglobe() local r2 = region.create(1, 0, "ocean") local f = faction.create("snowglobe2@eressea.de", "human", "de") local u = unit.create(f, r1, 1) - local have = 6 local fail = 0 u:add_item("snowglobe", have) - local xform = { ocean = "glacier", glacier = "glacier", firewall = "volcano", volcano = "mountain", desert = "plain", plain = "plain" } - u:clear_orders() - u:add_order("BENUTZEN 1 Schneekugel Ost") + local xform = { ocean = "glacier", glacier = "glacier", firewall = "volcano", desert = "plain", volcano = "mountain", plain = "plain" } for k, v in pairs(xform) do r2.terrain = k - process_orders() + use_snowglobe(u, 1, "Ost", nil) assert_equal(v, r2.terrain) - if k~=v then - have=have - 1 - else + if k==v then fail = fail + 1 assert_equal(fail, f:count_msg_type('target_region_invalid')) end - assert_equal(have, u:get_item("snowglobe")) end end From 998dcffab2f29f81b3a64c595275ed01ac78a372 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Feb 2017 09:03:08 +0100 Subject: [PATCH 492/675] introduce an rcoption struct. used for pretty rare options that have no property in the race struct. --- clibs | 2 +- cmake | 2 +- src/kernel/faction.c | 10 +------ src/kernel/race.c | 69 +++++++++++++++++++++++++++++++++++++++++++- src/kernel/race.h | 4 +++ 5 files changed, 75 insertions(+), 12 deletions(-) diff --git a/clibs b/clibs index f91ef37f0..27c8b3202 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c +Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 diff --git a/cmake b/cmake index f1fb3943a..d88983c7f 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit f1fb3943ace59994d90d71a891b80033dc2700a2 +Subproject commit d88983c7ff4bc3a4884a7c3f74e8190bac5eab23 diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 30a623e44..a5373d44d 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -558,20 +558,12 @@ void faction_setpassword(faction * f, const char *pwhash) f->_password = strdup(pwhash); } -const race *other_race(const race *rc) { - if (rc->parameters) { - const char *str = get_param(rc->parameters, "other_race"); - return str ? rc_find(str) : NULL; - } - return NULL; -} - bool valid_race(const struct faction *f, const struct race *rc) { if (f->race == rc) return true; else { - return other_race(f->race) == rc; + return rc_otherrace(f->race) == rc; } } diff --git a/src/kernel/race.c b/src/kernel/race.c index 9a5ce84c2..bc4bdd1e4 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -44,6 +44,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include @@ -77,6 +78,59 @@ static const char *racenames[MAXRACES] = { "clone" }; +#define MAXOPTIONS 4 +typedef struct rcoption { + unsigned char key[MAXOPTIONS]; + variant value[MAXOPTIONS]; +} rcoption; + +enum { + RCO_NONE, + RCO_SCARE, + RCO_OTHER +}; + +static void rc_setoption(race *rc, int key, const char *value) { + int i; + variant *v = NULL; + if (!rc->options) { + rc->options = malloc(sizeof(rcoption)); + rc->options->key[0] = key; + rc->options->key[1] = RCO_NONE; + v = rc->options->value; + } else { + for (i=0;!v && i < MAXOPTIONS && rc->options->key[i]!=RCO_NONE;++i) { + if (rc->options->key[i]==key) { + v = rc->options->value+i; + } + } + if (!v) { + assert(ioptions->value+i; + rc->options->key[i] = key; + } + } + assert(v); + if (key == RCO_SCARE) { + v->i = atoi(value); + } + else if (key == RCO_OTHER) { + v->v = rc_get_or_create(value); + } +} + +static variant *rc_getoption(const race *rc, int key) { + if (rc->options) { + int i; + for (i=0;i!=MAXOPTIONS && rc->options->key[i]!=RCO_NONE;++i) { + if (rc->options->key[i]==key) { + return rc->options->value+i; + } + } + } + return NULL; +} + const struct race *findrace(const char *s, const struct locale *lang) { void **tokens = get_translations(lang, UT_RACES); @@ -297,7 +351,14 @@ int rc_armor_bonus(const race *rc) int rc_scare(const struct race *rc) { - return get_param_int(rc->parameters, "ai.scare", 0); + variant *v = rc_getoption(rc, RCO_SCARE); + return v ? v->i : 0; +} + +const race *rc_otherrace(const race *rc) +{ + variant *v = rc_getoption(rc, RCO_OTHER); + return v ? (const race *)v->v : NULL; } int rc_migrants_formula(const race *rc) @@ -314,6 +375,12 @@ void rc_set_param(struct race *rc, const char *key, const char *value) { rc->flags |= RCF_MIGRANTS; } } + else if (strcmp(key, "other_race")==0) { + rc_setoption(rc, RCO_OTHER, value); + } + else if (strcmp(key, "ai.scare")==0) { + rc_setoption(rc, RCO_SCARE, value); + } else { set_param(&rc->parameters, key, value); } diff --git a/src/kernel/race.h b/src/kernel/race.h index 906b56808..f4afb04de 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -47,6 +47,7 @@ extern "C" { struct spell; struct spellref; struct locale; + struct rcoption; extern int num_races; @@ -153,6 +154,8 @@ extern "C" { struct item *(*itemdrop) (const struct race *, int size); void(*init_familiar) (struct unit *); + struct rcoption *options; // rarely used properties + const struct race *familiars[MAXMAGIETYP]; struct race *next; } race; @@ -189,6 +192,7 @@ extern "C" { double rc_maxaura(const struct race *rc); int rc_armor_bonus(const struct race *rc); int rc_scare(const struct race *rc); + const race *rc_otherrace(const race *rc); #define MIGRANTS_NONE 0 #define MIGRANTS_LOG10 1 From 28c951bdfd423aaa381324665369ffaff4fd5549 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Feb 2017 09:46:36 +0100 Subject: [PATCH 493/675] eliminate race.parameters. move all special properties to race.options --- src/kernel/race.c | 71 +++++++++++++++++++++++++++++++++++++++--- src/kernel/race.h | 4 ++- src/kernel/race.test.c | 6 ++-- src/kernel/xmlreader.c | 1 - src/market.c | 16 ---------- src/morale.c | 7 ++--- src/upkeep.c | 18 +++++------ 7 files changed, 84 insertions(+), 39 deletions(-) diff --git a/src/kernel/race.c b/src/kernel/race.c index bc4bdd1e4..8b2632753 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -86,8 +86,12 @@ typedef struct rcoption { enum { RCO_NONE, - RCO_SCARE, - RCO_OTHER + RCO_SCARE, // races that scare and eat peasants + RCO_OTHER, // may recruit from another race + RCO_STAMINA, // every n levels of stamina add +1 RC + RCO_HUNGER, // custom hunger.damage override (char *) + RCO_TRADELUX, + RCO_TRADEHERB, }; static void rc_setoption(race *rc, int key, const char *value) { @@ -114,9 +118,21 @@ static void rc_setoption(race *rc, int key, const char *value) { if (key == RCO_SCARE) { v->i = atoi(value); } + else if (key == RCO_STAMINA) { + v->i = atoi(value); + } else if (key == RCO_OTHER) { v->v = rc_get_or_create(value); } + else if (key == RCO_HUNGER) { + v->v = strdup(value); + } + else if (key == RCO_TRADEHERB) { + v->i = atoi(value); + } + else if (key == RCO_TRADELUX) { + v->i = atoi(value); + } } static variant *rc_getoption(const race *rc, int key) { @@ -238,12 +254,20 @@ void free_races(void) { while (races) { int i; race * rc = races->next; + rcoption * opt = races->options; + if (opt) { + for (i=0;i!=MAXOPTIONS && opt->key[i]!=RCO_NONE;++i) { + if (opt->key[i]==RCO_HUNGER) { + free(opt->value[i].v); + } + } + free(opt); + } for (i = 0; races->attack[i].type!=AT_NONE; ++i) { spellref_free(races->attack[i].data.sp); } spellref_free(races->precombatspell); - free_params(&races->parameters); free(xrefs); xrefs = 0; free(races->_name); @@ -344,9 +368,16 @@ double rc_maxaura(const race *rc) { return rc->maxaura / 100.0; } +const char * rc_hungerdamage(const race *rc) +{ + variant *v = rc_getoption(rc, RCO_HUNGER); + return v ? (const char *)v->v : NULL; +} + int rc_armor_bonus(const race *rc) { - return get_param_int(rc->parameters, "armor.stamina", 0); + variant *v = rc_getoption(rc, RCO_STAMINA); + return v ? v->i : 0; } int rc_scare(const struct race *rc) @@ -355,6 +386,24 @@ int rc_scare(const struct race *rc) return v ? v->i : 0; } +int rc_luxury_trade(const struct race *rc) +{ + if (rc) { + variant *v = rc_getoption(rc, RCO_TRADELUX); + if (v) return v->i; + } + return 1000; +} + +int rc_herb_trade(const struct race *rc) +{ + if (rc) { + variant *v = rc_getoption(rc, RCO_TRADEHERB); + if (v) return v->i; + } + return 500; +} + const race *rc_otherrace(const race *rc) { variant *v = rc_getoption(rc, RCO_OTHER); @@ -381,8 +430,20 @@ void rc_set_param(struct race *rc, const char *key, const char *value) { else if (strcmp(key, "ai.scare")==0) { rc_setoption(rc, RCO_SCARE, value); } + else if (strcmp(key, "hunger.damage")==0) { + rc_setoption(rc, RCO_HUNGER, value); + } + else if (strcmp(key, "armor.stamina")==0) { + rc_setoption(rc, RCO_STAMINA, value); + } + else if (strcmp(key, "luxury_trade")==0) { + rc_setoption(rc, RCO_TRADELUX, value); + } + else if (strcmp(key, "herb_trade")==0) { + rc_setoption(rc, RCO_TRADEHERB, value); + } else { - set_param(&rc->parameters, key, value); + log_error("unknown property for race %s: %s=%s", rc->_name, key, value); } } diff --git a/src/kernel/race.h b/src/kernel/race.h index f4afb04de..6321d4f22 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -138,7 +138,6 @@ extern "C" { int df_default; /* Verteidigungsskill Unbewaffnet (default: -2) */ int at_bonus; /* Ver�ndert den Angriffsskill (default: 0) */ int df_bonus; /* Ver�ndert den Verteidigungskill (default: 0) */ - struct param *parameters; // additional properties, for an example see natural_armor struct spellref *precombatspell; signed char *study_speed; /* study-speed-bonus in points/turn (0=30 Tage) */ int flags; @@ -188,10 +187,13 @@ extern "C" { void rc_set_param(struct race *rc, const char *key, const char *value); + int rc_luxury_trade(const struct race *rc); + int rc_herb_trade(const struct race *rc); double rc_magres(const struct race *rc); double rc_maxaura(const struct race *rc); int rc_armor_bonus(const struct race *rc); int rc_scare(const struct race *rc); + const char * rc_hungerdamage(const race *rc); const race *rc_otherrace(const race *rc); #define MIGRANTS_NONE 0 diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index 857e8696a..8363d8b72 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -88,9 +88,7 @@ static void test_rc_set_param(CuTest *tc) { race *rc; test_setup(); rc = test_create_race("human"); - CuAssertPtrEquals(tc, NULL, rc->parameters); - rc_set_param(rc, "hodor", "HODOR"); - CuAssertStrEquals(tc, "HODOR", get_param(rc->parameters, "hodor")); + CuAssertPtrEquals(tc, NULL, rc->options); rc_set_param(rc, "recruit_multi", "0.5"); CuAssertDblEquals(tc, 0.5, rc->recruit_multi, 0.0); rc_set_param(rc, "migrants.formula", "1"); @@ -98,6 +96,8 @@ static void test_rc_set_param(CuTest *tc) { CuAssertIntEquals(tc, MIGRANTS_LOG10, rc_migrants_formula(rc)); rc_set_param(rc, "ai.scare", "400"); CuAssertIntEquals(tc, 400, rc_scare(rc)); + rc_set_param(rc, "hunger.damage", "1d10+12"); + CuAssertStrEquals(tc, "1d10+12", rc_hungerdamage(rc)); test_cleanup(); } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 0864df9a6..00bb9f848 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1738,7 +1738,6 @@ static int parse_races(xmlDocPtr doc) xmlFree(propValue); } } - rc->recruit_multi = get_param_flt(rc->parameters, "recruit_multi", 1.0); /* reading eressea/races/race/skill */ xpath->node = node; diff --git a/src/market.c b/src/market.c index 254d3a483..8fd4e3f0d 100644 --- a/src/market.c +++ b/src/market.c @@ -66,22 +66,6 @@ attrib_type at_market = { NULL, NULL, NULL, ATF_UNIQUE }; -int rc_luxury_trade(const struct race *rc) -{ - if (rc) { - return get_param_int(rc->parameters, "luxury_trade", 1000); - } - return 1000; -} - -int rc_herb_trade(const struct race *rc) -{ - if (rc) { - return get_param_int(rc->parameters, "herb_trade", 500); - } - return 500; -} - #define MAX_MARKETS 128 #define MIN_PEASANTS 50 /* if there are at least this many peasants, you will get 1 good */ diff --git a/src/morale.c b/src/morale.c index 1bdf2363d..580af899f 100644 --- a/src/morale.c +++ b/src/morale.c @@ -31,10 +31,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include -static double rc_popularity(const struct race *rc) +static double popularity() { - int pop = get_param_int(rc->parameters, "morale", MORALE_AVERAGE); - return 1.0 / (pop - MORALE_COOLDOWN); /* 10 turns average */ + return 1.0 / (MORALE_AVERAGE - MORALE_COOLDOWN); /* 10 turns average */ } void morale_update(region *r) { @@ -52,7 +51,7 @@ void morale_update(region *r) { if (morale < maxmorale) { if (stability > MORALE_COOLDOWN && r->land->ownership->owner && morale < MORALE_MAX) { - double ch = rc_popularity(r->land->ownership->owner->race); + double ch = popularity(); if (is_cursed(r->attribs, C_GENEROUS, 0)) { ch *= 1.2; /* 20% improvement */ } diff --git a/src/upkeep.c b/src/upkeep.c index c53c321d0..8494d7f25 100644 --- a/src/upkeep.c +++ b/src/upkeep.c @@ -59,7 +59,7 @@ static void help_feed(unit * donor, unit * u, int *need_p) } static const char *hunger_damage(const race *rc) { - const char * damage = rc->parameters ? get_param(rc->parameters, "hunger.damage") : NULL; + const char * damage = rc_hungerdamage(rc); if (!damage) { damage = config_get("hunger.damage"); } @@ -98,11 +98,11 @@ static bool hunger(int number, unit * u) deathcounts(r, dead); } if (hpsub > 0) { - /* Jetzt die Schden der nicht gestorbenen abziehen. */ + /* Jetzt die Sch�den der nicht gestorbenen abziehen. */ u->hp -= hpsub; - /* Meldung nur, wenn noch keine fr Tote generiert. */ + /* Meldung nur, wenn noch keine f�r Tote generiert. */ if (dead == 0) { - /* Durch unzureichende Ernhrung wird %s geschwcht */ + /* Durch unzureichende Ern�hrung wird %s geschw�cht */ ADDMSG(&u->faction->msgs, msg_message("malnourish", "unit region", u, r)); } } @@ -125,13 +125,13 @@ void get_food(region * r) return; } /* 1. Versorgung von eigenen Einheiten. Das vorhandene Silber - * wird zunchst so auf die Einheiten aufgeteilt, dass idealerweise - * jede Einheit genug Silber fr ihren Unterhalt hat. */ + * wird zun�chst so auf die Einheiten aufgeteilt, dass idealerweise + * jede Einheit genug Silber f�r ihren Unterhalt hat. */ for (u = r->units; u; u = u->next) { int need = lifestyle(u); - /* Erstmal zurcksetzen */ + /* Erstmal zur�cksetzen */ freset(u, UFL_HUNGER); if (u->ship && (u->ship->flags & SF_FISHING)) { @@ -230,7 +230,7 @@ void get_food(region * r) } /* 3. bestimmen, wie viele Bauern gefressen werden. - * bei fehlenden Bauern den Dmon hungern lassen + * bei fehlenden Bauern den D�mon hungern lassen */ for (u = r->units; u; u = u->next) { if (u_race(u) == rc_demon) { @@ -293,7 +293,7 @@ void get_food(region * r) } rsetpeasants(r, peasantfood / 10); - /* 3. Von den berlebenden das Geld abziehen: */ + /* 3. Von den �berlebenden das Geld abziehen: */ for (u = r->units; u; u = u->next) { int need = MIN(get_money(u), lifestyle(u)); change_money(u, -need); From 2267373b2e40409f75f485c1155dd69e9dbf7cba Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Feb 2017 10:44:11 +0100 Subject: [PATCH 494/675] gcc warning --- clibs | 2 +- cmake | 2 +- src/morale.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clibs b/clibs index 27c8b3202..f91ef37f0 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 +Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c diff --git a/cmake b/cmake index d88983c7f..f1fb3943a 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit d88983c7ff4bc3a4884a7c3f74e8190bac5eab23 +Subproject commit f1fb3943ace59994d90d71a891b80033dc2700a2 diff --git a/src/morale.c b/src/morale.c index 580af899f..67108333e 100644 --- a/src/morale.c +++ b/src/morale.c @@ -31,7 +31,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include -static double popularity() +static double popularity(void) { return 1.0 / (MORALE_AVERAGE - MORALE_COOLDOWN); /* 10 turns average */ } From baf3275ebac67b3d01e1040bd644c9f3cb984bd2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Feb 2017 11:52:07 +0100 Subject: [PATCH 495/675] valgrind: always terminate options --- src/kernel/race.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/kernel/race.c b/src/kernel/race.c index 8b2632753..c57d98a24 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -112,6 +112,9 @@ static void rc_setoption(race *rc, int key, const char *value) { assert(ioptions->value+i; rc->options->key[i] = key; + if (i+1options->key[i+1]=RCO_NONE; + } } } assert(v); From d851554ebe68abc540a45796767fc016a786b0c0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Feb 2017 18:16:34 +0100 Subject: [PATCH 496/675] MSVC doesn't like to do integer->char conversions. --- src/kernel/race.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/kernel/race.c b/src/kernel/race.c index c57d98a24..c7c2e8165 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -94,7 +94,8 @@ enum { RCO_TRADEHERB, }; -static void rc_setoption(race *rc, int key, const char *value) { +static void rc_setoption(race *rc, int k, const char *value) { + unsigned char key = (unsigned char)k; int i; variant *v = NULL; if (!rc->options) { From 8ffa0919366a631e9189ee9a84c562de3b8a5d4f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Feb 2017 20:34:11 +0100 Subject: [PATCH 497/675] do not abort xml parsing when there is no calendar --- src/kernel/xmlreader.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 00bb9f848..cd3331517 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -358,16 +358,13 @@ static int parse_calendar(xmlDocPtr doc) xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathObjectPtr xpathCalendars; xmlNodeSetPtr nsetCalendars; - int c, rv = 0; /* reading eressea/buildings/building */ xpathCalendars = xmlXPathEvalExpression(BAD_CAST "/eressea/calendar", xpath); nsetCalendars = xpathCalendars->nodesetval; months_per_year = 0; - if (nsetCalendars == NULL || nsetCalendars->nodeNr == 0) { - rv = -1; - } - else + if (nsetCalendars != NULL && nsetCalendars->nodeNr != 0) { + int c; for (c = 0; c != nsetCalendars->nodeNr; ++c) { xmlNodePtr calendar = nsetCalendars->nodeTab[c]; xmlXPathObjectPtr xpathWeeks, xpathMonths, xpathSeasons; @@ -477,10 +474,11 @@ static int parse_calendar(xmlDocPtr doc) xmlFree(newyear); newyear = NULL; } + } xmlXPathFreeObject(xpathCalendars); xmlXPathFreeContext(xpath); - return rv; + return 0; } static int parse_ships(xmlDocPtr doc) From 60497da87b74c4228523e63d927c741abafa2d67 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 7 Feb 2017 20:50:07 +0100 Subject: [PATCH 498/675] print error message when missing parameter translation. --- src/kernel/xmlreader.c | 3 +-- src/util/language.c | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index cd3331517..6491daf20 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -359,7 +359,6 @@ static int parse_calendar(xmlDocPtr doc) xmlXPathObjectPtr xpathCalendars; xmlNodeSetPtr nsetCalendars; - /* reading eressea/buildings/building */ xpathCalendars = xmlXPathEvalExpression(BAD_CAST "/eressea/calendar", xpath); nsetCalendars = xpathCalendars->nodesetval; months_per_year = 0; @@ -374,7 +373,7 @@ static int parse_calendar(xmlDocPtr doc) xmlChar *start; start = xmlGetProp(calendar, BAD_CAST "start"); - if (start && config_get("game.start")==NULL) { + if (start && config_get("game.start") == NULL) { config_set("game.start", (const char *)start); xmlFree(start); } diff --git a/src/util/language.c b/src/util/language.c index 300e69103..0de04be71 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -300,6 +300,9 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_ struct critbit_tree ** cb = (struct critbit_tree **)tokens; add_translation(cb, key, i); } + else { + log_error("no translation for %s in locale %s", s, lang->name); + } } } } From f48dd415380b82b509447650bd96221b9a4b37c8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 7 Feb 2017 21:37:38 +0100 Subject: [PATCH 499/675] fix a segfault in free_Races --- src/kernel/config.c | 2 +- src/kernel/race.c | 8 +++++++- src/kernel/race.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index ca23a5bc9..b2734d43a 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -203,7 +203,7 @@ param_t findparam(const char *s, const struct locale * lang) void **tokens = get_translations(lang, UT_PARAMS); critbit_tree *cb = (critbit_tree *)*tokens; if (!cb) { - log_warning("no parameters defined in locale %s", locale_name(lang)); + log_error("no parameters defined in locale %s", locale_name(lang)); } else if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) { cb_get_kv(match, &i, sizeof(int)); diff --git a/src/kernel/race.c b/src/kernel/race.c index c7c2e8165..a4a11c15d 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -269,7 +269,13 @@ void free_races(void) { free(opt); } for (i = 0; races->attack[i].type!=AT_NONE; ++i) { - spellref_free(races->attack[i].data.sp); + att *at = races->attack + i; + if (at->type == AT_SPELL) { + spellref_free(at->data.sp); + } + else { + free(at->data.dice); + } } spellref_free(races->precombatspell); free(xrefs); diff --git a/src/kernel/race.h b/src/kernel/race.h index 6321d4f22..c58bad701 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -105,7 +105,7 @@ extern "C" { typedef struct att { int type; union { - const char *dice; + char *dice; struct spellref *sp; } data; int flags; From b504899b07fbcc48f9c96cec85da3c2e4d066561 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 9 Feb 2017 23:28:50 +0100 Subject: [PATCH 500/675] fix locale initialization --- src/bind_config.c | 2 -- src/bindings.c | 2 +- src/kernel/config.c | 2 +- src/laws.c | 1 + src/util/language.c | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/bind_config.c b/src/bind_config.c index faf543f47..c603800ed 100644 --- a/src/bind_config.c +++ b/src/bind_config.c @@ -22,7 +22,6 @@ void config_reset(void) { default_locale = 0; free_config(); - free_locales(); free_nrmesssages(); free_spells(); free_buildingtypes(); @@ -37,7 +36,6 @@ int config_parse(const char *json) if (conf) { json_config(conf); cJSON_Delete(conf); - init_locales(); return 0; } else { diff --git a/src/bindings.c b/src/bindings.c index 7bf30202a..1515c74e0 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -517,7 +517,7 @@ static void reset_game(void) for (f = factions; f; f = f->next) { f->flags &= FFL_SAVEMASK; } - init_locales(); +// init_locales(); } static int tolua_process_orders(lua_State * L) diff --git a/src/kernel/config.c b/src/kernel/config.c index b2734d43a..ca23a5bc9 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -203,7 +203,7 @@ param_t findparam(const char *s, const struct locale * lang) void **tokens = get_translations(lang, UT_PARAMS); critbit_tree *cb = (critbit_tree *)*tokens; if (!cb) { - log_error("no parameters defined in locale %s", locale_name(lang)); + log_warning("no parameters defined in locale %s", locale_name(lang)); } else if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) { cb_get_kv(match, &i, sizeof(int)); diff --git a/src/laws.c b/src/laws.c index 98ff5d9f6..78ca6fba9 100644 --- a/src/laws.c +++ b/src/laws.c @@ -4196,6 +4196,7 @@ void init_processor(void) void processorders(void) { + init_locales(); init_processor(); process(); /*************************************************/ diff --git a/src/util/language.c b/src/util/language.c index 0de04be71..86a6895be 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -301,7 +301,7 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_ add_translation(cb, key, i); } else { - log_error("no translation for %s in locale %s", s, lang->name); + log_warning("no translation for %s in locale %s", s, lang->name); } } } From 2ee0e599b173295f45fabf58124e2063047ce3b1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Feb 2017 17:38:39 +0100 Subject: [PATCH 501/675] initialize game after loading config --- scripts/eressea/xmlconf.lua | 1 + src/bind_eressea.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/scripts/eressea/xmlconf.lua b/scripts/eressea/xmlconf.lua index 9d87f3f3e..584f8d3e2 100644 --- a/scripts/eressea/xmlconf.lua +++ b/scripts/eressea/xmlconf.lua @@ -7,3 +7,4 @@ if config.rules then assert(0 == read_xml(confdir .. rules .. 'config.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") assert(0 == eressea.config.read(rules .. 'config.json', confdir), "could not read JSON data") end +eressea.game.reset() diff --git a/src/bind_eressea.c b/src/bind_eressea.c index 279ce8f4e..de8751306 100755 --- a/src/bind_eressea.c +++ b/src/bind_eressea.c @@ -9,6 +9,8 @@ #include #include +#include + #include #include @@ -16,6 +18,7 @@ void eressea_free_game(void) { free_gamedata(); init_resources(); + init_locales(); } int eressea_read_game(const char * filename) { From 853f63b50129f1d0d7ab0013f7e330c760f69daf Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Feb 2017 20:27:13 +0100 Subject: [PATCH 502/675] delete unitmessage trigger, it is unused --- src/spells.c | 1 - src/triggers/CMakeLists.txt | 1 - src/triggers/triggers.c | 2 - src/triggers/unitmessage.c | 124 ------------------------------------ src/triggers/unitmessage.h | 37 ----------- 5 files changed, 165 deletions(-) delete mode 100644 src/triggers/unitmessage.c delete mode 100644 src/triggers/unitmessage.h diff --git a/src/spells.c b/src/spells.c index 0bb6df5af..e936a46a2 100644 --- a/src/spells.c +++ b/src/spells.c @@ -95,7 +95,6 @@ #include #include #include -#include /* attributes includes */ #include diff --git a/src/triggers/CMakeLists.txt b/src/triggers/CMakeLists.txt index d6670a95b..e123698d6 100644 --- a/src/triggers/CMakeLists.txt +++ b/src/triggers/CMakeLists.txt @@ -11,7 +11,6 @@ killunit.c shock.c timeout.c triggers.c -unitmessage.c ) FOREACH(_FILE ${_FILES}) LIST(APPEND _SOURCES ${PROJECT_NAME}/${_FILE}) diff --git a/src/triggers/triggers.c b/src/triggers/triggers.c index 433201abd..8826fcba2 100644 --- a/src/triggers/triggers.c +++ b/src/triggers/triggers.c @@ -28,7 +28,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include /* util includes */ @@ -47,7 +46,6 @@ void register_triggers(void) tt_register(&tt_giveitem); tt_register(&tt_killunit); tt_register(&tt_shock); - tt_register(&tt_unitmessage); tt_register(&tt_timeout); tt_register(&tt_clonedied); } diff --git a/src/triggers/unitmessage.c b/src/triggers/unitmessage.c deleted file mode 100644 index 7ba97d9bc..000000000 --- a/src/triggers/unitmessage.c +++ /dev/null @@ -1,124 +0,0 @@ -/* -+-------------------+ Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -+-------------------+ -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - -#include -#include "unitmessage.h" - -/* kernel includes */ -#include -#include -#include - -/* util includes */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* ansi includes */ -#include -#include -#include -#include - -/*** -** give an item to someone -**/ - -typedef struct unitmessage_data { - struct unit *target; - char *string; - int type; - int level; -} unitmessage_data; - -static void unitmessage_init(trigger * t) -{ - t->data.v = calloc(sizeof(unitmessage_data), 1); -} - -static void unitmessage_free(trigger * t) -{ - unitmessage_data *sd = (unitmessage_data *)t->data.v; - free(sd->string); - free(t->data.v); -} - -static int unitmessage_handle(trigger * t, void *data) -{ - /* call an event handler on unitmessage. - * data.v -> ( variant event, int timer ) - */ - unitmessage_data *td = (unitmessage_data *)t->data.v; - if (td->target && td->target->no) { - struct faction *f = td->target->faction; - const char * str = LOC(f->locale, td->string); - /* bug found in turn 733: sometimes, alps have f*cked up messages */ - if (td->string && td->string[0]) { - addmessage(td->target->region, f, str, td->type, - td->level); - } - } - UNUSED_ARG(data); - return 0; -} - -static void unitmessage_write(const trigger * t, struct storage *store) -{ - unitmessage_data *td = (unitmessage_data *)t->data.v; - write_unit_reference(td->target, store); - WRITE_TOK(store, td->string); - WRITE_INT(store, td->type); - WRITE_INT(store, td->level); -} - -static int unitmessage_read(trigger * t, gamedata *data) -{ - unitmessage_data *td = (unitmessage_data *)t->data.v; - char zText[256]; - - int result = read_reference(&td->target, data, read_unit_reference, - resolve_unit); - READ_TOK(data->store, zText, sizeof(zText)); - td->string = strdup(zText); - READ_INT(data->store, &td->type); - READ_INT(data->store, &td->level); - - if (result == 0 && td->target == NULL) { - return AT_READ_FAIL; - } - return AT_READ_OK; -} - -trigger_type tt_unitmessage = { - "unitmessage", - unitmessage_init, - unitmessage_free, - unitmessage_handle, - unitmessage_write, - unitmessage_read -}; - -trigger *trigger_unitmessage(unit * target, const char *string, int type, - int level) -{ - trigger *t = t_new(&tt_unitmessage); - unitmessage_data *td = (unitmessage_data *)t->data.v; - td->target = target; - td->string = strdup(string); - td->type = type; - td->level = level; - return t; -} diff --git a/src/triggers/unitmessage.h b/src/triggers/unitmessage.h deleted file mode 100644 index 5b5b0793b..000000000 --- a/src/triggers/unitmessage.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef UNITMESSAGE_H -#define UNITMESSAGE_H -#ifdef __cplusplus -extern "C" { -#endif - - /* all types we use are defined here to reduce dependencies */ - struct trigger_type; - struct trigger; - struct unit; - - extern struct trigger_type tt_unitmessage; - extern struct trigger *trigger_unitmessage(struct unit *target, - const char *string, int type, int level); - -#ifdef __cplusplus -} -#endif -#endif From c897108a2cf29a0f562d44da294d91b2a749db9c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Feb 2017 20:58:34 +0100 Subject: [PATCH 503/675] clibs latest --- clibs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clibs b/clibs index f91ef37f0..27c8b3202 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c +Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 From 10e78b1455147442a4334a3f6c845545ba2c0244 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Feb 2017 22:15:21 +0100 Subject: [PATCH 504/675] remove code for dict and lua .objects properties. rewrite muschelplateau code to use keys. --- scripts/eressea/embassy.lua | 18 +--- src/CMakeLists.txt | 1 - src/attributes/dict.c | 179 +++++++++------------------------- src/attributes/dict.h | 7 -- src/attributes/key.c | 2 +- src/bind_dict.c | 185 ------------------------------------ src/bind_dict.h | 26 ----- src/bind_faction.c | 40 ++++++-- src/bind_region.c | 13 +-- src/bind_unit.c | 8 -- src/bindings.c | 2 - 11 files changed, 79 insertions(+), 402 deletions(-) delete mode 100644 src/bind_dict.c delete mode 100644 src/bind_dict.h diff --git a/scripts/eressea/embassy.lua b/scripts/eressea/embassy.lua index 82bce62c2..704581c6f 100644 --- a/scripts/eressea/embassy.lua +++ b/scripts/eressea/embassy.lua @@ -1,19 +1,5 @@ -- Muschelplateau --- global exports (use item) -function use_seashell(u, amount) --- Muschelplateau... - local visit = u.faction.objects:get("embassy_muschel") - if visit and u.region~= home then - local turns = get_turn() - visit - local msg = message.create('msg_event') - msg:set_string("string", u.name .. "(" .. itoa36(u.id) .. ") erzählt den Bewohnern von " .. u.region.name .. " von Muschelplateau, das die Partei " .. u.faction.name .. " vor " .. turns .. " Wochen besucht hat." ) - msg:send_region(u.region) - return 0 - end - return -4 -end - if not config.embassy then return nil end local embassy = {} @@ -34,10 +20,10 @@ function embassy.update() eressea.log.debug("updating embassies in " .. tostring(home)) local u for u in home.units do - if u.faction.objects:get('embassy_muschel')==nil then + if not u.faction:get_key('mupL') then if (u.faction:add_item('seashell', 1)>0) then eressea.log.debug("new seashell for " .. tostring(u.faction)) - u.faction.objects:set('embassy_muschel', get_turn()) + u.faction:set_key('mupL', get_turn()) end end end diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a65cb8912..b4d3614e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -148,7 +148,6 @@ set(SERVER_SRC bind_locale.c bind_eressea.c bind_faction.c - bind_dict.c bind_order.c bindings.c bind_message.c diff --git a/src/attributes/dict.c b/src/attributes/dict.c index a3f034145..6d4b3ed3c 100644 --- a/src/attributes/dict.c +++ b/src/attributes/dict.c @@ -19,6 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include "dict.h" +#include "key.h" /* kernel includes */ #include @@ -29,6 +30,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* util includes */ #include +#include +#include #include #include @@ -54,46 +57,6 @@ typedef struct dict_data { } data; } dict_data; -static void -dict_write(const attrib * a, const void *owner, struct storage *store) -{ - const dict_data *data = (dict_data *)a->data.v; - int type = (int)data->type; - WRITE_TOK(store, data->name); - WRITE_INT(store, type); - switch (data->type) { - case TINTEGER: - WRITE_INT(store, data->data.i); - break; - case TREAL: - WRITE_FLT(store, (float)data->data.real); - break; - case TSTRING: - WRITE_STR(store, data->data.str); - break; - case TUNIT: - write_unit_reference(data->data.u, store); - break; - case TFACTION: - write_faction_reference(data->data.f, store); - break; - case TBUILDING: - write_building_reference(data->data.b, store); - break; - case TSHIP: - /* write_ship_reference(data->data.sh, store); */ - assert(!"not implemented"); - break; - case TREGION: - write_region_reference(data->data.r, store); - break; - case TNONE: - break; - default: - assert(!"illegal type in object-attribute"); - } -} - static int dict_read(attrib * a, void *owner, gamedata *data) { storage *store = data->store; @@ -164,7 +127,7 @@ static int dict_read(attrib * a, void *owner, gamedata *data) default: return AT_READ_FAIL; } - return AT_READ_OK; + return AT_READ_DEPR; } static void dict_init(attrib * a) @@ -184,100 +147,46 @@ static void dict_done(attrib * a) free(a->data.v); } +static void dict_upgrade(attrib **alist, attrib *abegin) { + int n = 0, *keys = 0; + int i = 0, val[4]; + attrib *a, *ak = a_find(*alist, &at_keys); + if (ak) { + keys = (int *)ak->data.v; + if (keys) n = keys[0]; + } + for (a = abegin; a && a->type == abegin->type; a = a->next) { + dict_data *dd = (dict_data *)a->data.v; + if (dd->type != TINTEGER) { + log_error("dict conversion, bad type %d for %s", dd->type, dd->name); + } + else { + if (strcmp(dd->name, "embassy_muschel")==0) { + val[i++] = atoi36("mupL"); + } + else { + log_error("dict conversion, bad entry %s", dd->name); + } + } + if (i == 4) { + keys = realloc(keys, sizeof(int) * (n + i + 1)); + memcpy(keys + n + 1, val, sizeof(int)*i); + n += i; + i = 0; + } + } + if (i > 0) { + keys = realloc(keys, sizeof(int) * (n + i + 1)); + memcpy(keys + n + 1, val, sizeof(int)*i); + if (!ak) { + ak = a_add(alist, a_new(&at_keys)); + } + } + ak->data.v = keys; + keys[0] = n + i; +} + attrib_type at_dict = { "object", dict_init, dict_done, NULL, - dict_write, dict_read + NULL, dict_read, dict_upgrade }; - -const char *dict_name(const attrib * a) -{ - dict_data *data = (dict_data *)a->data.v; - return data->name; -} - -struct attrib *dict_create(const char *name, dict_type type, variant value) -{ - attrib *a = a_new(&at_dict); - dict_data *data = (dict_data *)a->data.v; - data->name = strdup(name); - - dict_set(a, type, value); - return a; -} - -void dict_set(attrib * a, dict_type type, variant value) -{ - dict_data *data = (dict_data *)a->data.v; - - if (data->type == TSTRING) - free(data->data.str); - data->type = type; - switch (type) { - case TSTRING: - data->data.str = value.v ? strdup(value.v) : NULL; - break; - case TINTEGER: - data->data.i = value.i; - break; - case TREAL: - data->data.real = value.f; - break; - case TREGION: - data->data.r = (region *)value.v; - break; - case TBUILDING: - data->data.b = (building *)value.v; - break; - case TFACTION: - data->data.f = (faction *)value.v; - break; - case TUNIT: - data->data.u = (unit *)value.v; - break; - case TSHIP: - data->data.sh = (ship *)value.v; - break; - case TNONE: - break; - default: - assert(!"invalid object-type"); - break; - } -} - -void dict_get(const struct attrib *a, dict_type * type, variant * value) -{ - dict_data *data = (dict_data *)a->data.v; - *type = data->type; - switch (data->type) { - case TSTRING: - value->v = data->data.str; - break; - case TINTEGER: - value->i = data->data.i; - break; - case TREAL: - value->f = (float)data->data.real; - break; - case TREGION: - value->v = data->data.r; - break; - case TBUILDING: - value->v = data->data.b; - break; - case TFACTION: - value->v = data->data.f; - break; - case TUNIT: - value->v = data->data.u; - break; - case TSHIP: - value->v = data->data.sh; - break; - case TNONE: - break; - default: - assert(!"invalid object-type"); - break; - } -} diff --git a/src/attributes/dict.h b/src/attributes/dict.h index 5b282779e..7b028fa00 100644 --- a/src/attributes/dict.h +++ b/src/attributes/dict.h @@ -26,13 +26,6 @@ extern "C" { extern struct attrib_type at_dict; - struct attrib *dict_create(const char *name, dict_type type, - variant value); - void dict_get(const struct attrib *a, dict_type * type, - variant * value); - void dict_set(struct attrib *a, dict_type type, variant value); - const char *dict_name(const struct attrib *a); - #ifdef __cplusplus } #endif diff --git a/src/attributes/key.c b/src/attributes/key.c index 0b252e0c0..ef4b79ad5 100644 --- a/src/attributes/key.c +++ b/src/attributes/key.c @@ -66,7 +66,7 @@ attrib_type at_keys = { NULL }; -void a_upgradekeys(attrib **alist, attrib *abegin) { +static void a_upgradekeys(attrib **alist, attrib *abegin) { int n = 0, *keys = 0; int i = 0, val[4]; attrib *a, *ak = a_find(*alist, &at_keys); diff --git a/src/bind_dict.c b/src/bind_dict.c deleted file mode 100644 index 40f73690f..000000000 --- a/src/bind_dict.c +++ /dev/null @@ -1,185 +0,0 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - -#include -#include "bind_dict.h" - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include - -static int tolua_dict_get(lua_State * L) -{ - dict self = (dict)tolua_tousertype(L, 1, 0); - const char *name = tolua_tostring(L, 2, 0); - attrib *a = a_find(*self, &at_dict); - - for (; a && a->type == &at_dict; a = a->next) { - const char *obj_name = dict_name(a); - if (obj_name && name && strcmp(obj_name, name) == 0) { - variant val; - dict_type type; - - dict_get(a, &type, &val); - switch (type) { - case TNONE: - lua_pushnil(L); - break; - case TINTEGER: - lua_pushinteger(L, val.i); - break; - case TREAL: - lua_pushnumber(L, (lua_Number)val.f); - break; - case TREGION: - tolua_pushusertype(L, val.v, TOLUA_CAST "region"); - break; - case TBUILDING: - tolua_pushusertype(L, val.v, TOLUA_CAST "building"); - break; - case TUNIT: - tolua_pushusertype(L, val.v, TOLUA_CAST "unit"); - break; - case TSHIP: - tolua_pushusertype(L, val.v, TOLUA_CAST "ship"); - break; - case TSTRING: - tolua_pushstring(L, (const char *)val.v); - break; - default: - assert(!"not implemented"); - } - return 1; - } - } - lua_pushnil(L); - return 1; -} - -static int tolua_dict_set_number(lua_State * L) -{ - dict self = (dict)tolua_tousertype(L, 1, 0); - const char *name = tolua_tostring(L, 2, 0); - lua_Number value = tolua_tonumber(L, 3, 0); - attrib *a = a_find(*self, &at_dict); - variant val; - - val.f = (float)value; - - for (; a && a->type == &at_dict; a = a->next) { - if (strcmp(dict_name(a), name) == 0) { - dict_set(a, TREAL, val); - return 0; - } - } - - a = a_add(self, dict_create(name, TREAL, val)); - return 0; -} - -static int tolua_dict_set_string(lua_State * L) -{ - dict self = (dict)tolua_tousertype(L, 1, 0); - const char *name = tolua_tostring(L, 2, 0); - const char *value = tolua_tostring(L, 3, 0); - attrib *a = a_find(*self, &at_dict); - variant val; - - val.v = strdup(value); - - for (; a && a->type == &at_dict; a = a->next) { - if (strcmp(dict_name(a), name) == 0) { - dict_set(a, TSTRING, val); - return 0; - } - } - - a = a_add(self, dict_create(name, TSTRING, val)); - return 0; -} - -static int tolua_dict_set_usertype(lua_State * L, int type) -{ - dict self = (dict)tolua_tousertype(L, 1, 0); - const char *name = tolua_tostring(L, 2, 0); - unit *value = tolua_tousertype(L, 3, 0); - attrib *a = a_find(*self, &at_dict); - variant val; - - val.v = value; - - for (; a && a->type == &at_dict; a = a->next) { - if (strcmp(dict_name(a), name) == 0) { - dict_set(a, type, val); - return 0; - } - } - - a = a_add(self, dict_create(name, type, val)); - return 0; -} - -static int tolua_dict_set(lua_State * L) -{ - tolua_Error tolua_err; - if (tolua_isnumber(L, 3, 0, &tolua_err)) { - return tolua_dict_set_number(L); - } - else if (tolua_isusertype(L, 3, TOLUA_CAST "unit", 0, &tolua_err)) { - return tolua_dict_set_usertype(L, TUNIT); - } - else if (tolua_isusertype(L, 3, TOLUA_CAST "faction", 0, &tolua_err)) { - return tolua_dict_set_usertype(L, TFACTION); - } - else if (tolua_isusertype(L, 3, TOLUA_CAST "ship", 0, &tolua_err)) { - return tolua_dict_set_usertype(L, TSHIP); - } - else if (tolua_isusertype(L, 3, TOLUA_CAST "building", 0, &tolua_err)) { - return tolua_dict_set_usertype(L, TBUILDING); - } - else if (tolua_isusertype(L, 3, TOLUA_CAST "region", 0, &tolua_err)) { - return tolua_dict_set_usertype(L, TREGION); - } - return tolua_dict_set_string(L); -} - -void tolua_dict_open(lua_State * L) -{ - /* register user types */ - tolua_usertype(L, USERTYPE_DICT); - - tolua_module(L, NULL, 0); - tolua_beginmodule(L, NULL); - { - tolua_cclass(L, USERTYPE_DICT, USERTYPE_DICT, - TOLUA_CAST "", NULL); - tolua_beginmodule(L, USERTYPE_DICT); - { - tolua_function(L, TOLUA_CAST "get", tolua_dict_get); - tolua_function(L, TOLUA_CAST "set", tolua_dict_set); - } - tolua_endmodule(L); - } - tolua_endmodule(L); -} diff --git a/src/bind_dict.h b/src/bind_dict.h deleted file mode 100644 index 83ca1efbf..000000000 --- a/src/bind_dict.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#define USERTYPE_DICT ((char *)"dict") - - struct lua_State; - void tolua_dict_open(struct lua_State *L); - - typedef struct attrib **dict; - -#ifdef __cplusplus -} -#endif diff --git a/src/bind_faction.c b/src/bind_faction.c index f5c393de6..749bb65f6 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -13,7 +13,6 @@ without prior permission by the authors of Eressea. #include #include "bind_faction.h" #include "bind_unit.h" -#include "bind_dict.h" #include "bindings.h" #include "helpers.h" @@ -27,7 +26,9 @@ without prior permission by the authors of Eressea. #include #include #include +#include +#include #include #include #include @@ -241,6 +242,32 @@ static int tolua_faction_addnotice(lua_State * L) return 0; } +static int tolua_faction_getkey(lua_State * L) +{ + faction *self = (faction *)tolua_tousertype(L, 1, 0); + const char *name = tolua_tostring(L, 2, 0); + int flag = atoi36(name); + + lua_pushboolean(L, key_get(self->attribs, flag)); + return 1; +} + +static int tolua_faction_setkey(lua_State * L) +{ + faction *self = (faction *)tolua_tousertype(L, 1, 0); + const char *name = tolua_tostring(L, 2, 0); + int value = tolua_toboolean(L, 3, 0); + int flag = atoi36(name); + + if (value) { + key_set(&self->attribs, flag); + } + else { + key_unset(&self->attribs, flag); + } + return 0; +} + static int tolua_faction_count_msg_type(lua_State *L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); const char *str = tolua_tostring(L, 2, 0); @@ -258,13 +285,6 @@ static int tolua_faction_count_msg_type(lua_State *L) { return 1; } -static int tolua_faction_get_objects(lua_State * L) -{ - faction *self = (faction *)tolua_tousertype(L, 1, 0); - tolua_pushusertype(L, (void *)&self->attribs, USERTYPE_DICT); - return 1; -} - static int tolua_faction_get_policy(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); @@ -618,8 +638,8 @@ void tolua_faction_open(lua_State * L) /* tech debt hack, siehe https://paper.dropbox.com/doc/Weihnachten-2015-5tOx5r1xsgGDBpb0gILrv#:h=Probleme-mit-Tests-(Nachtrag-0 */ tolua_function(L, TOLUA_CAST "count_msg_type", tolua_faction_count_msg_type); - tolua_variable(L, TOLUA_CAST "objects", tolua_faction_get_objects, - NULL); + tolua_function(L, TOLUA_CAST "get_key", tolua_faction_getkey); + tolua_function(L, TOLUA_CAST "set_key", tolua_faction_setkey); } tolua_endmodule(L); } diff --git a/src/bind_region.c b/src/bind_region.c index 2e328dc96..d9956c8b6 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -14,7 +14,6 @@ without prior permission by the authors of Eressea. #include "bind_region.h" #include "bind_unit.h" #include "bind_ship.h" -#include "bind_dict.h" #include "bind_building.h" #include "chaos.h" @@ -36,10 +35,11 @@ without prior permission by the authors of Eressea. #include #include -#include #include #include +#include + #include #include @@ -434,13 +434,6 @@ static int tolua_region_set_resource(lua_State * L) return 0; } -static int tolua_region_get_objects(lua_State * L) -{ - region *self = (region *)tolua_tousertype(L, 1, 0); - tolua_pushusertype(L, (void *)&self->attribs, USERTYPE_DICT); - return 1; -} - static int tolua_region_destroy(lua_State * L) { region *self = (region *)tolua_tousertype(L, 1, 0); @@ -733,8 +726,6 @@ void tolua_region_open(lua_State * L) tolua_function(L, TOLUA_CAST "get_key", tolua_region_getkey); tolua_function(L, TOLUA_CAST "set_key", tolua_region_setkey); - - tolua_variable(L, TOLUA_CAST "objects", tolua_region_get_objects, 0); } tolua_endmodule(L); diff --git a/src/bind_unit.c b/src/bind_unit.c index 1983e0f62..c0939b5cf 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -13,7 +13,6 @@ without prior permission by the authors of Eressea. #include #include "bind_unit.h" -#include "bind_dict.h" #include "alchemy.h" #include "bindings.h" #include "move.h" @@ -67,12 +66,6 @@ static int tolua_bufunit(lua_State * L) { return 1; } -static int tolua_unit_get_objects(lua_State * L) -{ - unit *self = (unit *)tolua_tousertype(L, 1, 0); - tolua_pushusertype(L, (void *)&self->attribs, USERTYPE_DICT); - return 1; -} int tolua_unitlist_nextf(lua_State * L) { @@ -1013,7 +1006,6 @@ void tolua_unit_open(lua_State * L) tolua_unit_set_race); tolua_variable(L, TOLUA_CAST "hp_max", &tolua_unit_get_hpmax, 0); - tolua_variable(L, TOLUA_CAST "objects", &tolua_unit_get_objects, 0); tolua_function(L, TOLUA_CAST "show", &tolua_bufunit); } tolua_endmodule(L); diff --git a/src/bindings.c b/src/bindings.c index 1515c74e0..2e4ed3dc6 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -15,7 +15,6 @@ without prior permission by the authors of Eressea. #include "bind_unit.h" #include "bind_storage.h" #include "bind_building.h" -#include "bind_dict.h" #include "bind_message.h" #include "bind_building.h" #include "bind_faction.h" @@ -1143,7 +1142,6 @@ lua_State *lua_init(const dictionary *inifile) { tolua_unit_open(L); tolua_message_open(L); tolua_order_open(L); - tolua_dict_open(L); #ifdef USE_CURSES tolua_gmtool_open(L); #endif From 40de740a0aa06e6b036ca9fe03b1f0a4fee3dc74 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Feb 2017 22:24:36 +0100 Subject: [PATCH 505/675] remove dict from ships and buildings, too --- src/bind_building.c | 9 --------- src/bind_ship.c | 10 ---------- 2 files changed, 19 deletions(-) diff --git a/src/bind_building.c b/src/bind_building.c index f8cf4e6df..ea689bfb5 100644 --- a/src/bind_building.c +++ b/src/bind_building.c @@ -13,7 +13,6 @@ without prior permission by the authors of Eressea. #include #include "bind_building.h" #include "bind_unit.h" -#include "bind_dict.h" #include #include @@ -41,13 +40,6 @@ int tolua_buildinglist_next(lua_State * L) return 0; /* no more values to return */ } -static int tolua_building_get_objects(lua_State * L) -{ - building *self = (building *)tolua_tousertype(L, 1, 0); - tolua_pushusertype(L, (void *)&self->attribs, USERTYPE_DICT); - return 1; -} - static int tolua_building_set_working(lua_State * L) { building *self = (building *)tolua_tousertype(L, 1, 0); @@ -258,7 +250,6 @@ void tolua_building_open(lua_State * L) tolua_variable(L, TOLUA_CAST "size", tolua_building_get_size, tolua_building_set_size); tolua_function(L, TOLUA_CAST "get_typename", tolua_building_get_typename); - tolua_variable(L, TOLUA_CAST "objects", tolua_building_get_objects, 0); tolua_variable(L, TOLUA_CAST "working", tolua_building_get_working, tolua_building_set_working); } diff --git a/src/bind_ship.c b/src/bind_ship.c index 95006cf5f..515fa8de3 100644 --- a/src/bind_ship.c +++ b/src/bind_ship.c @@ -13,7 +13,6 @@ without prior permission by the authors of Eressea. #include #include "bind_ship.h" #include "bind_unit.h" -#include "bind_dict.h" #include "move.h" @@ -115,13 +114,6 @@ static int tolua_ship_get_units(lua_State * L) return 1; } -static int tolua_ship_get_objects(lua_State * L) -{ - ship *self = (ship *)tolua_tousertype(L, 1, 0); - tolua_pushusertype(L, (void *)&self->attribs, USERTYPE_DICT); - return 1; -} - static int tolua_ship_create(lua_State * L) { region *r = (region *)tolua_tousertype(L, 1, 0); @@ -233,8 +225,6 @@ void tolua_ship_open(lua_State * L) tolua_variable(L, TOLUA_CAST "type", tolua_ship_get_type, 0); tolua_variable(L, TOLUA_CAST "damage", tolua_ship_get_damage, tolua_ship_set_damage); - tolua_variable(L, TOLUA_CAST "objects", tolua_ship_get_objects, 0); - tolua_function(L, TOLUA_CAST "create", tolua_ship_create); } tolua_endmodule(L); From f6fcd392934fbaa90d2edb72421114da09d6f564 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Feb 2017 22:28:57 +0100 Subject: [PATCH 506/675] add a failing test for familiars (disabled). remove superfluous init_locales calls. --- src/bind_config.c | 1 - src/kernel/save.c | 1 - src/laws.c | 1 - src/magic.test.c | 20 ++++++++++++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/bind_config.c b/src/bind_config.c index c603800ed..b4aa68d58 100644 --- a/src/bind_config.c +++ b/src/bind_config.c @@ -20,7 +20,6 @@ #include "kernel/terrain.h" void config_reset(void) { - default_locale = 0; free_config(); free_nrmesssages(); free_spells(); diff --git a/src/kernel/save.c b/src/kernel/save.c index 8ec797e68..67ed7e125 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1470,7 +1470,6 @@ int readgame(const char *filename) FILE *F; size_t sz; - init_locales(); log_debug("- reading game data from %s", filename); join_path(datapath(), filename, path, sizeof(path)); diff --git a/src/laws.c b/src/laws.c index 78ca6fba9..98ff5d9f6 100644 --- a/src/laws.c +++ b/src/laws.c @@ -4196,7 +4196,6 @@ void init_processor(void) void processorders(void) { - init_locales(); init_processor(); process(); /*************************************************/ diff --git a/src/magic.test.c b/src/magic.test.c index 4a6078589..07a6d5257 100644 --- a/src/magic.test.c +++ b/src/magic.test.c @@ -2,6 +2,7 @@ #include "magic.h" #include "teleport.h" +#include "give.h" #include #include @@ -448,6 +449,24 @@ static void test_max_spellpoints(CuTest *tc) { test_cleanup(); } +static void test_familiar_mage(CuTest *tc) { + unit *um, *uf, *ut; + test_setup(); + um = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + uf = test_create_unit(um->faction, um->region); + ut = test_create_unit(um->faction, um->region); + set_number(ut, 0); + CuAssertTrue(tc, create_newfamiliar(um, uf)); + CuAssertTrue(tc, is_familiar(uf)); + CuAssertTrue(tc, !is_familiar(um)); + CuAssertPtrEquals(tc, um, get_familiar_mage(uf)); + CuAssertPtrEquals(tc, uf, get_familiar(um)); + + CuAssertPtrEquals(tc, NULL, give_men(1, um, ut, NULL)); + CuAssertPtrEquals(tc, ut, get_familiar_mage(uf)); + test_cleanup(); +} + CuSuite *get_magic_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -465,5 +484,6 @@ CuSuite *get_magic_suite(void) SUITE_ADD_TEST(suite, test_hasspell); SUITE_ADD_TEST(suite, test_magic_resistance); SUITE_ADD_TEST(suite, test_max_spellpoints); + DISABLE_TEST(suite, test_familiar_mage); return suite; } From b56538e0923475992d62e0e875c252f21d67bc53 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Feb 2017 22:37:15 +0100 Subject: [PATCH 507/675] remove test for dicts --- scripts/tests/common.lua | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 670060816..96673bfd3 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -330,17 +330,6 @@ function test_message() return msg end -function test_hashtable() - local f = faction.create("noreply1@eressea.de", "human", "de") - f.objects:set("enno", "smart guy") - f.objects:set("age", 10) - assert(f.objects:get("jesus") == nil) - assert(f.objects:get("enno") == "smart guy") - assert(f.objects:get("age") == 10) - f.objects:set("age", nil) - assert(f.objects:get("age") == nil) -end - function test_events() local fail = 1 local function msg_handler(u, evt) From e5c95f1501a7800eed9ac1f113058715671b7221 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 7 Feb 2017 10:39:54 +0100 Subject: [PATCH 508/675] avoid division by zero when no calendar is configured --- src/kernel/xmlreader.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 6491daf20..d89259317 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -361,7 +361,6 @@ static int parse_calendar(xmlDocPtr doc) xpathCalendars = xmlXPathEvalExpression(BAD_CAST "/eressea/calendar", xpath); nsetCalendars = xpathCalendars->nodesetval; - months_per_year = 0; if (nsetCalendars != NULL && nsetCalendars->nodeNr != 0) { int c; for (c = 0; c != nsetCalendars->nodeNr; ++c) { From 17ff2ead416576937212d7ccb140a2d41e389a64 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 05:52:46 +0100 Subject: [PATCH 509/675] make_locales from config_get --- clibs | 2 +- src/kernel/xmlreader.c | 4 ---- src/main.c | 6 +++--- src/util/language.c | 6 +++--- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/clibs b/clibs index 27c8b3202..f91ef37f0 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 +Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index d89259317..5ce6800ef 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -66,10 +66,6 @@ static void xml_readtext(xmlNodePtr node, struct locale **lang, xmlChar ** text) xmlChar *propValue = xmlGetProp(node, BAD_CAST "locale"); assert(propValue != NULL); *lang = get_locale((const char *)propValue); -#ifdef MAKE_LOCALES - if (*lang == NULL) - *lang = get_or_create_locale((const char *)propValue); -#endif xmlFree(propValue); *text = xmlNodeListGetString(node->doc, node->children, 1); diff --git a/src/main.c b/src/main.c index a3bcdb866..875a33bf9 100644 --- a/src/main.c +++ b/src/main.c @@ -70,15 +70,13 @@ static void load_inifile(dictionary * d) lomem = iniparser_getint(d, "game:lomem", lomem) ? 1 : 0; verbosity = iniparser_getint(d, "game:verbose", 2); - str = iniparser_getstring(d, "game:locales", "de,en"); - make_locales(str); } static dictionary *parse_config(const char *filename) { char path[MAX_PATH]; dictionary *d; - const char *cfgpath = config_get("config.path"); + const char *str, *cfgpath = config_get("config.path"); if (cfgpath) { join_path(cfgpath, filename, path, sizeof(path)); @@ -99,6 +97,8 @@ static dictionary *parse_config(const char *filename) gm_codepage = iniparser_getint(d, "editor:codepage", gm_codepage); #endif } + str = config_get("game.locales"); + make_locales(str ? str : "de,en"); return d; } diff --git a/src/util/language.c b/src/util/language.c index 86a6895be..3f628036d 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -327,10 +327,10 @@ static int locale_init = 0; void init_locales(void) { - int l; + locale * lang; if (locale_init) return; - for (l = 0; localenames[l]; ++l) { - struct locale *lang = get_or_create_locale(localenames[l]); + assert(locales); + for (lang = locales; lang; lang = lang->next) { init_locale(lang); } locale_init = 1; From 6893248473d740557197b2f4d5405c5197f84c6f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 06:06:33 +0100 Subject: [PATCH 510/675] jsonconf should not need to create locales --- src/kernel/jsonconf.c | 8 ++++---- src/kernel/jsonconf.test.c | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 7a074a410..89219665e 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -654,7 +654,7 @@ static void json_strings(cJSON *json) { } for (child = json->child; child; child = child->next) { if (child->type == cJSON_Object) { - struct locale *lang = get_or_create_locale(child->string); + struct locale *lang = get_locale(child->string); json_locale(child, lang); } else { @@ -695,7 +695,7 @@ static void json_directions(cJSON *json) { return; } for (child = json->child; child; child = child->next) { - struct locale * lang = get_or_create_locale(child->string); + struct locale * lang = get_locale(child->string); json_direction(child, lang); } } @@ -771,7 +771,7 @@ static void json_skills(cJSON *json) { return; } for (child = json->child; child; child = child->next) { - struct locale * lang = get_or_create_locale(child->string); + struct locale * lang = get_locale(child->string); json_skill(child, lang); } } @@ -783,7 +783,7 @@ static void json_keywords(cJSON *json) { return; } for (child = json->child; child; child = child->next) { - struct locale * lang = get_or_create_locale(child->string); + struct locale * lang = get_locale(child->string); json_keyword(child, lang); } } diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 7c591f075..abf64e7d5 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -600,9 +600,10 @@ static void test_infinitive_from_config(CuTest *tc) { cJSON *json = cJSON_Parse(data); CuAssertPtrNotNull(tc, json); + test_setup(); + lang = get_or_create_locale("de"); json_config(json); - lang = get_or_create_locale("de"); CuAssertIntEquals(tc, K_STUDY, get_keyword("LERN", lang)); CuAssertIntEquals(tc, K_STUDY, get_keyword("LERNE", lang)); CuAssertIntEquals(tc, K_STUDY, get_keyword("LERNEN", lang)); From ac8250ecd85b1cb31c2164b236abf867a542975e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 06:14:29 +0100 Subject: [PATCH 511/675] remove global read_orders binding --- src/bindings.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index 2e4ed3dc6..21f2aad58 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -223,14 +223,6 @@ static int tolua_rng_int(lua_State * L) return 1; } -static int tolua_read_orders(lua_State * L) -{ - const char *filename = tolua_tostring(L, 1, 0); - int result = readorders(filename); - lua_pushinteger(L, result); - return 1; -} - static int tolua_message_unit(lua_State * L) { unit *sender = (unit *)tolua_tousertype(L, 1, 0); @@ -1072,8 +1064,6 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile) tolua_function(L, TOLUA_CAST "factions", tolua_get_factions); tolua_function(L, TOLUA_CAST "regions", tolua_get_regions); tolua_function(L, TOLUA_CAST "read_turn", tolua_read_turn); -// tolua_function(L, TOLUA_CAST "write_map", &tolua_write_map); - tolua_function(L, TOLUA_CAST "read_orders", tolua_read_orders); tolua_function(L, TOLUA_CAST "process_orders", tolua_process_orders); tolua_function(L, TOLUA_CAST "init_reports", tolua_init_reports); tolua_function(L, TOLUA_CAST "write_reports", tolua_write_reports); From 75514014bc7769963d82cb7e8368118b6cbcf654 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 06:20:37 +0100 Subject: [PATCH 512/675] no need to create locale here --- src/reports.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reports.c b/src/reports.c index 318660024..f904f5799 100644 --- a/src/reports.c +++ b/src/reports.c @@ -157,7 +157,7 @@ size_t report_status(const unit * u, const struct locale *lang, char *fsbuf, siz if (!status) { const char *lname = locale_name(lang); - struct locale *wloc = get_or_create_locale(lname); + struct locale *wloc = get_locale(lname); log_warning("no translation for combat status %s in %s", combatstatus[u->status], lname); locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]+7); len = strlcpy(fsbuf, combatstatus[u->status]+7, buflen); From a4bd4320e538db848d2e523ebc110e0ad84fc007 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 06:24:25 +0100 Subject: [PATCH 513/675] fix bad read_orders call --- scripts/run-turn.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run-turn.lua b/scripts/run-turn.lua index 92efa8a14..9118ed8ee 100644 --- a/scripts/run-turn.lua +++ b/scripts/run-turn.lua @@ -146,7 +146,7 @@ function process(rules, orders) init_summary() -- run the turn: - if read_orders(orders) ~= 0 then + if eressea.read_orders(orders) ~= 0 then print("could not read " .. orders) return -1 end From b05c2564e52e212076d62568b36eba9c24d67c5f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 13:22:44 +0100 Subject: [PATCH 514/675] make att_modification not crash when a good/bad dream curse has no magician. --- clibs | 2 +- conf/e2/locales.xml | 12 ++++++++++++ src/kernel/curse.h | 2 +- src/kernel/unit.c | 2 +- src/spells.c | 6 +++--- 5 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 conf/e2/locales.xml diff --git a/clibs b/clibs index f91ef37f0..27c8b3202 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c +Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 diff --git a/conf/e2/locales.xml b/conf/e2/locales.xml new file mode 100644 index 000000000..f71525343 --- /dev/null +++ b/conf/e2/locales.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/kernel/curse.h b/src/kernel/curse.h index 4cff4f9a1..543755c2b 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -210,7 +210,7 @@ extern "C" { typedef struct curse { variant data; /* pointer auf spezielle curse-unterstructs */ struct curse *nexthash; - const curse_type *type; /* Zeiger auf ein curse_type-struct */ + const curse_type *type; /* Zeiger auf ein curse_type-struct */ struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */ double vigour; /* Strke der Verzauberung, Widerstand gegen Antimagie */ double effect; diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 27a296a15..f92916b2f 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1301,7 +1301,7 @@ static int att_modification(const unit * u, skill_t sk) while (a && a->type == &at_curse) { curse *c = (curse *)a->data.v; - if (curse_active(c) && c->type == gbdream_ct) { + if (c->magician && curse_active(c) && c->type == gbdream_ct) { int effect = curse_geteffect_int(c); bool allied = alliedunit(c->magician, u->faction, HELP_GUARD); if (allied) { diff --git a/src/spells.c b/src/spells.c index e936a46a2..19c1e81f8 100644 --- a/src/spells.c +++ b/src/spells.c @@ -4726,7 +4726,7 @@ static int sp_gbdreams(castorder * co, const char *curse_name, int effect) /* Erfolg melden */ ADDMSG(&mage->faction->msgs, msg_message("regionmagic_effect", - "unit region command", c->magician, mage->region, co->order)); + "unit region command", mage, mage->region, co->order)); return cast_level; } @@ -4867,7 +4867,7 @@ int sp_sweetdreams(castorder * co) effect = 0.05f; c = create_curse(mage, &u->attribs, ct_find("orcish"), power, duration, effect, men); - msg = msg_message("sp_sweetdreams_effect", "mage unit region", c->magician, u, r); + msg = msg_message("sp_sweetdreams_effect", "mage unit region", mage, u, r); r_addmessage(r, mage->faction, msg); if (u->faction != mage->faction) { r_addmessage(r, u->faction, msg); @@ -4892,7 +4892,7 @@ int sp_disturbingdreams(castorder * co) c = create_curse(mage, &r->attribs, ct_find("badlearn"), power, duration, effect, 0); ADDMSG(&mage->faction->msgs, msg_message("sp_disturbingdreams_effect", - "mage region", c->magician, r)); + "mage region", mage, r)); return cast_level; } From 4828045fd7edc52ffba69ca1081be2047f7cd0f2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 18:52:41 +0100 Subject: [PATCH 515/675] there is no NEWATSROI, remove dead code --- src/give.c | 2 +- src/kernel/unit.c | 27 --------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/give.c b/src/give.c index 4f8417bf2..d1a9d75f4 100644 --- a/src/give.c +++ b/src/give.c @@ -227,7 +227,7 @@ static bool can_give_men(const unit *u, const unit *dst, order *ord, message **m if (unit_has_cursed_item(u)) { if (msg) *msg = msg_error(u, ord, 78); } - else if (dst && (has_skill(u, SK_MAGIC) && dst->number > 0)) { + else if (has_skill(u, SK_MAGIC)) { /* cannot give units to and from magicians */ if (msg) *msg = msg_error(u, ord, 158); } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index f92916b2f..2f38a0836 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1245,24 +1245,6 @@ static int item_invis(const unit *u) { + (rsphere ? i_get(u->items, rsphere->itype) * 100 : 0); } -#ifdef NEWATSROI -static int item_modification(const unit * u, skill_t sk, int val) -{ - if (sk == SK_STEALTH) { - if (item_invis(u) >= u->number) { - val += ROIBONUS; - } - } - if (sk == SK_PERCEPTION) { - const struct resource_type *rtype = get_resourcetype(R_AMULET_OF_TRUE_SEEING); - if (i_get(u->items, rtype->itype) >= u->number) { - val += ATSBONUS; - } - } - return val; -} -#endif - static int att_modification(const unit * u, skill_t sk) { double result = 0; @@ -1335,11 +1317,6 @@ int get_modifier(const unit * u, skill_t sk, int level, const region * r, bool n skill += rc_skillmod(u_race(u), r, sk); skill += att_modification(u, sk); -#ifdef NEWATSROI - if (!noitem) { - skill = item_modification(u, sk, skill); - } -#endif skill = skillmod(u->attribs, u, r, sk, skill, SMF_ALWAYS); if (fval(u, UFL_HUNGER)) { @@ -1382,9 +1359,6 @@ int effskill_study(const unit * u, skill_t sk, const region * r) int invisible(const unit * target, const unit * viewer) { -#ifdef NEWATSROI - return 0; -#else if (viewer && viewer->faction == target->faction) return 0; else { @@ -1398,7 +1372,6 @@ int invisible(const unit * target, const unit * viewer) } return hidden; } -#endif } /** remove the unit from memory. From 182fc3fa3c2f574685600498586972bfde848ece Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 19:32:27 +0100 Subject: [PATCH 516/675] remove test for bug 2253 --- src/give.test.c | 6 ------ src/spells.c | 11 ++++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/give.test.c b/src/give.test.c index 029ee7c44..7da787c87 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -124,12 +124,6 @@ static void test_give_men_magicians(CuTest * tc) { CuAssertIntEquals(tc, 1, env.src->number); msg_release(msg); - - set_number(env.dst, 0); - CuAssertPtrEquals(tc, NULL, give_men(1, env.src, env.dst, NULL)); - CuAssertIntEquals(tc, 1, env.dst->number); - CuAssertIntEquals(tc, 0, env.src->number); - p = rpeasants(env.r); CuAssertPtrNotNull(tc, msg = disband_men(1, env.dst, NULL)); CuAssertStrEquals(tc, "give_person_peasants", (const char *)msg->parameters[0].v); diff --git a/src/spells.c b/src/spells.c index 19c1e81f8..b40192016 100644 --- a/src/spells.c +++ b/src/spells.c @@ -4714,7 +4714,6 @@ static int sp_gbdreams(castorder * co, const char *curse_name, int effect) int cast_level = co->level; double power = co->force; region *r = co_get_region(co); - curse *c; /* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken, * also duration+2 */ @@ -4722,8 +4721,8 @@ static int sp_gbdreams(castorder * co, const char *curse_name, int effect) duration = 2 + rng_int() % duration; /* Nichts machen als ein entsprechendes Attribut in die Region legen. */ - c = create_curse(mage, &r->attribs, ct_find(curse_name), power, duration, effect, 0); - + create_curse(mage, &r->attribs, ct_find(curse_name), power, duration, effect, 0); + /* Erfolg melden */ ADDMSG(&mage->faction->msgs, msg_message("regionmagic_effect", "unit region command", mage, mage->region, co->order)); @@ -4841,7 +4840,6 @@ int sp_sweetdreams(castorder * co) /* Schleife ueber alle angegebenen Einheiten */ for (n = 0; n < pa->length; n++) { - curse *c; unit *u; double effect; message *msg; @@ -4865,7 +4863,7 @@ int sp_sweetdreams(castorder * co) /* Nichts machen als ein entsprechendes Attribut an die Einheit legen. */ effect = 0.05f; - c = create_curse(mage, &u->attribs, ct_find("orcish"), power, duration, effect, men); + create_curse(mage, &u->attribs, ct_find("orcish"), power, duration, effect, men); msg = msg_message("sp_sweetdreams_effect", "mage unit region", mage, u, r); r_addmessage(r, mage->faction, msg); @@ -4886,10 +4884,9 @@ int sp_disturbingdreams(castorder * co) double power = co->force; int duration = 1 + (int)(power / 6); double effect; - curse *c; effect = 10; - c = create_curse(mage, &r->attribs, ct_find("badlearn"), power, duration, effect, 0); + create_curse(mage, &r->attribs, ct_find("badlearn"), power, duration, effect, 0); ADDMSG(&mage->faction->msgs, msg_message("sp_disturbingdreams_effect", "mage region", mage, r)); From f132dfe4d46b4b3d695c0a4b756c52d075696413 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 19:57:02 +0100 Subject: [PATCH 517/675] bug 2282: Datenfile 2012 kaputt. make the reader for at_keys accept that sometimes, there are 0 keys. --- src/attributes/key.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/attributes/key.c b/src/attributes/key.c index 0b252e0c0..ae15a38e3 100644 --- a/src/attributes/key.c +++ b/src/attributes/key.c @@ -38,7 +38,10 @@ static void a_writekeys(const attrib *a, const void *o, storage *store) { static int a_readkeys(attrib * a, void *owner, gamedata *data) { int i, *p = 0; READ_INT(data->store, &i); - assert(i < 4096 && i>0); + assert(i < 4096 && i>=0); + if (i == 0) { + return AT_READ_FAIL; + } a->data.v = p = malloc(sizeof(int)*(i + 1)); *p++ = i; while (i--) { From c73c7d4cfdeafc58cf307bcc9bfa984e8109498f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 20:15:54 +0100 Subject: [PATCH 518/675] remove bad extra spaces in build script --- s/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s/build b/s/build index f471229b8..acd338c4a 100755 --- a/s/build +++ b/s/build @@ -35,7 +35,7 @@ git submodule update echo "build eressea" cd $ROOT/$BUILD BRANCH=$(git status -s -b | head -1 | cut -d\ -f 2 | sed 's/\..*//') -if [ "$BRANCH" == "master" ] ; then +if [ "$BRANCH"=="master" ] ; then VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//') cmake -DERESSEA_VERSION="$VERSION" .. else From 3ea12be5642c130fd40a13c7e765e0c66927e14d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 13 Feb 2017 18:48:38 +0100 Subject: [PATCH 519/675] BENUTZE Muschel repariert. at_keys hat jetzt auch zu jedem key ein value, und Funktionen zum Update altee Daten. --- scripts/eressea/embassy.lua | 16 +++++- src/attributes/dict.c | 98 +++++++++++-------------------------- src/attributes/dict.h | 10 ++-- src/attributes/key.c | 62 +++++++++++++---------- src/attributes/key.h | 6 +-- src/attributes/key.test.c | 47 ++++++++++++------ src/bind_faction.c | 6 +-- src/bind_region.c | 4 +- src/bind_unit.c | 2 +- src/bindings.c | 4 +- src/kernel/group.test.c | 4 +- src/kernel/item.c | 2 +- src/kernel/save.test.c | 8 +-- src/util/gamedata.h | 3 +- 14 files changed, 135 insertions(+), 137 deletions(-) diff --git a/scripts/eressea/embassy.lua b/scripts/eressea/embassy.lua index 704581c6f..93ff66d7c 100644 --- a/scripts/eressea/embassy.lua +++ b/scripts/eressea/embassy.lua @@ -5,6 +5,20 @@ if not config.embassy then return nil end local embassy = {} local home = nil +-- global exports (use item) +function use_seashell(u, amount) +-- Muschelplateau... + local visit = u.faction:get_key('mupL') + if visit and u.region~= home then + local turns = get_turn() - visit + local msg = message.create('msg_event') + msg:set_string("string", u.name .. "(" .. itoa36(u.id) .. ") erzählt den Bewohnern von " .. u.region.name .. " von Muschelplateau, das die Partei " .. u.faction.name .. " vor " .. turns .. " Wochen besucht hat." ) + msg:send_region(u.region) + return 0 + end + return -4 +end + function embassy.init() home = get_region(165,30) if home==nil then @@ -20,7 +34,7 @@ function embassy.update() eressea.log.debug("updating embassies in " .. tostring(home)) local u for u in home.units do - if not u.faction:get_key('mupL') then + if u.faction:get_key('mupL')==0 then if (u.faction:add_item('seashell', 1)>0) then eressea.log.debug("new seashell for " .. tostring(u.faction)) u.faction:set_key('mupL', get_turn()) diff --git a/src/attributes/dict.c b/src/attributes/dict.c index 6d4b3ed3c..ad66e3676 100644 --- a/src/attributes/dict.c +++ b/src/attributes/dict.c @@ -42,6 +42,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +typedef enum { + TNONE = 0, TINTEGER = 1 +} dict_type; + typedef struct dict_data { dict_type type; char *name; @@ -62,94 +66,38 @@ static int dict_read(attrib * a, void *owner, gamedata *data) storage *store = data->store; char name[NAMESIZE]; dict_data *dd = (dict_data *)a->data.v; - int result, n; - float flt; + int n; READ_STR(store, name, sizeof(name)); dd->name = strdup(name); READ_INT(store, &n); dd->type = (dict_type)n; - switch (dd->type) { - case TINTEGER: - READ_INT(store, &dd->data.i); - break; - case TREAL: - READ_FLT(store, &flt); - if ((int)flt == flt) { - dd->type = TINTEGER; - dd->data.i = (int)flt; - } - else { - dd->data.real = flt; - } - break; - case TSTRING: - READ_STR(store, name, sizeof(name)); - dd->data.str = strdup(name); - break; - case TBUILDING: - result = - read_reference(&dd->data.b, data, read_building_reference, - resolve_building); - if (result == 0 && !dd->data.b) { - return AT_READ_FAIL; - } - break; - case TUNIT: - result = - read_reference(&dd->data.u, data, read_unit_reference, resolve_unit); - if (result == 0 && !dd->data.u) { - return AT_READ_FAIL; - } - break; - case TFACTION: - result = - read_reference(&dd->data.f, data, read_faction_reference, - resolve_faction); - if (result == 0 && !dd->data.f) { - return AT_READ_FAIL; - } - break; - case TREGION: - result = - read_reference(&dd->data.r, data, read_region_reference, - RESOLVE_REGION(data->version)); - if (result == 0 && !dd->data.r) { - return AT_READ_FAIL; - } - break; - case TSHIP: - /* return read_ship_reference(&data->data.sh, store); */ - assert(!"not implemented"); - break; - case TNONE: - break; - default: + if (dd->type != TINTEGER) { + log_error("read dict, invalid type %d", n); return AT_READ_FAIL; } + READ_INT(store, &dd->data.i); return AT_READ_DEPR; } static void dict_init(attrib * a) { - dict_data *data; + dict_data *dd; a->data.v = malloc(sizeof(dict_data)); - data = (dict_data *)a->data.v; - data->type = TNONE; + dd = (dict_data *)a->data.v; + dd->type = TNONE; } static void dict_done(attrib * a) { - dict_data *data = (dict_data *)a->data.v; - if (data->type == TSTRING) - free(data->data.str); - free(data->name); + dict_data *dd = (dict_data *)a->data.v; + free(dd->name); free(a->data.v); } static void dict_upgrade(attrib **alist, attrib *abegin) { int n = 0, *keys = 0; - int i = 0, val[4]; + int i = 0, val[8]; attrib *a, *ak = a_find(*alist, &at_keys); if (ak) { keys = (int *)ak->data.v; @@ -162,7 +110,9 @@ static void dict_upgrade(attrib **alist, attrib *abegin) { } else { if (strcmp(dd->name, "embassy_muschel")==0) { - val[i++] = atoi36("mupL"); + val[i * 2] = atoi36("mupL"); + val[i * 2 + 1] = dd->data.i; + ++i; } else { log_error("dict conversion, bad entry %s", dd->name); @@ -170,14 +120,14 @@ static void dict_upgrade(attrib **alist, attrib *abegin) { } if (i == 4) { keys = realloc(keys, sizeof(int) * (n + i + 1)); - memcpy(keys + n + 1, val, sizeof(int)*i); + memcpy(keys + n + 1, val, sizeof(val)); n += i; i = 0; } } if (i > 0) { - keys = realloc(keys, sizeof(int) * (n + i + 1)); - memcpy(keys + n + 1, val, sizeof(int)*i); + keys = realloc(keys, sizeof(int) * (2 * (n + i) + 1)); + memcpy(keys + n*2 + 1, val, sizeof(int)*i*2); if (!ak) { ak = a_add(alist, a_new(&at_keys)); } @@ -190,3 +140,11 @@ attrib_type at_dict = { "object", dict_init, dict_done, NULL, NULL, dict_read, dict_upgrade }; + +void dict_set(attrib * a, const char * name, int value) +{ + dict_data *dd = (dict_data *)a->data.v; + dd->name = strdup(name); + dd->type = TINTEGER; + dd->data.i = value; +} diff --git a/src/attributes/dict.h b/src/attributes/dict.h index 7b028fa00..cc700bb9f 100644 --- a/src/attributes/dict.h +++ b/src/attributes/dict.h @@ -13,18 +13,16 @@ #ifndef H_ATTRIBUTE_OBJECT #define H_ATTRIBUTE_OBJECT -#include +struct attrib_type; +struct attrib; #ifdef __cplusplus extern "C" { #endif - typedef enum { - TNONE = 0, TINTEGER = 1, TREAL = 2, TSTRING = 3, - TUNIT = 10, TFACTION = 11, TREGION = 12, TBUILDING = 13, TSHIP = 14 - } dict_type; + extern struct attrib_type at_dict; // DEPRECATED: at_dict has been replaced with at_keys - extern struct attrib_type at_dict; + void dict_set(struct attrib * a, const char * name, int value); #ifdef __cplusplus } diff --git a/src/attributes/key.c b/src/attributes/key.c index 84bbf7c04..904df32be 100644 --- a/src/attributes/key.c +++ b/src/attributes/key.c @@ -30,8 +30,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static void a_writekeys(const attrib *a, const void *o, storage *store) { int i, *keys = (int *)a->data.v; - for (i = 0; i <= keys[0]; ++i) { - WRITE_INT(store, keys[i]); + WRITE_INT(store, keys[0]); + for (i = 0; i < keys[0]; ++i) { + WRITE_INT(store, keys[i * 2 + 1]); + WRITE_INT(store, keys[i * 2 + 2]); } } @@ -42,10 +44,16 @@ static int a_readkeys(attrib * a, void *owner, gamedata *data) { if (i == 0) { return AT_READ_FAIL; } - a->data.v = p = malloc(sizeof(int)*(i + 1)); + a->data.v = p = malloc(sizeof(int)*(i*2 + 1)); *p++ = i; while (i--) { READ_INT(data->store, p++); + if (data->version >= KEYVAL_VERSION) { + READ_INT(data->store, p++); + } + else { + *p++ = 1; + } } return AT_READ_OK; } @@ -71,24 +79,25 @@ attrib_type at_keys = { static void a_upgradekeys(attrib **alist, attrib *abegin) { int n = 0, *keys = 0; - int i = 0, val[4]; + int i = 0, val[8]; attrib *a, *ak = a_find(*alist, &at_keys); if (ak) { keys = (int *)ak->data.v; if (keys) n = keys[0]; } for (a = abegin; a && a->type == abegin->type; a = a->next) { - val[i++] = a->data.i; - if (i == 4) { - keys = realloc(keys, sizeof(int) * (n + i + 1)); - memcpy(keys + n + 1, val, sizeof(int)*i); + val[i * 2] = a->data.i; + val[i * 2 + 1] = 1; + if (++i == 4) { + keys = realloc(keys, sizeof(int) * (2 * (n + i) + 1)); + memcpy(keys + 2 * n + 1, val, sizeof(val)); n += i; i = 0; } } if (i > 0) { - keys = realloc(keys, sizeof(int) * (n + i + 1)); - memcpy(keys + n + 1, val, sizeof(int)*i); + keys = realloc(keys, sizeof(int) * (2 * (n + i) + 1)); + memcpy(keys + 2 * n + 1, val, sizeof(int)*i*2); if (!ak) { ak = a_add(alist, a_new(&at_keys)); } @@ -107,9 +116,9 @@ attrib_type at_key = { a_upgradekeys }; -void key_set(attrib ** alist, int key) +void key_set(attrib ** alist, int key, int val) { - int *keys, n = 1; + int *keys, n = 0; attrib *a; assert(key != 0); a = a_find(*alist, &at_keys); @@ -118,12 +127,13 @@ void key_set(attrib ** alist, int key) } keys = (int *)a->data.v; if (keys) { - n = keys[0] + 1; + n = keys[0]; } - keys = realloc(keys, sizeof(int) *(n + 1)); - // TODO: does insertion sort pay off here? - keys[0] = n; - keys[n] = key; + keys = realloc(keys, sizeof(int) *(2 * n + 3)); + // TODO: does insertion sort pay off here? prob. not. + keys[0] = n + 1; + keys[2 * n + 1] = key; + keys[2 * n + 2] = val; a->data.v = keys; } @@ -135,29 +145,31 @@ void key_unset(attrib ** alist, int key) if (a) { int i, *keys = (int *)a->data.v; if (keys) { - for (i = 1; i <= keys[0]; ++i) { - if (keys[i] == key) { - keys[i] = keys[keys[0]]; + int n = keys[0]; + for (i = 0; i != n; ++i) { + if (keys[2 * i + 1] == key) { + memmove(keys + 2 * i + 1, keys + 2 * n - 1, 2 * sizeof(int)); keys[0]--; + break; } } } } } -bool key_get(attrib *alist, int key) { +int key_get(attrib *alist, int key) { attrib *a; assert(key != 0); a = a_find(alist, &at_keys); if (a) { int i, *keys = (int *)a->data.v; if (keys) { - for (i = 1; i <= keys[0]; ++i) { - if (keys[i] == key) { - return true; + for (i = 0; i != keys[0]; ++i) { + if (keys[i*2+1] == key) { + return keys[i * 2 + 2]; } } } } - return false; + return 0; } diff --git a/src/attributes/key.h b/src/attributes/key.h index d2cea1ff0..81511d248 100644 --- a/src/attributes/key.h +++ b/src/attributes/key.h @@ -26,12 +26,12 @@ extern "C" { #endif struct attrib; struct attrib_type; - extern struct attrib_type at_key; + extern struct attrib_type at_key; // DEPRECATED: at_key has been replaced with at_keys extern struct attrib_type at_keys; - void key_set(struct attrib **alist, int key); + void key_set(struct attrib **alist, int key, int value); void key_unset(struct attrib **alist, int key); - bool key_get(struct attrib *alist, int key); + int key_get(struct attrib *alist, int key); #ifdef __cplusplus } diff --git a/src/attributes/key.test.c b/src/attributes/key.test.c index 2b7632917..b816e1d86 100644 --- a/src/attributes/key.test.c +++ b/src/attributes/key.test.c @@ -1,22 +1,24 @@ #include #include "key.h" +#include "dict.h" #include +#include #include #include static void test_get_set_keys(CuTest *tc) { attrib *a = 0; - key_set(&a, 42); - key_set(&a, 43); - key_set(&a, 44); - CuAssertTrue(tc, key_get(a, 42)); - CuAssertTrue(tc, key_get(a, 43)); - CuAssertTrue(tc, key_get(a, 44)); + key_set(&a, 42, 1); + key_set(&a, 43, 2); + key_set(&a, 44, 3); + CuAssertIntEquals(tc, 1, key_get(a, 42)); + CuAssertIntEquals(tc, 2, key_get(a, 43)); + CuAssertIntEquals(tc, 3, key_get(a, 44)); key_unset(&a, 42); - CuAssertTrue(tc, !key_get(a, 42)); - CuAssertTrue(tc, key_get(a, 43)); - CuAssertTrue(tc, key_get(a, 44)); + CuAssertIntEquals(tc, 0, key_get(a, 42)); + CuAssertIntEquals(tc, 2, key_get(a, 43)); + CuAssertIntEquals(tc, 3, key_get(a, 44)); a_removeall(&a, NULL); } @@ -26,7 +28,7 @@ static attrib *key_set_orig(attrib **alist, int key) { return a; } -static void test_upgrade(CuTest *tc) { +static void test_upgrade_key(CuTest *tc) { attrib *alist = 0; key_set_orig(&alist, 40); key_set_orig(&alist, 41); @@ -35,18 +37,31 @@ static void test_upgrade(CuTest *tc) { key_set_orig(&alist, 44); CuAssertPtrNotNull(tc, alist->type->upgrade); alist->type->upgrade(&alist, alist); - CuAssertTrue(tc, key_get(alist, 40)); - CuAssertTrue(tc, key_get(alist, 41)); - CuAssertTrue(tc, key_get(alist, 42)); - CuAssertTrue(tc, key_get(alist, 43)); - CuAssertTrue(tc, key_get(alist, 44)); + CuAssertIntEquals(tc, 1, key_get(alist, 40)); + CuAssertIntEquals(tc, 1, key_get(alist, 41)); + CuAssertIntEquals(tc, 1, key_get(alist, 42)); + CuAssertIntEquals(tc, 1, key_get(alist, 43)); + CuAssertIntEquals(tc, 1, key_get(alist, 44)); a_removeall(&alist, NULL); } +static void test_upgrade_dict(CuTest *tc) { + attrib *a; + + a = a_new(&at_dict); + + dict_set(a, "embassy_muschel", 42); + CuAssertPtrNotNull(tc, a->type->upgrade); + a->type->upgrade(&a, a); + CuAssertIntEquals(tc, 42, key_get(a, atoi36("mupL"))); + a_removeall(&a, NULL); +} + CuSuite *get_key_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_get_set_keys); - SUITE_ADD_TEST(suite, test_upgrade); + SUITE_ADD_TEST(suite, test_upgrade_key); + SUITE_ADD_TEST(suite, test_upgrade_dict); return suite; } diff --git a/src/bind_faction.c b/src/bind_faction.c index 749bb65f6..371481fcb 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -248,7 +248,7 @@ static int tolua_faction_getkey(lua_State * L) const char *name = tolua_tostring(L, 2, 0); int flag = atoi36(name); - lua_pushboolean(L, key_get(self->attribs, flag)); + lua_pushinteger(L, key_get(self->attribs, flag)); return 1; } @@ -256,11 +256,11 @@ static int tolua_faction_setkey(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); const char *name = tolua_tostring(L, 2, 0); - int value = tolua_toboolean(L, 3, 0); + int value = (int)tolua_tonumber(L, 3, 0); int flag = atoi36(name); if (value) { - key_set(&self->attribs, flag); + key_set(&self->attribs, flag, value); } else { key_unset(&self->attribs, flag); diff --git a/src/bind_region.c b/src/bind_region.c index d9956c8b6..51a5bedd4 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -544,11 +544,11 @@ static int tolua_region_setkey(lua_State * L) { region *self = (region *)tolua_tousertype(L, 1, 0); const char *name = tolua_tostring(L, 2, 0); - int value = tolua_toboolean(L, 3, 0); + int value = (int)tolua_tonumber(L, 3, 0); int flag = atoi36(name); if (value) { - key_set(&self->attribs, flag); + key_set(&self->attribs, flag, value); } else { key_unset(&self->attribs, flag); diff --git a/src/bind_unit.c b/src/bind_unit.c index c0939b5cf..a9d413bf0 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -786,7 +786,7 @@ static int tolua_unit_set_flag(lua_State * L) int value = (int)tolua_tonumber(L, 3, 0); int flag = atoi36(name); if (value) { - key_set(&self->attribs, flag); + key_set(&self->attribs, flag, value); } else { key_unset(&self->attribs, flag); diff --git a/src/bindings.c b/src/bindings.c index 21f2aad58..531b68618 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -206,10 +206,10 @@ static int tolua_translate(lua_State * L) static int tolua_setkey(lua_State * L) { const char *name = tolua_tostring(L, 1, 0); - int value = tolua_toboolean(L, 2, 0); + int value = (int)tolua_tonumber(L, 3, 0); int flag = atoi36(name); if (value) { - key_set(&global.attribs, flag); + key_set(&global.attribs, flag, value); } else { key_unset(&global.attribs, flag); diff --git a/src/kernel/group.test.c b/src/kernel/group.test.c index 78ee6b24f..e95458114 100644 --- a/src/kernel/group.test.c +++ b/src/kernel/group.test.c @@ -84,7 +84,7 @@ static void test_group_readwrite(CuTest * tc) f = test_create_faction(0); new_group(f, "NW", 42); g = new_group(f, "Egoisten", 43); - key_set(&g->attribs, 44); + key_set(&g->attribs, 44, 44); al = ally_add(&g->allies, f); al->status = HELP_GIVE; write_groups(&store, f); @@ -108,7 +108,7 @@ static void test_group_readwrite(CuTest * tc) CuAssertStrEquals(tc, "Egoisten", f->groups->next->name); CuAssertPtrEquals(tc, 0, f->groups->allies); g = f->groups->next; - CuAssertTrue(tc, key_get(g->attribs, 44)); + CuAssertIntEquals(tc, 44, key_get(g->attribs, 44)); CuAssertPtrNotNull(tc, g->allies); CuAssertPtrEquals(tc, 0, g->allies->next); CuAssertPtrEquals(tc, f, g->allies->faction); diff --git a/src/kernel/item.c b/src/kernel/item.c index 34a0e1875..9327700cd 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -939,7 +939,7 @@ struct order *ord) use_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, user->number); - key_set(&f->attribs, atoi36("mbst")); + key_set(&f->attribs, atoi36("mbst"), turn); set_level(user, SK_MAGIC, 3); ADDMSG(&user->faction->msgs, msg_message("use_item", diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index c05ce4455..70bcb2e65 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -211,8 +211,8 @@ static void test_readwrite_attrib(CuTest *tc) { attrib *a = NULL; test_setup(); - key_set(&a, 41); - key_set(&a, 42); + key_set(&a, 41, 42); + key_set(&a, 42, 43); mstream_init(&data.strm); gamedata_init(&data, &store, RELEASE_VERSION); write_attribs(data.store, a, NULL); @@ -223,8 +223,8 @@ static void test_readwrite_attrib(CuTest *tc) { read_attribs(&data, &a, NULL); mstream_done(&data.strm); gamedata_done(&data); - CuAssertTrue(tc, key_get(a, 41)); - CuAssertTrue(tc, key_get(a, 42)); + CuAssertIntEquals(tc, 42, key_get(a, 41)); + CuAssertIntEquals(tc, 43, key_get(a, 42)); a_removeall(&a, NULL); test_cleanup(); diff --git a/src/util/gamedata.h b/src/util/gamedata.h index bb1632838..75a750452 100644 --- a/src/util/gamedata.h +++ b/src/util/gamedata.h @@ -32,10 +32,11 @@ #define NOCRYPT_VERSION 352 /* passwords are plaintext again */ #define ATHASH_VERSION 353 /* attribute-type hash, not name */ #define NOWATCH_VERSION 354 /* plane->watchers is gone */ +#define KEYVAL_VERSION 355 /* at_keys has values */ /* unfinished: */ #define CRYPT_VERSION 400 /* passwords are encrypted */ -#define RELEASE_VERSION NOWATCH_VERSION /* current datafile */ +#define RELEASE_VERSION KEYVAL_VERSION /* current datafile */ #define MIN_VERSION INTPAK_VERSION /* minimal datafile we support */ #define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */ From aa230cc191b85dbcf40051bb0093e09046b5b6f4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 14 Feb 2017 12:15:36 +0100 Subject: [PATCH 520/675] fix coverity warnings --- src/attributes/key.c | 8 ++++++-- src/kernel/version.c | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/attributes/key.c b/src/attributes/key.c index 904df32be..8b09fdd1c 100644 --- a/src/attributes/key.c +++ b/src/attributes/key.c @@ -102,8 +102,12 @@ static void a_upgradekeys(attrib **alist, attrib *abegin) { ak = a_add(alist, a_new(&at_keys)); } } - ak->data.v = keys; - keys[0] = n + i; + if (ak) { + ak->data.v = keys; + if (keys) { + keys[0] = n + i; + } + } } attrib_type at_key = { diff --git a/src/kernel/version.c b/src/kernel/version.c index 7e8ed01d7..8cf6a372e 100644 --- a/src/kernel/version.c +++ b/src/kernel/version.c @@ -11,8 +11,9 @@ const char *eressea_version(void) { #ifdef ERESSEA_BUILDNO return ERESSEA_VERSION "-" ERESSEA_BUILDNO; -#endif +#else return ERESSEA_VERSION; +#endif } int version_no(const char *str) { From 08e14f3095c6feb62821dd3101d4b13bf6f503c9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 14 Feb 2017 16:23:40 +0100 Subject: [PATCH 521/675] coverity warnings --- src/attributes/dict.c | 8 ++++++-- src/economy.c | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/attributes/dict.c b/src/attributes/dict.c index ad66e3676..36d017b2c 100644 --- a/src/attributes/dict.c +++ b/src/attributes/dict.c @@ -132,8 +132,12 @@ static void dict_upgrade(attrib **alist, attrib *abegin) { ak = a_add(alist, a_new(&at_keys)); } } - ak->data.v = keys; - keys[0] = n + i; + if (ak) { + ak->data.v = keys; + if (keys) { + keys[0] = n + i; + } + } } attrib_type at_dict = { diff --git a/src/economy.c b/src/economy.c index dcbc7431e..dec4517a4 100644 --- a/src/economy.c +++ b/src/economy.c @@ -2707,7 +2707,7 @@ static void expandloot(region * r, request * lootorders) { unit *u; unsigned int i; - int looted = 0; + int m, looted = 0; int startmoney = rmoney(r); expandorders(r, lootorders); @@ -2724,9 +2724,9 @@ static void expandloot(region * r, request * lootorders) free(g_requests); /* Lowering morale by 1 depending on the looted money (+20%) */ - if (rng_int() % 100 < 20 + (looted * 80) / startmoney) { - int m = region_get_morale(r); - if (m) { + m = region_get_morale(r); + if (m && startmoney>0) { + if (rng_int() % 100 < 20 + (looted * 80) / startmoney) { /*Nur Moral -1, turns is not changed, so the first time nothing happens if the morale is good*/ region_set_morale(r, m - 1, -1); } From 623137e872f3bec0f824ff40cdb51914681074bd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 14 Feb 2017 19:57:31 +0100 Subject: [PATCH 522/675] test guardhouse level limits. --- scripts/tests/e3/castles.lua | 52 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/scripts/tests/e3/castles.lua b/scripts/tests/e3/castles.lua index df395ed3d..eafc58b51 100644 --- a/scripts/tests/e3/castles.lua +++ b/scripts/tests/e3/castles.lua @@ -11,30 +11,40 @@ function teardown() eressea.settings.set("rules.food.flags", "0") end +function test_watch() + local r = region.create(0, 0, "plain") + local b = building.create(r, "watch") + + assert_equal("scaffolding", b:get_typename(1)) + assert_equal("scaffolding", b:get_typename(4)) + assert_equal("guardhouse", b:get_typename(5)) + assert_equal("guardhouse", b:get_typename(9)) + assert_equal("guardtower", b:get_typename(10)) +end + function test_small_castles() - local r = region.create(0, 0, "plain") - local f1 = faction.create("noreply@eressea.de", "human", "de") - local u1 = unit.create(f1, r, 1) - local f2 = faction.create("noreply@eressea.de", "halfling", "de") - local u2 = unit.create(f2, r, 1) - u1:add_item("money", 10000) + local r = region.create(0, 0, "plain") + local f1 = faction.create("noreply@eressea.de", "human", "de") + local u1 = unit.create(f1, r, 1) + local f2 = faction.create("noreply@eressea.de", "halfling", "de") + local u2 = unit.create(f2, r, 1) - local b = building.create(r, "castle") - u2.building = b - u1.building = b + local b = building.create(r, "castle") + u2.building = b + u1.building = b - b.owner = u2 - assert_equal("site", b:get_typename(7)) - assert_equal("fortification", b:get_typename(8)) - b.owner = u1 - assert_equal("site", b:get_typename(9)) - assert_equal("fortification", b:get_typename(10)) + b.owner = u2 + assert_equal("site", b:get_typename(7)) + assert_equal("fortification", b:get_typename(8)) + b.owner = u1 + assert_equal("site", b:get_typename(9)) + assert_equal("fortification", b:get_typename(10)) end function test_build_normal() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) u:clear_orders() u:add_item("stone", 10) u:set_skill("building", 10) @@ -45,9 +55,9 @@ function test_build_normal() end function test_build_packice() - local r = region.create(0, 0, "packice") - local f = faction.create("packice@eressea.de", "human", "de") - local u = unit.create(f, r, 1) + local r = region.create(0, 0, "packice") + local f = faction.create("packice@eressea.de", "human", "de") + local u = unit.create(f, r, 1) u:clear_orders() u:add_item("stone", 10) u:set_skill("building", 10) From 1dcb21b08cffe1be5170c0ac4fa77747dfaa686e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 14 Feb 2017 20:30:24 +0100 Subject: [PATCH 523/675] bug 2281: add a failing test https://bugs.eressea.de/view.php?id=2281 --- scripts/tests/e3/castles.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts/tests/e3/castles.lua b/scripts/tests/e3/castles.lua index eafc58b51..b16019159 100644 --- a/scripts/tests/e3/castles.lua +++ b/scripts/tests/e3/castles.lua @@ -11,6 +11,28 @@ function teardown() eressea.settings.set("rules.food.flags", "0") end +function test_build_watch() + local r = region.create(0, 0, "plain") + local f = faction.create("e3build@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + + u.number = 20 + u:add_item("log", 20) + u.id = 42 + + u:set_skill("building", 1) + u:add_order("MACHE Wache") + process_orders() + assert_not_nil(u.building) + assert_equal(5, u.building.size) + + u:set_skill("building", 2) + u:add_order("MACHE Wache " .. itoa36(u.building.id)) + process_orders() + assert_not_nil(u.building) + assert_equal(10, u.building.size) +end + function test_watch() local r = region.create(0, 0, "plain") local b = building.create(r, "watch") From 4ce415be5099ef93f20c9634d1c396a7effa8e5e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 14 Feb 2017 20:51:03 +0100 Subject: [PATCH 524/675] BUG 2281: fix maxsize of guard towers. --- res/e3a/buildings.xml | 2 +- src/kernel/build.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/res/e3a/buildings.xml b/res/e3a/buildings.xml index c1edbcc0b..f65654e2f 100644 --- a/res/e3a/buildings.xml +++ b/res/e3a/buildings.xml @@ -3,7 +3,7 @@ - + diff --git a/src/kernel/build.c b/src/kernel/build.c index dff51cf6c..6b23723e8 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -595,7 +595,7 @@ int build(unit * u, const construction * ctype, int completed, int want) else break; } - if (type->materials) + if (type->materials) { for (c = 0; type->materials[c].number; c++) { const struct resource_type *rtype = type->materials[c].rtype; int prebuilt = @@ -620,6 +620,7 @@ int build(unit * u, const construction * ctype, int completed, int want) use_pooled(u, rtype, GET_DEFAULT, (need - prebuilt + multi - 1) / multi); } + } made += n; skills -= n * type->minskill; want -= n; From 794710189940fec22b1a02ccef5a36681f56cdfd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 14 Feb 2017 21:01:22 +0100 Subject: [PATCH 525/675] factor out some function to make future debugging easier. --- src/kernel/build.c | 131 ++++++++++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 56 deletions(-) diff --git a/src/kernel/build.c b/src/kernel/build.c index 6b23723e8..78bcd6b8f 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -428,6 +428,76 @@ int roqf_factor(void) return value; } +static int use_materials(unit *u, const construction *type, int n, int completed) { + if (type->materials) { + int c; + for (c = 0; type->materials[c].number; c++) { + const struct resource_type *rtype = type->materials[c].rtype; + int prebuilt = + required(completed, type->reqsize, type->materials[c].number); + int need = + required(completed + n, type->reqsize, type->materials[c].number); + int multi = 1; + int canuse = 100; /* normalization */ + if (building_is_active(u->building) && inside_building(u)) { + canuse = matmod(u->building->type->attribs, u, rtype, canuse); + } + if (canuse < 0) { + return canuse; /* pass errors to caller */ + } + canuse = matmod(type->attribs, u, rtype, canuse); + + assert(canuse % 100 == 0 + || !"only constant multipliers are implemented in build()"); + multi = canuse / 100; + if (canuse < 0) { + return canuse; /* pass errors to caller */ + } + use_pooled(u, rtype, GET_DEFAULT, + (need - prebuilt + multi - 1) / multi); + } + } + return 0; +} + +static int count_materials(unit *u, const construction *type, int n, int completed) +{ + if (type->materials) { + int c; + for (c = 0; n > 0 && type->materials[c].number; c++) { + const struct resource_type *rtype = type->materials[c].rtype; + int need, prebuilt; + int canuse = get_pooled(u, rtype, GET_DEFAULT, INT_MAX); + + if (building_is_active(u->building) && inside_building(u)) { + canuse = matmod(u->building->type->attribs, u, rtype, canuse); + } + + if (canuse < 0) + return canuse; /* pass errors to caller */ + canuse = matmod(type->attribs, u, rtype, canuse); + if (type->reqsize > 1) { + prebuilt = + required(completed, type->reqsize, type->materials[c].number); + for (; n;) { + need = + required(completed + n, type->reqsize, type->materials[c].number); + if (need - prebuilt <= canuse) + break; + --n; /* TODO: optimieren? */ + } + } + else { + int maxn = canuse / type->materials[c].number; + if (maxn < n) { + n = maxn; + } + } + } + } + return n; +} + /** Use up resources for building an object. * Build up to 'size' points of 'type', where 'completed' * of the first object have already been finished. return the @@ -492,7 +562,7 @@ int build(unit * u, const construction * ctype, int completed, int want) } } for (; want > 0 && skills > 0;) { - int c, n; + int err, n; /* skip over everything that's already been done: * type->improvement==NULL means no more improvements, but no size limits @@ -559,67 +629,16 @@ int build(unit * u, const construction * ctype, int completed, int want) } } - if (type->materials) - for (c = 0; n > 0 && type->materials[c].number; c++) { - const struct resource_type *rtype = type->materials[c].rtype; - int need, prebuilt; - int canuse = get_pooled(u, rtype, GET_DEFAULT, INT_MAX); - - if (building_is_active(u->building) && inside_building(u)) { - canuse = matmod(u->building->type->attribs, u, rtype, canuse); - } - - if (canuse < 0) - return canuse; /* pass errors to caller */ - canuse = matmod(type->attribs, u, rtype, canuse); - if (type->reqsize > 1) { - prebuilt = - required(completed, type->reqsize, type->materials[c].number); - for (; n;) { - need = - required(completed + n, type->reqsize, type->materials[c].number); - if (need - prebuilt <= canuse) - break; - --n; /* TODO: optimieren? */ - } - } - else { - int maxn = canuse / type->materials[c].number; - if (maxn < n) - n = maxn; - } - } + n = count_materials(u, type, n, completed); if (n <= 0) { if (made == 0) return ENOMATERIALS; else break; } - if (type->materials) { - for (c = 0; type->materials[c].number; c++) { - const struct resource_type *rtype = type->materials[c].rtype; - int prebuilt = - required(completed, type->reqsize, type->materials[c].number); - int need = - required(completed + n, type->reqsize, type->materials[c].number); - int multi = 1; - int canuse = 100; /* normalization */ - if (building_is_active(u->building) && inside_building(u)) { - canuse = matmod(u->building->type->attribs, u, rtype, canuse); - } - if (canuse < 0) - return canuse; /* pass errors to caller */ - canuse = matmod(type->attribs, u, rtype, canuse); - - assert(canuse % 100 == 0 - || !"only constant multipliers are implemented in build()"); - multi = canuse / 100; - if (canuse < 0) - return canuse; /* pass errors to caller */ - - use_pooled(u, rtype, GET_DEFAULT, - (need - prebuilt + multi - 1) / multi); - } + err = use_materials(u, type, n, completed); + if (err < 0) { + return err; } made += n; skills -= n * type->minskill; From 5680057e7f0c27cf90eeb81588bd5659d5be8874 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 15 Feb 2017 17:09:23 +0100 Subject: [PATCH 526/675] adding simple test for MAKE --- src/economy.c | 140 ++++++++++++++++++++++----------------------- src/economy.h | 1 + src/economy.test.c | 31 ++++++++++ src/kernel/build.c | 2 +- src/kernel/item.h | 6 +- 5 files changed, 107 insertions(+), 73 deletions(-) diff --git a/src/economy.c b/src/economy.c index dec4517a4..711a80d82 100644 --- a/src/economy.c +++ b/src/economy.c @@ -534,7 +534,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders) } if (has_skill(u, SK_MAGIC)) { /* error158;de;{unit} in {region}: '{command}' - Magier arbeiten - * grundstzlich nur alleine! */ + * grunds�tzlich nur alleine! */ cmistake(u, ord, 158, MSG_EVENT); return; } @@ -895,7 +895,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) const resource_type *rring; int amount, skill; - /* momentan kann man keine ressourcen abbauen, wenn man dafr + /* momentan kann man keine ressourcen abbauen, wenn man daf�r * Materialverbrauch hat: */ assert(itype != NULL && (itype->construction == NULL || itype->construction->materials == NULL)); @@ -928,8 +928,8 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) } } - /* Bergwchter knnen Abbau von Eisen/Laen durch Bewachen verhindern. - * Als magische Wesen 'sehen' Bergwchter alles und werden durch + /* Bergw�chter k�nnen Abbau von Eisen/Laen durch Bewachen verhindern. + * Als magische Wesen 'sehen' Bergw�chter alles und werden durch * Belagerung nicht aufgehalten. (Ansonsten wie oben bei Elfen anpassen). */ if (itype->rtype && (itype->rtype == get_resourcetype(R_IRON) || itype->rtype == rt_find("laen"))) { @@ -1095,7 +1095,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) if (avail > 0) { int want = required(al->want - al->get, al->save); int x = avail * want / nreq; - /* Wenn Rest, dann wrfeln, ob ich was bekomme: */ + /* Wenn Rest, dann w�rfeln, ob ich was bekomme: */ if (rng_int() % nreq < (avail * want) % nreq) ++x; avail -= x; @@ -1140,7 +1140,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) if (avail > 0) { int want = required(al->want, al->save); int x = avail * want / nreq; - /* Wenn Rest, dann wrfeln, ob ich was bekomme: */ + /* Wenn Rest, dann w�rfeln, ob ich was bekomme: */ if (rng_int() % nreq < (avail * want) % nreq) ++x; avail -= x; @@ -1248,7 +1248,7 @@ static void create_potion(unit * u, const potion_type * ptype, int want) } } -static void create_item(unit * u, const item_type * itype, int want) +void make_item(unit * u, const item_type * itype, int want) { if (itype->construction && fval(itype->rtype, RTF_LIMITED)) { #if GUARD_DISABLES_PRODUCTION == 1 @@ -1402,7 +1402,7 @@ int make_cmd(unit * u, struct order *ord) } } else if (itype != NULL) { - create_item(u, itype, m); + make_item(u, itype, m); } else { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_cannotmake", "")); @@ -1453,15 +1453,15 @@ static void expandbuying(region * r, request * buyorders) return; /* Initialisation. multiplier ist der Multiplikator auf den - * Verkaufspreis. Fr max_products Produkte kauft man das Produkt zum - * einfachen Verkaufspreis, danach erhht sich der Multiplikator um 1. - * counter ist ein Zhler, der die gekauften Produkte zhlt. money - * wird fr die debug message gebraucht. */ + * Verkaufspreis. F�r max_products Produkte kauft man das Produkt zum + * einfachen Verkaufspreis, danach erh�ht sich der Multiplikator um 1. + * counter ist ein Z�hler, der die gekauften Produkte z�hlt. money + * wird f�r die debug message gebraucht. */ max_products = rpeasants(r) / TRADE_FRACTION; - /* Kauf - auch so programmiert, da er leicht erweiterbar auf mehrere - * Gter pro Monat ist. j sind die Befehle, i der Index des + /* Kauf - auch so programmiert, da� er leicht erweiterbar auf mehrere + * G�ter pro Monat ist. j sind die Befehle, i der Index des * gehandelten Produktes. */ if (max_products > 0) { unsigned int j; @@ -1483,10 +1483,10 @@ static void expandbuying(region * r, request * buyorders) unit *u = g_requests[j].unit; item *items; - /* litems zhlt die Gter, die verkauft wurden, u->n das Geld, das - * verdient wurde. Dies mu gemacht werden, weil der Preis stndig sinkt, + /* litems z�hlt die G�ter, die verkauft wurden, u->n das Geld, das + * verdient wurde. Dies mu� gemacht werden, weil der Preis st�ndig sinkt, * man sich also das verdiente Geld und die verkauften Produkte separat - * merken mu. */ + * merken mu�. */ attrib *a = a_find(u->attribs, &at_luxuries); if (a == NULL) a = a_add(&u->attribs, a_new(&at_luxuries)); @@ -1503,7 +1503,7 @@ static void expandbuying(region * r, request * buyorders) rsetmoney(r, rmoney(r) + price); /* Falls mehr als max_products Bauern ein Produkt verkauft haben, steigt - * der Preis Multiplikator fr das Produkt um den Faktor 1. Der Zhler + * der Preis Multiplikator f�r das Produkt um den Faktor 1. Der Z�hler * wird wieder auf 0 gesetzt. */ if (++trade->number == max_products) { trade->number = 0; @@ -1563,7 +1563,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord) return; } /* Im Augenblick kann man nur 1 Produkt kaufen. expandbuying ist aber - * schon dafr ausgerstet, mehrere Produkte zu kaufen. */ + * schon daf�r ausger�stet, mehrere Produkte zu kaufen. */ kwd = init_order(ord); assert(kwd == K_BUY); @@ -1573,7 +1573,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord) return; } if (besieged(u)) { - /* Belagerte Einheiten knnen nichts kaufen. */ + /* Belagerte Einheiten k�nnen nichts kaufen. */ cmistake(u, ord, 60, MSG_COMMERCE); return; } @@ -1587,7 +1587,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord) } } else { - /* ...oder in der Region mu es eine Burg geben. */ + /* ...oder in der Region mu� es eine Burg geben. */ building *b = 0; if (r->buildings) { static int cache; @@ -1608,11 +1608,11 @@ static void buy(unit * u, request ** buyorders, struct order *ord) } } - /* Ein Hndler kann nur 10 Gter pro Talentpunkt handeln. */ + /* Ein H�ndler kann nur 10 G�ter pro Talentpunkt handeln. */ k = u->number * 10 * effskill(u, SK_TRADE, 0); - /* hat der Hndler bereits gehandelt, muss die Menge der bereits - * verkauften/gekauften Gter abgezogen werden */ + /* hat der H�ndler bereits gehandelt, muss die Menge der bereits + * verkauften/gekauften G�ter abgezogen werden */ a = a_find(u->attribs, &at_trades); if (!a) { a = a_add(&u->attribs, a_new(&at_trades)); @@ -1629,7 +1629,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord) } assert(n >= 0); - /* die Menge der verkauften Gter merken */ + /* die Menge der verkauften G�ter merken */ a->data.i += n; s = gettoken(token, sizeof(token)); @@ -1662,7 +1662,7 @@ static void add_income(unit * u, int type, int want, int qty) "unit region mode wanted amount", u, u->region, type, want, qty)); } -/* Steuerstze in % bei Burggre */ +/* Steuers�tze in % bei Burggr��e */ static int tax_per_size[7] = { 0, 6, 12, 18, 24, 30, 36 }; static void expandselling(region * r, request * sellorders, int limit) @@ -1697,11 +1697,11 @@ static void expandselling(region * r, request * sellorders, int limit) } memset(counter, 0, sizeof(int) * ncounter); - if (!sellorders) { /* NEIN, denn Insekten knnen in || !r->buildings) */ - return; /* Smpfen und Wsten auch so handeln */ + if (!sellorders) { /* NEIN, denn Insekten k�nnen in || !r->buildings) */ + return; /* S�mpfen und W�sten auch so handeln */ } - /* Stelle Eigentmer der grten Burg fest. Bekommt Steuern aus jedem - * Verkauf. Wenn zwei Burgen gleicher Gre bekommt gar keiner etwas. */ + /* Stelle Eigent�mer der gr��ten Burg fest. Bekommt Steuern aus jedem + * Verkauf. Wenn zwei Burgen gleicher Gr��e bekommt gar keiner etwas. */ for (b = rbuildings(r); b; b = b->next) { if (b->size > maxsize && building_owner(b) != NULL && b->type == castle_bt) { @@ -1724,13 +1724,13 @@ static void expandselling(region * r, request * sellorders, int limit) maxowner = (unit *)NULL; } } - /* Die Region muss genug Geld haben, um die Produkte kaufen zu knnen. */ + /* Die Region muss genug Geld haben, um die Produkte kaufen zu k�nnen. */ money = rmoney(r); - /* max_products sind 1/100 der Bevlkerung, falls soviele Produkte + /* max_products sind 1/100 der Bev�lkerung, falls soviele Produkte * verkauft werden - counter[] - sinkt die Nachfrage um 1 Punkt. - * multiplier speichert r->demand fr die debug message ab. */ + * multiplier speichert r->demand f�r die debug message ab. */ max_products = rpeasants(r) / TRADE_FRACTION; if (max_products <= 0) @@ -1798,11 +1798,11 @@ static void expandselling(region * r, request * sellorders, int limit) change_money(u, price); fset(u, UFL_LONGACTION | UFL_NOTMOVING); - /* r->money -= price; --- dies wird eben nicht ausgefhrt, denn die - * Produkte knnen auch als Steuern eingetrieben werden. In der Region - * wurden Silberstcke gegen Luxusgter des selben Wertes eingetauscht! + /* r->money -= price; --- dies wird eben nicht ausgef�hrt, denn die + * Produkte k�nnen auch als Steuern eingetrieben werden. In der Region + * wurden Silberst�cke gegen Luxusg�ter des selben Wertes eingetauscht! * Falls mehr als max_products Kunden ein Produkt gekauft haben, sinkt - * die Nachfrage fr das Produkt um 1. Der Zhler wird wieder auf 0 + * die Nachfrage f�r das Produkt um 1. Der Z�hler wird wieder auf 0 * gesetzt. */ if (++counter[i] > max_products) { @@ -1819,7 +1819,7 @@ static void expandselling(region * r, request * sellorders, int limit) } free(g_requests); - /* Steuern. Hier werden die Steuern dem Besitzer der grten Burg gegeben. */ + /* Steuern. Hier werden die Steuern dem Besitzer der gr��ten Burg gegeben. */ if (maxowner) { if (taxcollected > 0) { change_money(maxowner, (int)taxcollected); @@ -1876,7 +1876,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) cmistake(u, ord, 69, MSG_INCOME); return false; } - /* sellorders sind KEIN array, weil fr alle items DIE SELBE resource + /* sellorders sind KEIN array, weil f�r alle items DIE SELBE resource * (das geld der region) aufgebraucht wird. */ kwd = init_order(ord); @@ -1901,13 +1901,13 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) return false; } } - /* Belagerte Einheiten knnen nichts verkaufen. */ + /* Belagerte Einheiten k�nnen nichts verkaufen. */ if (besieged(u)) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error60", "")); return false; } - /* In der Region mu es eine Burg geben. */ + /* In der Region mu� es eine Burg geben. */ if (u_race(u) == get_race(RC_INSECT)) { if (r->terrain != newterrain(T_SWAMP) && r->terrain != newterrain(T_DESERT) @@ -1917,7 +1917,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) } } else { - /* ...oder in der Region mu es eine Burg geben. */ + /* ...oder in der Region mu� es eine Burg geben. */ building *b = 0; if (r->buildings) { for (b = r->buildings; b; b = b->next) { @@ -1930,7 +1930,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) } } - /* Ein Hndler kann nur 10 Gter pro Talentpunkt verkaufen. */ + /* Ein H�ndler kann nur 10 G�ter pro Talentpunkt verkaufen. */ n = MIN(n, u->number * 10 * effskill(u, SK_TRADE, 0)); @@ -1956,7 +1956,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) } available = get_pooled(u, itype->rtype, GET_DEFAULT, INT_MAX); - /* Wenn andere Einheiten das selbe verkaufen, mu ihr Zeug abgezogen + /* Wenn andere Einheiten das selbe verkaufen, mu� ihr Zeug abgezogen * werden damit es nicht zweimal verkauft wird: */ for (o = *sellorders; o; o = o->next) { if (o->type.ltype == ltype && o->unit->faction == u->faction) { @@ -1973,16 +1973,16 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) return false; } /* Hier wird request->type verwendet, weil die obere limit durch - * das silber gegeben wird (region->money), welches fr alle + * das silber gegeben wird (region->money), welches f�r alle * (!) produkte als summe gilt, als nicht wie bei der - * produktion, wo fr jedes produkt einzeln eine obere limite + * produktion, wo f�r jedes produkt einzeln eine obere limite * existiert, so dass man arrays von orders machen kann. */ - /* Ein Hndler kann nur 10 Gter pro Talentpunkt handeln. */ + /* Ein H�ndler kann nur 10 G�ter pro Talentpunkt handeln. */ k = u->number * 10 * effskill(u, SK_TRADE, 0); - /* hat der Hndler bereits gehandelt, muss die Menge der bereits - * verkauften/gekauften Gter abgezogen werden */ + /* hat der H�ndler bereits gehandelt, muss die Menge der bereits + * verkauften/gekauften G�ter abgezogen werden */ a = a_find(u->attribs, &at_trades); if (!a) { a = a_add(&u->attribs, a_new(&at_trades)); @@ -1993,7 +1993,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) n = MIN(n, k); assert(n >= 0); - /* die Menge der verkauften Gter merken */ + /* die Menge der verkauften G�ter merken */ a->data.i += n; o = (request *)calloc(1, sizeof(request)); o->unit = u; @@ -2017,8 +2017,8 @@ static void expandstealing(region * r, request * stealorders) expandorders(r, stealorders); if (!norders) return; - /* Fr jede unit in der Region wird Geld geklaut, wenn sie Opfer eines - * Beklauen-Orders ist. Jedes Opfer mu einzeln behandelt werden. + /* F�r jede unit in der Region wird Geld geklaut, wenn sie Opfer eines + * Beklauen-Orders ist. Jedes Opfer mu� einzeln behandelt werden. * * u ist die beklaute unit. oa.unit ist die klauende unit. */ @@ -2079,7 +2079,7 @@ static void plant(unit * u, int raw) return; } - /* Skill prfen */ + /* Skill pr�fen */ skill = effskill(u, SK_HERBALISM, 0); if (skill < 6) { ADDMSG(&u->faction->msgs, @@ -2087,14 +2087,14 @@ static void plant(unit * u, int raw) "skill minskill product", SK_HERBALISM, 6, itype->rtype, 1)); return; } - /* Wasser des Lebens prfen */ + /* Wasser des Lebens pr�fen */ if (get_pooled(u, rt_water, GET_DEFAULT, 1) == 0) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "resource_missing", "missing", rt_water)); return; } n = get_pooled(u, itype->rtype, GET_DEFAULT, skill * u->number); - /* Kruter prfen */ + /* Kr�uter pr�fen */ if (n == 0) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "resource_missing", "missing", @@ -2104,7 +2104,7 @@ static void plant(unit * u, int raw) n = MIN(skill * u->number, n); n = MIN(raw, n); - /* Fr jedes Kraut Talent*10% Erfolgschance. */ + /* F�r jedes Kraut Talent*10% Erfolgschance. */ for (i = n; i > 0; i--) { if (rng_int() % 10 < skill) planted++; @@ -2129,10 +2129,10 @@ static void planttrees(unit * u, int raw) return; } - /* Mallornbume kann man nur in Mallornregionen zchten */ + /* Mallornb�ume kann man nur in Mallornregionen z�chten */ rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORNSEED : R_SEED); - /* Skill prfen */ + /* Skill pr�fen */ skill = effskill(u, SK_HERBALISM, 0); if (skill < 6) { ADDMSG(&u->faction->msgs, @@ -2157,7 +2157,7 @@ static void planttrees(unit * u, int raw) } n = MIN(raw, n); - /* Fr jeden Samen Talent*10% Erfolgschance. */ + /* F�r jeden Samen Talent*10% Erfolgschance. */ for (i = n; i > 0; i--) { if (rng_int() % 10 < skill) planted++; @@ -2172,7 +2172,7 @@ static void planttrees(unit * u, int raw) "unit region amount herb", u, r, planted, rtype)); } -/* zchte bume */ +/* z�chte b�ume */ static void breedtrees(unit * u, int raw) { int n, i, skill, planted = 0; @@ -2184,7 +2184,7 @@ static void breedtrees(unit * u, int raw) get_gamedate(turn, &date); current_season = date.season; - /* Bume zchten geht nur im Frhling */ + /* B�ume z�chten geht nur im Fr�hling */ if (current_season != SEASON_SPRING) { planttrees(u, raw); return; @@ -2194,10 +2194,10 @@ static void breedtrees(unit * u, int raw) return; } - /* Mallornbume kann man nur in Mallornregionen zchten */ + /* Mallornb�ume kann man nur in Mallornregionen z�chten */ rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORNSEED : R_SEED); - /* Skill prfen */ + /* Skill pr�fen */ skill = effskill(u, SK_HERBALISM, 0); if (skill < 12) { planttrees(u, raw); @@ -2207,7 +2207,7 @@ static void breedtrees(unit * u, int raw) /* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */ raw = MIN(skill * u->number, raw); n = get_pooled(u, rtype, GET_DEFAULT, raw); - /* Samen prfen */ + /* Samen pr�fen */ if (n == 0) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype)); @@ -2215,7 +2215,7 @@ static void breedtrees(unit * u, int raw) } n = MIN(raw, n); - /* Fr jeden Samen Talent*5% Erfolgschance. */ + /* F�r jeden Samen Talent*5% Erfolgschance. */ for (i = n; i > 0; i--) { if (rng_int() % 100 < skill * 5) planted++; @@ -2230,7 +2230,7 @@ static void breedtrees(unit * u, int raw) "unit region amount herb", u, r, planted, rtype)); } -/* zchte pferde */ +/* z�chte pferde */ static void breedhorses(unit * u) { int n, c, breed = 0; @@ -2283,7 +2283,7 @@ static void breed_cmd(unit * u, struct order *ord) return; } - /* zchte [] */ + /* z�chte [] */ (void)init_order(ord); s = gettoken(token, sizeof(token)); @@ -2549,7 +2549,7 @@ static void expandentertainment(region * r) m -= u->n; entertaining -= o->qty; - /* Nur soviel PRODUCEEXP wie auch tatschlich gemacht wurde */ + /* Nur soviel PRODUCEEXP wie auch tats�chlich gemacht wurde */ produceexp(u, SK_ENTERTAINMENT, MIN(u->n, u->number)); add_income(u, IC_ENTERTAIN, o->qty, u->n); fset(u, UFL_LONGACTION | UFL_NOTMOVING); @@ -3121,7 +3121,7 @@ void produce(struct region *r) /* Entertainment (expandentertainment) und Besteuerung (expandtax) vor den * Befehlen, die den Bauern mehr Geld geben, damit man aus den Zahlen der - * letzten Runde berechnen kann, wieviel die Bauern fr Unterhaltung + * letzten Runde berechnen kann, wieviel die Bauern f�r Unterhaltung * auszugeben bereit sind. */ if (entertaining) expandentertainment(r); @@ -3136,7 +3136,7 @@ void produce(struct region *r) /* An erster Stelle Kaufen (expandbuying), die Bauern so Geld bekommen, um * nachher zu beim Verkaufen (expandselling) den Spielern abkaufen zu - * knnen. */ + * k�nnen. */ if (buyorders) expandbuying(r, buyorders); diff --git a/src/economy.h b/src/economy.h index 5549e13cb..7b0eed8c9 100644 --- a/src/economy.h +++ b/src/economy.h @@ -56,6 +56,7 @@ extern "C" { enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC, IC_LOOT }; void maintain_buildings(struct region *r); + void make_item(struct unit * u, const struct item_type * itype, int want); int make_cmd(struct unit *u, struct order *ord); void split_allocations(struct region *r); int give_control_cmd(struct unit *u, struct order *ord); diff --git a/src/economy.test.c b/src/economy.test.c index 3c4a5f257..bee074714 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -341,12 +341,43 @@ static void test_income(CuTest *tc) test_cleanup(); } +static void test_make_item(CuTest *tc) { + unit *u; + struct item_type *itype; + const struct resource_type *rt_silver; + + test_setup(); + init_resources(); + rt_silver = get_resourcetype(R_SILVER); + itype = test_create_itemtype("log"); + u = test_create_unit(test_create_faction(0), test_create_region(0,0,0)); + make_item(u, itype, 1); + CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error_cannotmake")); + CuAssertIntEquals(tc, 0, get_item(u, itype)); + test_clear_messages(u->faction); + itype->construction = calloc(1, sizeof(construction)); + itype->construction->skill = SK_ALCHEMY; + itype->construction->minskill = 1; + itype->construction->maxsize = 1; + itype->construction->reqsize = 1; + itype->construction->materials = calloc(2, sizeof(requirement)); + itype->construction->materials[0].rtype = rt_silver; + itype->construction->materials[0].number = 1; + set_level(u, SK_ALCHEMY, 1); + set_item(u, rt_silver->itype, 1); + make_item(u, itype, 1); + CuAssertIntEquals(tc, 1, get_item(u, itype)); + CuAssertIntEquals(tc, 0, get_item(u, rt_silver->itype)); + test_cleanup(); +} + CuSuite *get_economy_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_give_control_building); SUITE_ADD_TEST(suite, test_give_control_ship); SUITE_ADD_TEST(suite, test_income); + SUITE_ADD_TEST(suite, test_make_item); SUITE_ADD_TEST(suite, test_steal_okay); SUITE_ADD_TEST(suite, test_steal_ocean); SUITE_ADD_TEST(suite, test_steal_nosteal); diff --git a/src/kernel/build.c b/src/kernel/build.c index 78bcd6b8f..88ab35fd2 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -397,7 +397,7 @@ static int required(int size, int msize, int maxneed) * braucht man required von maxneed resourcen */ { int used; - + assert(msize > 0); used = size * maxneed / msize; if (size * maxneed % msize) ++used; diff --git a/src/kernel/item.h b/src/kernel/item.h index c32f38057..39a2d0687 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -70,7 +70,7 @@ extern "C" { typedef char *(*rtype_name) (const struct resource_type * rtype, int flags); typedef struct resource_type { /* --- constants --- */ - char *_name; /* wie es heit */ + char *_name; /* wie es hei�t */ unsigned int flags; /* --- functions --- */ rtype_uchange uchange; @@ -136,7 +136,7 @@ extern "C" { int weight; int capacity; struct construction *construction; - char *_appearance[2]; /* wie es fr andere aussieht */ + char *_appearance[2]; /* wie es f�r andere aussieht */ /* --- functions --- */ bool(*canuse) (const struct unit * user, const struct item_type * itype); @@ -311,6 +311,8 @@ extern "C" { extern const struct potion_type *oldpotiontype[]; const struct resource_type *get_resourcetype(resource_t rt); + int get_item(const struct unit * u, const struct item_type *itype); + int set_item(struct unit * u, const struct item_type *itype, int value); int get_money(const struct unit *); int set_money(struct unit *, int); int change_money(struct unit *, int); From 5902a6922f06eae2d42591a71ff76b670cd146de Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 15 Feb 2017 20:50:45 +0100 Subject: [PATCH 527/675] BUG 2279: add a failing unit test. --- src/economy.test.c | 36 +++++++++++++++++++++++++++++++++++- src/kernel/resources.h | 16 +++++++--------- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/economy.test.c b/src/economy.test.c index bee074714..ddb0cafbc 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -11,10 +11,12 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -345,11 +347,17 @@ static void test_make_item(CuTest *tc) { unit *u; struct item_type *itype; const struct resource_type *rt_silver; + resource_type *rtype; + attrib *a; + resource_limit *rdata; test_setup(); init_resources(); + + /* make items from other items (turn silver to stone) */ rt_silver = get_resourcetype(R_SILVER); - itype = test_create_itemtype("log"); + itype = test_create_itemtype("stone"); + rtype = itype->rtype; u = test_create_unit(test_create_faction(0), test_create_region(0,0,0)); make_item(u, itype, 1); CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error_cannotmake")); @@ -368,6 +376,32 @@ static void test_make_item(CuTest *tc) { make_item(u, itype, 1); CuAssertIntEquals(tc, 1, get_item(u, itype)); CuAssertIntEquals(tc, 0, get_item(u, rt_silver->itype)); + + /* make level-based raw materials, no materials used in construction */ + free(itype->construction->materials); + itype->construction->materials = 0; + rtype->flags |= RTF_LIMITED; + a = a_add(&rtype->attribs, a_new(&at_resourcelimit)); + rdata = (resource_limit *)a->data.v; + rdata->value = 0; + rmt_create(rtype, "stone"); + add_resource(u->region, 1, 300, 150, rtype); + u->region->resources->amount = 300; /* there are 300 stones at level 1 */ + set_level(u, SK_ALCHEMY, 10); + + make_item(u, itype, 10); + split_allocations(u->region); + CuAssertIntEquals(tc, 11, get_item(u, itype)); + CuAssertIntEquals(tc, 290, u->region->resources->amount); /* used 10 stones to make 10 stones */ + + rdata->modifiers = calloc(2, sizeof(resource_mod)); + rdata->modifiers[0].flags = RMF_SAVEMATERIAL; + rdata->modifiers[0].race = u->_race; + rdata->modifiers[0].value.f = (float)0.6; + make_item(u, itype, 10); + split_allocations(u->region); + CuAssertIntEquals(tc, 21, get_item(u, itype)); + CuAssertIntEquals(tc, 284, u->region->resources->amount); /* 60% saving = 6 stones make 10 stones */ test_cleanup(); } diff --git a/src/kernel/resources.h b/src/kernel/resources.h index 32c69036c..a1a7abd40 100644 --- a/src/kernel/resources.h +++ b/src/kernel/resources.h @@ -55,18 +55,16 @@ extern "C" { extern struct rawmaterial_type *rawmaterialtypes; - extern void update_resources(struct region *r); - extern void terraform_resources(struct region *r); - extern void read_resources(struct region *r); - extern void write_resources(struct region *r); - extern struct rawmaterial *rm_get(struct region *, + void update_resources(struct region *r); + void terraform_resources(struct region *r); + struct rawmaterial *rm_get(struct region *, const struct resource_type *); - extern struct rawmaterial_type *rmt_find(const char *str); - extern struct rawmaterial_type *rmt_get(const struct resource_type *); + struct rawmaterial_type *rmt_find(const char *str); + struct rawmaterial_type *rmt_get(const struct resource_type *); - extern void add_resource(struct region *r, int level, int base, int divisor, + void add_resource(struct region *r, int level, int base, int divisor, const struct resource_type *rtype); - extern struct rawmaterial_type *rmt_create(const struct resource_type *rtype, + struct rawmaterial_type *rmt_create(const struct resource_type *rtype, const char *name); #ifdef __cplusplus From 50083fc668641d6c232ce6b3958e16240c91a31d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 15 Feb 2017 21:16:54 +0100 Subject: [PATCH 528/675] BUG 2279: too many resources used. diddling the resource-save formula until test passes. --- src/economy.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/economy.c b/src/economy.c index 711a80d82..b38244ca8 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1038,8 +1038,6 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) static int required(int want, double save) { int req = (int)(want * save); - if (req < want * save) - ++req; return req; } @@ -1095,14 +1093,14 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) if (avail > 0) { int want = required(al->want - al->get, al->save); int x = avail * want / nreq; - /* Wenn Rest, dann w�rfeln, ob ich was bekomme: */ - if (rng_int() % nreq < (avail * want) % nreq) - ++x; + int r = (avail * want) % nreq; + /* Wenn Rest, dann wuerfeln, ob ich etwas bekomme: */ + if (r > 0 && rng_int() % nreq < r) ++x; avail -= x; use += x; nreq -= want; need -= x; - al->get = MIN(al->want, al->get + (int)(x / al->save)); + al->get = MIN(al->want, al->get + (int)(1 + x / al->save)); } } if (use) { From 20ff8981df584330e1cc9d3f29811903dcba961b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 15 Feb 2017 09:30:36 +0100 Subject: [PATCH 529/675] trying to extract allocation modifiers into a separate function --- src/economy.c | 80 ++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 45 deletions(-) diff --git a/src/economy.c b/src/economy.c index b38244ca8..abbf28a02 100644 --- a/src/economy.c +++ b/src/economy.c @@ -883,6 +883,32 @@ enum { AFL_LOWSKILL = 1 << 1 }; +struct message * get_modifiers(unit *u, const resource_mod *mod, double *savep, int *skillp) { + struct building *b = inside_building(u); + const struct building_type *btype = building_is_active(b) ? b->type : NULL; + double save = 1.0; + int skill = 0; + + for (; mod->flags != 0; ++mod) { + if (mod->btype == NULL || mod->btype == btype) { + if (mod->flags & RMF_REQUIREDBUILDING) { + return msg_error(u, u->thisorder, 104);; + } + if (mod->race == NULL || mod->race == u_race(u)) { + if (mod->flags & RMF_SAVEMATERIAL) { + save *= mod->value.f; + } + if (mod->flags & RMF_SKILL) { + skill += mod->value.i; + } + } + } + } + *skillp = skill; + *savep = save; + return NULL; +} + static void allocate_resource(unit * u, const resource_type * rtype, int want) { const item_type *itype = resource2item(rtype); @@ -893,7 +919,8 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) attrib *a = a_find(rtype->attribs, &at_resourcelimit); resource_limit *rdata = (resource_limit *)a->data.v; const resource_type *rring; - int amount, skill; + int amount, skill, skill_mod; + double save_mod; /* momentan kann man keine ressourcen abbauen, wenn man daf�r * Materialverbrauch hat: */ @@ -915,16 +942,11 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) } if (rdata->modifiers) { - resource_mod *mod = rdata->modifiers; - for (; mod->flags != 0; ++mod) { - if (mod->flags & RMF_REQUIREDBUILDING) { - struct building *b = inside_building(u); - const struct building_type *btype = building_is_active(b) ? b->type : NULL; - if (mod->btype && mod->btype != btype) { - cmistake(u, u->thisorder, 104, MSG_PRODUCE); - return; - } - } + message *msg = get_modifiers(u, rdata->modifiers, &save_mod, &skill_mod); + if (msg) { + ADDMSG(&u->faction->msgs, msg); + msg_release(msg); + return; } } @@ -962,23 +984,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) itype->rtype)); return; } - else { - struct building *b = inside_building(u); - const struct building_type *btype = building_is_active(b) ? b->type : NULL; - - if (rdata->modifiers) { - resource_mod *mod = rdata->modifiers; - for (; mod->flags != 0; ++mod) { - if (mod->flags & RMF_SKILL) { - if (mod->btype == NULL || mod->btype == btype) { - if (mod->race == NULL || mod->race == u_race(u)) { - skill += mod->value.i; - } - } - } - } - } - } + skill += skill_mod; amount = skill * u->number; /* nun ist amount die Gesamtproduktion der Einheit (in punkten) */ @@ -1013,26 +1019,10 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) } al = new_allocation(); al->want = amount; - al->save = 1.0; + al->save = save_mod; al->next = alist->data; al->unit = u; alist->data = al; - - if (rdata->modifiers) { - struct building *b = inside_building(u); - const struct building_type *btype = building_is_active(b) ? b->type : NULL; - - resource_mod *mod = rdata->modifiers; - for (; mod->flags != 0; ++mod) { - if (mod->flags & RMF_SAVEMATERIAL) { - if (mod->btype == NULL || mod->btype == btype) { - if (mod->race == NULL || mod->race == u_race(u)) { - al->save *= mod->value.f; - } - } - } - } - } } static int required(int want, double save) From a5dfe12d48cc147f8ecbbc6e7087c231581fd6dd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 16 Feb 2017 19:38:09 +0100 Subject: [PATCH 530/675] initialize variable --- src/economy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/economy.c b/src/economy.c index abbf28a02..df01f3b45 100644 --- a/src/economy.c +++ b/src/economy.c @@ -919,8 +919,8 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) attrib *a = a_find(rtype->attribs, &at_resourcelimit); resource_limit *rdata = (resource_limit *)a->data.v; const resource_type *rring; - int amount, skill, skill_mod; - double save_mod; + int amount, skill, skill_mod = 0; + double save_mod = 1.0; /* momentan kann man keine ressourcen abbauen, wenn man daf�r * Materialverbrauch hat: */ From a624915a0634ef1ac731c6c12e99242e25609a3d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 16 Feb 2017 20:26:34 +0100 Subject: [PATCH 531/675] error message if building is required. was broken in recent commit. also fix reference counts. --- src/economy.c | 6 ++---- src/economy.test.c | 7 +++++++ src/kernel/messages.c | 2 -- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/economy.c b/src/economy.c index df01f3b45..4c54cb5da 100644 --- a/src/economy.c +++ b/src/economy.c @@ -891,9 +891,6 @@ struct message * get_modifiers(unit *u, const resource_mod *mod, double *savep, for (; mod->flags != 0; ++mod) { if (mod->btype == NULL || mod->btype == btype) { - if (mod->flags & RMF_REQUIREDBUILDING) { - return msg_error(u, u->thisorder, 104);; - } if (mod->race == NULL || mod->race == u_race(u)) { if (mod->flags & RMF_SAVEMATERIAL) { save *= mod->value.f; @@ -902,6 +899,8 @@ struct message * get_modifiers(unit *u, const resource_mod *mod, double *savep, skill += mod->value.i; } } + } else if (mod->flags & RMF_REQUIREDBUILDING) { + return msg_error(u, u->thisorder, 104); } } *skillp = skill; @@ -945,7 +944,6 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) message *msg = get_modifiers(u, rdata->modifiers, &save_mod, &skill_mod); if (msg) { ADDMSG(&u->faction->msgs, msg); - msg_release(msg); return; } } diff --git a/src/economy.test.c b/src/economy.test.c index ddb0cafbc..7101d859a 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -402,6 +402,13 @@ static void test_make_item(CuTest *tc) { split_allocations(u->region); CuAssertIntEquals(tc, 21, get_item(u, itype)); CuAssertIntEquals(tc, 284, u->region->resources->amount); /* 60% saving = 6 stones make 10 stones */ + + rdata->modifiers[0].flags = RMF_REQUIREDBUILDING; + rdata->modifiers[0].race = NULL; + rdata->modifiers[0].btype = bt_get_or_create("mine"); + make_item(u, itype, 10); + CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error104")); + test_cleanup(); } diff --git a/src/kernel/messages.c b/src/kernel/messages.c index cb859df96..f74e9c0d7 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -270,8 +270,6 @@ void syntax_error(const struct unit *u, struct order *ord) ADDMSG(&u->faction->msgs, result); } -extern unsigned int new_hashstring(const char *s); - void free_messagelist(mlist *msgs) { struct mlist **mlistptr; From 2328975dc226c735f5652918482e8e995345c52b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 17 Feb 2017 21:45:10 +0100 Subject: [PATCH 532/675] do not use floats for material-save. abusing variants for storing short fractions. remove unused RMF_SAVERESOURCE. --- src/economy.c | 40 ++++++++++++++++++++++++++-------------- src/economy.test.c | 4 +++- src/kernel/item.h | 3 +-- src/kernel/xmlreader.c | 7 ++----- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/economy.c b/src/economy.c index 4c54cb5da..70b48e9ce 100644 --- a/src/economy.c +++ b/src/economy.c @@ -863,7 +863,7 @@ static void manufacture(unit * u, const item_type * itype, int want) typedef struct allocation { struct allocation *next; int want, get; - double save; + variant save; unsigned int flags; unit *unit; } allocation; @@ -883,17 +883,18 @@ enum { AFL_LOWSKILL = 1 << 1 }; -struct message * get_modifiers(unit *u, const resource_mod *mod, double *savep, int *skillp) { +struct message * get_modifiers(unit *u, const resource_mod *mod, variant *savep, int *skillp) { struct building *b = inside_building(u); const struct building_type *btype = building_is_active(b) ? b->type : NULL; - double save = 1.0; + int save_n = 1, save_d = 1; int skill = 0; for (; mod->flags != 0; ++mod) { if (mod->btype == NULL || mod->btype == btype) { if (mod->race == NULL || mod->race == u_race(u)) { if (mod->flags & RMF_SAVEMATERIAL) { - save *= mod->value.f; + save_n *= mod->value.sa[0]; + save_d *= mod->value.sa[1]; } if (mod->flags & RMF_SKILL) { skill += mod->value.i; @@ -904,7 +905,12 @@ struct message * get_modifiers(unit *u, const resource_mod *mod, double *savep, } } *skillp = skill; - *savep = save; + assert(save_n < SHRT_MAX); + assert(save_n > SHRT_MIN); + assert(save_d < SHRT_MAX); + assert(save_d > SHRT_MIN); + savep->sa[0] = (short)save_n; + savep->sa[1] = (short)save_d; return NULL; } @@ -919,7 +925,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) resource_limit *rdata = (resource_limit *)a->data.v; const resource_type *rring; int amount, skill, skill_mod = 0; - double save_mod = 1.0; + variant save_mod; /* momentan kann man keine ressourcen abbauen, wenn man daf�r * Materialverbrauch hat: */ @@ -947,6 +953,10 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) return; } } + else { + save_mod.sa[0] = 1; + save_mod.sa[1] = 1; + } /* Bergw�chter k�nnen Abbau von Eisen/Laen durch Bewachen verhindern. * Als magische Wesen 'sehen' Bergw�chter alles und werden durch @@ -1023,9 +1033,9 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) alist->data = al; } -static int required(int want, double save) +static int required(int want, variant save) { - int req = (int)(want * save); + int req = (int)(want * save.sa[0] / save.sa[1]); return req; } @@ -1088,7 +1098,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) use += x; nreq -= want; need -= x; - al->get = MIN(al->want, al->get + (int)(1 + x / al->save)); + al->get = MIN(al->want, al->get + x * al->save.sa[1] / al->save.sa[0]); } } if (use) { @@ -1126,12 +1136,13 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) if (avail > 0) { int want = required(al->want, al->save); int x = avail * want / nreq; - /* Wenn Rest, dann w�rfeln, ob ich was bekomme: */ - if (rng_int() % nreq < (avail * want) % nreq) - ++x; + int rx = (avail * want) % nreq; + /* Wenn Rest, dann wuerfeln, ob ich was bekomme: */ + if (rx>0 && rng_int() % nreq < rx) ++x; avail -= x; nreq -= want; - al->get = MIN(al->want, (int)(x / al->save)); + al->get = x * al->save.sa[0] / al->save.sa[1]; + al->get = MIN(al->want, al->get); if (rdata->produce) { int use = required(al->get, al->save); if (use) @@ -2619,8 +2630,9 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork) if (jobs >= working) workers = u->number; else { + int r = (u->number * jobs) % working; workers = u->number * jobs / working; - if (rng_int() % working < (u->number * jobs) % working) + if (r > 0 && rng_int() % working < r) workers++; } diff --git a/src/economy.test.c b/src/economy.test.c index 7101d859a..d9f9b82e8 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -350,6 +350,7 @@ static void test_make_item(CuTest *tc) { resource_type *rtype; attrib *a; resource_limit *rdata; + double d = 0.6; test_setup(); init_resources(); @@ -397,7 +398,8 @@ static void test_make_item(CuTest *tc) { rdata->modifiers = calloc(2, sizeof(resource_mod)); rdata->modifiers[0].flags = RMF_SAVEMATERIAL; rdata->modifiers[0].race = u->_race; - rdata->modifiers[0].value.f = (float)0.6; + rdata->modifiers[0].value.sa[0] = (short)(0.5+100*d); + rdata->modifiers[0].value.sa[1] = 100; make_item(u, itype, 10); split_allocations(u->region); CuAssertIntEquals(tc, 21, get_item(u, itype)); diff --git a/src/kernel/item.h b/src/kernel/item.h index 39a2d0687..e6301c314 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -91,8 +91,7 @@ extern "C" { /* resource-limits for regions */ #define RMF_SKILL 0x01 /* int, bonus on resource production skill */ -#define RMF_SAVEMATERIAL 0x02 /* float, multiplier on resource usage */ -#define RMF_SAVERESOURCE 0x03 /* int, bonus on resource production skill */ +#define RMF_SAVEMATERIAL 0x02 /* fraction (sa[0]/sa[1]), multiplier on resource usage */ #define RMF_REQUIREDBUILDING 0x04 /* building, required to build */ typedef struct resource_mod { diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 5ce6800ef..5cecc4fdb 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1025,13 +1025,10 @@ static int parse_resources(xmlDocPtr doc) rdata->modifiers[k].flags = RMF_SKILL; } else if (strcmp((const char *)propValue, "material") == 0) { - rdata->modifiers[k].value.f = (float)xml_fvalue(node, "value", 0); + rdata->modifiers[k].value.sa[0] = (short)(0.5+100*xml_fvalue(node, "value", 0)); + rdata->modifiers[k].value.sa[1] = 100; rdata->modifiers[k].flags = RMF_SAVEMATERIAL; } - else if (strcmp((const char *)propValue, "resource") == 0) { - rdata->modifiers[k].value.f = (float)xml_fvalue(node, "value", 0); - rdata->modifiers[k].flags = RMF_SAVERESOURCE; - } else if (strcmp((const char *)propValue, "require") == 0) { xmlChar *propBldg = xmlGetProp(node, BAD_CAST "building"); if (propBldg != NULL) { From 0a3e3de5a33405b0de1e93e5734266c48a94e126 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 17 Feb 2017 22:01:51 +0100 Subject: [PATCH 533/675] refactor fractions a little bit. --- src/kernel/xmlreader.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 5cecc4fdb..36f003e80 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1025,8 +1025,17 @@ static int parse_resources(xmlDocPtr doc) rdata->modifiers[k].flags = RMF_SKILL; } else if (strcmp((const char *)propValue, "material") == 0) { - rdata->modifiers[k].value.sa[0] = (short)(0.5+100*xml_fvalue(node, "value", 0)); - rdata->modifiers[k].value.sa[1] = 100; + int num, den = 100; + double fval = xml_fvalue(node, "value", 0); + // TODO: extract into a function for reading fractions? + num = (int)(fval * den + 0.5); + if (num % 10 == 0) { + // TODO: calculating a GCD would be better than this + num /= 10; + den /= 10; + } + rdata->modifiers[k].value.sa[0] = (short)num; + rdata->modifiers[k].value.sa[1] = (short)den; rdata->modifiers[k].flags = RMF_SAVEMATERIAL; } else if (strcmp((const char *)propValue, "require") == 0) { From aee68fbd0fb0bc5ec2c159ce4812ef7749dd1fc2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Feb 2017 11:19:42 +0100 Subject: [PATCH 534/675] github issue #658 MACHE 1 EISEN use 1 iron even with savings. --- src/economy.c | 2 ++ src/economy.test.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/economy.c b/src/economy.c index 70b48e9ce..ab1875eed 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1036,6 +1036,8 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) static int required(int want, variant save) { int req = (int)(want * save.sa[0] / save.sa[1]); + int r = want * save.sa[0] % save.sa[1]; + if (r>0) ++req; return req; } diff --git a/src/economy.test.c b/src/economy.test.c index d9f9b82e8..fdc218844 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -405,6 +405,11 @@ static void test_make_item(CuTest *tc) { CuAssertIntEquals(tc, 21, get_item(u, itype)); CuAssertIntEquals(tc, 284, u->region->resources->amount); /* 60% saving = 6 stones make 10 stones */ + make_item(u, itype, 1); + split_allocations(u->region); + CuAssertIntEquals(tc, 22, get_item(u, itype)); + CuAssertIntEquals(tc, 283, u->region->resources->amount); /* no free lunches */ + rdata->modifiers[0].flags = RMF_REQUIREDBUILDING; rdata->modifiers[0].race = NULL; rdata->modifiers[0].btype = bt_get_or_create("mine"); From 9682d6b48c751a236844d7a3c3d8dff2bf0be74e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Feb 2017 15:45:57 +0100 Subject: [PATCH 535/675] implement quick-and-dirty gcd --- src/kernel/xmlreader.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 36f003e80..3a4b351dd 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -905,6 +905,22 @@ static int parse_rules(xmlDocPtr doc) return 0; } +static int gcd(int num, int den) { + const int primes[] = { 3, 5, 7, 11, 0 }; + int i=0, g = 1, p = 2; + while (p && p<=den && p<=num) { + if (num % p == 0 && den % p == 0) { + num /= p; + den /= p; + g *= p; + } + else { + p = primes[i++]; + } + } + return g; +} + static int parse_resources(xmlDocPtr doc) { xmlXPathContextPtr xpath = xmlXPathNewContext(doc); @@ -1025,15 +1041,13 @@ static int parse_resources(xmlDocPtr doc) rdata->modifiers[k].flags = RMF_SKILL; } else if (strcmp((const char *)propValue, "material") == 0) { - int num, den = 100; + int g, num, den = 100; double fval = xml_fvalue(node, "value", 0); // TODO: extract into a function for reading fractions? num = (int)(fval * den + 0.5); - if (num % 10 == 0) { - // TODO: calculating a GCD would be better than this - num /= 10; - den /= 10; - } + g = gcd(num, den); + num /= g; + den /= g; rdata->modifiers[k].value.sa[0] = (short)num; rdata->modifiers[k].value.sa[1] = (short)den; rdata->modifiers[k].flags = RMF_SAVEMATERIAL; From a754975ef9d957b79f7e142244ff27301081f7ec Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Feb 2017 17:52:25 +0100 Subject: [PATCH 536/675] fix loading data where embassy uses floats. --- src/attributes/dict.c | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/attributes/dict.c b/src/attributes/dict.c index 36d017b2c..f95555734 100644 --- a/src/attributes/dict.c +++ b/src/attributes/dict.c @@ -43,7 +43,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include typedef enum { - TNONE = 0, TINTEGER = 1 + TNONE = 0, TINTEGER = 1, TREAL = 2 } dict_type; typedef struct dict_data { @@ -72,11 +72,18 @@ static int dict_read(attrib * a, void *owner, gamedata *data) dd->name = strdup(name); READ_INT(store, &n); dd->type = (dict_type)n; - if (dd->type != TINTEGER) { + if (dd->type == TINTEGER) { + READ_INT(store, &dd->data.i); + } + else if (dd->type == TREAL) { + float flt; + READ_FLT(store, &flt); + dd->data.real = flt; + } + else { log_error("read dict, invalid type %d", n); return AT_READ_FAIL; } - READ_INT(store, &dd->data.i); return AT_READ_DEPR; } @@ -95,6 +102,16 @@ static void dict_done(attrib * a) free(a->data.v); } +static void upgrade_keyval(const dict_data *dd, int keyval[], int v) { + if (strcmp(dd->name, "embassy_muschel") == 0) { + keyval[0] = atoi36("mupL"); + keyval[1] = v; + } + else { + log_error("dict conversion, bad entry %s", dd->name); + } +} + static void dict_upgrade(attrib **alist, attrib *abegin) { int n = 0, *keys = 0; int i = 0, val[8]; @@ -105,18 +122,17 @@ static void dict_upgrade(attrib **alist, attrib *abegin) { } for (a = abegin; a && a->type == abegin->type; a = a->next) { dict_data *dd = (dict_data *)a->data.v; - if (dd->type != TINTEGER) { - log_error("dict conversion, bad type %d for %s", dd->type, dd->name); + if (dd->type == TINTEGER) { + upgrade_keyval(dd, val + i * 2, dd->data.i); + ++i; + } + else if (dd->type == TREAL) { + upgrade_keyval(dd, val + i * 2, (int)dd->data.real); + ++i; } else { - if (strcmp(dd->name, "embassy_muschel")==0) { - val[i * 2] = atoi36("mupL"); - val[i * 2 + 1] = dd->data.i; - ++i; - } - else { - log_error("dict conversion, bad entry %s", dd->name); - } + log_error("dict conversion, bad type %d for %s", dd->type, dd->name); + assert(!"invalid input"); } if (i == 4) { keys = realloc(keys, sizeof(int) * (n + i + 1)); From daa75543610ea410b3ade74d670224a86001ff12 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Feb 2017 18:14:18 +0100 Subject: [PATCH 537/675] remove race.precombatspell --- res/eressea/races.xml | 1 - src/kernel/race.c | 2 -- src/kernel/race.h | 1 - src/kernel/xmlreader.c | 11 ----------- src/magic.c | 7 ------- 5 files changed, 22 deletions(-) diff --git a/res/eressea/races.xml b/res/eressea/races.xml index e4e22d0c3..de5a26325 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -1283,7 +1283,6 @@ - diff --git a/src/kernel/race.c b/src/kernel/race.c index a4a11c15d..683d37d63 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -277,7 +277,6 @@ void free_races(void) { free(at->data.dice); } } - spellref_free(races->precombatspell); free(xrefs); xrefs = 0; free(races->_name); @@ -337,7 +336,6 @@ race *rc_create(const char *zName) assert(strchr(zName, ' ') == NULL); } rc->_name = strdup(zName); - rc->precombatspell = NULL; rc->attack[0].type = AT_COMBATSPELL; for (i = 1; i < RACE_ATTACKS; ++i) diff --git a/src/kernel/race.h b/src/kernel/race.h index c58bad701..8fc6d5989 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -138,7 +138,6 @@ extern "C" { int df_default; /* Verteidigungsskill Unbewaffnet (default: -2) */ int at_bonus; /* Ver�ndert den Angriffsskill (default: 0) */ int df_bonus; /* Ver�ndert den Verteidigungskill (default: 0) */ - struct spellref *precombatspell; signed char *study_speed; /* study-speed-bonus in points/turn (0=30 Tage) */ int flags; int battle_flags; diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 3a4b351dd..1ac5583ec 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1849,17 +1849,6 @@ static int parse_races(xmlDocPtr doc) } xmlXPathFreeObject(result); - /* reading eressea/races/race/precombatspell */ - xpath->node = node; - result = xmlXPathEvalExpression(BAD_CAST "precombatspell", xpath); - assert(rc->precombatspell == NULL - || !"precombatspell is already initialized"); - for (k = 0; k != result->nodesetval->nodeNr; ++k) { - xmlNodePtr node = result->nodesetval->nodeTab[k]; - rc->precombatspell = xml_spellref(node, "spell"); - } - xmlXPathFreeObject(result); - /* reading eressea/races/race/attack */ xpath->node = node; result = xmlXPathEvalExpression(BAD_CAST "attack", xpath); diff --git a/src/magic.c b/src/magic.c index 89774e96a..19890ec0e 100644 --- a/src/magic.c +++ b/src/magic.c @@ -561,13 +561,6 @@ const spell *get_combatspell(const unit * u, int nr) if (m) { return m->combatspells[nr].sp; } - else { - const race * rc = u_race(u); - if (rc->precombatspell) { - return spellref_get(rc->precombatspell); - } - } - return NULL; } From 7d5586635ea4523a056def5656a81867b1660d8a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Feb 2017 18:24:44 +0100 Subject: [PATCH 538/675] remove shadowcall spell --- res/core/de/strings.xml | 8 -------- res/core/messages.xml | 10 ---------- res/e3a/races.xml | 31 ------------------------------- res/e3a/spellbooks/gray.xml | 1 - res/e3a/spells.xml | 3 --- res/eressea/races.xml | 25 ------------------------- res/eressea/spellbooks/gray.xml | 1 - res/eressea/spells.xml | 3 --- 8 files changed, 82 deletions(-) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index bccfdd165..3aa71393d 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -3819,10 +3819,6 @@ Meteorregen Meteor Shower - - Schattenruf - Shadow Call - Erschaffe einen Ring der Regeneration Create A Ring of Regeneration @@ -4503,10 +4499,6 @@ Verletzt alle Gegner. Injures all enemies. - - Ruft Schattenwesen. - Calls beings from shadow. - Panik. Panic. diff --git a/res/core/messages.xml b/res/core/messages.xml index c28670d65..3fae49eb3 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -7521,16 +7521,6 @@ "$unit($mage) casts $spell($spell). $int($amount) fighters are temporarily losing some of their memories." - - - - - - - "$unit($mage) ruft $int($amount) $race($race, 0) zu Hilfe." - "$unit($mage) calls upon the help of $int($amount) $race($race, 0)." - - diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 7e75f3fd4..5060604a3 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -885,35 +885,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/e3a/spellbooks/gray.xml b/res/e3a/spellbooks/gray.xml index 5967d6265..9c0035e78 100644 --- a/res/e3a/spellbooks/gray.xml +++ b/res/e3a/spellbooks/gray.xml @@ -107,7 +107,6 @@ - diff --git a/res/e3a/spells.xml b/res/e3a/spells.xml index ec656c18f..74eb89146 100644 --- a/res/e3a/spells.xml +++ b/res/e3a/spells.xml @@ -665,9 +665,6 @@ - - - diff --git a/res/eressea/races.xml b/res/eressea/races.xml index de5a26325..26607a297 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -1284,29 +1284,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/eressea/spellbooks/gray.xml b/res/eressea/spellbooks/gray.xml index a7f718f2a..ae7a1f611 100644 --- a/res/eressea/spellbooks/gray.xml +++ b/res/eressea/spellbooks/gray.xml @@ -123,7 +123,6 @@ - diff --git a/res/eressea/spells.xml b/res/eressea/spells.xml index 5af11913e..1d762f4bd 100644 --- a/res/eressea/spells.xml +++ b/res/eressea/spells.xml @@ -471,9 +471,6 @@ - - - From a553b2258a0509bd7fa04e10262f8ef7a074246f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Feb 2017 18:25:58 +0100 Subject: [PATCH 539/675] remove code for shadowcall, too --- src/spells.c | 1 - src/spells/combatspells.c | 36 ------------------------------------ src/spells/combatspells.h | 1 - 3 files changed, 38 deletions(-) diff --git a/src/spells.c b/src/spells.c index b40192016..66f5325c9 100644 --- a/src/spells.c +++ b/src/spells.c @@ -6596,7 +6596,6 @@ static spelldata spell_functions[] = { { "powerful_dragonbreath", sp_dragonodem, 0 }, { "drain_skills", sp_dragonodem, 0 }, { "aura_of_fear", sp_flee, 0 }, - { "shadowcall", sp_shadowcall, 0 }, { "immolation", sp_immolation, 0 }, { "firestorm", sp_immolation, 0 }, { "coldfront", sp_immolation, 0 }, diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index 76fd605ff..939433617 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -815,42 +815,6 @@ int sp_drainodem(fighter * fi, int level, double power, spell * sp) /* ------------------------------------------------------------- */ /* PRECOMBAT */ -int sp_shadowcall(struct castorder * co) -{ - fighter * fi = co->magician.fig; - int level = co->level; - double power = co->force; - battle *b = fi->side->battle; - region *r = b->region; - unit *mage = fi->unit; - attrib *a; - int force = (int)(get_force(power, 3) / 2); - unit *u; - const char *rcnames[3] = { "shadowbat", "nightmare", "vampunicorn" }; - const race *rc = rc_find(rcnames[rng_int() % 3]); - message *msg; - - u = create_unit(r, mage->faction, force, rc, 0, NULL, mage); - setstatus(u, ST_FIGHT); - - set_level(u, SK_WEAPONLESS, (int)(power / 2)); - set_level(u, SK_STAMINA, (int)(power / 2)); - u->hp = u->number * unit_max_hp(u); - - a = a_new(&at_unitdissolve); - a->data.ca[0] = 0; - a->data.ca[1] = 100; - a_add(&u->attribs, a); - - make_fighter(b, u, fi->side, is_attacker(fi)); - msg = - msg_message("sp_shadowcall_effect", "mage amount race", mage, u->number, - u_race(u)); - message_all(b, msg); - msg_release(msg); - return level; -} - static fighter *summon_allies(const fighter *fi, const race *rc, int number) { attrib *a; unit *mage = fi->unit; diff --git a/src/spells/combatspells.h b/src/spells/combatspells.h index 4e3173a66..cf07c2a89 100644 --- a/src/spells/combatspells.h +++ b/src/spells/combatspells.h @@ -49,7 +49,6 @@ extern "C" { int sp_armorshield(struct castorder * co); int sp_stun(struct castorder * co); int sp_undeadhero(struct castorder * co); - int sp_shadowcall(struct castorder * co); int sp_immolation(struct castorder * co); #ifdef __cplusplus From 5b52451d9dc749de1b22d3b5fa3ea5571bce9d7d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Feb 2017 19:21:54 +0100 Subject: [PATCH 540/675] remove unused ai.aggression atribute --- res/e3a/races.xml | 6 +++--- res/eressea/races.xml | 6 +++--- src/kernel/race.h | 1 - src/kernel/xmlreader.c | 1 - src/monsters.c | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 5060604a3..ccc118877 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -765,7 +765,7 @@ - + @@ -803,7 +803,7 @@ - + @@ -836,7 +836,7 @@ - + diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 26607a297..3cf5136a4 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -1038,7 +1038,7 @@ - + @@ -1074,7 +1074,7 @@ - + @@ -1105,7 +1105,7 @@ - + diff --git a/src/kernel/race.h b/src/kernel/race.h index 8fc6d5989..05e9ffdec 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -130,7 +130,6 @@ extern "C" { int capacity; int income; float speed; - float aggression; /* chance that a monster will attack */ int hitpoints; char *def_damage; int armor; diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 1ac5583ec..9faf92ef8 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1595,7 +1595,6 @@ static void parse_ai(race * rc, xmlNodePtr node) xmlFree(propValue); } rc->splitsize = xml_ivalue(node, "splitsize", 0); - rc->aggression = (float)xml_fvalue(node, "aggression", 0.04); if (xml_bvalue(node, "killpeasants", false)) rc->flags |= RCF_KILLPEASANTS; if (xml_bvalue(node, "moverandom", false)) diff --git a/src/monsters.c b/src/monsters.c index a7678c701..3c9ee1eb8 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -216,7 +216,7 @@ static order *get_money_for_dragon(region * r, unit * udragon, int wanted) /* falls genug geld in der region ist, treiben wir steuern ein. */ if (rmoney(r) >= wanted) { /* 5% chance, dass der drache aus einer laune raus attackiert */ - if (!attacks || chance(1.0 - u_race(udragon)->aggression)) { + if (!attacks) { /* Drachen haben in E3 und E4 keine Einnahmen. Neuer Befehl Pluendern erstmal nur fuer Monster?*/ return create_order(K_LOOT, default_locale, NULL); } From 4e5f1d05ce228219a0e8b9865569d16499c79fa8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Feb 2017 21:15:14 +0100 Subject: [PATCH 541/675] Be very strict about C standards. Compile with -std=c89 in gcc. remove all // comments (they are nice, but unnecessary). variables only declared at start of block. various pedantery. backwards compatible va_copy for pre-C99 gcc. --- src/CMakeLists.txt | 4 +-- src/alchemy.c | 7 ++--- src/attributes/dict.h | 2 +- src/attributes/key.c | 2 +- src/attributes/key.h | 2 +- src/battle.c | 4 +-- src/battle.test.c | 6 ++-- src/bind_faction.c | 2 +- src/bind_storage.c | 5 +-- src/bind_unit.c | 4 ++- src/bindings.c | 2 -- src/creport.c | 8 ++--- src/economy.c | 6 ++-- src/economy.test.c | 8 ++--- src/give.c | 6 ++-- src/give.test.c | 2 +- src/gmtool.c | 4 +-- src/guard.test.c | 2 +- src/json.c | 6 ++-- src/json.test.c | 2 +- src/kernel/build.test.c | 2 +- src/kernel/building.c | 7 +++-- src/kernel/building.h | 4 +-- src/kernel/config.c | 11 +++---- src/kernel/config.h | 4 +-- src/kernel/config.test.c | 6 ++-- src/kernel/connection.c | 2 +- src/kernel/curse.c | 2 +- src/kernel/curse.test.c | 1 - src/kernel/equipment.c | 2 +- src/kernel/faction.c | 3 +- src/kernel/faction.h | 6 ++-- src/kernel/item.c | 13 ++++---- src/kernel/item.test.c | 2 +- src/kernel/jsonconf.c | 8 +++-- src/kernel/jsonconf.test.c | 4 +-- src/kernel/messages.test.c | 2 +- src/kernel/race.c | 14 ++++----- src/kernel/race.h | 2 +- src/kernel/region.c | 2 +- src/kernel/save.c | 8 ++--- src/kernel/save.h | 2 +- src/kernel/save.test.c | 2 +- src/kernel/terrain.c | 2 +- src/kernel/unit.c | 5 ++- src/kernel/unit.test.c | 23 +++++++------- src/kernel/version.c | 2 +- src/kernel/xmlreader.c | 10 +++--- src/keyword.c | 2 +- src/keyword.h | 1 - src/laws.c | 61 ++++++++++++++++++------------------ src/laws.test.c | 25 ++++++++------- src/magic.c | 10 +++--- src/magic.h | 2 +- src/magic.test.c | 2 +- src/main.c | 4 +-- src/monsters.c | 2 +- src/monsters.test.c | 6 ++-- src/move.c | 16 +++++----- src/move.test.c | 7 +++-- src/names.c | 2 +- src/piracy.c | 11 ++++--- src/piracy.test.c | 6 ++-- src/platform.h | 5 +++ src/prefix.h | 2 +- src/report.c | 15 +++++---- src/reports.c | 40 +++++++++++------------ src/spells.c | 2 +- src/spells.test.c | 14 +++++---- src/spells/combatspells.c | 5 +-- src/spy.c | 2 +- src/spy.test.c | 2 +- src/study.test.c | 2 +- src/test_eressea.c | 9 ++++-- src/triggers/changefaction.c | 1 - src/triggers/createunit.c | 1 - src/upkeep.test.c | 6 ++-- src/util/attrib.c | 6 ++-- src/util/attrib.h | 6 ++-- src/util/bsdstring.c | 2 +- src/util/bsdstring.test.c | 2 +- src/util/language.c | 10 +++--- src/util/log.c | 12 +++---- src/util/parser.test.c | 4 +-- src/util/password.h | 6 ++-- src/util/umlaut.c | 2 +- src/util/unicode.test.c | 4 +-- src/util/variant.h | 4 +-- src/volcano.c | 8 ++--- 89 files changed, 285 insertions(+), 279 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b4d3614e9..3fc1e62a7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,8 +25,8 @@ IF (CMAKE_COMPILER_IS_GNUCC) ENDIF() IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89 -ansi -pedantic") add_definitions(-DHAVE__BOOL) ELSEIF(MSVC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP") diff --git a/src/alchemy.c b/src/alchemy.c index 81244eba1..aff3485ef 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -172,8 +172,7 @@ static int potion_luck(unit *u, region *r, attrib_type *atype, int amount) { static int potion_truth(unit *u) { UNUSED_ARG(u); - // TODO: this potion does nothing! - // fset(u, UFL_DISBELIEVES); + /* TODO: this potion does nothing! */ return 1; } @@ -297,7 +296,7 @@ static void a_initeffect(attrib * a) a->data.v = calloc(sizeof(effect_data), 1); } -static void a_finalizeeffect(attrib * a) //-V524 +static void a_finalizeeffect(attrib * a) /*-V524 */ { free(a->data.v); } @@ -328,7 +327,7 @@ static int a_readeffect(attrib * a, void *owner, struct gamedata *data) return AT_READ_FAIL; } if (rtype->ptype==oldpotiontype[P_HEAL]) { - // healing potions used to have long-term effects + /* healing potions used to have long-term effects */ return AT_READ_FAIL; } edata->type = rtype->ptype; diff --git a/src/attributes/dict.h b/src/attributes/dict.h index cc700bb9f..aa6b4566a 100644 --- a/src/attributes/dict.h +++ b/src/attributes/dict.h @@ -20,7 +20,7 @@ struct attrib; extern "C" { #endif - extern struct attrib_type at_dict; // DEPRECATED: at_dict has been replaced with at_keys + extern struct attrib_type at_dict; /* DEPRECATED: at_dict has been replaced with at_keys */ void dict_set(struct attrib * a, const char * name, int value); diff --git a/src/attributes/key.c b/src/attributes/key.c index 8b09fdd1c..31580bccf 100644 --- a/src/attributes/key.c +++ b/src/attributes/key.c @@ -134,7 +134,7 @@ void key_set(attrib ** alist, int key, int val) n = keys[0]; } keys = realloc(keys, sizeof(int) *(2 * n + 3)); - // TODO: does insertion sort pay off here? prob. not. + /* TODO: does insertion sort pay off here? prob. not. */ keys[0] = n + 1; keys[2 * n + 1] = key; keys[2 * n + 2] = val; diff --git a/src/attributes/key.h b/src/attributes/key.h index 81511d248..0b3ab748f 100644 --- a/src/attributes/key.h +++ b/src/attributes/key.h @@ -26,7 +26,7 @@ extern "C" { #endif struct attrib; struct attrib_type; - extern struct attrib_type at_key; // DEPRECATED: at_key has been replaced with at_keys + extern struct attrib_type at_key; /* DEPRECATED: at_key has been replaced with at_keys */ extern struct attrib_type at_keys; void key_set(struct attrib **alist, int key, int value); diff --git a/src/battle.c b/src/battle.c index 04e72d92c..9ce22918a 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1111,7 +1111,7 @@ int calculate_armor(troop dt, const weapon_type *dwtype, const weapon_type *awty ar += am; if (magres) { - // calculate damage multiplier for magical damage + /* calculate damage multiplier for magical damage */ double res = 1.0 - magic_resistance(du); if (u_race(du)->battle_flags & BF_EQUIPMENT) { @@ -1302,10 +1302,10 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) if (oldpotiontype[P_HEAL] && !fval(&df->person[dt.index], FL_HEALING_USED)) { if (i_get(du->items, oldpotiontype[P_HEAL]->itype) > 0) { - i_change(&du->items, oldpotiontype[P_HEAL]->itype, -1); message *m = msg_message("battle::potionsave", "unit", du); message_faction(b, du->faction, m); msg_release(m); + i_change(&du->items, oldpotiontype[P_HEAL]->itype, -1); fset(&df->person[dt.index], FL_HEALING_USED); df->person[dt.index].hp = u_race(du)->hitpoints * 5; /* give the person a buffer */ return false; diff --git a/src/battle.test.c b/src/battle.test.c index 946d5fcee..5d34766db 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -433,9 +433,9 @@ static void test_battle_skilldiff(CuTest *tc) td.fighter->person[0].flags |= FL_SLEEPING; CuAssertIntEquals(tc, 3, skilldiff(ta, td, 0)); - // TODO: unarmed halfling vs. dragon: +5 - // TODO: rule_goblin_bonus - // TODO: weapon modifiers, missiles, skill_formula + /* TODO: unarmed halfling vs. dragon: +5 */ + /* TODO: rule_goblin_bonus */ + /* TODO: weapon modifiers, missiles, skill_formula */ free_battle(b); test_cleanup(); diff --git a/src/bind_faction.c b/src/bind_faction.c index 371481fcb..518ccccac 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -381,7 +381,7 @@ static int tolua_faction_get_origin(lua_State * L) static int tolua_faction_destroy(lua_State * L) { faction **fp, *f = (faction *)tolua_tousertype(L, 1, 0); - // TODO: this loop is slow af, but what can we do? + /* TODO: this loop is slow af, but what can we do? */ for (fp = &factions; *fp; fp = &(*fp)->next) { if (*fp == f) { destroyfaction(fp); diff --git a/src/bind_storage.c b/src/bind_storage.c index 6b582e815..68ac36179 100644 --- a/src/bind_storage.c +++ b/src/bind_storage.c @@ -100,8 +100,9 @@ static int tolua_storage_tostring(lua_State * L) { gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0); char name[64]; - // safe to use sprintf here, because: - // %p is at most 16 characters, %d 20, text is 16, comes to 53 with \0 + /* safe to use sprintf here, because: + * %p is at most 16 characters, %d 20, text is 16, + * comes to 53 with \0 */ sprintf(name, "", (void *)data, data->version); lua_pushstring(L, name); return 1; diff --git a/src/bind_unit.c b/src/bind_unit.c index a9d413bf0..c8ac2b362 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -857,13 +857,15 @@ static int tolua_unit_create(lua_State * L) { faction *f = (faction *)tolua_tousertype(L, 1, 0); region *r = (region *)tolua_tousertype(L, 2, 0); + unit *u; const char *rcname = tolua_tostring(L, 4, NULL); int num = (int)tolua_tonumber(L, 3, 1); const race *rc; + assert(f && r); rc = rcname ? rc_find(rcname) : f->race; assert(rc); - unit *u = create_unit(r, f, num, rc, 0, NULL, NULL); + u = create_unit(r, f, num, rc, 0, NULL, NULL); tolua_pushusertype(L, u, TOLUA_CAST "unit"); return 1; } diff --git a/src/bindings.c b/src/bindings.c index 531b68618..18261a507 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -508,7 +508,6 @@ static void reset_game(void) for (f = factions; f; f = f->next) { f->flags &= FFL_SAVEMASK; } -// init_locales(); } static int tolua_process_orders(lua_State * L) @@ -1178,7 +1177,6 @@ int eressea_run(lua_State *L, const char *luafile) lua_remove(L, -2); /* try to run configuration scripts: */ - // err = run_script(L, "config.lua"); err = run_script(L, "custom.lua"); /* run the main script */ diff --git a/src/creport.c b/src/creport.c index 345aaf0bc..c2d10d1c0 100644 --- a/src/creport.c +++ b/src/creport.c @@ -286,7 +286,7 @@ cr_output_curses(struct stream *out, const faction * viewer, const void *obj, ob } static void cr_output_curses_compat(FILE *F, const faction * viewer, const void *obj, objtype_t typ) { - // TODO: eliminate this function + /* TODO: eliminate this function */ stream strm; fstream_init(&strm, F); cr_output_curses(&strm, viewer, obj, typ); @@ -718,7 +718,7 @@ static void cr_output_spells(stream *out, const unit * u, int maxlevel) for (ql = book->spells, qi = 0; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= maxlevel) { - // TODO: no need to deref spref here, spref->name == sp->sname + /* TODO: no need to deref spref here, spref->name == sp->sname */ spell * sp = sbe->sp; const char *name = translate(mkname("spell", sp->sname), spell_name(sp, f->locale)); if (!header) { @@ -752,7 +752,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f, const char *prefix; assert(u && u->number); - assert(u->region == r); // TODO: if this holds true, then why did we pass in r? + assert(u->region == r); /* TODO: if this holds true, then why did we pass in r? */ if (fval(u_race(u), RCF_INVISIBLE)) return; @@ -990,7 +990,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f, static void cr_output_unit_compat(FILE * F, const region * r, const faction * f, const unit * u, int mode) { - // TODO: eliminate this function + /* TODO: eliminate this function */ stream strm; fstream_init(&strm, F); cr_output_unit(&strm, r, f, u, mode); diff --git a/src/economy.c b/src/economy.c index ab1875eed..94a1a90fa 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1753,7 +1753,7 @@ static void expandselling(region * r, request * sellorders, int limit) int i; int use = 0; for (i = 0, search = luxurytypes; search != ltype; search = search->next) { - // TODO: this is slow and lame! + /* TODO: this is slow and lame! */ ++i; } if (counter[i] >= limit) @@ -2444,8 +2444,8 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders) f = u2->faction; } else { - // TODO: is this really necessary? it's the only time we use faction.c/deadhash - // it allows stealing from a unit in a dead faction, but why? + /* TODO: is this really necessary? it's the only time we use faction.c/deadhash + * it allows stealing from a unit in a dead faction, but why? */ f = dfindhash(id); } diff --git a/src/economy.test.c b/src/economy.test.c index fdc218844..766fb4302 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -266,7 +266,7 @@ static void test_maintain_buildings(CuTest *tc) { b->size = btype->maxsize; u_set_building(u, b); - // this building has no upkeep, it just works: + /* this building has no upkeep, it just works: */ b->flags = 0; maintain_buildings(r); CuAssertIntEquals(tc, BLD_MAINTAINED, fval(b, BLD_MAINTAINED)); @@ -278,7 +278,7 @@ static void test_maintain_buildings(CuTest *tc) { req[0].rtype = itype->rtype; btype->maintenance = req; - // we cannot afford to pay: + /* we cannot afford to pay: */ b->flags = 0; maintain_buildings(r); CuAssertIntEquals(tc, 0, fval(b, BLD_MAINTAINED)); @@ -287,7 +287,7 @@ static void test_maintain_buildings(CuTest *tc) { test_clear_messagelist(&f->msgs); test_clear_messagelist(&r->msgs); - // we can afford to pay: + /* we can afford to pay: */ i_change(&u->items, itype, 100); b->flags = 0; maintain_buildings(r); @@ -298,7 +298,7 @@ static void test_maintain_buildings(CuTest *tc) { CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "maintenance")); test_clear_messagelist(&f->msgs); - // this building has no owner, it doesn't work: + /* this building has no owner, it doesn't work: */ u_set_building(u, NULL); b->flags = 0; maintain_buildings(r); diff --git a/src/give.c b/src/give.c index d1a9d75f4..5abb950a6 100644 --- a/src/give.c +++ b/src/give.c @@ -70,8 +70,8 @@ static bool can_give(const unit * u, const unit * u2, const item_type * itype, i { if (u2) { if (u2->number==0 && !fval(u2, UFL_ISNEW)) { - // https://bugs.eressea.de/view.php?id=2230 - // cannot give anything to dead units + /* https://bugs.eressea.de/view.php?id=2230 + * cannot give anything to dead units */ return false; } else if (u->faction != u2->faction) { int rule = rule_give(); @@ -258,7 +258,7 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord) message * msg; int maxt = max_transfers(); - assert(u2); // use disband_men for GIVE 0 + assert(u2); /* use disband_men for GIVE 0 */ if (!can_give_men(u, u2, ord, &msg)) { return msg; diff --git a/src/give.test.c b/src/give.test.c index 7da787c87..fbb71cf3c 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -393,7 +393,7 @@ static void test_give_new_unit(CuTest * tc) { } static void test_give_invalid_target(CuTest *tc) { - // bug https://bugs.eressea.de/view.php?id=1685 + /* bug https://bugs.eressea.de/view.php?id=1685 */ struct give env = { 0 }; order *ord; diff --git a/src/gmtool.c b/src/gmtool.c index 3db673731..5a0cd576c 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -184,7 +184,7 @@ map_region *mr_get(const view * vi, int xofs, int yofs) static point *coor2point(const coordinate * c, point * p) { assert(c && p); - p->x = c->x * TWIDTH + c->y * TWIDTH / 2; //-V537 + p->x = c->x * TWIDTH + c->y * TWIDTH / 2; /*-V537 */ p->y = c->y * THEIGHT; return p; } @@ -262,7 +262,7 @@ static chtype mr_tile(const map_region * mr, int highlight) const region *r = mr->r; switch (r->terrain->_name[0]) { case 'o': - return '.' | COLOR_PAIR(hl + COLOR_CYAN) | A_BOLD; //-V525 + return '.' | COLOR_PAIR(hl + COLOR_CYAN) | A_BOLD; /*-V525 */ case 'd': return 'D' | COLOR_PAIR(hl + COLOR_YELLOW) | A_BOLD; case 't': diff --git a/src/guard.test.c b/src/guard.test.c index c5bffeab5..fb55129ee 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -34,7 +34,7 @@ static void test_is_guarded(CuTest *tc) { } static void test_guard_unskilled(CuTest * tc) -// TODO: it would be better to test armedmen() +/* TODO: it would be better to test armedmen() */ { unit *u, *ug; region *r; diff --git a/src/json.c b/src/json.c index 2c27b9947..e6eacced9 100644 --- a/src/json.c +++ b/src/json.c @@ -67,13 +67,13 @@ int json_export(stream * out, int flags) { cJSON *json, *root = cJSON_CreateObject(); assert(out && out->api); if (regions && (flags & EXPORT_REGIONS)) { - char id[32]; // TODO: static_assert(INT_MAX < 10^32) + char id[32]; /* TODO: static_assert(INT_MAX < 10^32) */ region * r; plane * p; cJSON_AddItemToObject(root, "planes", json = cJSON_CreateObject()); for (p = planes; p; p = p->next) { cJSON *data; - sprintf(id, "%d", p->id); // safe, unless int is bigger than 64 bit + sprintf(id, "%d", p->id); /* safe, unless int is bigger than 64 bit */ cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); cJSON_AddNumberToObject(data, "x", p->minx); cJSON_AddNumberToObject(data, "y", p->miny); @@ -85,7 +85,7 @@ int json_export(stream * out, int flags) { cJSON_AddItemToObject(root, "regions", json = cJSON_CreateObject()); for (r = regions; r; r = r->next) { cJSON *data; - sprintf(id, "%d", r->uid); // safe, unless int is bigger than 64 bit + sprintf(id, "%d", r->uid); /* safe, unless int is bigger than 64 bit */ cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); cJSON_AddNumberToObject(data, "x", r->x); cJSON_AddNumberToObject(data, "y", r->y); diff --git a/src/json.test.c b/src/json.test.c index 528b734a4..57cb6e136 100644 --- a/src/json.test.c +++ b/src/json.test.c @@ -16,7 +16,7 @@ static char *strip(char *str) { char *s = str, *b = str, *e = str; - // b is where text begins, e where it ends, s where we insert it. + /* b is where text begins, e where it ends, s where we insert it. */ for (; *b && isspace(*b); ++b) {}; for (e = b; *e && !isspace(*e); ++e) {}; while (*b) { diff --git a/src/kernel/build.test.c b/src/kernel/build.test.c index b714f58f0..77efcfd73 100644 --- a/src/kernel/build.test.c +++ b/src/kernel/build.test.c @@ -200,7 +200,7 @@ static void test_build_with_potion(CuTest *tc) { CuAssertIntEquals(tc, 4, build(u, &bf.cons, 0, 20)); CuAssertIntEquals(tc, 2, get_effect(u, ptype)); set_level(u, SK_ARMORER, bf.cons.minskill); - scale_number(u, 2); // OBS: this scales the effects, too: + scale_number(u, 2); /* OBS: this scales the effects, too: */ CuAssertIntEquals(tc, 4, get_effect(u, ptype)); CuAssertIntEquals(tc, 4, build(u, &bf.cons, 0, 20)); CuAssertIntEquals(tc, 2, get_effect(u, ptype)); diff --git a/src/kernel/building.c b/src/kernel/building.c index 98caad07a..06078aaba 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -461,8 +461,8 @@ void remove_building(building ** blist, building * b) bunhash(b); /* Falls Karawanserei, Damm oder Tunnel einst�rzen, wird die schon - * gebaute Stra�e zur H�lfte vernichtet */ - // TODO: caravan, tunnel, dam modularization ? is_building_type ? + * gebaute Strasse zur Haelfte vernichtet */ + /* TODO: caravan, tunnel, dam modularization ? is_building_type ? */ if (b->type == bt_caravan || b->type == bt_dam || b->type == bt_tunnel) { region *r = b->region; int d; @@ -605,10 +605,11 @@ static unit *building_owner_ex(const building * bld, const struct faction * last unit *building_owner(const building * bld) { + unit *owner; if (!bld) { return NULL; } - unit *owner = bld->_owner; + owner = bld->_owner; if (!owner || (owner->building != bld || owner->number <= 0)) { unit * heir = building_owner_ex(bld, owner ? owner->faction : 0); return (heir && heir->number > 0) ? heir : 0; diff --git a/src/kernel/building.h b/src/kernel/building.h index 8b1a5b05b..1adce7e09 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -55,8 +55,8 @@ extern "C" { typedef enum { DEFENSE_BONUS, - CLOSE_COMBAT_ATTACK_BONUS, // TODO: only DEFENSE_BONUS is in use? - RANGED_ATTACK_BONUS, + CLOSE_COMBAT_ATTACK_BONUS, /* TODO: only DEFENSE_BONUS is in use? */ + RANGED_ATTACK_BONUS } building_bonus; typedef struct building_type { diff --git a/src/kernel/config.c b/src/kernel/config.c index ca23a5bc9..3f04b03b3 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -275,7 +275,6 @@ unit *getnewunit(const region * r, const faction * f) /* -- Erschaffung neuer Einheiten ------------------------------ */ static const char *forbidden[] = { "t", "te", "tem", "temp", NULL }; -// PEASANT: "b", "ba", "bau", "baue", "p", "pe", "pea", "peas" static int *forbidden_ids; int forbiddenid(int id) @@ -491,19 +490,19 @@ int check_param(const struct param *p, const char *key, const char *searchvalue) { int result = 0; const char *value = get_param(p, key); + char *v, *p_value; if (!value) { return 0; } - char *p_value = strdup(value); - const char *delimiter = " ,;"; - char *v = strtok(p_value, delimiter); + p_value = strdup(value); + v = strtok(p_value, " ,;"); while (v != NULL) { if (strcmp(v, searchvalue) == 0) { result = 1; break; } - v = strtok(NULL, delimiter); + v = strtok(NULL, " ,;"); } free(p_value); return result; @@ -836,7 +835,7 @@ const char * game_name(void) const char * game_name_upper(void) { - static char result[32]; // FIXME: static result + static char result[32]; /* FIXME: static result */ char *r = result; const char *param = game_name(); const char *c = param; diff --git a/src/kernel/config.h b/src/kernel/config.h index b51ba2725..e38d1dd56 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -61,8 +61,8 @@ extern "C" { int newcontainerid(void); bool rule_region_owners(void); - bool rule_stealth_other(void); // units can pretend to be another faction, TARNE PARTEI - bool rule_stealth_anon(void); // units can anonymize their faction, TARNE PARTEI [NICHT] + bool rule_stealth_other(void); /* units can pretend to be another faction, TARNE PARTEI */ + bool rule_stealth_anon(void); /* units can anonymize their faction, TARNE PARTEI [NICHT] */ int rule_alliance_limit(void); int rule_faction_limit(void); #define HARVEST_WORK 0x00 diff --git a/src/kernel/config.test.c b/src/kernel/config.test.c index 72b2387ac..9a10a4c56 100644 --- a/src/kernel/config.test.c +++ b/src/kernel/config.test.c @@ -51,7 +51,7 @@ static void test_read_unitid(CuTest *tc) { CuAssertIntEquals(tc, -1, read_unitid(u->faction, u->region)); free_order(ord); - // bug https://bugs.eressea.de/view.php?id=1685 + /* bug https://bugs.eressea.de/view.php?id=1685 */ ord = create_order(K_GIVE, lang, "##"); init_order(ord); CuAssertIntEquals(tc, -1, read_unitid(u->faction, u->region)); @@ -98,14 +98,14 @@ static void test_getunit(CuTest *tc) { CuAssertPtrEquals(tc, NULL, u2); free_order(ord); - // bug https://bugs.eressea.de/view.php?id=1685 + /* bug https://bugs.eressea.de/view.php?id=1685 */ ord = create_order(K_GIVE, lang, "TEMP ##"); init_order(ord); CuAssertIntEquals(tc, GET_NOTFOUND, getunit(u->region, u->faction, &u2)); CuAssertPtrEquals(tc, NULL, u2); free_order(ord); - // bug https://bugs.eressea.de/view.php?id=1685 + /* bug https://bugs.eressea.de/view.php?id=1685 */ ord = create_order(K_GIVE, lang, "##"); init_order(ord); CuAssertIntEquals(tc, GET_NOTFOUND, getunit(u->region, u->faction, &u2)); diff --git a/src/kernel/connection.c b/src/kernel/connection.c index 5b2615bcc..43caee729 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -640,7 +640,7 @@ int read_borders(gamedata *data) if (!to || !from) { log_error("%s connection %d has missing regions", zText, bid); if (type->read) { - // skip ahead + /* skip ahead */ connection dummy; type->read(&dummy, data); } diff --git a/src/kernel/curse.c b/src/kernel/curse.c index 7df567940..25f89ec1f 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -696,7 +696,7 @@ void transfer_curse(unit * u, unit * u2, int n) int curse_cansee(const curse *c, const faction *viewer, objtype_t typ, const void *obj, int self) { if (self < 3 && c->magician && c->magician->faction == viewer) { - // magicians can see their own curses better than anybody, no exceptions + /* magicians can see their own curses better than anybody, no exceptions */ self = 3; } else if (c->type->cansee) { diff --git a/src/kernel/curse.test.c b/src/kernel/curse.test.c index 0ca4510d9..56c3288f8 100644 --- a/src/kernel/curse.test.c +++ b/src/kernel/curse.test.c @@ -55,7 +55,6 @@ static void setup_curse(curse_fixture *fix, const char *name) { } static void cleanup_curse(curse_fixture *fix) { - // destroy_curse(fix->c); test_cleanup(); } diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index 6b74121ff..d9a971455 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -253,7 +253,7 @@ void equipment_done(void) { free(eq->items); eq->items = next; } - // TODO: subsets, skills + /* TODO: subsets, skills */ for (i=0;i!=MAXSKILLS;++i) { free(eq->skills[i]); } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index a5373d44d..57cd5d3af 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -449,7 +449,7 @@ void destroyfaction(faction ** fp) /* units of other factions that were disguised as this faction * have their disguise replaced by ordinary faction hiding. */ if (rule_stealth_other()) { - // TODO: f.alive should be tested for in get_otherfaction + /* TODO: f.alive should be tested for in get_otherfaction */ region *rc; for (rc = regions; rc; rc = rc->next) { for (u = rc->units; u; u = u->next) { @@ -553,7 +553,6 @@ void faction_setbanner(faction * self, const char *banner) void faction_setpassword(faction * f, const char *pwhash) { assert(pwhash); - // && pwhash[0] == '$'); free(f->_password); f->_password = strdup(pwhash); } diff --git a/src/kernel/faction.h b/src/kernel/faction.h index 1bab9101c..0a0ac39d6 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -38,11 +38,11 @@ extern "C" { extern struct attrib_type at_maxmagicians; /* faction flags */ -#define FFL_NEWID (1<<0) // Die Partei hat bereits einmal ihre no gewechselt +#define FFL_NEWID (1<<0) /* Die Partei hat bereits einmal ihre no gewechselt */ #define FFL_ISNEW (1<<1) -#define FFL_PWMSG (1<<2) // received a "new password" message +#define FFL_PWMSG (1<<2) /* received a "new password" message */ #define FFL_QUIT (1<<3) -#define FFL_CURSED (1<<4) // you're going to have a bad time +#define FFL_CURSED (1<<4) /* you're going to have a bad time */ #define FFL_DEFENDER (1<<10) #define FFL_SELECT (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */ #define FFL_NOAID (1<<21) /* Hilfsflag Kampf */ diff --git a/src/kernel/item.c b/src/kernel/item.c index 9327700cd..177e44831 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -155,7 +155,7 @@ const char *resourcename(const resource_type * rtype, int flags) } } if (flags & NMF_PLURAL) { - static char name[64]; // FIXME: static return value + static char name[64]; /* FIXME: static return value */ size_t len = strlen(rtype->_name); assert(len <= sizeof(name) - 3); memcpy(name, rtype->_name, len); @@ -638,11 +638,14 @@ static const char *resourcenames[MAX_RESOURCES] = { const resource_type *get_resourcetype(resource_t type) { static int update; static struct resource_type * rtypes[MAX_RESOURCES]; + const resource_type *rtype = NULL; if (update != num_resources) { memset(rtypes, 0, sizeof(rtypes)); update = num_resources; } - const resource_type *rtype = rtypes[type]; + else { + rtype = rtypes[type]; + } if (!rtype) { rtype = rtypes[type] = rt_find(resourcenames[type]); } @@ -975,27 +978,23 @@ void init_resources(void) { resource_type *rtype; - rt_get_or_create(resourcenames[R_PERSON]); // lousy hack + rt_get_or_create(resourcenames[R_PERSON]); /* lousy hack */ rtype = rt_get_or_create(resourcenames[R_PEASANT]); rtype->uchange = res_changepeasants; - // R_SILVER rtype = rt_get_or_create(resourcenames[R_SILVER]); rtype->flags |= RTF_ITEM | RTF_POOLED; rtype->uchange = res_changeitem; rtype->itype = it_get_or_create(rtype); rtype->itype->give = give_money; - // R_PERMAURA rtype = rt_get_or_create(resourcenames[R_PERMAURA]); rtype->uchange = res_changepermaura; - // R_LIFE rtype = rt_get_or_create(resourcenames[R_LIFE]); rtype->uchange = res_changehp; - // R_AURA rtype = rt_get_or_create(resourcenames[R_AURA]); rtype->uchange = res_changeaura; diff --git a/src/kernel/item.test.c b/src/kernel/item.test.c index 231b45d00..52e7d9917 100644 --- a/src/kernel/item.test.c +++ b/src/kernel/item.test.c @@ -19,7 +19,7 @@ static void test_resourcename_no_appearance(CuTest *tc) { const resource_type *rtype; test_cleanup(); - init_resources(); // creates R_SILVER + init_resources(); /* creates R_SILVER */ rtype = get_resourcetype(R_SILVER); assert(rtype && rtype->itype); assert(rtype->itype->_appearance[0] == 0); diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 89219665e..2478c838f 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -146,6 +146,8 @@ static void json_maintenance(cJSON *json, maintenance **mtp) { static void json_construction(cJSON *json, construction **consp) { cJSON *child; + construction * cons; + if (json->type == cJSON_Array) { int size = 0; for (child = json->child; child; child = child->next) { @@ -164,7 +166,7 @@ static void json_construction(cJSON *json, construction **consp) { log_error("construction %s is not a json object: %d", json->string, json->type); return; } - construction * cons = (construction *)calloc(sizeof(construction), 1); + cons = (construction *)calloc(sizeof(construction), 1); for (child = json->child; child; child = child->next) { switch (child->type) { case cJSON_Object: @@ -191,8 +193,8 @@ static void json_construction(cJSON *json, construction **consp) { } static void json_terrain_production(cJSON *json, terrain_production *prod) { - assert(json->type == cJSON_Object); cJSON *child; + assert(json->type == cJSON_Object); for (child = json->child; child; child = child->next) { char **dst = 0; switch (child->type) { @@ -490,7 +492,7 @@ static void json_race(cJSON *json, race *rc) { else if (strcmp(child->string, "ac") == 0) { rc->armor = child->valueint; } - // TODO: studyspeed (orcs only) + /* TODO: studyspeed (orcs only) */ break; case cJSON_Array: if (strcmp(child->string, "flags") == 0) { diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index abf64e7d5..dcf748d00 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -75,7 +75,7 @@ static void test_settings(CuTest * tc) cJSON *json = cJSON_Parse(data); test_cleanup(); - config_set("game.id", "42"); // should not be replaced + config_set("game.id", "42"); /* should not be replaced */ json_config(json); CuAssertStrEquals(tc, "42", config_get("game.id")); CuAssertStrEquals(tc, "1", config_get("true")); @@ -488,7 +488,7 @@ static void test_terrains(CuTest * tc) CuAssertPtrEquals(tc, rt_get_or_create("h0"), ter->herbs[0]->rtype); CuAssertPtrEquals(tc, rt_get_or_create("h1"), ter->herbs[1]->rtype); CuAssertPtrEquals(tc, 0, (void *)ter->herbs[2]); - CuAssertPtrNotNull(tc, ter->name); // anything named "plain" uses plain_name() + CuAssertPtrNotNull(tc, ter->name); /* anything named "plain" uses plain_name() */ CuAssertPtrNotNull(tc, ter->production); CuAssertPtrEquals(tc, rt_get_or_create("stone"), (resource_type *)ter->production[0].type); CuAssertDblEquals(tc, 0.1, ter->production[0].chance, 0.01); diff --git a/src/kernel/messages.test.c b/src/kernel/messages.test.c index c391c8720..7b0f2dd5e 100644 --- a/src/kernel/messages.test.c +++ b/src/kernel/messages.test.c @@ -39,7 +39,7 @@ void test_message(CuTest *tc) { static void test_merge_split(CuTest *tc) { message_list *mlist = 0, *append = 0; - struct mlist **split; // TODO: why is this a double asterisk? + struct mlist **split; /* TODO: why is this a double asterisk? */ message_type *mtype = mt_new("custom", NULL); message *msg; diff --git a/src/kernel/race.c b/src/kernel/race.c index 683d37d63..2ede414c7 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -86,12 +86,12 @@ typedef struct rcoption { enum { RCO_NONE, - RCO_SCARE, // races that scare and eat peasants - RCO_OTHER, // may recruit from another race - RCO_STAMINA, // every n levels of stamina add +1 RC - RCO_HUNGER, // custom hunger.damage override (char *) + RCO_SCARE, /* races that scare and eat peasants */ + RCO_OTHER, /* may recruit from another race */ + RCO_STAMINA, /* every n levels of stamina add +1 RC */ + RCO_HUNGER, /* custom hunger.damage override (char *) */ RCO_TRADELUX, - RCO_TRADEHERB, + RCO_TRADEHERB }; static void rc_setoption(race *rc, int k, const char *value) { @@ -476,7 +476,7 @@ const char* rc_name(const race * rc, name_t n, char *name, size_t size) { const char *rc_name_s(const race * rc, name_t n) { - static char name[64]; // FIXME: static return value + static char name[64]; /* FIXME: static return value */ return rc_name(rc, n, name, sizeof(name)); } @@ -497,7 +497,7 @@ const char *racename(const struct locale *loc, const unit * u, const race * rc) const char *str, *prefix = raceprefix(u); if (prefix != NULL) { - static char lbuf[80]; // FIXME: static return value + static char lbuf[80]; /* FIXME: static return value */ char *bufp = lbuf; size_t size = sizeof(lbuf) - 1; int ch, bytes; diff --git a/src/kernel/race.h b/src/kernel/race.h index 05e9ffdec..ceb5e59d9 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -151,7 +151,7 @@ extern "C" { struct item *(*itemdrop) (const struct race *, int size); void(*init_familiar) (struct unit *); - struct rcoption *options; // rarely used properties + struct rcoption *options; /* rarely used properties */ const struct race *familiars[MAXMAGIETYP]; struct race *next; diff --git a/src/kernel/region.c b/src/kernel/region.c index 06d2d9d7c..aefffa875 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -1132,7 +1132,7 @@ void terraform_region(region * r, const terrain_type * terrain) } } if (!nb) { - // TODO: this is really lame + /* TODO: this is really lame */ int i = get_maxluxuries(); if (i > 0) { i = rng_int() % i; diff --git a/src/kernel/save.c b/src/kernel/save.c index 67ed7e125..3ddaf7a7c 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -94,7 +94,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* exported symbols symbols */ int firstx = 0, firsty = 0; -// TODO: is this still important? +/* TODO: is this still important? */ int enc_gamedata = ENCODING_UTF8; /* local symbols */ @@ -467,7 +467,7 @@ void read_planes(gamedata *data) { } } read_attribs(data, &pl->attribs, pl); - if (pl->id != 1094969858) { // Regatta + if (pl->id != 1094969858) { /* Regatta */ addlist(&planes, pl); } } @@ -1206,7 +1206,7 @@ static void read_password(gamedata *data, faction *f) { char * pass = getpasswd(f->no); if (pass) { faction_setpassword(f, password_encode(pass, PASSWORD_DEFAULT)); - free(pass); // TODO: remove this allocation! + free(pass); /* TODO: remove this allocation! */ } else { log_error("data version is BADCRYPT but %s not in password.txt", itoa36(f->no)); @@ -1542,7 +1542,7 @@ struct building *read_building(gamedata *data) { b->type = bt_find(name); read_attribs(data, &b->attribs, b); - // repairs, bug 2221: + /* repairs, bug 2221: */ if (b->type->maxsize>0 && b->size>b->type->maxsize) { log_error("building too big: %s (%s size %d of %d), fixing.", buildingname(b), b->type->_name, b->size, b->type->maxsize); b->size = b->type->maxsize; diff --git a/src/kernel/save.h b/src/kernel/save.h index 4ead34efe..763ff66b6 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -40,7 +40,7 @@ extern "C" { /* Nach MAX_INPUT_SIZE brechen wir das Einlesen der Zeile ab und nehmen an, * dass hier ein Fehler (fehlende ") vorliegt */ - // TODO: is this *really* still in use? + /* TODO: is this *really* still in use? */ extern int enc_gamedata; int readorders(const char *filename); diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index 70bcb2e65..9501df896 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -78,7 +78,7 @@ static void test_readwrite_unit(CuTest * tc) mstream_done(&data.strm); gamedata_done(&data); - move_unit(u, r, NULL); // this makes sure that u doesn't leak + move_unit(u, r, NULL); /* this makes sure that u doesn't leak */ test_cleanup(); } diff --git a/src/kernel/terrain.c b/src/kernel/terrain.c index ca72e3060..3d6f4c313 100644 --- a/src/kernel/terrain.c +++ b/src/kernel/terrain.c @@ -114,7 +114,7 @@ terrain_type * get_or_create_terrain(const char *name) { terrain->next = registered_terrains; registered_terrains = terrain; if (strcmp("plain", name) == 0) { - // TODO: this is awful, it belongs in config + /* TODO: this is awful, it belongs in config */ terrain->name = &plain_name; } } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 2f38a0836..1acebac6d 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -120,7 +120,7 @@ unit *findunitr(const region * r, int n) return (u && u->region == r) ? u : 0; } -// TODO: deprecated, replace with findunit(n) +/* TODO: deprecated, replace with findunit(n) */ unit *findunitg(int n, const region * hint) { UNUSED_ARG(hint); @@ -366,7 +366,7 @@ int gift_items(unit * u, int flags) static unit *deleted_units = NULL; #define DMAXHASH 7919 -#undef DMAXHASH // TODO: makes dfindhash slow! +#undef DMAXHASH /* TODO: makes dfindhash slow! */ #ifdef DMAXHASH typedef struct dead { struct dead *nexthash; @@ -455,7 +455,6 @@ int remove_unit(unit ** ulist, unit * u) #ifdef DMAXHASH dhash(u->no, u->faction); #endif - // u_setfaction(u, NULL); u->region = NULL; diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index 1ddf6282e..16ff2890b 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -260,7 +260,7 @@ static void test_skillmod(CuTest *tc) { CuAssertIntEquals(tc, 10, effskill(u, SK_ARMORER, 0)); a_remove(&u->attribs, a); - a_add(&u->attribs, a = make_skillmod(NOSKILL, SMF_ALWAYS, 0, 2.0, 0)); // NOSKILL means any skill + a_add(&u->attribs, a = make_skillmod(NOSKILL, SMF_ALWAYS, 0, 2.0, 0)); /* NOSKILL means any skill */ CuAssertIntEquals(tc, 10, effskill(u, SK_ARMORER, 0)); a_remove(&u->attribs, a); @@ -296,7 +296,7 @@ static void test_skill_familiar(CuTest *tc) { test_cleanup(); - // setup two units + /* setup two units */ mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); fam = test_create_unit(mag->faction, test_create_region(0, 0, 0)); set_level(fam, SK_PERCEPTION, 6); @@ -304,14 +304,14 @@ static void test_skill_familiar(CuTest *tc) { set_level(mag, SK_PERCEPTION, 6); CuAssertIntEquals(tc, 6, effskill(mag, SK_PERCEPTION, 0)); - // make them mage and familiar to each other + /* make them mage and familiar to each other */ CuAssertIntEquals(tc, true, create_newfamiliar(mag, fam)); - // when they are in the same region, the mage gets half their skill as a bonus + /* when they are in the same region, the mage gets half their skill as a bonus */ CuAssertIntEquals(tc, 6, effskill(fam, SK_PERCEPTION, 0)); CuAssertIntEquals(tc, 9, effskill(mag, SK_PERCEPTION, 0)); - // when they are further apart, divide bonus by distance + /* when they are further apart, divide bonus by distance */ r = test_create_region(3, 0, 0); move_unit(fam, r, &r->units); CuAssertIntEquals(tc, 7, effskill(mag, SK_PERCEPTION, 0)); @@ -323,7 +323,6 @@ static void test_age_familiar(CuTest *tc) { test_cleanup(); - // setup two units mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); fam = test_create_unit(mag->faction, test_create_region(0, 0, 0)); CuAssertPtrEquals(tc, 0, get_familiar(mag)); @@ -426,28 +425,28 @@ static void test_remove_unit(CuTest *tc) { remove_unit(&r->units, u1); CuAssertIntEquals(tc, 0, u1->number); CuAssertPtrEquals(tc, 0, u1->region); - // money is given to a survivor: + /* money is given to a survivor: */ CuAssertPtrEquals(tc, 0, u1->items); CuAssertIntEquals(tc, 0, region_getresource(r, rtype)); CuAssertIntEquals(tc, 100, i_get(u2->items, rtype->itype)); - // unit is removed from f->units: + /* unit is removed from f->units: */ CuAssertPtrEquals(tc, 0, u1->nextF); CuAssertPtrEquals(tc, u2, f->units); CuAssertPtrEquals(tc, 0, u2->nextF); CuAssertPtrEquals(tc, 0, u2->prevF); - // unit is no longer in r->units: + /* unit is no longer in r->units: */ CuAssertPtrEquals(tc, u2, r->units); CuAssertPtrEquals(tc, 0, u2->next); - // unit is in deleted_units: + /* unit is in deleted_units: */ CuAssertPtrEquals(tc, 0, findunit(uno)); CuAssertPtrEquals(tc, f, dfindhash(uno)); remove_unit(&r->units, u2); - // no survivor, give money to peasants: + /* no survivor, give money to peasants: */ CuAssertIntEquals(tc, 100, region_getresource(r, rtype)); - // there are now no more units: + /* there are now no more units: */ CuAssertPtrEquals(tc, 0, r->units); CuAssertPtrEquals(tc, 0, f->units); test_cleanup(); diff --git a/src/kernel/version.c b/src/kernel/version.c index 8cf6a372e..633fbf7bf 100644 --- a/src/kernel/version.c +++ b/src/kernel/version.c @@ -4,7 +4,7 @@ #include #ifndef ERESSEA_VERSION -// the version number, if it was not passed to make with -D +/* the version number, if it was not passed to make with -D */ #define ERESSEA_VERSION "3.11.0" #endif diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 9faf92ef8..2cf0b42e8 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -659,7 +659,7 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype) xmlFree(propValue); propValue = xmlGetProp(node, BAD_CAST "value"); - wtype->damage[pos] = strdup((const char *)propValue); // TODO: this is a memory leak + wtype->damage[pos] = strdup((const char *)propValue); /* TODO: this is a memory leak */ if (k == 0) wtype->damage[1 - pos] = wtype->damage[pos]; xmlFree(propValue); @@ -1043,7 +1043,7 @@ static int parse_resources(xmlDocPtr doc) else if (strcmp((const char *)propValue, "material") == 0) { int g, num, den = 100; double fval = xml_fvalue(node, "value", 0); - // TODO: extract into a function for reading fractions? + /* TODO: extract into a function for reading fractions? */ num = (int)(fval * den + 0.5); g = gcd(num, den); num /= g; @@ -1635,8 +1635,8 @@ static int parse_races(xmlDocPtr doc) xmlFree(propValue); rc->magres = xml_ivalue(node, "magres", rc->magres); - rc->healing = (int)(xml_fvalue(node, "healing", rc->healing) * 100); // TODO: store as int in XML - rc->maxaura = (int)(xml_fvalue(node, "maxaura", rc->maxaura) * 100); // TODO: store as int in XML + rc->healing = (int)(xml_fvalue(node, "healing", rc->healing) * 100); /* TODO: store as int in XML */ + rc->maxaura = (int)(xml_fvalue(node, "maxaura", rc->maxaura) * 100); /* TODO: store as int in XML */ rc->regaura = (float)xml_fvalue(node, "regaura", rc->regaura); rc->recruitcost = xml_ivalue(node, "recruitcost", rc->recruitcost); rc->maintenance = xml_ivalue(node, "maintenance", rc->maintenance); @@ -1722,7 +1722,7 @@ static int parse_races(xmlDocPtr doc) rc->ec_flags |= ECF_REC_UNLIMITED; if (xml_bvalue(node, "equipment", false)) - rc->battle_flags |= BF_EQUIPMENT; // TODO: invert this flag, so rc_get_or_create gets simpler + rc->battle_flags |= BF_EQUIPMENT; /* TODO: invert this flag, so rc_get_or_create gets simpler */ if (xml_bvalue(node, "noblock", false)) rc->battle_flags |= BF_NOBLOCK; if (xml_bvalue(node, "invinciblenonmagic", false)) diff --git a/src/keyword.c b/src/keyword.c index 199811669..ba05cbe4b 100644 --- a/src/keyword.c +++ b/src/keyword.c @@ -13,7 +13,7 @@ const char * keyword(keyword_t kwd) { - static char result[32]; // FIXME: static return value + static char result[32]; /* FIXME: static return value */ if (kwd==NOKEYWORD) { return NULL; } diff --git a/src/keyword.h b/src/keyword.h index 1d8f04bb2..19e55e88f 100644 --- a/src/keyword.h +++ b/src/keyword.h @@ -84,7 +84,6 @@ extern "C" bool keyword_disabled(keyword_t kwd); void enable_keyword(keyword_t kwd, bool enabled); const char *keyword(keyword_t kwd); - // #define keyword(kwd) mkname("keyword", keywords[kwd]) #ifdef __cplusplus #endif diff --git a/src/laws.c b/src/laws.c index 98ff5d9f6..e314e2d85 100644 --- a/src/laws.c +++ b/src/laws.c @@ -736,8 +736,8 @@ growing_herbs(region * r, const int current_season, const int last_weeks_season) void immigration(void) { region *r; - log_info(" - Einwanderung..."); int repopulate = config_get_int("rules.economy.repopulate_maximum", 90); + log_info(" - Einwanderung..."); for (r = regions; r; r = r->next) { if (r->land && r->land->newpeasants) { int rp = rpeasants(r) + r->land->newpeasants; @@ -2124,10 +2124,11 @@ int mail_cmd(unit * u, struct order *ord) int banner_cmd(unit * u, struct order *ord) { - init_order(ord); - const char * s = getstrtoken(); + const char * s; free(u->faction->banner); + init_order(ord); + s = getstrtoken(); u->faction->banner = s ? strdup(s) : 0; add_message(&u->faction->msgs, msg_message("changebanner", "value", u->faction->banner)); @@ -2414,12 +2415,12 @@ static void reshow_other(unit * u, struct order *ord, const char *s) { rc = findrace(s, u->faction->locale); if (itype) { - // if this is a potion, we need the right alchemy skill + /* if this is a potion, we need the right alchemy skill */ int i = i_get(u->items, itype); - err = 36; // we do not have this item? + err = 36; /* we do not have this item? */ if (i <= 0) { - // we don't have the item, but it may be a potion that we know + /* we don't have the item, but it may be a potion that we know */ const potion_type *ptype = resource2potion(item2resource(itype)); if (ptype) { if (2 * ptype->level > effskill(u, SK_ALCHEMY, 0)) { @@ -2724,13 +2725,13 @@ void sinkships(struct region * r) if (!sh->type->construction || sh->size >= sh->type->construction->maxsize) { if (fval(r->terrain, SEA_REGION)) { if (!enoughsailors(sh, crew_skill(sh))) { - // ship is at sea, but not enough people to control it + /* ship is at sea, but not enough people to control it */ double dmg = config_get_flt("rules.ship.damage.nocrewocean", 0.3); damage_ship(sh, dmg); } } else if (!ship_owner(sh)) { - // any ship lying around without an owner slowly rots + /* any ship lying around without an owner slowly rots */ double dmg = config_get_flt("rules.ship.damage.nocrew", 0.05); damage_ship(sh, dmg); } @@ -2971,7 +2972,7 @@ static void ageing(void) a_age(&u->attribs, u); if (u == *up) handle_event(u->attribs, "timer", u); - if (u == *up) //-V581 + if (u == *up) /*-V581 */ up = &(*up)->next; } @@ -2981,7 +2982,7 @@ static void ageing(void) a_age(&s->attribs, s); if (s == *sp) handle_event(s->attribs, "timer", s); - if (s == *sp) //-V581 + if (s == *sp) /*-V581 */ sp = &(*sp)->next; } @@ -3109,7 +3110,7 @@ void new_units(void) } u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u); if (name != NULL) - free(name); // TODO: use a buffer on the stack instead? + free(name); /* TODO: use a buffer on the stack instead? */ fset(u2, UFL_ISNEW); a_add(&u2->attribs, a_new(&at_alias))->data.i = alias; @@ -3158,10 +3159,10 @@ void update_long_order(unit * u) free_orders(&u->old_orders); } - // hungry units do not get long orders: + /* hungry units do not get long orders: */ if (hunger) { if (u->old_orders) { - // keep looking for repeated orders that might clear the old_orders + /* keep looking for repeated orders that might clear the old_orders */ continue; } break; @@ -3169,19 +3170,19 @@ void update_long_order(unit * u) if (is_long(kwd)) { if (thiskwd == NOKEYWORD) { - // we have found the (first) long order - // some long orders can have multiple instances: + /* we have found the (first) long order + * some long orders can have multiple instances: */ switch (kwd) { /* Wenn gehandelt wird, darf kein langer Befehl ausgeführt - * werden. Da Handel erst nach anderen langen Befehlen kommt, - * muss das vorher abgefangen werden. Wir merken uns also - * hier, ob die Einheit handelt. */ + * werden. Da Handel erst nach anderen langen Befehlen kommt, + * muss das vorher abgefangen werden. Wir merken uns also + * hier, ob die Einheit handelt. */ case K_BUY: case K_SELL: case K_CAST: - // non-exclusive orders can be used with others. BUY can be paired with SELL, - // CAST with other CAST orders. compatibility is checked once the second - // long order is analyzed (below). + /* non-exclusive orders can be used with others. BUY can be paired with SELL, + * CAST with other CAST orders. compatibility is checked once the second + * long order is analyzed (below). */ exclusive = false; break; @@ -3192,8 +3193,8 @@ void update_long_order(unit * u) thiskwd = kwd; } else { - // we have found a second long order. this is okay for some, but not all commands. - // u->thisorder is already set, and should not have to be updated. + /* we have found a second long order. this is okay for some, but not all commands. + * u->thisorder is already set, and should not have to be updated. */ switch (kwd) { case K_CAST: if (thiskwd != K_CAST) { @@ -3214,9 +3215,8 @@ void update_long_order(unit * u) } break; default: - // TODO: decide https://bugs.eressea.de/view.php?id=2080#c6011 if (kwd > thiskwd) { - // swap out thisorder for the new one + /* swap out thisorder for the new one */ cmistake(u, u->thisorder, 52, MSG_EVENT); set_order(&u->thisorder, copy_order(ord)); } @@ -3229,11 +3229,11 @@ void update_long_order(unit * u) } } if (hunger) { - // Hungernde Einheiten führen NUR den default-Befehl aus + /* Hungernde Einheiten führen NUR den default-Befehl aus */ set_order(&u->thisorder, default_order(u->faction->locale)); } else if (!exclusive) { - // Wenn die Einheit handelt oder zaubert, muss der Default-Befehl gelöscht werden. + /* Wenn die Einheit handelt oder zaubert, muss der Default-Befehl gelöscht werden. */ set_order(&u->thisorder, NULL); } } @@ -3377,7 +3377,7 @@ void defaultorders(void) free_order(ord); if (!neworders) { /* lange Befehle aus orders und old_orders löschen zu gunsten des neuen */ - // TODO: why only is_exclusive, not is_long? what about CAST, BUY, SELL? + /* TODO: why only is_exclusive, not is_long? what about CAST, BUY, SELL? */ remove_exclusive(&u->orders); remove_exclusive(&u->old_orders); neworders = true; @@ -3522,7 +3522,7 @@ int use_cmd(unit * u, struct order *ord) cmistake(u, ord, 50, MSG_PRODUCE); break; default: - // no error + /* no error */ break; } return err; @@ -3534,12 +3534,13 @@ int pay_cmd(unit * u, struct order *ord) cmistake(u, ord, 6, MSG_EVENT); } else { + building *b = NULL; param_t p; int id; + init_order(ord); p = getparam(u->faction->locale); id = getid(); - building *b = NULL; if (p == P_NOT) { unit *owner = building_owner(u->building); /* If the unit is not the owner of the building: error */ diff --git a/src/laws.test.c b/src/laws.test.c index 5eb742809..cca55beb1 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -758,8 +758,9 @@ static void test_peasant_luck_effect(CuTest *tc) { static void test_luck_message(CuTest *tc) { region* r; + attrib *a; - test_cleanup(); + test_setup(); r = test_create_region(0, 0, NULL); rsetpeasants(r, 1); @@ -767,7 +768,7 @@ static void test_luck_message(CuTest *tc) { CuAssertPtrEquals_Msg(tc, "unexpected message", (void *)NULL, r->msgs); - attrib *a = (attrib *)a_find(r->attribs, &at_peasantluck); + a = (attrib *)a_find(r->attribs, &at_peasantluck); if (!a) a = a_add(&r->attribs, a_new(&at_peasantluck)); a->data.i += 10; @@ -782,7 +783,7 @@ static void test_luck_message(CuTest *tc) { static unit * setup_name_cmd(void) { faction *f; - test_cleanup(); + test_setup(); f = test_create_faction(0); return test_create_unit(f, test_create_region(0, 0, 0)); } @@ -886,7 +887,7 @@ static void test_name_ship(CuTest *tc) { } static void test_long_order_normal(CuTest *tc) { - // TODO: write more tests + /* TODO: write more tests */ unit *u; order *ord; @@ -906,7 +907,7 @@ static void test_long_order_normal(CuTest *tc) { } static void test_long_order_none(CuTest *tc) { - // TODO: write more tests + /* TODO: write more tests */ unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); @@ -918,7 +919,7 @@ static void test_long_order_none(CuTest *tc) { } static void test_long_order_cast(CuTest *tc) { - // TODO: write more tests + /* TODO: write more tests */ unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); @@ -932,7 +933,7 @@ static void test_long_order_cast(CuTest *tc) { } static void test_long_order_buy_sell(CuTest *tc) { - // TODO: write more tests + /* TODO: write more tests */ unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); @@ -947,7 +948,7 @@ static void test_long_order_buy_sell(CuTest *tc) { } static void test_long_order_multi_long(CuTest *tc) { - // TODO: write more tests + /* TODO: write more tests */ unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); @@ -961,7 +962,7 @@ static void test_long_order_multi_long(CuTest *tc) { } static void test_long_order_multi_buy(CuTest *tc) { - // TODO: write more tests + /* TODO: write more tests */ unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); @@ -975,7 +976,7 @@ static void test_long_order_multi_buy(CuTest *tc) { } static void test_long_order_multi_sell(CuTest *tc) { - // TODO: write more tests + /* TODO: write more tests */ unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); @@ -990,7 +991,7 @@ static void test_long_order_multi_sell(CuTest *tc) { } static void test_long_order_buy_cast(CuTest *tc) { - // TODO: write more tests + /* TODO: write more tests */ unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); @@ -1473,7 +1474,7 @@ static void test_demon_hunger(CuTest * tc) } static void test_armedmen(CuTest *tc) { - // TODO: test RCF_NOWEAPONS and SK_WEAPONLESS + /* TODO: test RCF_NOWEAPONS and SK_WEAPONLESS */ unit *u; item_type *it_sword; weapon_type *wtype; diff --git a/src/magic.c b/src/magic.c index 19890ec0e..3cb297c07 100644 --- a/src/magic.c +++ b/src/magic.c @@ -173,7 +173,7 @@ static void a_initicastle(struct attrib *a) a->data.v = calloc(sizeof(icastle_data), 1); } -static void a_finalizeicastle(struct attrib *a) //-V524 +static void a_finalizeicastle(struct attrib *a) /*-V524 */ { free(a->data.v); } @@ -475,14 +475,14 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells spellno = rng_int() % maxspell; sbe = commonspells[spellno]; if (sbe->level > f->max_spelllevel) { - // not going to pick it in this round, move it to the end for later + /* not going to pick it in this round, move it to the end for later */ commonspells[spellno] = commonspells[--maxspell]; commonspells[maxspell] = sbe; sbe = 0; } else { if (f->spellbook && spellbook_get(f->spellbook, sbe->sp)) { - // already have this spell, remove it from the list of candidates + /* already have this spell, remove it from the list of candidates */ commonspells[spellno] = commonspells[--numspells]; if (maxspell > numspells) { maxspell = numspells; @@ -2942,7 +2942,7 @@ const char *spell_info(const spell * sp, const struct locale *lang) return LOC(lang, mkname("spellinfo", sp->sname)); } -// TODO: should take the name, not the spell (spellref optimizations) +/* TODO: should take the name, not the spell (spellref optimizations) */ const char *spell_name(const spell * sp, const struct locale *lang) { return LOC(lang, mkname("spell", sp->sname)); @@ -2984,7 +2984,7 @@ spell *unit_getspell(struct unit *u, const char *name, const struct locale * lan if (sb) { select_spellbook(&tokens, sb, lang); } -#if 0 // TODO: some familiars can cast spells from the mage's spellbook? +#if 0 /* TODO: some familiars can cast spells from the mage's spellbook? */ u = get_familiar_mage(u); if (u) { sb = unit_get_spellbook(u); diff --git a/src/magic.h b/src/magic.h index f62c533bd..d282767a9 100644 --- a/src/magic.h +++ b/src/magic.h @@ -59,7 +59,7 @@ extern "C" { sppobj_t typ; int flag; union { - struct region *r; //TODO: V117 http://www.viva64.com/en/V117 Memsize type is used in the union. + struct region *r; struct unit *u; struct building *b; struct ship *sh; diff --git a/src/magic.test.c b/src/magic.test.c index 07a6d5257..baf8ede50 100644 --- a/src/magic.test.c +++ b/src/magic.test.c @@ -443,7 +443,7 @@ static void test_max_spellpoints(CuTest *tc) { CuAssertIntEquals(tc, 3, max_spellpoints(u->region, u)); set_level(u, SK_MAGIC, 2); CuAssertIntEquals(tc, 9, max_spellpoints(u->region, u)); - // permanent aura loss: + /* permanent aura loss: */ CuAssertIntEquals(tc, 7, change_maxspellpoints(u, -2)); CuAssertIntEquals(tc, 7, max_spellpoints(u->region, u)); test_cleanup(); diff --git a/src/main.c b/src/main.c index 875a33bf9..dd65ec9e1 100644 --- a/src/main.c +++ b/src/main.c @@ -223,11 +223,11 @@ static int parse_args(int argc, char **argv, int *exitcode) } } - // open logfile on disk: + /* open logfile on disk: */ log_flags = verbosity_to_flags(log_flags); log_open(logfile, log_flags); - // also log to stderr: + /* also log to stderr: */ log_stderr = verbosity_to_flags(verbosity); if (log_stderr) { log_to_file(log_stderr | LOG_FLUSH | LOG_BRIEF, stderr); diff --git a/src/monsters.c b/src/monsters.c index 3c9ee1eb8..0d9857024 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -673,7 +673,7 @@ static order *plan_dragon(unit * u) } if (tr != NULL) { assert(long_order == NULL); - // TODO: per-race planning functions? + /* TODO: per-race planning functions? */ if (rc == rc_wyrm) { long_order = make_movement_order(u, tr, 1, allowed_dragon); } diff --git a/src/monsters.test.c b/src/monsters.test.c index e0eaa3ccc..3f2782173 100644 --- a/src/monsters.test.c +++ b/src/monsters.test.c @@ -90,7 +90,7 @@ static void test_monsters_attack_ocean(CuTest * tc) unit *u, *m; create_monsters(&f, &f2, &u, &m); - r = findregion(-1, 0); // ocean + r = findregion(-1, 0); /* ocean */ u = test_create_unit(u->faction, r); unit_setid(u, 2); m = test_create_unit(m->faction, r); @@ -125,7 +125,7 @@ static void test_seaserpent_piracy(CuTest * tc) race *rc; create_monsters(&f, &f2, &u, &m); - r = findregion(-1, 0); // ocean + r = findregion(-1, 0); /* ocean */ u = test_create_unit(u->faction, r); unit_setid(u, 2); m = test_create_unit(m->faction, r); @@ -198,7 +198,7 @@ static void test_dragon_moves(CuTest * tc) create_monsters(&f, &f2, &u, &m); rsetmoney(findregion(1, 0), 1000); - r = findregion(0, 0); // plain + r = findregion(0, 0); /* plain */ rsetpeasants(r, 0); rsetmoney(r, 0); diff --git a/src/move.c b/src/move.c index f06a0b901..8ad25bc5a 100644 --- a/src/move.c +++ b/src/move.c @@ -509,10 +509,10 @@ static double overload(const region * r, ship * sh) else { int n = 0, p = 0; int mcabins = sh->type->cabins; + double ovl; getshipweight(sh, &n, &p); - - double ovl = n / (double)sh->type->cargo; + ovl = n / (double)sh->type->cargo; if (mcabins) ovl = MAX(ovl, p / (double)mcabins); return ovl; @@ -801,7 +801,7 @@ region * drift_target(ship *sh) { if (rn != NULL && check_ship_allowed(sh, rn) >= 0) { rnext = rn; if (!fval(rnext->terrain, SEA_REGION)) { - // prefer drifting towards non-ocean regions + /* prefer drifting towards non-ocean regions */ break; } } @@ -952,8 +952,8 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r) if ((u->faction == reisender->faction) || (ucontact(u, reisender)) || (alliedunit(u, reisender->faction, HELP_GUARD))) guard_count = guard_count - u->number; else if (sk >= stealth) { - guard_count += u->number; double prob_u = (sk - stealth) * skill_prob; + guard_count += u->number; /* amulet counts at most once */ prob_u += MIN(1, MIN(u->number, i_get(u->items, ramulet->itype))) * amulet_prob; if (u->building && (u->building->type == castle_bt) && u == building_owner(u->building)) @@ -1406,7 +1406,7 @@ static int movement_speed(unit * u) return BP_DRAGON; } switch (old_race(u_race(u))) { - case RC_BIRTHDAYDRAGON: // FIXME: catdragon has RCF_DRAGON, so this cannot happen + case RC_BIRTHDAYDRAGON: /* FIXME: catdragon has RCF_DRAGON, so this cannot happen */ case RC_SONGDRAGON: mp = BP_DRAGON; break; @@ -1473,9 +1473,9 @@ static arg_regions *var_copy_regions(const region_list * begin, int size) if (size > 0) { int i = 0; + arg_regions *dst; assert(size > 0); - arg_regions *dst = - (arg_regions *)malloc(sizeof(arg_regions) + sizeof(region *) * (size_t)size); + dst = (arg_regions *)malloc(sizeof(arg_regions) + sizeof(region *) * (size_t)size); assert_alloc(dst); dst->nregions = size; dst->regions = (region **)(dst + 1); @@ -1840,7 +1840,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) } } } - } // storms_enabled + } /* storms_enabled */ if (!fval(tthis, SEA_REGION)) { if (!fval(tnext, SEA_REGION)) { /* check that you're not traveling from one land region to another. */ diff --git a/src/move.test.c b/src/move.test.c index 6a2a0e7db..c444fe4a8 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -434,8 +434,9 @@ static void test_follow_ship_msg(CuTest * tc) { order *ord; traveldir *td = NULL; attrib *a; - - test_cleanup(); + void *p; + + test_setup(); test_create_world(); f = test_create_faction(0); r = findregion(0, 0); @@ -467,7 +468,7 @@ static void test_follow_ship_msg(CuTest * tc) { follow_ship(u, ord); CuAssertPtrNotNull(tc, msg = test_find_messagetype(u->faction->msgs, "error18")); - void *p = msg->parameters[2].v; + p = msg->parameters[2].v; CuAssertPtrNotNull(tc, p); CuAssertIntEquals(tc, K_FOLLOW, getkeyword((order *)p)); diff --git a/src/names.c b/src/names.c index 969e278d8..cf0d9fd09 100644 --- a/src/names.c +++ b/src/names.c @@ -280,7 +280,7 @@ static void dragon_name(unit * u) if (u->number > 1) { const char *no_article = strchr((const char *)str, ' '); assert(no_article); - // TODO: localization + /* TODO: localization */ sprintf(name, "Die %sn von %s", no_article + 1, rname(u->region, default_locale)); } diff --git a/src/piracy.c b/src/piracy.c index b2f96c596..80b1dd47a 100644 --- a/src/piracy.c +++ b/src/piracy.c @@ -149,8 +149,8 @@ void piracy_cmd(unit * u) region *rc = rconnect(r, dir); aff[dir].value = 0; aff[dir].target = 0; - // TODO this could still result in an illegal movement order (through a wall or whatever) - // which will be prevented by move_cmd below + /* TODO this could still result in an illegal movement order (through a wall or whatever) + * which will be prevented by move_cmd below */ if (rc && ((sh && !fval(rc->terrain, FORBIDDEN_REGION) && can_takeoff(sh, r, rc)) || (canswim(u) && fval(rc->terrain, SWIM_INTO) && fval(rc->terrain, SEA_REGION)))) { @@ -161,7 +161,8 @@ void piracy_cmd(unit * u) faction *f = visible_faction(cap->faction, cap); if (alliedunit(u, f, HELP_FIGHT)) continue; - if (!il || intlist_find(il, cap->faction->no)) { // TODO: shouldn't this be f->no? + if (!il || intlist_find(il, cap->faction->no)) { + /* TODO: shouldn't this be f->no? */ ++aff[dir].value; if (rng_int() % aff[dir].value == 0) { aff[dir].target = f; @@ -202,8 +203,8 @@ void piracy_cmd(unit * u) "ship unit region dir", sh, u, r, target_dir)); /* Befehl konstruieren */ - // TODO: why change u->thisorder? - // FIXME: when u->thisorder == ord, set_order calls free, destroys both. + /* TODO: why change u->thisorder? */ + /* FIXME: when u->thisorder == ord, set_order calls free, destroys both. */ ord = create_order(K_MOVE, u->faction->locale, "%s", LOC(u->faction->locale, directions[target_dir])); /* Bewegung ausfhren */ diff --git a/src/piracy.test.c b/src/piracy.test.c index 82e4e55b7..d690776f1 100644 --- a/src/piracy.test.c +++ b/src/piracy.test.c @@ -97,7 +97,7 @@ static void test_piracy_cmd(CuTest * tc) { CuAssertTrue(tc, u->region != r); CuAssertPtrEquals(tc, u2->region, u->region); CuAssertPtrEquals(tc, u2->region, u->ship->region); - CuAssertPtrNotNullMsg(tc, "successful PIRACY sets attribute", r->attribs); // FIXME: this is testing implementation, not interface + CuAssertPtrNotNullMsg(tc, "successful PIRACY sets attribute", r->attribs); /* FIXME: this is testing implementation, not interface */ CuAssertPtrNotNullMsg(tc, "successful PIRACY message", test_find_messagetype(f->msgs, "piratesawvictim")); CuAssertPtrNotNullMsg(tc, "successful PIRACY movement", test_find_messagetype(f->msgs, "shipsail")); @@ -183,14 +183,14 @@ static void test_piracy_cmd_land_to_land(CuTest * tc) { t_plain = get_or_create_terrain("plain"); stype = test_create_shiptype("boat"); - // create a target: + /* create a target: */ r = test_create_region(0, 0, t_plain); f = test_create_faction(0); u = test_create_unit(f, r); u->ship = test_create_ship(r, stype); target = f->no; - // create a pirate: + /* create a pirate: */ r = test_create_region(1, 0, t_plain); f = test_create_faction(0); u = test_create_unit(f, r); diff --git a/src/platform.h b/src/platform.h index 7ddb612ae..6ccbb8d6d 100644 --- a/src/platform.h +++ b/src/platform.h @@ -15,6 +15,11 @@ #pragma warning(disable: 4456) // declaration hides previous #pragma warning(disable: 4457) // declaration hides function parameter #pragma warning(disable: 4459) // declaration hides global +#else /* assume gcc */ +#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L +# define va_copy(a,b) __va_copy(a,b) +#endif + #endif #define _POSIX_C_SOURCE 200809L diff --git a/src/prefix.h b/src/prefix.h index aa04e505b..96d07aa02 100644 --- a/src/prefix.h +++ b/src/prefix.h @@ -8,7 +8,7 @@ extern "C" { #endif int add_raceprefix(const char *); - char **race_prefixes; // zero-terminated array of valid prefixes + char **race_prefixes; /* zero-terminated array of valid prefixes */ void free_prefixes(void); #ifdef __cplusplus diff --git a/src/report.c b/src/report.c index 06244c70c..cf00abbc3 100644 --- a/src/report.c +++ b/src/report.c @@ -100,7 +100,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #if defined(_MSC_VER) && _MSC_VER >= 1900 -# pragma warning(disable: 4774) // TODO: remove this +# pragma warning(disable: 4774) /* TODO: remove this */ #endif extern int *storms; @@ -120,7 +120,7 @@ static void check_errno(const char * file, int line) { static char *gamedate_season(const struct locale *lang) { - static char buf[256]; // FIXME: static return value + static char buf[256]; /* FIXME: static return value */ gamedate gd; get_gamedate(turn, &gd); @@ -1195,7 +1195,7 @@ static void describe(struct stream *out, const region * r, faction * f) bufp = buf; size = sizeof(buf) - 1; - // this localization might not work for every language but is fine for de and en + /* this localization might not work for every language but is fine for de and en */ bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_schemes_prefix"), size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1237,7 +1237,7 @@ static void describe(struct stream *out, const region * r, faction * f) for (d = 0; d != MAXDIRECTIONS; ++d) { if (!e->exist[d]) continue; - // this localization might not work for every language but is fine for de and en + /* this localization might not work for every language but is fine for de and en */ if (first) bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_borderlist_prefix"), size); else if (e->lastd == d) @@ -1251,8 +1251,8 @@ static void describe(struct stream *out, const region * r, faction * f) WARN_STATIC_BUFFER(); first = false; } - // TODO name is localized? Works for roads anyway... - // TODO: creating messages during reporting makes them not show up in CR? + /* TODO name is localized? Works for roads anyway... */ + /* TODO: creating messages during reporting makes them not show up in CR? */ msg = msg_message("nr_borderlist_postfix", "transparent object", e->transparent, e->name); bytes = (int)nr_render(msg, f->locale, bufp, size, f); @@ -1987,7 +1987,7 @@ static void cb_write_travelthru(region *r, unit *u, void *cbdata) { } } if (len >= size || data->counter == data->maxtravel) { - // buffer is full + /* buffer is full */ *writep = 0; paragraph(data->out, data->start, 0, 0, 0); data->writep = data->start; @@ -2332,7 +2332,6 @@ report_plaintext(const char *filename, report_context * ctx, /* Nachrichten an REGION in der Region */ if (r->seen.mode == seen_unit || r->seen.mode == seen_travel) { - // TODO: Bug 2073 message_list *mlist = r_getmessages(r, f); if (mlist) { struct mlist **split = merge_messages(mlist, r->msgs); diff --git a/src/reports.c b/src/reports.c index f904f5799..7d8374ff5 100644 --- a/src/reports.c +++ b/src/reports.c @@ -77,7 +77,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "move.h" #if defined(_MSC_VER) && _MSC_VER >= 1900 -# pragma warning(disable: 4774) // TODO: remove this +# pragma warning(disable: 4774) /* TODO: remove this */ #endif #define SCALEWEIGHT 100 /* Faktor, um den die Anzeige von Gewichten skaliert wird */ @@ -680,7 +680,7 @@ size_t size) if (wrptr(&bufp, &size, result) != 0) { WARN_STATIC_BUFFER(); } - // TODO: no need to deref the spellref here (spref->name is good) + /* TODO: no need to deref the spellref here (spref->name is good) */ bufp = STRLCPY(bufp, spell_name(sbe->sp, f->locale), size); } } @@ -851,7 +851,7 @@ const struct unit * u, struct skill * sv, int *dh, int days) void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned int width, char mark) { bool firstline; - static char buf[REPORTWIDTH + 1]; // FIXME: static buffer, artificial limit + static char buf[REPORTWIDTH + 1]; /* FIXME: static buffer, artificial limit */ size_t len = strlen(s); assert(width <= REPORTWIDTH); @@ -882,7 +882,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned } memcpy(buf + indent, s, cut - s); buf[indent + (cut - s)] = 0; - addstrlist(SP, buf); // TODO: too much string copying, cut out this function + addstrlist(SP, buf); /* TODO: too much string copying, cut out this function */ while (*cut == ' ') { ++cut; } @@ -1017,7 +1017,7 @@ static void cb_add_address(region *r, unit *ut, void *cbdata) { } static void add_travelthru_addresses(region *r, faction *f, selist **flist, int stealthmod) { - // for each traveling unit: add the faction of any unit is can see + /* for each traveling unit: add the faction of any unit is can see */ address_data cbdata = { 0 }; cbdata.f = f; cbdata.flist = flist; @@ -1338,7 +1338,7 @@ void prepare_report(report_context *ctx, faction *f) if (f->age<=2) { if ((f->flags&FFL_PWMSG)==0) { - // TODO: this assumes unencrypted passwords + /* TODO: this assumes unencrypted passwords */ f->flags |= FFL_PWMSG; ADDMSG(&f->msgs, msg_message("changepasswd", "value", f->_password)); } @@ -1348,7 +1348,7 @@ void prepare_report(report_context *ctx, faction *f) ctx->report_time = time(NULL); ctx->addresses = NULL; ctx->userdata = NULL; - // [first,last) interval of regions with a unit in it: + /* [first,last) interval of regions with a unit in it: */ ctx->first = firstregion(f); ctx->last = lastregion(f); @@ -1388,9 +1388,9 @@ void prepare_report(report_context *ctx, faction *f) travelthru_map(r, cb_add_seen, f); } } - // [fast,last) interval of seen regions (with lighthouses and travel) - // TODO: what about neighbours? when are they included? do we need - // them outside of the CR? + /* [fast,last) interval of seen regions (with lighthouses and travel) + * TODO: what about neighbours? when are they included? do we need + * them outside of the CR? */ ctx->first = firstregion(f); ctx->last = lastregion(f); } @@ -1582,7 +1582,7 @@ static void var_free_resources(variant x) x.v = 0; } -static void var_free_regions(variant x) //-V524 +static void var_free_regions(variant x) /*-V524 */ { free(x.v); } @@ -1630,7 +1630,7 @@ f_regionid(const region * r, const faction * f, char *buffer, size_t size) static char *f_regionid_s(const region * r, const faction * f) { - static char buf[NAMESIZE + 20]; // FIXME: static return value + static char buf[NAMESIZE + 20]; /* FIXME: static return value */ f_regionid(r, f, buf, sizeof(buf)); return buf; @@ -1689,11 +1689,10 @@ static void eval_spell(struct opstack **stack, const void *userdata) const struct spell *sp = (const struct spell *)opop(stack).v; const char *c = sp ? spell_name(sp, f->locale) : LOC(f->locale, "an_unknown_spell"); - assert(c || !"spell without description!"); - size_t len = strlen(c); variant var; - var.v = strcpy(balloc(len + 1), c); + assert(c || !"spell without description!"); + var.v = strcpy(balloc(strlen(c) + 1), c); opush(stack, var); } @@ -1703,11 +1702,10 @@ static void eval_curse(struct opstack **stack, const void *userdata) const struct curse_type *sp = (const struct curse_type *)opop(stack).v; const char *c = sp ? curse_name(sp, f->locale) : LOC(f->locale, "an_unknown_curse"); - assert(c || !"spell effect without description!"); - size_t len = strlen(c); variant var; - var.v = strcpy(balloc(len + 1), c); + assert(c || !"spell effect without description!"); + var.v = strcpy(balloc(strlen(c) + 1), c); opush(stack, var); } @@ -1947,7 +1945,7 @@ static void eval_regions(struct opstack **stack, const void *userdata) const char *get_mailcmd(const struct locale *loc) { - static char result[64]; // FIXME: static return buffer + static char result[64]; /* FIXME: static return buffer */ snprintf(result, sizeof(result), "%s %d %s", game_name_upper(), game_id(), LOC(loc, "mailcmd")); return result; } @@ -2057,12 +2055,12 @@ int stream_printf(struct stream * out, const char *format, ...) { int result; char buffer[4096]; size_t bytes = sizeof(buffer); - // TODO: should be in storage/stream.c (doesn't exist yet) + /* TODO: should be in storage/stream.c (doesn't exist yet) */ va_start(args, format); result = vsnprintf(buffer, bytes, format, args); if (result >= 0 && (size_t)result < bytes) { bytes = (size_t)result; - // TODO: else = buffer too small + /* TODO: else = buffer too small */ } out->api->write(out->handle, buffer, bytes); va_end(args); diff --git a/src/spells.c b/src/spells.c index 66f5325c9..091d3d076 100644 --- a/src/spells.c +++ b/src/spells.c @@ -4194,7 +4194,7 @@ static int sp_seduce(castorder * co) { const resource_type *rsilver = get_resourcetype(R_SILVER); unit *target; - item **itmp, *items = 0;; + item **itmp, *items = 0; unit *mage = co->magician.u; spellparameter *pa = co->par; int cast_level = co->level; diff --git a/src/spells.test.c b/src/spells.test.c index 3c773d489..07a980e03 100644 --- a/src/spells.test.c +++ b/src/spells.test.c @@ -25,8 +25,9 @@ static void test_good_dreams(CuTest *tc) { unit *u1, *u2; int level; castorder co; - - test_cleanup(); + curse *curse; + + test_setup(); test_create_world(); r = findregion(0, 0); f1 = test_create_faction(0); @@ -38,7 +39,7 @@ static void test_good_dreams(CuTest *tc) { level = sp_gooddreams(&co); CuAssertIntEquals(tc, 10, level); - curse *curse = get_curse(r->attribs, ct_find("gbdream")); + curse = get_curse(r->attribs, ct_find("gbdream")); CuAssertTrue(tc, curse && curse->duration > 1); CuAssertTrue(tc, curse->effect == 1); @@ -81,8 +82,9 @@ static void test_bad_dreams(CuTest *tc) { unit *u1, *u2; int level; castorder co; - - test_cleanup(); + curse *curse; + + test_setup(); test_create_world(); r = findregion(0, 0); f1 = test_create_faction(0); @@ -94,7 +96,7 @@ static void test_bad_dreams(CuTest *tc) { level = sp_baddreams(&co); CuAssertIntEquals(tc, 10, level); - curse *curse = get_curse(r->attribs, ct_find("gbdream")); + curse = get_curse(r->attribs, ct_find("gbdream")); CuAssertTrue(tc, curse && curse->duration > 1); CuAssertTrue(tc, curse->effect == -1); diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index 939433617..37191d177 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -47,8 +47,9 @@ #define EFFECT_HEALING_SPELL 5 -// Some spells with a fixed, known ID (in XML). -// TODO: this method of identifying spells is error-prone, do not use it for new spells. +/* Some spells with a fixed, known ID (in XML). + * TODO: this method of identifying spells is error-prone, + * do not use it for new spells. */ enum { SPL_FIREBALL = 4, SPL_HAGEL = 5, diff --git a/src/spy.c b/src/spy.c index 0ca3050c2..d4082cad7 100644 --- a/src/spy.c +++ b/src/spy.c @@ -303,9 +303,9 @@ int setstealth_cmd(unit * u, struct order *ord) } if (rule_stealth_other()) { if (get_keyword(s, u->faction->locale) == K_NUMBER) { - s = gettoken(token, sizeof(token)); int nr = -1; + s = gettoken(token, sizeof(token)); if (s) { nr = atoi36(s); } diff --git a/src/spy.test.c b/src/spy.test.c index 34f6e5067..8341b17d3 100644 --- a/src/spy.test.c +++ b/src/spy.test.c @@ -60,6 +60,7 @@ static void set_factionstealth(unit *u, faction *f) { static void test_all_spy_message(CuTest *tc) { spy_fixture fix; + item_type *itype; setup_spy(&fix); @@ -69,7 +70,6 @@ static void test_all_spy_message(CuTest *tc) { create_mage(fix.victim, M_DRAIG); set_factionstealth(fix.victim, fix.spy->faction); - item_type *itype; itype = it_get_or_create(rt_get_or_create("sword")); new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2); i_change(&fix.victim->items, itype, 1); diff --git a/src/study.test.c b/src/study.test.c index 7556e817a..3b411c7df 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -303,7 +303,7 @@ static void test_demon_skillchanges(CuTest *tc) { CuAssertPtrNotNull(tc, u); set_level(u, SK_CROSSBOW, 1); demon_skillchange(u); - // TODO: sensing here + /* TODO: sensing here */ test_cleanup(); } diff --git a/src/test_eressea.c b/src/test_eressea.c index 02d52c5ed..4ffe1f19c 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -52,9 +52,12 @@ void RunTests(CuSuite * suite, const char *name) { bool list = false; #define ADD_SUITE(name) \ - CuSuite *get_##name##_suite(void); \ - if (list) printf("%s\n", #name); \ - if (!list || argc>0) add_suite(get_##name##_suite, #name, argc, argv) + do { \ + CuSuite *get_##name##_suite(void); \ + if (list) printf("%s\n", #name); \ + if (!list || argc>0) add_suite(get_##name##_suite, #name, argc, argv); \ + } while (0) + int RunAllTests(int argc, char *argv[]) { diff --git a/src/triggers/changefaction.c b/src/triggers/changefaction.c index 3de537c7b..e8b6a4879 100644 --- a/src/triggers/changefaction.c +++ b/src/triggers/changefaction.c @@ -92,7 +92,6 @@ static int changefaction_read(trigger * t, gamedata *data) return AT_READ_FAIL; } ur_add(var, &td->faction, resolve_faction); - // read_reference(&td->faction, store, read_faction_reference, resolve_faction); return AT_READ_OK; } diff --git a/src/triggers/createunit.c b/src/triggers/createunit.c index 41573d86b..1148b1d5a 100644 --- a/src/triggers/createunit.c +++ b/src/triggers/createunit.c @@ -102,7 +102,6 @@ static int createunit_read(trigger * t, gamedata *data) else { result = AT_READ_FAIL; } - // read_reference(&td->f, store, read_faction_reference, resolve_faction); read_reference(&td->r, data, read_region_reference, RESOLVE_REGION(data->version)); diff --git a/src/upkeep.test.c b/src/upkeep.test.c index e84402d4b..2a91a0df1 100644 --- a/src/upkeep.test.c +++ b/src/upkeep.test.c @@ -35,7 +35,7 @@ void test_upkeep_default(CuTest * tc) config_set("rules.food.flags", "0"); i_change(&u1->items, i_silver, 20); get_food(r); - // since u1 and u2 are not allied, u1 should not help u2 with upkeep + /* since u1 and u2 are not allied, u1 should not help u2 with upkeep */ CuAssertIntEquals(tc, 10, i_get(u1->items, i_silver)); CuAssertIntEquals(tc, 0, fval(u1, UFL_HUNGER)); CuAssertIntEquals(tc, UFL_HUNGER, fval(u2, UFL_HUNGER)); @@ -63,7 +63,7 @@ void test_upkeep_hunger_damage(CuTest * tc) config_set("rules.food.flags", "0"); u1->hp = 100; get_food(r); - // since u1 and u2 are not allied, u1 should not help u2 with upkeep + /* since u1 and u2 are not allied, u1 should not help u2 with upkeep */ CuAssertTrue(tc, u1->hp < 100); test_cleanup(); @@ -152,7 +152,7 @@ void test_upkeep_free(CuTest * tc) u = test_create_unit(test_create_faction(test_create_race("human")), r); assert(r && u); - config_set("rules.food.flags", "4"); // FOOD_IS_FREE + config_set("rules.food.flags", "4"); /* FOOD_IS_FREE */ get_food(r); CuAssertIntEquals(tc, 0, i_get(u->items, i_silver)); CuAssertIntEquals(tc, 0, fval(u, UFL_HUNGER)); diff --git a/src/util/attrib.c b/src/util/attrib.c index a99a70ba3..fda143168 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -153,7 +153,7 @@ static unsigned int __at_hashkey(const char *s) while (i > 0) { key = (s[--i] + key * 37); } - return key & 0x7fffffff; //TODO: V112 http://www.viva64.com/en/V112 Dangerous magic number 0x7fffffff used: return key & 0x7fffffff;. + return key & 0x7fffffff; } void at_register(attrib_type * at) @@ -161,7 +161,7 @@ void at_register(attrib_type * at) attrib_type *find; if (at->read == NULL) { - log_warning("registering non-persistent attribute %s.\n", at->name); //TODO: V111 http://www.viva64.com/en/V111 Call of function 'log_warning' with variable number of arguments. Second argument has memsize type. + log_warning("registering non-persistent attribute %s.\n", at->name); } at->hashkey = __at_hashkey(at->name); find = at_hash[at->hashkey % MAXATHASH]; @@ -169,7 +169,7 @@ void at_register(attrib_type * at) find = find->nexthash; } if (find && find == at) { - log_warning("attribute '%s' was registered more than once\n", at->name); //TODO: V111 http://www.viva64.com/en/V111 Call of function 'log_warning' with variable number of arguments. Second argument has memsize type. + log_warning("attribute '%s' was registered more than once\n", at->name); return; } else { diff --git a/src/util/attrib.h b/src/util/attrib.h index 45dc9b942..601a6f32a 100644 --- a/src/util/attrib.h +++ b/src/util/attrib.h @@ -32,14 +32,14 @@ extern "C" { typedef struct attrib { const struct attrib_type *type; union { - afun f; //TODO: V117 http://www.viva64.com/en/V117 Memsize type is used in the union. - void *v; //TODO: V117 http://www.viva64.com/en/V117 Memsize type is used in the union. + afun f; + void *v; int i; float flt; char c; short s; short sa[2]; - char ca[4]; //TODO: V112 http://www.viva64.com/en/V112 Dangerous magic number 4 used: char ca[4];. + char ca[4]; } data; /* internal data, do not modify: */ struct attrib *next; /* next attribute in the list */ diff --git a/src/util/bsdstring.c b/src/util/bsdstring.c index 4fc56ce4e..0f3d49801 100644 --- a/src/util/bsdstring.c +++ b/src/util/bsdstring.c @@ -13,7 +13,7 @@ int wrptr(char **ptr, size_t * size, int result) { size_t bytes = (size_t)result; if (result < 0) { - // buffer was too small + /* buffer was too small */ if (*size > 0) { **ptr = 0; *size = 0; diff --git a/src/util/bsdstring.test.c b/src/util/bsdstring.test.c index b5fe81156..d4276ef61 100644 --- a/src/util/bsdstring.test.c +++ b/src/util/bsdstring.test.c @@ -32,7 +32,7 @@ static void test_strlcpy(CuTest * tc) CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 4)); CuAssertStrEquals(tc, "her", buffer); - CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 8)); //-V666 + CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 8)); /*-V666 */ CuAssertStrEquals(tc, "herp", buffer); CuAssertIntEquals(tc, 0x7f, buffer[5]); diff --git a/src/util/language.c b/src/util/language.c index 3f628036d..b3cce61af 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -239,7 +239,7 @@ char *mkname_buf(const char *space, const char *name, char *buffer) const char *mkname(const char *space, const char *name) { - static char zBuffer[128]; // FIXME: static return value + static char zBuffer[128]; /* FIXME: static return value */ return mkname_buf(space, name, zBuffer); } @@ -272,7 +272,7 @@ void add_translation(struct critbit_tree **cbp, const char *key, int i) { if (str) { size_t len = strlen(str); if (!cb) { - // TODO: this will leak, because we do not know how to clean it up */ + /* TODO: this will leak, because we do not know how to clean it up */ *cbp = cb = (struct critbit_tree *)calloc(1, sizeof(struct critbit_tree)); } len = cb_new_kv(str, len, &i, sizeof(int), buffer); @@ -292,7 +292,7 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_ assert(maxstrings > 0); tokens = get_translations(lang, ut); for (i = 0; i != maxstrings; ++i) { - // TODO: swap the name of s and key + /* TODO: swap the name of s and key */ const char * s = string_cb(i); if (s) { const char * key = locale_string(lang, s, false); @@ -349,7 +349,7 @@ void free_locales(void) { for (i = UT_PARAMS; i != UT_RACES; ++i) { struct critbit_tree ** cb = (struct critbit_tree **)get_translations(locales, i); if (*cb) { - // TODO: this crashes? + /* TODO: this crashes? */ cb_clear(*cb); free(*cb); } @@ -373,5 +373,5 @@ void free_locales(void) { free(locales); locales = next; } - memset(lstrs, 0, sizeof(lstrs)); // TODO: does this data need to be free'd? + memset(lstrs, 0, sizeof(lstrs)); /* TODO: does this data need to be free'd? */ } diff --git a/src/util/log.c b/src/util/log.c index 759efba39..24ddce757 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -137,7 +137,7 @@ static int check_dupe(const char *format, int level) static char last_message[32]; /* STATIC_XCALL: used across calls */ static int dupes = 0; /* STATIC_XCALL: used across calls */ if (strncmp(last_message, format, sizeof(last_message)) == 0) { - // TODO: C6054: String 'last_message' might not be zero - terminated. + /* TODO: C6054: String 'last_message' might not be zero - terminated. */ ++dupes; return 1; } @@ -197,16 +197,16 @@ static void log_write(int flags, const char *module, const char *format, va_list int level = flags & LOG_LEVELS; if (lg->flags & level) { int dupe = 0; - va_list copy; - - va_copy(copy, args); if (lg->flags & LOG_BRIEF) { dupe = check_dupe(format, level); } if (dupe == 0) { + va_list copy; + + va_copy(copy, args); lg->log(lg->data, level, NULL, format, copy); + va_end(copy); } - va_end(copy); } } } @@ -220,7 +220,7 @@ void log_fatal(const char *format, ...) va_end(args); } -void log_error(const char *format, ...) //-V524 +void log_error(const char *format, ...) /*-V524 */ { va_list args; va_start(args, format); diff --git a/src/util/parser.test.c b/src/util/parser.test.c index c7ac0bb05..942aa1866 100644 --- a/src/util/parser.test.c +++ b/src/util/parser.test.c @@ -49,11 +49,11 @@ static void test_parse_token_limit_utf8(CuTest *tc) { tok = parse_token(&str, lbuf, sizeof(lbuf)); CuAssertPtrEquals(tc, (void *)(orig + strlen(orig)), (void *)str); - CuAssertStrEquals(tc, tok, "\xc3\xa4\xc3\xb6\xc3\xbc"); // just three letters fit, 6 bytes long + CuAssertStrEquals(tc, tok, "\xc3\xa4\xc3\xb6\xc3\xbc"); /* just three letters fit, 6 bytes long */ tok = parse_token(&str, lbuf, sizeof(lbuf)); CuAssertPtrEquals(tc, NULL, (void *)tok); - str = orig; // now with an extra byte in the front, maxing out lbuf exactly + str = orig; /* now with an extra byte in the front, maxing out lbuf exactly */ tok = parse_token(&str, lbuf, sizeof(lbuf)); CuAssertPtrEquals(tc, (void *)(orig + strlen(orig)), (void *)str); CuAssertStrEquals(tc, tok, "a\xc3\xa4\xc3\xb6\xc3\xbc"); diff --git a/src/util/password.h b/src/util/password.h index b83d544a6..ba55f6cb9 100644 --- a/src/util/password.h +++ b/src/util/password.h @@ -4,9 +4,9 @@ #define PASSWORD_PLAINTEXT 0 #define PASSWORD_DEFAULT PASSWORD_PLAINTEXT -#define VERIFY_OK 0 // password matches hash -#define VERIFY_FAIL 1 // password is wrong -#define VERIFY_UNKNOWN 2 // hashing algorithm not supported +#define VERIFY_OK 0 +#define VERIFY_FAIL 1 +#define VERIFY_UNKNOWN 2 int password_verify(const char *hash, const char *passwd); const char * password_encode(const char *passwd, int algo); bool password_is_implemented(int algo); diff --git a/src/util/umlaut.c b/src/util/umlaut.c index 6be0bdde5..d29cb78ac 100644 --- a/src/util/umlaut.c +++ b/src/util/umlaut.c @@ -168,7 +168,7 @@ void addtoken(tnode ** root, const char *str, variant id) next = next->nexthash; if (!next) { tref *ref; - tnode *node = mknode(); // TODO: what is the reason for this empty node to exist? + tnode *node = mknode(); /* TODO: what is the reason for this empty node to exist? */ if (ucs < 'a' || ucs > 'z') { lcs = towlower((wint_t)ucs); diff --git a/src/util/unicode.test.c b/src/util/unicode.test.c index 76cda9a8f..7c1c1031a 100644 --- a/src/util/unicode.test.c +++ b/src/util/unicode.test.c @@ -47,7 +47,7 @@ static void test_unicode_tolower(CuTest * tc) static void test_unicode_utf8_to_other(CuTest *tc) { - const unsigned char uchar_str[] = { 0xc3, 0x98, 0xc5, 0xb8, 0xc2, 0x9d, 'l', 0 }; // ØŸl + const unsigned char uchar_str[] = { 0xc3, 0x98, 0xc5, 0xb8, 0xc2, 0x9d, 'l', 0 }; /* ØŸl */ utf8_t *utf8_str = (utf8_t *)uchar_str; unsigned char ch; size_t sz; @@ -111,7 +111,7 @@ static void test_unicode_bug2262(CuTest *tc) { CuAssertIntEquals(tc, 'u', ucs); CuAssertIntEquals(tc, 0, unicode_utf8_trim(name)); - name[0] = -4; // latin1: ü should fail to decode + name[0] = -4; /* latin1: ü should fail to decode */ CuAssertIntEquals(tc, EILSEQ, unicode_utf8_to_ucs4(&ucs, name, &sz)); CuAssertIntEquals(tc, EILSEQ, unicode_utf8_trim(name)); } diff --git a/src/util/variant.h b/src/util/variant.h index 4559264ed..b65ee0868 100644 --- a/src/util/variant.h +++ b/src/util/variant.h @@ -5,12 +5,12 @@ extern "C" { #endif typedef union variant { - void *v; //TODO: V117 http://www.viva64.com/en/V117 Memsize type is used in the union. + void *v; int i; char c; short s; short sa[2]; - char ca[4]; //TODO: V112 http://www.viva64.com/en/V112 Dangerous magic number 4 used: char ca[4];. + char ca[4]; float f; } variant; diff --git a/src/volcano.c b/src/volcano.c index 89a865017..fb4cfa74c 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -291,10 +291,10 @@ void volcano_update(void) r->terrain = t_volcano; } else if (r->uid == 1246051340 || outbreak_chance()) { - // HACK: a fixed E4-only region-uid in Code. - // FIXME: In E4 gibt es eine Ebene #1246051340, die Smalland heisst. - // da das kein aktiver Vulkan ist, ist dieser Test da nicht idiotisch? - // das sollte bestimmt rn betreffen? + /* HACK: a fixed E4-only region-uid in Code. + * FIXME: In E4 gibt es eine Ebene #1246051340, die Smalland heisst. + * da das kein aktiver Vulkan ist, ist dieser Test da nicht idiotisch? + * das sollte bestimmt rn betreffen? */ region *rn; rn = rrandneighbour(r); volcano_outbreak(r, rn); From 12b1dcaa38e4349335a759a9309d01a1a298e910 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Feb 2017 21:23:24 +0100 Subject: [PATCH 542/675] remove platform-cruft --- src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3fc1e62a7..ae5923313 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,7 +27,6 @@ IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89 -ansi -pedantic") - add_definitions(-DHAVE__BOOL) ELSEIF(MSVC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP") set(CMAKE_EXE_LINKER_FLAGS_DEBUG From 9e14bf5cf9993594eb4efb76b3bc29f554cc72de Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Feb 2017 21:26:38 +0100 Subject: [PATCH 543/675] clang complains about -ansi? --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ae5923313..43f109fed 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,7 +26,7 @@ ENDIF() IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89 -ansi -pedantic") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89") ELSEIF(MSVC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP") set(CMAKE_EXE_LINKER_FLAGS_DEBUG From 5796f60f16b69acdd4d5d72a64d5e465c5e4aa70 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Feb 2017 22:00:48 +0100 Subject: [PATCH 544/675] spells will always resist magic --- src/magic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/magic.c b/src/magic.c index 2299e6523..15dc14307 100644 --- a/src/magic.c +++ b/src/magic.c @@ -1240,6 +1240,9 @@ target_resists_magic(unit * magician, void *obj, int objtyp, int t_bonus) skill *sv; unit *u = (unit *)obj; + if (u_race(u)==get_race(RC_SPELL)) { + return true; + } at = effskill(magician, SK_MAGIC, 0); for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) { From be14394529305cfeeab26e6b06f1621094cedff4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 19 Feb 2017 16:33:24 +0100 Subject: [PATCH 545/675] load locales and rules separately (xml prep work) --- conf/e2/locales.xml | 1 + conf/e2/{config.xml => rules.xml} | 13 ------------- conf/e3/locales.xml | 13 +++++++++++++ conf/e3/{config.xml => rules.xml} | 5 ----- scripts/eressea/xmlconf.lua | 3 ++- 5 files changed, 16 insertions(+), 19 deletions(-) rename conf/e2/{config.xml => rules.xml} (75%) create mode 100644 conf/e3/locales.xml rename conf/e3/{config.xml => rules.xml} (84%) diff --git a/conf/e2/locales.xml b/conf/e2/locales.xml index f71525343..7a31bbc17 100644 --- a/conf/e2/locales.xml +++ b/conf/e2/locales.xml @@ -3,6 +3,7 @@ + diff --git a/conf/e2/config.xml b/conf/e2/rules.xml similarity index 75% rename from conf/e2/config.xml rename to conf/e2/rules.xml index 56c622d04..8d0b01b27 100644 --- a/conf/e2/config.xml +++ b/conf/e2/rules.xml @@ -1,11 +1,5 @@ - - - - - - @@ -26,7 +20,6 @@ - @@ -46,10 +39,4 @@ - - - - - - diff --git a/conf/e3/locales.xml b/conf/e3/locales.xml new file mode 100644 index 000000000..2d94bf202 --- /dev/null +++ b/conf/e3/locales.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/conf/e3/config.xml b/conf/e3/rules.xml similarity index 84% rename from conf/e3/config.xml rename to conf/e3/rules.xml index ac05d5a5a..421b54d7a 100644 --- a/conf/e3/config.xml +++ b/conf/e3/rules.xml @@ -1,8 +1,5 @@ - - - @@ -15,8 +12,6 @@ - - diff --git a/scripts/eressea/xmlconf.lua b/scripts/eressea/xmlconf.lua index 584f8d3e2..84f29eceb 100644 --- a/scripts/eressea/xmlconf.lua +++ b/scripts/eressea/xmlconf.lua @@ -4,7 +4,8 @@ if config.install then end if config.rules then local rules = config.rules .. '/' - assert(0 == read_xml(confdir .. rules .. 'config.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") assert(0 == eressea.config.read(rules .. 'config.json', confdir), "could not read JSON data") + assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") + assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") end eressea.game.reset() From ba1fdcce599110bb95c74b0b3753cbb991cbae91 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Feb 2017 07:47:36 +0100 Subject: [PATCH 546/675] remove race.describe funpointer --- res/e3a/races.xml | 1 - res/eressea/races.xml | 1 - src/kernel/race.c | 4 ---- src/kernel/race.h | 3 --- src/kernel/save.c | 11 ----------- src/kernel/unit.c | 11 +++++++++-- src/kernel/unit.test.c | 14 ++++++++++++-- src/kernel/xmlreader.c | 3 --- src/names.c | 28 ++++++++++------------------ src/names.test.c | 1 - 10 files changed, 31 insertions(+), 46 deletions(-) diff --git a/res/e3a/races.xml b/res/e3a/races.xml index ccc118877..acc002b1a 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -615,7 +615,6 @@ - diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 3cf5136a4..9f3624d70 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -602,7 +602,6 @@ regaura="1.000000" weight="100" capacity="540" speed="1.000000" hp="20" damage="0d0" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" invinciblenonmagic="yes"> - diff --git a/src/kernel/race.c b/src/kernel/race.c index 2ede414c7..1385bd932 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -542,10 +542,6 @@ variant read_race_reference(struct storage *store) return result; } -void register_race_description_function(race_desc_func func, const char *name) { - register_function((pf_generic)func, name); -} - void register_race_name_function(race_name_func func, const char *name) { register_function((pf_generic)func, name); } diff --git a/src/kernel/race.h b/src/kernel/race.h index ceb5e59d9..80f2622f3 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -112,7 +112,6 @@ extern "C" { int level; } att; - typedef const char *(*race_desc_func)(const struct race *rc, const struct locale *lang); typedef void (*race_name_func)(struct unit *); typedef struct race { @@ -145,7 +144,6 @@ extern "C" { signed char bonus[MAXSKILLS]; race_name_func generate_name; - race_desc_func describe; void(*age) (struct unit * u); bool(*move_allowed) (const struct region *, const struct region *); struct item *(*itemdrop) (const struct race *, int size); @@ -267,7 +265,6 @@ extern "C" { const char *raceprefix(const struct unit *u); void register_race_name_function(race_name_func, const char *); - void register_race_description_function(race_desc_func, const char *); #ifdef __cplusplus } diff --git a/src/kernel/save.c b/src/kernel/save.c index 3ddaf7a7c..d4045d05f 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -695,17 +695,6 @@ unit *read_unit(struct gamedata *data) else u->irace = NULL; - if (rc->describe) { - const char *rcdisp = rc->describe(rc, u->faction->locale); - if (u->display && rcdisp) { - /* see if the data file contains old descriptions */ - if (strcmp(rcdisp, u->display) == 0) { - free(u->display); - u->display = NULL; - } - } - } - READ_INT(data->store, &n); if (n > 0) { building * b = findbuilding(n); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 1acebac6d..ab1669ed9 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -531,8 +531,15 @@ const char *u_description(const unit * u, const struct locale *lang) if (u->display && u->display[0]) { return u->display; } - else if (u_race(u)->describe) { - return u_race(u)->describe(u->_race, lang); + else { + char zText[64]; + const char * d; + const race * rc = u_race(u); + snprintf(zText, sizeof(zText), "describe_%s", rc->_name); + d = locale_getstring(lang, zText); + if (d) { + return d; + } } return NULL; } diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index 16ff2890b..c187f7bab 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -390,14 +390,24 @@ static void test_limited_skills(CuTest *tc) { static void test_unit_description(CuTest *tc) { race *rc; unit *u; + struct locale *lang; + test_setup(); + lang = test_create_locale(); rc = test_create_race("hodor"); u = test_create_unit(test_create_faction(rc), test_create_region(0,0,0)); + CuAssertPtrEquals(tc, 0, u->display); - CuAssertStrEquals(tc, 0, u_description(u, u->faction->locale)); + CuAssertStrEquals(tc, 0, u_description(u, lang)); u->display = strdup("Hodor"); CuAssertStrEquals(tc, "Hodor", u_description(u, NULL)); - CuAssertStrEquals(tc, "Hodor", u_description(u, u->faction->locale)); + CuAssertStrEquals(tc, "Hodor", u_description(u, lang)); + + free(u->display); + u->display = NULL; + locale_setstring(lang, "describe_hodor", "HODOR"); + CuAssertStrEquals(tc, "HODOR", u_description(u, lang)); + test_cleanup(); } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 2cf0b42e8..44a8c161e 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1795,9 +1795,6 @@ static int parse_races(xmlDocPtr doc) if (strcmp((const char *)propValue, "name") == 0) { rc->generate_name = (race_name_func)fun; } - else if (strcmp((const char *)propValue, "describe") == 0) { - rc->describe = (race_desc_func)fun; - } else if (strcmp((const char *)propValue, "age") == 0) { rc->age = (void(*)(struct unit *))fun; } diff --git a/src/names.c b/src/names.c index cf0d9fd09..780386deb 100644 --- a/src/names.c +++ b/src/names.c @@ -45,13 +45,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -static const char *describe_race(const race * rc, const struct locale *lang) -{ - char zText[32]; - sprintf(zText, "describe_%s", rc->_name); - return locale_getstring(lang, zText); -} - static void count_particles(const char *monster, int *num_prefix, int *num_name, int *num_postfix) { char zText[32]; @@ -395,29 +388,29 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) int result; UNUSED_ARG(buflen); - /* Prfen, ob Kurz genug */ + /* Pr�fen, ob Kurz genug */ if (strlen(s) <= maxchars) { return s; } - /* Anzahl der Wrter feststellen */ + /* Anzahl der W�rter feststellen */ while (*p != 0) { result = unicode_utf8_to_ucs4(&ucs, p, &size); assert(result == 0 || "damnit, we're not handling invalid input here!"); - /* Leerzeichen berspringen */ + /* Leerzeichen �berspringen */ while (*p != 0 && !iswalnum((wint_t)ucs)) { p += size; result = unicode_utf8_to_ucs4(&ucs, p, &size); assert(result == 0 || "damnit, we're not handling invalid input here!"); } - /* Counter erhhen */ + /* Counter erh�hen */ if (*p != 0) ++c; - /* alnums berspringen */ + /* alnums �berspringen */ while (*p != 0 && iswalnum((wint_t)ucs)) { p += size; result = unicode_utf8_to_ucs4(&ucs, p, &size); @@ -425,10 +418,10 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) } } - /* Buchstaben pro Teilkrzel = MAX(1,max/AnzWort) */ + /* Buchstaben pro Teilk�rzel = MAX(1,max/AnzWort) */ bpt = (c > 0) ? MAX(1, maxchars / c) : 1; - /* Einzelne Wrter anspringen und jeweils die ersten BpT kopieren */ + /* Einzelne W�rter anspringen und jeweils die ersten BpT kopieren */ p = s; c = 0; @@ -438,7 +431,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) assert(result == 0 || "damnit, we're not handling invalid input here!"); while (*p != 0 && c < maxchars) { - /* Leerzeichen berspringen */ + /* Leerzeichen �berspringen */ while (*p != 0 && !iswalnum((wint_t)ucs)) { p += size; @@ -446,7 +439,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) assert(result == 0 || "damnit, we're not handling invalid input here!"); } - /* alnums bertragen */ + /* alnums �bertragen */ for (i = 0; i < bpt && *p != 0 && iswalnum((wint_t)ucs); ++i) { memcpy(bufp, p, size); @@ -458,7 +451,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) assert(result == 0 || "damnit, we're not handling invalid input here!"); } - /* Bis zum nchsten Leerzeichen */ + /* Bis zum n�chsten Leerzeichen */ while (c < maxchars && *p != 0 && iswalnum((wint_t)ucs)) { p += size; @@ -474,7 +467,6 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) void register_names(void) { - register_race_description_function(describe_race, "describe_race"); /* function name * generate a name for a nonplayerunit * race->generate_name() */ diff --git a/src/names.test.c b/src/names.test.c index 8109fc2d4..01fe0ff41 100644 --- a/src/names.test.c +++ b/src/names.test.c @@ -32,7 +32,6 @@ static void test_names(CuTest * tc) CuAssertPtrNotNull(tc, get_function("namedragon")); CuAssertPtrNotNull(tc, get_function("namedracoid")); CuAssertPtrNotNull(tc, get_function("namegeneric")); - CuAssertPtrNotNull(tc, get_function("describe_race")); test_cleanup(); } From 59f87edbb1ca38e6b078a70d13ef2ea53cd907f2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Feb 2017 09:00:48 +0100 Subject: [PATCH 547/675] remove unused race.move_allowed method --- res/e3a/races.xml | 1 - res/eressea/races.xml | 5 ----- res/races/dragon.xml | 1 - res/races/wyrm.xml | 1 - res/races/youngdragon.xml | 1 - src/kernel/race.h | 1 - src/kernel/xmlreader.c | 4 ---- src/races/races.c | 4 +--- 8 files changed, 1 insertion(+), 17 deletions(-) diff --git a/res/e3a/races.xml b/res/e3a/races.xml index acc002b1a..1036ba223 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -875,7 +875,6 @@ - diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 9f3624d70..6899a8070 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -732,7 +732,6 @@ - @@ -745,7 +744,6 @@ - @@ -758,7 +756,6 @@ - @@ -1141,7 +1138,6 @@ - @@ -1273,7 +1269,6 @@ - diff --git a/res/races/dragon.xml b/res/races/dragon.xml index f8022d0a4..7a36e4b84 100644 --- a/res/races/dragon.xml +++ b/res/races/dragon.xml @@ -6,7 +6,6 @@ dragon="yes"> - diff --git a/res/races/wyrm.xml b/res/races/wyrm.xml index 3ee48ca67..dab1a9e1f 100644 --- a/res/races/wyrm.xml +++ b/res/races/wyrm.xml @@ -5,7 +5,6 @@ defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes" income="5000"> - diff --git a/res/races/youngdragon.xml b/res/races/youngdragon.xml index d5b23b601..0ac2d35be 100644 --- a/res/races/youngdragon.xml +++ b/res/races/youngdragon.xml @@ -6,7 +6,6 @@ teach="no" getitem="yes" resistbash="yes" dragon="yes" income="150"> - diff --git a/src/kernel/race.h b/src/kernel/race.h index 80f2622f3..32ff05ebd 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -145,7 +145,6 @@ extern "C" { race_name_func generate_name; void(*age) (struct unit * u); - bool(*move_allowed) (const struct region *, const struct region *); struct item *(*itemdrop) (const struct race *, int size); void(*init_familiar) (struct unit *); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 44a8c161e..508516671 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1798,10 +1798,6 @@ static int parse_races(xmlDocPtr doc) else if (strcmp((const char *)propValue, "age") == 0) { rc->age = (void(*)(struct unit *))fun; } - else if (strcmp((const char *)propValue, "move") == 0) { - rc->move_allowed = - (bool(*)(const struct region *, const struct region *))fun; - } else if (strcmp((const char *)propValue, "itemdrop") == 0) { rc->itemdrop = (struct item * (*)(const struct race *, int))fun; } diff --git a/src/races/races.c b/src/races/races.c index 8af9cf2ed..bb699520e 100644 --- a/src/races/races.c +++ b/src/races/races.c @@ -88,15 +88,13 @@ static void equip_newunits(const struct equipment *eq, struct unit *u) } } -/* Die Funktionen werden ber den hier registrierten Namen in races.xml +/* Die Funktionen werden �ber den hier registrierten Namen in races.xml * in die jeweilige Rassendefiniton eingebunden */ void register_races(void) { /* function initfamiliar */ register_function((pf_generic)oldfamiliars, "oldfamiliars"); - register_function((pf_generic)allowed_dragon, "movedragon"); - register_function((pf_generic)allowed_swim, "moveswimming"); register_function((pf_generic)allowed_fly, "moveflying"); register_function((pf_generic)allowed_walk, "movewalking"); From 04154628e6ed8dd91b3c2bc5c7d07e7da1184c43 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Feb 2017 09:18:04 +0100 Subject: [PATCH 548/675] remove funpointer for spoils --- res/e3a/races.xml | 7 ------- res/eressea/races.xml | 11 ----------- res/races/aquarian.xml | 1 - res/races/cat.xml | 1 - res/races/demon.xml | 1 - res/races/dwarf.xml | 3 +-- res/races/elf.xml | 3 +-- res/races/goblin-2.xml | 1 - res/races/goblin-3.xml | 1 - res/races/goblin.xml | 1 - res/races/halfling.xml | 3 +-- res/races/human.xml | 1 - res/races/insect.xml | 3 +-- res/races/troll.xml | 1 - src/battle.c | 12 +++++------- src/kernel/item.c | 3 +-- src/kernel/item.h | 1 + src/kernel/race.h | 1 - src/kernel/xmlreader.c | 3 --- 19 files changed, 11 insertions(+), 47 deletions(-) diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 1036ba223..e2cc60e55 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -34,7 +34,6 @@ - @@ -48,7 +47,6 @@ - @@ -76,7 +74,6 @@ - @@ -103,7 +100,6 @@ - @@ -123,7 +119,6 @@ - @@ -142,7 +137,6 @@ - @@ -165,7 +159,6 @@ - diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 6899a8070..70dd1af9f 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -12,7 +12,6 @@ - @@ -780,7 +779,6 @@ - @@ -799,7 +797,6 @@ - @@ -825,7 +822,6 @@ - @@ -858,7 +854,6 @@ - @@ -888,7 +883,6 @@ - @@ -919,7 +913,6 @@ - @@ -951,7 +944,6 @@ - @@ -1149,7 +1141,6 @@ - @@ -1179,7 +1170,6 @@ - @@ -1206,7 +1196,6 @@ - diff --git a/res/races/aquarian.xml b/res/races/aquarian.xml index a0e1189b7..19fd3aee7 100644 --- a/res/races/aquarian.xml +++ b/res/races/aquarian.xml @@ -1,7 +1,6 @@ - diff --git a/res/races/cat.xml b/res/races/cat.xml index 75bc8019a..5986c223c 100644 --- a/res/races/cat.xml +++ b/res/races/cat.xml @@ -1,7 +1,6 @@ - diff --git a/res/races/demon.xml b/res/races/demon.xml index 0ce4c86ff..69d98145f 100644 --- a/res/races/demon.xml +++ b/res/races/demon.xml @@ -6,7 +6,6 @@ unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" shapeshift="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes" healing="1.5"> - diff --git a/res/races/dwarf.xml b/res/races/dwarf.xml index c5c4f2fcf..043b76aa7 100644 --- a/res/races/dwarf.xml +++ b/res/races/dwarf.xml @@ -1,7 +1,6 @@ - @@ -30,4 +29,4 @@ - \ No newline at end of file + diff --git a/res/races/elf.xml b/res/races/elf.xml index ee1278a26..683ee823b 100644 --- a/res/races/elf.xml +++ b/res/races/elf.xml @@ -1,7 +1,6 @@ - @@ -26,4 +25,4 @@ - \ No newline at end of file + diff --git a/res/races/goblin-2.xml b/res/races/goblin-2.xml index f8964d7c0..f26fa780e 100644 --- a/res/races/goblin-2.xml +++ b/res/races/goblin-2.xml @@ -5,7 +5,6 @@ speed="1.0" hp="16" damage="1d5" unarmedattack="-2" unarmeddefense="0" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes" healing="2.0"> - diff --git a/res/races/goblin-3.xml b/res/races/goblin-3.xml index 4ad83967d..3fd594939 100644 --- a/res/races/goblin-3.xml +++ b/res/races/goblin-3.xml @@ -5,7 +5,6 @@ speed="1.0" hp="16" damage="1d5" unarmedattack="-2" unarmeddefense="0" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes" healing="2.0"> - diff --git a/res/races/goblin.xml b/res/races/goblin.xml index 101cdaa86..a05d127e3 100644 --- a/res/races/goblin.xml +++ b/res/races/goblin.xml @@ -6,7 +6,6 @@ unarmedattack="-2" unarmeddefense="0" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes" healing="2.0"> - diff --git a/res/races/halfling.xml b/res/races/halfling.xml index 4801685a0..3628d2b35 100644 --- a/res/races/halfling.xml +++ b/res/races/halfling.xml @@ -1,8 +1,7 @@ - - + diff --git a/res/races/human.xml b/res/races/human.xml index 8f1ad5cb4..f91ba7daf 100644 --- a/res/races/human.xml +++ b/res/races/human.xml @@ -1,7 +1,6 @@ - diff --git a/res/races/insect.xml b/res/races/insect.xml index dc9faa06d..75e16f7af 100644 --- a/res/races/insect.xml +++ b/res/races/insect.xml @@ -1,7 +1,6 @@ - @@ -27,4 +26,4 @@ - \ No newline at end of file + diff --git a/res/races/troll.xml b/res/races/troll.xml index c70020fa2..9168a6d0e 100644 --- a/res/races/troll.xml +++ b/res/races/troll.xml @@ -6,7 +6,6 @@ unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes" healing="1.5"> - diff --git a/src/battle.c b/src/battle.c index 9ce22918a..0ff8eecaa 100644 --- a/src/battle.c +++ b/src/battle.c @@ -925,14 +925,12 @@ void kill_troop(troop dt) if (!df->alive) { char eqname[64]; const struct equipment *eq; - if (u_race(du)->itemdrop) { - item *drops = u_race(du)->itemdrop(u_race(du), du->number - df->run.number); - - if (drops != NULL) { - i_merge(&du->items, &drops); - } + const race *rc = u_race(du); + item *drops = item_spoil(rc, du->number - df->run.number); + if (drops != NULL) { + i_merge(&du->items, &drops); } - sprintf(eqname, "%s_spoils", u_race(du)->_name); + sprintf(eqname, "%s_spoils", rc->_name); eq = get_equipment(eqname); if (eq != NULL) { equip_items(&du->items, eq); diff --git a/src/kernel/item.c b/src/kernel/item.c index 177e44831..c37e3d40c 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -1175,7 +1175,7 @@ attrib_type at_resourcelimit = { finalize_resourcelimit, }; -static item *default_spoil(const struct race *rc, int size) +item *item_spoil(const struct race *rc, int size) { item *itm = NULL; @@ -1303,7 +1303,6 @@ void register_resources(void) register_function((pf_generic)res_changepermaura, "changepermaura"); register_function((pf_generic)res_changehp, "changehp"); register_function((pf_generic)res_changeaura, "changeaura"); - register_function((pf_generic)default_spoil, "defaultdrops"); register_item_use(use_potion, "usepotion"); register_item_use(use_potion_delayed, "usepotion_delayed"); diff --git a/src/kernel/item.h b/src/kernel/item.h index e6301c314..79e6f103d 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -309,6 +309,7 @@ extern "C" { extern const struct potion_type *oldpotiontype[]; const struct resource_type *get_resourcetype(resource_t rt); + struct item *item_spoil(const struct race *rc, int size); int get_item(const struct unit * u, const struct item_type *itype); int set_item(struct unit * u, const struct item_type *itype, int value); diff --git a/src/kernel/race.h b/src/kernel/race.h index 32ff05ebd..380b843bd 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -145,7 +145,6 @@ extern "C" { race_name_func generate_name; void(*age) (struct unit * u); - struct item *(*itemdrop) (const struct race *, int size); void(*init_familiar) (struct unit *); struct rcoption *options; /* rarely used properties */ diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 508516671..97fab3b8d 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1798,9 +1798,6 @@ static int parse_races(xmlDocPtr doc) else if (strcmp((const char *)propValue, "age") == 0) { rc->age = (void(*)(struct unit *))fun; } - else if (strcmp((const char *)propValue, "itemdrop") == 0) { - rc->itemdrop = (struct item * (*)(const struct race *, int))fun; - } else if (strcmp((const char *)propValue, "initfamiliar") == 0) { rc->init_familiar = (void(*)(struct unit *))fun; } From 5ba3d76efb6e69c82c0e9dfcd2ef22bb02e3c999 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Feb 2017 09:32:03 +0100 Subject: [PATCH 549/675] remove race.init_familiar funpointer --- res/e3a/races.xml | 19 ------------------- res/eressea/races.xml | 21 --------------------- src/kernel/race.c | 2 +- src/kernel/race.h | 2 +- src/kernel/xmlreader.c | 4 +--- src/spells.c | 15 ++++++++++----- 6 files changed, 13 insertions(+), 50 deletions(-) diff --git a/res/e3a/races.xml b/res/e3a/races.xml index e2cc60e55..e81d31b92 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -10,7 +10,6 @@ - @@ -183,7 +182,6 @@ - @@ -210,7 +208,6 @@ - @@ -232,7 +229,6 @@ - @@ -254,7 +250,6 @@ - @@ -278,7 +273,6 @@ - @@ -302,7 +296,6 @@ - @@ -325,7 +318,6 @@ - @@ -352,7 +344,6 @@ - @@ -375,7 +366,6 @@ - @@ -400,7 +390,6 @@ - @@ -427,7 +416,6 @@ - @@ -451,7 +439,6 @@ - @@ -475,7 +462,6 @@ - @@ -498,7 +484,6 @@ - @@ -526,7 +511,6 @@ - @@ -550,7 +534,6 @@ - @@ -573,7 +556,6 @@ - @@ -597,7 +579,6 @@ - diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 70dd1af9f..470a33a3f 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -28,7 +28,6 @@ - @@ -62,7 +61,6 @@ - @@ -91,7 +89,6 @@ - @@ -119,7 +116,6 @@ - @@ -149,7 +145,6 @@ - @@ -179,7 +174,6 @@ - @@ -210,7 +204,6 @@ - @@ -245,7 +238,6 @@ - @@ -276,7 +268,6 @@ - @@ -309,7 +300,6 @@ - @@ -341,7 +331,6 @@ - @@ -371,7 +360,6 @@ - @@ -402,7 +390,6 @@ - @@ -432,7 +419,6 @@ - @@ -464,7 +450,6 @@ - @@ -496,7 +481,6 @@ - @@ -526,7 +510,6 @@ - @@ -559,7 +542,6 @@ - @@ -589,7 +571,6 @@ - @@ -882,7 +863,6 @@ - @@ -943,7 +923,6 @@ - diff --git a/src/kernel/race.c b/src/kernel/race.c index 1385bd932..e3983bffe 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -226,7 +226,7 @@ race_list *get_familiarraces(void) if (!init) { race *rc = races; for (; rc != NULL; rc = rc->next) { - if (rc->init_familiar != NULL) { + if (rc->flags & RCF_FAMILIAR) { racelist_insert(&familiarraces, rc); } } diff --git a/src/kernel/race.h b/src/kernel/race.h index 380b843bd..1322d3aad 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -145,7 +145,6 @@ extern "C" { race_name_func generate_name; void(*age) (struct unit * u); - void(*init_familiar) (struct unit *); struct rcoption *options; /* rarely used properties */ @@ -226,6 +225,7 @@ extern "C" { #define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */ #define RCF_ATTACK_MOVED (1<<29) /* may attack if it has moved */ #define RCF_MIGRANTS (1<<30) /* may have migrant units (human bonus) */ +#define RCF_FAMILIAR (1<<31) /* may be a familiar */ /* Economic flags */ #define ECF_KEEP_ITEM (1<<1) /* gibt Gegenst�nde weg */ diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 97fab3b8d..2ba8e2b75 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1798,9 +1798,6 @@ static int parse_races(xmlDocPtr doc) else if (strcmp((const char *)propValue, "age") == 0) { rc->age = (void(*)(struct unit *))fun; } - else if (strcmp((const char *)propValue, "initfamiliar") == 0) { - rc->init_familiar = (void(*)(struct unit *))fun; - } else { log_error("unknown function type '%s' for race %s\n", (const char *)propValue, rc->_name); } @@ -1822,6 +1819,7 @@ static int parse_races(xmlDocPtr doc) propValue = xmlGetProp(node, BAD_CAST "race"); assert(propValue != NULL); frc = rc_get_or_create((const char *)propValue); + frc->flags |= RCF_FAMILIAR; if (xml_bvalue(node, "default", false)) { rc->familiars[k] = rc->familiars[0]; rc->familiars[0] = frc; diff --git a/src/spells.c b/src/spells.c index 091d3d076..95b26434f 100644 --- a/src/spells.c +++ b/src/spells.c @@ -34,10 +34,10 @@ #include /* kernel includes */ -#include -#include #include #include +#include +#include #include #include #include @@ -514,11 +514,16 @@ static const race *select_familiar(const race * magerace, magic_t magiegebiet) static void make_familiar(unit * familiar, unit * mage) { /* skills and spells: */ - if (u_race(familiar)->init_familiar != NULL) { - u_race(familiar)->init_familiar(familiar); + const struct equipment *eq; + char eqname[64]; + const race * rc = u_race(familiar); + snprintf(eqname, sizeof(eqname), "%s_familiar", rc->_name); + eq = get_equipment(eqname); + if (eq != NULL) { + equip_items(&familiar->items, eq); } else { - log_error("could not perform initialization for familiar %s.\n", familiar->faction->race->_name); + log_error("could not perform initialization for familiar %s.\n", rc->_name); } /* triggers: */ From 4bd295e3b283c6dae43ca593ecf8af8fd4e7f1d6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Feb 2017 20:42:31 +0100 Subject: [PATCH 550/675] remove the nearly unused illusion race --- res/core/messages.xml | 14 -------------- res/e3a/races.xml | 7 ------- res/eressea/races.xml | 6 ------ src/kernel/race.c | 15 +++++++++++---- src/kernel/race.h | 4 ++-- src/races/CMakeLists.txt | 1 - src/races/illusion.c | 38 -------------------------------------- src/races/races.c | 2 -- src/reports.c | 5 ++--- 9 files changed, 15 insertions(+), 77 deletions(-) delete mode 100644 src/races/illusion.c diff --git a/res/core/messages.xml b/res/core/messages.xml index 3fae49eb3..e312fcc7c 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -3266,20 +3266,6 @@ "$unit($unit) marschiert in eine Antimagiezone und löst sich auf." "$unit($unit) walks into an antimagical zone and dissolves." - - - - - "$unit($unit) hat sich unbemerkt verflüchtigt." - "$unit($unit) has dissolved without a trace." - - - - - - "$unit($unit) wird sich bald verflüchtigen." - "$unit($unit) will dissolve soon." - diff --git a/res/e3a/races.xml b/res/e3a/races.xml index e81d31b92..83d356f75 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -696,13 +696,6 @@ - - - - - - - diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 470a33a3f..bce464d78 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -745,12 +745,6 @@ - - - - - - diff --git a/src/kernel/race.c b/src/kernel/race.c index e3983bffe..56b0590ae 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -66,7 +66,7 @@ static int rc_changes = 1; static const char *racenames[MAXRACES] = { "dwarf", "elf", NULL, "goblin", "human", "troll", "demon", "insect", - "halfling", "cat", "aquarian", "orc", "snotling", "undead", "illusion", + "halfling", "cat", "aquarian", "orc", "snotling", "undead", NULL, "youngdragon", "dragon", "wyrm", "ent", "catdragon", "dracoid", NULL, "spell", "irongolem", "stonegolem", "shadowdemon", "shadowmaster", "mountainguard", "alp", "toad", "braineater", "peasant", @@ -296,9 +296,16 @@ static race *rc_find_i(const char *name) while (rc && strcmp(rname, rc->_name) != 0) { rc = rc->next; } - if (!rc && strcmp(name, "uruk") == 0) { - rc = rc_find_i("orc"); - log_warning("a reference was made to the retired race '%s', returning '%s'.", name, rc->_name); + if (!rc) { + const char *rc_depr[] = { "uruk", "orc", "illusion", "template", NULL }; + int i; + for (i = 0; rc_depr[i]; i += 2) { + if (strcmp(name, rc_depr[i]) == 0) { + rc = rc_find_i(rc_depr[i + 1]); + log_warning("a reference was made to the retired race '%s', returning '%s'.", name, rc->_name); + break; + } + } } return rc; } diff --git a/src/kernel/race.h b/src/kernel/race.h index 1322d3aad..1039402b0 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -65,8 +65,8 @@ extern "C" { RC_ORC, RC_SNOTLING, RC_UNDEAD, - RC_ILLUSION, - RC_FIREDRAGON, + + RC_FIREDRAGON = 15, RC_DRAGON, RC_WYRM, RC_TREEMAN, diff --git a/src/races/CMakeLists.txt b/src/races/CMakeLists.txt index 1f3044e3a..ff6025581 100644 --- a/src/races/CMakeLists.txt +++ b/src/races/CMakeLists.txt @@ -1,7 +1,6 @@ PROJECT(races C) SET(_FILES dragons.c -illusion.c races.c zombies.c ) diff --git a/src/races/illusion.c b/src/races/illusion.c deleted file mode 100644 index 7411ae4d5..000000000 --- a/src/races/illusion.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Eressea PB(E)M host Copyright (C) 1998-2015 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - -#include - -/* kernel includes */ -#include -#include -#include -#include - -/* libc includes */ -#include -#include - -#define ILLUSIONMAX 6 - -void age_illusion(unit * u) -{ - if (u->faction->race != get_race(RC_ILLUSION)) { - if (u->age == ILLUSIONMAX) { - ADDMSG(&u->faction->msgs, msg_message("warnillusiondissolve", "unit", u)); - } - else if (u->age > ILLUSIONMAX) { - set_number(u, 0); - ADDMSG(&u->faction->msgs, msg_message("illusiondissolve", "unit", u)); - } - } -} diff --git a/src/races/races.c b/src/races/races.c index bb699520e..7ca9e976a 100644 --- a/src/races/races.c +++ b/src/races/races.c @@ -31,7 +31,6 @@ void age_firedragon(struct unit *u); void age_dragon(struct unit *u); -void age_illusion(struct unit *u); void age_undead(struct unit *u); void age_skeleton(struct unit *u); void age_zombie(struct unit *u); @@ -101,7 +100,6 @@ void register_races(void) /* function age for race->age() */ register_function((pf_generic)age_undead, "ageundead"); - register_function((pf_generic)age_illusion, "ageillusion"); register_function((pf_generic)age_skeleton, "ageskeleton"); register_function((pf_generic)age_zombie, "agezombie"); register_function((pf_generic)age_ghoul, "ageghoul"); diff --git a/src/reports.c b/src/reports.c index 7d8374ff5..a49957b9d 100644 --- a/src/reports.c +++ b/src/reports.c @@ -123,13 +123,12 @@ const char *options[MAXOPTIONS] = { bool omniscient(const faction *f) { - static const race *rc_template, *rc_illusion; + static const race *rc_template; static int cache; if (rc_changed(&cache)) { - rc_illusion = get_race(RC_ILLUSION); rc_template = get_race(RC_TEMPLATE); } - return (f->race == rc_template || f->race == rc_illusion); + return (f->race == rc_template); } From 44f6336e1f8d150430a7f66a6955ddfa5b010040 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Feb 2017 21:04:50 +0100 Subject: [PATCH 551/675] do not register unused functions. --- src/races/races.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/races/races.c b/src/races/races.c index 7ca9e976a..a05f3d211 100644 --- a/src/races/races.c +++ b/src/races/races.c @@ -36,16 +36,6 @@ void age_skeleton(struct unit *u); void age_zombie(struct unit *u); void age_ghoul(struct unit *u); -static void oldfamiliars(unit * u) -{ - char fname[64]; - /* these familiars have no special skills. - */ - snprintf(fname, sizeof(fname), "%s_familiar", u_race(u)->_name); - create_mage(u, M_GRAY); - equip_unit(u, get_equipment(fname)); -} - static void equip_newunits(const struct equipment *eq, struct unit *u) { struct region *r = u->region; @@ -91,12 +81,7 @@ static void equip_newunits(const struct equipment *eq, struct unit *u) * in die jeweilige Rassendefiniton eingebunden */ void register_races(void) { - /* function initfamiliar */ - register_function((pf_generic)oldfamiliars, "oldfamiliars"); - - register_function((pf_generic)allowed_swim, "moveswimming"); - register_function((pf_generic)allowed_fly, "moveflying"); - register_function((pf_generic)allowed_walk, "movewalking"); + register_function((pf_generic)equip_newunits, "equip_newunits"); /* function age for race->age() */ register_function((pf_generic)age_undead, "ageundead"); @@ -105,9 +90,4 @@ void register_races(void) register_function((pf_generic)age_ghoul, "ageghoul"); register_function((pf_generic)age_dragon, "agedragon"); register_function((pf_generic)age_firedragon, "agefiredragon"); - - /* function itemdrop - * to generate battle spoils - * race->itemdrop() */ - register_function((pf_generic)equip_newunits, "equip_newunits"); } From a1dc3dc8e4f43088cf0898a259b81c191e375021 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Feb 2017 21:19:13 +0100 Subject: [PATCH 552/675] remove race.age from XML data (set in rc_create) --- res/e3a/races.xml | 4 ---- res/eressea/races.xml | 6 ------ src/kernel/race.c | 4 ++++ src/kernel/xmlreader.c | 3 --- src/races/races.c | 12 ++++++------ 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 83d356f75..b7111b4f1 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -699,7 +699,6 @@ - @@ -752,7 +751,6 @@ - @@ -788,7 +786,6 @@ - @@ -820,7 +817,6 @@ - diff --git a/res/eressea/races.xml b/res/eressea/races.xml index bce464d78..b9077d98b 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -723,7 +723,6 @@ - @@ -735,7 +734,6 @@ - @@ -748,7 +746,6 @@ - @@ -1019,7 +1016,6 @@ - @@ -1053,7 +1049,6 @@ - @@ -1083,7 +1078,6 @@ - diff --git a/src/kernel/race.c b/src/kernel/race.c index 56b0590ae..4e8e0817c 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -327,6 +327,7 @@ race *rc_create(const char *zName) { race *rc; int i; + char zText[64]; assert(zName); rc = (race *)calloc(sizeof(race), 1); @@ -350,6 +351,9 @@ race *rc_create(const char *zName) rc->index = num_races++; ++rc_changes; rc->next = races; + + snprintf(zText, sizeof(zText), "age_%s", zName); + rc->age = (void(*) (struct unit *))get_function(zText); return races = rc; } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 2ba8e2b75..5c294d13a 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1795,9 +1795,6 @@ static int parse_races(xmlDocPtr doc) if (strcmp((const char *)propValue, "name") == 0) { rc->generate_name = (race_name_func)fun; } - else if (strcmp((const char *)propValue, "age") == 0) { - rc->age = (void(*)(struct unit *))fun; - } else { log_error("unknown function type '%s' for race %s\n", (const char *)propValue, rc->_name); } diff --git a/src/races/races.c b/src/races/races.c index a05f3d211..92a3d3e3d 100644 --- a/src/races/races.c +++ b/src/races/races.c @@ -84,10 +84,10 @@ void register_races(void) register_function((pf_generic)equip_newunits, "equip_newunits"); /* function age for race->age() */ - register_function((pf_generic)age_undead, "ageundead"); - register_function((pf_generic)age_skeleton, "ageskeleton"); - register_function((pf_generic)age_zombie, "agezombie"); - register_function((pf_generic)age_ghoul, "ageghoul"); - register_function((pf_generic)age_dragon, "agedragon"); - register_function((pf_generic)age_firedragon, "agefiredragon"); + register_function((pf_generic)age_undead, "age_undead"); + register_function((pf_generic)age_skeleton, "age_skeleton"); + register_function((pf_generic)age_zombie, "age_zombie"); + register_function((pf_generic)age_ghoul, "age_ghoul"); + register_function((pf_generic)age_dragon, "age_dragon"); + register_function((pf_generic)age_firedragon, "age_youngdragon"); } From 7e4b0ac71772361c11b345dfbbc9ee232b34ee21 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Feb 2017 21:21:05 +0100 Subject: [PATCH 553/675] fix XML file --- res/races/dragon.xml | 1 - res/races/youngdragon.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/res/races/dragon.xml b/res/races/dragon.xml index 7a36e4b84..f42037312 100644 --- a/res/races/dragon.xml +++ b/res/races/dragon.xml @@ -5,7 +5,6 @@ income="1000" walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes"> - diff --git a/res/races/youngdragon.xml b/res/races/youngdragon.xml index 0ac2d35be..df10a44e9 100644 --- a/res/races/youngdragon.xml +++ b/res/races/youngdragon.xml @@ -5,7 +5,6 @@ defensemodifier="4" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes" income="150"> - From bfb5a9b69231c1b53ae9d3ad700582d332beb125 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Feb 2017 22:07:36 +0100 Subject: [PATCH 554/675] set age_unit and name_unit funpointers in rc_create. no more in XML races. rename juju-zombie => juju. --- res/core/de/strings.xml | 8 ++++---- res/core/fr/strings.xml | 4 ++-- res/e3a/races.xml | 19 +------------------ res/eressea/races.xml | 23 +---------------------- src/kernel/race.c | 12 ++++++++---- src/kernel/race.h | 8 ++++---- src/kernel/unit.c | 9 ++++++--- src/kernel/unit.test.c | 2 +- src/kernel/xmlreader.c | 24 ------------------------ src/laws.c | 5 +++-- src/names.c | 23 ++++++++++------------- src/names.test.c | 35 ++++++++++++++++++++--------------- 12 files changed, 60 insertions(+), 112 deletions(-) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 3aa71393d..97ded6e8d 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -2379,19 +2379,19 @@ ghoul - + Juju-Zombie juju-zombie - + Juju-Zombies juju-zombies - + Juju-Zombies juju-zombies - + Juju-Zombie juju-zombie diff --git a/res/core/fr/strings.xml b/res/core/fr/strings.xml index d1801b338..7eb091570 100644 --- a/res/core/fr/strings.xml +++ b/res/core/fr/strings.xml @@ -1912,10 +1912,10 @@ zombie - + zombies juju - + zombie juju diff --git a/res/e3a/races.xml b/res/e3a/races.xml index b7111b4f1..2e5a81aee 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -415,7 +415,6 @@ - @@ -588,7 +587,6 @@ - @@ -643,19 +641,16 @@ - - - @@ -667,7 +662,6 @@ - @@ -683,7 +677,6 @@ - @@ -691,14 +684,12 @@ - - @@ -731,7 +722,6 @@ - @@ -750,7 +740,6 @@ - @@ -766,9 +755,8 @@ - + - @@ -785,7 +773,6 @@ - @@ -800,7 +787,6 @@ - @@ -816,7 +802,6 @@ - @@ -831,13 +816,11 @@ - - diff --git a/res/eressea/races.xml b/res/eressea/races.xml index b9077d98b..6deefacc9 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -330,7 +330,6 @@ - @@ -581,7 +580,6 @@ - @@ -652,19 +650,16 @@ - - - @@ -676,7 +671,6 @@ - @@ -691,7 +685,6 @@ - @@ -705,13 +698,11 @@ - - @@ -722,7 +713,6 @@ - @@ -733,7 +723,6 @@ - @@ -745,7 +734,6 @@ - @@ -997,7 +985,6 @@ - @@ -1015,7 +1002,6 @@ - @@ -1030,9 +1016,8 @@ - + - @@ -1048,7 +1033,6 @@ - @@ -1062,7 +1046,6 @@ - @@ -1077,7 +1060,6 @@ - @@ -1091,12 +1073,10 @@ - - @@ -1224,7 +1204,6 @@ - diff --git a/src/kernel/race.c b/src/kernel/race.c index 4e8e0817c..4a3a04916 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -74,7 +74,7 @@ static const char *racenames[MAXRACES] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "seaserpent", "shadowknight", NULL, "skeleton", "skeletonlord", "zombie", - "juju-zombie", "ghoul", "ghast", NULL, NULL, "template", + "juju", "ghoul", "ghast", NULL, NULL, "template", "clone" }; @@ -297,7 +297,7 @@ static race *rc_find_i(const char *name) rc = rc->next; } if (!rc) { - const char *rc_depr[] = { "uruk", "orc", "illusion", "template", NULL }; + const char *rc_depr[] = { "uruk", "orc", "illusion", "template", "juju-zombie", "juju", NULL }; int i; for (i = 0; rc_depr[i]; i += 2) { if (strcmp(name, rc_depr[i]) == 0) { @@ -353,7 +353,11 @@ race *rc_create(const char *zName) rc->next = races; snprintf(zText, sizeof(zText), "age_%s", zName); - rc->age = (void(*) (struct unit *))get_function(zText); + rc->age_unit = (race_func)get_function(zText); + + snprintf(zText, sizeof(zText), "name_%s", zName); + rc->name_unit = (race_func)get_function(zText); + return races = rc; } @@ -553,6 +557,6 @@ variant read_race_reference(struct storage *store) return result; } -void register_race_name_function(race_name_func func, const char *name) { +void register_race_function(race_func func, const char *name) { register_function((pf_generic)func, name); } diff --git a/src/kernel/race.h b/src/kernel/race.h index 1039402b0..e464c9447 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -112,7 +112,7 @@ extern "C" { int level; } att; - typedef void (*race_name_func)(struct unit *); + typedef void (*race_func) (struct unit *); typedef struct race { char *_name; @@ -143,8 +143,8 @@ extern "C" { struct att attack[RACE_ATTACKS]; signed char bonus[MAXSKILLS]; - race_name_func generate_name; - void(*age) (struct unit * u); + race_func name_unit; + race_func age_unit; struct rcoption *options; /* rarely used properties */ @@ -262,7 +262,7 @@ extern "C" { variant read_race_reference(struct storage *store); const char *raceprefix(const struct unit *u); - void register_race_name_function(race_name_func, const char *); + void register_race_function(race_func, const char *); #ifdef __cplusplus } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index ab1669ed9..4592d0bc7 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1460,8 +1460,11 @@ void default_name(const unit *u, char name[], int len) { void name_unit(unit * u) { const race *rc = u_race(u); - if (rc->generate_name) { - rc->generate_name(u); + if (rc->name_unit) { + rc->name_unit(u); + } + else if (u->faction->flags & FFL_NPC) { + unit_setname(u, NULL); } else { char name[32]; @@ -1514,7 +1517,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace, if (dname) { u->_name = strdup(dname); } - else if (urace->generate_name || playerrace(urace)) { + else if (urace->name_unit || playerrace(urace)) { name_unit(u); } diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index c187f7bab..7c7bb087b 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -487,7 +487,7 @@ static void test_name_unit(CuTest *tc) { test_setup(); rc = test_create_race("skeleton"); u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); - rc->generate_name = gen_name; + rc->name_unit = gen_name; name_unit(u); CuAssertStrEquals(tc, "Hodor", unit_getname(u)); test_cleanup(); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 5c294d13a..695f91d69 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1778,30 +1778,6 @@ static int parse_races(xmlDocPtr doc) } xmlXPathFreeObject(result); - /* reading eressea/races/race/function */ - xpath->node = node; - result = xmlXPathEvalExpression(BAD_CAST "function", xpath); - for (k = 0; k != result->nodesetval->nodeNr; ++k) { - xmlNodePtr node = result->nodesetval->nodeTab[k]; - pf_generic fun; - - parse_function(node, &fun, &propValue); - if (fun == NULL) { - log_error("unknown function name '%s' for race %s\n", (const char *)propValue, rc->_name); - xmlFree(propValue); - continue; - } - assert(propValue != NULL); - if (strcmp((const char *)propValue, "name") == 0) { - rc->generate_name = (race_name_func)fun; - } - else { - log_error("unknown function type '%s' for race %s\n", (const char *)propValue, rc->_name); - } - xmlFree(propValue); - } - xmlXPathFreeObject(result); - /* reading eressea/races/race/familiar */ xpath->node = node; result = xmlXPathEvalExpression(BAD_CAST "familiar", xpath); diff --git a/src/laws.c b/src/laws.c index e314e2d85..253b45b89 100644 --- a/src/laws.c +++ b/src/laws.c @@ -164,9 +164,10 @@ static void age_unit(region * r, unit * u) } } else { + const race *rc = u_race(u); ++u->age; - if (u->number > 0 && u_race(u)->age) { - u_race(u)->age(u); + if (u->number > 0 && rc->age_unit) { + rc->age_unit(u); } } if (u->region && is_astral(u->region)) { diff --git a/src/names.c b/src/names.c index 780386deb..bc740a704 100644 --- a/src/names.c +++ b/src/names.c @@ -212,11 +212,6 @@ const char *silbe3[SIL3] = { "bus", }; -static void generic_name(unit * u) -{ - unit_setname(u, NULL); -} - static void dragon_name(unit * u) { char name[NAMESIZE + 1]; @@ -469,12 +464,14 @@ void register_names(void) { /* function name * generate a name for a nonplayerunit - * race->generate_name() */ - register_race_name_function(undead_name, "nameundead"); - register_race_name_function(skeleton_name, "nameskeleton"); - register_race_name_function(zombie_name, "namezombie"); - register_race_name_function(ghoul_name, "nameghoul"); - register_race_name_function(dracoid_name, "namedracoid"); - register_race_name_function(dragon_name, "namedragon"); - register_race_name_function(generic_name, "namegeneric"); + * race->name_unit() */ + + register_race_function(undead_name, "name_undead"); + register_race_function(skeleton_name, "name_skeleton"); + register_race_function(zombie_name, "name_zombie"); + register_race_function(ghoul_name, "name_ghoul"); + register_race_function(dracoid_name, "name_dracoid"); + register_race_function(dragon_name, "name_dragon"); + register_race_function(dragon_name, "name_youngdragon"); + register_race_function(dragon_name, "name_wyrm"); } diff --git a/src/names.test.c b/src/names.test.c index 01fe0ff41..7d62d4752 100644 --- a/src/names.test.c +++ b/src/names.test.c @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -12,31 +13,33 @@ static void test_names(CuTest * tc) { - race_name_func foo; unit *u; race *rc; test_cleanup(); register_names(); + CuAssertPtrNotNull(tc, get_function("name_undead")); + CuAssertPtrNotNull(tc, get_function("name_skeleton")); + CuAssertPtrNotNull(tc, get_function("name_zombie")); + CuAssertPtrNotNull(tc, get_function("name_ghoul")); + CuAssertPtrNotNull(tc, get_function("name_dragon")); + CuAssertPtrNotNull(tc, get_function("name_youngdragon")); + CuAssertPtrNotNull(tc, get_function("name_wyrm")); + CuAssertPtrNotNull(tc, get_function("name_dracoid")); default_locale = test_create_locale(); - u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); rc = test_create_race("undead"); + u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); locale_setstring(default_locale, "undead_name_0", "Graue"); locale_setstring(default_locale, "undead_postfix_0", "Kobolde"); - CuAssertPtrNotNull(tc, foo = (race_name_func)get_function("nameundead")); - rc->generate_name = foo; - rc->generate_name(u); + CuAssertPtrNotNull(tc, rc->name_unit); + CuAssertTrue(tc, rc->name_unit == (race_func)get_function("name_undead")); + name_unit(u); CuAssertStrEquals(tc, "Graue Kobolde", u->_name); - CuAssertPtrNotNull(tc, get_function("nameskeleton")); - CuAssertPtrNotNull(tc, get_function("namezombie")); - CuAssertPtrNotNull(tc, get_function("nameghoul")); - CuAssertPtrNotNull(tc, get_function("namedragon")); - CuAssertPtrNotNull(tc, get_function("namedracoid")); - CuAssertPtrNotNull(tc, get_function("namegeneric")); test_cleanup(); } static void test_monster_names(CuTest *tc) { unit *u; + faction *f; race *rc; test_setup(); @@ -45,11 +48,13 @@ static void test_monster_names(CuTest *tc) { locale_setstring(default_locale, "race::irongolem", "Eisengolem"); locale_setstring(default_locale, "race::irongolem_p", "Eisengolems"); rc = test_create_race("irongolem"); - u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); + f = test_create_faction(rc); + f->flags |= FFL_NPC; + u = test_create_unit(f, test_create_region(0, 0, 0)); + unit_setname(u, "Hodor"); CuAssertPtrNotNull(tc, u->_name); - rc->generate_name = (race_name_func)get_function("namegeneric"); - rc->generate_name(u); - CuAssertPtrEquals(tc, 0, u->_name); + name_unit(u); + CuAssertPtrEquals(tc, NULL, u->_name); CuAssertStrEquals(tc, "Eisengolem", unit_getname(u)); u->number = 2; CuAssertStrEquals(tc, "Eisengolems", unit_getname(u)); From deb39f6b8f8386169d4dd1ebe81429e9fdd0b6db Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 22 Feb 2017 14:27:13 +0100 Subject: [PATCH 555/675] test building_effsize does what it does --- src/kernel/building.test.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index e02d16556..8bafcab85 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -515,6 +515,31 @@ static void test_cmp_castle_size(CuTest *tc) { test_cleanup(); } +static void test_building_effsize(CuTest *tc) { + building *b; + building_type *btype; + construction *cons; + + test_setup(); + btype = bt_get_or_create("castle"); + cons = btype->construction = calloc(1, sizeof(construction)); + cons->maxsize = 5; + cons = cons->improvement = calloc(1, sizeof(construction)); + cons->maxsize = 5; + cons = cons->improvement = calloc(1, sizeof(construction)); + cons->maxsize = -1; + b = test_create_building(test_create_region(0,0,0), btype); + b->size = 1; + CuAssertIntEquals(tc, 0, buildingeffsize(b, false)); + b->size = 5; + CuAssertIntEquals(tc, 1, buildingeffsize(b, false)); + b->size = 10; + CuAssertIntEquals(tc, 2, buildingeffsize(b, false)); + b->size = 20; + CuAssertIntEquals(tc, 2, buildingeffsize(b, false)); + test_cleanup(); +} + CuSuite *get_building_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -522,6 +547,7 @@ CuSuite *get_building_suite(void) SUITE_ADD_TEST(suite, test_register_building); SUITE_ADD_TEST(suite, test_btype_defaults); SUITE_ADD_TEST(suite, test_building_set_owner); + SUITE_ADD_TEST(suite, test_building_effsize); SUITE_ADD_TEST(suite, test_buildingowner_resets_when_empty); SUITE_ADD_TEST(suite, test_buildingowner_goes_to_next_when_empty); SUITE_ADD_TEST(suite, test_buildingowner_goes_to_other_when_empty); From 3274065004bf42a0ab670a0c27f4da0da3cf3e20 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 22 Feb 2017 19:38:46 +0100 Subject: [PATCH 556/675] reduce complexity of building_protection. --- .gitignore | 3 ++ res/buildings/castle-2.xml | 13 +++--- res/buildings/castle.xml | 15 ++++--- res/e3a/buildings.xml | 7 ++-- src/battle.c | 18 ++++---- src/battle.test.c | 84 ++++++++++++++++++++------------------ src/kernel/build.h | 3 -- src/kernel/building.c | 36 ++++------------ src/kernel/building.h | 13 ++---- src/kernel/building.test.c | 1 - src/kernel/xmlreader.c | 6 --- src/tests.c | 2 +- 12 files changed, 87 insertions(+), 114 deletions(-) diff --git a/.gitignore b/.gitignore index 4e63f5d9c..d7c102f5a 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ tmp/ tests/config.lua tests/reports/ tests/data/185.dat +/quicklist/ +/cutest/ +/critbit/ diff --git a/res/buildings/castle-2.xml b/res/buildings/castle-2.xml index 593e9ae5e..7b015d199 100644 --- a/res/buildings/castle-2.xml +++ b/res/buildings/castle-2.xml @@ -1,24 +1,23 @@ - - + - + - + - + - + - + diff --git a/res/buildings/castle.xml b/res/buildings/castle.xml index 253f49811..6e9140222 100644 --- a/res/buildings/castle.xml +++ b/res/buildings/castle.xml @@ -1,26 +1,25 @@ - - + - + - + - + - + - + - + diff --git a/res/e3a/buildings.xml b/res/e3a/buildings.xml index f65654e2f..9eeca952f 100644 --- a/res/e3a/buildings.xml +++ b/res/e3a/buildings.xml @@ -5,15 +5,14 @@ - - + - + - + diff --git a/src/battle.c b/src/battle.c index 0ff8eecaa..23c219109 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1892,10 +1892,11 @@ int skilldiff(troop at, troop dt, int dist) } if (df->building) { - if (df->building->attribs) { + building *b = df->building; + if (b->attribs) { const curse_type *strongwall_ct = ct_find("strongwall"); if (strongwall_ct) { - curse *c = get_curse(df->building->attribs, strongwall_ct); + curse *c = get_curse(b->attribs, strongwall_ct); if (curse_active(c)) { /* wirkt auf alle Geb�ude */ skdiff -= curse_geteffect_int(c); @@ -1903,15 +1904,16 @@ int skilldiff(troop at, troop dt, int dist) } } } - if (df->building->type->protection) { - int beff = df->building->type->protection(df->building, du, DEFENSE_BONUS); - if (beff) { + if (b->type->flags & BTF_FORTIFICATION) { + int stage = buildingeffsize(b, false); + int beff = building_protection(b->type, stage); + if (beff > 0) { skdiff -= beff; is_protected = 2; - if (df->building->attribs) { + if (b->attribs) { const curse_type *magicwalls_ct = ct_find("magicwalls"); if (magicwalls_ct - && curse_active(get_curse(df->building->attribs, magicwalls_ct))) { + && curse_active(get_curse(b->attribs, magicwalls_ct))) { /* Verdoppelt Burgenbonus */ skdiff -= beff; } @@ -2022,7 +2024,7 @@ void damage_building(battle * b, building * bldg, int damage_abs) /* Wenn Burg, dann gucken, ob die Leute alle noch in das Geb�ude passen. */ - if (bldg->type->protection) { + if (bldg->type->flags & BTF_FORTIFICATION) { side *s; bldg->sizeleft = bldg->size; diff --git a/src/battle.test.c b/src/battle.test.c index 5d34766db..987613277 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -60,10 +60,23 @@ static void test_make_fighter(CuTest * tc) test_cleanup(); } -static int add_two(const building * b, const unit * u, building_bonus bonus) { +static int add_two(const building * b, const unit * u) { return 2; } +static building_type * setup_castle(void) { + building_type * btype; + construction *cons; + + btype = bt_get_or_create("castle"); + btype->flags |= BTF_FORTIFICATION; + cons = btype->construction = calloc(1, sizeof(construction)); + cons->maxsize = 5; + cons = cons->improvement = calloc(1, sizeof(construction)); + cons->maxsize = -1; + return btype; +} + static void test_defenders_get_building_bonus(CuTest * tc) { unit *du, *au; @@ -72,16 +85,13 @@ static void test_defenders_get_building_bonus(CuTest * tc) fighter *df, *af; battle *b; side *ds, *as; - int diff; troop dt, at; building_type * btype; test_cleanup(); + btype = setup_castle(); r = test_create_region(0, 0, 0); - btype = bt_get_or_create("castle"); - btype->protection = &add_two; bld = test_create_building(r, btype); - bld->size = 10; du = test_create_unit(test_create_faction(NULL), r); au = test_create_unit(test_create_faction(NULL), r); @@ -101,11 +111,14 @@ static void test_defenders_get_building_bonus(CuTest * tc) at.fighter = af; at.index = 0; - diff = skilldiff(at, dt, 0); - CuAssertIntEquals(tc, -2, diff); + bld->size = 10; /* stage 1 building */ + CuAssertIntEquals(tc, -1, skilldiff(at, dt, 0)); + CuAssertIntEquals(tc, 0, skilldiff(dt, at, 0)); + + bld->size = 1; /* stage 0 building */ + CuAssertIntEquals(tc, 0, skilldiff(at, dt, 0)); + CuAssertIntEquals(tc, 0, skilldiff(dt, at, 0)); - diff = skilldiff(dt, at, 0); - CuAssertIntEquals(tc, 0, diff); free_battle(b); test_cleanup(); } @@ -122,8 +135,8 @@ static void test_attackers_get_no_building_bonus(CuTest * tc) test_cleanup(); r = test_create_region(0, 0, 0); - btype = bt_get_or_create("castle"); - btype->protection = &add_two; + btype = setup_castle(); + btype->flags |= BTF_FORTIFICATION; bld = test_create_building(r, btype); bld->size = 10; @@ -151,9 +164,9 @@ static void test_building_bonus_respects_size(CuTest * tc) faction * f; test_cleanup(); + btype = setup_castle(); r = test_create_region(0, 0, 0); - btype = bt_get_or_create("castle"); - btype->protection = &add_two; + btype->flags |= BTF_FORTIFICATION; bld = test_create_building(r, btype); bld->size = 10; @@ -178,28 +191,25 @@ static void test_building_bonus_respects_size(CuTest * tc) static void test_building_defence_bonus(CuTest * tc) { - unit *au; - region *r; - building * bld; building_type * btype; - faction * f; - int def; test_cleanup(); - r = test_create_region(0, 0, 0); - btype = test_create_buildingtype("castle"); - btype->protection = (int(*)(const struct building *, const struct unit *, building_bonus))get_function("building_protection"); - btype->construction->defense_bonus = 3; - bld = test_create_building(r, btype); - bld->size = 1; + btype = setup_castle(); - f = test_create_faction(NULL); - au = test_create_unit(f, r); - scale_number(au, 1); - u_set_building(au, bld); + btype->maxsize = -1; /* unlimited buildigs get the castle bonus */ + CuAssertIntEquals(tc, 0, building_protection(btype, 0)); + CuAssertIntEquals(tc, 1, building_protection(btype, 1)); + CuAssertIntEquals(tc, 3, building_protection(btype, 2)); + CuAssertIntEquals(tc, 5, building_protection(btype, 3)); + CuAssertIntEquals(tc, 8, building_protection(btype, 4)); + CuAssertIntEquals(tc, 12, building_protection(btype, 5)); + CuAssertIntEquals(tc, 12, building_protection(btype, 6)); - def = btype->protection(bld, au, DEFENSE_BONUS); - CuAssertIntEquals(tc, 3, def); + btype->maxsize = 10; /* limited-size buildings are treated like an E3 watchtower */ + CuAssertIntEquals(tc, 0, building_protection(btype, 0)); + CuAssertIntEquals(tc, 1, building_protection(btype, 1)); + CuAssertIntEquals(tc, 2, building_protection(btype, 2)); + CuAssertIntEquals(tc, 2, building_protection(btype, 3)); test_cleanup(); } @@ -441,10 +451,6 @@ static void test_battle_skilldiff(CuTest *tc) test_cleanup(); } -static int protect(const building *b, const unit *u, building_bonus bonus) { - return (bonus == DEFENSE_BONUS) ? 4 : 0; -} - static void test_battle_skilldiff_building(CuTest *tc) { troop ta, td; @@ -455,7 +461,7 @@ static void test_battle_skilldiff_building(CuTest *tc) const curse_type *strongwall_ct, *magicwalls_ct; test_cleanup(); - btype = test_create_buildingtype("castle"); + btype = setup_castle(); strongwall_ct = ct_find("strongwall"); magicwalls_ct = ct_find("magicwalls"); @@ -470,14 +476,14 @@ static void test_battle_skilldiff_building(CuTest *tc) ua = test_create_unit(test_create_faction(0), r); CuAssertIntEquals(tc, 0, skilldiff(ta, td, 0)); - btype->protection = protect; - CuAssertIntEquals(tc, -4, skilldiff(ta, td, 0)); + ud->building->size = 10; + CuAssertIntEquals(tc, -1, skilldiff(ta, td, 0)); create_curse(NULL, &ud->building->attribs, magicwalls_ct, 1, 1, 1, 1); - CuAssertIntEquals(tc, -8, skilldiff(ta, td, 0)); + CuAssertIntEquals(tc, -2, skilldiff(ta, td, 0)); create_curse(NULL, &ud->building->attribs, strongwall_ct, 1, 1, 2, 1); - CuAssertIntEquals(tc, -10, skilldiff(ta, td, 0)); + CuAssertIntEquals(tc, -4, skilldiff(ta, td, 0)); free_battle(b); test_cleanup(); diff --git a/src/kernel/build.h b/src/kernel/build.h index 38fefb88a..7780a6cd2 100644 --- a/src/kernel/build.h +++ b/src/kernel/build.h @@ -45,9 +45,6 @@ extern "C" { int maxsize; /* maximum size of this type */ int reqsize; /* size of object using up 1 set of requirement. */ - int defense_bonus; /* protection bonus (defense) during combat */ - int close_combat_bonus; /* close combat attack bonus*/ - int ranged_bonus; /* ranged attack bonus */ requirement *materials; /* material req'd to build one object */ const struct building_type *btype; /* building type required to make this thing */ diff --git a/src/kernel/building.c b/src/kernel/building.c index 06078aaba..3c21f4dbe 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -337,40 +337,24 @@ const building_type *findbuildingtype(const char *name, int cmp_castle_size(const building * b, const building * a) { - if (!b || !b->type->protection || !building_owner(b)) { + if (!b || !(b->type->flags & BTF_FORTIFICATION) || !building_owner(b)) { return -1; } - if (!a || !a->type->protection || !building_owner(a)) { + if (!a || !(a->type->flags & BTF_FORTIFICATION) || !building_owner(a)) { return 1; } return b->size - a->size; } -int building_protection(const building * b, const unit * u, building_bonus bonus) +static const int castle_bonus[6] = { 0, 1, 3, 5, 8, 12 }; +static const int watch_bonus[3] = { 0, 1, 2 }; + +int building_protection(const building_type * btype, int stage) { - int i = 0; - int bsize = buildingeffsize(b, false); - const construction *cons = b->type->construction; - if (!cons) { - return 0; - } - - for (i = 0; i < bsize; i++) - { - cons = cons->improvement; - } - - switch (bonus) - { - case DEFENSE_BONUS: - return cons->defense_bonus; - case CLOSE_COMBAT_ATTACK_BONUS: - return cons->close_combat_bonus; - case RANGED_ATTACK_BONUS: - return cons->ranged_bonus; - default: - return 0; + if (btype->maxsize < 0) { + return castle_bonus[MIN(stage, 5)]; } + return watch_bonus[MIN(stage, 2)]; } void write_building_reference(const struct building *b, struct storage *store) @@ -925,8 +909,6 @@ int cmp_current_owner(const building * b, const building * a) void register_buildings(void) { register_function((pf_generic)minimum_wage, "minimum_wage"); - register_function((pf_generic)building_protection, - "building_protection"); register_function((pf_generic)init_smithy, "init_smithy"); register_function((pf_generic)castle_name, "castle_name"); register_function((pf_generic)castle_name_2, "castle_name_2"); diff --git a/src/kernel/building.h b/src/kernel/building.h index 1adce7e09..8c23fdb7c 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -51,13 +51,7 @@ extern "C" { #define BTF_MAGIC 0x40 /* magical effect */ #define BTF_ONEPERTURN 0x80 /* one one sizepoint can be added per turn */ #define BTF_NAMECHANGE 0x100 /* name and description can be changed more than once */ -#define BTF_FORTIFICATION 0x200 /* safe from monsters */ - - typedef enum { - DEFENSE_BONUS, - CLOSE_COMBAT_ATTACK_BONUS, /* TODO: only DEFENSE_BONUS is in use? */ - RANGED_ATTACK_BONUS - } building_bonus; +#define BTF_FORTIFICATION 0x200 /* building_protection, safe from monsters */ typedef struct building_type { char *_name; @@ -77,7 +71,6 @@ extern "C" { const struct building * b, int size); void(*init) (struct building_type *); void(*age) (struct building *); - int(*protection) (const struct building *, const struct unit *, building_bonus bonus); double(*taxes) (const struct building *, int size); struct attrib *attribs; } building_type; @@ -85,8 +78,8 @@ extern "C" { extern struct selist *buildingtypes; extern struct attrib_type at_building_action; - int cmp_castle_size(const struct building * b, const struct building * a); - int building_protection(const struct building * b, const struct unit * u, building_bonus bonus); + int cmp_castle_size(const struct building *b, const struct building *a); + int building_protection(const struct building_type *btype, int stage); building_type *bt_get_or_create(const char *name); bool bt_changed(int *cache); const building_type *bt_find(const char *name); diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index e02d16556..4395f1c40 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -376,7 +376,6 @@ static void test_btype_defaults(CuTest *tc) { CuAssertTrue(tc, !btype->name); CuAssertTrue(tc, !btype->init); CuAssertTrue(tc, !btype->age); - CuAssertTrue(tc, !btype->protection); CuAssertTrue(tc, !btype->taxes); CuAssertDblEquals(tc, 1.0, btype->auraregen, 0.0); CuAssertIntEquals(tc, -1, btype->maxsize); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 695f91d69..555c0f679 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -167,9 +167,6 @@ construction ** consPtr) con->maxsize = xml_ivalue(node, "maxsize", -1); con->minskill = xml_ivalue(node, "minskill", -1); con->reqsize = xml_ivalue(node, "reqsize", 1); - con->defense_bonus = xml_ivalue(node, "defense_bonus", 0); - con->close_combat_bonus = xml_ivalue(node, "close_combat_bonus", 0); - con->ranged_bonus = xml_ivalue(node, "ranged_bonus", 0); propValue = xmlGetProp(node, BAD_CAST "building"); if (propValue != NULL) { @@ -301,9 +298,6 @@ static int parse_buildings(xmlDocPtr doc) else if (strcmp((const char *)propValue, "age") == 0) { btype->age = (void(*)(struct building *))fun; } - else if (strcmp((const char *)propValue, "protection") == 0) { - btype->protection = (int(*)(const struct building *, const struct unit *, building_bonus))fun; - } else if (strcmp((const char *)propValue, "taxes") == 0) { btype->taxes = (double(*)(const struct building *, int))fun; } diff --git a/src/tests.c b/src/tests.c index 6a43e6e79..c448a27ae 100644 --- a/src/tests.c +++ b/src/tests.c @@ -230,7 +230,7 @@ building * test_create_building(region * r, const building_type * btype) assert(r); if (!btype) { building_type *bt_castle = test_create_buildingtype("castle"); - bt_castle->protection = building_protection; + bt_castle->flags |= BTF_FORTIFICATION; btype = bt_castle; } b = new_building(btype, r, default_locale); From 82e4d754292478e82af1202524d7ba04293f0fe9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 22 Feb 2017 19:43:17 +0100 Subject: [PATCH 557/675] unused function --- src/battle.test.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/battle.test.c b/src/battle.test.c index 987613277..109561161 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -60,10 +60,6 @@ static void test_make_fighter(CuTest * tc) test_cleanup(); } -static int add_two(const building * b, const unit * u) { - return 2; -} - static building_type * setup_castle(void) { building_type * btype; construction *cons; From 67831ad7083fb4af108a373a3ae3e18a38c418ea Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 22 Feb 2017 20:16:51 +0100 Subject: [PATCH 558/675] we like test_setup. --- src/battle.test.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/battle.test.c b/src/battle.test.c index 109561161..d15c335a9 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -26,7 +26,7 @@ static void test_make_fighter(CuTest * tc) faction * f; const resource_type *rtype; - test_cleanup(); + test_setup(); test_create_horse(); r = test_create_region(0, 0, 0); f = test_create_faction(NULL); @@ -84,7 +84,7 @@ static void test_defenders_get_building_bonus(CuTest * tc) troop dt, at; building_type * btype; - test_cleanup(); + test_setup(); btype = setup_castle(); r = test_create_region(0, 0, 0); bld = test_create_building(r, btype); @@ -129,7 +129,7 @@ static void test_attackers_get_no_building_bonus(CuTest * tc) side *as; building_type * btype; - test_cleanup(); + test_setup(); r = test_create_region(0, 0, 0); btype = setup_castle(); btype->flags |= BTF_FORTIFICATION; @@ -159,7 +159,7 @@ static void test_building_bonus_respects_size(CuTest * tc) building_type * btype; faction * f; - test_cleanup(); + test_setup(); btype = setup_castle(); r = test_create_region(0, 0, 0); btype->flags |= BTF_FORTIFICATION; @@ -189,7 +189,7 @@ static void test_building_defence_bonus(CuTest * tc) { building_type * btype; - test_cleanup(); + test_setup(); btype = setup_castle(); btype->maxsize = -1; /* unlimited buildigs get the castle bonus */ @@ -225,7 +225,7 @@ static void test_natural_armor(CuTest * tc) race *rc; unit *u; - test_cleanup(); + test_setup(); rc = test_create_race("human"); u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); set_level(u, SK_STAMINA, 2); @@ -252,7 +252,7 @@ static void test_calculate_armor(CuTest * tc) race *rc; double magres = 0.0; - test_cleanup(); + test_setup(); r = test_create_region(0, 0, 0); ibelt = it_get_or_create(rt_get_or_create("trollbelt")); ishield = it_get_or_create(rt_get_or_create("shield")); @@ -321,7 +321,7 @@ static void test_magic_resistance(CuTest *tc) race *rc; double magres; - test_cleanup(); + test_setup(); r = test_create_region(0, 0, 0); ishield = it_get_or_create(rt_get_or_create("shield")); ashield = new_armortype(ishield, 0.0, 0.5, 1, ATF_SHIELD); @@ -386,7 +386,7 @@ static void test_projectile_armor(CuTest * tc) item_type *ishield, *ichain; race *rc; - test_cleanup(); + test_setup(); r = test_create_region(0, 0, 0); ishield = it_get_or_create(rt_get_or_create("shield")); ashield = new_armortype(ishield, 0.0, 0.5, 1, ATF_SHIELD); @@ -420,7 +420,7 @@ static void test_battle_skilldiff(CuTest *tc) unit *ua, *ud; battle *b = NULL; - test_cleanup(); + test_setup(); r = test_create_region(0, 0, 0); ud = test_create_unit(test_create_faction(0), r); @@ -456,7 +456,7 @@ static void test_battle_skilldiff_building(CuTest *tc) building_type *btype; const curse_type *strongwall_ct, *magicwalls_ct; - test_cleanup(); + test_setup(); btype = setup_castle(); strongwall_ct = ct_find("strongwall"); magicwalls_ct = ct_find("magicwalls"); From ce2ea95880aef67ff52c1dd773f8b5bcbd41b576 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 22 Feb 2017 20:28:34 +0100 Subject: [PATCH 559/675] begin refactoring limited resources. --- src/economy.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/economy.c b/src/economy.c index 94a1a90fa..f98d0f8e1 100644 --- a/src/economy.c +++ b/src/economy.c @@ -914,6 +914,11 @@ struct message * get_modifiers(unit *u, const resource_mod *mod, variant *savep, return NULL; } +static resource_limit *get_resourcelimit(const resource_type *rtype) { + attrib *a = a_find(rtype->attribs, &at_resourcelimit); + return a ? (resource_limit *)a->data.v : NULL; +} + static void allocate_resource(unit * u, const resource_type * rtype, int want) { const item_type *itype = resource2item(rtype); @@ -921,8 +926,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) int dm = 0; allocation_list *alist; allocation *al; - attrib *a = a_find(rtype->attribs, &at_resourcelimit); - resource_limit *rdata = (resource_limit *)a->data.v; + resource_limit *rdata = get_resourcelimit(rtype); const resource_type *rring; int amount, skill, skill_mod = 0; variant save_mod; @@ -1119,8 +1123,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) { allocation *al; int nreq = 0; - attrib *a = a_find(rtype->attribs, &at_resourcelimit); - resource_limit *rdata = (resource_limit *)a->data.v; + resource_limit *rdata = get_resourcelimit(rtype); int avail = rdata->value; for (al = alist; al; al = al->next) { @@ -1160,10 +1163,9 @@ typedef void(*allocate_function) (const resource_type *, struct region *, static allocate_function get_allocator(const struct resource_type *rtype) { - attrib *a = a_find(rtype->attribs, &at_resourcelimit); + resource_limit *rdata = get_resourcelimit(rtype); - if (a != NULL) { - resource_limit *rdata = (resource_limit *)a->data.v; + if (rdata) { if (rdata->value > 0 || rdata->limit != NULL) { return attrib_allocation; } From 1498f2e1d772a5c4c51ce96348e1c5d07611aac8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 22 Feb 2017 21:10:22 +0100 Subject: [PATCH 560/675] refactor rawmaterial_type. still have to decide if we need it at all. --- src/economy.c | 3 +-- src/economy.test.c | 7 +++---- src/items/seed.c | 12 ++++-------- src/kernel/item.c | 16 ---------------- src/kernel/item.h | 24 +++++------------------- src/kernel/resources.c | 12 ++++++------ src/kernel/resources.h | 24 +++++++++++++++++++++++- src/kernel/xmlreader.c | 19 +++++++------------ 8 files changed, 49 insertions(+), 68 deletions(-) diff --git a/src/economy.c b/src/economy.c index f98d0f8e1..f0a693eca 100644 --- a/src/economy.c +++ b/src/economy.c @@ -915,8 +915,7 @@ struct message * get_modifiers(unit *u, const resource_mod *mod, variant *savep, } static resource_limit *get_resourcelimit(const resource_type *rtype) { - attrib *a = a_find(rtype->attribs, &at_resourcelimit); - return a ? (resource_limit *)a->data.v : NULL; + return rtype->limit; } static void allocate_resource(unit * u, const resource_type * rtype, int want) diff --git a/src/economy.test.c b/src/economy.test.c index 766fb4302..c67237c40 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -348,7 +348,7 @@ static void test_make_item(CuTest *tc) { struct item_type *itype; const struct resource_type *rt_silver; resource_type *rtype; - attrib *a; + rawmaterial_type *rmt; resource_limit *rdata; double d = 0.6; @@ -382,10 +382,9 @@ static void test_make_item(CuTest *tc) { free(itype->construction->materials); itype->construction->materials = 0; rtype->flags |= RTF_LIMITED; - a = a_add(&rtype->attribs, a_new(&at_resourcelimit)); - rdata = (resource_limit *)a->data.v; + rmt = rmt_create(rtype, "rm_stone"); + rdata = rtype->limit = calloc(1, sizeof(resource_limit)); rdata->value = 0; - rmt_create(rtype, "stone"); add_resource(u->region, 1, 300, 150, rtype); u->region->resources->amount = 300; /* there are 300 stones at level 1 */ set_level(u, SK_ALCHEMY, 10); diff --git a/src/items/seed.c b/src/items/seed.c index f17e8ed29..334c6a05d 100644 --- a/src/items/seed.c +++ b/src/items/seed.c @@ -24,6 +24,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include /* util includes */ #include @@ -31,6 +32,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* libc includes */ #include +#include static void produce_seeds(region * r, const resource_type * rtype, int norders) { @@ -48,14 +50,11 @@ static int limit_seeds(const region * r, const resource_type * rtype) void init_seed(void) { - attrib *a; - resource_limit *rdata; resource_type *rtype; rtype = rt_find("seed"); if (rtype != NULL) { - a = a_add(&rtype->attribs, a_new(&at_resourcelimit)); - rdata = (resource_limit *)a->data.v; + resource_limit *rdata = rtype->limit = calloc(1, sizeof(resource_limit)); rdata->limit = limit_seeds; rdata->produce = produce_seeds; } @@ -80,17 +79,14 @@ static int limit_mallornseeds(const region * r, const resource_type * rtype) void init_mallornseed(void) { - attrib *a; - resource_limit *rdata; resource_type *rtype; rtype = rt_find("mallornseed"); if (rtype != NULL) { + resource_limit *rdata = rtype->limit = calloc(1, sizeof(resource_limit)); rtype->flags |= RTF_LIMITED; rtype->flags |= RTF_POOLED; - a = a_add(&rtype->attribs, a_new(&at_resourcelimit)); - rdata = (resource_limit *)a->data.v; rdata->limit = limit_mallornseeds; rdata->produce = produce_mallornseeds; } diff --git a/src/kernel/item.c b/src/kernel/item.c index c37e3d40c..5beac7189 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -1159,22 +1159,6 @@ const item_type *finditemtype(const char *name, const struct locale *lang) return 0; } -static void init_resourcelimit(attrib * a) -{ - a->data.v = calloc(sizeof(resource_limit), 1); -} - -static void finalize_resourcelimit(attrib * a) -{ - free(a->data.v); -} - -attrib_type at_resourcelimit = { - "resourcelimit", - init_resourcelimit, - finalize_resourcelimit, -}; - item *item_spoil(const struct race *rc, int size) { item *itm = NULL; diff --git a/src/kernel/item.h b/src/kernel/item.h index 79e6f103d..1d3e5ff29 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -29,6 +29,7 @@ extern "C" { struct unit; struct attrib; struct attrib_type; + struct race; struct region; struct resource_type; struct locale; @@ -37,6 +38,8 @@ extern "C" { struct order; struct storage; struct gamedata; + struct rawmaterial_type; + struct resource_limit; typedef struct item { struct item *next; @@ -76,6 +79,8 @@ extern "C" { rtype_uchange uchange; rtype_uget uget; rtype_name name; + struct rawmaterial_type *raw; + struct resource_limit *limit; /* --- pointers --- */ struct attrib *attribs; struct item_type *itype; @@ -94,25 +99,6 @@ extern "C" { #define RMF_SAVEMATERIAL 0x02 /* fraction (sa[0]/sa[1]), multiplier on resource usage */ #define RMF_REQUIREDBUILDING 0x04 /* building, required to build */ - typedef struct resource_mod { - variant value; - const struct building_type *btype; - const struct race *race; - unsigned int flags; - } resource_mod; - - extern struct attrib_type at_resourcelimit; - typedef int(*rlimit_limit) (const struct region * r, - const struct resource_type * rtype); - typedef void(*rlimit_produce) (struct region * r, - const struct resource_type * rtype, int n); - typedef struct resource_limit { - rlimit_limit limit; - rlimit_produce produce; - int value; - resource_mod *modifiers; - } resource_limit; - /* bitfield values for item_type::flags */ #define ITF_NONE 0x0000 #define ITF_HERB 0x0001 /* this item is a herb */ diff --git a/src/kernel/resources.c b/src/kernel/resources.c index e32c7ad55..d02153e8f 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -195,16 +195,16 @@ struct rawmaterial_type *rmt_find(const char *str) struct rawmaterial_type *rmt_get(const struct resource_type *rtype) { - rawmaterial_type *rmt = rawmaterialtypes; - while (rmt && rmt->rtype != rtype) - rmt = rmt->next; - return rmt; + return rtype->raw; } -struct rawmaterial_type *rmt_create(const struct resource_type *rtype, +struct rawmaterial_type *rmt_create(struct resource_type *rtype, const char *name) { - rawmaterial_type *rmtype = malloc(sizeof(rawmaterial_type)); + rawmaterial_type *rmtype; + + assert(!rtype->raw); + rmtype = rtype->raw = malloc(sizeof(rawmaterial_type)); rmtype->name = strdup(name); rmtype->rtype = rtype; rmtype->terraform = terraform_default; diff --git a/src/kernel/resources.h b/src/kernel/resources.h index a1a7abd40..dd4cfd664 100644 --- a/src/kernel/resources.h +++ b/src/kernel/resources.h @@ -15,6 +15,9 @@ extern "C" { #endif + struct building_type; + struct race; + enum { RM_USED = 1 << 0, /* resource has been used */ RM_MALLORN = 1 << 1 /* this is not wood. it's mallorn */ @@ -40,6 +43,25 @@ extern "C" { struct rawmaterial *next; } rawmaterial; + typedef int(*rlimit_limit) (const struct region * r, + const struct resource_type * rtype); + typedef void(*rlimit_produce) (struct region * r, + const struct resource_type * rtype, int n); + + typedef struct resource_mod { + variant value; + const struct building_type *btype; + const struct race *race; + unsigned int flags; + } resource_mod; + + typedef struct resource_limit { + rlimit_limit limit; + rlimit_produce produce; + int value; + resource_mod *modifiers; + } resource_limit; + typedef struct rawmaterial_type { char *name; const struct resource_type *rtype; @@ -64,7 +86,7 @@ extern "C" { void add_resource(struct region *r, int level, int base, int divisor, const struct resource_type *rtype); - struct rawmaterial_type *rmt_create(const struct resource_type *rtype, + struct rawmaterial_type *rmt_create(struct resource_type *rtype, const char *name); #ifdef __cplusplus diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 555c0f679..2d08f40a4 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -949,12 +949,6 @@ static int parse_resources(xmlDocPtr doc) rtype->flags |= flags; xmlFree(name); - name = xmlGetProp(node, BAD_CAST "material"); - if (name) { - rmt_create(rtype, (const char *)name); - xmlFree(name); - } - /* reading eressea/resources/resource/function */ xpath->node = node; result = xmlXPathEvalExpression(BAD_CAST "function", xpath); @@ -987,18 +981,20 @@ static int parse_resources(xmlDocPtr doc) } xmlXPathFreeObject(result); + name = xmlGetProp(node, BAD_CAST "material"); + if (name) { + rmt_create(rtype, (const char *)name); + xmlFree(name); + } + /* reading eressea/resources/resource/resourcelimit */ xpath->node = node; result = xmlXPathEvalExpression(BAD_CAST "resourcelimit", xpath); assert(result->nodesetval->nodeNr <= 1); if (result->nodesetval->nodeNr != 0) { - resource_limit *rdata; - attrib *a = a_find(rtype->attribs, &at_resourcelimit); + resource_limit *rdata = rtype->limit = calloc(1, sizeof(resource_limit)); xmlNodePtr limit = result->nodesetval->nodeTab[0]; - if (a == NULL) - a = a_add(&rtype->attribs, a_new(&at_resourcelimit)); - rdata = (resource_limit *)a->data.v; rtype->flags |= RTF_LIMITED; xpath->node = limit; xmlXPathFreeObject(result); @@ -1095,7 +1091,6 @@ static int parse_resources(xmlDocPtr doc) } } xmlXPathFreeObject(result); - /* reading eressea/resources/resource/resourcelimit/function */ xpath->node = node; result = xmlXPathEvalExpression(BAD_CAST "resourcelimit/function", xpath); From f4dc88c3be008c9a4c3517c93d6284697789664d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 23 Feb 2017 07:53:28 +0100 Subject: [PATCH 561/675] strip rawmaterial_type to just the funpointers --- src/kernel/item.c | 3 +++ src/kernel/resources.c | 14 +++++--------- src/kernel/resources.h | 4 ---- src/kernel/save.c | 2 +- src/reports.c | 12 ++++++------ 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/kernel/item.c b/src/kernel/item.c index 5beac7189..9bc321fdb 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -1242,6 +1242,9 @@ void free_rtype(resource_type *rtype) { if (rtype->itype) { free_itype(rtype->itype); } + if (rtype->raw) { + free(rtype->raw); + } free(rtype->_name); free(rtype); } diff --git a/src/kernel/resources.c b/src/kernel/resources.c index d02153e8f..1261417f1 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -183,14 +183,13 @@ struct rawmaterial *rm_get(region * r, const struct resource_type *rtype) return rm; } -struct rawmaterial_type *rawmaterialtypes = 0; - struct rawmaterial_type *rmt_find(const char *str) { - rawmaterial_type *rmt = rawmaterialtypes; - while (rmt && strcmp(rmt->name, str) != 0) - rmt = rmt->next; - return rmt; + resource_type *rtype = rt_find(str); + if (!rtype && strncmp(str, "rm_", 3) == 0) { + rtype = rt_find(str+3); + } + return rtype ? rtype->raw : NULL; } struct rawmaterial_type *rmt_get(const struct resource_type *rtype) @@ -205,13 +204,10 @@ struct rawmaterial_type *rmt_create(struct resource_type *rtype, assert(!rtype->raw); rmtype = rtype->raw = malloc(sizeof(rawmaterial_type)); - rmtype->name = strdup(name); rmtype->rtype = rtype; rmtype->terraform = terraform_default; rmtype->update = NULL; rmtype->use = use_default; rmtype->visible = visible_default; - rmtype->next = rawmaterialtypes; - rawmaterialtypes = rmtype; return rmtype; } diff --git a/src/kernel/resources.h b/src/kernel/resources.h index dd4cfd664..9d248c0f8 100644 --- a/src/kernel/resources.h +++ b/src/kernel/resources.h @@ -63,16 +63,12 @@ extern "C" { } resource_limit; typedef struct rawmaterial_type { - char *name; const struct resource_type *rtype; void(*terraform) (struct rawmaterial *, const struct region *); void(*update) (struct rawmaterial *, const struct region *); void(*use) (struct rawmaterial *, const struct region *, int amount); int(*visible) (const struct rawmaterial *, int skilllevel); - - /* no initialization required */ - struct rawmaterial_type *next; } rawmaterial_type; extern struct rawmaterial_type *rawmaterialtypes; diff --git a/src/kernel/save.c b/src/kernel/save.c index d4045d05f..21ec98e76 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1068,7 +1068,7 @@ void writeregion(struct gamedata *data, const region * r) WRITE_INT(data->store, rhorses(r)); while (res) { - WRITE_TOK(data->store, res->type->name); + WRITE_TOK(data->store, res->type->rtype->_name); WRITE_INT(data->store, res->level); WRITE_INT(data->store, res->amount); WRITE_INT(data->store, res->startlevel); diff --git a/src/reports.c b/src/reports.c index a49957b9d..a70219b0b 100644 --- a/src/reports.c +++ b/src/reports.c @@ -412,32 +412,32 @@ const faction * viewer, bool see_unit) if (money) { if (n >= size) return -1; - report_resource(result + n, "rm_money", money, -1); + report_resource(result + n, "money", money, -1); ++n; } if (peasants) { if (n >= size) return -1; - report_resource(result + n, "rm_peasant", peasants, -1); + report_resource(result + n, "peasant", peasants, -1); ++n; } if (horses) { if (n >= size) return -1; - report_resource(result + n, "rm_horse", horses, -1); + report_resource(result + n, "horse", horses, -1); ++n; } if (saplings) { if (n >= size) return -1; - report_resource(result + n, mallorn ? "rm_mallornsapling" : "rm_sapling", + report_resource(result + n, mallorn ? "mallornsapling" : "sapling", saplings, -1); ++n; } if (trees) { if (n >= size) return -1; - report_resource(result + n, mallorn ? "rm_mallorn" : "rm_tree", trees, + report_resource(result + n, mallorn ? "mallorn" : "tree", trees, -1); ++n; } @@ -469,7 +469,7 @@ const faction * viewer, bool see_unit) if (level >= 0 && visible >= 0) { if (n >= size) return -1; - report_resource(result + n, res->type->name, visible, level); + report_resource(result + n, res->type->rtype->_name, visible, level); n++; } res = res->next; From be42137833d87889df5f157720df80432ba5746d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 23 Feb 2017 08:02:24 +0100 Subject: [PATCH 562/675] fix rmt_find for trees --- src/economy.test.c | 2 +- src/kernel/resources.c | 16 +++++++++++++--- src/kernel/resources.h | 3 +-- src/kernel/xmlreader.c | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/economy.test.c b/src/economy.test.c index c67237c40..2de6265f0 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -382,7 +382,7 @@ static void test_make_item(CuTest *tc) { free(itype->construction->materials); itype->construction->materials = 0; rtype->flags |= RTF_LIMITED; - rmt = rmt_create(rtype, "rm_stone"); + rmt = rmt_create(rtype); rdata = rtype->limit = calloc(1, sizeof(resource_limit)); rdata->value = 0; add_resource(u->region, 1, 300, 150, rtype); diff --git a/src/kernel/resources.c b/src/kernel/resources.c index 1261417f1..e8be234a1 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -185,10 +185,21 @@ struct rawmaterial *rm_get(region * r, const struct resource_type *rtype) struct rawmaterial_type *rmt_find(const char *str) { + const char * replace[] = { "rm_tree", "log", NULL }; resource_type *rtype = rt_find(str); if (!rtype && strncmp(str, "rm_", 3) == 0) { - rtype = rt_find(str+3); + int i; + for (i = 0; replace[i]; i+=2) { + if (strcmp(replace[i], str) == 0) { + rtype = rt_find(replace[i+1]); + break; + } + } + if (!rtype) { + rtype = rt_find(str+3); + } } + assert(rtype); return rtype ? rtype->raw : NULL; } @@ -197,8 +208,7 @@ struct rawmaterial_type *rmt_get(const struct resource_type *rtype) return rtype->raw; } -struct rawmaterial_type *rmt_create(struct resource_type *rtype, - const char *name) +struct rawmaterial_type *rmt_create(struct resource_type *rtype) { rawmaterial_type *rmtype; diff --git a/src/kernel/resources.h b/src/kernel/resources.h index 9d248c0f8..3e93ea1de 100644 --- a/src/kernel/resources.h +++ b/src/kernel/resources.h @@ -82,8 +82,7 @@ extern "C" { void add_resource(struct region *r, int level, int base, int divisor, const struct resource_type *rtype); - struct rawmaterial_type *rmt_create(struct resource_type *rtype, - const char *name); + struct rawmaterial_type *rmt_create(struct resource_type *rtype); #ifdef __cplusplus } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 2d08f40a4..9ba05e101 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -983,7 +983,7 @@ static int parse_resources(xmlDocPtr doc) name = xmlGetProp(node, BAD_CAST "material"); if (name) { - rmt_create(rtype, (const char *)name); + rmt_create(rtype); xmlFree(name); } From 9cbd5b88e6bf64f1f451a3e831bcb851181bfdc2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 23 Feb 2017 08:07:47 +0100 Subject: [PATCH 563/675] rm_tree is not actually a thing --- src/kernel/resources.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/kernel/resources.c b/src/kernel/resources.c index e8be234a1..ae93d542a 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -185,19 +185,9 @@ struct rawmaterial *rm_get(region * r, const struct resource_type *rtype) struct rawmaterial_type *rmt_find(const char *str) { - const char * replace[] = { "rm_tree", "log", NULL }; resource_type *rtype = rt_find(str); if (!rtype && strncmp(str, "rm_", 3) == 0) { - int i; - for (i = 0; replace[i]; i+=2) { - if (strcmp(replace[i], str) == 0) { - rtype = rt_find(replace[i+1]); - break; - } - } - if (!rtype) { - rtype = rt_find(str+3); - } + rtype = rt_find(str+3); } assert(rtype); return rtype ? rtype->raw : NULL; From 5e2903258c64ce4b12ce0db3b5ca8f142ef91124 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 23 Feb 2017 14:45:19 +0100 Subject: [PATCH 564/675] kill old element from XML --- res/adamantium.xml | 1 - res/core/resources/mallorn.xml | 1 - res/e3a/resources/iron.xml | 1 - 3 files changed, 3 deletions(-) diff --git a/res/adamantium.xml b/res/adamantium.xml index cc1cedadc..decc5636c 100644 --- a/res/adamantium.xml +++ b/res/adamantium.xml @@ -7,7 +7,6 @@ - diff --git a/res/core/resources/mallorn.xml b/res/core/resources/mallorn.xml index 2d301758e..fc678e79e 100644 --- a/res/core/resources/mallorn.xml +++ b/res/core/resources/mallorn.xml @@ -6,7 +6,6 @@ - diff --git a/res/e3a/resources/iron.xml b/res/e3a/resources/iron.xml index b245da358..06b70e45a 100644 --- a/res/e3a/resources/iron.xml +++ b/res/e3a/resources/iron.xml @@ -6,6 +6,5 @@ - From f06d86007c35780f1164405435b7320416fe32e1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 23 Feb 2017 22:08:16 +0100 Subject: [PATCH 565/675] seed normalization (broken) --- res/core/resources/mallornseed.xml | 4 ++ res/core/resources/seed.xml | 4 ++ res/e3a/resources/seed.xml | 8 ++- scripts/eressea/resources.lua | 46 +++++++++++++-- scripts/tests/common.lua | 62 ++++++++++++-------- src/eressea.c | 9 ++- src/gmtool.c | 1 - src/items/CMakeLists.txt | 2 - src/items/itemtypes.c | 33 ----------- src/items/itemtypes.h | 25 -------- src/items/seed.c | 93 ------------------------------ src/items/seed.h | 31 ---------- src/kernel/xmlreader.c | 4 +- 13 files changed, 102 insertions(+), 220 deletions(-) delete mode 100644 src/items/itemtypes.c delete mode 100644 src/items/itemtypes.h delete mode 100644 src/items/seed.c delete mode 100644 src/items/seed.h diff --git a/res/core/resources/mallornseed.xml b/res/core/resources/mallornseed.xml index 7a5a0310f..01b8a3416 100644 --- a/res/core/resources/mallornseed.xml +++ b/res/core/resources/mallornseed.xml @@ -3,4 +3,8 @@ + + + + diff --git a/res/core/resources/seed.xml b/res/core/resources/seed.xml index 99f5f5804..2bda26eeb 100644 --- a/res/core/resources/seed.xml +++ b/res/core/resources/seed.xml @@ -3,4 +3,8 @@ + + + + diff --git a/res/e3a/resources/seed.xml b/res/e3a/resources/seed.xml index 21652f364..2bda26eeb 100644 --- a/res/e3a/resources/seed.xml +++ b/res/e3a/resources/seed.xml @@ -1,4 +1,10 @@ - + + + + + + + diff --git a/scripts/eressea/resources.lua b/scripts/eressea/resources.lua index 94908c1ab..2829d00c7 100644 --- a/scripts/eressea/resources.lua +++ b/scripts/eressea/resources.lua @@ -38,8 +38,47 @@ function hp_changeresource(u, delta) return hp end +local function mallorn_region(r) + return r:get_flag(1) -- RF_MALLORN +end + +function seed_limit(r) + if mallorn_region(r) then + return 0 + end + return r:get_resource("seed") +end + +function seed_produce(r, n) + if not mallorn_region(r) then + local seeds = r:get_resource("seed") + if seeds>=n then + r:set_resource("seed", seeds-n) + else + r:set_resource("seed", 0) + end + end +end + +function mallornseed_limit(r) + if mallorn_region(r) then + return r:get_resource("seed") + end + return 0 +end + +function mallornseed_produce(r, n) + if mallorn_region(r) then + local seeds = r:get_resource("seed") + if seeds>=n then + r:set_resource("seed", seeds-n) + else + r:set_resource("seed", 0) + end + end +end function horse_limit(r) - return r:get_resource("horse") + return r:get_resource("horse") end function horse_produce(r, n) @@ -52,9 +91,6 @@ function horse_produce(r, n) end function log_limit(r) --- if r:get_flag(1) then -- RF_MALLORN --- return 0 --- end return r:get_resource("tree") + r:get_resource("sapling") end @@ -75,7 +111,7 @@ function log_produce(r, n) end function mallorn_limit(r) - if not r:get_flag(1) then -- RF_MALLORN + if not mallorn_region(r) then return 0 end return r:get_resource("tree") + r:get_resource("sapling") diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 96673bfd3..27177d1b6 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -438,10 +438,9 @@ function test_recruit() u:add_item("money", 110*n+20) u:add_order("REKRUTIERE " .. n) process_orders() - assert(u.number == n+1) + assert_equal(n+1, u.number) local p = r:get_resource("peasant") - assert(p<200 and p>=200-n) - -- assert(u:get_item("money")==10) + assert_true(p<200 and p>=200-n) end function test_produce() @@ -468,7 +467,7 @@ function test_work() u:clear_orders() u:add_order("ARBEITEN") process_orders() - assert(u:get_item("money")>=10) + assert_equal(20, u:get_item("money")) end function test_upkeep() @@ -480,7 +479,7 @@ function test_upkeep() u:clear_orders() u:add_order("LERNE Waffenbau") process_orders() - assert(u:get_item("money")==u.number) + assert_equal(u:get_item("money"), u.number) end function test_id() @@ -488,50 +487,63 @@ function test_id() local f = faction.create("noreply11@eressea.de", "human", "de") f.id = atoi36("42") - assert(get_faction(42)~=f) - assert(get_faction("42")==f) - assert(get_faction(atoi36("42"))==f) + assert_not_equal(f, get_faction(42)) + assert_equal(f, get_faction("42")) + assert_equal(f, get_faction(atoi36("42"))) local u = unit.create(f, r, 1) u.id = atoi36("42") - assert(get_unit(42)~=u) - assert(get_unit("42")==u) - assert(get_unit(atoi36("42"))==u) + assert_not_equal(get_unit(42), u) + assert_equal(get_unit("42"), u) + assert_equal(get_unit(atoi36("42")), u) local b = building.create(r, "castle") -- b.id = atoi36("42") local fortytwo = itoa36(b.id) - assert(get_building(fortytwo)==b) - assert(get_building(atoi36(fortytwo))==b) + assert_equal(get_building(fortytwo), b) + assert_equal(get_building(atoi36(fortytwo)), b) local s = _test_create_ship(r) assert_not_nil(s) -- s.id = atoi36("42") local fortytwo = itoa36(s.id) - assert(get_ship(fortytwo)==s) - assert(get_ship(atoi36(fortytwo))==s) + assert_equal(get_ship(fortytwo), s) + assert_equal(get_ship(atoi36(fortytwo)), s) end function test_herbalism() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply12@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("money", u.number * 100) - u:set_skill("herbalism", 5) - u:clear_orders() - u:add_order("MACHE Samen") - process_orders() + local r = region.create(0, 0, "plain") + local f = faction.create("herbalism@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + + eressea.settings.set("rules.grow.formula", 0) -- plants do not grow + u:add_item("money", u.number * 100) + u:set_skill("herbalism", 5) + + r:set_resource("seed", 100) + r:set_flag(1, false) -- regular trees + u:clear_orders() + u:add_order("MACHE Samen") + process_orders() + assert_equal(1, u:get_item("seed")) + assert_equal(99, r:get_resource("seed")) + r:set_flag(1, true) -- mallorn + u:clear_orders() + u:add_order("MACHE Mallornsamen") + process_orders() + assert_equal(1, u:get_item("mallornseed")) + assert_equal(98, r:get_resource("seed")) end function test_mallorn() local r = region.create(0, 0, "plain") r:set_flag(1, false) -- not mallorn r:set_resource("tree", 100) - assert(r:get_resource("tree")==100) + assert_equal(100, r:get_resource("tree")) local m = region.create(0, 0, "plain") m:set_flag(1, true) -- mallorn m:set_resource("tree", 100) - assert(m:get_resource("tree")==100) + assert_equal(100, m:get_resource("tree")) local f = faction.create("noreply13@eressea.de", "human", "de") diff --git a/src/eressea.c b/src/eressea.c index dead153cb..07ea132a8 100755 --- a/src/eressea.c +++ b/src/eressea.c @@ -21,7 +21,10 @@ #include #include #include -#include +#include +#include +#include + #include #include #include @@ -81,7 +84,9 @@ void game_init(void) #endif wormholes_register(); - register_itemtypes(); + register_weapons(); + register_xerewards(); + register_artrewards(); #ifdef USE_LIBXML2 register_xmlreader(); #endif diff --git a/src/gmtool.c b/src/gmtool.c index 5a0cd576c..3551c3436 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -47,7 +47,6 @@ #include #include -#include #include #include diff --git a/src/items/CMakeLists.txt b/src/items/CMakeLists.txt index 0a2c581b4..b2bf2dfe5 100644 --- a/src/items/CMakeLists.txt +++ b/src/items/CMakeLists.txt @@ -7,8 +7,6 @@ xerewards.test.c SET(_FILES artrewards.c demonseye.c -itemtypes.c -seed.c speedsail.c weapons.c xerewards.c diff --git a/src/items/itemtypes.c b/src/items/itemtypes.c deleted file mode 100644 index 930829668..000000000 --- a/src/items/itemtypes.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - -#include -#include "itemtypes.h" - -#include "xerewards.h" -#include "artrewards.h" -#include "weapons.h" -#include "seed.h" - -void register_itemtypes(void) -{ - /* registering misc. functions */ - register_weapons(); - register_xerewards(); - register_artrewards(); -} - -void init_itemtypes(void) -{ - init_seed(); - init_mallornseed(); -} diff --git a/src/items/itemtypes.h b/src/items/itemtypes.h deleted file mode 100644 index ec705c55b..000000000 --- a/src/items/itemtypes.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - -#ifndef H_ITM_ITEMS -#define H_ITM_ITEMS -#ifdef __cplusplus -extern "C" { -#endif - - extern void init_itemtypes(void); - extern void register_itemtypes(void); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/items/seed.c b/src/items/seed.c deleted file mode 100644 index 334c6a05d..000000000 --- a/src/items/seed.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#include - -#include "seed.h" - -/* kernel includes */ -#include -#include -#include -#include - -/* util includes */ -#include -#include - -/* libc includes */ -#include -#include - -static void produce_seeds(region * r, const resource_type * rtype, int norders) -{ - assert(r->land && r->land->trees[0] >= norders); - r->land->trees[0] -= norders; -} - -static int limit_seeds(const region * r, const resource_type * rtype) -{ - if ((r->flags & RF_MALLORN)) { - return 0; - } - return r->land ? r->land->trees[0] : 0; -} - -void init_seed(void) -{ - resource_type *rtype; - - rtype = rt_find("seed"); - if (rtype != NULL) { - resource_limit *rdata = rtype->limit = calloc(1, sizeof(resource_limit)); - rdata->limit = limit_seeds; - rdata->produce = produce_seeds; - } -} - -/* mallorn */ - -static void -produce_mallornseeds(region * r, const resource_type * rtype, int norders) -{ - assert(r->flags & RF_MALLORN); - r->land->trees[0] -= norders; -} - -static int limit_mallornseeds(const region * r, const resource_type * rtype) -{ - if (!(r->flags & RF_MALLORN)) { - return 0; - } - return r->land ? r->land->trees[0] : 0; -} - -void init_mallornseed(void) -{ - resource_type *rtype; - - rtype = rt_find("mallornseed"); - if (rtype != NULL) { - resource_limit *rdata = rtype->limit = calloc(1, sizeof(resource_limit)); - rtype->flags |= RTF_LIMITED; - rtype->flags |= RTF_POOLED; - - rdata->limit = limit_mallornseeds; - rdata->produce = produce_mallornseeds; - } -} diff --git a/src/items/seed.h b/src/items/seed.h deleted file mode 100644 index c853adfde..000000000 --- a/src/items/seed.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef H_ITM_SEED -#define H_ITM_SEED -#ifdef __cplusplus -extern "C" { -#endif - - extern void init_seed(void); - extern void init_mallornseed(void); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 9ba05e101..27adba598 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1061,7 +1061,7 @@ static int parse_resources(xmlDocPtr doc) /* reading eressea/resources/resource/resourcelimit/function */ result = xmlXPathEvalExpression(BAD_CAST "function", xpath); - if (result->nodesetval != NULL) + if (result->nodesetval != NULL) { for (k = 0; k != result->nodesetval->nodeNr; ++k) { xmlNodePtr node = result->nodesetval->nodeTab[k]; pf_generic fun; @@ -1089,6 +1089,7 @@ static int parse_resources(xmlDocPtr doc) } xmlFree(propValue); } + } } xmlXPathFreeObject(result); /* reading eressea/resources/resource/resourcelimit/function */ @@ -1118,7 +1119,6 @@ static int parse_resources(xmlDocPtr doc) /* make sure old items (used in requirements) are available */ init_resources(); - init_itemtypes(); return 0; } From 6ce487e48511911e45dcb85c6354bfc894af9157 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 23 Feb 2017 22:19:48 +0100 Subject: [PATCH 566/675] MACHE Samen geht in E3 nicht. limited ist unnoetig --- res/e3a/resources/mallornseed.xml | 2 +- res/e3a/resources/seed.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/res/e3a/resources/mallornseed.xml b/res/e3a/resources/mallornseed.xml index 4a348c212..576035b34 100644 --- a/res/e3a/resources/mallornseed.xml +++ b/res/e3a/resources/mallornseed.xml @@ -1,4 +1,4 @@ - + diff --git a/res/e3a/resources/seed.xml b/res/e3a/resources/seed.xml index 21652f364..62c971540 100644 --- a/res/e3a/resources/seed.xml +++ b/res/e3a/resources/seed.xml @@ -1,4 +1,4 @@ - + From 794dae11cf73b272c76867bc82643778351c5c6f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 24 Feb 2017 14:29:14 +0100 Subject: [PATCH 567/675] remove artsculpture and genericbuilding. deal with buildings having an unknown type. --- res/core/common/buildings.xml | 3 +-- res/core/de/strings.xml | 2 +- res/core/en/strings.xml | 2 +- res/core/fr/strings.xml | 2 +- src/kernel/building.c | 9 +++++++-- src/kernel/save.c | 5 +++++ 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/res/core/common/buildings.xml b/res/core/common/buildings.xml index cf183086b..17f779843 100644 --- a/res/core/common/buildings.xml +++ b/res/core/common/buildings.xml @@ -4,9 +4,8 @@ - + - diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 97ded6e8d..002727630 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -912,7 +912,7 @@ Traumschlößchen - + Struktur diff --git a/res/core/en/strings.xml b/res/core/en/strings.xml index d80c742b9..063194c5d 100644 --- a/res/core/en/strings.xml +++ b/res/core/en/strings.xml @@ -310,7 +310,7 @@ dam - + structure diff --git a/res/core/fr/strings.xml b/res/core/fr/strings.xml index 7eb091570..c69bb5b75 100644 --- a/res/core/fr/strings.xml +++ b/res/core/fr/strings.xml @@ -324,7 +324,7 @@ barrage - + bâtiment diff --git a/src/kernel/building.c b/src/kernel/building.c index 3c21f4dbe..6d0db8f43 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -325,8 +325,13 @@ const building_type *findbuildingtype(const char *name, building_type *btype = (building_type *)selist_get(ql, qi); const char *n = LOC(lang, btype->_name); - type.v = (void *)btype; - addtoken((struct tnode **)&bn->names, n, type); + if (!n) { + log_error("building type %s has no translation in %s", + btype->_name, locale_name(lang)); + } else { + type.v = (void *)btype; + addtoken((struct tnode **)&bn->names, n, type); + } } bnames = bn; } diff --git a/src/kernel/save.c b/src/kernel/save.c index 21ec98e76..8316121f3 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1529,6 +1529,11 @@ struct building *read_building(gamedata *data) { READ_INT(store, &b->size); READ_STR(store, name, sizeof(name)); b->type = bt_find(name); + if (!b->type) { + log_error("building %d has unknown type %s", b->no, name); + b->type = bt_find("building"); + assert(b->type); + } read_attribs(data, &b->attribs, b); /* repairs, bug 2221: */ From 2d4b61afa90c938468c730e017eff7bbc5393ead Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 24 Feb 2017 14:32:18 +0100 Subject: [PATCH 568/675] the artacademy was E2-only --- res/core/common/buildings.xml | 1 - res/core/de/strings.xml | 8 -------- res/eressea/buildings.xml | 1 + res/eressea/strings.xml | 8 ++++++++ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/res/core/common/buildings.xml b/res/core/common/buildings.xml index 17f779843..540e9f085 100644 --- a/res/core/common/buildings.xml +++ b/res/core/common/buildings.xml @@ -5,7 +5,6 @@ - diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 002727630..5bde79c29 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -915,14 +915,6 @@ Struktur - - Akademie der Künste - academy of arts - - - Skulptur - sculpture - diff --git a/res/eressea/buildings.xml b/res/eressea/buildings.xml index 64d65cff0..670ab484e 100644 --- a/res/eressea/buildings.xml +++ b/res/eressea/buildings.xml @@ -4,4 +4,5 @@ + diff --git a/res/eressea/strings.xml b/res/eressea/strings.xml index 61a35ebe5..28547679d 100644 --- a/res/eressea/strings.xml +++ b/res/eressea/strings.xml @@ -352,6 +352,14 @@ + + Akademie der Künste + academy of arts + + + Skulptur + sculpture + Horn des Tanzes horn of dancing From 25d3aacffaf6b19b1352b037f31ba45df31f78dc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 24 Feb 2017 14:38:08 +0100 Subject: [PATCH 569/675] remove artrewards, they predate my backups --- res/eressea/artrewards.xml | 14 ---- res/eressea/items.xml | 13 ---- res/eressea/strings.xml | 36 --------- res/items.xml | 3 - src/eressea.c | 2 - src/items/CMakeLists.txt | 1 - src/items/artrewards.c | 155 ------------------------------------- src/items/artrewards.h | 30 ------- 8 files changed, 254 deletions(-) delete mode 100644 res/items.xml delete mode 100644 src/items/artrewards.c delete mode 100644 src/items/artrewards.h diff --git a/res/eressea/artrewards.xml b/res/eressea/artrewards.xml index 6cb836c52..2a3c09950 100644 --- a/res/eressea/artrewards.xml +++ b/res/eressea/artrewards.xml @@ -1,20 +1,6 @@ - - - - - - - - - - - - - - diff --git a/res/eressea/items.xml b/res/eressea/items.xml index 8b2df7add..69f84c890 100644 --- a/res/eressea/items.xml +++ b/res/eressea/items.xml @@ -63,19 +63,6 @@ - - - - - - - - - - - - - diff --git a/res/eressea/strings.xml b/res/eressea/strings.xml index 28547679d..f7497b810 100644 --- a/res/eressea/strings.xml +++ b/res/eressea/strings.xml @@ -356,42 +356,6 @@ Akademie der Künste academy of arts - - Skulptur - sculpture - - - Horn des Tanzes - horn of dancing - - - Hörner des Tanzes - horns of dancing - - - Miniatur einer Akademie der Künste - academy of arts in a box - - - Miniaturen einer Akademie der Künste - academies of arts in a box - - - Miniatur einer Skulptur - art sculpture in a box - - - Miniaturen einer Skulptur - art sculptures in a box - - - Gefangener Windgeist - trapped air elemental - - - Gefangene Windgeister - trapped air elementals - Auratrank aura potion diff --git a/res/items.xml b/res/items.xml deleted file mode 100644 index 108e6d398..000000000 --- a/res/items.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/eressea.c b/src/eressea.c index 07ea132a8..8001355f1 100755 --- a/src/eressea.c +++ b/src/eressea.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -86,7 +85,6 @@ void game_init(void) register_weapons(); register_xerewards(); - register_artrewards(); #ifdef USE_LIBXML2 register_xmlreader(); #endif diff --git a/src/items/CMakeLists.txt b/src/items/CMakeLists.txt index b2bf2dfe5..bbf192a66 100644 --- a/src/items/CMakeLists.txt +++ b/src/items/CMakeLists.txt @@ -5,7 +5,6 @@ xerewards.test.c ) SET(_FILES -artrewards.c demonseye.c speedsail.c weapons.c diff --git a/src/items/artrewards.c b/src/items/artrewards.c deleted file mode 100644 index 23ab2119e..000000000 --- a/src/items/artrewards.c +++ /dev/null @@ -1,155 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#include -#include "artrewards.h" - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include - -/* util includes */ -#include -#include - -/* libc includes */ -#include -#include -#include -#include - -#define HORNRANGE 10 -#define HORNDURATION 3 -#define HORNIMMUNITY 30 - -static int age_peaceimmune(attrib * a, void *owner) -{ - UNUSED_ARG(owner); - return (--a->data.i > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; -} - -static attrib_type at_peaceimmune = { - "peaceimmune", - NULL, NULL, - age_peaceimmune, - a_writeint, - a_readint -}; - -static int -use_hornofdancing(struct unit *u, const struct item_type *itype, -int amount, struct order *ord) -{ - region *r; - int regionsPacified = 0; - - for (r = regions; r; r = r->next) { - if (distance(u->region, r) < HORNRANGE) { - if (a_find(r->attribs, &at_peaceimmune) == NULL) { - attrib *a; - - create_curse(u, &r->attribs, ct_find("peacezone"), - 20, HORNDURATION, 1.0, 0); - - a = a_add(&r->attribs, a_new(&at_peaceimmune)); - a->data.i = HORNIMMUNITY; - - ADDMSG(&r->msgs, msg_message("hornofpeace_r_success", - "unit region", u, u->region)); - - regionsPacified++; - } - else { - ADDMSG(&r->msgs, msg_message("hornofpeace_r_nosuccess", - "unit region", u, u->region)); - } - } - } - - if (regionsPacified > 0) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "hornofpeace_u_success", - "pacified", regionsPacified)); - } - else { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "hornofpeace_u_nosuccess", - "")); - } - - return 0; -} - -#define SPEEDUP 2 - -static int -useonother_trappedairelemental(struct unit *u, int shipId, -const struct item_type *itype, int amount, struct order *ord) -{ - curse *c; - ship *sh; - - if (shipId <= 0) { - cmistake(u, ord, 20, MSG_MOVE); - return -1; - } - - sh = findshipr(u->region, shipId); - if (!sh) { - cmistake(u, ord, 20, MSG_MOVE); - return -1; - } - - c = - create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, SPEEDUP, - 0); - c_setflag(c, CURSE_NOAGE); - - ADDMSG(&u->faction->msgs, msg_message("trappedairelemental_success", - "unit region command ship", u, u->region, ord, sh)); - - use_pooled(u, itype->rtype, GET_DEFAULT, 1); - - return 0; -} - -static int -use_trappedairelemental(struct unit *u, -const struct item_type *itype, int amount, struct order *ord) -{ - ship *sh = u->ship; - - if (sh == NULL) { - cmistake(u, ord, 20, MSG_MOVE); - return -1; - } - return useonother_trappedairelemental(u, sh->no, itype, amount, ord); -} - -void register_artrewards(void) -{ - at_register(&at_peaceimmune); - register_item_use(use_hornofdancing, "use_hornofdancing"); - register_item_use(use_trappedairelemental, "use_trappedairelemental"); - register_item_useonother(useonother_trappedairelemental, - "useonother_trappedairelemental"); -} diff --git a/src/items/artrewards.h b/src/items/artrewards.h deleted file mode 100644 index 779e7cc5f..000000000 --- a/src/items/artrewards.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef H_ITM_ARTREWARDS -#define H_ITM_ARTREWARDS -#ifdef __cplusplus -extern "C" { -#endif - - extern void register_artrewards(void); - -#ifdef __cplusplus -} -#endif -#endif From 158e0646e1b5b8059f8863b93b5dc0e6f8427064 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 24 Feb 2017 15:48:49 +0100 Subject: [PATCH 570/675] implement fractions --- src/util/CMakeLists.txt | 1 + src/util/variant.c | 36 ++++++++++++++++++++++++++++++++++++ src/util/variant.h | 6 ++++++ 3 files changed, 43 insertions(+) create mode 100644 src/util/variant.c diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 842bcf58c..743ff4d88 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -56,6 +56,7 @@ strings.c translation.c umlaut.c unicode.c +variant.c xml.c ) FOREACH(_FILE ${_FILES}) diff --git a/src/util/variant.c b/src/util/variant.c new file mode 100644 index 000000000..e3461f861 --- /dev/null +++ b/src/util/variant.c @@ -0,0 +1,36 @@ +#include "variant.h" +#include + +static int lcd(int a, int b) { + return a * b; +} + +variant frac_add(variant a, variant b) +{ + int num, den; + variant v; + den = lcd(a.sa[1], b.sa[1]); + num = a.sa[0] * lcd / a.sa[1] + b.sa[0] * lcd / b.sa[1]; + assert(num >= SHRT_MIN && num <= SHRT_MAX); + assert(den >= SHRT_MIN && den <= SHRT_MAX); + v.sa[0] = (short)num; + v.sa[1] = (short)den; + return v; +} + +variant frac_mul(variant a, variant b) +{ + variant v = a; + return v; +} + +variant frac_div(variant a, variant b) +{ + variant v = a; + return v; +} + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/util/variant.h b/src/util/variant.h index b65ee0868..8c78bc3ac 100644 --- a/src/util/variant.h +++ b/src/util/variant.h @@ -1,3 +1,5 @@ +#pragma once + #ifndef STRUCT_VARIANT_H #define STRUCT_VARIANT_H #ifdef __cplusplus @@ -19,6 +21,10 @@ extern "C" { VAR_FLOAT } variant_type; + variant frac_add(variant a, variant b); + variant frac_mul(variant a, variant b); + variant frac_div(variant a, variant b); + #ifdef __cplusplus } #endif From 234eb62226d665880b23e808ba2817fed66a7c76 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 24 Feb 2017 17:51:35 +0100 Subject: [PATCH 571/675] short and sweet math with fractions. goinf to use this for magres. --- src/test_eressea.c | 2 ++ src/util/CMakeLists.txt | 1 + src/util/variant.c | 54 +++++++++++++++++++++++++++++------------ src/util/variant.h | 1 + src/util/variant.test.c | 28 +++++++++++++++++++++ 5 files changed, 71 insertions(+), 15 deletions(-) create mode 100644 src/util/variant.test.c diff --git a/src/test_eressea.c b/src/test_eressea.c index 4ffe1f19c..1d991725f 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -6,6 +6,7 @@ #include #include #include +#include #pragma warning(disable: 4210) @@ -85,6 +86,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(unicode); ADD_SUITE(strings); ADD_SUITE(log); + ADD_SUITE(variant); ADD_SUITE(rng); /* items */ ADD_SUITE(xerewards); diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 743ff4d88..91ed118ae 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -28,6 +28,7 @@ log.test.c # translation.test.c umlaut.test.c unicode.test.c +variant.test.c # xml.test.c ) diff --git a/src/util/variant.c b/src/util/variant.c index e3461f861..74d7adb1c 100644 --- a/src/util/variant.c +++ b/src/util/variant.c @@ -1,16 +1,39 @@ +#include #include "variant.h" + +#include #include -static int lcd(int a, int b) { - return a * b; +static int gcd(int a, int b) { + const int primes[] = { 3, 5, 7, 11, 13, 17, 19, 23, 0 }; + int i = 0, g = 1, p = 2; + while (p && p <= a && p <= b) { + if (a % p == 0 && b % p == 0) { + a /= p; + b /= p; + g *= p; + } + else { + p = primes[i++]; + } + } + return g; } -variant frac_add(variant a, variant b) +static int lcm(int a, int b) { + int x; + if (a == b) return a; + x = (a * b); + x = (x > 0 ? x : -x) / gcd(a, b); + return x; +} + +variant frac_make(int num, int den) { - int num, den; variant v; - den = lcd(a.sa[1], b.sa[1]); - num = a.sa[0] * lcd / a.sa[1] + b.sa[0] * lcd / b.sa[1]; + int g = gcd(num, den); + num /= g; + den /= g; assert(num >= SHRT_MIN && num <= SHRT_MAX); assert(den >= SHRT_MIN && den <= SHRT_MAX); v.sa[0] = (short)num; @@ -18,19 +41,20 @@ variant frac_add(variant a, variant b) return v; } +variant frac_add(variant a, variant b) +{ + int num, den; + den = lcm(a.sa[1], b.sa[1]); + num = a.sa[0] * den / a.sa[1] + b.sa[0] * den / b.sa[1]; + return frac_make(num, den); +} + variant frac_mul(variant a, variant b) { - variant v = a; - return v; + return frac_make(a.sa[0] * b.sa[0], a.sa[1] * b.sa[1]); } variant frac_div(variant a, variant b) { - variant v = a; - return v; + return frac_make(a.sa[0] * b.sa[1], a.sa[1] * b.sa[0]); } - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/util/variant.h b/src/util/variant.h index 8c78bc3ac..f98fa0b80 100644 --- a/src/util/variant.h +++ b/src/util/variant.h @@ -21,6 +21,7 @@ extern "C" { VAR_FLOAT } variant_type; + variant frac_make(int num, int den); variant frac_add(variant a, variant b); variant frac_mul(variant a, variant b); variant frac_div(variant a, variant b); diff --git a/src/util/variant.test.c b/src/util/variant.test.c new file mode 100644 index 000000000..6344e5c33 --- /dev/null +++ b/src/util/variant.test.c @@ -0,0 +1,28 @@ +#include +#include "variant.h" + +#include + +static void test_fractions(CuTest *tc) { + variant a, b; + a = frac_make(120, 12000); + CuAssertIntEquals(tc, 1, a.sa[0]); + CuAssertIntEquals(tc, 100, a.sa[1]); + b = frac_make(23, 2300); + a = frac_add(a, b); + CuAssertIntEquals(tc, 1, a.sa[0]); + CuAssertIntEquals(tc, 50, a.sa[1]); + a = frac_mul(a, b); + CuAssertIntEquals(tc, 1, a.sa[0]); + CuAssertIntEquals(tc, 5000, a.sa[1]); + a = frac_div(b, b); + CuAssertIntEquals(tc, 1, a.sa[0]); + CuAssertIntEquals(tc, 1, a.sa[1]); +} + +CuSuite *get_variant_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_fractions); + return suite; +} From e0229be5007f14e85162b65808bbe3617c2da300 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 24 Feb 2017 17:55:06 +0100 Subject: [PATCH 572/675] also implement subtraction. --- src/util/variant.c | 6 ++++++ src/util/variant.h | 1 + src/util/variant.test.c | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/src/util/variant.c b/src/util/variant.c index 74d7adb1c..2ffe4a4e3 100644 --- a/src/util/variant.c +++ b/src/util/variant.c @@ -49,6 +49,12 @@ variant frac_add(variant a, variant b) return frac_make(num, den); } +variant frac_sub(variant a, variant b) +{ + b.sa[0] = -b.sa[0]; + return frac_add(a, b); +} + variant frac_mul(variant a, variant b) { return frac_make(a.sa[0] * b.sa[0], a.sa[1] * b.sa[1]); diff --git a/src/util/variant.h b/src/util/variant.h index f98fa0b80..4bd5d952d 100644 --- a/src/util/variant.h +++ b/src/util/variant.h @@ -23,6 +23,7 @@ extern "C" { variant frac_make(int num, int den); variant frac_add(variant a, variant b); + variant frac_sub(variant a, variant b); variant frac_mul(variant a, variant b); variant frac_div(variant a, variant b); diff --git a/src/util/variant.test.c b/src/util/variant.test.c index 6344e5c33..793e4f683 100644 --- a/src/util/variant.test.c +++ b/src/util/variant.test.c @@ -18,6 +18,10 @@ static void test_fractions(CuTest *tc) { a = frac_div(b, b); CuAssertIntEquals(tc, 1, a.sa[0]); CuAssertIntEquals(tc, 1, a.sa[1]); + a = frac_sub(a, a); + CuAssertIntEquals(tc, 0, a.sa[0]); + a = frac_mul(a, b); + CuAssertIntEquals(tc, 0, a.sa[0]); } CuSuite *get_variant_suite(void) From e557140ad1038dc745c656f06c76c3a0696fa618 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 24 Feb 2017 20:47:31 +0100 Subject: [PATCH 573/675] more fractions functionality. --- src/util/variant.c | 14 ++++++++++++++ src/util/variant.h | 8 ++++++++ src/util/variant.test.c | 10 +++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/util/variant.c b/src/util/variant.c index 2ffe4a4e3..c1d42808d 100644 --- a/src/util/variant.c +++ b/src/util/variant.c @@ -4,6 +4,9 @@ #include #include +const variant frac_zero = { .sa = { 0, 1 } }; +const variant frac_one = { .sa = { 1, 1 } }; + static int gcd(int a, int b) { const int primes[] = { 3, 5, 7, 11, 13, 17, 19, 23, 0 }; int i = 0, g = 1, p = 2; @@ -28,6 +31,10 @@ static int lcm(int a, int b) { return x; } +bool frac_equal(variant a, variant b) { + return frac_sign(frac_sub(a, b)) == 0; +} + variant frac_make(int num, int den) { variant v; @@ -64,3 +71,10 @@ variant frac_div(variant a, variant b) { return frac_make(a.sa[0] * b.sa[1], a.sa[1] * b.sa[0]); } + +int frac_sign(variant a) { + if (a.sa[0] == 0) return 0; + if (a.sa[0] > 0 && a.sa[1] > 0) return 1; + if (a.sa[0] < 0 && a.sa[1] < 0) return 1; + return -1; +} diff --git a/src/util/variant.h b/src/util/variant.h index 4bd5d952d..ae75c5cda 100644 --- a/src/util/variant.h +++ b/src/util/variant.h @@ -2,6 +2,9 @@ #ifndef STRUCT_VARIANT_H #define STRUCT_VARIANT_H + +#include + #ifdef __cplusplus extern "C" { #endif @@ -21,11 +24,16 @@ extern "C" { VAR_FLOAT } variant_type; + extern const variant frac_zero; + extern const variant frac_one; + variant frac_make(int num, int den); variant frac_add(variant a, variant b); variant frac_sub(variant a, variant b); variant frac_mul(variant a, variant b); variant frac_div(variant a, variant b); + int frac_sign(variant a); + bool frac_equal(variant a, variant b); #ifdef __cplusplus } diff --git a/src/util/variant.test.c b/src/util/variant.test.c index 793e4f683..12299720b 100644 --- a/src/util/variant.test.c +++ b/src/util/variant.test.c @@ -20,8 +20,16 @@ static void test_fractions(CuTest *tc) { CuAssertIntEquals(tc, 1, a.sa[1]); a = frac_sub(a, a); CuAssertIntEquals(tc, 0, a.sa[0]); - a = frac_mul(a, b); + a = frac_sub(frac_one, a); + CuAssertIntEquals(tc, 1, a.sa[0]); + CuAssertIntEquals(tc, 1, a.sa[1]); + a = frac_mul(a, frac_zero); CuAssertIntEquals(tc, 0, a.sa[0]); + CuAssertIntEquals(tc, 1, frac_sign(frac_make(-1, -1))); + CuAssertIntEquals(tc, 1, frac_sign(frac_make(1, 1))); + CuAssertIntEquals(tc, -1, frac_sign(frac_make(-1, 1))); + CuAssertIntEquals(tc, -1, frac_sign(frac_make(1, -1))); + CuAssertIntEquals(tc, 0, frac_sign(frac_make(0, 1))); } CuSuite *get_variant_suite(void) From 3a985108a669d300408cb93a77e7898e2518fb1f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 24 Feb 2017 20:47:47 +0100 Subject: [PATCH 574/675] change all magic resistance to use fractions. --- src/battle.c | 36 ++++++++++------ src/battle.h | 2 +- src/battle.test.c | 67 ++++++++++++++++------------- src/economy.test.c | 2 +- src/guard.test.c | 6 +-- src/kernel/building.h | 2 +- src/kernel/building.test.c | 2 +- src/kernel/item.c | 4 +- src/kernel/item.h | 10 ++--- src/kernel/jsonconf.c | 2 +- src/kernel/jsonconf.test.c | 3 +- src/kernel/race.c | 5 ++- src/kernel/race.h | 4 +- src/kernel/race.test.c | 3 +- src/kernel/xmlreader.c | 47 ++++++++------------ src/laws.test.c | 4 +- src/magic.c | 88 ++++++++++++++++++++++++-------------- src/magic.h | 2 +- src/magic.test.c | 12 +++--- src/spells.c | 7 ++- src/spy.test.c | 2 +- src/volcano.c | 11 +++-- 22 files changed, 178 insertions(+), 143 deletions(-) diff --git a/src/battle.c b/src/battle.c index 23c219109..9864adc41 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1059,7 +1059,7 @@ static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_ return modifier; } -int calculate_armor(troop dt, const weapon_type *dwtype, const weapon_type *awtype, double *magres) { +int calculate_armor(troop dt, const weapon_type *dwtype, const weapon_type *awtype, variant *magres) { fighter *df = dt.fighter; unit *du = df->unit; int ar = 0, an, am; @@ -1110,21 +1110,31 @@ int calculate_armor(troop dt, const weapon_type *dwtype, const weapon_type *awty if (magres) { /* calculate damage multiplier for magical damage */ - double res = 1.0 - magic_resistance(du); + variant res; + + res = frac_sub(frac_one, magic_resistance(du)); if (u_race(du)->battle_flags & BF_EQUIPMENT) { /* der Effekt von Laen steigt nicht linear */ - if (armor && fval(armor, ATF_LAEN)) - res *= (1 - armor->magres); - if (shield && fval(shield, ATF_LAEN)) - res *= (1 - shield->magres); - if (dwtype) - res *= (1 - dwtype->magres); + if (armor && fval(armor, ATF_LAEN)) { + res = frac_mul(res, frac_sub(frac_one, armor->magres)); + } + if (shield && fval(shield, ATF_LAEN)) { + res = frac_mul(res, frac_sub(frac_one, shield->magres)); + } + if (dwtype) { + res = frac_mul(res, frac_sub(frac_one, dwtype->magres)); + } } - /* gegen Magie wirkt nur nat�rliche und magische R�stung */ + /* gegen Magie wirkt nur natuerliche und magische Ruestung */ ar = an + am; - *magres = res > 0 ? res : 0; + if (res.sa[0] >= 0) { + *magres = res; + } + else { + *magres = frac_make(0, 1); + } } return ar; @@ -1147,7 +1157,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) const weapon_type *dwtype = NULL; const weapon_type *awtype = NULL; const weapon *weapon; - double res = 1.0; + variant res = frac_make(1, 1); int rda, sk = 0, sd; bool magic = false; @@ -1190,9 +1200,9 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) return false; } - /* TODO not sure if res could be > 1 here */ if (magic) { - da = (int)(MAX(da * res, 0)); + res = frac_mul(frac_make(da, 1), res); + da = res.sa[0] / res.sa[1]; } if (type != AT_COMBATSPELL && type != AT_SPELL) { diff --git a/src/battle.h b/src/battle.h index 1b4cf2588..85e65cf66 100644 --- a/src/battle.h +++ b/src/battle.h @@ -248,7 +248,7 @@ extern "C" { int count_enemies(struct battle *b, const struct fighter *af, int minrow, int maxrow, int select); int natural_armor(struct unit * u); - int calculate_armor(troop dt, const struct weapon_type *dwtype, const struct weapon_type *awtype, double *magres); + int calculate_armor(troop dt, const struct weapon_type *dwtype, const struct weapon_type *awtype, union variant *magres); bool terminate(troop dt, troop at, int type, const char *damage, bool missile); extern void message_all(battle * b, struct message *m); diff --git a/src/battle.test.c b/src/battle.test.c index d15c335a9..b00d06a98 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -250,23 +250,24 @@ static void test_calculate_armor(CuTest * tc) armor_type *ashield, *achain; item_type *ibelt, *ishield, *ichain; race *rc; - double magres = 0.0; + variant magres = frac_zero; + variant v50p = frac_make(1, 2); test_setup(); r = test_create_region(0, 0, 0); ibelt = it_get_or_create(rt_get_or_create("trollbelt")); ishield = it_get_or_create(rt_get_or_create("shield")); - ashield = new_armortype(ishield, 0.0, 0.5, 1, ATF_SHIELD); + ashield = new_armortype(ishield, 0.0, v50p, 1, ATF_SHIELD); ichain = it_get_or_create(rt_get_or_create("chainmail")); - achain = new_armortype(ichain, 0.0, 0.5, 3, ATF_NONE); - wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, 0.5, 0, 0, 0, 0, SK_MELEE, 1); + achain = new_armortype(ichain, 0.0, v50p, 3, ATF_NONE); + wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, v50p, 0, 0, 0, 0, SK_MELEE, 1); rc = test_create_race("human"); du = test_create_unit(test_create_faction(rc), r); dt.index = 0; dt.fighter = setup_fighter(&b, du); CuAssertIntEquals_Msg(tc, "default ac", 0, calculate_armor(dt, 0, 0, &magres)); - CuAssertDblEquals_Msg(tc, "magres unmodified", 1.0, magres, 0.01); + CuAssertIntEquals_Msg(tc, "magres unmodified", magres.sa[0], magres.sa[1]); free_battle(b); b = NULL; @@ -299,13 +300,13 @@ static void test_calculate_armor(CuTest * tc) wtype->flags = WTF_NONE; CuAssertIntEquals_Msg(tc, "magical attack", 3, calculate_armor(dt, 0, 0, &magres)); - CuAssertDblEquals_Msg(tc, "magres unmodified", 1.0, magres, 0.01); + CuAssertIntEquals_Msg(tc, "magres unmodified", magres.sa[1], magres.sa[0]); ashield->flags |= ATF_LAEN; achain->flags |= ATF_LAEN; - magres = 1.0; + magres = frac_one; CuAssertIntEquals_Msg(tc, "laen armor", 3, calculate_armor(dt, 0, 0, &magres)); - CuAssertDblEquals_Msg(tc, "laen magres bonus", 0.25, magres, 0.01); + CuAssertIntEquals_Msg(tc, "laen magres bonus", 4, magres.sa[1]); free_battle(b); test_cleanup(); } @@ -319,38 +320,42 @@ static void test_magic_resistance(CuTest *tc) armor_type *ashield, *achain; item_type *ishield, *ichain; race *rc; - double magres; + variant magres; + variant v50p = frac_make(1, 2); + variant v10p = frac_make(1, 10); test_setup(); r = test_create_region(0, 0, 0); ishield = it_get_or_create(rt_get_or_create("shield")); - ashield = new_armortype(ishield, 0.0, 0.5, 1, ATF_SHIELD); + ashield = new_armortype(ishield, 0.0, v50p, 1, ATF_SHIELD); ichain = it_get_or_create(rt_get_or_create("chainmail")); - achain = new_armortype(ichain, 0.0, 0.5, 3, ATF_NONE); + achain = new_armortype(ichain, 0.0, v50p, 3, ATF_NONE); rc = test_create_race("human"); du = test_create_unit(test_create_faction(rc), r); dt.index = 0; + i_change(&du->items, ishield, 1); dt.fighter = setup_fighter(&b, du); calculate_armor(dt, 0, 0, &magres); - CuAssertDblEquals_Msg(tc, "no magres bonus", 0.0, magic_resistance(du), 0.01); - CuAssertDblEquals_Msg(tc, "no magres reduction", 1.0, magres, 0.01); + CuAssertIntEquals_Msg(tc, "no magres reduction", magres.sa[1], magres.sa[0]); + magres = magic_resistance(du); + CuAssertIntEquals_Msg(tc, "no magres reduction", 0, magres.sa[0]); ashield->flags |= ATF_LAEN; - ashield->magres = 0.1; + ashield->magres = v10p; calculate_armor(dt, 0, 0, &magres); + CuAssert(tc, "laen reduction => 10%%", frac_equal(frac_make(9, 10), magres)); free_battle(b); b = NULL; - i_change(&du->items, ishield, 1); i_change(&du->items, ichain, 1); achain->flags |= ATF_LAEN; - achain->magres = 0.1; + achain->magres = v10p; ashield->flags |= ATF_LAEN; - ashield->magres = 0.1; + ashield->magres = v10p; dt.fighter = setup_fighter(&b, du); calculate_armor(dt, 0, 0, &magres); - CuAssertDblEquals_Msg(tc, "laen reduction", 0.81, magres, 0.01); + CuAssert(tc, "2x laen reduction => 81%%", frac_equal(frac_make(81, 100), magres)); free_battle(b); b = NULL; @@ -359,17 +364,20 @@ static void test_magic_resistance(CuTest *tc) set_level(du, SK_MAGIC, 2); dt.fighter = setup_fighter(&b, du); calculate_armor(dt, 0, 0, &magres); - CuAssertDblEquals_Msg(tc, "skill bonus", 0.1, magic_resistance(du), 0.01); - CuAssertDblEquals_Msg(tc, "skill reduction", 0.9, magres, 0.01); - rc->magres = 50; /* percentage, gets added to skill bonus */ + CuAssert(tc, "skill reduction => 90%%", frac_equal(magres, frac_make(9, 10))); + magres = magic_resistance(du); + CuAssert(tc, "skill reduction", frac_equal(magres, v10p)); + rc->magres = v50p; /* percentage, gets added to skill bonus */ calculate_armor(dt, 0, 0, &magres); - CuAssertDblEquals_Msg(tc, "race bonus", 0.6, magic_resistance(du), 0.01); - CuAssertDblEquals_Msg(tc, "race reduction", 0.4, magres, 0.01); + CuAssert(tc, "race reduction => 40%%", frac_equal(magres, frac_make(4, 10))); + magres = magic_resistance(du); + CuAssert(tc, "race bonus => 60%%", frac_equal(magres, frac_make(60, 100))); - rc->magres = 150; /* should not cause negative damage multiplier */ - CuAssertDblEquals_Msg(tc, "magic resistance is never > 0.9", 0.9, magic_resistance(du), 0.01); + rc->magres = frac_make(15, 10); /* 150% resistance should not cause negative damage multiplier */ + magres = magic_resistance(du); + CuAssert(tc, "magic resistance is never > 0.9", frac_equal(magres, frac_make(9, 10))); calculate_armor(dt, 0, 0, &magres); - CuAssertDblEquals_Msg(tc, "damage reduction is never < 0.1", 0.1, magres, 0.01); + CuAssert(tc, "damage reduction is never < 0.1", frac_equal(magres, frac_make(1, 10))); free_battle(b); test_cleanup(); @@ -385,14 +393,15 @@ static void test_projectile_armor(CuTest * tc) armor_type *ashield, *achain; item_type *ishield, *ichain; race *rc; + variant v50p = frac_make(1, 2); test_setup(); r = test_create_region(0, 0, 0); ishield = it_get_or_create(rt_get_or_create("shield")); - ashield = new_armortype(ishield, 0.0, 0.5, 1, ATF_SHIELD); + ashield = new_armortype(ishield, 0.0, v50p, 1, ATF_SHIELD); ichain = it_get_or_create(rt_get_or_create("chainmail")); - achain = new_armortype(ichain, 0.0, 0.5, 3, ATF_NONE); - wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, 0.5, 0, 0, 0, 0, SK_MELEE, 1); + achain = new_armortype(ichain, 0.0, v50p, 3, ATF_NONE); + wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, v50p, 0, 0, 0, 0, SK_MELEE, 1); rc = test_create_race("human"); rc->battle_flags |= BF_EQUIPMENT; du = test_create_unit(test_create_faction(rc), r); diff --git a/src/economy.test.c b/src/economy.test.c index 2de6265f0..4ddd20105 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -211,7 +211,7 @@ static void test_tax_cmd(CuTest *tc) { silver = get_resourcetype(R_SILVER)->itype; sword = it_get_or_create(rt_get_or_create("sword")); - new_weapontype(sword, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 1); + new_weapontype(sword, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 1); i_change(&u->items, sword, 1); set_level(u, SK_MELEE, 1); diff --git a/src/guard.test.c b/src/guard.test.c index fb55129ee..17aa2891c 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -42,7 +42,7 @@ static void test_guard_unskilled(CuTest * tc) test_setup(); itype = it_get_or_create(rt_get_or_create("sword")); - new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2); + new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2); r = test_create_region(0, 0, 0); u = test_create_unit(test_create_faction(0), r); ug = test_create_unit(test_create_faction(0), r); @@ -61,7 +61,7 @@ static void test_guard_armed(CuTest * tc) test_setup(); itype = it_get_or_create(rt_get_or_create("sword")); - new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2); + new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2); r = test_create_region(0, 0, 0); u = test_create_unit(test_create_faction(0), r); ug = test_create_unit(test_create_faction(0), r); @@ -80,7 +80,7 @@ static void test_is_guard(CuTest * tc) test_setup(); itype = it_get_or_create(rt_get_or_create("sword")); - new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2); + new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2); r = test_create_region(0, 0, 0); ug = test_create_unit(test_create_faction(0), r); i_change(&ug->items, itype, 1); diff --git a/src/kernel/building.h b/src/kernel/building.h index 8c23fdb7c..6d66aa9ab 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -60,7 +60,7 @@ extern "C" { int capacity; /* Kapazit�t pro Gr��enpunkt */ int maxcapacity; /* Max. Kapazit�t */ int maxsize; /* how big can it get, with all the extensions? */ - int magres; /* how well it resists against spells */ + variant magres; /* how well it resists against spells */ int magresbonus; /* bonus it gives the target against spells */ int fumblebonus; /* bonus that reduces fumbling */ double auraregen; /* modifier for aura regeneration inside building */ diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index 1286fd6b4..2819d4a16 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -381,7 +381,7 @@ static void test_btype_defaults(CuTest *tc) { CuAssertIntEquals(tc, -1, btype->maxsize); CuAssertIntEquals(tc, 1, btype->capacity); CuAssertIntEquals(tc, -1, btype->maxcapacity); - CuAssertIntEquals(tc, 0, btype->magres); + CuAssertIntEquals(tc, 0, btype->magres.sa[0]); CuAssertIntEquals(tc, 0, btype->magresbonus); CuAssertIntEquals(tc, 0, btype->fumblebonus); CuAssertIntEquals(tc, 0, btype->flags); diff --git a/src/kernel/item.c b/src/kernel/item.c index 9bc321fdb..6e64c147f 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -275,7 +275,7 @@ luxury_type *new_luxurytype(item_type * itype, int price) } weapon_type *new_weapontype(item_type * itype, - int wflags, double magres, const char *damage[], int offmod, int defmod, + int wflags, variant magres, const char *damage[], int offmod, int defmod, int reload, skill_t sk, int minskill) { weapon_type *wtype; @@ -301,7 +301,7 @@ weapon_type *new_weapontype(item_type * itype, return wtype; } -armor_type *new_armortype(item_type * itype, double penalty, double magres, +armor_type *new_armortype(item_type * itype, double penalty, variant magres, int prot, unsigned int flags) { armor_type *atype; diff --git a/src/kernel/item.h b/src/kernel/item.h index 1d3e5ff29..c1ac38517 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -181,7 +181,7 @@ extern "C" { const item_type *itype; unsigned int flags; double penalty; - double magres; + variant magres; int prot; float projectile; /* chance, dass ein projektil abprallt */ } armor_type; @@ -205,7 +205,7 @@ extern "C" { int minskill; int offmod; int defmod; - double magres; + variant magres; int reload; /* time to reload this weapon */ weapon_mod *modifiers; /* --- functions --- */ @@ -244,14 +244,12 @@ extern "C" { /* creation */ resource_type *rt_get_or_create(const char *name); item_type *it_get_or_create(resource_type *rtype); - item_type *new_itemtype(resource_type * rtype, int iflags, int weight, - int capacity); luxury_type *new_luxurytype(item_type * itype, int price); weapon_type *new_weapontype(item_type * itype, int wflags, - double magres, const char *damage[], int offmod, int defmod, int reload, + variant magres, const char *damage[], int offmod, int defmod, int reload, skill_t sk, int minskill); armor_type *new_armortype(item_type * itype, double penalty, - double magres, int prot, unsigned int flags); + variant magres, int prot, unsigned int flags); potion_type *new_potiontype(item_type * itype, int level); typedef enum { diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 2478c838f..287aa61db 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -460,7 +460,7 @@ static void json_race(cJSON *json, race *rc) { break; case cJSON_Number: if (strcmp(child->string, "magres") == 0) { - rc->magres = child->valueint; + rc->magres = frac_make(child->valueint, 100); } else if (strcmp(child->string, "maxaura") == 0) { rc->maxaura = child->valueint; diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index dcf748d00..8b8ac8c14 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -163,8 +163,7 @@ static void test_races(CuTest * tc) CuAssertPtrNotNull(tc, rc); CuAssertIntEquals(tc, RCF_NPC | RCF_WALK | RCF_UNDEAD, rc->flags); CuAssertStrEquals(tc, "1d4", rc->def_damage); - CuAssertIntEquals(tc, 100, rc->magres); - CuAssertDblEquals(tc, 1.0, rc_magres(rc), 0.0); + CuAssertTrue(tc, frac_equal(frac_one, rc->magres)); CuAssertIntEquals(tc, 200, rc->maxaura); CuAssertDblEquals(tc, 2.0, rc_maxaura(rc), 0.0); CuAssertDblEquals(tc, 3.0, rc->regaura, 0.0); diff --git a/src/kernel/race.c b/src/kernel/race.c index 4a3a04916..d159fd6d8 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -331,6 +331,7 @@ race *rc_create(const char *zName) assert(zName); rc = (race *)calloc(sizeof(race), 1); + rc->magres.sa[1] = 1; rc->hitpoints = 1; rc->weight = PERSON_WEIGHT; rc->capacity = 540; @@ -383,8 +384,8 @@ bool r_insectstalled(const region * r) return fval(r->terrain, ARCTIC_REGION); } -double rc_magres(const race *rc) { - return rc->magres / 100.0; +variant rc_magres(const race *rc) { + return rc->magres; } double rc_maxaura(const race *rc) { diff --git a/src/kernel/race.h b/src/kernel/race.h index e464c9447..f14b8e54f 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -116,7 +116,7 @@ extern "C" { typedef struct race { char *_name; - int magres; + variant magres; int healing; int maxaura; /* Faktor auf Maximale Aura */ double regaura; /* Faktor auf Regeneration */ @@ -182,7 +182,7 @@ extern "C" { int rc_luxury_trade(const struct race *rc); int rc_herb_trade(const struct race *rc); - double rc_magres(const struct race *rc); + variant rc_magres(const struct race *rc); double rc_maxaura(const struct race *rc); int rc_armor_bonus(const struct race *rc); int rc_scare(const struct race *rc); diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index 8363d8b72..07ecbdd45 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -24,8 +24,7 @@ static void test_rc_defaults(CuTest *tc) { rc = rc_get_or_create("human"); CuAssertStrEquals(tc, "human", rc->_name); CuAssertIntEquals(tc, 0, rc_armor_bonus(rc)); - CuAssertIntEquals(tc, 0, rc->magres); - CuAssertDblEquals(tc, 0.0, rc_magres(rc), 0.0); + CuAssertIntEquals(tc, 0, rc->magres.sa[0]); CuAssertIntEquals(tc, 0, rc->healing); CuAssertDblEquals(tc, 0.0, rc_maxaura(rc), 0.0); CuAssertDblEquals(tc, 1.0, rc->recruit_multi, 0.0); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 27adba598..74459270c 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -61,6 +61,19 @@ without prior permission by the authors of Eressea. #include #ifdef USE_LIBXML2 + +static variant xml_fraction(xmlNodePtr node, const char *name) { + xmlChar *propValue = xmlGetProp(node, BAD_CAST name); + if (propValue != NULL) { + int num, den = 100; + double fval = atof((const char *)propValue); + num = (int)(fval * den + 0.5); + xmlFree(propValue); + return frac_make(num, den); + } + return frac_make(0, 1); +} + static void xml_readtext(xmlNodePtr node, struct locale **lang, xmlChar ** text) { xmlChar *propValue = xmlGetProp(node, BAD_CAST "locale"); @@ -245,7 +258,7 @@ static int parse_buildings(xmlDocPtr doc) btype->maxcapacity = xml_ivalue(node, "maxcapacity", btype->maxcapacity); btype->maxsize = xml_ivalue(node, "maxsize", btype->maxsize); - btype->magres = xml_ivalue(node, "magres", btype->magres); + btype->magres = frac_make(xml_ivalue(node, "magres", 0), 100); btype->magresbonus = xml_ivalue(node, "magresbonus", btype->magresbonus); btype->fumblebonus = xml_ivalue(node, "fumblebonus", btype->fumblebonus); btype->auraregen = xml_fvalue(node, "auraregen", btype->auraregen); @@ -582,7 +595,7 @@ static armor_type *xml_readarmor(xmlXPathContextPtr xpath, item_type * itype) unsigned int flags = ATF_NONE; int ac = xml_ivalue(node, "ac", 0); double penalty = xml_fvalue(node, "penalty", 0.0); - double magres = xml_fvalue(node, "magres", 0.0); + variant magres = xml_fraction(node, "magres"); if (xml_bvalue(node, "laen", false)) flags |= ATF_LAEN; @@ -607,7 +620,7 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype) int offmod = xml_ivalue(node, "offmod", 0); int defmod = xml_ivalue(node, "defmod", 0); int reload = xml_ivalue(node, "reload", 0); - double magres = xml_fvalue(node, "magres", 0.0); + variant magres = xml_fraction(node, "magres"); if (xml_bvalue(node, "armorpiercing", false)) flags |= WTF_ARMORPIERCING; @@ -899,22 +912,6 @@ static int parse_rules(xmlDocPtr doc) return 0; } -static int gcd(int num, int den) { - const int primes[] = { 3, 5, 7, 11, 0 }; - int i=0, g = 1, p = 2; - while (p && p<=den && p<=num) { - if (num % p == 0 && den % p == 0) { - num /= p; - den /= p; - g *= p; - } - else { - p = primes[i++]; - } - } - return g; -} - static int parse_resources(xmlDocPtr doc) { xmlXPathContextPtr xpath = xmlXPathNewContext(doc); @@ -1031,15 +1028,7 @@ static int parse_resources(xmlDocPtr doc) rdata->modifiers[k].flags = RMF_SKILL; } else if (strcmp((const char *)propValue, "material") == 0) { - int g, num, den = 100; - double fval = xml_fvalue(node, "value", 0); - /* TODO: extract into a function for reading fractions? */ - num = (int)(fval * den + 0.5); - g = gcd(num, den); - num /= g; - den /= g; - rdata->modifiers[k].value.sa[0] = (short)num; - rdata->modifiers[k].value.sa[1] = (short)den; + rdata->modifiers[k].value = xml_fraction(node, "value"); rdata->modifiers[k].flags = RMF_SAVEMATERIAL; } else if (strcmp((const char *)propValue, "require") == 0) { @@ -1623,7 +1612,7 @@ static int parse_races(xmlDocPtr doc) rc->def_damage = strdup((const char *)propValue); xmlFree(propValue); - rc->magres = xml_ivalue(node, "magres", rc->magres); + rc->magres = frac_make(xml_ivalue(node, "magres", 100), 100); rc->healing = (int)(xml_fvalue(node, "healing", rc->healing) * 100); /* TODO: store as int in XML */ rc->maxaura = (int)(xml_fvalue(node, "maxaura", rc->maxaura) * 100); /* TODO: store as int in XML */ rc->regaura = (float)xml_fvalue(node, "regaura", rc->regaura); diff --git a/src/laws.test.c b/src/laws.test.c index cca55beb1..c27651d83 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -611,7 +611,7 @@ void setup_guard(guard_fixture *fix, bool armed) { if (armed) { item_type *itype; itype = it_get_or_create(rt_get_or_create("sword")); - new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2); + new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2); i_change(&u->items, itype, 1); set_level(u, SK_MELEE, 2); } @@ -1481,7 +1481,7 @@ static void test_armedmen(CuTest *tc) { test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); it_sword = test_create_itemtype("sword"); - wtype = new_weapontype(it_sword, 0, 0.5, 0, 0, 0, 0, SK_MELEE, 1); + wtype = new_weapontype(it_sword, 0, frac_make(1, 2), 0, 0, 0, 0, SK_MELEE, 1); CuAssertIntEquals(tc, 0, armedmen(u, false)); CuAssertIntEquals(tc, 0, armedmen(u, true)); set_level(u, SK_MELEE, 1); diff --git a/src/magic.c b/src/magic.c index 65b454c04..de1336d66 100644 --- a/src/magic.c +++ b/src/magic.c @@ -1135,27 +1135,29 @@ static int farcasting(unit * magician, region * r) /* allgemeine Magieresistenz einer Einheit, * reduziert magischen Schaden */ -double magic_resistance(unit * target) +variant magic_resistance(unit * target) { attrib *a; curse *c; const curse_type * ct_goodresist = 0, *ct_badresist = 0; const resource_type *rtype; const race *rc = u_race(target); - double probability = rc_magres(rc); + variant v, prob = rc_magres(rc); const plane *pl = rplane(target->region); if (rc == get_race(RC_HIRNTOETER) && !pl) { - probability /= 2; + prob.sa[1] *= 2; } assert(target->number > 0); /* Magier haben einen Resistenzbonus vom Magietalent * 5% */ - probability += effskill(target, SK_MAGIC, 0) * 0.05; + prob = frac_add(prob, frac_make(effskill(target, SK_MAGIC, 0), 20)); /* Auswirkungen von Zaubern auf der Einheit */ c = get_curse(target->attribs, ct_find("magicresistance")); if (c) { - probability += 0.01 * curse_geteffect(c) * get_cursedmen(target, c); + /* TODO: legacy. magicresistance-effect is an integer-percentage stored in a double */ + int effect = curse_geteffect_int(c) * get_cursedmen(target, c); + prob = frac_add(prob, frac_make(effect, 100)); } /* Unicorn +10 */ @@ -1163,7 +1165,7 @@ double magic_resistance(unit * target) if (rtype) { int n = i_get(target->items, rtype->itype); if (n) { - probability += n * 0.1 / target->number; + prob = frac_add(prob, frac_make(n, target->number * 10)); } } @@ -1180,13 +1182,15 @@ double magic_resistance(unit * target) if (mage != NULL) { if (ct_goodresist && c->type == ct_goodresist) { if (alliedunit(mage, target->faction, HELP_GUARD)) { - probability += curse_geteffect(c) * 0.01; + /* TODO: legacy. magicresistance-effect is an integer-percentage stored in a double */ + prob = frac_add(prob, frac_make(curse_geteffect_int(c), 100)); ct_goodresist = 0; /* only one effect per region */ } } else if (ct_badresist && c->type == ct_badresist) { if (!alliedunit(mage, target->faction, HELP_GUARD)) { - probability -= curse_geteffect(c) * 0.01; + /* TODO: legacy. magicresistance-effect is an integer-percentage stored in a double */ + prob = frac_sub(prob, frac_make(curse_geteffect_int(c), 100)); ct_badresist = 0; /* only one effect per region */ } } @@ -1202,11 +1206,18 @@ double magic_resistance(unit * target) const struct building_type *btype = building_is_active(b) ? b->type : NULL; /* gesegneter Steinkreis gibt 30% dazu */ - if (btype) - probability += btype->magresbonus * 0.01; + if (btype) { + /* TODO: legacy. building-bonus is an integer-percentage */ + prob = frac_add(prob, frac_make(btype->magresbonus, 100)); + } } - return (probability<0.9) ? probability : 0.9; + /* resistance must never be more than 90% */ + v = frac_make(9, 10); + if (frac_sign(frac_sub(prob, v)) > 0) { /* prob < 90% */ + return v; /* at most 90% */ + } + return prob; } /* ------------------------------------------------------------- */ @@ -1223,12 +1234,12 @@ double magic_resistance(unit * target) bool target_resists_magic(unit * magician, void *obj, int objtyp, int t_bonus) { - double probability = 0.0; + variant v02p, v98p, prob = frac_make(t_bonus, 100); + attrib *a = NULL; - if (magician == NULL) - return true; - if (obj == NULL) + if (magician == NULL || obj == NULL) { return true; + } switch (objtyp) { case TYP_UNIT: @@ -1248,43 +1259,56 @@ target_resists_magic(unit * magician, void *obj, int objtyp, int t_bonus) pa = sk; } - /* Contest */ - probability = 0.05 * (10 + pa - at); - - probability += magic_resistance((unit *)obj); + /* Contest, probability = 0.05 * (10 + pa - at); */ + prob = frac_add(prob, frac_make(10 + pa - at, 20)); + prob = frac_add(prob, magic_resistance((unit *)obj)); break; } case TYP_REGION: - /* Bonus durch Zauber */ + /* Bonus durch Zauber probability += - 0.01 * get_curseeffect(((region *)obj)->attribs, C_RESIST_MAGIC, 0); + 0.01 * get_curseeffect(((region *)obj)->attribs, C_RESIST_MAGIC, 0); */ + a = ((region *)obj)->attribs; break; case TYP_BUILDING: - /* Bonus durch Zauber */ + /* Bonus durch Zauber probability += - 0.01 * get_curseeffect(((building *)obj)->attribs, C_RESIST_MAGIC, 0); - - /* Bonus durch Typ */ - probability += 0.01 * ((building *)obj)->type->magres; - + 0.01 * get_curseeffect(((building *)obj)->attribs, C_RESIST_MAGIC, 0); */ + a = ((building *)obj)->attribs; + /* Bonus durch Typ + probability += 0.01 * ((building *)obj)->type->magres; */ + prob = frac_add(prob, ((building *)obj)->type->magres); break; case TYP_SHIP: /* Bonus durch Zauber */ - probability += - 0.01 * get_curseeffect(((ship *)obj)->attribs, C_RESIST_MAGIC, 0); + a = ((ship *)obj)->attribs; break; } - probability = MAX(0.02, probability + t_bonus * 0.01); - probability = MIN(0.98, probability); + if (a) { + const struct curse_type *ct_resist = ct_find(oldcursename(C_RESIST_MAGIC)); + curse * c = get_curse(a, ct_resist); + int effect = curse_geteffect_int(c); + prob = frac_add(prob, frac_make(effect, 100)); + } + + /* ignore results < 2% and > 98% */ + v02p = frac_make(1, 50); + v98p = frac_make(49, 50); + if (frac_sign(frac_sub(prob, v02p)) < 0) { + prob = v02p; + } + else if (frac_sign(frac_sub(prob, v98p)) > 0) { + prob = v98p; + } /* gibt true, wenn die Zufallszahl kleiner als die chance ist und * false, wenn sie gleich oder größer ist, dh je größer die * Magieresistenz (chance) desto eher gibt die Funktion true zurück */ - return chance(probability); + return rng_int() % prob.sa[1] < prob.sa[0]; } /* ------------------------------------------------------------- */ diff --git a/src/magic.h b/src/magic.h index d282767a9..37fe33eae 100644 --- a/src/magic.h +++ b/src/magic.h @@ -315,7 +315,7 @@ extern "C" { bool is_magic_resistant(struct unit *magician, struct unit *target, int resist_bonus); /* Mapperfunktion fr target_resists_magic() vom Typ struct unit. */ - extern double magic_resistance(struct unit *target); + variant magic_resistance(struct unit *target); /* gibt die Chance an, mit der einem Zauber widerstanden wird. Je * grer, desto resistenter ist da Opfer */ bool target_resists_magic(struct unit *magician, void *obj, int objtyp, diff --git a/src/magic.test.c b/src/magic.test.c index baf8ede50..a5a842172 100644 --- a/src/magic.test.c +++ b/src/magic.test.c @@ -414,15 +414,15 @@ static void test_magic_resistance(CuTest *tc) { test_setup(); rc = test_create_race("human"); u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); - CuAssertDblEquals(tc, rc->magres/100.0, magic_resistance(u), 0.01); - rc->magres = 100; - CuAssertDblEquals_Msg(tc, "magic resistance is capped at 0.9", 0.9, magic_resistance(u), 0.01); + CuAssertTrue(tc, frac_equal(rc->magres, magic_resistance(u))); + rc->magres = frac_one; + CuAssert(tc, "magic resistance is capped at 0.9", frac_equal(magic_resistance(u), frac_make(9, 10))); rc = test_create_race("braineater"); - rc->magres = 100; + rc->magres = frac_one; u_setrace(u, rc); - CuAssertDblEquals_Msg(tc, "brain eaters outside astral space have 50% magres", 0.5, magic_resistance(u), 0.01); + CuAssert(tc, "brain eaters outside astral space have 50% magres", frac_equal(magic_resistance(u), frac_make(1, 2))); u->region->_plane = get_astralplane(); - CuAssertDblEquals_Msg(tc, "brain eaters in astral space have full magres", 0.9, magic_resistance(u), 0.01); + CuAssert(tc, "brain eaters in astral space have full magres", frac_equal(magic_resistance(u), frac_make(9, 10))); test_cleanup(); } diff --git a/src/spells.c b/src/spells.c index 95b26434f..fcee1b51b 100644 --- a/src/spells.c +++ b/src/spells.c @@ -2851,7 +2851,8 @@ static int dc_age(struct curse *c) while (*up != NULL) { unit *u = *up; int hp; - double damage = c->effect * u->number; + variant dmg = frac_make(u->number, 1); + double damage = c->effect; if (u->number <= 0 || target_resists_magic(mage, u, TYP_UNIT, 0)) { up = &u->next; @@ -2859,7 +2860,9 @@ static int dc_age(struct curse *c) } /* Reduziert durch Magieresistenz */ - damage *= (1.0 - magic_resistance(u)); + dmg = frac_mul(dmg, frac_sub(frac_make(1,1), magic_resistance(u))); + damage *= dmg.sa[0]; + damage /= dmg.sa[1]; hp = change_hitpoints(u, -(int)damage); ADDMSG(&u->faction->msgs, msg_message((hp>0)?"poison_damage":"poison_death", "region unit", r, u)); diff --git a/src/spy.test.c b/src/spy.test.c index 8341b17d3..ae1550689 100644 --- a/src/spy.test.c +++ b/src/spy.test.c @@ -71,7 +71,7 @@ static void test_all_spy_message(CuTest *tc) { set_factionstealth(fix.victim, fix.spy->faction); itype = it_get_or_create(rt_get_or_create("sword")); - new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2); + new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2); i_change(&fix.victim->items, itype, 1); spy_message(99, fix.spy, fix.victim); diff --git a/src/volcano.c b/src/volcano.c index fb4cfa74c..9734bb2cd 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -80,7 +80,6 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic) int *hp, hpstack[20]; int h; int i, dead = 0, hp_rem = 0, heiltrank; - double magres = magic_resistance(u); assert(u->number); if (fval(u_race(u), RCF_ILLUSIONARY) || u_race(u) == get_race(RC_SPELL)) { @@ -105,10 +104,14 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic) /* Schaden */ for (i = 0; i < u->number; i++) { int damage = dice_rand(dam); - if (magic) - damage = (int)(damage * (1.0 - magres)); - if (physical) + if (magic) { + variant magres = magic_resistance(u); + magres = frac_sub(frac_make(1, 1), magres); + damage = damage * magres.sa[0] / magres.sa[1]; + } + if (physical) { damage -= nb_armor(u, i); + } hp[i] -= damage; } From 6031dff6850ec50b61d1f937383cce353390fcbb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 25 Feb 2017 19:50:32 +0100 Subject: [PATCH 575/675] resource_limit.value is always zero, never initialized. kill it. --- clibs | 2 +- src/economy.c | 4 ++-- src/economy.test.c | 1 - src/kernel/resources.h | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/clibs b/clibs index 27c8b3202..b91413316 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 +Subproject commit b91413316ce13044c555084a9f605983586107b4 diff --git a/src/economy.c b/src/economy.c index f0a693eca..f9ded29de 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1123,7 +1123,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) allocation *al; int nreq = 0; resource_limit *rdata = get_resourcelimit(rtype); - int avail = rdata->value; + int avail = 0; for (al = alist; al; al = al->next) { nreq += required(al->want, al->save); @@ -1165,7 +1165,7 @@ static allocate_function get_allocator(const struct resource_type *rtype) resource_limit *rdata = get_resourcelimit(rtype); if (rdata) { - if (rdata->value > 0 || rdata->limit != NULL) { + if (rdata->limit != NULL) { return attrib_allocation; } return leveled_allocation; diff --git a/src/economy.test.c b/src/economy.test.c index 4ddd20105..aea42491d 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -384,7 +384,6 @@ static void test_make_item(CuTest *tc) { rtype->flags |= RTF_LIMITED; rmt = rmt_create(rtype); rdata = rtype->limit = calloc(1, sizeof(resource_limit)); - rdata->value = 0; add_resource(u->region, 1, 300, 150, rtype); u->region->resources->amount = 300; /* there are 300 stones at level 1 */ set_level(u, SK_ALCHEMY, 10); diff --git a/src/kernel/resources.h b/src/kernel/resources.h index 3e93ea1de..d7c0e5bfd 100644 --- a/src/kernel/resources.h +++ b/src/kernel/resources.h @@ -58,7 +58,6 @@ extern "C" { typedef struct resource_limit { rlimit_limit limit; rlimit_produce produce; - int value; resource_mod *modifiers; } resource_limit; From d039ca2b2ed552d959da14712aa0a334b63d1946 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 25 Feb 2017 21:07:13 +0100 Subject: [PATCH 576/675] fix display of sapling and mallornsapling. remove mateiral from XML where it's not needed. --- res/core/de/strings.xml | 40 ++-------------------------------- res/core/resources/horse.xml | 2 +- res/core/resources/log.xml | 2 +- res/core/resources/mallorn.xml | 2 +- 4 files changed, 5 insertions(+), 41 deletions(-) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 5bde79c29..26e8cc862 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -6611,53 +6611,17 @@ EINLADEN INVITE - - Steine - stones - - - Pferde - horses - - - Bauern - peasants - - - Silber - silver - - - Laen - laen - - - + Schößlinge saplings - + Mallornschößlinge mallorn saplings - - Bäume - trees - - - - Mallorn - mallorn - - - - Eisen - iron - - Winter winter diff --git a/res/core/resources/horse.xml b/res/core/resources/horse.xml index 53699c696..d7f794491 100644 --- a/res/core/resources/horse.xml +++ b/res/core/resources/horse.xml @@ -1,5 +1,5 @@ - + diff --git a/res/core/resources/log.xml b/res/core/resources/log.xml index e3a33ef8b..48662878f 100644 --- a/res/core/resources/log.xml +++ b/res/core/resources/log.xml @@ -1,5 +1,5 @@ - + diff --git a/res/core/resources/mallorn.xml b/res/core/resources/mallorn.xml index fc678e79e..96892b802 100644 --- a/res/core/resources/mallorn.xml +++ b/res/core/resources/mallorn.xml @@ -1,5 +1,5 @@ - + From 84c6a4b7b56d1bd6b96a874d0e85e2126959fa14 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 25 Feb 2017 21:24:47 +0100 Subject: [PATCH 577/675] remove last vestiges of the rm_* material names --- clibs | 2 +- res/adamantium.xml | 2 +- res/core/resources/iron.xml | 2 +- res/core/resources/laen.xml | 2 +- res/core/resources/stone.xml | 2 +- res/e3a/resources/iron.xml | 2 +- res/e3a/resources/stone.xml | 2 +- src/economy.test.c | 3 +-- src/kernel/xmlreader.c | 4 +--- 9 files changed, 9 insertions(+), 12 deletions(-) diff --git a/clibs b/clibs index b91413316..27c8b3202 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit b91413316ce13044c555084a9f605983586107b4 +Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 diff --git a/res/adamantium.xml b/res/adamantium.xml index decc5636c..bb94dfc12 100644 --- a/res/adamantium.xml +++ b/res/adamantium.xml @@ -1,7 +1,7 @@ - + diff --git a/res/core/resources/iron.xml b/res/core/resources/iron.xml index 3f8897abc..469840669 100644 --- a/res/core/resources/iron.xml +++ b/res/core/resources/iron.xml @@ -1,5 +1,5 @@ - + diff --git a/res/core/resources/laen.xml b/res/core/resources/laen.xml index 12062bf07..30531c0fe 100644 --- a/res/core/resources/laen.xml +++ b/res/core/resources/laen.xml @@ -1,5 +1,5 @@ - + diff --git a/res/core/resources/stone.xml b/res/core/resources/stone.xml index c227dcc5c..91d3aac5d 100644 --- a/res/core/resources/stone.xml +++ b/res/core/resources/stone.xml @@ -1,5 +1,5 @@ - + diff --git a/res/e3a/resources/iron.xml b/res/e3a/resources/iron.xml index 06b70e45a..7ffe36f1e 100644 --- a/res/e3a/resources/iron.xml +++ b/res/e3a/resources/iron.xml @@ -1,5 +1,5 @@ - + diff --git a/res/e3a/resources/stone.xml b/res/e3a/resources/stone.xml index 746b79c21..dfb039093 100644 --- a/res/e3a/resources/stone.xml +++ b/res/e3a/resources/stone.xml @@ -1,5 +1,5 @@ - + diff --git a/src/economy.test.c b/src/economy.test.c index aea42491d..6d9c84542 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -348,7 +348,6 @@ static void test_make_item(CuTest *tc) { struct item_type *itype; const struct resource_type *rt_silver; resource_type *rtype; - rawmaterial_type *rmt; resource_limit *rdata; double d = 0.6; @@ -382,7 +381,7 @@ static void test_make_item(CuTest *tc) { free(itype->construction->materials); itype->construction->materials = 0; rtype->flags |= RTF_LIMITED; - rmt = rmt_create(rtype); + rmt_create(rtype); rdata = rtype->limit = calloc(1, sizeof(resource_limit)); add_resource(u->region, 1, 300, 150, rtype); u->region->resources->amount = 300; /* there are 300 stones at level 1 */ diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 74459270c..737a12f66 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -978,10 +978,8 @@ static int parse_resources(xmlDocPtr doc) } xmlXPathFreeObject(result); - name = xmlGetProp(node, BAD_CAST "material"); - if (name) { + if (xml_bvalue(node, "material", false)) { rmt_create(rtype); - xmlFree(name); } /* reading eressea/resources/resource/resourcelimit */ From 114d088bb502c1f7173b7586b1edef59ecb5b2d2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 13:08:50 +0100 Subject: [PATCH 578/675] allow testers.txt to contain comments --- s/preview | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s/preview b/s/preview index 0c1467627..1607afc55 100755 --- a/s/preview +++ b/s/preview @@ -160,7 +160,7 @@ case "$1" in done if [ $sent -eq 0 ]; then if [ -e ../$factions ]; then - for faction in $(cat ../$factions) ; do + for faction in $(grep -v -E '^#' ../$factions) ; do send $faction done fi From 7a1cebb25977571ccd02e18674f7cc01db3fe708 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 13:10:23 +0100 Subject: [PATCH 579/675] silence the preview-build --- s/preview | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s/preview b/s/preview index 1607afc55..40dc2952c 100755 --- a/s/preview +++ b/s/preview @@ -27,7 +27,7 @@ git fetch || abort "failed to update source. do you have local changes?" [ -z $1 ] || git checkout $1 git pull git submodule update -s/build || abort "build failed." +s/build > /dev/null || abort "build failed." } function assert_file() { From f4180638af0bf83b68621245bfe57f681c658ca6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 13:12:47 +0100 Subject: [PATCH 580/675] also silence the git pull command and valgrind --- s/preview | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s/preview b/s/preview index 40dc2952c..68fe6e39f 100755 --- a/s/preview +++ b/s/preview @@ -25,7 +25,7 @@ cd $SOURCE rm -rf crypto tolua git fetch || abort "failed to update source. do you have local changes?" [ -z $1 ] || git checkout $1 -git pull +git pull -q git submodule update s/build > /dev/null || abort "build failed." } @@ -79,7 +79,7 @@ SUPP="$SOURCE/share/debian-7_8.supp" SERVER="$SOURCE/Debug/eressea/eressea" VALGRIND=$(which valgrind) if [ ! -z $VALGRIND ]; then -SERVER="$VALGRIND --suppressions=$SUPP --error-exitcode=1 --leak-check=no $SERVER" +SERVER="$VALGRIND --quiet --suppressions=$SUPP --error-exitcode=1 --leak-check=no $SERVER" fi $SERVER -v$verbose -t$turn $SOURCE/scripts/run-turn.lua let turn=$turn+1 From 0738090f281811d72d4a55aafebeae34545b0274 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 13:19:47 +0100 Subject: [PATCH 581/675] no more funpointers in resource_limit. change how resource limits in lua are called. --- src/economy.c | 34 +++++++++++++--------------------- src/helpers.c | 11 +++++------ src/kernel/resources.c | 21 +++++++++++++++++++++ src/kernel/resources.h | 13 ++++++------- src/kernel/xmlreader.c | 35 ----------------------------------- 5 files changed, 45 insertions(+), 69 deletions(-) diff --git a/src/economy.c b/src/economy.c index f9ded29de..b1b9afb32 100644 --- a/src/economy.c +++ b/src/economy.c @@ -914,10 +914,6 @@ struct message * get_modifiers(unit *u, const resource_mod *mod, variant *savep, return NULL; } -static resource_limit *get_resourcelimit(const resource_type *rtype) { - return rtype->limit; -} - static void allocate_resource(unit * u, const resource_type * rtype, int want) { const item_type *itype = resource2item(rtype); @@ -925,7 +921,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) int dm = 0; allocation_list *alist; allocation *al; - resource_limit *rdata = get_resourcelimit(rtype); + resource_limit *rdata = rtype->limit; const resource_type *rring; int amount, skill, skill_mod = 0; variant save_mod; @@ -936,8 +932,8 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) || itype->construction->materials == NULL)); assert(rdata != NULL); - if (rdata->limit != NULL) { - int avail = rdata->limit(r, rtype); + if (!rtype->raw) { + int avail = limit_resource(r, rtype); if (avail <= 0) { cmistake(u, u->thisorder, 121, MSG_PRODUCE); return; @@ -1122,17 +1118,17 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) { allocation *al; int nreq = 0; - resource_limit *rdata = get_resourcelimit(rtype); int avail = 0; for (al = alist; al; al = al->next) { nreq += required(al->want, al->save); } - if (rdata->limit) { - avail = rdata->limit(r, rtype); - if (avail < 0) + if (!rtype->raw) { + avail = limit_resource(r, rtype); + if (avail < 0) { avail = 0; + } } avail = MIN(avail, nreq); @@ -1147,10 +1143,11 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) nreq -= want; al->get = x * al->save.sa[0] / al->save.sa[1]; al->get = MIN(al->want, al->get); - if (rdata->produce) { + if (!rtype->raw) { int use = required(al->get, al->save); - if (use) - rdata->produce(r, rtype, use); + if (use) { + produce_resource(r, rtype, use); + } } } } @@ -1162,15 +1159,10 @@ typedef void(*allocate_function) (const resource_type *, struct region *, static allocate_function get_allocator(const struct resource_type *rtype) { - resource_limit *rdata = get_resourcelimit(rtype); - - if (rdata) { - if (rdata->limit != NULL) { - return attrib_allocation; - } + if (rtype->raw) { return leveled_allocation; } - return NULL; + return attrib_allocation; } void split_allocations(region * r) diff --git a/src/helpers.c b/src/helpers.c index e9502e075..ad222a0c6 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -27,6 +27,7 @@ without prior permission by the authors of Eressea. #include #include #include +#include #include #include #include @@ -78,7 +79,7 @@ lua_giveitem(unit * s, unit * d, const item_type * itype, int n, struct order *o return result; } -static int limit_resource(const region * r, const resource_type * rtype) +static int limit_resource_lua(const region * r, const resource_type * rtype) { char fname[64]; int result = -1; @@ -110,7 +111,7 @@ static int limit_resource(const region * r, const resource_type * rtype) } static void -produce_resource(region * r, const resource_type * rtype, int norders) +produce_resource_lua(region * r, const resource_type * rtype, int norders) { lua_State *L = (lua_State *)global.vm_state; char fname[64]; @@ -564,9 +565,7 @@ void register_tolua_helpers(void) register_function((pf_generic)lua_maintenance, TOLUA_CAST "lua_maintenance"); - register_function((pf_generic)produce_resource, - TOLUA_CAST "lua_produceresource"); - register_function((pf_generic)limit_resource, - TOLUA_CAST "lua_limitresource"); + res_produce_fun = produce_resource_lua; + res_limit_fun = limit_resource_lua; register_item_give(lua_giveitem, TOLUA_CAST "lua_giveitem"); } diff --git a/src/kernel/resources.c b/src/kernel/resources.c index ae93d542a..f99783763 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -69,6 +69,7 @@ const resource_type * rtype) rm->divisor = divisor; rm->flags = 0; rm->type = rmt_get(rtype); + assert(rm->type); update_resource(rm, 1.0); rm->type->terraform(rm, r); } @@ -211,3 +212,23 @@ struct rawmaterial_type *rmt_create(struct resource_type *rtype) rmtype->visible = visible_default; return rmtype; } + +int(*res_limit_fun)(const struct region *, const struct resource_type *); +void(*res_produce_fun)(struct region *, const struct resource_type *, int); + +int limit_resource(const struct region *r, const resource_type *rtype) +{ + assert(!rtype->raw); + if (res_limit_fun) { + return res_limit_fun(r, rtype); + } + return -1; +} + +void produce_resource(struct region *r, const struct resource_type *rtype, int amount) +{ + assert(!rtype->raw); + if (res_produce_fun) { + res_produce_fun(r, rtype, amount); + } +} diff --git a/src/kernel/resources.h b/src/kernel/resources.h index d7c0e5bfd..6ee021fc1 100644 --- a/src/kernel/resources.h +++ b/src/kernel/resources.h @@ -43,11 +43,6 @@ extern "C" { struct rawmaterial *next; } rawmaterial; - typedef int(*rlimit_limit) (const struct region * r, - const struct resource_type * rtype); - typedef void(*rlimit_produce) (struct region * r, - const struct resource_type * rtype, int n); - typedef struct resource_mod { variant value; const struct building_type *btype; @@ -56,8 +51,6 @@ extern "C" { } resource_mod; typedef struct resource_limit { - rlimit_limit limit; - rlimit_produce produce; resource_mod *modifiers; } resource_limit; @@ -83,6 +76,12 @@ extern "C" { const struct resource_type *rtype); struct rawmaterial_type *rmt_create(struct resource_type *rtype); + extern int(*res_limit_fun)(const struct region *, const struct resource_type *); + extern void(*res_produce_fun)(struct region *, const struct resource_type *, int); + + int limit_resource(const struct region *r, const struct resource_type *rtype); + void produce_resource(struct region *r, const struct resource_type *rtype, int amount); + #ifdef __cplusplus } #endif diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 737a12f66..ae8a76163 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -933,8 +933,6 @@ static int parse_resources(xmlDocPtr doc) if (xml_bvalue(node, "pooled", true)) flags |= RTF_POOLED; - if (xml_bvalue(node, "limited", false)) - flags |= RTF_LIMITED; name = xmlGetProp(node, BAD_CAST "name"); if (!name) { @@ -1044,39 +1042,6 @@ static int parse_resources(xmlDocPtr doc) xmlFree(propValue); } } - xmlXPathFreeObject(result); - - /* reading eressea/resources/resource/resourcelimit/function */ - result = xmlXPathEvalExpression(BAD_CAST "function", xpath); - if (result->nodesetval != NULL) { - for (k = 0; k != result->nodesetval->nodeNr; ++k) { - xmlNodePtr node = result->nodesetval->nodeTab[k]; - pf_generic fun; - - propValue = xmlGetProp(node, BAD_CAST "value"); - assert(propValue != NULL); - fun = get_function((const char *)propValue); - if (fun == NULL) { - log_error("unknown limit '%s' for resource %s\n", (const char *)propValue, rtype->_name); - xmlFree(propValue); - continue; - } - xmlFree(propValue); - - propValue = xmlGetProp(node, BAD_CAST "name"); - assert(propValue != NULL); - if (strcmp((const char *)propValue, "produce") == 0) { - rdata->produce = (rlimit_produce)fun; - } - else if (strcmp((const char *)propValue, "limit") == 0) { - rdata->limit = (rlimit_limit)fun; - } - else { - log_error("unknown limit '%s' for resource %s\n", (const char *)propValue, rtype->_name); - } - xmlFree(propValue); - } - } } xmlXPathFreeObject(result); /* reading eressea/resources/resource/resourcelimit/function */ From c3b0b9e8b339fee47f065e67762aef0d5d0a4af9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 13:47:22 +0100 Subject: [PATCH 582/675] fix missing limit-flags. --- res/core/resources/horse.xml | 4 ---- res/core/resources/log.xml | 4 +--- res/core/resources/mallorn.xml | 4 +--- res/core/resources/mallornseed.xml | 4 ---- res/core/resources/seed.xml | 4 ---- src/economy.c | 3 +-- src/kernel/xmlreader.c | 4 +++- 7 files changed, 6 insertions(+), 21 deletions(-) diff --git a/res/core/resources/horse.xml b/res/core/resources/horse.xml index d7f794491..243b547db 100644 --- a/res/core/resources/horse.xml +++ b/res/core/resources/horse.xml @@ -4,8 +4,4 @@ - - - - diff --git a/res/core/resources/log.xml b/res/core/resources/log.xml index 48662878f..3a1e8db50 100644 --- a/res/core/resources/log.xml +++ b/res/core/resources/log.xml @@ -1,12 +1,10 @@ - + - - diff --git a/res/core/resources/mallorn.xml b/res/core/resources/mallorn.xml index 96892b802..39a0230d1 100644 --- a/res/core/resources/mallorn.xml +++ b/res/core/resources/mallorn.xml @@ -1,12 +1,10 @@ - + - - diff --git a/res/core/resources/mallornseed.xml b/res/core/resources/mallornseed.xml index 01b8a3416..7a5a0310f 100644 --- a/res/core/resources/mallornseed.xml +++ b/res/core/resources/mallornseed.xml @@ -3,8 +3,4 @@ - - - - diff --git a/res/core/resources/seed.xml b/res/core/resources/seed.xml index 2bda26eeb..99f5f5804 100644 --- a/res/core/resources/seed.xml +++ b/res/core/resources/seed.xml @@ -3,8 +3,4 @@ - - - - diff --git a/src/economy.c b/src/economy.c index b1b9afb32..f7f23eb16 100644 --- a/src/economy.c +++ b/src/economy.c @@ -930,7 +930,6 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) * Materialverbrauch hat: */ assert(itype != NULL && (itype->construction == NULL || itype->construction->materials == NULL)); - assert(rdata != NULL); if (!rtype->raw) { int avail = limit_resource(r, rtype); @@ -945,7 +944,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) return; } - if (rdata->modifiers) { + if (rdata && rdata->modifiers) { message *msg = get_modifiers(u, rdata->modifiers, &save_mod, &skill_mod); if (msg) { ADDMSG(&u->faction->msgs, msg); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index ae8a76163..d4c31001e 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -980,6 +980,9 @@ static int parse_resources(xmlDocPtr doc) rmt_create(rtype); } + if (xml_bvalue(node, "limited", false)) { + rtype->flags |= RTF_LIMITED; + } /* reading eressea/resources/resource/resourcelimit */ xpath->node = node; result = xmlXPathEvalExpression(BAD_CAST "resourcelimit", xpath); @@ -988,7 +991,6 @@ static int parse_resources(xmlDocPtr doc) resource_limit *rdata = rtype->limit = calloc(1, sizeof(resource_limit)); xmlNodePtr limit = result->nodesetval->nodeTab[0]; - rtype->flags |= RTF_LIMITED; xpath->node = limit; xmlXPathFreeObject(result); From d4b973fea4eb2791693f052cf1aca07a4511b23a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 13:55:19 +0100 Subject: [PATCH 583/675] remove resource_limit struct indirection. --- src/economy.c | 5 ++--- src/economy.test.c | 18 ++++++++---------- src/kernel/item.c | 9 +++------ src/kernel/item.h | 4 ++-- src/kernel/resources.h | 4 ---- src/kernel/xmlreader.c | 19 +++++++++---------- 6 files changed, 24 insertions(+), 35 deletions(-) diff --git a/src/economy.c b/src/economy.c index f7f23eb16..ab6862aa4 100644 --- a/src/economy.c +++ b/src/economy.c @@ -921,7 +921,6 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) int dm = 0; allocation_list *alist; allocation *al; - resource_limit *rdata = rtype->limit; const resource_type *rring; int amount, skill, skill_mod = 0; variant save_mod; @@ -944,8 +943,8 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) return; } - if (rdata && rdata->modifiers) { - message *msg = get_modifiers(u, rdata->modifiers, &save_mod, &skill_mod); + if (rtype->modifiers) { + message *msg = get_modifiers(u, rtype->modifiers, &save_mod, &skill_mod); if (msg) { ADDMSG(&u->faction->msgs, msg); return; diff --git a/src/economy.test.c b/src/economy.test.c index 6d9c84542..8b1b0b0fa 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -348,7 +348,6 @@ static void test_make_item(CuTest *tc) { struct item_type *itype; const struct resource_type *rt_silver; resource_type *rtype; - resource_limit *rdata; double d = 0.6; test_setup(); @@ -382,7 +381,6 @@ static void test_make_item(CuTest *tc) { itype->construction->materials = 0; rtype->flags |= RTF_LIMITED; rmt_create(rtype); - rdata = rtype->limit = calloc(1, sizeof(resource_limit)); add_resource(u->region, 1, 300, 150, rtype); u->region->resources->amount = 300; /* there are 300 stones at level 1 */ set_level(u, SK_ALCHEMY, 10); @@ -392,11 +390,11 @@ static void test_make_item(CuTest *tc) { CuAssertIntEquals(tc, 11, get_item(u, itype)); CuAssertIntEquals(tc, 290, u->region->resources->amount); /* used 10 stones to make 10 stones */ - rdata->modifiers = calloc(2, sizeof(resource_mod)); - rdata->modifiers[0].flags = RMF_SAVEMATERIAL; - rdata->modifiers[0].race = u->_race; - rdata->modifiers[0].value.sa[0] = (short)(0.5+100*d); - rdata->modifiers[0].value.sa[1] = 100; + rtype->modifiers = calloc(2, sizeof(resource_mod)); + rtype->modifiers[0].flags = RMF_SAVEMATERIAL; + rtype->modifiers[0].race = u->_race; + rtype->modifiers[0].value.sa[0] = (short)(0.5+100*d); + rtype->modifiers[0].value.sa[1] = 100; make_item(u, itype, 10); split_allocations(u->region); CuAssertIntEquals(tc, 21, get_item(u, itype)); @@ -407,9 +405,9 @@ static void test_make_item(CuTest *tc) { CuAssertIntEquals(tc, 22, get_item(u, itype)); CuAssertIntEquals(tc, 283, u->region->resources->amount); /* no free lunches */ - rdata->modifiers[0].flags = RMF_REQUIREDBUILDING; - rdata->modifiers[0].race = NULL; - rdata->modifiers[0].btype = bt_get_or_create("mine"); + rtype->modifiers[0].flags = RMF_REQUIREDBUILDING; + rtype->modifiers[0].race = NULL; + rtype->modifiers[0].btype = bt_get_or_create("mine"); make_item(u, itype, 10); CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error104")); diff --git a/src/kernel/item.c b/src/kernel/item.c index 6e64c147f..38d2e8711 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -1236,15 +1236,12 @@ void free_rtype(resource_type *rtype) { if (rtype->wtype) { free_wtype(rtype->wtype); } - if (rtype->atype) { - free(rtype->atype); - } if (rtype->itype) { free_itype(rtype->itype); } - if (rtype->raw) { - free(rtype->raw); - } + free(rtype->atype); + free(rtype->modifiers); + free(rtype->raw); free(rtype->_name); free(rtype); } diff --git a/src/kernel/item.h b/src/kernel/item.h index c1ac38517..4351d611d 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -39,7 +39,7 @@ extern "C" { struct storage; struct gamedata; struct rawmaterial_type; - struct resource_limit; + struct resource_mod; typedef struct item { struct item *next; @@ -80,7 +80,7 @@ extern "C" { rtype_uget uget; rtype_name name; struct rawmaterial_type *raw; - struct resource_limit *limit; + struct resource_mod *modifiers; /* --- pointers --- */ struct attrib *attribs; struct item_type *itype; diff --git a/src/kernel/resources.h b/src/kernel/resources.h index 6ee021fc1..b448425f4 100644 --- a/src/kernel/resources.h +++ b/src/kernel/resources.h @@ -50,10 +50,6 @@ extern "C" { unsigned int flags; } resource_mod; - typedef struct resource_limit { - resource_mod *modifiers; - } resource_limit; - typedef struct rawmaterial_type { const struct resource_type *rtype; diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index d4c31001e..3cf8b8601 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -988,7 +988,6 @@ static int parse_resources(xmlDocPtr doc) result = xmlXPathEvalExpression(BAD_CAST "resourcelimit", xpath); assert(result->nodesetval->nodeNr <= 1); if (result->nodesetval->nodeNr != 0) { - resource_limit *rdata = rtype->limit = calloc(1, sizeof(resource_limit)); xmlNodePtr limit = result->nodesetval->nodeTab[0]; xpath->node = limit; @@ -996,7 +995,7 @@ static int parse_resources(xmlDocPtr doc) result = xmlXPathEvalExpression(BAD_CAST "modifier", xpath); if (result->nodesetval != NULL) { - rdata->modifiers = + rtype->modifiers = calloc(result->nodesetval->nodeNr + 1, sizeof(resource_mod)); for (k = 0; k != result->nodesetval->nodeNr; ++k) { xmlNodePtr node = result->nodesetval->nodeTab[k]; @@ -1010,31 +1009,31 @@ static int parse_resources(xmlDocPtr doc) rc = rc_get_or_create((const char *)propValue); xmlFree(propValue); } - rdata->modifiers[k].race = rc; + rtype->modifiers[k].race = rc; propValue = xmlGetProp(node, BAD_CAST "building"); if (propValue != NULL) { btype = bt_get_or_create((const char *)propValue); xmlFree(propValue); } - rdata->modifiers[k].btype = btype; + rtype->modifiers[k].btype = btype; propValue = xmlGetProp(node, BAD_CAST "type"); assert(propValue != NULL); if (strcmp((const char *)propValue, "skill") == 0) { - rdata->modifiers[k].value.i = xml_ivalue(node, "value", 0); - rdata->modifiers[k].flags = RMF_SKILL; + rtype->modifiers[k].value.i = xml_ivalue(node, "value", 0); + rtype->modifiers[k].flags = RMF_SKILL; } else if (strcmp((const char *)propValue, "material") == 0) { - rdata->modifiers[k].value = xml_fraction(node, "value"); - rdata->modifiers[k].flags = RMF_SAVEMATERIAL; + rtype->modifiers[k].value = xml_fraction(node, "value"); + rtype->modifiers[k].flags = RMF_SAVEMATERIAL; } else if (strcmp((const char *)propValue, "require") == 0) { xmlChar *propBldg = xmlGetProp(node, BAD_CAST "building"); if (propBldg != NULL) { btype = bt_get_or_create((const char *)propBldg); - rdata->modifiers[k].btype = btype; - rdata->modifiers[k].flags = RMF_REQUIREDBUILDING; + rtype->modifiers[k].btype = btype; + rtype->modifiers[k].flags = RMF_REQUIREDBUILDING; xmlFree(propBldg); } } From 6e27adb892c1f7ed7f4d627797fa243bd7d79840 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 14:00:20 +0100 Subject: [PATCH 584/675] remove pointless wrapper from XML. --- res/adamantium.xml | 4 +- res/core/resources/iron.xml | 8 +-- res/core/resources/laen.xml | 8 +-- res/core/resources/log.xml | 8 +-- res/core/resources/mallorn.xml | 8 +-- res/core/resources/stone.xml | 8 +-- res/e3a/resources/iron.xml | 8 +-- res/e3a/resources/stone.xml | 8 +-- src/kernel/xmlreader.c | 101 +++++++++++++++------------------ 9 files changed, 68 insertions(+), 93 deletions(-) diff --git a/res/adamantium.xml b/res/adamantium.xml index bb94dfc12..77e138f77 100644 --- a/res/adamantium.xml +++ b/res/adamantium.xml @@ -5,9 +5,7 @@ - - - + diff --git a/res/core/resources/iron.xml b/res/core/resources/iron.xml index 469840669..70d5c1080 100644 --- a/res/core/resources/iron.xml +++ b/res/core/resources/iron.xml @@ -1,11 +1,9 @@ - - - - + + + - diff --git a/res/core/resources/laen.xml b/res/core/resources/laen.xml index 30531c0fe..4099f5ca9 100644 --- a/res/core/resources/laen.xml +++ b/res/core/resources/laen.xml @@ -1,9 +1,7 @@ - - - - + + + - diff --git a/res/core/resources/log.xml b/res/core/resources/log.xml index 3a1e8db50..e3710d496 100644 --- a/res/core/resources/log.xml +++ b/res/core/resources/log.xml @@ -1,10 +1,8 @@ - - - - + + + - diff --git a/res/core/resources/mallorn.xml b/res/core/resources/mallorn.xml index 39a0230d1..3dff091c6 100644 --- a/res/core/resources/mallorn.xml +++ b/res/core/resources/mallorn.xml @@ -1,10 +1,8 @@ - - - - + + + - diff --git a/res/core/resources/stone.xml b/res/core/resources/stone.xml index 91d3aac5d..e1c5651ed 100644 --- a/res/core/resources/stone.xml +++ b/res/core/resources/stone.xml @@ -1,11 +1,9 @@ - - - - + + + - diff --git a/res/e3a/resources/iron.xml b/res/e3a/resources/iron.xml index 7ffe36f1e..01e0d8d6d 100644 --- a/res/e3a/resources/iron.xml +++ b/res/e3a/resources/iron.xml @@ -1,10 +1,8 @@ - - - - + + + - diff --git a/res/e3a/resources/stone.xml b/res/e3a/resources/stone.xml index dfb039093..d8fd08573 100644 --- a/res/e3a/resources/stone.xml +++ b/res/e3a/resources/stone.xml @@ -1,10 +1,8 @@ - - - - + + + - diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 3cf8b8601..21c80566c 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -983,65 +983,56 @@ static int parse_resources(xmlDocPtr doc) if (xml_bvalue(node, "limited", false)) { rtype->flags |= RTF_LIMITED; } - /* reading eressea/resources/resource/resourcelimit */ + /* reading eressea/resources/resource/modifier */ xpath->node = node; - result = xmlXPathEvalExpression(BAD_CAST "resourcelimit", xpath); - assert(result->nodesetval->nodeNr <= 1); - if (result->nodesetval->nodeNr != 0) { - xmlNodePtr limit = result->nodesetval->nodeTab[0]; + result = xmlXPathEvalExpression(BAD_CAST "modifier", xpath); + if (result->nodesetval != NULL && result->nodesetval->nodeNr > 0) { + rtype->modifiers = + calloc(result->nodesetval->nodeNr + 1, sizeof(resource_mod)); + for (k = 0; k != result->nodesetval->nodeNr; ++k) { + xmlNodePtr node = result->nodesetval->nodeTab[k]; + building_type *btype = NULL; + const race *rc = NULL; - xpath->node = limit; - xmlXPathFreeObject(result); - - result = xmlXPathEvalExpression(BAD_CAST "modifier", xpath); - if (result->nodesetval != NULL) { - rtype->modifiers = - calloc(result->nodesetval->nodeNr + 1, sizeof(resource_mod)); - for (k = 0; k != result->nodesetval->nodeNr; ++k) { - xmlNodePtr node = result->nodesetval->nodeTab[k]; - building_type *btype = NULL; - const race *rc = NULL; - - propValue = xmlGetProp(node, BAD_CAST "race"); - if (propValue != NULL) { - rc = rc_find((const char *)propValue); - if (rc == NULL) - rc = rc_get_or_create((const char *)propValue); - xmlFree(propValue); - } - rtype->modifiers[k].race = rc; - - propValue = xmlGetProp(node, BAD_CAST "building"); - if (propValue != NULL) { - btype = bt_get_or_create((const char *)propValue); - xmlFree(propValue); - } - rtype->modifiers[k].btype = btype; - - propValue = xmlGetProp(node, BAD_CAST "type"); - assert(propValue != NULL); - if (strcmp((const char *)propValue, "skill") == 0) { - rtype->modifiers[k].value.i = xml_ivalue(node, "value", 0); - rtype->modifiers[k].flags = RMF_SKILL; - } - else if (strcmp((const char *)propValue, "material") == 0) { - rtype->modifiers[k].value = xml_fraction(node, "value"); - rtype->modifiers[k].flags = RMF_SAVEMATERIAL; - } - else if (strcmp((const char *)propValue, "require") == 0) { - xmlChar *propBldg = xmlGetProp(node, BAD_CAST "building"); - if (propBldg != NULL) { - btype = bt_get_or_create((const char *)propBldg); - rtype->modifiers[k].btype = btype; - rtype->modifiers[k].flags = RMF_REQUIREDBUILDING; - xmlFree(propBldg); - } - } - else { - log_error("unknown type '%s' for resourcelimit-modifier '%s'\n", (const char *)propValue, rtype->_name); - } + propValue = xmlGetProp(node, BAD_CAST "race"); + if (propValue != NULL) { + rc = rc_find((const char *)propValue); + if (rc == NULL) + rc = rc_get_or_create((const char *)propValue); xmlFree(propValue); } + rtype->modifiers[k].race = rc; + + propValue = xmlGetProp(node, BAD_CAST "building"); + if (propValue != NULL) { + btype = bt_get_or_create((const char *)propValue); + xmlFree(propValue); + } + rtype->modifiers[k].btype = btype; + + propValue = xmlGetProp(node, BAD_CAST "type"); + assert(propValue != NULL); + if (strcmp((const char *)propValue, "skill") == 0) { + rtype->modifiers[k].value.i = xml_ivalue(node, "value", 0); + rtype->modifiers[k].flags = RMF_SKILL; + } + else if (strcmp((const char *)propValue, "material") == 0) { + rtype->modifiers[k].value = xml_fraction(node, "value"); + rtype->modifiers[k].flags = RMF_SAVEMATERIAL; + } + else if (strcmp((const char *)propValue, "require") == 0) { + xmlChar *propBldg = xmlGetProp(node, BAD_CAST "building"); + if (propBldg != NULL) { + btype = bt_get_or_create((const char *)propBldg); + rtype->modifiers[k].btype = btype; + rtype->modifiers[k].flags = RMF_REQUIREDBUILDING; + xmlFree(propBldg); + } + } + else { + log_error("unknown type '%s' for resourcelimit-modifier '%s'\n", (const char *)propValue, rtype->_name); + } + xmlFree(propValue); } } xmlXPathFreeObject(result); From 67252e29247b84155e6e2ee434462a9c88113ac8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 15:03:47 +0100 Subject: [PATCH 585/675] add conversion program --- src/CMakeLists.txt | 10 ++++++++++ src/convert.c | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 src/convert.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 43f109fed..7be3dd3b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -187,6 +187,15 @@ target_link_libraries(eressea ${INIPARSER_LIBRARIES} ) +add_executable(convert convert.c) +target_link_libraries(convert + game + ${LUA_MATH_LIBRARY} + ${STORAGE_LIBRARIES} + ${CLIBS_LIBRARIES} + ${INIPARSER_LIBRARIES} +) + set(TESTS_SRC monsters.test.c names.test.c @@ -268,6 +277,7 @@ endif(CURSES_FOUND) if (LIBXML2_FOUND) include_directories (${LIBXML2_INCLUDE_DIR}) target_link_libraries(eressea ${LIBXML2_LIBRARIES}) +target_link_libraries(convert ${LIBXML2_LIBRARIES}) target_link_libraries(test_eressea ${LIBXML2_LIBRARIES}) add_definitions(-DUSE_LIBXML2) endif (LIBXML2_FOUND) diff --git a/src/convert.c b/src/convert.c new file mode 100644 index 000000000..4558ed3ab --- /dev/null +++ b/src/convert.c @@ -0,0 +1,3 @@ +int main(void) { + return -1; +} From f406c476574a86657b7f679ebba398366187d465 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 15:30:58 +0100 Subject: [PATCH 586/675] use converter frm noxml branch --- src/convert.c | 26 ++++++++++++++++++++++++-- src/kernel/CMakeLists.txt | 1 + src/kernel/rules.c | 12 ++++++++++++ src/kernel/rules.h | 5 +++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 src/kernel/rules.c create mode 100644 src/kernel/rules.h diff --git a/src/convert.c b/src/convert.c index 4558ed3ab..3b982e64f 100644 --- a/src/convert.c +++ b/src/convert.c @@ -1,3 +1,25 @@ -int main(void) { - return -1; +#include + +#include +#include +#include + +#include + +#include + +#include + +int main(int argc, char **argv) { + const char * xmlfile, *catalog; + + register_races(); + register_xmlreader(); + + if (argc < 3) return -1; + xmlfile = argv[1]; + catalog = argv[2]; + read_xml(xmlfile, catalog); + write_rules("rules.dat"); + return 0; } diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index d3a2e8e56..b8423ae03 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -54,6 +54,7 @@ pool.c race.c region.c resources.c +rules.c save.c ship.c skills.c diff --git a/src/kernel/rules.c b/src/kernel/rules.c new file mode 100644 index 000000000..c7499fe0c --- /dev/null +++ b/src/kernel/rules.c @@ -0,0 +1,12 @@ +#include +#include "rules.h" + +int write_rules(const char *filename) { + return -1; +} + +int read_rules(const char *filename) +{ + return -1; +} + diff --git a/src/kernel/rules.h b/src/kernel/rules.h new file mode 100644 index 000000000..98f0bf240 --- /dev/null +++ b/src/kernel/rules.h @@ -0,0 +1,5 @@ +#pragma once + +int read_rules(const char *filename); +int write_rules(const char * filename); + From 71e5d101a82272d2c67d35201314cf52cf292002 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 15:33:32 +0100 Subject: [PATCH 587/675] converter compiles fine, does nothing --- src/convert.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/convert.c b/src/convert.c index 3b982e64f..a67c5a287 100644 --- a/src/convert.c +++ b/src/convert.c @@ -1,25 +1,44 @@ #include + +#ifdef USE_LIBXML2 +#include +#include +#endif #include #include -#include - #include -#include - #include +#include + +static int usage(void) { + return -1; +} + int main(int argc, char **argv) { - const char * xmlfile, *catalog; + const char *mode; register_races(); +#ifdef USE_LIBXML2 register_xmlreader(); - - if (argc < 3) return -1; - xmlfile = argv[1]; - catalog = argv[2]; - read_xml(xmlfile, catalog); - write_rules("rules.dat"); - return 0; +#endif + if (argc < 2) return usage(); + mode = argv[1]; +#ifdef USE_LIBXML2 + if (strcmp(mode, "rules")==0) { + const char *xmlfile, *catalog; + if (argc < 4) return usage(); + xmlfile = argv[2]; + catalog = argv[3]; + read_xml(xmlfile, catalog); + write_rules("rules.dat"); + return 0; + } +#endif + if (strcmp(mode, "po")==0) { + return 0; + } + return usage(); } From 56eb1b753cb33f9db228644370450dc91b905517 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 15:52:58 +0100 Subject: [PATCH 588/675] fix header missing a struct --- src/kernel/xmlreader.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/kernel/xmlreader.h b/src/kernel/xmlreader.h index 5dfb643f1..290b785c3 100644 --- a/src/kernel/xmlreader.h +++ b/src/kernel/xmlreader.h @@ -12,6 +12,9 @@ without prior permission by the authors of Eressea. #ifndef H_KRNL_XMLREADER_H #define H_KRNL_XMLREADER_H + +struct spell; + #ifdef __cplusplus extern "C" { #endif From 3c60f863a572ad5c04f2c9c0be69267a04000c78 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 18:17:58 +0100 Subject: [PATCH 589/675] remove the special_resources trie. memory leak, bad performance. --- scripts/eressea/xmasitems.lua | 1 + src/bind_region.c | 93 +++++++++++++++-------------------- 2 files changed, 41 insertions(+), 53 deletions(-) diff --git a/scripts/eressea/xmasitems.lua b/scripts/eressea/xmasitems.lua index a05e023b8..27ea641ee 100644 --- a/scripts/eressea/xmasitems.lua +++ b/scripts/eressea/xmasitems.lua @@ -25,6 +25,7 @@ end function use_stardust(u, amount) local p = u.region:get_resource("peasant") + assert(p>0) p = math.ceil(1.5 * p) u.region:set_resource("peasant", p) local msg = usepotion_message(u, "stardust") diff --git a/src/bind_region.c b/src/bind_region.c index 51a5bedd4..9e4e2f778 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -341,20 +341,16 @@ static int tolua_region_get_resourcelevel(lua_State * L) #define LUA_ASSERT(c, s) if (!(c)) { log_error("%s(%d): %s\n", __FILE__, __LINE__, (s)); return 0; } -static critbit_tree * special_resources(void) -{ - static critbit_tree cb = CRITBIT_TREE(); - if (!cb.root) { - const char * special[] = { "seed", "sapling", "tree", "grave", "chaos", 0 }; - char buffer[32]; - int i; - for (i = 0; special[i]; ++i) { - size_t len = strlen(special[i]); - len = cb_new_kv(special[i], len, &i, sizeof(int), buffer); - cb_insert(&cb, buffer, len); +static int special_resource(const char *type) { + const char * special[] = { "seed", "sapling", "tree", "grave", "chaos", 0 }; + int i; + + for (i = 0; special[i]; ++i) { + if (strcmp(type, special[i]) == 0) { + return i; } } - return &cb; + return -1; } static int tolua_region_get_resource(lua_State * L) @@ -362,32 +358,27 @@ static int tolua_region_get_resource(lua_State * L) region *r; const char *type; const resource_type *rtype; - int result = 0; - void * match; - critbit_tree * cb = special_resources(); + int result; r = (region *)tolua_tousertype(L, 1, 0); LUA_ASSERT(r != NULL, "invalid parameter"); type = tolua_tostring(L, 2, 0); LUA_ASSERT(type != NULL, "invalid parameter"); - - if (cb_find_prefix(cb, type, strlen(type) + 1, &match, 1, 0)) { - cb_get_kv(match, &result, sizeof(result)); - switch (result) { - case 0: - case 1: - case 2: - result = rtrees(r, result); - break; - case 3: - result = deathcount(r); - break; - case 4: - result = get_chaoscount(r); - break; - } - } - else { + + result = special_resource(type); + switch (result) { + case 0: + case 1: + case 2: + result = rtrees(r, result); + break; + case 3: + result = deathcount(r); + break; + case 4: + result = get_chaoscount(r); + break; + default: rtype = rt_find(type); if (rtype) { result = region_getresource(r, rtype); @@ -406,27 +397,23 @@ static int tolua_region_set_resource(lua_State * L) region *r = (region *)tolua_tousertype(L, 1, 0); const char *type = tolua_tostring(L, 2, 0); int result, value = (int)tolua_tonumber(L, 3, 0); - critbit_tree * cb = special_resources(); - void * match; + const resource_type *rtype; - if (cb_find_prefix(cb, type, strlen(type) + 1, &match, 1, 0)) { - cb_get_kv(match, &result, sizeof(result)); - switch (result) { - case 0: - case 1: - case 2: - rsettrees(r, result, value); - break; - case 3: - deathcounts(r, value - deathcount(r)); - break; - case 4: - add_chaoscount(r, value - get_chaoscount(r)); - break; - } - } - else { - const resource_type *rtype = rt_find(type); + result = special_resource(type); + switch (result) { + case 0: + case 1: + case 2: + rsettrees(r, result, value); + break; + case 3: + deathcounts(r, value - deathcount(r)); + break; + case 4: + add_chaoscount(r, value - get_chaoscount(r)); + break; + default: + rtype = rt_find(type); if (rtype != NULL) { region_setresource(r, rtype, value); } From b8ffc20d87c4b592e4c8c8cf43a21b2abec840f6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 19:54:58 +0100 Subject: [PATCH 590/675] remove item_useonother callbacks (use is fine). add a test for foolpotion. --- res/core/common/potions.xml | 2 +- scripts/tests/e2/e2features.lua | 24 ++++++++++++++++++++++++ src/kernel/item.c | 13 ++++++------- src/kernel/item.h | 2 -- src/kernel/xmlreader.c | 5 ----- src/laws.c | 22 ++++++---------------- 6 files changed, 37 insertions(+), 31 deletions(-) diff --git a/res/core/common/potions.xml b/res/core/common/potions.xml index 84b1e5f52..12ac67aa2 100644 --- a/res/core/common/potions.xml +++ b/res/core/common/potions.xml @@ -101,7 +101,7 @@ - + diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index de94ea34f..28cbbf69b 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -230,6 +230,30 @@ function test_no_uruk() assert_equal(f1.race, "orc") end +function test_foolpotion() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("p7", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Dumpfbackenbrot 4242") + process_orders() + assert_equal(1, u:get_item("p7")) + assert_equal(1, f:count_msg_type('feedback_unit_not_found')) + local u2 = unit.create(f, r, 1) + + u:clear_orders() + u:add_order("BENUTZEN 1 Dumpfbackenbrot " .. itoa36(u2.id)) + process_orders() + assert_equal(1, u:get_item("p7")) + assert_equal(1, f:count_msg_type('error64')) + + u:set_skill("stealth", 1); + process_orders() + assert_equal(0, u:get_item("p7")) + assert_equal(1, f:count_msg_type('givedumb')) +end + function test_snowman() local r = region.create(0, 0, "glacier") local f = faction.create("noreply@eressea.de", "human", "de") diff --git a/src/kernel/item.c b/src/kernel/item.c index 38d2e8711..9240a7994 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -820,9 +820,8 @@ struct order *ord) return 0; } -static int -use_warmthpotion(struct unit *u, const struct item_type *itype, int amount, -struct order *ord) +static int use_warmthpotion(unit *u, const item_type *itype, + int amount, struct order *ord) { if (u->faction->race == get_race(RC_INSECT)) { fset(u, UFL_WARMTH); @@ -841,10 +840,10 @@ struct order *ord) return 0; } -static int -use_foolpotion(struct unit *u, int targetno, const struct item_type *itype, -int amount, struct order *ord) +static int use_foolpotion(unit *u, const item_type *itype, int amount, + struct order *ord) { + int targetno = read_unitid(u->faction, u->region); unit *target = findunit(targetno); if (target == NULL || u->region != target->region) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", @@ -1295,7 +1294,7 @@ void register_resources(void) register_item_use(use_warmthpotion, "usewarmthpotion"); register_item_use(use_bloodpotion, "usebloodpotion"); register_item_use(use_healingpotion, "usehealingpotion"); - register_item_useonother(use_foolpotion, "usefoolpotion"); + register_item_use(use_foolpotion, "usefoolpotion"); register_item_use(use_mistletoe, "usemistletoe"); register_item_use(use_magicboost, "usemagicboost"); register_item_use(use_snowball, "usesnowball"); diff --git a/src/kernel/item.h b/src/kernel/item.h index 4351d611d..a2e588318 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -127,8 +127,6 @@ extern "C" { const struct item_type * itype); int(*use) (struct unit * user, const struct item_type * itype, int amount, struct order * ord); - int(*useonother) (struct unit * user, int targetno, - const struct item_type * itype, int amount, struct order * ord); int(*give) (struct unit * src, struct unit * dest, const struct item_type * itm, int number, struct order * ord); int score; diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 21c80566c..f5e45dd5c 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -857,11 +857,6 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) itype->canuse = (bool(*)(const struct unit *, const struct item_type *))fun; } - else if (strcmp((const char *)propValue, "useonother") == 0) { - itype->useonother = - (int(*)(struct unit *, int, const struct item_type *, int, - struct order *))fun; - } else { log_error("unknown function type '%s' for item '%s'\n", (const char *)propValue, rtype->_name); } diff --git a/src/laws.c b/src/laws.c index 253b45b89..09b1439c0 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3242,11 +3242,6 @@ void update_long_order(unit * u) static int use_item(unit * u, const item_type * itype, int amount, struct order *ord) { int i; - int target = -1; - - if (itype->useonother) { - target = read_unitid(u->faction, u->region); - } i = get_pooled(u, itype->rtype, GET_DEFAULT, amount); if (amount > i) { @@ -3257,19 +3252,14 @@ static int use_item(unit * u, const item_type * itype, int amount, struct order return ENOITEM; } - if (target == -1) { - if (itype->use) { - int result = itype->use(u, itype, amount, ord); - if (result > 0) { - use_pooled(u, itype->rtype, GET_DEFAULT, result); - } - return result; + if (itype->use) { + int result = itype->use(u, itype, amount, ord); + if (result > 0) { + use_pooled(u, itype->rtype, GET_DEFAULT, result); } - return EUNUSABLE; - } - else { - return itype->useonother(u, target, itype, amount, ord); + return result; } + return EUNUSABLE; } void monthly_healing(void) From b8d9fae4e446685b2e331036b80540283401f001 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 20:16:22 +0100 Subject: [PATCH 591/675] begin version 3.12 --- src/kernel/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/version.c b/src/kernel/version.c index 633fbf7bf..39f4f30e6 100644 --- a/src/kernel/version.c +++ b/src/kernel/version.c @@ -5,7 +5,7 @@ #ifndef ERESSEA_VERSION /* the version number, if it was not passed to make with -D */ -#define ERESSEA_VERSION "3.11.0" +#define ERESSEA_VERSION "3.12.0" #endif const char *eressea_version(void) { From 8b69b6d003358e88b278f717bfb2e22d91355b0b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 04:00:45 +0100 Subject: [PATCH 592/675] test peasantblood effects --- scripts/tests/e2/e2features.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index 28cbbf69b..eb2d06f0d 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -230,6 +230,32 @@ function test_no_uruk() assert_equal(f1.race, "orc") end +function test_bloodpotion_demon() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "demon", "de") + local u = unit.create(f, r, 1) + u:add_item("peasantblood", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Bauernblut") + process_orders() + assert_equal(0, u:get_item("peasantblood")) + assert_equal(1, f:count_msg_type('usepotion')) + assert_equal("demon", u.race) +end + +function test_bloodpotion_other() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("peasantblood", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Bauernblut") + process_orders() + assert_equal(0, u:get_item("peasantblood")) + assert_equal(1, f:count_msg_type('usepotion')) + assert_equal("smurf", u.race) +end + function test_foolpotion() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") From 44c3838d790c290bff577e385be65d3f2f8182b9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 04:22:28 +0100 Subject: [PATCH 593/675] WIP: itype->use elimination. --- res/e3a/items.xml | 4 +--- res/eressea/items.xml | 24 ++++++------------------ src/helpers.c | 10 +++++++--- src/kernel/item.h | 1 + src/kernel/resources.c | 2 ++ src/kernel/resources.h | 3 ++- src/kernel/xmlreader.c | 3 +++ src/laws.c | 4 ++-- 8 files changed, 24 insertions(+), 27 deletions(-) diff --git a/res/e3a/items.xml b/res/e3a/items.xml index 7d7e6b286..fa3af4b41 100644 --- a/res/e3a/items.xml +++ b/res/e3a/items.xml @@ -81,9 +81,7 @@ - - - + diff --git a/res/eressea/items.xml b/res/eressea/items.xml index 69f84c890..c0b8b5126 100644 --- a/res/eressea/items.xml +++ b/res/eressea/items.xml @@ -17,21 +17,15 @@ - - - + - - - + - - - + @@ -44,23 +38,17 @@ - - - + - - - + - - - + diff --git a/src/helpers.c b/src/helpers.c index ad222a0c6..e5bdf6ff9 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -490,14 +490,18 @@ static int lua_equipmentcallback(const struct equipment *eq, unit * u) } /** callback for an item-use function written in lua. */ -int -lua_useitem(struct unit *u, const struct item_type *itype, int amount, +static int +use_item_lua(struct unit *u, const struct item_type *itype, int amount, struct order *ord) { lua_State *L = (lua_State *)global.vm_state; int result = 0; char fname[64]; + if (itype->use) { + return itype->use(u, itype, amount, ord); + } + strlcpy(fname, "use_", sizeof(fname)); strlcat(fname, itype->rtype->_name, sizeof(fname)); @@ -551,7 +555,6 @@ void register_tolua_helpers(void) register_function((pf_generic)lua_callspell, TOLUA_CAST "lua_castspell"); register_function((pf_generic)lua_initfamiliar, TOLUA_CAST "lua_initfamiliar"); - register_item_use(&lua_useitem, TOLUA_CAST "lua_useitem"); register_function((pf_generic)lua_getresource, TOLUA_CAST "lua_getresource"); register_function((pf_generic)lua_canuse_item, @@ -565,6 +568,7 @@ void register_tolua_helpers(void) register_function((pf_generic)lua_maintenance, TOLUA_CAST "lua_maintenance"); + item_use_fun = use_item_lua; res_produce_fun = produce_resource_lua; res_limit_fun = limit_resource_lua; register_item_give(lua_giveitem, TOLUA_CAST "lua_giveitem"); diff --git a/src/kernel/item.h b/src/kernel/item.h index a2e588318..b0bc10cd8 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -107,6 +107,7 @@ extern "C" { #define ITF_BIG 0x0008 /* big item, e.g. does not fit in a bag of holding */ #define ITF_ANIMAL 0x0010 /* an animal */ #define ITF_VEHICLE 0x0020 /* a vehicle, drawn by two animals */ +#define ITF_CANUSE 0x0040 /* can be used with use_item_fun callout */ /* error codes for item_type::use */ #define ECUSTOM -1 diff --git a/src/kernel/resources.c b/src/kernel/resources.c index f99783763..10cb2bab6 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -213,6 +213,8 @@ struct rawmaterial_type *rmt_create(struct resource_type *rtype) return rmtype; } +int(*item_use_fun)(struct unit *u, const struct item_type *itype, int amount, + struct order *ord); int(*res_limit_fun)(const struct region *, const struct resource_type *); void(*res_produce_fun)(struct region *, const struct resource_type *, int); diff --git a/src/kernel/resources.h b/src/kernel/resources.h index b448425f4..7f48fa0dd 100644 --- a/src/kernel/resources.h +++ b/src/kernel/resources.h @@ -74,7 +74,8 @@ extern "C" { extern int(*res_limit_fun)(const struct region *, const struct resource_type *); extern void(*res_produce_fun)(struct region *, const struct resource_type *, int); - + extern int (*item_use_fun)(struct unit *, const struct item_type *, int amount, + struct order *ord); int limit_resource(const struct region *r, const struct resource_type *rtype); void produce_resource(struct region *r, const struct resource_type *rtype, int amount); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index f5e45dd5c..6f62738e3 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -767,6 +767,8 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) if (xml_bvalue(node, "cursed", false)) flags |= ITF_CURSED; + if (xml_bvalue(node, "use", false)) + flags |= ITF_CANUSE; if (xml_bvalue(node, "notlost", false)) flags |= ITF_NOTLOST; if (xml_bvalue(node, "herb", false)) @@ -849,6 +851,7 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) struct order *))fun; } else if (strcmp((const char *)propValue, "use") == 0) { + itype->flags |= ITF_CANUSE; itype->use = (int(*)(struct unit *, const struct item_type *, int, struct order *))fun; diff --git a/src/laws.c b/src/laws.c index 09b1439c0..0d0e53110 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3252,8 +3252,8 @@ static int use_item(unit * u, const item_type * itype, int amount, struct order return ENOITEM; } - if (itype->use) { - int result = itype->use(u, itype, amount, ord); + if (itype->flags & ITF_CANUSE) { + int result = item_use_fun(u, itype, amount, ord); if (result > 0) { use_pooled(u, itype->rtype, GET_DEFAULT, result); } From 715c8569ba50b3f53d4824122244de34bf130a37 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 09:48:24 +0100 Subject: [PATCH 594/675] hacked the item-use function, XML needs cleaning up, funpointer needs to die --- src/helpers.c | 27 ++++++++++++++++++--------- src/kernel/item.c | 4 ++-- src/kernel/xmlreader.c | 4 ++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/helpers.c b/src/helpers.c index e5bdf6ff9..5124ca0ae 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -13,6 +13,7 @@ without prior permission by the authors of Eressea. #include #include "helpers.h" #include "vortex.h" +#include "alchemy.h" #include #include @@ -491,20 +492,21 @@ static int lua_equipmentcallback(const struct equipment *eq, unit * u) /** callback for an item-use function written in lua. */ static int -use_item_lua(struct unit *u, const struct item_type *itype, int amount, -struct order *ord) +use_item_lua(unit *u, const item_type *itype, int amount, struct order *ord) { lua_State *L = (lua_State *)global.vm_state; int result = 0; char fname[64]; - - if (itype->use) { - return itype->use(u, itype, amount, ord); - } + int (*callout)(unit *, const item_type *, int, struct order *); strlcpy(fname, "use_", sizeof(fname)); strlcat(fname, itype->rtype->_name, sizeof(fname)); + callout = (int(*)(unit *, const item_type *, int, struct order *))get_function(fname); + if (callout) { + return callout(u, itype, amount, ord); + } + lua_getglobal(L, fname); if (lua_isfunction(L, -1)) { tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit"); @@ -520,11 +522,18 @@ struct order *ord) result = (int)lua_tonumber(L, -1); lua_pop(L, 1); } + return result; } - else { - log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname); - lua_pop(L, 1); + if (itype->rtype->ptype) { + return use_potion(u, itype, amount, ord); + } else { + log_error("no such callout: %s", fname); } + if (itype->use) { + return itype->use(u, itype, amount, ord); + } + log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname); + lua_pop(L, 1); return result; } diff --git a/src/kernel/item.c b/src/kernel/item.c index 9240a7994..5991eca96 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -1292,9 +1292,9 @@ void register_resources(void) register_item_use(use_tacticcrystal, "use_tacticcrystal"); register_item_use(use_birthdayamulet, "use_birthdayamulet"); register_item_use(use_warmthpotion, "usewarmthpotion"); - register_item_use(use_bloodpotion, "usebloodpotion"); + register_item_use(use_bloodpotion, "use_peasantblood"); register_item_use(use_healingpotion, "usehealingpotion"); - register_item_use(use_foolpotion, "usefoolpotion"); + register_item_use(use_foolpotion, "use_p7"); register_item_use(use_mistletoe, "usemistletoe"); register_item_use(use_magicboost, "usemagicboost"); register_item_use(use_snowball, "usesnowball"); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 6f62738e3..c4ce845a5 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -805,6 +805,10 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) result = xmlXPathEvalExpression(BAD_CAST "potion", xpath); assert(result->nodesetval->nodeNr <= 1); if (result->nodesetval->nodeNr != 0) { + if ((itype->flags & ITF_CANUSE) == 0) { + log_error("potion %s has no use attribute", rtype->_name); + itype->flags |= ITF_CANUSE; + } xpath->node = result->nodesetval->nodeTab[0]; rtype->ptype = xml_readpotion(xpath, itype); } From 604b574d0f25e600ea8b25ac520e567adcfab55f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 11:39:55 +0100 Subject: [PATCH 595/675] fix potion-use? need more testing --- res/core/common/potions.xml | 45 +++++++++++---------------------- res/e3a/items.xml | 24 ++++++------------ scripts/tests/e2/e2features.lua | 15 +++++++++++ src/kernel/item.c | 7 +++-- 4 files changed, 41 insertions(+), 50 deletions(-) diff --git a/res/core/common/potions.xml b/res/core/common/potions.xml index 12ac67aa2..4812727dd 100644 --- a/res/core/common/potions.xml +++ b/res/core/common/potions.xml @@ -4,8 +4,7 @@ - - + @@ -15,8 +14,7 @@ - - + @@ -26,8 +24,7 @@ - - + @@ -37,8 +34,7 @@ - - + @@ -48,8 +44,7 @@ - - + @@ -61,8 +56,7 @@ - - + @@ -74,8 +68,7 @@ - - + @@ -87,8 +80,7 @@ - - + @@ -100,8 +92,7 @@ - - + @@ -113,8 +104,7 @@ - - + @@ -126,8 +116,7 @@ - - + @@ -139,8 +128,7 @@ - - + @@ -152,8 +140,7 @@ - - + @@ -166,8 +153,7 @@ - - + @@ -181,8 +167,7 @@ - - + diff --git a/res/e3a/items.xml b/res/e3a/items.xml index fa3af4b41..9e928837e 100644 --- a/res/e3a/items.xml +++ b/res/e3a/items.xml @@ -7,64 +7,56 @@ - - + - - + - - + - - + - - + - - + - - + - - + diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index eb2d06f0d..c88dfdf22 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -230,6 +230,21 @@ function test_no_uruk() assert_equal(f1.race, "orc") end +function test_ointment() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + local hp = u.hp + u.hp = 0 + u:add_item("ointment", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Wundsalbe") + process_orders() + assert_equal(0, u:get_item("ointment")) + assert_equal(1, f:count_msg_type('usepotion')) + assert_equal(hp, u.hp) +end + function test_bloodpotion_demon() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "demon", "de") diff --git a/src/kernel/item.c b/src/kernel/item.c index 5991eca96..1fa006c73 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -1287,13 +1287,12 @@ void register_resources(void) register_function((pf_generic)res_changehp, "changehp"); register_function((pf_generic)res_changeaura, "changeaura"); - register_item_use(use_potion, "usepotion"); - register_item_use(use_potion_delayed, "usepotion_delayed"); + register_item_use(use_potion_delayed, "use_p2"); register_item_use(use_tacticcrystal, "use_tacticcrystal"); register_item_use(use_birthdayamulet, "use_birthdayamulet"); - register_item_use(use_warmthpotion, "usewarmthpotion"); + register_item_use(use_warmthpotion, "use_nestwarmth"); register_item_use(use_bloodpotion, "use_peasantblood"); - register_item_use(use_healingpotion, "usehealingpotion"); + register_item_use(use_healingpotion, "use_ointment"); register_item_use(use_foolpotion, "use_p7"); register_item_use(use_mistletoe, "usemistletoe"); register_item_use(use_magicboost, "usemagicboost"); From 60c2f1e8074a94f34325d4436c2aa4088045b974 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 14:01:41 +0100 Subject: [PATCH 596/675] test the birthday amulet --- res/core/common/items.xml | 4 +--- scripts/tests/e2/e2features.lua | 14 +++++++++++++- src/bind_region.c | 20 ++++++++++++++++++++ src/kernel/item.c | 2 +- src/kernel/xmlreader.c | 1 + 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/res/core/common/items.xml b/res/core/common/items.xml index c903a6b78..8745b6e59 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -62,9 +62,7 @@ - - - + diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index c88dfdf22..5af956980 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -230,12 +230,24 @@ function test_no_uruk() assert_equal(f1.race, "orc") end +function test_meow() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("aoc", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Katzenamulett") + process_orders() + assert_equal(1, u:get_item("aoc")) + assert_equal(1, r:count_msg_type('meow')) +end + function test_ointment() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") local u = unit.create(f, r, 1) local hp = u.hp - u.hp = 0 + u.hp = 1 u:add_item("ointment", 1) u:clear_orders() u:add_order("BENUTZEN 1 Wundsalbe") diff --git a/src/bind_region.c b/src/bind_region.c index 9e4e2f778..05c0e3842 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -29,6 +29,7 @@ without prior permission by the authors of Eressea. #include #include #include +#include #include #include #include @@ -46,6 +47,23 @@ without prior permission by the authors of Eressea. #include #include +static int tolua_region_count_msg_type(lua_State *L) { + region *self = (region *)tolua_tousertype(L, 1, 0); + const char *str = tolua_tostring(L, 2, 0); + int n = 0; + if (self->msgs) { + mlist * ml = self->msgs->begin; + while (ml) { + if (strcmp(str, ml->msg->type->name) == 0) { + ++n; + } + ml = ml->next; + } + } + lua_pushinteger(L, n); + return 1; +} + int tolua_regionlist_next(lua_State * L) { region **region_ptr = (region **)lua_touserdata(L, lua_upvalueindex(1)); @@ -671,6 +689,8 @@ void tolua_region_open(lua_State * L) tolua_function(L, TOLUA_CAST "destroy", tolua_region_destroy); tolua_function(L, TOLUA_CAST "__tostring", tolua_region_tostring); + tolua_function(L, TOLUA_CAST "count_msg_type", tolua_region_count_msg_type); + /* flags */ tolua_variable(L, TOLUA_CAST "blocked", tolua_region_get_blocked, tolua_region_set_blocked); diff --git a/src/kernel/item.c b/src/kernel/item.c index 1fa006c73..e0f8f64cc 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -1289,7 +1289,7 @@ void register_resources(void) register_item_use(use_potion_delayed, "use_p2"); register_item_use(use_tacticcrystal, "use_tacticcrystal"); - register_item_use(use_birthdayamulet, "use_birthdayamulet"); + register_item_use(use_birthdayamulet, "use_aoc"); register_item_use(use_warmthpotion, "use_nestwarmth"); register_item_use(use_bloodpotion, "use_peasantblood"); register_item_use(use_healingpotion, "use_ointment"); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index c4ce845a5..69e9c22d0 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -855,6 +855,7 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) struct order *))fun; } else if (strcmp((const char *)propValue, "use") == 0) { + log_error("%s has a use function", rtype->_name); itype->flags |= ITF_CANUSE; itype->use = (int(*)(struct unit *, const struct item_type *, int, From 5ffe60193bdbdaad2b72f019b020bc2dd1743f76 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 14:10:12 +0100 Subject: [PATCH 597/675] move items with tests to items.c --- src/items.c | 134 ++++++++++++++++++++++++++++++++++++++++++++-- src/kernel/item.c | 134 ++-------------------------------------------- 2 files changed, 133 insertions(+), 135 deletions(-) diff --git a/src/items.c b/src/items.c index bb5009038..cae5ea642 100644 --- a/src/items.c +++ b/src/items.c @@ -1,6 +1,7 @@ #include #include "items.h" +#include "alchemy.h" #include "study.h" #include "economy.h" #include "move.h" @@ -14,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -21,9 +23,15 @@ #include +/* triggers includes */ +#include +#include + #include +#include #include #include +#include #include #include @@ -125,15 +133,15 @@ struct order *ord) UNUSED_ARG(ord); assert(sp); - /* Reduziert die Strke jedes Spruchs um effect */ + /* Reduziert die St�rke jedes Spruchs um effect */ effect = 5; - /* Hlt Sprche bis zu einem summierten Gesamtlevel von power aus. + /* H�lt Spr�che bis zu einem summierten Gesamtlevel von power aus. * Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone * um seine Stufe */ force = effect * 20; /* Stufe 5 =~ 100 */ - /* Regionszauber auflsen */ + /* Regionszauber aufl�sen */ while (*ap && force > 0) { curse *c; attrib *a = *ap; @@ -145,7 +153,7 @@ struct order *ord) } c = (curse *)a->data.v; - /* Immunitt prfen */ + /* Immunit�t pr�fen */ if (c_flags(c) & CURSE_IMMUNE) { do { ap = &(*ap)->next; @@ -264,6 +272,118 @@ int amount, struct order *ord) return 0; } +static int +use_birthdayamulet(unit * u, const struct item_type *itype, int amount, +struct order *ord) +{ + direction_t d; + message *msg = msg_message("meow", ""); + + UNUSED_ARG(ord); + UNUSED_ARG(amount); + UNUSED_ARG(itype); + + add_message(&u->region->msgs, msg); + for (d = 0; d < MAXDIRECTIONS; d++) { + region *tr = rconnect(u->region, d); + if (tr) + add_message(&tr->msgs, msg); + } + msg_release(msg); + return 0; +} + +static int use_foolpotion(unit *u, const item_type *itype, int amount, + struct order *ord) +{ + int targetno = read_unitid(u->faction, u->region); + unit *target = findunit(targetno); + if (target == NULL || u->region != target->region) { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", + "")); + return ECUSTOM; + } + if (effskill(u, SK_STEALTH, 0) <= effskill(target, SK_PERCEPTION, 0)) { + cmistake(u, ord, 64, MSG_EVENT); + return ECUSTOM; + } + ADDMSG(&u->faction->msgs, msg_message("givedumb", + "unit recipient amount", u, target, amount)); + + change_effect(target, itype->rtype->ptype, amount); + use_pooled(u, itype->rtype, GET_DEFAULT, amount); + return 0; +} + +static int +use_bloodpotion(struct unit *u, const struct item_type *itype, int amount, +struct order *ord) +{ + if (u->number == 0 || u_race(u) == get_race(RC_DAEMON)) { + change_effect(u, itype->rtype->ptype, 100 * amount); + } + else { + const race *irace = u_irace(u); + if (irace == u_race(u)) { + const race *rcfailure = rc_find("smurf"); + if (!rcfailure) { + rcfailure = rc_find("toad"); + } + if (rcfailure) { + trigger *trestore = trigger_changerace(u, u_race(u), irace); + if (trestore) { + int duration = 2 + rng_int() % 8; + + add_trigger(&u->attribs, "timer", trigger_timeout(duration, + trestore)); + u->irace = NULL; + u_setrace(u, rcfailure); + } + } + } + } + use_pooled(u, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, + amount); + usetpotionuse(u, itype->rtype->ptype); + + ADDMSG(&u->faction->msgs, msg_message("usepotion", + "unit potion", u, itype->rtype)); + return 0; +} + +static int heal(unit * user, int effect) +{ + int req = unit_max_hp(user) * user->number - user->hp; + if (req > 0) { + req = MIN(req, effect); + effect -= req; + user->hp += req; + } + return effect; +} + +static int +use_healingpotion(struct unit *user, const struct item_type *itype, int amount, +struct order *ord) +{ + int effect = amount * 400; + unit *u = user->region->units; + effect = heal(user, effect); + while (effect > 0 && u != NULL) { + if (u->faction == user->faction) { + effect = heal(u, effect); + } + u = u->next; + } + use_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, + amount); + usetpotionuse(user, itype->rtype->ptype); + + ADDMSG(&user->faction->msgs, msg_message("usepotion", + "unit potion", user, itype->rtype)); + return 0; +} + void register_itemfunctions(void) { register_demonseye(); @@ -274,4 +394,10 @@ void register_itemfunctions(void) register_item_use(use_instantartacademy, "use_instantartacademy"); register_item_use(use_bagpipeoffear, "use_bagpipeoffear"); register_item_use(use_aurapotion50, "use_aurapotion50"); + + /* have tests: */ + register_item_use(use_birthdayamulet, "use_aoc"); + register_item_use(use_foolpotion, "use_p7"); + register_item_use(use_bloodpotion, "use_peasantblood"); + register_item_use(use_healingpotion, "use_ointment"); } diff --git a/src/kernel/item.c b/src/kernel/item.c index e0f8f64cc..ecad829ca 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -34,23 +34,18 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "terrain.h" #include "unit.h" -/* triggers includes */ -#include -#include - /* util includes */ #include #include -#include -#include #include #include #include #include #include -#include #include +#include +#include #include /* libc includes */ @@ -675,27 +670,6 @@ int set_item(unit * u, const item_type *itype, int value) return value; } -static int -use_birthdayamulet(unit * u, const struct item_type *itype, int amount, -struct order *ord) -{ - direction_t d; - message *msg = msg_message("meow", ""); - - UNUSED_ARG(ord); - UNUSED_ARG(amount); - UNUSED_ARG(itype); - - add_message(&u->region->msgs, msg); - for (d = 0; d < MAXDIRECTIONS; d++) { - region *tr = rconnect(u->region, d); - if (tr) - add_message(&tr->msgs, msg); - } - msg_release(msg); - return 0; -} - /* t_item::flags */ #define FL_ITEM_CURSED (1<<0) #define FL_ITEM_NOTLOST (1<<1) @@ -766,17 +740,6 @@ mod_dwarves_only(const unit * u, const region * r, skill_t sk, int value) return -118; } -static int heal(unit * user, int effect) -{ - int req = unit_max_hp(user) * user->number - user->hp; - if (req > 0) { - req = MIN(req, effect); - effect -= req; - user->hp += req; - } - return effect; -} - void register_item_give(int(*foo) (struct unit *, struct unit *, const struct item_type *, int, struct order *), const char *name) @@ -791,35 +754,6 @@ struct order *), const char *name) register_function((pf_generic)foo, name); } -void -register_item_useonother(int(*foo) (struct unit *, int, -const struct item_type *, int, struct order *), const char *name) -{ - register_function((pf_generic)foo, name); -} - -static int -use_healingpotion(struct unit *user, const struct item_type *itype, int amount, -struct order *ord) -{ - int effect = amount * 400; - unit *u = user->region->units; - effect = heal(user, effect); - while (effect > 0 && u != NULL) { - if (u->faction == user->faction) { - effect = heal(u, effect); - } - u = u->next; - } - use_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, - amount); - usetpotionuse(user, itype->rtype->ptype); - - ADDMSG(&user->faction->msgs, msg_message("usepotion", - "unit potion", user, itype->rtype)); - return 0; -} - static int use_warmthpotion(unit *u, const item_type *itype, int amount, struct order *ord) { @@ -840,64 +774,6 @@ static int use_warmthpotion(unit *u, const item_type *itype, return 0; } -static int use_foolpotion(unit *u, const item_type *itype, int amount, - struct order *ord) -{ - int targetno = read_unitid(u->faction, u->region); - unit *target = findunit(targetno); - if (target == NULL || u->region != target->region) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", - "")); - return ECUSTOM; - } - if (effskill(u, SK_STEALTH, 0) <= effskill(target, SK_PERCEPTION, 0)) { - cmistake(u, ord, 64, MSG_EVENT); - return ECUSTOM; - } - ADDMSG(&u->faction->msgs, msg_message("givedumb", - "unit recipient amount", u, target, amount)); - - change_effect(target, itype->rtype->ptype, amount); - use_pooled(u, itype->rtype, GET_DEFAULT, amount); - return 0; -} - -static int -use_bloodpotion(struct unit *u, const struct item_type *itype, int amount, -struct order *ord) -{ - if (u->number == 0 || u_race(u) == get_race(RC_DAEMON)) { - change_effect(u, itype->rtype->ptype, 100 * amount); - } - else { - const race *irace = u_irace(u); - if (irace == u_race(u)) { - const race *rcfailure = rc_find("smurf"); - if (!rcfailure) { - rcfailure = rc_find("toad"); - } - if (rcfailure) { - trigger *trestore = trigger_changerace(u, u_race(u), irace); - if (trestore) { - int duration = 2 + rng_int() % 8; - - add_trigger(&u->attribs, "timer", trigger_timeout(duration, - trestore)); - u->irace = NULL; - u_setrace(u, rcfailure); - } - } - } - } - use_pooled(u, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, - amount); - usetpotionuse(u, itype->rtype->ptype); - - ADDMSG(&u->faction->msgs, msg_message("usepotion", - "unit potion", u, itype->rtype)); - return 0; -} - #include static int use_mistletoe(struct unit *user, const struct item_type *itype, int amount, @@ -1288,12 +1164,8 @@ void register_resources(void) register_function((pf_generic)res_changeaura, "changeaura"); register_item_use(use_potion_delayed, "use_p2"); - register_item_use(use_tacticcrystal, "use_tacticcrystal"); - register_item_use(use_birthdayamulet, "use_aoc"); register_item_use(use_warmthpotion, "use_nestwarmth"); - register_item_use(use_bloodpotion, "use_peasantblood"); - register_item_use(use_healingpotion, "use_ointment"); - register_item_use(use_foolpotion, "use_p7"); + register_item_use(use_tacticcrystal, "use_tacticcrystal"); register_item_use(use_mistletoe, "usemistletoe"); register_item_use(use_magicboost, "usemagicboost"); register_item_use(use_snowball, "usesnowball"); From db0cbf34c713a25ff2c8743ad808a5a94577c2a6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 14:17:38 +0100 Subject: [PATCH 598/675] test for aurapotion --- scripts/tests/e2/e2features.lua | 17 +++++++++++++++++ src/items.c | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index 5af956980..59e93f86b 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -242,6 +242,23 @@ function test_meow() assert_equal(1, r:count_msg_type('meow')) end +function test_aurapotion50() + eressea.settings.set("magic.regeneration.enable", "0") + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("aurapotion50", 1) + u:set_skill('magic', 10); + u.magic = 'gwyrrd' + u.aura = 0 + u:clear_orders() + u:add_order("BENUTZEN 1 Auratrank") + process_orders() + assert_equal(0, u:get_item("aurapotion50")) + assert_equal(1, f:count_msg_type('aurapotion50')) + assert_equal(50, u.aura) +end + function test_ointment() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") diff --git a/src/items.c b/src/items.c index cae5ea642..75cb79b68 100644 --- a/src/items.c +++ b/src/items.c @@ -393,9 +393,9 @@ void register_itemfunctions(void) register_item_use(use_speedsail, "use_speedsail"); register_item_use(use_instantartacademy, "use_instantartacademy"); register_item_use(use_bagpipeoffear, "use_bagpipeoffear"); - register_item_use(use_aurapotion50, "use_aurapotion50"); /* have tests: */ + register_item_use(use_aurapotion50, "use_aurapotion50"); register_item_use(use_birthdayamulet, "use_aoc"); register_item_use(use_foolpotion, "use_p7"); register_item_use(use_bloodpotion, "use_peasantblood"); From 3d4860c0337933841b39820edeba3b3d1657bbc7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 14:19:25 +0100 Subject: [PATCH 599/675] remove more of the artrewards --- src/items.c | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/src/items.c b/src/items.c index 75cb79b68..b01fe21db 100644 --- a/src/items.c +++ b/src/items.c @@ -179,50 +179,6 @@ struct order *ord) return 0; } -static int -use_instantartsculpture(struct unit *u, const struct item_type *itype, -int amount, struct order *ord) -{ - building *b; - - if (u->region->land == NULL) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", "")); - return -1; - } - - b = new_building(bt_find("artsculpture"), u->region, u->faction->locale); - b->size = 100; - - ADDMSG(&u->region->msgs, msg_message("artsculpture_create", "unit region", - u, u->region)); - - use_pooled(u, itype->rtype, GET_DEFAULT, 1); - - return 0; -} - -static int -use_instantartacademy(struct unit *u, const struct item_type *itype, -int amount, struct order *ord) -{ - building *b; - - if (u->region->land == NULL) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", "")); - return -1; - } - - b = new_building(bt_find("artacademy"), u->region, u->faction->locale); - b->size = 100; - - ADDMSG(&u->region->msgs, msg_message("artacademy_create", "unit region", u, - u->region)); - - use_pooled(u, itype->rtype, GET_DEFAULT, 1); - - return 0; -} - #define BAGPIPEFRACTION dice_rand("2d4+2") #define BAGPIPEDURATION dice_rand("2d10+4") @@ -388,10 +344,8 @@ void register_itemfunctions(void) { register_demonseye(); register_item_use(use_antimagiccrystal, "use_antimagiccrystal"); - register_item_use(use_instantartsculpture, "use_instantartsculpture"); register_item_use(use_studypotion, "use_studypotion"); register_item_use(use_speedsail, "use_speedsail"); - register_item_use(use_instantartacademy, "use_instantartacademy"); register_item_use(use_bagpipeoffear, "use_bagpipeoffear"); /* have tests: */ From 108501e398a29106d1ba6a86e2730210d0ee5cdc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 15:14:52 +0100 Subject: [PATCH 600/675] tests for more items --- res/core/common/items.xml | 4 +-- scripts/tests/e2/e2features.lua | 52 +++++++++++++++++++++++++++++++++ src/items.c | 7 +++-- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/res/core/common/items.xml b/res/core/common/items.xml index 8745b6e59..30926a844 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -128,9 +128,7 @@ - - - + diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index 59e93f86b..a942480a9 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -259,6 +259,58 @@ function test_aurapotion50() assert_equal(50, u.aura) end +function test_bagpipe() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("bagpipeoffear", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Dudelsack") + process_orders() + assert_equal(1, u:get_item("bagpipeoffear")) + assert_equal(1, f:count_msg_type('bagpipeoffear_faction')) + assert_equal(1, r:count_msg_type('bagpipeoffear_region')) +end + +function test_speedsail() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u.ship = ship.create(r, "boat") + u:add_item("speedsail", 2) + u:clear_orders() + u:add_order("BENUTZEN 1 Sonnensegel") + process_orders() + assert_equal(1, u:get_item("speedsail")) + assert_equal(1, f:count_msg_type('use_speedsail')) +end + +--[[ +function test_studypotion() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("studypotion", 2) + u:clear_orders() + u:add_order("LERNE Unterhaltung") + u:add_order("BENUTZEN 1 Lerntrank") + process_orders() + assert_equal(1, u:get_item("studypotion")) +end +]]-- + +function test_antimagic() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("antimagic", 2) + u:clear_orders() + u:add_order("BENUTZEN 1 Antimagiekristall") + process_orders() + assert_equal(1, r:count_msg_type('use_antimagiccrystal')) + assert_equal(1, u:get_item("antimagic")) +end + function test_ointment() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") diff --git a/src/items.c b/src/items.c index b01fe21db..9833ac6f7 100644 --- a/src/items.c +++ b/src/items.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -343,12 +344,12 @@ struct order *ord) void register_itemfunctions(void) { register_demonseye(); - register_item_use(use_antimagiccrystal, "use_antimagiccrystal"); register_item_use(use_studypotion, "use_studypotion"); - register_item_use(use_speedsail, "use_speedsail"); - register_item_use(use_bagpipeoffear, "use_bagpipeoffear"); /* have tests: */ + register_item_use(use_antimagiccrystal, "use_antimagic"); + register_item_use(use_speedsail, "use_speedsail"); + register_item_use(use_bagpipeoffear, "use_bagpipeoffear"); register_item_use(use_aurapotion50, "use_aurapotion50"); register_item_use(use_birthdayamulet, "use_aoc"); register_item_use(use_foolpotion, "use_p7"); From 1a0992e37b1385ba91b633a58d7d7e982a3ebc63 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 18:21:41 +0100 Subject: [PATCH 601/675] =?UTF-8?q?remove=20remainders=20of=20the=20arena.?= =?UTF-8?q?=20Auge=20des=20Drachens=20haben=20noch=20einige=20Spieler,=20d?= =?UTF-8?q?arf=20nicht=20gel=C3=B6scht=20werden.=20move=20item=20tests=20t?= =?UTF-8?q?o=20tests/items.lua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...txt => gprof-v3.10.0-163-gdfab45d.profile} | 0 res/core/common/items.xml | 5 + res/eressea/items.xml | 20 +- res/eressea/strings.xml | 35 --- scripts/tests/e2/e2features.lua | 165 ------------ scripts/tests/e2/init.lua | 1 + scripts/tests/items.lua | 186 +++++++++++++ src/attributes/attributes.c | 1 + src/eressea.c | 6 - src/gmtool.c | 3 - src/items.c | 9 +- src/modules/CMakeLists.txt | 1 - src/modules/arena.c | 255 ------------------ src/modules/arena.h | 39 --- src/settings.h | 1 - 15 files changed, 198 insertions(+), 529 deletions(-) rename doc/{gprof-v3.10.0-163-gdfab45d.txt => gprof-v3.10.0-163-gdfab45d.profile} (100%) create mode 100644 scripts/tests/items.lua delete mode 100644 src/modules/arena.c delete mode 100644 src/modules/arena.h diff --git a/doc/gprof-v3.10.0-163-gdfab45d.txt b/doc/gprof-v3.10.0-163-gdfab45d.profile similarity index 100% rename from doc/gprof-v3.10.0-163-gdfab45d.txt rename to doc/gprof-v3.10.0-163-gdfab45d.profile diff --git a/res/core/common/items.xml b/res/core/common/items.xml index 30926a844..63a07d88f 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -98,6 +98,11 @@ + + + + + diff --git a/res/eressea/items.xml b/res/eressea/items.xml index c0b8b5126..007f0277c 100644 --- a/res/eressea/items.xml +++ b/res/eressea/items.xml @@ -86,27 +86,9 @@ - - - - - - - - - - - - - - - - - - - + diff --git a/res/eressea/strings.xml b/res/eressea/strings.xml index f7497b810..4869014c5 100644 --- a/res/eressea/strings.xml +++ b/res/eressea/strings.xml @@ -116,18 +116,6 @@ Eine Geburtstagstorte mit 10 Kerzen. Herzlichen Glückwunsch, Eressea! A birthday cake with 10 candles. Happy Birthday, Eressea! - - Dieses Fluggerät aus der Schmiede der Zwerge von Celeband galt wie die - 'Ebene der Herausforderung' seit Urzeiten als verschollen, ja man - zweifelte seine Existenz an. Die Sage überliefert, das derjenige, der - sie auf der Spitze des Turmes seiner Gesinnung benutzt, als einziger - die 'Ebene der Herausforderungen' verlassen kann. - - - Glückwunsch, mein Kind. Du bist im Besitz des mächtigsten - Artefaktes Eresseas. Ein Fluch, sagt man, liege auf ihm, denn - niemand hat es bisher lange sein Eigen genannt... - Kleines trockenes Dauergebäck, m od. s; - u. -es, - u. -e @@ -374,29 +362,6 @@ - - - Auge des Dämon - eye of the demon - oeil du démon - - - Augen des Dämon - eyes of the demon - oeil du démon - - - Schwinge des Greifen - wing of the gryphon - aile du griffon - - - Schwingen des Greifen - wings of the gryphon - ailes du griffon - - - Adamantium adamantium diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index a942480a9..da2a98d55 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -230,171 +230,6 @@ function test_no_uruk() assert_equal(f1.race, "orc") end -function test_meow() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("aoc", 1) - u:clear_orders() - u:add_order("BENUTZEN 1 Katzenamulett") - process_orders() - assert_equal(1, u:get_item("aoc")) - assert_equal(1, r:count_msg_type('meow')) -end - -function test_aurapotion50() - eressea.settings.set("magic.regeneration.enable", "0") - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("aurapotion50", 1) - u:set_skill('magic', 10); - u.magic = 'gwyrrd' - u.aura = 0 - u:clear_orders() - u:add_order("BENUTZEN 1 Auratrank") - process_orders() - assert_equal(0, u:get_item("aurapotion50")) - assert_equal(1, f:count_msg_type('aurapotion50')) - assert_equal(50, u.aura) -end - -function test_bagpipe() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("bagpipeoffear", 1) - u:clear_orders() - u:add_order("BENUTZEN 1 Dudelsack") - process_orders() - assert_equal(1, u:get_item("bagpipeoffear")) - assert_equal(1, f:count_msg_type('bagpipeoffear_faction')) - assert_equal(1, r:count_msg_type('bagpipeoffear_region')) -end - -function test_speedsail() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.ship = ship.create(r, "boat") - u:add_item("speedsail", 2) - u:clear_orders() - u:add_order("BENUTZEN 1 Sonnensegel") - process_orders() - assert_equal(1, u:get_item("speedsail")) - assert_equal(1, f:count_msg_type('use_speedsail')) -end - ---[[ -function test_studypotion() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("studypotion", 2) - u:clear_orders() - u:add_order("LERNE Unterhaltung") - u:add_order("BENUTZEN 1 Lerntrank") - process_orders() - assert_equal(1, u:get_item("studypotion")) -end -]]-- - -function test_antimagic() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("antimagic", 2) - u:clear_orders() - u:add_order("BENUTZEN 1 Antimagiekristall") - process_orders() - assert_equal(1, r:count_msg_type('use_antimagiccrystal')) - assert_equal(1, u:get_item("antimagic")) -end - -function test_ointment() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - local hp = u.hp - u.hp = 1 - u:add_item("ointment", 1) - u:clear_orders() - u:add_order("BENUTZEN 1 Wundsalbe") - process_orders() - assert_equal(0, u:get_item("ointment")) - assert_equal(1, f:count_msg_type('usepotion')) - assert_equal(hp, u.hp) -end - -function test_bloodpotion_demon() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "demon", "de") - local u = unit.create(f, r, 1) - u:add_item("peasantblood", 1) - u:clear_orders() - u:add_order("BENUTZEN 1 Bauernblut") - process_orders() - assert_equal(0, u:get_item("peasantblood")) - assert_equal(1, f:count_msg_type('usepotion')) - assert_equal("demon", u.race) -end - -function test_bloodpotion_other() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("peasantblood", 1) - u:clear_orders() - u:add_order("BENUTZEN 1 Bauernblut") - process_orders() - assert_equal(0, u:get_item("peasantblood")) - assert_equal(1, f:count_msg_type('usepotion')) - assert_equal("smurf", u.race) -end - -function test_foolpotion() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("p7", 1) - u:clear_orders() - u:add_order("BENUTZEN 1 Dumpfbackenbrot 4242") - process_orders() - assert_equal(1, u:get_item("p7")) - assert_equal(1, f:count_msg_type('feedback_unit_not_found')) - local u2 = unit.create(f, r, 1) - - u:clear_orders() - u:add_order("BENUTZEN 1 Dumpfbackenbrot " .. itoa36(u2.id)) - process_orders() - assert_equal(1, u:get_item("p7")) - assert_equal(1, f:count_msg_type('error64')) - - u:set_skill("stealth", 1); - process_orders() - assert_equal(0, u:get_item("p7")) - assert_equal(1, f:count_msg_type('givedumb')) -end - -function test_snowman() - local r = region.create(0, 0, "glacier") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("snowman", 1) - u:clear_orders() - u:add_order("BENUTZEN 1 Schneemann") - process_orders() - for u2 in r.units do - if u2.id~=u.id then - assert_equal("snowman", u2.race) - assert_equal(1000, u2.hp) - u = nil - break - end - end - assert_equal(nil, u) -end - function test_block_movement() eressea.settings.set("rules.guard.base_stop_prob", "0.3") eressea.settings.set("rules.guard.amulet_stop_prob", "0.0") diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index afaac7209..4d916d1a9 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -8,6 +8,7 @@ require 'tests.e2.destroy' require 'tests.e2.guard' require 'tests.e2.spells' require 'tests.e2.stealth' +require 'tests.items' require 'tests.orders' require 'tests.common' require 'tests.report' diff --git a/scripts/tests/items.lua b/scripts/tests/items.lua new file mode 100644 index 000000000..15d638a63 --- /dev/null +++ b/scripts/tests/items.lua @@ -0,0 +1,186 @@ +require "lunit" + +module("tests.items", package.seeall, lunit.testcase ) + +function setup() + eressea.free_game() + eressea.settings.set("nmr.timeout", "0") + eressea.settings.set("rules.food.flags", "4") + eressea.settings.set("rules.ship.storms", "0") + eressea.settings.set("rules.encounters", "0") +end + +function test_meow() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("aoc", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Katzenamulett") + process_orders() + assert_equal(1, u:get_item("aoc")) + assert_equal(1, r:count_msg_type('meow')) +end + +function test_aurapotion50() + eressea.settings.set("magic.regeneration.enable", "0") + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("aurapotion50", 1) + u:set_skill('magic', 10); + u.magic = 'gwyrrd' + u.aura = 0 + u:clear_orders() + u:add_order("BENUTZEN 1 Auratrank") + process_orders() + assert_equal(0, u:get_item("aurapotion50")) + assert_equal(1, f:count_msg_type('aurapotion50')) + assert_equal(50, u.aura) +end + +function test_bagpipe() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("bagpipeoffear", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Dudelsack") + process_orders() + assert_equal(1, u:get_item("bagpipeoffear")) + assert_equal(1, f:count_msg_type('bagpipeoffear_faction')) + assert_equal(1, r:count_msg_type('bagpipeoffear_region')) +end + +function test_speedsail() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u.ship = ship.create(r, "boat") + u:add_item("speedsail", 2) + u:clear_orders() + u:add_order("BENUTZEN 1 Sonnensegel") + process_orders() + assert_equal(1, u:get_item("speedsail")) + assert_equal(1, f:count_msg_type('use_speedsail')) +end + +function test_skillpotion() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("skillpotion", 2) + u:clear_orders() + u:add_order("BENUTZEN 1 Talenttrunk") + process_orders() + assert_equal(1, u:get_item("skillpotion")) + assert_equal(1, f:count_msg_type('skillpotion_use')) +end + +function test_studypotion() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("studypotion", 2) + u:clear_orders() + u:add_order("LERNE Unterhaltung") + u:add_order("BENUTZEN 1 Lerntrank") + process_orders() + assert_equal(1, u:get_item("studypotion")) +end + +function test_antimagic() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("antimagic", 2) + u:clear_orders() + u:add_order("BENUTZEN 1 Antimagiekristall") + process_orders() + assert_equal(1, r:count_msg_type('use_antimagiccrystal')) + assert_equal(1, u:get_item("antimagic")) +end + +function test_ointment() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + local hp = u.hp + u.hp = 1 + u:add_item("ointment", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Wundsalbe") + process_orders() + assert_equal(0, u:get_item("ointment")) + assert_equal(1, f:count_msg_type('usepotion')) + assert_equal(hp, u.hp) +end + +function test_bloodpotion_demon() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "demon", "de") + local u = unit.create(f, r, 1) + u:add_item("peasantblood", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Bauernblut") + process_orders() + assert_equal(0, u:get_item("peasantblood")) + assert_equal(1, f:count_msg_type('usepotion')) + assert_equal("demon", u.race) +end + +function test_bloodpotion_other() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("peasantblood", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Bauernblut") + process_orders() + assert_equal(0, u:get_item("peasantblood")) + assert_equal(1, f:count_msg_type('usepotion')) + assert_equal("smurf", u.race) +end + +function test_foolpotion() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("p7", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Dumpfbackenbrot 4242") + process_orders() + assert_equal(1, u:get_item("p7")) + assert_equal(1, f:count_msg_type('feedback_unit_not_found')) + local u2 = unit.create(f, r, 1) + + u:clear_orders() + u:add_order("BENUTZEN 1 Dumpfbackenbrot " .. itoa36(u2.id)) + process_orders() + assert_equal(1, u:get_item("p7")) + assert_equal(1, f:count_msg_type('error64')) + + u:set_skill("stealth", 1); + process_orders() + assert_equal(0, u:get_item("p7")) + assert_equal(1, f:count_msg_type('givedumb')) +end + +function test_snowman() + local r = region.create(0, 0, "glacier") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("snowman", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Schneemann") + process_orders() + for u2 in r.units do + if u2.id~=u.id then + assert_equal("snowman", u2.race) + assert_equal(1000, u2.hp) + u = nil + break + end + end + assert_equal(nil, u) +end diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index 42f5247fe..ae6869df8 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -112,6 +112,7 @@ void register_attributes(void) at_register(&at_germs); + at_deprecate("hurting", a_readint); /* an old arena attribute */ at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */ at_deprecate("orcification", a_readint); /* required for old datafiles */ at_deprecate("lua", read_ext); /* required for old datafiles */ diff --git a/src/eressea.c b/src/eressea.c index 8001355f1..2d53c2511 100755 --- a/src/eressea.c +++ b/src/eressea.c @@ -8,9 +8,6 @@ #if MUSEUM_MODULE #include #endif -#if ARENA_MODULE -#include -#endif #include #include #include @@ -77,9 +74,6 @@ void game_init(void) register_itemfunctions(); #if MUSEUM_MODULE register_museum(); -#endif -#if ARENA_MODULE - register_arena(); #endif wormholes_register(); diff --git a/src/gmtool.c b/src/gmtool.c index 3551c3436..148aafe6d 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -26,9 +26,6 @@ #if MUSEUM_MODULE #include #endif -#if ARENA_MODULE -#include -#endif #include #include diff --git a/src/items.c b/src/items.c index 9833ac6f7..197240d3e 100644 --- a/src/items.c +++ b/src/items.c @@ -70,9 +70,9 @@ struct order *ord) if (amount > MAXGAIN) { amount = MAXGAIN; } - teach->value += amount * 30; - if (teach->value > MAXGAIN * 30) { - teach->value = MAXGAIN * 30; + teach->value += amount * STUDYDAYS; + if (teach->value > MAXGAIN * STUDYDAYS) { + teach->value = MAXGAIN * STUDYDAYS; } i_change(&u->items, itype, -amount); return 0; @@ -80,7 +80,6 @@ struct order *ord) } return EUNUSABLE; } - /* END studypotion */ /* BEGIN speedsail */ @@ -344,9 +343,9 @@ struct order *ord) void register_itemfunctions(void) { register_demonseye(); - register_item_use(use_studypotion, "use_studypotion"); /* have tests: */ + register_item_use(use_studypotion, "use_studypotion"); register_item_use(use_antimagiccrystal, "use_antimagic"); register_item_use(use_speedsail, "use_speedsail"); register_item_use(use_bagpipeoffear, "use_bagpipeoffear"); diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 633c486f5..82dee9ec4 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -1,6 +1,5 @@ PROJECT(modules C) SET(_FILES -arena.c autoseed.c gmcmd.c museum.c diff --git a/src/modules/arena.c b/src/modules/arena.c deleted file mode 100644 index fbc3f0673..000000000 --- a/src/modules/arena.c +++ /dev/null @@ -1,255 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#include -#include - -#if ARENA_MODULE -#include "arena.h" - -/* modules include */ -#include "score.h" - -/* items include */ -#include - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* util include */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* libc include */ -#include -#include -#include -#include - -/* exports: */ -plane *arena = NULL; - -/* local vars */ -#define CENTRAL_VOLCANO 1 - -static region *tower_region[6]; -static region *start_region[6]; - -static region *arena_region(int school) -{ - return tower_region[school]; -} - -static building *arena_tower(int school) -{ - return arena_region(school)->buildings; -} - -static int leave_fail(unit * u) -{ - ADDMSG(&u->faction->msgs, msg_message("arena_leave_fail", "unit", u)); - return 1; -} - -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_ARG(amount); - UNUSED_ARG(ord); - UNUSED_ARG(itype); - assert(!"not implemented"); - return 0; -} - -static int enter_fail(unit * u) -{ - ADDMSG(&u->faction->msgs, msg_message("arena_enter_fail", "region unit", - u->region, u)); - return 1; -} - -static int -enter_arena(unit * u, const item_type * itype, int amount, order * ord) -{ - skill_t sk; - region *r = u->region; - unit *u2; - int fee = 2000; - UNUSED_ARG(ord); - UNUSED_ARG(amount); - UNUSED_ARG(itype); - if (u->faction->score > fee * 5) { - score_t score = u->faction->score / 5; - if (score < INT_MAX) { - fee = (int)score; - } - else { - fee = INT_MAX; - } - } - if (getplane(r) == arena) - return -1; - if (u->number != 1 && enter_fail(u)) - return -1; - if (get_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT, fee) < fee - && enter_fail(u)) - return -1; - for (sk = 0; sk != MAXSKILLS; ++sk) { - if (get_level(u, sk) > 1 && enter_fail(u)) - return -1; - } - for (u2 = r->units; u2; u2 = u2->next) - if (u2->faction == u->faction) - break; - - assert(!"not implemented"); - /* - for (res=0;res!=MAXRESOURCES;++res) if (res!=R_SILVER && res!=R_ARENA_GATE && (is_item(res) || is_herb(res) || is_potion(res))) { - int x = get_resource(u, res); - if (x) { - if (u2) { - change_resource(u2, res, x); - change_resource(u, res, -x); - } - else if (enter_fail(u)) return -1; - } - } - */ - if (get_money(u) > fee) { - if (u2) - change_money(u2, get_money(u) - fee); - else if (enter_fail(u)) - return -1; - } - ADDMSG(&u->faction->msgs, msg_message("arena_enter_fail", "region unit", - u->region, u)); - use_pooled(u, itype->rtype, GET_SLACK | GET_RESERVE, 1); - use_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT, fee); - set_money(u, 109); - fset(u, UFL_ANON_FACTION); - move_unit(u, start_region[rng_int() % 6], NULL); - return 0; -} -#ifdef CENTRAL_VOLCANO - -static int caldera_handle(trigger * t, void *data) -{ - /* call an event handler on caldera. - * data.v -> ( variant event, int timer ) - */ - building *b = (building *)t->data.v; - if (b != NULL) { - unit **up = &b->region->units; - while (*up) { - unit *u = *up; - if (u->building == b) { - message *msg; - if (u->items) { - item **ip = &u->items; - msg = msg_message("caldera_handle_1", "unit items", u, u->items); - while (*ip) { - item *i = *ip; - i_remove(ip, i); - if (*ip == i) - ip = &i->next; - } - } - else { - msg = msg_message("caldera_handle_0", "unit", u); - } - add_message(&u->region->msgs, msg); - set_number(u, 0); - } - if (*up == u) - up = &u->next; - } - } - else { - log_error("could not perform caldera::handle()\n"); - } - UNUSED_ARG(data); - return 0; -} - -static void caldera_write(const trigger * t, struct storage *store) -{ - building *b = (building *)t->data.v; - write_building_reference(b, store); -} - -static int caldera_read(trigger * t, struct gamedata *data) -{ - int rb = - read_reference(&t->data.v, data, read_building_reference, - resolve_building); - if (rb == 0 && !t->data.v) { - return AT_READ_FAIL; - } - return AT_READ_OK; -} - -struct trigger_type tt_caldera = { - "caldera", - NULL, - NULL, - caldera_handle, - caldera_write, - caldera_read -}; - -#endif - -void register_arena(void) -{ - at_deprecate("hurting", a_readint); - register_function((pf_generic)enter_arena, "enter_arena"); - register_function((pf_generic)leave_arena, "leave_arena"); - tt_register(&tt_caldera); -} - -#endif /* def ARENA_MODULE */ diff --git a/src/modules/arena.h b/src/modules/arena.h deleted file mode 100644 index 64bfc7e87..000000000 --- a/src/modules/arena.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef ARENA_H -#define ARENA_H -#ifdef __cplusplus -extern "C" { -#endif - -#if ARENA_MODULE == 0 -#error "must define ARENA_MODULE to use this module" -#endif - /* exports: */ - extern struct plane *arena; - - extern void register_arena(void); -#ifdef ARENA_CREATION - extern void create_arena(void); -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/settings.h b/src/settings.h index b77e4687a..e7ec39305 100644 --- a/src/settings.h +++ b/src/settings.h @@ -31,7 +31,6 @@ * or both. We don't want separate binaries for different games */ #define MUSEUM_MODULE 1 -#define ARENA_MODULE 1 #undef REGIONOWNERS /* (WIP) region-owner uses HELP_TRAVEL to control entry to region */ From 1b93c148065a6353eb648a0223f778a69cf09517 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 18:50:48 +0100 Subject: [PATCH 602/675] Test E2 items in E2 only. Remove eye of demon (broken item). --- res/core/common/items.xml | 16 +----- res/core/de/strings.xml | 6 -- res/core/en/strings.xml | 6 -- res/core/fr/strings.xml | 6 -- res/eressea/items.xml | 4 ++ res/eressea/strings.xml | 11 +++- scripts/tests/e2/init.lua | 1 + scripts/tests/e2/items.lua | 109 +++++++++++++++++++++++++++++++++++ scripts/tests/e3/init.lua | 1 + scripts/tests/items.lua | 115 ++++++++----------------------------- src/items.c | 33 +++++++++-- src/items/CMakeLists.txt | 1 - src/items/demonseye.c | 65 --------------------- src/items/demonseye.h | 30 ---------- src/kernel/item.c | 29 ---------- src/modules/gmcmd.c | 1 - 16 files changed, 180 insertions(+), 254 deletions(-) create mode 100644 scripts/tests/e2/items.lua delete mode 100644 src/items/demonseye.c delete mode 100644 src/items/demonseye.h diff --git a/res/core/common/items.xml b/res/core/common/items.xml index 63a07d88f..0e1505205 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -61,14 +61,8 @@ - - - - - - - + @@ -105,16 +99,12 @@ - - - + - - - + diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 26e8cc862..46d5605b1 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -1458,12 +1458,6 @@ Amulette des wahren Sehens - - Katzenamulett - - - Katzenamulette - Ring der Unsichtbarkeit diff --git a/res/core/en/strings.xml b/res/core/en/strings.xml index 063194c5d..14b2b817d 100644 --- a/res/core/en/strings.xml +++ b/res/core/en/strings.xml @@ -444,12 +444,6 @@ amulets of chastity - - amulet of the kitten - - - amulets of the kitten - amulet of darkness diff --git a/res/core/fr/strings.xml b/res/core/fr/strings.xml index c69bb5b75..13e6beb25 100644 --- a/res/core/fr/strings.xml +++ b/res/core/fr/strings.xml @@ -458,12 +458,6 @@ amulettes de chasteté - - amulette du chaton - - - amulettes du chaton - amulette de ténčbres diff --git a/res/eressea/items.xml b/res/eressea/items.xml index 007f0277c..a785691fe 100644 --- a/res/eressea/items.xml +++ b/res/eressea/items.xml @@ -86,6 +86,10 @@ + + + + diff --git a/res/eressea/strings.xml b/res/eressea/strings.xml index 4869014c5..8afeabbca 100644 --- a/res/eressea/strings.xml +++ b/res/eressea/strings.xml @@ -392,5 +392,14 @@ Adamantiumrüstungen adamantium plates - + + Katzenamulett + amulet of the kitten + amulette du chaton + + + amulets of the kitten + Katzenamulette + amulettes du chaton + diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 4d916d1a9..5f81933d7 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -8,6 +8,7 @@ require 'tests.e2.destroy' require 'tests.e2.guard' require 'tests.e2.spells' require 'tests.e2.stealth' +require 'tests.e2.items' require 'tests.items' require 'tests.orders' require 'tests.common' diff --git a/scripts/tests/e2/items.lua b/scripts/tests/e2/items.lua new file mode 100644 index 000000000..da72bdbbc --- /dev/null +++ b/scripts/tests/e2/items.lua @@ -0,0 +1,109 @@ +require "lunit" + +module("tests.items", package.seeall, lunit.testcase ) + +function setup() + eressea.free_game() + eressea.settings.set("nmr.timeout", "0") + eressea.settings.set("rules.food.flags", "4") + eressea.settings.set("rules.ship.storms", "0") + eressea.settings.set("rules.encounters", "0") + eressea.settings.set("magic.regeneration.enable", "0") +end + +function test_meow() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("aoc", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Katzenamulett") + process_orders() + assert_equal(1, u:get_item("aoc")) + assert_equal(1, r:count_msg_type('meow')) +end + +function test_aurapotion50() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("aurapotion50", 1) + u:set_skill('magic', 10); + u.magic = 'gwyrrd' + u.aura = 0 + u:clear_orders() + u:add_order("BENUTZEN 1 Auratrank") + process_orders() + assert_equal(0, u:get_item("aurapotion50")) + assert_equal(1, f:count_msg_type('aurapotion50')) + assert_equal(50, u.aura) +end + +function test_bagpipe() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("bagpipeoffear", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Dudelsack") + process_orders() + assert_equal(1, u:get_item("bagpipeoffear")) + assert_equal(1, f:count_msg_type('bagpipeoffear_faction')) + assert_equal(1, r:count_msg_type('bagpipeoffear_region')) +end + +function test_speedsail() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u.ship = ship.create(r, "boat") + u:add_item("speedsail", 2) + u:clear_orders() + u:add_order("BENUTZEN 1 Sonnensegel") + process_orders() + assert_equal(1, u:get_item("speedsail")) + assert_equal(1, f:count_msg_type('use_speedsail')) +end + +function test_foolpotion() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("p7", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Dumpfbackenbrot 4242") + process_orders() + assert_equal(1, u:get_item("p7")) + assert_equal(1, f:count_msg_type('feedback_unit_not_found')) + local u2 = unit.create(f, r, 1) + + u:clear_orders() + u:add_order("BENUTZEN 1 Dumpfbackenbrot " .. itoa36(u2.id)) + process_orders() + assert_equal(1, u:get_item("p7")) + assert_equal(1, f:count_msg_type('error64')) + + u:set_skill("stealth", 1); + process_orders() + assert_equal(0, u:get_item("p7")) + assert_equal(1, f:count_msg_type('givedumb')) +end + +function test_snowman() + local r = region.create(0, 0, "glacier") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("snowman", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Schneemann") + process_orders() + for u2 in r.units do + if u2.id~=u.id then + assert_equal("snowman", u2.race) + assert_equal(1000, u2.hp) + u = nil + break + end + end + assert_equal(nil, u) +end diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua index 4655fdcef..95df86c4c 100644 --- a/scripts/tests/e3/init.lua +++ b/scripts/tests/e3/init.lua @@ -6,6 +6,7 @@ require 'tests.e3.parser' require 'tests.e3.morale' require 'tests.orders' require 'tests.common' +require 'tests.items' -- require 'tests.report' require 'tests.magicbag' require 'tests.process' diff --git a/scripts/tests/items.lua b/scripts/tests/items.lua index 15d638a63..ff292b4cb 100644 --- a/scripts/tests/items.lua +++ b/scripts/tests/items.lua @@ -8,61 +8,35 @@ function setup() eressea.settings.set("rules.food.flags", "4") eressea.settings.set("rules.ship.storms", "0") eressea.settings.set("rules.encounters", "0") -end - -function test_meow() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("aoc", 1) - u:clear_orders() - u:add_order("BENUTZEN 1 Katzenamulett") - process_orders() - assert_equal(1, u:get_item("aoc")) - assert_equal(1, r:count_msg_type('meow')) -end - -function test_aurapotion50() eressea.settings.set("magic.regeneration.enable", "0") +end + +function test_dreameye() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") local u = unit.create(f, r, 1) - u:add_item("aurapotion50", 1) - u:set_skill('magic', 10); - u.magic = 'gwyrrd' + u:add_item("dreameye", 2) + u:clear_orders() + u:add_order("BENUTZEN 1 Traumauge") + process_orders() + assert_equal(1, u:get_item("dreameye")) + assert_equal(1, f:count_msg_type('use_tacticcrystal')) +end + +function test_manacrystal() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("manacrystal", 2) + u:clear_orders() + u.magic = "gwyrrd" + u:set_skill('magic', 1) u.aura = 0 - u:clear_orders() - u:add_order("BENUTZEN 1 Auratrank") + u:add_order("BENUTZEN 1 Astralkristall") process_orders() - assert_equal(0, u:get_item("aurapotion50")) - assert_equal(1, f:count_msg_type('aurapotion50')) - assert_equal(50, u.aura) -end - -function test_bagpipe() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("bagpipeoffear", 1) - u:clear_orders() - u:add_order("BENUTZEN 1 Dudelsack") - process_orders() - assert_equal(1, u:get_item("bagpipeoffear")) - assert_equal(1, f:count_msg_type('bagpipeoffear_faction')) - assert_equal(1, r:count_msg_type('bagpipeoffear_region')) -end - -function test_speedsail() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.ship = ship.create(r, "boat") - u:add_item("speedsail", 2) - u:clear_orders() - u:add_order("BENUTZEN 1 Sonnensegel") - process_orders() - assert_equal(1, u:get_item("speedsail")) - assert_equal(1, f:count_msg_type('use_speedsail')) + assert_equal(1, u:get_item("manacrystal")) + assert_equal(25, u.aura) + assert_equal(1, f:count_msg_type('manacrystal_use')) end function test_skillpotion() @@ -141,46 +115,3 @@ function test_bloodpotion_other() assert_equal(1, f:count_msg_type('usepotion')) assert_equal("smurf", u.race) end - -function test_foolpotion() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("p7", 1) - u:clear_orders() - u:add_order("BENUTZEN 1 Dumpfbackenbrot 4242") - process_orders() - assert_equal(1, u:get_item("p7")) - assert_equal(1, f:count_msg_type('feedback_unit_not_found')) - local u2 = unit.create(f, r, 1) - - u:clear_orders() - u:add_order("BENUTZEN 1 Dumpfbackenbrot " .. itoa36(u2.id)) - process_orders() - assert_equal(1, u:get_item("p7")) - assert_equal(1, f:count_msg_type('error64')) - - u:set_skill("stealth", 1); - process_orders() - assert_equal(0, u:get_item("p7")) - assert_equal(1, f:count_msg_type('givedumb')) -end - -function test_snowman() - local r = region.create(0, 0, "glacier") - local f = faction.create("noreply@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:add_item("snowman", 1) - u:clear_orders() - u:add_order("BENUTZEN 1 Schneemann") - process_orders() - for u2 in r.units do - if u2.id~=u.id then - assert_equal("snowman", u2.race) - assert_equal(1000, u2.hp) - u = nil - break - end - end - assert_equal(nil, u) -end diff --git a/src/items.c b/src/items.c index 197240d3e..ccba7ae7f 100644 --- a/src/items.c +++ b/src/items.c @@ -21,8 +21,6 @@ #include #include -#include - /* triggers includes */ #include #include @@ -340,11 +338,38 @@ struct order *ord) return 0; } +/* ------------------------------------------------------------- */ +/* Kann auch von Nichtmagier benutzt werden, modifiziert Taktik fuer diese +* Runde um -1 - 4 Punkte. */ +static int +use_tacticcrystal(unit * u, const struct item_type *itype, int amount, + struct order *ord) +{ + int i; + for (i = 0; i != amount; ++i) { + int duration = 1; /* wirkt nur eine Runde */ + curse *c; + float effect; + float power = 5; /* Widerstand gegen Antimagiesprueche, ist in diesem + Fall egal, da der curse fuer den Kampf gelten soll, + der vor den Antimagiezaubern passiert */ + + effect = (float)(rng_int() % 6 - 1); + c = create_curse(u, &u->attribs, ct_find("skillmod"), power, + duration, effect, u->number); + c->data.i = SK_TACTICS; + UNUSED_ARG(ord); + } + use_pooled(u, itype->rtype, GET_DEFAULT, amount); + ADDMSG(&u->faction->msgs, msg_message("use_tacticcrystal", + "unit region", u, u->region)); + return 0; +} + void register_itemfunctions(void) { - register_demonseye(); - /* have tests: */ + register_item_use(use_tacticcrystal, "use_dreameye"); register_item_use(use_studypotion, "use_studypotion"); register_item_use(use_antimagiccrystal, "use_antimagic"); register_item_use(use_speedsail, "use_speedsail"); diff --git a/src/items/CMakeLists.txt b/src/items/CMakeLists.txt index bbf192a66..37777f9e4 100644 --- a/src/items/CMakeLists.txt +++ b/src/items/CMakeLists.txt @@ -5,7 +5,6 @@ xerewards.test.c ) SET(_FILES -demonseye.c speedsail.c weapons.c xerewards.c diff --git a/src/items/demonseye.c b/src/items/demonseye.c deleted file mode 100644 index 563a16047..000000000 --- a/src/items/demonseye.c +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#include -#include "demonseye.h" - -/* kernel includes */ -#include -#include -#include -#include -#include -#include - -/* util includes */ -#include - -/* libc includes */ -#include - -static int -summon_igjarjuk(struct unit *u, const struct item_type *itype, int amount, -struct order *ord) -{ - struct plane *p = rplane(u->region); - UNUSED_ARG(amount); - UNUSED_ARG(itype); - if (p != NULL) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", "")); - return EUNUSABLE; - } - else { - assert(!"not implemented"); - return EUNUSABLE; - } -} - -static int -give_igjarjuk(struct unit *src, struct unit *d, const struct item_type *itype, -int n, struct order *ord) -{ - ADDMSG(&src->faction->msgs, msg_feedback(src, ord, "error_giveeye", "")); - return 0; -} - -void register_demonseye(void) -{ - register_item_use(summon_igjarjuk, "useigjarjuk"); - register_item_give(give_igjarjuk, "giveigjarjuk"); -} diff --git a/src/items/demonseye.h b/src/items/demonseye.h deleted file mode 100644 index 8d878a174..000000000 --- a/src/items/demonseye.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef H_ITM_DEMONSEYE -#define H_ITM_DEMONSEYE -#ifdef __cplusplus -extern "C" { -#endif - - void register_demonseye(void); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/kernel/item.c b/src/kernel/item.c index ecad829ca..adfddf6f4 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -677,34 +677,6 @@ int set_item(unit * u, const item_type *itype, int value) #define FL_ITEM_ANIMAL (1<<3) /* ist ein Tier */ #define FL_ITEM_MOUNT ((1<<4) | FL_ITEM_ANIMAL) /* ist ein Reittier */ -/* ------------------------------------------------------------- */ -/* Kann auch von Nichtmagier benutzt werden, modifiziert Taktik fuer diese - * Runde um -1 - 4 Punkte. */ -static int -use_tacticcrystal(unit * u, const struct item_type *itype, int amount, -struct order *ord) -{ - int i; - for (i = 0; i != amount; ++i) { - int duration = 1; /* wirkt nur eine Runde */ - curse *c; - float effect; - float power = 5; /* Widerstand gegen Antimagiesprueche, ist in diesem - Fall egal, da der curse fuer den Kampf gelten soll, - der vor den Antimagiezaubern passiert */ - - effect = (float)(rng_int() % 6 - 1); - c = create_curse(u, &u->attribs, ct_find("skillmod"), power, - duration, effect, u->number); - c->data.i = SK_TACTICS; - UNUSED_ARG(ord); - } - use_pooled(u, itype->rtype, GET_DEFAULT, amount); - ADDMSG(&u->faction->msgs, msg_message("use_tacticcrystal", - "unit region", u, u->region)); - return 0; -} - typedef struct t_item { const char *name; /* [0]: Einzahl fuer eigene; [1]: Mehrzahl fuer eigene; @@ -1165,7 +1137,6 @@ void register_resources(void) register_item_use(use_potion_delayed, "use_p2"); register_item_use(use_warmthpotion, "use_nestwarmth"); - register_item_use(use_tacticcrystal, "use_tacticcrystal"); register_item_use(use_mistletoe, "usemistletoe"); register_item_use(use_magicboost, "usemagicboost"); register_item_use(use_snowball, "usesnowball"); diff --git a/src/modules/gmcmd.c b/src/modules/gmcmd.c index 9a4e7ac47..c911e3de4 100644 --- a/src/modules/gmcmd.c +++ b/src/modules/gmcmd.c @@ -16,7 +16,6 @@ #include /* misc includes */ -#include #include #include From 9d09574d5e10c8ec30e6ae8c564030e872ba0e20 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 19:35:14 +0100 Subject: [PATCH 603/675] enable process_orders to be done in steps. by checking before turn_end(), we can sense temporary attributes and curses on a unit before they age away. --- res/core/common/items.xml | 10 +++---- res/eressea/artrewards.xml | 8 ++---- scripts/tests/e2/items.lua | 18 ++++++++----- scripts/tests/items.lua | 27 +++++++++++++++++-- src/bind_unit.c | 19 ++++++++++++++ src/bindings.c | 53 +++++++++++++++----------------------- src/items.c | 27 ++++++++++++++++++- src/kernel/item.c | 24 ----------------- src/laws.c | 49 +++++++++++++++++++++++++++++++++-- src/laws.h | 4 ++- src/util/attrib.c | 16 +++++++++--- src/util/attrib.h | 18 ++++++------- 12 files changed, 180 insertions(+), 93 deletions(-) diff --git a/res/core/common/items.xml b/res/core/common/items.xml index 0e1505205..8f2bbabf8 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -110,20 +110,16 @@ - - - + - - - + - + diff --git a/res/eressea/artrewards.xml b/res/eressea/artrewards.xml index 2a3c09950..b18fd5b20 100644 --- a/res/eressea/artrewards.xml +++ b/res/eressea/artrewards.xml @@ -3,16 +3,12 @@ - - - + - - - + diff --git a/scripts/tests/e2/items.lua b/scripts/tests/e2/items.lua index da72bdbbc..9bc747650 100644 --- a/scripts/tests/e2/items.lua +++ b/scripts/tests/e2/items.lua @@ -1,6 +1,6 @@ require "lunit" -module("tests.items", package.seeall, lunit.testcase ) +module("tests.e2.items", package.seeall, lunit.testcase ) function setup() eressea.free_game() @@ -18,9 +18,11 @@ function test_meow() u:add_item("aoc", 1) u:clear_orders() u:add_order("BENUTZEN 1 Katzenamulett") - process_orders() + turn_begin() + turn_process() assert_equal(1, u:get_item("aoc")) assert_equal(1, r:count_msg_type('meow')) + turn_end() end function test_aurapotion50() @@ -33,10 +35,12 @@ function test_aurapotion50() u.aura = 0 u:clear_orders() u:add_order("BENUTZEN 1 Auratrank") - process_orders() + turn_begin() + turn_process() assert_equal(0, u:get_item("aurapotion50")) assert_equal(1, f:count_msg_type('aurapotion50')) assert_equal(50, u.aura) + turn_end() end function test_bagpipe() @@ -69,24 +73,26 @@ function test_foolpotion() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") local u = unit.create(f, r, 1) + turn_begin() u:add_item("p7", 1) u:clear_orders() u:add_order("BENUTZEN 1 Dumpfbackenbrot 4242") - process_orders() + turn_process() assert_equal(1, u:get_item("p7")) assert_equal(1, f:count_msg_type('feedback_unit_not_found')) local u2 = unit.create(f, r, 1) u:clear_orders() u:add_order("BENUTZEN 1 Dumpfbackenbrot " .. itoa36(u2.id)) - process_orders() + turn_process() assert_equal(1, u:get_item("p7")) assert_equal(1, f:count_msg_type('error64')) u:set_skill("stealth", 1); - process_orders() + turn_process() assert_equal(0, u:get_item("p7")) assert_equal(1, f:count_msg_type('givedumb')) + turn_end() end function test_snowman() diff --git a/scripts/tests/items.lua b/scripts/tests/items.lua index ff292b4cb..48f466409 100644 --- a/scripts/tests/items.lua +++ b/scripts/tests/items.lua @@ -11,6 +11,22 @@ function setup() eressea.settings.set("magic.regeneration.enable", "0") end +function test_mistletoe() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item('mistletoe', 2) + u:clear_orders() + u:add_order("BENUTZEN 1 Mistelzweig") + process_orders() + assert_equal(1, u:get_item('mistletoe')) + assert_equal(1, f:count_msg_type('use_item')) + u.number = 2 + process_orders() + assert_equal(1, u:get_item('mistletoe')) + assert_equal(1, f:count_msg_type('use_singleperson')) +end + function test_dreameye() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") @@ -18,9 +34,14 @@ function test_dreameye() u:add_item("dreameye", 2) u:clear_orders() u:add_order("BENUTZEN 1 Traumauge") - process_orders() + assert_false(u:is_cursed('skillmod')) + turn_begin() + turn_process() + assert_true(u:is_cursed('skillmod')) assert_equal(1, u:get_item("dreameye")) assert_equal(1, f:count_msg_type('use_tacticcrystal')) + turn_end() + assert_false(u:is_cursed('skillmod')) end function test_manacrystal() @@ -33,10 +54,12 @@ function test_manacrystal() u:set_skill('magic', 1) u.aura = 0 u:add_order("BENUTZEN 1 Astralkristall") - process_orders() + turn_begin() + turn_process() assert_equal(1, u:get_item("manacrystal")) assert_equal(25, u.aura) assert_equal(1, f:count_msg_type('manacrystal_use')) + turn_end() end function test_skillpotion() diff --git a/src/bind_unit.c b/src/bind_unit.c index c8ac2b362..0358e1938 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -26,6 +26,7 @@ without prior permission by the authors of Eressea. /* kernel includes */ #include #include +#include #include #include #include @@ -770,6 +771,21 @@ static int tolua_unit_get_orders(lua_State * L) return 1; } +static int tolua_unit_is_cursed(lua_State *L) { + unit *self = (unit *)tolua_tousertype(L, 1, 0); + const char *name = tolua_tostring(L, 2, 0); + lua_pushboolean(L, self->attribs && curse_active(get_curse(self->attribs, ct_find(name)))); + return 1; +} + +static int tolua_unit_has_attrib(lua_State *L) { + unit *self = (unit *)tolua_tousertype(L, 1, 0); + const char *name = tolua_tostring(L, 2, 0); + attrib * a = a_find(self->attribs, at_find(name)); + lua_pushboolean(L, a != NULL); + return 1; +} + static int tolua_unit_get_flag(lua_State * L) { unit *self = (unit *)tolua_tousertype(L, 1, 0); @@ -956,6 +972,9 @@ void tolua_unit_open(lua_State * L) tolua_function(L, TOLUA_CAST "clear_orders", &tolua_unit_clear_orders); tolua_variable(L, TOLUA_CAST "orders", &tolua_unit_get_orders, 0); + tolua_function(L, TOLUA_CAST "is_cursed", &tolua_unit_is_cursed); + tolua_function(L, TOLUA_CAST "has_attrib", &tolua_unit_has_attrib); + /* key-attributes for named flags: */ tolua_function(L, TOLUA_CAST "set_flag", &tolua_unit_set_flag); tolua_function(L, TOLUA_CAST "get_flag", &tolua_unit_get_flag); diff --git a/src/bindings.c b/src/bindings.c index 18261a507..1d6270b35 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -480,44 +480,30 @@ static int tolua_write_reports(lua_State * L) return 1; } -static void reset_game(void) -{ - region *r; - faction *f; - for (r = regions; r; r = r->next) { - unit *u; - building *b; - r->flags &= RF_SAVEMASK; - for (u = r->units; u; u = u->next) { - u->flags &= UFL_SAVEMASK; - } - for (b = r->buildings; b; b = b->next) { - b->flags &= BLD_SAVEMASK; - } - if (r->land && r->land->ownership && r->land->ownership->owner) { - faction *owner = r->land->ownership->owner; - if (owner == get_monsters()) { - /* some compat-fix, i believe. */ - owner = update_owners(r); - } - if (owner) { - fset(r, RF_GUARDED); - } - } - } - for (f = factions; f; f = f->next) { - f->flags &= FFL_SAVEMASK; - } -} - static int tolua_process_orders(lua_State * L) { - ++turn; - reset_game(); processorders(); return 0; } +static int tolua_turn_begin(lua_State * L) +{ + turn_begin(); + return 0; +} + +static int tolua_turn_process(lua_State * L) +{ + turn_process(); + return 0; +} + +static int tolua_turn_end(lua_State * L) +{ + turn_end(); + return 0; +} + static int tolua_write_passwords(lua_State * L) { int result = writepasswd(); @@ -1063,6 +1049,9 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile) tolua_function(L, TOLUA_CAST "factions", tolua_get_factions); tolua_function(L, TOLUA_CAST "regions", tolua_get_regions); tolua_function(L, TOLUA_CAST "read_turn", tolua_read_turn); + tolua_function(L, TOLUA_CAST "turn_begin", tolua_turn_begin); + tolua_function(L, TOLUA_CAST "turn_process", tolua_turn_process); + tolua_function(L, TOLUA_CAST "turn_end", tolua_turn_end); tolua_function(L, TOLUA_CAST "process_orders", tolua_process_orders); tolua_function(L, TOLUA_CAST "init_reports", tolua_init_reports); tolua_function(L, TOLUA_CAST "write_reports", tolua_write_reports); diff --git a/src/items.c b/src/items.c index ccba7ae7f..192bb111d 100644 --- a/src/items.c +++ b/src/items.c @@ -21,6 +21,8 @@ #include #include +#include + /* triggers includes */ #include #include @@ -347,7 +349,7 @@ use_tacticcrystal(unit * u, const struct item_type *itype, int amount, { int i; for (i = 0; i != amount; ++i) { - int duration = 1; /* wirkt nur eine Runde */ + int duration = 1; /* wirkt nur in dieser Runde */ curse *c; float effect; float power = 5; /* Widerstand gegen Antimagiesprueche, ist in diesem @@ -366,9 +368,32 @@ use_tacticcrystal(unit * u, const struct item_type *itype, int amount, return 0; } +static int +use_mistletoe(struct unit *user, const struct item_type *itype, int amount, + struct order *ord) +{ + int mtoes = + get_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, + user->number); + + if (user->number > mtoes) { + ADDMSG(&user->faction->msgs, msg_message("use_singleperson", + "unit item region command", user, itype->rtype, user->region, ord)); + return -1; + } + use_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, + user->number); + a_add(&user->attribs, make_fleechance((float)1.0)); + ADDMSG(&user->faction->msgs, + msg_message("use_item", "unit item", user, itype->rtype)); + + return 0; +} + void register_itemfunctions(void) { /* have tests: */ + register_item_use(use_mistletoe, "use_mistletoe"); register_item_use(use_tacticcrystal, "use_dreameye"); register_item_use(use_studypotion, "use_studypotion"); register_item_use(use_antimagiccrystal, "use_antimagic"); diff --git a/src/kernel/item.c b/src/kernel/item.c index adfddf6f4..1692ed706 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -746,29 +746,6 @@ static int use_warmthpotion(unit *u, const item_type *itype, return 0; } -#include -static int -use_mistletoe(struct unit *user, const struct item_type *itype, int amount, -struct order *ord) -{ - int mtoes = - get_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, - user->number); - - if (user->number > mtoes) { - ADDMSG(&user->faction->msgs, msg_message("use_singleperson", - "unit item region command", user, itype->rtype, user->region, ord)); - return -1; - } - use_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, - user->number); - a_add(&user->attribs, make_fleechance((float)1.0)); - ADDMSG(&user->faction->msgs, - msg_message("use_item", "unit item", user, itype->rtype)); - - return 0; -} - static int use_magicboost(struct unit *user, const struct item_type *itype, int amount, struct order *ord) @@ -1137,7 +1114,6 @@ void register_resources(void) register_item_use(use_potion_delayed, "use_p2"); register_item_use(use_warmthpotion, "use_nestwarmth"); - register_item_use(use_mistletoe, "usemistletoe"); register_item_use(use_magicboost, "usemagicboost"); register_item_use(use_snowball, "usesnowball"); diff --git a/src/laws.c b/src/laws.c index 0d0e53110..cc10baeb5 100644 --- a/src/laws.c +++ b/src/laws.c @@ -4186,16 +4186,54 @@ void init_processor(void) } } -void processorders(void) +static void reset_game(void) +{ + region *r; + faction *f; + for (r = regions; r; r = r->next) { + unit *u; + building *b; + r->flags &= RF_SAVEMASK; + for (u = r->units; u; u = u->next) { + u->flags &= UFL_SAVEMASK; + } + for (b = r->buildings; b; b = b->next) { + b->flags &= BLD_SAVEMASK; + } + if (r->land && r->land->ownership && r->land->ownership->owner) { + faction *owner = r->land->ownership->owner; + if (owner == get_monsters()) { + /* some compat-fix, i believe. */ + owner = update_owners(r); + } + if (owner) { + fset(r, RF_GUARDED); + } + } + } + for (f = factions; f; f = f->next) { + f->flags &= FFL_SAVEMASK; + } +} + +void turn_begin(void) +{ + ++turn; + reset_game(); +} + +void turn_process(void) { init_processor(); process(); - /*************************************************/ if (config_get_int("modules.markets", 0)) { do_markets(); } +} +void turn_end(void) +{ log_info(" - Attribute altern"); ageing(); remove_empty_units(); @@ -4210,6 +4248,13 @@ void processorders(void) update_spells(); } +void processorders(void) +{ + turn_begin(); + turn_process(); + turn_end(); +} + void update_subscriptions(void) { FILE *F; diff --git a/src/laws.h b/src/laws.h index f05c11ab4..090d2b978 100755 --- a/src/laws.h +++ b/src/laws.h @@ -53,8 +53,10 @@ extern "C" { int enter_building(struct unit *u, struct order *ord, int id, bool report); int enter_ship(struct unit *u, struct order *ord, int id, bool report); - /* eressea-specific. put somewhere else, please. */ void processorders(void); + void turn_begin(void); + void turn_process(void); + void turn_end(void); void new_units(void); void defaultorders(void); diff --git a/src/util/attrib.c b/src/util/attrib.c index fda143168..993f634d2 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -179,7 +179,17 @@ void at_register(attrib_type * at) at_hash[at->hashkey % MAXATHASH] = at; } -static attrib_type *at_find(unsigned int hk) +struct attrib_type *at_find(const char *name) { + attrib_type *find; + unsigned int hash = __at_hashkey(name); + find = at_hash[hash % MAXATHASH]; + while (find && hash != find->hashkey) { + find = find->nexthash; + } + return find; +} + +static attrib_type *at_find_key(unsigned int hk) { const char *translate[3][2] = { { "zielregion", "targetregion" }, /* remapping: from 'zielregion, heute targetregion */ @@ -193,7 +203,7 @@ static attrib_type *at_find(unsigned int hk) int i = 0; while (translate[i][0]) { if (__at_hashkey(translate[i][0]) == hk) - return at_find(__at_hashkey(translate[i][1])); + return at_find_key(__at_hashkey(translate[i][1])); ++i; } } @@ -408,7 +418,7 @@ void at_deprecate(const char * name, int(*reader)(attrib *, void *, struct gamed static int a_read_i(gamedata *data, attrib ** attribs, void *owner, unsigned int key) { int retval = AT_READ_OK; int(*reader)(attrib *, void *, struct gamedata *) = 0; - attrib_type *at = at_find(key); + attrib_type *at = at_find_key(key); attrib * na = 0; if (at) { diff --git a/src/util/attrib.h b/src/util/attrib.h index 601a6f32a..6043a960f 100644 --- a/src/util/attrib.h +++ b/src/util/attrib.h @@ -65,19 +65,19 @@ extern "C" { unsigned int hashkey; } attrib_type; - extern void at_register(attrib_type * at); - extern void at_deprecate(const char * name, int(*reader)(attrib *, void *, struct gamedata *)); + void at_register(attrib_type * at); + void at_deprecate(const char * name, int(*reader)(attrib *, void *, struct gamedata *)); + struct attrib_type *at_find(const char *name); void write_attribs(struct storage *store, struct attrib *alist, const void *owner); int read_attribs(struct gamedata *store, struct attrib **alist, void *owner); - extern attrib *a_select(attrib * a, const void *data, - bool(*compare) (const attrib *, const void *)); - extern attrib *a_find(attrib * a, const attrib_type * at); - extern attrib *a_add(attrib ** pa, attrib * at); - extern int a_remove(attrib ** pa, attrib * at); - extern void a_removeall(attrib ** a, const attrib_type * at); - extern attrib *a_new(const attrib_type * at); + attrib *a_select(attrib * a, const void *data, bool(*compare) (const attrib *, const void *)); + attrib *a_find(attrib * a, const attrib_type * at); + attrib *a_add(attrib ** pa, attrib * at); + int a_remove(attrib ** pa, attrib * at); + void a_removeall(attrib ** a, const attrib_type * at); + attrib *a_new(const attrib_type * at); int a_age(attrib ** attribs, void *owner); int a_read_orig(struct gamedata *data, attrib ** attribs, void *owner); From 462d0118e30f13f4b9b936c32abd2b32977ea4c2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 20:16:50 +0100 Subject: [PATCH 604/675] better testing for some items. --- scripts/tests/e2/items.lua | 16 +++++++++++-- scripts/tests/items.lua | 45 ++++++++++++++++++++++++++++++------- src/attributes/attributes.c | 3 +++ src/attributes/fleechance.c | 5 ----- src/attributes/fleechance.h | 1 - src/bind_region.c | 24 ++++++++++++++++++++ src/bind_ship.c | 27 ++++++++++++++++++++++ src/bind_unit.c | 16 ++++++++----- src/items.c | 7 +++--- src/util/attrib.c | 16 +++++-------- 10 files changed, 125 insertions(+), 35 deletions(-) diff --git a/scripts/tests/e2/items.lua b/scripts/tests/e2/items.lua index 9bc747650..93c88790f 100644 --- a/scripts/tests/e2/items.lua +++ b/scripts/tests/e2/items.lua @@ -47,26 +47,38 @@ function test_bagpipe() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") local u = unit.create(f, r, 1) + turn_begin() u:add_item("bagpipeoffear", 1) u:clear_orders() u:add_order("BENUTZEN 1 Dudelsack") - process_orders() + assert_equal(nil, r:get_curse('depression')) + turn_process() + assert_equal(0, r:get_curse('depression')) assert_equal(1, u:get_item("bagpipeoffear")) assert_equal(1, f:count_msg_type('bagpipeoffear_faction')) assert_equal(1, r:count_msg_type('bagpipeoffear_region')) + turn_end() + -- duration is variable, but at least 4 + assert_equal(0, r:get_curse('depression')) end function test_speedsail() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") local u = unit.create(f, r, 1) + + turn_begin() u.ship = ship.create(r, "boat") u:add_item("speedsail", 2) u:clear_orders() u:add_order("BENUTZEN 1 Sonnensegel") - process_orders() + assert_equal(nil, u.ship:get_curse('shipspeed')) + turn_process() + assert_equal(1, u.ship:get_curse('shipspeed')) assert_equal(1, u:get_item("speedsail")) assert_equal(1, f:count_msg_type('use_speedsail')) + turn_end() + assert_equal(1, u.ship:get_curse('shipspeed')) -- effect stays forever end function test_foolpotion() diff --git a/scripts/tests/items.lua b/scripts/tests/items.lua index 48f466409..f82aa9e7b 100644 --- a/scripts/tests/items.lua +++ b/scripts/tests/items.lua @@ -11,20 +11,37 @@ function setup() eressea.settings.set("magic.regeneration.enable", "0") end -function test_mistletoe() +function test_mistletoe_okay() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") local u = unit.create(f, r, 1) + turn_begin() u:add_item('mistletoe', 2) u:clear_orders() u:add_order("BENUTZEN 1 Mistelzweig") - process_orders() + assert_false(u:has_attrib('fleechance')) + turn_process() + assert_true(u:has_attrib('fleechance')) assert_equal(1, u:get_item('mistletoe')) assert_equal(1, f:count_msg_type('use_item')) + turn_end() +end + +function test_mistletoe_fail() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + turn_begin() + u:add_item('mistletoe', 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Mistelzweig") + assert_false(u:has_attrib('fleechance')) u.number = 2 - process_orders() + turn_process() + assert_false(u:has_attrib('fleechance')) assert_equal(1, u:get_item('mistletoe')) assert_equal(1, f:count_msg_type('use_singleperson')) + turn_end() end function test_dreameye() @@ -34,14 +51,14 @@ function test_dreameye() u:add_item("dreameye", 2) u:clear_orders() u:add_order("BENUTZEN 1 Traumauge") - assert_false(u:is_cursed('skillmod')) + assert_nil(u:get_curse('skillmod')) turn_begin() turn_process() - assert_true(u:is_cursed('skillmod')) + assert_not_nil(u:get_curse('skillmod')) assert_equal(1, u:get_item("dreameye")) assert_equal(1, f:count_msg_type('use_tacticcrystal')) turn_end() - assert_false(u:is_cursed('skillmod')) + assert_equal(nil, u:get_curse('skillmod')) end function test_manacrystal() @@ -78,24 +95,36 @@ function test_studypotion() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") local u = unit.create(f, r, 1) + turn_begin() u:add_item("studypotion", 2) u:clear_orders() u:add_order("LERNE Unterhaltung") u:add_order("BENUTZEN 1 Lerntrank") - process_orders() + turn_process() + -- cannot sense the "learning" attribute, because study_cmd + -- removes it during processing :( assert_equal(1, u:get_item("studypotion")) + turn_end() end function test_antimagic() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") local u = unit.create(f, r, 1) + + turn_begin() u:add_item("antimagic", 2) u:clear_orders() u:add_order("BENUTZEN 1 Antimagiekristall") - process_orders() + assert_equal(nil, r:get_curse('antimagiczone')) + turn_process() + assert_equal(5, r:get_curse('antimagiczone')) assert_equal(1, r:count_msg_type('use_antimagiccrystal')) assert_equal(1, u:get_item("antimagic")) + turn_end() + assert_equal(5, r:get_curse('antimagiczone')) -- haelt zwei wochen + turn_end() -- hack: age the curse again + assert_equal(nil, r:get_curse('antimagiczone')) end function test_ointment() diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index ae6869df8..0fe42a92e 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -25,6 +25,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* attributes includes */ #include "follow.h" +#include "fleechance.h" #include "hate.h" #include "iceberg.h" #include "key.h" @@ -58,6 +59,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include + attrib_type at_unitdissolve = { "unitdissolve", NULL, NULL, NULL, a_writechars, a_readchars }; @@ -92,6 +94,7 @@ void register_attributes(void) at_register(&at_woodcount); /* neue UNIT-Attribute */ + at_register(&at_fleechance); at_register(&at_siege); at_register(&at_effect); at_register(&at_private); diff --git a/src/attributes/fleechance.c b/src/attributes/fleechance.c index afba2d301..b8012fba5 100644 --- a/src/attributes/fleechance.c +++ b/src/attributes/fleechance.c @@ -38,8 +38,3 @@ attrib *make_fleechance(float fleechance) a->data.flt = fleechance; return a; } - -void init_fleechance(void) -{ - at_register(&at_fleechance); -} diff --git a/src/attributes/fleechance.h b/src/attributes/fleechance.h index b2f75671c..d5817b8b7 100644 --- a/src/attributes/fleechance.h +++ b/src/attributes/fleechance.h @@ -25,7 +25,6 @@ extern "C" { extern struct attrib_type at_fleechance; struct attrib *make_fleechance(float fleechance); - void init_fleechance(void); #ifdef __cplusplus } diff --git a/src/bind_region.c b/src/bind_region.c index 05c0e3842..fdab4a10f 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -19,6 +19,7 @@ without prior permission by the authors of Eressea. #include "chaos.h" #include +#include #include #include #include @@ -670,6 +671,27 @@ static int tolua_distance(lua_State * L) return 1; } +static int tolua_region_get_curse(lua_State *L) { + region *self = (region *)tolua_tousertype(L, 1, 0); + const char *name = tolua_tostring(L, 2, 0); + if (self->attribs) { + curse * c = get_curse(self->attribs, ct_find(name)); + if (c) { + lua_pushnumber(L, curse_geteffect(c)); + return 1; + } + } + return 0; +} + +static int tolua_region_has_attrib(lua_State *L) { + region *self = (region *)tolua_tousertype(L, 1, 0); + const char *name = tolua_tostring(L, 2, 0); + attrib * a = a_find(self->attribs, at_find(name)); + lua_pushboolean(L, a != NULL); + return 1; +} + void tolua_region_open(lua_State * L) { /* register user types */ @@ -691,6 +713,8 @@ void tolua_region_open(lua_State * L) tolua_function(L, TOLUA_CAST "count_msg_type", tolua_region_count_msg_type); + tolua_function(L, TOLUA_CAST "get_curse", &tolua_region_get_curse); + tolua_function(L, TOLUA_CAST "has_attrib", &tolua_region_has_attrib); /* flags */ tolua_variable(L, TOLUA_CAST "blocked", tolua_region_get_blocked, tolua_region_set_blocked); diff --git a/src/bind_ship.c b/src/bind_ship.c index 515fa8de3..c5e0735ed 100644 --- a/src/bind_ship.c +++ b/src/bind_ship.c @@ -16,11 +16,13 @@ without prior permission by the authors of Eressea. #include "move.h" +#include #include #include #include #include +#include #include #include @@ -198,6 +200,27 @@ static int tolua_ship_set_damage(lua_State * L) return 0; } +static int tolua_ship_get_curse(lua_State *L) { + ship *self = (ship *)tolua_tousertype(L, 1, 0); + const char *name = tolua_tostring(L, 2, 0); + if (self->attribs) { + curse * c = get_curse(self->attribs, ct_find(name)); + if (c) { + lua_pushnumber(L, curse_geteffect(c)); + return 1; + } + } + return 0; +} + +static int tolua_ship_has_attrib(lua_State *L) { + ship *self = (ship *)tolua_tousertype(L, 1, 0); + const char *name = tolua_tostring(L, 2, 0); + attrib * a = a_find(self->attribs, at_find(name)); + lua_pushboolean(L, a != NULL); + return 1; +} + void tolua_ship_open(lua_State * L) { /* register user types */ @@ -225,6 +248,10 @@ void tolua_ship_open(lua_State * L) tolua_variable(L, TOLUA_CAST "type", tolua_ship_get_type, 0); tolua_variable(L, TOLUA_CAST "damage", tolua_ship_get_damage, tolua_ship_set_damage); + + tolua_function(L, TOLUA_CAST "get_curse", &tolua_ship_get_curse); + tolua_function(L, TOLUA_CAST "has_attrib", &tolua_ship_has_attrib); + tolua_function(L, TOLUA_CAST "create", tolua_ship_create); } tolua_endmodule(L); diff --git a/src/bind_unit.c b/src/bind_unit.c index 0358e1938..8247e13d5 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -771,17 +771,23 @@ static int tolua_unit_get_orders(lua_State * L) return 1; } -static int tolua_unit_is_cursed(lua_State *L) { +static int tolua_unit_get_curse(lua_State *L) { unit *self = (unit *)tolua_tousertype(L, 1, 0); const char *name = tolua_tostring(L, 2, 0); - lua_pushboolean(L, self->attribs && curse_active(get_curse(self->attribs, ct_find(name)))); - return 1; + if (self->attribs) { + curse * c = get_curse(self->attribs, ct_find(name)); + if (c) { + lua_pushnumber(L, curse_geteffect(c)); + return 1; + } + } + return 0; } static int tolua_unit_has_attrib(lua_State *L) { unit *self = (unit *)tolua_tousertype(L, 1, 0); const char *name = tolua_tostring(L, 2, 0); - attrib * a = a_find(self->attribs, at_find(name)); + attrib * a = self->attribs ? a_find(self->attribs, at_find(name)) : NULL; lua_pushboolean(L, a != NULL); return 1; } @@ -972,7 +978,7 @@ void tolua_unit_open(lua_State * L) tolua_function(L, TOLUA_CAST "clear_orders", &tolua_unit_clear_orders); tolua_variable(L, TOLUA_CAST "orders", &tolua_unit_get_orders, 0); - tolua_function(L, TOLUA_CAST "is_cursed", &tolua_unit_is_cursed); + tolua_function(L, TOLUA_CAST "get_curse", &tolua_unit_get_curse); tolua_function(L, TOLUA_CAST "has_attrib", &tolua_unit_has_attrib); /* key-attributes for named flags: */ diff --git a/src/items.c b/src/items.c index 192bb111d..f8739cb73 100644 --- a/src/items.c +++ b/src/items.c @@ -43,7 +43,7 @@ static int use_studypotion(struct unit *u, const struct item_type *itype, int amount, struct order *ord) { - if (init_order(u->thisorder) == K_STUDY) { + if (u->thisorder && init_order(u->thisorder) == K_STUDY) { char token[128]; skill_t sk = NOSKILL; skill *sv = 0; @@ -97,9 +97,8 @@ struct order *ord) } effect = SPEEDSAIL_EFFECT; - c = - create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, effect, - 0); + c = create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, + effect, 0); c_setflag(c, CURSE_NOAGE); ADDMSG(&u->faction->msgs, msg_message("use_speedsail", "unit speed", u, diff --git a/src/util/attrib.c b/src/util/attrib.c index 993f634d2..b3b9c0a6e 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -179,16 +179,6 @@ void at_register(attrib_type * at) at_hash[at->hashkey % MAXATHASH] = at; } -struct attrib_type *at_find(const char *name) { - attrib_type *find; - unsigned int hash = __at_hashkey(name); - find = at_hash[hash % MAXATHASH]; - while (find && hash != find->hashkey) { - find = find->nexthash; - } - return find; -} - static attrib_type *at_find_key(unsigned int hk) { const char *translate[3][2] = { @@ -210,6 +200,11 @@ static attrib_type *at_find_key(unsigned int hk) return find; } +struct attrib_type *at_find(const char *name) { + unsigned int hash = __at_hashkey(name); + return at_find_key(hash); +} + attrib *a_select(attrib * a, const void *data, bool(*compare) (const attrib *, const void *)) { @@ -220,6 +215,7 @@ attrib *a_select(attrib * a, const void *data, attrib *a_find(attrib * a, const attrib_type * at) { + assert(at); while (a && a->type != at) a = a->nexttype; return a; From 9e239c88f486218739d5052aafde7b2a43407e69 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 20:26:48 +0100 Subject: [PATCH 605/675] testing insect warmth potion --- scripts/tests/e2/items.lua | 32 ++++++++++++++++++++++++++++++++ scripts/tests/items.lua | 2 +- src/items.c | 21 +++++++++++++++++++++ src/kernel/item.c | 29 ----------------------------- 4 files changed, 54 insertions(+), 30 deletions(-) diff --git a/scripts/tests/e2/items.lua b/scripts/tests/e2/items.lua index 93c88790f..24f27f4b2 100644 --- a/scripts/tests/e2/items.lua +++ b/scripts/tests/e2/items.lua @@ -11,6 +11,38 @@ function setup() eressea.settings.set("magic.regeneration.enable", "0") end +function test_nestwarmth_insect() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "insect", "de") + local u = unit.create(f, r, 1) + local flags = u.flags + u:add_item("nestwarmth", 2) + u:clear_orders() + u:add_order("BENUTZEN 1 Nestwaerme") + turn_begin() + turn_process() + assert_equal(flags+64, u.flags) -- UFL_WARMTH + assert_equal(1, u:get_item("nestwarmth")) + assert_equal(1, f:count_msg_type('usepotion')) + turn_end() +end + +function test_nestwarmth_other() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + local flags = u.flags + u:add_item("nestwarmth", 2) + u:clear_orders() + u:add_order("BENUTZEN 1 Nestwaerme") + turn_begin() + turn_process() + assert_equal(flags, u.flags) -- nothing happens + assert_equal(2, u:get_item("nestwarmth")) + assert_equal(1, f:count_msg_type('error163')) + turn_end() +end + function test_meow() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") diff --git a/scripts/tests/items.lua b/scripts/tests/items.lua index f82aa9e7b..aad52c2b2 100644 --- a/scripts/tests/items.lua +++ b/scripts/tests/items.lua @@ -58,7 +58,7 @@ function test_dreameye() assert_equal(1, u:get_item("dreameye")) assert_equal(1, f:count_msg_type('use_tacticcrystal')) turn_end() - assert_equal(nil, u:get_curse('skillmod')) + assert_nil(u:get_curse('skillmod')) end function test_manacrystal() diff --git a/src/items.c b/src/items.c index f8739cb73..51a4b2970 100644 --- a/src/items.c +++ b/src/items.c @@ -389,6 +389,26 @@ use_mistletoe(struct unit *user, const struct item_type *itype, int amount, return 0; } +static int use_warmthpotion(unit *u, const item_type *itype, + int amount, struct order *ord) +{ + if (u->faction->race == get_race(RC_INSECT)) { + u->flags |= UFL_WARMTH; + } + else { + /* nur fuer insekten: */ + cmistake(u, ord, 163, MSG_EVENT); + return ECUSTOM; + } + use_pooled(u, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, + amount); + usetpotionuse(u, itype->rtype->ptype); + + ADDMSG(&u->faction->msgs, msg_message("usepotion", + "unit potion", u, itype->rtype)); + return 0; +} + void register_itemfunctions(void) { /* have tests: */ @@ -403,4 +423,5 @@ void register_itemfunctions(void) register_item_use(use_foolpotion, "use_p7"); register_item_use(use_bloodpotion, "use_peasantblood"); register_item_use(use_healingpotion, "use_ointment"); + register_item_use(use_warmthpotion, "use_nestwarmth"); } diff --git a/src/kernel/item.c b/src/kernel/item.c index 1692ed706..8d5224d79 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -726,26 +726,6 @@ struct order *), const char *name) register_function((pf_generic)foo, name); } -static int use_warmthpotion(unit *u, const item_type *itype, - int amount, struct order *ord) -{ - if (u->faction->race == get_race(RC_INSECT)) { - fset(u, UFL_WARMTH); - } - else { - /* nur fuer insekten: */ - cmistake(u, ord, 163, MSG_EVENT); - return ECUSTOM; - } - use_pooled(u, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, - amount); - usetpotionuse(u, itype->rtype->ptype); - - ADDMSG(&u->faction->msgs, msg_message("usepotion", - "unit potion", u, itype->rtype)); - return 0; -} - static int use_magicboost(struct unit *user, const struct item_type *itype, int amount, struct order *ord) @@ -775,13 +755,6 @@ struct order *ord) return 0; } -static int -use_snowball(struct unit *user, const struct item_type *itype, int amount, -struct order *ord) -{ - return 0; -} - static void init_oldpotions(void) { const char *potionnames[MAX_POTIONS] = { @@ -1113,9 +1086,7 @@ void register_resources(void) register_function((pf_generic)res_changeaura, "changeaura"); register_item_use(use_potion_delayed, "use_p2"); - register_item_use(use_warmthpotion, "use_nestwarmth"); register_item_use(use_magicboost, "usemagicboost"); - register_item_use(use_snowball, "usesnowball"); register_item_give(give_horses, "givehorses"); } From 49d8a03eca1e5752fc9c7546e53a8b9376653d75 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 20:41:05 +0100 Subject: [PATCH 606/675] remote the item_type.use funpointer. --- res/eressea/items.xml | 16 ++++------------ src/helpers.c | 3 --- src/kernel/item.h | 4 ---- src/kernel/xmlreader.c | 7 ------- src/modules/museum.c | 5 +++-- 5 files changed, 7 insertions(+), 28 deletions(-) diff --git a/res/eressea/items.xml b/res/eressea/items.xml index a785691fe..3f5cc3d17 100644 --- a/res/eressea/items.xml +++ b/res/eressea/items.xml @@ -54,30 +54,22 @@ - - - + - - - + - - - + - - - + diff --git a/src/helpers.c b/src/helpers.c index 5124ca0ae..e8e6521c4 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -529,9 +529,6 @@ use_item_lua(unit *u, const item_type *itype, int amount, struct order *ord) } else { log_error("no such callout: %s", fname); } - if (itype->use) { - return itype->use(u, itype, amount, ord); - } log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname); lua_pop(L, 1); diff --git a/src/kernel/item.h b/src/kernel/item.h index b0bc10cd8..14196ab37 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -126,8 +126,6 @@ extern "C" { /* --- functions --- */ bool(*canuse) (const struct unit * user, const struct item_type * itype); - int(*use) (struct unit * user, const struct item_type * itype, int amount, - struct order * ord); int(*give) (struct unit * src, struct unit * dest, const struct item_type * itm, int number, struct order * ord); int score; @@ -310,8 +308,6 @@ extern "C" { const struct item_type *, int, struct order *), const char *name); void register_item_use(int(*foo) (struct unit *, const struct item_type *, int, struct order *), const char *name); - void register_item_useonother(int(*foo) (struct unit *, int, - const struct item_type *, int, struct order *), const char *name); void free_resources(void); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 69e9c22d0..af0a9dd23 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -854,13 +854,6 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) (int(*)(struct unit *, struct unit *, const struct item_type *, int, struct order *))fun; } - else if (strcmp((const char *)propValue, "use") == 0) { - log_error("%s has a use function", rtype->_name); - itype->flags |= ITF_CANUSE; - itype->use = - (int(*)(struct unit *, const struct item_type *, int, - struct order *))fun; - } else if (strcmp((const char *)propValue, "canuse") == 0) { itype->canuse = (bool(*)(const struct unit *, const struct item_type *))fun; diff --git a/src/modules/museum.c b/src/modules/museum.c index af37019d0..1eee3529f 100644 --- a/src/modules/museum.c +++ b/src/modules/museum.c @@ -497,9 +497,10 @@ void register_museum(void) at_register(&at_museumgivebackcookie); at_register(&at_museumgiveback); - register_item_use(use_museumticket, "use_museumticket"); - register_item_use(use_museumkey, "use_museumkey"); register_item_use(use_museumexitticket, "use_museumexitticket"); + register_item_use(use_museumticket, "use_museumticket"); + register_item_use(use_museumkey, "use_questkey1"); + register_item_use(use_museumkey, "use_questkey2"); } #endif From 69e28034b458ad1afd34cb51e49ec088710a111a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Feb 2017 21:00:15 +0100 Subject: [PATCH 607/675] Kill unused "magicboost" function. I have no idea why this exists. --- src/items.c | 3 +++ src/kernel/item.c | 32 -------------------------------- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/src/items.c b/src/items.c index 51a4b2970..78f6e3188 100644 --- a/src/items.c +++ b/src/items.c @@ -424,4 +424,7 @@ void register_itemfunctions(void) register_item_use(use_bloodpotion, "use_peasantblood"); register_item_use(use_healingpotion, "use_ointment"); register_item_use(use_warmthpotion, "use_nestwarmth"); + + /* ungetestet: Wasser des Lebens */ + register_item_use(use_potion_delayed, "use_p2"); } diff --git a/src/kernel/item.c b/src/kernel/item.c index 8d5224d79..6bd97e6dd 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -726,35 +726,6 @@ struct order *), const char *name) register_function((pf_generic)foo, name); } -static int -use_magicboost(struct unit *user, const struct item_type *itype, int amount, -struct order *ord) -{ - int mtoes = - get_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, - user->number); - faction *f = user->faction; - if (user->number > mtoes) { - ADDMSG(&user->faction->msgs, msg_message("use_singleperson", - "unit item region command", user, itype->rtype, user->region, ord)); - return -1; - } - if (!is_mage(user) || key_get(f->attribs, atoi36("mbst"))) { - cmistake(user, user->thisorder, 214, MSG_EVENT); - return -1; - } - use_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, - user->number); - - key_set(&f->attribs, atoi36("mbst"), turn); - set_level(user, SK_MAGIC, 3); - - ADDMSG(&user->faction->msgs, msg_message("use_item", - "unit item", user, itype->rtype)); - - return 0; -} - static void init_oldpotions(void) { const char *potionnames[MAX_POTIONS] = { @@ -1085,8 +1056,5 @@ void register_resources(void) register_function((pf_generic)res_changehp, "changehp"); register_function((pf_generic)res_changeaura, "changeaura"); - register_item_use(use_potion_delayed, "use_p2"); - register_item_use(use_magicboost, "usemagicboost"); - register_item_give(give_horses, "givehorses"); } From 75ce6fd23a4d965d3f531a1764bb866cf3598c43 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 28 Feb 2017 03:48:41 +0100 Subject: [PATCH 608/675] regaura=1 is default --- clibs | 2 +- res/races/goblin-2.xml | 2 +- res/races/goblin-3.xml | 2 +- res/races/goblin.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clibs b/clibs index 27c8b3202..b91413316 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 +Subproject commit b91413316ce13044c555084a9f605983586107b4 diff --git a/res/races/goblin-2.xml b/res/races/goblin-2.xml index f26fa780e..b092dfaaa 100644 --- a/res/races/goblin-2.xml +++ b/res/races/goblin-2.xml @@ -1,5 +1,5 @@ - - Date: Tue, 28 Feb 2017 04:03:36 +0100 Subject: [PATCH 609/675] remove unused files --- res/races.xml | 14 -------------- res/races/goblin-2.xml | 24 ------------------------ 2 files changed, 38 deletions(-) delete mode 100644 res/races.xml delete mode 100644 res/races/goblin-2.xml diff --git a/res/races.xml b/res/races.xml deleted file mode 100644 index fcfc1742b..000000000 --- a/res/races.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/res/races/goblin-2.xml b/res/races/goblin-2.xml deleted file mode 100644 index b092dfaaa..000000000 --- a/res/races/goblin-2.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - From 5a01eae522bf025b4a681aeb13033f2d4a0b8cbe Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 28 Feb 2017 10:48:27 +0100 Subject: [PATCH 610/675] make item_use function crash if new and old rules do not agree add a 'test' function to E3 that exercises all those items --- scripts/tests/e3/init.lua | 1 + scripts/tests/e3/items.lua | 35 ++++++++++++++++++++++++ src/battle.c | 6 +++-- src/kernel/item.h | 2 ++ src/kernel/race.c | 13 +++++++++ src/kernel/race.h | 4 +++ src/kernel/race.test.c | 54 +++++++++++++++++++++++++++++++++++++- 7 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 scripts/tests/e3/items.lua diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua index 95df86c4c..28a2cf6e5 100644 --- a/scripts/tests/e3/init.lua +++ b/scripts/tests/e3/init.lua @@ -4,6 +4,7 @@ require 'tests.e3.spells' require 'tests.e3.rules' require 'tests.e3.parser' require 'tests.e3.morale' +require 'tests.e3.items' require 'tests.orders' require 'tests.common' require 'tests.items' diff --git a/scripts/tests/e3/items.lua b/scripts/tests/e3/items.lua new file mode 100644 index 000000000..9c6035bf7 --- /dev/null +++ b/scripts/tests/e3/items.lua @@ -0,0 +1,35 @@ +require "lunit" + +module("tests.e3.items", package.seeall, lunit.testcase ) + +function setup() + eressea.game.reset() + eressea.settings.set("rules.food.flags", "4") -- food is free + eressea.settings.set("NewbieImmunity", "0") +end + +function test_goblins() + local r = region.create(0, 0, "plain") + assert(r) + local f1 = faction.create("goblin@eressea.de", "goblin", "de") + local f2 = faction.create("dwarf@eressea.de", "dwarf", "de") + local f3 = faction.create("elf@eressea.de", "elf", "de") + local u1 = unit.create(f1, r, 1) + local u2 = unit.create(f2, r, 1) + local u3 = unit.create(f3, r, 1) + + local restricted = { + "towershield", "rep_crossbow", "plate", "lance", + "mllornlance", "greatbow", "greataxe", "axe", "scale", + "plate", "rustyhalberd", "halberd", "greatsword" + } + for k, v in ipairs(restricted) do + u1:add_item(v, 1) + u2:add_item(v, 1) + u2:add_item(v, 1) + end + + u1:add_order("ATTACKIERE " .. itoa36(u2.id)) + u1:add_order("ATTACKIERE " .. itoa36(u3.id)) + process_orders() +end diff --git a/src/battle.c b/src/battle.c index 9864adc41..9e2958242 100644 --- a/src/battle.c +++ b/src/battle.c @@ -576,10 +576,12 @@ static weapon *select_weapon(const troop t, bool attacking, static bool i_canuse(const unit * u, const item_type * itype) { + bool result = true; if (itype->canuse) { - return itype->canuse(u, itype); + result = itype->canuse(u, itype); } - return true; + assert(result==rc_can_use(u_race(u), itype)); + return result; } static int diff --git a/src/kernel/item.h b/src/kernel/item.h index 14196ab37..d38a21340 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -121,6 +121,8 @@ extern "C" { unsigned int flags; int weight; int capacity; + int mask_allow; + int mask_deny; struct construction *construction; char *_appearance[2]; /* wie es f�r andere aussieht */ /* --- functions --- */ diff --git a/src/kernel/race.c b/src/kernel/race.c index d159fd6d8..efe38dcfe 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -54,6 +54,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* libc includes */ #include #include +#include #include #include #include @@ -94,6 +95,7 @@ enum { RCO_TRADEHERB }; + static void rc_setoption(race *rc, int k, const char *value) { unsigned char key = (unsigned char)k; int i; @@ -323,6 +325,17 @@ bool rc_changed(int *cache) { return false; } +bool rc_can_use(const struct race *rc, const struct item_type *itype) +{ + if (itype->mask_allow) { + return (rc->mask_item==0 || (itype->mask_allow & rc->mask_item) != 0); + } + if (itype->mask_deny) { + return (itype->mask_deny & rc->mask_item) == 0; + } + return true; +} + race *rc_create(const char *zName) { race *rc; diff --git a/src/kernel/race.h b/src/kernel/race.h index f14b8e54f..fcd78ae19 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -48,6 +48,7 @@ extern "C" { struct spellref; struct locale; struct rcoption; + struct item_type; extern int num_races; @@ -140,6 +141,7 @@ extern "C" { int flags; int battle_flags; int ec_flags; + int mask_item; struct att attack[RACE_ATTACKS]; signed char bonus[MAXSKILLS]; @@ -174,6 +176,8 @@ extern "C" { const race *rc_find(const char *); void free_races(void); + bool rc_can_use(const struct race *rc, const struct item_type *itype); + typedef enum name_t { NAME_SINGULAR, NAME_PLURAL, NAME_DEFINITIVE, NAME_CATEGORY } name_t; const char * rc_name_s(const race *rc, name_t n); const char * rc_name(const race *rc, name_t n, char *name, size_t size); diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index 07ecbdd45..b292a825e 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -1,10 +1,13 @@ #include #include #include "race.h" -#include +#include "item.h" + #include +#include #include +#include #include static void test_rc_name(CuTest *tc) { @@ -100,6 +103,54 @@ static void test_rc_set_param(CuTest *tc) { test_cleanup(); } +static void test_rc_can_use(CuTest *tc) { + race *rc; + item_type *itype; + + test_setup(); + rc = test_create_race("goblin"); + itype = test_create_itemtype("plate"); + CuAssertTrue(tc, rc_can_use(rc, itype)); + + /* default case. all items and races in E2 */ + itype->mask_deny = 0; + rc->mask_item = 0; + CuAssertTrue(tc, rc_can_use(rc, itype)); + + /* some race is forbidden from using this item. */ + itype->mask_deny = 1; + + /* we are not that race. */ + rc->mask_item = 2; + CuAssertTrue(tc, rc_can_use(rc, itype)); + + /* we are that race */ + rc->mask_item = 1; + CuAssertTrue(tc, ! rc_can_use(rc, itype)); + + /* we are not a special race at all */ + rc->mask_item = 0; + CuAssertTrue(tc, rc_can_use(rc, itype)); + + /* only one race is allowed to use this item */ + itype->mask_deny = 0; + itype->mask_allow = 1; + + /* we are not that race */ + rc->mask_item = 2; + CuAssertTrue(tc, ! rc_can_use(rc, itype)); + + /* we are that race */ + rc->mask_item = 1; + CuAssertTrue(tc, rc_can_use(rc, itype)); + + /* we are not special */ + rc->mask_item = 0; + CuAssertTrue(tc, rc_can_use(rc, itype)); + + test_cleanup(); +} + CuSuite *get_race_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -109,6 +160,7 @@ CuSuite *get_race_suite(void) SUITE_ADD_TEST(suite, test_rc_defaults); SUITE_ADD_TEST(suite, test_rc_find); SUITE_ADD_TEST(suite, test_rc_set_param); + SUITE_ADD_TEST(suite, test_rc_can_use); return suite; } From c276b5a43ca2e1471d9aa33d3451a30f42930342 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 28 Feb 2017 10:58:09 +0100 Subject: [PATCH 611/675] generate error, not crash. todo: fix items --- scripts/tests/e3/items.lua | 2 +- src/battle.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/tests/e3/items.lua b/scripts/tests/e3/items.lua index 9c6035bf7..b2100f5ed 100644 --- a/scripts/tests/e3/items.lua +++ b/scripts/tests/e3/items.lua @@ -26,7 +26,7 @@ function test_goblins() for k, v in ipairs(restricted) do u1:add_item(v, 1) u2:add_item(v, 1) - u2:add_item(v, 1) + u3:add_item(v, 1) end u1:add_order("ATTACKIERE " .. itoa36(u2.id)) diff --git a/src/battle.c b/src/battle.c index 9e2958242..fa5725c50 100644 --- a/src/battle.c +++ b/src/battle.c @@ -580,7 +580,12 @@ static bool i_canuse(const unit * u, const item_type * itype) if (itype->canuse) { result = itype->canuse(u, itype); } - assert(result==rc_can_use(u_race(u), itype)); + if (result!=rc_can_use(u_race(u), itype)) { + log_error("conversion error: %s should be %s to use %s", + u->_race->_name, + result ? "allowed" : "forbidden", + itype->rtype->_name); + } return result; } From 2eb88c472cbf9cb40def53514c24b0cba5412a05 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 28 Feb 2017 11:07:32 +0100 Subject: [PATCH 612/675] have I bollocksed up the deny/allow rules? looks like it --- res/e3a/armor/towershield.xml | 2 +- res/e3a/races.xml | 18 +++++++++++++++--- res/races/goblin-3.xml | 2 +- scripts/tests/e3/items.lua | 13 +++++++++---- src/kernel/xmlreader.c | 3 +++ 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/res/e3a/armor/towershield.xml b/res/e3a/armor/towershield.xml index e80c03523..dcd2858cf 100644 --- a/res/e3a/armor/towershield.xml +++ b/res/e3a/armor/towershield.xml @@ -1,6 +1,6 @@ - + diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 2e5a81aee..fc16645c6 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -71,7 +71,11 @@ - + @@ -116,7 +120,11 @@ - + @@ -156,7 +164,11 @@ - + diff --git a/res/races/goblin-3.xml b/res/races/goblin-3.xml index a65d4c99a..8deb33f5e 100644 --- a/res/races/goblin-3.xml +++ b/res/races/goblin-3.xml @@ -3,7 +3,7 @@ recruitcost="60" maintenance="6" weight="600" capacity="440" speed="1.0" hp="16" damage="1d5" unarmedattack="-2" unarmeddefense="0" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" -getitem="yes" equipment="yes" healing="2.0"> +getitem="yes" equipment="yes" healing="2.0" items="4"> diff --git a/scripts/tests/e3/items.lua b/scripts/tests/e3/items.lua index b2100f5ed..5594eed67 100644 --- a/scripts/tests/e3/items.lua +++ b/scripts/tests/e3/items.lua @@ -14,7 +14,9 @@ function test_goblins() local f1 = faction.create("goblin@eressea.de", "goblin", "de") local f2 = faction.create("dwarf@eressea.de", "dwarf", "de") local f3 = faction.create("elf@eressea.de", "elf", "de") - local u1 = unit.create(f1, r, 1) + local ud = unit.create(f1, r, 1) + local uh = unit.create(f1, r, 1) + uh.race = "halfling" local u2 = unit.create(f2, r, 1) local u3 = unit.create(f3, r, 1) @@ -24,12 +26,15 @@ function test_goblins() "plate", "rustyhalberd", "halberd", "greatsword" } for k, v in ipairs(restricted) do - u1:add_item(v, 1) + ud:add_item(v, 1) + uh:add_item(v, 1) u2:add_item(v, 1) u3:add_item(v, 1) end - u1:add_order("ATTACKIERE " .. itoa36(u2.id)) - u1:add_order("ATTACKIERE " .. itoa36(u3.id)) + uh:add_order("ATTACKIERE " .. itoa36(u2.id)) + uh:add_order("ATTACKIERE " .. itoa36(u3.id)) + ud:add_order("ATTACKIERE " .. itoa36(u2.id)) + ud:add_order("ATTACKIERE " .. itoa36(u3.id)) process_orders() end diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index af0a9dd23..3a6ba6d81 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -782,6 +782,8 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) itype = rtype->itype ? rtype->itype : it_get_or_create(rtype); itype->weight = xml_ivalue(node, "weight", 0); itype->capacity = xml_ivalue(node, "capacity", 0); + itype->mask_allow = xml_ivalue(node, "allow", 0); + itype->mask_deny = xml_ivalue(node, "deny", 0); itype->flags |= flags; /* reading item/construction */ @@ -1575,6 +1577,7 @@ static int parse_races(xmlDocPtr doc) rc->speed = (float)xml_fvalue(node, "speed", rc->speed); rc->hitpoints = xml_ivalue(node, "hp", rc->hitpoints); rc->armor = (char)xml_ivalue(node, "ac", rc->armor); + rc->mask_item = (char)xml_ivalue(node, "items", rc->mask_item); study_speed_base = xml_ivalue(node, "studyspeed", 0); rc->at_default = (char)xml_ivalue(node, "unarmedattack", -2); From 17d410345ff6b68e5e6c4ef15fa1d45205174957 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 28 Feb 2017 21:50:49 +0100 Subject: [PATCH 613/675] failing test for bug 2288 --- scripts/tests/e3/rules.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index 2cba83f21..3a5cdadfa 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -37,6 +37,10 @@ function teardown() set_rule("rules.ship.storms") end +function test_calendar() + assert_equal(get_season(396), "calendar::winter") +end + function disable_test_bug_1738_build_castle_e3() local r = region.create(0, 0, "plain") local f = faction.create("bug_1738@eressea.de", "human", "de") @@ -990,4 +994,4 @@ function test_bug2187() -- write_report(f) set_rule("rules.food.flags", "4") -end \ No newline at end of file +end From e2e602e7ba96adb2b89c35415c649b20789fd875 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 1 Mar 2017 08:28:15 +0100 Subject: [PATCH 614/675] fix off-by-one calendar, bug 2288 --- res/core/calendar.xml | 2 +- scripts/tests/e2/e2features.lua | 5 +++++ src/calendar.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/res/core/calendar.xml b/res/core/calendar.xml index 42f83d58b..d96037698 100644 --- a/res/core/calendar.xml +++ b/res/core/calendar.xml @@ -1,5 +1,5 @@ - + diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index de94ea34f..cba363d83 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -10,6 +10,11 @@ function setup() eressea.settings.set("rules.encounters", "0") end +function test_calendar() + assert_equal(get_season(1011), "calendar::winter") + assert_equal(get_season(1012), "calendar::spring") +end + function test_herbalism() -- OBS: herbalism is currently an E2-only skill local r = region.create(0, 0, "plain") diff --git a/src/calendar.c b/src/calendar.c index 2099b6631..d2a70c974 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -18,7 +18,7 @@ int seasons = 0; int first_turn(void) { - return config_get_int("game.start", 1); + return config_get_int("game.start", 0); } const gamedate *get_gamedate(int turn, gamedate * gd) From fc8e6dc6de1da81b7681697bb2886ae3c9246831 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 1 Mar 2017 14:59:20 +0100 Subject: [PATCH 615/675] TARNE PARTEI creport test --- src/creport.test.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ src/spy.c | 22 +++++++++++--------- src/spy.h | 11 ++++++---- src/spy.test.c | 8 -------- 4 files changed, 70 insertions(+), 22 deletions(-) diff --git a/src/creport.test.c b/src/creport.test.c index 21a6c09b7..079220738 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -1,6 +1,7 @@ #include #include "creport.h" #include "move.h" +#include "spy.h" #include "travelthru.h" #include "keyword.h" @@ -48,9 +49,59 @@ static void test_cr_unit(CuTest *tc) { test_cleanup(); } +static int cr_get_int(stream *strm, const char *match, int def) +{ + char line[1024]; + + strm->api->rewind(strm->handle); + while (strm->api->readln(strm->handle, line, sizeof(line))==0) { + if (strstr(line, match)) { + return atoi(line); + } + } + return def; +} + +static void test_cr_factionstealth(CuTest *tc) { + stream strm; + faction *f1, *f2, *fr; + region *r; + unit *u; + + test_setup(); + mstream_init(&strm); + f1 = test_create_faction(0); + f2 = test_create_faction(0); + fr = test_create_faction(0); + r = test_create_region(0, 0, 0); + u = test_create_unit(f1, r); + + cr_output_unit(&strm, u->region, f1, u, seen_unit); + CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); + + set_factionstealth(u, f2); + CuAssertPtrNotNull(tc, u->attribs); + + cr_output_unit(&strm, u->region, f1, u, seen_unit); + CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); + CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); + + cr_output_unit(&strm, u->region, f2, u, seen_unit); + CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); + CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); + CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1)); + + mstream_done(&strm); + test_cleanup(); +} + CuSuite *get_creport_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_cr_unit); + SUITE_ADD_TEST(suite, test_cr_factionstealth); return suite; } diff --git a/src/spy.c b/src/spy.c index d4082cad7..c9667f7ee 100644 --- a/src/spy.c +++ b/src/spy.c @@ -178,7 +178,7 @@ int spy_cmd(unit * u, struct order *ord) return 0; } -void set_factionstealth(unit * u, faction * f) +static bool can_set_factionstealth(const unit * u, const faction * f) { region *lastr = NULL; /* for all units mu of our faction, check all the units in the region @@ -194,7 +194,7 @@ void set_factionstealth(unit * u, faction * f) faction *fv = visible_faction(f, ru); if (fv == f) { if (cansee(f, lastr, ru, 0)) - break; + return true; } } ru = ru->next; @@ -204,13 +204,15 @@ void set_factionstealth(unit * u, faction * f) } mu = mu->nextF; } - if (mu != NULL) { - attrib *a = a_find(u->attribs, &at_otherfaction); - if (!a) - a = a_add(&u->attribs, make_otherfaction(f)); - else - a->data.v = f; - } + return true; +} + +void set_factionstealth(unit *u, faction *f) { + attrib *a = a_find(u->attribs, &at_otherfaction); + if (!a) + a = a_add(&u->attribs, make_otherfaction(f)); + else + a->data.v = f; } int setstealth_cmd(unit * u, struct order *ord) @@ -315,7 +317,7 @@ int setstealth_cmd(unit * u, struct order *ord) } else { struct faction *f = findfaction(nr); - if (f == NULL) { + if (f == NULL || !can_set_factionstealth(u, f)) { cmistake(u, ord, 66, MSG_EVENT); break; } diff --git a/src/spy.h b/src/spy.h index d3ee0c728..665595ef4 100644 --- a/src/spy.h +++ b/src/spy.h @@ -26,12 +26,15 @@ extern "C" { struct region; struct strlist; struct order; + struct faction; - extern int setstealth_cmd(struct unit *u, struct order *ord); - extern int spy_cmd(struct unit *u, struct order *ord); - extern int sabotage_cmd(struct unit *u, struct order *ord); - extern void spy_message(int spy, const struct unit *u, + int setstealth_cmd(struct unit *u, struct order *ord); + int spy_cmd(struct unit *u, struct order *ord); + int sabotage_cmd(struct unit *u, struct order *ord); + void spy_message(int spy, const struct unit *u, const struct unit *target); + void set_factionstealth(struct unit * u, struct faction * f); + #define OCEAN_SWIMMER_CHANCE 0.1 #define CANAL_SWIMMER_CHANCE 0.9 diff --git a/src/spy.test.c b/src/spy.test.c index ae1550689..0dfaada7a 100644 --- a/src/spy.test.c +++ b/src/spy.test.c @@ -50,14 +50,6 @@ static void test_simple_spy_message(CuTest *tc) { test_cleanup(); } -static void set_factionstealth(unit *u, faction *f) { - attrib *a = a_find(u->attribs, &at_otherfaction); - if (!a) - a = a_add(&u->attribs, make_otherfaction(f)); - else - a->data.v = f; -} - static void test_all_spy_message(CuTest *tc) { spy_fixture fix; item_type *itype; From 6d9387f6c23ae9aef9fa301da0a4eea1f2f2d939 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 1 Mar 2017 18:16:07 +0100 Subject: [PATCH 616/675] warn about unused variables, back on --- src/CMakeLists.txt | 2 +- src/creport.test.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 43f109fed..f9c92ff2c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,7 +21,7 @@ COMPILE_DEFINITIONS ERESSEA_BUILDNO="${ERESSEA_BUILDNO}") ENDIF() IF (CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") +# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") ENDIF() IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") diff --git a/src/creport.test.c b/src/creport.test.c index 079220738..11701b62e 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -64,7 +64,7 @@ static int cr_get_int(stream *strm, const char *match, int def) static void test_cr_factionstealth(CuTest *tc) { stream strm; - faction *f1, *f2, *fr; + faction *f1, *f2; region *r; unit *u; @@ -72,7 +72,6 @@ static void test_cr_factionstealth(CuTest *tc) { mstream_init(&strm); f1 = test_create_faction(0); f2 = test_create_faction(0); - fr = test_create_faction(0); r = test_create_region(0, 0, 0); u = test_create_unit(f1, r); From 295614643a3eccf7c689c0151836a701b5eba580 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 1 Mar 2017 19:18:00 +0100 Subject: [PATCH 617/675] more factionstealth testing. --- src/creport.c | 24 +++++++++--------------- src/creport.test.c | 10 ++++++++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/creport.c b/src/creport.c index c2d10d1c0..d2f50e816 100644 --- a/src/creport.c +++ b/src/creport.c @@ -763,12 +763,9 @@ void cr_output_unit(stream *out, const region * r, const faction * f, stream_printf(out, "\"%s\";Beschr\n", str); } /* print faction information */ - sf = visible_faction(f, u); + sf = visible_faction(NULL, u); prefix = raceprefix(u); if (u->faction == f || omniscient(f)) { - const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); - const faction *otherfaction = - a_otherfaction ? get_otherfaction(a_otherfaction) : NULL; /* my own faction, full info */ const attrib *a = NULL; unit *mage; @@ -780,12 +777,12 @@ void cr_output_unit(stream *out, const region * r, const faction * f, stream_printf(out, "%d;gruppe\n", g->gid); } stream_printf(out, "%d;Partei\n", u->faction->no); - if (sf != u->faction) + if (sf && sf != u->faction) { stream_printf(out, "%d;Verkleidung\n", sf->no); - if (fval(u, UFL_ANON_FACTION)) - stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION)!=0); - if (otherfaction && otherfaction != u->faction) { - stream_printf(out, "%d;Anderepartei\n", otherfaction->no); + stream_printf(out, "%d;Anderepartei\n", sf->no); + } + if (fval(u, UFL_ANON_FACTION)) { + stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION) != 0); } mage = get_familiar_mage(u); if (mage) { @@ -798,17 +795,14 @@ void cr_output_unit(stream *out, const region * r, const faction * f, stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION) != 0); } else { - const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); - const faction *otherfaction = - a_otherfaction ? get_otherfaction(a_otherfaction) : NULL; /* other unit. show visible faction, not u->faction */ - stream_printf(out, "%d;Partei\n", sf->no); + stream_printf(out, "%d;Partei\n", sf ? sf->no : f->no); if (sf == f) { stream_printf(out, "1;Verraeter\n"); } - if (otherfaction && otherfaction != u->faction) { + if (sf && sf != u->faction) { if (alliedunit(u, f, HELP_FSTEALTH)) { - stream_printf(out, "%d;Anderepartei\n", otherfaction->no); + stream_printf(out, "%d;Anderepartei\n", sf->no); } } } diff --git a/src/creport.test.c b/src/creport.test.c index 11701b62e..14f40268c 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -5,6 +5,7 @@ #include "travelthru.h" #include "keyword.h" +#include #include #include #include @@ -67,6 +68,7 @@ static void test_cr_factionstealth(CuTest *tc) { faction *f1, *f2; region *r; unit *u; + ally *al; test_setup(); mstream_init(&strm); @@ -93,6 +95,14 @@ static void test_cr_factionstealth(CuTest *tc) { CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1)); + al = ally_add(&f1->allies, f2); + al->status = HELP_FSTEALTH; + + cr_output_unit(&strm, u->region, f2, u, seen_unit); + CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); + CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); + CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1)); + mstream_done(&strm); test_cleanup(); } From e0085eac0c797add6302bb53e24b3e472684cc58 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 1 Mar 2017 19:52:23 +0100 Subject: [PATCH 618/675] write a test for get_addresses before modifying it. --- src/creport.c | 2 +- src/reports.c | 2 +- src/reports.h | 1 + src/reports.test.c | 27 +++++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/creport.c b/src/creport.c index d2f50e816..99a9ede97 100644 --- a/src/creport.c +++ b/src/creport.c @@ -764,7 +764,6 @@ void cr_output_unit(stream *out, const region * r, const faction * f, } /* print faction information */ sf = visible_faction(NULL, u); - prefix = raceprefix(u); if (u->faction == f || omniscient(f)) { /* my own faction, full info */ const attrib *a = NULL; @@ -807,6 +806,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f, } } } + prefix = raceprefix(u); if (prefix) { prefix = mkname("prefix", prefix); stream_printf(out, "\"%s\";typprefix\n", translate(prefix, LOC(f->locale, diff --git a/src/reports.c b/src/reports.c index a70219b0b..acbc36f69 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1024,7 +1024,7 @@ static void add_travelthru_addresses(region *r, faction *f, selist **flist, int travelthru_map(r, cb_add_address, &cbdata); } -static void get_addresses(report_context * ctx) +void get_addresses(report_context * ctx) { /* "TODO: travelthru" */ region *r; diff --git a/src/reports.h b/src/reports.h index 4fab104ef..855234376 100644 --- a/src/reports.h +++ b/src/reports.h @@ -81,6 +81,7 @@ extern "C" { void prepare_report(report_context *ctx, struct faction *f); void finish_reports(report_context *ctx); + void get_addresses(report_context * ctx); typedef int(*report_fun) (const char *filename, report_context * ctx, const char *charset); diff --git a/src/reports.test.c b/src/reports.test.c index e3ca5c89b..534cb2187 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -279,6 +279,32 @@ static void test_prepare_travelthru(CuTest *tc) { test_cleanup(); } +static void test_get_addresses(CuTest *tc) { + report_context ctx; + faction *f, *f2, *f1; + region *r; + int i; + + test_setup(); + f = test_create_faction(0); + f1 = test_create_faction(0); + f2 = test_create_faction(0); + r = test_create_region(0, 0, 0); + test_create_unit(f, r); + test_create_unit(f1, r); + test_create_unit(f2, r); + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, r, ctx.first); + CuAssertPtrEquals(tc, NULL, ctx.last); + get_addresses(&ctx); + CuAssertPtrNotNull(tc, ctx.addresses); + CuAssertIntEquals(tc, 3, selist_length(ctx.addresses)); + CuAssertIntEquals(tc, 1, (i=0, selist_find(&ctx.addresses, &i, f1, NULL))); + CuAssertIntEquals(tc, 1, (i=0, selist_find(&ctx.addresses, &i, f2, NULL))); + CuAssertIntEquals(tc, 1, (i=0, selist_find(&ctx.addresses, &i, f, NULL))); + test_cleanup(); +} + void test_prepare_lighthouse_capacity(CuTest *tc) { building *b; building_type *btype; @@ -490,6 +516,7 @@ CuSuite *get_reports_suite(void) SUITE_ADD_TEST(suite, test_prepare_lighthouse_owners); SUITE_ADD_TEST(suite, test_prepare_lighthouse_capacity); SUITE_ADD_TEST(suite, test_prepare_travelthru); + SUITE_ADD_TEST(suite, test_get_addresses); SUITE_ADD_TEST(suite, test_reorder_units); SUITE_ADD_TEST(suite, test_seen_faction); SUITE_ADD_TEST(suite, test_regionid); From 83a862d557c4989d99c7daf3cbc9f5b2c6aa7cbc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 1 Mar 2017 19:54:52 +0100 Subject: [PATCH 619/675] add a failing test for bug 2286 --- src/reports.test.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/reports.test.c b/src/reports.test.c index 534cb2187..a6f53d43a 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -2,6 +2,7 @@ #include "reports.h" #include "move.h" +#include "spy.h" #include "lighthouse.h" #include "travelthru.h" #include "keyword.h" @@ -298,10 +299,39 @@ static void test_get_addresses(CuTest *tc) { CuAssertPtrEquals(tc, NULL, ctx.last); get_addresses(&ctx); CuAssertPtrNotNull(tc, ctx.addresses); + CuAssertIntEquals(tc, 1, (i = 0, selist_find(&ctx.addresses, &i, f, NULL))); + CuAssertIntEquals(tc, 1, (i = 0, selist_find(&ctx.addresses, &i, f1, NULL))); + CuAssertIntEquals(tc, 1, (i = 0, selist_find(&ctx.addresses, &i, f2, NULL))); CuAssertIntEquals(tc, 3, selist_length(ctx.addresses)); + test_cleanup(); +} + +static void test_get_addresses_fstealth(CuTest *tc) { + report_context ctx; + faction *f, *f2, *f1; + region *r; + unit *u; + int i; + + test_setup(); + f = test_create_faction(0); + f1 = test_create_faction(0); + f2 = test_create_faction(0); + r = test_create_region(0, 0, 0); + test_create_unit(f, r); + test_create_unit(f1, r); + u = test_create_unit(f2, r); + set_factionstealth(u, f1); + + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, r, ctx.first); + CuAssertPtrEquals(tc, NULL, ctx.last); + get_addresses(&ctx); + CuAssertPtrNotNull(tc, ctx.addresses); + CuAssertIntEquals(tc, 1, (i = 0, selist_find(&ctx.addresses, &i, f, NULL))); CuAssertIntEquals(tc, 1, (i=0, selist_find(&ctx.addresses, &i, f1, NULL))); CuAssertIntEquals(tc, 1, (i=0, selist_find(&ctx.addresses, &i, f2, NULL))); - CuAssertIntEquals(tc, 1, (i=0, selist_find(&ctx.addresses, &i, f, NULL))); + CuAssertIntEquals(tc, 3, selist_length(ctx.addresses)); test_cleanup(); } @@ -517,6 +547,7 @@ CuSuite *get_reports_suite(void) SUITE_ADD_TEST(suite, test_prepare_lighthouse_capacity); SUITE_ADD_TEST(suite, test_prepare_travelthru); SUITE_ADD_TEST(suite, test_get_addresses); + SUITE_ADD_TEST(suite, test_get_addresses_fstealth); SUITE_ADD_TEST(suite, test_reorder_units); SUITE_ADD_TEST(suite, test_seen_faction); SUITE_ADD_TEST(suite, test_regionid); From 98447668caef8a0c09406e89fb82f5ac15867570 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 1 Mar 2017 20:37:49 +0100 Subject: [PATCH 620/675] fix bad tests, upgrade clibs. --- clibs | 2 +- src/reports.test.c | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/clibs b/clibs index 27c8b3202..d286006a2 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 +Subproject commit d286006a28c8aa7cd70ed7fd4cd172b50ade9727 diff --git a/src/reports.test.c b/src/reports.test.c index a6f53d43a..e0cabb6d8 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -284,7 +284,6 @@ static void test_get_addresses(CuTest *tc) { report_context ctx; faction *f, *f2, *f1; region *r; - int i; test_setup(); f = test_create_faction(0); @@ -299,9 +298,9 @@ static void test_get_addresses(CuTest *tc) { CuAssertPtrEquals(tc, NULL, ctx.last); get_addresses(&ctx); CuAssertPtrNotNull(tc, ctx.addresses); - CuAssertIntEquals(tc, 1, (i = 0, selist_find(&ctx.addresses, &i, f, NULL))); - CuAssertIntEquals(tc, 1, (i = 0, selist_find(&ctx.addresses, &i, f1, NULL))); - CuAssertIntEquals(tc, 1, (i = 0, selist_find(&ctx.addresses, &i, f2, NULL))); + CuAssertTrue(tc, selist_contains(ctx.addresses, f, NULL)); + CuAssertTrue(tc, selist_contains(ctx.addresses, f1, NULL)); + CuAssertTrue(tc, selist_contains(ctx.addresses, f2, NULL)); CuAssertIntEquals(tc, 3, selist_length(ctx.addresses)); test_cleanup(); } @@ -311,7 +310,6 @@ static void test_get_addresses_fstealth(CuTest *tc) { faction *f, *f2, *f1; region *r; unit *u; - int i; test_setup(); f = test_create_faction(0); @@ -328,10 +326,10 @@ static void test_get_addresses_fstealth(CuTest *tc) { CuAssertPtrEquals(tc, NULL, ctx.last); get_addresses(&ctx); CuAssertPtrNotNull(tc, ctx.addresses); - CuAssertIntEquals(tc, 1, (i = 0, selist_find(&ctx.addresses, &i, f, NULL))); - CuAssertIntEquals(tc, 1, (i=0, selist_find(&ctx.addresses, &i, f1, NULL))); - CuAssertIntEquals(tc, 1, (i=0, selist_find(&ctx.addresses, &i, f2, NULL))); - CuAssertIntEquals(tc, 3, selist_length(ctx.addresses)); + CuAssertTrue(tc, selist_contains(ctx.addresses, f, NULL)); + CuAssertTrue(tc, selist_contains(ctx.addresses, f1, NULL)); + CuAssertTrue(tc, ! selist_contains(ctx.addresses, f2, NULL)); + CuAssertIntEquals(tc, 2, selist_length(ctx.addresses)); test_cleanup(); } From 7f03417c37132b3ae05b7a1e7f1cebfa12018517 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 1 Mar 2017 21:10:50 +0100 Subject: [PATCH 621/675] bug 2286: fix missing addresses. was using cansee_unit wrong, mixed up traveler (ut) and target (u). --- src/reports.c | 2 +- src/reports.test.c | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/reports.c b/src/reports.c index acbc36f69..ea504d46b 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1006,7 +1006,7 @@ static void cb_add_address(region *r, unit *ut, void *cbdata) { for (u = r->units; u; u = u->next) { faction *sf = visible_faction(f, u); assert(u->faction != f); /* if this is see_travel only, then I shouldn't be here. */ - if (data->lastf != sf && cansee_unit(u, ut, data->stealthmod)) { + if (data->lastf != sf && cansee_unit(ut, u, data->stealthmod)) { add_seen_faction_i(data->flist, sf); data->lastf = sf; break; diff --git a/src/reports.test.c b/src/reports.test.c index e0cabb6d8..c026041a9 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -317,9 +317,8 @@ static void test_get_addresses_fstealth(CuTest *tc) { f2 = test_create_faction(0); r = test_create_region(0, 0, 0); test_create_unit(f, r); - test_create_unit(f1, r); - u = test_create_unit(f2, r); - set_factionstealth(u, f1); + u = test_create_unit(f1, r); + set_factionstealth(u, f2); prepare_report(&ctx, f); CuAssertPtrEquals(tc, r, ctx.first); @@ -327,8 +326,38 @@ static void test_get_addresses_fstealth(CuTest *tc) { get_addresses(&ctx); CuAssertPtrNotNull(tc, ctx.addresses); CuAssertTrue(tc, selist_contains(ctx.addresses, f, NULL)); - CuAssertTrue(tc, selist_contains(ctx.addresses, f1, NULL)); - CuAssertTrue(tc, ! selist_contains(ctx.addresses, f2, NULL)); + CuAssertTrue(tc, !selist_contains(ctx.addresses, f1, NULL)); + CuAssertTrue(tc, selist_contains(ctx.addresses, f2, NULL)); + CuAssertIntEquals(tc, 2, selist_length(ctx.addresses)); + test_cleanup(); +} + +static void test_get_addresses_travelthru(CuTest *tc) { + report_context ctx; + faction *f, *f2, *f1; + region *r1, *r2; + unit *u; + + test_setup(); + f = test_create_faction(0); + f1 = test_create_faction(0); + f2 = test_create_faction(0); + r1 = test_create_region(0, 0, 0); + r2 = test_create_region(1, 0, 0); + u = test_create_unit(f, r2); + travelthru_add(r1, u); + u = test_create_unit(f1, r1); + set_factionstealth(u, f2); + u->building = test_create_building(u->region, test_create_buildingtype("tower")); + + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, r1, ctx.first); + CuAssertPtrEquals(tc, NULL, ctx.last); + get_addresses(&ctx); + CuAssertPtrNotNull(tc, ctx.addresses); + CuAssertTrue(tc, selist_contains(ctx.addresses, f, NULL)); + CuAssertTrue(tc, !selist_contains(ctx.addresses, f1, NULL)); + CuAssertTrue(tc, selist_contains(ctx.addresses, f2, NULL)); CuAssertIntEquals(tc, 2, selist_length(ctx.addresses)); test_cleanup(); } @@ -546,6 +575,7 @@ CuSuite *get_reports_suite(void) SUITE_ADD_TEST(suite, test_prepare_travelthru); SUITE_ADD_TEST(suite, test_get_addresses); SUITE_ADD_TEST(suite, test_get_addresses_fstealth); + SUITE_ADD_TEST(suite, test_get_addresses_travelthru); SUITE_ADD_TEST(suite, test_reorder_units); SUITE_ADD_TEST(suite, test_seen_faction); SUITE_ADD_TEST(suite, test_regionid); From 912a8b5412d7fd213ab29e226c060ddbcb8c7b17 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 1 Mar 2017 21:17:37 +0100 Subject: [PATCH 622/675] bug 2291: json settings must not override eressea.ini. https://bugs.eressea.de/view.php?id=2291 --- src/kernel/jsonconf.c | 20 ++++++++++---------- src/kernel/jsonconf.test.c | 3 +++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 287aa61db..0f5642c42 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -797,18 +797,18 @@ static void json_settings(cJSON *json) { return; } for (child = json->child; child; child = child->next) { - if (child->valuestring) { - config_set(child->string, child->valuestring); - } - else { - char value[32]; - if (child->type == cJSON_Number && child->valuedouble && child->valueintvaluedouble) { - sprintf(value, "%f", child->valuedouble); + if (config_get(child->string) == NULL) { + if (child->valuestring) { + config_set(child->string, child->valuestring); } else { - sprintf(value, "%d", child->valueint); - } - if (config_get(child->string) == NULL) { + char value[32]; + if (child->type == cJSON_Number && child->valuedouble && child->valueint < child->valuedouble) { + sprintf(value, "%f", child->valuedouble); + } + else { + sprintf(value, "%d", child->valueint); + } config_set(child->string, value); } } diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 8b8ac8c14..456a27d22 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -70,14 +70,17 @@ static void test_settings(CuTest * tc) "\"integer\" : 14," "\"true\": true," "\"game.id\": 4," + "\"game.name\": \"E3\"," "\"false\": false," "\"float\" : 1.5 }}"; cJSON *json = cJSON_Parse(data); test_cleanup(); config_set("game.id", "42"); /* should not be replaced */ + config_set("game.name", "Eressea"); /* should not be replaced */ json_config(json); CuAssertStrEquals(tc, "42", config_get("game.id")); + CuAssertStrEquals(tc, "Eressea", config_get("game.name")); CuAssertStrEquals(tc, "1", config_get("true")); CuAssertStrEquals(tc, "0", config_get("false")); CuAssertStrEquals(tc, "1d4", config_get("string")); From e826b7af227d3e49746fb9f9647ef9a5f3bb1b82 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Mar 2017 08:08:35 +0100 Subject: [PATCH 623/675] fix mail processing scripts --- process/orders-accept | 4 ++++ process/orders-process | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/process/orders-accept b/process/orders-accept index 78af0a056..2f8f0bd29 100755 --- a/process/orders-accept +++ b/process/orders-accept @@ -360,6 +360,10 @@ def accept(game, locale, stream, extend=None): return 0 # the main body of the script: +try: + os.mkdir(os.path.join(rootdir, 'log')) +except: + pass # already exists? LOG_FILENAME=os.path.join(rootdir, 'log/orders.log') logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME) logger = logging diff --git a/process/orders-process b/process/orders-process index b33cc05bf..79c7b3378 100755 --- a/process/orders-process +++ b/process/orders-process @@ -2,6 +2,7 @@ # -*- coding: iso-8859-1 -*- from os import unlink, symlink, rename, popen, tmpfile +import sys import os import os.path import ConfigParser @@ -82,7 +83,7 @@ frommail = 'eressea-server@kn-bremen.de' gamename = 'Eressea' sender = '%s Server <%s>' % (gamename, frommail) -inifile = os.path.join(gamedir, 'eressea.ini') +inifile = os.path.join(game_dir, 'eressea.ini') if not os.path.exists(inifile): print "no such file: " . inifile else: @@ -202,7 +203,7 @@ for line in lines: results = check_pwd(infile, email, pw_data) logfile = open(os.path.join(game_dir, "zug.log"), "a") dirname, filename = split_filename(infile) - msg = messages["validate-"+locale] + " " + infilename + "\n\n" + msg = messages["validate-"+locale] + " " + infile + "\n\n" for faction, game_email, success, pwd in results: msg = msg + messages["faction-"+locale] + " " + faction + "\n" if success: failed = False From 3cb24299fa4231df4929559c20b2fd9bbad61edf Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Mar 2017 12:39:21 +0100 Subject: [PATCH 624/675] bug 2292: only land regions can be guarded. https://bugs.eressea.de/view.php?id=2292 Also adding tests for every other failure reason. --- src/guard.c | 3 ++ src/guard.h | 2 +- src/guard.test.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++ src/laws.c | 45 ++++++++++---------- 4 files changed, 133 insertions(+), 22 deletions(-) diff --git a/src/guard.c b/src/guard.c index 07640452c..1f2ee7f3f 100644 --- a/src/guard.c +++ b/src/guard.c @@ -34,6 +34,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. guard_t can_start_guarding(const unit * u) { + if (!u->region->land) { + return E_GUARD_TERRAIN; + } if (u->status >= ST_FLEE || fval(u, UFL_FLEEING)) return E_GUARD_FLEEING; /* Monster der Monsterpartei duerfen immer bewachen */ diff --git a/src/guard.h b/src/guard.h index 101369f40..5a717d92d 100644 --- a/src/guard.h +++ b/src/guard.h @@ -12,7 +12,7 @@ extern "C" { struct unit; struct region; - typedef enum { E_GUARD_OK, E_GUARD_UNARMED, E_GUARD_NEWBIE, E_GUARD_FLEEING } guard_t; + typedef enum { E_GUARD_OK, E_GUARD_UNARMED, E_GUARD_NEWBIE, E_GUARD_FLEEING, E_GUARD_TERRAIN } guard_t; guard_t can_start_guarding(const struct unit * u); void update_guards(void); diff --git a/src/guard.test.c b/src/guard.test.c index 17aa2891c..1ffd1b4da 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -7,7 +7,9 @@ #include #include #include +#include #include +#include #include #include @@ -128,14 +130,117 @@ static void test_guard_monsters(CuTest * tc) test_cleanup(); } +static void test_update_guard(CuTest * tc) +/* https://bugs.eressea.de/view.php?id=2292 */ +{ + unit *ug; + region *r; + item_type *itype; + const struct terrain_type *t_ocean, *t_plain; + + test_setup(); + t_ocean = test_create_terrain("ocean", SEA_REGION); + t_plain = test_create_terrain("plain", LAND_REGION); + itype = it_get_or_create(rt_get_or_create("sword")); + new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2); + r = test_create_region(0, 0, t_ocean); + ug = test_create_unit(test_create_faction(0), r); + i_change(&ug->items, itype, 1); + set_level(ug, SK_MELEE, 2); + setguard(ug, true); + CuAssertIntEquals(tc, 1, armedmen(ug, false)); + CuAssertTrue(tc, is_guard(ug)); + + terraform_region(r, t_ocean); + update_guards(); + CuAssertTrue(tc, ! is_guard(ug)); + + test_cleanup(); +} + +static void test_guard_on(CuTest * tc) +{ + unit *ug; + region *r; + item_type *itype; + terrain_type *t_ocean, *t_plain; + + test_setup(); + t_ocean = test_create_terrain("ocean", SEA_REGION); + t_plain = test_create_terrain("plain", LAND_REGION); + itype = it_get_or_create(rt_get_or_create("sword")); + new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2); + r = test_create_region(0, 0, t_plain); + ug = test_create_unit(test_create_faction(0), r); + i_change(&ug->items, itype, 1); + set_level(ug, SK_MELEE, 2); + ug->thisorder = create_order(K_GUARD, ug->faction->locale, NULL); + + setguard(ug, false); + CuAssertIntEquals(tc, E_GUARD_OK, can_start_guarding(ug)); + guard_on_cmd(ug, ug->thisorder); + CuAssertTrue(tc, is_guard(ug)); + + terraform_region(r, t_ocean); + + setguard(ug, false); + CuAssertIntEquals(tc, E_GUARD_TERRAIN, can_start_guarding(ug)); + guard_on_cmd(ug, ug->thisorder); + CuAssertTrue(tc, !is_guard(ug)); + CuAssertPtrNotNull(tc, test_find_messagetype(ug->faction->msgs, "error2")); + + setguard(ug, false); + t_ocean->flags &= ~ SEA_REGION; + CuAssertIntEquals(tc, E_GUARD_TERRAIN, can_start_guarding(ug)); + guard_on_cmd(ug, ug->thisorder); + CuAssertTrue(tc, !is_guard(ug)); + CuAssertPtrNotNull(tc, test_find_messagetype(ug->faction->msgs, "error_onlandonly")); + + terraform_region(r, t_plain); + + i_change(&ug->items, itype, -1); + CuAssertIntEquals(tc, E_GUARD_UNARMED, can_start_guarding(ug)); + guard_on_cmd(ug, ug->thisorder); + CuAssertTrue(tc, !is_guard(ug)); + CuAssertPtrNotNull(tc, test_find_messagetype(ug->faction->msgs, "unit_unarmed")); + i_change(&ug->items, itype, 1); + + test_clear_messages(ug->faction); + set_level(ug, SK_MELEE, 0); + CuAssertIntEquals(tc, E_GUARD_UNARMED, can_start_guarding(ug)); + guard_on_cmd(ug, ug->thisorder); + CuAssertTrue(tc, !is_guard(ug)); + CuAssertPtrNotNull(tc, test_find_messagetype(ug->faction->msgs, "unit_unarmed")); + set_level(ug, SK_MELEE, 2); + + ug->status = ST_FLEE; + CuAssertIntEquals(tc, E_GUARD_FLEEING, can_start_guarding(ug)); + guard_on_cmd(ug, ug->thisorder); + CuAssertTrue(tc, !is_guard(ug)); + CuAssertPtrNotNull(tc, test_find_messagetype(ug->faction->msgs, "error320")); + ug->status = ST_FIGHT; + + config_set("NewbieImmunity", "5"); + CuAssertIntEquals(tc, E_GUARD_NEWBIE, can_start_guarding(ug)); + guard_on_cmd(ug, ug->thisorder); + CuAssertTrue(tc, !is_guard(ug)); + CuAssertPtrNotNull(tc, test_find_messagetype(ug->faction->msgs, "error304")); + config_set("NewbieImmunity", NULL); + + test_clear_messages(ug->faction); + test_cleanup(); +} + CuSuite *get_guard_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_is_guarded); SUITE_ADD_TEST(suite, test_is_guard); SUITE_ADD_TEST(suite, test_guard_unskilled); + SUITE_ADD_TEST(suite, test_guard_on); SUITE_ADD_TEST(suite, test_guard_armed); SUITE_ADD_TEST(suite, test_guard_unarmed); SUITE_ADD_TEST(suite, test_guard_monsters); + SUITE_ADD_TEST(suite, test_update_guard); return suite; } diff --git a/src/laws.c b/src/laws.c index 253b45b89..dfbd163cb 100644 --- a/src/laws.c +++ b/src/laws.c @@ -2686,31 +2686,34 @@ int guard_on_cmd(unit * u, struct order *ord) return 0; } - if (fval(u->region->terrain, SEA_REGION)) { - cmistake(u, ord, 2, MSG_EVENT); + if (fval(u, UFL_MOVED)) { + cmistake(u, ord, 187, MSG_EVENT); + } + else if (fval(u_race(u), RCF_ILLUSIONARY) + || u_race(u) == get_race(RC_SPELL)) { + cmistake(u, ord, 95, MSG_EVENT); } else { - if (fval(u, UFL_MOVED)) { - cmistake(u, ord, 187, MSG_EVENT); + int err = can_start_guarding(u); + if (err == E_GUARD_OK) { + setguard(u, true); } - else if (fval(u_race(u), RCF_ILLUSIONARY) - || u_race(u) == get_race(RC_SPELL)) { - cmistake(u, ord, 95, MSG_EVENT); + else if (err == E_GUARD_TERRAIN) { + if (fval(u->region->terrain, SEA_REGION)) { + cmistake(u, ord, 2, MSG_EVENT); + } + else { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", "")); + } } - else { - int err = can_start_guarding(u); - if (err == E_GUARD_OK) { - setguard(u, true); - } - else if (err == E_GUARD_UNARMED) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "unit_unarmed", "")); - } - else if (err == E_GUARD_FLEEING) { - cmistake(u, ord, 320, MSG_EVENT); - } - else if (err == E_GUARD_NEWBIE) { - cmistake(u, ord, 304, MSG_EVENT); - } + else if (err == E_GUARD_UNARMED) { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "unit_unarmed", "")); + } + else if (err == E_GUARD_FLEEING) { + cmistake(u, ord, 320, MSG_EVENT); + } + else if (err == E_GUARD_NEWBIE) { + cmistake(u, ord, 304, MSG_EVENT); } } return 0; From 326f543ece2aaf13966c76b598e4e76801f7a0e0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Mar 2017 13:01:27 +0100 Subject: [PATCH 625/675] gcc reports unused variable. and for once, that points to a bug! --- src/guard.c | 1 + src/guard.test.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/guard.c b/src/guard.c index 1f2ee7f3f..a7fa1a97a 100644 --- a/src/guard.c +++ b/src/guard.c @@ -72,6 +72,7 @@ void setguard(unit * u, bool enabled) } else { assert(!fval(u, UFL_MOVED)); assert(u->status < ST_FLEE); + assert(u->region->land); fset(u, UFL_GUARD); fset(u->region, RF_GUARDED); } diff --git a/src/guard.test.c b/src/guard.test.c index 1ffd1b4da..cc59af4d8 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -143,7 +143,7 @@ static void test_update_guard(CuTest * tc) t_plain = test_create_terrain("plain", LAND_REGION); itype = it_get_or_create(rt_get_or_create("sword")); new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2); - r = test_create_region(0, 0, t_ocean); + r = test_create_region(0, 0, t_plain); ug = test_create_unit(test_create_faction(0), r); i_change(&ug->items, itype, 1); set_level(ug, SK_MELEE, 2); From 45854851ae4b26a19d3584689ca5479ea96b982c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Mar 2017 18:08:58 +0100 Subject: [PATCH 626/675] bug 2292: allow packice to be guarded again. https://bugs.eressea.de/view.php?id=2292 --- src/guard.c | 8 ++++---- src/guard.test.c | 16 ++++++++-------- src/laws.c | 7 +------ 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/guard.c b/src/guard.c index a7fa1a97a..55f189b6c 100644 --- a/src/guard.c +++ b/src/guard.c @@ -24,17 +24,18 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "monsters.h" #include -#include +#include #include #include #include -#include +#include +#include #include guard_t can_start_guarding(const unit * u) { - if (!u->region->land) { + if (u->region->terrain->flags & SEA_REGION) { return E_GUARD_TERRAIN; } if (u->status >= ST_FLEE || fval(u, UFL_FLEEING)) @@ -72,7 +73,6 @@ void setguard(unit * u, bool enabled) } else { assert(!fval(u, UFL_MOVED)); assert(u->status < ST_FLEE); - assert(u->region->land); fset(u, UFL_GUARD); fset(u->region, RF_GUARDED); } diff --git a/src/guard.test.c b/src/guard.test.c index cc59af4d8..8302bcc9a 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -140,7 +140,7 @@ static void test_update_guard(CuTest * tc) test_setup(); t_ocean = test_create_terrain("ocean", SEA_REGION); - t_plain = test_create_terrain("plain", LAND_REGION); + t_plain = test_create_terrain("packice", ARCTIC_REGION); itype = it_get_or_create(rt_get_or_create("sword")); new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2); r = test_create_region(0, 0, t_plain); @@ -181,6 +181,13 @@ static void test_guard_on(CuTest * tc) guard_on_cmd(ug, ug->thisorder); CuAssertTrue(tc, is_guard(ug)); + terraform_region(r, test_create_terrain("packice", ARCTIC_REGION)); + + setguard(ug, false); + CuAssertIntEquals(tc, E_GUARD_OK, can_start_guarding(ug)); + guard_on_cmd(ug, ug->thisorder); + CuAssertTrue(tc, is_guard(ug)); + terraform_region(r, t_ocean); setguard(ug, false); @@ -189,13 +196,6 @@ static void test_guard_on(CuTest * tc) CuAssertTrue(tc, !is_guard(ug)); CuAssertPtrNotNull(tc, test_find_messagetype(ug->faction->msgs, "error2")); - setguard(ug, false); - t_ocean->flags &= ~ SEA_REGION; - CuAssertIntEquals(tc, E_GUARD_TERRAIN, can_start_guarding(ug)); - guard_on_cmd(ug, ug->thisorder); - CuAssertTrue(tc, !is_guard(ug)); - CuAssertPtrNotNull(tc, test_find_messagetype(ug->faction->msgs, "error_onlandonly")); - terraform_region(r, t_plain); i_change(&ug->items, itype, -1); diff --git a/src/laws.c b/src/laws.c index dfbd163cb..3d996971b 100644 --- a/src/laws.c +++ b/src/laws.c @@ -2699,12 +2699,7 @@ int guard_on_cmd(unit * u, struct order *ord) setguard(u, true); } else if (err == E_GUARD_TERRAIN) { - if (fval(u->region->terrain, SEA_REGION)) { - cmistake(u, ord, 2, MSG_EVENT); - } - else { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", "")); - } + cmistake(u, ord, 2, MSG_EVENT); } else if (err == E_GUARD_UNARMED) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "unit_unarmed", "")); From 4502141c5b6c851c0f7091bd8d83ccd7de174e6b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Mar 2017 18:28:00 +0100 Subject: [PATCH 627/675] bug 2292: set mailcmd from eressea.ini this fixes https://bugs.eressea.de/view.php?id=2292 --- src/kernel/config.c | 22 +++++++++++++--------- src/kernel/config.h | 2 +- src/kernel/config.test.c | 14 +++++++++++++- src/reports.c | 2 +- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index 3f04b03b3..b605fddd4 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -833,17 +833,21 @@ const char * game_name(void) return param ? param : global.gamename; } -const char * game_name_upper(void) +const char * game_mailcmd(void) { - static char result[32]; /* FIXME: static result */ - char *r = result; - const char *param = game_name(); - const char *c = param; - while (*c && (result+sizeof(result))>r) { - *r++ = (char)toupper(*c++); + const char *param = config_get("game.mailcmd"); + if (!param) { + static char result[32]; /* FIXME: static result */ + char *r = result; + const char *c; + param = game_name(); + for (c = param; *c && (result + sizeof(result)) > r; ++c) { + *r++ = (char)toupper(*c); + } + *r = '\0'; + return result; } - *r = '\0'; - return result; + return param; } int game_id(void) { diff --git a/src/kernel/config.h b/src/kernel/config.h index e38d1dd56..3b307bbdd 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -51,7 +51,7 @@ extern "C" { param_t getparam(const struct locale *lang); const char * game_name(void); - const char * game_name_upper(void); + const char * game_mailcmd(void); int game_id(void); /* returns a value between [0..xpct_2], generated with two dice */ diff --git a/src/kernel/config.test.c b/src/kernel/config.test.c index 9a10a4c56..7acf8e948 100644 --- a/src/kernel/config.test.c +++ b/src/kernel/config.test.c @@ -245,7 +245,6 @@ static void test_config_inifile(CuTest *tc) { config_set_from(ini); CuAssertStrEquals(tc, "Eressea", config_get("game.name")); CuAssertStrEquals(tc, "Eressea", game_name()); - CuAssertStrEquals(tc, "ERESSEA", game_name_upper()); CuAssertIntEquals(tc, 42, game_id()); iniparser_freedict(ini); test_cleanup(); @@ -274,6 +273,18 @@ static void test_findparam(CuTest *tc) { test_cleanup(); } +static void test_game_mailcmd(CuTest *tc) { + test_setup(); + CuAssertStrEquals(tc, "Eressea", game_name()); + CuAssertStrEquals(tc, "ERESSEA", game_mailcmd()); + config_set("game.name", "Hodor"); + CuAssertStrEquals(tc, "Hodor", game_name()); + CuAssertStrEquals(tc, "HODOR", game_mailcmd()); + config_set("game.mailcmd", "ERESSEA"); + CuAssertStrEquals(tc, "ERESSEA", game_mailcmd()); + test_cleanup(); +} + CuSuite *get_config_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -287,6 +298,7 @@ CuSuite *get_config_suite(void) SUITE_ADD_TEST(suite, test_getunit); SUITE_ADD_TEST(suite, test_read_unitid); SUITE_ADD_TEST(suite, test_default_order); + SUITE_ADD_TEST(suite, test_game_mailcmd); SUITE_ADD_TEST(suite, test_rules); return suite; } diff --git a/src/reports.c b/src/reports.c index ea504d46b..a07b60f4b 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1945,7 +1945,7 @@ static void eval_regions(struct opstack **stack, const void *userdata) const char *get_mailcmd(const struct locale *loc) { static char result[64]; /* FIXME: static return buffer */ - snprintf(result, sizeof(result), "%s %d %s", game_name_upper(), game_id(), LOC(loc, "mailcmd")); + snprintf(result, sizeof(result), "%s %d %s", game_mailcmd(), game_id(), LOC(loc, "mailcmd")); return result; } From b0baba4405890cbb5678fa099b74aaabd18d5a35 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Mar 2017 19:21:11 +0100 Subject: [PATCH 628/675] bug 2290: sawmill bonus was broken. not pleased with the test, which is in lua only. https://bugs.eressea.de/view.php?id=2290 --- scripts/tests/e2/init.lua | 3 +-- scripts/tests/e3/init.lua | 1 + scripts/tests/economy.lua | 14 ++++++++++++++ src/economy.c | 4 ++-- src/economy.test.c | 6 ++++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index afaac7209..25e21f3e5 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,5 +1,3 @@ -require 'tests.economy' - require 'tests.e2.undead' require 'tests.e2.shiplanding' require 'tests.e2.e2features' @@ -8,6 +6,7 @@ require 'tests.e2.destroy' require 'tests.e2.guard' require 'tests.e2.spells' require 'tests.e2.stealth' +require 'tests.economy' require 'tests.orders' require 'tests.common' require 'tests.report' diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua index 4655fdcef..4501e35eb 100644 --- a/scripts/tests/e3/init.lua +++ b/scripts/tests/e3/init.lua @@ -4,6 +4,7 @@ require 'tests.e3.spells' require 'tests.e3.rules' require 'tests.e3.parser' require 'tests.e3.morale' +require 'tests.economy' require 'tests.orders' require 'tests.common' -- require 'tests.report' diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua index b628dd47b..fe1574887 100644 --- a/scripts/tests/economy.lua +++ b/scripts/tests/economy.lua @@ -127,6 +127,20 @@ function test_ironkeeper_guards_iron() assert_equal(level, u:get_item("iron")) end +function test_sawmill() + local r = region.create(0, 0, "plain") + r:set_resource("tree", 100) + local u = unit.create(faction.create("human"), r) + u:add_item("money", 250) -- sawmill maintenance + u:set_skill("forestry", 6) + u.building = building.create(r, "sawmill") + u.building.size = 1 + u:add_order("MACHE 6 HOLZ") + process_orders() + assert_equal(6, u:get_item("log")) + assert_equal(97, r:get_resource("tree")) +end + function test_ent_guards_trees() local r = region.create(0, 0, "plain") r:set_resource("tree", 100) diff --git a/src/economy.c b/src/economy.c index f9ded29de..a3b300788 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1123,7 +1123,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) allocation *al; int nreq = 0; resource_limit *rdata = get_resourcelimit(rtype); - int avail = 0; + int avail = INT_MAX; for (al = alist; al; al = al->next) { nreq += required(al->want, al->save); @@ -1145,7 +1145,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) if (rx>0 && rng_int() % nreq < rx) ++x; avail -= x; nreq -= want; - al->get = x * al->save.sa[0] / al->save.sa[1]; + al->get = x * al->save.sa[1] / al->save.sa[0]; al->get = MIN(al->want, al->get); if (rdata->produce) { int use = required(al->get, al->save); diff --git a/src/economy.test.c b/src/economy.test.c index 6d9c84542..e14b473b4 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -407,6 +407,12 @@ static void test_make_item(CuTest *tc) { CuAssertIntEquals(tc, 22, get_item(u, itype)); CuAssertIntEquals(tc, 283, u->region->resources->amount); /* no free lunches */ + rdata->modifiers[0].value = frac_make(1, 2); + make_item(u, itype, 6); + split_allocations(u->region); + CuAssertIntEquals(tc, 28, get_item(u, itype)); + CuAssertIntEquals(tc, 280, u->region->resources->amount); /* 50% saving = 3 stones make 6 stones */ + rdata->modifiers[0].flags = RMF_REQUIREDBUILDING; rdata->modifiers[0].race = NULL; rdata->modifiers[0].btype = bt_get_or_create("mine"); From bec7a338ab013827460615b17db92d32f560412e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Mar 2017 08:08:35 +0100 Subject: [PATCH 629/675] fix mail processing scripts --- process/orders-accept | 4 ++++ process/orders-process | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/process/orders-accept b/process/orders-accept index 78af0a056..2f8f0bd29 100755 --- a/process/orders-accept +++ b/process/orders-accept @@ -360,6 +360,10 @@ def accept(game, locale, stream, extend=None): return 0 # the main body of the script: +try: + os.mkdir(os.path.join(rootdir, 'log')) +except: + pass # already exists? LOG_FILENAME=os.path.join(rootdir, 'log/orders.log') logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME) logger = logging diff --git a/process/orders-process b/process/orders-process index b33cc05bf..79c7b3378 100755 --- a/process/orders-process +++ b/process/orders-process @@ -2,6 +2,7 @@ # -*- coding: iso-8859-1 -*- from os import unlink, symlink, rename, popen, tmpfile +import sys import os import os.path import ConfigParser @@ -82,7 +83,7 @@ frommail = 'eressea-server@kn-bremen.de' gamename = 'Eressea' sender = '%s Server <%s>' % (gamename, frommail) -inifile = os.path.join(gamedir, 'eressea.ini') +inifile = os.path.join(game_dir, 'eressea.ini') if not os.path.exists(inifile): print "no such file: " . inifile else: @@ -202,7 +203,7 @@ for line in lines: results = check_pwd(infile, email, pw_data) logfile = open(os.path.join(game_dir, "zug.log"), "a") dirname, filename = split_filename(infile) - msg = messages["validate-"+locale] + " " + infilename + "\n\n" + msg = messages["validate-"+locale] + " " + infile + "\n\n" for faction, game_email, success, pwd in results: msg = msg + messages["faction-"+locale] + " " + faction + "\n" if success: failed = False From 6e8e16309989bbfc7251ca77e7c805de5e8c5d11 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Mar 2017 09:56:27 +0100 Subject: [PATCH 630/675] make item allow/deny XML easier to read, fix code --- res/core/weapons/greatbow.xml | 2 +- res/core/weapons/rep_crossbow.xml | 2 +- res/e3a/armor/plate.xml | 2 +- res/e3a/armor/scale.xml | 2 +- res/e3a/armor/towershield.xml | 2 +- res/e3a/races.xml | 6 +++--- res/e3a/weapons.xml | 4 ++-- res/e3a/weapons/greatbow.xml | 2 +- res/e3a/weapons/halberd.xml | 2 +- res/e3a/weapons/mallornlance.xml | 2 +- res/e3a/weapons/rustyhalberd.xml | 2 +- res/races/goblin-3.xml | 2 +- scripts/tests/e3/items.lua | 4 ++-- src/kernel/race.c | 2 +- src/kernel/race.test.c | 2 +- src/kernel/xmlreader.c | 26 +++++++++++++++++++++++--- 16 files changed, 42 insertions(+), 22 deletions(-) diff --git a/res/core/weapons/greatbow.xml b/res/core/weapons/greatbow.xml index 10b270e55..14734a129 100644 --- a/res/core/weapons/greatbow.xml +++ b/res/core/weapons/greatbow.xml @@ -1,6 +1,6 @@ - + diff --git a/res/core/weapons/rep_crossbow.xml b/res/core/weapons/rep_crossbow.xml index 66e3f9fc2..d6f869046 100644 --- a/res/core/weapons/rep_crossbow.xml +++ b/res/core/weapons/rep_crossbow.xml @@ -1,6 +1,6 @@ - + diff --git a/res/e3a/armor/plate.xml b/res/e3a/armor/plate.xml index 29cabbf1a..9aeafc3c1 100644 --- a/res/e3a/armor/plate.xml +++ b/res/e3a/armor/plate.xml @@ -1,6 +1,6 @@ - + diff --git a/res/e3a/armor/scale.xml b/res/e3a/armor/scale.xml index 7039b4008..691ce5ba7 100644 --- a/res/e3a/armor/scale.xml +++ b/res/e3a/armor/scale.xml @@ -1,6 +1,6 @@ - + diff --git a/res/e3a/armor/towershield.xml b/res/e3a/armor/towershield.xml index dcd2858cf..78e113e2a 100644 --- a/res/e3a/armor/towershield.xml +++ b/res/e3a/armor/towershield.xml @@ -1,6 +1,6 @@ - + diff --git a/res/e3a/races.xml b/res/e3a/races.xml index fc16645c6..8b0cfae6d 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -75,7 +75,7 @@ regaura="1.0" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" - giveunit="yes" getitem="yes" equipment="yes" items="8"> + giveunit="yes" getitem="yes" equipment="yes"> @@ -124,7 +124,7 @@ recruitcost="200" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" - giveunit="yes" getitem="yes" equipment="yes" items="2"> + giveunit="yes" getitem="yes" equipment="yes" > @@ -168,7 +168,7 @@ recruitcost="240" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" - giveunit="yes" getitem="yes" equipment="yes" items="1"> + giveunit="yes" getitem="yes" equipment="yes"> diff --git a/res/e3a/weapons.xml b/res/e3a/weapons.xml index 052266a02..96a987b28 100644 --- a/res/e3a/weapons.xml +++ b/res/e3a/weapons.xml @@ -1,9 +1,7 @@ - - @@ -13,6 +11,8 @@ + + diff --git a/res/e3a/weapons/greatbow.xml b/res/e3a/weapons/greatbow.xml index 7f08427c8..b488a011c 100644 --- a/res/e3a/weapons/greatbow.xml +++ b/res/e3a/weapons/greatbow.xml @@ -4,7 +4,7 @@ * has lower damage --> - + diff --git a/res/e3a/weapons/halberd.xml b/res/e3a/weapons/halberd.xml index 2c11b62fc..c07cbfd4d 100644 --- a/res/e3a/weapons/halberd.xml +++ b/res/e3a/weapons/halberd.xml @@ -3,7 +3,7 @@ 1. you cannt use this with cavalry --> - + diff --git a/res/e3a/weapons/mallornlance.xml b/res/e3a/weapons/mallornlance.xml index 1fcad08c8..d2aacaea7 100644 --- a/res/e3a/weapons/mallornlance.xml +++ b/res/e3a/weapons/mallornlance.xml @@ -1,6 +1,6 @@ - + diff --git a/res/e3a/weapons/rustyhalberd.xml b/res/e3a/weapons/rustyhalberd.xml index ed25d5db7..32c0d4497 100644 --- a/res/e3a/weapons/rustyhalberd.xml +++ b/res/e3a/weapons/rustyhalberd.xml @@ -3,7 +3,7 @@ 1. you cannot use this with cavalry --> - + diff --git a/res/races/goblin-3.xml b/res/races/goblin-3.xml index 8deb33f5e..a65d4c99a 100644 --- a/res/races/goblin-3.xml +++ b/res/races/goblin-3.xml @@ -3,7 +3,7 @@ recruitcost="60" maintenance="6" weight="600" capacity="440" speed="1.0" hp="16" damage="1d5" unarmedattack="-2" unarmeddefense="0" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" -getitem="yes" equipment="yes" healing="2.0" items="4"> +getitem="yes" equipment="yes" healing="2.0"> diff --git a/scripts/tests/e3/items.lua b/scripts/tests/e3/items.lua index 5594eed67..349e12b2a 100644 --- a/scripts/tests/e3/items.lua +++ b/scripts/tests/e3/items.lua @@ -22,8 +22,8 @@ function test_goblins() local restricted = { "towershield", "rep_crossbow", "plate", "lance", - "mllornlance", "greatbow", "greataxe", "axe", "scale", - "plate", "rustyhalberd", "halberd", "greatsword" + "mallornlance", "greatbow", "greataxe", "axe", "scale", + "plate", "halberd", "greatsword", "rustyhalberd" } for k, v in ipairs(restricted) do ud:add_item(v, 1) diff --git a/src/kernel/race.c b/src/kernel/race.c index efe38dcfe..8a8cc906e 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -328,7 +328,7 @@ bool rc_changed(int *cache) { bool rc_can_use(const struct race *rc, const struct item_type *itype) { if (itype->mask_allow) { - return (rc->mask_item==0 || (itype->mask_allow & rc->mask_item) != 0); + return (itype->mask_allow & rc->mask_item) != 0; } if (itype->mask_deny) { return (itype->mask_deny & rc->mask_item) == 0; diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c index b292a825e..2db76a6fd 100644 --- a/src/kernel/race.test.c +++ b/src/kernel/race.test.c @@ -146,7 +146,7 @@ static void test_rc_can_use(CuTest *tc) { /* we are not special */ rc->mask_item = 0; - CuAssertTrue(tc, rc_can_use(rc, itype)); + CuAssertTrue(tc, ! rc_can_use(rc, itype)); test_cleanup(); } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 3a6ba6d81..208a586a7 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -757,6 +757,27 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype) return wtype; } +static int race_mask = 1; + +static void mask_races(xmlNodePtr node, const char *key, int *maskp) { + xmlChar *propValue = xmlGetProp(node, BAD_CAST key); + char *tok; + int mask = 0; + assert(maskp); + tok = strtok((char *)propValue, " ,"); + while (tok) { + race * rc = rc_get_or_create(tok); + if (!rc->mask_item) { + rc->mask_item = race_mask; + race_mask = race_mask << 1; + } + mask |= rc->mask_item; + tok = strtok(NULL, " ,"); + } + *maskp = mask; + xmlFree(propValue); +} + static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) { xmlNodePtr node = xpath->node; @@ -782,8 +803,8 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) itype = rtype->itype ? rtype->itype : it_get_or_create(rtype); itype->weight = xml_ivalue(node, "weight", 0); itype->capacity = xml_ivalue(node, "capacity", 0); - itype->mask_allow = xml_ivalue(node, "allow", 0); - itype->mask_deny = xml_ivalue(node, "deny", 0); + mask_races(node, "allow", &itype->mask_allow); + mask_races(node, "deny", &itype->mask_deny); itype->flags |= flags; /* reading item/construction */ @@ -1577,7 +1598,6 @@ static int parse_races(xmlDocPtr doc) rc->speed = (float)xml_fvalue(node, "speed", rc->speed); rc->hitpoints = xml_ivalue(node, "hp", rc->hitpoints); rc->armor = (char)xml_ivalue(node, "ac", rc->armor); - rc->mask_item = (char)xml_ivalue(node, "items", rc->mask_item); study_speed_base = xml_ivalue(node, "studyspeed", 0); rc->at_default = (char)xml_ivalue(node, "unarmedattack", -2); From 5b1e786fb262090c63e3d7490dd357e4c5d60018 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Mar 2017 10:35:34 +0100 Subject: [PATCH 631/675] fix bad strtok call --- src/kernel/xmlreader.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 208a586a7..d6397edf5 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -761,21 +761,22 @@ static int race_mask = 1; static void mask_races(xmlNodePtr node, const char *key, int *maskp) { xmlChar *propValue = xmlGetProp(node, BAD_CAST key); - char *tok; int mask = 0; assert(maskp); - tok = strtok((char *)propValue, " ,"); - while (tok) { - race * rc = rc_get_or_create(tok); - if (!rc->mask_item) { - rc->mask_item = race_mask; - race_mask = race_mask << 1; + if (propValue) { + char * tok = strtok((char *)propValue, " ,"); + while (tok) { + race * rc = rc_get_or_create(tok); + if (!rc->mask_item) { + rc->mask_item = race_mask; + race_mask = race_mask << 1; + } + mask |= rc->mask_item; + tok = strtok(NULL, " ,"); } - mask |= rc->mask_item; - tok = strtok(NULL, " ,"); + xmlFree(propValue); } *maskp = mask; - xmlFree(propValue); } static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) From 591a5b67d3ee9af6aa9b2325c8ed5764c1201c67 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Mar 2017 16:38:28 +0100 Subject: [PATCH 632/675] add missing files --- res/e3a/weapons/axe.xml | 14 ++++++++++++++ res/e3a/weapons/lance.xml | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 res/e3a/weapons/axe.xml create mode 100644 res/e3a/weapons/lance.xml diff --git a/res/e3a/weapons/axe.xml b/res/e3a/weapons/axe.xml new file mode 100644 index 000000000..991a2b504 --- /dev/null +++ b/res/e3a/weapons/axe.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/res/e3a/weapons/lance.xml b/res/e3a/weapons/lance.xml new file mode 100644 index 000000000..a3f641833 --- /dev/null +++ b/res/e3a/weapons/lance.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + From 259d7d9e804f6169c85250688a801a82ddae9654 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Mar 2017 16:50:43 +0100 Subject: [PATCH 633/675] add a test for giving horses to 0. should add those horses to the region. remove horses from test that is about 50% silver. --- scripts/tests/common.lua | 13 +++++++++++++ scripts/tests/e3/items.lua | 13 +++++++++++++ scripts/tests/e3/rules.lua | 6 +----- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 03ae5db85..317380417 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -1028,3 +1028,16 @@ function test_recruit() assert_equal(6, u.number) end end + +function test_give_horses() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + + r:set_resource("horse", 0) + u:add_item("horse", 20) + u:add_order("GIB 0 10 PFERDE") + process_orders() + assert_equal(10, r:get_resource("horse")) + assert_equal(10, u:get_item("horse")) +end diff --git a/scripts/tests/e3/items.lua b/scripts/tests/e3/items.lua index 349e12b2a..d916be744 100644 --- a/scripts/tests/e3/items.lua +++ b/scripts/tests/e3/items.lua @@ -8,6 +8,19 @@ function setup() eressea.settings.set("NewbieImmunity", "0") end +function test_give_horses() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + + r:set_resource("horse", 0) + u:add_item("charger", 20) + u:add_order("GIB 0 10 Streitross") + process_orders() + assert_equal(10, r:get_resource("horse")) + assert_equal(10, u:get_item("charger")) +end + function test_goblins() local r = region.create(0, 0, "plain") assert(r) diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index 2cba83f21..2ecdf1ff7 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -626,11 +626,7 @@ function test_give_50_percent_of_money() u1:add_order("GIB " .. itoa36(u2.id) .. " 221 Silber") u2:clear_orders() u2:add_order("HELFEN " .. itoa36(u1.faction.id) .. " GIB") - u2:add_item("horse", 100) - u2:add_order("GIB 0 ALLES PFERD") - local h = r:get_resource("horse") process_orders() - assert_true(r:get_resource("horse")>=h+100) assert_equal(m1-221, u1:get_item("money")) assert_equal(m2+110, u2:get_item("money")) end @@ -990,4 +986,4 @@ function test_bug2187() -- write_report(f) set_rule("rules.food.flags", "4") -end \ No newline at end of file +end From 681a4bdaa8333d5b4e808760a0faf221ed3ae481 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Mar 2017 17:27:51 +0100 Subject: [PATCH 634/675] dolphins are animals, but not horses. --- scripts/tests/common.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 317380417..fa2fd9f35 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -1036,8 +1036,11 @@ function test_give_horses() r:set_resource("horse", 0) u:add_item("horse", 20) - u:add_order("GIB 0 10 PFERDE") + u:add_item("dolphin", 10) + u:add_order("GIB 0 10 PFERD") + u:add_order("GIB 0 5 DELPHIN") process_orders() assert_equal(10, r:get_resource("horse")) + assert_equal(5, u:get_item("dolphin")) assert_equal(10, u:get_item("horse")) end From a265bc9cdb1abc59f9c4145da5317d406602e77b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Mar 2017 18:02:43 +0100 Subject: [PATCH 635/675] test giving stuff to 0. --- scripts/tests/e3/items.lua | 25 ++++++++++++++++++++++++- src/laws.c | 13 +++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/scripts/tests/e3/items.lua b/scripts/tests/e3/items.lua index d916be744..caf566468 100644 --- a/scripts/tests/e3/items.lua +++ b/scripts/tests/e3/items.lua @@ -23,7 +23,6 @@ end function test_goblins() local r = region.create(0, 0, "plain") - assert(r) local f1 = faction.create("goblin@eressea.de", "goblin", "de") local f2 = faction.create("dwarf@eressea.de", "dwarf", "de") local f3 = faction.create("elf@eressea.de", "elf", "de") @@ -51,3 +50,27 @@ function test_goblins() ud:add_order("ATTACKIERE " .. itoa36(u3.id)) process_orders() end + +function test_make_horse() + eressea.settings.set("rules.horses.growth", "0") + local r = region.create(0, 0, "plain") + local f = faction.create("horses@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:set_skill("training", 4) + r:set_resource("horse", 100) + u:add_order("MACHE 1 PFERD") + process_orders() + assert_equal(1, u:get_item("horse")) + assert_equal(99, r:get_resource("horse")) + + u:clear_orders() + u:add_order("MACHE 1 STREITROSS") + u:add_item("money", 200) + u:add_item("iron", 1) + process_orders() + assert_equal(1, u:get_item("charger")) + assert_equal(0, u:get_item("horse")) + assert_equal(0, u:get_item("iron")) + assert_equal(0, u:get_item("money")) + assert_equal(99, r:get_resource("horse")) +end diff --git a/src/laws.c b/src/laws.c index cc10baeb5..b8291440f 100644 --- a/src/laws.c +++ b/src/laws.c @@ -333,7 +333,7 @@ int peasant_luck_effect(int peasants, int luck, int maxp, double variance) #endif -static void peasants(region * r) +static void peasants(region * r, int rule) { int peasants = rpeasants(r); int money = rmoney(r); @@ -341,7 +341,7 @@ static void peasants(region * r) int n, satiated; int dead = 0; - if (peasants > 0 && config_get_int("rules.peasants.growth", 1)) { + if (peasants > 0 && rule > 0) { int luck = 0; double fraction = peasants * peasant_growth_factor(); int births = RAND_ROUND(fraction); @@ -812,6 +812,8 @@ void demographics(void) static int last_weeks_season = -1; static int current_season = -1; int plant_rules = config_get_int("rules.grow.formula", 2); + int horse_rules = config_get_int("rules.horses.growth", 1); + int peasant_rules = config_get_int("rules.peasants.growth", 1); const struct building_type *bt_harbour = bt_find("harbour"); if (current_season < 0) { @@ -843,7 +845,8 @@ void demographics(void) * und gewandert sind */ calculate_emigration(r); - peasants(r); + peasants(r, peasant_rules); + if (r->age > 20) { double mwp = MAX(region_maxworkers(r), 1); double prob = @@ -854,7 +857,9 @@ void demographics(void) plagues(r); } } - horses(r); + if (horse_rules > 0) { + horses(r); + } if (plant_rules == 2) { /* E2 */ growing_trees(r, current_season, last_weeks_season); growing_herbs(r, current_season, last_weeks_season); From af28da365da44af452b50cf8790575e0483482bf Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Mar 2017 18:53:39 +0100 Subject: [PATCH 636/675] test giving silber to peasants. --- scripts/tests/common.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index fa2fd9f35..c3e2472c4 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -1044,3 +1044,18 @@ function test_give_horses() assert_equal(5, u:get_item("dolphin")) assert_equal(10, u:get_item("horse")) end + +function test_give_silver() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + + r:set_resource("peasant", 0) + r:set_resource("money", 11) + u:clear_orders() + u:add_item("money", 20) + u:add_order("GIB 0 10 SILBER") + process_orders() + assert_equal(21, r:get_resource("money")) + assert_equal(10, u:get_item("money")) +end From d976ee6f67663c1f0d92bbee458ee8cae009f647 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Mar 2017 19:17:20 +0100 Subject: [PATCH 637/675] special cases, not callbacks, for money and horses. --- res/core/common/items.xml | 4 +-- res/core/resources/horse.xml | 3 +- res/e3a/items.xml | 3 +- scripts/tests/common.lua | 8 ++--- src/give.c | 57 +++++++++++++++++++++++++++++++----- src/kernel/item.c | 43 --------------------------- src/kernel/item.h | 2 -- src/kernel/item.test.c | 1 - src/kernel/xmlreader.c | 7 +---- 9 files changed, 57 insertions(+), 71 deletions(-) diff --git a/res/core/common/items.xml b/res/core/common/items.xml index 8f2bbabf8..35f9af2c5 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -70,9 +70,7 @@ - - - + diff --git a/res/core/resources/horse.xml b/res/core/resources/horse.xml index 243b547db..608fca20a 100644 --- a/res/core/resources/horse.xml +++ b/res/core/resources/horse.xml @@ -1,7 +1,6 @@ - - + diff --git a/res/e3a/items.xml b/res/e3a/items.xml index 9e928837e..0399043e5 100644 --- a/res/e3a/items.xml +++ b/res/e3a/items.xml @@ -62,13 +62,12 @@ - + - diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index c3e2472c4..4f6ed9cbb 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -1035,14 +1035,14 @@ function test_give_horses() local u = unit.create(f, r, 1) r:set_resource("horse", 0) - u:add_item("horse", 20) + u:add_item("horse", 21) u:add_item("dolphin", 10) - u:add_order("GIB 0 10 PFERD") + u:add_order("GIB 0 7 PFERD") u:add_order("GIB 0 5 DELPHIN") process_orders() - assert_equal(10, r:get_resource("horse")) + assert_equal(7, r:get_resource("horse")) assert_equal(5, u:get_item("dolphin")) - assert_equal(10, u:get_item("horse")) + assert_equal(14, u:get_item("horse")) end function test_give_silver() diff --git a/src/give.c b/src/give.c index 5abb950a6..884c55283 100644 --- a/src/give.c +++ b/src/give.c @@ -19,6 +19,7 @@ /* kernel includes */ #include +#include #include #include #include @@ -147,17 +148,45 @@ int give_quota(const unit * src, const unit * dst, const item_type * type, return n; } +static int +give_horses(unit * s, unit * d, const item_type * itype, int n, + struct order *ord) +{ + if (d == NULL) { + region *r = s->region; + if (r->land) { + rsethorses(r, rhorses(r) + n); + } + return 0; + } + return -1; /* use the mechanism */ +} + +static int +give_money(unit * s, unit * d, const item_type * itype, int n, + struct order *ord) +{ + if (d == NULL) { + region *r = s->region; + if (r->land) { + rsetmoney(r, rmoney(r) + n); + } + return 0; + } + return -1; /* use the mechanism */ +} + int give_item(int want, const item_type * itype, unit * src, unit * dest, struct order *ord) { short error = 0; - int n, r; + int n, delta; assert(itype != NULL); n = get_pooled(src, item2resource(itype), GET_SLACK | GET_POOLED_SLACK, want); n = MIN(want, n); - r = n; + delta = n; if (dest && src->faction != dest->faction && src->faction->age < GiveRestriction()) { if (ord != NULL) { @@ -178,18 +207,19 @@ struct order *ord) else if (itype->flags & ITF_CURSED) { error = 25; } - else if (itype->give == NULL || itype->give(src, dest, itype, n, ord) != 0) { + else { int use = use_pooled(src, item2resource(itype), GET_SLACK, n); + if (use < n) use += use_pooled(src, item2resource(itype), GET_POOLED_SLACK, n - use); if (dest) { - r = give_quota(src, dest, itype, n); - i_change(&dest->items, itype, r); + delta = give_quota(src, dest, itype, n); + i_change(&dest->items, itype, delta); #ifdef RESERVE_GIVE #ifdef RESERVE_DONATIONS - change_reservation(dest, itype, r); + change_reservation(dest, itype, delta); #else if (src->faction == dest->faction) { change_reservation(dest, item2resource(itype), r); @@ -199,14 +229,25 @@ struct order *ord) #if MUSEUM_MODULE && defined(TODO) /* TODO: use a trigger for the museum warden! */ if (a_find(dest->attribs, &at_warden)) { - warden_add_give(src, dest, itype, r); + warden_add_give(src, dest, itype, delta); } #endif handle_event(dest->attribs, "receive", src); } + else { + /* return horses to the region */ + if (itype->construction && itype->flags & ITF_ANIMAL) { + if (itype->construction->skill == SK_HORSE_TRAINING) { + give_horses(src, dest, itype, n, ord); + } + } + else if (itype->rtype == get_resourcetype(R_SILVER)) { + give_money(src, dest, itype, n, ord); + } + } handle_event(src->attribs, "give", dest); } - add_give(src, dest, n, r, item2resource(itype), ord, error); + add_give(src, dest, n, delta, item2resource(itype), ord, error); if (error) return -1; return 0; diff --git a/src/kernel/item.c b/src/kernel/item.c index 6bd97e6dd..1197e7ce5 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -565,46 +565,6 @@ item *i_new(const item_type * itype, int size) #include "region.h" -static int -give_horses(unit * s, unit * d, const item_type * itype, int n, -struct order *ord) -{ - if (d == NULL) { - int use = use_pooled(s, item2resource(itype), GET_SLACK, n); - region *r = s->region; - if (use < n) { - use += - use_pooled(s, item2resource(itype), GET_RESERVE | GET_POOLED_SLACK, - n - use); - } - if (r->land) { - rsethorses(r, rhorses(r) + use); - } - return 0; - } - return -1; /* use the mechanism */ -} - -static int -give_money(unit * s, unit * d, const item_type * itype, int n, -struct order *ord) -{ - if (d == NULL) { - int use = use_pooled(s, item2resource(itype), GET_SLACK, n); - region *r = s->region; - if (use < n) { - use += - use_pooled(s, item2resource(itype), GET_RESERVE | GET_POOLED_SLACK, - n - use); - } - if (r->land) { - rsetmoney(r, rmoney(r) + use); - } - return 0; - } - return -1; /* use the mechanism */ -} - #define R_MINOTHER R_SILVER #define R_MINHERB R_PLAIN_1 #define R_MINPOTION R_FAST @@ -755,7 +715,6 @@ void init_resources(void) rtype->flags |= RTF_ITEM | RTF_POOLED; rtype->uchange = res_changeitem; rtype->itype = it_get_or_create(rtype); - rtype->itype->give = give_money; rtype = rt_get_or_create(resourcenames[R_PERMAURA]); rtype->uchange = res_changepermaura; @@ -1055,6 +1014,4 @@ void register_resources(void) register_function((pf_generic)res_changepermaura, "changepermaura"); register_function((pf_generic)res_changehp, "changehp"); register_function((pf_generic)res_changeaura, "changeaura"); - - register_item_give(give_horses, "givehorses"); } diff --git a/src/kernel/item.h b/src/kernel/item.h index d38a21340..5f8d879f9 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -128,8 +128,6 @@ extern "C" { /* --- functions --- */ bool(*canuse) (const struct unit * user, const struct item_type * itype); - int(*give) (struct unit * src, struct unit * dest, - const struct item_type * itm, int number, struct order * ord); int score; } item_type; diff --git a/src/kernel/item.test.c b/src/kernel/item.test.c index 52e7d9917..e8b8d79e3 100644 --- a/src/kernel/item.test.c +++ b/src/kernel/item.test.c @@ -162,7 +162,6 @@ static void test_core_resources(CuTest *tc) { CuAssertPtrNotNull(tc, rtype = rt_find("money")); CuAssertPtrNotNull(tc, rtype->itype); CuAssertPtrNotNull(tc, rtype->uchange); - CuAssertPtrNotNull(tc, rtype->itype->give); CuAssertPtrNotNull(tc, rtype = rt_find("peasant")); CuAssertPtrEquals(tc, 0, rtype->itype); CuAssertPtrNotNull(tc, rtype = rt_find("person")); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index d6397edf5..edbaa37f4 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -873,12 +873,7 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) continue; } assert(propValue != NULL); - if (strcmp((const char *)propValue, "give") == 0) { - itype->give = - (int(*)(struct unit *, struct unit *, const struct item_type *, int, - struct order *))fun; - } - else if (strcmp((const char *)propValue, "canuse") == 0) { + if (strcmp((const char *)propValue, "canuse") == 0) { itype->canuse = (bool(*)(const struct unit *, const struct item_type *))fun; } From d9d542cfeebf4019f95761c0f7713a83724b1250 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Mar 2017 19:19:33 +0100 Subject: [PATCH 638/675] we only call these when target is 0, anyway. --- src/give.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/give.c b/src/give.c index 884c55283..5cd19710e 100644 --- a/src/give.c +++ b/src/give.c @@ -148,32 +148,22 @@ int give_quota(const unit * src, const unit * dst, const item_type * type, return n; } -static int -give_horses(unit * s, unit * d, const item_type * itype, int n, - struct order *ord) +static void +give_horses(unit * s, const item_type * itype, int n) { - if (d == NULL) { - region *r = s->region; - if (r->land) { - rsethorses(r, rhorses(r) + n); - } - return 0; + region *r = s->region; + if (r->land) { + rsethorses(r, rhorses(r) + n); } - return -1; /* use the mechanism */ } -static int -give_money(unit * s, unit * d, const item_type * itype, int n, - struct order *ord) +static void +give_money(unit * s, const item_type * itype, int n) { - if (d == NULL) { - region *r = s->region; - if (r->land) { - rsetmoney(r, rmoney(r) + n); - } - return 0; + region *r = s->region; + if (r->land) { + rsetmoney(r, rmoney(r) + n); } - return -1; /* use the mechanism */ } int @@ -238,11 +228,11 @@ struct order *ord) /* return horses to the region */ if (itype->construction && itype->flags & ITF_ANIMAL) { if (itype->construction->skill == SK_HORSE_TRAINING) { - give_horses(src, dest, itype, n, ord); + give_horses(src, itype, n); } } else if (itype->rtype == get_resourcetype(R_SILVER)) { - give_money(src, dest, itype, n, ord); + give_money(src, itype, n); } } handle_event(src->attribs, "give", dest); From 50bdc71c1b9f359dc2b8bbbfb5d0840be4e05c06 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 4 Mar 2017 17:27:13 +0100 Subject: [PATCH 639/675] kill lua_canuse_item and itype->canuse --- res/core/armor/plate.xml | 1 - res/core/weapons/axe.xml | 1 - res/core/weapons/greatbow.xml | 3 +-- res/core/weapons/greatsword.xml | 1 - res/core/weapons/halberd.xml | 1 - res/core/weapons/lance.xml | 1 - res/core/weapons/mallornlance.xml | 1 - res/core/weapons/rep_crossbow.xml | 16 ---------------- res/core/weapons/rustyaxe.xml | 1 - res/core/weapons/rustyhalberd.xml | 1 - res/e3a/armor/plate.xml | 1 - res/e3a/armor/scale.xml | 1 - res/e3a/armor/towershield.xml | 1 - res/e3a/weapons/axe.xml | 1 - res/e3a/weapons/greatbow.xml | 1 - res/e3a/weapons/halberd.xml | 1 - res/e3a/weapons/lance.xml | 1 - res/e3a/weapons/mallornlance.xml | 1 - res/e3a/weapons/rustyhalberd.xml | 1 - scripts/eressea/e3/rules.lua | 28 ---------------------------- scripts/eressea/resources.lua | 7 ------- src/battle.c | 12 +----------- src/helpers.c | 30 ------------------------------ src/kernel/item.h | 3 --- src/kernel/xmlreader.c | 8 +------- 25 files changed, 3 insertions(+), 121 deletions(-) delete mode 100644 res/core/weapons/rep_crossbow.xml diff --git a/res/core/armor/plate.xml b/res/core/armor/plate.xml index a22064e90..97d855a73 100644 --- a/res/core/armor/plate.xml +++ b/res/core/armor/plate.xml @@ -1,7 +1,6 @@ - diff --git a/res/core/weapons/axe.xml b/res/core/weapons/axe.xml index 80a872ad7..3f97a5b8a 100644 --- a/res/core/weapons/axe.xml +++ b/res/core/weapons/axe.xml @@ -1,7 +1,6 @@ - diff --git a/res/core/weapons/greatbow.xml b/res/core/weapons/greatbow.xml index 14734a129..32f07a41e 100644 --- a/res/core/weapons/greatbow.xml +++ b/res/core/weapons/greatbow.xml @@ -1,7 +1,6 @@ - - + diff --git a/res/core/weapons/greatsword.xml b/res/core/weapons/greatsword.xml index cd48b8296..56285f6af 100644 --- a/res/core/weapons/greatsword.xml +++ b/res/core/weapons/greatsword.xml @@ -1,7 +1,6 @@ - diff --git a/res/core/weapons/halberd.xml b/res/core/weapons/halberd.xml index 5025f4793..7abc86902 100644 --- a/res/core/weapons/halberd.xml +++ b/res/core/weapons/halberd.xml @@ -1,7 +1,6 @@ - diff --git a/res/core/weapons/lance.xml b/res/core/weapons/lance.xml index abbb7f31f..4a02bc06f 100644 --- a/res/core/weapons/lance.xml +++ b/res/core/weapons/lance.xml @@ -1,7 +1,6 @@ - diff --git a/res/core/weapons/mallornlance.xml b/res/core/weapons/mallornlance.xml index 0186143e4..c67390d52 100644 --- a/res/core/weapons/mallornlance.xml +++ b/res/core/weapons/mallornlance.xml @@ -1,7 +1,6 @@ - diff --git a/res/core/weapons/rep_crossbow.xml b/res/core/weapons/rep_crossbow.xml deleted file mode 100644 index d6f869046..000000000 --- a/res/core/weapons/rep_crossbow.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/res/core/weapons/rustyaxe.xml b/res/core/weapons/rustyaxe.xml index 2ff19570c..fea6b8642 100644 --- a/res/core/weapons/rustyaxe.xml +++ b/res/core/weapons/rustyaxe.xml @@ -1,7 +1,6 @@ - diff --git a/res/core/weapons/rustyhalberd.xml b/res/core/weapons/rustyhalberd.xml index c1b1f69a9..3f0bd93b7 100644 --- a/res/core/weapons/rustyhalberd.xml +++ b/res/core/weapons/rustyhalberd.xml @@ -1,7 +1,6 @@ - diff --git a/res/e3a/armor/plate.xml b/res/e3a/armor/plate.xml index 9aeafc3c1..79391fbcb 100644 --- a/res/e3a/armor/plate.xml +++ b/res/e3a/armor/plate.xml @@ -1,7 +1,6 @@ - diff --git a/res/e3a/armor/scale.xml b/res/e3a/armor/scale.xml index 691ce5ba7..1038f4d6c 100644 --- a/res/e3a/armor/scale.xml +++ b/res/e3a/armor/scale.xml @@ -1,7 +1,6 @@ - diff --git a/res/e3a/armor/towershield.xml b/res/e3a/armor/towershield.xml index 78e113e2a..38e4f0928 100644 --- a/res/e3a/armor/towershield.xml +++ b/res/e3a/armor/towershield.xml @@ -1,7 +1,6 @@ - diff --git a/res/e3a/weapons/axe.xml b/res/e3a/weapons/axe.xml index 991a2b504..6066c4cfc 100644 --- a/res/e3a/weapons/axe.xml +++ b/res/e3a/weapons/axe.xml @@ -1,7 +1,6 @@ - diff --git a/res/e3a/weapons/greatbow.xml b/res/e3a/weapons/greatbow.xml index b488a011c..745d1793d 100644 --- a/res/e3a/weapons/greatbow.xml +++ b/res/e3a/weapons/greatbow.xml @@ -5,7 +5,6 @@ --> - diff --git a/res/e3a/weapons/halberd.xml b/res/e3a/weapons/halberd.xml index c07cbfd4d..c22e020b4 100644 --- a/res/e3a/weapons/halberd.xml +++ b/res/e3a/weapons/halberd.xml @@ -4,7 +4,6 @@ --> - diff --git a/res/e3a/weapons/lance.xml b/res/e3a/weapons/lance.xml index a3f641833..285862484 100644 --- a/res/e3a/weapons/lance.xml +++ b/res/e3a/weapons/lance.xml @@ -1,7 +1,6 @@ - diff --git a/res/e3a/weapons/mallornlance.xml b/res/e3a/weapons/mallornlance.xml index d2aacaea7..8eb25ceb4 100644 --- a/res/e3a/weapons/mallornlance.xml +++ b/res/e3a/weapons/mallornlance.xml @@ -1,7 +1,6 @@ - diff --git a/res/e3a/weapons/rustyhalberd.xml b/res/e3a/weapons/rustyhalberd.xml index 32c0d4497..a53aec515 100644 --- a/res/e3a/weapons/rustyhalberd.xml +++ b/res/e3a/weapons/rustyhalberd.xml @@ -4,7 +4,6 @@ --> - diff --git a/scripts/eressea/e3/rules.lua b/scripts/eressea/e3/rules.lua index c0ac8978a..e7a54ff41 100644 --- a/scripts/eressea/e3/rules.lua +++ b/scripts/eressea/e3/rules.lua @@ -1,31 +1,3 @@ --- when appending to this, make sure the item has a canuse-function! -local goblin_denied = " plate lance mallornlance greatbow axe greatsword halberd rustyaxe rustyhalberd towershield scale " -function item_canuse(u, iname) - local race = u.race - if race=="goblin" then - if string.find(goblin_denied, " " .. iname .. " ") then - return false - end - end - if iname=="rep_crossbow" then - -- only dwarves and halflings allowed to use repeating crossbow - return race=="dwarf" or race=="halfling" - end - if iname=="scale" then - -- only dwarves and halflings can use scale - return race=="dwarf" or race=="halfling" - end - if iname=="towershield" then - -- only dwarves allowed to use towershield - return race=="dwarf" - end - if iname=="greatbow" then - -- only elves use greatbow - return race=="elf" - end - return true -end - function building_taxes(b, blevel) btype = b.type if btype=="castle" then diff --git a/scripts/eressea/resources.lua b/scripts/eressea/resources.lua index 2829d00c7..588620aa4 100644 --- a/scripts/eressea/resources.lua +++ b/scripts/eressea/resources.lua @@ -1,12 +1,5 @@ -- global functions used in items.xml -if not item_canuse then - -- define a default, everyone can use everything - function item_canuse(u, iname) - return true - end -end - function peasant_getresource(u) return u.region:get_resource("peasant") end diff --git a/src/battle.c b/src/battle.c index fa5725c50..e8eb426e3 100644 --- a/src/battle.c +++ b/src/battle.c @@ -576,17 +576,7 @@ static weapon *select_weapon(const troop t, bool attacking, static bool i_canuse(const unit * u, const item_type * itype) { - bool result = true; - if (itype->canuse) { - result = itype->canuse(u, itype); - } - if (result!=rc_can_use(u_race(u), itype)) { - log_error("conversion error: %s should be %s to use %s", - u->_race->_name, - result ? "allowed" : "forbidden", - itype->rtype->_name); - } - return result; + return rc_can_use(u_race(u), itype); } static int diff --git a/src/helpers.c b/src/helpers.c index e8e6521c4..a4746461b 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -320,34 +320,6 @@ static int lua_getresource(unit * u, const struct resource_type *rtype) return result; } -static bool lua_canuse_item(const unit * u, const struct item_type *itype) -{ - bool result = true; - lua_State *L = (lua_State *)global.vm_state; - const char *fname = "item_canuse"; - - lua_getglobal(L, fname); - if (lua_isfunction(L, -1)) { - tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit"); - tolua_pushstring(L, itype->rtype->_name); - - if (lua_pcall(L, 2, 1, 0) != 0) { - const char *error = lua_tostring(L, -1); - log_error("use(%s) calling '%s': %s.\n", unitname(u), fname, error); - lua_pop(L, 1); - } - else { - result = lua_toboolean(L, -1); - lua_pop(L, 1); - } - } - else { - log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname); - lua_pop(L, 1); - } - return result; -} - static int lua_wage(const region * r, const faction * f, const race * rc, int in_turn) { @@ -563,8 +535,6 @@ void register_tolua_helpers(void) TOLUA_CAST "lua_initfamiliar"); register_function((pf_generic)lua_getresource, TOLUA_CAST "lua_getresource"); - register_function((pf_generic)lua_canuse_item, - TOLUA_CAST "lua_canuse_item"); register_function((pf_generic)lua_changeresource, TOLUA_CAST "lua_changeresource"); register_function((pf_generic)lua_equipmentcallback, diff --git a/src/kernel/item.h b/src/kernel/item.h index 5f8d879f9..dda0cf3e4 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -125,9 +125,6 @@ extern "C" { int mask_deny; struct construction *construction; char *_appearance[2]; /* wie es f�r andere aussieht */ - /* --- functions --- */ - bool(*canuse) (const struct unit * user, - const struct item_type * itype); int score; } item_type; diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index edbaa37f4..aabab91d6 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -873,13 +873,7 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) continue; } assert(propValue != NULL); - if (strcmp((const char *)propValue, "canuse") == 0) { - itype->canuse = - (bool(*)(const struct unit *, const struct item_type *))fun; - } - else { - log_error("unknown function type '%s' for item '%s'\n", (const char *)propValue, rtype->_name); - } + log_error("unknown function type '%s' for item '%s'\n", (const char *)propValue, rtype->_name); xmlFree(propValue); } itype->score = xml_ivalue(node, "score", 0); From acfb6665390df3a85ad17eb803717d5d31b26421 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 4 Mar 2017 20:59:43 +0100 Subject: [PATCH 640/675] remove rtype->uget funpointer, and lua callbacks. fix a missing lua_pop that trashed the heap. --- res/core/resources/hp.xml | 1 - res/core/resources/peasant.xml | 1 - res/e3a/weapons.xml | 2 +- res/e3a/weapons/rep_crossbow.xml | 15 +++++++++++++++ scripts/eressea/resources.lua | 8 -------- src/helpers.c | 2 +- src/kernel/item.h | 3 --- src/kernel/pool.c | 14 ++++++-------- src/kernel/region.c | 3 +++ src/kernel/save.c | 2 ++ src/kernel/xmlreader.c | 3 --- 11 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 res/e3a/weapons/rep_crossbow.xml diff --git a/res/core/resources/hp.xml b/res/core/resources/hp.xml index fb1b6e32f..aa0ad4d29 100644 --- a/res/core/resources/hp.xml +++ b/res/core/resources/hp.xml @@ -1,5 +1,4 @@ - diff --git a/res/core/resources/peasant.xml b/res/core/resources/peasant.xml index 32e1e1ca1..bce23430c 100644 --- a/res/core/resources/peasant.xml +++ b/res/core/resources/peasant.xml @@ -1,5 +1,4 @@ - diff --git a/res/e3a/weapons.xml b/res/e3a/weapons.xml index 96a987b28..fdc8f1f3a 100644 --- a/res/e3a/weapons.xml +++ b/res/e3a/weapons.xml @@ -4,13 +4,13 @@ - + diff --git a/res/e3a/weapons/rep_crossbow.xml b/res/e3a/weapons/rep_crossbow.xml new file mode 100644 index 000000000..02f0d865f --- /dev/null +++ b/res/e3a/weapons/rep_crossbow.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/scripts/eressea/resources.lua b/scripts/eressea/resources.lua index 588620aa4..fa6e1c4da 100644 --- a/scripts/eressea/resources.lua +++ b/scripts/eressea/resources.lua @@ -1,9 +1,5 @@ -- global functions used in items.xml -function peasant_getresource(u) - return u.region:get_resource("peasant") -end - function peasant_changeresource(u, delta) local p = u.region:get_resource("peasant") p = p + delta @@ -14,10 +10,6 @@ function peasant_changeresource(u, delta) return p end -function hp_getresource(u) - return u.hp -end - function hp_changeresource(u, delta) local hp = u.hp + delta diff --git a/src/helpers.c b/src/helpers.c index a4746461b..402ecdd48 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -496,13 +496,13 @@ use_item_lua(unit *u, const item_type *itype, int amount, struct order *ord) } return result; } + lua_pop(L, 1); if (itype->rtype->ptype) { return use_potion(u, itype, amount, ord); } else { log_error("no such callout: %s", fname); } log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname); - lua_pop(L, 1); return result; } diff --git a/src/kernel/item.h b/src/kernel/item.h index dda0cf3e4..77fe1a9c2 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -68,8 +68,6 @@ extern "C" { typedef int(*rtype_uchange) (struct unit * user, const struct resource_type * rtype, int delta); - typedef int(*rtype_uget) (const struct unit * user, - const struct resource_type * rtype); typedef char *(*rtype_name) (const struct resource_type * rtype, int flags); typedef struct resource_type { /* --- constants --- */ @@ -77,7 +75,6 @@ extern "C" { unsigned int flags; /* --- functions --- */ rtype_uchange uchange; - rtype_uget uget; rtype_name name; struct rawmaterial_type *raw; struct resource_mod *modifiers; diff --git a/src/kernel/pool.c b/src/kernel/pool.c index 702f86e0f..8dfd589c3 100644 --- a/src/kernel/pool.c +++ b/src/kernel/pool.c @@ -40,11 +40,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. int get_resource(const unit * u, const resource_type * rtype) { assert(rtype); - if (rtype->uget) { - /* this resource is probably special */ - int i = rtype->uget(u, rtype); - if (i >= 0) - return i; + if (rtype == get_resourcetype(R_PEASANT)) { + return u->region->land ? u->region->land->peasants : 0; + } + else if (rtype == rt_find("hp")) { + return u->hp; } else if (rtype->uchange) { /* this resource is probably special */ @@ -176,7 +176,7 @@ int count) } if (rtype->flags & RTF_POOLED && mode & ~(GET_SLACK | GET_RESERVE)) { for (v = r->units; v && use < count; v = v->next) - if (u != v && (v->items || rtype->uget)) { + if (u != v) { int mask; if ((u_race(v)->ec_flags & ECF_KEEP_ITEM)) @@ -234,8 +234,6 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count) int mask; if ((u_race(v)->ec_flags & ECF_KEEP_ITEM)) continue; - if (v->items == NULL && rtype->uget == NULL) - continue; if (v->faction == f) { mask = (mode >> 3) & (GET_SLACK | GET_RESERVE); diff --git a/src/kernel/region.c b/src/kernel/region.c index aefffa875..e4f33db33 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -38,6 +38,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "unit.h" /* util includes */ +#include #include #include #include @@ -697,6 +698,7 @@ void r_setdemand(region * r, const luxury_type * ltype, int value) d = *dp; if (!d) { d = *dp = malloc(sizeof(struct demand)); + assert_alloc(d); d->next = NULL; d->type = ltype; } @@ -768,6 +770,7 @@ region *new_region(int x, int y, struct plane *pl, int uid) return r; } r = calloc(1, sizeof(region)); + assert_alloc(r); r->x = x; r->y = y; r->uid = uid; diff --git a/src/kernel/save.c b/src/kernel/save.c index 8316121f3..e487737f9 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -52,6 +52,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include /* util includes */ +#include #include #include #include @@ -646,6 +647,7 @@ unit *read_unit(struct gamedata *data) } else { u = calloc(sizeof(unit), 1); + assert_alloc(u); u->no = n; uhash(u); } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index aabab91d6..4db528853 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -972,9 +972,6 @@ static int parse_resources(xmlDocPtr doc) if (strcmp((const char *)propValue, "change") == 0) { rtype->uchange = (rtype_uchange)fun; } - else if (strcmp((const char *)propValue, "get") == 0) { - rtype->uget = (rtype_uget)fun; - } else if (strcmp((const char *)propValue, "name") == 0) { rtype->name = (rtype_name)fun; } From caa8159428ef17f0b2d0b668a0d00ada291b6c32 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 09:52:17 +0100 Subject: [PATCH 641/675] eliminate duplicate string definition --- res/core/de/strings.xml | 9 --------- src/report.c | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 26e8cc862..5dc649aa1 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -6570,15 +6570,6 @@ - - Baum - tree - - - Bäume - trees - - Mallornbaum mallorn tree diff --git a/src/report.c b/src/report.c index cf00abbc3..6af46ba07 100644 --- a/src/report.c +++ b/src/report.c @@ -987,10 +987,10 @@ static void describe(struct stream *out, const region * r, faction * f) } } else if (trees == 1) { - bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_tree"), size); + bytes = (int)strlcpy(bufp, LOC(f->locale, "tree"), size); } else { - bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_tree_p"), size); + bytes = (int)strlcpy(bufp, LOC(f->locale, "tree_p"), size); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); From 614978a3433bf9250212b705784ca3996977ee58 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 10:26:39 +0100 Subject: [PATCH 642/675] add a breaking test for the CR. trees and peasants are not reported correctly. --- tests/write-reports.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/write-reports.sh b/tests/write-reports.sh index 2183b17dd..6581066f0 100755 --- a/tests/write-reports.sh +++ b/tests/write-reports.sh @@ -16,10 +16,10 @@ while [ ! -d $ROOT/.git ]; do ROOT=`dirname $ROOT` done -set -e +#set -e cd $ROOT/tests setup -cleanup +#cleanup VALGRIND=`which valgrind` TESTS=../Debug/eressea/test_eressea SERVER=../Debug/eressea/eressea @@ -34,10 +34,14 @@ $VALGRIND $SERVER -t 184 ../scripts/reports.lua [ -d reports ] || quit 4 "no reports directory created" CRFILE=184-zvto.cr grep -q PARTEI reports/$CRFILE || quit 1 "CR did not contain any factions" +grep -q -E '"B.ume";type"' reports/$CRFILE || \ + quit 1 "CR did not contain trees" +grep -q '"Bauern";type"' reports/$CRFILE || \ + quit 1 "CR did not contain peasants" grep -q REGION reports/$CRFILE || quit 2 "CR did not contain any regions" grep -q SCHIFF reports/$CRFILE || quit 3 "CR did not contain any ships" grep -q BURG reports/$CRFILE || quit 4 "CR did not contain any buildings" grep -q EINHEIT reports/$CRFILE || quit 5 "CR did not contain any units" grep -q GEGENSTAENDE reports/$CRFILE || quit 6 "CR did not contain any items" echo "integration tests: PASS" -cleanup +#cleanup From 5675ef6091ffc7bb08a1cfff25e9c0f07595d9ed Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 11:10:59 +0100 Subject: [PATCH 643/675] clean and extend the enum of resources. --- src/economy.c | 6 +++--- src/kernel/item.c | 22 +++++++++++++--------- src/kernel/item.h | 27 +++++++++++++++++++-------- src/modules/arena.c | 2 +- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/economy.c b/src/economy.c index a3b300788..248344e47 100644 --- a/src/economy.c +++ b/src/economy.c @@ -2130,7 +2130,7 @@ static void planttrees(unit * u, int raw) } /* Mallornb�ume kann man nur in Mallornregionen z�chten */ - rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORNSEED : R_SEED); + rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORN_SEED : R_SEED); /* Skill pr�fen */ skill = effskill(u, SK_HERBALISM, 0); @@ -2195,7 +2195,7 @@ static void breedtrees(unit * u, int raw) } /* Mallornb�ume kann man nur in Mallornregionen z�chten */ - rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORNSEED : R_SEED); + rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORN_SEED : R_SEED); /* Skill pr�fen */ skill = effskill(u, SK_HERBALISM, 0); @@ -2313,7 +2313,7 @@ static void breed_cmd(unit * u, struct order *ord) default: if (p != P_ANY) { rtype = findresourcetype(s, u->faction->locale); - if (rtype == get_resourcetype(R_SEED) || rtype == get_resourcetype(R_MALLORNSEED)) { + if (rtype == get_resourcetype(R_SEED) || rtype == get_resourcetype(R_MALLORN_SEED)) { breedtrees(u, m); break; } diff --git a/src/kernel/item.c b/src/kernel/item.c index 6e64c147f..58e3326a2 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -614,25 +614,24 @@ struct order *ord) #define R_MINHERB R_PLAIN_1 #define R_MINPOTION R_FAST #define R_MINITEM R_IRON -#define MAXITEMS MAX_ITEMS -#define MAXRESOURCES MAX_RESOURCES -#define MAXHERBS MAX_HERBS -#define MAXPOTIONS MAX_POTIONS #define MAXHERBSPERPOTION 6 -const potion_type *oldpotiontype[MAXPOTIONS + 1]; +const potion_type *oldpotiontype[MAX_POTIONS + 1]; /*** alte items ***/ static const char *resourcenames[MAX_RESOURCES] = { + "money", "aura", "permaura", + "hp", "peasant", "person", + "sapling", "mallornsapling", + "tree", "mallorntree", + "seed", "mallornseed", "iron", "stone", "horse", "ao_healing", "aots", "roi", "rop", "ao_chastity", "laen", "fairyboot", "aoc", "pegasus", "elvenhorse", "charger", "dolphin", "roqf", "trollbelt", "aurafocus", "sphereofinv", "magicbag", - "magicherbbag", "dreameye", "p2", "seed", "mallornseed", - "money", "aura", "permaura", - "hp", "peasant", "person" + "magicherbbag", "dreameye", "p2" }; const resource_type *get_resourcetype(resource_t type) { @@ -966,7 +965,7 @@ static void init_oldpotions(void) }; int p; - for (p = 0; p != MAXPOTIONS; ++p) { + for (p = 0; p != MAX_POTIONS; ++p) { item_type *itype = it_find(potionnames[p]); if (itype != NULL) { oldpotiontype[p] = itype->rtype->ptype; @@ -978,6 +977,11 @@ void init_resources(void) { resource_type *rtype; + /* there are resources that are special and must be hard-coded. + * these are not items, but things like trees or hitpoints + * which can be used in a construction recipe or as a spell ingredient. + */ + rt_get_or_create(resourcenames[R_PERSON]); /* lousy hack */ rtype = rt_get_or_create(resourcenames[R_PEASANT]); diff --git a/src/kernel/item.h b/src/kernel/item.h index c1ac38517..c08c676be 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -252,8 +252,27 @@ extern "C" { variant magres, int prot, unsigned int flags); potion_type *new_potiontype(item_type * itype, int level); + + /* these constants are used with get_resourcetype. + * The order of the enum is not important for stored data. + * The resourcenames array must be updated to match. + */ + typedef enum { + /* SPECIAL */ + R_SILVER, + R_AURA, /* Aura */ + R_PERMAURA, /* Permanente Aura */ + R_LIFE, + R_PEASANT, + R_PERSON, + R_SAPLING, + R_MALLORN_SAPLING, + R_TREE, + R_MALLORN_TREE, /* ITEMS: */ + R_SEED, + R_MALLORN_SEED, R_IRON, R_STONE, R_HORSE, @@ -277,15 +296,7 @@ extern "C" { R_SACK_OF_CONSERVATION, R_TACTICCRYSTAL, R_WATER_OF_LIFE, - R_SEED, - R_MALLORNSEED, /* SONSTIGE */ - R_SILVER, - R_AURA, /* Aura */ - R_PERMAURA, /* Permanente Aura */ - R_LIFE, - R_PEASANT, - R_PERSON, MAX_RESOURCES, /* do not use outside item.c ! */ NORESOURCE = -1 diff --git a/src/modules/arena.c b/src/modules/arena.c index fbc3f0673..aada12234 100644 --- a/src/modules/arena.c +++ b/src/modules/arena.c @@ -149,7 +149,7 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord) assert(!"not implemented"); /* - for (res=0;res!=MAXRESOURCES;++res) if (res!=R_SILVER && res!=R_ARENA_GATE && (is_item(res) || is_herb(res) || is_potion(res))) { + for (res=0;res!=MAX_RESOURCES;++res) if (res!=R_SILVER && res!=R_ARENA_GATE && (is_item(res) || is_herb(res) || is_potion(res))) { int x = get_resource(u, res); if (x) { if (u2) { From ae6a4ca3392ee3ebbd6e80774de538a4a8dc322d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 11:42:11 +0100 Subject: [PATCH 644/675] new clibs submodule --- clibs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clibs b/clibs index b91413316..d286006a2 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit b91413316ce13044c555084a9f605983586107b4 +Subproject commit d286006a28c8aa7cd70ed7fd4cd172b50ade9727 From aa662e65d20bc80d819aff09dd3b01007473723d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 11:25:17 +0100 Subject: [PATCH 645/675] eliminate R_PERSON hack. --- res/core/messages.xml | 12 ++++++++++++ src/give.c | 24 +++++++++++++++++++++++- src/give.test.c | 2 ++ src/kernel/item.c | 4 +--- src/kernel/item.h | 1 - src/kernel/item.test.c | 2 -- 6 files changed, 38 insertions(+), 7 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index e312fcc7c..32d8e35a6 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -6882,6 +6882,7 @@ "$string" "$string" + @@ -6892,6 +6893,16 @@ "$unit($unit) transfers $int($amount) person$if($eq($amount,1),"","s") to $unit($target)." + + + + + + + "$unit($target) erhält $int($amount) Person$if($eq($amount,1),"","en") von $unit($unit)." + "$unit($target) receives $int($amount) person$if($eq($amount,1),"","s") from $unit($unit)." + + @@ -6913,6 +6924,7 @@ "$unit($target) erhält $int($amount) $resource($resource,$amount) von $unit($unit)." "$unit($target) receives $int($amount) $resource($resource,$amount) from $unit($unit)." + diff --git a/src/give.c b/src/give.c index 5abb950a6..eeb641665 100644 --- a/src/give.c +++ b/src/give.c @@ -121,6 +121,28 @@ const resource_type * rtype, struct order *ord, int error) } } +static void add_give_person(unit * u, unit * u2, int given, + struct order *ord, int error) +{ + assert(u2); + if (error) { + cmistake(u, ord, error, MSG_COMMERCE); + } + else if (u2->faction != u->faction) { + message *msg; + + msg = msg_message("give_person", "unit target resource amount", + u, u2, given); + add_message(&u->faction->msgs, msg); + msg_release(msg); + + msg = msg_message("receive_person", "unit target resource amount", + u, u2, given); + add_message(&u2->faction->msgs, msg); + msg_release(msg); + } +} + static bool limited_give(const item_type * type) { /* trade only money 2:1, if at all */ @@ -531,7 +553,7 @@ void give_unit(unit * u, unit * u2, order * ord) cmistake(u, ord, 156, MSG_COMMERCE); return; } - add_give(u, u2, u->number, u->number, get_resourcetype(R_PERSON), ord, 0); + add_give_person(u, u2, u->number, ord, 0); u_setfaction(u, u2->faction); u2->faction->newbies += u->number; } diff --git a/src/give.test.c b/src/give.test.c index fbb71cf3c..33f70fb90 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -83,6 +83,8 @@ static void test_give_unit(CuTest * tc) { CuAssertPtrEquals(tc, env.f2, env.src->faction); CuAssertIntEquals(tc, 1, env.f2->newbies); CuAssertPtrEquals(tc, 0, env.f1->units); + CuAssertPtrNotNull(tc, test_find_messagetype(env.f1->msgs, "give_person")); + CuAssertPtrNotNull(tc, test_find_messagetype(env.f2->msgs, "receive_person")); test_cleanup(); } diff --git a/src/kernel/item.c b/src/kernel/item.c index 58e3326a2..6c96cb0b0 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -622,7 +622,7 @@ const potion_type *oldpotiontype[MAX_POTIONS + 1]; static const char *resourcenames[MAX_RESOURCES] = { "money", "aura", "permaura", - "hp", "peasant", "person", + "hp", "peasant", "sapling", "mallornsapling", "tree", "mallorntree", "seed", "mallornseed", @@ -982,8 +982,6 @@ void init_resources(void) * which can be used in a construction recipe or as a spell ingredient. */ - rt_get_or_create(resourcenames[R_PERSON]); /* lousy hack */ - rtype = rt_get_or_create(resourcenames[R_PEASANT]); rtype->uchange = res_changepeasants; diff --git a/src/kernel/item.h b/src/kernel/item.h index c08c676be..bb114c8ac 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -265,7 +265,6 @@ extern "C" { R_PERMAURA, /* Permanente Aura */ R_LIFE, R_PEASANT, - R_PERSON, R_SAPLING, R_MALLORN_SAPLING, R_TREE, diff --git a/src/kernel/item.test.c b/src/kernel/item.test.c index 52e7d9917..c824d082a 100644 --- a/src/kernel/item.test.c +++ b/src/kernel/item.test.c @@ -165,8 +165,6 @@ static void test_core_resources(CuTest *tc) { CuAssertPtrNotNull(tc, rtype->itype->give); CuAssertPtrNotNull(tc, rtype = rt_find("peasant")); CuAssertPtrEquals(tc, 0, rtype->itype); - CuAssertPtrNotNull(tc, rtype = rt_find("person")); - CuAssertPtrEquals(tc, 0, rtype->itype); CuAssertPtrNotNull(tc, rtype = rt_find("permaura")); CuAssertPtrEquals(tc, 0, rtype->itype); CuAssertPtrNotNull(tc, rtype = rt_find("hp")); From 6a8762540970158af26dee391df74a1b13328cdd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 15:26:04 +0100 Subject: [PATCH 646/675] refactor cr_output_resources for easy testing. Write a (failing) test that checks first resource is silver. --- src/creport.c | 38 +++++++++++++++++++++++++------------- src/creport.h | 3 ++- src/creport.test.c | 27 +++++++++++++++++++++++++++ src/kernel/item.c | 10 +++++----- src/reports.c | 3 ++- 5 files changed, 61 insertions(+), 20 deletions(-) diff --git a/src/creport.c b/src/creport.c index 99a9ede97..aa4fd2f98 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1157,11 +1157,9 @@ cr_borders(const region * r, const faction * f, seen_mode mode, FILE * F) } } -static void -cr_output_resources(FILE * F, report_context * ctx, region *r, bool see_unit) +void cr_output_resources(stream *out, const faction * f, const region *r, bool see_unit) { char cbuf[BUFFERSIZE], *pos = cbuf; - faction *f = ctx->f; resource_report result[MAX_RAWMATERIALS]; int n, size = report_resources(r, result, MAX_RAWMATERIALS, f, see_unit); @@ -1169,15 +1167,18 @@ cr_output_resources(FILE * F, report_context * ctx, region *r, bool see_unit) int trees = rtrees(r, 2); int saplings = rtrees(r, 1); - if (trees > 0) - fprintf(F, "%d;Baeume\n", trees); - if (saplings > 0) - fprintf(F, "%d;Schoesslinge\n", saplings); - if (fval(r, RF_MALLORN) && (trees > 0 || saplings > 0)) - fprintf(F, "1;Mallorn\n"); + if (trees > 0) { + stream_printf(out, "%d;Baeume\n", trees); + } + if (saplings > 0) { + stream_printf(out, "%d;Schoesslinge\n", trees); + } + if (fval(r, RF_MALLORN) && (trees > 0 || saplings > 0)) { + sputs("1;Mallorn\n", out); + } for (n = 0; n < size; ++n) { if (result[n].level >= 0 && result[n].number >= 0) { - fprintf(F, "%d;%s\n", result[n].number, crtag(result[n].name)); + stream_printf(out, "%d;%s\n", result[n].number, crtag(result[n].name)); } } #endif @@ -1189,10 +1190,21 @@ cr_output_resources(FILE * F, report_context * ctx, region *r, bool see_unit) result[n].level); } } - if (pos != cbuf) - fputs(cbuf, F); + if (pos != cbuf) { + sputs(cbuf, out); + } } +static void cr_output_resources_compat(FILE *F, report_context * ctx, + region *r, bool see_unit) +{ + /* TODO: eliminate this function */ + stream strm; + fstream_init(&strm, F); + cr_output_resources(&strm, ctx->f, r, see_unit); +} + + static void cr_region_header(FILE * F, int plid, int nx, int ny, int uid) { @@ -1357,7 +1369,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r) /* this writes both some tags (RESOURCECOMPAT) and a block. * must not write any blocks before it */ - cr_output_resources(F, ctx, r, r->seen.mode >= seen_unit); + cr_output_resources_compat(F, ctx, r, r->seen.mode >= seen_unit); if (r->seen.mode >= seen_unit) { /* trade */ diff --git a/src/creport.h b/src/creport.h index fc2517859..435bb637f 100644 --- a/src/creport.h +++ b/src/creport.h @@ -29,7 +29,8 @@ extern "C" { int crwritemap(const char *filename); void cr_output_unit(struct stream *out, const struct region * r, const struct faction * f, const struct unit * u, seen_mode mode); - + void cr_output_resources(struct stream *out, const struct faction * f, + const struct region *r, bool see_unit); #ifdef __cplusplus } #endif diff --git a/src/creport.test.c b/src/creport.test.c index 14f40268c..254a73cbb 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -50,6 +50,32 @@ static void test_cr_unit(CuTest *tc) { test_cleanup(); } +static void test_cr_resources(CuTest *tc) { + stream strm; + char line[1024]; + faction *f; + region *r; + + test_cleanup(); + f = test_create_faction(0); + r = test_create_region(0, 0, 0); + r->land->horses = 100; + r->land->peasants = 200; + r->land->money = 300; + + mstream_init(&strm); + cr_output_resources(&strm, f, r, false); + strm.api->rewind(strm.handle); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "\"Silber\";type", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "300;number", line); + mstream_done(&strm); + test_cleanup(); +} + static int cr_get_int(stream *strm, const char *match, int def) { char line[1024]; @@ -111,6 +137,7 @@ CuSuite *get_creport_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_cr_unit); + SUITE_ADD_TEST(suite, test_cr_resources); SUITE_ADD_TEST(suite, test_cr_factionstealth); return suite; } diff --git a/src/kernel/item.c b/src/kernel/item.c index 6c96cb0b0..476387075 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -982,23 +982,23 @@ void init_resources(void) * which can be used in a construction recipe or as a spell ingredient. */ - rtype = rt_get_or_create(resourcenames[R_PEASANT]); - rtype->uchange = res_changepeasants; - rtype = rt_get_or_create(resourcenames[R_SILVER]); rtype->flags |= RTF_ITEM | RTF_POOLED; rtype->uchange = res_changeitem; rtype->itype = it_get_or_create(rtype); rtype->itype->give = give_money; + rtype = rt_get_or_create(resourcenames[R_AURA]); + rtype->uchange = res_changeaura; + rtype = rt_get_or_create(resourcenames[R_PERMAURA]); rtype->uchange = res_changepermaura; rtype = rt_get_or_create(resourcenames[R_LIFE]); rtype->uchange = res_changehp; - rtype = rt_get_or_create(resourcenames[R_AURA]); - rtype->uchange = res_changeaura; + rtype = rt_get_or_create(resourcenames[R_PEASANT]); + rtype->uchange = res_changepeasants; /* alte typen registrieren: */ init_oldpotions(); diff --git a/src/reports.c b/src/reports.c index a07b60f4b..74b800a90 100644 --- a/src/reports.c +++ b/src/reports.c @@ -2049,7 +2049,8 @@ static void log_orders(const struct message *msg) } } -int stream_printf(struct stream * out, const char *format, ...) { +int stream_printf(struct stream * out, const char *format, ...) +{ va_list args; int result; char buffer[4096]; From 83f170541b23ab2826280a31fd422f1f0725397a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 15:51:04 +0100 Subject: [PATCH 647/675] short unit-test for resources in the CR. now complains because Bauern!=Bauer. TODO: crtag is shit. --- src/creport.c | 12 ++++++----- src/creport.test.c | 52 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/creport.c b/src/creport.c index aa4fd2f98..c766ae872 100644 --- a/src/creport.c +++ b/src/creport.c @@ -91,10 +91,11 @@ bool opt_cr_absolute_coords = false; #ifdef TAG_LOCALE static const char *crtag(const char *key) { - static const struct locale *lang = NULL; - if (!lang) - lang = get_locale(TAG_LOCALE); - return LOC(lang, key); + /* TODO: those locale lookups are shit, but static kills testing */ + const char *result; + const struct locale *lang = get_locale(TAG_LOCALE); + result = LOC(lang, key); + return result; } #else #define crtag(x) (x) @@ -1096,6 +1097,7 @@ static void cr_reportspell(FILE * F, spell * sp, int level, const struct locale static char *cr_output_resource(char *buf, const char *name, const struct locale *loc, int amount, int level) { + assert(name); buf += sprintf(buf, "RESOURCE %u\n", hashstring(name)); buf += sprintf(buf, "\"%s\";type\n", translate(name, LOC(loc, name))); if (amount >= 0) { @@ -1171,7 +1173,7 @@ void cr_output_resources(stream *out, const faction * f, const region *r, bool s stream_printf(out, "%d;Baeume\n", trees); } if (saplings > 0) { - stream_printf(out, "%d;Schoesslinge\n", trees); + stream_printf(out, "%d;Schoesslinge\n", saplings); } if (fval(r, RF_MALLORN) && (trees > 0 || saplings > 0)) { sputs("1;Mallorn\n", out); diff --git a/src/creport.test.c b/src/creport.test.c index 254a73cbb..8819aab9b 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -55,23 +55,73 @@ static void test_cr_resources(CuTest *tc) { char line[1024]; faction *f; region *r; + struct locale *lang; + + test_setup(); + lang = get_or_create_locale("de"); /* CR tags are translated from this */ + locale_setstring(lang, "money", "Silber"); + locale_setstring(lang, "money_p", "Silber"); + locale_setstring(lang, "horse", "Pferd"); + locale_setstring(lang, "horse_p", "Pferde"); + locale_setstring(lang, "peasant", "Bauer"); + locale_setstring(lang, "peasant_p", "Bauern"); + locale_setstring(lang, "tree", "Baum"); + locale_setstring(lang, "tree_p", "B?ume"); + locale_setstring(lang, "sapling", "Schoessling"); + locale_setstring(lang, "sapling_p", "Schoesslinge"); - test_cleanup(); f = test_create_faction(0); r = test_create_region(0, 0, 0); r->land->horses = 100; r->land->peasants = 200; r->land->money = 300; + rsettrees(r, 0, 1); + rsettrees(r, 1, 2); + rsettrees(r, 2, 3); mstream_init(&strm); cr_output_resources(&strm, f, r, false); strm.api->rewind(strm.handle); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "3;Baeume", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "2;Schoesslinge", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, "\"Silber\";type", line); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, "300;number", line); + + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "\"Bauern\";type", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "200;number", line); + + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "\"Pferde\";type", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "300;number", line); + + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "\"Schoesslinge\";type", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "2;number", line); + + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "\"B?ume\";type", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "3;number", line); + mstream_done(&strm); test_cleanup(); } From 45862a06d04dbc2990c484e8951c9bdc457fb075 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 16:55:11 +0100 Subject: [PATCH 648/675] Add a good test for the NR. TODO: make it fail. --- src/creport.test.c | 6 ++--- src/kernel/item.c | 16 +++++------- src/kernel/item.test.c | 8 +++--- src/report.c | 20 ++++++++------- src/report.h | 3 ++- src/report.test.c | 58 +++++++++++++++++++++++++++++++++++++----- 6 files changed, 79 insertions(+), 32 deletions(-) diff --git a/src/creport.test.c b/src/creport.test.c index 8819aab9b..b329e2d22 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -65,8 +65,8 @@ static void test_cr_resources(CuTest *tc) { locale_setstring(lang, "horse_p", "Pferde"); locale_setstring(lang, "peasant", "Bauer"); locale_setstring(lang, "peasant_p", "Bauern"); - locale_setstring(lang, "tree", "Baum"); - locale_setstring(lang, "tree_p", "B?ume"); + locale_setstring(lang, "tree", "Blume"); + locale_setstring(lang, "tree_p", "Blumen"); locale_setstring(lang, "sapling", "Schoessling"); locale_setstring(lang, "sapling_p", "Schoesslinge"); @@ -118,7 +118,7 @@ static void test_cr_resources(CuTest *tc) { CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); - CuAssertStrEquals(tc, "\"B?ume\";type", line); + CuAssertStrEquals(tc, "\"Blumen\";type", line); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, "3;number", line); diff --git a/src/kernel/item.c b/src/kernel/item.c index 476387075..1fb90d456 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -610,12 +610,6 @@ struct order *ord) return -1; /* use the mechanism */ } -#define R_MINOTHER R_SILVER -#define R_MINHERB R_PLAIN_1 -#define R_MINPOTION R_FAST -#define R_MINITEM R_IRON -#define MAXHERBSPERPOTION 6 - const potion_type *oldpotiontype[MAX_POTIONS + 1]; /*** alte items ***/ @@ -982,21 +976,25 @@ void init_resources(void) * which can be used in a construction recipe or as a spell ingredient. */ + /* special resources needed in report_region */ rtype = rt_get_or_create(resourcenames[R_SILVER]); rtype->flags |= RTF_ITEM | RTF_POOLED; rtype->uchange = res_changeitem; rtype->itype = it_get_or_create(rtype); rtype->itype->give = give_money; + rtype = rt_get_or_create(resourcenames[R_HORSE]); + rtype->flags |= RTF_ITEM | RTF_LIMITED; + rtype->itype = it_get_or_create(rtype); + rtype->itype->flags |= ITF_ANIMAL | ITF_BIG; + + /* "special" spell components */ rtype = rt_get_or_create(resourcenames[R_AURA]); rtype->uchange = res_changeaura; - rtype = rt_get_or_create(resourcenames[R_PERMAURA]); rtype->uchange = res_changepermaura; - rtype = rt_get_or_create(resourcenames[R_LIFE]); rtype->uchange = res_changehp; - rtype = rt_get_or_create(resourcenames[R_PEASANT]); rtype->uchange = res_changepeasants; diff --git a/src/kernel/item.test.c b/src/kernel/item.test.c index c824d082a..6e3615797 100644 --- a/src/kernel/item.test.c +++ b/src/kernel/item.test.c @@ -117,14 +117,14 @@ void test_findresourcetype(CuTest * tc) test_setup(); lang = get_or_create_locale("de"); - locale_setstring(lang, "horse", "Pferd"); + locale_setstring(lang, "log", "Holz"); locale_setstring(lang, "peasant", "Bauer"); init_resources(); CuAssertPtrNotNull(tc, rt_find("peasant")); - CuAssertPtrEquals(tc, 0, rt_find("horse")); - itype = test_create_itemtype("horse"); + CuAssertPtrEquals(tc, 0, rt_find("log")); + itype = test_create_itemtype("log"); - CuAssertPtrEquals(tc, (void*)itype->rtype, (void*)findresourcetype("Pferd", lang)); + CuAssertPtrEquals(tc, (void*)itype->rtype, (void*)findresourcetype("Holz", lang)); CuAssertPtrEquals(tc, (void *)rt_find("peasant"), (void *)findresourcetype("Bauer", lang)); test_cleanup(); } diff --git a/src/report.c b/src/report.c index 6af46ba07..6e8d811bc 100644 --- a/src/report.c +++ b/src/report.c @@ -878,7 +878,7 @@ bool see_border(const connection * b, const faction * f, const region * r) return cs; } -static void describe(struct stream *out, const region * r, faction * f) +void report_region(struct stream *out, const region * r, faction * f) { int n; bool dh; @@ -1181,7 +1181,6 @@ static void describe(struct stream *out, const region * r, faction * f) dh = 1; } } - newline(out); *bufp = 0; paragraph(out, buf, 0, 0, 0); @@ -1999,7 +1998,7 @@ static void cb_write_travelthru(region *r, unit *u, void *cbdata) { } } -void write_travelthru(struct stream *out, region *r, const faction *f) +void report_travelthru(struct stream *out, region *r, const faction *f) { int maxtravel; char buf[8192]; @@ -2281,7 +2280,8 @@ report_plaintext(const char *filename, report_context * ctx, if (r->seen.mode == seen_unit) { anyunits = 1; - describe(out, r, f); + newline(out); + report_region(out, r, f); if (markets_module() && r->land) { const item_type *lux = r_luxury(r); const item_type *herb = r->land->herbtype; @@ -2308,20 +2308,22 @@ report_plaintext(const char *filename, report_context * ctx, } guards(out, r, f); newline(out); - write_travelthru(out, r, f); + report_travelthru(out, r, f); } else { if (r->seen.mode == seen_far) { - describe(out, r, f); + newline(out); + report_region(out, r, f); newline(out); guards(out, r, f); newline(out); - write_travelthru(out, r, f); + report_travelthru(out, r, f); } else { - describe(out, r, f); newline(out); - write_travelthru(out, r, f); + report_region(out, r, f); + newline(out); + report_travelthru(out, r, f); } } /* Statistik */ diff --git a/src/report.h b/src/report.h index 84a6c66d4..45c620562 100644 --- a/src/report.h +++ b/src/report.h @@ -27,7 +27,8 @@ extern "C" { void register_nr(void); void report_cleanup(void); void write_spaces(struct stream *out, size_t num); - void write_travelthru(struct stream *out, struct region * r, const struct faction * f); + void report_travelthru(struct stream *out, struct region * r, const struct faction * f); + void report_region(struct stream *out, const struct region * r, struct faction * f); void nr_spell_syntax(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang); void nr_spell(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang); diff --git a/src/report.test.c b/src/report.test.c index aa3c52695..5b1a8c058 100644 --- a/src/report.test.c +++ b/src/report.test.c @@ -56,7 +56,52 @@ static void test_write_many_spaces(CuTest *tc) { mstream_done(&out); } -static void test_write_travelthru(CuTest *tc) { +static void test_report_region(CuTest *tc) { + char buf[1024]; + region *r; + faction *f; + stream out = { 0 }; + size_t len; + struct locale *lang; + + test_setup(); + init_resources(); + lang = get_or_create_locale("de"); /* CR tags are translated from this */ + locale_setstring(lang, "money", "Silber"); + locale_setstring(lang, "money_p", "Silber"); + locale_setstring(lang, "horse", "Pferd"); + locale_setstring(lang, "horse_p", "Pferde"); + locale_setstring(lang, "peasant", "Bauer"); + locale_setstring(lang, "peasant_p", "Bauern"); + locale_setstring(lang, "tree", "Blume"); + locale_setstring(lang, "tree_p", "Blumen"); + locale_setstring(lang, "stone", "Stein"); + locale_setstring(lang, "stone_p", "Steine"); + locale_setstring(lang, "sapling", "Schoessling"); + locale_setstring(lang, "sapling_p", "Schoesslinge"); + locale_setstring(lang, "plain", "Ebene"); + + mstream_init(&out); + r = test_create_region(0, 0, 0); + r->land->peasants = 100; + r->land->horses = 200; + rsettrees(r, 0, 1); + rsettrees(r, 1, 2); + rsettrees(r, 2, 3); + region_setname(r, "Hodor"); + f = test_create_faction(0); + f->locale = lang; + + report_region(&out, r, f); + out.api->rewind(out.handle); + len = out.api->read(out.handle, buf, sizeof(buf)); + buf[len] = '\0'; + CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 3/2 Blumen, 100 Bauern, 200 Pferde.\n", buf); + mstream_done(&out); + test_cleanup(); +} + +static void test_report_travelthru(CuTest *tc) { stream out = { 0 }; char buf[1024]; size_t len; @@ -65,7 +110,7 @@ static void test_write_travelthru(CuTest *tc) { unit *u; struct locale *lang; - test_cleanup(); + test_setup(); lang = get_or_create_locale("de"); locale_setstring(lang, "travelthru_header", "Durchreise: "); mstream_init(&out); @@ -77,7 +122,7 @@ static void test_write_travelthru(CuTest *tc) { unit_setname(u, "Hodor"); unit_setid(u, 1); - write_travelthru(&out, r, f); + report_travelthru(&out, r, f); out.api->rewind(out.handle); len = out.api->read(out.handle, buf, sizeof(buf)); CuAssertIntEquals_Msg(tc, "no travelers, no report", 0, (int)len); @@ -85,7 +130,7 @@ static void test_write_travelthru(CuTest *tc) { mstream_init(&out); travelthru_add(r, u); - write_travelthru(&out, r, f); + report_travelthru(&out, r, f); out.api->rewind(out.handle); len = out.api->read(out.handle, buf, sizeof(buf)); buf[len] = '\0'; @@ -94,7 +139,7 @@ static void test_write_travelthru(CuTest *tc) { mstream_init(&out); move_unit(u, r, 0); - write_travelthru(&out, r, f); + report_travelthru(&out, r, f); out.api->rewind(out.handle); len = out.api->read(out.handle, buf, sizeof(buf)); CuAssertIntEquals_Msg(tc, "do not list units that stopped in the region", 0, (int)len); @@ -234,7 +279,8 @@ CuSuite *get_report_suite(void) CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_write_spaces); SUITE_ADD_TEST(suite, test_write_many_spaces); - SUITE_ADD_TEST(suite, test_write_travelthru); + SUITE_ADD_TEST(suite, test_report_travelthru); + SUITE_ADD_TEST(suite, test_report_region); SUITE_ADD_TEST(suite, test_write_spell_syntax); return suite; } From 52dd11a28f0dda31f80c2c07197dae631b313ca6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 17:18:17 +0100 Subject: [PATCH 649/675] create a failing test for stones in the NR. --- src/kernel/resources.c | 1 + src/report.test.c | 34 +++++++++++++++++++++++++++++++--- src/reports.c | 8 +++++--- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/kernel/resources.c b/src/kernel/resources.c index ae93d542a..a3f86aac6 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -203,6 +203,7 @@ struct rawmaterial_type *rmt_create(struct resource_type *rtype) rawmaterial_type *rmtype; assert(!rtype->raw); + assert(!rtype->itype || rtype->itype->construction); rmtype = rtype->raw = malloc(sizeof(rawmaterial_type)); rmtype->rtype = rtype; rmtype->terraform = terraform_default; diff --git a/src/report.test.c b/src/report.test.c index 5b1a8c058..92bfe3d9e 100644 --- a/src/report.test.c +++ b/src/report.test.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -60,12 +61,22 @@ static void test_report_region(CuTest *tc) { char buf[1024]; region *r; faction *f; + unit *u; stream out = { 0 }; size_t len; struct locale *lang; + struct resource_type *rt_stone; + construction *cons; test_setup(); init_resources(); + rt_stone = rt_get_or_create("stone"); + rt_stone->itype = it_get_or_create(rt_stone); + cons = rt_stone->itype->construction = calloc(1, sizeof(construction)); + cons->minskill = 1; + cons->skill = SK_QUARRYING; + rmt_create(rt_stone); + lang = get_or_create_locale("de"); /* CR tags are translated from this */ locale_setstring(lang, "money", "Silber"); locale_setstring(lang, "money_p", "Silber"); @@ -80,23 +91,40 @@ static void test_report_region(CuTest *tc) { locale_setstring(lang, "sapling", "Schoessling"); locale_setstring(lang, "sapling_p", "Schoesslinge"); locale_setstring(lang, "plain", "Ebene"); + locale_setstring(lang, "see_travel", "durchgereist"); mstream_init(&out); r = test_create_region(0, 0, 0); - r->land->peasants = 100; - r->land->horses = 200; + add_resource(r, 1, 100, 10, rt_stone); + CuAssertIntEquals(tc, 135, r->resources->amount); + CuAssertIntEquals(tc, 1, r->resources->level); + r->land->peasants = 5; + r->land->horses = 7; + r->land->money = 2; rsettrees(r, 0, 1); rsettrees(r, 1, 2); rsettrees(r, 2, 3); region_setname(r, "Hodor"); f = test_create_faction(0); f->locale = lang; + u = test_create_unit(f, r); + set_level(u, SK_QUARRYING, 1); + r->seen.mode = seen_travel; report_region(&out, r, f); out.api->rewind(out.handle); len = out.api->read(out.handle, buf, sizeof(buf)); buf[len] = '\0'; - CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 3/2 Blumen, 100 Bauern, 200 Pferde.\n", buf); + CuAssertStrEquals(tc, "Hodor (0,0) (durchgereist), Ebene, 3/2 Blumen, 5 Bauern, 2 Silber, 7 Pferde.\n", buf); + + r->seen.mode = seen_unit; + out.api->rewind(out.handle); + report_region(&out, r, f); + out.api->rewind(out.handle); + len = out.api->read(out.handle, buf, sizeof(buf)); + buf[len] = '\0'; + CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 3/2 Blumen, 135 Steine/1, 5 Bauern, 2 Silber, 7 Pferde.\n", buf); + mstream_done(&out); test_cleanup(); } diff --git a/src/reports.c b/src/reports.c index 74b800a90..737e4fc48 100644 --- a/src/reports.c +++ b/src/reports.c @@ -448,17 +448,19 @@ const faction * viewer, bool see_unit) while (res) { int maxskill = 0; const item_type *itype = resource2item(res->type->rtype); - int level = res->level + itype->construction->minskill - 1; + int minskill = itype->construction->minskill; + skill_t skill = itype->construction->skill; + int level = res->level + minskill - 1; int visible = -1; if (res->type->visible == NULL) { visible = res->amount; - level = res->level + itype->construction->minskill - 1; + level = res->level + minskill - 1; } else { const unit *u; for (u = r->units; visible != res->amount && u != NULL; u = u->next) { if (u->faction == viewer) { - int s = effskill(u, itype->construction->skill, 0); + int s = effskill(u, skill, 0); if (s > maxskill) { maxskill = s; visible = res->type->visible(res, maxskill); From d6ce1d9cfeeda100e10c9ac3cb429ac874a7786e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 17:26:00 +0100 Subject: [PATCH 650/675] Add a test for singular resources. --- src/report.test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/report.test.c b/src/report.test.c index 92bfe3d9e..0bfea3c69 100644 --- a/src/report.test.c +++ b/src/report.test.c @@ -125,6 +125,19 @@ static void test_report_region(CuTest *tc) { buf[len] = '\0'; CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 3/2 Blumen, 135 Steine/1, 5 Bauern, 2 Silber, 7 Pferde.\n", buf); + r->resources->amount = 1; + r->land->peasants = 1; + r->land->horses = 1; + r->land->money = 1; + + r->seen.mode = seen_unit; + out.api->rewind(out.handle); + report_region(&out, r, f); + out.api->rewind(out.handle); + len = out.api->read(out.handle, buf, sizeof(buf)); + buf[len] = '\0'; + CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 3/2 Blumen, 1 Stein/1, 1 Bauer, 1 Silber, 1 Pferd.\n", buf); + mstream_done(&out); test_cleanup(); } From 0379a17350b778040b318657282408f996657494 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 17:42:57 +0100 Subject: [PATCH 651/675] make report_resource return an rtype, not a name. --- src/creport.c | 12 ++++++------ src/creport.test.c | 1 + src/kernel/item.c | 5 +++++ src/report.c | 2 +- src/reports.c | 25 +++++++++++++------------ src/reports.h | 2 +- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/creport.c b/src/creport.c index c766ae872..ee7abcc87 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1094,12 +1094,12 @@ static void cr_reportspell(FILE * F, spell * sp, int level, const struct locale } } -static char *cr_output_resource(char *buf, const char *name, +static char *cr_output_resource(char *buf, const resource_type *rtype, const struct locale *loc, int amount, int level) { - assert(name); - buf += sprintf(buf, "RESOURCE %u\n", hashstring(name)); - buf += sprintf(buf, "\"%s\";type\n", translate(name, LOC(loc, name))); + assert(rtype); + buf += sprintf(buf, "RESOURCE %u\n", hashstring(rtype->_name)); + buf += sprintf(buf, "\"%s\";type\n", translate(rtype->_name, LOC(loc, rtype->_name))); if (amount >= 0) { if (level >= 0) buf += sprintf(buf, "%d;skill\n", level); @@ -1180,7 +1180,7 @@ void cr_output_resources(stream *out, const faction * f, const region *r, bool s } for (n = 0; n < size; ++n) { if (result[n].level >= 0 && result[n].number >= 0) { - stream_printf(out, "%d;%s\n", result[n].number, crtag(result[n].name)); +/* stream_printf(out, "%d;%s\n", result[n].number, crtag(result[n].name)); */ } } #endif @@ -1188,7 +1188,7 @@ void cr_output_resources(stream *out, const faction * f, const region *r, bool s for (n = 0; n < size; ++n) { if (result[n].number >= 0) { pos = - cr_output_resource(pos, result[n].name, f->locale, result[n].number, + cr_output_resource(pos, result[n].rtype, f->locale, result[n].number, result[n].level); } } diff --git a/src/creport.test.c b/src/creport.test.c index b329e2d22..aff170b01 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -58,6 +58,7 @@ static void test_cr_resources(CuTest *tc) { struct locale *lang; test_setup(); + init_resources(); lang = get_or_create_locale("de"); /* CR tags are translated from this */ locale_setstring(lang, "money", "Silber"); locale_setstring(lang, "money_p", "Silber"); diff --git a/src/kernel/item.c b/src/kernel/item.c index 1fb90d456..48ea7a690 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -988,6 +988,11 @@ void init_resources(void) rtype->itype = it_get_or_create(rtype); rtype->itype->flags |= ITF_ANIMAL | ITF_BIG; + rtype = rt_get_or_create(resourcenames[R_SAPLING]); + rtype = rt_get_or_create(resourcenames[R_TREE]); + rtype = rt_get_or_create(resourcenames[R_MALLORN_SAPLING]); + rtype = rt_get_or_create(resourcenames[R_MALLORN_TREE]); + /* "special" spell components */ rtype = rt_get_or_create(resourcenames[R_AURA]); rtype->uchange = res_changeaura; diff --git a/src/report.c b/src/report.c index 6e8d811bc..43a7ab514 100644 --- a/src/report.c +++ b/src/report.c @@ -1005,7 +1005,7 @@ void report_region(struct stream *out, const region * r, faction * f) for (n = 0; n < numresults; ++n) { if (result[n].number >= 0 && result[n].level >= 0) { bytes = snprintf(bufp, size, ", %d %s/%d", result[n].number, - LOC(f->locale, result[n].name), result[n].level); + LOC(f->locale, result[n].rtype->_name), result[n].level); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } diff --git a/src/reports.c b/src/reports.c index 737e4fc48..63e274265 100644 --- a/src/reports.c +++ b/src/reports.c @@ -346,11 +346,11 @@ report_items(const unit *u, item * result, int size, const unit * owner, return n; } -static void -report_resource(resource_report * result, const char *name, int number, -int level) +static void report_resource(resource_report * result, const resource_type *rtype, + int number, int level) { - result->name = name; + assert(rtype); + result->rtype = rtype; result->number = number; result->level = level; } @@ -408,37 +408,38 @@ const faction * viewer, bool see_unit) int trees = rtrees(r, 2); int saplings = rtrees(r, 1); bool mallorn = fval(r, RF_MALLORN) != 0; + const resource_type *rtype; if (money) { if (n >= size) return -1; - report_resource(result + n, "money", money, -1); + report_resource(result + n, get_resourcetype(R_SILVER), money, -1); ++n; } if (peasants) { if (n >= size) return -1; - report_resource(result + n, "peasant", peasants, -1); + report_resource(result + n, get_resourcetype(R_PEASANT), peasants, -1); ++n; } if (horses) { if (n >= size) return -1; - report_resource(result + n, "horse", horses, -1); + report_resource(result + n, get_resourcetype(R_HORSE), horses, -1); ++n; } if (saplings) { if (n >= size) return -1; - report_resource(result + n, mallorn ? "mallornsapling" : "sapling", - saplings, -1); + rtype = get_resourcetype(mallorn ? R_MALLORN_SAPLING : R_SAPLING); + report_resource(result + n, rtype, saplings, -1); ++n; } if (trees) { if (n >= size) return -1; - report_resource(result + n, mallorn ? "mallorn" : "tree", trees, - -1); + rtype = get_resourcetype(mallorn ? R_MALLORN_TREE : R_TREE); + report_resource(result + n, rtype, trees, -1); ++n; } } @@ -471,7 +472,7 @@ const faction * viewer, bool see_unit) if (level >= 0 && visible >= 0) { if (n >= size) return -1; - report_resource(result + n, res->type->rtype->_name, visible, level); + report_resource(result + n, res->type->rtype, visible, level); n++; } res = res->next; diff --git a/src/reports.h b/src/reports.h index 855234376..6ce14e775 100644 --- a/src/reports.h +++ b/src/reports.h @@ -107,7 +107,7 @@ extern "C" { } arg_regions; typedef struct resource_report { - const char *name; + const struct resource_type *rtype; int number; int level; } resource_report; From 8d7f9663912b83134b391f97a909ec742da45699 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 18:23:24 +0100 Subject: [PATCH 652/675] BUG 2298: fix CR output. always use the plural form. --- src/creport.c | 7 +++++-- src/creport.test.c | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/creport.c b/src/creport.c index ee7abcc87..b9088f020 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1097,9 +1097,11 @@ static void cr_reportspell(FILE * F, spell * sp, int level, const struct locale static char *cr_output_resource(char *buf, const resource_type *rtype, const struct locale *loc, int amount, int level) { + const char * name; assert(rtype); + name = resourcename(rtype, 1); buf += sprintf(buf, "RESOURCE %u\n", hashstring(rtype->_name)); - buf += sprintf(buf, "\"%s\";type\n", translate(rtype->_name, LOC(loc, rtype->_name))); + buf += sprintf(buf, "\"%s\";type\n", translate(name, LOC(loc, rtype->_name))); if (amount >= 0) { if (level >= 0) buf += sprintf(buf, "%d;skill\n", level); @@ -1180,7 +1182,8 @@ void cr_output_resources(stream *out, const faction * f, const region *r, bool s } for (n = 0; n < size; ++n) { if (result[n].level >= 0 && result[n].number >= 0) { -/* stream_printf(out, "%d;%s\n", result[n].number, crtag(result[n].name)); */ + const char * name = resourcename(result[n].rtype, result[n].number != 1); + stream_printf(out, "%d;%s\n", result[n].number, crtag(name)); } } #endif diff --git a/src/creport.test.c b/src/creport.test.c index aff170b01..d0ce1532d 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -73,7 +73,7 @@ static void test_cr_resources(CuTest *tc) { f = test_create_faction(0); r = test_create_region(0, 0, 0); - r->land->horses = 100; + r->land->horses = 1; r->land->peasants = 200; r->land->money = 300; rsettrees(r, 0, 1); @@ -107,7 +107,7 @@ static void test_cr_resources(CuTest *tc) { CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, "\"Pferde\";type", line); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); - CuAssertStrEquals(tc, "300;number", line); + CuAssertStrEquals(tc, "1;number", line); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); From f699c32f0e76ddb46f5a237920153f6445be1dab Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 18:25:15 +0100 Subject: [PATCH 653/675] BUG 2298: fix NR display. always use correct singular or plural form. --- src/report.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/report.c b/src/report.c index 43a7ab514..612df1dad 100644 --- a/src/report.c +++ b/src/report.c @@ -1004,8 +1004,9 @@ void report_region(struct stream *out, const region * r, faction * f) for (n = 0; n < numresults; ++n) { if (result[n].number >= 0 && result[n].level >= 0) { + const char * name = resourcename(result[n].rtype, result[n].number!=1); bytes = snprintf(bufp, size, ", %d %s/%d", result[n].number, - LOC(f->locale, result[n].rtype->_name), result[n].level); + LOC(f->locale, name), result[n].level); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } From dbe5980577bf92554877ed4da1860561621f6b8e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 18:47:49 +0100 Subject: [PATCH 654/675] CR is missing saplings? --- src/creport.c | 4 ++++ tests/run-turn.sh | 5 ++++- tests/write-reports.sh | 14 +++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/creport.c b/src/creport.c index b9088f020..706f622de 100644 --- a/src/creport.c +++ b/src/creport.c @@ -417,6 +417,7 @@ static int cr_resources(variant var, char *buffer, const void *userdata) char *wp = buffer; if (rlist != NULL) { const char *name = resourcename(rlist->type, rlist->number != 1); + assert(name); wp += sprintf(wp, "\"%d %s", rlist->number, translate(name, LOC(f->locale, name))); @@ -425,6 +426,7 @@ static int cr_resources(variant var, char *buffer, const void *userdata) if (rlist == NULL) break; name = resourcename(rlist->type, rlist->number != 1); + assert(name); wp += sprintf(wp, ", %d %s", rlist->number, translate(name, LOC(f->locale, name))); @@ -1100,6 +1102,7 @@ static char *cr_output_resource(char *buf, const resource_type *rtype, const char * name; assert(rtype); name = resourcename(rtype, 1); + assert(name); buf += sprintf(buf, "RESOURCE %u\n", hashstring(rtype->_name)); buf += sprintf(buf, "\"%s\";type\n", translate(name, LOC(loc, rtype->_name))); if (amount >= 0) { @@ -1183,6 +1186,7 @@ void cr_output_resources(stream *out, const faction * f, const region *r, bool s for (n = 0; n < size; ++n) { if (result[n].level >= 0 && result[n].number >= 0) { const char * name = resourcename(result[n].rtype, result[n].number != 1); + assert(name); stream_printf(out, "%d;%s\n", result[n].number, crtag(name)); } } diff --git a/tests/run-turn.sh b/tests/run-turn.sh index 519ed8bd8..9297278c3 100755 --- a/tests/run-turn.sh +++ b/tests/run-turn.sh @@ -53,10 +53,13 @@ assert_grep_count reports/$CRFILE '^BURG' 1 assert_grep_count reports/$CRFILE '^EINHEIT' 2 assert_grep_count reports/$CRFILE '^GEGENSTAENDE' 2 +assert_grep_count reports/185-heg.cr ';Baeume' 4 +assert_grep_count reports/185-heg.cr '"B.ume";type' 4 +assert_grep_count reports/185-heg.cr '"Pferde";type' 6 assert_grep_count reports/185-heg.nr 'erblickt' 6 assert_grep_count reports/185-heg.cr '"lighthouse";visibility' 6 assert_grep_count reports/185-heg.cr '"neighbour";visibility' 11 assert_grep_count reports/185-6rLo.cr '^EINHEIT' 2 assert_grep_count reports/185-6rLo.cr '^REGION' 13 echo "integration tests: PASS" -cleanup +#cleanup diff --git a/tests/write-reports.sh b/tests/write-reports.sh index 6581066f0..5621e84a9 100755 --- a/tests/write-reports.sh +++ b/tests/write-reports.sh @@ -34,14 +34,18 @@ $VALGRIND $SERVER -t 184 ../scripts/reports.lua [ -d reports ] || quit 4 "no reports directory created" CRFILE=184-zvto.cr grep -q PARTEI reports/$CRFILE || quit 1 "CR did not contain any factions" -grep -q -E '"B.ume";type"' reports/$CRFILE || \ - quit 1 "CR did not contain trees" -grep -q '"Bauern";type"' reports/$CRFILE || \ - quit 1 "CR did not contain peasants" +grep -q -E '"B.ume";type' reports/$CRFILE || \ + quit 1 "regions did not contain trees" +grep -q -E '"Silber";type' reports/$CRFILE || \ + quit 1 "regions did not contain silver" +grep -q '"Bauern";type' reports/$CRFILE || \ + quit 1 "regions did not contain peasants" +grep -q '"Sch..linge";type' reports/$CRFILE || \ + quit 1 "regions did not contain saplings" grep -q REGION reports/$CRFILE || quit 2 "CR did not contain any regions" grep -q SCHIFF reports/$CRFILE || quit 3 "CR did not contain any ships" grep -q BURG reports/$CRFILE || quit 4 "CR did not contain any buildings" grep -q EINHEIT reports/$CRFILE || quit 5 "CR did not contain any units" grep -q GEGENSTAENDE reports/$CRFILE || quit 6 "CR did not contain any items" echo "integration tests: PASS" -#cleanup +cleanup From cdb65dfd36dce5365a2ad45a02f3f0fec82b0d6b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 18:57:28 +0100 Subject: [PATCH 655/675] Turns out: We did not have a singular form of sapling. --- res/core/de/strings.xml | 10 ++++++++++ src/creport.c | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 5dc649aa1..d69c0919f 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -6604,11 +6604,21 @@ + Schößling + sapling + + + Schößlinge saplings + Mallornschößling + mallorn sapling + + + Mallornschößlinge mallorn saplings diff --git a/src/creport.c b/src/creport.c index b9088f020..bb2d68d1d 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1178,7 +1178,7 @@ void cr_output_resources(stream *out, const faction * f, const region *r, bool s stream_printf(out, "%d;Schoesslinge\n", saplings); } if (fval(r, RF_MALLORN) && (trees > 0 || saplings > 0)) { - sputs("1;Mallorn\n", out); + sputs("1;Mallorn", out); } for (n = 0; n < size; ++n) { if (result[n].level >= 0 && result[n].number >= 0) { @@ -1196,7 +1196,7 @@ void cr_output_resources(stream *out, const faction * f, const region *r, bool s } } if (pos != cbuf) { - sputs(cbuf, out); + swrite(cbuf, 1, pos - cbuf, out); } } From e233ed434447d1a076756c3bdee68eb093fffe60 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 19:23:47 +0100 Subject: [PATCH 656/675] eliminate source of randomness from test --- src/report.test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/report.test.c b/src/report.test.c index 0bfea3c69..3c6a09ae1 100644 --- a/src/report.test.c +++ b/src/report.test.c @@ -96,7 +96,7 @@ static void test_report_region(CuTest *tc) { mstream_init(&out); r = test_create_region(0, 0, 0); add_resource(r, 1, 100, 10, rt_stone); - CuAssertIntEquals(tc, 135, r->resources->amount); + r->resources->amount = 135; CuAssertIntEquals(tc, 1, r->resources->level); r->land->peasants = 5; r->land->horses = 7; From 33b98b59ec3b3c9d515a09809d8e1c4f44209c49 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 5 Mar 2017 22:28:08 +0100 Subject: [PATCH 657/675] when make_frac cannot find a gcd, cheat. --- src/util/variant.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util/variant.c b/src/util/variant.c index c1d42808d..af5d690f4 100644 --- a/src/util/variant.c +++ b/src/util/variant.c @@ -2,6 +2,7 @@ #include "variant.h" #include +#include #include const variant frac_zero = { .sa = { 0, 1 } }; @@ -41,8 +42,13 @@ variant frac_make(int num, int den) int g = gcd(num, den); num /= g; den /= g; - assert(num >= SHRT_MIN && num <= SHRT_MAX); - assert(den >= SHRT_MIN && den <= SHRT_MAX); + if (num < SHRT_MIN || num > SHRT_MAX || den < SHRT_MIN || den > SHRT_MAX) { + int a = abs(num/SHRT_MIN) + 1; + int b = abs(den/SHRT_MIN) + 1; + if (b>a) a = b; + num /= a; + den /= a; + } v.sa[0] = (short)num; v.sa[1] = (short)den; return v; From f4eda9f59ecfca40f1f8ff2fb86515f135a56f96 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Mar 2017 06:28:12 +0100 Subject: [PATCH 658/675] prefer dice to dice_rand --- src/items.c | 4 ++-- src/kernel/region.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/items.c b/src/items.c index 78f6e3188..0f97ea675 100644 --- a/src/items.c +++ b/src/items.c @@ -178,8 +178,8 @@ struct order *ord) return 0; } -#define BAGPIPEFRACTION dice_rand("2d4+2") -#define BAGPIPEDURATION dice_rand("2d10+4") +#define BAGPIPEFRACTION (dice(2,4)+2) +#define BAGPIPEDURATION (dice(2,10)+4) static int use_bagpipeoffear(struct unit *u, const struct item_type *itype, diff --git a/src/kernel/region.c b/src/kernel/region.c index e4f33db33..48256fb60 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -1217,7 +1217,7 @@ void terraform_region(region * r, const terrain_type * terrain) if (!fval(r, RF_CHAOTIC)) { int peasants; - peasants = (region_maxworkers(r) * (20 + dice_rand("6d10"))) / 100; + peasants = (region_maxworkers(r) * (20 + dice(6, 10))) / 100; rsetpeasants(r, MAX(100, peasants)); rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL, INT_MAX) + 1) + rng_int() % 5)); From 1c72b0f29739eeb61902f3ccb1eff965a5d6c1c0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Mar 2017 07:42:12 +0100 Subject: [PATCH 659/675] warn about missing game.mailcmd setting --- src/kernel/config.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kernel/config.c b/src/kernel/config.c index b605fddd4..a18fc6494 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -845,6 +845,7 @@ const char * game_mailcmd(void) *r++ = (char)toupper(*c); } *r = '\0'; + log_warning("game.mailcmd configuration is not set, using %s from game.name", result); return result; } return param; From 4b246863c0588fdec7560268ed8a0c6b7668a342 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Mar 2017 20:37:17 +0100 Subject: [PATCH 660/675] bug 2303: correct the test. we cannot reuse the memstream. need to recreate it for each test. need to rewrite the code in creport.c, it is crazy. --- src/creport.c | 10 +++++----- src/creport.test.c | 17 +++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/creport.c b/src/creport.c index 99a9ede97..e023e28a5 100644 --- a/src/creport.c +++ b/src/creport.c @@ -796,14 +796,14 @@ void cr_output_unit(stream *out, const region * r, const faction * f, else { /* other unit. show visible faction, not u->faction */ stream_printf(out, "%d;Partei\n", sf ? sf->no : f->no); - if (sf == f) { - stream_printf(out, "1;Verraeter\n"); - } - if (sf && sf != u->faction) { - if (alliedunit(u, f, HELP_FSTEALTH)) { + if (alliedunit(u, f, HELP_FSTEALTH)) { + if (sf && sf != u->faction) { stream_printf(out, "%d;Anderepartei\n", sf->no); } } + else if (sf == f) { + stream_printf(out, "1;Verraeter\n"); + } } } prefix = raceprefix(u); diff --git a/src/creport.test.c b/src/creport.test.c index 14f40268c..441c4dc87 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -71,39 +71,44 @@ static void test_cr_factionstealth(CuTest *tc) { ally *al; test_setup(); - mstream_init(&strm); f1 = test_create_faction(0); f2 = test_create_faction(0); r = test_create_region(0, 0, 0); u = test_create_unit(f1, r); + mstream_init(&strm); cr_output_unit(&strm, u->region, f1, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); + mstream_done(&strm); set_factionstealth(u, f2); CuAssertPtrNotNull(tc, u->attribs); + mstream_init(&strm); cr_output_unit(&strm, u->region, f1, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); + mstream_done(&strm); + mstream_init(&strm); cr_output_unit(&strm, u->region, f2, u, seen_unit); - CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); - CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); + CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Partei", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1)); + mstream_done(&strm); al = ally_add(&f1->allies, f2); al->status = HELP_FSTEALTH; - + mstream_init(&strm); cr_output_unit(&strm, u->region, f2, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); - CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1)); - + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); mstream_done(&strm); + test_cleanup(); } From 05bb109a093ddb823c44a20f11e95abfa27927cd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Mar 2017 21:35:48 +0100 Subject: [PATCH 661/675] BUG 2303: allied units are not traitors. had to rewrite the creport code for this, it is probably less efficient now than ever, but at least it works. --- src/attributes/otherfaction.c | 19 +++++++------ src/attributes/otherfaction.h | 2 +- src/battle.c | 3 +- src/creport.c | 52 +++++++++++++++-------------------- src/kernel/faction.c | 4 +-- src/kernel/unit.c | 8 ++++-- src/report.c | 7 ++--- src/reports.c | 25 +++++++++-------- 8 files changed, 56 insertions(+), 64 deletions(-) diff --git a/src/attributes/otherfaction.c b/src/attributes/otherfaction.c index 83c56e767..c9e56fe27 100644 --- a/src/attributes/otherfaction.c +++ b/src/attributes/otherfaction.c @@ -57,10 +57,16 @@ attrib_type at_otherfaction = { "otherfaction", NULL, NULL, NULL, write_of, read_of, NULL, ATF_UNIQUE }; -struct faction *get_otherfaction(const struct attrib *a) +faction *get_otherfaction(const unit * u) { - faction * f = (faction *)(a->data.v); - return (f && f->_alive) ? f : NULL; + attrib *a = a_find(u->attribs, &at_otherfaction); + if (a) { + faction * f = (faction *)(a->data.v); + if (f && f->_alive) { + return f; + } + } + return NULL; } struct attrib *make_otherfaction(struct faction *f) @@ -73,11 +79,8 @@ struct attrib *make_otherfaction(struct faction *f) faction *visible_faction(const faction * f, const unit * u) { if (f == NULL || !alliedunit(u, f, HELP_FSTEALTH)) { - attrib *a = a_find(u->attribs, &at_otherfaction); - if (a) { - faction *fv = get_otherfaction(a); - if (fv) return fv; - } + faction *fv = get_otherfaction(u); + if (fv) return fv; } return u->faction; } diff --git a/src/attributes/otherfaction.h b/src/attributes/otherfaction.h index 726d86b0e..8a6471658 100644 --- a/src/attributes/otherfaction.h +++ b/src/attributes/otherfaction.h @@ -25,7 +25,7 @@ extern "C" { struct attrib; extern struct attrib_type at_otherfaction; - extern struct faction *get_otherfaction(const struct attrib *a); + extern struct faction *get_otherfaction(const struct unit *u); extern struct attrib *make_otherfaction(struct faction *f); extern struct faction *visible_faction(const struct faction *f, const struct unit *u); diff --git a/src/battle.c b/src/battle.c index 9864adc41..018133516 100644 --- a/src/battle.c +++ b/src/battle.c @@ -3126,8 +3126,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) int speeded = 0, speed = 1; int rest; const group *g = NULL; - const attrib *a = a_find(u->attribs, &at_otherfaction); - const faction *stealthfaction = a ? get_otherfaction(a) : NULL; + const faction *stealthfaction = get_otherfaction(u); unsigned int flags = 0; assert(u->number); diff --git a/src/creport.c b/src/creport.c index e023e28a5..df616a105 100644 --- a/src/creport.c +++ b/src/creport.c @@ -748,8 +748,9 @@ void cr_output_unit(stream *out, const region * r, const faction * f, const char *pzTmp; skill *sv; item result[MAX_INVENTORY]; - const faction *sf; + const faction *fother, *fseen; const char *prefix; + bool allied; assert(u && u->number); assert(u->region == r); /* TODO: if this holds true, then why did we pass in r? */ @@ -762,10 +763,8 @@ void cr_output_unit(stream *out, const region * r, const faction * f, if (str) { stream_printf(out, "\"%s\";Beschr\n", str); } - /* print faction information */ - sf = visible_faction(NULL, u); - if (u->faction == f || omniscient(f)) { - /* my own faction, full info */ + + if (u->faction == f) { const attrib *a = NULL; unit *mage; @@ -775,36 +774,29 @@ void cr_output_unit(stream *out, const region * r, const faction * f, const group *g = (const group *)a->data.v; stream_printf(out, "%d;gruppe\n", g->gid); } - stream_printf(out, "%d;Partei\n", u->faction->no); - if (sf && sf != u->faction) { - stream_printf(out, "%d;Verkleidung\n", sf->no); - stream_printf(out, "%d;Anderepartei\n", sf->no); - } - if (fval(u, UFL_ANON_FACTION)) { - stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION) != 0); - } mage = get_familiar_mage(u); if (mage) { stream_printf(out, "%u;familiarmage\n", mage->no); } } - else { - if (fval(u, UFL_ANON_FACTION)) { - /* faction info is hidden */ - stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION) != 0); - } - else { - /* other unit. show visible faction, not u->faction */ - stream_printf(out, "%d;Partei\n", sf ? sf->no : f->no); - if (alliedunit(u, f, HELP_FSTEALTH)) { - if (sf && sf != u->faction) { - stream_printf(out, "%d;Anderepartei\n", sf->no); - } - } - else if (sf == f) { - stream_printf(out, "1;Verraeter\n"); - } - } + + fseen = u->faction; + fother = get_otherfaction(u); + allied = u->faction == f || alliedunit(u, f, HELP_FSTEALTH); + if (fother && f != u->faction && !allied) { + /* getarnt, keine eigene, und kein HELFE fuer uns: wir sehen den fake */ + fseen = fother; + } + stream_printf(out, "%d;Partei\n", fseen->no); + if (fother && fother!=fseen) { + stream_printf(out, "%d;Anderepartei\n", fother->no); + } + if (fseen==f && fval(u, UFL_ANON_FACTION)) { + sputs("1;Parteitarnung", out); + } + if (!allied && fother == f) { + /* sieht aus wie unsere, ist es aber nicht. */ + stream_printf(out, "1;Verraeter\n"); } prefix = raceprefix(u); if (prefix) { diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 57cd5d3af..139474048 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -449,12 +449,10 @@ void destroyfaction(faction ** fp) /* units of other factions that were disguised as this faction * have their disguise replaced by ordinary faction hiding. */ if (rule_stealth_other()) { - /* TODO: f.alive should be tested for in get_otherfaction */ region *rc; for (rc = regions; rc; rc = rc->next) { for (u = rc->units; u; u = u->next) { - attrib *a = a_find(u->attribs, &at_otherfaction); - if (a && get_otherfaction(a) == f) { + if (u->attribs && get_otherfaction(u) == f) { a_removeall(&u->attribs, &at_otherfaction); if (rule_stealth_anon()) { fset(u, UFL_ANON_FACTION); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 4592d0bc7..595accba2 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1565,9 +1565,11 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace, set_group(u, g); } } - a = a_find(creator->attribs, &at_otherfaction); - if (a) { - a_add(&u->attribs, make_otherfaction(get_otherfaction(a))); + if (creator->attribs) { + faction *otherf = get_otherfaction(creator); + if (otherf) { + a_add(&u->attribs, make_otherfaction(otherf)); + } } a = a_add(&u->attribs, a_new(&at_creator)); diff --git a/src/report.c b/src/report.c index cf00abbc3..81d5ad016 100644 --- a/src/report.c +++ b/src/report.c @@ -680,7 +680,6 @@ static void rps_nowrap(struct stream *out, const char *s) static void nr_unit(struct stream *out, const faction * f, const unit * u, int indent, seen_mode mode) { - attrib *a_otherfaction; char marker; int dh; bool isbattle = (bool)(mode == seen_battle); @@ -692,16 +691,14 @@ nr_unit(struct stream *out, const faction * f, const unit * u, int indent, seen_ newline(out); dh = bufunit(f, u, indent, mode, buf, sizeof(buf)); - a_otherfaction = a_find(u->attribs, &at_otherfaction); - if (u->faction == f) { marker = '*'; } else if (is_allied(u->faction, f)) { marker = 'o'; } - else if (a_otherfaction && f != u->faction - && get_otherfaction(a_otherfaction) == f && !fval(u, UFL_ANON_FACTION)) { + else if (u->attribs && f != u->faction + && !fval(u, UFL_ANON_FACTION) && get_otherfaction(u) == f) { marker = '!'; } else { diff --git a/src/reports.c b/src/reports.c index a07b60f4b..8f59f47a2 100644 --- a/src/reports.c +++ b/src/reports.c @@ -497,7 +497,6 @@ size_t size) bufp = STRLCPY(bufp, unitname(u), size); fv = visible_faction(f, u); if (!isbattle) { - attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); if (u->faction == f) { if (fval(u, UFL_GROUP)) { attrib *a = a_find(u->attribs, &at_group); @@ -511,11 +510,11 @@ size_t size) bufp = STRLCPY(bufp, ", ", size); bufp = STRLCPY(bufp, LOC(f->locale, "anonymous"), size); } - else if (a_otherfaction) { - faction *otherfaction = get_otherfaction(a_otherfaction); - if (otherfaction) { + else if (u->attribs) { + faction *otherf = get_otherfaction(u); + if (otherf) { bufp = STRLCPY(bufp, ", ", size); - bufp = STRLCPY(bufp, factionname(otherfaction), size); + bufp = STRLCPY(bufp, factionname(otherf), size); } } } @@ -525,13 +524,15 @@ size_t size) bufp = STRLCPY(bufp, LOC(f->locale, "anonymous"), size); } else { - if (a_otherfaction && alliedunit(u, f, HELP_FSTEALTH)) { - faction *f = get_otherfaction(a_otherfaction); - int result = - snprintf(bufp, size, ", %s (%s)", factionname(f), - factionname(u->faction)); - if (wrptr(&bufp, &size, result) != 0) - WARN_STATIC_BUFFER(); + if (u->attribs && alliedunit(u, f, HELP_FSTEALTH)) { + faction *otherf = get_otherfaction(u); + if (otherf) { + int result = + snprintf(bufp, size, ", %s (%s)", factionname(otherf), + factionname(u->faction)); + if (wrptr(&bufp, &size, result) != 0) + WARN_STATIC_BUFFER(); + } } else { bufp = STRLCPY(bufp, ", ", size); From e3a969ce9b6d078fe0731f2982e04faac005190d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Mar 2017 21:43:31 +0100 Subject: [PATCH 662/675] add a test to see that frac_make can handle large integers. --- src/util/variant.test.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/util/variant.test.c b/src/util/variant.test.c index 12299720b..37aa3f77e 100644 --- a/src/util/variant.test.c +++ b/src/util/variant.test.c @@ -30,6 +30,16 @@ static void test_fractions(CuTest *tc) { CuAssertIntEquals(tc, -1, frac_sign(frac_make(-1, 1))); CuAssertIntEquals(tc, -1, frac_sign(frac_make(1, -1))); CuAssertIntEquals(tc, 0, frac_sign(frac_make(0, 1))); + + /* we reduce large integers by calculating the gcd */ + a = frac_make(480000, 3000); + CuAssertIntEquals(tc, 160, a.sa[0]); + CuAssertIntEquals(tc, 1, a.sa[1]); + + /* if num is too big for a short, and the gcd is 1, we cheat: */ + a = frac_make(480001, 3000); + CuAssertIntEquals(tc, 32000, a.sa[0]); + CuAssertIntEquals(tc, 200, a.sa[1]); } CuSuite *get_variant_suite(void) From 40e0a9a65f956c037cff8dba0a4e0030c24ede44 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Mar 2017 22:21:27 +0100 Subject: [PATCH 663/675] merge bugs --- src/kernel/item.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/src/kernel/item.c b/src/kernel/item.c index d9a466543..97ae92174 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -565,46 +565,6 @@ item *i_new(const item_type * itype, int size) #include "region.h" -static int -give_horses(unit * s, unit * d, const item_type * itype, int n, -struct order *ord) -{ - if (d == NULL) { - int use = use_pooled(s, item2resource(itype), GET_SLACK, n); - region *r = s->region; - if (use < n) { - use += - use_pooled(s, item2resource(itype), GET_RESERVE | GET_POOLED_SLACK, - n - use); - } - if (r->land) { - rsethorses(r, rhorses(r) + use); - } - return 0; - } - return -1; /* use the mechanism */ -} - -static int -give_money(unit * s, unit * d, const item_type * itype, int n, -struct order *ord) -{ - if (d == NULL) { - int use = use_pooled(s, item2resource(itype), GET_SLACK, n); - region *r = s->region; - if (use < n) { - use += - use_pooled(s, item2resource(itype), GET_RESERVE | GET_POOLED_SLACK, - n - use); - } - if (r->land) { - rsetmoney(r, rmoney(r) + use); - } - return 0; - } - return -1; /* use the mechanism */ -} - const potion_type *oldpotiontype[MAX_POTIONS + 1]; /*** alte items ***/ From ce9e2ce314211a84349e8eed78ade5e88d88b29a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Mar 2017 22:24:15 +0100 Subject: [PATCH 664/675] fix invalid arguments for give/receive messages. --- src/give.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/give.c b/src/give.c index eeb641665..b52168647 100644 --- a/src/give.c +++ b/src/give.c @@ -131,12 +131,12 @@ static void add_give_person(unit * u, unit * u2, int given, else if (u2->faction != u->faction) { message *msg; - msg = msg_message("give_person", "unit target resource amount", + msg = msg_message("give_person", "unit target amount", u, u2, given); add_message(&u->faction->msgs, msg); msg_release(msg); - msg = msg_message("receive_person", "unit target resource amount", + msg = msg_message("receive_person", "unit target amount", u, u2, given); add_message(&u2->faction->msgs, msg); msg_release(msg); From 29a8342b4e961f1ca40af1c5dfddb263f2ca466d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 7 Mar 2017 19:30:52 +0100 Subject: [PATCH 665/675] BUG 2305: show the correct Parteitarnung in the CR. We didn't have the required tests, so of course I broke it. --- src/creport.c | 31 +++++++++++++------------ src/creport.test.c | 57 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/src/creport.c b/src/creport.c index f5d0f27fd..f22096f19 100644 --- a/src/creport.c +++ b/src/creport.c @@ -751,7 +751,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f, const char *pzTmp; skill *sv; item result[MAX_INVENTORY]; - const faction *fother, *fseen; + const faction *fother; const char *prefix; bool allied; @@ -783,24 +783,27 @@ void cr_output_unit(stream *out, const region * r, const faction * f, } } - fseen = u->faction; fother = get_otherfaction(u); allied = u->faction == f || alliedunit(u, f, HELP_FSTEALTH); - if (fother && f != u->faction && !allied) { - /* getarnt, keine eigene, und kein HELFE fuer uns: wir sehen den fake */ - fseen = fother; + if (allied) { + /* allies can tell that the unit is anonymous */ + /* the true faction is visible to allies */ + stream_printf(out, "%d;Partei\n", u->faction->no); + if (fother) { + stream_printf(out, "%d;Anderepartei\n", fother->no); + } + } else if (!fval(u, UFL_ANON_FACTION)) { + /* OBS: anonymity overrides everything */ + /* we have no alliance, so we get duped */ + stream_printf(out, "%d;Partei\n", (fother ? fother : u->faction)->no); + if (fother==f) { + /* sieht aus wie unsere, ist es aber nicht. */ + stream_printf(out, "1;Verraeter\n"); + } } - stream_printf(out, "%d;Partei\n", fseen->no); - if (fother && fother!=fseen) { - stream_printf(out, "%d;Anderepartei\n", fother->no); - } - if (fseen==f && fval(u, UFL_ANON_FACTION)) { + if (fval(u, UFL_ANON_FACTION)) { sputs("1;Parteitarnung", out); } - if (!allied && fother == f) { - /* sieht aus wie unsere, ist es aber nicht. */ - stream_printf(out, "1;Verraeter\n"); - } prefix = raceprefix(u); if (prefix) { prefix = mkname("prefix", prefix); diff --git a/src/creport.test.c b/src/creport.test.c index a56d1d589..62ad7fb10 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -130,10 +130,12 @@ static void test_cr_resources(CuTest *tc) { static int cr_get_int(stream *strm, const char *match, int def) { char line[1024]; + size_t len = strlen(match); strm->api->rewind(strm->handle); while (strm->api->readln(strm->handle, line, sizeof(line))==0) { - if (strstr(line, match)) { + const char * pos = strstr(line, match); + if (pos && pos[len]=='\0') { return atoi(line); } } @@ -153,30 +155,69 @@ static void test_cr_factionstealth(CuTest *tc) { r = test_create_region(0, 0, 0); u = test_create_unit(f1, r); + /* report to ourselves */ mstream_init(&strm); cr_output_unit(&strm, u->region, f1, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Parteitarnung", -1)); mstream_done(&strm); + /* ... also when we are anonymous */ + u->flags |= UFL_ANON_FACTION; + mstream_init(&strm); + cr_output_unit(&strm, u->region, f1, u, seen_unit); + CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); + CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Parteitarnung", -1)); + u->flags &= ~UFL_ANON_FACTION; + mstream_done(&strm); + + /* we see that our unit is cloaked */ set_factionstealth(u, f2); CuAssertPtrNotNull(tc, u->attribs); - mstream_init(&strm); cr_output_unit(&strm, u->region, f1, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Parteitarnung", -1)); mstream_done(&strm); + /* ... also when we are anonymous */ + u->flags |= UFL_ANON_FACTION; + mstream_init(&strm); + cr_output_unit(&strm, u->region, f1, u, seen_unit); + CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); + CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); + CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Parteitarnung", -1)); + u->flags &= ~UFL_ANON_FACTION; + mstream_done(&strm); + + /* we can tell that someone is presenting as us */ mstream_init(&strm); cr_output_unit(&strm, u->region, f2, u, seen_unit); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Parteitarnung", -1)); mstream_done(&strm); + /* ... but not if they are anonymous */ + u->flags |= UFL_ANON_FACTION; + mstream_init(&strm); + cr_output_unit(&strm, u->region, f2, u, seen_unit); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Partei", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); + CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Parteitarnung", -1)); + u->flags &= ~UFL_ANON_FACTION; + mstream_done(&strm); + + /* we see the same thing as them when we are an ally */ al = ally_add(&f1->allies, f2); al->status = HELP_FSTEALTH; mstream_init(&strm); @@ -184,6 +225,18 @@ static void test_cr_factionstealth(CuTest *tc) { CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Parteitarnung", -1)); + mstream_done(&strm); + + /* ... also when they are anonymous */ + u->flags |= UFL_ANON_FACTION; + mstream_init(&strm); + cr_output_unit(&strm, u->region, f1, u, seen_unit); + CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); + CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); + CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); + CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Parteitarnung", -1)); + u->flags &= ~UFL_ANON_FACTION; mstream_done(&strm); test_cleanup(); From 517da2dff10bd73e275b5e85c895339a51cacae7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 8 Mar 2017 18:15:31 +0100 Subject: [PATCH 666/675] breaking test for bug 2309 --- src/reports.test.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/reports.test.c b/src/reports.test.c index c026041a9..9dab0c0a7 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -7,6 +7,7 @@ #include "travelthru.h" #include "keyword.h" +#include #include #include #include @@ -20,10 +21,13 @@ #include #include +#include #include #include #include +#include + #include #include #include @@ -153,6 +157,42 @@ static void test_sparagraph(CuTest *tc) { freestrlist(sp); } +static void test_bufunit_bug_2305(CuTest *tc) { + unit *u; + faction *f1, *f2; + region *r; + ally *al; + char buf[1024]; + + test_setup(); + r = test_create_region(0, 0, 0); + f1 = test_create_faction(0); + f2 = test_create_faction(0); + u = test_create_unit(f1, r); + faction_setname(u->faction, "UFO"); + renumber_faction(u->faction, 1); + unit_setname(u, "Hodor"); + unit_setid(u, 1); + key_set(&u->attribs, 42, 42); + + /* report to self */ + bufunit(f1, u, 0, seen_unit, buf, sizeof(buf)); + CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressive.", buf); + + /* report to another faction */ + bufunit(f2, u, 0, seen_unit, buf, sizeof(buf)); + CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buf); + + al = ally_add(&f1->allies, f2); + al->status = HELP_FSTEALTH; + + /* report to an allied faction (bug 2305) */ + bufunit(f2, u, 0, seen_unit, buf, sizeof(buf)); + CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buf); + + test_cleanup(); +} + static void test_write_unit(CuTest *tc) { unit *u; faction *f; @@ -160,7 +200,7 @@ static void test_write_unit(CuTest *tc) { struct locale *lang; char buffer[1024]; - test_cleanup(); + test_setup(); rc = rc_get_or_create("human"); rc->bonus[SK_ALCHEMY] = 1; lang = get_or_create_locale("de"); @@ -581,6 +621,7 @@ CuSuite *get_reports_suite(void) SUITE_ADD_TEST(suite, test_regionid); SUITE_ADD_TEST(suite, test_sparagraph); SUITE_ADD_TEST(suite, test_write_unit); + SUITE_ADD_TEST(suite, test_bufunit_bug_2305); SUITE_ADD_TEST(suite, test_arg_resources); return suite; } From 4bda1a34e026bde2a08a77cc098c86c1fbc353d7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 8 Mar 2017 18:29:04 +0100 Subject: [PATCH 667/675] made a mistake in this test. creport was reporting to wrong faction (that sees the same output, so it didn't fail). --- src/creport.test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/creport.test.c b/src/creport.test.c index 62ad7fb10..acd6201f9 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -231,7 +231,7 @@ static void test_cr_factionstealth(CuTest *tc) { /* ... also when they are anonymous */ u->flags |= UFL_ANON_FACTION; mstream_init(&strm); - cr_output_unit(&strm, u->region, f1, u, seen_unit); + cr_output_unit(&strm, u->region, f2, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); From 77abd703bdb6b586b3dde608f6a78b1d462dce18 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 8 Mar 2017 20:15:41 +0100 Subject: [PATCH 668/675] backfill test that demonstrates bug 2305. --- src/attributes/otherfaction.h | 6 +-- src/reports.test.c | 83 ++++++++++++++++++++++++++++------- tests/runtests.bat | 1 + vs2017-build.bat | 13 ++++++ 4 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 vs2017-build.bat diff --git a/src/attributes/otherfaction.h b/src/attributes/otherfaction.h index 8a6471658..a274bcd49 100644 --- a/src/attributes/otherfaction.h +++ b/src/attributes/otherfaction.h @@ -25,9 +25,9 @@ extern "C" { struct attrib; extern struct attrib_type at_otherfaction; - extern struct faction *get_otherfaction(const struct unit *u); - extern struct attrib *make_otherfaction(struct faction *f); - extern struct faction *visible_faction(const struct faction *f, + struct faction *get_otherfaction(const struct unit *u); + struct attrib *make_otherfaction(struct faction *f); + struct faction *visible_faction(const struct faction *f, const struct unit *u); #ifdef __cplusplus diff --git a/src/reports.test.c b/src/reports.test.c index 9dab0c0a7..65d50c93e 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -157,48 +158,95 @@ static void test_sparagraph(CuTest *tc) { freestrlist(sp); } -static void test_bufunit_bug_2305(CuTest *tc) { - unit *u; +static void test_bufunit_fstealth(CuTest *tc) { faction *f1, *f2; region *r; + unit *u; ally *al; - char buf[1024]; + char buf[256]; + struct locale *lang; test_setup(); - r = test_create_region(0, 0, 0); + lang = get_or_create_locale("de"); + locale_setstring(lang, "status_aggressive", "aggressive"); + locale_setstring(lang, "anonymous", "anonymous"); f1 = test_create_faction(0); + f1->locale = lang; f2 = test_create_faction(0); + f2->locale = lang; + r = test_create_region(0, 0, 0); u = test_create_unit(f1, r); - faction_setname(u->faction, "UFO"); - renumber_faction(u->faction, 1); + faction_setname(f1, "UFO"); + renumber_faction(f1, 1); + faction_setname(f2, "TWW"); + renumber_faction(f2, 2); unit_setname(u, "Hodor"); unit_setid(u, 1); key_set(&u->attribs, 42, 42); - /* report to self */ + /* report to ourselves */ bufunit(f1, u, 0, seen_unit, buf, sizeof(buf)); CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressive.", buf); - /* report to another faction */ - bufunit(f2, u, 0, seen_unit, buf, sizeof(buf)); - CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buf); + /* ... also when we are anonymous */ + u->flags |= UFL_ANON_FACTION; + bufunit(f1, u, 0, seen_unit, buf, sizeof(buf)); + CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human, aggressive.", buf); + u->flags &= ~UFL_ANON_FACTION; + /* we see that our unit is cloaked */ + set_factionstealth(u, f2); + CuAssertPtrNotNull(tc, u->attribs); + bufunit(f1, u, 0, seen_unit, buf, sizeof(buf)); + CuAssertStrEquals(tc, "Hodor (1), TWW (2), 1 human, aggressive.", buf); + + /* ... also when we are anonymous */ + u->flags |= UFL_ANON_FACTION; + bufunit(f1, u, 0, seen_unit, buf, sizeof(buf)); + CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human, aggressive.", buf); + u->flags &= ~UFL_ANON_FACTION; + + /* we can see that someone is presenting as us */ + bufunit(f2, u, 0, seen_unit, buf, sizeof(buf)); + CuAssertStrEquals(tc, "Hodor (1), TWW (2), 1 human.", buf); + + /* ... but not if they are anonymous */ + u->flags |= UFL_ANON_FACTION; + bufunit(f2, u, 0, seen_unit, buf, sizeof(buf)); + CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human.", buf); + u->flags &= ~UFL_ANON_FACTION; + + /* we see the same thing as them when we are an ally */ al = ally_add(&f1->allies, f2); al->status = HELP_FSTEALTH; - - /* report to an allied faction (bug 2305) */ bufunit(f2, u, 0, seen_unit, buf, sizeof(buf)); - CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buf); + CuAssertStrEquals(tc, "Hodor (1), TWW (2) (UFO (1)), 1 human.", buf); + + /* ... also when they are anonymous */ + u->flags |= UFL_ANON_FACTION; + bufunit(f2, u, 0, seen_unit, buf, sizeof(buf)); + CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human.", buf); + u->flags &= ~UFL_ANON_FACTION; + + /* fstealth has no influence when we are allies, same results again */ + set_factionstealth(u, NULL); + bufunit(f2, u, 0, seen_unit, buf, sizeof(buf)); + CuAssertStrEquals(tc, "Hodor (1), UFO(1), 1 human.", buf); + + u->flags |= UFL_ANON_FACTION; + bufunit(f2, u, 0, seen_unit, buf, sizeof(buf)); + CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human.", buf); + u->flags &= ~UFL_ANON_FACTION; test_cleanup(); } -static void test_write_unit(CuTest *tc) { +static void test_bufunit(CuTest *tc) { unit *u; faction *f; race *rc; struct locale *lang; - char buffer[1024]; + char buffer[256]; test_setup(); rc = rc_get_or_create("human"); @@ -231,6 +279,7 @@ static void test_write_unit(CuTest *tc) { f->locale = get_or_create_locale("de"); bufunit(f, u, 0, 0, buffer, sizeof(buffer)); CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buffer); + test_cleanup(); } @@ -620,8 +669,8 @@ CuSuite *get_reports_suite(void) SUITE_ADD_TEST(suite, test_seen_faction); SUITE_ADD_TEST(suite, test_regionid); SUITE_ADD_TEST(suite, test_sparagraph); - SUITE_ADD_TEST(suite, test_write_unit); - SUITE_ADD_TEST(suite, test_bufunit_bug_2305); + SUITE_ADD_TEST(suite, test_bufunit); + SUITE_ADD_TEST(suite, test_bufunit_fstealth); SUITE_ADD_TEST(suite, test_arg_resources); return suite; } diff --git a/tests/runtests.bat b/tests/runtests.bat index 41b5f8056..7a58e5762 100644 --- a/tests/runtests.bat +++ b/tests/runtests.bat @@ -3,6 +3,7 @@ IF EXIST ..\build-vs10 SET BUILD=..\build-vs10\eressea\Debug IF EXIST ..\build-vs11 SET BUILD=..\build-vs11\eressea\Debug IF EXIST ..\build-vs12 SET BUILD=..\build-vs12\eressea\Debug IF EXIST ..\build-vs14 SET BUILD=..\build-vs14\eressea\Debug +IF EXIST ..\build-vs15 SET BUILD=..\build-vs15\eressea\Debug SET SERVER=%BUILD%\eressea.exe %BUILD%\test_eressea.exe %SERVER% ..\scripts\run-tests.lua diff --git a/vs2017-build.bat b/vs2017-build.bat new file mode 100644 index 000000000..7503153fe --- /dev/null +++ b/vs2017-build.bat @@ -0,0 +1,13 @@ +@ECHO OFF +SET VSVERSION=15 +SET SRCDIR=%CD% +CD .. +SET ERESSEA=%CD% + +CD %SRCDIR% +IF exist build-vs%VSVERSION% goto HAVEDIR +mkdir build-vs%VSVERSION% +:HAVEDIR +cd build-vs%VSVERSION% +"%ProgramFiles%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE .. +PAUSE From f54165d4f14df2b95a26046527c74fc0d516312f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 8 Mar 2017 20:30:32 +0100 Subject: [PATCH 669/675] BUG 2309: show true faction to allies. https://bugs.eressea.de/view.php?id=2309 --- src/reports.c | 4 ++++ src/reports.test.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/reports.c b/src/reports.c index aae3d3031..85ab34209 100644 --- a/src/reports.c +++ b/src/reports.c @@ -536,6 +536,10 @@ size_t size) if (wrptr(&bufp, &size, result) != 0) WARN_STATIC_BUFFER(); } + else { + bufp = STRLCPY(bufp, ", ", size); + bufp = STRLCPY(bufp, factionname(fv), size); + } } else { bufp = STRLCPY(bufp, ", ", size); diff --git a/src/reports.test.c b/src/reports.test.c index 65d50c93e..976e9dfe1 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -231,7 +231,7 @@ static void test_bufunit_fstealth(CuTest *tc) { /* fstealth has no influence when we are allies, same results again */ set_factionstealth(u, NULL); bufunit(f2, u, 0, seen_unit, buf, sizeof(buf)); - CuAssertStrEquals(tc, "Hodor (1), UFO(1), 1 human.", buf); + CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buf); u->flags |= UFL_ANON_FACTION; bufunit(f2, u, 0, seen_unit, buf, sizeof(buf)); From be0b54494ee2cf9532175655c09c6636aca2659a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 10 Mar 2017 21:29:37 +0100 Subject: [PATCH 670/675] clean up some tests. the test locale gets some extra strings. test_create_world is bad, stop using it. unfinished. --- src/kernel/alliance.test.c | 3 +- src/kernel/building.test.c | 165 ++++++++++--------------------------- src/kernel/item.c | 1 + src/kernel/unit.test.c | 8 +- src/laws.test.c | 107 +++++++++++------------- src/magic.test.c | 35 ++++---- src/market.test.c | 4 +- src/move.test.c | 24 +++--- src/piracy.test.c | 2 +- src/spy.test.c | 17 +--- src/study.test.c | 11 +-- src/tests.c | 46 +++++++++-- src/tests.h | 5 +- src/tests.test.c | 37 --------- src/upkeep.test.c | 21 +++-- src/vortex.test.c | 2 +- 16 files changed, 186 insertions(+), 302 deletions(-) diff --git a/src/kernel/alliance.test.c b/src/kernel/alliance.test.c index c0ec03fbc..f63767672 100644 --- a/src/kernel/alliance.test.c +++ b/src/kernel/alliance.test.c @@ -17,7 +17,7 @@ typedef struct alliance_fixture { } alliance_fixture; static void setup_alliance(alliance_fixture *fix) { - test_create_world(); + test_setup(); fix->rc = test_create_race("human"); fix->f1 = test_create_faction(fix->rc); fix->f2 = test_create_faction(fix->rc); @@ -49,7 +49,6 @@ static void test_alliance_join(CuTest *tc) { alliance_fixture fix; alliance * al; - test_setup(); setup_alliance(&fix); CuAssertPtrEquals(tc, 0, fix.f1->alliance); CuAssertPtrEquals(tc, 0, fix.f2->alliance); diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c index 2819d4a16..3f415a913 100644 --- a/src/kernel/building.test.c +++ b/src/kernel/building.test.c @@ -40,18 +40,13 @@ static void test_building_set_owner(CuTest * tc) struct building *bld; struct unit *u1, *u2; struct faction *f; - const struct building_type *btype; - const struct race *human; - test_cleanup(); - test_create_world(); + test_setup(); - human = rc_find("human"); - btype = bt_find("castle"); - f = test_create_faction(human); - r = findregion(0, 0); + f = test_create_faction(NULL); + r = test_create_region(0, 0, NULL); - bld = test_create_building(r, btype); + bld = test_create_building(r, NULL); u1 = test_create_unit(f, r); u_set_building(u1, bld); CuAssertPtrEquals(tc, u1, building_owner(bld)); @@ -70,22 +65,13 @@ static void test_buildingowner_goes_to_next_when_empty(CuTest * tc) struct building *bld; struct unit *u, *u2; struct faction *f; - const struct building_type *btype; - const struct race *human; - test_cleanup(); - test_create_world(); + test_setup(); - human = rc_find("human"); - CuAssertPtrNotNull(tc, human); + f = test_create_faction(NULL); + r = test_create_plain(0, 0); - btype = bt_find("castle"); - CuAssertPtrNotNull(tc, btype); - - f = test_create_faction(human); - r = findregion(0, 0); - - bld = test_create_building(r, btype); + bld = test_create_building(r, NULL); CuAssertPtrNotNull(tc, bld); u = test_create_unit(f, r); @@ -105,22 +91,13 @@ static void test_buildingowner_goes_to_other_when_empty(CuTest * tc) struct building *bld; struct unit *u, *u2; struct faction *f; - const struct building_type *btype; - const struct race *human; - test_cleanup(); - test_create_world(); + test_setup(); - human = rc_find("human"); - CuAssertPtrNotNull(tc, human); + f = test_create_faction(NULL); + r = test_create_plain(0, 0); - btype = bt_find("castle"); - CuAssertPtrNotNull(tc, btype); - - f = test_create_faction(human); - r = findregion(0, 0); - - bld = test_create_building(r, btype); + bld = test_create_building(r, NULL); CuAssertPtrNotNull(tc, bld); u2 = test_create_unit(f, r); @@ -141,23 +118,14 @@ static void test_buildingowner_goes_to_same_faction_when_empty(CuTest * tc) struct building *bld; struct unit *u, *u2, *u3; struct faction *f1, *f2; - const struct building_type *btype; - const struct race *human; - test_cleanup(); - test_create_world(); + test_setup(); - human = rc_find("human"); - CuAssertPtrNotNull(tc, human); + f1 = test_create_faction(NULL); + f2 = test_create_faction(NULL); + r = test_create_plain(0, 0); - btype = bt_find("castle"); - CuAssertPtrNotNull(tc, btype); - - f1 = test_create_faction(human); - f2 = test_create_faction(human); - r = findregion(0, 0); - - bld = test_create_building(r, btype); + bld = test_create_building(r, NULL); CuAssertPtrNotNull(tc, bld); u2 = test_create_unit(f2, r); @@ -181,22 +149,12 @@ static void test_buildingowner_goes_to_next_after_leave(CuTest * tc) struct building *bld; struct unit *u, *u2; struct faction *f; - const struct building_type *btype; - const struct race *human; - test_cleanup(); - test_create_world(); + test_setup(); + f = test_create_faction(NULL); + r = test_create_plain(0, 0); - human = rc_find("human"); - CuAssertPtrNotNull(tc, human); - - btype = bt_find("castle"); - CuAssertPtrNotNull(tc, btype); - - f = test_create_faction(human); - r = findregion(0, 0); - - bld = test_create_building(r, btype); + bld = test_create_building(r, NULL); CuAssertPtrNotNull(tc, bld); u = test_create_unit(f, r); @@ -216,22 +174,13 @@ static void test_buildingowner_goes_to_other_after_leave(CuTest * tc) struct building *bld; struct unit *u, *u2; struct faction *f; - const struct building_type *btype; - const struct race *human; - test_cleanup(); - test_create_world(); + test_setup(); - human = rc_find("human"); - CuAssertPtrNotNull(tc, human); + f = test_create_faction(NULL); + r = test_create_plain(0, 0); - btype = bt_find("castle"); - CuAssertPtrNotNull(tc, btype); - - f = test_create_faction(human); - r = findregion(0, 0); - - bld = test_create_building(r, btype); + bld = test_create_building(r, NULL); CuAssertPtrNotNull(tc, bld); u2 = test_create_unit(f, r); @@ -251,23 +200,14 @@ static void test_buildingowner_goes_to_same_faction_after_leave(CuTest * tc) struct building *bld; struct unit *u, *u2, *u3; struct faction *f1, *f2; - const struct building_type *btype; - const struct race *human; - test_cleanup(); - test_create_world(); + test_setup(); - human = rc_find("human"); - CuAssertPtrNotNull(tc, human); + f1 = test_create_faction(NULL); + f2 = test_create_faction(NULL); + r = test_create_plain(0, 0); - btype = bt_find("castle"); - CuAssertPtrNotNull(tc, btype); - - f1 = test_create_faction(human); - f2 = test_create_faction(human); - r = findregion(0, 0); - - bld = test_create_building(r, btype); + bld = test_create_building(r, NULL); CuAssertPtrNotNull(tc, bld); u2 = test_create_unit(f2, r); @@ -293,22 +233,13 @@ static void test_buildingowner_resets_when_empty(CuTest * tc) struct building *bld; struct unit *u; struct faction *f; - const struct building_type *btype; - const struct race *human; - test_cleanup(); - test_create_world(); + test_setup(); - human = rc_find("human"); - CuAssertPtrNotNull(tc, human); + f = test_create_faction(NULL); + r = test_create_plain(0, 0); - btype = bt_find("castle"); - CuAssertPtrNotNull(tc, btype); - - f = test_create_faction(human); - r = findregion(0, 0); - - bld = test_create_building(r, btype); + bld = test_create_building(r, NULL); CuAssertPtrNotNull(tc, bld); u = test_create_unit(f, r); @@ -328,22 +259,13 @@ void test_buildingowner_goes_to_empty_unit_after_leave(CuTest * tc) struct building *bld; struct unit *u1, *u2, *u3; struct faction *f1; - const struct building_type *btype; - const struct race *human; - test_cleanup(); - test_create_world(); + test_setup(); - human = rc_find("human"); - CuAssertPtrNotNull(tc, human); + f1 = test_create_faction(NULL); + r = test_create_plain(0, 0); - btype = bt_find("castle"); - CuAssertPtrNotNull(tc, btype); - - f1 = test_create_faction(human); - r = findregion(0, 0); - - bld = test_create_building(r, btype); + bld = test_create_building(r, NULL); CuAssertPtrNotNull(tc, bld); u1 = test_create_unit(f1, r); @@ -394,16 +316,15 @@ static void test_buildingtype_exists(CuTest * tc) building *b; building_type *btype, *btype2; - test_cleanup(); - test_create_world(); + test_setup(); - btype2 = bt_get_or_create("castle"); + btype2 = test_create_buildingtype("castle"); assert(btype2); - btype = test_create_buildingtype("Hodor"); + btype = test_create_buildingtype("lighhouse"); btype->maxsize = 10; - r = findregion(-1, 0); - b = new_building(btype, r, default_locale); + r = test_create_plain(0, 0); + b = test_create_building(r, btype); CuAssertPtrNotNull(tc, b); b->size = 10; diff --git a/src/kernel/item.c b/src/kernel/item.c index 48ea7a690..605511005 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -981,6 +981,7 @@ void init_resources(void) rtype->flags |= RTF_ITEM | RTF_POOLED; rtype->uchange = res_changeitem; rtype->itype = it_get_or_create(rtype); + rtype->itype->weight = 1; rtype->itype->give = give_money; rtype = rt_get_or_create(resourcenames[R_HORSE]); diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index 7c7bb087b..e1654b821 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -225,12 +225,12 @@ static void test_default_name(CuTest *tc) { struct locale* lang; char buf[32], compare[32]; - test_cleanup(); - test_create_world(); - lang = get_or_create_locale("de"); + test_setup(); + + lang = test_create_locale(); locale_setstring(lang, "unitdefault", "Zweiheit"); - u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0)); + u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0)); default_name(u, buf, sizeof(buf)); diff --git a/src/laws.test.c b/src/laws.test.c index c27651d83..672105e08 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -34,15 +34,12 @@ static void test_new_building_can_be_renamed(CuTest * tc) { region *r; building *b; - building_type *btype; - test_cleanup(); - test_create_world(); + test_setup(); + test_create_locale(); + r = test_create_region(0, 0, 0); - btype = bt_get_or_create("castle"); - r = findregion(-1, 0); - - b = new_building(btype, r, default_locale); + b = test_create_building(r, NULL); CuAssertTrue(tc, !renamed_building(b)); } @@ -54,12 +51,10 @@ static void test_rename_building(CuTest * tc) faction *f; building_type *btype; - test_cleanup(); - test_create_world(); + test_setup(); - btype = bt_get_or_create("castle"); - - r = findregion(-1, 0); + btype = test_create_buildingtype("castle"); + r = test_create_region(0, 0, 0); b = new_building(btype, r, default_locale); f = test_create_faction(NULL); u = test_create_unit(f, r); @@ -78,12 +73,10 @@ static void test_rename_building_twice(CuTest * tc) building *b; building_type *btype; - test_cleanup(); - test_create_world(); + test_setup(); - btype = bt_get_or_create("castle"); - - r = findregion(-1, 0); + btype = test_create_buildingtype("castle"); + r = test_create_region(0, 0, 0); b = new_building(btype, r, default_locale); f = test_create_faction(NULL); u = test_create_unit(f, r); @@ -104,11 +97,10 @@ static void test_contact(CuTest * tc) building_type *btype; ally *al; - test_cleanup(); - test_create_world(); + test_setup(); - btype = bt_get_or_create("castle"); - r = findregion(0, 0); + btype = test_create_buildingtype("castle"); + r = test_create_region(0, 0, 0); b = new_building(btype, r, default_locale); u1 = test_create_unit(test_create_faction(0), r); u2 = test_create_unit(test_create_faction(0), r); @@ -134,13 +126,12 @@ static void test_enter_building(CuTest * tc) building *b; race * rc; - test_cleanup(); - test_create_world(); + test_setup(); - r = findregion(0, 0); + r = test_create_region(0, 0, 0); rc = rc_get_or_create("human"); u = test_create_unit(test_create_faction(rc), r); - b = test_create_building(r, bt_get_or_create("castle")); + b = test_create_building(r, test_create_buildingtype("castle")); rc->flags = RCF_WALK; u->building = 0; @@ -489,7 +480,7 @@ static void setup_pay_cmd(struct pay_fixture *fix) { f = test_create_faction(NULL); r = findregion(0, 0); assert(r && f); - btcastle = bt_get_or_create("castle"); + btcastle = test_create_buildingtype("castle"); btcastle->taxes = level_taxes; b = test_create_building(r, btcastle); assert(b); @@ -530,7 +521,8 @@ static void test_pay_cmd_other_building(CuTest *tc) { test_setup(); setup_pay_cmd(&fix); f = fix.u1->faction; - b = test_create_building(fix.u1->region, bt_get_or_create("lighthouse")); + /* lighthouse is not in the test locale, so we're using castle */ + b = test_create_building(fix.u1->region, test_create_buildingtype("lighthouse")); config_set("rules.region_owners", "1"); config_set("rules.region_owner_pay_building", "lighthouse"); update_owners(b->region); @@ -569,14 +561,13 @@ static void test_new_units(CuTest *tc) { region *r; const struct locale *loc; - test_cleanup(); - test_create_world(); + test_setup(); f = test_create_faction(NULL); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); assert(r && f); u = test_create_unit(f, r); assert(u && !u->next); - loc = get_locale("de"); + loc = test_create_locale(); assert(loc); u->orders = create_order(K_MAKETEMP, loc, "hurr"); new_units(); @@ -598,11 +589,10 @@ void setup_guard(guard_fixture *fix, bool armed) { faction *f; unit * u; - test_cleanup(); - test_create_world(); + test_setup(); f = test_create_faction(NULL); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); assert(r && f); u = test_create_unit(f, r); fset(u, UFL_GUARD); @@ -707,18 +697,18 @@ static void test_reserve_self(CuTest *tc) { const resource_type *rtype; const struct locale *loc; - test_cleanup(); - test_create_world(); + test_setup(); + init_resources(); rtype = get_resourcetype(R_SILVER); assert(rtype && rtype->itype); f = test_create_faction(NULL); - r = findregion(0, 0); + r = test_create_region(0, 0, 0); assert(r && f); u1 = test_create_unit(f, r); u2 = test_create_unit(f, r); assert(u1 && u2); - loc = get_locale("de"); + loc = test_create_locale(); assert(loc); ord = create_order(K_RESERVE, loc, "200 SILBER"); assert(ord); @@ -741,7 +731,7 @@ static void statistic_test(CuTest *tc, int peasants, int luck, int maxp, } static void test_peasant_luck_effect(CuTest *tc) { - test_cleanup(); + test_setup(); config_set("rules.peasants.peasantluck.factor", "10"); config_set("rules.peasants.growth.factor", "0.001"); @@ -891,7 +881,7 @@ static void test_long_order_normal(CuTest *tc) { unit *u; order *ord; - test_cleanup(); + test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); fset(u, UFL_MOVED); fset(u, UFL_LONGACTION); @@ -909,7 +899,7 @@ static void test_long_order_normal(CuTest *tc) { static void test_long_order_none(CuTest *tc) { /* TODO: write more tests */ unit *u; - test_cleanup(); + test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); update_long_order(u); CuAssertPtrEquals(tc, 0, u->thisorder); @@ -921,7 +911,7 @@ static void test_long_order_none(CuTest *tc) { static void test_long_order_cast(CuTest *tc) { /* TODO: write more tests */ unit *u; - test_cleanup(); + test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); unit_addorder(u, create_order(K_CAST, u->faction->locale, 0)); unit_addorder(u, create_order(K_CAST, u->faction->locale, 0)); @@ -935,7 +925,7 @@ static void test_long_order_cast(CuTest *tc) { static void test_long_order_buy_sell(CuTest *tc) { /* TODO: write more tests */ unit *u; - test_cleanup(); + test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); unit_addorder(u, create_order(K_BUY, u->faction->locale, 0)); unit_addorder(u, create_order(K_SELL, u->faction->locale, 0)); @@ -950,7 +940,7 @@ static void test_long_order_buy_sell(CuTest *tc) { static void test_long_order_multi_long(CuTest *tc) { /* TODO: write more tests */ unit *u; - test_cleanup(); + test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); unit_addorder(u, create_order(K_MOVE, u->faction->locale, 0)); unit_addorder(u, create_order(K_DESTROY, u->faction->locale, 0)); @@ -964,7 +954,7 @@ static void test_long_order_multi_long(CuTest *tc) { static void test_long_order_multi_buy(CuTest *tc) { /* TODO: write more tests */ unit *u; - test_cleanup(); + test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); unit_addorder(u, create_order(K_BUY, u->faction->locale, 0)); unit_addorder(u, create_order(K_BUY, u->faction->locale, 0)); @@ -978,7 +968,7 @@ static void test_long_order_multi_buy(CuTest *tc) { static void test_long_order_multi_sell(CuTest *tc) { /* TODO: write more tests */ unit *u; - test_cleanup(); + test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); unit_addorder(u, create_order(K_SELL, u->faction->locale, 0)); unit_addorder(u, create_order(K_BUY, u->faction->locale, 0)); @@ -993,7 +983,7 @@ static void test_long_order_multi_sell(CuTest *tc) { static void test_long_order_buy_cast(CuTest *tc) { /* TODO: write more tests */ unit *u; - test_cleanup(); + test_setup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); unit_addorder(u, create_order(K_BUY, u->faction->locale, 0)); unit_addorder(u, create_order(K_CAST, u->faction->locale, 0)); @@ -1006,7 +996,7 @@ static void test_long_order_buy_cast(CuTest *tc) { static void test_long_order_hungry(CuTest *tc) { unit *u; - test_cleanup(); + test_setup(); config_set("hunger.long", "1"); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); fset(u, UFL_HUNGER); @@ -1145,7 +1135,7 @@ static void test_ally_cmd(CuTest *tc) { static void test_nmr_warnings(CuTest *tc) { faction *f1, *f2; - test_cleanup(); + test_setup(); config_set("nmr.timeout", "3"); f1 = test_create_faction(0); f2 = test_create_faction(0); @@ -1166,7 +1156,7 @@ static void test_nmr_warnings(CuTest *tc) { static unit * setup_mail_cmd(void) { faction *f; - test_cleanup(); + test_setup(); f = test_create_faction(0); return test_create_unit(f, test_create_region(0, 0, 0)); } @@ -1283,7 +1273,7 @@ static void test_show_without_item(CuTest *tc) item *i; struct locale *loc; - test_cleanup(); + test_setup(); loc = get_or_create_locale("de"); locale_setstring(loc, parameters[P_ANY], "ALLE"); @@ -1326,7 +1316,7 @@ static void test_show_elf(CuTest *tc) { struct locale *loc; message * msg; - test_cleanup(); + test_setup(); mt_register(mt_new_va("msg_event", "string:string", 0)); rc = test_create_race("elf"); @@ -1362,7 +1352,7 @@ static void test_show_race(CuTest *tc) { struct locale *loc; message * msg; - test_cleanup(); + test_setup(); mt_register(mt_new_va("msg_event", "string:string", 0)); test_create_race("human"); @@ -1406,9 +1396,8 @@ static void test_immigration(CuTest * tc) double inject[] = { 1 }; int (*old_wage)(const region*, const faction*, const race*, int) = global.functions.wage; - test_cleanup(); - test_create_world(); - r = findregion(0, 0); + test_setup(); + r = test_create_region(0, 0, 0); rsetpeasants(r, 0); config_set("rules.economy.repopulate_maximum", 0); @@ -1442,9 +1431,9 @@ static void test_demon_hunger(CuTest * tc) unit *u; message* msg; - test_cleanup(); - test_create_world(); - r = findregion(0, 0); + test_setup(); + init_resources(); + r = test_create_region(0, 0, 0); rc = test_create_race("demon"); f = test_create_faction(rc); u = test_create_unit(f, r); diff --git a/src/magic.test.c b/src/magic.test.c index a5a842172..a3a199e42 100644 --- a/src/magic.test.c +++ b/src/magic.test.c @@ -87,8 +87,8 @@ void test_pay_spell(CuTest * tc) int level; test_setup(); - test_create_world(); - r = findregion(0, 0); + init_resources(); + r = test_create_region(0, 0, NULL); f = test_create_faction(0); u = test_create_unit(f, r); CuAssertPtrNotNull(tc, u); @@ -121,8 +121,8 @@ void test_pay_spell_failure(CuTest * tc) int level; test_setup(); - test_create_world(); - r = findregion(0, 0); + init_resources(); + r = test_create_region(0, 0, NULL); f = test_create_faction(0); u = test_create_unit(f, r); CuAssertPtrNotNull(tc, u); @@ -159,8 +159,7 @@ void test_getspell_unit(CuTest * tc) struct locale * lang; test_setup(); - test_create_world(); - r = findregion(0, 0); + r = test_create_region(0, 0, 0); f = test_create_faction(0); u = test_create_unit(f, r); create_mage(u, M_GRAY); @@ -168,7 +167,7 @@ void test_getspell_unit(CuTest * tc) set_level(u, SK_MAGIC, 1); - lang = get_locale("de"); + lang = test_create_locale(); sp = create_spell("testspell", 0); locale_setstring(lang, mkname("spell", sp->sname), "Herp-a-derp"); @@ -188,8 +187,7 @@ void test_getspell_faction(CuTest * tc) struct locale * lang; test_setup(); - test_create_world(); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); f = test_create_faction(0); f->magiegebiet = M_TYBIED; u = test_create_unit(f, r); @@ -198,7 +196,7 @@ void test_getspell_faction(CuTest * tc) set_level(u, SK_MAGIC, 1); - lang = get_locale("de"); + lang = test_create_locale(); sp = create_spell("testspell", 0); locale_setstring(lang, mkname("spell", sp->sname), "Herp-a-derp"); @@ -220,8 +218,7 @@ void test_getspell_school(CuTest * tc) struct spellbook * book; test_setup(); - test_create_world(); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); f = test_create_faction(0); f->magiegebiet = M_TYBIED; u = test_create_unit(f, r); @@ -229,7 +226,7 @@ void test_getspell_school(CuTest * tc) enable_skill(SK_MAGIC, true); set_level(u, SK_MAGIC, 1); - lang = get_locale("de"); + lang = test_create_locale(); sp = create_spell("testspell", 0); locale_setstring(lang, mkname("spell", sp->sname), "Herp-a-derp"); @@ -251,8 +248,7 @@ void test_set_pre_combatspell(CuTest * tc) const int index = 0; test_setup(); - test_create_world(); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); f = test_create_faction(0); f->magiegebiet = M_TYBIED; u = test_create_unit(f, r); @@ -284,8 +280,7 @@ void test_set_main_combatspell(CuTest * tc) const int index = 1; test_setup(); - test_create_world(); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); f = test_create_faction(0); f->magiegebiet = M_TYBIED; u = test_create_unit(f, r); @@ -317,8 +312,7 @@ void test_set_post_combatspell(CuTest * tc) const int index = 2; test_setup(); - test_create_world(); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); f = test_create_faction(0); f->magiegebiet = M_TYBIED; u = test_create_unit(f, r); @@ -349,8 +343,7 @@ void test_hasspell(CuTest * tc) struct region * r; test_setup(); - test_create_world(); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); f = test_create_faction(0); f->magiegebiet = M_TYBIED; u = test_create_unit(f, r); diff --git a/src/market.test.c b/src/market.test.c index b4d5f05f5..b70288e90 100644 --- a/src/market.test.c +++ b/src/market.test.c @@ -31,9 +31,7 @@ static void test_market_curse(CuTest * tc) luxury_type *lux; building_type *btype; - free_gamedata(); - test_cleanup(); - test_create_world(); + test_setup(); htype = test_create_itemtype("herb"); htype->flags |= ITF_HERB; diff --git a/src/move.test.c b/src/move.test.c index c444fe4a8..bb3b9d88d 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -158,16 +158,14 @@ static void test_ship_has_harbormaster_ally(CuTest * tc) { } static void test_walkingcapacity(CuTest *tc) { - region *r; unit *u; int cap; const struct item_type *itype; - test_cleanup(); - test_create_world(); + test_setup(); + init_resources(); - r = findregion(0, 0); - u = test_create_unit(test_create_faction(0), r); + u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL)); cap = u->number * (u->_race->capacity + u->_race->weight); CuAssertIntEquals(tc, cap, walkingcapacity(u)); scale_number(u, 2); @@ -183,7 +181,7 @@ static void test_walkingcapacity(CuTest *tc) { cap += itype->capacity; CuAssertIntEquals(tc, cap, walkingcapacity(u)); - itype = it_find("cart"); + itype = test_create_itemtype("cart"); assert(itype); i_change(&u->items, itype, 1); CuAssertIntEquals(tc, cap, walkingcapacity(u)); @@ -265,15 +263,15 @@ struct drift_fixture { }; void setup_drift (struct drift_fixture *fix) { - test_cleanup(); + test_setup(); config_set("rules.ship.storms", "0"); - test_create_world(); test_create_shiptype("drifter"); fix->st_boat = st_get_or_create("drifter"); fix->st_boat->cabins = 20000; - fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r=findregion(-1,0)); + test_create_ocean(0, 0); + fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r = test_create_ocean(-1, 0)); assert(fix->r && fix->u && fix->f); set_level(fix->u, SK_SAILING, fix->st_boat->sumskill); u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat)); @@ -437,9 +435,11 @@ static void test_follow_ship_msg(CuTest * tc) { void *p; test_setup(); - test_create_world(); + init_resources(); + f = test_create_faction(0); - r = findregion(0, 0); + r = test_create_plain(0, 0); + test_create_ocean(-1, 1); /* D_NORTHWEST */ stype = st_find("boat"); sh = test_create_ship(r, stype); @@ -452,7 +452,7 @@ static void test_follow_ship_msg(CuTest * tc) { assert(ord); unit_addorder(u, ord); - set_money(u, 999999); + set_money(u, 999999); /* overloaded ship */ a = a_add(&(r->attribs), a_new(&at_shiptrail)); td = (traveldir *)a->data.v; diff --git a/src/piracy.test.c b/src/piracy.test.c index d690776f1..40e66af18 100644 --- a/src/piracy.test.c +++ b/src/piracy.test.c @@ -116,7 +116,7 @@ static void test_piracy_cmd_errors(CuTest * tc) { st_boat = st_get_or_create("boat"); r = test_create_race("pirates"); u = test_create_unit(f = test_create_faction(r), test_create_region(0, 0, get_or_create_terrain("ocean"))); - f->locale = get_or_create_locale("de"); + f->locale = test_create_locale(); u->thisorder = create_order(K_PIRACY, f->locale, ""); assert(u && u->thisorder); diff --git a/src/spy.test.c b/src/spy.test.c index 0dfaada7a..190cb09a5 100644 --- a/src/spy.test.c +++ b/src/spy.test.c @@ -77,23 +77,12 @@ static void test_all_spy_message(CuTest *tc) { test_cleanup(); } -static void setup_sabotage(void) { - struct locale *lang; - - test_setup(); - lang = get_or_create_locale("de"); - locale_setstring(lang, parameters[P_SHIP], "SCHIFF"); - locale_setstring(lang, parameters[P_ANY], "ALLE"); - init_parameters(lang); - init_locales(); -} - static void test_sabotage_self(CuTest *tc) { unit *u; region *r; order *ord; - setup_sabotage(); + test_setup(); r = test_create_region(0, 0, 0); assert(r); u = test_create_unit(test_create_faction(NULL), r); @@ -115,7 +104,7 @@ static void test_sabotage_other_fail(CuTest *tc) { order *ord; message *msg; - setup_sabotage(); + test_setup(); r = test_create_region(0, 0, 0); assert(r); u = test_create_unit(test_create_faction(NULL), r); @@ -164,7 +153,7 @@ static void test_sabotage_other_success(CuTest *tc) { region *r; order *ord; - setup_sabotage(); + test_setup(); r = test_create_region(0, 0, 0); assert(r); u = test_create_unit(test_create_faction(NULL), r); diff --git a/src/study.test.c b/src/study.test.c index 3b411c7df..74104704b 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -63,8 +63,6 @@ static void setup_locale(struct locale *lang) { if (!locale_getstring(lang, mkname("skill", skillnames[i]))) locale_setstring(lang, mkname("skill", skillnames[i]), skillnames[i]); } - locale_setstring(lang, parameters[P_ANY], "ALLE"); - init_parameters(lang); init_skills(lang); } @@ -76,10 +74,9 @@ static void setup_study(study_fixture *fix, skill_t sk) { assert(fix); test_setup(); config_set("study.random_progress", "0"); - test_create_world(); - r = findregion(0, 0); + r = test_create_region(0, 0, 0); f = test_create_faction(0); - lang = get_or_create_locale(locale_name(f->locale)); + f->locale = lang = test_create_locale(); setup_locale(lang); fix->u = test_create_unit(f, r); assert(fix->u); @@ -145,7 +142,7 @@ static void test_study_bug_2194(CuTest *tc) { test_setup(); random_source_inject_constant(0.0); init_resources(); - loc = get_or_create_locale("de"); + loc = test_create_locale(); setup_locale(loc); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); scale_number(u, 2); @@ -219,7 +216,7 @@ static void test_academy_building(CuTest *tc) { random_source_inject_constant(0.0); init_resources(); - loc = get_or_create_locale("de"); + loc = test_create_locale(); setup_locale(loc); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); scale_number(u, 2); diff --git a/src/tests.c b/src/tests.c index c448a27ae..faa8f6e2e 100644 --- a/src/tests.c +++ b/src/tests.c @@ -53,9 +53,7 @@ struct region *test_create_region(int x, int y, const terrain_type *terrain) r = new_region(x, y, findplane(x, y), 0); } if (!terrain) { - terrain_type *t = get_or_create_terrain("plain"); - t->size = 1000; - fset(t, LAND_REGION|CAVALRY_REGION|FOREST_REGION|FLY_INTO|WALK_INTO); + terrain_type *t = test_create_terrain("plain", LAND_REGION | CAVALRY_REGION | FOREST_REGION | FLY_INTO | WALK_INTO); terraform_region(r, t); } else { @@ -69,12 +67,37 @@ struct region *test_create_region(int x, int y, const terrain_type *terrain) return r; } +region *test_create_ocean(int x, int y) +{ + terrain_type *ter = test_create_terrain("ocean", SEA_REGION | FLY_INTO | SWIM_INTO); + return test_create_region(x, y, ter); +} + +region *test_create_plain(int x, int y) { + return test_create_region(x, y, NULL); +} + struct locale * test_create_locale(void) { struct locale *loc = get_locale("test"); if (!loc) { int i; loc = get_or_create_locale("test"); locale_setstring(loc, "factiondefault", parameters[P_FACTION]); + locale_setstring(loc, "unitdefault", parameters[P_UNIT]); + locale_setstring(loc, "money", "Silber"); + locale_setstring(loc, "money_p", "Silber"); + locale_setstring(loc, "cart", "Wagen"); + locale_setstring(loc, "cart_p", "Wagen"); + locale_setstring(loc, "horse", "Pferd"); + locale_setstring(loc, "horse_p", "Pferde"); + locale_setstring(loc, "iron", "Eisen"); + locale_setstring(loc, "iron_p", "Eisen"); + locale_setstring(loc, "stone", "Stein"); + locale_setstring(loc, "stone_p", "Steine"); + locale_setstring(loc, "plain", "Ebene"); + locale_setstring(loc, "ocean", "Ozean"); + locale_setstring(loc, "race::human", "Mensch"); + locale_setstring(loc, "race::human_p", "Menschen"); for (i = 0; i < MAXSKILLS; ++i) { if (!locale_getstring(loc, mkname("skill", skillnames[i]))) locale_setstring(loc, mkname("skill", skillnames[i]), skillnames[i]); @@ -314,7 +337,7 @@ void test_create_castorder(castorder *co, unit *u, int level, float force, int r struct locale * lang; order *ord; - lang = get_or_create_locale("en"); + lang = test_create_locale(); create_castorder(co, u, NULL, NULL, u->region, level, force, range, ord = create_order(K_CAST, lang, ""), par); free_order(ord); } @@ -373,7 +396,7 @@ void test_create_world(void) item_type * itype; struct locale * loc; - loc = get_or_create_locale("de"); + loc = test_create_locale(); locale_setstring(loc, parameters[P_SHIP], "SCHIFF"); locale_setstring(loc, parameters[P_ANY], "ALLE"); @@ -381,7 +404,18 @@ void test_create_world(void) locale_setstring(loc, "status_aggressive", "aggressiv"); locale_setstring(loc, keyword(K_RESERVE), "RESERVIEREN"); - locale_setstring(loc, "money", "SILBER"); + locale_setstring(loc, "money", "Silber"); + locale_setstring(loc, "money_p", "Silber"); + locale_setstring(loc, "cart", "Wagen"); + locale_setstring(loc, "cart_p", "Wagen"); + locale_setstring(loc, "horse", "Pferd"); + locale_setstring(loc, "horse_p", "Pferde"); + locale_setstring(loc, "iron", "Eisen"); + locale_setstring(loc, "iron_p", "Eisen"); + locale_setstring(loc, "stone", "Stein"); + locale_setstring(loc, "stone_p", "Steine"); + locale_setstring(loc, "plain", "Ebene"); + locale_setstring(loc, "ocean", "Ozean"); init_resources(); get_resourcetype(R_SILVER)->itype->weight = 1; diff --git a/src/tests.h b/src/tests.h index c99147e6a..669318d99 100644 --- a/src/tests.h +++ b/src/tests.h @@ -43,8 +43,9 @@ extern "C" { struct locale * test_create_locale(void); struct terrain_type * test_create_terrain(const char * name, unsigned int flags); struct race *test_create_race(const char *name); - struct region *test_create_region(int x, int y, - const struct terrain_type *terrain); + struct region *test_create_region(int x, int y, const struct terrain_type *terrain); + struct region *test_create_ocean(int x, int y); + struct region *test_create_plain(int x, int y); struct faction *test_create_faction(const struct race *rc); struct unit *test_create_unit(struct faction *f, struct region *r); void test_create_world(void); diff --git a/src/tests.test.c b/src/tests.test.c index 9dd47e4d1..880956e8b 100644 --- a/src/tests.test.c +++ b/src/tests.test.c @@ -34,46 +34,9 @@ static void test_resources(CuTest *tc) { CuAssertPtrEquals(tc, (void *)rtype, (void *)get_resourcetype(R_STONE)); } -static void test_recreate_world(CuTest * tc) -{ - test_setup(); - CuAssertPtrEquals(tc, 0, get_locale("de")); - CuAssertPtrEquals(tc, 0, (void *)rt_find("horse")); - - test_create_world(); - CuAssertPtrEquals(tc, default_locale, get_locale("de")); - CuAssertPtrNotNull(tc, default_locale); - CuAssertPtrNotNull(tc, findregion(0, 0)); - CuAssertPtrNotNull(tc, get_terrain("plain")); - CuAssertPtrNotNull(tc, get_terrain("ocean")); - CuAssertPtrNotNull(tc, (void *)rt_find("horse")); - CuAssertPtrNotNull(tc, get_resourcetype(R_HORSE)); - CuAssertPtrNotNull(tc, (void *)rt_find("money")); - CuAssertPtrNotNull(tc, get_resourcetype(R_LIFE)); - CuAssertPtrNotNull(tc, get_resourcetype(R_SILVER)); - CuAssertPtrNotNull(tc, get_resourcetype(R_AURA)); - CuAssertPtrNotNull(tc, get_resourcetype(R_PERMAURA)); - CuAssertPtrNotNull(tc, get_resourcetype(R_PEASANT)); - - test_cleanup(); - CuAssertPtrEquals(tc, 0, get_locale("de")); - CuAssertPtrEquals(tc, 0, (void*)get_terrain("plain")); - CuAssertPtrEquals(tc, 0, (void*)get_terrain("ocean")); - CuAssertPtrEquals(tc, 0, (void*)rt_find("horse")); - CuAssertPtrEquals(tc, 0, (void*)get_resourcetype(R_HORSE)); - CuAssertPtrEquals(tc, 0, (void *)rt_find("money")); - CuAssertPtrEquals(tc, 0, (void *)get_resourcetype(R_LIFE)); - CuAssertPtrEquals(tc, 0, (void *)get_resourcetype(R_SILVER)); - CuAssertPtrEquals(tc, 0, (void *)get_resourcetype(R_AURA)); - CuAssertPtrEquals(tc, 0, (void *)get_resourcetype(R_PERMAURA)); - CuAssertPtrEquals(tc, 0, (void *)get_resourcetype(R_PEASANT)); - CuAssertPtrEquals(tc, 0, findregion(0, 0)); -} - CuSuite *get_tests_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_resources); - SUITE_ADD_TEST(suite, test_recreate_world); return suite; } diff --git a/src/upkeep.test.c b/src/upkeep.test.c index 2a91a0df1..bc53d5bbc 100644 --- a/src/upkeep.test.c +++ b/src/upkeep.test.c @@ -20,11 +20,10 @@ void test_upkeep_default(CuTest * tc) const item_type *i_silver; test_setup(); - test_create_world(); - + init_resources(); i_silver = it_find("money"); assert(i_silver); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); f1 = test_create_faction(test_create_race("human")); f2 = test_create_faction(test_create_race("human")); assert(f1 && f2); @@ -51,11 +50,11 @@ void test_upkeep_hunger_damage(CuTest * tc) const item_type *i_silver; test_setup(); - test_create_world(); + init_resources(); i_silver = it_find("money"); assert(i_silver); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); f1 = test_create_faction(test_create_race("human")); u1 = test_create_unit(f1, r); assert(r && u1); @@ -76,11 +75,11 @@ void test_upkeep_from_pool(CuTest * tc) const item_type *i_silver; test_setup(); - test_create_world(); + init_resources(); i_silver = it_find("money"); assert(i_silver); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); assert(r); u1 = test_create_unit(test_create_faction(test_create_race("human")), r); assert(u1); @@ -110,11 +109,11 @@ void test_upkeep_from_friend(CuTest * tc) const item_type *i_silver; test_setup(); - test_create_world(); + init_resources(); i_silver = it_find("money"); assert(i_silver); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); f1 = test_create_faction(test_create_race("human")); f2 = test_create_faction(test_create_race("human")); assert(f1 && f2); @@ -144,11 +143,11 @@ void test_upkeep_free(CuTest * tc) const item_type *i_silver; test_setup(); - test_create_world(); + init_resources(); i_silver = it_find("money"); assert(i_silver); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); u = test_create_unit(test_create_faction(test_create_race("human")), r); assert(r && u); diff --git a/src/vortex.test.c b/src/vortex.test.c index 21ea6596c..b4940b6bc 100644 --- a/src/vortex.test.c +++ b/src/vortex.test.c @@ -23,7 +23,7 @@ static void test_move_to_vortex(CuTest *tc) { struct locale *lang; test_setup(); - lang = get_or_create_locale("en"); + lang = test_create_locale(); locale_setstring(lang, "vortex", "wirbel"); init_locale(lang); t_plain = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION); From fe95ddafa112f5cb85bfa81decdf51362e38aa2e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 10 Mar 2017 21:43:36 +0100 Subject: [PATCH 671/675] reduce "translation not found" warnings in tests. --- src/laws.test.c | 29 ++++++++++++++--------------- src/move.test.c | 4 ++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/laws.test.c b/src/laws.test.c index 672105e08..0f61c7613 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -52,7 +52,7 @@ static void test_rename_building(CuTest * tc) building_type *btype; test_setup(); - + test_create_locale(); btype = test_create_buildingtype("castle"); r = test_create_region(0, 0, 0); b = new_building(btype, r, default_locale); @@ -74,7 +74,7 @@ static void test_rename_building_twice(CuTest * tc) building_type *btype; test_setup(); - + test_create_locale(); btype = test_create_buildingtype("castle"); r = test_create_region(0, 0, 0); b = new_building(btype, r, default_locale); @@ -98,7 +98,7 @@ static void test_contact(CuTest * tc) ally *al; test_setup(); - + test_create_locale(); btype = test_create_buildingtype("castle"); r = test_create_region(0, 0, 0); b = new_building(btype, r, default_locale); @@ -127,9 +127,9 @@ static void test_enter_building(CuTest * tc) race * rc; test_setup(); - + test_create_locale(); r = test_create_region(0, 0, 0); - rc = rc_get_or_create("human"); + rc = test_create_race("human"); u = test_create_unit(test_create_faction(rc), r); b = test_create_building(r, test_create_buildingtype("castle")); @@ -1270,7 +1270,6 @@ static void test_show_without_item(CuTest *tc) unit *u; order *ord; item_type *itype; - item *i; struct locale *loc; test_setup(); @@ -1283,26 +1282,26 @@ static void test_show_without_item(CuTest *tc) f = test_create_faction(test_create_race("human")); u = test_create_unit(f, r); + itype = it_get_or_create(rt_get_or_create("testitem")); + ord = create_order(K_RESHOW, f->locale, "testname"); - itype = it_get_or_create(rt_get_or_create("testitem")); - i = i_new(itype, 1); - reshow_cmd(u, ord); - CuAssertTrue(tc, test_find_messagetype(f->msgs, "error21") != NULL); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error21")); test_clear_messages(f); locale_setstring(loc, "testitem", "testname"); locale_setstring(loc, "iteminfo::testitem", "testdescription"); + reshow_cmd(u, ord); - CuAssertTrue(tc, test_find_messagetype(f->msgs, "error21") == NULL); - CuAssertTrue(tc, test_find_messagetype(f->msgs, "error36") != NULL); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error21")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error36")); test_clear_messages(f); - i_add(&(u->items), i); + i_add(&(u->items), i_new(itype, 1)); reshow_cmd(u, ord); - CuAssertTrue(tc, test_find_messagetype(f->msgs, "error21") == NULL); - CuAssertTrue(tc, test_find_messagetype(f->msgs, "error36") == NULL); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error21")); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error36")); test_clear_messages(f); free_order(ord); diff --git a/src/move.test.c b/src/move.test.c index bb3b9d88d..ab30300e8 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -264,10 +264,10 @@ struct drift_fixture { void setup_drift (struct drift_fixture *fix) { test_setup(); + test_create_locale(); config_set("rules.ship.storms", "0"); - test_create_shiptype("drifter"); - fix->st_boat = st_get_or_create("drifter"); + fix->st_boat = test_create_shiptype("boat"); fix->st_boat->cabins = 20000; test_create_ocean(0, 0); From 8b9f0f08942ef60bed449123cdf5c8843945d434 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 10 Mar 2017 23:18:09 +0100 Subject: [PATCH 672/675] BUG 2307: report mallorn trees as Mallorn in the CR. for legacy compatibility, we cannot call them Mallornbaeume. --- res/core/de/strings.xml | 8 ++--- src/creport.c | 8 +++-- src/creport.test.c | 70 ++++++++++++++++++++++++++++++++++++----- src/reports.c | 28 ++++++++--------- 4 files changed, 87 insertions(+), 27 deletions(-) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index d69c0919f..a39657580 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -484,13 +484,13 @@ - Mallornbaum - mallorn tree + Mallorn + mallorn - Mallornbäume - mallorn trees + Mallorn + mallorn diff --git a/src/creport.c b/src/creport.c index f22096f19..d16f87f22 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1094,12 +1094,16 @@ static void cr_reportspell(FILE * F, spell * sp, int level, const struct locale static char *cr_output_resource(char *buf, const resource_type *rtype, const struct locale *loc, int amount, int level) { - const char * name; + const char *name, *tname; assert(rtype); name = resourcename(rtype, 1); assert(name); buf += sprintf(buf, "RESOURCE %u\n", hashstring(rtype->_name)); - buf += sprintf(buf, "\"%s\";type\n", translate(name, LOC(loc, rtype->_name))); + tname = LOC(loc, rtype->_name); + assert(tname); + tname = translate(name, tname); + assert(tname); + buf += sprintf(buf, "\"%s\";type\n", tname); if (amount >= 0) { if (level >= 0) buf += sprintf(buf, "%d;skill\n", level); diff --git a/src/creport.test.c b/src/creport.test.c index acd6201f9..46e6e6967 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -50,11 +50,7 @@ static void test_cr_unit(CuTest *tc) { test_cleanup(); } -static void test_cr_resources(CuTest *tc) { - stream strm; - char line[1024]; - faction *f; - region *r; +static void setup_resources(void) { struct locale *lang; test_setup(); @@ -70,6 +66,19 @@ static void test_cr_resources(CuTest *tc) { locale_setstring(lang, "tree_p", "Blumen"); locale_setstring(lang, "sapling", "Schoessling"); locale_setstring(lang, "sapling_p", "Schoesslinge"); + locale_setstring(lang, "mallornsapling", "Mallornschoessling"); + locale_setstring(lang, "mallornsapling_p", "Mallornschoesslinge"); + locale_setstring(lang, "mallorntree", "Mallorn"); + locale_setstring(lang, "mallorntree_p", "Mallorn"); +} + +static void test_cr_resources(CuTest *tc) { + stream strm; + char line[1024]; + faction *f; + region *r; + + setup_resources(); f = test_create_faction(0); r = test_create_region(0, 0, 0); @@ -88,6 +97,20 @@ static void test_cr_resources(CuTest *tc) { CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, "2;Schoesslinge", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "\"Schoesslinge\";type", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "2;number", line); + + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "\"Blumen\";type", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "3;number", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); @@ -109,17 +132,49 @@ static void test_cr_resources(CuTest *tc) { CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, "1;number", line); + mstream_done(&strm); + test_cleanup(); +} + +static void test_cr_mallorn(CuTest *tc) { + stream strm; + char line[1024]; + faction *f; + region *r; + + setup_resources(); + + f = test_create_faction(0); + r = test_create_region(0, 0, 0); + r->land->horses = 1; + r->land->peasants = 200; + r->land->money = 300; + r->flags |= RF_MALLORN; + rsettrees(r, 0, 1); + rsettrees(r, 1, 2); + rsettrees(r, 2, 3); + + mstream_init(&strm); + cr_output_resources(&strm, f, r, false); + strm.api->rewind(strm.handle); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "3;Baeume", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "2;Schoesslinge", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "1;Mallorn", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); - CuAssertStrEquals(tc, "\"Schoesslinge\";type", line); + CuAssertStrEquals(tc, "\"Mallornschoesslinge\";type", line); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, "2;number", line); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); - CuAssertStrEquals(tc, "\"Blumen\";type", line); + CuAssertStrEquals(tc, "\"Mallorn\";type", line); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, "3;number", line); @@ -247,6 +302,7 @@ CuSuite *get_creport_suite(void) CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_cr_unit); SUITE_ADD_TEST(suite, test_cr_resources); + SUITE_ADD_TEST(suite, test_cr_mallorn); SUITE_ADD_TEST(suite, test_cr_factionstealth); return suite; } diff --git a/src/reports.c b/src/reports.c index 85ab34209..c23809a32 100644 --- a/src/reports.c +++ b/src/reports.c @@ -410,6 +410,20 @@ const faction * viewer, bool see_unit) bool mallorn = fval(r, RF_MALLORN) != 0; const resource_type *rtype; + if (saplings) { + if (n >= size) + return -1; + rtype = get_resourcetype(mallorn ? R_MALLORN_SAPLING : R_SAPLING); + report_resource(result + n, rtype, saplings, -1); + ++n; + } + if (trees) { + if (n >= size) + return -1; + rtype = get_resourcetype(mallorn ? R_MALLORN_TREE : R_TREE); + report_resource(result + n, rtype, trees, -1); + ++n; + } if (money) { if (n >= size) return -1; @@ -428,20 +442,6 @@ const faction * viewer, bool see_unit) report_resource(result + n, get_resourcetype(R_HORSE), horses, -1); ++n; } - if (saplings) { - if (n >= size) - return -1; - rtype = get_resourcetype(mallorn ? R_MALLORN_SAPLING : R_SAPLING); - report_resource(result + n, rtype, saplings, -1); - ++n; - } - if (trees) { - if (n >= size) - return -1; - rtype = get_resourcetype(mallorn ? R_MALLORN_TREE : R_TREE); - report_resource(result + n, rtype, trees, -1); - ++n; - } } if (see_unit) { From 98a48edb9ad40efe9b333d977a17f8a35a565813 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Mar 2017 12:25:49 +0100 Subject: [PATCH 673/675] I've got a 64-bit CMake on Windows now. --- vs2015-build.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs2015-build.bat b/vs2015-build.bat index 6c39659d1..262d498bf 100644 --- a/vs2015-build.bat +++ b/vs2015-build.bat @@ -9,5 +9,5 @@ IF exist build-vs%VSVERSION% goto HAVEDIR mkdir build-vs%VSVERSION% :HAVEDIR cd build-vs%VSVERSION% -"%ProgramFiles(x86)%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE .. +"%ProgramFiles%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE .. PAUSE From 41c679396449b09be1da65421f94326ff5fb0b4b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Mar 2017 12:57:02 +0100 Subject: [PATCH 674/675] matching test_setup and test_cleanup calls. --- src/laws.test.c | 38 ++++++++++++++++++++++++++------------ src/market.test.c | 1 + 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/laws.test.c b/src/laws.test.c index 0f61c7613..937754988 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -41,6 +41,7 @@ static void test_new_building_can_be_renamed(CuTest * tc) b = test_create_building(r, NULL); CuAssertTrue(tc, !renamed_building(b)); + test_cleanup(); } static void test_rename_building(CuTest * tc) @@ -63,6 +64,7 @@ static void test_rename_building(CuTest * tc) rename_building(u, NULL, b, "Villa Nagel"); CuAssertStrEquals(tc, "Villa Nagel", b->name); CuAssertTrue(tc, renamed_building(b)); + test_cleanup(); } static void test_rename_building_twice(CuTest * tc) @@ -87,6 +89,7 @@ static void test_rename_building_twice(CuTest * tc) rename_building(u, NULL, b, "Villa Kunterbunt"); CuAssertStrEquals(tc, "Villa Kunterbunt", b->name); + test_cleanup(); } static void test_contact(CuTest * tc) @@ -117,6 +120,7 @@ static void test_contact(CuTest * tc) CuAssertIntEquals(tc, HELP_GIVE, can_contact(r, u1, u2)); u_set_building(u2, b); CuAssertIntEquals(tc, 1, can_contact(r, u1, u2)); + test_cleanup(); } static void test_enter_building(CuTest * tc) @@ -229,6 +233,7 @@ static void test_display_cmd(CuTest *tc) { } static void test_rule_force_leave(CuTest *tc) { + test_setup(); config_set("rules.owners.force_leave", "0"); CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_ALL)); CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_POSTCOMBAT)); @@ -241,6 +246,7 @@ static void test_rule_force_leave(CuTest *tc) { config_set("rules.owners.force_leave", "3"); CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_ALL)); CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_POSTCOMBAT)); + test_cleanup(); } static void test_force_leave_buildings(CuTest *tc) { @@ -249,7 +255,8 @@ static void test_force_leave_buildings(CuTest *tc) { unit *u1, *u2, *u3; building * b; message *msg; - test_cleanup(); + + test_setup(); r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION)); u1 = test_create_unit(test_create_faction(NULL), r); u2 = test_create_unit(u1->faction, r); @@ -279,7 +286,8 @@ static void test_force_leave_ships(CuTest *tc) { unit *u1, *u2; ship *sh; message *msg; - test_cleanup(); + + test_setup(); r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION)); u1 = test_create_unit(test_create_faction(NULL), r); u2 = test_create_unit(test_create_faction(NULL), r); @@ -298,7 +306,8 @@ static void test_force_leave_ships_on_ocean(CuTest *tc) { region *r; unit *u1, *u2; ship *sh; - test_cleanup(); + + test_setup(); r = test_create_region(0, 0, test_create_terrain("ocean", SEA_REGION)); u1 = test_create_unit(test_create_faction(NULL), r); u2 = test_create_unit(test_create_faction(NULL), r); @@ -319,7 +328,7 @@ static void test_fishing_feeds_2_people(CuTest * tc) unit *u; ship *sh; - test_cleanup(); + test_setup(); test_create_world(); r = findregion(-1, 0); CuAssertStrEquals(tc, "ocean", r->terrain->_name); /* test_create_world needs coverage */ @@ -344,6 +353,7 @@ static void test_fishing_feeds_2_people(CuTest * tc) sh->flags |= SF_FISHING; get_food(r); CuAssertIntEquals(tc, 32, i_get(u->items, rtype->itype)); + test_cleanup(); } static void test_fishing_does_not_give_goblins_money(CuTest * tc) @@ -354,7 +364,7 @@ static void test_fishing_does_not_give_goblins_money(CuTest * tc) unit *u; ship *sh; - test_cleanup(); + test_setup(); test_create_world(); rtype = get_resourcetype(R_SILVER); @@ -370,6 +380,7 @@ static void test_fishing_does_not_give_goblins_money(CuTest * tc) sh->flags |= SF_FISHING; get_food(r); CuAssertIntEquals(tc, 42, i_get(u->items, rtype->itype)); + test_cleanup(); } static void test_fishing_gets_reset(CuTest * tc) @@ -380,7 +391,7 @@ static void test_fishing_gets_reset(CuTest * tc) unit *u; ship *sh; - test_cleanup(); + test_setup(); test_create_world(); rtype = get_resourcetype(R_SILVER); r = findregion(-1, 0); @@ -399,10 +410,12 @@ static void test_fishing_gets_reset(CuTest * tc) scale_number(u, 1); get_food(r); CuAssertIntEquals(tc, 32, i_get(u->items, rtype->itype)); + test_cleanup(); } static void test_unit_limit(CuTest * tc) { + test_setup(); config_set("rules.limit.faction", "250"); CuAssertIntEquals(tc, 250, rule_faction_limit()); @@ -411,7 +424,7 @@ static void test_unit_limit(CuTest * tc) config_set("rules.limit.alliance", "250"); CuAssertIntEquals(tc, 250, rule_alliance_limit()); - + test_cleanup(); } extern int checkunitnumber(const faction * f, int add); @@ -419,7 +432,7 @@ static void test_cannot_create_unit_above_limit(CuTest * tc) { faction *f; - test_cleanup(); + test_setup(); test_create_world(); f = test_create_faction(NULL); config_set("rules.limit.faction", "4"); @@ -430,6 +443,7 @@ static void test_cannot_create_unit_above_limit(CuTest * tc) config_set("rules.limit.alliance", "3"); CuAssertIntEquals(tc, 0, checkunitnumber(f, 3)); CuAssertIntEquals(tc, 1, checkunitnumber(f, 4)); + test_cleanup(); } static void test_reserve_cmd(CuTest *tc) { @@ -439,7 +453,7 @@ static void test_reserve_cmd(CuTest *tc) { order *ord; const resource_type *rtype; - test_cleanup(); + test_setup(); test_create_world(); rtype = get_resourcetype(R_SILVER); @@ -499,7 +513,7 @@ static void test_pay_cmd(CuTest *tc) { faction *f; building *b; - test_cleanup(); + test_setup(); setup_pay_cmd(&fix); b = fix.u1->building; f = fix.u1->faction; @@ -542,7 +556,7 @@ static void test_pay_cmd_must_be_owner(CuTest *tc) { faction *f; building *b; - test_cleanup(); + test_setup(); setup_pay_cmd(&fix); b = fix.u1->building; f = fix.u1->faction; @@ -1321,7 +1335,7 @@ static void test_show_elf(CuTest *tc) { rc = test_create_race("elf"); test_create_itemtype("elvenhorse"); - loc = get_or_create_locale("de"); + loc = test_create_locale(); locale_setstring(loc, "elvenhorse", "Elfenpferd"); locale_setstring(loc, "elvenhorse_p", "Elfenpferde"); locale_setstring(loc, "race::elf_p", "Elfen"); diff --git a/src/market.test.c b/src/market.test.c index b70288e90..a631dbcb7 100644 --- a/src/market.test.c +++ b/src/market.test.c @@ -76,6 +76,7 @@ static void test_market_curse(CuTest * tc) CuAssertIntEquals(tc, 70, i_get(u->items, htype)); CuAssertIntEquals(tc, 35, i_get(u->items, ltype)); + test_cleanup(); } static void test_rc_trade(CuTest *tc) { From cdf13c9fec49288d52e5286d263bdf8329e211d8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Mar 2017 14:22:21 +0100 Subject: [PATCH 675/675] stop using test_create_world, use test_setup. --- src/economy.test.c | 24 +++++++++++------------- src/give.test.c | 3 +-- src/kernel/faction.test.c | 6 ++---- src/reports.test.c | 15 ++++----------- src/spells/magicresistance.test.c | 18 ++++++++---------- 5 files changed, 26 insertions(+), 40 deletions(-) diff --git a/src/economy.test.c b/src/economy.test.c index e14b473b4..7534afe7e 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -128,12 +128,9 @@ static struct unit *create_recruiter(void) { unit *u; const resource_type* rtype; - test_cleanup(); - test_create_world(); - - r=findregion(0, 0); + r=test_create_region(0, 0, NULL); rsetpeasants(r, 999); - f = test_create_faction(rc_find("human")); + f = test_create_faction(NULL); u = test_create_unit(f, r); rtype = get_resourcetype(R_SILVER); change_resource(u, rtype, 1000); @@ -143,9 +140,10 @@ static struct unit *create_recruiter(void) { static void test_heroes_dont_recruit(CuTest * tc) { unit *u; - test_cleanup(); - + test_setup(); + init_resources(); u = create_recruiter(); + fset(u, UFL_HERO); unit_addorder(u, create_order(K_RECRUIT, default_locale, "1")); @@ -160,8 +158,8 @@ static void test_heroes_dont_recruit(CuTest * tc) { static void test_normals_recruit(CuTest * tc) { unit *u; - test_cleanup(); - + test_setup(); + init_resources(); u = create_recruiter(); unit_addorder(u, create_order(K_RECRUIT, default_locale, "1")); @@ -193,11 +191,11 @@ static void test_tax_cmd(CuTest *tc) { request *taxorders = 0; - test_cleanup(); + test_setup(); + init_resources(); config_set("taxing.perlevel", "20"); - test_create_world(); f = test_create_faction(NULL); - r = findregion(0, 0); + r = test_create_region(0, 0, NULL); assert(r && f); u = test_create_unit(f, r); @@ -210,7 +208,7 @@ static void test_tax_cmd(CuTest *tc) { silver = get_resourcetype(R_SILVER)->itype; - sword = it_get_or_create(rt_get_or_create("sword")); + sword = test_create_itemtype("sword"); new_weapontype(sword, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 1); i_change(&u->items, sword, 1); set_level(u, SK_MELEE, 1); diff --git a/src/give.test.c b/src/give.test.c index 33f70fb90..1767dec36 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -324,8 +324,7 @@ static void test_give_herbs(CuTest * tc) { struct order *ord; test_setup_ex(tc); - test_create_world(); - env.f2 = env.f1 = test_create_faction(0); + env.f2 = env.f1 = test_create_faction(NULL); setup_give(&env); i_change(&env.src->items, env.itype, 10); diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index c01731964..80faba3c1 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -153,8 +153,7 @@ static void test_set_origin(CuTest *tc) { int x = 0, y = 0; plane *pl; - test_cleanup(); - test_create_world(); + test_setup(); pl = create_new_plane(0, "", 0, 19, 0, 19, 0); f = test_create_faction(0); CuAssertPtrEquals(tc, 0, f->ursprung); @@ -179,8 +178,7 @@ static void test_set_origin_bug(CuTest *tc) { plane *pl; int x = 17, y = 10; - test_cleanup(); - test_create_world(); + test_setup(); pl = create_new_plane(0, "", 0, 19, 0, 19, 0); f = test_create_faction(0); faction_setorigin(f, 0, -10, 3); diff --git a/src/reports.test.c b/src/reports.test.c index 976e9dfe1..f66d94684 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -45,18 +45,11 @@ static void test_reorder_units(CuTest * tc) ship * s; unit *u0, *u1, *u2, *u3, *u4; struct faction * f; - const building_type *btype; - const ship_type *stype; - test_cleanup(); - test_create_world(); - - btype = bt_find("castle"); - stype = st_find("boat"); - - r = findregion(-1, 0); - b = test_create_building(r, btype); - s = test_create_ship(r, stype); + test_setup(); + r = test_create_region(0, 0, NULL); + b = test_create_building(r, NULL); + s = test_create_ship(r, NULL); f = test_create_faction(0); u0 = test_create_unit(f, r); diff --git a/src/spells/magicresistance.test.c b/src/spells/magicresistance.test.c index e9cc98e34..621d2c3b4 100644 --- a/src/spells/magicresistance.test.c +++ b/src/spells/magicresistance.test.c @@ -28,13 +28,12 @@ static void test_magicresistance_unit(CuTest *tc) { message *msg; curse *c; - test_cleanup(); - test_create_world(); - r=findregion(0, 0); - f1 = test_create_faction(test_create_race("human")); + test_setup(); + r = test_create_plain(0, 0); + f1 = test_create_faction(NULL); u1 = test_create_unit(f1, r); - f2 = test_create_faction(test_create_race("human")); + f2 = test_create_faction(NULL); u2 = test_create_unit(f2, r); c = create_curse(u1, &u2->attribs, ct_find("magicresistance"), 10, 20, 30, u2->number); @@ -56,13 +55,12 @@ static void test_magicresistance_building(CuTest *tc) { message *msg; curse *c; - test_cleanup(); - test_create_world(); - r = findregion(0, 0); - f1 = test_create_faction(test_create_race("human")); + test_setup(); + r = test_create_plain(0, 0); + f1 = test_create_faction(NULL); u1 = test_create_unit(f1, r); - b1 = test_create_building(r, test_create_buildingtype("castle")); + b1 = test_create_building(r, NULL); c = create_curse(u1, &b1->attribs, ct_find("magicresistance"), 10, 20, 30, 0); CuAssertPtrNotNull(tc, b1->attribs);