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) {
|
else if (p == P_HERBS) {
|
||||||
bool given = false;
|
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,
|
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;
|
||||||
|
@ -660,7 +660,7 @@ void give_cmd(unit * u, order * ord)
|
||||||
if (!s || *s == 0) { /* GIVE ALL items that you have */
|
if (!s || *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 ((u_race(u)->ec_flags & ECF_KEEP_ITEM) && 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;
|
||||||
|
@ -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,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
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 (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,
|
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;
|
||||||
|
|
|
@ -62,6 +62,7 @@ static int json_flags(cJSON *json, const char *flags[]) {
|
||||||
for (i = 0; flags[i]; ++i) {
|
for (i = 0; flags[i]; ++i) {
|
||||||
if (strcmp(flags[i], entry->valuestring) == 0) {
|
if (strcmp(flags[i], entry->valuestring) == 0) {
|
||||||
result |= (1 << i);
|
result |= (1 << i);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,7 +345,7 @@ static void json_race(cJSON *json, race *rc) {
|
||||||
"coastal", "", "cansail", 0
|
"coastal", "", "cansail", 0
|
||||||
};
|
};
|
||||||
const char *ecflags[] = {
|
const char *ecflags[] = {
|
||||||
"", "giveitem", "giveperson",
|
"", "keepitem", "giveperson",
|
||||||
"giveunit", "getitem", 0
|
"giveunit", "getitem", 0
|
||||||
};
|
};
|
||||||
if (json->type != cJSON_Object) {
|
if (json->type != cJSON_Object) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ static void test_flags(CuTest *tc) {
|
||||||
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_ec_flag(tc, "getitem", GETITEM);
|
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, "giveperson", GIVEPERSON);
|
||||||
check_ec_flag(tc, "giveunit", GIVEUNIT);
|
check_ec_flag(tc, "giveunit", GIVEUNIT);
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
|
|
|
@ -179,7 +179,7 @@ int count)
|
||||||
if (u != v && (v->items || rtype->uget)) {
|
if (u != v && (v->items || rtype->uget)) {
|
||||||
int mask;
|
int mask;
|
||||||
|
|
||||||
if ((urace(v)->ec_flags & GIVEITEM) == 0)
|
if ((urace(v)->ec_flags & ECF_KEEP_ITEM))
|
||||||
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 ((urace(v)->ec_flags & ECF_KEEP_ITEM))
|
||||||
continue;
|
continue;
|
||||||
if (v->items == NULL && rtype->uget == NULL)
|
if (v->items == NULL && rtype->uget == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -215,7 +215,7 @@ extern "C" {
|
||||||
#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */
|
#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */
|
||||||
|
|
||||||
/* Economic flags */
|
/* 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 GIVEPERSON (1<<2) /* übergibt Personen */
|
||||||
#define GIVEUNIT (1<<3) /* Einheiten an andere Partei übergeben */
|
#define GIVEUNIT (1<<3) /* Einheiten an andere Partei übergeben */
|
||||||
#define GETITEM (1<<4) /* nimmt Gegenstände an */
|
#define GETITEM (1<<4) /* nimmt Gegenstände an */
|
||||||
|
|
|
@ -257,9 +257,9 @@ static buddy *get_friends(const unit * u, int *numfriends)
|
||||||
*fr = nf;
|
*fr = nf;
|
||||||
}
|
}
|
||||||
else if (nf->faction == u2->faction
|
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 */
|
/* 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;
|
nf->unit = u2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ int gift_items(unit * u, int flags)
|
||||||
|
|
||||||
if (u->items == NULL || fval(u_race(u), RCF_ILLUSIONARY))
|
if (u->items == NULL || fval(u_race(u), RCF_ILLUSIONARY))
|
||||||
return 0;
|
return 0;
|
||||||
if ((u_race(u)->ec_flags & GIVEITEM) == 0)
|
if ((u_race(u)->ec_flags & ECF_KEEP_ITEM))
|
||||||
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 */
|
||||||
|
@ -311,7 +311,7 @@ int gift_items(unit * u, int flags)
|
||||||
/* some units won't take stuff: */
|
/* some units won't take stuff: */
|
||||||
if (u_race(u2)->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 */
|
/* 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);
|
i_merge(&u2->items, &u->items);
|
||||||
u->items = NULL;
|
u->items = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1693,8 +1693,8 @@ 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", true))
|
if (!xml_bvalue(node, "keepitem", false))
|
||||||
rc->ec_flags |= GIVEITEM;
|
rc->ec_flags |= ECF_KEEP_ITEM;
|
||||||
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))
|
||||||
|
|
|
@ -3092,7 +3092,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 ((u_race(u)->ec_flags & ECF_KEEP_ITEM) == 0) {
|
||||||
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)) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct race *test_create_race(const char *name)
|
||||||
{
|
{
|
||||||
race *rc = rc_get_or_create(name);
|
race *rc = rc_get_or_create(name);
|
||||||
rc->maintenance = 10;
|
rc->maintenance = 10;
|
||||||
rc->ec_flags |= GETITEM | GIVEITEM;
|
rc->ec_flags |= GETITEM;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,7 @@ int lifestyle(const unit * u)
|
||||||
|
|
||||||
static bool help_money(const unit * u)
|
static bool help_money(const unit * u)
|
||||||
{
|
{
|
||||||
if (u_race(u)->ec_flags & GIVEITEM)
|
return !(u_race(u)->ec_flags & ECF_KEEP_ITEM);
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue