diff Actor.cpp @ 1545:c4ab816fcc5e

assert, Abortf, AbortWithError -> Assert, Error refactors here and there
author Nomad
date Sat, 07 Sep 2013 20:05:20 +0200
parents 61458df2cb4f
children 9a6567c6c76c
line wrap: on
line diff
--- a/Actor.cpp	Sat Sep 07 15:20:57 2013 +0200
+++ b/Actor.cpp	Sat Sep 07 20:05:20 2013 +0200
@@ -2,9 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
-
 #include "mm7_data.h"
 #include "DecalBuilder.h"
 
@@ -1826,7 +1823,7 @@
     v41.vDirection.y = (signed __int64)(1.0 / v33 * v43 * 65536.0);
     v41.vDirection.z = (signed __int64)(1.0 / v33 * a4a * 65536.0);
     v41.uDistance = (signed __int64)v33;
-    v41.uDistanceXZ = (signed __int64)sqrt(outy2 + outx2);
+    v41.uDistanceXZ = sqrt(outy2 + outx2);
     v41.uYawAngle = stru_5C6E00->Atan2((signed __int64)v42, (signed __int64)v43);
     v41.uPitchAngle = stru_5C6E00->Atan2(v41.uDistanceXZ, (signed __int64)a4a);
   }
@@ -4063,7 +4060,7 @@
 	//int v61; // [sp-14h] [bp-C4h]@168
 	//AIDirection *v62; // [sp-14h] [bp-C4h]@213
 	//signed int v63; // [sp-14h] [bp-C4h]@216
-	unsigned int v64; // [sp-14h] [bp-C4h]@219
+	//unsigned int v64; // [sp-14h] [bp-C4h]@219
 	unsigned int v65; // [sp-10h] [bp-C0h]@144
 	char v66; // [sp-10h] [bp-C0h]@147
 	//AIDirection *v67; // [sp-10h] [bp-C0h]@167
@@ -4194,19 +4191,19 @@
 				++v14;
 			}
 			while ( v13 < 22 );*/
-			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
+			if (pActor->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) )
 				pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight;
-			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 )
+			if (pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0)
 				pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
 			// not sure
-			else  if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 )
+			else if (pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0)
 				pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType;
 			
-			if ((signed __int64)pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 
-				|| (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0)
-				continue;
+			if (pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 ||
+				pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0)
+		      continue;
 			
 			//v15 = pMiscTimer->uTimeElapsed;
 			//v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime;
@@ -4408,7 +4405,7 @@
 					pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
 			}
 
-			if ( (signed __int64)pActor->pActorBuffs[4].uExpireTime > 0 )
+			if (pActor->pActorBuffs[4].uExpireTime > 0)
 			{
 				if ( (signed int)v36 >= 10240 )
 				{
@@ -4430,7 +4427,7 @@
 				{
 					if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 					{
-						Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333),	&pDir);
+						Actor::AI_Stand(actor_id, target_pid, pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333,	&pDir);
 					}
 					else
 					{
@@ -4477,21 +4474,19 @@
 							}
 							else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 							}
 							else
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								if ( v80 * 307.2 > (double)v81 )
 								{
-									v64 = (signed __int64)v47;
-									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+									Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 								}
 								else
 								{
-									Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
+									Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, &pDir);
 								}
 							}
 						}
@@ -4503,9 +4498,8 @@
 								{
 									if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 									{
-										v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-										v64 = (signed __int64)v47;
-										Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+										v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+										Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 									}
 									else
 									{
@@ -4515,9 +4509,8 @@
 								}
 								else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 								{
-									v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-									v64 = (signed __int64)v47;
-									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+									v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+									Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 								}
 								else
 								{
@@ -4530,9 +4523,8 @@
 							}
 							else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 							}
 							else
 							{
@@ -4559,14 +4551,13 @@
 							}
 							else if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 							}
 							else
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, &pDir);
 							}
 						}
 						else
@@ -4577,9 +4568,8 @@
 								{
 									if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 									{
-										v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-										v64 = (signed __int64)v47;
-										Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+										v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+										Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 									}
 									else
 									{
@@ -4588,9 +4578,8 @@
 								}
 								else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 								{
-									v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-									v64 = (signed __int64)v47;
-									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+									v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+									Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 								}
 								else
 								{
@@ -4600,9 +4589,8 @@
 							}
 							else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 							}
 							else
 							{
@@ -4638,8 +4626,7 @@
 					v58 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 					memcpy(&v74, v57, sizeof(v74));
 					memcpy(&pDir, &v74, sizeof(pDir));
-					v64 = (signed __int64)v58;
-					Actor::AI_Stand(actor_id, 4, v64, &pDir);
+					Actor::AI_Stand(actor_id, 4, v58, &pDir);
 				}				
 			}
 			else if ( !pActor->pMonsterInfo.uMissleAttack2Type )
@@ -4650,9 +4637,8 @@
 					{
 						if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 						{
-							v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-							v64 = (signed __int64)v47;
-							Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+							v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+							Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 						}
 						else
 						{
@@ -4661,9 +4647,8 @@
 					}
 					else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 					{
-						v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-						v64 = (signed __int64)v47;
-						Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+						v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+						Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 					}
 					else
 					{
@@ -4673,9 +4658,8 @@
 				}
 				else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 				{
-					v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-					v64 = (signed __int64)v47;
-					Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+					v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+					Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 				}
 				else
 				{
@@ -4686,14 +4670,9 @@
 			{
 				v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 				if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
-				{
-					v64 = (signed __int64)v47;
-					Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
-				}
+					Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 				else
-				{
-					Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
-				}
+					Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, &pDir);
 			}
 			else
 			{
@@ -4711,7 +4690,6 @@
 int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive)
 {
   unsigned int uAliveActors; // eax@6
-  int v5; // ecx@10
   unsigned int uTotalActors; // [sp+0h] [bp-4h]@1
 
   uTotalActors = 0;
@@ -4739,12 +4717,11 @@
   {
     uAliveActors = SearchAliveActors(&uTotalActors);
   }
-  v5 = 0;
-  if ( uNumAlive )
-    LOBYTE(v5) = (signed int)uAliveActors >= (signed int)uNumAlive;
+
+  if (uNumAlive)
+    return uAliveActors >= uNumAlive;
   else
-    LOBYTE(v5) = uTotalActors == uAliveActors;
-  return v5;
+    return uTotalActors == uAliveActors;
 }
 //----- (00408B54) --------------------------------------------------------
 unsigned int SearchActorByID(unsigned int *pTotalActors, unsigned int a2)
@@ -5029,7 +5006,7 @@
   if (pMonster->IsNotAlive())
     return;
 
-  BYTE1(pMonster->uAttributes) |= 0xC0u;
+  pMonster->uAttributes |= 0xC000;
   if ( pMonster->uAIState == Fleeing )
     pMonster->uAttributes |= 0x20000u;
   //v57 = 0;
@@ -5424,7 +5401,7 @@
   monster_id = a1;
   x_ = x;
   v15 = a1;
-  if ( (signed int)uNumActors < 500
+  if (uNumActors < 500
     && ((signed int)pAllocator->uBigBufferSizeAligned >> 10) - ((signed int)pAllocator->uNextFreeOffsetInBigBuffer >> 10) >= 2000 )
   {
     v16 = 0;