From 06a04d0e20032d74f68362f2011e3a2caac47df7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 12 Sep 2015 19:48:03 +0200 Subject: [PATCH] fix logging for sp_igjarjuk, temporarily set log-levels for the game to error|warn|info remove some code that accesses `verbosity` variable (todo: hide it more, fix logging) --- process/run-turn | 2 +- src/creport.c | 1 - src/kernel/faction.c | 3 +- src/laws.c | 8 ++--- src/listbox.c | 7 ++--- src/main.c | 4 +-- src/monsters.c | 22 +++++--------- src/reports.c | 8 ++--- src/spells/combatspells.c | 10 +++--- src/spells/combatspells.h | 64 +++++++++++++++++++-------------------- src/util/log.h | 4 +-- 11 files changed, 57 insertions(+), 76 deletions(-) diff --git a/process/run-turn b/process/run-turn index 80e12b093..0c5ee8fd2 100755 --- a/process/run-turn +++ b/process/run-turn @@ -9,6 +9,6 @@ fi cd $ERESSEA/game-$GAME echo "running turn $TURN, game $GAME" -$ERESSEA/server/bin/eressea -v1 -t $TURN run-turn.lua +$ERESSEA/server/bin/eressea -v3 -t $TURN run-turn.lua mkdir -p log ln -f eressea.log log/eressea.log.$TURN diff --git a/src/creport.c b/src/creport.c index 85dde4a93..aea88f03a 100644 --- a/src/creport.c +++ b/src/creport.c @@ -81,7 +81,6 @@ without prior permission by the authors of Eressea. #include /* imports */ -extern int verbosity; bool opt_cr_absolute_coords = false; /* globals */ diff --git a/src/kernel/faction.c b/src/kernel/faction.c index e57dd64ed..c47abada1 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -608,8 +608,7 @@ void remove_empty_factions(void) ursprung *ur = f->ursprung; while (ur && ur->id != 0) ur = ur->next; - if (verbosity >= 2) - log_printf(stdout, "\t%s\n", factionname(f)); + log_debug("dead: %s", factionname(f)); /* Einfach in eine Datei schreiben und später vermailen */ diff --git a/src/laws.c b/src/laws.c index a04655439..2f3cd2728 100755 --- a/src/laws.c +++ b/src/laws.c @@ -4064,11 +4064,10 @@ void process(void) region *r; processor *pglobal = proc; - if (verbosity >= 3) - printf("- Step %u\n", prio); + log_debug("- Step %u\n", prio); while (proc && proc->priority == prio) { if (proc->name && verbosity >= 1) - log_printf(stdout, " - %s\n", proc->name); + log_debug(" - %s\n", proc->name); proc = proc->next; } @@ -4164,8 +4163,7 @@ void process(void) } } - if (verbosity >= 3) - printf("\n - Leere Gruppen loeschen...\n"); + log_debug("\n - Leere Gruppen loeschen...\n"); for (f = factions; f; f = f->next) { group **gp = &f->groups; while (*gp) { diff --git a/src/listbox.c b/src/listbox.c index 525970637..3686cbba1 100644 --- a/src/listbox.c +++ b/src/listbox.c @@ -88,9 +88,7 @@ list_selection *do_selection(list_selection * sel, const char *title, width = (int)strlen(s->str); } ++height; - if (verbosity >= 5) { - log_printf(stdout, "s %s w %d h %d\n", s->str, width, height); - } + log_debug("s %s w %d h %d\n", s->str, width, height); } if (height == 0 || width == 0) return 0; @@ -99,8 +97,7 @@ list_selection *do_selection(list_selection * sel, const char *title, if (height + 2 > SY) height = SY - 2; - if (verbosity >= 5) - log_printf(stdout, "w %d h %d\n", width, height); + log_debug("w %d h %d\n", width, height); wn = newwin(height + 2, width + 4, (SY - height - 2) / 2, (SX - width - 4) / 2); diff --git a/src/main.c b/src/main.c index a1ebc6f06..5559a2086 100644 --- a/src/main.c +++ b/src/main.c @@ -202,10 +202,10 @@ static int parse_args(int argc, char **argv, int *exitcode) log_stderr = LOG_CPERROR | LOG_CPWARNING; break; case 3: - log_stderr = LOG_CPERROR | LOG_CPWARNING | LOG_CPDEBUG; + log_stderr = LOG_CPERROR | LOG_CPWARNING | LOG_CPINFO; break; default: - log_stderr = LOG_CPERROR | LOG_CPWARNING | LOG_CPDEBUG | LOG_CPINFO; + log_stderr = LOG_CPERROR | LOG_CPWARNING | LOG_CPINFO | LOG_CPDEBUG; break; } diff --git a/src/monsters.c b/src/monsters.c index d81ba7f81..95dd6164c 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -943,11 +943,9 @@ void spawn_dragons(void) fset(u, UFL_ISNEW | UFL_MOVED); equip_unit(u, get_equipment("monster_dragon")); - if (verbosity >= 2) { - log_printf(stdout, "%d %s in %s.\n", u->number, - LOC(default_locale, - rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL)); - } + log_debug("spawning %d %s in %s.\n", u->number, + LOC(default_locale, + rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL)); name_unit(u); @@ -976,6 +974,7 @@ void spawn_undead(void) /* Chance 0.1% * chaosfactor */ if (r->land && unburied > r->land->peasants / 20 && rng_int() % 10000 < (100 + 100 * chaosfactor(r))) { + message *msg; unit *u; /* es ist sinnfrei, wenn irgendwo im Wald 3er-Einheiten Untote entstehen. * Lieber sammeln lassen, bis sie mindestens 5% der Bevölkerung sind, und @@ -1018,14 +1017,10 @@ void spawn_undead(void) deathcounts(r, -undead); name_unit(u); - if (verbosity >= 2) { - log_printf(stdout, "%d %s in %s.\n", u->number, - LOC(default_locale, - rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL)); - } - - { - message *msg = msg_message("undeadrise", "region", r); + log_debug("spawning %d %s in %s.\n", u->number, + LOC(default_locale, + rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL)); + msg = msg_message("undeadrise", "region", r); add_message(&r->msgs, msg); for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT); @@ -1036,7 +1031,6 @@ void spawn_undead(void) add_message(&u->faction->msgs, msg); } msg_release(msg); - } } else { int i = deathcount(r); diff --git a/src/reports.c b/src/reports.c index 9d4d7f21c..21d51afa2 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1681,9 +1681,7 @@ int write_reports(faction * f, time_t ltime) log_warning("errno was %d before writing reports", errno); errno = 0; } - if (verbosity >= 2) { - log_printf(stdout, "Reports for %s:", factionname(f)); - } + log_debug("Reports for %s:", factionname(f)); for (rtype = report_types; rtype != NULL; rtype = rtype->next) { if (f->options & rtype->flag) { int error; @@ -1795,9 +1793,7 @@ int reports(void) int retval = 0; char path[MAX_PATH]; - if (verbosity >= 1) { - log_printf(stdout, "Writing reports for turn %d:", turn); - } + log_info("Writing reports for turn %d:", turn); report_donations(); remove_empty_units(); diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index dc7bb1bda..4b8cc8b51 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -872,9 +872,7 @@ static fighter *summon_allies(const fighter *fi, const race *rc, int number) { a->data.ca[1] = 100; a_add(&u->attribs, a); - msg = - msg_message("sp_wolfhowl_effect", "mage amount race", - mage, u->number, rc); + msg = msg_message("sp_wolfhowl_effect", "mage amount race", mage, u->number, rc); message_all(b, msg); msg_release(msg); @@ -883,12 +881,12 @@ static fighter *summon_allies(const fighter *fi, const race *rc, int number) { int sp_igjarjuk(castorder *co) { unit *u; - fighter * fi = co->magician.fig; + fighter *fm = co->magician.fig, *fi; const race *rc = get_race(RC_WYRM); - fi = summon_allies(fi, rc, 1); + fi = summon_allies(fm, rc, 1); u = fi->unit; unit_setname(u, "Igjarjuk"); - log_debug("%s calls a wyrm in %s", unitname(fi->unit), regionname(u->region, 0)); + log_info("%s summons Igjarjuk in %s", unitname(fm->unit), regionname(u->region, 0)); return co->level; } diff --git a/src/spells/combatspells.h b/src/spells/combatspells.h index 8b06fabb1..4e3173a66 100644 --- a/src/spells/combatspells.h +++ b/src/spells/combatspells.h @@ -17,40 +17,40 @@ extern "C" { #endif - struct fighter; + struct castorder; /* Kampfzauber */ - extern int sp_fumbleshield(struct castorder * co); - extern int sp_shadowknights(struct castorder * co); - extern int sp_combatrosthauch(struct castorder * co); - extern int sp_kampfzauber(struct castorder * co); - extern int sp_healing(struct castorder * co); - extern int sp_keeploot(struct castorder * co); - extern int sp_reanimate(struct castorder * co); - extern int sp_chaosrow(struct castorder * co); - extern int sp_flee(struct castorder * co); - extern int sp_berserk(struct castorder * co); - extern int sp_tiredsoldiers(struct castorder * co); - extern int sp_reeling_arrows(struct castorder * co); - extern int sp_denyattack(struct castorder * co); - extern int sp_sleep(struct castorder * co); - extern int sp_windshield(struct castorder * co); - extern int sp_strong_wall(struct castorder * co); - extern int sp_petrify(struct castorder * co); - extern int sp_hero(struct castorder * co); - extern int sp_frighten(struct castorder * co); - extern int sp_mindblast(struct castorder * co); - extern int sp_mindblast_temp(struct castorder * co); - extern int sp_speed(struct castorder * co); - extern int sp_wolfhowl(struct castorder * co); - extern int sp_igjarjuk(struct castorder * co); - extern int sp_dragonodem(struct castorder * co); - extern int sp_reduceshield(struct castorder * co); - extern int sp_armorshield(struct castorder * co); - extern int sp_stun(struct castorder * co); - extern int sp_undeadhero(struct castorder * co); - extern int sp_shadowcall(struct castorder * co); - extern int sp_immolation(struct castorder * co); + int sp_fumbleshield(struct castorder * co); + int sp_shadowknights(struct castorder * co); + int sp_combatrosthauch(struct castorder * co); + int sp_kampfzauber(struct castorder * co); + int sp_healing(struct castorder * co); + int sp_keeploot(struct castorder * co); + int sp_reanimate(struct castorder * co); + int sp_chaosrow(struct castorder * co); + int sp_flee(struct castorder * co); + int sp_berserk(struct castorder * co); + int sp_tiredsoldiers(struct castorder * co); + int sp_reeling_arrows(struct castorder * co); + int sp_denyattack(struct castorder * co); + int sp_sleep(struct castorder * co); + int sp_windshield(struct castorder * co); + int sp_strong_wall(struct castorder * co); + int sp_petrify(struct castorder * co); + int sp_hero(struct castorder * co); + int sp_frighten(struct castorder * co); + int sp_mindblast(struct castorder * co); + int sp_mindblast_temp(struct castorder * co); + int sp_speed(struct castorder * co); + int sp_wolfhowl(struct castorder * co); + int sp_igjarjuk(struct castorder * co); + int sp_dragonodem(struct castorder * co); + int sp_reduceshield(struct castorder * co); + int sp_armorshield(struct castorder * co); + int sp_stun(struct castorder * co); + int sp_undeadhero(struct castorder * co); + int sp_shadowcall(struct castorder * co); + int sp_immolation(struct castorder * co); #ifdef __cplusplus } diff --git a/src/util/log.h b/src/util/log.h index ef93ca3a5..40a667de4 100644 --- a/src/util/log.h +++ b/src/util/log.h @@ -30,8 +30,8 @@ extern "C" { #define LOG_FLUSH 0x01 #define LOG_CPWARNING 0x02 #define LOG_CPERROR 0x04 -#define LOG_CPDEBUG 0x08 -#define LOG_CPINFO 0x10 +#define LOG_CPINFO 0x08 +#define LOG_CPDEBUG 0x10 extern int log_flags; extern int log_stderr;