forked from github/server
In the game, there is only ever one special direction, and it is for the astral space.
less XML, more code. cleaning up the special direction parsing a bit.
This commit is contained in:
parent
932a615837
commit
c0230d2662
|
@ -22,7 +22,6 @@
|
||||||
<xi:include href="config:///game/familiars.xml"/>
|
<xi:include href="config:///game/familiars.xml"/>
|
||||||
<xi:include href="config:///core/terrains.xml"/>
|
<xi:include href="config:///core/terrains.xml"/>
|
||||||
<xi:include href="config:///game/terrains.xml"/>
|
<xi:include href="config:///game/terrains.xml"/>
|
||||||
<xi:include href="config:///default/directions.xml"/>
|
|
||||||
<xi:include href="config:///game/artrewards.xml"/>
|
<xi:include href="config:///game/artrewards.xml"/>
|
||||||
<xi:include href="config:///game/buildings.xml"/>
|
<xi:include href="config:///game/buildings.xml"/>
|
||||||
<xi:include href="config:///core/calendar.xml"/>
|
<xi:include href="config:///core/calendar.xml"/>
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
<xi:include href="config:///core/common/buildings.xml"/>
|
<xi:include href="config:///core/common/buildings.xml"/>
|
||||||
<xi:include href="config:///game/familiars.xml"/>
|
<xi:include href="config:///game/familiars.xml"/>
|
||||||
|
|
||||||
<xi:include href="config:///default/directions.xml"/>
|
|
||||||
<xi:include href="config:///default/adamantium.xml" />
|
<xi:include href="config:///default/adamantium.xml" />
|
||||||
|
|
||||||
<xi:include href="config:///game/ships.xml"/>
|
<xi:include href="config:///game/ships.xml"/>
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
<xi:include href="config:///core/common/buildings.xml"/>
|
<xi:include href="config:///core/common/buildings.xml"/>
|
||||||
<xi:include href="config:///game/familiars.xml"/>
|
<xi:include href="config:///game/familiars.xml"/>
|
||||||
|
|
||||||
<xi:include href="config:///default/directions.xml"/>
|
|
||||||
<xi:include href="config:///default/adamantium.xml" />
|
<xi:include href="config:///default/adamantium.xml" />
|
||||||
|
|
||||||
<xi:include href="config:///game/ships.xml"/>
|
<xi:include href="config:///game/ships.xml"/>
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
<xi:include href="config:///game/familiars.xml"/>
|
<xi:include href="config:///game/familiars.xml"/>
|
||||||
<xi:include href="config:///core/terrains.xml"/>
|
<xi:include href="config:///core/terrains.xml"/>
|
||||||
<xi:include href="config:///game/terrains.xml"/>
|
<xi:include href="config:///game/terrains.xml"/>
|
||||||
<xi:include href="config:///default/directions.xml"/>
|
|
||||||
<xi:include href="config:///game/artrewards.xml"/>
|
<xi:include href="config:///game/artrewards.xml"/>
|
||||||
<xi:include href="config:///game/buildings.xml"/>
|
<xi:include href="config:///game/buildings.xml"/>
|
||||||
<xi:include href="config:///core/calendar.xml"/>
|
<xi:include href="config:///core/calendar.xml"/>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<eressea xmlns:xi="http://www.w3.org/2001/XInclude">
|
<eressea xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||||
<xi:include href="config:///default/directions.xml"/>
|
|
||||||
|
|
||||||
<xi:include href="config:///core/messages.xml"/>
|
<xi:include href="config:///core/messages.xml"/>
|
||||||
|
|
||||||
<xi:include href="config:///core/de/strings.xml"/>
|
<xi:include href="config:///core/de/strings.xml"/>
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<directions>
|
|
||||||
<dir name="vortex" desc="vortex_desc"/>
|
|
||||||
</directions>
|
|
|
@ -461,33 +461,6 @@ static int parse_calendar(xmlDocPtr doc)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_directions(xmlDocPtr doc)
|
|
||||||
{
|
|
||||||
xmlXPathContextPtr xpath = xmlXPathNewContext(doc);
|
|
||||||
xmlXPathObjectPtr xpathDirections;
|
|
||||||
xmlNodeSetPtr nsetDirections;
|
|
||||||
int rv = 0;
|
|
||||||
|
|
||||||
/* reading eressea/directions/dir */
|
|
||||||
xpathDirections =
|
|
||||||
xmlXPathEvalExpression(BAD_CAST "/eressea/directions/dir", xpath);
|
|
||||||
nsetDirections = xpathDirections->nodesetval;
|
|
||||||
if (nsetDirections != NULL) {
|
|
||||||
int k;
|
|
||||||
for (k = 0; k != nsetDirections->nodeNr; ++k) {
|
|
||||||
xmlNodePtr dir = nsetDirections->nodeTab[k];
|
|
||||||
xmlChar *propValue = xmlGetProp(dir, BAD_CAST "name");
|
|
||||||
|
|
||||||
register_special_direction((const char *)propValue);
|
|
||||||
xmlFree(propValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xmlXPathFreeObject(xpathDirections);
|
|
||||||
xmlXPathFreeContext(xpath);
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int parse_ships(xmlDocPtr doc)
|
static int parse_ships(xmlDocPtr doc)
|
||||||
{
|
{
|
||||||
xmlXPathContextPtr xpath = xmlXPathNewContext(doc);
|
xmlXPathContextPtr xpath = xmlXPathNewContext(doc);
|
||||||
|
@ -2309,6 +2282,5 @@ void register_xmlreader(void)
|
||||||
xml_register_callback(parse_equipment); /* requires spells */
|
xml_register_callback(parse_equipment); /* requires spells */
|
||||||
xml_register_callback(parse_races); /* requires spells */
|
xml_register_callback(parse_races); /* requires spells */
|
||||||
xml_register_callback(parse_calendar);
|
xml_register_callback(parse_calendar);
|
||||||
xml_register_callback(parse_directions);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1086,7 +1086,11 @@ int movewhere(const unit * u, const char *token, region * r, region ** resultp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODIRECTION:
|
case NODIRECTION:
|
||||||
r2 = find_special_direction(r, token, u->faction->locale);
|
token = (const char *)get_translation(u->faction->locale, token, UT_SPECDIR);
|
||||||
|
if (!token) {
|
||||||
|
return E_MOVE_NOREGION;
|
||||||
|
}
|
||||||
|
r2 = find_special_direction(r, token);
|
||||||
if (r2 == NULL) {
|
if (r2 == NULL) {
|
||||||
return E_MOVE_NOREGION;
|
return E_MOVE_NOREGION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6868,6 +6868,7 @@ void register_spells(void)
|
||||||
register_function((pf_generic)sp_kampfzauber, "combat_spell");
|
register_function((pf_generic)sp_kampfzauber, "combat_spell");
|
||||||
|
|
||||||
register_spelldata();
|
register_spelldata();
|
||||||
|
register_special_direction("vortex");
|
||||||
|
|
||||||
register_unitcurse();
|
register_unitcurse();
|
||||||
register_regioncurse();
|
register_regioncurse();
|
||||||
|
|
|
@ -234,6 +234,15 @@ void ** get_translations(const struct locale *lang, int index)
|
||||||
return lstrs[0].tokens + index;
|
return lstrs[0].tokens + index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *get_translation(const struct locale *lang, const char *str, int index) {
|
||||||
|
void **tokens = get_translations(lang, index);
|
||||||
|
variant var;
|
||||||
|
if (findtoken(*tokens, str, &var) == E_TOK_SUCCESS) {
|
||||||
|
return var.v;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void free_locales(void)
|
void free_locales(void)
|
||||||
{
|
{
|
||||||
while (locales) {
|
while (locales) {
|
||||||
|
|
|
@ -65,7 +65,8 @@ extern "C" {
|
||||||
UT_MAX
|
UT_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
void ** get_translations(const struct locale *lang, int index);
|
void ** get_translations(const struct locale *lang, int type);
|
||||||
|
void * get_translation(const struct locale *lang, const char *str, int type);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ void opstack_push(opstack ** stackp, variant data)
|
||||||
opstack *stack = *stackp;
|
opstack *stack = *stackp;
|
||||||
if (stack == NULL) {
|
if (stack == NULL) {
|
||||||
stack = (opstack *) malloc(sizeof(opstack));
|
stack = (opstack *) malloc(sizeof(opstack));
|
||||||
stack->size = 1;
|
stack->size = 2;
|
||||||
stack->begin = malloc(sizeof(variant) * stack->size);
|
stack->begin = malloc(sizeof(variant) * stack->size);
|
||||||
stack->top = stack->begin;
|
stack->top = stack->begin;
|
||||||
*stackp = stack;
|
*stackp = stack;
|
||||||
|
|
13
src/vortex.c
13
src/vortex.c
|
@ -39,7 +39,7 @@ void register_special_direction(const char *name)
|
||||||
var.v = str;
|
var.v = str;
|
||||||
addtoken(tokens, token, var);
|
addtoken(tokens, token, var);
|
||||||
|
|
||||||
if (lang == default_locale) {
|
if (lang == locales) {
|
||||||
dir_lookup *dl = malloc(sizeof(dir_lookup));
|
dir_lookup *dl = malloc(sizeof(dir_lookup));
|
||||||
dl->name = str;
|
dl->name = str;
|
||||||
dl->oldname = token;
|
dl->oldname = token;
|
||||||
|
@ -134,8 +134,7 @@ attrib_type at_direction = {
|
||||||
a_readdirection
|
a_readdirection
|
||||||
};
|
};
|
||||||
|
|
||||||
region *find_special_direction(const region * r, const char *token,
|
region *find_special_direction(const region * r, const char *token)
|
||||||
const struct locale *lang)
|
|
||||||
{
|
{
|
||||||
attrib *a;
|
attrib *a;
|
||||||
spec_direction *d;
|
spec_direction *d;
|
||||||
|
@ -146,16 +145,10 @@ region *find_special_direction(const region * r, const char *token,
|
||||||
a = a->next) {
|
a = a->next) {
|
||||||
d = (spec_direction *)(a->data.v);
|
d = (spec_direction *)(a->data.v);
|
||||||
|
|
||||||
if (d->active) {
|
if (d->active && strcmp(token, d->keyword) == 0) {
|
||||||
void **tokens = get_translations(lang, UT_SPECDIR);
|
|
||||||
variant var;
|
|
||||||
if (findtoken(*tokens, token, &var) == E_TOK_SUCCESS) {
|
|
||||||
if (strcmp((const char *)var.v, d->keyword) == 0) {
|
|
||||||
return findregion(d->x, d->y);
|
return findregion(d->x, d->y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ extern "C" {
|
||||||
|
|
||||||
struct region;
|
struct region;
|
||||||
struct attrib;
|
struct attrib;
|
||||||
struct locale;
|
|
||||||
|
|
||||||
typedef struct spec_direction {
|
typedef struct spec_direction {
|
||||||
int x, y;
|
int x, y;
|
||||||
|
@ -19,7 +18,7 @@ extern "C" {
|
||||||
extern struct attrib_type at_direction;
|
extern struct attrib_type at_direction;
|
||||||
|
|
||||||
struct region *find_special_direction(const struct region *r,
|
struct region *find_special_direction(const struct region *r,
|
||||||
const char *token, const struct locale *lang);
|
const char *token);
|
||||||
void register_special_direction(const char *name);
|
void register_special_direction(const char *name);
|
||||||
struct spec_direction *special_direction(const struct region * from,
|
struct spec_direction *special_direction(const struct region * from,
|
||||||
const struct region * to);
|
const struct region * to);
|
||||||
|
|
Loading…
Reference in New Issue