2001-01-25 10:37:55 +01:00
|
|
|
|
/* vi: set ts=2:
|
|
|
|
|
*
|
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2000
|
|
|
|
|
* 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 */
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#include "building.h"
|
2001-09-05 21:40:40 +02:00
|
|
|
|
#include "faction.h"
|
|
|
|
|
#include "group.h"
|
|
|
|
|
#include "item.h"
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#include "karma.h"
|
|
|
|
|
#include "magic.h"
|
2002-02-06 09:06:02 +01:00
|
|
|
|
#include "message.h"
|
2001-09-05 21:40:40 +02:00
|
|
|
|
#include "race.h"
|
|
|
|
|
#include "region.h"
|
|
|
|
|
#include "ship.h"
|
|
|
|
|
#include "skill.h"
|
|
|
|
|
#include "unit.h"
|
|
|
|
|
#include "plane.h"
|
2001-04-29 21:27:42 +02:00
|
|
|
|
#ifdef USE_UGROUPS
|
|
|
|
|
# include "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 */
|
|
|
|
|
#include <base36.h>
|
|
|
|
|
#include <goodies.h>
|
|
|
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
/* 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>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
const char * g_reportdir;
|
|
|
|
|
|
|
|
|
|
const char *neue_gebiete[] = {
|
|
|
|
|
"Kein Magiegebiet",
|
|
|
|
|
"Illaun",
|
|
|
|
|
"Tybied",
|
|
|
|
|
"Cerddor",
|
|
|
|
|
"Gwyrrd",
|
|
|
|
|
"Draig"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const char *coasts[MAXDIRECTIONS] =
|
|
|
|
|
{
|
|
|
|
|
"Nordwestk<EFBFBD>ste",
|
|
|
|
|
"Nordostk<EFBFBD>ste",
|
|
|
|
|
"Ostk<EFBFBD>ste",
|
|
|
|
|
"S<EFBFBD>dostk<EFBFBD>ste",
|
|
|
|
|
"S<EFBFBD>dwestk<EFBFBD>ste",
|
|
|
|
|
"Westk<EFBFBD>ste"
|
|
|
|
|
};
|
|
|
|
|
|
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]));
|
2002-02-06 09:06:02 +01:00
|
|
|
|
if (fval(u, FL_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) {
|
|
|
|
|
const herb_type * htype = resource2herb(i->type->rtype);
|
|
|
|
|
if (htype!=NULL) *number = 1;
|
|
|
|
|
else *number = i->number;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
int i, dh;
|
|
|
|
|
skill_t sk;
|
|
|
|
|
int getarnt = fval(u, FL_PARTEITARNUNG);
|
2001-09-05 21:40:40 +02:00
|
|
|
|
faction *fv;
|
|
|
|
|
attrib *a_otherfaction;
|
- 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
|
|
|
|
const char *pzTmp;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
spell *sp;
|
|
|
|
|
building * b;
|
|
|
|
|
boolean itemcloak = is_cursed(u->attribs, C_ITEMCLOAK, 0);
|
|
|
|
|
boolean isbattle = (boolean)(mode == see_battle);
|
|
|
|
|
int telepath_see = fspecial(f, FS_TELEPATHY);
|
|
|
|
|
attrib *a_fshidden = NULL;
|
|
|
|
|
item * itm;
|
|
|
|
|
item * show;
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if(fspecial(u->faction, FS_HIDDEN))
|
|
|
|
|
a_fshidden = a_find(u->attribs, &at_fshidden);
|
|
|
|
|
|
|
|
|
|
strcpy(buf, unitname(u));
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
|
|
|
|
fv = visible_faction(f,u);
|
2001-04-14 14:11:45 +02:00
|
|
|
|
a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2001-04-14 14:11:45 +02:00
|
|
|
|
if (u->faction == f) {
|
|
|
|
|
attrib *a = a_find(u->attribs, &at_group);
|
|
|
|
|
if (a) {
|
|
|
|
|
group * g = (group*)a->data.v;
|
|
|
|
|
scat(", ");
|
|
|
|
|
scat(groupid(g, f));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
2001-04-14 14:11:45 +02:00
|
|
|
|
if (getarnt) {
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat(", "); scat(LOC(f->locale, "anonymous"));
|
2001-04-14 14:11:45 +02:00
|
|
|
|
} else if (a_otherfaction) {
|
|
|
|
|
scat(", ");
|
|
|
|
|
scat(factionname(findfaction(a_otherfaction->data.i)));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (getarnt) {
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat(", "); scat(LOC(f->locale, "anonymous"));
|
2001-04-14 14:11:45 +02:00
|
|
|
|
} else {
|
|
|
|
|
scat(", ");
|
2001-09-05 21:40:40 +02:00
|
|
|
|
if(a_otherfaction
|
|
|
|
|
&& allied(u, f, HELP_FSTEALTH)) {
|
|
|
|
|
scat(factionname(findfaction(a_otherfaction->data.i)));
|
|
|
|
|
scat(" (");
|
|
|
|
|
scat(factionname(u->faction));
|
|
|
|
|
scat(")");
|
|
|
|
|
} else {
|
|
|
|
|
scat(factionname(fv));
|
|
|
|
|
}
|
2001-04-14 14:11:45 +02:00
|
|
|
|
}
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
2001-04-14 14:11:45 +02:00
|
|
|
|
|
2001-12-10 01:13:39 +01:00
|
|
|
|
#ifdef USE_UGROUPS
|
|
|
|
|
if(u->faction == f) {
|
|
|
|
|
attrib *a = a_find(u->attribs, &at_ugroup);
|
|
|
|
|
if(a) {
|
|
|
|
|
ugroup *ug = findugroupid(u->faction, a->data.i);
|
|
|
|
|
if(is_ugroupleader(u, ug)) {
|
|
|
|
|
scat("*");
|
|
|
|
|
}
|
|
|
|
|
scat(itoa36(ug->id));
|
|
|
|
|
}
|
|
|
|
|
scat(", ");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
scat(", ");
|
2001-04-28 17:39:13 +02:00
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if(u->faction != f && a_fshidden
|
2001-03-07 16:00:18 +01:00
|
|
|
|
&& a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 6) {
|
2001-01-25 10:37:55 +01:00
|
|
|
|
scat("? ");
|
|
|
|
|
} else {
|
|
|
|
|
icat(u->number);
|
|
|
|
|
scat(" ");
|
|
|
|
|
}
|
|
|
|
|
|
- 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
|
|
|
|
pzTmp = get_racename(u->attribs);
|
|
|
|
|
if (pzTmp || u->irace != u->race) {
|
2001-09-05 21:40:40 +02:00
|
|
|
|
if (pzTmp)
|
|
|
|
|
scat(pzTmp);
|
|
|
|
|
else
|
|
|
|
|
scat(racename(f->locale, u, u->irace));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if (u->faction == f) {
|
|
|
|
|
scat(" (");
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat(racename(f->locale, u, u->race));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
scat(")");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat(racename(f->locale, u, u->race));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* status */
|
|
|
|
|
|
|
|
|
|
if (u->number && (u->faction == f || telepath_see || isbattle)) {
|
2002-02-06 09:06:02 +01:00
|
|
|
|
const char * c = locale_string(f->locale, hp_status(u));
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat(", ");
|
|
|
|
|
scat(report_kampfstatus(u, f->locale));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if (c || fval(u, FL_HUNGER)) {
|
|
|
|
|
scat(" (");
|
|
|
|
|
if(c) scat(c);
|
|
|
|
|
if(fval(u, FL_HUNGER)) {
|
|
|
|
|
if (c) scat(", hungert");
|
|
|
|
|
else scat("hungert");
|
|
|
|
|
}
|
|
|
|
|
scat(")");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (getguard(u)) scat(", bewacht die Region");
|
|
|
|
|
|
|
|
|
|
if (u->faction==f || telepath_see) {
|
|
|
|
|
attrib * a = a_find(u->attribs, &at_follow);
|
|
|
|
|
if (a) {
|
2001-02-09 14:53:53 +01:00
|
|
|
|
unit * uf = (unit*)a->data.v;
|
|
|
|
|
if (uf) {
|
2001-01-25 10:37:55 +01:00
|
|
|
|
scat(", folgt ");
|
2001-02-09 14:53:53 +01:00
|
|
|
|
scat(itoa36(uf->no));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((b = usiege(u))!=NULL) {
|
|
|
|
|
scat(", belagert ");
|
|
|
|
|
scat(buildingname(b));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dh = 0;
|
|
|
|
|
if (u->faction == f || telepath_see) {
|
|
|
|
|
for (sk = 0; sk != MAXSKILLS; sk++) {
|
2001-04-16 16:34:19 +02:00
|
|
|
|
spskill(f->locale, u, sk, &dh, 1);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dh = 0;
|
2001-12-10 01:13:39 +01:00
|
|
|
|
if (f == u->faction || telepath_see || omniscient(f)) {
|
2001-01-25 10:37:55 +01:00
|
|
|
|
show = u->items;
|
|
|
|
|
} else if (!itemcloak && mode >= see_unit && !(a_fshidden
|
2001-03-07 16:00:18 +01:00
|
|
|
|
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH) >= 3)) {
|
2001-01-25 10:37:55 +01:00
|
|
|
|
show = NULL;
|
|
|
|
|
for (itm=u->items;itm;itm=itm->next) {
|
|
|
|
|
item * ishow;
|
|
|
|
|
const char * ic;
|
|
|
|
|
int in;
|
2001-02-17 16:52:47 +01:00
|
|
|
|
report_item(u, itm, f, NULL, &ic, &in, false);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if (ic && *ic && in>0) {
|
|
|
|
|
for (ishow = show; ishow; ishow=ishow->next) {
|
|
|
|
|
const char * sc;
|
|
|
|
|
int sn;
|
|
|
|
|
if (ishow->type==itm->type) sc=ic;
|
2001-02-17 16:52:47 +01:00
|
|
|
|
else report_item(u, ishow, f, NULL, &sc, &sn, false);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
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-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
show = NULL;
|
|
|
|
|
}
|
|
|
|
|
for (itm=show; itm; itm=itm->next) {
|
|
|
|
|
const char * ic;
|
|
|
|
|
int in;
|
2001-02-17 16:52:47 +01:00
|
|
|
|
report_item(u, itm, f, &ic, NULL, &in, false);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if (in==0 || ic==NULL) continue;
|
|
|
|
|
scat(", ");
|
|
|
|
|
|
|
|
|
|
if (!dh) {
|
2001-04-22 07:36:50 +02:00
|
|
|
|
sprintf(buf+strlen(buf), "%s: ", LOC(f->locale, "nr_inventory"));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
dh = 1;
|
|
|
|
|
}
|
|
|
|
|
if (in == 1) {
|
|
|
|
|
scat(ic);
|
|
|
|
|
} else {
|
|
|
|
|
icat(in);
|
|
|
|
|
scat(" ");
|
|
|
|
|
scat(ic);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (show!=u->items) while (show) i_free(i_remove(&show, show));
|
|
|
|
|
|
|
|
|
|
if (u->faction == f || telepath_see) {
|
|
|
|
|
dh = 0;
|
|
|
|
|
|
|
|
|
|
if (is_mage(u) == true) {
|
|
|
|
|
scat(". Aura ");
|
|
|
|
|
icat(get_spellpoints(u));
|
|
|
|
|
scat("/");
|
|
|
|
|
icat(max_spellpoints(u->region,u));
|
|
|
|
|
{
|
|
|
|
|
spell_ptr *spt;
|
|
|
|
|
int t = effskill(u, SK_MAGIC);
|
|
|
|
|
|
|
|
|
|
for (spt = get_mage(u)->spellptr;spt; spt = spt->next){
|
|
|
|
|
sp = find_spellbyid(spt->spellid);
|
|
|
|
|
if(sp->level > t){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!dh){
|
2001-04-22 07:36:50 +02:00
|
|
|
|
sprintf(buf+strlen(buf),", %s: ", LOC(f->locale, "nr_spells"));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
dh = 1;
|
|
|
|
|
}else{
|
|
|
|
|
scat(", ");
|
|
|
|
|
}
|
|
|
|
|
scat(sp->name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dh = 0;
|
|
|
|
|
for (i = 0; i < MAXCOMBATSPELLS; i++){
|
|
|
|
|
sp = get_combatspell(u,i);
|
|
|
|
|
if (sp) {
|
|
|
|
|
dh = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(dh){
|
|
|
|
|
dh = 0;
|
2001-04-22 07:36:50 +02:00
|
|
|
|
sprintf(buf+strlen(buf),", %s: ", LOC(f->locale, "nr_combatspells"));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
for (i = 0; i < MAXCOMBATSPELLS; i++){
|
|
|
|
|
if (!dh){
|
|
|
|
|
dh = 1;
|
|
|
|
|
}else{
|
|
|
|
|
scat(", ");
|
|
|
|
|
}
|
|
|
|
|
sp = get_combatspell(u,i);
|
|
|
|
|
if (sp) {
|
|
|
|
|
int sl;
|
|
|
|
|
scat(sp->name);
|
|
|
|
|
if((sl = get_combatspelllevel(u,i)) > 0) {
|
|
|
|
|
scat(" (");
|
|
|
|
|
icat(sl);
|
|
|
|
|
scat(")");
|
|
|
|
|
}
|
|
|
|
|
}else{
|
2001-04-22 07:36:50 +02:00
|
|
|
|
scat(LOC(f->locale, "nr_nospells"));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isbattle && u->lastorder[0]) {
|
|
|
|
|
scat(", \"");
|
|
|
|
|
scat(u->lastorder);
|
|
|
|
|
scat("\"");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
|
|
if (u->display[0]) {
|
|
|
|
|
scat("; ");
|
|
|
|
|
scat(u->display);
|
|
|
|
|
|
|
|
|
|
i = u->display[strlen(u->display) - 1];
|
|
|
|
|
}
|
|
|
|
|
if (i != '!' && i != '?' && i != '.')
|
|
|
|
|
scat(".");
|
|
|
|
|
|
- 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
|
|
|
|
pzTmp = uprivate(u);
|
|
|
|
|
if (u->faction == f && pzTmp) {
|
2001-01-25 10:37:55 +01:00
|
|
|
|
scat(" (Bem: ");
|
- 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
|
|
|
|
scat(pzTmp);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
scat(")");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dh=0;
|
|
|
|
|
if (!getarnt && f && f->allies) {
|
|
|
|
|
ally *sf;
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
2001-01-25 10:37:55 +01: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-01-25 10:37:55 +01:00
|
|
|
|
dh = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return dh;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
int
|
2001-04-28 17:39:13 +02:00
|
|
|
|
bufunit_ugroupleader(const faction * f, const unit * u, int indent, int mode)
|
|
|
|
|
{
|
|
|
|
|
int i, dh;
|
|
|
|
|
int getarnt = fval(u, FL_PARTEITARNUNG);
|
2001-09-05 21:40:40 +02:00
|
|
|
|
faction *fv;
|
2001-04-28 17:39:13 +02:00
|
|
|
|
const char *pzTmp;
|
|
|
|
|
boolean itemcloak = is_cursed(u->attribs, C_ITEMCLOAK, 0);
|
|
|
|
|
attrib *a_fshidden = NULL;
|
|
|
|
|
item * itm;
|
|
|
|
|
item * show;
|
|
|
|
|
ugroup *ug = findugroup(u);
|
|
|
|
|
boolean guards = false;
|
|
|
|
|
boolean sieges = false;
|
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];
|
|
|
|
|
if(!itemcloak && mode >= see_unit && !(a_fshidden
|
|
|
|
|
&& 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;
|
|
|
|
|
if (u->display[0]) {
|
|
|
|
|
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
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
void
|
2002-02-15 17:13:30 +01:00
|
|
|
|
spskill(const struct locale * lang, const struct unit * u, skill_t sk, int *dh,
|
|
|
|
|
boolean days)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
{
|
2001-04-22 07:36:50 +02:00
|
|
|
|
char * sbuf = buf+strlen(buf);
|
2002-02-22 20:41:20 +01:00
|
|
|
|
int i, effsk;
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if (!u->number)
|
|
|
|
|
return;
|
|
|
|
|
|
2002-02-15 17:13:30 +01:00
|
|
|
|
if (!has_skill(u, sk)) return;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2001-04-22 07:36:50 +02:00
|
|
|
|
strcat(sbuf, ", "); sbuf+=2;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
if (!*dh) {
|
2001-04-22 07:36:50 +02:00
|
|
|
|
sbuf += sprintf(sbuf, "%s: ", LOC(lang, "nr_skills"));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
*dh = 1;
|
|
|
|
|
}
|
2001-04-22 07:36:50 +02:00
|
|
|
|
sbuf += sprintf(sbuf, "%s ", skillname(sk, lang));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
if (sk == SK_MAGIC){
|
|
|
|
|
if (find_magetype(u) != M_GRAU){
|
2001-04-22 07:36:50 +02:00
|
|
|
|
sbuf += sprintf(sbuf, "%s ", magietypen[find_magetype(u)]);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-19 15:19:24 +01:00
|
|
|
|
if (sk == SK_STEALTH) {
|
|
|
|
|
i = u_geteffstealth(u);
|
|
|
|
|
if(i>=0) {
|
2001-04-22 07:36:50 +02:00
|
|
|
|
sbuf += sprintf(sbuf, "%d/", i);
|
2001-02-19 15:19:24 +01:00
|
|
|
|
}
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-22 20:41:20 +01:00
|
|
|
|
effsk = effskill(u, sk);
|
|
|
|
|
sbuf += sprintf(sbuf, "%d", effsk);
|
|
|
|
|
|
|
|
|
|
#if SKILLPOINTS == 1
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if (days) {
|
|
|
|
|
assert(u->number);
|
2002-02-15 17:13:30 +01:00
|
|
|
|
sbuf += sprintf(sbuf, " [%d]", get_skill(u, sk) / u->number);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
2002-02-22 20:41:20 +01:00
|
|
|
|
#else
|
2002-02-23 20:04:51 +01:00
|
|
|
|
if(u->faction->options & Pow(O_SHOWSKCHANGE)) {
|
|
|
|
|
skill *skill = get_skill(u, sk);
|
2002-02-24 18:53:23 +01:00
|
|
|
|
int oldeff = 0;
|
2002-02-23 20:04:51 +01:00
|
|
|
|
int diff;
|
|
|
|
|
|
2002-02-24 18:53:23 +01:00
|
|
|
|
if(skill->old > 0) {
|
|
|
|
|
oldeff = skill->old + get_modifier(u, sk, skill->old, u->region);
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-23 20:04:51 +01:00
|
|
|
|
oldeff = max(0, oldeff);
|
|
|
|
|
diff = effsk - oldeff;
|
|
|
|
|
|
|
|
|
|
if(diff != 0) {
|
|
|
|
|
sbuf += sprintf(sbuf, " (%s%hd)", (diff>0)?"+":"", diff);
|
2002-02-22 20:41:20 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-02-19 15:19:24 +01:00
|
|
|
|
#endif
|
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)
|
|
|
|
|
{
|
2001-04-28 17:39:13 +02:00
|
|
|
|
int dh;
|
2001-04-29 21:27:42 +02:00
|
|
|
|
#ifdef USE_UGROUPS
|
2001-04-28 17:39:13 +02:00
|
|
|
|
ugroup *ug = findugroup(u);
|
|
|
|
|
|
|
|
|
|
if(ug) {
|
|
|
|
|
if(is_ugroupleader(u, ug)) {
|
|
|
|
|
dh = bufunit_ugroupleader(f, u, indent, mode);
|
|
|
|
|
} else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2001-04-29 21:27:42 +02:00
|
|
|
|
} else
|
|
|
|
|
#endif
|
2001-04-28 17:39:13 +02:00
|
|
|
|
dh = bufunit(f, u, indent, mode);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
lparagraph(SP, buf, indent, (char) ((u->faction == f) ? '*' : (dh ? '+' : '-')));
|
|
|
|
|
}
|
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){
|
|
|
|
|
/* bei Magiern Zauberspr<70>che und Magiegebiet */
|
|
|
|
|
if (is_mage(target)){
|
|
|
|
|
spell_ptr *spt;
|
|
|
|
|
spell *sp;
|
2001-03-01 00:28:55 +01:00
|
|
|
|
int first = 1;
|
|
|
|
|
int found = 0;
|
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat("Magiegebiet: ");
|
|
|
|
|
scat(magietypen[find_magetype(target)]);
|
|
|
|
|
if (get_mage(target)) {
|
|
|
|
|
scat(", Spr<70>che: ");
|
|
|
|
|
|
|
|
|
|
for (spt = get_mage(target)->spellptr;spt; spt = spt->next){
|
|
|
|
|
sp = find_spellbyid(spt->spellid);
|
2001-03-01 00:28:55 +01:00
|
|
|
|
found++;
|
2001-09-05 21:40:40 +02:00
|
|
|
|
if (first == 1){
|
2001-03-01 00:28:55 +01:00
|
|
|
|
first = 0;
|
|
|
|
|
} else {
|
|
|
|
|
scat(", ");
|
|
|
|
|
}
|
2001-09-05 21:40:40 +02:00
|
|
|
|
scat(sp->name);
|
|
|
|
|
}
|
|
|
|
|
if (found == 0) {
|
|
|
|
|
scat("Keine");
|
2001-03-01 00:28:55 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
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("'. ");
|
|
|
|
|
} else if (!fval(target, FL_PARTEITARNUNG)){
|
|
|
|
|
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-02-06 09:06:02 +01:00
|
|
|
|
ADDMSG(&u->faction->msgs, msg_message("spyreport",
|
|
|
|
|
"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 *
|
|
|
|
|
visible_faction(const faction *f, const unit * u)
|
|
|
|
|
{
|
|
|
|
|
if(!allied(u, f, HELP_FSTEALTH)) {
|
|
|
|
|
attrib *a = a_find(u->attribs, &at_otherfaction);
|
|
|
|
|
if (a) return get_otherfaction(a);
|
|
|
|
|
}
|
|
|
|
|
return u->faction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
faction_list *
|
|
|
|
|
get_addresses(const faction * f, const seen_region * seenregions)
|
|
|
|
|
{
|
|
|
|
|
/* "TODO: travelthru" */
|
|
|
|
|
const seen_region * sr = seenregions;
|
|
|
|
|
const faction * lastf = NULL;
|
|
|
|
|
faction_list * flist = calloc(1, sizeof(faction_list));
|
|
|
|
|
flist->data = findfaction(f->no);
|
|
|
|
|
while (sr!=NULL) {
|
|
|
|
|
const region * r = sr->r;
|
|
|
|
|
const unit * u = r->units;
|
|
|
|
|
while (u!=NULL) {
|
|
|
|
|
faction * sf = visible_faction(f, u);
|
|
|
|
|
if (sf && sf!=f && sf!=lastf && !fval(u, FL_PARTEITARNUNG) && cansee(f, r, u, 0)) {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
sr = sr->next;
|
|
|
|
|
}
|
|
|
|
|
return flist;
|
|
|
|
|
}
|