Revert "use race::flags|RCF_NOGIVE instead of race::ec_flags|GIVEITEM"

E3 Tests (GIVE) did not pass.

This reverts commit 5ec3f5b83a.
This commit is contained in:
Enno Rehling 2014-07-06 00:29:52 -07:00
parent 5ec3f5b83a
commit 88f9d247bd
11 changed files with 35 additions and 29 deletions

View File

@ -430,6 +430,7 @@ end
function test_give_50_percent_of_money()
local r = region.create(0, 0, "plain")
r.name = "50percent"
local u1 = unit.create(faction.create("noreply@eressea.de", "human", "de"), r, 1)
local u2 = unit.create(faction.create("noreply@eressea.de", "orc", "de"), r, 1)
u1.faction.age = 10

View File

@ -776,7 +776,7 @@ static void give_cmd(unit * u, order * ord)
else if (p == P_HERBS) {
bool given = false;
if (fval(u_race(u), RCF_NOGIVE) && u2 != NULL) {
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
return;
@ -847,7 +847,7 @@ 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 (fval(u_race(u), RCF_NOGIVE) && u2 != NULL) {
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
return;
@ -885,8 +885,7 @@ static void give_cmd(unit * u, order * ord)
n = u->number;
give_men(n, u, u2, ord);
}
}
else if (fval(u_race(u), RCF_NOGIVE) && 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(u)));
} else if (u2 && !(u_race(u2)->ec_flags & GETITEM)) {
@ -936,7 +935,7 @@ static void give_cmd(unit * u, order * ord)
}
if (u2 != NULL) {
if (fval(u_race(u), RCF_NOGIVE) && u2 != NULL) {
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
return;

View File

@ -214,7 +214,7 @@ int armedmen(const unit * u, bool siege_weapons)
{
item *itm;
int n = 0;
if (!fval(u_race(u), RCF_NOWEAPONS)) {
if (!(urace(u)->flags & RCF_NOWEAPONS)) {
if (effskill(u, SK_WEAPONLESS) >= 1) {
/* kann ohne waffen bewachen: fuer drachen */
n = u->number;
@ -784,7 +784,7 @@ weapon_effskill(troop t, troop enemy, const weapon * w, bool attacking,
skill += CavalryBonus(tu, enemy, BONUS_SKILL);
if (wtype)
skill =
skillmod(u_race(tu)->attribs, tu, tu->region, wtype->skill, skill,
skillmod(urace(tu)->attribs, tu, tu->region, wtype->skill, skill,
SMF_RIDING);
}

View File

@ -332,8 +332,7 @@ static void json_race(cJSON *json, race *rc) {
"noteach", "horse", "desert",
"illusionary", "absorbpeasants", "noheal",
"noweapons", "shapeshift", "", "undead", "dragon",
"coastal", "", "cansail", "invisible", "shipspeed",
"stonegolem", "irongolem", "nogive", 0
"coastal", "", "cansail", 0
};
if (json->type!=cJSON_Object) {
log_error_n("race %s is not a json object: %d", json->string, json->type);

View File

@ -39,7 +39,6 @@ static void test_flags(CuTest *tc) {
check_flag(tc, "undead", RCF_UNDEAD);
check_flag(tc, "dragon", RCF_DRAGON);
check_flag(tc, "fly", RCF_FLY);
check_flag(tc, "nogive", RCF_NOGIVE);
test_cleanup();
}

View File

@ -182,7 +182,7 @@ get_pooled(const unit * u, const resource_type * rtype, unsigned int mode,
if (v->items == NULL && rtype->uget == NULL)
continue;
if (fval(u_race(v), RCF_NOGIVE))
if ((urace(v)->ec_flags & GIVEITEM) == 0)
continue;
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)
if (u != v) {
int mask;
if (fval(u_race(v), RCF_NOGIVE))
if ((urace(v)->ec_flags & GIVEITEM) == 0)
continue;
if (v->items == NULL && rtype->uget == NULL)
continue;

View File

@ -213,7 +213,6 @@ extern "C" {
#define RCF_SHIPSPEED (1<<26) /* race gets +1 on shipspeed */
#define RCF_STONEGOLEM (1<<27) /* race gets stonegolem properties */
#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */
#define RCF_NOGIVE (1<<29) /* will not GIVE anything away */
/* Economic flags */
#define GIVEITEM (1<<1) /* gibt Gegenstände weg */

View File

@ -196,9 +196,10 @@ static buddy *get_friends(const unit * u, int *numfriends)
nf->unit = u2;
nf->number = 0;
*fr = nf;
} else if (nf->faction == u2->faction && !fval(u_race(u2), RCF_NOGIVE)) {
} else if (nf->faction == u2->faction
&& (u_race(u2)->ec_flags & GIVEITEM)) {
/* we don't like to gift it to units that won't give it back */
if (fval(u_race(nf->unit), RCF_NOGIVE)) {
if ((u_race(nf->unit)->ec_flags & GIVEITEM) == 0) {
nf->unit = u2;
}
}
@ -238,20 +239,20 @@ int gift_items(unit * u, int flags)
flags -= GIFT_SELF;
}
if (u->items == NULL || fval(u_race(u), RCF_ILLUSIONARY) || fval(u_race(u), RCF_NOGIVE)) {
if (u->items == NULL || fval(u_race(u), RCF_ILLUSIONARY))
return 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 */
if (u->faction && (u->faction->flags & FFL_QUIT) == 0 && (flags & GIFT_SELF)) {
unit *u2, *u3 = NULL;
for (u2 = r->units; u2; u2 = u2->next) {
if (u2 != u && u2->faction == u->faction && u2->number > 0) {
const race * rc = u_race(u2);
/* some units won't take stuff: */
if (rc->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 (!fval(rc, RCF_NOGIVE)) {
if (u_race(u2)->ec_flags & GIVEITEM) {
i_merge(&u2->items, &u->items);
u->items = NULL;
break;
@ -860,6 +861,11 @@ bool leave(unit * u, bool force)
return true;
}
const struct race *urace(const struct unit *u)
{
return u->race_;
}
bool can_survive(const unit * u, const region * r)
{
if ((fval(r->terrain, WALK_INTO) && (u_race(u)->flags & RCF_WALK))

View File

@ -141,6 +141,8 @@ extern "C" {
struct unit *utarget(const struct unit *u);
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);
void usetprivate(struct unit *u, const char *c);

View File

@ -1721,9 +1721,8 @@ static int parse_races(xmlDocPtr doc)
if (xml_bvalue(node, "irongolem", false))
rc->flags |= RCF_IRONGOLEM;
if (xml_bvalue(node, "giveitem", false)) {
rc->flags |= RCF_NOGIVE;
}
if (xml_bvalue(node, "giveitem", false))
rc->ec_flags |= GIVEITEM;
if (xml_bvalue(node, "giveperson", false))
rc->ec_flags |= GIVEPERSON;
if (xml_bvalue(node, "giveunit", false))

View File

@ -138,7 +138,9 @@ static void checkorders(void)
static bool help_money(const unit * u)
{
return !fval(u_race(u), RCF_NOGIVE);
if (u_race(u)->ec_flags & GIVEITEM)
return true;
return false;
}
static void help_feed(unit * donor, unit * u, int *need_p)
@ -3261,7 +3263,7 @@ static building *age_building(building * b)
bt_blessed = bt_find("blessedstonecircle");
ct_astralblock = ct_find("astralblock");
/* blessed stone circles create an astral protection in the astral region
/* blesses stone circles create an astral protection in the astral region
* above the shield, which prevents chaos suction and other spells.
* 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.
@ -3277,7 +3279,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 (!fval(u_race(u), RCF_NOGIVE)) {
if (!(u_race(u)->ec_flags & GIVEITEM) == 0) {
int n, unicorns = 0;
for (n = 0; n != u->number; ++n) {
if (chance(0.02)) {
@ -4039,7 +4041,7 @@ int pay_cmd(unit * u, struct order *ord)
int reserve_cmd(unit * u, struct order *ord)
{
if (u->number > 0 && (u_race(u)->ec_flags & GETITEM)) {
if (u->number > 0 && (urace(u)->ec_flags & GETITEM)) {
int use, count;
const resource_type *rtype;
const char *s;