disable the battle.fast cache

it doesn't look very good, anyhow
let's see how much that actually costs
This commit is contained in:
Enno Rehling 2021-03-24 20:40:33 +01:00
parent b5cc4e6fac
commit 195e49e7f0
2 changed files with 22 additions and 1 deletions

View file

@ -878,7 +878,9 @@ void remove_troop(troop dt)
fighter *df = dt.fighter; fighter *df = dt.fighter;
struct person p = df->person[dt.index]; struct person p = df->person[dt.index];
battle *b = df->side->battle; battle *b = df->side->battle;
#ifdef BATTLE_FAST
b->fast.alive = -1; /* invalidate cached value */ b->fast.alive = -1; /* invalidate cached value */
#endif
b->rowcache.alive = -1; /* invalidate cached value */ b->rowcache.alive = -1; /* invalidate cached value */
++df->removed; ++df->removed;
++df->side->removed; ++df->side->removed;
@ -1418,8 +1420,9 @@ count_enemies_i(battle * b, const fighter * af, int minrow, int maxrow,
return i; return i;
} }
#ifdef BATTLE_FAST
int 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 select)
{ {
int sr = statusrow(af->status); int sr = statusrow(af->status);
@ -1451,6 +1454,22 @@ count_enemies(battle * b, const fighter * af, int minrow, int maxrow,
} }
return 0; 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) troop select_enemy(fighter * af, int minrow, int maxrow, int select)
{ {

View file

@ -93,6 +93,7 @@ extern "C" {
int row; int row;
int result; int result;
} rowcache; } rowcache;
#ifdef BATTLE_FAST
struct { struct {
struct side *side; struct side *side;
int status; int status;
@ -100,6 +101,7 @@ extern "C" {
int minrow, maxrow; int minrow, maxrow;
int enemies[8]; int enemies[8];
} fast; } fast;
#endif
} battle; } battle;
typedef struct weapon { typedef struct weapon {