Fix bug #6272. Doesn't solve real issue though.

With experience_modifier=30, the unit Eraol (xp=18, max=60, * 30% ==
18) should have already advanced, but it hasn't.
This commit is contained in:
Rusty Russell 2006-07-19 11:54:19 +00:00
parent 099d2219bd
commit 7aa313fc5b

View File

@ -408,6 +408,11 @@ void ai::attack_analysis::analyze(const gamemap& map, unit_map& units,
int xp_for_advance = up->second.max_experience() - up->second.experience();
int kill_xp, fight_xp;
// See bug #6272... in some cases unit has already got enough xp to advance,
// but hasn't (bug elsewhere?). Can cause divide by zero.
if (xp_for_advance <= 0)
xp_for_advance = 1;
fight_xp = defend_it->second.level();
kill_xp = fight_xp * game_config::kill_experience;