Valenar crash: bad report interval when a faction has no units.

This commit is contained in:
Enno Rehling 2017-06-26 20:39:05 +02:00
parent 1e78414562
commit 7790ebd671
1 changed files with 33 additions and 28 deletions

View File

@ -1367,6 +1367,9 @@ void reorder_units(region * r)
static region *lastregion(faction * f)
{
if (!f->units) {
return NULL;
}
return f->last ? f->last->next : NULL;
}
@ -1418,10 +1421,11 @@ void prepare_report(report_context *ctx, faction *f)
ctx->addresses = NULL;
ctx->userdata = NULL;
/* [first,last) interval of regions with a unit in it: */
if (f->units) {
ctx->first = firstregion(f);
ctx->last = lastregion(f);
for (r = ctx->first; r!=ctx->last; r = r->next) {
for (r = ctx->first; r != ctx->last; r = r->next) {
int range = 0;
unit *u;
if (fval(r, RF_LIGHTHOUSE) && bt_lighthouse) {
@ -1453,10 +1457,11 @@ void prepare_report(report_context *ctx, faction *f)
prepare_lighthouse(f, r, range);
}
if (fval(r, RF_TRAVELUNIT) && r->seen.mode<seen_travel) {
if (fval(r, RF_TRAVELUNIT) && r->seen.mode < seen_travel) {
travelthru_map(r, cb_add_seen, f);
}
}
}
/* [fast,last) interval of seen regions (with lighthouses and travel)
* TODO: what about neighbours? when are they included? do we need
* them outside of the CR? */