2017-12-30 07:34:17 +01:00
|
|
|
#ifdef _MSC_VER
|
2010-08-08 10:06:34 +02:00
|
|
|
#include <platform.h>
|
2017-12-30 07:34:17 +01:00
|
|
|
#endif
|
2010-08-08 10:06:34 +02:00
|
|
|
#include <kernel/config.h>
|
|
|
|
|
|
|
|
#include "summary.h"
|
|
|
|
#include "laws.h"
|
2016-12-23 18:05:38 +01:00
|
|
|
#include "monsters.h"
|
2018-02-14 20:00:48 +01:00
|
|
|
#include "kernel/calendar.h"
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
#include <kernel/alliance.h>
|
|
|
|
#include <kernel/faction.h>
|
|
|
|
#include <kernel/item.h>
|
|
|
|
#include <kernel/race.h>
|
|
|
|
#include <kernel/region.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>
|
2014-08-11 12:02:16 +02:00
|
|
|
#include <util/log.h>
|
2017-12-29 11:44:14 +01:00
|
|
|
#include <util/path.h>
|
2018-01-28 19:12:31 +01:00
|
|
|
#include <util/unicode.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2016-09-09 17:20:09 +02:00
|
|
|
#include <assert.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
#include <string.h>
|
2014-03-15 19:29:11 +01:00
|
|
|
#include <stdlib.h>
|
2013-12-29 09:19:22 +01:00
|
|
|
#include <stdio.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
#undef SUMMARY_BOM /* write a BOM in the summary file */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
typedef struct summary {
|
2015-01-30 20:37:14 +01:00
|
|
|
int waffen;
|
|
|
|
int factions;
|
|
|
|
int ruestungen;
|
|
|
|
int schiffe;
|
|
|
|
int gebaeude;
|
|
|
|
int maxskill;
|
|
|
|
int heroes;
|
|
|
|
int inhabitedregions;
|
|
|
|
int peasants;
|
|
|
|
int nunits;
|
|
|
|
int playerpop;
|
2018-01-27 21:44:36 +01:00
|
|
|
long long int playermoney;
|
|
|
|
long long int peasantmoney;
|
2015-01-30 20:37:14 +01:00
|
|
|
int armed_men;
|
|
|
|
int poprace[MAXRACES];
|
|
|
|
int factionrace[MAXRACES];
|
|
|
|
int landregionen;
|
|
|
|
int regionen_mit_spielern;
|
|
|
|
int landregionen_mit_spielern;
|
|
|
|
int inactive_volcanos;
|
|
|
|
int active_volcanos;
|
|
|
|
int spielerpferde;
|
|
|
|
int pferde;
|
|
|
|
struct language {
|
|
|
|
struct language *next;
|
|
|
|
int number;
|
|
|
|
const struct locale *locale;
|
|
|
|
} *languages;
|
2010-08-08 10:06:34 +02:00
|
|
|
} summary;
|
|
|
|
|
2014-08-27 06:40:18 +02:00
|
|
|
|
|
|
|
int *nmrs = NULL;
|
|
|
|
|
|
|
|
int update_nmrs(void)
|
|
|
|
{
|
2018-12-09 03:42:08 +01:00
|
|
|
int newplayers = 0;
|
2014-08-27 06:40:18 +02:00
|
|
|
faction *f;
|
2016-09-09 17:40:36 +02:00
|
|
|
int timeout = NMRTimeout();
|
2014-08-27 06:40:18 +02:00
|
|
|
|
2016-09-09 17:40:36 +02:00
|
|
|
if (timeout>0) {
|
2018-12-09 03:42:08 +01:00
|
|
|
int i;
|
2016-09-09 17:40:36 +02:00
|
|
|
if (nmrs == NULL) {
|
|
|
|
nmrs = malloc(sizeof(int) * (timeout + 1));
|
2018-12-15 20:01:51 +01:00
|
|
|
if (!nmrs) abort();
|
2016-09-09 17:40:36 +02:00
|
|
|
}
|
|
|
|
for (i = 0; i <= timeout; ++i) {
|
|
|
|
nmrs[i] = 0;
|
|
|
|
}
|
2014-08-27 06:40:18 +02:00
|
|
|
}
|
2016-09-09 17:40:36 +02:00
|
|
|
|
2014-08-27 06:40:18 +02:00
|
|
|
for (f = factions; f; f = f->next) {
|
2017-12-27 22:59:50 +01:00
|
|
|
if (f->age<=1) {
|
2014-08-27 06:40:18 +02:00
|
|
|
++newplayers;
|
|
|
|
}
|
2016-05-29 10:58:49 +02:00
|
|
|
else if (!fval(f, FFL_NOIDLEOUT|FFL_CURSED)) {
|
2017-06-11 17:06:13 +02:00
|
|
|
int nmr = turn - f->lastorders;
|
2016-09-09 17:40:36 +02:00
|
|
|
if (timeout>0) {
|
|
|
|
if (nmr < 0 || nmr > timeout) {
|
2016-11-17 21:29:15 +01:00
|
|
|
log_error("faction %s has %d NMR", itoa36(f->no), nmr);
|
2017-12-30 07:34:17 +01:00
|
|
|
if (nmr < 0) nmr = 0;
|
|
|
|
if (nmr > timeout) nmr = timeout;
|
2016-09-09 17:40:36 +02:00
|
|
|
}
|
|
|
|
if (nmr > 0) {
|
2016-11-17 21:29:15 +01:00
|
|
|
log_debug("faction %s has %d NMR", itoa36(f->no), nmr);
|
2016-09-09 17:40:36 +02:00
|
|
|
}
|
|
|
|
++nmrs[nmr];
|
2016-05-29 10:58:49 +02:00
|
|
|
}
|
2014-08-27 06:40:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return newplayers;
|
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static void out_faction(FILE * file, const struct faction *f)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
if (alliances != NULL) {
|
2017-03-11 18:10:23 +01:00
|
|
|
fprintf(file, "%s (%s/%d) (%.3s/%.3s), %d Einh., %d Pers., %d NMR\n",
|
2015-01-30 20:37:14 +01:00
|
|
|
f->name, itoa36(f->no), f_get_alliance(f) ? f->alliance->id : 0,
|
|
|
|
LOC(default_locale, rc_name_s(f->race, NAME_SINGULAR)), magic_school[f->magiegebiet],
|
2017-03-11 19:36:26 +01:00
|
|
|
f->num_units, f->num_people, turn - f->lastorders);
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
|
|
|
else {
|
2017-03-11 18:10:23 +01:00
|
|
|
fprintf(file, "%s (%.3s/%.3s), %d Einh., %d Pers., %d NMR\n",
|
2015-01-30 20:37:14 +01:00
|
|
|
factionname(f), LOC(default_locale, rc_name_s(f->race, NAME_SINGULAR)),
|
2017-03-11 19:36:26 +01:00
|
|
|
magic_school[f->magiegebiet], f->num_units, f->num_people,
|
2015-01-30 20:37:14 +01:00
|
|
|
turn - f->lastorders);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static char *gamedate2(const struct locale *lang)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
static char buf[256];
|
|
|
|
gamedate gd;
|
2016-09-09 17:29:17 +02:00
|
|
|
const char *week = "a_week", *month = "a_month";
|
2015-01-30 20:37:14 +01:00
|
|
|
|
2016-09-09 17:42:00 +02:00
|
|
|
get_gamedate(turn, &gd);
|
2016-09-09 17:29:17 +02:00
|
|
|
if (weeknames2) {
|
|
|
|
week = weeknames2[gd.week];
|
|
|
|
}
|
2017-05-07 17:46:51 +02:00
|
|
|
month = calendar_month(gd.month);
|
2015-01-30 20:37:14 +01:00
|
|
|
sprintf(buf, "in %s des Monats %s im Jahre %d %s.",
|
2017-05-07 17:46:51 +02:00
|
|
|
LOC(lang, mkname("calendar", week)),
|
|
|
|
LOC(lang, mkname("calendar", month)),
|
|
|
|
gd.year,
|
|
|
|
LOC(lang, mkname("calendar", calendar_era())));
|
2015-01-30 20:37:14 +01:00
|
|
|
return buf;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static void writeturn(void)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2017-01-10 16:31:05 +01:00
|
|
|
char zText[4096];
|
2015-01-30 20:37:14 +01:00
|
|
|
FILE *f;
|
|
|
|
|
2017-12-29 11:44:14 +01:00
|
|
|
path_join(basepath(), "datum", zText, sizeof(zText));
|
2015-01-30 20:37:14 +01:00
|
|
|
f = fopen(zText, "w");
|
|
|
|
if (!f) {
|
|
|
|
perror(zText);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fputs(gamedate2(default_locale), f);
|
|
|
|
fclose(f);
|
2017-12-29 11:44:14 +01:00
|
|
|
path_join(basepath(), "turn", zText, sizeof(zText));
|
2015-01-30 20:37:14 +01:00
|
|
|
f = fopen(zText, "w");
|
|
|
|
if (!f) {
|
|
|
|
perror(zText);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fprintf(f, "%d\n", turn);
|
|
|
|
fclose(f);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2018-01-28 11:37:42 +01:00
|
|
|
static int count_umlaut(const char *s)
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
const char *cp;
|
|
|
|
for (cp = s; *cp; ++cp) {
|
2019-08-01 18:40:42 +02:00
|
|
|
wint_t wc = *cp;
|
|
|
|
if (wc & 0x80) {
|
2018-01-28 19:12:31 +01:00
|
|
|
size_t size;
|
2018-02-07 18:05:14 +01:00
|
|
|
int err;
|
2019-08-01 18:40:42 +02:00
|
|
|
err = unicode_utf8_decode(&wc, cp, &size);
|
2018-02-07 18:05:14 +01:00
|
|
|
if (err != 0) {
|
|
|
|
log_error("illegal utf8 encoding %s at %s", s, cp);
|
|
|
|
return result;
|
|
|
|
}
|
2018-01-28 19:12:31 +01:00
|
|
|
cp += size;
|
2018-02-07 18:05:14 +01:00
|
|
|
++result;
|
2018-01-28 11:37:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-01-28 19:12:31 +01:00
|
|
|
static void summarize_races(const summary *s, FILE *F, bool full) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < MAXRACES; i++) {
|
|
|
|
if (s->poprace[i] > 0) {
|
|
|
|
const char *pad = " ";
|
|
|
|
int lpad = (int)strlen(pad);
|
|
|
|
const race *rc = get_race(i);
|
|
|
|
const char *rcname = LOC(default_locale, rc_name_s(rc, NAME_PLURAL));
|
|
|
|
lpad -= count_umlaut(rcname);
|
|
|
|
assert(lpad >= 0);
|
|
|
|
if (full) {
|
|
|
|
fputs(pad + lpad, F);
|
|
|
|
fprintf(F, "%20s: ", rcname);
|
|
|
|
fprintf(F, "%8d\n", s->poprace[i]);
|
|
|
|
}
|
|
|
|
else if (i != RC_TEMPLATE && i != RC_CLONE) {
|
|
|
|
if (playerrace(rc)) {
|
|
|
|
fputs(pad + lpad, F);
|
|
|
|
fprintf(F, "%16s: ", rcname);
|
|
|
|
fprintf(F, "%8d\n", s->poprace[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-28 11:37:42 +01:00
|
|
|
static void summarize_players(const summary *s, FILE *F) {
|
|
|
|
int i;
|
|
|
|
const char * suffix = LOC(default_locale, "stat_tribe_p");
|
|
|
|
|
|
|
|
for (i = 0; i < MAXRACES; i++) {
|
|
|
|
if (i != RC_TEMPLATE && i != RC_CLONE && s->factionrace[i]) {
|
|
|
|
const race *rc = get_race(i);
|
|
|
|
if (rc && playerrace(rc)) {
|
|
|
|
const char * pad = " ";
|
2018-01-28 19:12:31 +01:00
|
|
|
int lpad = (int)strlen(pad);
|
2018-01-28 11:37:42 +01:00
|
|
|
const char *rccat = LOC(default_locale, rc_name_s(rc, NAME_CATEGORY));
|
|
|
|
lpad -= count_umlaut(rccat);
|
|
|
|
assert(lpad >= 0);
|
|
|
|
fputs(pad + lpad, F);
|
2018-01-28 19:12:31 +01:00
|
|
|
fprintf(F, "%16s%s:", rccat, suffix);
|
2018-01-28 11:37:42 +01:00
|
|
|
fprintf(F, "%8d\n", s->factionrace[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void report_summary(const summary * s, bool full)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
FILE *F = NULL;
|
2018-01-28 11:37:42 +01:00
|
|
|
int newplayers = 0;
|
2015-01-30 20:37:14 +01:00
|
|
|
faction *f;
|
2017-01-10 16:31:05 +01:00
|
|
|
char zText[4096];
|
2016-09-09 17:40:36 +02:00
|
|
|
int timeout = NMRTimeout();
|
2015-01-30 20:37:14 +01:00
|
|
|
|
|
|
|
if (full) {
|
2017-12-29 11:44:14 +01:00
|
|
|
path_join(basepath(), "parteien.full", zText, sizeof(zText));
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
|
|
|
else {
|
2017-12-29 11:44:14 +01:00
|
|
|
path_join(basepath(), "parteien", zText, sizeof(zText));
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
|
|
|
F = fopen(zText, "w");
|
|
|
|
if (!F) {
|
|
|
|
perror(zText);
|
|
|
|
return;
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
#ifdef SUMMARY_BOM
|
2015-01-30 20:37:14 +01:00
|
|
|
else {
|
|
|
|
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
|
|
|
fwrite(utf8_bom, 1, 3, F);
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
#endif
|
2015-01-30 20:37:14 +01:00
|
|
|
log_info("writing summary to file: parteien.\n");
|
|
|
|
fprintf(F, "%s\n%s\n\n", game_name(), gamedate2(default_locale));
|
2018-01-27 21:44:36 +01:00
|
|
|
fprintf(F, "Auswertung Nr: %8d\n\n", turn);
|
|
|
|
fprintf(F, "Parteien: %8d\n", s->factions);
|
|
|
|
fprintf(F, "Einheiten: %8d\n", s->nunits);
|
|
|
|
fprintf(F, "Spielerpopulation: %8d\n", s->playerpop);
|
|
|
|
fprintf(F, " davon bewaffnet: %8d\n", s->armed_men);
|
|
|
|
fprintf(F, " Helden: %8d\n", s->heroes);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
|
|
|
if (full) {
|
2018-01-27 21:44:36 +01:00
|
|
|
fprintf(F, "Regionen: %8d\n", (int)listlen(regions));
|
|
|
|
fprintf(F, "Bewohnte Regionen: %8d\n", s->inhabitedregions);
|
|
|
|
fprintf(F, "Landregionen: %8d\n", s->landregionen);
|
|
|
|
fprintf(F, "Spielerregionen: %8d\n", s->regionen_mit_spielern);
|
|
|
|
fprintf(F, "Landspielerregionen: %8d\n", s->landregionen_mit_spielern);
|
|
|
|
fprintf(F, "Inaktive Vulkane: %8d\n", s->inactive_volcanos);
|
|
|
|
fprintf(F, "Aktive Vulkane: %8d\n\n", s->active_volcanos);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2018-01-28 11:37:42 +01:00
|
|
|
summarize_players(s, F);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
|
|
|
if (full) {
|
|
|
|
fprintf(F, "\n");
|
|
|
|
{
|
|
|
|
struct language *plang = s->languages;
|
|
|
|
while (plang != NULL) {
|
2018-01-27 21:44:36 +01:00
|
|
|
fprintf(F, "Sprache %2s: %8d\n", locale_name(plang->locale),
|
|
|
|
plang->number);
|
2015-01-30 20:37:14 +01:00
|
|
|
plang = plang->next;
|
|
|
|
}
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
fprintf(F, "\n");
|
2018-01-28 19:12:31 +01:00
|
|
|
summarize_races(s, F, full);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
|
|
|
if (full) {
|
2018-01-27 21:44:36 +01:00
|
|
|
fprintf(F, "\nWaffen: %8d\n", s->waffen);
|
|
|
|
fprintf(F, "Ruestungen: %8d\n", s->ruestungen);
|
|
|
|
fprintf(F, "ungezaehmte Pferde: %8d\n", s->pferde);
|
|
|
|
fprintf(F, "gezaehmte Pferde: %8d\n", s->spielerpferde);
|
|
|
|
fprintf(F, "Schiffe: %8d\n", s->schiffe);
|
|
|
|
fprintf(F, "Gebaeude: %8d\n", s->gebaeude);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
2018-01-27 21:44:36 +01:00
|
|
|
fprintf(F, "\nBauernpopulation: %8d\n", s->peasants);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
2018-01-27 21:44:36 +01:00
|
|
|
fprintf(F, "Population gesamt: %8d\n\n", s->playerpop + s->peasants);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
2018-01-27 21:44:36 +01:00
|
|
|
fprintf(F, "Reichtum Spieler: %12lld Silber\n", s->playermoney);
|
|
|
|
fprintf(F, "Reichtum Bauern: %12lld Silber\n", s->peasantmoney);
|
|
|
|
fprintf(F, "Reichtum gesamt: %12lld Silber\n\n",
|
|
|
|
s->playermoney + s->peasantmoney);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2018-01-28 19:12:31 +01:00
|
|
|
fprintf(F, "\n");
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
newplayers = update_nmrs();
|
|
|
|
|
2016-09-09 17:40:36 +02:00
|
|
|
if (nmrs) {
|
2018-01-28 11:37:42 +01:00
|
|
|
int i;
|
2016-09-09 17:40:36 +02:00
|
|
|
for (i = 0; i <= timeout; ++i) {
|
|
|
|
if (i == timeout) {
|
2018-01-28 19:12:31 +01:00
|
|
|
fprintf(F, "+ NMR: %3d\n", nmrs[i]);
|
2016-09-09 17:40:36 +02:00
|
|
|
}
|
|
|
|
else {
|
2018-01-28 19:12:31 +01:00
|
|
|
fprintf(F, "%d NMR: %3d\n", i, nmrs[i]);
|
2016-09-09 17:40:36 +02:00
|
|
|
}
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2015-01-30 20:37:14 +01:00
|
|
|
if (age) {
|
|
|
|
if (age[2] != 0) {
|
2018-01-28 19:12:31 +01:00
|
|
|
fprintf(F, "Erstabgaben: %3d%%\n", 100 - (dropouts[0] * 100 / age[2]));
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
|
|
|
if (age[3] != 0) {
|
2018-01-28 19:12:31 +01:00
|
|
|
fprintf(F, "Zweitabgaben: %3d%%\n", 100 - (dropouts[1] * 100 / age[3]));
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
|
|
|
}
|
2018-01-28 19:12:31 +01:00
|
|
|
fprintf(F, "Neue Spieler: %d\n", newplayers);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
|
|
|
if (full) {
|
2016-09-09 17:40:36 +02:00
|
|
|
if (factions) {
|
2015-01-30 20:37:14 +01:00
|
|
|
fprintf(F, "\nParteien:\n\n");
|
2016-09-09 17:40:36 +02:00
|
|
|
for (f = factions; f; f = f->next) {
|
|
|
|
out_faction(F, f);
|
|
|
|
}
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
|
|
|
|
2016-09-09 17:40:36 +02:00
|
|
|
if (timeout>0 && full) {
|
2018-01-28 11:37:42 +01:00
|
|
|
int i;
|
2015-01-30 20:37:14 +01:00
|
|
|
fprintf(F, "\n\nFactions with NMRs:\n");
|
2016-09-09 17:40:36 +02:00
|
|
|
for (i = timeout; i > 0; --i) {
|
2015-01-30 20:37:14 +01:00
|
|
|
for (f = factions; f; f = f->next) {
|
2016-09-09 17:40:36 +02:00
|
|
|
if (i == timeout) {
|
2015-01-30 20:37:14 +01:00
|
|
|
if (turn - f->lastorders >= i) {
|
|
|
|
out_faction(F, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (turn - f->lastorders == i) {
|
|
|
|
out_faction(F, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
fclose(F);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
if (full) {
|
|
|
|
log_info("writing date & turn\n");
|
|
|
|
writeturn();
|
|
|
|
}
|
|
|
|
free(nmrs);
|
|
|
|
nmrs = NULL;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 17:20:09 +02:00
|
|
|
void free_summary(summary *sum) {
|
2016-09-09 17:40:36 +02:00
|
|
|
while (sum->languages) {
|
|
|
|
struct language *next = sum->languages->next;
|
|
|
|
free(sum->languages);
|
|
|
|
sum->languages = next;
|
|
|
|
}
|
2016-09-09 17:20:09 +02:00
|
|
|
free(sum);
|
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
summary *make_summary(void)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2014-06-23 16:28:10 +02:00
|
|
|
faction *f;
|
|
|
|
region *r;
|
|
|
|
unit *u;
|
|
|
|
summary *s = calloc(1, sizeof(summary));
|
2014-06-24 16:42:45 +02:00
|
|
|
const struct resource_type *rhorse = get_resourcetype(R_HORSE);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
for (f = factions; f; f = f->next) {
|
2015-07-07 00:49:12 +02:00
|
|
|
const struct locale *lang = f->locale;
|
2015-01-30 20:37:14 +01:00
|
|
|
struct language *plang = s->languages;
|
|
|
|
while (plang && plang->locale != lang)
|
|
|
|
plang = plang->next;
|
|
|
|
if (!plang) {
|
2018-12-15 19:38:40 +01:00
|
|
|
plang = calloc(1, sizeof(struct language));
|
2015-01-30 20:37:14 +01:00
|
|
|
plang->next = s->languages;
|
|
|
|
s->languages = plang;
|
|
|
|
plang->locale = lang;
|
|
|
|
}
|
|
|
|
++plang->number;
|
2016-01-11 11:54:45 +01:00
|
|
|
if (f->units) {
|
2015-01-30 20:37:14 +01:00
|
|
|
s->factions++;
|
|
|
|
/* Problem mit Monsterpartei ... */
|
|
|
|
if (!is_monsters(f)) {
|
2015-11-11 15:36:57 +01:00
|
|
|
int rc = old_race(f->race);
|
|
|
|
if (rc >= 0) {
|
|
|
|
s->factionrace[rc]++;
|
|
|
|
}
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2015-01-30 20:37:14 +01:00
|
|
|
|
|
|
|
/* count everything */
|
|
|
|
|
|
|
|
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++;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
2015-01-30 20:37:14 +01:00
|
|
|
if (r->terrain == newterrain(T_VOLCANO)) {
|
|
|
|
s->inactive_volcanos++;
|
|
|
|
}
|
|
|
|
else if (r->terrain == newterrain(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);
|
|
|
|
|
|
|
|
for (u = r->units; u; u = u->next) {
|
2015-10-29 09:24:58 +01:00
|
|
|
int orace;
|
2015-01-30 20:37:14 +01:00
|
|
|
f = u->faction;
|
|
|
|
if (!is_monsters(u->faction)) {
|
|
|
|
skill *sv;
|
|
|
|
item *itm;
|
|
|
|
|
|
|
|
s->nunits++;
|
|
|
|
s->playerpop += u->number;
|
|
|
|
if (u->flags & UFL_HERO) {
|
|
|
|
s->heroes += u->number;
|
|
|
|
}
|
|
|
|
s->spielerpferde += i_get(u->items, rhorse->itype);
|
|
|
|
s->playermoney += get_money(u);
|
|
|
|
s->armed_men += armedmen(u, true);
|
|
|
|
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 += i_get(u->items, rhorse->itype);
|
|
|
|
|
|
|
|
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
|
|
|
|
skill_t sk = sv->id;
|
2015-08-27 16:16:55 +02:00
|
|
|
int aktskill = effskill(u, sk, r);
|
2015-01-30 20:37:14 +01:00
|
|
|
if (aktskill > s->maxskill)
|
|
|
|
s->maxskill = aktskill;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 09:24:58 +01:00
|
|
|
orace = (int)old_race(u_race(u));
|
|
|
|
if (orace >= 0) {
|
|
|
|
s->poprace[orace] += u->number;
|
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
return s;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|