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) {
unit *u;
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)) {
int n;

View File

@ -3493,7 +3493,7 @@ init_battle(region * r, battle **bp)
order * ord;
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;
if (!init) {

View File

@ -984,15 +984,15 @@ att_modification(const unit *u, skill_t sk)
attrib * a;
int result = 0;
static boolean init = false;
static const curse_type * skillmod_ct;
static const curse_type * gbdream_ct;
static const curse_type * skillmod_ct, * gbdream_ct, * worse_ct;
if (!init) {
init = true;
skillmod_ct = ct_find("skillmod");
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) {
curse * c;
variant var;