cache the toad race

This commit is contained in:
Enno Rehling 2016-09-19 07:02:45 +02:00
parent fe383af5f2
commit 025c0b91d9
1 changed files with 13 additions and 5 deletions

View File

@ -94,6 +94,9 @@ magic_t getmagicskill(const struct locale * lang)
/* familiars and toads are not migrants */ /* familiars and toads are not migrants */
bool is_migrant(unit * u) bool is_migrant(unit * u)
{ {
static int cache;
static race *toad_rc;
if (u_race(u) == u->faction->race) if (u_race(u) == u->faction->race)
return false; return false;
@ -101,16 +104,21 @@ bool is_migrant(unit * u)
return false; return false;
if (is_familiar(u)) if (is_familiar(u))
return false; return false;
if (u_race(u) == get_race(RC_TOAD)) if (rc_changed(&cache)) {
return false; toad_rc = get_race(RC_TOAD);
}
return true; return u_race(u) != toad_rc;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
bool magic_lowskill(unit * u) bool magic_lowskill(unit * u)
{ {
return (u_race(u) == get_race(RC_TOAD)) ? true : false; static race *toad_rc;
static int cache;
if (rc_changed(&cache)) {
toad_rc = get_race(RC_TOAD);
}
return u_race(u) == toad_rc;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */