- asserting on valid return values from recruit-function

- fixing  crashbug with --lomem)
This commit is contained in:
Enno Rehling 2005-06-04 01:43:38 +00:00
parent d8c0e47b44
commit c1e86e4fa0
2 changed files with 9 additions and 8 deletions

View File

@ -389,21 +389,22 @@ expandrecruit(region * r, request * recruitorders)
/* centaurs: */
recruits = select_recruitment(&recruitorders, horse_recruiters, &total);
if (recruits) {
int horses = rhorses(r) * 2;
int recruited, horses = rhorses(r) * 2;
if (total<horses) horses = total;
horses = horses / 2 - do_recruiting(recruits, horses);
rsethorses(r, horses);
recruited = do_recruiting(recruits, horses);
rsethorses(r, (horses - recruited) / 2);
free_recruitments(recruits);
}
/* peasant limited: */
recruits = select_recruitment(&recruitorders, peasant_recruiters, &total);
if (recruits) {
int peasants = rpeasants(r);
int rfrac = (2 * peasants) / RECRUITFRACTION; /* anzahl orks. 2 ork = 1 bauer */
int recruited, peasants = rpeasants(r) * 2;
int rfrac = peasants / RECRUITFRACTION; /* anzahl orks. 2 ork = 1 bauer */
if (total<rfrac) rfrac = total;
peasants = peasants - (1 + do_recruiting(recruits, rfrac))/2;
rsetpeasants(r, peasants);
recruited = do_recruiting(recruits, rfrac);
assert(recruited<=rfrac);
rsetpeasants(r, (peasants - recruited)/2);
free_recruitments(recruits);
}

View File

@ -810,7 +810,7 @@ free_region(region * r)
while (r->individual_messages) {
struct individual_message * msg = r->individual_messages;
r->individual_messages = msg->next;
free_messagelist(msg->msgs);
if (msg->msgs) free_messagelist(msg->msgs);
free(msg);
}