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,6 +3153,7 @@ join_battle(battle * b, unit * u, boolean attack, fighter ** cp)
for (s=b->sides;s!=b->sides+b->nsides;++s) {
fighter *fig;
if (s->faction==u->faction) {
for (fig=s->fighters;fig;fig=fig->next) {
if (fig->unit == u) {
c = fig;
@ -3163,6 +3164,7 @@ join_battle(battle * b, unit * u, boolean attack, fighter ** cp)
}
}
}
}
if (!c) {
*cp = make_fighter(b, u, NULL, attack);
return *cp!=NULL;
@ -3330,14 +3332,16 @@ battle_report(battle * b)
bfaction *bf;
for (s=b->sides;s!=b->sides+b->nsides;++s) {
if (s->alive-s->removed > 0) {
for (s2=b->sides;s2!=b->sides+b->nsides;++s2) {
if (s->alive-s->removed > 0 && s2->alive-s2->removed > 0 && enemy(s, s2)) {
if (s2->alive-s2->removed > 0 && enemy(s, s2)) {
cont = true;
break;
}
}
if (cont) break;
}
}
printf(" %d", b->turn);
fflush(stdout);