forked from github/server
Merge pull request #763 from ennorehling/libdb
smarter cmake with db-select options
This commit is contained in:
commit
ce0ac9b6a1
8 changed files with 152 additions and 129 deletions
|
@ -38,8 +38,12 @@ else (MSVC)
|
||||||
find_package (Curses)
|
find_package (Curses)
|
||||||
endif (MSVC)
|
endif (MSVC)
|
||||||
|
|
||||||
find_package (SQLite3)
|
if (ERESSEA_DB STREQUAL "db")
|
||||||
find_package (BerkeleyDB)
|
find_package (BerkeleyDB REQUIRED QUIET)
|
||||||
|
else()
|
||||||
|
find_package (SQLite3 REQUIRED QUIET)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package (LibXml2 REQUIRED)
|
find_package (LibXml2 REQUIRED)
|
||||||
find_package (ToLua REQUIRED)
|
find_package (ToLua REQUIRED)
|
||||||
if (TOLUA_FOUND)
|
if (TOLUA_FOUND)
|
||||||
|
|
7
s/build
7
s/build
|
@ -31,15 +31,18 @@ if [ ! -d $ROOT/$BUILD ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "build eressea"
|
echo "build eressea"
|
||||||
|
CMAKE_ARGS=".."
|
||||||
cd $ROOT/$BUILD
|
cd $ROOT/$BUILD
|
||||||
BRANCH=$(git status -s -b | head -1 | cut -d\ -f 2 | sed 's/\..*//')
|
BRANCH=$(git status -s -b | head -1 | cut -d\ -f 2 | sed 's/\..*//')
|
||||||
if [ "$BRANCH" = "master" ] ; then
|
if [ "$BRANCH" = "master" ] ; then
|
||||||
VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//')
|
VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//')
|
||||||
echo "$BRANCH $VERSION"
|
echo "$BRANCH $VERSION"
|
||||||
cmake -DERESSEA_VERSION="$VERSION" ..
|
CMAKE_ARGS="-DERESSEA_VERSION=$VERSION ${CMAKE_ARGS}"
|
||||||
else
|
else
|
||||||
REV=$(git rev-parse --short HEAD)
|
REV=$(git rev-parse --short HEAD)
|
||||||
cmake -DERESSEA_BUILDNO="$REV" ..
|
CMAKE_ARGS="-DERESSEA_BUILDNO=$REV $CMAKE_ARGS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cmake ${CMAKE_ARGS}
|
||||||
make $MAKEOPTS && make test
|
make $MAKEOPTS && make test
|
||||||
cd $OLDPWD
|
cd $OLDPWD
|
||||||
|
|
38
s/cmake-init
38
s/cmake-init
|
@ -1,5 +1,20 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
ERESSEA_DB=sqlite
|
||||||
|
if [ -e /usr/include/db.h ] ; then
|
||||||
|
ERESSEA_DB=db
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Parse command line arguments
|
||||||
|
while [ ! -z "$1" ] ; do
|
||||||
|
if [ "$1" = "--with-db" ] ; then
|
||||||
|
ERESSEA_DB=db
|
||||||
|
elif [ "$1" = "--with-sqlite" ] ; then
|
||||||
|
ERESSEA_DB=sqlite
|
||||||
|
fi
|
||||||
|
shift 1
|
||||||
|
done
|
||||||
|
|
||||||
ROOT=$(git rev-parse --show-toplevel)
|
ROOT=$(git rev-parse --show-toplevel)
|
||||||
[ -z $BUILD ] && BUILD=Debug
|
[ -z $BUILD ] && BUILD=Debug
|
||||||
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
|
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
|
||||||
|
@ -15,8 +30,6 @@ mkdir -p $BIN_DIR
|
||||||
rm -f $BUILD
|
rm -f $BUILD
|
||||||
ln -sf $BIN_DIR $BUILD
|
ln -sf $BIN_DIR $BUILD
|
||||||
|
|
||||||
rm -f CMakeCache.txt
|
|
||||||
|
|
||||||
# use anything installed in /opt or /usr
|
# use anything installed in /opt or /usr
|
||||||
LIBRARY_PATH=/opt/lib:/opt/lib/$MACHINE:/usr/lib/$MACHINE
|
LIBRARY_PATH=/opt/lib:/opt/lib/$MACHINE:/usr/lib/$MACHINE
|
||||||
INCLUDE_PATH=/opt/include:/usr/include
|
INCLUDE_PATH=/opt/include:/usr/include
|
||||||
|
@ -30,11 +43,6 @@ if [ -d $HOME/usr ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DEST=$(dirname $ROOT)/server
|
DEST=$(dirname $ROOT)/server
|
||||||
ARGS=" -DCMAKE_BUILD_TYPE=$BUILD \
|
|
||||||
-DCMAKE_LIBRARY_PATH=$LIBRARY_PATH \
|
|
||||||
-DCMAKE_PREFIX_PATH=$PREFIX_PATH \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=$DEST"
|
|
||||||
# -DCMAKE_INCLUDE_PATH=$INCLUDE_PATH
|
|
||||||
|
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
|
|
||||||
|
@ -46,7 +54,17 @@ elif [ -d /usr/local/include/lua5.1 ]; then
|
||||||
LUA_DIR=/usr/local
|
LUA_DIR=/usr/local
|
||||||
LUA_VERSION="5.1"
|
LUA_VERSION="5.1"
|
||||||
fi
|
fi
|
||||||
export LUA_DIR
|
|
||||||
|
cat >| $BUILD/config.cmake <<HEREDOC
|
||||||
|
SET (ERESSEA_DB "$ERESSEA_DB" CACHE STRING "Database driver")
|
||||||
|
SET (LUA_DIR "$LUA_DIR" CACHE PATH "Lua root path")
|
||||||
|
SET (CMAKE_BUILD_TYPE "$BUILD" FORCE)
|
||||||
|
SET (CMAKE_INSTALL_PREFIX "$DEST" CACHE PATH "")
|
||||||
|
SET (CMAKE_LIBRARY_PATH "$LIBRARY_PATH" CACHE PATH "")
|
||||||
|
SET (CMAKE_PREFIX_PATH "$PREFIX_PATH" CACHE PATH "")
|
||||||
|
HEREDOC
|
||||||
|
|
||||||
|
#echo 'SET (LUA_DIR "$LUA_DIR" PATH)' >> $BUILD/config.cmake
|
||||||
|
|
||||||
path="$(which tolua)"
|
path="$(which tolua)"
|
||||||
if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then
|
if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then
|
||||||
|
@ -59,7 +77,7 @@ if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then
|
||||||
echo "building tolua..."
|
echo "building tolua..."
|
||||||
cd tolua
|
cd tolua
|
||||||
make
|
make
|
||||||
ARGS="$ARGS -DPC_TOLUA_DIR=$ROOT/tolua"
|
echo 'SET(PC_TOLUA_DIR "$ROOT/tolua" CACHE PATH "tolua root")' >> $BUILD/config.cmake
|
||||||
else
|
else
|
||||||
echo "tolua is $path"
|
echo "tolua is $path"
|
||||||
fi
|
fi
|
||||||
|
@ -68,6 +86,6 @@ unset path
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cd $BIN_DIR
|
cd $BIN_DIR
|
||||||
cmake .. $ARGS $*
|
cmake -C config.cmake .. $*
|
||||||
cd $OLDPWD
|
cd $OLDPWD
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,6 @@ function process(rules, orders)
|
||||||
end
|
end
|
||||||
|
|
||||||
turn_begin()
|
turn_begin()
|
||||||
init_summary()
|
|
||||||
|
|
||||||
-- run the turn:
|
-- run the turn:
|
||||||
if eressea.read_orders(orders) ~= 0 then
|
if eressea.read_orders(orders) ~= 0 then
|
||||||
|
|
|
@ -518,26 +518,15 @@ static int tolua_write_passwords(lua_State * L)
|
||||||
return 0;
|
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)
|
static int tolua_write_summary(lua_State * L)
|
||||||
{
|
{
|
||||||
|
struct summary *sum;
|
||||||
UNUSED_ARG(L);
|
UNUSED_ARG(L);
|
||||||
if (sum_begin) {
|
|
||||||
struct summary *sum_end = make_summary();
|
sum = make_summary();
|
||||||
report_summary(sum_end, sum_begin, false);
|
report_summary(sum, false);
|
||||||
report_summary(sum_end, sum_begin, true);
|
report_summary(sum, true);
|
||||||
free_summary(sum_end);
|
free_summary(sum);
|
||||||
free_summary(sum_begin);
|
|
||||||
sum_begin = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -1073,7 +1062,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 "init_reports", tolua_init_reports);
|
||||||
tolua_function(L, TOLUA_CAST "write_reports", tolua_write_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 "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_summary", tolua_write_summary);
|
||||||
tolua_function(L, TOLUA_CAST "write_passwords", tolua_write_passwords);
|
tolua_function(L, TOLUA_CAST "write_passwords", tolua_write_passwords);
|
||||||
tolua_function(L, TOLUA_CAST "message_unit", tolua_message_unit);
|
tolua_function(L, TOLUA_CAST "message_unit", tolua_message_unit);
|
||||||
|
|
199
src/summary.c
199
src/summary.c
|
@ -32,6 +32,7 @@
|
||||||
#include <util/lists.h>
|
#include <util/lists.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <util/path.h>
|
#include <util/path.h>
|
||||||
|
#include <util/unicode.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -52,8 +53,8 @@ typedef struct summary {
|
||||||
int peasants;
|
int peasants;
|
||||||
int nunits;
|
int nunits;
|
||||||
int playerpop;
|
int playerpop;
|
||||||
double playermoney;
|
long long int playermoney;
|
||||||
double peasantmoney;
|
long long int peasantmoney;
|
||||||
int armed_men;
|
int armed_men;
|
||||||
int poprace[MAXRACES];
|
int poprace[MAXRACES];
|
||||||
int factionrace[MAXRACES];
|
int factionrace[MAXRACES];
|
||||||
|
@ -111,22 +112,6 @@ int update_nmrs(void)
|
||||||
return newplayers;
|
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)
|
static void out_faction(FILE * file, const struct faction *f)
|
||||||
{
|
{
|
||||||
if (alliances != NULL) {
|
if (alliances != NULL) {
|
||||||
|
@ -185,10 +170,73 @@ static void writeturn(void)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void report_summary(summary * s, summary * o, bool full)
|
static int count_umlaut(const char *s)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
const char *cp;
|
||||||
|
for (cp = s; *cp; ++cp) {
|
||||||
|
ucs4_t ucs = *cp;
|
||||||
|
if (ucs & 0x80) {
|
||||||
|
size_t size;
|
||||||
|
++result;
|
||||||
|
unicode_utf8_to_ucs4(&ucs, cp, &size);
|
||||||
|
cp += size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = " ";
|
||||||
|
int lpad = (int)strlen(pad);
|
||||||
|
const char *rccat = LOC(default_locale, rc_name_s(rc, NAME_CATEGORY));
|
||||||
|
lpad -= count_umlaut(rccat);
|
||||||
|
assert(lpad >= 0);
|
||||||
|
fputs(pad + lpad, F);
|
||||||
|
fprintf(F, "%16s%s:", rccat, suffix);
|
||||||
|
fprintf(F, "%8d\n", s->factionrace[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void report_summary(const summary * s, bool full)
|
||||||
{
|
{
|
||||||
FILE *F = NULL;
|
FILE *F = NULL;
|
||||||
int i, newplayers = 0;
|
int newplayers = 0;
|
||||||
faction *f;
|
faction *f;
|
||||||
char zText[4096];
|
char zText[4096];
|
||||||
int timeout = NMRTimeout();
|
int timeout = NMRTimeout();
|
||||||
|
@ -212,120 +260,82 @@ void report_summary(summary * s, summary * o, bool full)
|
||||||
#endif
|
#endif
|
||||||
log_info("writing summary to file: parteien.\n");
|
log_info("writing summary to file: parteien.\n");
|
||||||
fprintf(F, "%s\n%s\n\n", game_name(), gamedate2(default_locale));
|
fprintf(F, "%s\n%s\n\n", game_name(), gamedate2(default_locale));
|
||||||
fprintf(F, "Auswertung Nr: %d\n\n", turn);
|
fprintf(F, "Auswertung Nr: %8d\n\n", turn);
|
||||||
fprintf(F, "Parteien: %s\n", pcomp(s->factions, o->factions));
|
fprintf(F, "Parteien: %8d\n", s->factions);
|
||||||
fprintf(F, "Einheiten: %s\n", pcomp(s->nunits, o->nunits));
|
fprintf(F, "Einheiten: %8d\n", s->nunits);
|
||||||
fprintf(F, "Spielerpopulation: %s\n", pcomp(s->playerpop, o->playerpop));
|
fprintf(F, "Spielerpopulation: %8d\n", s->playerpop);
|
||||||
fprintf(F, " davon bewaffnet: %s\n", pcomp(s->armed_men, o->armed_men));
|
fprintf(F, " davon bewaffnet: %8d\n", s->armed_men);
|
||||||
fprintf(F, " Helden: %s\n", pcomp(s->heroes, o->heroes));
|
fprintf(F, " Helden: %8d\n", s->heroes);
|
||||||
|
|
||||||
if (full) {
|
if (full) {
|
||||||
fprintf(F, "Regionen: %d\n", (int)listlen(regions));
|
fprintf(F, "Regionen: %8d\n", (int)listlen(regions));
|
||||||
fprintf(F, "Bewohnte Regionen: %d\n", s->inhabitedregions);
|
fprintf(F, "Bewohnte Regionen: %8d\n", s->inhabitedregions);
|
||||||
fprintf(F, "Landregionen: %d\n", s->landregionen);
|
fprintf(F, "Landregionen: %8d\n", s->landregionen);
|
||||||
fprintf(F, "Spielerregionen: %d\n", s->regionen_mit_spielern);
|
fprintf(F, "Spielerregionen: %8d\n", s->regionen_mit_spielern);
|
||||||
fprintf(F, "Landspielerregionen: %d\n", s->landregionen_mit_spielern);
|
fprintf(F, "Landspielerregionen: %8d\n", s->landregionen_mit_spielern);
|
||||||
fprintf(F, "Inaktive Vulkane: %d\n", s->inactive_volcanos);
|
fprintf(F, "Inaktive Vulkane: %8d\n", s->inactive_volcanos);
|
||||||
fprintf(F, "Aktive Vulkane: %d\n\n", s->active_volcanos);
|
fprintf(F, "Aktive Vulkane: %8d\n\n", s->active_volcanos);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAXRACES; i++) {
|
summarize_players(s, F);
|
||||||
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]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (full) {
|
if (full) {
|
||||||
fprintf(F, "\n");
|
fprintf(F, "\n");
|
||||||
{
|
{
|
||||||
struct language *plang = s->languages;
|
struct language *plang = s->languages;
|
||||||
while (plang != NULL) {
|
while (plang != NULL) {
|
||||||
struct language *olang = o->languages;
|
fprintf(F, "Sprache %2s: %8d\n", locale_name(plang->locale),
|
||||||
int nold = 0;
|
plang->number);
|
||||||
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;
|
plang = plang->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(F, "\n");
|
fprintf(F, "\n");
|
||||||
if (full) {
|
summarize_races(s, F, 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]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (i = 0; i < MAXRACES; i++) {
|
|
||||||
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]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (full) {
|
if (full) {
|
||||||
fprintf(F, "\nWaffen: %s\n", pcomp(s->waffen, o->waffen));
|
fprintf(F, "\nWaffen: %8d\n", s->waffen);
|
||||||
fprintf(F, "Ruestungen: %s\n",
|
fprintf(F, "Ruestungen: %8d\n", s->ruestungen);
|
||||||
pcomp(s->ruestungen, o->ruestungen));
|
fprintf(F, "ungezaehmte Pferde: %8d\n", s->pferde);
|
||||||
fprintf(F, "ungezaehmte Pferde: %s\n", pcomp(s->pferde, o->pferde));
|
fprintf(F, "gezaehmte Pferde: %8d\n", s->spielerpferde);
|
||||||
fprintf(F, "gezaehmte Pferde: %s\n",
|
fprintf(F, "Schiffe: %8d\n", s->schiffe);
|
||||||
pcomp(s->spielerpferde, o->spielerpferde));
|
fprintf(F, "Gebaeude: %8d\n", s->gebaeude);
|
||||||
fprintf(F, "Schiffe: %s\n", pcomp(s->schiffe, o->schiffe));
|
|
||||||
fprintf(F, "Gebaeude: %s\n", pcomp(s->gebaeude, o->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",
|
fprintf(F, "Reichtum Spieler: %12lld Silber\n", s->playermoney);
|
||||||
pcomp(s->playermoney, o->playermoney));
|
fprintf(F, "Reichtum Bauern: %12lld Silber\n", s->peasantmoney);
|
||||||
fprintf(F, "Reichtum Bauern: %s Silber\n",
|
fprintf(F, "Reichtum gesamt: %12lld Silber\n\n",
|
||||||
pcomp(s->peasantmoney, o->peasantmoney));
|
s->playermoney + s->peasantmoney);
|
||||||
fprintf(F, "Reichtum gesamt: %s Silber\n\n",
|
|
||||||
pcomp(s->playermoney + s->peasantmoney,
|
|
||||||
o->playermoney + o->peasantmoney));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(F, "\n\n");
|
fprintf(F, "\n");
|
||||||
|
|
||||||
newplayers = update_nmrs();
|
newplayers = update_nmrs();
|
||||||
|
|
||||||
if (nmrs) {
|
if (nmrs) {
|
||||||
|
int i;
|
||||||
for (i = 0; i <= timeout; ++i) {
|
for (i = 0; i <= timeout; ++i) {
|
||||||
if (i == timeout) {
|
if (i == timeout) {
|
||||||
fprintf(F, "+ NMR:\t\t %d\n", nmrs[i]);
|
fprintf(F, "+ NMR: %3d\n", nmrs[i]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(F, "%d NMR:\t\t %d\n", i, nmrs[i]);
|
fprintf(F, "%d NMR: %3d\n", i, nmrs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (age) {
|
if (age) {
|
||||||
if (age[2] != 0) {
|
if (age[2] != 0) {
|
||||||
fprintf(F, "Erstabgaben:\t %d%%\n", 100 - (dropouts[0] * 100 / age[2]));
|
fprintf(F, "Erstabgaben: %3d%%\n", 100 - (dropouts[0] * 100 / age[2]));
|
||||||
}
|
}
|
||||||
if (age[3] != 0) {
|
if (age[3] != 0) {
|
||||||
fprintf(F, "Zweitabgaben:\t %d%%\n", 100 - (dropouts[1] * 100 / age[3]));
|
fprintf(F, "Zweitabgaben: %3d%%\n", 100 - (dropouts[1] * 100 / age[3]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(F, "Neue Spieler:\t %d\n", newplayers);
|
fprintf(F, "Neue Spieler: %d\n", newplayers);
|
||||||
|
|
||||||
if (full) {
|
if (full) {
|
||||||
if (factions) {
|
if (factions) {
|
||||||
|
@ -336,6 +346,7 @@ void report_summary(summary * s, summary * o, bool full)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout>0 && full) {
|
if (timeout>0 && full) {
|
||||||
|
int i;
|
||||||
fprintf(F, "\n\nFactions with NMRs:\n");
|
fprintf(F, "\n\nFactions with NMRs:\n");
|
||||||
for (i = timeout; i > 0; --i) {
|
for (i = timeout; i > 0; --i) {
|
||||||
for (f = factions; f; f = f->next) {
|
for (f = factions; f; f = f->next) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ extern "C" {
|
||||||
|
|
||||||
struct summary;
|
struct summary;
|
||||||
|
|
||||||
void report_summary(struct summary *n, struct summary *o, bool full);
|
void report_summary(const struct summary *sum, bool full);
|
||||||
struct summary *make_summary(void);
|
struct summary *make_summary(void);
|
||||||
void free_summary(struct summary *sum);
|
void free_summary(struct summary *sum);
|
||||||
int update_nmrs(void);
|
int update_nmrs(void);
|
||||||
|
|
|
@ -15,7 +15,7 @@ static void test_summary(CuTest * tc)
|
||||||
test_create_faction(NULL);
|
test_create_faction(NULL);
|
||||||
test_create_faction(NULL);
|
test_create_faction(NULL);
|
||||||
sum = make_summary();
|
sum = make_summary();
|
||||||
report_summary(sum, sum, true);
|
report_summary(sum, true);
|
||||||
CuAssertIntEquals(tc, 0, remove("parteien.full"));
|
CuAssertIntEquals(tc, 0, remove("parteien.full"));
|
||||||
CuAssertIntEquals(tc, 0, remove("datum"));
|
CuAssertIntEquals(tc, 0, remove("datum"));
|
||||||
CuAssertIntEquals(tc, 0, remove("turn"));
|
CuAssertIntEquals(tc, 0, remove("turn"));
|
||||||
|
|
Loading…
Reference in a new issue