forked from github/server
use race::flags|RCF_NOGIVE instead of race::ec_flags|GIVEITEM
None of this has tests, it'd going to be years before a change like this can be made without fear D-:
This commit is contained in:
parent
b21cb8f5c7
commit
5ec3f5b83a
|
@ -776,7 +776,7 @@ static void give_cmd(unit * u, order * ord)
|
||||||
|
|
||||||
else if (p == P_HERBS) {
|
else if (p == P_HERBS) {
|
||||||
bool given = false;
|
bool given = false;
|
||||||
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
|
if (fval(u_race(u), RCF_NOGIVE) && u2 != NULL) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
||||||
return;
|
return;
|
||||||
|
@ -847,7 +847,7 @@ static void give_cmd(unit * u, order * ord)
|
||||||
if (*s == 0) { /* GIVE ALL items that you have */
|
if (*s == 0) { /* GIVE ALL items that you have */
|
||||||
|
|
||||||
/* do these checks once, not for each item we have: */
|
/* do these checks once, not for each item we have: */
|
||||||
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
|
if (fval(u_race(u), RCF_NOGIVE) && u2 != NULL) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
||||||
return;
|
return;
|
||||||
|
@ -885,7 +885,8 @@ static void give_cmd(unit * u, order * ord)
|
||||||
n = u->number;
|
n = u->number;
|
||||||
give_men(n, u, u2, ord);
|
give_men(n, u, u2, ord);
|
||||||
}
|
}
|
||||||
} else if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
|
}
|
||||||
|
else if (fval(u_race(u), RCF_NOGIVE) && u2 != NULL) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
||||||
} else if (u2 && !(u_race(u2)->ec_flags & GETITEM)) {
|
} else if (u2 && !(u_race(u2)->ec_flags & GETITEM)) {
|
||||||
|
@ -935,7 +936,7 @@ static void give_cmd(unit * u, order * ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u2 != NULL) {
|
if (u2 != NULL) {
|
||||||
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
|
if (fval(u_race(u), RCF_NOGIVE) && u2 != NULL) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -214,7 +214,7 @@ int armedmen(const unit * u, bool siege_weapons)
|
||||||
{
|
{
|
||||||
item *itm;
|
item *itm;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
if (!(urace(u)->flags & RCF_NOWEAPONS)) {
|
if (!fval(u_race(u), RCF_NOWEAPONS)) {
|
||||||
if (effskill(u, SK_WEAPONLESS) >= 1) {
|
if (effskill(u, SK_WEAPONLESS) >= 1) {
|
||||||
/* kann ohne waffen bewachen: fuer drachen */
|
/* kann ohne waffen bewachen: fuer drachen */
|
||||||
n = u->number;
|
n = u->number;
|
||||||
|
@ -784,7 +784,7 @@ weapon_effskill(troop t, troop enemy, const weapon * w, bool attacking,
|
||||||
skill += CavalryBonus(tu, enemy, BONUS_SKILL);
|
skill += CavalryBonus(tu, enemy, BONUS_SKILL);
|
||||||
if (wtype)
|
if (wtype)
|
||||||
skill =
|
skill =
|
||||||
skillmod(urace(tu)->attribs, tu, tu->region, wtype->skill, skill,
|
skillmod(u_race(tu)->attribs, tu, tu->region, wtype->skill, skill,
|
||||||
SMF_RIDING);
|
SMF_RIDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -332,7 +332,8 @@ static void json_race(cJSON *json, race *rc) {
|
||||||
"noteach", "horse", "desert",
|
"noteach", "horse", "desert",
|
||||||
"illusionary", "absorbpeasants", "noheal",
|
"illusionary", "absorbpeasants", "noheal",
|
||||||
"noweapons", "shapeshift", "", "undead", "dragon",
|
"noweapons", "shapeshift", "", "undead", "dragon",
|
||||||
"coastal", "", "cansail", 0
|
"coastal", "", "cansail", "invisible", "shipspeed",
|
||||||
|
"stonegolem", "irongolem", "nogive", 0
|
||||||
};
|
};
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("race %s is not a json object: %d", json->string, json->type);
|
log_error_n("race %s is not a json object: %d", json->string, json->type);
|
||||||
|
|
|
@ -39,6 +39,7 @@ static void test_flags(CuTest *tc) {
|
||||||
check_flag(tc, "undead", RCF_UNDEAD);
|
check_flag(tc, "undead", RCF_UNDEAD);
|
||||||
check_flag(tc, "dragon", RCF_DRAGON);
|
check_flag(tc, "dragon", RCF_DRAGON);
|
||||||
check_flag(tc, "fly", RCF_FLY);
|
check_flag(tc, "fly", RCF_FLY);
|
||||||
|
check_flag(tc, "nogive", RCF_NOGIVE);
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ get_pooled(const unit * u, const resource_type * rtype, unsigned int mode,
|
||||||
|
|
||||||
if (v->items == NULL && rtype->uget == NULL)
|
if (v->items == NULL && rtype->uget == NULL)
|
||||||
continue;
|
continue;
|
||||||
if ((urace(v)->ec_flags & GIVEITEM) == 0)
|
if (fval(u_race(v), RCF_NOGIVE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (v->faction == f) {
|
if (v->faction == f) {
|
||||||
|
@ -232,7 +232,7 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
|
||||||
for (v = r->units; use > 0 && v != NULL; v = v->next)
|
for (v = r->units; use > 0 && v != NULL; v = v->next)
|
||||||
if (u != v) {
|
if (u != v) {
|
||||||
int mask;
|
int mask;
|
||||||
if ((urace(v)->ec_flags & GIVEITEM) == 0)
|
if (fval(u_race(v), RCF_NOGIVE))
|
||||||
continue;
|
continue;
|
||||||
if (v->items == NULL && rtype->uget == NULL)
|
if (v->items == NULL && rtype->uget == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -213,6 +213,7 @@ extern "C" {
|
||||||
#define RCF_SHIPSPEED (1<<26) /* race gets +1 on shipspeed */
|
#define RCF_SHIPSPEED (1<<26) /* race gets +1 on shipspeed */
|
||||||
#define RCF_STONEGOLEM (1<<27) /* race gets stonegolem properties */
|
#define RCF_STONEGOLEM (1<<27) /* race gets stonegolem properties */
|
||||||
#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */
|
#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */
|
||||||
|
#define RCF_NOGIVE (1<<29) /* will not GIVE anything away */
|
||||||
|
|
||||||
/* Economic flags */
|
/* Economic flags */
|
||||||
#define GIVEITEM (1<<1) /* gibt Gegenstände weg */
|
#define GIVEITEM (1<<1) /* gibt Gegenstände weg */
|
||||||
|
|
|
@ -196,10 +196,9 @@ static buddy *get_friends(const unit * u, int *numfriends)
|
||||||
nf->unit = u2;
|
nf->unit = u2;
|
||||||
nf->number = 0;
|
nf->number = 0;
|
||||||
*fr = nf;
|
*fr = nf;
|
||||||
} else if (nf->faction == u2->faction
|
} else if (nf->faction == u2->faction && !fval(u_race(u2), RCF_NOGIVE)) {
|
||||||
&& (u_race(u2)->ec_flags & GIVEITEM)) {
|
|
||||||
/* we don't like to gift it to units that won't give it back */
|
/* we don't like to gift it to units that won't give it back */
|
||||||
if ((u_race(nf->unit)->ec_flags & GIVEITEM) == 0) {
|
if (fval(u_race(nf->unit), RCF_NOGIVE)) {
|
||||||
nf->unit = u2;
|
nf->unit = u2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,20 +238,20 @@ int gift_items(unit * u, int flags)
|
||||||
flags -= GIFT_SELF;
|
flags -= GIFT_SELF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u->items == NULL || fval(u_race(u), RCF_ILLUSIONARY))
|
if (u->items == NULL || fval(u_race(u), RCF_ILLUSIONARY) || fval(u_race(u), RCF_NOGIVE)) {
|
||||||
return 0;
|
|
||||||
if ((u_race(u)->ec_flags & GIVEITEM) == 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* at first, I should try giving my crap to my own units in this region */
|
/* at first, I should try giving my crap to my own units in this region */
|
||||||
if (u->faction && (u->faction->flags & FFL_QUIT) == 0 && (flags & GIFT_SELF)) {
|
if (u->faction && (u->faction->flags & FFL_QUIT) == 0 && (flags & GIFT_SELF)) {
|
||||||
unit *u2, *u3 = NULL;
|
unit *u2, *u3 = NULL;
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2 != u && u2->faction == u->faction && u2->number > 0) {
|
if (u2 != u && u2->faction == u->faction && u2->number > 0) {
|
||||||
|
const race * rc = u_race(u2);
|
||||||
/* some units won't take stuff: */
|
/* some units won't take stuff: */
|
||||||
if (u_race(u2)->ec_flags & GETITEM) {
|
if (rc->ec_flags & GETITEM) {
|
||||||
/* we don't like to gift it to units that won't give it back */
|
/* we don't like to gift it to units that won't give it back */
|
||||||
if (u_race(u2)->ec_flags & GIVEITEM) {
|
if (!fval(rc, RCF_NOGIVE)) {
|
||||||
i_merge(&u2->items, &u->items);
|
i_merge(&u2->items, &u->items);
|
||||||
u->items = NULL;
|
u->items = NULL;
|
||||||
break;
|
break;
|
||||||
|
@ -861,11 +860,6 @@ bool leave(unit * u, bool force)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct race *urace(const struct unit *u)
|
|
||||||
{
|
|
||||||
return u->race_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool can_survive(const unit * u, const region * r)
|
bool can_survive(const unit * u, const region * r)
|
||||||
{
|
{
|
||||||
if ((fval(r->terrain, WALK_INTO) && (u_race(u)->flags & RCF_WALK))
|
if ((fval(r->terrain, WALK_INTO) && (u_race(u)->flags & RCF_WALK))
|
||||||
|
|
|
@ -141,8 +141,6 @@ extern "C" {
|
||||||
struct unit *utarget(const struct unit *u);
|
struct unit *utarget(const struct unit *u);
|
||||||
void usettarget(struct unit *u, const struct unit *b);
|
void usettarget(struct unit *u, const struct unit *b);
|
||||||
|
|
||||||
extern const struct race *urace(const struct unit *u);
|
|
||||||
|
|
||||||
const char *uprivate(const struct unit *u);
|
const char *uprivate(const struct unit *u);
|
||||||
void usetprivate(struct unit *u, const char *c);
|
void usetprivate(struct unit *u, const char *c);
|
||||||
|
|
||||||
|
|
|
@ -1721,8 +1721,9 @@ static int parse_races(xmlDocPtr doc)
|
||||||
if (xml_bvalue(node, "irongolem", false))
|
if (xml_bvalue(node, "irongolem", false))
|
||||||
rc->flags |= RCF_IRONGOLEM;
|
rc->flags |= RCF_IRONGOLEM;
|
||||||
|
|
||||||
if (xml_bvalue(node, "giveitem", false))
|
if (xml_bvalue(node, "giveitem", false)) {
|
||||||
rc->ec_flags |= GIVEITEM;
|
rc->flags |= RCF_NOGIVE;
|
||||||
|
}
|
||||||
if (xml_bvalue(node, "giveperson", false))
|
if (xml_bvalue(node, "giveperson", false))
|
||||||
rc->ec_flags |= GIVEPERSON;
|
rc->ec_flags |= GIVEPERSON;
|
||||||
if (xml_bvalue(node, "giveunit", false))
|
if (xml_bvalue(node, "giveunit", false))
|
||||||
|
|
10
src/laws.c
10
src/laws.c
|
@ -138,9 +138,7 @@ static void checkorders(void)
|
||||||
|
|
||||||
static bool help_money(const unit * u)
|
static bool help_money(const unit * u)
|
||||||
{
|
{
|
||||||
if (u_race(u)->ec_flags & GIVEITEM)
|
return !fval(u_race(u), RCF_NOGIVE);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void help_feed(unit * donor, unit * u, int *need_p)
|
static void help_feed(unit * donor, unit * u, int *need_p)
|
||||||
|
@ -3263,7 +3261,7 @@ static building *age_building(building * b)
|
||||||
bt_blessed = bt_find("blessedstonecircle");
|
bt_blessed = bt_find("blessedstonecircle");
|
||||||
ct_astralblock = ct_find("astralblock");
|
ct_astralblock = ct_find("astralblock");
|
||||||
|
|
||||||
/* blesses stone circles create an astral protection in the astral region
|
/* blessed stone circles create an astral protection in the astral region
|
||||||
* above the shield, which prevents chaos suction and other spells.
|
* above the shield, which prevents chaos suction and other spells.
|
||||||
* The shield is created when a magician enters the blessed stone circle,
|
* The shield is created when a magician enters the blessed stone circle,
|
||||||
* and lasts for as long as his skill level / 2 is, at no mana cost.
|
* and lasts for as long as his skill level / 2 is, at no mana cost.
|
||||||
|
@ -3279,7 +3277,7 @@ static building *age_building(building * b)
|
||||||
* find out if there's a magician in there. */
|
* find out if there's a magician in there. */
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
if (b == u->building && inside_building(u)) {
|
if (b == u->building && inside_building(u)) {
|
||||||
if (!(u_race(u)->ec_flags & GIVEITEM) == 0) {
|
if (!fval(u_race(u), RCF_NOGIVE)) {
|
||||||
int n, unicorns = 0;
|
int n, unicorns = 0;
|
||||||
for (n = 0; n != u->number; ++n) {
|
for (n = 0; n != u->number; ++n) {
|
||||||
if (chance(0.02)) {
|
if (chance(0.02)) {
|
||||||
|
@ -4041,7 +4039,7 @@ int pay_cmd(unit * u, struct order *ord)
|
||||||
|
|
||||||
int reserve_cmd(unit * u, struct order *ord)
|
int reserve_cmd(unit * u, struct order *ord)
|
||||||
{
|
{
|
||||||
if (u->number > 0 && (urace(u)->ec_flags & GETITEM)) {
|
if (u->number > 0 && (u_race(u)->ec_flags & GETITEM)) {
|
||||||
int use, count;
|
int use, count;
|
||||||
const resource_type *rtype;
|
const resource_type *rtype;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
Loading…
Reference in New Issue