From 5b437c5833cce545a489d1f14fdd1729c82bbe5f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 5 Jul 2014 19:20:15 -0700 Subject: [PATCH] Replace RCF_PLAYERRACE with RCF_NPC, it's the less confusing default for tests. --- src/kernel/jsonconf.test.c | 6 +++--- src/kernel/race.h | 4 ++-- src/kernel/xmlreader.c | 4 ++-- src/tests.c | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 932b88ac0..3d7ffbbeb 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -32,7 +32,7 @@ static void check_flag(CuTest *tc, const char *name, int flag) { } static void test_flags(CuTest *tc) { - check_flag(tc, "playerrace", RCF_PLAYERRACE); + check_flag(tc, "npc", RCF_NPC); check_flag(tc, "scarepeasants", RCF_SCAREPEASANTS); check_flag(tc, "cansteal", RCF_CANSTEAL); check_flag(tc, "noheal", RCF_NOHEAL); @@ -56,7 +56,7 @@ static void test_races(CuTest * tc) "\"capacity\" : 4," "\"hp\" : 5," "\"ac\" : 6," - "\"flags\" : [ \"playerrace\", \"walk\", \"undead\" ]" + "\"flags\" : [ \"npc\", \"walk\", \"undead\" ]" "}}}"; cJSON *json = cJSON_Parse(data); const struct race *rc; @@ -70,7 +70,7 @@ static void test_races(CuTest * tc) CuAssertPtrNotNull(tc, races); rc = rc_find("orc"); CuAssertPtrNotNull(tc, rc); - CuAssertIntEquals(tc, RCF_PLAYERRACE|RCF_WALK|RCF_UNDEAD, rc->flags); + CuAssertIntEquals(tc, RCF_NPC|RCF_WALK|RCF_UNDEAD, rc->flags); CuAssertStrEquals(tc, "1d4", rc->def_damage); CuAssertDblEquals(tc, 1.0, rc->magres, 0.0); CuAssertDblEquals(tc, 2.0, rc->maxaura, 0.0); diff --git a/src/kernel/race.h b/src/kernel/race.h index 3f83e6a53..3834dbfb7 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -184,7 +184,7 @@ extern "C" { void free_races(void); /* Flags */ -#define RCF_PLAYERRACE (1<<0) /* can be played by a player. */ +#define RCF_NPC (1<<0) /* can be played by a player. */ #define RCF_KILLPEASANTS (1<<1) /* Töten Bauern. Dämonen werden nicht über dieses Flag, sondern in randenc() behandelt. */ #define RCF_SCAREPEASANTS (1<<2) #define RCF_CANSTEAL (1<<3) @@ -238,7 +238,7 @@ extern "C" { #define omniscient(f) ((f)->race==get_race(RC_ILLUSION) || (f)->race==get_race(RC_TEMPLATE)) -#define playerrace(rc) (fval((rc), RCF_PLAYERRACE)) +#define playerrace(rc) (!fval((rc), RCF_NPC)) #define dragonrace(rc) ((rc) == get_race(RC_FIREDRAGON) || (rc) == get_race(RC_DRAGON) || (rc) == get_race(RC_WYRM) || (rc) == get_race(RC_BIRTHDAYDRAGON)) #define humanoidrace(rc) (fval((rc), RCF_UNDEAD) || (rc)==get_race(RC_DRACOID) || playerrace(rc)) #define illusionaryrace(rc) (fval(rc, RCF_ILLUSIONARY)) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 3d5c962eb..bc0bcd50e 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1668,8 +1668,8 @@ static int parse_races(xmlDocPtr doc) rc->at_bonus = (char)xml_ivalue(node, "attackmodifier", 0); rc->df_bonus = (char)xml_ivalue(node, "defensemodifier", 0); - if (xml_bvalue(node, "playerrace", false)) - rc->flags |= RCF_PLAYERRACE; + if (!xml_bvalue(node, "playerrace", false)) + rc->flags |= RCF_NPC; if (xml_bvalue(node, "scarepeasants", false)) rc->flags |= RCF_SCAREPEASANTS; if (xml_bvalue(node, "cansteal", true)) diff --git a/src/tests.c b/src/tests.c index 00e8db540..abe9b085a 100644 --- a/src/tests.c +++ b/src/tests.c @@ -25,7 +25,6 @@ struct race *test_create_race(const char *name) { race *rc = rc_get_or_create(name); - rc->flags |= RCF_PLAYERRACE; rc->maintenance = 10; return rc; }