Enforcing maximum size of units in recruiting.

This commit is contained in:
Enno Rehling 2006-10-29 13:04:18 +00:00
parent 13e19fb8b3
commit b1f1f07231
2 changed files with 6 additions and 0 deletions

View File

@ -353,6 +353,11 @@ do_recruiting(recruitment * recruits, int available)
number = min(number, afford); number = min(number, afford);
use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, rc->recruitcost*number); 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); add_recruits(u, number, req->qty);
if ((rc->ec_flags & ECF_REC_ETHEREAL)==0) { if ((rc->ec_flags & ECF_REC_ETHEREAL)==0) {
recruited += number * multi; recruited += number * multi;

View File

@ -186,6 +186,7 @@ give_men(int n, unit * u, unit * u2, struct order * ord)
if (u2 && n+u2->number > UNIT_MAXSIZE) { if (u2 && n+u2->number > UNIT_MAXSIZE) {
n = UNIT_MAXSIZE-u2->number; n = UNIT_MAXSIZE-u2->number;
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_unit_size", "maxsize", UNIT_MAXSIZE)); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_unit_size", "maxsize", UNIT_MAXSIZE));
assert(n>=0);
} }
if (n == 0) { if (n == 0) {
error = 96; error = 96;