forked from github/server
cache some of the highest-ranking ct_find callers
This commit is contained in:
parent
e7739867df
commit
9af5fb0326
2 changed files with 12 additions and 5 deletions
|
@ -923,8 +923,12 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
int esize = 0;
|
||||
double wage;
|
||||
attrib *a;
|
||||
const struct curse_type *ctype;
|
||||
static int ct_cache;
|
||||
static const struct curse_type *drought_ct;
|
||||
|
||||
if (ct_changed(&ct_cache)) {
|
||||
drought_ct = ct_find("drought");
|
||||
}
|
||||
if (b != NULL) {
|
||||
/* TODO: this reveals imaginary castles */
|
||||
esize = buildingeffsize(b, false);
|
||||
|
@ -969,9 +973,8 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
}
|
||||
|
||||
/* Bei einer Dürre verdient man nur noch ein Viertel */
|
||||
ctype = ct_find("drought");
|
||||
if (ctype) {
|
||||
curse *c = get_curse(r->attribs, ctype);
|
||||
if (drought_ct) {
|
||||
curse *c = get_curse(r->attribs, drought_ct);
|
||||
if (curse_active(c))
|
||||
wage /= curse_geteffect(c);
|
||||
}
|
||||
|
|
|
@ -1733,7 +1733,11 @@ int unit_max_hp(const unit * u)
|
|||
|
||||
/* der healing curse veraendert die maximalen hp */
|
||||
if (u->region && u->region->attribs) {
|
||||
const curse_type *heal_ct = ct_find("healingzone");
|
||||
static int cache;
|
||||
static const curse_type *heal_ct;
|
||||
if (ct_changed(&cache)) {
|
||||
heal_ct = ct_find("healingzone");
|
||||
}
|
||||
if (heal_ct) {
|
||||
curse *c = get_curse(u->region->attribs, heal_ct);
|
||||
if (c) {
|
||||
|
|
Loading…
Reference in a new issue