diff Actor.cpp @ 1906:768590235c2c

UpdateActorAI getting rid of unnecessary memcpys
author Grumpy7
date Sun, 20 Oct 2013 23:50:19 -0700
parents 436553b0603c
children 1eb0515ff54b
line wrap: on
line diff
--- a/Actor.cpp	Sun Oct 20 23:12:09 2013 -0700
+++ b/Actor.cpp	Sun Oct 20 23:50:19 2013 -0700
@@ -2922,7 +2922,7 @@
 	int target_pid_type; // [sp+70h] [bp-40h]@83
 	signed int a1; // [sp+74h] [bp-3Ch]@129
 	int v78; // [sp+78h] [bp-38h]@79
-	AIDirection pDir; // [sp+7Ch] [bp-34h]@129
+	AIDirection* pDir; // [sp+7Ch] [bp-34h]@129
 	float v80; // [sp+98h] [bp-18h]@33
 	int v81; // [sp+9Ch] [bp-14h]@100
 	//int v82; // [sp+A0h] [bp-10h]@45
@@ -2955,11 +2955,11 @@
 				
 			pParty->uFlags |= 2u;
 			pParty->armageddon_timer -= pMiscTimer->uTimeElapsed;
-			v4 = pParty->field_16140 + 50;
+			v4 = pParty->armageddonDamage + 50;
 			if ( pParty->armageddon_timer <= 0 )
 			{
 				pParty->armageddon_timer = 0;
-				for(int i = 0; i < uNumActors; i++)
+				for(size_t i = 0; i < uNumActors; i++)
 				{
 					pActor=&pActors[i];
 					if ( pActor->CanAct() )
@@ -2984,7 +2984,7 @@
 				for(int i = 1; i <= 4; i++)
 				{
 					pPlayer = pPlayers[i];
-					if ( !pPlayer->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] )
+					if ( !pPlayer->pConditions[Condition_Dead] && !pPlayer->pConditions[Condition_Pertified] && !pPlayer->pConditions[Condition_Eradicated] )
 						pPlayer->ReceiveDamage(v4, DMGT_5);
 				}
 			}
@@ -3127,14 +3127,14 @@
 					pActor->pActorBuffs[i].IsBuffExpiredToTime(pParty->uTimePlayed);
 				}
 			}
-			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
+			if ( pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
 				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[2].uExpireTime < 0 )
+			if ( pActor->pActorBuffs[2].uExpireTime < 0 )
 			{
 				pActor->uAIState = Removed;
 				continue;
@@ -3154,9 +3154,7 @@
 			if ( !(pActor->uAttributes & 0x8000) )
 				pActor->uAttributes |= 0x8000;
 			a1 = PID(OBJECT_Actor,actor_id);
-			v30 = Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0);
-			memcpy(&v75, v30, sizeof(v75));
-			memcpy(&pDir, &v75, sizeof(pDir));
+			pDir = Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0);
 			uAIState = pActor->uAIState; 
 			/*if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Friendly
 				&& (signed int)v21->pMonsterInfo.uRecoveryTime <= 0
@@ -3170,7 +3168,7 @@
 			*/
 			if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly
 				|| (signed int)pActor->pMonsterInfo.uRecoveryTime > 0
-				|| v80 * 307.2 < (double)(signed int)v75.uDistance
+				|| v80 * 307.2 < pDir->uDistance
 				|| uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting
 				&&  !pActor->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned )
 			{
@@ -3194,33 +3192,33 @@
 				else if ( pActor->uAIState == AttackingRanged1 )
 				{
 					v34 = pActor->pMonsterInfo.uMissleAttack1Type;
-					Actor::AI_RangedAttack(actor_id, &pDir, v34, 0);
+					Actor::AI_RangedAttack(actor_id, pDir, v34, 0);
 				}
 				else if ( pActor->uAIState == AttackingRanged2 )
 				{
 					v34 = pActor->pMonsterInfo.uMissleAttack2Type;
-					Actor::AI_RangedAttack(actor_id, &pDir, v34, 1);
+					Actor::AI_RangedAttack(actor_id, pDir, v34, 1);
 				}
 				else if ( pActor->uAIState == AttackingRanged3 )
 				{
 					v65 = pActor->pMonsterInfo.uSpellSkillAndMastery1;
 					v33 = pActor->pMonsterInfo.uSpell1ID;
-					Actor::AI_SpellAttack(actor_id, &pDir, v33, 2, v65);
+					Actor::AI_SpellAttack(actor_id, pDir, v33, 2, v65);
 				}
 				else if ( pActor->uAIState == AttackingRanged4 )
 				{
 					v65 = pActor->pMonsterInfo.uSpellSkillAndMastery2;
 					v33 = pActor->pMonsterInfo.uSpell2ID;
-					Actor::AI_SpellAttack(actor_id, &pDir, v33, 3, v65);
+					Actor::AI_SpellAttack(actor_id, pDir, v33, 3, v65);
 				}
 			}
 
-			v36 = v75.uDistance;
+			v36 = pDir->uDistance;
 			if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly)
 			{
 				if ( target_pid_type == OBJECT_Actor )
 				{
-					v36 = v75.uDistance;
+					v36 = pDir->uDistance;
 					//v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (pActor->pMonsterInfo.uID - 1) / 3]
 					//	+ (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3);
                     v37 =pFactionTable->relations[(pActor->pMonsterInfo.uID-1) / 3 + 1][(pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3 + 1];
@@ -3262,7 +3260,7 @@
 				{
 					//peasents after attacked
 					//guard after attacked
-					Actor::AI_Flee(actor_id, target_pid, 0, &pDir);
+					Actor::AI_Flee(actor_id, target_pid, 0, pDir);
 				}
 				continue;
 			}
@@ -3274,11 +3272,11 @@
 				{
 					if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 					{
-						Actor::AI_Stand(actor_id, target_pid, pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333,	&pDir);
+						Actor::AI_Stand(actor_id, target_pid, pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333,	pDir);
 					}
 					else
 					{
-						Actor::AI_Flee(actor_id, target_pid, 0, &pDir);
+						Actor::AI_Flee(actor_id, target_pid, 0, pDir);
 						continue;
 					}
 						
@@ -3295,7 +3293,7 @@
 						v42 = (double)(signed int)v84;
 						if ( v43 > v42 && (signed int)v36 < 10240 )
 						{
-							Actor::AI_Flee(actor_id, target_pid, 0, &pDir);
+							Actor::AI_Flee(actor_id, target_pid, 0, pDir);
 							continue;
 						}
 					}
@@ -3317,23 +3315,23 @@
 						{
 							if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 )
 							{
-								Actor::AI_MissileAttack1(actor_id, target_pid, &pDir);
+								Actor::AI_MissileAttack1(actor_id, target_pid, pDir);
 							}
 							else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 							{
 								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+								Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 							}
 							else
 							{
 								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								if ( v80 * 307.2 > (double)v81 )
 								{
-									Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+									Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 								}
 								else
 								{
-									Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, &pDir);
+									Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, pDir);
 								}
 							}
 						}
@@ -3346,18 +3344,18 @@
 									if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 									{
 										v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-										Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+										Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 									}
 									else
 									{
 										//monsters
-										Actor::AI_Pursue3(actor_id, target_pid, 0, &pDir);
+										Actor::AI_Pursue3(actor_id, target_pid, 0, pDir);
 									}
 								}
 								else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 								{
 									v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-									Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+									Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 								}
 								else
 								{
@@ -3365,18 +3363,18 @@
 									//monsters
 									//guard after player runs away
 									// follow player
-									Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70);
+									Actor::AI_Pursue2(actor_id, target_pid, 0, pDir, v70);
 								}
 							}
 							else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 							{
 								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+								Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 							}
 							else
 							{
 								//monsters
-								Actor::AI_MeleeAttack(actor_id, target_pid, &pDir);
+								Actor::AI_MeleeAttack(actor_id, target_pid, pDir);
 							}
 						}
 						continue;
@@ -3392,19 +3390,19 @@
 							if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 )
 							{
 								if ( v45 == 2 )
-									Actor::AI_SpellAttack1(actor_id, target_pid, &pDir);
+									Actor::AI_SpellAttack1(actor_id, target_pid, pDir);
 								else
-									Actor::AI_SpellAttack2(actor_id, target_pid, &pDir);
+									Actor::AI_SpellAttack2(actor_id, target_pid, pDir);
 							}
 							else if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 							{
 								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+								Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 							}
 							else
 							{
 								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, &pDir);
+								Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, pDir);
 							}
 						}
 						else
@@ -3416,32 +3414,32 @@
 									if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 									{
 										v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-										Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+										Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 									}
 									else
 									{
-										Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir);
+										Actor::AI_Pursue3(actor_id, target_pid, 256, pDir);
 									}
 								}
 								else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 								{
 									v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-									Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+									Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 								}
 								else
 								{
 									v70 = (signed __int64)v80 * 307.2;
-									Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70);
+									Actor::AI_Pursue2(actor_id, target_pid, 0, pDir, v70);
 								}
 							}
 							else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 							{
 								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+								Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 							}
 							else
-							{
-								Actor::AI_MeleeAttack(actor_id, target_pid, &pDir);
+							{								
+							    Actor::AI_MeleeAttack(actor_id, target_pid, pDir);
 							}
 						}
 						continue;
@@ -3471,9 +3469,7 @@
 				{
 					v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0);
 					v58 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-					memcpy(&v74, v57, sizeof(v74));
-					memcpy(&pDir, &v74, sizeof(pDir));
-					Actor::AI_Stand(actor_id, 4, v58, &pDir);
+					Actor::AI_Stand(actor_id, 4, v58, pDir);
 				}				
 			}
 			else if ( !pActor->pMonsterInfo.uMissleAttack2Type )
@@ -3485,45 +3481,45 @@
 						if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 						{
 							v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-							Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+							Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 						}
 						else
 						{
-							Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir);
+							Actor::AI_Pursue3(actor_id, target_pid, 256, pDir);
 						}
 					}
 					else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 					{
 						v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-						Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+						Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 					}
 					else
 					{
 						v70 = (signed __int64)v80 * 307.2;
-						Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70);
+						Actor::AI_Pursue2(actor_id, target_pid, 0, pDir, v70);
 					}
 				}
 				else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 				{
 					v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-					Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+					Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 				}
 				else
 				{
-					Actor::AI_MeleeAttack(actor_id, target_pid, &pDir);
+					Actor::AI_MeleeAttack(actor_id, target_pid, pDir);
 				}
 			}
 			else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 			{
 				v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 				if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
-					Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
+					Actor::AI_Stand(actor_id, target_pid, v47, pDir);
 				else
-					Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, &pDir);
+					Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, pDir);
 			}
 			else
 			{
-				Actor::AI_MissileAttack2(actor_id, target_pid, &pDir);
+				Actor::AI_MissileAttack2(actor_id, target_pid, pDir);
 			}		
 		}
 	}