forked from github/server
all kinds of race flag breakage repaired.
but now, humans suddenly can't build a ship in E2?
This commit is contained in:
parent
5de2a9e2ae
commit
9e16ebc01a
9 changed files with 26 additions and 19 deletions
|
@ -883,7 +883,7 @@ static int nfamiliars;
|
||||||
static void XMLCALL start_races(parseinfo *pi, const XML_Char *el, const XML_Char **attr) {
|
static void XMLCALL start_races(parseinfo *pi, const XML_Char *el, const XML_Char **attr) {
|
||||||
race *rc = (race *)pi->object;
|
race *rc = (race *)pi->object;
|
||||||
const char *flag_names[] = {
|
const char *flag_names[] = {
|
||||||
"!playerrace", "killpeasants", "scarepeasants", "!cansteal",
|
"playerrace", "killpeasants", "scarepeasants", "!cansteal",
|
||||||
"moverandom", "cannotmove", "learn", "fly", "swim", "walk",
|
"moverandom", "cannotmove", "learn", "fly", "swim", "walk",
|
||||||
"!learn", "!teach", "horse", "desert", "illusionary",
|
"!learn", "!teach", "horse", "desert", "illusionary",
|
||||||
"absorbpeasants", "noheal", "noweapons", "shapeshift",
|
"absorbpeasants", "noheal", "noweapons", "shapeshift",
|
||||||
|
|
|
@ -480,17 +480,16 @@ static void json_ship(cJSON *json, ship_type *st) {
|
||||||
static void json_race(cJSON *json, race *rc) {
|
static void json_race(cJSON *json, race *rc) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
const char *flags[] = {
|
const char *flags[] = {
|
||||||
"npc", "killpeasants", "scarepeasants",
|
"player", "killpeasants", "scarepeasants",
|
||||||
"nosteal", "moverandom", "cannotmove",
|
"nosteal", "moverandom", "cannotmove",
|
||||||
"learn", "fly", "swim", "walk", "nolearn",
|
"learn", "fly", "swim", "walk", "nolearn",
|
||||||
"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", NULL
|
||||||
};
|
};
|
||||||
const char *ecflags[] = {
|
const char *ecflags[] = {
|
||||||
"", "keepitem", "giveperson",
|
"giveperson", "giveunit", "getitem", NULL
|
||||||
"giveunit", "getitem", 0
|
|
||||||
};
|
};
|
||||||
if (json->type != cJSON_Object) {
|
if (json->type != cJSON_Object) {
|
||||||
log_error("race %s is not a json object: %d", json->string, json->type);
|
log_error("race %s is not a json object: %d", json->string, json->type);
|
||||||
|
|
|
@ -56,7 +56,7 @@ static void check_flag(CuTest *tc, const char *name, int flag) {
|
||||||
|
|
||||||
static void test_flags(CuTest *tc) {
|
static void test_flags(CuTest *tc) {
|
||||||
test_setup();
|
test_setup();
|
||||||
check_flag(tc, "npc", RCF_NPC);
|
check_flag(tc, "player", RCF_PLAYABLE);
|
||||||
check_flag(tc, "scarepeasants", RCF_SCAREPEASANTS);
|
check_flag(tc, "scarepeasants", RCF_SCAREPEASANTS);
|
||||||
check_flag(tc, "nosteal", RCF_NOSTEAL);
|
check_flag(tc, "nosteal", RCF_NOSTEAL);
|
||||||
check_flag(tc, "noheal", RCF_NOHEAL);
|
check_flag(tc, "noheal", RCF_NOHEAL);
|
||||||
|
@ -181,7 +181,7 @@ static void test_races(CuTest * tc)
|
||||||
"\"income\" : 30,"
|
"\"income\" : 30,"
|
||||||
"\"hp\" : 5,"
|
"\"hp\" : 5,"
|
||||||
"\"ac\" : 6,"
|
"\"ac\" : 6,"
|
||||||
"\"flags\" : [ \"npc\", \"walk\", \"undead\" ]"
|
"\"flags\" : [ \"player\", \"walk\", \"undead\" ]"
|
||||||
"}}}";
|
"}}}";
|
||||||
cJSON *json = cJSON_Parse(data);
|
cJSON *json = cJSON_Parse(data);
|
||||||
const struct race *rc;
|
const struct race *rc;
|
||||||
|
@ -195,7 +195,7 @@ static void test_races(CuTest * tc)
|
||||||
CuAssertPtrNotNull(tc, races);
|
CuAssertPtrNotNull(tc, races);
|
||||||
rc = rc_find("orc");
|
rc = rc_find("orc");
|
||||||
CuAssertPtrNotNull(tc, rc);
|
CuAssertPtrNotNull(tc, rc);
|
||||||
CuAssertIntEquals(tc, RCF_NPC | RCF_WALK | RCF_UNDEAD, rc->flags);
|
CuAssertIntEquals(tc, RCF_PLAYABLE | RCF_WALK | RCF_UNDEAD, rc->flags);
|
||||||
CuAssertStrEquals(tc, "1d4", rc->def_damage);
|
CuAssertStrEquals(tc, "1d4", rc->def_damage);
|
||||||
CuAssertTrue(tc, frac_equal(frac_one, rc->magres));
|
CuAssertTrue(tc, frac_equal(frac_one, rc->magres));
|
||||||
CuAssertIntEquals(tc, 200, rc->maxaura);
|
CuAssertIntEquals(tc, 200, rc->maxaura);
|
||||||
|
|
|
@ -356,6 +356,7 @@ race *rc_create(const char *zName)
|
||||||
|
|
||||||
rc->magres.sa[1] = 1;
|
rc->magres.sa[1] = 1;
|
||||||
rc->hitpoints = 1;
|
rc->hitpoints = 1;
|
||||||
|
rc->flags = RCF_DEFAULT;
|
||||||
rc->weight = PERSON_WEIGHT;
|
rc->weight = PERSON_WEIGHT;
|
||||||
rc->capacity = 540;
|
rc->capacity = 540;
|
||||||
rc->income = 20;
|
rc->income = 20;
|
||||||
|
|
|
@ -202,7 +202,7 @@ extern "C" {
|
||||||
int rc_get_mask(char *list);
|
int rc_get_mask(char *list);
|
||||||
|
|
||||||
/* Flags. Do not reorder these without changing json_race() in jsonconf.c */
|
/* Flags. Do not reorder these without changing json_race() in jsonconf.c */
|
||||||
#define RCF_NPC (1<<0) /* cannot be the race for a player faction (and other limits?) */
|
#define RCF_PLAYABLE (1<<0) /* cannot be the race for a player faction (and other limits?) */
|
||||||
#define RCF_KILLPEASANTS (1<<1) /* a monster that eats peasants */
|
#define RCF_KILLPEASANTS (1<<1) /* a monster that eats peasants */
|
||||||
#define RCF_SCAREPEASANTS (1<<2) /* a monster that scares peasants out of the hex */
|
#define RCF_SCAREPEASANTS (1<<2) /* a monster that scares peasants out of the hex */
|
||||||
#define RCF_NOSTEAL (1<<3) /* this race has high stealth, but is not allowed to steal */
|
#define RCF_NOSTEAL (1<<3) /* this race has high stealth, but is not allowed to steal */
|
||||||
|
@ -233,7 +233,7 @@ extern "C" {
|
||||||
#define RCF_MIGRANTS (1<<28) /* may have migrant units (human bonus) */
|
#define RCF_MIGRANTS (1<<28) /* may have migrant units (human bonus) */
|
||||||
#define RCF_FAMILIAR (1<<29) /* may be a familiar */
|
#define RCF_FAMILIAR (1<<29) /* may be a familiar */
|
||||||
|
|
||||||
#define RCF_DEFAULT (RCF_NOSTEAL|RCF_CANSAIL|RCF_NOLEARN)
|
#define RCF_DEFAULT 0
|
||||||
|
|
||||||
/* Economic flags */
|
/* Economic flags */
|
||||||
#define ECF_GIVEPERSON (1<<0) /* <20>bergibt Personen */
|
#define ECF_GIVEPERSON (1<<0) /* <20>bergibt Personen */
|
||||||
|
@ -256,7 +256,7 @@ extern "C" {
|
||||||
const char *racename(const struct locale *lang, const struct unit *u,
|
const char *racename(const struct locale *lang, const struct unit *u,
|
||||||
const race * rc);
|
const race * rc);
|
||||||
|
|
||||||
#define playerrace(rc) (!((rc)->flags & RCF_NPC))
|
#define playerrace(rc) ((rc)->flags & RCF_PLAYABLE)
|
||||||
#define dragonrace(rc) ((rc)->flags & RCF_DRAGON)
|
#define dragonrace(rc) ((rc)->flags & RCF_DRAGON)
|
||||||
#define humanoidrace(rc) (((rc)->flags & RCF_UNDEAD) || (rc)==get_race(RC_DRACOID) || playerrace(rc))
|
#define humanoidrace(rc) (((rc)->flags & RCF_UNDEAD) || (rc)==get_race(RC_DRACOID) || playerrace(rc))
|
||||||
#define illusionaryrace(rc) ((rc)->flags & RCF_ILLUSIONARY)
|
#define illusionaryrace(rc) ((rc)->flags & RCF_ILLUSIONARY)
|
||||||
|
|
|
@ -55,12 +55,16 @@ static void create_monsters(unit **up, unit **um) {
|
||||||
test_create_horse();
|
test_create_horse();
|
||||||
default_locale = test_create_locale();
|
default_locale = test_create_locale();
|
||||||
fp = test_create_faction(NULL);
|
fp = test_create_faction(NULL);
|
||||||
|
|
||||||
fm = get_or_create_monsters();
|
fm = get_or_create_monsters();
|
||||||
|
fset(fm, FFL_NOIDLEOUT);
|
||||||
|
assert(fval(fm, FFL_NPC));
|
||||||
|
assert(fval(fm, FFL_NOIDLEOUT));
|
||||||
|
|
||||||
assert(rc_find(fm->race->_name));
|
assert(rc_find(fm->race->_name));
|
||||||
rc = rc_get_or_create(fm->race->_name);
|
rc = rc_get_or_create(fm->race->_name);
|
||||||
fset(rc, RCF_UNARMEDGUARD|RCF_NPC|RCF_DRAGON);
|
fset(rc, RCF_UNARMEDGUARD|RCF_DRAGON);
|
||||||
fset(fm, FFL_NOIDLEOUT);
|
assert(!fval(fm->race, RCF_PLAYABLE));
|
||||||
assert(fval(fm, FFL_NPC) && fval(fm->race, RCF_UNARMEDGUARD) && fval(fm->race, RCF_NPC) && fval(fm, FFL_NOIDLEOUT));
|
|
||||||
|
|
||||||
test_create_region(-1, 0, test_create_terrain("ocean", SEA_REGION | SWIM_INTO | FLY_INTO));
|
test_create_region(-1, 0, test_create_terrain("ocean", SEA_REGION | SWIM_INTO | FLY_INTO));
|
||||||
test_create_region(1, 0, 0);
|
test_create_region(1, 0, 0);
|
||||||
|
@ -261,12 +265,12 @@ static void test_spawn_seaserpent(CuTest *tc) {
|
||||||
race *rc;
|
race *rc;
|
||||||
test_setup();
|
test_setup();
|
||||||
rc = test_create_race("seaserpent");
|
rc = test_create_race("seaserpent");
|
||||||
rc->flags |= RCF_NPC;
|
rc->flags &= ~RCF_PLAYABLE;
|
||||||
r = test_create_region(0, 0, NULL);
|
r = test_create_region(0, 0, NULL);
|
||||||
f = test_create_faction(NULL);
|
f = test_create_faction(NULL);
|
||||||
u = spawn_seaserpent(r, f);
|
u = spawn_seaserpent(r, f);
|
||||||
CuAssertPtrNotNull(tc, u);
|
CuAssertPtrNotNull(tc, u);
|
||||||
CuAssertPtrEquals(tc, 0, u->_name);
|
CuAssertPtrEquals(tc, NULL, u->_name);
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,10 @@ static void test_setstealth_demon_bad(CuTest *tc) {
|
||||||
lang = test_create_locale();
|
lang = test_create_locale();
|
||||||
rc = test_create_race("demon");
|
rc = test_create_race("demon");
|
||||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||||
|
|
||||||
rc = test_create_race("smurf");
|
rc = test_create_race("smurf");
|
||||||
|
rc->flags &= ~RCF_PLAYABLE;
|
||||||
|
|
||||||
init_races(lang);
|
init_races(lang);
|
||||||
u->thisorder = create_order(K_SETSTEALTH, lang, racename(lang, u, rc));
|
u->thisorder = create_order(K_SETSTEALTH, lang, racename(lang, u, rc));
|
||||||
setstealth_cmd(u, u->thisorder);
|
setstealth_cmd(u, u->thisorder);
|
||||||
|
|
|
@ -43,7 +43,7 @@ struct race *test_create_race(const char *name)
|
||||||
rc->maintenance = 10;
|
rc->maintenance = 10;
|
||||||
rc->hitpoints = 20;
|
rc->hitpoints = 20;
|
||||||
rc->maxaura = 100;
|
rc->maxaura = 100;
|
||||||
rc->flags |= RCF_WALK;
|
rc->flags |= (RCF_WALK|RCF_PLAYABLE);
|
||||||
rc->ec_flags |= ECF_GETITEM;
|
rc->ec_flags |= ECF_GETITEM;
|
||||||
rc->battle_flags = BF_EQUIPMENT;
|
rc->battle_flags = BF_EQUIPMENT;
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
@ -1332,9 +1332,9 @@ static int parse_races(xmlDocPtr doc)
|
||||||
rc->flags |= RCF_NOSTEAL;
|
rc->flags |= RCF_NOSTEAL;
|
||||||
if (!xml_bvalue(node, "learn", true))
|
if (!xml_bvalue(node, "learn", true))
|
||||||
rc->flags |= RCF_NOLEARN;
|
rc->flags |= RCF_NOLEARN;
|
||||||
if (!xml_bvalue(node, "playerrace", false)) {
|
if (xml_bvalue(node, "playerrace", false)) {
|
||||||
assert(rc->recruitcost == 0);
|
assert(rc->recruitcost == 0);
|
||||||
rc->flags |= RCF_NPC;
|
rc->flags |= RCF_PLAYABLE;
|
||||||
}
|
}
|
||||||
if (xml_bvalue(node, "scarepeasants", false))
|
if (xml_bvalue(node, "scarepeasants", false))
|
||||||
rc->flags |= RCF_SCAREPEASANTS;
|
rc->flags |= RCF_SCAREPEASANTS;
|
||||||
|
|
Loading…
Reference in a new issue