forked from github/server
remove rowcache optimization, it had hardly any effect.
This commit is contained in:
parent
53d4010958
commit
ce5ac00b80
24
src/battle.c
24
src/battle.c
|
@ -379,7 +379,7 @@ static int get_row(const side * s, int row, const side * vs)
|
||||||
memset(size, 0, sizeof(size));
|
memset(size, 0, sizeof(size));
|
||||||
for (line = FIRST_ROW; line != NUMROWS; ++line) {
|
for (line = FIRST_ROW; line != NUMROWS; ++line) {
|
||||||
int si, sa_i;
|
int si, sa_i;
|
||||||
/* how many enemies are there in the first row? */
|
/* how many enemies are there in this row? */
|
||||||
for (si = 0; s->enemies[si]; ++si) {
|
for (si = 0; s->enemies[si]; ++si) {
|
||||||
side *se = s->enemies[si];
|
side *se = s->enemies[si];
|
||||||
if (se->size[line] > 0) {
|
if (se->size[line] > 0) {
|
||||||
|
@ -429,24 +429,14 @@ int get_unitrow(const fighter * af, const side * vs)
|
||||||
int row = statusrow(af->status);
|
int row = statusrow(af->status);
|
||||||
if (vs == NULL) {
|
if (vs == NULL) {
|
||||||
int i;
|
int i;
|
||||||
for (i = FIGHT_ROW; i != row; ++i)
|
for (i = FIGHT_ROW; i != row; ++i) {
|
||||||
if (af->side->size[i])
|
if (af->side->size[i]) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return FIGHT_ROW + (row - i);
|
return FIGHT_ROW + (row - i);
|
||||||
}
|
}
|
||||||
else {
|
return get_row(af->side, row, vs);
|
||||||
battle *b = vs->battle;
|
|
||||||
if (row != b->rowcache.row || b->alive != b->rowcache.alive
|
|
||||||
|| af->side != b->rowcache.as || vs != b->rowcache.vs) {
|
|
||||||
b->rowcache.alive = b->alive;
|
|
||||||
b->rowcache.as = af->side;
|
|
||||||
b->rowcache.vs = vs;
|
|
||||||
b->rowcache.row = row;
|
|
||||||
b->rowcache.result = get_row(af->side, row, vs);
|
|
||||||
return b->rowcache.result;
|
|
||||||
}
|
|
||||||
return b->rowcache.result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reportcasualties(battle * b, fighter * fig, int dead)
|
static void reportcasualties(battle * b, fighter * fig, int dead)
|
||||||
|
@ -878,7 +868,7 @@ 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;
|
||||||
b->rowcache.alive = -1; /* invalidate cached value */
|
|
||||||
++df->removed;
|
++df->removed;
|
||||||
++df->side->removed;
|
++df->side->removed;
|
||||||
df->person[dt.index] = df->person[df->alive - df->removed];
|
df->person[dt.index] = df->person[df->alive - df->removed];
|
||||||
|
|
|
@ -86,13 +86,6 @@ extern "C" {
|
||||||
bool has_tactics_turn;
|
bool has_tactics_turn;
|
||||||
bool reelarrow;
|
bool reelarrow;
|
||||||
int alive;
|
int alive;
|
||||||
struct {
|
|
||||||
const struct side *as;
|
|
||||||
const struct side *vs;
|
|
||||||
int alive;
|
|
||||||
int row;
|
|
||||||
int result;
|
|
||||||
} rowcache;
|
|
||||||
} battle;
|
} battle;
|
||||||
|
|
||||||
typedef struct weapon {
|
typedef struct weapon {
|
||||||
|
|
Loading…
Reference in New Issue