2001-01-25 10:37:55 +01:00
|
|
|
|
/* vi: set ts=2:
|
|
|
|
|
*
|
2003-07-29 11:48:03 +02:00
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
2001-01-25 10:37:55 +01:00
|
|
|
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
|
|
|
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
|
|
|
|
* Henning Peters (faroul@beyond.kn-bremen.de)
|
|
|
|
|
* Enno Rehling (enno@eressea-pbem.de)
|
|
|
|
|
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
|
|
|
|
*
|
|
|
|
|
* based on:
|
|
|
|
|
*
|
|
|
|
|
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
|
|
|
|
* Atlantis v1.7 Copyright 1996 by Alex Schr<EFBFBD>der
|
|
|
|
|
*
|
|
|
|
|
* This program may not be used, modified or distributed without
|
|
|
|
|
* prior permission by the authors of Eressea.
|
|
|
|
|
* This program may not be sold or used commercially without prior written
|
|
|
|
|
* permission from the authors.
|
|
|
|
|
*/
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include "eressea.h"
|
|
|
|
|
#include "reports.h"
|
|
|
|
|
|
2001-03-01 00:28:55 +01:00
|
|
|
|
/* kernel includes */
|
2005-11-02 22:10:40 +01:00
|
|
|
|
#include <kernel/building.h>
|
|
|
|
|
#include <kernel/border.h>
|
|
|
|
|
#include <kernel/terrain.h>
|
|
|
|
|
#include <kernel/faction.h>
|
|
|
|
|
#include <kernel/group.h>
|
|
|
|
|
#include <kernel/item.h>
|
|
|
|
|
#include <kernel/karma.h>
|
|
|
|
|
#include <kernel/magic.h>
|
|
|
|
|
#include <kernel/message.h>
|
|
|
|
|
#include <kernel/order.h>
|
|
|
|
|
#include <kernel/plane.h>
|
|
|
|
|
#include <kernel/race.h>
|
|
|
|
|
#include <kernel/region.h>
|
|
|
|
|
#include <kernel/ship.h>
|
|
|
|
|
#include <kernel/skill.h>
|
|
|
|
|
#include <kernel/unit.h>
|
2001-04-29 21:27:42 +02:00
|
|
|
|
#ifdef USE_UGROUPS
|
2005-11-02 22:10:40 +01:00
|
|
|
|
# include <kernel/ugroup.h>
|
2001-12-10 01:13:39 +01:00
|
|
|
|
# include <attributes/ugroup.h>
|
2001-04-29 21:27:42 +02:00
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
/* util includes */
|
2005-06-17 20:12:58 +02:00
|
|
|
|
#include <util/bsdstring.h>
|
|
|
|
|
#include <util/base36.h>
|
2005-11-02 22:10:40 +01:00
|
|
|
|
#include <util/functions.h>
|
2005-06-17 20:12:58 +02:00
|
|
|
|
#include <util/goodies.h>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
2005-11-02 22:10:40 +01:00
|
|
|
|
#include <time.h>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
/* attributes includes */
|
|
|
|
|
#include <attributes/follow.h>
|
2001-04-14 14:11:45 +02:00
|
|
|
|
#include <attributes/otherfaction.h>
|
- Neue Messages fertig
Messages werden jetzt in einem anderen Meta-Format (message* of
message_type*) gespeichert, das man in beliebige Formate (CR oder NR)
rendern kann. crmessage.c und nrmessage.c sind die render-engines dafür.
Die Messagetypen werden in res/{de,en}/messages.xml gesammelt, ultimativ
kann das aber durchaus eine einzelne Datei sein. Die ist derzeit nicht
wirklich xml (Umlaute drin, keine Definitionsdatei), aber gut lesbar.
- make_message
Diese Funktion ersetzt new_message, und ist etwas einfacher in der Syntax:
make_message("dumb_mistake", "unit region command", u, r, cmd) erzeugt
eine neue Nachricht, die dann einfach mit add_message wie bisher an die
Nachrichtenliste gehängt werden kann.
TODO: Messages könnte man durchaus reference-counten, und in mehrere Listen
einfügen, solang sie a) mehrfachverwendet (Kampf!) und b) vom Betrachter
unabhängig sind. Das spart einigen Speicher.
- CR Version erhöht.
Weil die MESSAGETYPES Blocks anders sind als früher
- OFFENSIVE_DELAY
Verbietet Einheiten, deren Partei eine Reigon niht bewachen, den
Angriff in der Region, wenn sie sich in der Runde zuvor bewegt haben.
Status der letzten Runde wird in neuem Attribut at_moved gespeichert.
- SHORT_ATTACKS
ein define, das angibt ob Kämpfen grundsätzlich keine lange Aktion ist.
- XML Parser
xml.[hc] enthält einen XML-Parser, dem man ein plugin mit callbacks
übergibt, die nach dem Parsen eines tokens aufgerufen werden.
2001-04-12 19:21:57 +02:00
|
|
|
|
#include <attributes/racename.h>
|
2005-11-02 22:10:40 +01:00
|
|
|
|
#include <attributes/viewrange.h>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2005-05-07 00:30:19 +02:00
|
|
|
|
const char * g_reportdir;
|
2005-05-04 19:11:34 +02:00
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
const char *coasts[MAXDIRECTIONS] =
|
|
|
|
|
{
|
2004-03-28 22:53:47 +02:00
|
|
|
|
"coast::nw",
|
|
|
|
|
"coast::ne",
|
|
|
|
|
"coast::e",
|
|
|
|
|
"coast::se",
|
|
|
|
|
"coast::sw",
|
|
|
|
|
"coast::w"
|
2001-01-25 10:37:55 +01:00
|
|
|
|
};
|
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
|
const char *
|
2001-01-25 10:37:55 +01:00
|
|
|
|
reportpath(void)
|
|
|
|
|
{
|
2001-01-31 08:59:44 +01:00
|
|
|
|
static char zText[MAX_PATH];
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if (g_reportdir) return g_reportdir;
|
|
|
|
|
return strcat(strcpy(zText, basepath()), "/reports");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
groupid(const struct group * g, const struct faction * f)
|
|
|
|
|
{
|
|
|
|
|
typedef char name[OBJECTIDSIZE + 1];
|
|
|
|
|
static name idbuf[8];
|
|
|
|
|
static int nextbuf = 0;
|
|
|
|
|
char *buf = idbuf[(++nextbuf) % 8];
|
|
|
|
|
sprintf(buf, "%s (%s)", g->name, factionid(f));
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
|
static const char *
|
|
|
|
|
report_kampfstatus(const unit * u, const struct locale * lang)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
{
|
|
|
|
|
static char fsbuf[64];
|
2001-09-05 21:40:40 +02:00
|
|
|
|
static const char * azstatus[] = {
|
|
|
|
|
"status_aggressive", "status_front",
|
|
|
|
|
"status_rear", "status_defensive",
|
|
|
|
|
"status_avoid", "status_flee" };
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
|
strcpy(fsbuf, LOC(lang, azstatus[u->status]));
|
2003-07-29 11:48:03 +02:00
|
|
|
|
if (fval(u, UFL_NOAID)) {
|
2001-09-05 21:40:40 +02:00
|
|
|
|
strcat(fsbuf, ", ");
|
|
|
|
|
strcat(fsbuf, LOC(lang, "status_noaid"));
|
|
|
|
|
}
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
return fsbuf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
hp_status(const unit * u)
|
|
|
|
|
{
|
|
|
|
|
double p = (double) ((double) u->hp / (double) (u->number * unit_max_hp(u)));
|
|
|
|
|
|
2002-02-10 08:53:54 +01:00
|
|
|
|
if (p > 2.00) return mkname("damage", "critical");
|
|
|
|
|
if (p > 1.50) return mkname("damage", "heavily");
|
|
|
|
|
if (p < 0.50) return mkname("damage", "badly");
|
|
|
|
|
if (p < 0.75) return mkname("damage", "wounded");
|
|
|
|
|
if (p < 0.99) return mkname("damage", "exhausted");
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2001-02-17 16:52:47 +01:00
|
|
|
|
report_item(const unit * owner, const item * i, const faction * viewer, const char ** name, const char ** basename, int * number, boolean singular)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
{
|
|
|
|
|
if (owner->faction == viewer) {
|
2001-02-17 16:52:47 +01:00
|
|
|
|
if (name) *name = locale_string(viewer->locale, resourcename(i->type->rtype, ((i->number!=1 && !singular)?GR_PLURAL:0)));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if (basename) *basename = resourcename(i->type->rtype, 0);
|
|
|
|
|
if (number) *number = i->number;
|
|
|
|
|
} else if (i->type->rtype==r_silver) {
|
|
|
|
|
int pp = i->number/owner->number;
|
|
|
|
|
if (number) *number = 1;
|
2001-12-10 01:13:39 +01:00
|
|
|
|
if (pp > 50000 && dragonrace(owner->race)) {
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if (name) *name = locale_string(viewer->locale, "dragonhoard");
|
|
|
|
|
if (basename) *basename = "dragonhoard";
|
|
|
|
|
} else if (pp > 5000) {
|
|
|
|
|
if (name) *name = locale_string(viewer->locale, "moneychest");
|
|
|
|
|
if (basename) *basename = "moneychest";
|
|
|
|
|
} else if (pp > 500) {
|
|
|
|
|
if (name) *name = locale_string(viewer->locale, "moneybag");
|
|
|
|
|
if (basename) *basename = "moneybag";
|
|
|
|
|
} else {
|
|
|
|
|
if (number) *number = 0;
|
|
|
|
|
if (name) *name = NULL;
|
|
|
|
|
if (basename) *basename = NULL;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2001-02-17 16:52:47 +01:00
|
|
|
|
if (name) *name = locale_string(viewer->locale, resourcename(i->type->rtype, NMF_APPEARANCE|((i->number!=1 && !singular)?GR_PLURAL:0)));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if (basename) *basename = resourcename(i->type->rtype, NMF_APPEARANCE);
|
|
|
|
|
if (number) {
|
2005-10-25 14:38:01 +02:00
|
|
|
|
if (fval(i->type, ITF_HERB)) *number = 1;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
else *number = i->number;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-21 00:26:41 +02:00
|
|
|
|
|
2005-07-16 23:18:22 +02:00
|
|
|
|
#define ORDERS_IN_NR 1
|
2005-06-17 20:12:58 +02:00
|
|
|
|
static size_t
|
2005-07-16 23:18:22 +02:00
|
|
|
|
buforder(char * bufp, size_t size, const order * ord, int mode)
|
2005-05-21 00:26:41 +02:00
|
|
|
|
{
|
2005-06-17 20:12:58 +02:00
|
|
|
|
size_t tsize = 0, rsize;
|
|
|
|
|
|
|
|
|
|
rsize = strlcpy(bufp, ", \"", size);
|
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2005-07-16 23:18:22 +02:00
|
|
|
|
if (mode<ORDERS_IN_NR) {
|
|
|
|
|
char * cmd = getcommand(ord);
|
|
|
|
|
rsize = strlcpy(bufp, cmd, size);
|
|
|
|
|
free(cmd);
|
|
|
|
|
} else {
|
|
|
|
|
rsize = strlcpy(bufp, "...", size);
|
|
|
|
|
}
|
2005-06-17 20:12:58 +02:00
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
|
|
|
|
|
if (size>1) {
|
|
|
|
|
strcpy(bufp, "\"");
|
|
|
|
|
++tsize;
|
2005-05-21 00:26:41 +02:00
|
|
|
|
}
|
2005-06-17 20:12:58 +02:00
|
|
|
|
return tsize;
|
2005-05-21 00:26:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
int
|
2001-04-28 17:39:13 +02:00
|
|
|
|
bufunit(const faction * f, const unit * u, int indent, int mode)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
{
|
2004-04-22 00:09:39 +02:00
|
|
|
|
int i, dh;
|
|
|
|
|
skill_t sk;
|
|
|
|
|
int getarnt = fval(u, UFL_PARTEITARNUNG);
|
|
|
|
|
const char *pzTmp;
|
|
|
|
|
building * b;
|
|
|
|
|
boolean isbattle = (boolean)(mode == see_battle);
|
|
|
|
|
int telepath_see = fspecial(f, FS_TELEPATHY);
|
|
|
|
|
attrib *a_fshidden = NULL;
|
|
|
|
|
item * itm;
|
|
|
|
|
item * show;
|
|
|
|
|
faction *fv = visible_faction(f, u);
|
2005-05-01 13:32:24 +02:00
|
|
|
|
char * bufp = buf;
|
2005-06-13 22:28:27 +02:00
|
|
|
|
boolean itemcloak = false;
|
|
|
|
|
static const curse_type * itemcloak_ct = 0;
|
|
|
|
|
static boolean init = false;
|
2005-06-17 20:12:58 +02:00
|
|
|
|
size_t size = sizeof(buf), rsize;
|
2005-06-13 22:28:27 +02:00
|
|
|
|
|
|
|
|
|
if (!init) {
|
|
|
|
|
init = true;
|
|
|
|
|
itemcloak_ct = ct_find("itemcloak");
|
|
|
|
|
}
|
|
|
|
|
if (itemcloak_ct!=NULL) {
|
|
|
|
|
itemcloak = curse_active(get_curse(u->attribs, itemcloak_ct));
|
|
|
|
|
}
|
2004-04-22 00:09:39 +02:00
|
|
|
|
|
|
|
|
|
if (fspecial(u->faction, FS_HIDDEN))
|
|
|
|
|
a_fshidden = a_find(u->attribs, &at_fshidden);
|
|
|
|
|
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, unitname(u), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
|
|
|
|
|
if (!isbattle) {
|
|
|
|
|
attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
|
|
|
|
if (u->faction == f) {
|
2005-06-12 19:57:14 +02:00
|
|
|
|
if (fval(u, UFL_GROUP)) {
|
|
|
|
|
attrib *a = a_find(u->attribs, &at_group);
|
|
|
|
|
if (a) {
|
|
|
|
|
group * g = (group*)a->data.v;
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, groupid(g, f), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2005-06-12 19:57:14 +02:00
|
|
|
|
}
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
if (getarnt) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, LOC(f->locale, "anonymous"), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
} else if (a_otherfaction) {
|
|
|
|
|
faction * otherfaction = get_otherfaction(a_otherfaction);
|
|
|
|
|
if (otherfaction) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, factionname(otherfaction), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (getarnt) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, LOC(f->locale, "anonymous"), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
} else {
|
2005-05-04 19:11:34 +02:00
|
|
|
|
if (a_otherfaction && alliedunit(u, f, HELP_FSTEALTH)) {
|
|
|
|
|
faction * f = get_otherfaction(a_otherfaction);
|
2005-06-17 20:12:58 +02:00
|
|
|
|
bufp += snprintf(bufp, size, ", %s (%s)", factionname(f), factionname(u->faction));
|
|
|
|
|
size = sizeof(buf)-(bufp-buf);
|
2005-05-04 19:11:34 +02:00
|
|
|
|
} else {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, factionname(fv), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2005-05-04 19:11:34 +02:00
|
|
|
|
}
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-12-10 01:13:39 +01:00
|
|
|
|
#ifdef USE_UGROUPS
|
2004-04-22 00:09:39 +02:00
|
|
|
|
if (u->faction == f) {
|
|
|
|
|
attrib *a = a_find(u->attribs, &at_ugroup);
|
2005-05-04 19:11:34 +02:00
|
|
|
|
if (a) {
|
2004-04-22 00:09:39 +02:00
|
|
|
|
ugroup *ug = findugroupid(u->faction, a->data.i);
|
2005-05-04 19:11:34 +02:00
|
|
|
|
if (is_ugroupleader(u, ug)) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
if (size>1) {
|
|
|
|
|
strcpy(bufp++, "*");
|
|
|
|
|
--size;
|
|
|
|
|
}
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, itoa36(ug->id), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-12-10 01:13:39 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
|
|
|
|
|
if (u->faction != f && a_fshidden && a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 6) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, "? ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
} else {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
bufp += snprintf(bufp, size, "%d ", u->number);
|
|
|
|
|
size = sizeof(buf)-(bufp-buf);
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pzTmp = get_racename(u->attribs);
|
2004-07-11 00:31:21 +02:00
|
|
|
|
if (pzTmp) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, pzTmp, size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-07-11 00:31:21 +02:00
|
|
|
|
if (u->faction==f && fval(u->race, RCF_SHAPESHIFTANY)) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, " (", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, racename(f->locale, u, u->race), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
if (size>1) {
|
|
|
|
|
strcpy(bufp++, ")");
|
|
|
|
|
--size;
|
|
|
|
|
}
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, racename(f->locale, u, u->irace), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-07-11 00:31:21 +02:00
|
|
|
|
if (u->faction==f && u->irace!=u->race) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, " (", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, racename(f->locale, u, u->race), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
if (size>1) {
|
|
|
|
|
strcpy(bufp++, ")");
|
|
|
|
|
--size;
|
|
|
|
|
}
|
2004-07-11 00:31:21 +02:00
|
|
|
|
}
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
2004-08-03 17:34:26 +02:00
|
|
|
|
#ifdef HEROES
|
|
|
|
|
if (fval(u, UFL_HERO) && (u->faction == f || omniscient(f))) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, LOC(f->locale, "hero"), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-08-03 17:34:26 +02:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2004-04-22 00:09:39 +02:00
|
|
|
|
/* status */
|
|
|
|
|
|
|
|
|
|
if (u->number && (u->faction == f || telepath_see || isbattle)) {
|
|
|
|
|
const char * c = locale_string(f->locale, hp_status(u));
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, report_kampfstatus(u, f->locale), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
if (c || fval(u, UFL_HUNGER)) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, " (", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
if (c) {
|
|
|
|
|
rsize = strlcpy(bufp, c, size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
}
|
2005-05-04 19:11:34 +02:00
|
|
|
|
if (fval(u, UFL_HUNGER)) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
if (c) rsize = strlcpy(bufp, ", hungert", size);
|
|
|
|
|
else rsize = strlcpy(bufp, "hungert", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
}
|
|
|
|
|
if (size>1) {
|
|
|
|
|
strcpy(bufp++, ")");
|
|
|
|
|
--size;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-06-17 20:12:58 +02:00
|
|
|
|
if (getguard(u)) {
|
|
|
|
|
rsize = strlcpy(bufp, ", bewacht die Region", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
}
|
2004-04-22 00:09:39 +02:00
|
|
|
|
|
|
|
|
|
if ((b = usiege(u))!=NULL) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", belagert ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, buildingname(b), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dh = 0;
|
|
|
|
|
if (u->faction == f || telepath_see) {
|
|
|
|
|
for (sk = 0; sk != MAXSKILLS; sk++) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = spskill(bufp, size, f->locale, u, sk, &dh, 1);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dh = 0;
|
|
|
|
|
if (f == u->faction || telepath_see || omniscient(f)) {
|
|
|
|
|
show = u->items;
|
|
|
|
|
} else if (!itemcloak && mode >= see_unit && !(a_fshidden
|
|
|
|
|
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH) >= 3))
|
|
|
|
|
{
|
|
|
|
|
show = NULL;
|
|
|
|
|
for (itm=u->items;itm;itm=itm->next) {
|
|
|
|
|
item * ishow;
|
|
|
|
|
const char * ic;
|
|
|
|
|
int in;
|
|
|
|
|
report_item(u, itm, f, NULL, &ic, &in, false);
|
|
|
|
|
if (ic && *ic && in>0) {
|
|
|
|
|
for (ishow = show; ishow; ishow=ishow->next) {
|
|
|
|
|
const char * sc;
|
|
|
|
|
int sn;
|
|
|
|
|
if (ishow->type==itm->type) sc=ic;
|
|
|
|
|
else report_item(u, ishow, f, NULL, &sc, &sn, false);
|
|
|
|
|
if (sc==ic || strcmp(sc, ic)==0) {
|
|
|
|
|
ishow->number+=itm->number;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ishow==NULL) {
|
|
|
|
|
ishow = i_add(&show, i_new(itm->type, itm->number));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
show = NULL;
|
|
|
|
|
}
|
|
|
|
|
for (itm=show; itm; itm=itm->next) {
|
|
|
|
|
const char * ic;
|
|
|
|
|
int in;
|
|
|
|
|
report_item(u, itm, f, &ic, NULL, &in, false);
|
|
|
|
|
if (in==0 || ic==NULL) continue;
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
|
|
|
|
|
if (!dh) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
bufp += snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_inventory"));
|
|
|
|
|
size = sizeof(buf)-(bufp-buf);
|
2004-04-22 00:09:39 +02:00
|
|
|
|
dh = 1;
|
|
|
|
|
}
|
|
|
|
|
if (in == 1) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ic, size);
|
2004-04-22 00:09:39 +02:00
|
|
|
|
} else {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = snprintf(bufp, size, "%d %s", in, ic);
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
2005-06-17 20:12:58 +02:00
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
if (show!=u->items) while (show) i_free(i_remove(&show, show));
|
|
|
|
|
|
|
|
|
|
if (u->faction == f || telepath_see) {
|
2005-10-08 17:25:21 +02:00
|
|
|
|
sc_mage * m = get_mage(u);
|
2004-04-22 00:09:39 +02:00
|
|
|
|
|
2005-10-08 17:25:21 +02:00
|
|
|
|
if (m!=NULL) {
|
|
|
|
|
spell_list *slist = m->spells;
|
2005-06-17 20:12:58 +02:00
|
|
|
|
int t = effskill(u, SK_MAGIC);
|
|
|
|
|
bufp += snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region,u));
|
|
|
|
|
size = sizeof(buf)-(bufp-buf);
|
|
|
|
|
|
2005-10-08 17:25:21 +02:00
|
|
|
|
for (dh=0; slist; slist=slist->next) {
|
|
|
|
|
spell * sp = slist->data;
|
2005-06-17 20:12:58 +02:00
|
|
|
|
if (sp->level > t) continue;
|
|
|
|
|
if (!dh) {
|
|
|
|
|
rsize = snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells"));
|
|
|
|
|
dh = 1;
|
|
|
|
|
} else {
|
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
2005-06-17 20:12:58 +02:00
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, spell_name(sp, f->locale), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
2005-06-17 20:12:58 +02:00
|
|
|
|
|
2005-10-08 17:25:21 +02:00
|
|
|
|
for (i=0; i!=MAXCOMBATSPELLS; ++i) {
|
|
|
|
|
if (get_combatspell(u, i)) break;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
2005-10-08 17:25:21 +02:00
|
|
|
|
if (i!=MAXCOMBATSPELLS) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
bufp += snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_combatspells"));
|
|
|
|
|
size = sizeof(buf)-(bufp-buf);
|
2005-10-08 17:25:21 +02:00
|
|
|
|
dh = 0;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
for (i = 0; i < MAXCOMBATSPELLS; i++){
|
2005-10-08 17:25:21 +02:00
|
|
|
|
const spell *sp;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
if (!dh){
|
|
|
|
|
dh = 1;
|
2005-05-04 19:11:34 +02:00
|
|
|
|
} else {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
sp = get_combatspell(u,i);
|
|
|
|
|
if (sp) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
int sl = get_combatspelllevel(u, i);
|
|
|
|
|
rsize = strlcpy(bufp, spell_name(sp, u->faction->locale), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
|
|
|
|
|
if (sl > 0) {
|
|
|
|
|
bufp += snprintf(bufp, size, " (%d)", sl);
|
|
|
|
|
size = sizeof(buf)-(bufp-buf);
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
2005-05-04 19:11:34 +02:00
|
|
|
|
} else {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, LOC(f->locale, "nr_nospells"), size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-04-30 19:07:46 +02:00
|
|
|
|
#ifdef LASTORDER
|
2004-06-21 18:45:27 +02:00
|
|
|
|
if (!isbattle && u->lastorder) {
|
2005-07-16 23:18:22 +02:00
|
|
|
|
rsize = buforder(bufp, size, u->lastorder, 0);
|
2005-06-17 20:12:58 +02:00
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2005-05-21 00:26:41 +02:00
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
if (!isbattle) {
|
|
|
|
|
boolean printed = 0;
|
2005-07-16 23:18:22 +02:00
|
|
|
|
order * ord;;
|
|
|
|
|
for (ord=u->old_orders;ord;ord=ord->next) {
|
|
|
|
|
if (is_repeated(ord)) {
|
|
|
|
|
if (printed<ORDERS_IN_NR) {
|
|
|
|
|
rsize = buforder(bufp, size, ord, printed++);
|
2005-06-17 20:12:58 +02:00
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2005-07-16 23:18:22 +02:00
|
|
|
|
} else break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (printed<ORDERS_IN_NR) for (ord=u->orders;ord;ord=ord->next) {
|
|
|
|
|
if (is_repeated(ord)) {
|
|
|
|
|
if (printed<ORDERS_IN_NR) {
|
|
|
|
|
rsize = buforder(bufp, size, ord, printed++);
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
} else break;
|
2005-05-21 00:26:41 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
2005-04-30 19:07:46 +02:00
|
|
|
|
#endif
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
i = 0;
|
|
|
|
|
|
2005-04-23 11:47:03 +02:00
|
|
|
|
if (u->display && u->display[0]) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, "; ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
|
|
|
|
|
rsize = strlcpy(bufp, u->display, size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
|
|
|
|
|
i = u->display[strlen(u->display) - 1];
|
|
|
|
|
}
|
2005-06-17 20:12:58 +02:00
|
|
|
|
if (i != '!' && i != '?' && i != '.') {
|
|
|
|
|
if (size>1) {
|
|
|
|
|
strcpy(bufp++, ".");
|
|
|
|
|
--size;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-04-22 00:09:39 +02:00
|
|
|
|
pzTmp = uprivate(u);
|
|
|
|
|
if (u->faction == f && pzTmp) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, " (Bem: ", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, pzTmp, size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
rsize = strlcpy(bufp, ")", size);
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2004-04-22 00:09:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dh=0;
|
|
|
|
|
if (!getarnt && f) {
|
|
|
|
|
if (alliedfaction(getplane(u->region), f, fv, HELP_ALL)) {
|
|
|
|
|
dh = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return dh;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
2001-04-28 17:39:13 +02:00
|
|
|
|
/* TODO: telepath_see wird nicht ber<65>cksichtigt: Parteien mit
|
|
|
|
|
* telepath_see sollten immer einzelne Einheiten zu sehen
|
|
|
|
|
* bekommen, alles andere ist darstellungsteschnisch kompliziert.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-04-29 21:27:42 +02:00
|
|
|
|
#ifdef USE_UGROUPS
|
2005-05-04 19:11:34 +02:00
|
|
|
|
int
|
2001-04-28 17:39:13 +02:00
|
|
|
|
bufunit_ugroupleader(const faction * f, const unit * u, int indent, int mode)
|
|
|
|
|
{
|
|
|
|
|
int i, dh;
|
2003-07-29 11:48:03 +02:00
|
|
|
|
int getarnt = fval(u, UFL_PARTEITARNUNG);
|
2001-09-05 21:40:40 +02:00
|
|
|
|
faction *fv;
|
2001-04-28 17:39:13 +02:00
|
|
|
|
const char *pzTmp;
|
|
|
|
|
attrib *a_fshidden = NULL;
|
|
|
|
|
item * itm;
|
|
|
|
|
item * show;
|
|
|
|
|
ugroup *ug = findugroup(u);
|
|
|
|
|
boolean guards = false;
|
|
|
|
|
boolean sieges = false;
|
2005-06-13 22:28:27 +02:00
|
|
|
|
boolean itemcloak = false;
|
|
|
|
|
static const curse_type * itemcloak_ct = 0;
|
|
|
|
|
static boolean init = false;
|
|
|
|
|
|
|
|
|
|
if (!init) {
|
|
|
|
|
init = true;
|
|
|
|
|
itemcloak_ct = ct_find("itemcloak");
|
|
|
|
|
}
|
|
|
|
|
if (itemcloak_ct!=NULL) {
|
|
|
|
|
itemcloak = curse_active(get_curse(u->attribs, itemcloak_ct));
|
|
|
|
|
}
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
2001-04-28 17:39:13 +02:00
|
|
|
|
if(fspecial(u->faction, FS_HIDDEN))
|
|
|
|
|
a_fshidden = a_find(u->attribs, &at_fshidden);
|
|
|
|
|
|
|
|
|
|
strcpy(buf, u->name);
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
|
|
|
|
fv = visible_faction(f, u);
|
2001-04-28 17:39:13 +02:00
|
|
|
|
|
|
|
|
|
if (getarnt) {
|
|
|
|
|
scat(", ");
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat(LOC(f->locale, "anonymous"));
|
2001-04-28 17:39:13 +02:00
|
|
|
|
} else {
|
|
|
|
|
scat(", ");
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat(factionname(fv));
|
2001-04-28 17:39:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scat(", ");
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < ug->members; i++) {
|
|
|
|
|
unit *uc = ug->unit_array[i];
|
|
|
|
|
if(uc->faction != f && a_fshidden
|
|
|
|
|
&& a_fshidden->data.ca[0] == 1 && effskill(uc, SK_STEALTH) >= 6) {
|
|
|
|
|
scat("? ");
|
|
|
|
|
} else {
|
|
|
|
|
icat(uc->number);
|
|
|
|
|
scat(" ");
|
|
|
|
|
}
|
|
|
|
|
pzTmp = get_racename(uc->attribs);
|
|
|
|
|
if (pzTmp || u->irace != uc->race) {
|
|
|
|
|
if (pzTmp)
|
|
|
|
|
scat(pzTmp);
|
|
|
|
|
else
|
2001-12-10 01:13:39 +01:00
|
|
|
|
scat(racename(f->locale, u, u->irace));
|
2001-04-28 17:39:13 +02:00
|
|
|
|
scat(" (");
|
|
|
|
|
scat(itoa36(uc->no));
|
|
|
|
|
scat("), ");
|
|
|
|
|
} else {
|
2001-12-10 01:13:39 +01:00
|
|
|
|
scat(racename(f->locale, u, u->race));
|
2001-04-28 17:39:13 +02:00
|
|
|
|
scat(" (");
|
|
|
|
|
scat(itoa36(uc->no));
|
|
|
|
|
scat("), ");
|
|
|
|
|
}
|
|
|
|
|
if(getguard(uc)) guards = true;
|
|
|
|
|
if(usiege(uc)) sieges = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(guards == true) scat(", bewacht die Region");
|
|
|
|
|
|
|
|
|
|
if(sieges == true) {
|
|
|
|
|
scat(", belagert ");
|
|
|
|
|
for(i = 0; i < ug->members; i++) {
|
|
|
|
|
building *b = usiege(ug->unit_array[i]);
|
|
|
|
|
if(b) {
|
|
|
|
|
scat(buildingname(b));
|
|
|
|
|
scat(", ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dh = 0;
|
|
|
|
|
show = NULL;
|
|
|
|
|
for(i = 0; i < ug->members; i++) {
|
|
|
|
|
unit *uc = ug->unit_array[i];
|
2005-06-12 19:57:14 +02:00
|
|
|
|
if (!itemcloak && mode >= see_unit && !(a_fshidden
|
2001-04-28 17:39:13 +02:00
|
|
|
|
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH) >= 3)) {
|
|
|
|
|
for (itm=uc->items;itm;itm=itm->next) {
|
|
|
|
|
item *ishow;
|
|
|
|
|
const char * ic;
|
|
|
|
|
int in;
|
|
|
|
|
report_item(u, itm, f, NULL, &ic, &in, false);
|
|
|
|
|
if (ic && *ic && in>0) {
|
|
|
|
|
for (ishow = show; ishow; ishow=ishow->next) {
|
|
|
|
|
const char * sc;
|
|
|
|
|
int sn;
|
|
|
|
|
if (ishow->type==itm->type) sc=ic;
|
|
|
|
|
else report_item(u, ishow, f, NULL, &sc, &sn, false);
|
|
|
|
|
if (sc==ic || strcmp(sc, ic)==0) {
|
|
|
|
|
ishow->number+=itm->number;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ishow==NULL) {
|
2001-12-10 01:13:39 +01:00
|
|
|
|
ishow = i_add(&show, i_new(itm->type, itm->number));
|
2001-04-28 17:39:13 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (itm=show; itm; itm=itm->next) {
|
|
|
|
|
const char * ic;
|
|
|
|
|
int in;
|
|
|
|
|
report_item(u, itm, f, &ic, NULL, &in, false);
|
|
|
|
|
if (in==0 || ic==NULL) continue;
|
|
|
|
|
scat(", ");
|
|
|
|
|
|
|
|
|
|
if (!dh) {
|
|
|
|
|
sprintf(buf+strlen(buf), "%s: ", LOC(f->locale, "nr_inventory"));
|
|
|
|
|
dh = 1;
|
|
|
|
|
}
|
|
|
|
|
if (in == 1) {
|
|
|
|
|
scat(ic);
|
|
|
|
|
} else {
|
|
|
|
|
icat(in);
|
|
|
|
|
scat(" ");
|
|
|
|
|
scat(ic);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(show) while(show) i_free(i_remove(&show, show));
|
|
|
|
|
|
|
|
|
|
i = 0;
|
2005-04-23 11:47:03 +02:00
|
|
|
|
if (u->display && u->display[0]) {
|
2001-04-28 17:39:13 +02:00
|
|
|
|
scat("; ");
|
|
|
|
|
scat(u->display);
|
|
|
|
|
|
|
|
|
|
i = u->display[strlen(u->display) - 1];
|
|
|
|
|
}
|
|
|
|
|
if (i != '!' && i != '?' && i != '.')
|
|
|
|
|
scat(".");
|
|
|
|
|
|
|
|
|
|
dh=0;
|
|
|
|
|
if (!getarnt && f && f->allies) {
|
|
|
|
|
ally *sf;
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
2001-04-28 17:39:13 +02:00
|
|
|
|
for (sf = f->allies; sf && !dh; sf = sf->next) {
|
2001-09-05 21:40:40 +02:00
|
|
|
|
if (sf->status > 0 && sf->status <= HELP_ALL && sf->faction == fv) {
|
2001-04-28 17:39:13 +02:00
|
|
|
|
dh = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return dh;
|
|
|
|
|
}
|
2001-04-29 21:27:42 +02:00
|
|
|
|
#endif
|
2001-04-28 17:39:13 +02:00
|
|
|
|
|
2005-05-05 03:26:59 +02:00
|
|
|
|
size_t
|
2005-06-17 20:12:58 +02:00
|
|
|
|
spskill(char * buffer, size_t size, const struct locale * lang, const struct unit * u, skill_t sk, int *dh, int days)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
{
|
2005-05-07 01:25:08 +02:00
|
|
|
|
char * bufp = buffer;
|
|
|
|
|
int i, effsk;
|
2005-06-17 20:12:58 +02:00
|
|
|
|
size_t rsize;
|
|
|
|
|
size_t tsize = 0;
|
2002-02-22 20:41:20 +01:00
|
|
|
|
|
2005-05-07 01:25:08 +02:00
|
|
|
|
if (!u->number) return 0;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2005-05-07 01:25:08 +02:00
|
|
|
|
if (!has_skill(u, sk)) return 0;
|
|
|
|
|
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, ", ", size);
|
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2005-05-07 01:25:08 +02:00
|
|
|
|
if (!*dh) {
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, LOC(lang, "nr_skills"), size);
|
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
|
|
|
|
|
rsize = strlcpy(bufp, ": ", size);
|
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
|
2005-05-07 01:25:08 +02:00
|
|
|
|
*dh = 1;
|
|
|
|
|
}
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, skillname(sk, lang), size);
|
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
|
|
|
|
|
rsize = strlcpy(bufp, " ", size);
|
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2005-05-07 01:25:08 +02:00
|
|
|
|
|
|
|
|
|
if (sk == SK_MAGIC){
|
|
|
|
|
if (find_magetype(u) != M_GRAU){
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = strlcpy(bufp, LOC(lang, mkname("school", magietypen[find_magetype(u)])), size);
|
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
|
|
|
|
|
|
|
|
|
rsize = strlcpy(bufp, " ", size);
|
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2005-05-07 01:25:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-12 19:57:14 +02:00
|
|
|
|
if (sk == SK_STEALTH && fval(u, UFL_STEALTH)) {
|
2005-05-07 01:25:08 +02:00
|
|
|
|
i = u_geteffstealth(u);
|
2005-06-17 20:12:58 +02:00
|
|
|
|
if (i>=0) {
|
|
|
|
|
rsize = slprintf(bufp, size, "%d/", i);
|
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2005-05-07 01:25:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
effsk = effskill(u, sk);
|
2005-06-17 20:12:58 +02:00
|
|
|
|
rsize = slprintf(bufp, size, "%d", effsk);
|
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2005-05-07 01:25:08 +02:00
|
|
|
|
|
|
|
|
|
if(u->faction->options & Pow(O_SHOWSKCHANGE)) {
|
|
|
|
|
skill *skill = get_skill(u, sk);
|
|
|
|
|
int oldeff = 0;
|
|
|
|
|
int diff;
|
|
|
|
|
|
|
|
|
|
if (skill->old > 0) {
|
|
|
|
|
oldeff = skill->old + get_modifier(u, sk, skill->old, u->region, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
oldeff = max(0, oldeff);
|
|
|
|
|
diff = effsk - oldeff;
|
|
|
|
|
|
2005-06-17 20:12:58 +02:00
|
|
|
|
if (diff != 0) {
|
|
|
|
|
rsize = slprintf(bufp, size, " (%s%d)", (diff>0)?"+":"", diff);
|
|
|
|
|
tsize += rsize;
|
|
|
|
|
if (rsize>size) rsize = size-1;
|
|
|
|
|
size -= rsize;
|
|
|
|
|
bufp += rsize;
|
2005-05-07 01:25:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-06-17 20:12:58 +02:00
|
|
|
|
return tsize;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
lparagraph(struct strlist ** SP, char *s, int indent, char mark)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/* Die Liste SP wird mit dem String s aufgefuellt, mit indent und einer
|
|
|
|
|
* mark, falls angegeben. SP wurde also auf 0 gesetzt vor dem Aufruf.
|
|
|
|
|
* Vgl. spunit (). */
|
|
|
|
|
|
|
|
|
|
char *buflocal = calloc(strlen(s) + indent + 1, sizeof(char));
|
|
|
|
|
|
|
|
|
|
if (indent) {
|
|
|
|
|
memset(buflocal, ' ', indent);
|
|
|
|
|
if (mark)
|
|
|
|
|
buflocal[indent - 2] = mark;
|
|
|
|
|
}
|
|
|
|
|
strcpy(buflocal + indent, s);
|
|
|
|
|
addstrlist(SP, buflocal);
|
|
|
|
|
free(buflocal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
spunit(struct strlist ** SP, const struct faction * f, const unit * u, int indent,
|
|
|
|
|
int mode)
|
|
|
|
|
{
|
2004-04-22 00:09:39 +02:00
|
|
|
|
int dh;
|
2001-04-29 21:27:42 +02:00
|
|
|
|
#ifdef USE_UGROUPS
|
2004-04-22 00:09:39 +02:00
|
|
|
|
ugroup *ug = findugroup(u);
|
|
|
|
|
|
|
|
|
|
if(ug) {
|
|
|
|
|
if(is_ugroupleader(u, ug)) {
|
|
|
|
|
dh = bufunit_ugroupleader(f, u, indent, mode);
|
|
|
|
|
} else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else
|
2001-04-29 21:27:42 +02:00
|
|
|
|
#endif
|
2004-04-22 00:09:39 +02:00
|
|
|
|
dh = bufunit(f, u, indent, mode);
|
|
|
|
|
lparagraph(SP, buf, indent, (char) ((u->faction == f) ? '*' : (dh ? '+' : '-')));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
2001-03-01 00:28:55 +01:00
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
|
/* in spy steht der Unterschied zwischen Wahrnehmung des Opfers und
|
|
|
|
|
* Spionage des Spions */
|
2001-03-01 00:28:55 +01:00
|
|
|
|
void
|
|
|
|
|
spy_message(int spy, unit *u, unit *target)
|
|
|
|
|
{
|
|
|
|
|
const char *c;
|
|
|
|
|
|
2002-02-06 09:06:02 +01:00
|
|
|
|
produceexp(u, SK_SPY, u->number);
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
|
|
|
|
/* Infos:
|
|
|
|
|
* - Kampfstatus
|
|
|
|
|
* - verborgene Gegenst<EFBFBD>nde: Amulette, Ringe, Phiolen, Geld
|
|
|
|
|
* - Partei
|
|
|
|
|
* - Talentinfo
|
|
|
|
|
* - Zauberspr<EFBFBD>che
|
|
|
|
|
* - Zauberwirkungen
|
|
|
|
|
*/
|
|
|
|
|
/* mit spy=100 (magische Spionage) soll alles herausgefunden werden */
|
|
|
|
|
|
2002-02-06 09:06:02 +01:00
|
|
|
|
buf[0]='\0';
|
2001-09-05 21:40:40 +02:00
|
|
|
|
if (spy > 99){
|
|
|
|
|
/* magische Spionage */
|
|
|
|
|
/* Zauberwirkungen */
|
|
|
|
|
}
|
|
|
|
|
if (spy > 20){
|
2005-10-08 17:25:21 +02:00
|
|
|
|
sc_mage * m = get_mage(target);
|
2001-09-05 21:40:40 +02:00
|
|
|
|
/* bei Magiern Zauberspr<70>che und Magiegebiet */
|
2005-10-08 17:25:21 +02:00
|
|
|
|
if (m) {
|
|
|
|
|
spell_list *slist = m->spells;
|
|
|
|
|
boolean first = true;
|
2001-03-01 00:28:55 +01:00
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat("Magiegebiet: ");
|
2002-07-23 09:23:28 +02:00
|
|
|
|
scat(LOC(u->faction->locale, magietypen[find_magetype(target)]));
|
2005-10-08 17:25:21 +02:00
|
|
|
|
scat(", Spr<70>che: ");
|
|
|
|
|
|
|
|
|
|
for (;slist; slist=slist->next) {
|
|
|
|
|
spell * sp = slist->data;
|
|
|
|
|
if (first) {
|
|
|
|
|
first = false;
|
|
|
|
|
} else {
|
|
|
|
|
scat(", ");
|
2001-03-01 00:28:55 +01:00
|
|
|
|
}
|
2005-10-08 17:25:21 +02:00
|
|
|
|
scat(spell_name(sp, u->faction->locale));
|
2001-03-01 00:28:55 +01:00
|
|
|
|
}
|
2005-10-08 17:25:21 +02:00
|
|
|
|
if (first) scat("Keine");
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat(". ");
|
2001-03-01 00:28:55 +01:00
|
|
|
|
}
|
2001-09-05 21:40:40 +02:00
|
|
|
|
}
|
|
|
|
|
if (spy > 6){
|
|
|
|
|
/* wahre Partei */
|
|
|
|
|
scat("Partei '");
|
2001-03-01 00:28:55 +01:00
|
|
|
|
scat(factionname(target->faction));
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat("'. ");
|
|
|
|
|
} else {
|
|
|
|
|
/* ist die Einheit in Spionage nicht gut genug, glaubt sie die
|
|
|
|
|
* Parteitarnung */
|
|
|
|
|
faction *fv = visible_faction(u->faction,target);
|
|
|
|
|
|
|
|
|
|
if (fv != target->faction){
|
|
|
|
|
scat("Partei '");
|
|
|
|
|
scat(factionname(fv));
|
|
|
|
|
scat("'. ");
|
2003-07-29 11:48:03 +02:00
|
|
|
|
} else if (!fval(target, UFL_PARTEITARNUNG)){
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat("Partei '");
|
|
|
|
|
scat(factionname(target->faction));
|
|
|
|
|
scat("'. ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (spy > 0){
|
|
|
|
|
scat("Talente: ");
|
2001-03-01 00:28:55 +01:00
|
|
|
|
{
|
|
|
|
|
int first = 1;
|
|
|
|
|
int found = 0;
|
|
|
|
|
skill_t sk;
|
|
|
|
|
|
|
|
|
|
for (sk = 0; sk != MAXSKILLS; sk++) {
|
2002-02-15 17:13:30 +01:00
|
|
|
|
if (has_skill(target, sk)) {
|
2001-03-01 00:28:55 +01:00
|
|
|
|
found++;
|
|
|
|
|
if (first == 1) {
|
|
|
|
|
first = 0;
|
|
|
|
|
} else {
|
|
|
|
|
scat(", ");
|
|
|
|
|
}
|
2001-04-16 16:34:19 +02:00
|
|
|
|
scat(skillname(sk, u->faction->locale));
|
2001-03-01 00:28:55 +01:00
|
|
|
|
scat(" ");
|
|
|
|
|
icat(eff_skill(target, sk, target->region));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (found == 0) {
|
|
|
|
|
scat("Keine");
|
|
|
|
|
}
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat(". ");
|
2001-03-01 00:28:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat("Im Gep<65>ck sind");
|
2001-03-01 00:28:55 +01:00
|
|
|
|
{
|
|
|
|
|
boolean first = true;
|
|
|
|
|
int found = 0;
|
|
|
|
|
item * itm;
|
|
|
|
|
for (itm=target->items;itm;itm=itm->next) {
|
|
|
|
|
if (itm->number>0) {
|
|
|
|
|
resource_type * rtype = itm->type->rtype;
|
|
|
|
|
++found;
|
|
|
|
|
if (first) {
|
|
|
|
|
first = false;
|
|
|
|
|
scat(": ");
|
|
|
|
|
} else {
|
|
|
|
|
scat(", ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (itm->number == 1) {
|
|
|
|
|
scat("1 ");
|
|
|
|
|
scat(locale_string(u->faction->locale, resourcename(rtype, 0)));
|
|
|
|
|
} else {
|
|
|
|
|
icat(itm->number);
|
|
|
|
|
scat(" ");
|
|
|
|
|
scat(locale_string(u->faction->locale, resourcename(rtype, NMF_PLURAL)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (found == 0) {
|
|
|
|
|
scat(" keine verborgenen Gegenst<73>nde");
|
|
|
|
|
}
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat(". ");
|
2001-03-01 00:28:55 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-09-05 21:40:40 +02:00
|
|
|
|
/* spion ist gleich gut wie Wahrnehmung Opfer */
|
|
|
|
|
/* spion ist schlechter als Wahrnehmung Opfer */
|
|
|
|
|
{ /* immer */
|
|
|
|
|
scat("Kampfstatus: ");
|
|
|
|
|
scat(report_kampfstatus(target, u->faction->locale));
|
2002-02-06 09:06:02 +01:00
|
|
|
|
c = locale_string(u->faction->locale, hp_status(target));
|
2001-09-05 21:40:40 +02:00
|
|
|
|
if (c && strlen(c))
|
|
|
|
|
sprintf(buf, "%s (%s)", buf, c);
|
|
|
|
|
scat(".");
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-23 09:23:28 +02:00
|
|
|
|
ADDMSG(&u->faction->msgs, msg_message("spyreport",
|
2002-02-06 09:06:02 +01:00
|
|
|
|
"spy target report", u, target, strdup(buf)));
|
2001-03-01 00:28:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
* möglichen Exploit beseitigt:
GIB xyz EINHEIT
GIB 0 ALLES SILBER
--> ALLE Befehle der übergebenen Einheit werden gelöscht.
* neue Funktion (convenience): ucansee(f, u1, u2)
liefert u1, wenn cansee(f,u1), sonst u2
* neue mistakes eingefügt uns übersetzt
* message bugfix:
u->htisorder kann gelöscht werden (z.b. NACH). Daher muss ein pointer auf
einen befehl in einer message immer auf den u->order Eintrag zeigen, damit er
zeit der auswertung noch existiert.
findorder(u, u->thisorder) tut das. Ist an mehreren Stellen nicht benutzt
worden. assert eingebaut, das das prüft.
* RESERVE_DONATIONS
Gegenstände, die von einer anderen Partei übergeben wurden, werden nicht
reserviert.
* TWOPASS_GIVE:
GIB Befehle werden zuerst an fremde Einheiten, danach in einem zweiten
Durchlauf an eigene Einheiten, ausgeführt.
* msg_message
An einigen messages ausprobiert, ob man die gleiche Message mehreren
Parteien einhängen kann - klappt, spart Speicher.
Allerdings fehlt dazu ein ordentliches memory-management (refcounter)
2001-05-10 07:50:52 +02:00
|
|
|
|
const struct unit *
|
|
|
|
|
ucansee(const struct faction *f, const struct unit *u, const struct unit *x)
|
|
|
|
|
{
|
|
|
|
|
if (cansee(f, u->region, u, 0)) return u;
|
|
|
|
|
return x;
|
|
|
|
|
}
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
|
|
|
|
faction_list *
|
2005-04-27 23:03:08 +02:00
|
|
|
|
get_addresses(faction * f, struct seen_region * seehash[])
|
2001-09-05 21:40:40 +02:00
|
|
|
|
{
|
|
|
|
|
/* "TODO: travelthru" */
|
2005-04-27 15:30:12 +02:00
|
|
|
|
region *r, *last = lastregion(f);
|
2004-02-21 13:19:50 +01:00
|
|
|
|
const faction * lastf = NULL;
|
|
|
|
|
faction_list * flist = calloc(1, sizeof(faction_list));
|
2005-01-19 21:33:13 +01:00
|
|
|
|
flist->data = f;
|
|
|
|
|
|
2005-04-27 15:30:12 +02:00
|
|
|
|
for (r=firstregion(f);r!=last;r=r->next) {
|
2005-01-19 21:33:13 +01:00
|
|
|
|
const unit * u = r->units;
|
2005-04-27 23:03:08 +02:00
|
|
|
|
const seen_region * sr = find_seen(seehash, r);
|
2005-01-19 21:33:13 +01:00
|
|
|
|
|
2004-01-19 00:57:43 +01:00
|
|
|
|
if (sr==NULL) continue;
|
2005-01-19 21:33:13 +01:00
|
|
|
|
while (u!=NULL) {
|
2001-09-05 21:40:40 +02:00
|
|
|
|
faction * sf = visible_faction(f, u);
|
2002-10-06 09:28:36 +02:00
|
|
|
|
boolean ballied = sf && sf!=f && sf!=lastf
|
2003-07-29 11:48:03 +02:00
|
|
|
|
&& !fval(u, UFL_PARTEITARNUNG) && cansee(f, r, u, 0);
|
2002-10-06 09:28:36 +02:00
|
|
|
|
if (ballied || ALLIED(f, sf)) {
|
2001-09-05 21:40:40 +02:00
|
|
|
|
faction_list ** fnew = &flist;
|
|
|
|
|
while (*fnew && (*fnew)->data->no < sf->no) {
|
|
|
|
|
fnew =&(*fnew)->next;
|
|
|
|
|
}
|
|
|
|
|
if ((*fnew==NULL) || (*fnew)->data!=sf) {
|
|
|
|
|
faction_list * finsert = malloc(sizeof(faction_list));
|
|
|
|
|
finsert->next = *fnew;
|
|
|
|
|
*fnew = finsert;
|
|
|
|
|
finsert->data = sf;
|
|
|
|
|
}
|
|
|
|
|
lastf = sf;
|
|
|
|
|
}
|
|
|
|
|
u = u->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-06-27 18:56:01 +02:00
|
|
|
|
|
|
|
|
|
if (f->alliance != NULL) {
|
2002-10-20 10:00:28 +02:00
|
|
|
|
faction *f2;
|
2002-10-05 16:35:04 +02:00
|
|
|
|
for(f2 = factions; f2; f2 = f2->next) {
|
|
|
|
|
if(f2->alliance != NULL && f2->alliance == f->alliance) {
|
|
|
|
|
faction_list ** fnew = &flist;
|
|
|
|
|
while (*fnew && (*fnew)->data->no < f2->no) {
|
|
|
|
|
fnew =&(*fnew)->next;
|
|
|
|
|
}
|
|
|
|
|
if ((*fnew==NULL) || (*fnew)->data!=f2) {
|
|
|
|
|
faction_list * finsert = malloc(sizeof(faction_list));
|
|
|
|
|
finsert->next = *fnew;
|
|
|
|
|
*fnew = finsert;
|
|
|
|
|
finsert->data = f2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-02-21 13:19:50 +01:00
|
|
|
|
return flist;
|
2001-09-05 21:40:40 +02:00
|
|
|
|
}
|
2004-03-28 22:53:47 +02:00
|
|
|
|
|
2004-05-28 23:04:18 +02:00
|
|
|
|
#define MAXSEEHASH 10007
|
2005-04-27 23:03:08 +02:00
|
|
|
|
seen_region * reuse;
|
2004-03-28 22:53:47 +02:00
|
|
|
|
|
2005-04-27 23:03:08 +02:00
|
|
|
|
seen_region **
|
2004-03-28 22:53:47 +02:00
|
|
|
|
seen_init(void)
|
2005-04-27 23:03:08 +02:00
|
|
|
|
{
|
|
|
|
|
return (seen_region **)calloc(MAXSEEHASH, sizeof(seen_region*));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
seen_done(seen_region * seehash[])
|
2004-03-28 22:53:47 +02:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i=0;i!=MAXSEEHASH;++i) {
|
|
|
|
|
seen_region * sd = seehash[i];
|
|
|
|
|
if (sd==NULL) continue;
|
|
|
|
|
while (sd->nextHash!=NULL) sd = sd->nextHash;
|
|
|
|
|
sd->nextHash = reuse;
|
|
|
|
|
reuse = seehash[i];
|
|
|
|
|
seehash[i] = NULL;
|
|
|
|
|
}
|
2005-04-28 19:11:32 +02:00
|
|
|
|
free(seehash);
|
2004-03-28 22:53:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2005-04-27 23:03:08 +02:00
|
|
|
|
free_seen(void)
|
2004-03-28 22:53:47 +02:00
|
|
|
|
{
|
2005-04-27 23:03:08 +02:00
|
|
|
|
while (reuse) {
|
|
|
|
|
seen_region * r = reuse;
|
|
|
|
|
reuse = reuse->nextHash;
|
|
|
|
|
free(r);
|
|
|
|
|
}
|
2004-03-28 22:53:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
seen_region *
|
2005-04-27 23:03:08 +02:00
|
|
|
|
find_seen(struct seen_region * seehash[], const region * r)
|
2004-03-28 22:53:47 +02:00
|
|
|
|
{
|
2005-06-10 00:10:35 +02:00
|
|
|
|
unsigned int index = reg_hashkey(r) % MAXSEEHASH;
|
|
|
|
|
seen_region * find = seehash[index];
|
2004-03-28 22:53:47 +02:00
|
|
|
|
while (find) {
|
|
|
|
|
if (find->r==r) return find;
|
|
|
|
|
find=find->nextHash;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-01 02:26:15 +02:00
|
|
|
|
void
|
|
|
|
|
get_seen_interval(struct seen_region ** seen, region ** first, region ** last)
|
|
|
|
|
{
|
|
|
|
|
/* this is required to find the neighbour regions of the ones we are in,
|
|
|
|
|
* which may well be outside of [firstregion, lastregion) */
|
|
|
|
|
#ifdef ENUM_REGIONS
|
|
|
|
|
int i;
|
|
|
|
|
for (i=0;i!=MAXSEEHASH;++i) {
|
|
|
|
|
seen_region * sr = seen[i];
|
|
|
|
|
while (sr!=NULL) {
|
|
|
|
|
if (*first==NULL || sr->r->index<(*first)->index) {
|
|
|
|
|
*first = sr->r;
|
|
|
|
|
}
|
|
|
|
|
if (*last!=NULL && sr->r->index>=(*last)->index) {
|
|
|
|
|
*last = sr->r->next;
|
|
|
|
|
}
|
|
|
|
|
sr = sr->nextHash;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
region * r = regions;
|
|
|
|
|
while (r!=first) {
|
|
|
|
|
if (find_seen(seen, r)!=NULL) {
|
|
|
|
|
*first = r;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
r = r->next;
|
|
|
|
|
}
|
|
|
|
|
r = *last;
|
|
|
|
|
while (r!=NULL) {
|
|
|
|
|
if (find_seen(seen, r)!=NULL) {
|
|
|
|
|
*last = r->next;
|
|
|
|
|
}
|
|
|
|
|
r = r->next;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-28 22:53:47 +02:00
|
|
|
|
boolean
|
2005-05-01 02:26:15 +02:00
|
|
|
|
add_seen(struct seen_region * seehash[], struct region * r, unsigned char mode, boolean dis)
|
2004-03-28 22:53:47 +02:00
|
|
|
|
{
|
2005-04-27 23:03:08 +02:00
|
|
|
|
seen_region * find = find_seen(seehash, r);
|
2004-03-28 22:53:47 +02:00
|
|
|
|
if (find==NULL) {
|
2005-06-10 00:10:35 +02:00
|
|
|
|
unsigned int index = reg_hashkey(r) % MAXSEEHASH;
|
2004-03-28 22:53:47 +02:00
|
|
|
|
if (!reuse) reuse = (seen_region*)calloc(1, sizeof(struct seen_region));
|
|
|
|
|
find = reuse;
|
|
|
|
|
reuse = reuse->nextHash;
|
|
|
|
|
find->nextHash = seehash[index];
|
|
|
|
|
seehash[index] = find;
|
|
|
|
|
find->r = r;
|
|
|
|
|
} else if (find->mode >= mode) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
find->mode = mode;
|
|
|
|
|
find->disbelieves |= dis;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-02 22:10:40 +01:00
|
|
|
|
typedef struct report_type {
|
|
|
|
|
struct report_type * next;
|
|
|
|
|
report_fun write;
|
|
|
|
|
const char * extension;
|
|
|
|
|
int flag;
|
|
|
|
|
} report_type;
|
|
|
|
|
|
|
|
|
|
static report_type * report_types;
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
register_reporttype(const char * extension, report_fun write, int flag)
|
|
|
|
|
{
|
|
|
|
|
report_type * type = malloc(sizeof(report_type));
|
|
|
|
|
type->extension = extension;
|
|
|
|
|
type->write = write;
|
|
|
|
|
type->flag = flag;
|
|
|
|
|
type->next = report_types;
|
|
|
|
|
report_types = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static region_list *
|
|
|
|
|
get_regions_distance(region * root, int radius)
|
|
|
|
|
{
|
|
|
|
|
region_list * rptr, * rlist = NULL;
|
|
|
|
|
region_list ** rp = &rlist;
|
|
|
|
|
add_regionlist(rp, root);
|
|
|
|
|
fset(root, FL_MARK);
|
|
|
|
|
while (*rp) {
|
|
|
|
|
region_list * r = *rp;
|
|
|
|
|
direction_t d;
|
|
|
|
|
rp = &r->next;
|
|
|
|
|
for (d=0;d!=MAXDIRECTIONS;++d) {
|
|
|
|
|
region * rn = rconnect(r->data, d);
|
|
|
|
|
if (rn!=NULL && !fval(rn, FL_MARK) && distance(rn, root)<=radius) {
|
|
|
|
|
add_regionlist(rp, rn);
|
|
|
|
|
fset(rn, FL_MARK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (rptr=rlist;rptr;rptr=rptr->next) {
|
|
|
|
|
freset(rptr->data, FL_MARK);
|
|
|
|
|
}
|
|
|
|
|
return rlist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
view_default(struct seen_region ** seen, region *r, faction *f)
|
|
|
|
|
{
|
|
|
|
|
direction_t dir;
|
|
|
|
|
for (dir=0;dir!=MAXDIRECTIONS;++dir) {
|
|
|
|
|
region * r2 = rconnect(r, dir);
|
|
|
|
|
if (r2) {
|
|
|
|
|
border * b = get_borders(r, r2);
|
|
|
|
|
while (b) {
|
|
|
|
|
if (!b->type->transparent(b, f)) break;
|
|
|
|
|
b = b->next;
|
|
|
|
|
}
|
|
|
|
|
if (!b) add_seen(seen, r2, see_neighbour, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
view_neighbours(struct seen_region ** seen, region * r, faction * f)
|
|
|
|
|
{
|
|
|
|
|
direction_t dir;
|
|
|
|
|
for (dir=0;dir!=MAXDIRECTIONS;++dir) {
|
|
|
|
|
region * r2 = rconnect(r, dir);
|
|
|
|
|
if (r2) {
|
|
|
|
|
border * b = get_borders(r, r2);
|
|
|
|
|
while (b) {
|
|
|
|
|
if (!b->type->transparent(b, f)) break;
|
|
|
|
|
b = b->next;
|
|
|
|
|
}
|
|
|
|
|
if (!b) {
|
|
|
|
|
if (add_seen(seen, r2, see_far, false)) {
|
|
|
|
|
if (!(fval(r2->terrain, FORBIDDEN_REGION))) {
|
|
|
|
|
direction_t dir;
|
|
|
|
|
for (dir=0;dir!=MAXDIRECTIONS;++dir) {
|
|
|
|
|
region * r3 = rconnect(r2, dir);
|
|
|
|
|
if (r3) {
|
|
|
|
|
border * b = get_borders(r2, r3);
|
|
|
|
|
while (b) {
|
|
|
|
|
if (!b->type->transparent(b, f)) break;
|
|
|
|
|
b = b->next;
|
|
|
|
|
}
|
|
|
|
|
if (!b) add_seen(seen, r3, see_neighbour, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
recurse_regatta(struct seen_region ** seen, region *center, region *r, faction *f, int maxdist)
|
|
|
|
|
{
|
|
|
|
|
direction_t dir;
|
|
|
|
|
int dist = distance(center, r);
|
|
|
|
|
for (dir=0;dir!=MAXDIRECTIONS;++dir) {
|
|
|
|
|
region * r2 = rconnect(r, dir);
|
|
|
|
|
if (r2) {
|
|
|
|
|
int ndist = distance(center, r2);
|
|
|
|
|
if (ndist>dist && fval(r2->terrain, SEA_REGION)) {
|
|
|
|
|
border * b = get_borders(r, r2);
|
|
|
|
|
while (b) {
|
|
|
|
|
if (!b->type->transparent(b, f)) break;
|
|
|
|
|
b = b->next;
|
|
|
|
|
}
|
|
|
|
|
if (!b) {
|
|
|
|
|
if (ndist<maxdist) {
|
|
|
|
|
if (add_seen(seen, r2, see_far, false)) {
|
|
|
|
|
recurse_regatta(seen, center, r2, f, maxdist);
|
|
|
|
|
}
|
|
|
|
|
} else add_seen(seen, r2, see_neighbour, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
view_regatta(struct seen_region ** seen, region * r, faction * f)
|
|
|
|
|
{
|
|
|
|
|
unit *u;
|
|
|
|
|
int skill = 0;
|
|
|
|
|
for (u=r->units; u; u=u->next) {
|
|
|
|
|
if (u->faction==f) {
|
|
|
|
|
int es = effskill(u, SK_OBSERVATION);
|
|
|
|
|
if (es>skill) skill=es;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
recurse_regatta(seen, r, r, f, skill/2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct seen_region **
|
|
|
|
|
prepare_report(faction * f)
|
|
|
|
|
{
|
|
|
|
|
region * r;
|
|
|
|
|
region * end = lastregion(f);
|
|
|
|
|
struct seen_region ** seen = seen_init();
|
|
|
|
|
|
|
|
|
|
static const struct building_type * bt_lighthouse = NULL;
|
|
|
|
|
if (bt_lighthouse==NULL) bt_lighthouse = bt_find("lighthouse");
|
|
|
|
|
|
|
|
|
|
for (r = firstregion(f); r != end; r = r->next) {
|
|
|
|
|
attrib *ru;
|
|
|
|
|
unit * u;
|
|
|
|
|
plane * p = rplane(r);
|
|
|
|
|
unsigned char mode = see_none;
|
|
|
|
|
boolean dis = false;
|
|
|
|
|
int light = 0;
|
|
|
|
|
|
|
|
|
|
if (p) {
|
|
|
|
|
watcher * w = p->watchers;
|
|
|
|
|
while (w) {
|
|
|
|
|
if (f==w->faction) {
|
|
|
|
|
mode = w->mode;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
w = w->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (u = r->units; u; u = u->next) {
|
|
|
|
|
if (u->faction == f) {
|
|
|
|
|
if (u->building && u->building->type==bt_lighthouse) {
|
|
|
|
|
int r = lighthouse_range(u->building, f);
|
|
|
|
|
if (r>light) light = r;
|
|
|
|
|
}
|
|
|
|
|
if (u->race != new_race[RC_SPELL] || u->number == RS_FARVISION) {
|
|
|
|
|
mode = see_unit;
|
|
|
|
|
if (fval(u, UFL_DISBELIEVES)) {
|
|
|
|
|
dis = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (light) {
|
|
|
|
|
/* we are in a lighthouse. add the others! */
|
|
|
|
|
region_list * rlist = get_regions_distance(r, light);
|
|
|
|
|
region_list * rp = rlist;
|
|
|
|
|
while (rp) {
|
|
|
|
|
region * rl = rp->data;
|
|
|
|
|
if (fval(rl->terrain, SEA_REGION)) {
|
|
|
|
|
direction_t d;
|
|
|
|
|
add_seen(seen, rl, see_lighthouse, false);
|
|
|
|
|
for (d=0;d!=MAXDIRECTIONS;++d) {
|
|
|
|
|
region * rn = rconnect(rl, d);
|
|
|
|
|
if (rn!=NULL) {
|
|
|
|
|
add_seen(seen, rn, see_neighbour, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
rp = rp->next;
|
|
|
|
|
}
|
|
|
|
|
free_regionlist(rlist);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mode<see_travel && fval(r, RF_TRAVELUNIT)) {
|
|
|
|
|
for (ru = a_find(r->attribs, &at_travelunit); ru; ru = ru->nexttype) {
|
|
|
|
|
unit * u = (unit*)ru->data.v;
|
|
|
|
|
if (u->faction == f) {
|
|
|
|
|
mode = see_travel;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mode == see_none)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
add_seen(seen, r, mode, dis);
|
|
|
|
|
/* nicht, wenn Verwirrung herrscht: */
|
|
|
|
|
if (!is_cursed(r->attribs, C_REGCONF, 0)) {
|
|
|
|
|
void (*view)(struct seen_region **, region * r, faction * f) = view_default;
|
|
|
|
|
if (p && fval(p, PFL_SEESPECIAL)) {
|
|
|
|
|
attrib * a = a_find(p->attribs, &at_viewrange);
|
|
|
|
|
if (a) view = (void (*)(struct seen_region **, region * r, faction * f))a->data.f;
|
|
|
|
|
}
|
|
|
|
|
view(seen, r, f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return seen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
write_reports(faction * f, time_t ltime)
|
|
|
|
|
{
|
|
|
|
|
boolean gotit = false;
|
|
|
|
|
struct seen_region ** seen = prepare_report(f);
|
|
|
|
|
faction_list * addresses = get_addresses(f, seen);
|
|
|
|
|
report_type * rtype = report_types;
|
|
|
|
|
struct report_context ctx;
|
|
|
|
|
|
|
|
|
|
ctx.f = f;
|
|
|
|
|
ctx.addresses = addresses;
|
|
|
|
|
ctx.report_time = time(NULL);
|
|
|
|
|
ctx.seen = seen;
|
|
|
|
|
ctx.userdata = NULL;
|
|
|
|
|
|
|
|
|
|
printf("Reports f<>r %s: ", factionname(f));
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
|
|
for (;rtype!=NULL;rtype=rtype->next) {
|
|
|
|
|
if (f->options & rtype->flag) {
|
|
|
|
|
FILE * F;
|
|
|
|
|
sprintf(buf, "%s/%d-%s.%s", reportpath(), turn, factionid(f), rtype->extension);
|
|
|
|
|
F = fopen(buf, "wt");
|
|
|
|
|
if (F!=NULL) {
|
|
|
|
|
rtype->write(F, &ctx);
|
|
|
|
|
fclose(F);
|
|
|
|
|
gotit = true;
|
|
|
|
|
} else {
|
|
|
|
|
perror(buf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("Reports for %s: DONE\n", factionname(f));
|
|
|
|
|
if (!gotit) {
|
|
|
|
|
log_warning(("No report for faction %s!\n", factionid(f)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
freelist(addresses);
|
|
|
|
|
seen_done(seen);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nmr_warnings(void)
|
|
|
|
|
{
|
|
|
|
|
faction *f,*fa;
|
|
|
|
|
#define FRIEND (HELP_GUARD|HELP_MONEY)
|
|
|
|
|
for (f=factions;f;f=f->next) {
|
|
|
|
|
if (f->no != MONSTER_FACTION && (turn-f->lastorders) >= 2) {
|
|
|
|
|
message * msg = NULL;
|
|
|
|
|
for (fa=factions;fa;fa=fa->next) {
|
|
|
|
|
if (alliedfaction(NULL, f, fa, FRIEND) && alliedfaction(NULL, fa, f, FRIEND)) {
|
|
|
|
|
if (msg==NULL) {
|
|
|
|
|
sprintf(buf, "Achtung: %s hat einige Zeit keine "
|
|
|
|
|
"Z<EFBFBD>ge eingeschickt und k<>nnte dadurch in K<>rze aus dem "
|
|
|
|
|
"Spiel ausscheiden.", factionname(f));
|
|
|
|
|
msg = msg_message("msg_event", "string", buf);
|
|
|
|
|
}
|
|
|
|
|
add_message(&fa->msgs, msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (msg!=NULL) msg_release(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
report_donations(void)
|
|
|
|
|
{
|
|
|
|
|
region * r;
|
|
|
|
|
for (r=regions;r;r=r->next) {
|
|
|
|
|
while (r->donations) {
|
|
|
|
|
donation * sp = r->donations;
|
|
|
|
|
if (sp->amount > 0) {
|
|
|
|
|
struct message * msg = msg_message("donation",
|
|
|
|
|
"from to amount", sp->f1, sp->f2, sp->amount);
|
|
|
|
|
r_addmessage(r, sp->f1, msg);
|
|
|
|
|
r_addmessage(r, sp->f2, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
}
|
|
|
|
|
r->donations = sp->next;
|
|
|
|
|
free(sp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
write_script(FILE * F, const faction * f)
|
|
|
|
|
{
|
|
|
|
|
report_type * rtype;
|
|
|
|
|
|
|
|
|
|
fprintf(F, "faction=%s:email=%s", factionid(f), f->email);
|
|
|
|
|
if (f->options & (1<<O_BZIP2)) fputs(":compression=bz2", F);
|
|
|
|
|
else fputs(":compression=zip", F);
|
|
|
|
|
|
|
|
|
|
fputs(":reports=", F);
|
|
|
|
|
buf[0] = 0;
|
|
|
|
|
for (rtype=report_types;rtype!=NULL;rtype=rtype->next) {
|
|
|
|
|
if (f->options&rtype->flag) {
|
|
|
|
|
if (buf[0]) strcat(buf, ",");
|
|
|
|
|
strcat(buf, rtype->extension);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fputs(buf, F);
|
|
|
|
|
fputc('\n', F);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
static void
|
|
|
|
|
global_report(const char * filename)
|
|
|
|
|
{
|
|
|
|
|
FILE * F = fopen(filename, "w");
|
|
|
|
|
region * r;
|
|
|
|
|
faction * f;
|
|
|
|
|
faction * monsters = findfaction(MONSTER_FACTION);
|
|
|
|
|
faction_list * addresses = NULL;
|
|
|
|
|
struct seen_region ** seen;
|
|
|
|
|
|
|
|
|
|
if (!monsters) return;
|
|
|
|
|
if (!F) return;
|
|
|
|
|
|
|
|
|
|
/* list of all addresses */
|
|
|
|
|
for (f=factions;f;f=f->next) {
|
|
|
|
|
faction_list * flist = calloc(1, sizeof(faction_list));
|
|
|
|
|
flist->data = f;
|
|
|
|
|
flist->next = addresses;
|
|
|
|
|
addresses = flist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
seen = seen_init();
|
|
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
|
add_seen(seen, r, see_unit, true);
|
|
|
|
|
}
|
|
|
|
|
report_computer(F, monsters, seen, addresses, time(NULL));
|
|
|
|
|
freelist(addresses);
|
|
|
|
|
seen_done(seen);
|
|
|
|
|
fclose(F);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
reports(void)
|
|
|
|
|
{
|
|
|
|
|
faction *f;
|
|
|
|
|
FILE *mailit;
|
|
|
|
|
time_t ltime = time(NULL);
|
|
|
|
|
const char * str;
|
|
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
|
|
nmr_warnings();
|
|
|
|
|
report_donations();
|
|
|
|
|
remove_empty_units();
|
|
|
|
|
|
|
|
|
|
sprintf(buf, "%s/reports.txt", reportpath());
|
|
|
|
|
mailit = fopen(buf, "w");
|
|
|
|
|
if (mailit == NULL) {
|
|
|
|
|
log_error(("%s konnte nicht ge<67>ffnet werden!\n", buf));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (f = factions; f; f = f->next) {
|
|
|
|
|
int error = write_reports(f, ltime);
|
|
|
|
|
if (error) retval = error;
|
|
|
|
|
if (mailit) write_script(mailit, f);
|
|
|
|
|
}
|
|
|
|
|
if (mailit) fclose(mailit);
|
|
|
|
|
free_seen();
|
|
|
|
|
str = get_param(global.parameters, "globalreport");
|
|
|
|
|
#if 0
|
|
|
|
|
if (str!=NULL) {
|
|
|
|
|
sprintf(buf, "%s/%s.%u.cr", reportpath(), str, turn);
|
|
|
|
|
global_report(buf);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static variant
|
|
|
|
|
var_copy_string(variant x)
|
|
|
|
|
{
|
|
|
|
|
x.v = strdup((const char*)x.v);
|
|
|
|
|
return x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
var_free_string(variant x)
|
|
|
|
|
{
|
|
|
|
|
free(x.v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static variant
|
|
|
|
|
var_copy_order(variant x)
|
|
|
|
|
{
|
|
|
|
|
x.v = copy_order((order*)x.v);
|
|
|
|
|
return x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
var_free_order(variant x)
|
|
|
|
|
{
|
|
|
|
|
free_order(x.v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
reports_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* register datatypes for the different message objects */
|
|
|
|
|
register_argtype("alliance", NULL, NULL, VAR_VOIDPTR);
|
|
|
|
|
register_argtype("building", NULL, NULL, VAR_VOIDPTR);
|
|
|
|
|
register_argtype("direction", NULL, NULL, VAR_INT);
|
|
|
|
|
register_argtype("faction", NULL, NULL, VAR_VOIDPTR);
|
|
|
|
|
register_argtype("race", NULL, NULL, VAR_VOIDPTR);
|
|
|
|
|
register_argtype("region", NULL, NULL, VAR_VOIDPTR);
|
|
|
|
|
register_argtype("resource", NULL, NULL, VAR_VOIDPTR);
|
|
|
|
|
register_argtype("ship", NULL, NULL, VAR_VOIDPTR);
|
|
|
|
|
register_argtype("skill", NULL, NULL, VAR_VOIDPTR);
|
|
|
|
|
register_argtype("spell", NULL, NULL, VAR_VOIDPTR);
|
|
|
|
|
register_argtype("unit", NULL, NULL, VAR_VOIDPTR);
|
|
|
|
|
register_argtype("int", NULL, NULL, VAR_INT);
|
|
|
|
|
register_argtype("string", var_free_string, var_copy_string, VAR_VOIDPTR);
|
|
|
|
|
register_argtype("order", var_free_order, var_copy_order, VAR_VOIDPTR);
|
|
|
|
|
|
|
|
|
|
/* register alternative visibility functions */
|
|
|
|
|
register_function((pf_generic)view_neighbours, "view_neighbours");
|
|
|
|
|
register_function((pf_generic)view_regatta, "view_regatta");
|
2005-11-06 12:33:19 +01:00
|
|
|
|
}
|