From f92df416ff188524dbd64d11e29843c5aa69d3eb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 23 Nov 2014 15:50:22 +0100 Subject: [PATCH] monsters need a default locale, or their report will crash (thanks, Don!) - empty factions have not seen any region, prevent the code from crashing in that case. - must load the rules even when only writing the reports (taxation affects guards?) --- scripts/config.lua | 1 + scripts/run-turn.lua | 8 +------- src/monster.c | 2 +- src/reports.c | 10 ++++++++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/config.lua b/scripts/config.lua index b9dc8bca8..1251c1e1c 100644 --- a/scripts/config.lua +++ b/scripts/config.lua @@ -5,3 +5,4 @@ end package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' require 'eressea' require 'eressea.xmlconf' +return require('eressea.rules') diff --git a/scripts/run-turn.lua b/scripts/run-turn.lua index c9033afe3..283bdb1d1 100644 --- a/scripts/run-turn.lua +++ b/scripts/run-turn.lua @@ -174,12 +174,6 @@ end package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' require 'eressea' require 'eressea.xmlconf' -- read xml data +local rules = require('eressea.rules') -local rules = {} -if config.rules then - rules = require('eressea.' .. config.rules) - eressea.log.info('loaded ' .. #rules .. ' modules for ' .. config.rules) -else - eressea.log.warning('no rule modules loaded, specify a game in eressea.ini or with -r') -end run_turn(rules) diff --git a/src/monster.c b/src/monster.c index 1dd81b06e..6302c1af4 100644 --- a/src/monster.c +++ b/src/monster.c @@ -223,7 +223,7 @@ faction *get_or_create_monsters(void) if (!f) { const race *rc = rc_get_or_create("dragon"); const char *email = get_param(global.parameters, "monster.email"); - f = addfaction(email ? email : "noreply@eressea.de", NULL, rc, NULL, 0); + f = addfaction(email ? email : "noreply@eressea.de", NULL, rc, default_locale, 0); renumber_faction(f, MONSTER_ID); faction_setname(f, "Monster"); fset(f, FFL_NPC | FFL_NOIDLEOUT); diff --git a/src/reports.c b/src/reports.c index f22165e0e..fba0eacea 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1204,6 +1204,8 @@ static void get_seen_interval(report_context * ctx) /* this is required to find the neighbour regions of the ones we are in, * which may well be outside of [firstregion, lastregion) */ int i; + + assert(ctx->seen); for (i = 0; i != MAXSEEHASH; ++i) { seen_region *sr = ctx->seen[i]; while (sr != NULL) { @@ -1643,7 +1645,9 @@ int write_reports(faction * f, time_t ltime) ctx.last = lastregion(f); ctx.addresses = NULL; ctx.userdata = NULL; - get_seen_interval(&ctx); + if (ctx.seen) { + get_seen_interval(&ctx); + } get_addresses(&ctx); _mkdir(reportpath()); do { @@ -1679,7 +1683,9 @@ int write_reports(faction * f, time_t ltime) log_warning("No report for faction %s!", factionid(f)); } ql_free(ctx.addresses); - seen_done(ctx.seen); + if (ctx.seen) { + seen_done(ctx.seen); + } return 0; }