From 3d7b22fa219a4be4c7e808f9ddeef054281863c7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 24 Jan 2016 14:31:24 +0100 Subject: [PATCH] avoid crashing because of bug 2182 --- src/kernel/save.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 29439986a..1c78615a7 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -944,15 +944,19 @@ static region *readregion(struct gamedata *data, int x, int y) READ_INT(data->store, &n); rsetherbs(r, (short)n); READ_INT(data->store, &n); - rsetpeasants(r, n); + if (n < 0) { + /* bug 2182 */ + log_error("data has negative peasants: %d in %s", n, regionname(r, 0)); + rsetpeasants(r, 0); + } + else { + rsetpeasants(r, n); + } READ_INT(data->store, &n); rsetmoney(r, n); } assert(r->terrain != NULL); - assert(rhorses(r) >= 0); - assert(rpeasants(r) >= 0); - assert(rmoney(r) >= 0); if (r->land) { int n;