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?)
This commit is contained in:
Enno Rehling 2014-11-23 15:50:22 +01:00
parent 7d5109329f
commit f92df416ff
4 changed files with 11 additions and 10 deletions

View File

@ -5,3 +5,4 @@ end
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
require 'eressea'
require 'eressea.xmlconf'
return require('eressea.rules')

View File

@ -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)

View File

@ -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);

View File

@ -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;
}