forked from github/server
XML can use a catalog, because that makes life easier.
Fix a bunch of small stuff.
This commit is contained in:
parent
ce64d77be3
commit
8c9136e88b
|
@ -327,6 +327,9 @@ tolua_faction_create(lua_State* L)
|
|||
if (frace!=NULL) {
|
||||
f = addfaction(email, NULL, frace, loc, 0);
|
||||
}
|
||||
if (!f) {
|
||||
log_error(("faction.create(%s, %s, %s)\n", email, racename, lang));
|
||||
}
|
||||
tolua_pushusertype(L, f, TOLUA_CAST "faction");
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ tolua_select_region(lua_State* L)
|
|||
{
|
||||
region * r = tolua_tousertype(L, 1, 0);
|
||||
int select = tolua_toboolean(L, 2, 0);
|
||||
if (current_state) {
|
||||
if (current_state && r) {
|
||||
select_coordinate(current_state->selected, r->x, r->y, select);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -171,6 +171,9 @@ msg_set_int(lua_message * msg, const char * param, int value)
|
|||
int
|
||||
msg_send_faction(lua_message * msg, faction * f)
|
||||
{
|
||||
assert(f);
|
||||
assert(msg);
|
||||
|
||||
if (msg->mtype) {
|
||||
if (msg->msg==NULL) {
|
||||
msg->msg = msg_create(msg->mtype, msg->args);
|
||||
|
@ -303,9 +306,12 @@ tolua_msg_send_faction(lua_State * L)
|
|||
{
|
||||
lua_message * lmsg = (lua_message *)tolua_tousertype(L, 1, 0);
|
||||
faction * f = (faction *)tolua_tousertype(L, 2, 0);
|
||||
int result = msg_send_faction(lmsg, f);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
if (f && lmsg) {
|
||||
int result = msg_send_faction(lmsg, f);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -387,6 +387,9 @@ tolua_region_create(lua_State* L)
|
|||
plane * pl = findplane(x, y);
|
||||
const terrain_type * terrain = get_terrain(tname);
|
||||
region * r, * result;
|
||||
if (!terrain) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert(!pnormalize(&x, &y, pl));
|
||||
r = result = findregion(x, y);
|
||||
|
|
|
@ -977,7 +977,8 @@ int
|
|||
tolua_read_xml(lua_State* L)
|
||||
{
|
||||
const char * filename = tolua_tostring(L, 1, 0);
|
||||
init_data(filename);
|
||||
const char * catalog = tolua_tostring(L, 2, 0);
|
||||
init_data(filename, catalog);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1007,16 +1007,18 @@ inactivefaction(faction * f)
|
|||
FILE *inactiveFILE;
|
||||
char zText[128];
|
||||
|
||||
sprintf(zText, "%s/%s", datapath(), "/inactive");
|
||||
sprintf(zText, "%s/%s", datapath(), "inactive");
|
||||
inactiveFILE = fopen(zText, "a");
|
||||
|
||||
fprintf(inactiveFILE, "%s:%s:%d:%d\n",
|
||||
factionid(f),
|
||||
LOC(default_locale, rc_name(f->race, 1)),
|
||||
modify(count_all(f)),
|
||||
turn - f->lastorders);
|
||||
if (inactiveFILE) {
|
||||
fprintf(inactiveFILE, "%s:%s:%d:%d\n",
|
||||
factionid(f),
|
||||
LOC(default_locale, rc_name(f->race, 1)),
|
||||
modify(count_all(f)),
|
||||
turn - f->lastorders);
|
||||
|
||||
fclose(inactiveFILE);
|
||||
fclose(inactiveFILE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -4205,11 +4207,11 @@ update_subscriptions(void)
|
|||
}
|
||||
|
||||
int
|
||||
init_data(const char * filename)
|
||||
init_data(const char * filename, const char * catalog)
|
||||
{
|
||||
int l;
|
||||
|
||||
l = read_xml(filename);
|
||||
l = read_xml(filename, catalog);
|
||||
if (l) return l;
|
||||
|
||||
init_locales();
|
||||
|
|
|
@ -34,7 +34,7 @@ void find_address(void);
|
|||
void update_guards(void);
|
||||
void update_subscriptions(void);
|
||||
void deliverMail(struct faction * f, struct region * r, struct unit * u, const char *s, struct unit * receiver);
|
||||
int init_data(const char * filename);
|
||||
int init_data(const char * filename, const char * catalog);
|
||||
|
||||
/* eressea-specific. put somewhere else, please. */
|
||||
void processorders(void);
|
||||
|
|
|
@ -761,10 +761,10 @@ init_olditems(void)
|
|||
/* item is defined in XML file, but IT_XYZ enum still in use */
|
||||
const item_type * itype = it_find(itemnames[i]);
|
||||
|
||||
assert(itype);
|
||||
olditemtype[i] = itype;
|
||||
oldresourcetype[i] = itype->rtype;
|
||||
continue;
|
||||
if (itype) {
|
||||
olditemtype[i] = itype;
|
||||
oldresourcetype[i] = itype->rtype;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1191,8 +1191,10 @@ terraform_region(region * r, const terrain_type * terrain)
|
|||
{
|
||||
/* Resourcen, die nicht mehr vorkommen können, löschen */
|
||||
const terrain_type * oldterrain = r->terrain;
|
||||
|
||||
rawmaterial **lrm = &r->resources;
|
||||
|
||||
assert(terrain);
|
||||
|
||||
while (*lrm) {
|
||||
rawmaterial *rm = *lrm;
|
||||
const resource_type * rtype = NULL;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
/* util includes */
|
||||
#include "log.h"
|
||||
|
||||
#include <libxml/catalog.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
|
||||
/* libc includes */
|
||||
|
@ -105,11 +106,14 @@ xml_register_callback(xml_callback callback)
|
|||
}
|
||||
|
||||
int
|
||||
read_xml(const char * filename)
|
||||
read_xml(const char * filename, const char * catalog)
|
||||
{
|
||||
xml_reader * reader = xmlReaders;
|
||||
xmlDocPtr doc;
|
||||
|
||||
if (catalog) {
|
||||
xmlLoadCatalog(catalog);
|
||||
}
|
||||
#ifdef XML_PARSE_XINCLUDE
|
||||
doc = xmlReadFile(filename, NULL, XML_PARSE_XINCLUDE);
|
||||
#else
|
||||
|
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
|
||||
typedef int (*xml_callback)(xmlDocPtr);
|
||||
extern void xml_register_callback(xml_callback callback);
|
||||
extern int read_xml(const char * filename);
|
||||
extern int read_xml(const char * filename, const char * catalog);
|
||||
extern double xml_fvalue(xmlNodePtr node, const char * name, double dflt);
|
||||
extern int xml_ivalue(xmlNodePtr node, const char * name, int dflt);
|
||||
extern boolean xml_bvalue(xmlNodePtr node, const char * name, boolean dflt);
|
||||
|
|
Loading…
Reference in New Issue