Mercurial > mm7
changeset 1853:4ae5b7e7a920
Actor::AI_SpellAttack unnesting ifs, simplifying cycles
author | Grumpy7 |
---|---|
date | Mon, 14 Oct 2013 00:24:28 +0200 |
parents | 979380004db2 |
children | a02d72dd7653 |
files | Actor.cpp |
diffstat | 1 files changed, 72 insertions(+), 182 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Sun Oct 13 11:44:15 2013 +0200 +++ b/Actor.cpp Mon Oct 14 00:24:28 2013 +0200 @@ -253,7 +253,7 @@ int v54; // ecx@138 int v55; // eax@142 SpellBuff *v56; // esi@143 - Player **v57; // esi@145 + Player *v57; // esi@145 int v58; // eax@146 int v59; // edi@146 int v60; // eax@146 @@ -372,44 +372,24 @@ 0); return; } - v10 = 3; - if ( uSkillLevel & 0x0100 ) - { - v105 = 9; - } - else - { - if ( (uSkillLevel & 0x80u) == 0 ) - { - if ( !(uSkillLevel & 0x40) ) - goto LABEL_29; - v105 = 5; - } - else - { - v105 = 7; - } - } - v10 = v105; -LABEL_29: + if (masteryLevel <= 1) + v10 = 3; + else if (masteryLevel == 2 ) + v10 = 5; + else if (masteryLevel == 3 ) + v10 = 7; + else if (masteryLevel == 4 ) + v10 = 9; spellnuma = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; a1.uType = stru_4E3ACC[15].uType; v118 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v10 - 1); v11 = 0; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_33: - LOWORD(v11) = 0; - } - else + for (unsigned int i = 0; i < pObjectList->uNumObjects; i++) { - v12 = &pObjectList->pObjects->uObjectID; - while ( stru_4E3ACC[15].uType != *v12 ) + if (stru_4E3ACC[15].uType == pObjectList->pObjects[i].uObjectID) { - ++v11; - v12 += 28; - if ( v11 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_33; + v11 = i; + break; } } a1.uObjectDescID = v11; @@ -468,22 +448,14 @@ LABEL_159: a1.uType = stru_4E3ACC[uSpellID].uType; v119 = 0.0; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_191: - v82 = 0; - } - else + v82 = 0; + for (int i = 0; i < pObjectList->uNumObjects; i++) { - v66 = (char *)&pObjectList->pObjects->uObjectID; - while ( (short)a1.uType != *(short *)v66 ) + if (a1.uType == pObjectList->pObjects[i].uObjectID) { - ++LODWORD(v119); - v66 += 56; - if ( SLODWORD(v119) >= (signed int)pObjectList->uNumObjects ) - goto LABEL_191; + v82 = i; + break; } - v82 = LOWORD(v119); } a1.uObjectDescID = v82; a1.stru_24.Reset(); @@ -508,30 +480,15 @@ a1.uSpriteFrameID = 0; a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); a1.spell_target_pid = 0; - a1.field_60_distance_related_prolly_lod = 3; - if ( (double)v89 >= 307.2 ) - { - if ( v89 >= 1024 ) - { - if ( v89 >= 2560 ) - { - if ( v89 < 5120 ) - a1.field_60_distance_related_prolly_lod = 3; - } - else - { - a1.field_60_distance_related_prolly_lod = 2; - } - } - else - { - a1.field_60_distance_related_prolly_lod = 1; - } - } - else - { + if ((double)v89 < 307.2 ) a1.field_60_distance_related_prolly_lod = 0; - } + else if ( v89 < 1024 ) + a1.field_60_distance_related_prolly_lod = 1; + else if ( v89 < 2560 ) + a1.field_60_distance_related_prolly_lod = 2; + else + a1.field_60_distance_related_prolly_lod = 3; + a1.field_61 = 2; v91 = a1.Create( v86->uYawAngle, @@ -557,25 +514,12 @@ v114 = pParty->vPosition.z + 2500; v113 = pParty->vPosition.y; v23 = 8; - if ( uSkillLevel & 0x0100 ) - { - v107 = 14; - } - else - { - if ( (uSkillLevel & 0x80u) == 0 ) - { - if ( !(uSkillLevel & 0x40) ) - goto LABEL_48; - v107 = 10; - } - else - { - v107 = 12; - } - } - v23 = v107; -LABEL_48: + if (masteryLevel == 2) + v23 = 10; + else if (masteryLevel == 3) + v23 = 12; + else if (masteryLevel == 4) + v23 = 14; v119 = 0.0; spellnumb = 0; if ( v23 > 0 ) @@ -609,23 +553,14 @@ } a1.stru_24.Reset(); a1.uType = stru_4E3ACC[9].uType; - spellnumd = 0; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_57: - v34 = 0; - } - else + v34 = 0; + for (int i = 0; i < pObjectList->uNumObjects; i++) { - v33 = (char *)&pObjectList->pObjects->uObjectID; - while ( (short)a1.uType != *(short *)v33 ) + if (pObjectList->pObjects[i].uObjectID == a1.uType) { - ++spellnumd; - v33 += 56; - if ( spellnumd >= (signed int)pObjectList->uNumObjects ) - goto LABEL_57; + v34 = i; + break; } - v34 = spellnumd; } a1.uObjectDescID = v34; a1.spell_level = uSkillLevel; @@ -644,29 +579,14 @@ a1.uSoundID = 0; v35 = v117->uDistance; LODWORD(v119) = v117->uDistance; - if ( (double)SLODWORD(v119) >= 307.2 ) - { - if ( v35 >= 1024 ) - { - if ( v35 >= 2560 ) - { - if ( v35 < 5120 ) - a1.field_60_distance_related_prolly_lod = 3; - } - else - { - a1.field_60_distance_related_prolly_lod = 2; - } - } - else - { - a1.field_60_distance_related_prolly_lod = 1; - } - } - else - { + if ((double)v119 < 307.2 ) a1.field_60_distance_related_prolly_lod = 0; - } + else if ( v119 < 1024 ) + a1.field_60_distance_related_prolly_lod = 1; + else if ( v119 < 2560 ) + a1.field_60_distance_related_prolly_lod = 2; + else + a1.field_60_distance_related_prolly_lod = 3; a1.field_61 = 2; v36 = a1.Create( v32, @@ -824,38 +744,28 @@ { if ( uSpellID == 80 ) { - v56 = pParty->pPartyBuffs; - do + for (int i = 0; i < 20; i++ ) { - v56->Reset(); - ++v56; + pParty->pPartyBuffs[i].Reset(); } - while ( (signed int)v56 < (signed int)pParty->pPlayers ); - a1b = 1; - v57 = &pPlayers[1]; - do + for (int i = 1; i <= 4; i++) { - v58 = (*v57)->GetActualWillpower(); - v59 = (*v57)->GetParameterBonus(v58); - v60 = (*v57)->GetActualIntelligence(); - v61 = ((*v57)->GetParameterBonus(v60) + v59) >> 1; - v62 = (*v57)->GetActualLuck(); - v63 = v61 + (*v57)->GetParameterBonus(v62) + 30; + v57 = pPlayers[i]; + v58 = (v57)->GetActualWillpower(); + v59 = (v57)->GetParameterBonus(v58); + v60 = (v57)->GetActualIntelligence(); + v61 = ((v57)->GetParameterBonus(v60) + v59) >> 1; + v62 = (v57)->GetActualLuck(); + v63 = v61 + (v57)->GetParameterBonus(v62) + 30; if ( rand() % v63 < 30 ) { - v64 = 6048; - do + for (int k = 0; k < v57->pPlayerBuffs.size(); k++) { - ((SpellBuff *)((char *)*v57 + v64))->Reset(); - v64 += 16; + v57->pPlayerBuffs[k].Reset(); } - while ( v64 < 6432 ); - pOtherOverlayList->_4418B1(11210, a1b + 99, 0, 65536); + pOtherOverlayList->_4418B1(11210, i + 99, 0, 65536); } - ++a1b; - ++v57; } - while ( (signed int)v57 <= (signed int)&pPlayers[4] ); v65 = 8 * LODWORD(v120); LOBYTE(v65) = PID(OBJECT_Actor,LOBYTE(v120)); v99 = v65; @@ -901,9 +811,7 @@ pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0); return; } - v49 = uSpellID == 78; -LABEL_158: - if ( !v49 ) + if ( uSpellID != 78 ) return; goto LABEL_159; } @@ -1016,8 +924,9 @@ { if ( uSpellID != 95 ) { - v49 = uSpellID == 97; - goto LABEL_158; + if ( uSpellID != 97 ) + return; + goto LABEL_159; } if (masteryLevel == 0) v68 = 0; @@ -1045,44 +954,25 @@ pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0); return; } + v70 = 3; - if ( uSkillLevel & 0x100 ) - { + if (masteryLevel == 2) + v108 = 5; + else if (masteryLevel == 3) + v108 = 7; + else if (masteryLevel == 4) v108 = 9; - } - else - { - if ( (uSkillLevel & 0x80u) == 0 ) - { - if ( !(uSkillLevel & 0x40) ) - goto LABEL_179; - v108 = 5; - } - else - { - v108 = 7; - } - } - v70 = v108; -LABEL_179: + spellnume = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; a1.uType = stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType; v116 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v70 - 1); v71 = 0; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_183: - LOWORD(v71) = 0; - } - else + for (int i = 0; i < pObjectList->uNumObjects; i++) { - v72 = &pObjectList->pObjects->uObjectID; - while ( stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType != *v72 ) + if (pObjectList->pObjects[i].uObjectID == stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType) { - ++v71; - v72 += 28; - if ( v71 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_183; + v71 = i; + break; } } a1.uObjectDescID = v71;