Mercurial > mm7
diff Player.cpp @ 1271:5a3f48b370d5
Player::GetSkillIdxByOrder cleanup - extracting common branch bodies
author | Grumpy7 |
---|---|
date | Sat, 15 Jun 2013 02:23:04 +0200 |
parents | 2e4a07ad5243 |
children | 19a4809e1da0 |
line wrap: on
line diff
--- a/Player.cpp Sat Jun 15 02:15:03 2013 +0200 +++ b/Player.cpp Sat Jun 15 02:23:04 2013 +0200 @@ -6367,69 +6367,43 @@ //----- (004903C9) -------------------------------------------------------- PLAYER_SKILL_TYPE Player::GetSkillIdxByOrder(signed int order) { - PLAYER_SKILL_TYPE result; // eax@5 - int v3; // edx@5 - char *v4; // ecx@5 - int v5; // esi@11 - unsigned __int16 *v6; // edx@11 - int v7; // esi@18 - unsigned __int16 *pActiveSkill; // edx@18 - - - if ( order >= 0 ) - { - - if ( order <= 1 ) - { - result = (PLAYER_SKILL_TYPE)0; - v7 = 0; - pActiveSkill = this->pActiveSkills; - for (int i = 0; i < 37; i++) - { - if ( this->pActiveSkills[i] && pSkillAvailabilityPerClass[classType / 4][i] == 2 ) // 2 - primary skill - { - if ( v7 == order ) - return (PLAYER_SKILL_TYPE)i; - ++v7; - } - } - } - else - { - if ( order <= 3 ) - { - result = (PLAYER_SKILL_TYPE)0; - v5 = 0; - pActiveSkill = this->pActiveSkills; - for (int i = 0; i < 37; i++) - { - if ( this->pActiveSkills[i] && pSkillAvailabilityPerClass[classType / 4][i] == 1 ) // 2 - primary skill - { - if ( v5 == order - 2 ) - return (PLAYER_SKILL_TYPE)i; - ++v5; - } - } - } - else - { - if ( order <= 12 ) - { - v3 = 0; - for (int i = 0; i < 37; i++) - { - if ( pSkillAvailabilityPerClass[classType / 4][i] == 1 ) - { - if ( v3 == order - 4 ) - return (PLAYER_SKILL_TYPE)i; - ++v3; - } - } - } - } - } - } - return (PLAYER_SKILL_TYPE)37; + int counter; // edx@5 + bool canBeInactive; + unsigned char requiredValue; + signed int offset; + + if ( order <= 1 ) + { + canBeInactive = false; + requiredValue = 2; // 2 - primary skill + offset = 0; + } + else if ( order <= 3 ) + { + canBeInactive = false; + requiredValue = 1; // 1 - available + offset = 2; + } + else if ( order <= 12 ) + { + canBeInactive = true; + requiredValue = 1; // 1 - available + offset = 4; + } + else + { + return (PLAYER_SKILL_TYPE)37; + } + counter = 0; + for (int i = 0; i < 37; i++) + { + if ( (this->pActiveSkills[i] || canBeInactive) && pSkillAvailabilityPerClass[classType / 4][i] == requiredValue ) + { + if ( counter == order - offset ) + return (PLAYER_SKILL_TYPE)i; + ++counter; + } + } }