add a liberal sprinkling of assertions to catch negative peasants bug 2182

This commit is contained in:
Enno Rehling 2016-01-24 14:35:46 +01:00
parent 3d7b22fa21
commit 023686fab2

View file

@ -595,14 +595,19 @@ bool is_coastregion(region * r)
int rpeasants(const 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) void rsetpeasants(region * r, int value)
{ {
if (r->land) r->land->peasants = value; assert(r->land);
else assert(value>=0); assert(value >= 0);
r->land->peasants = value;
} }
int rmoney(const region * r) int rmoney(const region * r)