[11538] Add safeguard against weirdness in UpdateCombatSkills

Prevent weapon/defense update also in case of negative skill difference result (may become negative after use of .level -N -command)

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2011-05-25 12:24:29 +02:00
parent 4b919b1f32
commit 0fbf2cf7d3
2 changed files with 6 additions and 3 deletions

View file

@ -5614,8 +5614,11 @@ void Player::UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool de
if(lvldif < 3)
lvldif = 3;
uint32 skilldif = 5 * plevel - (defence ? GetBaseDefenseSkillValue() : GetBaseWeaponSkillValue(attType));
if(skilldif <= 0)
int32 skilldif = 5 * plevel - (defence ? GetBaseDefenseSkillValue() : GetBaseWeaponSkillValue(attType));
// Max skill reached for level.
// Can in some cases be less than 0: having max skill and then .level -1 as example.
if (skilldif <= 0)
return;
float chance = float(3 * lvldif * skilldif) / plevel;