Merge branch 'master' of github.com:eressea/core

This commit is contained in:
Enno Rehling 2013-05-03 09:53:23 -07:00
commit eceafaf11c
30 changed files with 365 additions and 378 deletions

View File

@ -839,7 +839,7 @@ static int tolua_unit_set_faction(lua_State * L)
static int tolua_unit_get_race(lua_State * L)
{
unit *self = (unit *) tolua_tousertype(L, 1, 0);
tolua_pushstring(L, self->race->_name[0]);
tolua_pushstring(L, u_race(self)->_name[0]);
return 1;
}
@ -851,9 +851,9 @@ static int tolua_unit_set_race(lua_State * L)
if (rc != NULL) {
if (count_unit(self))
--self->faction->no_units;
if (self->irace == self->race)
if (self->irace == u_race(self))
self->irace = NULL;
self->race = rc;
u_setrace(self, rc);
if (count_unit(self))
--self->faction->no_units;
}

View File

@ -247,7 +247,7 @@ static int lua_initfamiliar(unit * u)
int result = -1;
strlcpy(fname, "initfamiliar_", sizeof(fname));
strlcat(fname, u->race->_name[0], sizeof(fname));
strlcat(fname, u_race(u)->_name[0], sizeof(fname));
lua_getglobal(L, fname);
if (lua_isfunction(L, -1)) {
@ -268,7 +268,7 @@ static int lua_initfamiliar(unit * u)
create_mage(u, M_GRAY);
strlcpy(fname, u->race->_name[0], sizeof(fname));
strlcpy(fname, u_race(u)->_name[0], sizeof(fname));
strlcat(fname, "_familiar", sizeof(fname));
equip_unit(u, get_equipment(fname));
return result;

View File

@ -696,7 +696,7 @@ static void cr_output_unit(FILE * F, const region * r, const faction * f,
static bool init = false;
item result[MAX_INVENTORY];
if (fval(u->race, RCF_INVISIBLE))
if (fval(u_race(u), RCF_INVISIBLE))
return;
if (!init) {
@ -785,8 +785,8 @@ static void cr_output_unit(FILE * F, const region * r, const faction * f,
pzTmp = get_racename(u->attribs);
if (pzTmp) {
fprintf(F, "\"%s\";Typ\n", pzTmp);
if (u->faction == f && fval(u->race, RCF_SHAPESHIFTANY)) {
const char *zRace = rc_name(u->race, 1);
if (u->faction == f && fval(u_race(u), RCF_SHAPESHIFTANY)) {
const char *zRace = rc_name(u_race(u), 1);
fprintf(F, "\"%s\";wahrerTyp\n",
add_translation(zRace, locale_string(f->locale, zRace)));
}
@ -795,10 +795,10 @@ static void cr_output_unit(FILE * F, const region * r, const faction * f,
const char *zRace = rc_name(irace, 1);
fprintf(F, "\"%s\";Typ\n",
add_translation(zRace, locale_string(f->locale, zRace)));
if (u->faction == f && irace != u->race) {
if (u->faction == f && irace != u_race(u)) {
assert(skill_enabled[SK_STEALTH]
|| !"we're resetting this on load, so.. ircase should never be used");
zRace = rc_name(u->race, 1);
zRace = rc_name(u_race(u), 1);
fprintf(F, "\"%s\";wahrerTyp\n",
add_translation(zRace, locale_string(f->locale, zRace)));
}

View File

@ -126,7 +126,7 @@ static void recruit_init(void)
int income(const unit * u)
{
switch (old_race(u->race)) {
switch (old_race(u_race(u))) {
case RC_FIREDRAGON:
return 150 * u->number;
case RC_DRAGON:
@ -227,7 +227,7 @@ static recruitment *select_recruitment(request ** rop,
recruitment *rec = recruits;
request *ro = *rop;
unit *u = ro->unit;
const race *rc = u->race;
const race *rc = u_race(u);
int qty = quantify(rc, ro->qty);
if (qty < 0) {
@ -267,15 +267,15 @@ static void add_recruits(unit * u, int number, int wanted)
u->hp = number * unit_max_hp(u);
unew = u;
} else {
unew = create_unit(r, u->faction, number, u->race, 0, NULL, u);
unew = create_unit(r, u->faction, number, u_race(u), 0, NULL, u);
}
strlcpy(equipment, "new_", sizeof(equipment));
strlcat(equipment, u->race->_name[0], sizeof(equipment));
strlcat(equipment, u_race(u)->_name[0], sizeof(equipment));
strlcat(equipment, "_unit", sizeof(equipment));
equip_unit(unew, get_equipment(equipment));
if (unew->race->ec_flags & ECF_REC_HORSES) {
if (u_race(unew)->ec_flags & ECF_REC_HORSES) {
change_level(unew, SK_RIDING, 1);
}
@ -364,7 +364,7 @@ static int do_recruiting(recruitment * recruits, int available)
for (req = rec->requests; req; req = req->next) {
unit *u = req->unit;
const race *rc = u->race; /* race is set in recruit() */
const race *rc = u_race(u); /* race is set in recruit() */
int number, dec;
float multi = 2.0F * rc->recruit_multi;
@ -504,7 +504,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders)
request *o;
int recruitcost = -1;
const faction *f = u->faction;
const struct race *rc = u->race;
const struct race *rc = u_race(u);
const char *str;
init_tokens(ord);
@ -523,14 +523,14 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders)
}
}
if (recruitcost < 0) {
rc = u->race;
rc = u_race(u);
recruitcost = recruit_cost(f, rc);
if (recruitcost < 0) {
recruitcost = INT_MAX;
}
}
assert(rc);
u->race = rc;
u_setrace(u, rc);
#if GUARD_DISABLES_RECRUIT
/* this is a very special case because the recruiting unit may be empty
@ -767,7 +767,7 @@ static void give_cmd(unit * u, order * ord)
return;
}
if (u2 && u2->race == new_race[RC_SPELL]) {
if (u2 && u_race(u2) == new_race[RC_SPELL]) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found",
""));
return;
@ -780,18 +780,18 @@ static void give_cmd(unit * u, order * ord)
else if (p == P_HERBS) {
bool given = false;
if (!(u->race->ec_flags & GIVEITEM) && u2 != NULL) {
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_nogive", "race", u->race));
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
return;
}
if (!check_give(u, u2, NULL, GIVE_HERBS)) {
feedback_give_not_allowed(u, ord);
return;
}
if (u2 && !(u2->race->ec_flags & GETITEM)) {
if (u2 && !(u_race(u2)->ec_flags & GETITEM)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_notake", "race", u2->race));
msg_feedback(u, ord, "race_notake", "race", u_race(u2)));
return;
}
if (!u2) {
@ -831,7 +831,7 @@ static void give_cmd(unit * u, order * ord)
}
else if (p == P_UNIT) { /* Einheiten uebergeben */
if (!(u->race->ec_flags & GIVEUNIT)) {
if (!(u_race(u)->ec_flags & GIVEUNIT)) {
cmistake(u, ord, 167, MSG_COMMERCE);
return;
}
@ -851,14 +851,14 @@ static void give_cmd(unit * u, order * ord)
if (*s == 0) { /* GIVE ALL items that you have */
/* do these checks once, not for each item we have: */
if (!(u->race->ec_flags & GIVEITEM) && u2 != NULL) {
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_nogive", "race", u->race));
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
return;
}
if (u2 && !(u2->race->ec_flags & GETITEM)) {
if (u2 && !(u_race(u2)->ec_flags & GETITEM)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_notake", "race", u2->race));
msg_feedback(u, ord, "race_notake", "race", u_race(u2)));
return;
}
@ -882,19 +882,19 @@ static void give_cmd(unit * u, order * ord)
}
} else {
if (isparam(s, u->faction->locale, P_PERSON)) {
if (!(u->race->ec_flags & GIVEPERSON)) {
if (!(u_race(u)->ec_flags & GIVEPERSON)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_noregroup", "race", u->race));
msg_feedback(u, ord, "race_noregroup", "race", u_race(u)));
} else {
n = u->number;
give_men(n, u, u2, ord);
}
} else if (!(u->race->ec_flags & GIVEITEM) && u2 != NULL) {
} else if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_nogive", "race", u->race));
} else if (u2 && !(u2->race->ec_flags & GETITEM)) {
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
} else if (u2 && !(u_race(u2)->ec_flags & GETITEM)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_notake", "race", u2->race));
msg_feedback(u, ord, "race_notake", "race", u_race(u2)));
} else {
itype = finditemtype(s, u->faction->locale);
if (itype != NULL) {
@ -929,9 +929,9 @@ static void give_cmd(unit * u, order * ord)
}
if (isparam(s, u->faction->locale, P_PERSON)) {
if (!(u->race->ec_flags & GIVEPERSON)) {
if (!(u_race(u)->ec_flags & GIVEPERSON)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_noregroup", "race", u->race));
msg_feedback(u, ord, "race_noregroup", "race", u_race(u)));
return;
}
give_men(n, u, u2, ord);
@ -939,14 +939,14 @@ static void give_cmd(unit * u, order * ord)
}
if (u2 != NULL) {
if (!(u->race->ec_flags & GIVEITEM) && u2 != NULL) {
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_nogive", "race", u->race));
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
return;
}
if (!(u2->race->ec_flags & GETITEM)) {
if (!(u_race(u2)->ec_flags & GETITEM)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_notake", "race", u2->race));
msg_feedback(u, ord, "race_notake", "race", u_race(u2)));
return;
}
}
@ -1194,7 +1194,7 @@ static int recruit_archetype(unit * u, order * ord)
else if (strcmp(arch->rules[k].property, "race") == 0) {
const race *rc = rc_find(arch->rules[k].value);
assert(rc);
if (rc == u->race)
if (rc == u_race(u))
match = true;
} else if (strcmp(arch->rules[k].property, "building") == 0) {
const building_type *btype = bt_find(arch->rules[k].value);
@ -1242,7 +1242,7 @@ static int recruit_archetype(unit * u, order * ord)
if (n > 0) {
unit *u2;
if (merge) {
u2 = create_unit(u->region, u->faction, 0, u->race, 0, 0, u);
u2 = create_unit(u->region, u->faction, 0, u_race(u), 0, 0, u);
} else {
u2 = u;
}
@ -1260,7 +1260,7 @@ static int recruit_archetype(unit * u, order * ord)
}
ADDMSG(&u->faction->msgs, msg_message("recruit_archetype",
"unit amount archetype", u, n, arch->name[n == 1]));
if (u != u2 && u->race == u2->race) {
if (u != u2 && u_race(u) == u_race(u2)) {
transfermen(u2, u, u2->number);
}
return n;
@ -1437,7 +1437,7 @@ static bool can_guard(const unit * guard, const unit * u)
return false;
if (guard->number <= 0 || !cansee(guard->faction, guard->region, u, 0))
return false;
if (besieged(guard) || !(fval(guard->race, RCF_UNARMEDGUARD)
if (besieged(guard) || !(fval(u_race(guard), RCF_UNARMEDGUARD)
|| armedmen(guard, true)))
return false;
@ -1546,7 +1546,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
for (; mod->flags != 0; ++mod) {
if (mod->flags & RMF_SKILL) {
if (mod->btype == NULL || mod->btype == btype) {
if (mod->race == NULL || mod->race == u->race) {
if (mod->race == NULL || mod->race == u_race(u)) {
skill += mod->value.i;
}
}
@ -1599,7 +1599,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
for (; mod->flags != 0; ++mod) {
if (mod->flags & RMF_SAVEMATERIAL) {
if (mod->btype == NULL || mod->btype == btype) {
if (mod->race == NULL || mod->race == u->race) {
if (mod->race == NULL || mod->race == u_race(u)) {
al->save *= mod->value.f;
}
}
@ -2123,7 +2123,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord)
return;
}
if (u->race == new_race[RC_INSECT]) {
if (u_race(u) == new_race[RC_INSECT]) {
/* entweder man ist insekt, oder... */
if (r->terrain != newterrain(T_SWAMP) && r->terrain != newterrain(T_DESERT)
&& !rbuildings(r)) {
@ -2428,7 +2428,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
}
/* In der Region muß es eine Burg geben. */
if (u->race == new_race[RC_INSECT]) {
if (u_race(u) == new_race[RC_INSECT]) {
if (r->terrain != newterrain(T_SWAMP) && r->terrain != newterrain(T_DESERT)
&& !rbuildings(r)) {
cmistake(u, ord, 119, MSG_COMMERCE);
@ -2923,13 +2923,13 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
assert(skill_enabled[SK_PERCEPTION] && skill_enabled[SK_STEALTH]);
if (!fval(u->race, RCF_CANSTEAL)) {
if (!fval(u_race(u), RCF_CANSTEAL)) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "race_nosteal", "race",
u->race));
u_race(u)));
return;
}
if (fval(r->terrain, SEA_REGION) && u->race != new_race[RC_AQUARIAN]) {
if (fval(r->terrain, SEA_REGION) && u_race(u) != new_race[RC_AQUARIAN]) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
return;
}
@ -2983,7 +2983,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
if (n <= 0) {
/* Wahrnehmung == Tarnung */
if (u->race != new_race[RC_GOBLIN] || eff_skill(u, SK_STEALTH, r) <= 3) {
if (u_race(u) != new_race[RC_GOBLIN] || eff_skill(u, SK_STEALTH, r) <= 3) {
ADDMSG(&u->faction->msgs, msg_message("stealfail", "unit target", u, u2));
if (n == 0) {
ADDMSG(&u2->faction->msgs, msg_message("stealdetect", "unit", u2));
@ -3136,7 +3136,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
assert(workers >= 0);
u->n = workers * wage(u->region, u->faction, u->race, turn);
u->n = workers * wage(u->region, u->faction, u_race(u), turn);
jobs -= workers;
assert(jobs >= 0);
@ -3169,7 +3169,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
static int do_work(unit * u, order * ord, request * o)
{
if (playerrace(u->race)) {
if (playerrace(u_race(u))) {
region *r = u->region;
int w;
@ -3188,7 +3188,7 @@ static int do_work(unit * u, order * ord, request * o)
cmistake(u, ord, 69, MSG_INCOME);
return -1;
}
w = wage(r, u->faction, u->race, turn);
w = wage(r, u->faction, u_race(u), turn);
u->wants = u->number * w;
o->unit = u;
o->qty = u->number * w;
@ -3196,7 +3196,7 @@ static int do_work(unit * u, order * ord, request * o)
return 0;
} else if (ord && !is_monsters(u->faction)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_cantwork", "race", u->race));
msg_feedback(u, ord, "race_cantwork", "race", u_race(u)));
}
return -1;
}
@ -3234,7 +3234,7 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
request *o;
int max;
if (!humanoidrace(u->race) && !is_monsters(u->faction)) {
if (!humanoidrace(u_race(u)) && !is_monsters(u->faction)) {
cmistake(u, ord, 228, MSG_INCOME);
return;
}
@ -3261,7 +3261,7 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
if (max == 0)
max = INT_MAX;
if (!playerrace(u->race)) {
if (!playerrace(u_race(u))) {
u->wants = MIN(income(u), max);
} else {
u->wants = MIN(n * eff_skill(u, SK_TAXING, r) * 20, max);
@ -3390,10 +3390,10 @@ void produce(struct region *r)
order *ord;
bool trader = false;
if (u->race == new_race[RC_SPELL] || fval(u, UFL_LONGACTION))
if (u_race(u) == new_race[RC_SPELL] || fval(u, UFL_LONGACTION))
continue;
if (u->race == new_race[RC_INSECT] && r_insectstalled(r) &&
if (u_race(u) == new_race[RC_INSECT] && r_insectstalled(r) &&
!is_cursed(u->attribs, C_KAELTESCHUTZ, 0))
continue;
@ -3429,8 +3429,8 @@ void produce(struct region *r)
if (todo == NOKEYWORD)
continue;
if (fval(r->terrain, SEA_REGION) && u->race != new_race[RC_AQUARIAN]
&& !(u->race->flags & RCF_SWIM)
if (fval(r->terrain, SEA_REGION) && u_race(u) != new_race[RC_AQUARIAN]
&& !(u_race(u)->flags & RCF_SWIM)
&& todo != K_STEAL && todo != K_SPY && todo != K_SABOTAGE)
continue;

View File

@ -189,7 +189,7 @@ void give_men(int n, unit * u, unit * u2, struct order *ord)
return;
} else if (u == u2) {
error = 10;
} else if (!u2 && u->race == new_race[RC_SNOTLING]) {
} else if (!u2 && u_race(u) == new_race[RC_SNOTLING]) {
/* snotlings may not be given to the peasants. */
error = 307;
} else if (u2 && u2->number && (fval(u, UFL_HERO) != fval(u2, UFL_HERO))) {
@ -214,8 +214,8 @@ void give_men(int n, unit * u, unit * u2, struct order *ord)
} else if (u2 && (fval(u, UFL_WERE) != fval(u2, UFL_WERE))) {
/* werewolves can't be given to non-werewolves and vice-versa */
error = 312;
} else if (u2 && u2->number != 0 && u2->race != u->race) {
log_warning("faction %s attempts to give %s to %s.\n", itoa36(u->faction->no), u->race->_name[0], u2->race->_name[1]);
} else if (u2 && u2->number != 0 && u_race(u2) != u_race(u)) {
log_warning("faction %s attempts to give %s to %s.\n", itoa36(u->faction->no), u_race(u)->_name[0], u_race(u2)->_name[1]);
error = 139;
} else if (u2 != NULL && (get_racename(u2->attribs)
|| get_racename(u->attribs))) {
@ -236,7 +236,7 @@ void give_men(int n, unit * u, unit * u2, struct order *ord)
} else if (u2 && u->faction != u2->faction) {
if (u2->faction->newbies + n > MAXNEWBIES) {
error = 129;
} else if (u->race != u2->faction->race) {
} else if (u_race(u) != u2->faction->race) {
if (u2->faction->race != new_race[RC_HUMAN]) {
error = 120;
} else if (count_migrants(u2->faction) + n >
@ -277,7 +277,7 @@ void give_men(int n, unit * u, unit * u2, struct order *ord)
if (error == 0) {
if (u2 && u2->number == 0) {
set_racename(&u2->attribs, get_racename(u->attribs));
u2->race = u->race;
u_setrace(u2, u_race(u));
u2->irace = u->irace;
if (fval(u, UFL_HERO))
fset(u2, UFL_HERO);
@ -322,7 +322,7 @@ void give_men(int n, unit * u, unit * u2, struct order *ord)
} else {
if (getunitpeasants) {
#ifdef ORCIFICATION
if (u->race == new_race[RC_SNOTLING] && !fval(u->region, RF_ORCIFIED)) {
if (u_race(u) == new_race[RC_SNOTLING] && !fval(u->region, RF_ORCIFIED)) {
attrib *a = a_find(u->region->attribs, &at_orcification);
if (!a)
a = a_add(&u->region->attribs, a_new(&at_orcification));
@ -416,7 +416,7 @@ void give_unit(unit * u, unit * u2, order * ord)
cmistake(u, ord, 129, MSG_COMMERCE);
return;
}
if (u->race != u2->faction->race) {
if (u_race(u) != u2->faction->race) {
if (u2->faction->race != new_race[RC_HUMAN]) {
cmistake(u, ord, 120, MSG_COMMERCE);
return;

View File

@ -144,7 +144,7 @@ static void checkorders(void)
static bool help_money(const unit * u)
{
if (u->race->ec_flags & GIVEITEM)
if (u_race(u)->ec_flags & GIVEITEM)
return true;
return false;
}
@ -294,7 +294,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 == new_race[RC_DAEMON]) {
if (u_race(u) == new_race[RC_DAEMON]) {
int hungry = u->number;
/* use peasantblood before eating the peasants themselves */
@ -315,7 +315,7 @@ void get_food(region * r)
if (donor == u)
donor = r->units;
while (donor != NULL) {
if (donor->race == new_race[RC_DAEMON] && donor!=u) {
if (u_race(donor) == new_race[RC_DAEMON] && donor!=u) {
if (get_effect(donor, pt_blood)) {
/* if he's in our faction, drain him: */
if (donor->faction == u->faction)
@ -363,14 +363,14 @@ void get_food(region * r)
static void age_unit(region * r, unit * u)
{
if (u->race == new_race[RC_SPELL]) {
if (u_race(u) == new_race[RC_SPELL]) {
if (--u->age <= 0) {
remove_unit(&r->units, u);
}
} else {
++u->age;
if (u->number > 0 && u->race->age) {
u->race->age(u);
if (u->number > 0 && u_race(u)->age) {
u_race(u)->age(u);
}
}
#ifdef ASTRAL_ITEM_RESTRICTIONS
@ -681,7 +681,7 @@ static int count_race(const region * r, const race * rc)
int c = 0;
for (u = r->units; u; u = u->next)
if (u->race == rc)
if (u_race(u) == rc)
c += u->number;
return c;
@ -1111,7 +1111,7 @@ int leave_cmd(unit * u, struct order *ord)
}
if (fval(r->terrain, SEA_REGION) && u->ship) {
if (!fval(u->race, RCF_SWIM)) {
if (!fval(u_race(u), RCF_SWIM)) {
cmistake(u, ord, 11, MSG_MOVE);
return 0;
}
@ -1216,10 +1216,10 @@ int enter_ship(unit * u, struct order *ord, int id, int report)
region *r = u->region;
ship *sh;
/* Muß abgefangen werden, sonst könnten Schwimmer an
/* Muss abgefangen werden, sonst koennten Schwimmer an
* Bord von Schiffen an Land gelangen. */
if (!fval(u->race, RCF_CANSAIL) || (!fval(u->race, RCF_WALK)
&& !fval(u->race, RCF_FLY))) {
if (!fval(u_race(u), RCF_CANSAIL) || (!fval(u_race(u), RCF_WALK)
&& !fval(u_race(u), RCF_FLY))) {
cmistake(u, ord, 233, MSG_MOVE);
return 0;
}
@ -1247,7 +1247,7 @@ int enter_ship(unit * u, struct order *ord, int id, int report)
getshipweight(sh, &sweight, &scabins);
sweight += weight(u);
if (mcabins) {
int pweight = u->number * u->race->weight;
int pweight = u->number * u_race(u)->weight;
/* weight goes into number of cabins, not cargo */
scabins += pweight;
sweight -= pweight;
@ -1277,7 +1277,7 @@ int enter_building(unit * u, order * ord, int id, int report)
/* Schwimmer können keine Gebäude betreten, außer diese sind
* auf dem Ozean */
if (!fval(u->race, RCF_WALK) && !fval(u->race, RCF_FLY)) {
if (!fval(u_race(u), RCF_WALK) && !fval(u_race(u), RCF_FLY)) {
if (!fval(r->terrain, SEA_REGION)) {
if (report) {
cmistake(u, ord, 232, MSG_MOVE);
@ -2153,7 +2153,7 @@ mailunit(region * r, unit * u, int n, struct order *ord, const char *s)
deliverMail(u2->faction, r, u, s, u2);
/* now done in prepare_mail_cmd */
} else {
/* Immer eine Meldung - sonst könnte man so getarnte EHs enttarnen:
/* Immer eine Meldung - sonst koennte man so getarnte EHs enttarnen:
* keine Meldung -> EH hier. */
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "feedback_unit_not_found", ""));
@ -2511,7 +2511,7 @@ static bool display_race(faction * f, unit * u, const race * rc)
size_t size = sizeof(buf) - 1;
int bytes;
if (u && u->race != rc)
if (u && u_race(u) != rc)
return false;
name = rc_name(rc, 0);
@ -2728,9 +2728,9 @@ int promotion_cmd(unit * u, struct order *ord)
maxheroes(u->faction), countheroes(u->faction)));
return 0;
}
if (!valid_race(u->faction, u->race)) {
if (!valid_race(u->faction, u_race(u))) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "heroes_race", "race",
u->race));
u_race(u)));
return 0;
}
people = count_all(u->faction) * u->number;
@ -2904,7 +2904,7 @@ static int can_start_guarding(const unit * u)
{
if (u->status >= ST_FLEE)
return E_GUARD_FLEEING;
if (fval(u->race, RCF_UNARMEDGUARD))
if (fval(u_race(u), RCF_UNARMEDGUARD))
return E_GUARD_OK;
if (!armedmen(u, true))
return E_GUARD_UNARMED;
@ -2951,8 +2951,8 @@ int guard_on_cmd(unit * u, struct order *ord)
} else {
if (fval(u, UFL_MOVED)) {
cmistake(u, ord, 187, MSG_EVENT);
} else if (fval(u->race, RCF_ILLUSIONARY)
|| u->race == new_race[RC_SPELL]) {
} else if (fval(u_race(u), RCF_ILLUSIONARY)
|| u_race(u) == new_race[RC_SPELL]) {
cmistake(u, ord, 95, MSG_EVENT);
} else {
/* Monster der Monsterpartei dürfen immer bewachen */
@ -3303,7 +3303,7 @@ static building *age_building(building * b)
* find out if there's a magician in there. */
for (u = r->units; u; u = u->next) {
if (b == u->building && inside_building(u)) {
if (!(u->race->ec_flags & GIVEITEM) == 0) {
if (!(u_race(u)->ec_flags & GIVEITEM) == 0) {
int n, unicorns = 0;
for (n = 0; n != u->number; ++n) {
if (chance(0.02)) {
@ -3421,7 +3421,7 @@ static void ageing(void)
if (is_cursed(u->attribs, C_OLDRACE, 0)) {
curse *c = get_curse(u->attribs, ct_find("oldrace"));
if (c->duration == 1 && !(c_flags(c) & CURSE_NOAGE)) {
u->race = new_race[curse_geteffect_int(c)];
u_setrace(u, new_race[curse_geteffect_int(c)]);
u->irace = NULL;
}
}
@ -3767,7 +3767,7 @@ use_item(unit * u, const item_type * itype, int amount, struct order *ord)
static double heal_factor(const unit * u)
{
static float elf_regen = -1;
switch (old_race(u->race)) {
switch (old_race(u_race(u))) {
case RC_TROLL:
case RC_DAEMON:
return 1.5;
@ -3775,7 +3775,7 @@ static double heal_factor(const unit * u)
return 2.0;
case RC_ELF:
if (elf_regen < 0)
elf_regen = get_param_flt(u->race->parameters, "regen.forest", 1.0F);
elf_regen = get_param_flt(u_race(u)->parameters, "regen.forest", 1.0F);
if (elf_regen != 1.0 && r_isforest(u->region)) {
return elf_regen;
}
@ -3816,7 +3816,7 @@ void monthly_healing(void)
continue;
}
if (u->race->flags & RCF_NOHEAL)
if (u_race(u)->flags & RCF_NOHEAL)
continue;
if (fval(u, UFL_HUNGER))
continue;
@ -3911,8 +3911,8 @@ void defaultorders(void)
}
/* ************************************************************ */
/* GANZ WICHTIG! ALLE GEÄNDERTEN SPRÜCHE NEU ANZEIGEN */
/* GANZ WICHTIG! FÜGT AUCH NEUE ZAUBER IN DIE LISTE DER BEKANNTEN EIN */
/* GANZ WICHTIG! ALLE GEAENDERTEN SPRUECHE NEU ANZEIGEN */
/* GANZ WICHTIG! FUEGT AUCH NEUE ZAUBER IN DIE LISTE DER BEKANNTEN EIN */
/* ************************************************************ */
#define COMMONSPELLS 1 /* number of new common spells per level */
#define MAXMAGES 128 /* should be enough */
@ -4286,7 +4286,7 @@ void process(void)
if (porder->flags & PROC_LONGORDER) {
if (u->number == 0) {
ord = NULL;
} else if (u->race == new_race[RC_INSECT]
} else if (u_race(u) == new_race[RC_INSECT]
&& r_insectstalled(r)
&& !is_cursed(u->attribs, C_KAELTESCHUTZ, 0)) {
ord = NULL;
@ -4299,8 +4299,8 @@ void process(void)
*/
ord = NULL;
} else if (fval(r->terrain, SEA_REGION)
&& u->race != new_race[RC_AQUARIAN]
&& !(u->race->flags & RCF_SWIM)) {
&& u_race(u) != new_race[RC_AQUARIAN]
&& !(u_race(u)->flags & RCF_SWIM)) {
/* error message disabled by popular demand */
ord = NULL;
}
@ -4376,7 +4376,7 @@ int siege_cmd(unit * u, order * ord)
return 31;
}
if (!playerrace(u->race)) {
if (!playerrace(u_race(u))) {
/* keine Drachen, Illusionen, Untote etc */
cmistake(u, ord, 166, MSG_BATTLE);
return 166;

View File

@ -88,7 +88,7 @@ static void eaten_by_monster(unit * u)
multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0;
}
switch (old_race(u->race)) {
switch (old_race(u_race(u))) {
case RC_FIREDRAGON:
n = rng_int() % 80 * u->number;
horse = get_item(u, I_HORSE);
@ -126,7 +126,7 @@ static void absorbed_by_monster(unit * u)
{
int n;
switch (old_race(u->race)) {
switch (old_race(u_race(u))) {
default:
n = rng_int() % (u->number / 20 + 1);
}
@ -138,7 +138,7 @@ static void absorbed_by_monster(unit * u)
rsetpeasants(u->region, rpeasants(u->region) - n);
scale_number(u, u->number + n);
ADDMSG(&u->region->msgs, msg_message("absorbpeasants",
"unit race amount", u, u->race, n));
"unit race amount", u, u_race(u), n));
}
}
}
@ -179,7 +179,7 @@ static void scared_by_monster(unit * u)
{
int n;
switch (old_race(u->race)) {
switch (old_race(u_race(u))) {
case RC_FIREDRAGON:
n = rng_int() % 160 * u->number;
break;
@ -209,13 +209,13 @@ static void scared_by_monster(unit * u)
void monster_kills_peasants(unit * u)
{
if (!monster_is_waiting(u)) {
if (u->race->flags & RCF_SCAREPEASANTS) {
if (u_race(u)->flags & RCF_SCAREPEASANTS) {
scared_by_monster(u);
}
if (u->race->flags & RCF_KILLPEASANTS) {
if (u_race(u)->flags & RCF_KILLPEASANTS) {
eaten_by_monster(u);
}
if (u->race->flags & RCF_ABSORBPEASANTS) {
if (u_race(u)->flags & RCF_ABSORBPEASANTS) {
absorbed_by_monster(u);
}
}

View File

@ -113,30 +113,30 @@ static void dissolve_units(void)
rsetpeasants(r, rpeasants(r) + n);
msg =
msg_message("dissolve_units_1", "unit region number race", u, r,
n, u->race);
n, u_race(u));
break;
case 2:
if (r->land && !fval(r, RF_MALLORN)) {
rsettrees(r, 2, rtrees(r, 2) + n);
msg =
msg_message("dissolve_units_2", "unit region number race", u, r,
n, u->race);
n, u_race(u));
} else {
msg =
msg_message("dissolve_units_3", "unit region number race", u, r,
n, u->race);
n, u_race(u));
}
break;
default:
if (u->race == new_race[RC_STONEGOLEM]
|| u->race == new_race[RC_IRONGOLEM]) {
if (u_race(u) == new_race[RC_STONEGOLEM]
|| u_race(u) == new_race[RC_IRONGOLEM]) {
msg =
msg_message("dissolve_units_4", "unit region number race", u, r,
n, u->race);
n, u_race(u));
} else {
msg =
msg_message("dissolve_units_5", "unit region number race", u, r,
n, u->race);
n, u_race(u));
}
break;
}
@ -355,7 +355,7 @@ static void get_allies(region * r, unit * u)
u_setfaction(newunit, u->faction);
set_racename(&newunit->attribs, get_racename(u->attribs));
if (u->race->flags & RCF_SHAPESHIFT) {
if (u_race(u)->flags & RCF_SHAPESHIFT) {
newunit->irace = u->irace;
}
if (fval(u, UFL_ANON_FACTION))
@ -445,7 +445,7 @@ static unit *random_unit(const region * r)
unit *u;
for (u = r->units; u; u = u->next) {
if (u->race != new_race[RC_SPELL]) {
if (u_race(u) != new_race[RC_SPELL]) {
c += u->number;
}
}
@ -458,7 +458,7 @@ static unit *random_unit(const region * r)
u = r->units;
while (u && c < n) {
if (u->race != new_race[RC_SPELL]) {
if (u_race(u) != new_race[RC_SPELL]) {
c += u->number;
}
u = u->next;
@ -474,10 +474,10 @@ void chaos(region * r)
case 0: /* Untote */
if (!fval(r->terrain, SEA_REGION)) {
unit *u = random_unit(r);
if (u && playerrace(u->race)) {
if (u && playerrace(u_race(u))) {
ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u));
u_setfaction(u, get_monsters());
u->race = new_race[RC_GHOUL];
u_setrace(u, new_race[RC_GHOUL]);
}
}
break;
@ -536,7 +536,7 @@ void chaos(region * r)
for (up = &r->units; *up;) {
unit *u = *up;
if (u->race != new_race[RC_SPELL] && u->ship == 0 && !canfly(u)) {
if (u_race(u) != new_race[RC_SPELL] && u->ship == 0 && !canfly(u)) {
ADDMSG(&u->faction->msgs, msg_message("tidalwave_kill",
"region unit", r, u));
remove_unit(up, u);
@ -573,7 +573,7 @@ static int nb_armor(const unit * u, int index)
int av = 0;
int s = 0, a = 0;
if (!(u->race->battle_flags & BF_EQUIPMENT))
if (!(u_race(u)->battle_flags & BF_EQUIPMENT))
return 0;
/* Normale Rüstung */
@ -604,7 +604,7 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
double magres = magic_resistance(u);
assert(u->number);
if (fval(u->race, RCF_ILLUSIONARY) || u->race == new_race[RC_SPELL]) {
if (fval(u_race(u), RCF_ILLUSIONARY) || u_race(u) == new_race[RC_SPELL]) {
return 0;
}
@ -632,7 +632,7 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
heiltrank = 0;
/* Sieben Leben */
if (old_race(u->race) == RC_CAT && (chance(1.0 / 7))) {
if (old_race(u_race(u)) == RC_CAT && (chance(1.0 / 7))) {
hp[i] = u->hp / u->number;
hp_rem += hp[i];
continue;
@ -675,7 +675,7 @@ void drown(region * r)
while (*up) {
unit *u = *up;
int amphibian_level = 0;
if (u->ship || u->race == new_race[RC_SPELL] || u->number == 0) {
if (u->ship || u_race(u) == new_race[RC_SPELL] || u->number == 0) {
up = &u->next;
continue;
}
@ -1085,11 +1085,11 @@ static void orc_growth(void)
}
}
if (increase) {
unit *u2 = create_unit(r, u->faction, increase, u->race, 0, NULL, u);
unit *u2 = create_unit(r, u->faction, increase, u_race(u), 0, NULL, u);
transfermen(u2, u, u2->number);
ADDMSG(&u->faction->msgs, msg_message("orcgrowth",
"unit amount race", u, increase, u->race));
"unit amount race", u, increase, u_race(u)));
}
}
}
@ -1105,7 +1105,7 @@ static void demon_skillchanges(void)
for (r = regions; r; r = r->next) {
unit *u;
for (u = r->units; u; u = u->next) {
if (u->race == new_race[RC_DAEMON]) {
if (u_race(u) == new_race[RC_DAEMON]) {
skill *sv = u->skills;
int upchance = 15;
int downchance = 10;
@ -1295,7 +1295,7 @@ void randomevents(void)
for (u = r->units; u; u = u->next) {
if (u->faction && !is_monsters(u->faction)
&& (u->race->flags & RCF_DESERT)) {
&& (u_race(u)->flags & RCF_DESERT)) {
if (fval(u, UFL_ISNEW))
continue;
if (rng_int() % 100 < 5) {

View File

@ -692,7 +692,7 @@ nr_unit(FILE * F, const faction * f, const unit * u, int indent, int mode)
bool isbattle = (bool) (mode == see_battle);
char buf[8192];
if (fval(u->race, RCF_INVISIBLE))
if (fval(u_race(u), RCF_INVISIBLE))
return;
{
@ -1283,7 +1283,7 @@ static void statistics(FILE * F, const region * r, const faction * f)
/* count */
for (u = r->units; u; u = u->next) {
if (u->faction == f && !fval(u->race, RCF_INVISIBLE)) {
if (u->faction == f && !fval(u_race(u), RCF_INVISIBLE)) {
for (itm = u->items; itm; itm = itm->next) {
i_change(&items, itm->type, itm->number);
}
@ -1523,7 +1523,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
continue;
for (u = r->units; u; u = u->next) {
if (u->faction == f && !fval(u->race, RCF_INVISIBLE)) {
if (u->faction == f && !fval(u_race(u), RCF_INVISIBLE)) {
order *ord;
if (!dh) {
plane *pl = getplane(r);
@ -2191,7 +2191,7 @@ report_plaintext(const char *filename, report_context * ctx,
no_units = 0;
no_people = 0;
for (u = f->units; u; u = u->nextF) {
if (playerrace(u->race)) {
if (playerrace(u_race(u))) {
++no_people;
no_units += u->number;
assert(f == u->faction);

View File

@ -239,7 +239,7 @@ int setstealth_cmd(unit * u, struct order *ord)
trace = findrace(s, u->faction->locale);
if (trace) {
/* Dämonen können sich nur als andere Spielerrassen tarnen */
if (u->race == new_race[RC_DAEMON]) {
if (u_race(u) == new_race[RC_DAEMON]) {
race_t allowed[] = { RC_DWARF, RC_ELF, RC_ORC, RC_GOBLIN, RC_HUMAN,
RC_TROLL, RC_DAEMON, RC_INSECT, RC_HALFLING, RC_CAT, RC_AQUARIAN,
NORACE
@ -250,29 +250,29 @@ int setstealth_cmd(unit * u, struct order *ord)
break;
if (new_race[allowed[i]] == trace) {
u->irace = trace;
if (u->race->flags & RCF_SHAPESHIFTANY && get_racename(u->attribs))
if (u_race(u)->flags & RCF_SHAPESHIFTANY && get_racename(u->attribs))
set_racename(&u->attribs, NULL);
}
return 0;
}
/* Singdrachen können sich nur als Drachen tarnen */
if (u->race == new_race[RC_SONGDRAGON]
|| u->race == new_race[RC_BIRTHDAYDRAGON]) {
if (u_race(u) == new_race[RC_SONGDRAGON]
|| u_race(u) == new_race[RC_BIRTHDAYDRAGON]) {
if (trace == new_race[RC_SONGDRAGON] || trace == new_race[RC_FIREDRAGON]
|| trace == new_race[RC_DRAGON] || trace == new_race[RC_WYRM]) {
u->irace = trace;
if (u->race->flags & RCF_SHAPESHIFTANY && get_racename(u->attribs))
if (u_race(u)->flags & RCF_SHAPESHIFTANY && get_racename(u->attribs))
set_racename(&u->attribs, NULL);
}
return 0;
}
/* Dämomen und Illusionsparteien können sich als andere race tarnen */
if (u->race->flags & RCF_SHAPESHIFT) {
if (u_race(u)->flags & RCF_SHAPESHIFT) {
if (playerrace(trace)) {
u->irace = trace;
if ((u->race->flags & RCF_SHAPESHIFTANY) && get_racename(u->attribs))
if ((u_race(u)->flags & RCF_SHAPESHIFTANY) && get_racename(u->attribs))
set_racename(&u->attribs, NULL);
}
}
@ -328,7 +328,7 @@ int setstealth_cmd(unit * u, struct order *ord)
u_seteffstealth(u, -1);
break;
default:
if (u->race->flags & RCF_SHAPESHIFTANY) {
if (u_race(u)->flags & RCF_SHAPESHIFTANY) {
set_racename(&u->attribs, s);
} else {
cmistake(u, ord, 289, MSG_EVENT);

View File

@ -89,14 +89,14 @@ magic_t getmagicskill(const struct locale * lang)
/* Vertraute und Kröten sind keine Migranten */
bool is_migrant(unit * u)
{
if (u->race == u->faction->race)
if (u_race(u) == u->faction->race)
return false;
if (fval(u->race, RCF_UNDEAD | RCF_ILLUSIONARY))
if (fval(u_race(u), RCF_UNDEAD | RCF_ILLUSIONARY))
return false;
if (is_familiar(u))
return false;
if (u->race == new_race[RC_TOAD])
if (u_race(u) == new_race[RC_TOAD])
return false;
return true;
@ -105,7 +105,7 @@ bool is_migrant(unit * u)
/* ------------------------------------------------------------- */
bool magic_lowskill(unit * u)
{
return (u->race == new_race[RC_TOAD]) ? true : false;
return (u_race(u) == new_race[RC_TOAD]) ? true : false;
}
/* ------------------------------------------------------------- */
@ -160,8 +160,8 @@ const attrib_type at_learning = {
static int study_days(unit * student, skill_t sk)
{
int speed = 30;
if (student->race->study_speed) {
speed += student->race->study_speed[sk];
if (u_race(student)->study_speed) {
speed += u_race(student)->study_speed[sk];
if (speed < 30) {
skill *sv = get_skill(student, sk);
if (sv == 0) {
@ -288,7 +288,7 @@ int teach_cmd(unit * u, struct order *ord)
}
}
if ((u->race->flags & RCF_NOTEACH) || fval(u, UFL_WERE)) {
if ((u_race(u)->flags & RCF_NOTEACH) || fval(u, UFL_WERE)) {
cmistake(u, ord, 274, MSG_EVENT);
return 0;
}
@ -542,9 +542,9 @@ int learn_cmd(unit * u, order * ord)
learn_newskills = 1;
}
if ((u->race->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) {
if ((u_race(u)->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race",
u->race));
u_race(u)));
return 0;
}
@ -561,7 +561,7 @@ int learn_cmd(unit * u, order * ord)
return 0;
}
/* Hack: Talente mit Malus -99 können nicht gelernt werden */
if (u->race->bonus[sk] == -99) {
if (u_race(u)->bonus[sk] == -99) {
cmistake(u, ord, 771, MSG_EVENT);
return 0;
}
@ -575,7 +575,7 @@ int learn_cmd(unit * u, order * ord)
}
/* snotlings können Talente nur bis T8 lernen */
if (u->race == new_race[RC_SNOTLING]) {
if (u_race(u) == new_race[RC_SNOTLING]) {
if (get_level(u, sk) >= 8) {
cmistake(u, ord, 308, MSG_EVENT);
return 0;

View File

@ -404,7 +404,7 @@ summary *make_summary(void)
f->num_total += u->number;
f->money += get_money(u);
s->poprace[old_race(u->race)] += u->number;
s->poprace[old_race(u_race(u))] += u->number;
}
}
}

View File

@ -61,7 +61,7 @@ use_phoenixcompass(struct unit *u, const struct item_type *itype,
for (r = regions; r; r = r->next) {
for (u2 = r->units; u2; u2 = u2->next) {
if (u2->race == rc_phoenix) {
if (u_race(u2) == rc_phoenix) {
if (closest_phoenix == NULL) {
closest_phoenix = u2;
closest_phoenix_distance =

View File

@ -351,7 +351,7 @@ fighter *select_corpse(battle * b, fighter * af)
/* Geflohene haben auch 0 hp, dürfen hier aber nicht ausgewählt
* werden! */
int dead = dead_fighters(df);
if (!playerrace(df->unit->race))
if (!playerrace(u_race(df->unit)))
continue;
if (af && !helping(af->side, df->side))
@ -624,39 +624,39 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking)
skill = effskill(u, SK_WEAPONLESS);
if (skill <= 0) {
/* wenn kein waffenloser kampf, dann den rassen-defaultwert */
if (u->race == new_race[RC_ORC]) {
if (u_race(u) == new_race[RC_ORC]) {
int sword = effskill(u, SK_MELEE);
int spear = effskill(u, SK_SPEAR);
skill = MAX(sword, spear) - 3;
if (attacking) {
skill = MAX(skill, u->race->at_default);
skill = MAX(skill, u_race(u)->at_default);
} else {
skill = MAX(skill, u->race->df_default);
skill = MAX(skill, u_race(u)->df_default);
}
} else {
if (attacking) {
skill = u->race->at_default;
skill = u_race(u)->at_default;
} else {
skill = u->race->df_default;
skill = u_race(u)->df_default;
}
}
} else {
/* der rassen-defaultwert kann höher sein als der Talentwert von
* waffenloser kampf */
if (attacking) {
if (skill < u->race->at_default)
skill = u->race->at_default;
if (skill < u_race(u)->at_default)
skill = u_race(u)->at_default;
} else {
if (skill < u->race->df_default)
skill = u->race->df_default;
if (skill < u_race(u)->df_default)
skill = u_race(u)->df_default;
}
}
if (attacking) {
skill += u->race->at_bonus;
skill += u_race(u)->at_bonus;
if (fval(u->region->terrain, SEA_REGION) && u->ship)
skill += u->ship->type->at_bonus;
} else {
skill += u->race->df_bonus;
skill += u_race(u)->df_bonus;
if (fval(u->region->terrain, SEA_REGION) && u->ship)
skill += u->ship->type->df_bonus;
}
@ -669,9 +669,9 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking)
skill = 0;
if (skill > 0) {
if (attacking) {
skill += u->race->at_bonus;
skill += u_race(u)->at_bonus;
} else {
skill += u->race->df_bonus;
skill += u_race(u)->df_bonus;
}
}
if (attacking) {
@ -713,7 +713,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type)
if (skl > 0) {
if (type == BONUS_DAMAGE) {
int dmg = MIN(skl, 8);
if (enemy.fighter->unit->race == new_race[RC_TROLL]) {
if (u_race(enemy.fighter->unit) == new_race[RC_TROLL]) {
dmg = dmg / 4;
} else {
dmg = dmg / 2;
@ -769,7 +769,7 @@ weapon_effskill(troop t, troop enemy, const weapon * w, bool attacking,
race_list *rlist = wtype->modifiers[m].races;
if (rlist != NULL) {
while (rlist) {
if (rlist->data == tu->race)
if (rlist->data == u_race(tu))
break;
rlist = rlist->next;
}
@ -818,7 +818,7 @@ static const armor_type *select_armor(troop t, bool shield)
int geschuetzt = 0;
/* some monsters should not use armor (dragons in chainmail? ha!) */
if (!(u->race->battle_flags & BF_EQUIPMENT))
if (!(u_race(u)->battle_flags & BF_EQUIPMENT))
return NULL;
/* ... neither do werewolves */
@ -903,7 +903,7 @@ void rmfighter(fighter * df, int i)
ds->size[statusrow(df->status)] -= i;
/* Spezialwirkungen, z.B. Schattenritter */
if (df->unit->race->battle_flags & BF_NOBLOCK) {
if (u_race(df->unit)->battle_flags & BF_NOBLOCK) {
ds->nonblockers[SUM_ROW] -= i;
ds->nonblockers[statusrow(df->status)] -= i;
}
@ -949,14 +949,14 @@ void kill_troop(troop dt)
if (!df->alive) {
char eqname[64];
const struct equipment *eq;
if (du->race->itemdrop) {
item *drops = du->race->itemdrop(du->race, du->number - df->run.number);
if (u_race(du)->itemdrop) {
item *drops = u_race(du)->itemdrop(u_race(du), du->number - df->run.number);
if (drops != NULL) {
i_merge(&du->items, &drops);
}
}
sprintf(eqname, "%s_spoils", du->race->_name[0]);
sprintf(eqname, "%s_spoils", u_race(du)->_name[0]);
eq = get_equipment(eqname);
if (eq != NULL) {
equip_items(&du->items, eq);
@ -1033,19 +1033,19 @@ static void vampirism(troop at, int damage)
static int natural_armor(unit * du)
{
static int *bonus = 0;
int an = du->race->armor;
int an = u_race(du)->armor;
if (bonus == 0) {
bonus = calloc(sizeof(int), num_races);
}
if (bonus[du->race->index] == 0) {
bonus[du->race->index] =
get_param_int(du->race->parameters, "armor.stamina", -1);
if (bonus[du->race->index] == 0)
bonus[du->race->index] = -1;
if (bonus[u_race(du)->index] == 0) {
bonus[u_race(du)->index] =
get_param_int(u_race(du)->parameters, "armor.stamina", -1);
if (bonus[u_race(du)->index] == 0)
bonus[u_race(du)->index] = -1;
}
if (bonus[du->race->index] > 0) {
if (bonus[u_race(du)->index] > 0) {
int sk = effskill(du, SK_STAMINA);
sk /= bonus[du->race->index];
sk /= bonus[u_race(du)->index];
an += sk;
}
return an;
@ -1170,7 +1170,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
}
}
da += rc_specialdamage(au->race, du->race, awtype);
da += rc_specialdamage(u_race(au), u_race(du), awtype);
if (awtype != NULL && fval(awtype, WTF_MISSILE)) {
/* missile weapon bonus */
@ -1202,7 +1202,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
/* magic_resistance gib x% Resistenzbonus zurück */
res -= magic_resistance(du) * 3.0;
if (du->race->battle_flags & BF_EQUIPMENT) {
if (u_race(du)->battle_flags & BF_EQUIPMENT) {
#ifdef TODO_RUNESWORD
/* Runenschwert gibt im Kampf 80% Resistenzbonus */
if (dwp == WP_RUNESWORD)
@ -1226,18 +1226,18 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
rda = MAX(da - ar, 0);
if ((du->race->battle_flags & BF_INV_NONMAGIC) && !magic)
if ((u_race(du)->battle_flags & BF_INV_NONMAGIC) && !magic)
rda = 0;
else {
int qi;
quicklist *ql;
unsigned int i = 0;
if (du->race->battle_flags & BF_RES_PIERCE)
if (u_race(du)->battle_flags & BF_RES_PIERCE)
i |= WTF_PIERCE;
if (du->race->battle_flags & BF_RES_CUT)
if (u_race(du)->battle_flags & BF_RES_CUT)
i |= WTF_CUT;
if (du->race->battle_flags & BF_RES_BASH)
if (u_race(du)->battle_flags & BF_RES_BASH)
i |= WTF_BLUNT;
if (i && awtype && fval(awtype, i))
@ -1266,7 +1266,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
assert(dt.index < du->number);
df->person[dt.index].hp -= rda;
if (au->race == new_race[RC_DAEMON]) {
if (u_race(au) == new_race[RC_DAEMON]) {
vampirism(at, rda);
}
@ -1275,7 +1275,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
fprintf(bdebug, "Damage %d, armor %d: %d -> %d HP\n",
da, ar, df->person[dt.index].hp + rda, df->person[dt.index].hp);
}
if (au->race == new_race[RC_DAEMON]) {
if (u_race(au) == new_race[RC_DAEMON]) {
#ifdef TODO_RUNESWORD
if (select_weapon(dt, 0, -1) == WP_RUNESWORD)
continue;
@ -1290,7 +1290,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
}
/* Sieben Leben */
if (du->race == new_race[RC_CAT] && (chance(1.0 / 7))) {
if (u_race(du) == new_race[RC_CAT] && (chance(1.0 / 7))) {
assert(dt.index >= 0 && dt.index < du->number);
df->person[dt.index].hp = unit_max_hp(du);
return false;
@ -1313,7 +1313,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
msg_release(m);
}
assert(dt.index >= 0 && dt.index < du->number);
df->person[dt.index].hp = du->race->hitpoints;
df->person[dt.index].hp = u_race(du)->hitpoints;
return false;
}
}
@ -1464,7 +1464,7 @@ troop select_enemy(fighter * af, int minrow, int maxrow, int select)
#ifdef DEBUG_SELECT
troop result = no_troop;
#endif
if (af->unit->race->flags & RCF_FLY) {
if (u_race(af->unit)->flags & RCF_FLY) {
/* flying races ignore min- and maxrow and can attack anyone fighting
* them */
minrow = FIGHT_ROW;
@ -1564,7 +1564,7 @@ static troop select_opponent(battle * b, troop at, int mindist, int maxdist)
fighter *af = at.fighter;
troop dt;
if (af->unit->race->flags & RCF_FLY) {
if (u_race(af->unit)->flags & RCF_FLY) {
/* flying races ignore min- and maxrow and can attack anyone fighting
* them */
dt = select_enemy(at.fighter, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
@ -1849,11 +1849,11 @@ int skilldiff(troop at, troop dt, int dist)
skdiff += 2;
/* Effekte durch Rassen */
if (awp != NULL && au->race == new_race[RC_HALFLING] && dragonrace(du->race)) {
if (awp != NULL && u_race(au) == new_race[RC_HALFLING] && dragonrace(u_race(du))) {
skdiff += 5;
}
if (au->race == new_race[RC_GOBLIN]) {
if (u_race(au) == new_race[RC_GOBLIN]) {
static int goblin_bonus = -1;
if (goblin_bonus < 0)
goblin_bonus =
@ -2067,8 +2067,8 @@ static void make_heroes(battle * b)
unit *u = fig->unit;
if (fval(u, UFL_HERO)) {
int i;
if (!playerrace(u->race)) {
log_error("Hero %s is a %s.\n", unitname(u), u->race->_name[0]);
if (!playerrace(u_race(u))) {
log_error("Hero %s is a %s.\n", unitname(u), u_race(u)->_name[0]);
}
for (i = 0; i != u->number; ++i) {
fig->person[i].speed += (hero_speed - 1);
@ -2144,7 +2144,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
if (hits(ta, td, wp)) {
const char *d;
if (wp == NULL)
d = au->race->def_damage;
d = u_race(au)->def_damage;
else if (is_riding(ta))
d = wp->type->damage[1];
else
@ -2260,11 +2260,11 @@ void do_attack(fighter * af)
for (apr = 0; apr != attacks; ++apr) {
int a;
for (a = 0; a != 10 && au->race->attack[a].type != AT_NONE; ++a) {
for (a = 0; a != 10 && u_race(au)->attack[a].type != AT_NONE; ++a) {
if (apr > 0) {
/* Wenn die Waffe nachladen muss, oder es sich nicht um einen
* Waffen-Angriff handelt, dann gilt der Speed nicht. */
if (au->race->attack[a].type != AT_STANDARD)
if (u_race(au)->attack[a].type != AT_STANDARD)
continue;
else {
weapon *wp = preferred_weapon(ta, true);
@ -2272,7 +2272,7 @@ void do_attack(fighter * af)
continue;
}
}
attack(b, ta, &(au->race->attack[a]), apr);
attack(b, ta, &(u_race(au)->attack[a]), apr);
}
}
}
@ -2362,7 +2362,7 @@ double fleechance(unit * u)
c += (eff_skill(u, SK_STEALTH, r) * 0.05);
c += horsebonus(u);
if (u->race == new_race[RC_HALFLING]) {
if (u_race(u) == new_race[RC_HALFLING]) {
c += 0.20;
c = MIN(c, 0.90);
} else {
@ -2652,8 +2652,8 @@ static void aftermath(battle * b)
/* tote insgesamt: */
s->dead += dead;
/* Tote, die wiederbelebt werde können: */
if (playerrace(df->unit->race)) {
/* Tote, die wiederbelebt werde koennen: */
if (playerrace(u_race(df->unit))) {
s->casualties += dead;
}
if (df->hits + df->kills) {
@ -2769,7 +2769,7 @@ static void aftermath(battle * b)
}
s->flee += df->run.number;
if (playerrace(du->race)) {
if (playerrace(u_race(du))) {
/* tote im kampf werden zu regionsuntoten:
* for each of them, a peasant will die as well */
dead_players += dead;
@ -3207,7 +3207,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
}
/* Illusionen und Zauber kaempfen nicht */
if (fval(u->race, RCF_ILLUSIONARY) || idle(u->faction) || u->number == 0) {
if (fval(u_race(u), RCF_ILLUSIONARY) || idle(u->faction) || u->number == 0) {
return NULL;
}
if (s1 == NULL) {
@ -3233,7 +3233,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
set_attacker(fig);
} else {
building *bld = u->building;
if (bld && bld->sizeleft >= u->number && playerrace(u->race)) {
if (bld && bld->sizeleft >= u->number && playerrace(u_race(u))) {
fig->building = bld;
fig->building->sizeleft -= u->number;
}
@ -3304,7 +3304,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
/* Für alle Waffengattungen wird bestimmt, wie viele der Personen mit
* ihr kämpfen könnten, und was ihr Wert darin ist. */
if (u->race->battle_flags & BF_EQUIPMENT) {
if (u_race(u)->battle_flags & BF_EQUIPMENT) {
int oi = 0, di = 0;
for (itm = u->items; itm && w != WMAX; itm = itm->next) {
const weapon_type *wtype = resource2weapon(itm->type->rtype);
@ -3382,11 +3382,11 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
s1->size[statusrow(fig->status)] += u->number;
s1->size[SUM_ROW] += u->number;
if (u->race->battle_flags & BF_NOBLOCK) {
if (u_race(u)->battle_flags & BF_NOBLOCK) {
s1->nonblockers[statusrow(fig->status)] += u->number;
}
if (fig->unit->race->flags & RCF_HORSE) {
if (u_race(fig->unit)->flags & RCF_HORSE) {
fig->horses = fig->unit->number;
fig->elvenhorses = 0;
} else {
@ -3401,7 +3401,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
fig->elvenhorses = get_item(u, I_ELVENHORSE);
}
if (u->race->battle_flags & BF_EQUIPMENT) {
if (u_race(u)->battle_flags & BF_EQUIPMENT) {
for (itm = u->items; itm; itm = itm->next) {
if (itm->type->rtype->atype) {
if (i_canuse(u, itm->type)) {
@ -3430,18 +3430,18 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
if (fig->horses) {
if (!fval(r->terrain, CAVALRY_REGION) || r_isforest(r)
|| eff_skill(u, SK_RIDING, r) < CavalrySkill()
|| u->race == new_race[RC_TROLL] || fval(u, UFL_WERE))
|| u_race(u) == new_race[RC_TROLL] || fval(u, UFL_WERE))
fig->horses = 0;
}
if (fig->elvenhorses) {
if (eff_skill(u, SK_RIDING, r) < 5 || u->race == new_race[RC_TROLL]
if (eff_skill(u, SK_RIDING, r) < 5 || u_race(u) == new_race[RC_TROLL]
|| fval(u, UFL_WERE))
fig->elvenhorses = 0;
}
/* Schauen, wie gut wir in Taktik sind. */
if (tactics > 0 && u->race == new_race[RC_INSECT])
if (tactics > 0 && u_race(u) == new_race[RC_INSECT])
tactics -= 1 - (int)log10(fig->side->size[SUM_ROW]);
#ifdef TACTICS_MODIFIER
if (tactics > 0 && statusrow(fig->status) == FIGHT_ROW)
@ -3936,9 +3936,9 @@ static bool start_battle(region * r, battle ** bp)
continue;
}
if ((u->race->battle_flags & BF_CANATTACK) == 0) {
if ((u_race(u)->battle_flags & BF_CANATTACK) == 0) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "race_no_attack",
"race", u->race));
"race", u_race(u)));
continue;
}
/**
@ -4209,7 +4209,7 @@ static void battle_flee(battle * b)
/* keine Flucht von Schiffen auf hoher See */
continue;
}
if (fval(u->race, RCF_UNDEAD) || u->race == new_race[RC_SHADOWKNIGHT]) {
if (fval(u_race(u), RCF_UNDEAD) || u_race(u) == new_race[RC_SHADOWKNIGHT]) {
/* Untote fliehen nicht. Warum eigentlich? */
continue;
}

View File

@ -320,7 +320,7 @@ void build_road(region * r, unit * u, int size, direction_t d)
if (size > 0)
left = MIN(size, left);
/* baumaximum anhand der rohstoffe */
if (u->race == new_race[RC_STONEGOLEM]) {
if (u_race(u) == new_race[RC_STONEGOLEM]) {
n = u->number * GOLEM_STONE;
} else {
n = get_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT, left);
@ -360,7 +360,7 @@ void build_road(region * r, unit * u, int size, direction_t d)
* maximum. */
rsetroad(r, d, rroad(r, d) + (short)n);
if (u->race == new_race[RC_STONEGOLEM]) {
if (u_race(u) == new_race[RC_STONEGOLEM]) {
int golemsused = n / GOLEM_STONE;
if (n % GOLEM_STONE != 0) {
++golemsused;
@ -904,7 +904,7 @@ create_ship(region * r, unit * u, const struct ship_type *newtype, int want,
sh = new_ship(newtype, r, u->faction->locale);
if (leave(u, false)) {
if (fval(u->race, RCF_CANSAIL)) {
if (fval(u_race(u), RCF_CANSAIL)) {
u_set_ship(u, sh);
}
}

View File

@ -239,7 +239,7 @@ int LongHunger(const struct unit *u)
if (!fval(u, UFL_HUNGER))
return false;
#ifdef NEW_DAEMONHUNGER_RULE
if (u->race == new_race[RC_DAEMON])
if (u_race(u) == new_race[RC_DAEMON])
return false;
#endif
}
@ -637,9 +637,9 @@ int shipspeed(const ship * sh, const unit * u)
if (curse_active(get_curse(sh->attribs, nodrift_ct)))
k += 1;
if (u->faction->race == u->race) {
if (u->faction->race == u_race(u)) {
/* race bonus for this faction? */
if (fval(u->race, RCF_SHIPSPEED)) {
if (fval(u_race(u), RCF_SHIPSPEED)) {
k += 1;
}
}
@ -986,7 +986,7 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
if (u->faction == f || omniscient(f)) {
return true;
} else if (fval(u->race, RCF_INVISIBLE)) {
} else if (fval(u_race(u), RCF_INVISIBLE)) {
return false;
} else if (u->number == 0) {
attrib *a = a_find(u->attribs, &at_creator);
@ -1040,7 +1040,7 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
bool cansee_unit(const unit * u, const unit * target, int modifier)
/* target->region kann != u->region sein, wenn es um durchreisen geht */
{
if (fval(target->race, RCF_INVISIBLE) || target->number == 0)
if (fval(u_race(target), RCF_INVISIBLE) || target->number == 0)
return false;
else if (target->faction == u->faction)
return true;
@ -1083,7 +1083,7 @@ cansee_durchgezogen(const faction * f, const region * r, const unit * u,
int n;
unit *u2;
if (fval(u->race, RCF_INVISIBLE) || u->number == 0)
if (fval(u_race(u), RCF_INVISIBLE) || u->number == 0)
return false;
else if (u->faction == f)
return true;
@ -1199,7 +1199,7 @@ int count_all(const faction * f)
int n = 0;
unit *u;
for (u = f->units; u; u = u->nextF) {
if (playerrace(u->race)) {
if (playerrace(u_race(u))) {
n += u->number;
assert(f == u->faction);
}
@ -1217,9 +1217,9 @@ int count_migrants(const faction * f)
int n = 0;
while (u) {
assert(u->faction == f);
if (u->race != f->race && u->race != new_race[RC_ILLUSION]
&& u->race != new_race[RC_SPELL]
&& !!playerrace(u->race) && !(is_cursed(u->attribs, C_SLAVE, 0))) {
if (u_race(u) != f->race && u_race(u) != new_race[RC_ILLUSION]
&& u_race(u) != new_race[RC_SPELL]
&& !!playerrace(u_race(u)) && !(is_cursed(u->attribs, C_SLAVE, 0))) {
n += u->number;
}
u = u->nextF;
@ -2345,8 +2345,8 @@ void remove_empty_units_in_region(region * r)
}
}
}
if ((u->number == 0 && u->race != new_race[RC_SPELL]) || (u->age <= 0
&& u->race == new_race[RC_SPELL])) {
if ((u->number == 0 && u_race(u) != new_race[RC_SPELL]) || (u->age <= 0
&& u_race(u) == new_race[RC_SPELL])) {
remove_unit(up, u);
}
if (*up == u)
@ -2380,7 +2380,7 @@ int weight(const unit * u)
in_bag += w;
}
n += u->number * u->race->weight;
n += u->number * u_race(u)->weight;
w = get_item(u, I_BAG_OF_HOLDING) * BAGCAPACITY;
if (w > in_bag)
@ -2407,9 +2407,9 @@ unsigned int guard_flags(const unit * u)
#if GUARD_DISABLES_RECRUIT == 1
flags |= GUARD_RECRUIT;
#endif
switch (old_race(u->race)) {
switch (old_race(u_race(u))) {
case RC_ELF:
if (u->faction->race != u->race)
if (u->faction->race != u_race(u))
break;
/* else fallthrough */
case RC_TREEMAN:
@ -2484,9 +2484,9 @@ bool hunger(int number, unit * u)
if (damage == NULL)
damage = "1d12+12";
}
if (rc != u->race) {
rcdamage = get_param(u->race->parameters, "hunger.damage");
rc = u->race;
if (rc != u_race(u)) {
rcdamage = get_param(u_race(u)->parameters, "hunger.damage");
rc = u_race(u);
}
while (number--) {
@ -2843,7 +2843,7 @@ int maintenance_cost(const struct unit *u)
if (retval >= 0)
return retval;
}
return u->race->maintenance * u->number;
return u_race(u)->maintenance * u->number;
}
message *movement_error(unit * u, const char *token, order * ord,
@ -2928,7 +2928,7 @@ void add_income(unit * u, int type, int want, int qty)
int produceexp(struct unit *u, skill_t sk, int n)
{
if (global.producexpchance > 0.0F) {
if (n == 0 || !playerrace(u->race))
if (n == 0 || !playerrace(u_race(u)))
return 0;
learn_skill(u, sk, global.producexpchance);
}

View File

@ -448,7 +448,7 @@ extern "C" {
extern struct attrib_type at_guard;
extern void free_gamedata(void);
#if 1 /* disable to count all units */
# define count_unit(u) playerrace(u->race)
# define count_unit(u) playerrace(u_race(u))
#else
# define count_unit(u) 1
#endif

View File

@ -243,7 +243,7 @@ unit *addplayer(region * r, faction * f)
u = createunit(r, f, 1, f->race);
equip_items(&u->faction->items, get_equipment("new_faction"));
equip_unit(u, get_equipment("first_unit"));
sprintf(buffer, "first_%s", u->race->_name[0]);
sprintf(buffer, "first_%s", u_race(u)->_name[0]);
equip_unit(u, get_equipment(buffer));
u->hp = unit_max_hp(u) * u->number;
fset(u, UFL_ISNEW);
@ -314,8 +314,8 @@ void destroyfaction(faction * f)
} else {
region *r = u->region;
if (!fval(r->terrain, SEA_REGION) && !!playerrace(u->race)) {
const race *rc = u->race;
if (!fval(r->terrain, SEA_REGION) && !!playerrace(u_race(u))) {
const race *rc = u_race(u);
int m = rmoney(r);
if ((rc->ec_flags & ECF_REC_ETHEREAL) == 0) {

View File

@ -104,7 +104,7 @@ static int res_changepeasants(unit * u, const resource_type * rtype, int delta)
static int res_changeitem(unit * u, const resource_type * rtype, int delta)
{
int num;
if (rtype == oldresourcetype[R_STONE] && u->race == new_race[RC_STONEGOLEM]
if (rtype == oldresourcetype[R_STONE] && u_race(u) == new_race[RC_STONEGOLEM]
&& delta <= 0) {
int reduce = delta / GOLEM_STONE;
if (delta % GOLEM_STONE != 0)
@ -112,7 +112,7 @@ static int res_changeitem(unit * u, const resource_type * rtype, int delta)
scale_number(u, u->number + reduce);
num = u->number;
} else if (rtype == oldresourcetype[R_IRON]
&& u->race == new_race[RC_IRONGOLEM] && delta <= 0) {
&& u_race(u) == new_race[RC_IRONGOLEM] && delta <= 0) {
int reduce = delta / GOLEM_IRON;
if (delta % GOLEM_IRON != 0)
--reduce;
@ -712,7 +712,7 @@ const char *itemnames[MAXITEMS] = {
static int
mod_elves_only(const unit * u, const region * r, skill_t sk, int value)
{
if (u->race == new_race[RC_ELF])
if (u_race(u) == new_race[RC_ELF])
return value;
unused(r);
return -118;
@ -721,7 +721,7 @@ mod_elves_only(const unit * u, const region * r, skill_t sk, int value)
static int
mod_dwarves_only(const unit * u, const region * r, skill_t sk, int value)
{
if (u->race == new_race[RC_DWARF])
if (u_race(u) == new_race[RC_DWARF])
return value;
unused(r);
return -118;
@ -842,11 +842,11 @@ static int
use_bloodpotion(struct unit *u, const struct item_type *itype, int amount,
struct order *ord)
{
if (u->race == new_race[RC_DAEMON]) {
if (u_race(u) == new_race[RC_DAEMON]) {
change_effect(u, itype->rtype->ptype, 100 * amount);
} else {
const race *irace = u_irace(u);
if (irace == u->race) {
if (irace == u_race(u)) {
static race *rcfailure;
if (!rcfailure) {
rcfailure = rc_find("smurf");
@ -854,14 +854,14 @@ use_bloodpotion(struct unit *u, const struct item_type *itype, int amount,
rcfailure = rc_find("toad");
}
if (rcfailure) {
trigger *trestore = trigger_changerace(u, u->race, irace);
trigger *trestore = trigger_changerace(u, u_race(u), irace);
if (trestore) {
int duration = 2 + rng_int() % 8;
add_trigger(&u->attribs, "timer", trigger_timeout(duration,
trestore));
u->irace = NULL;
u->race = rcfailure;
u_setrace(u, rcfailure);
}
}
}

View File

@ -554,8 +554,8 @@ const spell *get_combatspell(const unit * u, int nr)
m = get_mage(u);
if (m) {
return m->combatspells[nr].sp;
} else if (u->race->precombatspell != NULL) {
return u->race->precombatspell;
} else if (u_race(u)->precombatspell != NULL) {
return u_race(u)->precombatspell;
}
return NULL;
@ -706,7 +706,7 @@ static int use_item_aura(const region * r, const unit * u)
int sk, n;
sk = eff_skill(u, SK_MAGIC, r);
n = (int)(sk * sk * u->race->maxaura / 4);
n = (int)(sk * sk * u_race(u)->maxaura / 4);
return n;
}
@ -719,7 +719,7 @@ int max_spellpoints(const region * r, const unit * u)
double divisor = 1.2;
sk = eff_skill(u, SK_MAGIC, r);
msp = u->race->maxaura * (pow(sk, potenz) / divisor + 1) + get_spchange(u);
msp = u_race(u)->maxaura * (pow(sk, potenz) / divisor + 1) + get_spchange(u);
if (get_item(u, I_AURAKULUM) > 0) {
msp += use_item_aura(r, u);
@ -1025,7 +1025,7 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level,
if (elf_power < 0) {
elf_power = get_param_int(global.parameters, "rules.magic.elfpower", 0);
}
if (elf_power && u->race == new_race[RC_ELF] && r_isforest(r)) {
if (elf_power && u_race(u) == new_race[RC_ELF] && r_isforest(r)) {
++force;
}
@ -1110,7 +1110,7 @@ double magic_resistance(unit * target)
const curse_type * ct_goodresist = 0, * ct_badresist = 0;
/* Bonus durch Rassenmagieresistenz */
double probability = target->race->magres;
double probability = u_race(target)->magres;
assert(target->number > 0);
/* Magier haben einen Resistenzbonus vom Magietalent * 5% */
@ -1354,7 +1354,7 @@ static void do_fumble(castorder * co)
* The list of things to happen are attached to a timeout
* trigger and that's added to the triggerlit of the mage gone toad.
*/
trigger *trestore = trigger_changerace(u, u->race, u->irace);
trigger *trestore = trigger_changerace(u, u_race(u), u->irace);
if (chance(0.7)) {
const item_type *it_toadslime = it_find("toadslime");
@ -1367,7 +1367,7 @@ static void do_fumble(castorder * co)
if (duration < 2)
duration = 2;
add_trigger(&u->attribs, "timer", trigger_timeout(duration, trestore));
u->race = new_race[RC_TOAD];
u_setrace(u, new_race[RC_TOAD]);
u->irace = NULL;
ADDMSG(&r->msgs, msg_message("patzer6", "unit region spell", u, r, sp));
break;
@ -1431,7 +1431,7 @@ static double regeneration(unit * u)
sk = effskill(u, SK_MAGIC);
/* Rassenbonus/-malus */
d = pow(sk, potenz) * u->race->regaura / divisor;
d = pow(sk, potenz) * u_race(u)->regaura / divisor;
d++;
/* Einfluss von Artefakten */
@ -2594,8 +2594,8 @@ static castorder *cast_cmd(unit * u, order * ord)
* normalerweise nur Meermenschen, ausgenommen explizit als
* OCEANCASTABLE deklarierte Sprüche */
if (fval(r->terrain, SEA_REGION)) {
if (u->race != new_race[RC_AQUARIAN]
&& !fval(u->race, RCF_SWIM)
if (u_race(u) != new_race[RC_AQUARIAN]
&& !fval(u_race(u), RCF_SWIM)
&& !(sp->sptyp & OCEANCASTABLE)) {
/* Fehlermeldung */
ADDMSG(&u->faction->msgs, msg_message("spellfail_onocean",
@ -2732,10 +2732,10 @@ void magic(void)
for (u = r->units; u; u = u->next) {
order *ord;
if (u->number <= 0 || u->race == new_race[RC_SPELL])
if (u->number <= 0 || u_race(u) == new_race[RC_SPELL])
continue;
if (u->race == new_race[RC_INSECT] && r_insectstalled(r) &&
if (u_race(u) == new_race[RC_INSECT] && r_insectstalled(r) &&
!is_cursed(u->attribs, C_KAELTESCHUTZ, 0))
continue;

View File

@ -196,7 +196,7 @@ static bool entrance_allowed(const struct unit *u, const struct region *r)
int personcapacity(const unit * u)
{
int cap = u->race->weight + u->race->capacity;
int cap = u_race(u)->weight + u_race(u)->capacity;
return cap;
}
@ -254,7 +254,7 @@ static int ridingcapacity(unit * u)
** von zwei Pferden gezogen wird */
animals = MIN(animals, effskill(u, SK_RIDING) * u->number * 2);
if (fval(u->race, RCF_HORSE))
if (fval(u_race(u), RCF_HORSE))
animals += u->number;
/* maximal diese Pferde können zum Ziehen benutzt werden */
@ -276,7 +276,7 @@ int walkingcapacity(const struct unit *u)
* die Leute tragen */
pferde_fuer_wagen = MIN(animals, effskill(u, SK_RIDING) * u->number * 4);
if (fval(u->race, RCF_HORSE)) {
if (fval(u_race(u), RCF_HORSE)) {
animals += u->number;
people = 0;
} else {
@ -288,7 +288,7 @@ int walkingcapacity(const struct unit *u)
n = wagen_mit_pferden * vcap;
if (u->race == new_race[RC_TROLL]) {
if (u_race(u) == new_race[RC_TROLL]) {
/* 4 Trolle ziehen einen Wagen. */
/* Unbesetzte Wagen feststellen */
wagen_ohne_pferde = vehicles - wagen_mit_pferden;
@ -340,7 +340,7 @@ static int canwalk(unit * u)
get_transporters(u->items, &animals, &acap, &vehicles, &vcap);
maxwagen = effskill(u, SK_RIDING) * u->number * 2;
if (u->race == new_race[RC_TROLL]) {
if (u_race(u) == new_race[RC_TROLL]) {
maxwagen = MAX(maxwagen, u->number / 4);
}
maxpferde = effskill(u, SK_RIDING) * u->number * 4 + u->number;
@ -370,7 +370,7 @@ bool canfly(unit * u)
if (get_item(u, I_PEGASUS) >= u->number && effskill(u, SK_RIDING) >= 4)
return true;
if (fval(u->race, RCF_FLY))
if (fval(u_race(u), RCF_FLY))
return true;
if (get_movement(&u->attribs, MV_FLY))
@ -384,10 +384,10 @@ bool canswim(unit * u)
if (get_item(u, I_DOLPHIN) >= u->number && effskill(u, SK_RIDING) >= 4)
return true;
if (u->race->flags & RCF_FLY)
if (u_race(u)->flags & RCF_FLY)
return true;
if (u->race->flags & RCF_SWIM)
if (u_race(u)->flags & RCF_SWIM)
return true;
if (get_movement(&u->attribs, MV_FLY))
@ -425,14 +425,14 @@ static int canride(unit * u)
maxunicorns = (skill / 5) * u->number;
maxhorses = skill * u->number * 2;
if (!(u->race->flags & RCF_HORSE)
if (!(u_race(u)->flags & RCF_HORSE)
&& ((horses == 0 && unicorns == 0)
|| horses > maxhorses || unicorns > maxunicorns)) {
return 0;
}
if (ridingcapacity(u) - eff_weight(u) >= 0) {
if (horses == 0 && unicorns >= u->number && !(u->race->flags & RCF_HORSE)) {
if (horses == 0 && unicorns >= u->number && !(u_race(u)->flags & RCF_HORSE)) {
return 2;
}
return 1;
@ -614,7 +614,7 @@ ship *move_ship(ship * sh, region * from, region * to, region_list * route)
static bool is_freezing(const unit * u)
{
if (u->race != new_race[RC_INSECT])
if (u_race(u) != new_race[RC_INSECT])
return false;
if (is_cursed(u->attribs, C_KAELTESCHUTZ, 0))
return false;
@ -828,7 +828,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r)
bool contact = false;
unit *guard = NULL;
if (fval(reisender->race, RCF_ILLUSIONARY))
if (fval(u_race(reisender), RCF_ILLUSIONARY))
return NULL;
for (u = r->units; u && !contact; u = u->next) {
if (is_guard(u, GUARD_TRAVELTHRU)) {
@ -895,7 +895,7 @@ static bool is_guardian_r(const unit * guard)
if ((guard->flags & UFL_GUARD) == 0)
return false;
if (!armedmen(guard, true) && !fval(guard->race, RCF_UNARMEDGUARD))
if (!armedmen(guard, true) && !fval(u_race(guard), RCF_UNARMEDGUARD))
return false;
return true;
}
@ -1096,7 +1096,7 @@ static bool transport(unit * ut, unit * u)
static bool can_move(const unit * u)
{
if (u->race->flags & RCF_CANNOTMOVE)
if (u_race(u)->flags & RCF_CANNOTMOVE)
return false;
if (get_movement(&u->attribs, MV_CANNOTMOVE))
return false;
@ -1318,11 +1318,11 @@ static int movement_speed(unit * u)
int mp;
static const curse_type *speed_ct;
static bool init = false;
double dk = u->race->speed;
double dk = u_race(u)->speed;
assert(u->number);
/* dragons have a fixed speed, and no other effects work on them: */
switch (old_race(u->race)) {
switch (old_race(u_race(u))) {
case RC_DRAGON:
case RC_WYRM:
case RC_FIREDRAGON:
@ -1371,7 +1371,7 @@ static int movement_speed(unit * u)
/* Im Astralraum sind Tyb und Ill-Magier doppelt so schnell.
* Nicht kumulativ mit anderen Beschleunigungen! */
if (mp * dk <= BP_WALKING * u->race->speed && is_astral(u->region)
if (mp * dk <= BP_WALKING * u_race(u)->speed && is_astral(u->region)
&& is_mage(u)) {
sc_mage *mage = get_mage(u);
if (mage->magietyp == M_TYBIED || mage->magietyp == M_ILLAUN) {
@ -1436,11 +1436,11 @@ static const region_list *travel_route(unit * u,
/* check movement from/to oceans.
* aquarian special, flying units, horses, the works */
if ((u->race->flags & RCF_FLY) == 0) {
if ((u_race(u)->flags & RCF_FLY) == 0) {
if (!fval(next->terrain, SEA_REGION)) {
/* next region is land */
if (fval(current->terrain, SEA_REGION)) {
int moving = u->race->flags & (RCF_SWIM | RCF_WALK | RCF_COASTAL);
int moving = u_race(u)->flags & (RCF_SWIM | RCF_WALK | RCF_COASTAL);
/* Die Einheit kann nicht fliegen, ist im Ozean, und will an Land */
if (moving != (RCF_SWIM | RCF_WALK) && (moving & RCF_COASTAL) == 0) {
/* can't swim+walk and isn't allowed to enter coast from sea */
@ -1449,7 +1449,7 @@ static const region_list *travel_route(unit * u,
break;
}
landing = true;
} else if ((u->race->flags & RCF_WALK) == 0) {
} else if ((u_race(u)->flags & RCF_WALK) == 0) {
/* Spezialeinheiten, die nicht laufen können. */
ADDMSG(&u->faction->msgs, msg_message("detectocean",
"unit region", u, next));
@ -1497,7 +1497,7 @@ static const region_list *travel_route(unit * u,
}
/* illusionary units disappear in antimagic zones */
if (fval(u->race, RCF_ILLUSIONARY)) {
if (fval(u_race(u), RCF_ILLUSIONARY)) {
curse *c = get_curse(next->attribs, ct_find("antimagiczone"));
if (curse_active(c)) {
curse_changevigour(&next->attribs, c, (float)-u->number);
@ -1515,7 +1515,7 @@ static const region_list *travel_route(unit * u,
}
/* unit is an insect and cannot move into a glacier */
if (u->race == new_race[RC_INSECT]) {
if (u_race(u) == new_race[RC_INSECT]) {
if (r_insectstalled(next) && is_freezing(u)) {
ADDMSG(&u->faction->msgs, msg_message("detectforbidden",
"unit region", u, next));
@ -2097,7 +2097,7 @@ static void travel(unit * u, region_list ** routep)
return;
}
}
if (u->ship && u->race->flags & RCF_SWIM) {
if (u->ship && u_race(u)->flags & RCF_SWIM) {
cmistake(u, u->thisorder, 143, MSG_MOVE);
return;
}

View File

@ -215,9 +215,9 @@ const char *silbe3[SIL3] = {
const char *generic_name(const unit * u)
{
if (u->no == 1) {
return LOC(u->faction->locale, mkname("race", u->race->_name[0]));
return LOC(u->faction->locale, mkname("race", u_race(u)->_name[0]));
}
return LOC(u->faction->locale, mkname("race", u->race->_name[1]));
return LOC(u->faction->locale, mkname("race", u_race(u)->_name[1]));
}
const char *dragon_name(const unit * u)

View File

@ -55,9 +55,9 @@ int get_resource(const unit * u, const resource_type * rtype)
return i;
}
if (itype != NULL) {
if (itype == olditemtype[R_STONE] && (u->race->flags & RCF_STONEGOLEM)) {
if (itype == olditemtype[R_STONE] && (u_race(u)->flags & RCF_STONEGOLEM)) {
return u->number * GOLEM_STONE;
} else if (itype == olditemtype[R_IRON] && (u->race->flags & RCF_IRONGOLEM)) {
} else if (itype == olditemtype[R_IRON] && (u_race(u)->flags & RCF_IRONGOLEM)) {
return u->number * GOLEM_IRON;
} else {
const item *i = *i_findc(&u->items, itype);
@ -98,9 +98,9 @@ int get_reservation(const unit * u, const resource_type * rtype)
{
reservation *res = u->reservations;
if (rtype == oldresourcetype[R_STONE] && (u->race->flags & RCF_STONEGOLEM))
if (rtype == oldresourcetype[R_STONE] && (u_race(u)->flags & RCF_STONEGOLEM))
return (u->number * GOLEM_STONE);
if (rtype == oldresourcetype[R_IRON] && (u->race->flags & RCF_IRONGOLEM))
if (rtype == oldresourcetype[R_IRON] && (u_race(u)->flags & RCF_IRONGOLEM))
return (u->number * GOLEM_IRON);
while (res && res->type != rtype)
res = res->next;
@ -166,7 +166,7 @@ get_pooled(const unit * u, const resource_type * rtype, unsigned int mode,
region *r = u->region;
int have = get_resource(u, rtype);
if ((u->race->ec_flags & GETITEM) == 0) {
if ((u_race(u)->ec_flags & GETITEM) == 0) {
mode &= (GET_SLACK | GET_RESERVE);
}
@ -211,7 +211,7 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
region *r = u->region;
int n = 0, have = get_resource(u, rtype);
if ((u->race->ec_flags & GETITEM) == 0) {
if ((u_race(u)->ec_flags & GETITEM) == 0) {
mode &= (GET_SLACK | GET_RESERVE);
}

View File

@ -157,7 +157,7 @@ report_item(const unit * owner, const item * i, const faction * viewer,
int pp = i->number / owner->number;
if (number)
*number = 1;
if (pp > 50000 && dragonrace(owner->race)) {
if (pp > 50000 && dragonrace(u_race(owner))) {
if (name)
*name = locale_string(viewer->locale, "dragonhoard");
if (basename)
@ -323,15 +323,15 @@ void report_race(const struct unit *u, const char **name, const char **illusion)
{
if (illusion) {
const race *irace = u_irace(u);
if (irace && irace != u->race) {
if (irace && irace != u_race(u)) {
*illusion = irace->_name[0];
} else {
*illusion = NULL;
}
}
if (name) {
*name = u->race->_name[0];
if (fval(u->race, RCF_SHAPESHIFTANY)) {
*name = u_race(u)->_name[0];
if (fval(u_race(u), RCF_SHAPESHIFTANY)) {
const char *str = get_racename(u->attribs);
if (str)
*name = str;
@ -561,11 +561,11 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
bytes = (int)strlcpy(bufp, pzTmp, size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
if (u->faction == f && fval(u->race, RCF_SHAPESHIFTANY)) {
if (u->faction == f && fval(u_race(u), RCF_SHAPESHIFTANY)) {
bytes = (int)strlcpy(bufp, " (", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes = (int)strlcpy(bufp, racename(f->locale, u, u->race), size);
bytes = (int)strlcpy(bufp, racename(f->locale, u, u_race(u)), size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
if (size > 1) {
@ -578,11 +578,11 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
bytes = (int)strlcpy(bufp, racename(f->locale, u, irace), size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
if (u->faction == f && irace != u->race) {
if (u->faction == f && irace != u_race(u)) {
bytes = (int)strlcpy(bufp, " (", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes = (int)strlcpy(bufp, racename(f->locale, u, u->race), size);
bytes = (int)strlcpy(bufp, racename(f->locale, u, u_race(u)), size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
if (size > 1) {
@ -1538,7 +1538,7 @@ static void prepare_reports(void)
prepare_lighthouse(u->building, u->faction);
}
if (u->race != new_race[RC_SPELL] || u->number == RS_FARVISION) {
if (u_race(u) != new_race[RC_SPELL] || u->number == RS_FARVISION) {
if (fval(u, UFL_DISBELIEVES)) {
add_seen(u->faction->seen, r, see_unit, true);
} else {
@ -1788,7 +1788,7 @@ int reports(void)
static variant var_copy_string(variant x)
{
x.v = x.v?strdup((const char *)x.v):0;
x.v = x.v ? strdup((const char *)x.v) : 0;
return x;
}

View File

@ -256,7 +256,7 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
i = getid();
u = findunitg(i, NULL);
if (u && u->race == new_race[RC_SPELL])
if (u && u_race(u) == new_race[RC_SPELL])
return NULL;
if (u && u->faction == f) {
order **ordp;
@ -764,8 +764,8 @@ unit *read_unit(struct storage *store)
} else {
store->r_tok_buf(store, rname, sizeof(rname));
}
u->race = rc_find(rname);
assert(u->race);
u_setrace(u, rc_find(rname));
if (store->version < STORAGE_VERSION) {
store->r_str_buf(store, rname, sizeof(rname));
} else {
@ -776,8 +776,8 @@ unit *read_unit(struct storage *store)
else
u->irace = NULL;
if (u->race->describe) {
const char *rcdisp = u->race->describe(u, u->faction->locale);
if (u_race(u)->describe) {
const char *rcdisp = u_race(u)->describe(u, u->faction->locale);
if (u->display && rcdisp) {
/* see if the data file contains old descriptions */
if (strcmp(rcdisp, u->display) == 0) {
@ -867,7 +867,7 @@ unit *read_unit(struct storage *store)
}
set_order(&u->thisorder, NULL);
assert(u->race);
assert(u_race(u));
while ((sk = (skill_t) store->r_int(store)) != NOSKILL) {
int level = store->r_int(store);
int weeks = store->r_int(store);
@ -901,8 +901,8 @@ void write_unit(struct storage *store, const unit * u)
store->w_str(store, u->display ? (const char *)u->display : "");
store->w_int(store, u->number);
store->w_int(store, u->age);
store->w_tok(store, u->race->_name[0]);
store->w_tok(store, (irace && irace != u->race) ? irace->_name[0] : "");
store->w_tok(store, u_race(u)->_name[0]);
store->w_tok(store, (irace && irace != u_race(u)) ? irace->_name[0] : "");
write_building_reference(u->building, store);
write_ship_reference(u->ship, store);
store->w_int(store, u->status);
@ -934,7 +934,7 @@ void write_unit(struct storage *store, const unit * u)
store->w_str(store, "");
store->w_brk(store);
assert(u->race);
assert(u_race(u));
for (i = 0; i != u->skill_size; ++i) {
skill *sv = u->skills + i;
@ -1493,31 +1493,6 @@ void writefaction(struct storage *store, const faction * f)
write_spellbook(f->spellbook, store);
}
static void repair_unit(unit * u) {
static const race * rctoad;
if (!rctoad) rctoad = rc_find("toad");
if (u->race==rctoad) {
int found = 0;
attrib * a = a_find(u->attribs, &at_eventhandler);
while (!found && a && a->type==&at_eventhandler) {
struct trigger ** tlist = get_triggers(a, "timer");
while (!found && tlist && *tlist) {
trigger * t = *tlist;
if (strcmp("changerace", t->type->name)==0) {
found = 1;
}
tlist = &t->next;
}
a = a->next;
}
if (!found) {
u->race = u->faction->race;
log_warning("This toad did not have a changerace trigger: %s\n", unitname(u));
}
}
}
int readgame(const char *filename, int mode, int backup)
{
int i, n, p;
@ -1743,7 +1718,6 @@ int readgame(const char *filename, int mode, int backup)
unit *u = read_unit(store);
sc_mage *mage;
repair_unit(u);
assert(u->region == NULL);
u->region = r;
*up = u;

View File

@ -277,7 +277,7 @@ void getshipweight(const ship * sh, int *sweight, int *scabins)
if (u->ship == sh) {
*sweight += weight(u);
if (sh->type->cabins) {
int pweight = u->number * u->race->weight;
int pweight = u->number * u_race(u)->weight;
/* weight goes into number of cabins, not cargo */
*scabins += pweight;
*sweight -= pweight;

View File

@ -183,7 +183,7 @@ static buddy *get_friends(const unit * u, int *numfriends)
buddy *nf, **fr = &friends;
/* some units won't take stuff: */
if (u2->race->ec_flags & GETITEM) {
if (u_race(u2)->ec_flags & GETITEM) {
while (*fr && (*fr)->faction->no < u2->faction->no)
fr = &(*fr)->next;
nf = *fr;
@ -195,9 +195,9 @@ static buddy *get_friends(const unit * u, int *numfriends)
nf->number = 0;
*fr = nf;
} else if (nf->faction == u2->faction
&& (u2->race->ec_flags & GIVEITEM)) {
&& (u_race(u2)->ec_flags & GIVEITEM)) {
/* we don't like to gift it to units that won't give it back */
if ((nf->unit->race->ec_flags & GIVEITEM) == 0) {
if ((u_race(nf->unit)->ec_flags & GIVEITEM) == 0) {
nf->unit = u2;
}
}
@ -234,9 +234,9 @@ int gift_items(unit * u, int flags)
flags -= GIFT_SELF;
}
if (u->items == NULL || fval(u->race, RCF_ILLUSIONARY))
if (u->items == NULL || fval(u_race(u), RCF_ILLUSIONARY))
return 0;
if ((u->race->ec_flags & GIVEITEM) == 0)
if ((u_race(u)->ec_flags & GIVEITEM) == 0)
return 0;
/* at first, I should try giving my crap to my own units in this region */
@ -245,9 +245,9 @@ int gift_items(unit * u, int flags)
for (u2 = r->units; u2; u2 = u2->next) {
if (u2 != u && u2->faction == u->faction && u2->number > 0) {
/* some units won't take stuff: */
if (u2->race->ec_flags & GETITEM) {
if (u_race(u2)->ec_flags & GETITEM) {
/* we don't like to gift it to units that won't give it back */
if (u2->race->ec_flags & GIVEITEM) {
if (u_race(u2)->ec_flags & GIVEITEM) {
i_merge(&u2->items, &u->items);
u->items = NULL;
break;
@ -324,7 +324,7 @@ void make_zombie(unit * u)
{
u_setfaction(u, get_monsters());
scale_number(u, 1);
u->race = new_race[RC_ZOMBIE];
u_setrace(u, new_race[RC_ZOMBIE]);
u->irace = NULL;
}
@ -438,8 +438,8 @@ const char *u_description(const unit * u, const struct locale *lang)
{
if (u->display && u->display[0]) {
return u->display;
} else if (u->race->describe) {
return u->race->describe(u, lang);
} else if (u_race(u)->describe) {
return u_race(u)->describe(u, lang);
}
return NULL;
}
@ -857,14 +857,14 @@ bool leave(unit * u, bool force)
const struct race *urace(const struct unit *u)
{
return u->race;
return u->race_;
}
bool can_survive(const unit * u, const region * r)
{
if ((fval(r->terrain, WALK_INTO) && (u->race->flags & RCF_WALK))
|| (fval(r->terrain, SWIM_INTO) && (u->race->flags & RCF_SWIM))
|| (fval(r->terrain, FLY_INTO) && (u->race->flags & RCF_FLY))) {
if ((fval(r->terrain, WALK_INTO) && (u_race(u)->flags & RCF_WALK))
|| (fval(r->terrain, SWIM_INTO) && (u_race(u)->flags & RCF_SWIM))
|| (fval(r->terrain, FLY_INTO) && (u_race(u)->flags & RCF_FLY))) {
static const curse_type *ctype = NULL;
if (has_horses(u) && !fval(r->terrain, WALK_INTO))
@ -872,7 +872,7 @@ bool can_survive(const unit * u, const region * r)
if (!ctype)
ctype = ct_find("holyground");
if (fval(u->race, RCF_UNDEAD) && curse_active(get_curse(r->attribs, ctype)))
if (fval(u_race(u), RCF_UNDEAD) && curse_active(get_curse(r->attribs, ctype)))
return false;
return true;
@ -1021,8 +1021,8 @@ void transfermen(unit * u, unit * u2, int n)
a = an;
}
} else if (r->land) {
if ((u->race->ec_flags & ECF_REC_ETHEREAL) == 0) {
const race *rc = u->race;
if ((u_race(u)->ec_flags & ECF_REC_ETHEREAL) == 0) {
const race *rc = u_race(u);
if (rc->ec_flags & ECF_REC_HORSES) { /* Zentauren an die Pferde */
int h = rhorses(r) + n;
rsethorses(r, h);
@ -1115,7 +1115,7 @@ void set_number(unit * u, int count)
if (count == 0) {
u->flags &= ~(UFL_HERO);
}
if (u->faction && playerrace(u->race)) {
if (u->faction && playerrace(u_race(u))) {
u->faction->num_people += count - u->number;
}
u->number = (unsigned short)count;
@ -1299,7 +1299,7 @@ get_modifier(const unit * u, skill_t sk, int level, const region * r,
}
}
skill += rc_skillmod(u->race, r, sk);
skill += rc_skillmod(u_race(u), r, sk);
skill += att_modification(u, sk);
if (!noitem) {
@ -1407,12 +1407,12 @@ static void createunitid(unit * u, int id)
void name_unit(unit * u)
{
if (u->race->generate_name) {
const char *gen_name = u->race->generate_name(u);
if (u_race(u)->generate_name) {
const char *gen_name = u_race(u)->generate_name(u);
if (gen_name) {
unit_setname(u, gen_name);
} else {
unit_setname(u, racename(u->faction->locale, u, u->race));
unit_setname(u, racename(u->faction->locale, u, u_race(u)));
}
} else {
char name[32];
@ -1462,7 +1462,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace,
}
}
u_seteffstealth(u, -1);
u->race = urace;
u_setrace(u, urace);
u->irace = NULL;
set_number(u, number);
@ -1497,7 +1497,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace,
if (creator->building) {
u_set_building(u, creator->building);
}
if (creator->ship && fval(u->race, RCF_CANSAIL)) {
if (creator->ship && fval(u_race(u), RCF_CANSAIL)) {
u_set_ship(u, creator->ship);
}
}
@ -1518,7 +1518,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace,
}
/* Daemonentarnung */
set_racename(&u->attribs, get_racename(creator->attribs));
if (fval(u->race, RCF_SHAPESHIFT) && fval(creator->race, RCF_SHAPESHIFT)) {
if (fval(u_race(u), RCF_SHAPESHIFT) && fval(u_race(creator), RCF_SHAPESHIFT)) {
u->irace = creator->irace;
}
@ -1665,7 +1665,7 @@ int unit_max_hp(const unit * u)
rules_stamina =
get_param_int(global.parameters, "rules.stamina", STAMINA_AFFECTS_HP);
}
h = u->race->hitpoints;
h = u_race(u)->hitpoints;
if (heal_ct == NULL)
heal_ct = ct_find("healingzone");
@ -1734,7 +1734,18 @@ const struct race *u_irace(const struct unit *u)
if (u->irace && skill_enabled[SK_STEALTH]) {
return u->irace;
}
return u->race;
return u->race_;
}
const struct race *u_race(const struct unit *u)
{
return u->race_;
}
void u_setrace(struct unit *u, const struct race *rc)
{
assert(rc);
u->race_ = rc;
}
void unit_add_spell(unit * u, sc_mage * m, struct spell * sp, int level)

View File

@ -104,7 +104,7 @@ extern "C" {
struct order *old_orders;
/* race and illusionary race */
const struct race *race;
const struct race *race_;
const struct race *irace;
unsigned int flags;
@ -130,6 +130,8 @@ extern "C" {
void u_seteffstealth(struct unit *u, int value);
int u_geteffstealth(const struct unit *u);
const struct race *u_irace(const struct unit *u);
const struct race *u_race(const struct unit *u);
void u_setrace(struct unit *u, const struct race *);
struct building *usiege(const struct unit *u);
void usetsiege(struct unit *u, const struct building *b);

View File

@ -106,13 +106,13 @@ void score(void)
int i;
faction *f = u->faction;
if (f == NULL || u->race == new_race[RC_SPELL]
|| u->race == new_race[RC_BIRTHDAYDRAGON]) {
if (f == NULL || u_race(u) == new_race[RC_SPELL]
|| u_race(u) == new_race[RC_BIRTHDAYDRAGON]) {
continue;
}
if (old_race(u->race) <= RC_AQUARIAN) {
f->score += (u->race->recruitcost * u->number) / 50;
if (old_race(u_race(u)) <= RC_AQUARIAN) {
f->score += (u_race(u)->recruitcost * u->number) / 50;
}
f->score += get_money(u) / 50;
for (itm = u->items; itm; itm = itm->next) {

View File

@ -66,7 +66,7 @@ static int changerace_handle(trigger * t, void *data)
changerace_data *td = (changerace_data *) t->data.v;
if (td->u) {
if (td->race != NULL)
td->u->race = td->race;
u_setrace(td->u, td->race);
if (td->irace != NULL)
td->u->irace = td->irace;
} else {
@ -108,7 +108,7 @@ trigger *trigger_changerace(struct unit * u, const struct race * prace,
trigger *t = t_new(&tt_changerace);
changerace_data *td = (changerace_data *) t->data.v;
assert(u->race == u_irace(u) || "!changerace-triggers cannot stack!");
assert(u_race(u) == u_irace(u) || "!changerace-triggers cannot stack!");
td->u = u;
td->race = prace;
td->irace = irace;