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;
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) {

View file

@ -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);

View file

@ -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;

View file

@ -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
}