making init_battle a bit faster by being a bit smarter.

This commit is contained in:
Enno Rehling 2008-05-05 16:08:46 +00:00
parent 2df1fbf0e9
commit 0af00c10ec

View file

@ -3153,13 +3153,15 @@ join_battle(battle * b, unit * u, boolean attack, fighter ** cp)
for (s=b->sides;s!=b->sides+b->nsides;++s) { for (s=b->sides;s!=b->sides+b->nsides;++s) {
fighter *fig; fighter *fig;
for (fig=s->fighters;fig;fig=fig->next) { if (s->faction==u->faction) {
if (fig->unit == u) { for (fig=s->fighters;fig;fig=fig->next) {
c = fig; if (fig->unit == u) {
if (attack) { c = fig;
set_attacker(fig); if (attack) {
set_attacker(fig);
}
break;
} }
break;
} }
} }
} }
@ -3330,13 +3332,15 @@ battle_report(battle * b)
bfaction *bf; bfaction *bf;
for (s=b->sides;s!=b->sides+b->nsides;++s) { for (s=b->sides;s!=b->sides+b->nsides;++s) {
for (s2=b->sides;s2!=b->sides+b->nsides;++s2) { if (s->alive-s->removed > 0) {
if (s->alive-s->removed > 0 && s2->alive-s2->removed > 0 && enemy(s, s2)) { for (s2=b->sides;s2!=b->sides+b->nsides;++s2) {
cont = true; if (s2->alive-s2->removed > 0 && enemy(s, s2)) {
break; cont = true;
break;
}
} }
if (cont) break;
} }
if (cont) break;
} }
printf(" %d", b->turn); printf(" %d", b->turn);