From b1f1f07231845b2dbd792ccea0d2ac741f01fa0a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Oct 2006 13:04:18 +0000 Subject: [PATCH] Enforcing maximum size of units in recruiting. --- src/common/gamecode/economy.c | 5 +++++ src/common/kernel/give.c | 1 + 2 files changed, 6 insertions(+) diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index f08dccfcc..94eb5f26e 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -353,6 +353,11 @@ do_recruiting(recruitment * recruits, int available) number = min(number, afford); use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, rc->recruitcost*number); } + if (u->number+number>UNIT_MAXSIZE) { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_unit_size", "maxsize", UNIT_MAXSIZE)); + number = UNIT_MAXSIZE-u->number; + assert(number>=0); + } add_recruits(u, number, req->qty); if ((rc->ec_flags & ECF_REC_ETHEREAL)==0) { recruited += number * multi; diff --git a/src/common/kernel/give.c b/src/common/kernel/give.c index ed83e0014..e9ef9e063 100644 --- a/src/common/kernel/give.c +++ b/src/common/kernel/give.c @@ -186,6 +186,7 @@ give_men(int n, unit * u, unit * u2, struct order * ord) if (u2 && n+u2->number > UNIT_MAXSIZE) { n = UNIT_MAXSIZE-u2->number; ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_unit_size", "maxsize", UNIT_MAXSIZE)); + assert(n>=0); } if (n == 0) { error = 96;