reducing the number of calls to ct_find by using a few static variables.

This commit is contained in:
Enno Rehling 2005-06-12 13:30:59 +00:00
parent 71dee49bbb
commit cc35801a19
4 changed files with 11 additions and 6 deletions

View File

@ -1142,7 +1142,12 @@ orc_growth(void)
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
unit *u; unit *u;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
curse *c = get_curse(u->attribs, ct_find("orcish")); static boolean init = false;
static curse *c = 0;
if (!init) {
init = true;
c = get_curse(u->attribs, ct_find("orcish"));
}
if (c && !has_skill(u, SK_MAGIC) && !has_skill(u, SK_ALCHEMY) && !fval(u, UFL_HERO)) { if (c && !has_skill(u, SK_MAGIC) && !has_skill(u, SK_ALCHEMY) && !fval(u, UFL_HERO)) {
int n; int n;

View File

@ -3493,7 +3493,7 @@ init_battle(region * r, battle **bp)
order * ord; order * ord;
for (ord=u->orders;ord;ord=ord->next) { for (ord=u->orders;ord;ord=ord->next) {
boolean init=false; static boolean init = false;
static const curse_type * peace_ct, * slave_ct, * calm_ct; static const curse_type * peace_ct, * slave_ct, * calm_ct;
if (!init) { if (!init) {

View File

@ -670,7 +670,7 @@ max_spellpoints(const region * r, const unit * u)
sk = eff_skill(u, SK_MAGIC, r); sk = eff_skill(u, SK_MAGIC, r);
msp = u->race->maxaura*(pow(sk, potenz)/divisor+1) + get_spchange(u); msp = u->race->maxaura*(pow(sk, potenz)/divisor+1) + get_spchange(u);
if (get_item(u,I_AURAKULUM) > 0) { if (get_item(u, I_AURAKULUM) > 0) {
msp += use_item_aura(r, u); msp += use_item_aura(r, u);
} }
n = get_curseeffect(u->attribs, C_AURA, 0); n = get_curseeffect(u->attribs, C_AURA, 0);

View File

@ -984,15 +984,15 @@ att_modification(const unit *u, skill_t sk)
attrib * a; attrib * a;
int result = 0; int result = 0;
static boolean init = false; static boolean init = false;
static const curse_type * skillmod_ct; static const curse_type * skillmod_ct, * gbdream_ct, * worse_ct;
static const curse_type * gbdream_ct;
if (!init) { if (!init) {
init = true; init = true;
skillmod_ct = ct_find("skillmod"); skillmod_ct = ct_find("skillmod");
gbdream_ct = ct_find("gbdream"); gbdream_ct = ct_find("gbdream");
worse_ct = ct_find("worse");
} }
result += get_curseeffect(u->attribs, C_ALLSKILLS, 0); result += curse_geteffect(get_curse(u->attribs, worse_ct));
if (skillmod_ct) { if (skillmod_ct) {
curse * c; curse * c;
variant var; variant var;