diff --git a/src/kernel/region.c b/src/kernel/region.c index ed56851ee..117884d48 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -595,13 +595,27 @@ bool is_coastregion(region * r) int rpeasants(const region * r) { +<<<<<<< HEAD return r->land ? r->land->peasants : 0; +======= + int value = 0; + if (r->land) { + value = r->land->peasants; + assert(value >= 0); + } + return value; +>>>>>>> master } void rsetpeasants(region * r, int value) { +<<<<<<< HEAD if (r->land) { assert(value >= 0); +======= + assert(value >= 0); + if (r->land) { +>>>>>>> master r->land->peasants = value; } } @@ -613,8 +627,14 @@ int rmoney(const region * r) void rsethorses(const region * r, int value) { +<<<<<<< HEAD if (r->land) { assert(value >= 0); +======= + assert(r->land || value==0); + assert(value >= 0); + if (r->land) { +>>>>>>> master r->land->horses = value; } } diff --git a/src/kernel/save.c b/src/kernel/save.c index 35062c44d..2d37c6822 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -949,15 +949,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;