Mercurial > mm7
diff mm7_3.cpp @ 845:8f135b689262
UpdateActors_ODM cleaning
author | zipi |
---|---|
date | Fri, 29 Mar 2013 16:13:32 +0000 |
parents | d593ca75c366 |
children | 39503542470c |
line wrap: on
line diff
--- a/mm7_3.cpp Fri Mar 29 14:53:06 2013 +0000 +++ b/mm7_3.cpp Fri Mar 29 16:13:32 2013 +0000 @@ -862,15 +862,15 @@ void __cdecl UpdateActors_ODM() { Actor *v0; // esi@2 - unsigned __int16 v1; // ax@2 + AIState uAIState; // ax@2 unsigned int v2; // ecx@6 int v3; // ebx@6 - int v4; // eax@8 + //int v4; // eax@8 int v5; // eax@10 int v6; // ecx@10 signed int v7; // ebx@10 signed int v8; // ebx@17 - unsigned __int8 v9; // zf@17 + //unsigned __int8 v9; // zf@17 unsigned __int8 v10; // sf@17 unsigned __int16 v11; // ax@21 int v12; // eax@29 @@ -895,7 +895,7 @@ int v31; // edi@57 signed int i; // ebx@57 unsigned int v33; // ecx@58 - int v34; // ebx@64 + //int v34; // ebx@64 int v35; // edi@64 int v36; // eax@64 unsigned __int16 v37; // cx@66 @@ -915,7 +915,7 @@ unsigned __int64 v51; // qax@85 unsigned __int8 v52; // zf@87 unsigned __int8 v53; // sf@87 - unsigned __int8 v54; // of@104 + // unsigned __int8 v54; // of@104 int v55; // eax@107 unsigned int v56; // edi@107 int v57; // ST10_4@107 @@ -933,67 +933,63 @@ unsigned int v69; // [sp+30h] [bp-20h]@6 unsigned int v70; // [sp+34h] [bp-1Ch]@10 int v71; // [sp+38h] [bp-18h]@62 - int v72; // [sp+3Ch] [bp-14h]@10 + int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10 + int v72b; int v73; // [sp+40h] [bp-10h]@17 - int v74; // [sp+44h] [bp-Ch]@8 + int uIsFlying; // [sp+44h] [bp-Ch]@8 unsigned int v75; // [sp+48h] [bp-8h]@1 - int v76; // [sp+4Ch] [bp-4h]@10 - - v75 = 0; - if ( (signed int)uNumActors <= 0 ) - return; - do + int uIsOnWater; // [sp+4Ch] [bp-4h]@10 + + for(v75=0;(signed int)v75 < (signed int)uNumActors;++v75) { v0 = &pActors[v75]; v66 = v0->vPosition.x; v65 = v0->vPosition.y; - v1 = v0->uAIState; - if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed ) - goto LABEL_121; + uAIState = v0->uAIState; + if ( uAIState == Removed || uAIState == Disabled || uAIState == Summoned || !v0->uMovementSpeed ) + { + continue; + } v2 = v0->pMonsterInfo.uID; v3 = 0; v69 = 0; if ( MonsterStats::BelongsToSupertype(v2, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) v3 = 1; - v4 = v0->pMonsterInfo.uFlying; v0->uSectorID = 0; - v74 = v4; + uIsFlying = v0->pMonsterInfo.uFlying; if ( !v0->CanAct() ) - v74 = 0; + uIsFlying = 0; v70 = IsTerrainSlopeTooHigh(v0->vPosition.x, v0->vPosition.y); v5 = ODM_GetFloorLevel( v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v0->uActorHeight, - &v76, + &uIsOnWater, (int *)&v69, v3); v6 = v0->vPosition.z; v7 = v5; v68 = v5; - v72 = 0; + uIsAboveFloor = 0; v67 = v69 == 0; if ( v6 > v5 + 1 ) - v72 = 1; - if ( v0->uAIState == 5 && v76 && !v72 ) + uIsAboveFloor = 1; + if ( uAIState == Dead && uIsOnWater && !uIsAboveFloor ) { v0->uAIState = Removed; - goto LABEL_121; + continue; } if ( v0->uCurrentActionAnimation == ANIM_Walking ) { v8 = v0->uMovementSpeed; - v9 = HIDWORD(v0->pActorBuffs[7].uExpireTime) == 0; - v10 = SHIDWORD(v0->pActorBuffs[7].uExpireTime) < 0; v73 = v0->uMovementSpeed; - if ( !v10 && (!(v10 | v9) || LODWORD(v0->pActorBuffs[7].uExpireTime) > 0) ) + if ( (signed __int64)v0->pActorBuffs[7].uExpireTime > 0 ) { v8 = (signed __int64)((double)v73 * 0.5); v73 = (signed __int64)((double)v73 * 0.5); } - v11 = v0->uAIState; - if ( v11 == 7 || v11 == 6 ) + if ( uAIState == Fleeing || uAIState == Pursuing ) { v8 *= 2; v73 = v8; @@ -1003,15 +999,13 @@ if ( v8 > 1000 ) v8 = 1000; v12 = stru_5C6E00->Cos(v0->uYawAngle); - v69 = v12; v13 = v12 * (signed __int64)v8; v73 = v13 >> 16; v0->vVelocity.x = WORD1(v13); v69 = stru_5C6E00->Sin(v0->uYawAngle); v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v8) >> 16; - v9 = v74 == 0; v0->vVelocity.y = v69 * v8 >> 16; - if ( !v9 ) + if ( uIsFlying ) { v14 = stru_5C6E00->Sin(v0->uPitchAngle); v69 = v14; @@ -1029,9 +1023,8 @@ v0->vVelocity.x = v73; v73 = v0->vVelocity.y; v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v73) >> 16; - v9 = v74 == 0; v0->vVelocity.y = v73; - if ( !v9 ) + if ( uIsFlying ) { v69 = 55000; v73 = v0->vVelocity.z; @@ -1041,14 +1034,14 @@ } if ( v0->vPosition.z < v7 ) { - v16 = v74; + v16 = uIsFlying; v0->vPosition.z = v7; v0->vVelocity.z = v16 != 0 ? 0x14 : 0; } v17 = 0; - if ( !v72 || v74 ) - { - if ( v70 && !v72 && v67 ) + if ( !uIsAboveFloor || uIsFlying ) + { + if ( v70 && !uIsAboveFloor && v67 ) { v18 = v0->vPosition.y; v19 = v0->vPosition.x; @@ -1060,14 +1053,14 @@ v23 = v62.y * v0->vVelocity.y; v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; v73 = abs(v62.x * v0->vVelocity.x + v22 * v0->vVelocity.z + v23) >> 16; - v72 = v21; + v72b = v21; v0->vVelocity.x += (unsigned int)(v73 * v62.x) >> 16; - v72 = (unsigned __int64)(v73 * (signed __int64)v72) >> 16; - v24 = v72; - v72 = v22; + v72b = (unsigned __int64)(v73 * (signed __int64)v72b) >> 16; + v24 = v72b; + v72b = v22; v0->vVelocity.y += v24; - v72 = (unsigned __int64)(v73 * (signed __int64)v72) >> 16; - v0->vVelocity.z += v72; + v72b = (unsigned __int64)(v73 * (signed __int64)v72b) >> 16; + v0->vVelocity.z += v72b; v17 = 0; } } @@ -1090,9 +1083,8 @@ v0->vVelocity.y = v17; v0->vVelocity.x = v17; } - v9 = v0->pMonsterInfo.uFlying == 0; stru_721530.field_0 = 1; - if ( v9 ) + if ( !uIsFlying ) v26 = 40; else v26 = v0->uActorRadius; @@ -1136,7 +1128,7 @@ v71 = i > 1; if ( stru_721530.field_7C < stru_721530.field_6C ) v70 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; - v34 = 0; + //v34 = 0; v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; v36 = ODM_GetFloorLevel( stru_721530.normal2.x, @@ -1146,7 +1138,7 @@ (int *)&v63, &v64, 0); - if ( v76 ) + if ( uIsOnWater ) { if ( v35 < v36 + 60 ) { @@ -1170,60 +1162,64 @@ v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; break; } - v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; + v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16; - v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; + v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16; - v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; + v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; v38 = stru_721530.uFaceID; v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16; stru_721530.field_70 += stru_721530.field_7C; v39 = v38 >> 3; - switch ( v38 & 7 ) - { - case 3: - if ( pParty->bTurnBasedModeOn != 1 ) - goto LABEL_97; - if ( pTurnEngine->field_4 != 2 && pTurnEngine->field_4 != 3 ) - { - v34 = 0; -LABEL_97: + switch ( PID_TYPE(v38) ) + { + case OBJECT_Actor: + if ( pTurnEngine->field_4 != 2 && pTurnEngine->field_4 != 3 || pParty->bTurnBasedModeOn != 1 ) + { + //if(pParty->bTurnBasedModeOn == 1) + //v34 = 0; if ( v0->pMonsterInfo.uHostilityType ) { - if ( v71 == v34 ) - goto LABEL_99; -LABEL_101: - Actor::AI_StandOrBored(v75, 4, v34, (AIDirection *)v34); - break; + if ( v71 == 0 ) + { + Actor::_402968(v75, v38, 0, (AIDirection *)0); + } + else + { + Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); + } } - if ( v71 != v34 ) - goto LABEL_101; - if ( pActors[v39].pMonsterInfo.uHostilityType ) + else if ( v71 != 0 ) + { + Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); + } + else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly ) { -LABEL_99: - Actor::_402968(v75, v38, v34, (AIDirection *)v34); - break; + Actor::_402968(v75, v38, 0, (AIDirection *)0); } -LABEL_103: - Actor::FaceObject(v75, v38, v34, (AIDirection *)v34); - break; + else + { + Actor::FaceObject(v75, v38, 0, (AIDirection *)0); + } } break; - case 4: + case OBJECT_Player: if ( !v0->GetActorsRelation(0) ) { v38 = stru_721530.uFaceID; - goto LABEL_103; + Actor::FaceObject(v75, v38, 0, (AIDirection *)0); + break; } v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0; v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0; v0->vVelocity.y = 0; v0->vVelocity.x = 0; - if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > 0) ) + //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > 0) ) + if ( (signed __int64)pParty->pPartyBuffs[11].uExpireTime < 0) pParty->pPartyBuffs[11].Reset(); viewparams->bRedrawGameUI = 1; break; - case 5: + case OBJECT_Decoration: v47 = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); v48 = stru_5C6E00->Atan2( v0->vPosition.x - pLevelDecorations[v39].vPosition.x, @@ -1238,7 +1234,7 @@ v70 = v51 >> 16; v0->vVelocity.y = WORD1(v51); break; - case 6: + case OBJECT_BModel: v40 = &pOutdoor->pBModels[v38 >> 9]; v41 = &v40->pFaces[v39 & 0x3F]; if ( !(BYTE3(v41->uAttributes) & 0x20) ) @@ -1258,16 +1254,16 @@ } else { - v72 = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z + v72b = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z + v41->pFacePlane.vNormal.x * v0->vVelocity.x) >> 16; - if ( stru_721530.field_64 >> 3 > v72 ) - v72 = stru_721530.field_64 >> 3; + if ( stru_721530.field_64 >> 3 > v72b ) + v72b = stru_721530.field_64 >> 3; v73 = v41->pFacePlane.vNormal.x; - v73 = (unsigned __int64)(v72 * (signed __int64)v73) >> 16; + v73 = (unsigned __int64)(v72b * (signed __int64)v73) >> 16; v71 = v41->pFacePlane.vNormal.y; - v71 = (unsigned __int64)(v72 * (signed __int64)v71) >> 16; + v71 = (unsigned __int64)(v72b * (signed __int64)v71) >> 16; v70 = v41->pFacePlane.vNormal.z; - v70 = (unsigned __int64)(v72 * (signed __int64)(signed int)v70) >> 16; + v70 = (unsigned __int64)(v72b * (signed __int64)(signed int)v70) >> 16; v0->vVelocity.x += v73; v0->vVelocity.y += v71; v0->vVelocity.z += v70; @@ -1302,35 +1298,31 @@ v70 = v0->vVelocity.z; v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16; ++v69; - v54 = v69 < 100; - v10 = (v69 - 100) < 0; + //v54 = v69 < 100; + //v10 = (v69 - 100) < 0; v0->vVelocity.z = v70; - if ( !(v10 ^ v54) ) + if ( v69 >= 100 ) break; v26 = stru_721530.prolly_normal_d; } v69 = WorldPosToGridCellX(v66); v55 = WorldPosToGridCellZ(v65); - v56 = v55 - 1; v57 = v0->vPosition.x; - v71 = v55 - 1; v68 = WorldPosToGridCellX(v57); v70 = WorldPosToGridCellZ(v0->vPosition.y) - 1; v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v69, v56) >> 1) & 1; v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v68, v70) >> 1) & 1; - v60 = 0; - if ( v69 == v68 && v71 == v70 && v58 ) - v60 = 1; - if ( !v67 ) - v60 = 1; - if ( !v60 ) + if ( WorldPosToGridCellX(v66) == WorldPosToGridCellX(v57) + && WorldPosToGridCellZ(v65) == WorldPosToGridCellZ(v0->vPosition.y) + && v58 + || v67 != 0 ) { if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) { v58 = v58 == 0; v59 = v59 == 0; } - if ( !v74 && v58 && !v59 ) + if ( !uIsFlying && v58 && !v59 ) { v0->vPosition.x = v66; v0->vPosition.y = v65; @@ -1343,10 +1335,7 @@ } } } -LABEL_121: - ++v75; - } - while ( (signed int)v75 < (signed int)uNumActors ); + } } //----- (0047253E) -------------------------------------------------------- @@ -15111,11 +15100,11 @@ unsigned __int16 v22; // ax@86 //signed int v23; // eax@94 //unsigned int v24; // eax@102 - signed int v25; // edi@102 - SpellBuff *v26; // esi@102 + //signed int v25; // edi@102 + //SpellBuff *v26; // esi@102 unsigned int v27; // ecx@123 unsigned int v28; // eax@123 - unsigned int v29; // eax@127 + //unsigned int v29; // eax@127 AIDirection *v30; // eax@129 unsigned __int16 v31; // ax@132 //unsigned int v32; // esi@142 @@ -15292,17 +15281,18 @@ ++v14; } while ( v13 < 22 );*/ - if ( actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) + if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) //&& SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12 // || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) ) actor->uActorHeight = pMonsterList->pMonsters[actor->pMonsterInfo.uID - 1].uMonsterHeight; - if ( actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) + if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; // not sure - else // if ( v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) + else // if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType; - if (actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime || actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) + if ((signed __int64)actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 + || (signed __int64)actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0) continue; //v15 = pMiscTimer->uTimeElapsed; @@ -15373,32 +15363,27 @@ } if ( !v21->sCurrentHP ) Actor::Die(actor_id); - v25 = 0; - v26 = v21->pActorBuffs; - do + for(int i=0;i<22;i++) { - if ( v25 != 10 ) + if ( i != 10 ) { - v26->_4585CA(pParty->uTimePlayed); - //v24 = 0; + v21->pActorBuffs[i]._4585CA(pParty->uTimePlayed); } - ++v25; - ++v26; } - while ( v25 < 22 ); - if ( v21->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) + if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight; - if ( v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) + if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; // not sure - else // if ( v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) + else // if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType; - if ( v21->pActorBuffs[2].uExpireTime < 0 ) + if ( (signed __int64)v21->pActorBuffs[2].uExpireTime < 0 ) { v21->uAIState = Removed; continue; } - if ( v21->pActorBuffs[5].uExpireTime || v21->pActorBuffs[6].uExpireTime ) + if ( (signed __int64)v21->pActorBuffs[5].uExpireTime > 0 + || (signed __int64)v21->pActorBuffs[6].uExpireTime > 0) { continue; } @@ -15409,9 +15394,8 @@ v21->pMonsterInfo.uRecoveryTime = v28 - v27; if ( v21->pMonsterInfo.uRecoveryTime< 0 ) v21->pMonsterInfo.uRecoveryTime = 0; - v29 = v21->uAttributes; - if ( !(v29 & 0x8000) ) - v21->uAttributes = v29 | 0x8000; + if ( !(v21->uAttributes & 0x8000) ) + v21->uAttributes |= 0x8000; a1 = 8 * actor_id | OBJECT_Actor; v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, actor_pid, &a3, 0); memcpy(&v75, v30, sizeof(v75));