forked from github/server
cache the toad race
This commit is contained in:
parent
fe383af5f2
commit
025c0b91d9
18
src/study.c
18
src/study.c
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
Loading…
Reference in New Issue