- fixed the summary.c

- implemented unicode_utf8_strcasecmp function
- fixed some xml files
- code compiles and runs on the console

TODO:
* switch from xmlChar to char again
* eliminate remaining warnings
* report.[hc] are still disabled

OPTIONAL:
* handle latin1 input?
This commit is contained in:
Enno Rehling 2007-08-09 06:42:37 +00:00
parent 940d236edc
commit 6acb1e22c5
21 changed files with 550 additions and 535 deletions

View file

@ -119,9 +119,6 @@
#define DMRISEHAFEN 0.2F /* weekly chance that demand goes up with harbor */
/* - external symbols ------------------------------------------ */
extern int dropouts[2];
extern int * age;
/* - exported global symbols ----------------------------------- */
boolean nobattle = false;
boolean nomonsters = false;
@ -1027,6 +1024,9 @@ quit(void)
}
}
int dropouts[2];
int * age = NULL;
static void
parse_restart(void)
{

View file

@ -38,6 +38,9 @@ void update_guards(void);
void processorders(void);
extern struct attrib_type at_germs;
extern int dropouts[2];
extern int * age;
#ifdef __cplusplus
}
#endif

View file

@ -101,12 +101,6 @@ extern int *storms;
extern int weeks_per_month;
extern int months_per_year;
boolean nocr = false;
boolean nonr = false;
boolean nosh = false;
boolean nomer = false;
boolean noreports = false;
static size_t
strxcpy(char * dst, const char * src) {
size_t s = 0;
@ -132,21 +126,6 @@ gamedate_season(const struct locale * lang)
return buf;
}
static char *
gamedate2(const struct locale * lang)
{
static char buf[256];
gamedate gd;
get_gamedate(turn, &gd);
sprintf(buf, "in %s des Monats %s im Jahre %d %s.",
LOC(lang, weeknames2[gd.week]),
LOC(lang, monthnames[gd.month]),
gd.year,
LOC(lang, agename));
return buf;
}
void
rpc(FILE * F, char c, size_t num)
{
@ -2187,26 +2166,6 @@ struct fsee {
#define REPORT_ZIP (1 << O_COMPRESS)
#define REPORT_BZIP2 (1 << O_BZIP2)
int
init_reports(void)
{
update_intervals();
#ifdef HAVE_STAT
{
stat_type st;
if (stat(reportpath(), &st)==0) return 0;
}
#endif
if (makedir(reportpath(), 0700)!=0) {
if (errno!=EEXIST) {
perror("could not create reportpath");
return -1;
}
}
return 0;
}
unit *
can_find(faction * f, faction * f2)
@ -2284,166 +2243,6 @@ kann_finden(faction * f1, faction * f2)
return (boolean)(can_find(f1, f2)!=NULL);
}
/******* summary *******/
int dropouts[2];
int * age = NULL;
typedef struct summary {
int waffen;
int factions;
int ruestungen;
int schiffe;
int gebaeude;
int maxskill;
int heroes;
int inhabitedregions;
int peasants;
int nunits;
int playerpop;
double playermoney;
double peasantmoney;
int armed_men;
int poprace[MAXRACES];
int factionrace[MAXRACES];
int landregionen;
int regionen_mit_spielern;
int landregionen_mit_spielern;
int orkifizierte_regionen;
int inactive_volcanos;
int active_volcanos;
int spielerpferde;
int pferde;
struct language {
struct language * next;
int number;
const struct locale * locale;
} * languages;
} summary;
summary *
make_summary(void)
{
faction *f;
region *r;
unit *u;
summary * s = calloc(1, sizeof(summary));
for (f = factions; f; f = f->next) {
const struct locale * lang = f->locale;
struct language * plang = s->languages;
while (plang && plang->locale != lang) plang=plang->next;
if (!plang) {
plang = calloc(sizeof(struct language), 1);
plang->next = s->languages;
s->languages = plang;
plang->locale = lang;
}
++plang->number;
f->nregions = 0;
f->num_total = 0;
f->money = 0;
if (f->alive && f->units) {
s->factions++;
/* Problem mit Monsterpartei ... */
if (f->no!=MONSTER_FACTION) {
s->factionrace[old_race(f->race)]++;
}
}
}
/* Alles zählen */
for (r = regions; r; r = r->next) {
s->pferde += rhorses(r);
s->schiffe += listlen(r->ships);
s->gebaeude += listlen(r->buildings);
if (!fval(r->terrain, SEA_REGION)) {
s->landregionen++;
if (r->units) {
s->landregionen_mit_spielern++;
}
if (fval(r, RF_ORCIFIED)) {
s->orkifizierte_regionen++;
}
if (rterrain(r) == T_VOLCANO) {
s->inactive_volcanos++;
} else if(rterrain(r) == T_VOLCANO_SMOKING) {
s->active_volcanos++;
}
}
if (r->units) {
s->regionen_mit_spielern++;
}
if (rpeasants(r) || r->units) {
s->inhabitedregions++;
s->peasants += rpeasants(r);
s->peasantmoney += rmoney(r);
/* Einheiten Info. nregions darf nur einmal pro Partei
* incrementiert werden. */
for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
for (u = r->units; u; u = u->next) {
f = u->faction;
if (u->faction->no != MONSTER_FACTION) {
skill * sv;
item * itm;
s->nunits++;
s->playerpop += u->number;
if (u->flags & UFL_HERO) {
s->heroes += u->number;
}
s->spielerpferde += get_item(u, I_HORSE);
s->playermoney += get_money(u);
s->armed_men += armedmen(u);
for (itm=u->items;itm;itm=itm->next) {
if (itm->type->rtype->wtype) {
s->waffen += itm->number;
}
if (itm->type->rtype->atype) {
s->ruestungen += itm->number;
}
}
s->spielerpferde += get_item(u, I_HORSE);
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
skill_t sk = sv->id;
int aktskill = eff_skill(u, sk, r);
if (aktskill > s->maxskill) s->maxskill = aktskill;
}
if (!fval(f, FFL_SELECT)) {
f->nregions++;
fset(f, FFL_SELECT);
}
}
f->num_total += u->number;
f->money += get_money(u);
s->poprace[old_race(u->race)] += u->number;
}
}
}
return s;
}
static char *
pcomp(double i, double j)
{
sprintf(buf, "%.0f (%s%.0f)", i, (i>=j)?"+":"", i-j);
return buf;
}
static char *
rcomp(int i, int j)
{
sprintf(buf, "%d (%s%d,%s%d%%)",
i, (i>=j)?"+":"", i-j, (i>=j)?"+":"",j?((i-j)*100)/j:0);
return buf;
}
static void
writemonument(void)
{
@ -2525,204 +2324,6 @@ writemonument(void)
}
static void
writeturn(void)
{
char zText[MAX_PATH];
FILE *f;
sprintf(zText, "%s/datum", basepath());
f = cfopen(zText, "w");
if (!f) return;
fputs(gamedate2(default_locale), f);
fclose(f);
sprintf(zText, "%s/turn", basepath());
f = cfopen(zText, "w");
if (!f) return;
fprintf(f, "%d\n", turn);
fclose(f);
}
static void
out_faction(FILE *file, faction *f)
{
if (alliances!=NULL) {
fprintf(file, "%s (%s/%d) (%.3s/%.3s), %d Einh., %d Pers., $%d, %d NMR\n",
f->name, itoa36(f->no), f->alliance?f->alliance->id:0,
LOC(default_locale, rc_name(f->race, 0)), magietypen[f->magiegebiet],
f->no_units, f->num_total, f->money, turn - f->lastorders);
} else {
fprintf(file, "%s (%.3s/%.3s), %d Einh., %d Pers., $%d, %d NMR\n",
factionname(f), LOC(default_locale, rc_name(f->race, 0)),
magietypen[f->magiegebiet], f->no_units, f->num_total, f->money,
turn - f->lastorders);
}
}
void
report_summary(summary * s, summary * o, boolean full)
{
FILE * F = NULL;
int i, newplayers = 0;
faction * f;
char zText[MAX_PATH];
if (full) {
sprintf(zText, "%s/parteien.full", basepath());
} else {
sprintf(zText, "%s/parteien", basepath());
}
F = cfopen(zText, "w");
if (!F) return;
printf("Schreibe Zusammenfassung (parteien)...\n");
fprintf(F, "%s\n%s\n\n", global.gamename, gamedate2(default_locale));
fprintf(F, "Auswertung Nr: %d\n\n", turn);
fprintf(F, "Parteien: %s\n", pcomp(s->factions, o->factions));
fprintf(F, "Einheiten: %s\n", pcomp(s->nunits, o->nunits));
fprintf(F, "Spielerpopulation: %s\n",
pcomp(s->playerpop, o->playerpop));
fprintf(F, " davon bewaffnet: %s\n",
pcomp(s->armed_men, o->armed_men));
#ifdef HEROES
fprintf(F, " Helden: %s\n", pcomp(s->heroes, o->heroes));
#endif
if (full) {
fprintf(F, "Regionen: %d\n", listlen(regions));
fprintf(F, "Bewohnte Regionen: %d\n", s->inhabitedregions);
fprintf(F, "Landregionen: %d\n", s->landregionen);
fprintf(F, "Spielerregionen: %d\n", s->regionen_mit_spielern);
fprintf(F, "Landspielerregionen: %d\n", s->landregionen_mit_spielern);
fprintf(F, "Orkifizierte Regionen: %d\n", s->orkifizierte_regionen);
fprintf(F, "Inaktive Vulkane: %d\n", s->inactive_volcanos);
fprintf(F, "Aktive Vulkane: %d\n\n", s->active_volcanos);
}
for (i = 0; i < MAXRACES; i++) {
const race * rc = new_race[i];
if (s->factionrace[i] && rc && playerrace(rc)
&& i != RC_TEMPLATE && i != RC_CLONE) {
fprintf(F, "%14svölker: %s\n", LOC(default_locale, rc_name(rc, 3)),
pcomp(s->factionrace[i], o->factionrace[i]));
}
}
if(full) {
fprintf(F, "\n");
{
struct language * plang = s->languages;
while (plang!=NULL) {
struct language * olang = o->languages;
int nold = 0;
while (olang && olang->locale!=plang->locale) olang=olang->next;
if (olang) nold = olang->number;
fprintf(F, "Sprache %12s: %s\n", locale_name(plang->locale),
rcomp(plang->number, nold));
plang=plang->next;
}
}
}
fprintf(F, "\n");
if (full) {
for (i = 0; i < MAXRACES; i++) {
const race * rc = new_race[i];
if (s->poprace[i]) {
fprintf(F, "%20s: %s\n", LOC(default_locale, rc_name(rc, 1)),
rcomp(s->poprace[i], o->poprace[i]));
}
}
} else {
for (i = 0; i < MAXRACES; i++) {
const race * rc = new_race[i];
if (s->poprace[i] && playerrace(rc)
&& i != RC_TEMPLATE && i != RC_CLONE) {
fprintf(F, "%20s: %s\n", LOC(default_locale, rc_name(rc, 1)),
rcomp(s->poprace[i], o->poprace[i]));
}
}
}
if (full) {
fprintf(F, "\nWaffen: %s\n", pcomp(s->waffen,o->waffen));
fprintf(F, "Rüstungen: %s\n",
pcomp(s->ruestungen,o->ruestungen));
fprintf(F, "ungezähmte Pferde: %s\n", pcomp(s->pferde, o->pferde));
fprintf(F, "gezähmte Pferde: %s\n",
pcomp(s->spielerpferde,o->spielerpferde));
fprintf(F, "Schiffe: %s\n", pcomp(s->schiffe, o->schiffe));
fprintf(F, "Gebäude: %s\n", pcomp(s->gebaeude, o->gebaeude));
fprintf(F, "\nBauernpopulation: %s\n", pcomp(s->peasants,o->peasants));
fprintf(F, "Population gesamt: %d\n\n", s->playerpop+s->peasants);
fprintf(F, "Reichtum Spieler: %s Silber\n",
pcomp(s->playermoney,o->playermoney));
fprintf(F, "Reichtum Bauern: %s Silber\n",
pcomp(s->peasantmoney, o->peasantmoney));
fprintf(F, "Reichtum gesamt: %s Silber\n\n",
pcomp(s->playermoney+s->peasantmoney, o->playermoney+o->peasantmoney));
}
fprintf(F, "\n\n");
newplayers = update_nmrs();
for (i = 0; i <= NMRTimeout(); ++i) {
if (i == NMRTimeout()) {
fprintf(F, "+ NMR:\t\t %d\n", nmrs[i]);
} else {
fprintf(F, "%d NMR:\t\t %d\n", i, nmrs[i]);
}
}
if (age) {
if (age[2] != 0) {
fprintf(F, "Erstabgaben:\t %d%%\n", 100 - (dropouts[0] * 100 / age[2]));
}
if (age[3] != 0) {
fprintf(F, "Zweitabgaben:\t %d%%\n", 100 - (dropouts[1] * 100 / age[3]));
}
}
fprintf(F, "Neue Spieler:\t %d\n", newplayers);
if (full) {
if (factions)
fprintf(F, "\nParteien:\n\n");
for (f = factions; f; f = f->next) {
out_faction(F, f);
}
if (NMRTimeout() && full) {
fprintf(F, "\n\nFactions with NMRs:\n");
for (i = NMRTimeout(); i > 0; --i) {
for(f=factions; f; f=f->next) {
if(i == NMRTimeout()) {
if(turn - f->lastorders >= i) {
out_faction(F, f);
}
} else {
if(turn - f->lastorders == i) {
out_faction(F, f);
}
}
}
}
}
}
fclose(F);
if (full) {
printf("writing date & turn\n");
writeturn();
writemonument();
}
free(nmrs);
nmrs = NULL;
}
/******* end summary ******/
static void

View file

@ -18,10 +18,6 @@ extern "C" {
extern void report_init(void);
extern void report_cleanup(void);
struct summary;
extern void report_summary(struct summary * n, struct summary * o, boolean full);
extern struct summary * make_summary(void);
#ifdef __cplusplus
}
#endif

View file

@ -2,14 +2,20 @@
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
* | | Enno Rehling <enno@eressea.de>
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
* | (c) 1998 - 2005 |
* | (c) 1998 - 2007 |
* | | This program may not be used, modified or distributed
* +-------------------+ without prior permission by the authors of Eressea.
*/
#ifndef GC_SPELLS_H
#define GC_SPELLS_H
extern void register_gcspells(void);
#ifdef __cplusplus
extern "C" {
#endif
extern void register_gcspells(void);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,407 @@
/* vi: set ts=2:
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
* | | Enno Rehling <enno@eressea.de>
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
* | (c) 1998 - 2007 |
* | | This program may not be used, modified or distributed
* +-------------------+ without prior permission by the authors of Eressea.
*
*/
/* wenn config.h nicht vor curses included wird, kompiliert es unter windows nicht */
#include <config.h>
#include <eressea.h>
#include "summary.h"
#include "laws.h"
#include <kernel/alliance.h>
#include <kernel/calendar.h>
#include <kernel/faction.h>
#include <kernel/item.h>
#include <kernel/race.h>
#include <kernel/region.h>
#include <kernel/reports.h>
#include <kernel/save.h>
#include <kernel/skill.h>
#include <kernel/terrain.h>
#include <kernel/terrainid.h>
#include <kernel/unit.h>
#include <util/base36.h>
#include <util/language.h>
#include <util/lists.h>
#include <string.h>
typedef struct summary {
int waffen;
int factions;
int ruestungen;
int schiffe;
int gebaeude;
int maxskill;
int heroes;
int inhabitedregions;
int peasants;
int nunits;
int playerpop;
double playermoney;
double peasantmoney;
int armed_men;
int poprace[MAXRACES];
int factionrace[MAXRACES];
int landregionen;
int regionen_mit_spielern;
int landregionen_mit_spielern;
int orkifizierte_regionen;
int inactive_volcanos;
int active_volcanos;
int spielerpferde;
int pferde;
struct language {
struct language * next;
int number;
const struct locale * locale;
} * languages;
} summary;
static char *
pcomp(double i, double j)
{
static char buf[32];
sprintf(buf, "%.0f (%s%.0f)", i, (i>=j)?"+":"", i-j);
return buf;
}
static char *
rcomp(int i, int j)
{
static char buf[32];
sprintf(buf, "%d (%s%d,%s%d%%)",
i, (i>=j)?"+":"", i-j, (i>=j)?"+":"",j?((i-j)*100)/j:0);
return buf;
}
static void
out_faction(FILE *file, const struct faction *f)
{
if (alliances!=NULL) {
fprintf(file, "%s (%s/%d) (%.3s/%.3s), %d Einh., %d Pers., $%d, %d NMR\n",
f->name, itoa36(f->no), f->alliance?f->alliance->id:0,
LOC(default_locale, rc_name(f->race, 0)), magietypen[f->magiegebiet],
f->no_units, f->num_total, f->money, turn - f->lastorders);
} else {
fprintf(file, "%s (%.3s/%.3s), %d Einh., %d Pers., $%d, %d NMR\n",
factionname(f), LOC(default_locale, rc_name(f->race, 0)),
magietypen[f->magiegebiet], f->no_units, f->num_total, f->money,
turn - f->lastorders);
}
}
static char *
gamedate2(const struct locale * lang)
{
static char buf[256];
gamedate gd;
get_gamedate(turn, &gd);
sprintf(buf, "in %s des Monats %s im Jahre %d %s.",
LOC(lang, weeknames2[gd.week]),
LOC(lang, monthnames[gd.month]),
gd.year,
LOC(lang, agename));
return buf;
}
static void
writeturn(void)
{
char zText[MAX_PATH];
FILE *f;
sprintf(zText, "%s/datum", basepath());
f = cfopen(zText, "w");
if (!f) return;
fputs(gamedate2(default_locale), f);
fclose(f);
sprintf(zText, "%s/turn", basepath());
f = cfopen(zText, "w");
if (!f) return;
fprintf(f, "%d\n", turn);
fclose(f);
}
void
report_summary(summary * s, summary * o, boolean full)
{
FILE * F = NULL;
int i, newplayers = 0;
faction * f;
char zText[MAX_PATH];
if (full) {
sprintf(zText, "%s/parteien.full", basepath());
} else {
sprintf(zText, "%s/parteien", basepath());
}
F = cfopen(zText, "w");
if (!F) return;
printf("Schreibe Zusammenfassung (parteien)...\n");
fprintf(F, "%s\n%s\n\n", global.gamename, gamedate2(default_locale));
fprintf(F, "Auswertung Nr: %d\n\n", turn);
fprintf(F, "Parteien: %s\n", pcomp(s->factions, o->factions));
fprintf(F, "Einheiten: %s\n", pcomp(s->nunits, o->nunits));
fprintf(F, "Spielerpopulation: %s\n",
pcomp(s->playerpop, o->playerpop));
fprintf(F, " davon bewaffnet: %s\n",
pcomp(s->armed_men, o->armed_men));
#ifdef HEROES
fprintf(F, " Helden: %s\n", pcomp(s->heroes, o->heroes));
#endif
if (full) {
fprintf(F, "Regionen: %d\n", listlen(regions));
fprintf(F, "Bewohnte Regionen: %d\n", s->inhabitedregions);
fprintf(F, "Landregionen: %d\n", s->landregionen);
fprintf(F, "Spielerregionen: %d\n", s->regionen_mit_spielern);
fprintf(F, "Landspielerregionen: %d\n", s->landregionen_mit_spielern);
fprintf(F, "Orkifizierte Regionen: %d\n", s->orkifizierte_regionen);
fprintf(F, "Inaktive Vulkane: %d\n", s->inactive_volcanos);
fprintf(F, "Aktive Vulkane: %d\n\n", s->active_volcanos);
}
for (i = 0; i < MAXRACES; i++) {
const race * rc = new_race[i];
if (s->factionrace[i] && rc && playerrace(rc)
&& i != RC_TEMPLATE && i != RC_CLONE) {
fprintf(F, "%14svölker: %s\n", LOC(default_locale, rc_name(rc, 3)),
pcomp(s->factionrace[i], o->factionrace[i]));
}
}
if(full) {
fprintf(F, "\n");
{
struct language * plang = s->languages;
while (plang!=NULL) {
struct language * olang = o->languages;
int nold = 0;
while (olang && olang->locale!=plang->locale) olang=olang->next;
if (olang) nold = olang->number;
fprintf(F, "Sprache %12s: %s\n", locale_name(plang->locale),
rcomp(plang->number, nold));
plang=plang->next;
}
}
}
fprintf(F, "\n");
if (full) {
for (i = 0; i < MAXRACES; i++) {
const race * rc = new_race[i];
if (s->poprace[i]) {
fprintf(F, "%20s: %s\n", LOC(default_locale, rc_name(rc, 1)),
rcomp(s->poprace[i], o->poprace[i]));
}
}
} else {
for (i = 0; i < MAXRACES; i++) {
const race * rc = new_race[i];
if (s->poprace[i] && playerrace(rc)
&& i != RC_TEMPLATE && i != RC_CLONE) {
fprintf(F, "%20s: %s\n", LOC(default_locale, rc_name(rc, 1)),
rcomp(s->poprace[i], o->poprace[i]));
}
}
}
if (full) {
fprintf(F, "\nWaffen: %s\n", pcomp(s->waffen,o->waffen));
fprintf(F, "Rüstungen: %s\n",
pcomp(s->ruestungen,o->ruestungen));
fprintf(F, "ungezähmte Pferde: %s\n", pcomp(s->pferde, o->pferde));
fprintf(F, "gezähmte Pferde: %s\n",
pcomp(s->spielerpferde,o->spielerpferde));
fprintf(F, "Schiffe: %s\n", pcomp(s->schiffe, o->schiffe));
fprintf(F, "Gebäude: %s\n", pcomp(s->gebaeude, o->gebaeude));
fprintf(F, "\nBauernpopulation: %s\n", pcomp(s->peasants,o->peasants));
fprintf(F, "Population gesamt: %d\n\n", s->playerpop+s->peasants);
fprintf(F, "Reichtum Spieler: %s Silber\n",
pcomp(s->playermoney,o->playermoney));
fprintf(F, "Reichtum Bauern: %s Silber\n",
pcomp(s->peasantmoney, o->peasantmoney));
fprintf(F, "Reichtum gesamt: %s Silber\n\n",
pcomp(s->playermoney+s->peasantmoney, o->playermoney+o->peasantmoney));
}
fprintf(F, "\n\n");
newplayers = update_nmrs();
for (i = 0; i <= NMRTimeout(); ++i) {
if (i == NMRTimeout()) {
fprintf(F, "+ NMR:\t\t %d\n", nmrs[i]);
} else {
fprintf(F, "%d NMR:\t\t %d\n", i, nmrs[i]);
}
}
if (age) {
if (age[2] != 0) {
fprintf(F, "Erstabgaben:\t %d%%\n", 100 - (dropouts[0] * 100 / age[2]));
}
if (age[3] != 0) {
fprintf(F, "Zweitabgaben:\t %d%%\n", 100 - (dropouts[1] * 100 / age[3]));
}
}
fprintf(F, "Neue Spieler:\t %d\n", newplayers);
if (full) {
if (factions)
fprintf(F, "\nParteien:\n\n");
for (f = factions; f; f = f->next) {
out_faction(F, f);
}
if (NMRTimeout() && full) {
fprintf(F, "\n\nFactions with NMRs:\n");
for (i = NMRTimeout(); i > 0; --i) {
for(f=factions; f; f=f->next) {
if(i == NMRTimeout()) {
if(turn - f->lastorders >= i) {
out_faction(F, f);
}
} else {
if(turn - f->lastorders == i) {
out_faction(F, f);
}
}
}
}
}
}
fclose(F);
if (full) {
printf("writing date & turn\n");
writeturn();
}
free(nmrs);
nmrs = NULL;
}
summary *
make_summary(void)
{
faction *f;
region *r;
unit *u;
summary * s = calloc(1, sizeof(summary));
for (f = factions; f; f = f->next) {
const struct locale * lang = f->locale;
struct language * plang = s->languages;
while (plang && plang->locale != lang) plang=plang->next;
if (!plang) {
plang = calloc(sizeof(struct language), 1);
plang->next = s->languages;
s->languages = plang;
plang->locale = lang;
}
++plang->number;
f->nregions = 0;
f->num_total = 0;
f->money = 0;
if (f->alive && f->units) {
s->factions++;
/* Problem mit Monsterpartei ... */
if (f->no!=MONSTER_FACTION) {
s->factionrace[old_race(f->race)]++;
}
}
}
/* Alles zählen */
for (r = regions; r; r = r->next) {
s->pferde += rhorses(r);
s->schiffe += listlen(r->ships);
s->gebaeude += listlen(r->buildings);
if (!fval(r->terrain, SEA_REGION)) {
s->landregionen++;
if (r->units) {
s->landregionen_mit_spielern++;
}
if (fval(r, RF_ORCIFIED)) {
s->orkifizierte_regionen++;
}
if (rterrain(r) == T_VOLCANO) {
s->inactive_volcanos++;
} else if(rterrain(r) == T_VOLCANO_SMOKING) {
s->active_volcanos++;
}
}
if (r->units) {
s->regionen_mit_spielern++;
}
if (rpeasants(r) || r->units) {
s->inhabitedregions++;
s->peasants += rpeasants(r);
s->peasantmoney += rmoney(r);
/* Einheiten Info. nregions darf nur einmal pro Partei
* incrementiert werden. */
for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
for (u = r->units; u; u = u->next) {
f = u->faction;
if (u->faction->no != MONSTER_FACTION) {
skill * sv;
item * itm;
s->nunits++;
s->playerpop += u->number;
if (u->flags & UFL_HERO) {
s->heroes += u->number;
}
s->spielerpferde += get_item(u, I_HORSE);
s->playermoney += get_money(u);
s->armed_men += armedmen(u);
for (itm=u->items;itm;itm=itm->next) {
if (itm->type->rtype->wtype) {
s->waffen += itm->number;
}
if (itm->type->rtype->atype) {
s->ruestungen += itm->number;
}
}
s->spielerpferde += get_item(u, I_HORSE);
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
skill_t sk = sv->id;
int aktskill = eff_skill(u, sk, r);
if (aktskill > s->maxskill) s->maxskill = aktskill;
}
if (!fval(f, FFL_SELECT)) {
f->nregions++;
fset(f, FFL_SELECT);
}
}
f->num_total += u->number;
f->money += get_money(u);
s->poprace[old_race(u->race)] += u->number;
}
}
}
return s;
}

View file

@ -0,0 +1,25 @@
/* vi: set ts=2:
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
* | | Enno Rehling <enno@eressea.de>
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
* | (c) 1998 - 2007 |
* | | This program may not be used, modified or distributed
* +-------------------+ without prior permission by the authors of Eressea.
*
*/
#ifndef H_GC_SUMMARY
#define H_GC_SUMMARY
#ifdef __cplusplus
extern "C" {
#endif
struct summary;
extern void report_summary(struct summary * n, struct summary * o, boolean full);
extern struct summary * make_summary(void);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -29,10 +29,12 @@
#include <util/attrib.h>
#include <util/base36.h>
#include <util/resolve.h>
#include <util/unicode.h>
/* libc includes */
#include <stdlib.h>
#include <string.h>
#include <wctype.h>
#define GMAXHASH 2039
static group * ghash[GMAXHASH];
@ -73,7 +75,7 @@ init_group(faction * f, group * g)
static group *
find_groupbyname(group * g, const xmlChar * name)
{
while (g && xml_strcasecmp(name, g->name)) g = g->next;
while (g && unicode_utf8_strcasecmp(name, g->name)!=0) g = g->next;
return g;
}

View file

@ -330,13 +330,13 @@ rt_register(resource_type * rtype)
const resource_type *
item2resource(const item_type * itype)
{
return itype->rtype;
return itype?itype->rtype:NULL;
}
const item_type *
resource2item(const resource_type * rtype)
{
return rtype->itype;
return rtype?rtype->itype:NULL;
}
const weapon_type *

View file

@ -63,6 +63,10 @@
#include <attributes/racename.h>
#include <attributes/viewrange.h>
boolean nocr = false;
boolean nonr = false;
boolean noreports = false;
const char * g_reportdir;
const char * visibility[] = {
"none",
@ -1353,11 +1357,7 @@ nmr_warnings(void)
for (fa=factions;fa;fa=fa->next) {
if (alliedfaction(NULL, f, fa, FRIEND) && alliedfaction(NULL, fa, f, FRIEND)) {
if (msg==NULL) {
char buf[4096];
sprintf(buf, "Achtung: %s hat einige Zeit keine "
"Züge eingeschickt und könnte dadurch in Kürze aus dem "
"Spiel ausscheiden.", factionname(f));
msg = msg_message("msg_event", "string", buf);
msg = msg_message("warn_dropout", "faction", f);
}
add_message(&fa->msgs, msg);
}
@ -1443,22 +1443,24 @@ global_report(const char * filename)
}
#endif
void
writeaddresses(void)
int
init_reports(void)
{
faction *f;
FILE *F;
char zText[MAX_PATH];
sprintf(zText, "%s/addresses", basepath());
F = cfopen(zText, "w");
if (!F) return;
update_intervals();
for (f = factions; f; f = f->next) {
if (f->no != MONSTER_FACTION && playerrace(f->race)) {
fprintf(F, "%s:%s:%s\n", factionname(f), f->email, f->banner);
#ifdef HAVE_STAT
{
stat_type st;
if (stat(reportpath(), &st)==0) return 0;
}
#endif
if (makedir(reportpath(), 0700)!=0) {
if (errno!=EEXIST) {
perror("could not create reportpath");
return -1;
}
}
fclose(F);
return 0;
}
int
@ -1478,7 +1480,7 @@ reports(void)
sprintf(path, "%s/reports.txt", reportpath());
mailit = fopen(path, "w");
if (mailit == NULL) {
log_error(("%s konnte nicht geöffnet werden!\n", path));
log_error(("%s could not be opened!\n", path));
}
for (f = factions; f; f = f->next) {
@ -1557,7 +1559,7 @@ static variant
var_copy_regions(variant x)
{
region_list * rsrc;
size_t size = 0;
int size = 0;
for (rsrc = (region_list*)x.v; rsrc!=NULL; rsrc=rsrc->next) {
++size;

View file

@ -32,6 +32,9 @@ extern "C" {
extern const char *directions[];
extern const char *coasts[];
extern boolean nonr;
extern boolean nocr;
extern boolean noreports;
/* kann_finden speedups */
extern boolean kann_finden(struct faction * f1, struct faction * f2);
@ -100,7 +103,6 @@ extern int bufunit(const struct faction * f, const struct unit * u, int indent,
extern const char * reportpath(void);
extern const xmlChar * trailinto(const struct region * r, const struct locale * lang);
extern const xmlChar * report_kampfstatus(const struct unit * u, const struct locale * lang);
extern void writeaddresses(void);
extern void reports_init(void);

View file

@ -458,11 +458,14 @@ parse_directions(xmlDocPtr doc)
xpathDirections = xmlXPathEvalExpression(BAD_CAST "/eressea/directions/dir", xpath);
nsetDirections = xpathDirections->nodesetval;
if (nsetDirections!=NULL) {
xmlNodePtr dir = nsetDirections->nodeTab[0];
xmlChar * property = xmlGetProp(dir, BAD_CAST "name");
int k;
for (k=0;k!=nsetDirections->nodeNr;++k) {
xmlNodePtr dir = nsetDirections->nodeTab[k];
xmlChar * property = xmlGetProp(dir, BAD_CAST "name");
register_special_direction((const char *)property);
xmlFree(property);
register_special_direction((const char *)property);
xmlFree(property);
}
}
xmlXPathFreeObject(xpathDirections);
xmlXPathFreeContext(xpath);

View file

@ -109,7 +109,7 @@ default_spoil(const struct race * rc, int size)
}
/* Die Funktionen werden über den hier registrierten Namen in races.xml
* in die jeweilige Rassendefiniton eingebunden */
* in die jeweilige Rassendefiniton eingebunden */
void
register_races(void)
{
@ -118,8 +118,11 @@ register_races(void)
register_function((pf_generic)allowed_dragon, "movedragon");
/* function age
* race->age() */
register_function((pf_generic)allowed_swim, "moveswimming");
register_function((pf_generic)allowed_fly, "moveflying");
register_function((pf_generic)allowed_walk, "movewalking");
/* function age for race->age() */
register_function((pf_generic)age_undead, "ageundead");
register_function((pf_generic)age_illusion, "ageillusion");
register_function((pf_generic)age_skeleton, "ageskeleton");

View file

@ -28,6 +28,7 @@ extern "C" {
*/
extern struct border_type bt_chaosgate;
extern struct border_type bt_firewall;
typedef struct wall_data {
struct unit * mage;
int force;

View file

@ -13,6 +13,37 @@
#include <errno.h>
int
unicode_utf8_strcasecmp(const xmlChar * a, const xmlChar * b)
{
while (*a && *b) {
int ret;
size_t size;
wint_t ucsa = *a, ucsb = *b;
if (ucsa>0x7F) {
ret = unicode_utf8_to_ucs4(&ucsa, a, &size);
if (ret!=0) return -1;
a += size;
} else ++a;
if (ucsb>0x7F) {
ret = unicode_utf8_to_ucs4(&ucsb, b, &size);
if (ret!=0) return -1;
b += size;
} else ++b;
if (ucsb!=ucsa) {
ucsb = towlower(ucsb);
ucsa = towlower(ucsa);
if (ucsb<ucsa) return 1;
if (ucsb>ucsa) return -1;
}
}
if (*b) return -1;
if (*a) return 1;
return 0;
}
/* Convert a UTF-8 encoded character to UCS-4. */
int
unicode_utf8_to_ucs4(wint_t *ucs4_character, const xmlChar *utf8_string,

View file

@ -22,6 +22,7 @@ extern "C" {
#include <wchar.h>
#define USE_UNICODE
extern int unicode_utf8_to_ucs4(wint_t *ucs4_character, const xmlChar *utf8_string, size_t *length);
extern int unicode_utf8_strcasecmp(const xmlChar * a, const xmlChar * b);
#ifdef __cplusplus
}

View file

@ -13,6 +13,7 @@
#include <gamecode/monster.h>
#include <gamecode/creport.h>
#include <gamecode/report.h>
#include <gamecode/summary.h>
#include <spells/spells.h>
@ -65,26 +66,6 @@ lua_planmonsters(void)
}
}
#define ISLANDSIZE 20
#define TURNS_PER_ISLAND 4
static void
lua_autoseed(const char * filename, bool new_island)
{
newfaction * players = read_newfactions(filename);
if (players!=NULL) {
rng_init(players->subscription);
while (players) {
int n = listlen(players);
int k = (n+ISLANDSIZE-1)/ISLANDSIZE;
k = n / k;
n = autoseed(&players, k, new_island || (turn % TURNS_PER_ISLAND)==0);
if (n==0) {
break;
}
}
}
}
#ifdef LUABIND_NO_EXCEPTIONS
static void
error_callback(lua_State * L)
@ -92,15 +73,6 @@ error_callback(lua_State * L)
}
#endif
static int
get_direction(const char * name)
{
for (int i=0;i!=MAXDIRECTIONS;++i) {
if (strcasecmp(directions[i], name)==0) return i;
}
return NODIRECTION;
}
static int
lua_writereport(faction * f)
{
@ -115,46 +87,6 @@ lua_writereports(void)
return reports();
}
static void
lua_equipunit(unit& u, const char * eqname)
{
equip_unit(&u, get_equipment(eqname));
}
static void
update_subscriptions(void)
{
FILE * F;
char zText[MAX_PATH];
faction * f;
strcat(strcpy(zText, basepath()), "/subscriptions");
F = fopen(zText, "r");
if (F==NULL) {
log_info((0, "could not open %s.\n", zText));
return;
}
for (;;) {
char zFaction[5];
int subscription, fno;
if (fscanf(F, "%d %s", &subscription, zFaction)<=0) break;
fno = atoi36(zFaction);
f = findfaction(fno);
if (f!=NULL) {
f->subscription=subscription;
}
}
fclose(F);
sprintf(zText, "subscriptions.%u", turn);
F = fopen(zText, "w");
for (f=factions;f!=NULL;f=f->next) {
fprintf(F, "%s:%u:%s:%s:%s:%u:\n",
itoa36(f->no), f->subscription, f->email, f->override,
dbrace(f->race), f->lastorders);
}
fclose(F);
}
static void
message_unit(unit& sender, unit& target, const char * str)
{
@ -173,15 +105,6 @@ message_region(unit& sender, const char * str)
ADDMSG(&sender.region->msgs, msg_message("mail_result", "unit message", &sender, str));
}
static void
lua_learnskill(unit& u, const char * skname, float chances)
{
skill_t sk = sk_find(skname);
if (sk!=NOSKILL) {
learn_skill(&u, sk, chances);
}
}
static int
read_game(const char * filename)
{
@ -218,7 +141,6 @@ write_summary()
summary * sum_end = make_summary();
report_summary(sum_end, sum_begin, false);
report_summary(sum_end, sum_begin, true);
writeaddresses();
return 0;
}
return -1;

View file

@ -136,11 +136,6 @@ extern "C" {
extern const char * g_basedir;
extern const char * g_resourcedir;
extern boolean nonr;
extern boolean nosh;
extern boolean nocr;
extern boolean noreports;
extern boolean nomer;
extern boolean nobattle;
extern boolean nomonsters;
extern boolean battledebug;
@ -436,7 +431,6 @@ usage(const char * prog, const char * arg)
"--debug : schreibt Debug-Ausgaben in die Datei debug\n"
"--nocr : keine CRs\n"
"--nonr : keine Reports\n"
"--nosh : keine Mail-Skripte\n"
"--crabsolute : absolute Koordinaten im CR\n"
"--help : help\n", prog);
return -1;
@ -484,7 +478,6 @@ read_args(int argc, char **argv, lua_State * luaState)
else if (strcmp(argv[i]+2, "ignore-errors")==0) g_ignore_errors = true;
else if (strcmp(argv[i]+2, "dirtyload")==0) dirtyload = true;
else if (strcmp(argv[i]+2, "nonr")==0) nonr = true;
else if (strcmp(argv[i]+2, "nosh")==0) nosh = true;
else if (strcmp(argv[i]+2, "lomem")==0) lomem = true;
else if (strcmp(argv[i]+2, "nobattle")==0) nobattle = true;
else if (strcmp(argv[i]+2, "nomonsters")==0) nomonsters = true;

View file

@ -1735,7 +1735,6 @@
<arg name="command" type="order"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Der Elementar ist zu klein, um das Gebäude zu tragen."</text>
</text>
</message>
<message name="sp_movecastle_fail_1" section="magic">
@ -1746,9 +1745,7 @@
<arg name="direction" type="direction"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Der Elementar weigert sich, nach $direction($direction) zu gehen."</text>
</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - The elemental refuses to go $direction($direction)."</text>
</text>
</message>
<message name="sp_migranten_fail1" section="magic">
@ -7012,6 +7009,8 @@
<arg name="resource" type="resource"/>
<arg name="target" type="unit"/>
</type>
</message>
<message name="give_peasants" section="economy">
<type>
<arg name="unit" type="unit"/>
@ -7021,6 +7020,7 @@
<text locale="de">"$unit($unit) übergibt $int($amount) $resource($resource,$amount) an die Bauern."</text>
<text locale="en">"$unit($unit) gives $int($amount) $resource($resource,$amount) to the local peasants."</text>
</message>
<message name="maintenance" section="economy">
<type>
<arg name="unit" type="unit"/>
@ -7471,7 +7471,6 @@
</type>
<text locale="de">"$unit($mage) erschafft in $region($region) eine verheerende Feuersbrunst. $int($amount) Bäume fallen den Flammen zum Opfer."</text>
<text locale="de">"$unit($mage) creates a flaming inferno in $region($region). $int($amount) trees fall vistim to the flames."</text>
</text>
</message>
<message name="recruit_effect" section="magic">
@ -8315,5 +8314,12 @@
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Dieser Zauber kann nciht auf Untote gezaubert werden."</text>
</message>
<message name="warn_dropout" section="errors">
<type>
<arg name="faction" type="faction"/>
</type>
<text locale="de">"Achtung: $faction($faction) hat einige Zeit keine Züge eingeschickt und könnte dadurch in Kürze aus dem Spiel ausscheiden"</text>
</message>
</messages>

View file

@ -661,7 +661,7 @@
</race>
<race name="shadowdemon" cansail="no" cansteal="no" canlearn="no" magres="0.750000" maxaura="1.000000" regaura="1.000000" recruitcost="5000" weight="500" capacity="540" speed="1.000000" hp="50" ac="3" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="8" defensemodifier="11" scarepeasants="yes" walk="yes" teach="no" desert="yes" recruitethereal="yes" nogive="yes">
<ai splitsize="1000" killpeasants="yes" moverandom="yes" learn="yes"/>
<function name="name" value="nameshadow"/>
<function name="name" value="namegeneric"/>
<attack type="4" damage="2d3"/>
<attack type="3" damage="1d1"/>
</race>

View file

@ -18,14 +18,24 @@ function write_emails(locales)
end
end
function write_addresses()
local file
local faction
file = io.open(basepath .. "/adressen", "w")
for faction in factions() do
-- print(faction.id .. " - " .. faction.locale)
file:write(tostring(faction) .. ":" .. faction.email .. ":" .. faction.banner .. "\n")
end
file:close()
end
function write_aliases()
local file
local key
local locale
local faction
file = io.open(basepath .. "/aliases." .. locale, "w")
local faction
for faction in factions() do
local unit
file:write("partei-" .. itoa36(faction.id) .. ": " .. faction.email .. "\n")
@ -43,4 +53,5 @@ function write_files(locales)
write_emails(locales)
write_aliases()
write_summary()
write_addresses()
end