remove duplication setstatus -> unit_setstatus

This commit is contained in:
Enno Rehling 2018-02-14 11:24:38 +01:00
parent b5ea102372
commit f4be3a1374
7 changed files with 19 additions and 28 deletions

View File

@ -495,7 +495,7 @@ unit *read_unit(gamedata *data)
}
READ_INT(data->store, &n);
setstatus(u, n);
unit_setstatus(u, n);
READ_INT(data->store, &u->flags);
u->flags &= UFL_SAVEMASK;
if ((u->flags & UFL_ANON_FACTION) && !rule_stealth_anon()) {

View File

@ -1530,7 +1530,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace,
attrib *a;
/* erbt Kampfstatus */
setstatus(u, creator->status);
unit_setstatus(u, creator->status);
/* erbt Gebaeude/Schiff */
if (creator->region == r) {
@ -1985,14 +1985,6 @@ bool has_horses(const unit * u)
return false;
}
void setstatus(unit *u, int status)
{
assert(status >= ST_AGGRO && status <= ST_FLEE);
if (u->status != status) {
u->status = (status_t)status;
}
}
#define MAINTENANCE 10
int maintenance_cost(const struct unit *u)
{

View File

@ -267,7 +267,6 @@ extern "C" {
int getunit(const struct region * r, const struct faction * f, struct unit **uresult);
int read_unitid(const struct faction *f, const struct region *r);
void setstatus(struct unit *u, int status);
/* !< sets combatstatus of a unit */
int besieged(const struct unit *u);
bool has_horses(const struct unit *u);

View File

@ -2438,22 +2438,22 @@ int status_cmd(unit * u, struct order *ord)
s = gettoken(token, sizeof(token));
switch (findparam(s, u->faction->locale)) {
case P_NOT:
setstatus(u, ST_AVOID);
unit_setstatus(u, ST_AVOID);
break;
case P_BEHIND:
setstatus(u, ST_BEHIND);
unit_setstatus(u, ST_BEHIND);
break;
case P_FLEE:
setstatus(u, ST_FLEE);
unit_setstatus(u, ST_FLEE);
break;
case P_CHICKEN:
setstatus(u, ST_CHICKEN);
unit_setstatus(u, ST_CHICKEN);
break;
case P_AGGRO:
setstatus(u, ST_AGGRO);
unit_setstatus(u, ST_AGGRO);
break;
case P_VORNE:
setstatus(u, ST_FIGHT);
unit_setstatus(u, ST_FIGHT);
break;
case P_HELP:
if (getparam(u->faction->locale) == P_NOT) {
@ -2469,7 +2469,7 @@ int status_cmd(unit * u, struct order *ord)
msg_feedback(u, ord, "unknown_status", ""));
}
else {
setstatus(u, ST_FIGHT);
unit_setstatus(u, ST_FIGHT);
}
}
return 0;
@ -2940,7 +2940,7 @@ void maketemp_cmd(unit *u, order **olist)
if (sh) {
set_leftship(u2, sh);
}
setstatus(u2, u->status);
unit_setstatus(u2, u->status);
/* copy orders until K_END from u to u2 */
ordp = &makeord->next;

View File

@ -615,11 +615,11 @@ static void recruit_dracoids(unit * dragon, int size)
change_money(dragon, -un->number * 50);
equip_unit(un, get_equipment("new_dracoid"));
setstatus(un, ST_FIGHT);
unit_setstatus(un, ST_FIGHT);
for (weapon = un->items; weapon; weapon = weapon->next) {
const weapon_type *wtype = weapon->type->rtype->wtype;
if (wtype && wtype->flags & WTF_MISSILE) {
setstatus(un, ST_BEHIND);
unit_setstatus(un, ST_BEHIND);
break;
}
}

View File

@ -518,7 +518,7 @@ static unit * make_familiar(unit * mage, region *r, const race *rc, const char *
unit *fam;
fam = create_unit(r, mage->faction, 1, rc, 0, name, mage);
setstatus(fam, ST_FLEE);
unit_setstatus(fam, ST_FLEE);
fset(fam, UFL_LOCKED);
/* triggers: */
@ -2161,7 +2161,7 @@ static int sp_ironkeeper(castorder * co)
create_unit(r, mage->faction, 1, get_race(RC_IRONKEEPER), 0, NULL, mage);
/*keeper->age = cast_level + 2; */
setstatus(keeper, ST_AVOID); /* kaempft nicht */
unit_setstatus(keeper, ST_AVOID); /* kaempft nicht */
setguard(keeper, true);
fset(keeper, UFL_ISNEW);
/* Parteitarnen, damit man nicht sofort wei<65>, wer dahinter steckt */
@ -4630,7 +4630,7 @@ int sp_clonecopy(castorder * co)
clone =
create_unit(target_region, mage->faction, 1, get_race(RC_CLONE), 0, name,
mage);
setstatus(clone, ST_FLEE);
unit_setstatus(clone, ST_FLEE);
fset(clone, UFL_LOCKED);
create_newclone(mage, clone);

View File

@ -731,7 +731,7 @@ static fighter *summon_allies(const fighter *fi, const race *rc, int number) {
unit *u =
create_unit(r, mage->faction, number, rc, 0, NULL, mage);
leave(u, true);
setstatus(u, ST_FIGHT);
unit_setstatus(u, ST_FIGHT);
u->hp = u->number * unit_max_hp(u);
@ -797,7 +797,7 @@ int sp_shadowknights(struct castorder * co)
u =
create_unit(r, mage->faction, force, get_race(RC_SHADOWKNIGHT), 0, NULL,
mage);
setstatus(u, ST_FIGHT);
unit_setstatus(u, ST_FIGHT);
u->hp = u->number * unit_max_hp(u);
@ -1280,7 +1280,7 @@ int sp_appeasement(struct castorder * co)
}
/* und bewachen nicht */
setguard(mage, false);
setstatus(mage, ST_FLEE);
unit_setstatus(mage, ST_FLEE);
/* wir tun so, als w<>re die Person geflohen */
fi->flags |= FIG_NOLOOT;
@ -1624,7 +1624,7 @@ int sp_undeadhero(struct castorder * co)
else {
unit_setinfo(u, NULL);
}
setstatus(u, du->status);
unit_setstatus(u, du->status);
setguard(u, false);
for (ilist = &du->items; *ilist;) {
item *itm = *ilist;