Bessere Zuornung der Aufrufe von lastregion und firstregion, für den Profiler

This commit is contained in:
Enno Rehling 2004-02-21 12:19:50 +00:00
parent 6ccb1b9bf6
commit 325dd3d2cc
4 changed files with 34 additions and 28 deletions

View file

@ -172,9 +172,9 @@ improve_all(faction * f, skill_t sk, int weeks)
region *r; region *r;
unit *u; unit *u;
int n = 0; 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) { for (u = r->units; u; u = u->next) {
if (u->faction == f && has_skill(u, sk)) { if (u->faction == f && has_skill(u, sk)) {
for (n=0;n!=weeks;++n) { for (n=0;n!=weeks;++n) {

View file

@ -1556,7 +1556,7 @@ order_template(FILE * F, faction * f)
plane *pl; plane *pl;
unit *u; unit *u;
int dh; int dh;
region *last = lastregion(f); region *last = f->last?f->last:lastregion(f);
rps_nowrap(F, ""); rps_nowrap(F, "");
rnl(F); rnl(F);
@ -1579,7 +1579,7 @@ order_template(FILE * F, faction * f)
rps_nowrap(F, buf); rps_nowrap(F, buf);
rnl(F); 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; dh = 0;
for (u = r->units; u; u = u->next) for (u = r->units; u; u = u->next)
if (u->faction == f && u->race != new_race[RC_SPELL]) { 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 dh;
int anyunits; int anyunits;
const struct region *r; const struct region *r;
region * last = lastregion(f); region * last = f->last?f->last:lastregion(f);
building *b; building *b;
ship *sh; ship *sh;
unit *u; unit *u;
@ -2203,7 +2203,7 @@ report(FILE *F, faction * f, const faction_list * addresses,
anyunits = 0; 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 unit_in_region = false;
boolean durchgezogen_in_region = false; boolean durchgezogen_in_region = false;
int turm_sieht_region = false; int turm_sieht_region = false;
@ -2796,10 +2796,10 @@ view_regatta(region * r, faction * f)
static void static void
prepare_report(faction * f) prepare_report(faction * f)
{ {
region * r; region * r;
region * end = lastregion(f); region * end = f->last?f->last:lastregion(f);
seen_init(); 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; attrib *ru;
unit * u; unit * u;
plane * p = rplane(r); plane * p = rplane(r);

View file

@ -439,17 +439,19 @@ count_all_money(const region * r)
int int
count_skill(faction * f, skill_t sk) count_skill(faction * f, skill_t sk)
{ {
int n = 0; int n = 0;
region *r; region *r;
unit *u; unit *u;
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) for (u = r->units; u; u = u->next) {
if (u->faction == f && has_skill(u, sk)) if (u->faction == f && has_skill(u, sk)) {
if (!is_familiar(u)) n += u->number; if (!is_familiar(u)) n += u->number;
}
return n; }
}
return n;
} }
int quiet = 0; int quiet = 0;

View file

@ -856,16 +856,17 @@ visible_faction(const faction *f, const unit * u)
faction_list * faction_list *
get_addresses(faction * f) get_addresses(faction * f)
{ {
#if 0
/* "TODO: travelthru" */ /* "TODO: travelthru" */
region *r, *last = lastregion(f); region *r, *last = f->last?f->last:lastregion(f);
const faction * lastf = NULL; const faction * lastf = NULL;
faction_list * flist = calloc(1, sizeof(faction_list)); faction_list * flist = calloc(1, sizeof(faction_list));
flist->data = findfaction(f->no); flist->data = findfaction(f->no);
for (r=firstregion(f);r!=last;r=r->next) { for (r=f->first?f->first:firstregion(f);r!=last;r=r->next) {
const unit * u = r->units; const unit * u = r->units;
const seen_region * sr = find_seen(r); const seen_region * sr = find_seen(r);
if (sr==NULL) continue; if (sr==NULL) continue;
while (u!=NULL) { while (u!=NULL) {
faction * sf = visible_faction(f, u); faction * sf = visible_faction(f, u);
boolean ballied = sf && sf!=f && sf!=lastf boolean ballied = sf && sf!=f && sf!=lastf
&& !fval(u, UFL_PARTEITARNUNG) && cansee(f, r, u, 0); && !fval(u, UFL_PARTEITARNUNG) && cansee(f, r, u, 0);
@ -904,5 +905,8 @@ get_addresses(faction * f)
} }
} }
#endif #endif
return flist; return flist;
#else
return NULL;
#endif
} }