forked from github/server
mapper should not try to load gamecode functions of objects
This commit is contained in:
parent
d4a0c6c06c
commit
40385e2d3e
|
@ -279,32 +279,34 @@ parse_buildings(xmlDocPtr doc)
|
||||||
xml_readconstruction(xpath, result->nodesetval->nodeTab, result->nodesetval->nodeNr, &bt->construction);
|
xml_readconstruction(xpath, result->nodesetval->nodeTab, result->nodesetval->nodeNr, &bt->construction);
|
||||||
xmlXPathFreeObject(result);
|
xmlXPathFreeObject(result);
|
||||||
|
|
||||||
/* reading eressea/buildings/building/function */
|
if (gamecode_enabled) {
|
||||||
xpath->node = node;
|
/* reading eressea/buildings/building/function */
|
||||||
result = xmlXPathEvalExpression(BAD_CAST "function", xpath);
|
xpath->node = node;
|
||||||
for (k=0;k!=result->nodesetval->nodeNr;++k) {
|
result = xmlXPathEvalExpression(BAD_CAST "function", xpath);
|
||||||
xmlNodePtr node = result->nodesetval->nodeTab[k];
|
for (k=0;k!=result->nodesetval->nodeNr;++k) {
|
||||||
pf_generic fun;
|
xmlNodePtr node = result->nodesetval->nodeTab[k];
|
||||||
parse_function(node, &fun, &property);
|
pf_generic fun;
|
||||||
|
parse_function(node, &fun, &property);
|
||||||
|
|
||||||
if (fun==NULL) {
|
if (fun==NULL) {
|
||||||
log_error(("unknown function name '%s' for building %s\n",
|
log_error(("unknown function name '%s' for building %s\n",
|
||||||
(const char*)property, bt->_name));
|
(const char*)property, bt->_name));
|
||||||
|
xmlFree(property);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assert(property!=NULL);
|
||||||
|
if (strcmp((const char*)property, "name")==0) {
|
||||||
|
bt->name = (const char * (*)(int size))fun;
|
||||||
|
} else if (strcmp((const char*)property, "init")==0) {
|
||||||
|
bt->init = (void (*)(struct building_type*))fun;
|
||||||
|
} else {
|
||||||
|
log_error(("unknown function type '%s' for building %s\n",
|
||||||
|
(const char*)property, bt->_name));
|
||||||
|
}
|
||||||
xmlFree(property);
|
xmlFree(property);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
assert(property!=NULL);
|
xmlXPathFreeObject(result);
|
||||||
if (strcmp((const char*)property, "name")==0) {
|
|
||||||
bt->name = (const char * (*)(int size))fun;
|
|
||||||
} else if (strcmp((const char*)property, "init")==0) {
|
|
||||||
bt->init = (void (*)(struct building_type*))fun;
|
|
||||||
} else {
|
|
||||||
log_error(("unknown function type '%s' for building %s\n",
|
|
||||||
(const char*)property, bt->_name));
|
|
||||||
}
|
|
||||||
xmlFree(property);
|
|
||||||
}
|
}
|
||||||
xmlXPathFreeObject(result);
|
|
||||||
|
|
||||||
/* reading eressea/buildings/building/maintenance */
|
/* reading eressea/buildings/building/maintenance */
|
||||||
result = xmlXPathEvalExpression(BAD_CAST "maintenance", xpath);
|
result = xmlXPathEvalExpression(BAD_CAST "maintenance", xpath);
|
||||||
|
@ -808,35 +810,37 @@ parse_resources(xmlDocPtr doc)
|
||||||
free(names[0]);
|
free(names[0]);
|
||||||
free(names[1]);
|
free(names[1]);
|
||||||
|
|
||||||
/* reading eressea/resources/resource/function */
|
if (gamecode_enabled) {
|
||||||
xpath->node = node;
|
/* reading eressea/resources/resource/function */
|
||||||
result = xmlXPathEvalExpression(BAD_CAST "function", xpath);
|
xpath->node = node;
|
||||||
if (result->nodesetval!=NULL) for (k=0;k!=result->nodesetval->nodeNr;++k) {
|
result = xmlXPathEvalExpression(BAD_CAST "function", xpath);
|
||||||
xmlNodePtr node = result->nodesetval->nodeTab[k];
|
if (result->nodesetval!=NULL) for (k=0;k!=result->nodesetval->nodeNr;++k) {
|
||||||
pf_generic fun;
|
xmlNodePtr node = result->nodesetval->nodeTab[k];
|
||||||
|
pf_generic fun;
|
||||||
|
|
||||||
parse_function(node, &fun, &property);
|
parse_function(node, &fun, &property);
|
||||||
if (fun==NULL) {
|
if (fun==NULL) {
|
||||||
log_error(("unknown function name '%s' for resource %s\n",
|
log_error(("unknown function name '%s' for resource %s\n",
|
||||||
(const char*)property, rtype->_name[0]));
|
(const char*)property, rtype->_name[0]));
|
||||||
|
xmlFree(property);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(property!=NULL);
|
||||||
|
if (strcmp((const char*)property, "change")==0) {
|
||||||
|
rtype->uchange = (rtype_uchange)fun;
|
||||||
|
} else if (strcmp((const char*)property, "get")==0) {
|
||||||
|
rtype->uget = (rtype_uget)fun;
|
||||||
|
} else if (strcmp((const char*)property, "name")==0) {
|
||||||
|
rtype->name = (rtype_name)fun;
|
||||||
|
} else {
|
||||||
|
log_error(("unknown function type '%s' for resource %s\n",
|
||||||
|
(const char*)property, rtype->_name[0]));
|
||||||
|
}
|
||||||
xmlFree(property);
|
xmlFree(property);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
xmlXPathFreeObject(result);
|
||||||
assert(property!=NULL);
|
|
||||||
if (strcmp((const char*)property, "change")==0) {
|
|
||||||
rtype->uchange = (rtype_uchange)fun;
|
|
||||||
} else if (strcmp((const char*)property, "get")==0) {
|
|
||||||
rtype->uget = (rtype_uget)fun;
|
|
||||||
} else if (strcmp((const char*)property, "name")==0) {
|
|
||||||
rtype->name = (rtype_name)fun;
|
|
||||||
} else {
|
|
||||||
log_error(("unknown function type '%s' for resource %s\n",
|
|
||||||
(const char*)property, rtype->_name[0]));
|
|
||||||
}
|
|
||||||
xmlFree(property);
|
|
||||||
}
|
}
|
||||||
xmlXPathFreeObject(result);
|
|
||||||
|
|
||||||
/* reading eressea/resources/resource/resourcelimit/function */
|
/* reading eressea/resources/resource/resourcelimit/function */
|
||||||
xpath->node = node;
|
xpath->node = node;
|
||||||
|
@ -1088,32 +1092,34 @@ parse_spells(xmlDocPtr doc)
|
||||||
if (xml_bvalue(node, "ocean", false)) sp->sptyp |= OCEANCASTABLE;
|
if (xml_bvalue(node, "ocean", false)) sp->sptyp |= OCEANCASTABLE;
|
||||||
if (xml_bvalue(node, "far", false)) sp->sptyp |= FARCASTING;
|
if (xml_bvalue(node, "far", false)) sp->sptyp |= FARCASTING;
|
||||||
|
|
||||||
/* reading eressea/spells/spell/function */
|
if (gamecode_enabled) {
|
||||||
xpath->node = node;
|
/* reading eressea/spells/spell/function */
|
||||||
result = xmlXPathEvalExpression(BAD_CAST "function", xpath);
|
xpath->node = node;
|
||||||
for (k=0;k!=result->nodesetval->nodeNr;++k) {
|
result = xmlXPathEvalExpression(BAD_CAST "function", xpath);
|
||||||
xmlNodePtr node = result->nodesetval->nodeTab[k];
|
for (k=0;k!=result->nodesetval->nodeNr;++k) {
|
||||||
pf_generic fun;
|
xmlNodePtr node = result->nodesetval->nodeTab[k];
|
||||||
|
pf_generic fun;
|
||||||
|
|
||||||
parse_function(node, &fun, &property);
|
parse_function(node, &fun, &property);
|
||||||
if (fun==NULL) {
|
if (fun==NULL) {
|
||||||
log_error(("unknown function name '%s' for spell '%s'\n",
|
log_error(("unknown function name '%s' for spell '%s'\n",
|
||||||
(const char*)property, sp->sname));
|
(const char*)property, sp->sname));
|
||||||
|
xmlFree(property);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assert(property!=NULL);
|
||||||
|
if (strcmp((const char*)property, "cast")==0) {
|
||||||
|
sp->sp_function = (spell_f)fun;
|
||||||
|
} else if (strcmp((const char*)property, "fumble")==0) {
|
||||||
|
sp->patzer = (pspell_f)fun;
|
||||||
|
} else {
|
||||||
|
log_error(("unknown function type '%s' for spell %s\n",
|
||||||
|
(const char*)property, sp->sname));
|
||||||
|
}
|
||||||
xmlFree(property);
|
xmlFree(property);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
assert(property!=NULL);
|
xmlXPathFreeObject(result);
|
||||||
if (strcmp((const char*)property, "cast")==0) {
|
|
||||||
sp->sp_function = (spell_f)fun;
|
|
||||||
} else if (strcmp((const char*)property, "fumble")==0) {
|
|
||||||
sp->patzer = (pspell_f)fun;
|
|
||||||
} else {
|
|
||||||
log_error(("unknown function type '%s' for spell %s\n",
|
|
||||||
(const char*)property, sp->sname));
|
|
||||||
}
|
|
||||||
xmlFree(property);
|
|
||||||
}
|
}
|
||||||
xmlXPathFreeObject(result);
|
|
||||||
|
|
||||||
/* reading eressea/spells/spell/resource */
|
/* reading eressea/spells/spell/resource */
|
||||||
xpath->node = node;
|
xpath->node = node;
|
||||||
|
@ -1278,38 +1284,40 @@ parse_races(xmlDocPtr doc)
|
||||||
}
|
}
|
||||||
xmlXPathFreeObject(result);
|
xmlXPathFreeObject(result);
|
||||||
|
|
||||||
/* reading eressea/races/race/function */
|
if (gamecode_enabled) {
|
||||||
xpath->node = node;
|
/* reading eressea/races/race/function */
|
||||||
result = xmlXPathEvalExpression(BAD_CAST "function", xpath);
|
xpath->node = node;
|
||||||
for (k=0;k!=result->nodesetval->nodeNr;++k) {
|
result = xmlXPathEvalExpression(BAD_CAST "function", xpath);
|
||||||
xmlNodePtr node = result->nodesetval->nodeTab[k];
|
for (k=0;k!=result->nodesetval->nodeNr;++k) {
|
||||||
pf_generic fun;
|
xmlNodePtr node = result->nodesetval->nodeTab[k];
|
||||||
|
pf_generic fun;
|
||||||
|
|
||||||
parse_function(node, &fun, &property);
|
parse_function(node, &fun, &property);
|
||||||
if (fun==NULL) {
|
if (fun==NULL) {
|
||||||
log_error(("unknown function name '%s' for race %s\n",
|
log_error(("unknown function name '%s' for race %s\n",
|
||||||
(const char*)property, rc->_name[0]));
|
(const char*)property, rc->_name[0]));
|
||||||
|
xmlFree(property);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assert(property!=NULL);
|
||||||
|
if (strcmp((const char*)property, "name")==0) {
|
||||||
|
rc->generate_name = (const char* (*)(const struct unit*))fun;
|
||||||
|
} else if (strcmp((const char*)property, "age")==0) {
|
||||||
|
rc->age = (void(*)(struct unit*))fun;
|
||||||
|
} else if (strcmp((const char*)property, "move")==0) {
|
||||||
|
rc->move_allowed = (boolean(*)(const struct region *, const struct region *))fun;
|
||||||
|
} else if (strcmp((const char*)property, "itemdrop")==0) {
|
||||||
|
rc->itemdrop = (struct item *(*)(const struct race *, int))fun;
|
||||||
|
} else if (strcmp((const char*)property, "initfamiliar")==0) {
|
||||||
|
rc->init_familiar = (void(*)(struct unit *))fun;
|
||||||
|
} else {
|
||||||
|
log_error(("unknown function type '%s' for race %s\n",
|
||||||
|
(const char*)property, rc->_name[0]));
|
||||||
|
}
|
||||||
xmlFree(property);
|
xmlFree(property);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
assert(property!=NULL);
|
xmlXPathFreeObject(result);
|
||||||
if (strcmp((const char*)property, "name")==0) {
|
|
||||||
rc->generate_name = (const char* (*)(const struct unit*))fun;
|
|
||||||
} else if (strcmp((const char*)property, "age")==0) {
|
|
||||||
rc->age = (void(*)(struct unit*))fun;
|
|
||||||
} else if (strcmp((const char*)property, "move")==0) {
|
|
||||||
rc->move_allowed = (boolean(*)(const struct region *, const struct region *))fun;
|
|
||||||
} else if (strcmp((const char*)property, "itemdrop")==0) {
|
|
||||||
rc->itemdrop = (struct item *(*)(const struct race *, int))fun;
|
|
||||||
} else if (strcmp((const char*)property, "initfamiliar")==0) {
|
|
||||||
rc->init_familiar = (void(*)(struct unit *))fun;
|
|
||||||
} else {
|
|
||||||
log_error(("unknown function type '%s' for race %s\n",
|
|
||||||
(const char*)property, rc->_name[0]));
|
|
||||||
}
|
|
||||||
xmlFree(property);
|
|
||||||
}
|
}
|
||||||
xmlXPathFreeObject(result);
|
|
||||||
|
|
||||||
/* reading eressea/races/race/familiar */
|
/* reading eressea/races/race/familiar */
|
||||||
xpath->node = node;
|
xpath->node = node;
|
||||||
|
|
Loading…
Reference in New Issue