diff --git a/src/battle.c b/src/battle.c index c95ebcda3..f106444ce 100644 --- a/src/battle.c +++ b/src/battle.c @@ -878,7 +878,9 @@ void remove_troop(troop dt) fighter *df = dt.fighter; struct person p = df->person[dt.index]; battle *b = df->side->battle; +#ifdef BATTLE_FAST b->fast.alive = -1; /* invalidate cached value */ +#endif b->rowcache.alive = -1; /* invalidate cached value */ ++df->removed; ++df->side->removed; @@ -1418,8 +1420,9 @@ count_enemies_i(battle * b, const fighter * af, int minrow, int maxrow, return i; } +#ifdef BATTLE_FAST int -count_enemies(battle * b, const fighter * af, int minrow, int maxrow, +count_enemies_fast(battle * b, const fighter * af, int minrow, int maxrow, int select) { int sr = statusrow(af->status); @@ -1451,6 +1454,22 @@ count_enemies(battle * b, const fighter * af, int minrow, int maxrow, } return 0; } +#endif + +int +count_enemies(battle *b, const fighter *af, int minrow, int maxrow, + int select) +{ +#ifdef BATTLE_FAST + return count_enemies_fast(b, af, minrow, maxrow, select); +#else + if (maxrow >= FIRST_ROW) { + int i = count_enemies_i(b, af, minrow, maxrow, select); + return i; + } + return 0; +#endif +} troop select_enemy(fighter * af, int minrow, int maxrow, int select) { diff --git a/src/battle.h b/src/battle.h index da6fea9a9..3f22b143a 100644 --- a/src/battle.h +++ b/src/battle.h @@ -93,6 +93,7 @@ extern "C" { int row; int result; } rowcache; +#ifdef BATTLE_FAST struct { struct side *side; int status; @@ -100,6 +101,7 @@ extern "C" { int minrow, maxrow; int enemies[8]; } fast; +#endif } battle; typedef struct weapon {