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