2016-11-01 17:25:52 +01:00
|
|
|
/*
|
2010-08-08 10:06:34 +02:00
|
|
|
+-------------------+ Enno Rehling <enno@eressea.de>
|
|
|
|
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
|
|
|
| (c) 1998 - 2008 | Katja Zedel <katze@felidae.kn-bremen.de>
|
2014-08-14 09:57:05 +02:00
|
|
|
+-------------------+
|
|
|
|
This program may not be used, modified or distributed
|
2010-08-08 10:06:34 +02:00
|
|
|
without prior permission by the authors of Eressea.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <platform.h>
|
|
|
|
#include <kernel/config.h>
|
2016-09-10 17:41:44 +02:00
|
|
|
#include <kernel/version.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
#include "creport.h"
|
2016-11-16 22:30:59 +01:00
|
|
|
#include "market.h"
|
2016-11-01 22:11:10 +01:00
|
|
|
#include "guard.h"
|
2015-08-18 18:57:04 +02:00
|
|
|
#include "travelthru.h"
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
/* tweakable features */
|
|
|
|
#define RENDER_CRMESSAGES
|
|
|
|
#define BUFFERSIZE 32768
|
|
|
|
#define RESOURCECOMPAT
|
|
|
|
|
|
|
|
/* modules include */
|
|
|
|
#include <modules/score.h>
|
|
|
|
|
|
|
|
/* attributes include */
|
|
|
|
#include <attributes/follow.h>
|
|
|
|
#include <attributes/otherfaction.h>
|
2014-11-01 12:09:56 +01:00
|
|
|
#include <attributes/racename.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
#include <attributes/raceprefix.h>
|
2014-11-01 12:09:56 +01:00
|
|
|
#include <attributes/stealth.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
/* gamecode includes */
|
|
|
|
#include "laws.h"
|
|
|
|
#include "economy.h"
|
2014-08-27 06:40:18 +02:00
|
|
|
#include "move.h"
|
|
|
|
#include "reports.h"
|
|
|
|
#include "alchemy.h"
|
2016-01-28 12:25:16 +01:00
|
|
|
#include "teleport.h"
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
/* kernel includes */
|
|
|
|
#include <kernel/alliance.h>
|
2012-06-30 20:07:28 +02:00
|
|
|
#include <kernel/ally.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
#include <kernel/connection.h>
|
|
|
|
#include <kernel/building.h>
|
2012-06-03 22:39:42 +02:00
|
|
|
#include <kernel/curse.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
#include <kernel/faction.h>
|
|
|
|
#include <kernel/group.h>
|
|
|
|
#include <kernel/item.h>
|
2014-06-09 18:54:48 +02:00
|
|
|
#include <kernel/messages.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
#include <kernel/order.h>
|
|
|
|
#include <kernel/plane.h>
|
|
|
|
#include <kernel/race.h>
|
|
|
|
#include <kernel/region.h>
|
|
|
|
#include <kernel/resources.h>
|
|
|
|
#include <kernel/ship.h>
|
2012-05-26 07:54:18 +02:00
|
|
|
#include <kernel/spell.h>
|
2012-05-25 07:10:18 +02:00
|
|
|
#include <kernel/spellbook.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
#include <kernel/terrain.h>
|
|
|
|
#include <kernel/unit.h>
|
|
|
|
|
|
|
|
/* util includes */
|
|
|
|
#include <util/attrib.h>
|
|
|
|
#include <util/base36.h>
|
|
|
|
#include <util/crmessage.h>
|
2015-05-15 20:35:36 +02:00
|
|
|
#include <util/strings.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
#include <util/language.h>
|
|
|
|
#include <util/log.h>
|
|
|
|
#include <util/message.h>
|
|
|
|
#include <util/nrmessage.h>
|
2017-01-26 17:41:21 +01:00
|
|
|
#include <selist.h>
|
2015-08-05 14:45:46 +02:00
|
|
|
#include <filestream.h>
|
2016-11-13 19:40:38 +01:00
|
|
|
#include <stream.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/* imports */
|
2012-06-24 07:41:07 +02:00
|
|
|
bool opt_cr_absolute_coords = false;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
/* globals */
|
|
|
|
#define C_REPORT_VERSION 66
|
|
|
|
|
|
|
|
#define TAG_LOCALE "de"
|
|
|
|
#ifdef TAG_LOCALE
|
2011-03-07 08:02:35 +01:00
|
|
|
static const char *crtag(const char *key)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
static const struct locale *lang = NULL;
|
|
|
|
if (!lang)
|
|
|
|
lang = get_locale(TAG_LOCALE);
|
2015-01-08 20:55:29 +01:00
|
|
|
return LOC(lang, key);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define crtag(x) (x)
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* translation table
|
|
|
|
*/
|
|
|
|
typedef struct translation {
|
2014-08-14 09:57:05 +02:00
|
|
|
struct translation *next;
|
|
|
|
char *key;
|
|
|
|
const char *value;
|
2010-08-08 10:06:34 +02:00
|
|
|
} translation;
|
|
|
|
|
|
|
|
#define TRANSMAXHASH 257
|
2011-03-07 08:02:35 +01:00
|
|
|
static translation *translation_table[TRANSMAXHASH];
|
|
|
|
static translation *junkyard;
|
|
|
|
|
2014-06-16 19:32:23 +02:00
|
|
|
static const char *translate(const char *key, const char *value)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
int kk = ((key[0] << 5) + key[0]) % TRANSMAXHASH;
|
|
|
|
translation *t = translation_table[kk];
|
|
|
|
while (t && strcmp(t->key, key) != 0)
|
|
|
|
t = t->next;
|
|
|
|
if (!t) {
|
|
|
|
if (junkyard) {
|
|
|
|
t = junkyard;
|
|
|
|
junkyard = junkyard->next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
t = malloc(sizeof(translation));
|
2017-01-10 16:31:05 +01:00
|
|
|
t->key = strdup(key);
|
2014-08-14 09:57:05 +02:00
|
|
|
t->value = value;
|
|
|
|
t->next = translation_table[kk];
|
|
|
|
translation_table[kk] = t;
|
|
|
|
}
|
|
|
|
return crtag(key);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static void write_translations(FILE * F)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
int i;
|
|
|
|
fputs("TRANSLATION\n", F);
|
|
|
|
for (i = 0; i != TRANSMAXHASH; ++i) {
|
|
|
|
translation *t = translation_table[i];
|
|
|
|
while (t) {
|
|
|
|
fprintf(F, "\"%s\";%s\n", t->value, crtag(t->key));
|
|
|
|
t = t->next;
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static void reset_translations(void)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
int i;
|
|
|
|
for (i = 0; i != TRANSMAXHASH; ++i) {
|
|
|
|
translation *t = translation_table[i];
|
|
|
|
while (t) {
|
|
|
|
translation *c = t->next;
|
|
|
|
free(t->key);
|
|
|
|
t->next = junkyard;
|
|
|
|
junkyard = t;
|
|
|
|
t = c;
|
|
|
|
}
|
|
|
|
translation_table[i] = 0;
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#include <kernel/objtypes.h>
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static void print_items(FILE * F, item * items, const struct locale *lang)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
item *itm;
|
|
|
|
|
|
|
|
for (itm = items; itm; itm = itm->next) {
|
|
|
|
int in = itm->number;
|
|
|
|
const char *ic = resourcename(itm->type->rtype, 0);
|
|
|
|
if (itm == items)
|
|
|
|
fputs("GEGENSTAENDE\n", F);
|
|
|
|
fprintf(F, "%d;%s\n", in, translate(ic, LOC(lang, ic)));
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-11-13 19:40:38 +01:00
|
|
|
cr_output_curses(struct stream *out, const faction * viewer, const void *obj, objtype_t typ)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
bool header = false;
|
|
|
|
attrib *a = NULL;
|
|
|
|
int self = 0;
|
|
|
|
region *r;
|
|
|
|
|
|
|
|
/* Die Sichtbarkeit eines Zaubers und die Zaubermeldung sind bei
|
2016-11-01 17:25:52 +01:00
|
|
|
* Gebaeuden und Schiffen je nach, ob man Besitzer ist, verschieden.
|
2014-08-14 09:57:05 +02:00
|
|
|
* Bei Einheiten sieht man Wirkungen auf eigene Einheiten immer.
|
2016-11-01 17:25:52 +01:00
|
|
|
* Spezialfaelle (besonderes Talent, verursachender Magier usw. werde
|
2014-08-14 09:57:05 +02:00
|
|
|
* bei jedem curse gesondert behandelt. */
|
|
|
|
if (typ == TYP_SHIP) {
|
|
|
|
ship *sh = (ship *)obj;
|
|
|
|
unit *owner = ship_owner(sh);
|
|
|
|
a = sh->attribs;
|
|
|
|
r = sh->region;
|
|
|
|
if (owner != NULL) {
|
|
|
|
if (owner->faction == viewer) {
|
|
|
|
self = 2;
|
|
|
|
}
|
|
|
|
else { /* steht eine person der Partei auf dem Schiff? */
|
|
|
|
unit *u = NULL;
|
|
|
|
for (u = r->units; u; u = u->next) {
|
|
|
|
if (u->ship == sh) {
|
|
|
|
self = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
else if (typ == TYP_BUILDING) {
|
|
|
|
building *b = (building *)obj;
|
|
|
|
unit *owner = building_owner(b);
|
|
|
|
a = b->attribs;
|
|
|
|
r = b->region;
|
|
|
|
if (owner != NULL) {
|
|
|
|
if (owner->faction == viewer) {
|
|
|
|
self = 2;
|
|
|
|
}
|
|
|
|
else { /* steht eine Person der Partei in der Burg? */
|
|
|
|
unit *u = NULL;
|
|
|
|
for (u = r->units; u; u = u->next) {
|
|
|
|
if (u->building == b) {
|
|
|
|
self = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
else if (typ == TYP_UNIT) {
|
|
|
|
unit *u = (unit *)obj;
|
|
|
|
a = u->attribs;
|
|
|
|
r = u->region;
|
|
|
|
if (u->faction == viewer) {
|
|
|
|
self = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (typ == TYP_REGION) {
|
|
|
|
r = (region *)obj;
|
|
|
|
a = r->attribs;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* fehler */
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
while (a) {
|
|
|
|
if (fval(a->type, ATF_CURSE)) {
|
|
|
|
curse *c = (curse *)a->data.v;
|
|
|
|
message *msg;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-08-07 15:52:10 +02:00
|
|
|
self = curse_cansee(c, viewer, typ, obj, self);
|
2014-08-14 09:57:05 +02:00
|
|
|
msg = msg_curse(c, obj, typ, self);
|
|
|
|
|
|
|
|
if (msg) {
|
|
|
|
char buf[BUFFERSIZE];
|
|
|
|
if (!header) {
|
|
|
|
header = 1;
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "EFFECTS\n");
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
nr_render(msg, viewer->locale, buf, sizeof(buf), viewer);
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "\"%s\"\n", buf);
|
2014-08-14 09:57:05 +02:00
|
|
|
msg_release(msg);
|
|
|
|
}
|
2015-07-03 17:36:37 +02:00
|
|
|
a = a->next;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
else if (a->type == &at_effect && self) {
|
|
|
|
effect_data *data = (effect_data *)a->data.v;
|
|
|
|
if (data->value > 0) {
|
|
|
|
const char *key = resourcename(data->type->itype->rtype, 0);
|
|
|
|
if (!header) {
|
|
|
|
header = 1;
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "EFFECTS\n");
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "\"%d %s\"\n", data->value, translate(key,
|
2015-01-08 20:55:29 +01:00
|
|
|
LOC(default_locale, key)));
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
2015-07-03 17:36:37 +02:00
|
|
|
a = a->next;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
a = a->nexttype;
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-05 14:45:46 +02:00
|
|
|
static void cr_output_curses_compat(FILE *F, const faction * viewer, const void *obj, objtype_t typ) {
|
|
|
|
// TODO: eliminate this function
|
|
|
|
stream strm;
|
|
|
|
fstream_init(&strm, F);
|
|
|
|
cr_output_curses(&strm, viewer, obj, typ);
|
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_unit(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
unit *u = (unit *)var.v;
|
|
|
|
sprintf(buffer, "%d", u ? u->no : -1);
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_ship(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
ship *u = (ship *)var.v;
|
|
|
|
sprintf(buffer, "%d", u ? u->no : -1);
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_building(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
building *u = (building *)var.v;
|
|
|
|
sprintf(buffer, "%d", u ? u->no : -1);
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_faction(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
faction *f = (faction *)var.v;
|
|
|
|
sprintf(buffer, "%d", f ? f->no : -1);
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_region(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
const faction *report = (const faction *)userdata;
|
|
|
|
region *r = (region *)var.v;
|
|
|
|
if (r) {
|
|
|
|
plane *pl = rplane(r);
|
|
|
|
int nx = r->x, ny = r->y;
|
|
|
|
pnormalize(&nx, &ny, pl);
|
2015-05-19 08:02:32 +02:00
|
|
|
adjust_coordinates(report, &nx, &ny, pl);
|
2014-08-14 09:57:05 +02:00
|
|
|
sprintf(buffer, "%d %d %d", nx, ny, plane_id(pl));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_resource(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
const faction *report = (const faction *)userdata;
|
|
|
|
const resource_type *r = (const resource_type *)var.v;
|
|
|
|
if (r) {
|
|
|
|
const char *key = resourcename(r, 0);
|
|
|
|
sprintf(buffer, "\"%s\"",
|
2015-01-08 20:55:29 +01:00
|
|
|
translate(key, LOC(report->locale, key)));
|
2014-08-14 09:57:05 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_race(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
const faction *report = (const faction *)userdata;
|
|
|
|
const struct race *rc = (const race *)var.v;
|
2014-12-09 07:20:36 +01:00
|
|
|
const char *key = rc_name_s(rc, NAME_SINGULAR);
|
2014-08-14 09:57:05 +02:00
|
|
|
sprintf(buffer, "\"%s\"",
|
2015-01-08 20:55:29 +01:00
|
|
|
translate(key, LOC(report->locale, key)));
|
2014-08-14 09:57:05 +02:00
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_alliance(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
const alliance *al = (const alliance *)var.v;
|
2017-01-10 16:31:05 +01:00
|
|
|
UNUSED_ARG(userdata);
|
2014-08-14 09:57:05 +02:00
|
|
|
if (al != NULL) {
|
|
|
|
sprintf(buffer, "%d", al->id);
|
|
|
|
}
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_skill(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
const faction *report = (const faction *)userdata;
|
|
|
|
skill_t sk = (skill_t)var.i;
|
2017-01-10 16:31:05 +01:00
|
|
|
UNUSED_ARG(userdata);
|
2014-08-14 09:57:05 +02:00
|
|
|
if (sk != NOSKILL)
|
|
|
|
sprintf(buffer, "\"%s\"",
|
|
|
|
translate(mkname("skill", skillnames[sk]), skillname(sk,
|
|
|
|
report->locale)));
|
|
|
|
else
|
|
|
|
strcpy(buffer, "\"\"");
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_order(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
order *ord = (order *)var.v;
|
2017-01-10 16:31:05 +01:00
|
|
|
UNUSED_ARG(userdata);
|
2014-08-14 09:57:05 +02:00
|
|
|
if (ord != NULL) {
|
|
|
|
char cmd[ORDERSIZE];
|
|
|
|
char *wp = buffer;
|
|
|
|
const char *rp;
|
|
|
|
|
|
|
|
get_command(ord, cmd, sizeof(cmd));
|
|
|
|
|
|
|
|
*wp++ = '\"';
|
|
|
|
for (rp = cmd; *rp;) {
|
2015-11-04 14:52:10 +01:00
|
|
|
char r = *rp++;
|
|
|
|
if (r == '\"' || r == '\\') {
|
2014-08-14 09:57:05 +02:00
|
|
|
*wp++ = '\\';
|
|
|
|
}
|
2015-11-04 14:52:10 +01:00
|
|
|
*wp++ = r;
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
*wp++ = '\"';
|
|
|
|
*wp++ = 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
else
|
|
|
|
strcpy(buffer, "\"\"");
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_resources(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
faction *f = (faction *)userdata;
|
|
|
|
resource *rlist = (resource *)var.v;
|
|
|
|
char *wp = buffer;
|
|
|
|
if (rlist != NULL) {
|
|
|
|
const char *name = resourcename(rlist->type, rlist->number != 1);
|
|
|
|
wp +=
|
|
|
|
sprintf(wp, "\"%d %s", rlist->number, translate(name, LOC(f->locale,
|
|
|
|
name)));
|
|
|
|
for (;;) {
|
|
|
|
rlist = rlist->next;
|
|
|
|
if (rlist == NULL)
|
|
|
|
break;
|
|
|
|
name = resourcename(rlist->type, rlist->number != 1);
|
|
|
|
wp +=
|
|
|
|
sprintf(wp, ", %d %s", rlist->number, translate(name,
|
|
|
|
LOC(f->locale, name)));
|
|
|
|
}
|
|
|
|
strcat(wp, "\"");
|
|
|
|
}
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_regions(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
faction *f = (faction *)userdata;
|
|
|
|
const arg_regions *rdata = (const arg_regions *)var.v;
|
|
|
|
|
|
|
|
if (rdata != NULL && rdata->nregions > 0) {
|
|
|
|
region *r = rdata->regions[0];
|
|
|
|
plane *pl = rplane(r);
|
|
|
|
int i, z = plane_id(pl);
|
|
|
|
char *wp = buffer;
|
|
|
|
int nx = r->x, ny = r->y;
|
|
|
|
|
|
|
|
pnormalize(&nx, &ny, pl);
|
2015-05-19 08:02:32 +02:00
|
|
|
adjust_coordinates(f, &nx, &ny, pl);
|
2014-08-14 09:57:05 +02:00
|
|
|
wp += sprintf(wp, "\"%d %d %d", nx, ny, z);
|
|
|
|
for (i = 1; i != rdata->nregions; ++i) {
|
|
|
|
r = rdata->regions[i];
|
|
|
|
pl = rplane(r);
|
|
|
|
z = plane_id(pl);
|
|
|
|
wp += sprintf(wp, ", %d %d %d", nx, ny, z);
|
|
|
|
}
|
|
|
|
strcat(wp, "\"");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
strcpy(buffer, "\"\"");
|
|
|
|
}
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_spell(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
const faction *report = (const faction *)userdata;
|
|
|
|
spell *sp = (spell *)var.v;
|
|
|
|
if (sp != NULL)
|
|
|
|
sprintf(buffer, "\"%s\"", spell_name(sp, report->locale));
|
|
|
|
else
|
|
|
|
strcpy(buffer, "\"\"");
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static int cr_curse(variant var, char *buffer, const void *userdata)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
const faction *report = (const faction *)userdata;
|
|
|
|
const curse_type *ctype = (const curse_type *)var.v;
|
|
|
|
if (ctype != NULL) {
|
|
|
|
sprintf(buffer, "\"%s\"", curse_name(ctype, report->locale));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpy(buffer, "\"\"");
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*static int msgno; */
|
|
|
|
|
|
|
|
#define MTMAXHASH 1021
|
|
|
|
|
|
|
|
static struct known_mtype {
|
2014-08-14 09:57:05 +02:00
|
|
|
const struct message_type *mtype;
|
|
|
|
struct known_mtype *nexthash;
|
2011-03-07 08:02:35 +01:00
|
|
|
} *mtypehash[MTMAXHASH];
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static void report_crtypes(FILE * F, const struct locale *lang)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
int i;
|
|
|
|
for (i = 0; i != MTMAXHASH; ++i) {
|
|
|
|
struct known_mtype *kmt;
|
|
|
|
for (kmt = mtypehash[i]; kmt; kmt = kmt->nexthash) {
|
|
|
|
const struct nrmessage_type *nrt = nrt_find(lang, kmt->mtype);
|
|
|
|
if (nrt) {
|
2014-08-24 22:54:40 +02:00
|
|
|
char buffer[DISPLAYSIZE];
|
2014-08-14 09:57:05 +02:00
|
|
|
unsigned int hash = kmt->mtype->key;
|
|
|
|
assert(hash > 0);
|
|
|
|
fprintf(F, "MESSAGETYPE %u\n", hash);
|
|
|
|
fputc('\"', F);
|
2014-08-24 22:54:40 +02:00
|
|
|
fputs(escape_string(nrt_string(nrt), buffer, sizeof(buffer)), F);
|
2014-08-14 09:57:05 +02:00
|
|
|
fputs("\";text\n", F);
|
|
|
|
fprintf(F, "\"%s\";section\n", nrt_section(nrt));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (mtypehash[i]) {
|
|
|
|
kmt = mtypehash[i];
|
|
|
|
mtypehash[i] = mtypehash[i]->nexthash;
|
|
|
|
free(kmt);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static unsigned int messagehash(const struct message *msg)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
variant var;
|
|
|
|
var.v = (void *)msg;
|
|
|
|
return (unsigned int)var.i;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2013-12-31 10:06:28 +01:00
|
|
|
/** writes a quoted string to the file
|
|
|
|
* no trailing space, since this is used to make the creport.
|
|
|
|
*/
|
|
|
|
static int fwritestr(FILE * F, const char *str)
|
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
int nwrite = 0;
|
|
|
|
fputc('\"', F);
|
|
|
|
if (str)
|
|
|
|
while (*str) {
|
2015-01-30 20:37:14 +01:00
|
|
|
int c = (int)(unsigned char)*str++;
|
|
|
|
switch (c) {
|
|
|
|
case '"':
|
|
|
|
case '\\':
|
|
|
|
fputc('\\', F);
|
|
|
|
fputc(c, F);
|
|
|
|
nwrite += 2;
|
|
|
|
break;
|
|
|
|
case '\n':
|
|
|
|
fputc('\\', F);
|
|
|
|
fputc('n', F);
|
|
|
|
nwrite += 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fputc(c, F);
|
|
|
|
++nwrite;
|
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
fputc('\"', F);
|
|
|
|
return nwrite + 2;
|
2013-12-31 10:06:28 +01:00
|
|
|
}
|
2013-12-29 09:31:49 +01:00
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static void render_messages(FILE * F, faction * f, message_list * msgs)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
struct mlist *m = msgs->begin;
|
|
|
|
while (m) {
|
|
|
|
char crbuffer[BUFFERSIZE]; /* gross, wegen spionage-messages :-( */
|
|
|
|
bool printed = false;
|
|
|
|
const struct message_type *mtype = m->msg->type;
|
|
|
|
unsigned int hash = mtype->key;
|
2010-08-08 10:06:34 +02:00
|
|
|
#ifdef RENDER_CRMESSAGES
|
2014-08-14 09:57:05 +02:00
|
|
|
char nrbuffer[1024 * 32];
|
|
|
|
nrbuffer[0] = '\0';
|
|
|
|
if (nr_render(m->msg, f->locale, nrbuffer, sizeof(nrbuffer), f) > 0) {
|
|
|
|
fprintf(F, "MESSAGE %u\n", messagehash(m->msg));
|
|
|
|
fprintf(F, "%u;type\n", hash);
|
|
|
|
fwritestr(F, nrbuffer);
|
|
|
|
fputs(";rendered\n", F);
|
|
|
|
printed = true;
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
#endif
|
2014-08-14 09:57:05 +02:00
|
|
|
crbuffer[0] = '\0';
|
|
|
|
if (cr_render(m->msg, crbuffer, (const void *)f) == 0) {
|
|
|
|
if (crbuffer[0]) {
|
|
|
|
if (!printed) {
|
|
|
|
fprintf(F, "MESSAGE %u\n", messagehash(m->msg));
|
|
|
|
}
|
|
|
|
fputs(crbuffer, F);
|
|
|
|
}
|
2012-05-22 06:00:04 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
else {
|
|
|
|
log_error("could not render cr-message %p: %s\n", m->msg, m->msg->type->name);
|
|
|
|
}
|
|
|
|
if (printed) {
|
|
|
|
unsigned int ihash = hash % MTMAXHASH;
|
|
|
|
struct known_mtype *kmt = mtypehash[ihash];
|
|
|
|
while (kmt && kmt->mtype != mtype)
|
|
|
|
kmt = kmt->nexthash;
|
|
|
|
if (kmt == NULL) {
|
|
|
|
kmt = (struct known_mtype *)malloc(sizeof(struct known_mtype));
|
|
|
|
kmt->nexthash = mtypehash[ihash];
|
|
|
|
kmt->mtype = mtype;
|
|
|
|
mtypehash[ihash] = kmt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m = m->next;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static void cr_output_messages(FILE * F, message_list * msgs, faction * f)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
if (msgs)
|
|
|
|
render_messages(F, f, msgs);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* prints a building */
|
|
|
|
static void
|
2011-03-07 08:02:35 +01:00
|
|
|
cr_output_building(FILE * F, building * b, const unit * owner, int fno,
|
2014-08-14 09:57:05 +02:00
|
|
|
faction * f)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
const char *bname, *billusion;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "BURG %d\n", b->no);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
report_building(b, &bname, &billusion);
|
|
|
|
if (billusion) {
|
|
|
|
fprintf(F, "\"%s\";Typ\n", translate(billusion, LOC(f->locale,
|
|
|
|
billusion)));
|
|
|
|
if (owner && owner->faction == f) {
|
|
|
|
fprintf(F, "\"%s\";wahrerTyp\n", translate(bname, LOC(f->locale,
|
|
|
|
bname)));
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
else {
|
|
|
|
fprintf(F, "\"%s\";Typ\n", translate(bname, LOC(f->locale, bname)));
|
|
|
|
}
|
|
|
|
fprintf(F, "\"%s\";Name\n", b->name);
|
|
|
|
if (b->display && b->display[0])
|
|
|
|
fprintf(F, "\"%s\";Beschr\n", b->display);
|
|
|
|
if (b->size)
|
|
|
|
fprintf(F, "%d;Groesse\n", b->size);
|
2015-10-29 08:47:58 +01:00
|
|
|
if (owner) {
|
|
|
|
fprintf(F, "%d;Besitzer\n", owner->no);
|
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
if (fno >= 0)
|
|
|
|
fprintf(F, "%d;Partei\n", fno);
|
|
|
|
if (b->besieged)
|
|
|
|
fprintf(F, "%d;Belagerer\n", b->besieged);
|
2015-08-05 14:45:46 +02:00
|
|
|
cr_output_curses_compat(F, f, b, TYP_BUILDING);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2011-03-07 08:02:35 +01:00
|
|
|
|
2010-08-08 10:06:34 +02:00
|
|
|
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
|
|
|
|
|
|
|
/* prints a ship */
|
|
|
|
static void
|
2011-03-07 08:02:35 +01:00
|
|
|
cr_output_ship(FILE * F, const ship * sh, const unit * u, int fcaptain,
|
2014-08-14 09:57:05 +02:00
|
|
|
const faction * f, const region * r)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
int w = 0;
|
|
|
|
assert(sh);
|
|
|
|
fprintf(F, "SCHIFF %d\n", sh->no);
|
|
|
|
fprintf(F, "\"%s\";Name\n", sh->name);
|
|
|
|
if (sh->display && sh->display[0])
|
|
|
|
fprintf(F, "\"%s\";Beschr\n", sh->display);
|
|
|
|
fprintf(F, "\"%s\";Typ\n", translate(sh->type->_name,
|
2015-01-08 20:55:29 +01:00
|
|
|
LOC(f->locale, sh->type->_name)));
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "%d;Groesse\n", sh->size);
|
|
|
|
if (sh->damage) {
|
|
|
|
int percent =
|
|
|
|
(sh->damage * 100 + DAMAGE_SCALE - 1) / (sh->size * DAMAGE_SCALE);
|
|
|
|
fprintf(F, "%d;Schaden\n", percent);
|
|
|
|
}
|
2015-10-29 08:47:58 +01:00
|
|
|
if (u) {
|
|
|
|
fprintf(F, "%d;Kapitaen\n", u->no);
|
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
if (fcaptain >= 0)
|
|
|
|
fprintf(F, "%d;Partei\n", fcaptain);
|
|
|
|
|
|
|
|
/* calculate cargo */
|
|
|
|
if (u && (u->faction == f || omniscient(f))) {
|
|
|
|
int n = 0, p = 0;
|
|
|
|
int mweight = shipcapacity(sh);
|
|
|
|
getshipweight(sh, &n, &p);
|
|
|
|
|
|
|
|
fprintf(F, "%d;capacity\n", mweight);
|
|
|
|
fprintf(F, "%d;cargo\n", n);
|
|
|
|
fprintf(F, "%d;speed\n", shipspeed(sh, u));
|
|
|
|
}
|
|
|
|
/* shore */
|
|
|
|
w = NODIRECTION;
|
|
|
|
if (!fval(r->terrain, SEA_REGION))
|
|
|
|
w = sh->coast;
|
|
|
|
if (w != NODIRECTION)
|
|
|
|
fprintf(F, "%d;Kueste\n", w);
|
|
|
|
|
2015-08-05 14:45:46 +02:00
|
|
|
cr_output_curses_compat(F, f, sh, TYP_SHIP);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2015-08-05 14:45:46 +02:00
|
|
|
static int stream_order(stream *out, const struct order *ord) {
|
|
|
|
const char *str;
|
2014-12-12 11:28:37 +01:00
|
|
|
char ebuf[1025];
|
2014-08-14 09:57:05 +02:00
|
|
|
char obuf[1024];
|
|
|
|
write_order(ord, obuf, sizeof(obuf));
|
2015-08-05 14:45:46 +02:00
|
|
|
str = escape_string(obuf, ebuf, sizeof(ebuf));
|
|
|
|
if (str == ebuf) {
|
|
|
|
ebuf[1024] = 0;
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
2015-08-05 14:45:46 +02:00
|
|
|
return stream_printf(out, "\"%s\"\n", str);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2015-08-05 14:45:46 +02:00
|
|
|
static void cr_output_spells(stream *out, const unit * u, int maxlevel)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
spellbook * book = unit_get_spellbook(u);
|
|
|
|
|
|
|
|
if (book) {
|
|
|
|
const faction * f = u->faction;
|
2017-01-26 17:41:21 +01:00
|
|
|
selist *ql;
|
2014-08-14 09:57:05 +02:00
|
|
|
int qi, header = 0;
|
|
|
|
|
2017-01-26 17:41:21 +01:00
|
|
|
for (ql = book->spells, qi = 0; ql; selist_advance(&ql, &qi, 1)) {
|
|
|
|
spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi);
|
2014-08-14 09:57:05 +02:00
|
|
|
if (sbe->level <= maxlevel) {
|
2017-02-02 16:52:32 +01:00
|
|
|
// TODO: no need to deref spref here, spref->name == sp->sname
|
2017-02-02 20:08:04 +01:00
|
|
|
spell * sp = sbe->sp;
|
2014-08-14 09:57:05 +02:00
|
|
|
const char *name = translate(mkname("spell", sp->sname), spell_name(sp, f->locale));
|
|
|
|
if (!header) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "SPRUECHE\n");
|
2014-08-14 09:57:05 +02:00
|
|
|
header = 1;
|
|
|
|
}
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "\"%s\"\n", name);
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-05 14:45:46 +02:00
|
|
|
/** prints all that belongs to a unit
|
|
|
|
* @param f observers faction
|
|
|
|
* @param u unit to report
|
|
|
|
*/
|
|
|
|
void cr_output_unit(stream *out, const region * r, const faction * f,
|
2016-09-13 17:02:51 +02:00
|
|
|
const unit * u, seen_mode mode)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
/* Race attributes are always plural and item attributes always
|
|
|
|
* singular */
|
|
|
|
const char *str;
|
|
|
|
const item_type *lasttype;
|
|
|
|
int pr;
|
2016-08-29 20:37:47 +02:00
|
|
|
item *itm, *show = NULL;
|
2014-08-14 09:57:05 +02:00
|
|
|
building *b;
|
|
|
|
const char *pzTmp;
|
|
|
|
skill *sv;
|
|
|
|
item result[MAX_INVENTORY];
|
2015-07-06 19:53:09 +02:00
|
|
|
const faction *sf;
|
|
|
|
const char *prefix;
|
2014-08-14 09:57:05 +02:00
|
|
|
|
2015-07-07 00:49:12 +02:00
|
|
|
assert(u && u->number);
|
2015-09-06 19:04:04 +02:00
|
|
|
assert(u->region == r); // TODO: if this holds true, then why did we pass in r?
|
2015-08-05 14:45:46 +02:00
|
|
|
if (fval(u_race(u), RCF_INVISIBLE))
|
2014-08-14 09:57:05 +02:00
|
|
|
return;
|
|
|
|
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "EINHEIT %d\n", u->no);
|
|
|
|
stream_printf(out, "\"%s\";Name\n", unit_getname(u));
|
2014-08-14 09:57:05 +02:00
|
|
|
str = u_description(u, f->locale);
|
|
|
|
if (str) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "\"%s\";Beschr\n", str);
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
2015-07-06 19:53:09 +02:00
|
|
|
/* print faction information */
|
|
|
|
sf = visible_faction(f, u);
|
|
|
|
prefix = raceprefix(u);
|
|
|
|
if (u->faction == f || omniscient(f)) {
|
|
|
|
const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
|
|
|
const faction *otherfaction =
|
|
|
|
a_otherfaction ? get_otherfaction(a_otherfaction) : NULL;
|
|
|
|
/* my own faction, full info */
|
|
|
|
const attrib *a = NULL;
|
|
|
|
unit *mage;
|
|
|
|
|
|
|
|
if (fval(u, UFL_GROUP))
|
|
|
|
a = a_find(u->attribs, &at_group);
|
|
|
|
if (a != NULL) {
|
|
|
|
const group *g = (const group *)a->data.v;
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;gruppe\n", g->gid);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;Partei\n", u->faction->no);
|
2015-07-06 19:53:09 +02:00
|
|
|
if (sf != u->faction)
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;Verkleidung\n", sf->no);
|
2015-07-06 19:53:09 +02:00
|
|
|
if (fval(u, UFL_ANON_FACTION))
|
2016-11-17 21:23:49 +01:00
|
|
|
stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION)!=0);
|
2016-07-03 11:02:21 +02:00
|
|
|
if (otherfaction && otherfaction != u->faction) {
|
|
|
|
stream_printf(out, "%d;Anderepartei\n", otherfaction->no);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
mage = get_familiar_mage(u);
|
|
|
|
if (mage) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%u;familiarmage\n", mage->no);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (fval(u, UFL_ANON_FACTION)) {
|
|
|
|
/* faction info is hidden */
|
2016-11-17 21:23:49 +01:00
|
|
|
stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION) != 0);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
|
|
|
const faction *otherfaction =
|
|
|
|
a_otherfaction ? get_otherfaction(a_otherfaction) : NULL;
|
|
|
|
/* other unit. show visible faction, not u->faction */
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;Partei\n", sf->no);
|
2015-07-06 19:53:09 +02:00
|
|
|
if (sf == f) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "1;Verraeter\n");
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
2016-07-03 11:02:21 +02:00
|
|
|
if (otherfaction && otherfaction != u->faction) {
|
|
|
|
if (alliedunit(u, f, HELP_FSTEALTH)) {
|
|
|
|
stream_printf(out, "%d;Anderepartei\n", otherfaction->no);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (prefix) {
|
|
|
|
prefix = mkname("prefix", prefix);
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "\"%s\";typprefix\n", translate(prefix, LOC(f->locale,
|
2015-07-06 19:53:09 +02:00
|
|
|
prefix)));
|
|
|
|
}
|
2015-11-04 19:08:45 +01:00
|
|
|
stream_printf(out, "%d;Anzahl\n", u->number);
|
2015-07-06 19:53:09 +02:00
|
|
|
|
|
|
|
pzTmp = get_racename(u->attribs);
|
|
|
|
if (pzTmp) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "\"%s\";Typ\n", pzTmp);
|
2015-07-06 19:53:09 +02:00
|
|
|
if (u->faction == f && fval(u_race(u), RCF_SHAPESHIFTANY)) {
|
|
|
|
const char *zRace = rc_name_s(u_race(u), NAME_PLURAL);
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "\"%s\";wahrerTyp\n",
|
2015-07-06 19:53:09 +02:00
|
|
|
translate(zRace, LOC(f->locale, zRace)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const race *irace = u_irace(u);
|
|
|
|
const char *zRace = rc_name_s(irace, NAME_PLURAL);
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "\"%s\";Typ\n",
|
2015-07-06 19:53:09 +02:00
|
|
|
translate(zRace, LOC(f->locale, zRace)));
|
|
|
|
if (u->faction == f && irace != u_race(u)) {
|
|
|
|
assert(skill_enabled(SK_STEALTH)
|
|
|
|
|| !"we're resetting this on load, so.. ircase should never be used");
|
|
|
|
zRace = rc_name_s(u_race(u), NAME_PLURAL);
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "\"%s\";wahrerTyp\n",
|
2015-07-06 19:53:09 +02:00
|
|
|
translate(zRace, LOC(f->locale, zRace)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (u->building) {
|
|
|
|
assert(u->building->region);
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;Burg\n", u->building->no);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
if (u->ship) {
|
|
|
|
assert(u->ship->region);
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;Schiff\n", u->ship->no);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
2016-10-31 07:45:06 +01:00
|
|
|
if (is_guard(u)) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;bewacht\n", 1);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
if ((b = usiege(u)) != NULL) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;belagert\n", b->no);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
/* additional information for own units */
|
|
|
|
if (u->faction == f || omniscient(f)) {
|
|
|
|
order *ord;
|
|
|
|
const char *xc;
|
|
|
|
const char *c;
|
|
|
|
int i;
|
|
|
|
sc_mage *mage;
|
|
|
|
|
|
|
|
i = ualias(u);
|
|
|
|
if (i > 0)
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;temp\n", i);
|
2015-07-06 19:53:09 +02:00
|
|
|
else if (i < 0)
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;alias\n", -i);
|
2015-07-06 19:53:09 +02:00
|
|
|
i = get_money(u);
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;Kampfstatus\n", u->status);
|
|
|
|
stream_printf(out, "%d;weight\n", weight(u));
|
2015-07-06 19:53:09 +02:00
|
|
|
if (fval(u, UFL_NOAID)) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "1;unaided\n");
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
if (fval(u, UFL_STEALTH)) {
|
|
|
|
i = u_geteffstealth(u);
|
|
|
|
if (i >= 0) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;Tarnung\n", i);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
xc = uprivate(u);
|
|
|
|
if (xc) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "\"%s\";privat\n", xc);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
c = hp_status(u);
|
|
|
|
if (c && *c && (u->faction == f || omniscient(f))) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "\"%s\";hp\n", translate(c,
|
2015-07-06 19:53:09 +02:00
|
|
|
LOC(u->faction->locale, c)));
|
|
|
|
}
|
|
|
|
if (fval(u, UFL_HERO)) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "1;hero\n");
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fval(u, UFL_HUNGER) && (u->faction == f)) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "1;hunger\n");
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
if (is_mage(u)) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;Aura\n", get_spellpoints(u));
|
|
|
|
stream_printf(out, "%d;Auramax\n", max_spellpoints(u->region, u));
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
/* default commands */
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "COMMANDS\n");
|
2015-07-06 19:53:09 +02:00
|
|
|
for (ord = u->old_orders; ord; ord = ord->next) {
|
|
|
|
/* this new order will replace the old defaults */
|
|
|
|
if (is_persistent(ord)) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_order(out, ord);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (ord = u->orders; ord; ord = ord->next) {
|
2015-08-04 22:47:55 +02:00
|
|
|
keyword_t kwd = getkeyword(ord);
|
|
|
|
if (u->old_orders && is_repeated(kwd))
|
2015-07-06 19:53:09 +02:00
|
|
|
continue; /* unit has defaults */
|
|
|
|
if (is_persistent(ord)) {
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_order(out, ord);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* talents */
|
|
|
|
pr = 0;
|
|
|
|
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
|
|
|
|
if (sv->level > 0) {
|
2015-09-06 19:04:04 +02:00
|
|
|
skill_t sk = sv->id;
|
|
|
|
int esk = effskill(u, sk, 0);
|
2015-07-06 19:53:09 +02:00
|
|
|
if (!pr) {
|
|
|
|
pr = 1;
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "TALENTE\n");
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d %d;%s\n", u->number * level_days(sv->level), esk,
|
2015-09-06 19:04:04 +02:00
|
|
|
translate(mkname("skill", skillnames[sk]), skillname(sk,
|
2015-07-06 19:53:09 +02:00
|
|
|
f->locale)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* spells that this unit can cast */
|
|
|
|
mage = get_mage(u);
|
|
|
|
if (mage) {
|
2015-08-27 16:16:55 +02:00
|
|
|
int i, maxlevel = effskill(u, SK_MAGIC, 0);
|
2015-08-05 14:45:46 +02:00
|
|
|
cr_output_spells(out, u, maxlevel);
|
2015-07-06 19:53:09 +02:00
|
|
|
|
|
|
|
for (i = 0; i != MAXCOMBATSPELLS; ++i) {
|
|
|
|
const spell *sp = mage->combatspells[i].sp;
|
|
|
|
if (sp) {
|
|
|
|
const char *name =
|
|
|
|
translate(mkname("spell", sp->sname), spell_name(sp,
|
|
|
|
f->locale));
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "KAMPFZAUBER %d\n", i);
|
|
|
|
stream_printf(out, "\"%s\";name\n", name);
|
|
|
|
stream_printf(out, "%d;level\n", mage->combatspells[i].level);
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* items */
|
|
|
|
pr = 0;
|
|
|
|
if (f == u->faction || omniscient(f)) {
|
|
|
|
show = u->items;
|
|
|
|
}
|
|
|
|
else {
|
2016-09-13 15:30:09 +02:00
|
|
|
if (mode >= seen_unit) {
|
2016-08-29 20:37:47 +02:00
|
|
|
int n = report_items(u, result, MAX_INVENTORY, u, f);
|
|
|
|
assert(n >= 0);
|
|
|
|
if (n > 0) {
|
|
|
|
show = result;
|
|
|
|
}
|
|
|
|
}
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
lasttype = NULL;
|
|
|
|
for (itm = show; itm; itm = itm->next) {
|
|
|
|
const char *ic;
|
|
|
|
int in;
|
|
|
|
assert(itm->type != lasttype
|
|
|
|
|| !"error: list contains two objects of the same item");
|
|
|
|
report_item(u, itm, f, NULL, &ic, &in, true);
|
|
|
|
if (in == 0)
|
|
|
|
continue;
|
|
|
|
if (!pr) {
|
|
|
|
pr = 1;
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "GEGENSTAENDE\n");
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
2015-08-05 14:45:46 +02:00
|
|
|
stream_printf(out, "%d;%s\n", in, translate(ic, LOC(f->locale, ic)));
|
2015-07-06 19:53:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-05 14:45:46 +02:00
|
|
|
cr_output_curses(out, f, u, TYP_UNIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cr_output_unit_compat(FILE * F, const region * r, const faction * f,
|
|
|
|
const unit * u, int mode)
|
|
|
|
{
|
|
|
|
// TODO: eliminate this function
|
|
|
|
stream strm;
|
|
|
|
fstream_init(&strm, F);
|
|
|
|
cr_output_unit(&strm, r, f, u, mode);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2011-03-07 08:02:35 +01:00
|
|
|
|
2010-08-08 10:06:34 +02:00
|
|
|
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
|
|
|
|
|
|
|
/* prints allies */
|
2011-03-07 08:02:35 +01:00
|
|
|
static void show_allies_cr(FILE * F, const faction * f, const ally * sf)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
for (; sf; sf = sf->next)
|
|
|
|
if (sf->faction) {
|
2015-01-30 20:37:14 +01:00
|
|
|
int mode = alliedgroup(NULL, f, sf->faction, sf, HELP_ALL);
|
|
|
|
if (mode != 0 && sf->status > 0) {
|
|
|
|
fprintf(F, "ALLIANZ %d\n", sf->faction->no);
|
|
|
|
fprintf(F, "\"%s\";Parteiname\n", sf->faction->name);
|
|
|
|
fprintf(F, "%d;Status\n", sf->status & HELP_ALL);
|
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* prints allies */
|
2011-03-07 08:02:35 +01:00
|
|
|
static void show_alliances_cr(FILE * F, const faction * f)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
alliance *al = f_get_alliance(f);
|
|
|
|
if (al) {
|
|
|
|
faction *lead = alliance_get_leader(al);
|
|
|
|
assert(lead);
|
|
|
|
fprintf(F, "ALLIANCE %d\n", al->id);
|
|
|
|
fprintf(F, "\"%s\";name\n", al->name);
|
|
|
|
fprintf(F, "%d;leader\n", lead->no);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
|
|
|
|
|
|
|
/* this is a copy of laws.c->find_address output changed. */
|
2017-01-26 17:41:21 +01:00
|
|
|
static void cr_find_address(FILE * F, const faction * uf, selist * addresses)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
int i = 0;
|
2017-01-26 17:41:21 +01:00
|
|
|
selist *flist = addresses;
|
2014-08-14 09:57:05 +02:00
|
|
|
while (flist) {
|
2017-01-26 17:41:21 +01:00
|
|
|
const faction *f = (const faction *)selist_get(flist, i);
|
2014-08-14 09:57:05 +02:00
|
|
|
if (uf != f) {
|
|
|
|
fprintf(F, "PARTEI %d\n", f->no);
|
|
|
|
fprintf(F, "\"%s\";Parteiname\n", f->name);
|
|
|
|
if (f->email)
|
|
|
|
fprintf(F, "\"%s\";email\n", f->email);
|
|
|
|
if (f->banner)
|
|
|
|
fprintf(F, "\"%s\";banner\n", f->banner);
|
|
|
|
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
|
|
|
|
if (f->alliance && f->alliance == uf->alliance) {
|
|
|
|
fprintf(F, "%d;alliance\n", f->alliance->id);
|
|
|
|
}
|
|
|
|
}
|
2017-01-26 17:41:21 +01:00
|
|
|
selist_advance(&flist, &i, 1);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
2011-03-07 08:02:35 +01:00
|
|
|
|
2010-08-08 10:06:34 +02:00
|
|
|
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
|
|
|
|
2012-05-25 07:10:18 +02:00
|
|
|
static void cr_reportspell(FILE * F, spell * sp, int level, const struct locale *lang)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
int k;
|
|
|
|
const char *name =
|
|
|
|
translate(mkname("spell", sp->sname), spell_name(sp, lang));
|
|
|
|
|
|
|
|
fprintf(F, "ZAUBER %d\n", hashstring(sp->sname));
|
|
|
|
fprintf(F, "\"%s\";name\n", name);
|
|
|
|
fprintf(F, "%d;level\n", level);
|
|
|
|
fprintf(F, "%d;rank\n", sp->rank);
|
|
|
|
fprintf(F, "\"%s\";info\n", spell_info(sp, lang));
|
|
|
|
if (sp->parameter)
|
|
|
|
fprintf(F, "\"%s\";syntax\n", sp->parameter);
|
|
|
|
else
|
|
|
|
fputs("\"\";syntax\n", F);
|
|
|
|
|
|
|
|
if (sp->sptyp & PRECOMBATSPELL)
|
|
|
|
fputs("\"precombat\";class\n", F);
|
|
|
|
else if (sp->sptyp & COMBATSPELL)
|
|
|
|
fputs("\"combat\";class\n", F);
|
|
|
|
else if (sp->sptyp & POSTCOMBATSPELL)
|
|
|
|
fputs("\"postcombat\";class\n", F);
|
|
|
|
else
|
|
|
|
fputs("\"normal\";class\n", F);
|
|
|
|
|
|
|
|
if (sp->sptyp & FARCASTING)
|
|
|
|
fputs("1;far\n", F);
|
|
|
|
if (sp->sptyp & OCEANCASTABLE)
|
|
|
|
fputs("1;ocean\n", F);
|
|
|
|
if (sp->sptyp & ONSHIPCAST)
|
|
|
|
fputs("1;ship\n", F);
|
|
|
|
if (!(sp->sptyp & NOTFAMILIARCAST))
|
|
|
|
fputs("1;familiar\n", F);
|
|
|
|
fputs("KOMPONENTEN\n", F);
|
|
|
|
|
|
|
|
for (k = 0; sp->components[k].type; ++k) {
|
|
|
|
const resource_type *rtype = sp->components[k].type;
|
|
|
|
int itemanz = sp->components[k].amount;
|
|
|
|
int costtyp = sp->components[k].cost;
|
|
|
|
if (itemanz > 0) {
|
|
|
|
const char *name = resourcename(rtype, 0);
|
|
|
|
fprintf(F, "%d %d;%s\n", itemanz, costtyp == SPC_LEVEL
|
|
|
|
|| costtyp == SPC_LINEAR, translate(name, LOC(lang, name)));
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static char *cr_output_resource(char *buf, const char *name,
|
2014-08-14 09:57:05 +02:00
|
|
|
const struct locale *loc, int amount, int level)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
buf += sprintf(buf, "RESOURCE %u\n", hashstring(name));
|
|
|
|
buf += sprintf(buf, "\"%s\";type\n", translate(name, LOC(loc, name)));
|
|
|
|
if (amount >= 0) {
|
|
|
|
if (level >= 0)
|
|
|
|
buf += sprintf(buf, "%d;skill\n", level);
|
|
|
|
buf += sprintf(buf, "%d;number\n", amount);
|
|
|
|
}
|
|
|
|
return buf;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-09-13 15:30:09 +02:00
|
|
|
cr_borders(const region * r, const faction * f, seen_mode mode, FILE * F)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
direction_t d;
|
|
|
|
int g = 0;
|
|
|
|
for (d = 0; d != MAXDIRECTIONS; d++) { /* Nachbarregionen, die gesehen werden, ermitteln */
|
|
|
|
const region *r2 = rconnect(r, d);
|
|
|
|
const connection *b;
|
|
|
|
if (!r2)
|
|
|
|
continue;
|
2016-09-13 15:30:09 +02:00
|
|
|
if (mode == seen_neighbour) {
|
|
|
|
if (r2->seen.mode <= seen_neighbour)
|
2014-08-14 09:57:05 +02:00
|
|
|
continue;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
b = get_borders(r, r2);
|
|
|
|
while (b) {
|
|
|
|
bool cs = b->type->fvisible(b, f, r);
|
|
|
|
|
|
|
|
if (!cs) {
|
|
|
|
cs = b->type->rvisible(b, r);
|
|
|
|
if (!cs) {
|
|
|
|
unit *us = r->units;
|
|
|
|
while (us && !cs) {
|
|
|
|
if (us->faction == f) {
|
|
|
|
cs = b->type->uvisible(b, us);
|
|
|
|
if (cs)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
us = us->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cs) {
|
2016-08-06 14:36:54 +02:00
|
|
|
const char *bname = border_name(b, r, f, GF_PURE);
|
|
|
|
bname = mkname("border", bname);
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "GRENZE %d\n", ++g);
|
|
|
|
fprintf(F, "\"%s\";typ\n", LOC(default_locale, bname));
|
|
|
|
fprintf(F, "%d;richtung\n", d);
|
|
|
|
if (!b->type->transparent(b, f))
|
|
|
|
fputs("1;opaque\n", F);
|
|
|
|
/* hack: */
|
|
|
|
if (b->type == &bt_road && r->terrain->max_road) {
|
|
|
|
int p = rroad(r, d) * 100 / r->terrain->max_road;
|
|
|
|
fprintf(F, "%d;prozent\n", p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = b->next;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-09-13 15:30:09 +02:00
|
|
|
cr_output_resources(FILE * F, report_context * ctx, region *r, bool see_unit)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
char cbuf[BUFFERSIZE], *pos = cbuf;
|
|
|
|
faction *f = ctx->f;
|
|
|
|
resource_report result[MAX_RAWMATERIALS];
|
2016-09-13 15:30:09 +02:00
|
|
|
int n, size = report_resources(r, result, MAX_RAWMATERIALS, f, see_unit);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
#ifdef RESOURCECOMPAT
|
2014-08-14 09:57:05 +02:00
|
|
|
int trees = rtrees(r, 2);
|
|
|
|
int saplings = rtrees(r, 1);
|
|
|
|
|
|
|
|
if (trees > 0)
|
|
|
|
fprintf(F, "%d;Baeume\n", trees);
|
|
|
|
if (saplings > 0)
|
|
|
|
fprintf(F, "%d;Schoesslinge\n", saplings);
|
|
|
|
if (fval(r, RF_MALLORN) && (trees > 0 || saplings > 0))
|
|
|
|
fprintf(F, "1;Mallorn\n");
|
|
|
|
for (n = 0; n < size; ++n) {
|
|
|
|
if (result[n].level >= 0 && result[n].number >= 0) {
|
|
|
|
fprintf(F, "%d;%s\n", result[n].number, crtag(result[n].name));
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
for (n = 0; n < size; ++n) {
|
|
|
|
if (result[n].number >= 0) {
|
|
|
|
pos =
|
|
|
|
cr_output_resource(pos, result[n].name, f->locale, result[n].number,
|
|
|
|
result[n].level);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
if (pos != cbuf)
|
|
|
|
fputs(cbuf, F);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-05-15 11:20:37 +02:00
|
|
|
cr_region_header(FILE * F, int plid, int nx, int ny, int uid)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
if (plid == 0) {
|
|
|
|
fprintf(F, "REGION %d %d\n", nx, ny);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(F, "REGION %d %d %d\n", nx, ny, plid);
|
|
|
|
}
|
|
|
|
if (uid)
|
|
|
|
fprintf(F, "%d;id\n", uid);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2015-08-19 14:37:51 +02:00
|
|
|
typedef struct travel_data {
|
|
|
|
const faction *f;
|
|
|
|
FILE *file;
|
|
|
|
int n;
|
|
|
|
} travel_data;
|
|
|
|
|
2015-08-19 14:50:19 +02:00
|
|
|
static void cb_cr_travelthru_ship(region *r, unit *u, void *cbdata) {
|
2015-08-19 14:37:51 +02:00
|
|
|
travel_data *data = (travel_data *)cbdata;
|
|
|
|
const faction *f = data->f;
|
|
|
|
FILE *F = data->file;
|
|
|
|
|
|
|
|
if (u->ship && travelthru_cansee(r, f, u)) {
|
|
|
|
if (data->n++ == 0) {
|
|
|
|
fprintf(F, "DURCHSCHIFFUNG\n");
|
|
|
|
}
|
|
|
|
fprintf(F, "\"%s\"\n", shipname(u->ship));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-19 14:50:19 +02:00
|
|
|
static void cb_cr_travelthru_unit(region *r, unit *u, void *cbdata) {
|
2015-08-19 14:37:51 +02:00
|
|
|
travel_data *data = (travel_data *)cbdata;
|
|
|
|
const faction *f = data->f;
|
|
|
|
FILE *F = data->file;
|
|
|
|
|
|
|
|
if (!u->ship && travelthru_cansee(r, f, u)) {
|
|
|
|
if (data->n++ == 0) {
|
|
|
|
fprintf(F, "DURCHREISE\n");
|
|
|
|
}
|
|
|
|
fprintf(F, "\"%s\"\n", unitname(u));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cr_output_travelthru(FILE *F, region *r, const faction *f) {
|
|
|
|
/* describe both passed and inhabited regions */
|
|
|
|
travel_data cbdata = { 0 };
|
|
|
|
cbdata.f = f;
|
|
|
|
cbdata.file = F;
|
|
|
|
cbdata.n = 0;
|
|
|
|
travelthru_map(r, cb_cr_travelthru_ship, &cbdata);
|
|
|
|
cbdata.n = 0;
|
|
|
|
travelthru_map(r, cb_cr_travelthru_unit, &cbdata);
|
|
|
|
}
|
|
|
|
|
2016-09-13 15:30:09 +02:00
|
|
|
static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
faction *f = ctx->f;
|
|
|
|
plane *pl = rplane(r);
|
|
|
|
int plid = plane_id(pl), nx, ny;
|
|
|
|
const char *tname;
|
|
|
|
int oc[4][2], o = 0;
|
|
|
|
int uid = r->uid;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
#ifdef OCEAN_NEIGHBORS_GET_NO_ID
|
2016-09-13 15:30:09 +02:00
|
|
|
if (r->seen.mode <= seen_neighbour && !r->land) {
|
2014-08-14 09:57:05 +02:00
|
|
|
uid = 0;
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
#endif
|
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
if (opt_cr_absolute_coords) {
|
|
|
|
nx = r->x;
|
|
|
|
ny = r->y;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
else {
|
|
|
|
nx = r->x, ny = r->y;
|
|
|
|
pnormalize(&nx, &ny, pl);
|
2015-05-19 08:02:32 +02:00
|
|
|
adjust_coordinates(f, &nx, &ny, pl);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
|
|
|
|
if (pl) {
|
|
|
|
if (ny == pl->maxy) {
|
|
|
|
oc[o][0] = nx;
|
|
|
|
oc[o++][1] = pl->miny - 1;
|
|
|
|
}
|
|
|
|
if (nx == pl->maxx) {
|
|
|
|
oc[o][0] = pl->minx - 1;
|
|
|
|
oc[o++][1] = ny;
|
|
|
|
}
|
|
|
|
if (ny == pl->miny) {
|
|
|
|
oc[o][0] = nx;
|
|
|
|
oc[o++][1] = pl->maxy + 1;
|
|
|
|
}
|
|
|
|
if (nx == pl->minx) {
|
|
|
|
oc[o][0] = pl->maxx + 1;
|
|
|
|
oc[o++][1] = ny;
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
while (o--) {
|
|
|
|
cr_region_header(F, plid, oc[o][0], oc[o][1], uid);
|
|
|
|
fputs("\"wrap\";visibility\n", F);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
cr_region_header(F, plid, nx, ny, uid);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
if (r->land) {
|
|
|
|
const char *str = rname(r, f->locale);
|
|
|
|
if (str && str[0]) {
|
|
|
|
fprintf(F, "\"%s\";Name\n", str);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
tname = terrain_name(r);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-08 20:55:29 +01:00
|
|
|
fprintf(F, "\"%s\";Terrain\n", translate(tname, LOC(f->locale, tname)));
|
2016-09-13 15:30:09 +02:00
|
|
|
if (r->seen.mode != seen_unit)
|
|
|
|
fprintf(F, "\"%s\";visibility\n", visibility[r->seen.mode]);
|
|
|
|
if (r->seen.mode == seen_neighbour) {
|
|
|
|
cr_borders(r, f, r->seen.mode, F);
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
building *b;
|
|
|
|
ship *sh;
|
|
|
|
unit *u;
|
2016-09-13 15:30:09 +02:00
|
|
|
int stealthmod = stealth_modifier(r->seen.mode);
|
2014-08-14 09:57:05 +02:00
|
|
|
|
|
|
|
if (r->display && r->display[0])
|
|
|
|
fprintf(F, "\"%s\";Beschr\n", r->display);
|
|
|
|
if (fval(r->terrain, LAND_REGION)) {
|
2015-07-06 19:53:09 +02:00
|
|
|
assert(r->land);
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "%d;Bauern\n", rpeasants(r));
|
|
|
|
fprintf(F, "%d;Pferde\n", rhorses(r));
|
|
|
|
|
2016-09-13 15:30:09 +02:00
|
|
|
if (r->seen.mode >= seen_unit) {
|
2014-08-14 09:57:05 +02:00
|
|
|
if (rule_region_owners()) {
|
|
|
|
faction *owner = region_get_owner(r);
|
|
|
|
if (owner) {
|
|
|
|
fprintf(F, "%d;owner\n", owner->no);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf(F, "%d;Silber\n", rmoney(r));
|
|
|
|
if (skill_enabled(SK_ENTERTAINMENT)) {
|
|
|
|
fprintf(F, "%d;Unterh\n", entertainmoney(r));
|
|
|
|
}
|
|
|
|
if (is_cursed(r->attribs, C_RIOT, 0)) {
|
|
|
|
fputs("0;Rekruten\n", F);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(F, "%d;Rekruten\n", rpeasants(r) / RECRUITFRACTION);
|
|
|
|
}
|
|
|
|
if (production(r)) {
|
|
|
|
int p_wage = wage(r, NULL, NULL, turn + 1);
|
|
|
|
fprintf(F, "%d;Lohn\n", p_wage);
|
|
|
|
if (is_mourning(r, turn + 1)) {
|
|
|
|
fputs("1;mourning\n", F);
|
|
|
|
}
|
|
|
|
}
|
2015-07-06 19:53:09 +02:00
|
|
|
if (r->land && r->land->ownership) {
|
2015-12-07 17:59:50 +01:00
|
|
|
fprintf(F, "%d;morale\n", region_get_morale(r));
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
/* this writes both some tags (RESOURCECOMPAT) and a block.
|
|
|
|
* must not write any blocks before it */
|
2016-09-13 15:30:09 +02:00
|
|
|
cr_output_resources(F, ctx, r, r->seen.mode >= seen_unit);
|
2014-08-14 09:57:05 +02:00
|
|
|
|
2016-09-13 15:30:09 +02:00
|
|
|
if (r->seen.mode >= seen_unit) {
|
2014-08-14 09:57:05 +02:00
|
|
|
/* trade */
|
|
|
|
if (markets_module() && r->land) {
|
|
|
|
const item_type *lux = r_luxury(r);
|
|
|
|
const item_type *herb = r->land->herbtype;
|
|
|
|
if (lux || herb) {
|
|
|
|
fputs("PREISE\n", F);
|
|
|
|
if (lux) {
|
|
|
|
const char *ch = resourcename(lux->rtype, 0);
|
|
|
|
fprintf(F, "%d;%s\n", 1, translate(ch,
|
2015-01-08 20:55:29 +01:00
|
|
|
LOC(f->locale, ch)));
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
if (herb) {
|
|
|
|
const char *ch = resourcename(herb->rtype, 0);
|
|
|
|
fprintf(F, "%d;%s\n", 1, translate(ch,
|
2015-01-08 20:55:29 +01:00
|
|
|
LOC(f->locale, ch)));
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (rpeasants(r) / TRADE_FRACTION > 0) {
|
|
|
|
struct demand *dmd = r->land->demands;
|
|
|
|
fputs("PREISE\n", F);
|
|
|
|
while (dmd) {
|
|
|
|
const char *ch = resourcename(dmd->type->itype->rtype, 0);
|
|
|
|
fprintf(F, "%d;%s\n", (dmd->value
|
|
|
|
? dmd->value * dmd->type->price
|
|
|
|
: -dmd->type->price),
|
2015-01-08 20:55:29 +01:00
|
|
|
translate(ch, LOC(f->locale, ch)));
|
2014-08-14 09:57:05 +02:00
|
|
|
dmd = dmd->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
if (r->land) {
|
|
|
|
print_items(F, r->land->items, f->locale);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2015-08-05 14:45:46 +02:00
|
|
|
cr_output_curses_compat(F, f, r, TYP_REGION);
|
2016-09-13 15:30:09 +02:00
|
|
|
cr_borders(r, f, r->seen.mode, F);
|
|
|
|
if (r->seen.mode == seen_unit && is_astral(r)
|
2014-08-14 09:57:05 +02:00
|
|
|
&& !is_cursed(r->attribs, C_ASTRALBLOCK, 0)) {
|
|
|
|
/* Sonderbehandlung Teleport-Ebene */
|
|
|
|
region_list *rl = astralregions(r, inhabitable);
|
|
|
|
|
|
|
|
if (rl) {
|
|
|
|
region_list *rl2 = rl;
|
|
|
|
while (rl2) {
|
|
|
|
region *r = rl2->data;
|
|
|
|
int nx = r->x, ny = r->y;
|
|
|
|
plane *plx = rplane(r);
|
|
|
|
|
|
|
|
pnormalize(&nx, &ny, plx);
|
2015-05-19 08:02:32 +02:00
|
|
|
adjust_coordinates(f, &nx, &ny, plx);
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "SCHEMEN %d %d\n", nx, ny);
|
|
|
|
fprintf(F, "\"%s\";Name\n", rname(r, f->locale));
|
|
|
|
rl2 = rl2->next;
|
|
|
|
}
|
|
|
|
free_regionlist(rl);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2015-08-19 14:37:51 +02:00
|
|
|
cr_output_travelthru(F, r, f);
|
2016-09-13 15:30:09 +02:00
|
|
|
if (r->seen.mode == seen_unit || r->seen.mode == seen_travel) {
|
2015-08-16 11:30:44 +02:00
|
|
|
message_list *mlist = r_getmessages(r, f);
|
2015-06-26 14:31:21 +02:00
|
|
|
cr_output_messages(F, r->msgs, f);
|
2015-08-16 11:30:44 +02:00
|
|
|
if (mlist) {
|
|
|
|
cr_output_messages(F, mlist, f);
|
2015-06-26 14:31:21 +02:00
|
|
|
}
|
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
/* buildings */
|
|
|
|
for (b = rbuildings(r); b; b = b->next) {
|
|
|
|
int fno = -1;
|
|
|
|
u = building_owner(b);
|
|
|
|
if (u && !fval(u, UFL_ANON_FACTION)) {
|
|
|
|
const faction *sf = visible_faction(f, u);
|
|
|
|
fno = sf->no;
|
2012-05-18 01:40:50 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
cr_output_building(F, b, u, fno, f);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
/* ships */
|
|
|
|
for (sh = r->ships; sh; sh = sh->next) {
|
|
|
|
int fno = -1;
|
|
|
|
u = ship_owner(sh);
|
|
|
|
if (u && !fval(u, UFL_ANON_FACTION)) {
|
|
|
|
const faction *sf = visible_faction(f, u);
|
|
|
|
fno = sf->no;
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
cr_output_ship(F, sh, u, fno, f, r);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
/* visible units */
|
|
|
|
for (u = r->units; u; u = u->next) {
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
if (u->building || u->ship || (stealthmod > INT_MIN
|
|
|
|
&& cansee(f, r, u, stealthmod))) {
|
2016-09-13 15:30:09 +02:00
|
|
|
cr_output_unit_compat(F, r, f, u, r->seen.mode);
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* main function of the creport. creates the header and traverses all regions */
|
|
|
|
static int
|
2016-11-25 20:15:11 +01:00
|
|
|
report_computer(const char *filename, report_context * ctx, const char *bom)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
static int era = -1;
|
|
|
|
int i;
|
|
|
|
faction *f = ctx->f;
|
|
|
|
const char *prefix;
|
|
|
|
region *r;
|
2017-01-22 04:46:36 +01:00
|
|
|
const char *mailto = config_get("game.email");
|
2014-08-14 09:57:05 +02:00
|
|
|
const attrib *a;
|
2016-02-05 23:10:05 +01:00
|
|
|
FILE *F = fopen(filename, "w");
|
2016-09-20 20:27:41 +02:00
|
|
|
static const race *rc_human;
|
|
|
|
static int rc_cache;
|
2011-03-07 08:02:35 +01:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
if (era < 0) {
|
2015-11-22 10:44:46 +01:00
|
|
|
era = config_get_int("world.era", 1);
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
if (F == NULL) {
|
|
|
|
perror(filename);
|
|
|
|
return -1;
|
|
|
|
}
|
2016-11-25 20:15:11 +01:00
|
|
|
else if (bom) {
|
|
|
|
fwrite(bom, 1, strlen(bom), F);
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
/* must call this to get all the neighbour regions */
|
|
|
|
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
|
|
|
/* initialisations, header and lists */
|
|
|
|
|
|
|
|
fprintf(F, "VERSION %d\n", C_REPORT_VERSION);
|
2016-12-05 07:54:43 +01:00
|
|
|
fprintf(F, "\"UTF-8\";charset\n\"%s\";locale\n",
|
2016-11-25 20:15:11 +01:00
|
|
|
locale_name(f->locale));
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "%d;noskillpoints\n", 1);
|
2015-09-26 14:01:01 +02:00
|
|
|
fprintf(F, "%lld;date\n", (long long)ctx->report_time);
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "\"%s\";Spiel\n", game_name());
|
|
|
|
fprintf(F, "\"%s\";Konfiguration\n", "Standard");
|
|
|
|
fprintf(F, "\"%s\";Koordinaten\n", "Hex");
|
2014-12-19 19:57:24 +01:00
|
|
|
fprintf(F, "%d;max_units\n", rule_faction_limit());
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "%d;Basis\n", 36);
|
|
|
|
fprintf(F, "%d;Runde\n", turn);
|
|
|
|
fprintf(F, "%d;Zeitalter\n", era);
|
2016-09-15 20:11:38 +02:00
|
|
|
fprintf(F, "\"%s\";Build\n", eressea_version());
|
2014-08-14 09:57:05 +02:00
|
|
|
if (mailto != NULL) {
|
2017-01-22 20:19:32 +01:00
|
|
|
const char * mailcmd = get_mailcmd(f->locale);
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "\"%s\";mailto\n", mailto);
|
2017-01-22 04:46:36 +01:00
|
|
|
fprintf(F, "\"%s\";mailcmd\n", mailcmd);
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
show_alliances_cr(F, f);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "PARTEI %d\n", f->no);
|
|
|
|
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
|
|
|
|
if (f_get_alliance(f)) {
|
|
|
|
fprintf(F, "%d;alliance\n", f->alliance->id);
|
|
|
|
fprintf(F, "%d;joined\n", f->alliance_joindate);
|
|
|
|
}
|
|
|
|
fprintf(F, "%d;age\n", f->age);
|
|
|
|
fprintf(F, "%d;Optionen\n", f->options);
|
|
|
|
if (f->options & want(O_SCORE) && f->age > DISPLAYSCORE) {
|
2015-09-06 19:04:04 +02:00
|
|
|
char score[32];
|
|
|
|
write_score(score, sizeof(score), f->score);
|
|
|
|
fprintf(F, "%s;Punkte\n", score);
|
|
|
|
write_score(score, sizeof(score), average_score_of_age(f->age, f->age / 24 + 1));
|
|
|
|
fprintf(F, "%s;Punktedurchschnitt\n", score);
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
{
|
2014-12-09 07:20:36 +01:00
|
|
|
const char *zRace = rc_name_s(f->race, NAME_PLURAL);
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "\"%s\";Typ\n", translate(zRace, LOC(f->locale, zRace)));
|
|
|
|
}
|
|
|
|
prefix = get_prefix(f->attribs);
|
|
|
|
if (prefix != NULL) {
|
|
|
|
prefix = mkname("prefix", prefix);
|
|
|
|
fprintf(F, "\"%s\";typprefix\n",
|
|
|
|
translate(prefix, LOC(f->locale, prefix)));
|
|
|
|
}
|
|
|
|
fprintf(F, "%d;Rekrutierungskosten\n", f->race->recruitcost);
|
|
|
|
fprintf(F, "%d;Anzahl Personen\n", count_all(f));
|
|
|
|
fprintf(F, "\"%s\";Magiegebiet\n", magic_school[f->magiegebiet]);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2016-09-20 20:27:41 +02:00
|
|
|
if (rc_changed(&rc_cache)) {
|
|
|
|
rc_human = rc_find("human");
|
|
|
|
}
|
|
|
|
if (f->race == rc_human) {
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "%d;Anzahl Immigranten\n", count_migrants(f));
|
|
|
|
fprintf(F, "%d;Max. Immigranten\n", count_maxmigrants(f));
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
i = countheroes(f);
|
|
|
|
if (i > 0)
|
|
|
|
fprintf(F, "%d;heroes\n", i);
|
|
|
|
i = maxheroes(f);
|
|
|
|
if (i > 0)
|
|
|
|
fprintf(F, "%d;max_heroes\n", i);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
if (f->age > 1 && f->lastorders != turn) {
|
|
|
|
fprintf(F, "%d;nmr\n", turn - f->lastorders);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "\"%s\";Parteiname\n", f->name);
|
|
|
|
fprintf(F, "\"%s\";email\n", f->email);
|
|
|
|
if (f->banner)
|
|
|
|
fprintf(F, "\"%s\";banner\n", f->banner);
|
|
|
|
print_items(F, f->items, f->locale);
|
|
|
|
fputs("OPTIONEN\n", F);
|
|
|
|
for (i = 0; i != MAXOPTIONS; ++i) {
|
|
|
|
int flag = want(i);
|
|
|
|
if (options[i]) {
|
|
|
|
fprintf(F, "%d;%s\n", (f->options & flag) ? 1 : 0, options[i]);
|
|
|
|
}
|
|
|
|
else if (f->options & flag) {
|
|
|
|
f->options &= (~flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
show_allies_cr(F, f, f->allies);
|
|
|
|
{
|
|
|
|
group *g;
|
|
|
|
for (g = f->groups; g; g = g->next) {
|
|
|
|
|
|
|
|
fprintf(F, "GRUPPE %d\n", g->gid);
|
|
|
|
fprintf(F, "\"%s\";name\n", g->name);
|
|
|
|
prefix = get_prefix(g->attribs);
|
|
|
|
if (prefix != NULL) {
|
|
|
|
prefix = mkname("prefix", prefix);
|
|
|
|
fprintf(F, "\"%s\";typprefix\n",
|
|
|
|
translate(prefix, LOC(f->locale, prefix)));
|
|
|
|
}
|
|
|
|
show_allies_cr(F, f, g->allies);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
cr_output_messages(F, f->msgs, f);
|
|
|
|
{
|
|
|
|
struct bmsg *bm;
|
|
|
|
for (bm = f->battles; bm; bm = bm->next) {
|
|
|
|
plane *pl = rplane(bm->r);
|
|
|
|
int plid = plane_id(pl);
|
|
|
|
region *r = bm->r;
|
|
|
|
int nx = r->x, ny = r->y;
|
|
|
|
|
|
|
|
pnormalize(&nx, &ny, pl);
|
2015-05-19 08:02:32 +02:00
|
|
|
adjust_coordinates(f, &nx, &ny, pl);
|
2014-08-14 09:57:05 +02:00
|
|
|
if (!plid)
|
|
|
|
fprintf(F, "BATTLE %d %d\n", nx, ny);
|
|
|
|
else {
|
|
|
|
fprintf(F, "BATTLE %d %d %d\n", nx, ny, plid);
|
|
|
|
}
|
|
|
|
cr_output_messages(F, bm->msgs, f);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
cr_find_address(F, f, ctx->addresses);
|
|
|
|
a = a_find(f->attribs, &at_reportspell);
|
|
|
|
while (a && a->type == &at_reportspell) {
|
|
|
|
spellbook_entry *sbe = (spellbook_entry *)a->data.v;
|
2017-02-02 20:08:04 +01:00
|
|
|
cr_reportspell(F, sbe->sp, sbe->level, f->locale);
|
2014-08-14 09:57:05 +02:00
|
|
|
a = a->next;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
for (a = a_find(f->attribs, &at_showitem); a && a->type == &at_showitem;
|
|
|
|
a = a->next) {
|
|
|
|
const potion_type *ptype =
|
|
|
|
resource2potion(((const item_type *)a->data.v)->rtype);
|
|
|
|
const char *ch;
|
|
|
|
const char *description = NULL;
|
|
|
|
|
|
|
|
if (ptype == NULL)
|
|
|
|
continue;
|
|
|
|
ch = resourcename(ptype->itype->rtype, 0);
|
|
|
|
fprintf(F, "TRANK %d\n", hashstring(ch));
|
2015-01-08 20:55:29 +01:00
|
|
|
fprintf(F, "\"%s\";Name\n", translate(ch, LOC(f->locale, ch)));
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "%d;Stufe\n", ptype->level);
|
|
|
|
|
|
|
|
if (description == NULL) {
|
|
|
|
const char *pname = resourcename(ptype->itype->rtype, 0);
|
|
|
|
const char *potiontext = mkname("potion", pname);
|
|
|
|
description = LOC(f->locale, potiontext);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
fprintf(F, "\"%s\";Beschr\n", description);
|
|
|
|
if (ptype->itype->construction) {
|
|
|
|
requirement *m = ptype->itype->construction->materials;
|
|
|
|
|
|
|
|
fprintf(F, "ZUTATEN\n");
|
|
|
|
|
|
|
|
while (m->number) {
|
|
|
|
ch = resourcename(m->rtype, 0);
|
2015-01-08 20:55:29 +01:00
|
|
|
fprintf(F, "\"%s\"\n", translate(ch, LOC(f->locale, ch)));
|
2014-08-14 09:57:05 +02:00
|
|
|
m++;
|
|
|
|
}
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2014-08-14 09:57:05 +02:00
|
|
|
/* traverse all regions */
|
2016-09-13 15:30:09 +02:00
|
|
|
for (r = ctx->first; r != ctx->last; r = r->next) {
|
2016-09-18 12:44:03 +02:00
|
|
|
if (r->seen.mode > seen_none) {
|
|
|
|
cr_output_region(F, ctx, r);
|
|
|
|
}
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
|
|
|
report_crtypes(F, f->locale);
|
|
|
|
write_translations(F);
|
|
|
|
reset_translations();
|
|
|
|
fclose(F);
|
|
|
|
return 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
int crwritemap(const char *filename)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
FILE *F = fopen(filename, "w");
|
|
|
|
region *r;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-10-30 12:55:30 +01:00
|
|
|
if (F) {
|
|
|
|
fprintf(F, "VERSION %d\n", C_REPORT_VERSION);
|
|
|
|
fputs("\"UTF-8\";charset\n", F);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-10-30 12:55:30 +01:00
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
plane *pl = rplane(r);
|
|
|
|
int plid = plane_id(pl);
|
|
|
|
if (plid) {
|
|
|
|
fprintf(F, "REGION %d %d %d\n", r->x, r->y, plid);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(F, "REGION %d %d\n", r->x, r->y);
|
|
|
|
}
|
|
|
|
fprintf(F, "\"%s\";Name\n\"%s\";Terrain\n", rname(r, default_locale),
|
|
|
|
LOC(default_locale, terrain_name(r)));
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
2015-10-30 12:55:30 +01:00
|
|
|
fclose(F);
|
|
|
|
return 0;
|
2014-08-14 09:57:05 +02:00
|
|
|
}
|
2015-10-30 12:55:30 +01:00
|
|
|
return EOF;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
void register_cr(void)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
tsf_register("report", &cr_ignore);
|
|
|
|
tsf_register("string", &cr_string);
|
|
|
|
tsf_register("order", &cr_order);
|
|
|
|
tsf_register("spell", &cr_spell);
|
|
|
|
tsf_register("curse", &cr_curse);
|
|
|
|
tsf_register("int", &cr_int);
|
|
|
|
tsf_register("unit", &cr_unit);
|
|
|
|
tsf_register("region", &cr_region);
|
|
|
|
tsf_register("faction", &cr_faction);
|
|
|
|
tsf_register("ship", &cr_ship);
|
|
|
|
tsf_register("building", &cr_building);
|
|
|
|
tsf_register("skill", &cr_skill);
|
|
|
|
tsf_register("resource", &cr_resource);
|
|
|
|
tsf_register("race", &cr_race);
|
|
|
|
tsf_register("direction", &cr_int);
|
|
|
|
tsf_register("alliance", &cr_alliance);
|
|
|
|
tsf_register("resources", &cr_resources);
|
|
|
|
tsf_register("items", &cr_resources);
|
|
|
|
tsf_register("regions", &cr_regions);
|
|
|
|
|
|
|
|
if (!nocr)
|
|
|
|
register_reporttype("cr", &report_computer, 1 << O_COMPUTER);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
void creport_cleanup(void)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-08-14 09:57:05 +02:00
|
|
|
while (junkyard) {
|
|
|
|
translation *t = junkyard;
|
|
|
|
junkyard = junkyard->next;
|
|
|
|
free(t);
|
|
|
|
}
|
|
|
|
junkyard = 0;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|