diff --git a/Source/player.cpp b/Source/player.cpp index b47dfaeef..e20b87be0 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -3792,10 +3792,7 @@ void ModifyPlrStr(int p, int l) } auto &player = Players[p]; - int max = player.GetMaximumAttributeValue(CharacterAttribute::Strength); - if (player._pBaseStr + l > max) { - l = max - player._pBaseStr; - } + l = clamp(l, 0 - player._pBaseStr, player.GetMaximumAttributeValue(CharacterAttribute::Strength) - player._pBaseStr); player._pStrength += l; player._pBaseStr += l; @@ -3814,10 +3811,7 @@ void ModifyPlrMag(int p, int l) } auto &player = Players[p]; - int max = player.GetMaximumAttributeValue(CharacterAttribute::Magic); - if (player._pBaseMag + l > max) { - l = max - player._pBaseMag; - } + l = clamp(l, 0 - player._pBaseStr, player.GetMaximumAttributeValue(CharacterAttribute::Magic) - player._pBaseMag); player._pMagic += l; player._pBaseMag += l; @@ -3850,10 +3844,7 @@ void ModifyPlrDex(int p, int l) } auto &player = Players[p]; - int max = player.GetMaximumAttributeValue(CharacterAttribute::Dexterity); - if (player._pBaseDex + l > max) { - l = max - player._pBaseDex; - } + l = clamp(l, 0 - player._pBaseDex, player.GetMaximumAttributeValue(CharacterAttribute::Dexterity) - player._pBaseDex); player._pDexterity += l; player._pBaseDex += l; @@ -3871,10 +3862,7 @@ void ModifyPlrVit(int p, int l) } auto &player = Players[p]; - int max = player.GetMaximumAttributeValue(CharacterAttribute::Vitality); - if (player._pBaseVit + l > max) { - l = max - player._pBaseVit; - } + l = clamp(l, 0 - player._pBaseVit, player.GetMaximumAttributeValue(CharacterAttribute::Vitality) - player._pBaseVit); player._pVitality += l; player._pBaseVit += l;