diff --git a/conf/e2/locales.xml b/conf/e2/locales.xml
index f71525343..7a31bbc17 100644
--- a/conf/e2/locales.xml
+++ b/conf/e2/locales.xml
@@ -3,6 +3,7 @@
+
diff --git a/conf/e2/config.xml b/conf/e2/rules.xml
similarity index 75%
rename from conf/e2/config.xml
rename to conf/e2/rules.xml
index 56c622d04..8d0b01b27 100644
--- a/conf/e2/config.xml
+++ b/conf/e2/rules.xml
@@ -1,11 +1,5 @@
-
-
-
-
-
-
@@ -26,7 +20,6 @@
-
@@ -46,10 +39,4 @@
-
-
-
-
-
-
diff --git a/conf/e3/locales.xml b/conf/e3/locales.xml
new file mode 100644
index 000000000..2d94bf202
--- /dev/null
+++ b/conf/e3/locales.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/e3/config.xml b/conf/e3/rules.xml
similarity index 84%
rename from conf/e3/config.xml
rename to conf/e3/rules.xml
index ac05d5a5a..421b54d7a 100644
--- a/conf/e3/config.xml
+++ b/conf/e3/rules.xml
@@ -1,8 +1,5 @@
-
-
-
@@ -15,8 +12,6 @@
-
-
diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml
index 3aa71393d..97ded6e8d 100644
--- a/res/core/de/strings.xml
+++ b/res/core/de/strings.xml
@@ -2379,19 +2379,19 @@
ghoul
-
+
Juju-Zombie
juju-zombie
-
+
Juju-Zombies
juju-zombies
-
+
Juju-Zombies
juju-zombies
-
+
Juju-Zombie
juju-zombie
diff --git a/res/core/fr/strings.xml b/res/core/fr/strings.xml
index d1801b338..7eb091570 100644
--- a/res/core/fr/strings.xml
+++ b/res/core/fr/strings.xml
@@ -1912,10 +1912,10 @@
zombie
-
+
zombies juju
-
+
zombie juju
diff --git a/res/core/messages.xml b/res/core/messages.xml
index 3fae49eb3..e312fcc7c 100644
--- a/res/core/messages.xml
+++ b/res/core/messages.xml
@@ -3266,20 +3266,6 @@
"$unit($unit) marschiert in eine Antimagiezone und löst sich auf."
"$unit($unit) walks into an antimagical zone and dissolves."
-
-
-
-
- "$unit($unit) hat sich unbemerkt verflüchtigt."
- "$unit($unit) has dissolved without a trace."
-
-
-
-
-
- "$unit($unit) wird sich bald verflüchtigen."
- "$unit($unit) will dissolve soon."
-
diff --git a/res/e3a/races.xml b/res/e3a/races.xml
index ccc118877..2e5a81aee 100644
--- a/res/e3a/races.xml
+++ b/res/e3a/races.xml
@@ -10,7 +10,6 @@
-
@@ -34,7 +33,6 @@
-
@@ -48,7 +46,6 @@
-
@@ -76,7 +73,6 @@
-
@@ -103,7 +99,6 @@
-
@@ -123,7 +118,6 @@
-
@@ -142,7 +136,6 @@
-
@@ -165,7 +158,6 @@
-
@@ -190,7 +182,6 @@
-
@@ -217,7 +208,6 @@
-
@@ -239,7 +229,6 @@
-
@@ -261,7 +250,6 @@
-
@@ -285,7 +273,6 @@
-
@@ -309,7 +296,6 @@
-
@@ -332,7 +318,6 @@
-
@@ -359,7 +344,6 @@
-
@@ -382,7 +366,6 @@
-
@@ -407,7 +390,6 @@
-
@@ -433,8 +415,6 @@
-
-
@@ -458,7 +438,6 @@
-
@@ -482,7 +461,6 @@
-
@@ -505,7 +483,6 @@
-
@@ -533,7 +510,6 @@
-
@@ -557,7 +533,6 @@
-
@@ -580,7 +555,6 @@
-
@@ -604,7 +578,6 @@
-
@@ -614,8 +587,6 @@
-
-
@@ -670,19 +641,16 @@
-
-
-
@@ -694,7 +662,6 @@
-
@@ -710,7 +677,6 @@
-
@@ -718,22 +684,12 @@
-
-
-
-
-
-
-
-
-
-
@@ -766,7 +722,6 @@
-
@@ -785,8 +740,6 @@
-
-
@@ -802,9 +755,8 @@
-
+
-
@@ -821,8 +773,6 @@
-
-
@@ -837,7 +787,6 @@
-
@@ -853,8 +802,6 @@
-
-
@@ -869,14 +816,11 @@
-
-
-
diff --git a/res/eressea/races.xml b/res/eressea/races.xml
index 3cf5136a4..6deefacc9 100644
--- a/res/eressea/races.xml
+++ b/res/eressea/races.xml
@@ -12,7 +12,6 @@
-
@@ -29,7 +28,6 @@
-
@@ -63,7 +61,6 @@
-
@@ -92,7 +89,6 @@
-
@@ -120,7 +116,6 @@
-
@@ -150,7 +145,6 @@
-
@@ -180,7 +174,6 @@
-
@@ -211,7 +204,6 @@
-
@@ -246,7 +238,6 @@
-
@@ -277,7 +268,6 @@
-
@@ -310,7 +300,6 @@
-
@@ -341,8 +330,6 @@
-
-
@@ -372,7 +359,6 @@
-
@@ -403,7 +389,6 @@
-
@@ -433,7 +418,6 @@
-
@@ -465,7 +449,6 @@
-
@@ -497,7 +480,6 @@
-
@@ -527,7 +509,6 @@
-
@@ -560,7 +541,6 @@
-
@@ -590,7 +570,6 @@
-
@@ -601,8 +580,6 @@
-
-
@@ -673,19 +650,16 @@
-
-
-
@@ -697,7 +671,6 @@
-
@@ -712,7 +685,6 @@
-
@@ -726,14 +698,11 @@
-
-
-
@@ -744,9 +713,6 @@
-
-
-
@@ -757,9 +723,6 @@
-
-
-
@@ -769,22 +732,13 @@
-
-
-
-
-
-
-
-
-
@@ -803,7 +757,6 @@
-
@@ -829,7 +782,6 @@
-
@@ -862,7 +814,6 @@
-
@@ -891,8 +842,6 @@
-
-
@@ -923,7 +872,6 @@
-
@@ -954,8 +902,6 @@
-
-
@@ -1039,7 +985,6 @@
-
@@ -1057,8 +1002,6 @@
-
-
@@ -1073,9 +1016,8 @@
-
+
-
@@ -1091,8 +1033,6 @@
-
-
@@ -1106,7 +1046,6 @@
-
@@ -1121,8 +1060,6 @@
-
-
@@ -1136,13 +1073,10 @@
-
-
-
@@ -1154,7 +1088,6 @@
-
@@ -1184,7 +1117,6 @@
-
@@ -1211,7 +1143,6 @@
-
@@ -1273,8 +1204,6 @@
-
-
diff --git a/res/races/aquarian.xml b/res/races/aquarian.xml
index a0e1189b7..19fd3aee7 100644
--- a/res/races/aquarian.xml
+++ b/res/races/aquarian.xml
@@ -1,7 +1,6 @@
-
diff --git a/res/races/cat.xml b/res/races/cat.xml
index 75bc8019a..5986c223c 100644
--- a/res/races/cat.xml
+++ b/res/races/cat.xml
@@ -1,7 +1,6 @@
-
diff --git a/res/races/demon.xml b/res/races/demon.xml
index 0ce4c86ff..69d98145f 100644
--- a/res/races/demon.xml
+++ b/res/races/demon.xml
@@ -6,7 +6,6 @@ unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes"
shapeshift="yes" giveperson="yes" giveunit="yes" getitem="yes"
recruitethereal="yes" equipment="yes" healing="1.5">
-
diff --git a/res/races/dragon.xml b/res/races/dragon.xml
index f8022d0a4..f42037312 100644
--- a/res/races/dragon.xml
+++ b/res/races/dragon.xml
@@ -5,8 +5,6 @@ income="1000" walk="yes" teach="no" getitem="yes" resistbash="yes"
dragon="yes">
-
-
diff --git a/res/races/dwarf.xml b/res/races/dwarf.xml
index c5c4f2fcf..043b76aa7 100644
--- a/res/races/dwarf.xml
+++ b/res/races/dwarf.xml
@@ -1,7 +1,6 @@
-
@@ -30,4 +29,4 @@
-
\ No newline at end of file
+
diff --git a/res/races/elf.xml b/res/races/elf.xml
index ee1278a26..683ee823b 100644
--- a/res/races/elf.xml
+++ b/res/races/elf.xml
@@ -1,7 +1,6 @@
-
@@ -26,4 +25,4 @@
-
\ No newline at end of file
+
diff --git a/res/races/goblin-2.xml b/res/races/goblin-2.xml
index f8964d7c0..f26fa780e 100644
--- a/res/races/goblin-2.xml
+++ b/res/races/goblin-2.xml
@@ -5,7 +5,6 @@ speed="1.0" hp="16" damage="1d5" unarmedattack="-2" unarmeddefense="0"
playerrace="yes" walk="yes" giveperson="yes" giveunit="yes"
getitem="yes" equipment="yes" healing="2.0">
-
diff --git a/res/races/goblin-3.xml b/res/races/goblin-3.xml
index 4ad83967d..3fd594939 100644
--- a/res/races/goblin-3.xml
+++ b/res/races/goblin-3.xml
@@ -5,7 +5,6 @@ speed="1.0" hp="16" damage="1d5" unarmedattack="-2" unarmeddefense="0"
playerrace="yes" walk="yes" giveperson="yes" giveunit="yes"
getitem="yes" equipment="yes" healing="2.0">
-
diff --git a/res/races/goblin.xml b/res/races/goblin.xml
index 101cdaa86..a05d127e3 100644
--- a/res/races/goblin.xml
+++ b/res/races/goblin.xml
@@ -6,7 +6,6 @@ unarmedattack="-2" unarmeddefense="0" playerrace="yes" walk="yes"
giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"
healing="2.0">
-
diff --git a/res/races/halfling.xml b/res/races/halfling.xml
index 4801685a0..3628d2b35 100644
--- a/res/races/halfling.xml
+++ b/res/races/halfling.xml
@@ -1,8 +1,7 @@
-
-
+
diff --git a/res/races/human.xml b/res/races/human.xml
index 8f1ad5cb4..f91ba7daf 100644
--- a/res/races/human.xml
+++ b/res/races/human.xml
@@ -1,7 +1,6 @@
-
diff --git a/res/races/insect.xml b/res/races/insect.xml
index dc9faa06d..75e16f7af 100644
--- a/res/races/insect.xml
+++ b/res/races/insect.xml
@@ -1,7 +1,6 @@
-
@@ -27,4 +26,4 @@
-
\ No newline at end of file
+
diff --git a/res/races/troll.xml b/res/races/troll.xml
index c70020fa2..9168a6d0e 100644
--- a/res/races/troll.xml
+++ b/res/races/troll.xml
@@ -6,7 +6,6 @@ unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes"
giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"
healing="1.5">
-
diff --git a/res/races/wyrm.xml b/res/races/wyrm.xml
index 3ee48ca67..dab1a9e1f 100644
--- a/res/races/wyrm.xml
+++ b/res/races/wyrm.xml
@@ -5,7 +5,6 @@ defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes"
teach="no" getitem="yes" resistbash="yes" dragon="yes" income="5000">
-
diff --git a/res/races/youngdragon.xml b/res/races/youngdragon.xml
index d5b23b601..df10a44e9 100644
--- a/res/races/youngdragon.xml
+++ b/res/races/youngdragon.xml
@@ -5,8 +5,6 @@ defensemodifier="4" scarepeasants="yes" fly="yes" walk="yes"
teach="no" getitem="yes" resistbash="yes" dragon="yes" income="150">
-
-
diff --git a/scripts/eressea/xmlconf.lua b/scripts/eressea/xmlconf.lua
index 584f8d3e2..84f29eceb 100644
--- a/scripts/eressea/xmlconf.lua
+++ b/scripts/eressea/xmlconf.lua
@@ -4,7 +4,8 @@ if config.install then
end
if config.rules then
local rules = config.rules .. '/'
- assert(0 == read_xml(confdir .. rules .. 'config.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?")
assert(0 == eressea.config.read(rules .. 'config.json', confdir), "could not read JSON data")
+ assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?")
+ assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?")
end
eressea.game.reset()
diff --git a/src/battle.c b/src/battle.c
index 9ce22918a..0ff8eecaa 100644
--- a/src/battle.c
+++ b/src/battle.c
@@ -925,14 +925,12 @@ void kill_troop(troop dt)
if (!df->alive) {
char eqname[64];
const struct equipment *eq;
- if (u_race(du)->itemdrop) {
- item *drops = u_race(du)->itemdrop(u_race(du), du->number - df->run.number);
-
- if (drops != NULL) {
- i_merge(&du->items, &drops);
- }
+ const race *rc = u_race(du);
+ item *drops = item_spoil(rc, du->number - df->run.number);
+ if (drops != NULL) {
+ i_merge(&du->items, &drops);
}
- sprintf(eqname, "%s_spoils", u_race(du)->_name);
+ sprintf(eqname, "%s_spoils", rc->_name);
eq = get_equipment(eqname);
if (eq != NULL) {
equip_items(&du->items, eq);
diff --git a/src/kernel/item.c b/src/kernel/item.c
index 177e44831..c37e3d40c 100644
--- a/src/kernel/item.c
+++ b/src/kernel/item.c
@@ -1175,7 +1175,7 @@ attrib_type at_resourcelimit = {
finalize_resourcelimit,
};
-static item *default_spoil(const struct race *rc, int size)
+item *item_spoil(const struct race *rc, int size)
{
item *itm = NULL;
@@ -1303,7 +1303,6 @@ void register_resources(void)
register_function((pf_generic)res_changepermaura, "changepermaura");
register_function((pf_generic)res_changehp, "changehp");
register_function((pf_generic)res_changeaura, "changeaura");
- register_function((pf_generic)default_spoil, "defaultdrops");
register_item_use(use_potion, "usepotion");
register_item_use(use_potion_delayed, "usepotion_delayed");
diff --git a/src/kernel/item.h b/src/kernel/item.h
index e6301c314..79e6f103d 100644
--- a/src/kernel/item.h
+++ b/src/kernel/item.h
@@ -309,6 +309,7 @@ extern "C" {
extern const struct potion_type *oldpotiontype[];
const struct resource_type *get_resourcetype(resource_t rt);
+ struct item *item_spoil(const struct race *rc, int size);
int get_item(const struct unit * u, const struct item_type *itype);
int set_item(struct unit * u, const struct item_type *itype, int value);
diff --git a/src/kernel/race.c b/src/kernel/race.c
index 2ede414c7..4a3a04916 100644
--- a/src/kernel/race.c
+++ b/src/kernel/race.c
@@ -66,7 +66,7 @@ static int rc_changes = 1;
static const char *racenames[MAXRACES] = {
"dwarf", "elf", NULL, "goblin", "human", "troll", "demon", "insect",
- "halfling", "cat", "aquarian", "orc", "snotling", "undead", "illusion",
+ "halfling", "cat", "aquarian", "orc", "snotling", "undead", NULL,
"youngdragon", "dragon", "wyrm", "ent", "catdragon", "dracoid",
NULL, "spell", "irongolem", "stonegolem", "shadowdemon",
"shadowmaster", "mountainguard", "alp", "toad", "braineater", "peasant",
@@ -74,7 +74,7 @@ static const char *racenames[MAXRACES] = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, "seaserpent",
"shadowknight", NULL, "skeleton", "skeletonlord", "zombie",
- "juju-zombie", "ghoul", "ghast", NULL, NULL, "template",
+ "juju", "ghoul", "ghast", NULL, NULL, "template",
"clone"
};
@@ -226,7 +226,7 @@ race_list *get_familiarraces(void)
if (!init) {
race *rc = races;
for (; rc != NULL; rc = rc->next) {
- if (rc->init_familiar != NULL) {
+ if (rc->flags & RCF_FAMILIAR) {
racelist_insert(&familiarraces, rc);
}
}
@@ -296,9 +296,16 @@ static race *rc_find_i(const char *name)
while (rc && strcmp(rname, rc->_name) != 0) {
rc = rc->next;
}
- if (!rc && strcmp(name, "uruk") == 0) {
- rc = rc_find_i("orc");
- log_warning("a reference was made to the retired race '%s', returning '%s'.", name, rc->_name);
+ if (!rc) {
+ const char *rc_depr[] = { "uruk", "orc", "illusion", "template", "juju-zombie", "juju", NULL };
+ int i;
+ for (i = 0; rc_depr[i]; i += 2) {
+ if (strcmp(name, rc_depr[i]) == 0) {
+ rc = rc_find_i(rc_depr[i + 1]);
+ log_warning("a reference was made to the retired race '%s', returning '%s'.", name, rc->_name);
+ break;
+ }
+ }
}
return rc;
}
@@ -320,6 +327,7 @@ race *rc_create(const char *zName)
{
race *rc;
int i;
+ char zText[64];
assert(zName);
rc = (race *)calloc(sizeof(race), 1);
@@ -343,6 +351,13 @@ race *rc_create(const char *zName)
rc->index = num_races++;
++rc_changes;
rc->next = races;
+
+ snprintf(zText, sizeof(zText), "age_%s", zName);
+ rc->age_unit = (race_func)get_function(zText);
+
+ snprintf(zText, sizeof(zText), "name_%s", zName);
+ rc->name_unit = (race_func)get_function(zText);
+
return races = rc;
}
@@ -542,10 +557,6 @@ variant read_race_reference(struct storage *store)
return result;
}
-void register_race_description_function(race_desc_func func, const char *name) {
- register_function((pf_generic)func, name);
-}
-
-void register_race_name_function(race_name_func func, const char *name) {
+void register_race_function(race_func func, const char *name) {
register_function((pf_generic)func, name);
}
diff --git a/src/kernel/race.h b/src/kernel/race.h
index ceb5e59d9..e464c9447 100644
--- a/src/kernel/race.h
+++ b/src/kernel/race.h
@@ -65,8 +65,8 @@ extern "C" {
RC_ORC,
RC_SNOTLING,
RC_UNDEAD,
- RC_ILLUSION,
- RC_FIREDRAGON,
+
+ RC_FIREDRAGON = 15,
RC_DRAGON,
RC_WYRM,
RC_TREEMAN,
@@ -112,8 +112,7 @@ extern "C" {
int level;
} att;
- typedef const char *(*race_desc_func)(const struct race *rc, const struct locale *lang);
- typedef void (*race_name_func)(struct unit *);
+ typedef void (*race_func) (struct unit *);
typedef struct race {
char *_name;
@@ -144,12 +143,8 @@ extern "C" {
struct att attack[RACE_ATTACKS];
signed char bonus[MAXSKILLS];
- race_name_func generate_name;
- race_desc_func describe;
- void(*age) (struct unit * u);
- bool(*move_allowed) (const struct region *, const struct region *);
- struct item *(*itemdrop) (const struct race *, int size);
- void(*init_familiar) (struct unit *);
+ race_func name_unit;
+ race_func age_unit;
struct rcoption *options; /* rarely used properties */
@@ -230,6 +225,7 @@ extern "C" {
#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */
#define RCF_ATTACK_MOVED (1<<29) /* may attack if it has moved */
#define RCF_MIGRANTS (1<<30) /* may have migrant units (human bonus) */
+#define RCF_FAMILIAR (1<<31) /* may be a familiar */
/* Economic flags */
#define ECF_KEEP_ITEM (1<<1) /* gibt Gegenst�nde weg */
@@ -266,8 +262,7 @@ extern "C" {
variant read_race_reference(struct storage *store);
const char *raceprefix(const struct unit *u);
- void register_race_name_function(race_name_func, const char *);
- void register_race_description_function(race_desc_func, const char *);
+ void register_race_function(race_func, const char *);
#ifdef __cplusplus
}
diff --git a/src/kernel/save.c b/src/kernel/save.c
index 3ddaf7a7c..d4045d05f 100644
--- a/src/kernel/save.c
+++ b/src/kernel/save.c
@@ -695,17 +695,6 @@ unit *read_unit(struct gamedata *data)
else
u->irace = NULL;
- if (rc->describe) {
- const char *rcdisp = rc->describe(rc, u->faction->locale);
- if (u->display && rcdisp) {
- /* see if the data file contains old descriptions */
- if (strcmp(rcdisp, u->display) == 0) {
- free(u->display);
- u->display = NULL;
- }
- }
- }
-
READ_INT(data->store, &n);
if (n > 0) {
building * b = findbuilding(n);
diff --git a/src/kernel/unit.c b/src/kernel/unit.c
index 1acebac6d..4592d0bc7 100644
--- a/src/kernel/unit.c
+++ b/src/kernel/unit.c
@@ -531,8 +531,15 @@ const char *u_description(const unit * u, const struct locale *lang)
if (u->display && u->display[0]) {
return u->display;
}
- else if (u_race(u)->describe) {
- return u_race(u)->describe(u->_race, lang);
+ else {
+ char zText[64];
+ const char * d;
+ const race * rc = u_race(u);
+ snprintf(zText, sizeof(zText), "describe_%s", rc->_name);
+ d = locale_getstring(lang, zText);
+ if (d) {
+ return d;
+ }
}
return NULL;
}
@@ -1453,8 +1460,11 @@ void default_name(const unit *u, char name[], int len) {
void name_unit(unit * u)
{
const race *rc = u_race(u);
- if (rc->generate_name) {
- rc->generate_name(u);
+ if (rc->name_unit) {
+ rc->name_unit(u);
+ }
+ else if (u->faction->flags & FFL_NPC) {
+ unit_setname(u, NULL);
}
else {
char name[32];
@@ -1507,7 +1517,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace,
if (dname) {
u->_name = strdup(dname);
}
- else if (urace->generate_name || playerrace(urace)) {
+ else if (urace->name_unit || playerrace(urace)) {
name_unit(u);
}
diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c
index 16ff2890b..7c7bb087b 100644
--- a/src/kernel/unit.test.c
+++ b/src/kernel/unit.test.c
@@ -390,14 +390,24 @@ static void test_limited_skills(CuTest *tc) {
static void test_unit_description(CuTest *tc) {
race *rc;
unit *u;
+ struct locale *lang;
+
test_setup();
+ lang = test_create_locale();
rc = test_create_race("hodor");
u = test_create_unit(test_create_faction(rc), test_create_region(0,0,0));
+
CuAssertPtrEquals(tc, 0, u->display);
- CuAssertStrEquals(tc, 0, u_description(u, u->faction->locale));
+ CuAssertStrEquals(tc, 0, u_description(u, lang));
u->display = strdup("Hodor");
CuAssertStrEquals(tc, "Hodor", u_description(u, NULL));
- CuAssertStrEquals(tc, "Hodor", u_description(u, u->faction->locale));
+ CuAssertStrEquals(tc, "Hodor", u_description(u, lang));
+
+ free(u->display);
+ u->display = NULL;
+ locale_setstring(lang, "describe_hodor", "HODOR");
+ CuAssertStrEquals(tc, "HODOR", u_description(u, lang));
+
test_cleanup();
}
@@ -477,7 +487,7 @@ static void test_name_unit(CuTest *tc) {
test_setup();
rc = test_create_race("skeleton");
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
- rc->generate_name = gen_name;
+ rc->name_unit = gen_name;
name_unit(u);
CuAssertStrEquals(tc, "Hodor", unit_getname(u));
test_cleanup();
diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c
index 2cf0b42e8..695f91d69 100644
--- a/src/kernel/xmlreader.c
+++ b/src/kernel/xmlreader.c
@@ -1778,46 +1778,6 @@ static int parse_races(xmlDocPtr doc)
}
xmlXPathFreeObject(result);
- /* reading eressea/races/race/function */
- xpath->node = node;
- result = xmlXPathEvalExpression(BAD_CAST "function", xpath);
- for (k = 0; k != result->nodesetval->nodeNr; ++k) {
- xmlNodePtr node = result->nodesetval->nodeTab[k];
- pf_generic fun;
-
- parse_function(node, &fun, &propValue);
- if (fun == NULL) {
- log_error("unknown function name '%s' for race %s\n", (const char *)propValue, rc->_name);
- xmlFree(propValue);
- continue;
- }
- assert(propValue != NULL);
- if (strcmp((const char *)propValue, "name") == 0) {
- rc->generate_name = (race_name_func)fun;
- }
- else if (strcmp((const char *)propValue, "describe") == 0) {
- rc->describe = (race_desc_func)fun;
- }
- else if (strcmp((const char *)propValue, "age") == 0) {
- rc->age = (void(*)(struct unit *))fun;
- }
- else if (strcmp((const char *)propValue, "move") == 0) {
- rc->move_allowed =
- (bool(*)(const struct region *, const struct region *))fun;
- }
- else if (strcmp((const char *)propValue, "itemdrop") == 0) {
- rc->itemdrop = (struct item * (*)(const struct race *, int))fun;
- }
- else if (strcmp((const char *)propValue, "initfamiliar") == 0) {
- rc->init_familiar = (void(*)(struct unit *))fun;
- }
- else {
- log_error("unknown function type '%s' for race %s\n", (const char *)propValue, rc->_name);
- }
- xmlFree(propValue);
- }
- xmlXPathFreeObject(result);
-
/* reading eressea/races/race/familiar */
xpath->node = node;
result = xmlXPathEvalExpression(BAD_CAST "familiar", xpath);
@@ -1832,6 +1792,7 @@ static int parse_races(xmlDocPtr doc)
propValue = xmlGetProp(node, BAD_CAST "race");
assert(propValue != NULL);
frc = rc_get_or_create((const char *)propValue);
+ frc->flags |= RCF_FAMILIAR;
if (xml_bvalue(node, "default", false)) {
rc->familiars[k] = rc->familiars[0];
rc->familiars[0] = frc;
diff --git a/src/laws.c b/src/laws.c
index e314e2d85..253b45b89 100644
--- a/src/laws.c
+++ b/src/laws.c
@@ -164,9 +164,10 @@ static void age_unit(region * r, unit * u)
}
}
else {
+ const race *rc = u_race(u);
++u->age;
- if (u->number > 0 && u_race(u)->age) {
- u_race(u)->age(u);
+ if (u->number > 0 && rc->age_unit) {
+ rc->age_unit(u);
}
}
if (u->region && is_astral(u->region)) {
diff --git a/src/names.c b/src/names.c
index cf0d9fd09..bc740a704 100644
--- a/src/names.c
+++ b/src/names.c
@@ -45,13 +45,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include
#include
-static const char *describe_race(const race * rc, const struct locale *lang)
-{
- char zText[32];
- sprintf(zText, "describe_%s", rc->_name);
- return locale_getstring(lang, zText);
-}
-
static void count_particles(const char *monster, int *num_prefix, int *num_name, int *num_postfix)
{
char zText[32];
@@ -219,11 +212,6 @@ const char *silbe3[SIL3] = {
"bus",
};
-static void generic_name(unit * u)
-{
- unit_setname(u, NULL);
-}
-
static void dragon_name(unit * u)
{
char name[NAMESIZE + 1];
@@ -395,29 +383,29 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars)
int result;
UNUSED_ARG(buflen);
- /* Prüfen, ob Kurz genug */
+ /* Pr�fen, ob Kurz genug */
if (strlen(s) <= maxchars) {
return s;
}
- /* Anzahl der Wörter feststellen */
+ /* Anzahl der W�rter feststellen */
while (*p != 0) {
result = unicode_utf8_to_ucs4(&ucs, p, &size);
assert(result == 0 || "damnit, we're not handling invalid input here!");
- /* Leerzeichen überspringen */
+ /* Leerzeichen �berspringen */
while (*p != 0 && !iswalnum((wint_t)ucs)) {
p += size;
result = unicode_utf8_to_ucs4(&ucs, p, &size);
assert(result == 0 || "damnit, we're not handling invalid input here!");
}
- /* Counter erhöhen */
+ /* Counter erh�hen */
if (*p != 0)
++c;
- /* alnums überspringen */
+ /* alnums �berspringen */
while (*p != 0 && iswalnum((wint_t)ucs)) {
p += size;
result = unicode_utf8_to_ucs4(&ucs, p, &size);
@@ -425,10 +413,10 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars)
}
}
- /* Buchstaben pro Teilkürzel = MAX(1,max/AnzWort) */
+ /* Buchstaben pro Teilk�rzel = MAX(1,max/AnzWort) */
bpt = (c > 0) ? MAX(1, maxchars / c) : 1;
- /* Einzelne Wörter anspringen und jeweils die ersten BpT kopieren */
+ /* Einzelne W�rter anspringen und jeweils die ersten BpT kopieren */
p = s;
c = 0;
@@ -438,7 +426,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars)
assert(result == 0 || "damnit, we're not handling invalid input here!");
while (*p != 0 && c < maxchars) {
- /* Leerzeichen überspringen */
+ /* Leerzeichen �berspringen */
while (*p != 0 && !iswalnum((wint_t)ucs)) {
p += size;
@@ -446,7 +434,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars)
assert(result == 0 || "damnit, we're not handling invalid input here!");
}
- /* alnums übertragen */
+ /* alnums �bertragen */
for (i = 0; i < bpt && *p != 0 && iswalnum((wint_t)ucs); ++i) {
memcpy(bufp, p, size);
@@ -458,7 +446,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars)
assert(result == 0 || "damnit, we're not handling invalid input here!");
}
- /* Bis zum nächsten Leerzeichen */
+ /* Bis zum n�chsten Leerzeichen */
while (c < maxchars && *p != 0 && iswalnum((wint_t)ucs)) {
p += size;
@@ -474,15 +462,16 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars)
void register_names(void)
{
- register_race_description_function(describe_race, "describe_race");
/* function name
* generate a name for a nonplayerunit
- * race->generate_name() */
- register_race_name_function(undead_name, "nameundead");
- register_race_name_function(skeleton_name, "nameskeleton");
- register_race_name_function(zombie_name, "namezombie");
- register_race_name_function(ghoul_name, "nameghoul");
- register_race_name_function(dracoid_name, "namedracoid");
- register_race_name_function(dragon_name, "namedragon");
- register_race_name_function(generic_name, "namegeneric");
+ * race->name_unit() */
+
+ register_race_function(undead_name, "name_undead");
+ register_race_function(skeleton_name, "name_skeleton");
+ register_race_function(zombie_name, "name_zombie");
+ register_race_function(ghoul_name, "name_ghoul");
+ register_race_function(dracoid_name, "name_dracoid");
+ register_race_function(dragon_name, "name_dragon");
+ register_race_function(dragon_name, "name_youngdragon");
+ register_race_function(dragon_name, "name_wyrm");
}
diff --git a/src/names.test.c b/src/names.test.c
index 8109fc2d4..7d62d4752 100644
--- a/src/names.test.c
+++ b/src/names.test.c
@@ -4,6 +4,7 @@
#include
#include
+#include
#include
#include
@@ -12,32 +13,33 @@
static void test_names(CuTest * tc)
{
- race_name_func foo;
unit *u;
race *rc;
test_cleanup();
register_names();
+ CuAssertPtrNotNull(tc, get_function("name_undead"));
+ CuAssertPtrNotNull(tc, get_function("name_skeleton"));
+ CuAssertPtrNotNull(tc, get_function("name_zombie"));
+ CuAssertPtrNotNull(tc, get_function("name_ghoul"));
+ CuAssertPtrNotNull(tc, get_function("name_dragon"));
+ CuAssertPtrNotNull(tc, get_function("name_youngdragon"));
+ CuAssertPtrNotNull(tc, get_function("name_wyrm"));
+ CuAssertPtrNotNull(tc, get_function("name_dracoid"));
default_locale = test_create_locale();
- u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
rc = test_create_race("undead");
+ u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
locale_setstring(default_locale, "undead_name_0", "Graue");
locale_setstring(default_locale, "undead_postfix_0", "Kobolde");
- CuAssertPtrNotNull(tc, foo = (race_name_func)get_function("nameundead"));
- rc->generate_name = foo;
- rc->generate_name(u);
+ CuAssertPtrNotNull(tc, rc->name_unit);
+ CuAssertTrue(tc, rc->name_unit == (race_func)get_function("name_undead"));
+ name_unit(u);
CuAssertStrEquals(tc, "Graue Kobolde", u->_name);
- CuAssertPtrNotNull(tc, get_function("nameskeleton"));
- CuAssertPtrNotNull(tc, get_function("namezombie"));
- CuAssertPtrNotNull(tc, get_function("nameghoul"));
- CuAssertPtrNotNull(tc, get_function("namedragon"));
- CuAssertPtrNotNull(tc, get_function("namedracoid"));
- CuAssertPtrNotNull(tc, get_function("namegeneric"));
- CuAssertPtrNotNull(tc, get_function("describe_race"));
test_cleanup();
}
static void test_monster_names(CuTest *tc) {
unit *u;
+ faction *f;
race *rc;
test_setup();
@@ -46,11 +48,13 @@ static void test_monster_names(CuTest *tc) {
locale_setstring(default_locale, "race::irongolem", "Eisengolem");
locale_setstring(default_locale, "race::irongolem_p", "Eisengolems");
rc = test_create_race("irongolem");
- u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+ f = test_create_faction(rc);
+ f->flags |= FFL_NPC;
+ u = test_create_unit(f, test_create_region(0, 0, 0));
+ unit_setname(u, "Hodor");
CuAssertPtrNotNull(tc, u->_name);
- rc->generate_name = (race_name_func)get_function("namegeneric");
- rc->generate_name(u);
- CuAssertPtrEquals(tc, 0, u->_name);
+ name_unit(u);
+ CuAssertPtrEquals(tc, NULL, u->_name);
CuAssertStrEquals(tc, "Eisengolem", unit_getname(u));
u->number = 2;
CuAssertStrEquals(tc, "Eisengolems", unit_getname(u));
diff --git a/src/races/CMakeLists.txt b/src/races/CMakeLists.txt
index 1f3044e3a..ff6025581 100644
--- a/src/races/CMakeLists.txt
+++ b/src/races/CMakeLists.txt
@@ -1,7 +1,6 @@
PROJECT(races C)
SET(_FILES
dragons.c
-illusion.c
races.c
zombies.c
)
diff --git a/src/races/illusion.c b/src/races/illusion.c
deleted file mode 100644
index 7411ae4d5..000000000
--- a/src/races/illusion.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Eressea PB(E)M host Copyright (C) 1998-2015
- * Christian Schlittchen (corwin@amber.kn-bremen.de)
- * Katja Zedel (katze@felidae.kn-bremen.de)
- * Henning Peters (faroul@beyond.kn-bremen.de)
- * Enno Rehling (enno@eressea.de)
- * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
- *
- * This program may not be used, modified or distributed without
- * prior permission by the authors of Eressea.
- */
-
-#include
-
-/* kernel includes */
-#include
-#include
-#include
-#include
-
-/* libc includes */
-#include
-#include
-
-#define ILLUSIONMAX 6
-
-void age_illusion(unit * u)
-{
- if (u->faction->race != get_race(RC_ILLUSION)) {
- if (u->age == ILLUSIONMAX) {
- ADDMSG(&u->faction->msgs, msg_message("warnillusiondissolve", "unit", u));
- }
- else if (u->age > ILLUSIONMAX) {
- set_number(u, 0);
- ADDMSG(&u->faction->msgs, msg_message("illusiondissolve", "unit", u));
- }
- }
-}
diff --git a/src/races/races.c b/src/races/races.c
index 8af9cf2ed..92a3d3e3d 100644
--- a/src/races/races.c
+++ b/src/races/races.c
@@ -31,22 +31,11 @@
void age_firedragon(struct unit *u);
void age_dragon(struct unit *u);
-void age_illusion(struct unit *u);
void age_undead(struct unit *u);
void age_skeleton(struct unit *u);
void age_zombie(struct unit *u);
void age_ghoul(struct unit *u);
-static void oldfamiliars(unit * u)
-{
- char fname[64];
- /* these familiars have no special skills.
- */
- snprintf(fname, sizeof(fname), "%s_familiar", u_race(u)->_name);
- create_mage(u, M_GRAY);
- equip_unit(u, get_equipment(fname));
-}
-
static void equip_newunits(const struct equipment *eq, struct unit *u)
{
struct region *r = u->region;
@@ -88,30 +77,17 @@ static void equip_newunits(const struct equipment *eq, struct unit *u)
}
}
-/* Die Funktionen werden über den hier registrierten Namen in races.xml
+/* Die Funktionen werden �ber den hier registrierten Namen in races.xml
* in die jeweilige Rassendefiniton eingebunden */
void register_races(void)
{
- /* function initfamiliar */
- register_function((pf_generic)oldfamiliars, "oldfamiliars");
-
- register_function((pf_generic)allowed_dragon, "movedragon");
-
- register_function((pf_generic)allowed_swim, "moveswimming");
- register_function((pf_generic)allowed_fly, "moveflying");
- register_function((pf_generic)allowed_walk, "movewalking");
+ register_function((pf_generic)equip_newunits, "equip_newunits");
/* function age for race->age() */
- register_function((pf_generic)age_undead, "ageundead");
- register_function((pf_generic)age_illusion, "ageillusion");
- register_function((pf_generic)age_skeleton, "ageskeleton");
- register_function((pf_generic)age_zombie, "agezombie");
- register_function((pf_generic)age_ghoul, "ageghoul");
- register_function((pf_generic)age_dragon, "agedragon");
- register_function((pf_generic)age_firedragon, "agefiredragon");
-
- /* function itemdrop
- * to generate battle spoils
- * race->itemdrop() */
- register_function((pf_generic)equip_newunits, "equip_newunits");
+ register_function((pf_generic)age_undead, "age_undead");
+ register_function((pf_generic)age_skeleton, "age_skeleton");
+ register_function((pf_generic)age_zombie, "age_zombie");
+ register_function((pf_generic)age_ghoul, "age_ghoul");
+ register_function((pf_generic)age_dragon, "age_dragon");
+ register_function((pf_generic)age_firedragon, "age_youngdragon");
}
diff --git a/src/reports.c b/src/reports.c
index 7d8374ff5..a49957b9d 100644
--- a/src/reports.c
+++ b/src/reports.c
@@ -123,13 +123,12 @@ const char *options[MAXOPTIONS] = {
bool omniscient(const faction *f)
{
- static const race *rc_template, *rc_illusion;
+ static const race *rc_template;
static int cache;
if (rc_changed(&cache)) {
- rc_illusion = get_race(RC_ILLUSION);
rc_template = get_race(RC_TEMPLATE);
}
- return (f->race == rc_template || f->race == rc_illusion);
+ return (f->race == rc_template);
}
diff --git a/src/spells.c b/src/spells.c
index 091d3d076..95b26434f 100644
--- a/src/spells.c
+++ b/src/spells.c
@@ -34,10 +34,10 @@
#include
/* kernel includes */
-#include
-#include
#include
#include
+#include
+#include
#include
#include
#include
@@ -514,11 +514,16 @@ static const race *select_familiar(const race * magerace, magic_t magiegebiet)
static void make_familiar(unit * familiar, unit * mage)
{
/* skills and spells: */
- if (u_race(familiar)->init_familiar != NULL) {
- u_race(familiar)->init_familiar(familiar);
+ const struct equipment *eq;
+ char eqname[64];
+ const race * rc = u_race(familiar);
+ snprintf(eqname, sizeof(eqname), "%s_familiar", rc->_name);
+ eq = get_equipment(eqname);
+ if (eq != NULL) {
+ equip_items(&familiar->items, eq);
}
else {
- log_error("could not perform initialization for familiar %s.\n", familiar->faction->race->_name);
+ log_error("could not perform initialization for familiar %s.\n", rc->_name);
}
/* triggers: */