Mercurial > mm7
changeset 1272:19a4809e1da0
Player::DecreaseAttribute cleanup
author | Grumpy7 |
---|---|
date | Sat, 15 Jun 2013 02:31:27 +0200 |
parents | 5a3f48b370d5 |
children | fbb7428fa58c |
files | Player.cpp |
diffstat | 1 files changed, 29 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/Player.cpp Sat Jun 15 02:23:04 2013 +0200 +++ b/Player.cpp Sat Jun 15 02:31:27 2013 +0200 @@ -6424,51 +6424,35 @@ pDroppedStep = StatTable[0][v2].uDroppedStep; uMinValue = pBaseValue - 2; pStep = StatTable[0][v2].uBaseStep; - switch ( eAttribute ) - { - case CHARACTER_ATTRIBUTE_STRENGTH: - if ( this->uMight <= pBaseValue ) - pStep = pDroppedStep; - if ( this->uMight - pStep >= uMinValue ) - this->uMight -= pStep; - break; - case CHARACTER_ATTRIBUTE_INTELLIGENCE: - if ( this->uIntelligence <= pBaseValue ) - pStep = pDroppedStep; - if ( this->uIntelligence - pStep >= uMinValue ) - this->uIntelligence -= pStep; - break; - case CHARACTER_ATTRIBUTE_WILLPOWER: - if ( this->uWillpower <= pBaseValue ) - pStep = pDroppedStep; - if ( this->uWillpower - pStep >= uMinValue ) - this->uWillpower -= pStep; - break; - case CHARACTER_ATTRIBUTE_ENDURANCE: - if ( this->uEndurance <= pBaseValue ) - pStep = pDroppedStep; - if ( this->uEndurance - pStep >= uMinValue ) - this->uEndurance -= pStep; - break; - case CHARACTER_ATTRIBUTE_ACCURACY: - if ( this->uAccuracy <= pBaseValue ) - pStep = pDroppedStep; - if ( this->uAccuracy - pStep >= uMinValue ) - this->uAccuracy -= pStep; - break; - case CHARACTER_ATTRIBUTE_SPEED: - if ( this->uSpeed <= pBaseValue ) - pStep = pDroppedStep; - if ( this->uSpeed - pStep >= uMinValue ) - this->uSpeed -= pStep; - break; - case CHARACTER_ATTRIBUTE_LUCK: - if ( this->uLuck <= pBaseValue ) - pStep = pDroppedStep; - if ( this->uLuck - pStep >= uMinValue ) - this->uLuck -= pStep; - break; - } + unsigned short* AttrToChange = nullptr; + switch ( eAttribute ) + { + case CHARACTER_ATTRIBUTE_STRENGTH: + AttrToChange = &this->uMight; + break; + case CHARACTER_ATTRIBUTE_INTELLIGENCE: + AttrToChange = &this->uIntelligence; + break; + case CHARACTER_ATTRIBUTE_WILLPOWER: + AttrToChange = &this->uWillpower; + break; + case CHARACTER_ATTRIBUTE_ENDURANCE: + AttrToChange = &this->uEndurance; + break; + case CHARACTER_ATTRIBUTE_ACCURACY: + AttrToChange = &this->uAccuracy; + break; + case CHARACTER_ATTRIBUTE_SPEED: + AttrToChange = &this->uSpeed; + break; + case CHARACTER_ATTRIBUTE_LUCK: + AttrToChange = &this->uLuck; + break; + } + if ( *AttrToChange <= pBaseValue ) + pStep = pDroppedStep; + if ( *AttrToChange - pStep >= uMinValue ) + *AttrToChange -= pStep; } //----- (004905F5) --------------------------------------------------------