forked from github/server
more xmlreport features
This commit is contained in:
parent
9ffcff7e2a
commit
2e09d16588
9 changed files with 85 additions and 37 deletions
|
@ -12,7 +12,6 @@
|
||||||
* prior permission by the authors of Eressea.
|
* prior permission by the authors of Eressea.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define INDENT 0
|
|
||||||
#define ECHECK_VERSION "4.01"
|
#define ECHECK_VERSION "4.01"
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
/* vi: set ts=2:
|
/* vi: set ts=2:
|
||||||
*
|
+-------------------+ Enno Rehling <enno@eressea.de>
|
||||||
*
|
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
| (c) 1998 - 2008 | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
+-------------------+
|
||||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
This program may not be used, modified or distributed
|
||||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
without prior permission by the authors of Eressea.
|
||||||
* Enno Rehling (enno@eressea.de)
|
|
||||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
|
||||||
*
|
|
||||||
* This program may not be used, modified or distributed without
|
|
||||||
* prior permission by the authors of Eressea.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -228,9 +223,8 @@ xml_skills(report_context * ctx, unit * u)
|
||||||
skill_t sk = sv->id;
|
skill_t sk = sv->id;
|
||||||
int esk = eff_skill(u, sk, u->region);
|
int esk = eff_skill(u, sk, u->region);
|
||||||
|
|
||||||
child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "skill"));
|
child = xmlNewTextChild(node, xct->ns_atl, BAD_CAST "skill", BAD_CAST itoab(esk, 10));
|
||||||
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "name", BAD_CAST skillnames[sk]);
|
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "type", BAD_CAST skillnames[sk]);
|
||||||
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "value", BAD_CAST itoab(esk, 10));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,6 +447,27 @@ xml_resources(report_context * ctx, const seen_region * sr)
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static xmlNodePtr
|
||||||
|
xml_diplomacy(report_context * ctx, const struct ally * allies)
|
||||||
|
{
|
||||||
|
xml_context* xct = (xml_context*)ctx->userdata;
|
||||||
|
xmlNodePtr child, node = xmlNewNode(xct->ns_atl, BAD_CAST "diplomacy");
|
||||||
|
const struct ally * sf;
|
||||||
|
|
||||||
|
for (sf=allies;sf;sf=sf->next) {
|
||||||
|
int i, status = sf->status;
|
||||||
|
for (i=0;helpmodes[i].name;++i) {
|
||||||
|
if (sf->faction && (status & helpmodes[i].status)==helpmodes[i].status) {
|
||||||
|
status -= helpmodes[i].status;
|
||||||
|
child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "status"));
|
||||||
|
xmlNewNsProp(child, xct->ns_xml, BAD_CAST "faction", xml_ref_faction(sf->faction));
|
||||||
|
xmlNewNsProp(child, xct->ns_xml, BAD_CAST "status", (xmlChar*)helpmodes[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
static xmlNodePtr
|
static xmlNodePtr
|
||||||
xml_groups(report_context * ctx, const group * groups)
|
xml_groups(report_context * ctx, const group * groups)
|
||||||
{
|
{
|
||||||
|
@ -466,6 +481,8 @@ xml_groups(report_context * ctx, const group * groups)
|
||||||
xmlNewNsProp(node, xct->ns_xml, XML_XML_ID, xml_ref_group(g));
|
xmlNewNsProp(node, xct->ns_xml, XML_XML_ID, xml_ref_group(g));
|
||||||
xmlNewTextChild(node, xct->ns_atl, BAD_CAST "name", (const xmlChar *)g->name);
|
xmlNewTextChild(node, xct->ns_atl, BAD_CAST "name", (const xmlChar *)g->name);
|
||||||
|
|
||||||
|
if (g->allies) xmlAddChild(child, xml_diplomacy(ctx, g->allies));
|
||||||
|
|
||||||
child = xmlAddChild(child, xmlNewNode(xct->ns_atl, BAD_CAST "prefix"));
|
child = xmlAddChild(child, xmlNewNode(xct->ns_atl, BAD_CAST "prefix"));
|
||||||
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", xml_ref_prefix(prefix));
|
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "ref", xml_ref_prefix(prefix));
|
||||||
}
|
}
|
||||||
|
@ -490,6 +507,8 @@ xml_faction(report_context * ctx, faction * f)
|
||||||
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "public");
|
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "rel", BAD_CAST "public");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (f->allies) xmlAddChild(node, xml_diplomacy(ctx, f->allies));
|
||||||
|
|
||||||
if (ctx->f==f) {
|
if (ctx->f==f) {
|
||||||
xmlAddChild(node, xml_link(ctx, BAD_CAST "race", BAD_CAST f->race->_name[0]));
|
xmlAddChild(node, xml_link(ctx, BAD_CAST "race", BAD_CAST f->race->_name[0]));
|
||||||
if (f->items) xmlAddChild(node, xml_inventory(ctx, f->items, NULL));
|
if (f->items) xmlAddChild(node, xml_inventory(ctx, f->items, NULL));
|
||||||
|
@ -590,13 +609,14 @@ xml_region(report_context * ctx, seen_region * sr)
|
||||||
ship * sh = r->ships;
|
ship * sh = r->ships;
|
||||||
building * b = r->buildings;
|
building * b = r->buildings;
|
||||||
|
|
||||||
|
/* TODO: entertain-quota, recruits, salary, prices, curses, borders, apparitions (Schemen), spells, travelthru, messages */
|
||||||
xmlNewNsProp(node, xct->ns_xml, XML_XML_ID, xml_ref_region(r));
|
xmlNewNsProp(node, xct->ns_xml, XML_XML_ID, xml_ref_region(r));
|
||||||
|
|
||||||
child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "coordinate"));
|
child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "coordinate"));
|
||||||
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "x", xml_i(region_x(r, ctx->f)));
|
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "x", xml_i(region_x(r, ctx->f)));
|
||||||
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "y", xml_i(region_y(r, ctx->f)));
|
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "y", xml_i(region_y(r, ctx->f)));
|
||||||
if (r->planep) {
|
if (r->planep) {
|
||||||
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "plane", xml_s(r->planep->name));
|
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "plane", (xmlChar *)r->planep->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "terrain"));
|
child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "terrain"));
|
||||||
|
@ -670,12 +690,29 @@ report_root(report_context * ctx)
|
||||||
const faction_list * address;
|
const faction_list * address;
|
||||||
region * r = ctx->first, * rend = ctx->last;
|
region * r = ctx->first, * rend = ctx->last;
|
||||||
xml_context* xct = (xml_context*)ctx->userdata;
|
xml_context* xct = (xml_context*)ctx->userdata;
|
||||||
xmlNodePtr xmlReport = xmlNewNode(NULL, BAD_CAST "atlantis");
|
xmlNodePtr node, child, xmlReport = xmlNewNode(NULL, BAD_CAST "atlantis");
|
||||||
|
const char * mailto = locale_string(ctx->f->locale, "mailto");
|
||||||
|
const char * mailcmd = locale_string(ctx->f->locale, "mailcmd");
|
||||||
|
char zText[128];
|
||||||
|
/* TODO: locale, age, options, messages */
|
||||||
|
|
||||||
xct->ns_xml = xmlNewNs(xmlReport, XML_XML_NAMESPACE, BAD_CAST "xml");
|
xct->ns_xml = xmlNewNs(xmlReport, XML_XML_NAMESPACE, BAD_CAST "xml");
|
||||||
xct->ns_atl = xmlNewNs(xmlReport, XML_ATL_NAMESPACE, NULL);
|
xct->ns_atl = xmlNewNs(xmlReport, XML_ATL_NAMESPACE, NULL);
|
||||||
xmlSetNs(xmlReport, xct->ns_atl);
|
xmlSetNs(xmlReport, xct->ns_atl);
|
||||||
|
|
||||||
|
node = xmlAddChild(xmlReport, xmlNewNode(xct->ns_atl, BAD_CAST "server"));
|
||||||
|
if (mailto) {
|
||||||
|
snprintf(zText, sizeof(zText), "mailto:%s?subject=%s", mailto, mailcmd);
|
||||||
|
child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "delivery"));
|
||||||
|
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "method", BAD_CAST "mail");
|
||||||
|
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "href", BAD_CAST zText);
|
||||||
|
}
|
||||||
|
xmlNewTextChild(node, xct->ns_atl, BAD_CAST "game", (xmlChar *)global.gamename);
|
||||||
|
strftime(zText, sizeof(zText), "%Y-%m-%dT%H:%M:%SZ", gmtime(&ctx->report_time));
|
||||||
|
xmlNewTextChild(node, xct->ns_atl, BAD_CAST "time", (xmlChar *)zText);
|
||||||
|
xmlNewTextChild(node, xct->ns_atl, BAD_CAST "turn", (xmlChar *)itoab(turn, 10));
|
||||||
|
|
||||||
|
|
||||||
for (address=ctx->addresses;address;address=address->next) {
|
for (address=ctx->addresses;address;address=address->next) {
|
||||||
xmlAddChild(xmlReport, xml_faction(ctx, address->data));
|
xmlAddChild(xmlReport, xml_faction(ctx, address->data));
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,6 +238,18 @@ old_race(const struct race * rc)
|
||||||
return NORACE;
|
return NORACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
helpmode helpmodes[] = {
|
||||||
|
{ "all", HELP_ALL },
|
||||||
|
{ "money", HELP_MONEY },
|
||||||
|
{ "fight", HELP_FIGHT },
|
||||||
|
{ "observe", HELP_OBSERVE },
|
||||||
|
{ "give", HELP_GIVE },
|
||||||
|
{ "guard", HELP_GUARD },
|
||||||
|
{ "stealth", HELP_FSTEALTH },
|
||||||
|
{ "travel", HELP_TRAVEL },
|
||||||
|
{ NULL, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
const char *directions[MAXDIRECTIONS+2] =
|
const char *directions[MAXDIRECTIONS+2] =
|
||||||
{
|
{
|
||||||
"northwest",
|
"northwest",
|
||||||
|
|
|
@ -409,6 +409,12 @@ extern struct order * default_order(const struct locale * lang);
|
||||||
extern int entertainmoney(const struct region * r);
|
extern int entertainmoney(const struct region * r);
|
||||||
|
|
||||||
extern void plagues(struct region * r, boolean ismagic);
|
extern void plagues(struct region * r, boolean ismagic);
|
||||||
|
typedef struct helpmode {
|
||||||
|
const char * name;
|
||||||
|
int status;
|
||||||
|
} helpmode;
|
||||||
|
|
||||||
|
extern struct helpmode helpmodes[];
|
||||||
|
|
||||||
extern struct attrib_type at_guard;
|
extern struct attrib_type at_guard;
|
||||||
extern void free_gamedata(void);
|
extern void free_gamedata(void);
|
||||||
|
|
|
@ -327,7 +327,6 @@ int change_money(struct unit *, int);
|
||||||
int res_changeitem(struct unit * u, const resource_type * rtype, int delta);
|
int res_changeitem(struct unit * u, const resource_type * rtype, int delta);
|
||||||
|
|
||||||
extern struct attrib_type at_showitem; /* show this potion's description */
|
extern struct attrib_type at_showitem; /* show this potion's description */
|
||||||
extern struct attrib_type at_seenitem; /* knows this potion's description, no need to reshow */
|
|
||||||
|
|
||||||
extern void register_resources(void);
|
extern void register_resources(void);
|
||||||
extern void init_resources(void);
|
extern void init_resources(void);
|
||||||
|
|
|
@ -351,11 +351,17 @@ report_resources(const seen_region * sr, resource_report * result, int size, con
|
||||||
|
|
||||||
if (r->land) {
|
if (r->land) {
|
||||||
int peasants = rpeasants(r);
|
int peasants = rpeasants(r);
|
||||||
|
int money = rmoney(r);
|
||||||
int horses = rhorses(r);
|
int horses = rhorses(r);
|
||||||
int trees = rtrees(r, 2);
|
int trees = rtrees(r, 2);
|
||||||
int saplings = rtrees(r, 1);
|
int saplings = rtrees(r, 1);
|
||||||
boolean mallorn = fval(r, RF_MALLORN)!=0;
|
boolean mallorn = fval(r, RF_MALLORN)!=0;
|
||||||
|
|
||||||
|
if (money) {
|
||||||
|
if (n>=size) return -1;
|
||||||
|
report_resource(result+n, "rm_money", peasants, -1);
|
||||||
|
++n;
|
||||||
|
}
|
||||||
if (peasants) {
|
if (peasants) {
|
||||||
if (n>=size) return -1;
|
if (n>=size) return -1;
|
||||||
report_resource(result+n, "rm_peasant", peasants, -1);
|
report_resource(result+n, "rm_peasant", peasants, -1);
|
||||||
|
|
|
@ -107,21 +107,6 @@ operator==(const faction& a, const faction&b)
|
||||||
return a.no==b.no;
|
return a.no==b.no;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct helpmode {
|
|
||||||
const char * name;
|
|
||||||
int status;
|
|
||||||
} helpmodes[] = {
|
|
||||||
{ "money", HELP_MONEY },
|
|
||||||
{ "fight", HELP_FIGHT },
|
|
||||||
{ "observe", HELP_OBSERVE },
|
|
||||||
{ "give", HELP_GIVE },
|
|
||||||
{ "guard", HELP_GUARD },
|
|
||||||
{ "stealth", HELP_FSTEALTH },
|
|
||||||
{ "travel", HELP_TRAVEL },
|
|
||||||
{ "all", HELP_ALL },
|
|
||||||
{ NULL, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
faction_getpolicy(const faction& a, const faction& b, const char * flag)
|
faction_getpolicy(const faction& a, const faction& b, const char * flag)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6742,6 +6742,10 @@
|
||||||
<text locale="de">Bauern</text>
|
<text locale="de">Bauern</text>
|
||||||
<text locale="en">peasants</text>
|
<text locale="en">peasants</text>
|
||||||
</string>
|
</string>
|
||||||
|
<string name="rm_money">
|
||||||
|
<text locale="de">Silber</text>
|
||||||
|
<text locale="en">silver</text>
|
||||||
|
</string>
|
||||||
<string name="rm_laen">
|
<string name="rm_laen">
|
||||||
<text locale="de">Laen</text>
|
<text locale="de">Laen</text>
|
||||||
<text locale="en">laen</text>
|
<text locale="en">laen</text>
|
||||||
|
|
|
@ -116,7 +116,7 @@ end
|
||||||
|
|
||||||
function test_hse()
|
function test_hse()
|
||||||
read_game("50.dat", "binary")
|
read_game("50.dat", "binary")
|
||||||
f = get_faction(atoi36("7scs"))
|
f = get_faction(atoi36("8h7f"))
|
||||||
f.options = f.options + 8192
|
f.options = f.options + 8192
|
||||||
init_reports()
|
init_reports()
|
||||||
write_report(f)
|
write_report(f)
|
||||||
|
@ -215,8 +215,8 @@ run_scripts()
|
||||||
-- test_free()
|
-- test_free()
|
||||||
-- test_bmark()
|
-- test_bmark()
|
||||||
-- test_realloc()
|
-- test_realloc()
|
||||||
test_xml()
|
-- test_xml()
|
||||||
-- test_hse()
|
test_hse()
|
||||||
-- test_reorder()
|
-- test_reorder()
|
||||||
-- test_tunnels()
|
-- test_tunnels()
|
||||||
-- test_md5()
|
-- test_md5()
|
||||||
|
|
Loading…
Reference in a new issue