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;
|
int esize = 0;
|
||||||
double wage;
|
double wage;
|
||||||
attrib *a;
|
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) {
|
if (b != NULL) {
|
||||||
/* TODO: this reveals imaginary castles */
|
/* TODO: this reveals imaginary castles */
|
||||||
esize = buildingeffsize(b, false);
|
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 */
|
/* Bei einer Dürre verdient man nur noch ein Viertel */
|
||||||
ctype = ct_find("drought");
|
if (drought_ct) {
|
||||||
if (ctype) {
|
curse *c = get_curse(r->attribs, drought_ct);
|
||||||
curse *c = get_curse(r->attribs, ctype);
|
|
||||||
if (curse_active(c))
|
if (curse_active(c))
|
||||||
wage /= curse_geteffect(c);
|
wage /= curse_geteffect(c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1733,7 +1733,11 @@ int unit_max_hp(const unit * u)
|
||||||
|
|
||||||
/* der healing curse veraendert die maximalen hp */
|
/* der healing curse veraendert die maximalen hp */
|
||||||
if (u->region && u->region->attribs) {
|
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) {
|
if (heal_ct) {
|
||||||
curse *c = get_curse(u->region->attribs, heal_ct);
|
curse *c = get_curse(u->region->attribs, heal_ct);
|
||||||
if (c) {
|
if (c) {
|
||||||
|
|
Loading…
Reference in a new issue