Merge pull request #704 from ennorehling/master

Valenar crash: bad report interval when a faction has no units.
This commit is contained in:
Enno Rehling 2017-06-26 20:50:05 +02:00 committed by GitHub
commit 2c356103e2
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) static region *lastregion(faction * f)
{ {
if (!f->units) {
return NULL;
}
return f->last ? f->last->next : NULL; return f->last ? f->last->next : NULL;
} }
@ -1418,10 +1421,11 @@ void prepare_report(report_context *ctx, faction *f)
ctx->addresses = NULL; ctx->addresses = NULL;
ctx->userdata = NULL; ctx->userdata = NULL;
/* [first,last) interval of regions with a unit in it: */ /* [first,last) interval of regions with a unit in it: */
if (f->units) {
ctx->first = firstregion(f); ctx->first = firstregion(f);
ctx->last = lastregion(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; int range = 0;
unit *u; unit *u;
if (fval(r, RF_LIGHTHOUSE) && bt_lighthouse) { if (fval(r, RF_LIGHTHOUSE) && bt_lighthouse) {
@ -1453,10 +1457,11 @@ void prepare_report(report_context *ctx, faction *f)
prepare_lighthouse(f, r, range); 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); travelthru_map(r, cb_add_seen, f);
} }
} }
}
/* [fast,last) interval of seen regions (with lighthouses and travel) /* [fast,last) interval of seen regions (with lighthouses and travel)
* TODO: what about neighbours? when are they included? do we need * TODO: what about neighbours? when are they included? do we need
* them outside of the CR? */ * them outside of the CR? */