Mercurial > mm7
diff Actor.cpp @ 82:1faa29fd4c2d
many type, memory, boundary fixes
author | zipi |
---|---|
date | Sun, 03 Feb 2013 23:37:17 +0000 |
parents | 2bcc7b24c831 |
children | 81e93310f73c |
line wrap: on
line diff
--- a/Actor.cpp Sun Feb 03 15:36:54 2013 +0000 +++ b/Actor.cpp Sun Feb 03 23:37:17 2013 +0000 @@ -1435,7 +1435,7 @@ void Actor::_43AC45(unsigned int uActorID, int a2) { Actor *v2; // esi@1 - char *v3; // edi@4 + Actor *v3; // edi@4 int v4; // ebx@8 int v5; // ST1C_4@8 int v6; // eax@8 @@ -1451,29 +1451,29 @@ v9 = 0; if ( (signed int)uNumActors > 0 ) { - v3 = (char *)&pActors[0].vPosition.y; + v3 = pActors; do { - if ( ((Actor *)(v3 - 144))->CanAct() ) + if ( v3->CanAct() ) { if ( v9 != uActorID_ ) { - if ( Actor::_43ABB0(v2, (Actor *)(v3 - 144)) ) + if ( Actor::_43ABB0(v2, v3) ) { - v4 = abs(*((short *)v3 - 1) - v2->vPosition.x); - v5 = abs(*(short *)v3 - v2->vPosition.y); - v6 = abs(*((short *)v3 + 1) - v2->vPosition.z); + v4 = abs(v3->vPosition.x - v2->vPosition.x); + v5 = abs(v3->vPosition.y - v2->vPosition.y); + v6 = abs(v3->vPosition.z - v2->vPosition.z); if ( (double)sub_4621DA(v4, v5, v6) < 4096.0 ) { - *(v3 - 83) = 4; + v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)4; if ( v7 == 1 ) - *(v3 - 106) |= 8u; + BYTE2(v3->uAttributes) |= 8u; } } } } ++v9; - v3 += 836; + ++v3; } while ( v9 < (signed int)uNumActors ); } @@ -3026,7 +3026,7 @@ signed int v6; // edx@2 ActorJob *v7; // eax@2 signed int v8; // edi@2 - char *v9; // ecx@2 + ActorJob *v9; // ecx@2 __int16 v10; // cx@15 signed int v12; // [sp+8h] [bp-4h]@1 @@ -3039,16 +3039,16 @@ v6 = 65535; v7 = &v4->pScheduledJobs[v3]; v8 = 7; - v9 = (char *)&v7[7].uHour; - while ( !(*(v9 - 3) & 1) || (unsigned __int8)*v9 > v12 ) + v9 = &v7[7];//(char *)&v7[7].uHour; + while ( !(v9->uAttributes & 1) || v9->uHour > v12 ) { --v8; - v9 -= 12; + --v9; if ( v8 < 0 ) - goto LABEL_8; + break; } - v6 = v8; -LABEL_8: + if( v8 >= 0 ) + v6 = v8; if ( !v8 && v6 == 65535 ) v6 = 7; v5 = &v7[v6]; @@ -3692,7 +3692,7 @@ unsigned int v4; // ebx@1 int v5; // ecx@1 unsigned int v6; // eax@1 - char *v7; // edi@2 + Actor *v7; // edi@2 __int16 v8; // ax@3 int v9; // eax@10 signed int v10; // eax@13 @@ -3728,25 +3728,25 @@ v26 = 0; if ( (signed int)uNumActors <= 0 ) goto LABEL_26; - v7 = (char *)&pActors[0].uAIState; + v7 = pActors; do { - v8 = *(short *)v7; - if ( *(short *)v7 == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 ) + v8 = v7->uAIState; + if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 ) goto LABEL_23; if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) ) goto LABEL_13; - if ( ((Actor *)(v7 - 176))->IsAlive() == 1 ) + if ( v7->IsAlive() == 1 ) { v24 = v4; v3->uLastCharacterIDToHit = v4; LABEL_13: - v10 = v3->GetActorsRelation((Actor *)(v7 - 176)); + v10 = v3->GetActorsRelation(v7); if ( v10 == v4 ) goto LABEL_23; goto LABEL_14; } - v18 = *((unsigned int *)v7 + 133); + v18 = v7->uGroup; if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup ) goto LABEL_23; v10 = 4; @@ -3754,9 +3754,9 @@ if ( v3->pMonsterInfo.uHostilityType ) v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType; v11 = dword_4DF380[v10]; - v23 = abs(v3->vPosition.x - *((short *)v7 - 17)); - v27 = abs(v3->vPosition.y - *((short *)v7 - 16)); - v12 = abs(v3->vPosition.z - *((short *)v7 - 15)); + v23 = abs(v3->vPosition.x - v7->vPosition.x); + v27 = abs(v3->vPosition.y - v7->vPosition.y); + v12 = abs(v3->vPosition.z - v7->vPosition.z); v19 = v12; if ( v23 <= v11 && v27 <= v11 @@ -3769,7 +3769,7 @@ } v4 = 0; LABEL_23: - v7 += 836; + ++v7; v5 = v26++ + 1; } while ( v26 < (signed int)uNumActors );