forked from github/server
BUG 2398: remove deltas from summary.
This commit is contained in:
parent
241cb4d6eb
commit
b6e8822044
5 changed files with 44 additions and 85 deletions
|
@ -129,7 +129,6 @@ function process(rules, orders)
|
|||
end
|
||||
|
||||
turn_begin()
|
||||
init_summary()
|
||||
|
||||
-- run the turn:
|
||||
if eressea.read_orders(orders) ~= 0 then
|
||||
|
|
|
@ -512,26 +512,15 @@ static int tolua_write_passwords(lua_State * L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct summary *sum_begin = 0;
|
||||
static int tolua_init_summary(lua_State * L)
|
||||
{
|
||||
UNUSED_ARG(L);
|
||||
sum_begin = make_summary();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_write_summary(lua_State * L)
|
||||
{
|
||||
struct summary *sum;
|
||||
UNUSED_ARG(L);
|
||||
if (sum_begin) {
|
||||
struct summary *sum_end = make_summary();
|
||||
report_summary(sum_end, sum_begin, false);
|
||||
report_summary(sum_end, sum_begin, true);
|
||||
free_summary(sum_end);
|
||||
free_summary(sum_begin);
|
||||
sum_begin = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
sum = make_summary();
|
||||
report_summary(sum, false);
|
||||
report_summary(sum, true);
|
||||
free_summary(sum);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
|
@ -1067,7 +1056,6 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile)
|
|||
tolua_function(L, TOLUA_CAST "init_reports", tolua_init_reports);
|
||||
tolua_function(L, TOLUA_CAST "write_reports", tolua_write_reports);
|
||||
tolua_function(L, TOLUA_CAST "write_report", tolua_write_report);
|
||||
tolua_function(L, TOLUA_CAST "init_summary", tolua_init_summary);
|
||||
tolua_function(L, TOLUA_CAST "write_summary", tolua_write_summary);
|
||||
tolua_function(L, TOLUA_CAST "write_passwords", tolua_write_passwords);
|
||||
tolua_function(L, TOLUA_CAST "message_unit", tolua_message_unit);
|
||||
|
|
100
src/summary.c
100
src/summary.c
|
@ -52,8 +52,8 @@ typedef struct summary {
|
|||
int peasants;
|
||||
int nunits;
|
||||
int playerpop;
|
||||
double playermoney;
|
||||
double peasantmoney;
|
||||
long long int playermoney;
|
||||
long long int peasantmoney;
|
||||
int armed_men;
|
||||
int poprace[MAXRACES];
|
||||
int factionrace[MAXRACES];
|
||||
|
@ -111,22 +111,6 @@ int update_nmrs(void)
|
|||
return newplayers;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -185,7 +169,7 @@ static void writeturn(void)
|
|||
fclose(f);
|
||||
}
|
||||
|
||||
void report_summary(summary * s, summary * o, bool full)
|
||||
void report_summary(summary * s, bool full)
|
||||
{
|
||||
FILE *F = NULL;
|
||||
int i, newplayers = 0;
|
||||
|
@ -212,30 +196,29 @@ void report_summary(summary * s, summary * o, bool full)
|
|||
#endif
|
||||
log_info("writing summary to file: parteien.\n");
|
||||
fprintf(F, "%s\n%s\n\n", game_name(), 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));
|
||||
fprintf(F, " Helden: %s\n", pcomp(s->heroes, o->heroes));
|
||||
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);
|
||||
|
||||
if (full) {
|
||||
fprintf(F, "Regionen: %d\n", (int)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, "Inaktive Vulkane: %d\n", s->inactive_volcanos);
|
||||
fprintf(F, "Aktive Vulkane: %d\n\n", s->active_volcanos);
|
||||
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);
|
||||
}
|
||||
|
||||
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)) {
|
||||
fprintf(F, "%13s%s: %s\n", LOC(default_locale, rc_name_s(rc, NAME_CATEGORY)),
|
||||
LOC(default_locale, "stat_tribe_p"), pcomp(s->factionrace[i],
|
||||
o->factionrace[i]));
|
||||
fprintf(F, "%13s%s: %8d\n", LOC(default_locale, rc_name_s(rc, NAME_CATEGORY)),
|
||||
LOC(default_locale, "stat_tribe_p"), s->factionrace[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -245,14 +228,8 @@ void report_summary(summary * s, summary * o, bool full)
|
|||
{
|
||||
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));
|
||||
fprintf(F, "Sprache %2s: %8d\n", locale_name(plang->locale),
|
||||
plang->number);
|
||||
plang = plang->next;
|
||||
}
|
||||
}
|
||||
|
@ -263,8 +240,8 @@ void report_summary(summary * s, summary * o, bool full)
|
|||
for (i = 0; i < MAXRACES; i++) {
|
||||
if (s->poprace[i]) {
|
||||
const race *rc = get_race(i);
|
||||
fprintf(F, "%20s: %s\n", LOC(default_locale, rc_name_s(rc, NAME_PLURAL)),
|
||||
rcomp(s->poprace[i], o->poprace[i]));
|
||||
fprintf(F, "%20s: %8d\n", LOC(default_locale, rc_name_s(rc, NAME_PLURAL)),
|
||||
s->poprace[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,34 +250,29 @@ void report_summary(summary * s, summary * o, bool full)
|
|||
if (i != RC_TEMPLATE && i != RC_CLONE && s->poprace[i]) {
|
||||
const race *rc = get_race(i);
|
||||
if (playerrace(rc)) {
|
||||
fprintf(F, "%20s: %s\n", LOC(default_locale, rc_name_s(rc, NAME_PLURAL)),
|
||||
rcomp(s->poprace[i], o->poprace[i]));
|
||||
fprintf(F, "%20s: %8d\n", LOC(default_locale, rc_name_s(rc, NAME_PLURAL)),
|
||||
s->poprace[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (full) {
|
||||
fprintf(F, "\nWaffen: %s\n", pcomp(s->waffen, o->waffen));
|
||||
fprintf(F, "Ruestungen: %s\n",
|
||||
pcomp(s->ruestungen, o->ruestungen));
|
||||
fprintf(F, "ungezaehmte Pferde: %s\n", pcomp(s->pferde, o->pferde));
|
||||
fprintf(F, "gezaehmte Pferde: %s\n",
|
||||
pcomp(s->spielerpferde, o->spielerpferde));
|
||||
fprintf(F, "Schiffe: %s\n", pcomp(s->schiffe, o->schiffe));
|
||||
fprintf(F, "Gebaeude: %s\n", pcomp(s->gebaeude, o->gebaeude));
|
||||
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);
|
||||
|
||||
fprintf(F, "\nBauernpopulation: %s\n", pcomp(s->peasants, o->peasants));
|
||||
fprintf(F, "\nBauernpopulation: %8d\n", s->peasants);
|
||||
|
||||
fprintf(F, "Population gesamt: %d\n\n", s->playerpop + s->peasants);
|
||||
fprintf(F, "Population gesamt: %8d\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, "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);
|
||||
}
|
||||
|
||||
fprintf(F, "\n\n");
|
||||
|
|
|
@ -19,7 +19,7 @@ extern "C" {
|
|||
|
||||
struct summary;
|
||||
|
||||
void report_summary(struct summary *n, struct summary *o, bool full);
|
||||
void report_summary(struct summary *sum, bool full);
|
||||
struct summary *make_summary(void);
|
||||
void free_summary(struct summary *sum);
|
||||
int update_nmrs(void);
|
||||
|
|
|
@ -15,7 +15,7 @@ static void test_summary(CuTest * tc)
|
|||
test_create_faction(NULL);
|
||||
test_create_faction(NULL);
|
||||
sum = make_summary();
|
||||
report_summary(sum, sum, true);
|
||||
report_summary(sum, true);
|
||||
CuAssertIntEquals(tc, 0, remove("parteien.full"));
|
||||
CuAssertIntEquals(tc, 0, remove("datum"));
|
||||
CuAssertIntEquals(tc, 0, remove("turn"));
|
||||
|
|
Loading…
Reference in a new issue