From 023686fab2b587436ee38c9533900c5ebfc9a817 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 24 Jan 2016 14:35:46 +0100 Subject: [PATCH] add a liberal sprinkling of assertions to catch negative peasants bug 2182 --- src/kernel/region.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/kernel/region.c b/src/kernel/region.c index 779b45e4a..01ec02375 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -595,14 +595,19 @@ bool is_coastregion(region * r) int rpeasants(const region * r) { - return ((r)->land ? (r)->land->peasants : 0); + int value = 0; + if (r->land) { + value = r->land->peasants; + assert(value >= 0); + } + return value; } void rsetpeasants(region * r, int value) { - if (r->land) r->land->peasants = value; - else assert(value>=0); - + assert(r->land); + assert(value >= 0); + r->land->peasants = value; } int rmoney(const region * r)