forked from github/server
cache some more get_race calls, especially for RC_SPELL.
This commit is contained in:
parent
8f1a1fc8c3
commit
63f60a2465
11
src/battle.c
11
src/battle.c
|
@ -1886,7 +1886,13 @@ int skilldiff(troop at, troop dt, int dist)
|
||||||
unit *au = af->unit, *du = df->unit;
|
unit *au = af->unit, *du = df->unit;
|
||||||
int is_protected = 0, skdiff = 0;
|
int is_protected = 0, skdiff = 0;
|
||||||
weapon *awp = select_weapon(at, true, dist > 1);
|
weapon *awp = select_weapon(at, true, dist > 1);
|
||||||
|
static int rc_cache;
|
||||||
|
static const race *rc_halfling, *rc_goblin;
|
||||||
|
|
||||||
|
if (rc_changed(&rc_cache)) {
|
||||||
|
rc_halfling = get_race(RC_HALFLING);
|
||||||
|
rc_goblin = get_race(RC_GOBLIN);
|
||||||
|
}
|
||||||
skdiff += af->person[at.index].attack;
|
skdiff += af->person[at.index].attack;
|
||||||
skdiff -= df->person[dt.index].defence;
|
skdiff -= df->person[dt.index].defence;
|
||||||
|
|
||||||
|
@ -1894,11 +1900,10 @@ int skilldiff(troop at, troop dt, int dist)
|
||||||
skdiff += 2;
|
skdiff += 2;
|
||||||
|
|
||||||
/* Effekte durch Rassen */
|
/* Effekte durch Rassen */
|
||||||
if (awp != NULL && u_race(au) == get_race(RC_HALFLING) && dragonrace(u_race(du))) {
|
if (awp != NULL && u_race(au) == rc_halfling && dragonrace(u_race(du))) {
|
||||||
skdiff += 5;
|
skdiff += 5;
|
||||||
}
|
}
|
||||||
|
else if (u_race(au) == rc_goblin) {
|
||||||
if (u_race(au) == get_race(RC_GOBLIN)) {
|
|
||||||
if (af->side->size[SUM_ROW] >= df->side->size[SUM_ROW] * rule_goblin_bonus) {
|
if (af->side->size[SUM_ROW] >= df->side->size[SUM_ROW] * rule_goblin_bonus) {
|
||||||
skdiff += 1;
|
skdiff += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,13 @@ static bool RemoveNMRNewbie(void)
|
||||||
|
|
||||||
static void age_unit(region * r, unit * u)
|
static void age_unit(region * r, unit * u)
|
||||||
{
|
{
|
||||||
if (u_race(u) == get_race(RC_SPELL)) {
|
static int rc_cache;
|
||||||
|
static const race *rc_spell;
|
||||||
|
|
||||||
|
if (rc_changed(&rc_cache)) {
|
||||||
|
rc_spell = get_race(RC_SPELL);
|
||||||
|
}
|
||||||
|
if (u_race(u) == rc_spell) {
|
||||||
if (--u->age <= 0) {
|
if (--u->age <= 0) {
|
||||||
remove_unit(&r->units, u);
|
remove_unit(&r->units, u);
|
||||||
}
|
}
|
||||||
|
|
|
@ -731,11 +731,16 @@ static void orc_growth(void)
|
||||||
static void demon_skillchanges(void)
|
static void demon_skillchanges(void)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r;
|
||||||
|
static const race *rc_demon;
|
||||||
|
static int rc_cache;
|
||||||
|
|
||||||
|
if (rc_changed(&rc_cache)) {
|
||||||
|
rc_demon = get_race(RC_DAEMON);
|
||||||
|
}
|
||||||
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) {
|
||||||
if (u_race(u) == get_race(RC_DAEMON)) {
|
if (u_race(u) == rc_demon) {
|
||||||
demon_skillchange(u);
|
demon_skillchange(u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,6 +546,12 @@ int study_cmd(unit * u, order * ord)
|
||||||
int maxalchemy = 0;
|
int maxalchemy = 0;
|
||||||
int speed_rule = (study_rule_t)config_get_int("study.speedup", 0);
|
int speed_rule = (study_rule_t)config_get_int("study.speedup", 0);
|
||||||
bool learn_newskills = config_get_int("study.newskills", 1) != 0;
|
bool learn_newskills = config_get_int("study.newskills", 1) != 0;
|
||||||
|
static const race *rc_snotling;
|
||||||
|
static int rc_cache;
|
||||||
|
|
||||||
|
if (rc_changed(&rc_cache)) {
|
||||||
|
rc_snotling = get_race(RC_SNOTLING);
|
||||||
|
}
|
||||||
|
|
||||||
if (!unit_can_study(u)) {
|
if (!unit_can_study(u)) {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race",
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race",
|
||||||
|
@ -575,7 +581,7 @@ int study_cmd(unit * u, order * ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* snotlings koennen Talente nur bis T8 lernen */
|
/* snotlings koennen Talente nur bis T8 lernen */
|
||||||
if (u_race(u) == get_race(RC_SNOTLING)) {
|
if (u_race(u) == rc_snotling) {
|
||||||
if (get_level(u, sk) >= 8) {
|
if (get_level(u, sk) >= 8) {
|
||||||
cmistake(u, ord, 308, MSG_EVENT);
|
cmistake(u, ord, 308, MSG_EVENT);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue