diff --git a/src/economy.c b/src/economy.c index caa771142..06b8c0f84 100644 --- a/src/economy.c +++ b/src/economy.c @@ -3106,11 +3106,17 @@ void produce(struct region *r) request *nextworker = workers; static int bt_cache; static const struct building_type *caravan_bt; - + static int rc_cache; + static const race *rc_spell, *rc_insect, *rc_aquarian; + if (bt_changed(&bt_cache)) { caravan_bt = bt_find("caravan"); } - + if (rc_changed(&rc_cache)) { + rc_spell = get_race(RC_SPELL); + rc_insect = get_race(RC_INSECT); + rc_aquarian = get_race(RC_AQUARIAN); + } assert(r); /* das sind alles befehle, die 30 tage brauchen, und die in thisorder @@ -3145,10 +3151,10 @@ void produce(struct region *r) bool trader = false; keyword_t todo; - if (u_race(u) == get_race(RC_SPELL) || fval(u, UFL_LONGACTION)) + if (u_race(u) == rc_spell || fval(u, UFL_LONGACTION)) continue; - if (u_race(u) == get_race(RC_INSECT) && r_insectstalled(r) && + if (u_race(u) == rc_insect && r_insectstalled(r) && !is_cursed(u->attribs, C_KAELTESCHUTZ, 0)) continue; @@ -3185,7 +3191,7 @@ void produce(struct region *r) if (todo == NOKEYWORD) continue; - if (fval(r->terrain, SEA_REGION) && u_race(u) != get_race(RC_AQUARIAN) + if (fval(r->terrain, SEA_REGION) && u_race(u) != rc_aquarian && !(u_race(u)->flags & RCF_SWIM) && todo != K_STEAL && todo != K_SPY && todo != K_SABOTAGE) continue; diff --git a/src/magic.c b/src/magic.c index 1c4ca2adb..83899f583 100644 --- a/src/magic.c +++ b/src/magic.c @@ -1363,7 +1363,9 @@ static void do_fumble(castorder * co) int level = co->level; int duration; double effect; - + static const race *rc_toad; + static int rc_cache; + ADDMSG(&u->faction->msgs, msg_message("patzer", "unit region spell", u, r, sp)); switch (rng_int() % 10) { @@ -1394,7 +1396,10 @@ static void do_fumble(castorder * co) duration = rng_int() % level / 2; if (duration < 2) duration = 2; add_trigger(&u->attribs, "timer", trigger_timeout(duration, trestore)); - u_setrace(u, get_race(RC_TOAD)); + if (rc_changed(&rc_cache)) { + rc_toad = get_race(RC_TOAD); + } + u_setrace(u, rc_toad); u->irace = NULL; ADDMSG(&r->msgs, msg_message("patzer6", "unit region spell", u, r, sp)); break; diff --git a/src/upkeep.c b/src/upkeep.c index a9feca37a..198ce73df 100644 --- a/src/upkeep.c +++ b/src/upkeep.c @@ -115,7 +115,12 @@ void get_food(region * r) unit *u; int peasantfood = rpeasants(r) * 10; int food_rules = config_get_int("rules.food.flags", 0); - + static const race *rc_demon; + static int rc_cache; + + if (rc_changed(&rc_cache)) { + rc_demon = get_race(RC_DAEMON); + } if (food_rules & FOOD_IS_FREE) { return; } @@ -228,7 +233,7 @@ void get_food(region * r) * bei fehlenden Bauern den Dämon hungern lassen */ for (u = r->units; u; u = u->next) { - if (u_race(u) == get_race(RC_DAEMON)) { + if (u_race(u) == rc_demon) { int hungry = u->number; /* use peasantblood before eating the peasants themselves */ @@ -250,7 +255,7 @@ void get_food(region * r) if (donor == u) donor = r->units; while (donor != NULL) { - if (u_race(donor) == get_race(RC_DAEMON) && donor != u) { + if (u_race(donor) == rc_demon && donor != u) { if (get_effect(donor, pt_blood)) { /* if he's in our faction, drain him: */ if (donor->faction == u->faction)