Mercurial > mm7
diff Actor.cpp @ 1910:8d3723ca71e6
Actor::GetDirectionInfo changed the signature to a less confusing one
author | Grumpy7 |
---|---|
date | Tue, 22 Oct 2013 00:39:04 -0700 |
parents | 18dacb49efe9 |
children | 3f0b9ffd788c |
line wrap: on
line diff
--- a/Actor.cpp Tue Oct 22 00:04:14 2013 -0700 +++ b/Actor.cpp Tue Oct 22 00:39:04 2013 -0700 @@ -949,7 +949,7 @@ // // originally this function had following prototype: // // struct DirectionInfo GetDirectionInfo(signed int object1, signed int object2, signed int a4) // // but compiler converts functions returning structures by value in the such way -struct AIDirection * Actor::GetDirectionInfo( unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4 ) +void Actor::GetDirectionInfo( unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4 ) { signed int v4; // eax@1 signed int v5; // ecx@1 @@ -1117,33 +1117,31 @@ v33 = sqrt(a4a * a4a + outy2 + outx2); if ( v33 <= 1.0 ) { - v41.vDirection.x = 65536; - v41.vDirection.y = 0; - v41.vDirection.z = 0; - v41.uDistance = 1; - v41.uDistanceXZ = 1; - v41.uYawAngle = 0; - v41.uPitchAngle = 0; + pOut->vDirection.x = 65536; + pOut->vDirection.y = 0; + pOut->vDirection.z = 0; + pOut->uDistance = 1; + pOut->uDistanceXZ = 1; + pOut->uYawAngle = 0; + pOut->uPitchAngle = 0; } else { - v41.vDirection.x = (int32_t)(1.0 / v33 * v31 * 65536.0); - v41.vDirection.y = (int32_t)(1.0 / v33 * v32 * 65536.0); - v41.vDirection.z = (int32_t)(1.0 / v33 * a4a * 65536.0); - v41.uDistance = (uint)v33; - v41.uDistanceXZ = (uint)sqrt(outy2 + outx2); - v41.uYawAngle = stru_5C6E00->Atan2((signed __int64)v31, (signed __int64)v32); - v41.uPitchAngle = stru_5C6E00->Atan2(v41.uDistanceXZ, (signed __int64)a4a); + pOut->vDirection.x = (int32_t)(1.0 / v33 * v31 * 65536.0); + pOut->vDirection.y = (int32_t)(1.0 / v33 * v32 * 65536.0); + pOut->vDirection.z = (int32_t)(1.0 / v33 * a4a * 65536.0); + pOut->uDistance = (uint)v33; + pOut->uDistanceXZ = (uint)sqrt(outy2 + outx2); + pOut->uYawAngle = stru_5C6E00->Atan2((signed __int64)v31, (signed __int64)v32); + pOut->uPitchAngle = stru_5C6E00->Atan2(pOut->uDistanceXZ, (signed __int64)a4a); } - result = pOut; - memcpy(pOut, &v41, sizeof(AIDirection)); - return result; } //----- (00404030) -------------------------------------------------------- void Actor::AI_FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4) { AIDirection *v7; // eax@3 + AIDirection v1; // eax@3 Actor *v9; // ebx@3 AIDirection a3; // [sp+8h] [bp-38h]@4 @@ -1152,7 +1150,8 @@ v9 = &pActors[uActorID]; if ( !a4 ) { - v7 = Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), uObjID, &a3, 0); + Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), uObjID, &v1, 0); + v7 = &v1; } else { @@ -1189,7 +1188,10 @@ AIDirection a3; if (!a4) - a4 = Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), object_to_face_pid, &a3, 0); + { + Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), object_to_face_pid, &a3, 0); + a4 = &a3; + } actor->uAIState = Standing; if (!uActionLength) @@ -1268,7 +1270,8 @@ } else { - v12 = Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), sTargetPid, &a3, 0); + Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), sTargetPid, &a3, 0); + v12 = &a3; } v3->uYawAngle = LOWORD(v12->uYawAngle); v3->uCurrentActionLength = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkMelee]].uAnimLength * 8; @@ -1542,7 +1545,8 @@ { if ( pDir == nullptr) { - v9 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), a2, &a3, 0); + Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), a2, &a3, 0); + v9 = &a3; } else { @@ -1625,7 +1629,8 @@ { if ( pDir == nullptr ) { - v9 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); + Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); + v9 = &a3; } else { @@ -1708,7 +1713,8 @@ { if ( pDir == nullptr ) { - v9 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); + Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); + v9 = &a3; } else { @@ -1788,7 +1794,8 @@ { if ( pDir == nullptr ) { - v10 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); + Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); + v10 = &a3; } else { @@ -1965,7 +1972,8 @@ && v4->uAIState != AttackingRanged4 && v4->uAIState != AttackingMelee)) { - v10 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), edx0, &a3, 0), sizeof(v10); + Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), edx0, &a3, 0); + v10 = &a3; v4->uYawAngle = LOWORD(v10->uYawAngle); v7 = pSpriteFrameTable->pSpriteSFrames[v4->pSpriteIDs[ANIM_GotHit]].uAnimLength; v4->uCurrentActionTime = 0; @@ -1986,7 +1994,10 @@ AIDirection a3; // [sp+Ch] [bp-5Ch]@2 if (!a4) - a4 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), uObjID, &a3, 0); + { + Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), uObjID, &a3, 0); + a4 = &a3; + } actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; @@ -2145,7 +2156,8 @@ if ( pDir == nullptr ) { - v10 = Actor::GetDirectionInfo(v8, a2, &a3, v6); + Actor::GetDirectionInfo(v8, a2, &a3, v6); + v10 = &a3; } else { @@ -2203,9 +2215,11 @@ v7 = PID(OBJECT_Actor,uActorID); if ( !a4 ) { - a4 = Actor::GetDirectionInfo(v7, sTargetPid, &a3, v5->pMonsterInfo.uFlying); + Actor::GetDirectionInfo(v7, sTargetPid, &a3, v5->pMonsterInfo.uFlying); + a4 = &a3; } - v13 = Actor::GetDirectionInfo(v7, 4u, &v10, 0); + Actor::GetDirectionInfo(v7, 4u, &v10, 0); + v13 = &v10; if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) || PID_TYPE(sTargetPid) == OBJECT_Actor && v13->uDistance < 307.2 ) { @@ -2257,7 +2271,8 @@ v10 = pDir; if ( !pDir ) { - v10 = Actor::GetDirectionInfo(v8, a2, &a3, v6); + Actor::GetDirectionInfo(v8, a2, &a3, v6); + v10 = &a3; } if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { @@ -2319,7 +2334,8 @@ } if ( !a4 ) { - v20 = Actor::GetDirectionInfo(v7, a2, &a3, v5); + Actor::GetDirectionInfo(v7, a2, &a3, v5); + v20 = &a3; } if ( MonsterStats::BelongsToSupertype(v6->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { @@ -3052,7 +3068,8 @@ if ( !(pActor->uAttributes & 0x8000) ) pActor->uAttributes |= 0x8000; a1 = PID(OBJECT_Actor,actor_id); - pDir = Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0); + Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0); + pDir = &a3; uAIState = pActor->uAIState; if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly || (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 @@ -3322,9 +3339,9 @@ } else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) { - v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0); + Actor::GetDirectionInfo(a1, 4u, &v72, 0); v58 = (uint)(pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333); - Actor::AI_Stand(actor_id, 4, v58, v57); + Actor::AI_Stand(actor_id, 4, v58, &v72); } } else if ( !pActor->pMonsterInfo.uMissleAttack2Type )