forked from github/server
make describe_braineater more generic (describe_race).
This commit is contained in:
parent
c18d75207e
commit
33701ab891
|
@ -34,7 +34,7 @@
|
|||
</string>
|
||||
<string name="songdragon">
|
||||
<text locale="de">Singdrachen sind von der Größe eines ausgewachsenden Tigers. Ihre Färbung reicht von schillerndem Rot, über dunkles Grün bis hin zu tiefem Schwarz. Alle bekannten Drachen dieser Art weisen eine hohe Intelligenz und ein hohes Maß an magischen Fähigkeiten auf. Wie Ihre großen Verwandten verfügen sie über einen Feuerodem. Sie lieben den Gesang und das üppige Mahl. Von Zeit zu Zeit gehen sie eine engen magisches Bund zu einem Magier ein. Wenn dies geschieht, so steht dem Magier ein äußerst loyaler und lohnender Vertrauter zur Seite.
|
||||
</text>
|
||||
</text>
|
||||
<text locale="en">Song Dragons are roughly the size of a fully grown tiger. Their coloring ranges from bright red, through a dark green shade to a deep black. All known dragons of this species display a high level of intelligence and highly developed magical skills. Like their larger cousins, Song Dragons posess a firegland. They love singing and a good meal. From time to time one of these magnificent creatures will bond with a mage. When this happens, the mage is assured of a most loyal and useful familiar at his side.</text>
|
||||
</string>
|
||||
<string name="unicorn">
|
||||
|
|
|
@ -619,7 +619,7 @@
|
|||
<race name="braineater" magres="0.900000" maxaura="1.0" regaura="1.0" weight="100" capacity="540" speed="1.0" hp="20" damage="0d0" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" invinciblenonmagic="yes">
|
||||
<ai splitsize="500" killpeasants="yes" moverandom="yes" learn="yes"/>
|
||||
<function name="name" value="namegeneric"/>
|
||||
<function name="describe" value="describe_braineater"/>
|
||||
<function name="describe" value="describe_race"/>
|
||||
<attack type="2" damage="3d15"/>
|
||||
<attack type="3" damage="1d1"/>
|
||||
<attack type="4" damage="1d1"/>
|
||||
|
|
|
@ -602,7 +602,7 @@
|
|||
regaura="1.000000" recruitcost="50000" weight="100" capacity="540" speed="1.000000" hp="20" damage="0d0" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" invinciblenonmagic="yes">
|
||||
<ai splitsize="500" killpeasants="yes" moverandom="yes" learn="yes"/>
|
||||
<function name="name" value="namegeneric"/>
|
||||
<function name="describe" value="describe_braineater"/>
|
||||
<function name="describe" value="describe_race"/>
|
||||
<attack type="2" damage="3d15"/>
|
||||
<attack type="3" damage="1d1"/>
|
||||
<attack type="4" damage="1d1"/>
|
||||
|
|
|
@ -319,6 +319,10 @@ const char *dbrace(const struct race *rc)
|
|||
return zText;
|
||||
}
|
||||
|
||||
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) {
|
||||
register_function((pf_generic)func, name);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ extern "C" {
|
|||
struct param;
|
||||
struct spell;
|
||||
|
||||
extern int num_races;
|
||||
|
||||
typedef enum {
|
||||
RC_DWARF, /* 0 - Zwerg */
|
||||
RC_ELF,
|
||||
|
@ -117,8 +119,7 @@ extern "C" {
|
|||
int level;
|
||||
} att;
|
||||
|
||||
extern int num_races;
|
||||
|
||||
typedef const char *(*race_desc_func)(const struct race *rc, const struct locale *lang);
|
||||
typedef void (*race_name_func)(struct unit *);
|
||||
|
||||
typedef struct race {
|
||||
|
@ -152,7 +153,7 @@ extern "C" {
|
|||
signed char bonus[MAXSKILLS];
|
||||
|
||||
race_name_func generate_name;
|
||||
const char *(*describe) (const struct unit *, const struct locale *);
|
||||
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);
|
||||
|
@ -168,8 +169,8 @@ extern "C" {
|
|||
const struct race *data;
|
||||
} race_list;
|
||||
|
||||
extern void racelist_clear(struct race_list **rl);
|
||||
extern void racelist_insert(struct race_list **rl, const struct race *r);
|
||||
void racelist_clear(struct race_list **rl);
|
||||
void racelist_insert(struct race_list **rl, const struct race *r);
|
||||
|
||||
|
||||
struct race_list *get_familiarraces(void);
|
||||
|
@ -178,8 +179,8 @@ extern "C" {
|
|||
/** TODO: compatibility hacks: **/
|
||||
race_t old_race(const struct race *);
|
||||
|
||||
extern race *rc_get_or_create(const char *name);
|
||||
extern const race *rc_find(const char *);
|
||||
race *rc_get_or_create(const char *name);
|
||||
const race *rc_find(const char *);
|
||||
void free_races(void);
|
||||
|
||||
typedef enum name_t { NAME_SINGULAR, NAME_PLURAL, NAME_DEFINITIVE, NAME_CATEGORY } name_t;
|
||||
|
@ -236,7 +237,6 @@ extern "C" {
|
|||
#define BF_INV_NONMAGIC (1<<5) /* Immun gegen nichtmagischen Schaden */
|
||||
#define BF_NO_ATTACK (1<<6) /* Kann keine ATTACKIERE Befehle ausfuehren */
|
||||
|
||||
int unit_old_max_hp(struct unit *u);
|
||||
const char *racename(const struct locale *lang, const struct unit *u,
|
||||
const race * rc);
|
||||
|
||||
|
@ -257,11 +257,9 @@ extern "C" {
|
|||
variant read_race_reference(struct storage *store);
|
||||
|
||||
const char *raceprefix(const struct unit *u);
|
||||
|
||||
void give_starting_equipment(const struct equipment *eq,
|
||||
struct unit *u);
|
||||
const char *dbrace(const struct race *rc);
|
||||
void register_race_name_function(race_name_func, const char *);
|
||||
void register_race_description_function(race_desc_func, const char *);
|
||||
char * race_namegen(const struct race *rc, struct unit *u);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -699,6 +699,7 @@ void write_attribs(storage *store, attrib *alist, const void *owner)
|
|||
unit *read_unit(struct gamedata *data)
|
||||
{
|
||||
unit *u;
|
||||
const race *rc;
|
||||
int number, n, p;
|
||||
order **orderp;
|
||||
char obuf[DISPLAYSIZE];
|
||||
|
@ -760,7 +761,9 @@ unit *read_unit(struct gamedata *data)
|
|||
u->age = (short)n;
|
||||
|
||||
READ_TOK(data->store, rname, sizeof(rname));
|
||||
u_setrace(u, rc_find(rname));
|
||||
rc = rc_find(rname);
|
||||
assert(rc);
|
||||
u_setrace(u, rc);
|
||||
|
||||
READ_TOK(data->store, rname, sizeof(rname));
|
||||
if (rname[0] && skill_enabled(SK_STEALTH))
|
||||
|
@ -768,8 +771,8 @@ unit *read_unit(struct gamedata *data)
|
|||
else
|
||||
u->irace = NULL;
|
||||
|
||||
if (u_race(u)->describe) {
|
||||
const char *rcdisp = u_race(u)->describe(u, u->faction->locale);
|
||||
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) {
|
||||
|
|
|
@ -470,7 +470,7 @@ const char *u_description(const unit * u, const struct locale *lang)
|
|||
return u->display;
|
||||
}
|
||||
else if (u_race(u)->describe) {
|
||||
return u_race(u)->describe(u, lang);
|
||||
return u_race(u)->describe(u->_race, lang);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -1800,8 +1800,7 @@ static int parse_races(xmlDocPtr doc)
|
|||
rc->generate_name = (race_name_func)fun;
|
||||
}
|
||||
else if (strcmp((const char *)propValue, "describe") == 0) {
|
||||
rc->describe =
|
||||
(const char *(*)(const struct unit *, const struct locale *))fun;
|
||||
rc->describe = (race_desc_func)fun;
|
||||
}
|
||||
else if (strcmp((const char *)propValue, "age") == 0) {
|
||||
rc->age = (void(*)(struct unit *))fun;
|
||||
|
|
|
@ -45,9 +45,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static const char *describe_braineater(unit * u, const struct locale *lang)
|
||||
static const char *describe_race(const race * rc, const struct locale *lang)
|
||||
{
|
||||
return LOC(lang, "describe_braineater");
|
||||
char zText[32];
|
||||
sprintf(zText, "describe_%s", rc->_name);
|
||||
return LOC(lang, zText);
|
||||
}
|
||||
|
||||
static void count_particles(const char *monster, int *num_prefix, int *num_name, int *num_postfix)
|
||||
|
@ -480,7 +482,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars)
|
|||
|
||||
void register_names(void)
|
||||
{
|
||||
register_function((pf_generic)describe_braineater, "describe_braineater");
|
||||
register_race_description_function(describe_race, "describe_race");
|
||||
/* function name
|
||||
* generate a name for a nonplayerunit
|
||||
* race->generate_name() */
|
||||
|
|
|
@ -32,7 +32,7 @@ static void test_names(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, get_function("namedragon"));
|
||||
CuAssertPtrNotNull(tc, get_function("namedracoid"));
|
||||
CuAssertPtrNotNull(tc, get_function("namegeneric"));
|
||||
CuAssertPtrNotNull(tc, get_function("describe_braineater"));
|
||||
CuAssertPtrNotNull(tc, get_function("describe_race"));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue