forked from github/server
Bug 2089 again. rename giveitem flag to keepitem, because races should default to not holding on to their stuff.
This commit is contained in:
parent
71d0558403
commit
f06e3371a0
|
@ -595,7 +595,7 @@ void give_cmd(unit * u, order * ord)
|
|||
|
||||
else if (p == P_HERBS) {
|
||||
bool given = false;
|
||||
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
|
||||
if ((u_race(u)->ec_flags & ECF_KEEP_ITEM) && u2 != NULL) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
||||
return;
|
||||
|
@ -660,7 +660,7 @@ void give_cmd(unit * u, order * ord)
|
|||
if (!s || *s == 0) { /* GIVE ALL items that you have */
|
||||
|
||||
/* do these checks once, not for each item we have: */
|
||||
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
|
||||
if ((u_race(u)->ec_flags & ECF_KEEP_ITEM) && u2 != NULL) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
||||
return;
|
||||
|
@ -704,7 +704,7 @@ void give_cmd(unit * u, order * ord)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
|
||||
else if ((u_race(u)->ec_flags & ECF_KEEP_ITEM) && u2 != NULL) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
||||
}
|
||||
|
@ -763,7 +763,7 @@ void give_cmd(unit * u, order * ord)
|
|||
}
|
||||
|
||||
if (u2 != NULL) {
|
||||
if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
|
||||
if ((u_race(u)->ec_flags & ECF_KEEP_ITEM) && u2 != NULL) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
||||
return;
|
||||
|
|
|
@ -62,6 +62,7 @@ static int json_flags(cJSON *json, const char *flags[]) {
|
|||
for (i = 0; flags[i]; ++i) {
|
||||
if (strcmp(flags[i], entry->valuestring) == 0) {
|
||||
result |= (1 << i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -344,7 +345,7 @@ static void json_race(cJSON *json, race *rc) {
|
|||
"coastal", "", "cansail", 0
|
||||
};
|
||||
const char *ecflags[] = {
|
||||
"", "giveitem", "giveperson",
|
||||
"", "keepitem", "giveperson",
|
||||
"giveunit", "getitem", 0
|
||||
};
|
||||
if (json->type != cJSON_Object) {
|
||||
|
|
|
@ -51,7 +51,7 @@ static void test_flags(CuTest *tc) {
|
|||
check_flag(tc, "dragon", RCF_DRAGON);
|
||||
check_flag(tc, "fly", RCF_FLY);
|
||||
check_ec_flag(tc, "getitem", GETITEM);
|
||||
check_ec_flag(tc, "giveitem", GIVEITEM);
|
||||
check_ec_flag(tc, "keepitem", ECF_KEEP_ITEM);
|
||||
check_ec_flag(tc, "giveperson", GIVEPERSON);
|
||||
check_ec_flag(tc, "giveunit", GIVEUNIT);
|
||||
test_cleanup();
|
||||
|
|
|
@ -179,7 +179,7 @@ int count)
|
|||
if (u != v && (v->items || rtype->uget)) {
|
||||
int mask;
|
||||
|
||||
if ((urace(v)->ec_flags & GIVEITEM) == 0)
|
||||
if ((urace(v)->ec_flags & ECF_KEEP_ITEM))
|
||||
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 ((urace(v)->ec_flags & GIVEITEM) == 0)
|
||||
if ((urace(v)->ec_flags & ECF_KEEP_ITEM))
|
||||
continue;
|
||||
if (v->items == NULL && rtype->uget == NULL)
|
||||
continue;
|
||||
|
|
|
@ -215,7 +215,7 @@ extern "C" {
|
|||
#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */
|
||||
|
||||
/* Economic flags */
|
||||
#define GIVEITEM (1<<1) /* gibt Gegenstände weg */
|
||||
#define ECF_KEEP_ITEM (1<<1) /* gibt Gegenstände weg */
|
||||
#define GIVEPERSON (1<<2) /* übergibt Personen */
|
||||
#define GIVEUNIT (1<<3) /* Einheiten an andere Partei übergeben */
|
||||
#define GETITEM (1<<4) /* nimmt Gegenstände an */
|
||||
|
|
|
@ -257,9 +257,9 @@ static buddy *get_friends(const unit * u, int *numfriends)
|
|||
*fr = nf;
|
||||
}
|
||||
else if (nf->faction == u2->faction
|
||||
&& (u_race(u2)->ec_flags & GIVEITEM)) {
|
||||
&& !(u_race(u2)->ec_flags & ECF_KEEP_ITEM)) {
|
||||
/* 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 ((u_race(nf->unit)->ec_flags & ECF_KEEP_ITEM)) {
|
||||
nf->unit = u2;
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ int gift_items(unit * u, int flags)
|
|||
|
||||
if (u->items == NULL || fval(u_race(u), RCF_ILLUSIONARY))
|
||||
return 0;
|
||||
if ((u_race(u)->ec_flags & GIVEITEM) == 0)
|
||||
if ((u_race(u)->ec_flags & ECF_KEEP_ITEM))
|
||||
return 0;
|
||||
|
||||
/* at first, I should try giving my crap to my own units in this region */
|
||||
|
@ -311,7 +311,7 @@ int gift_items(unit * u, int flags)
|
|||
/* some units won't take stuff: */
|
||||
if (u_race(u2)->ec_flags & GETITEM) {
|
||||
/* we don't like to gift it to units that won't give it back */
|
||||
if (u_race(u2)->ec_flags & GIVEITEM) {
|
||||
if (!(u_race(u2)->ec_flags & ECF_KEEP_ITEM)) {
|
||||
i_merge(&u2->items, &u->items);
|
||||
u->items = NULL;
|
||||
break;
|
||||
|
|
|
@ -1693,8 +1693,8 @@ static int parse_races(xmlDocPtr doc)
|
|||
if (xml_bvalue(node, "irongolem", false))
|
||||
rc->flags |= RCF_IRONGOLEM;
|
||||
|
||||
if (xml_bvalue(node, "giveitem", true))
|
||||
rc->ec_flags |= GIVEITEM;
|
||||
if (!xml_bvalue(node, "keepitem", false))
|
||||
rc->ec_flags |= ECF_KEEP_ITEM;
|
||||
if (xml_bvalue(node, "giveperson", false))
|
||||
rc->ec_flags |= GIVEPERSON;
|
||||
if (xml_bvalue(node, "giveunit", false))
|
||||
|
|
|
@ -3092,7 +3092,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(u)->ec_flags & GIVEITEM) == 0) {
|
||||
if ((u_race(u)->ec_flags & ECF_KEEP_ITEM) == 0) {
|
||||
int n, unicorns = 0;
|
||||
for (n = 0; n != u->number; ++n) {
|
||||
if (chance(0.02)) {
|
||||
|
|
|
@ -31,7 +31,7 @@ struct race *test_create_race(const char *name)
|
|||
{
|
||||
race *rc = rc_get_or_create(name);
|
||||
rc->maintenance = 10;
|
||||
rc->ec_flags |= GETITEM | GIVEITEM;
|
||||
rc->ec_flags |= GETITEM;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,9 +42,7 @@ int lifestyle(const unit * u)
|
|||
|
||||
static bool help_money(const unit * u)
|
||||
{
|
||||
if (u_race(u)->ec_flags & GIVEITEM)
|
||||
return true;
|
||||
return false;
|
||||
return !(u_race(u)->ec_flags & ECF_KEEP_ITEM);
|
||||
}
|
||||
|
||||
static void help_feed(unit * donor, unit * u, int *need_p)
|
||||
|
|
Loading…
Reference in New Issue