From efc87a16e39da415fd40a1034faf25ba87257e7c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 16 Nov 2015 16:57:51 +0100 Subject: [PATCH] clarify dragon planning code (bug 2159) --- src/monsters.c | 5 ++--- src/reports.c | 9 +++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/monsters.c b/src/monsters.c index 0ab88fa61..541a71c3f 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -685,14 +685,13 @@ static order *plan_dragon(unit * u) /* dragon gets bored and looks for a different place to go */ ta = set_new_dragon_target(u, u->region, DRAGON_RANGE); } - else - ta = a_find(u->attribs, &at_targetregion); if (ta != NULL) { tr = (region *)ta->data.v; if (tr == NULL || !path_exists(u->region, tr, DRAGON_RANGE, allowed_dragon)) { ta = set_new_dragon_target(u, u->region, DRAGON_RANGE); - if (ta) + if (ta) { tr = findregion(ta->data.sa[0], ta->data.sa[1]); + } } } if (tr != NULL) { diff --git a/src/reports.c b/src/reports.c index ca1cfb0f3..d88769457 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1547,6 +1547,7 @@ static void mkreportdir(const char *rpath) { abort(); } } + errno = 0; } int write_reports(faction * f, time_t ltime) @@ -1563,11 +1564,7 @@ int write_reports(faction * f, time_t ltime) } prepare_report(&ctx, f); get_addresses(&ctx); - mkreportdir(path); - if (errno) { - log_warning("errno was %d before writing reports", errno); - errno = 0; - } + mkreportdir(path); // FIXME: too many mkdir calls! init_reports is enough log_debug("Reports for %s:", factionname(f)); for (rtype = report_types; rtype != NULL; rtype = rtype->next) { if (f->options & rtype->flag) { @@ -1662,7 +1659,7 @@ int reports(void) report_donations(); remove_empty_units(); - mkreportdir(rpath); + mkreportdir(rpath); // FIXME: init_reports already does this? sprintf(path, "%s/reports.txt", rpath); mailit = fopen(path, "w"); if (mailit == NULL) {