From 325dd3d2cc052c548c6903447f35b99e1c288dbe Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Feb 2004 12:19:50 +0000 Subject: [PATCH] =?UTF-8?q?Bessere=20Zuornung=20der=20Aufrufe=20von=20last?= =?UTF-8?q?region=20und=20firstregion,=20f=C3=BCr=20den=20Profiler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/gamecode/randenc.c | 4 ++-- src/common/gamecode/report.c | 14 +++++++------- src/common/kernel/eressea.c | 24 +++++++++++++----------- src/common/kernel/reports.c | 20 ++++++++++++-------- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/common/gamecode/randenc.c b/src/common/gamecode/randenc.c index fb6941f20..1e4e68efb 100644 --- a/src/common/gamecode/randenc.c +++ b/src/common/gamecode/randenc.c @@ -172,9 +172,9 @@ improve_all(faction * f, skill_t sk, int weeks) region *r; unit *u; int n = 0; - region *last = lastregion(f); + region *last = f->last?f->last:lastregion(f); - for (r = firstregion(f); r != last; r = r->next) { + for (r = f->first?f->first:firstregion(f); r != last; r = r->next) { for (u = r->units; u; u = u->next) { if (u->faction == f && has_skill(u, sk)) { for (n=0;n!=weeks;++n) { diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 8e5866c50..7ace358ae 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -1556,7 +1556,7 @@ order_template(FILE * F, faction * f) plane *pl; unit *u; int dh; - region *last = lastregion(f); + region *last = f->last?f->last:lastregion(f); rps_nowrap(F, ""); rnl(F); @@ -1579,7 +1579,7 @@ order_template(FILE * F, faction * f) rps_nowrap(F, buf); rnl(F); - for (r = firstregion(f); r != last; r = r->next) { + for (r = f->first?f->first:firstregion(f); r != last; r = r->next) { dh = 0; for (u = r->units; u; u = u->next) if (u->faction == f && u->race != new_race[RC_SPELL]) { @@ -1963,7 +1963,7 @@ report(FILE *F, faction * f, const faction_list * addresses, int dh; int anyunits; const struct region *r; - region * last = lastregion(f); + region * last = f->last?f->last:lastregion(f); building *b; ship *sh; unit *u; @@ -2203,7 +2203,7 @@ report(FILE *F, faction * f, const faction_list * addresses, anyunits = 0; - for (r=firstregion(f);r!=last;r=r->next) { + for (r=f->first?f->first:firstregion(f);r!=last;r=r->next) { boolean unit_in_region = false; boolean durchgezogen_in_region = false; int turm_sieht_region = false; @@ -2796,10 +2796,10 @@ view_regatta(region * r, faction * f) static void prepare_report(faction * f) { - region * r; - region * end = lastregion(f); + region * r; + region * end = f->last?f->last:lastregion(f); seen_init(); - for (r = firstregion(f); r != end; r = r->next) { + for (r = f->first?f->first:firstregion(f); r != end; r = r->next) { attrib *ru; unit * u; plane * p = rplane(r); diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 622bd5de8..7f99b4d5a 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -439,17 +439,19 @@ count_all_money(const region * r) int count_skill(faction * f, skill_t sk) { - int n = 0; - region *r; - unit *u; - region *last = lastregion(f); - - for (r = firstregion(f); r != last; r = r->next) - for (u = r->units; u; u = u->next) - if (u->faction == f && has_skill(u, sk)) - if (!is_familiar(u)) n += u->number; - - return n; + int n = 0; + region *r; + unit *u; + region *last = f->last?f->last:lastregion(f); + + for (r =f->first?f->first:firstregion(f); r != last; r = r->next) { + for (u = r->units; u; u = u->next) { + if (u->faction == f && has_skill(u, sk)) { + if (!is_familiar(u)) n += u->number; + } + } + } + return n; } int quiet = 0; diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index 05718055c..f641a8299 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -856,16 +856,17 @@ visible_faction(const faction *f, const unit * u) faction_list * get_addresses(faction * f) { +#if 0 /* "TODO: travelthru" */ - region *r, *last = lastregion(f); - const faction * lastf = NULL; - faction_list * flist = calloc(1, sizeof(faction_list)); - flist->data = findfaction(f->no); - for (r=firstregion(f);r!=last;r=r->next) { - const unit * u = r->units; + region *r, *last = f->last?f->last:lastregion(f); + const faction * lastf = NULL; + faction_list * flist = calloc(1, sizeof(faction_list)); + flist->data = findfaction(f->no); + for (r=f->first?f->first:firstregion(f);r!=last;r=r->next) { + const unit * u = r->units; const seen_region * sr = find_seen(r); if (sr==NULL) continue; - while (u!=NULL) { + while (u!=NULL) { faction * sf = visible_faction(f, u); boolean ballied = sf && sf!=f && sf!=lastf && !fval(u, UFL_PARTEITARNUNG) && cansee(f, r, u, 0); @@ -904,5 +905,8 @@ get_addresses(faction * f) } } #endif - return flist; + return flist; +#else + return NULL; +#endif }