reordering of primary/secondary based on the defmissile value (small optimization)

This commit is contained in:
Enno Rehling 2002-10-01 16:40:44 +00:00
parent a185ed80da
commit 12da2eeaef
1 changed files with 3 additions and 3 deletions

View File

@ -2837,11 +2837,11 @@ make_fighter(battle * b, unit * u, boolean attack)
for (i=0; i!=w; ++i) { for (i=0; i!=w; ++i) {
int j, o=0, d=0; int j, o=0, d=0;
for (j=0; j!=i; ++j) { for (j=0; j!=i; ++j) {
if (fig->weapons[j].defskill>=fig->weapons[i].defskill) ++d; if (fig->weapons[j].defmissile>=fig->weapons[i].defmissile) ++d;
if (fig->weapons[j].offskill>=fig->weapons[i].offskill) ++o; if (fig->weapons[j].offskill>=fig->weapons[i].offskill) ++o;
} }
for (j=i+1; j!=w; ++j) { for (j=i+1; j!=w; ++j) {
if (fig->weapons[j].defskill>fig->weapons[i].defskill) ++d; if (fig->weapons[j].defmissile>fig->weapons[i].defmissile) ++d;
if (fig->weapons[j].offskill>fig->weapons[i].offskill) ++o; if (fig->weapons[j].offskill>fig->weapons[i].offskill) ++o;
} }
owp[o] = i; owp[o] = i;
@ -2872,7 +2872,7 @@ make_fighter(battle * b, unit * u, boolean attack)
++di; ++di;
} }
if (di==w) break; /* no more weapons available */ if (di==w) break; /* no more weapons available */
if (fig->weapons[dwp[di]].defskill>fig->person[i].weapon->defskill) { if (fig->weapons[dwp[di]].defmissile>fig->person[i].weapon->defmissile) {
fig->person[i].secondary = &fig->weapons[dwp[di]]; fig->person[i].secondary = &fig->weapons[dwp[di]];
++fig->weapons[dwp[di]].used; ++fig->weapons[dwp[di]].used;
} }