comparison Actor.cpp @ 82:1faa29fd4c2d

many type, memory, boundary fixes
author zipi
date Sun, 03 Feb 2013 23:37:17 +0000
parents 2bcc7b24c831
children 81e93310f73c
comparison
equal deleted inserted replaced
81:377535d6e366 82:1faa29fd4c2d
1433 1433
1434 //----- (0043AC45) -------------------------------------------------------- 1434 //----- (0043AC45) --------------------------------------------------------
1435 void Actor::_43AC45(unsigned int uActorID, int a2) 1435 void Actor::_43AC45(unsigned int uActorID, int a2)
1436 { 1436 {
1437 Actor *v2; // esi@1 1437 Actor *v2; // esi@1
1438 char *v3; // edi@4 1438 Actor *v3; // edi@4
1439 int v4; // ebx@8 1439 int v4; // ebx@8
1440 int v5; // ST1C_4@8 1440 int v5; // ST1C_4@8
1441 int v6; // eax@8 1441 int v6; // eax@8
1442 int v7; // [sp+4h] [bp-10h]@1 1442 int v7; // [sp+4h] [bp-10h]@1
1443 unsigned int uActorID_; // [sp+Ch] [bp-8h]@1 1443 unsigned int uActorID_; // [sp+Ch] [bp-8h]@1
1449 if ( a2 == 1 ) 1449 if ( a2 == 1 )
1450 BYTE2(v2->uAttributes) |= 8u; 1450 BYTE2(v2->uAttributes) |= 8u;
1451 v9 = 0; 1451 v9 = 0;
1452 if ( (signed int)uNumActors > 0 ) 1452 if ( (signed int)uNumActors > 0 )
1453 { 1453 {
1454 v3 = (char *)&pActors[0].vPosition.y; 1454 v3 = pActors;
1455 do 1455 do
1456 { 1456 {
1457 if ( ((Actor *)(v3 - 144))->CanAct() ) 1457 if ( v3->CanAct() )
1458 { 1458 {
1459 if ( v9 != uActorID_ ) 1459 if ( v9 != uActorID_ )
1460 { 1460 {
1461 if ( Actor::_43ABB0(v2, (Actor *)(v3 - 144)) ) 1461 if ( Actor::_43ABB0(v2, v3) )
1462 { 1462 {
1463 v4 = abs(*((short *)v3 - 1) - v2->vPosition.x); 1463 v4 = abs(v3->vPosition.x - v2->vPosition.x);
1464 v5 = abs(*(short *)v3 - v2->vPosition.y); 1464 v5 = abs(v3->vPosition.y - v2->vPosition.y);
1465 v6 = abs(*((short *)v3 + 1) - v2->vPosition.z); 1465 v6 = abs(v3->vPosition.z - v2->vPosition.z);
1466 if ( (double)sub_4621DA(v4, v5, v6) < 4096.0 ) 1466 if ( (double)sub_4621DA(v4, v5, v6) < 4096.0 )
1467 { 1467 {
1468 *(v3 - 83) = 4; 1468 v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)4;
1469 if ( v7 == 1 ) 1469 if ( v7 == 1 )
1470 *(v3 - 106) |= 8u; 1470 BYTE2(v3->uAttributes) |= 8u;
1471 } 1471 }
1472 } 1472 }
1473 } 1473 }
1474 } 1474 }
1475 ++v9; 1475 ++v9;
1476 v3 += 836; 1476 ++v3;
1477 } 1477 }
1478 while ( v9 < (signed int)uNumActors ); 1478 while ( v9 < (signed int)uNumActors );
1479 } 1479 }
1480 } 1480 }
1481 1481
3024 Actor *v4; // esi@1 3024 Actor *v4; // esi@1
3025 ActorJob *v5; // eax@1 3025 ActorJob *v5; // eax@1
3026 signed int v6; // edx@2 3026 signed int v6; // edx@2
3027 ActorJob *v7; // eax@2 3027 ActorJob *v7; // eax@2
3028 signed int v8; // edi@2 3028 signed int v8; // edi@2
3029 char *v9; // ecx@2 3029 ActorJob *v9; // ecx@2
3030 __int16 v10; // cx@15 3030 __int16 v10; // cx@15
3031 signed int v12; // [sp+8h] [bp-4h]@1 3031 signed int v12; // [sp+8h] [bp-4h]@1
3032 3032
3033 v3 = uActorID; 3033 v3 = uActorID;
3034 v12 = a2; 3034 v12 = a2;
3037 if ( v5 ) 3037 if ( v5 )
3038 { 3038 {
3039 v6 = 65535; 3039 v6 = 65535;
3040 v7 = &v4->pScheduledJobs[v3]; 3040 v7 = &v4->pScheduledJobs[v3];
3041 v8 = 7; 3041 v8 = 7;
3042 v9 = (char *)&v7[7].uHour; 3042 v9 = &v7[7];//(char *)&v7[7].uHour;
3043 while ( !(*(v9 - 3) & 1) || (unsigned __int8)*v9 > v12 ) 3043 while ( !(v9->uAttributes & 1) || v9->uHour > v12 )
3044 { 3044 {
3045 --v8; 3045 --v8;
3046 v9 -= 12; 3046 --v9;
3047 if ( v8 < 0 ) 3047 if ( v8 < 0 )
3048 goto LABEL_8; 3048 break;
3049 } 3049 }
3050 v6 = v8; 3050 if( v8 >= 0 )
3051 LABEL_8: 3051 v6 = v8;
3052 if ( !v8 && v6 == 65535 ) 3052 if ( !v8 && v6 == 65535 )
3053 v6 = 7; 3053 v6 = 7;
3054 v5 = &v7[v6]; 3054 v5 = &v7[v6];
3055 if ( v4->vInitialPosition.x != v5->vPos.x 3055 if ( v4->vInitialPosition.x != v5->vPos.x
3056 || v4->vInitialPosition.y != v5->vPos.y 3056 || v4->vInitialPosition.y != v5->vPos.y
3690 { 3690 {
3691 Actor *v3; // esi@1 3691 Actor *v3; // esi@1
3692 unsigned int v4; // ebx@1 3692 unsigned int v4; // ebx@1
3693 int v5; // ecx@1 3693 int v5; // ecx@1
3694 unsigned int v6; // eax@1 3694 unsigned int v6; // eax@1
3695 char *v7; // edi@2 3695 Actor *v7; // edi@2
3696 __int16 v8; // ax@3 3696 __int16 v8; // ax@3
3697 int v9; // eax@10 3697 int v9; // eax@10
3698 signed int v10; // eax@13 3698 signed int v10; // eax@13
3699 int v11; // ebx@16 3699 int v11; // ebx@16
3700 int v12; // eax@16 3700 int v12; // eax@16
3726 v21 = 0; 3726 v21 = 0;
3727 v24 = v6; 3727 v24 = v6;
3728 v26 = 0; 3728 v26 = 0;
3729 if ( (signed int)uNumActors <= 0 ) 3729 if ( (signed int)uNumActors <= 0 )
3730 goto LABEL_26; 3730 goto LABEL_26;
3731 v7 = (char *)&pActors[0].uAIState; 3731 v7 = pActors;
3732 do 3732 do
3733 { 3733 {
3734 v8 = *(short *)v7; 3734 v8 = v7->uAIState;
3735 if ( *(short *)v7 == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 ) 3735 if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 )
3736 goto LABEL_23; 3736 goto LABEL_23;
3737 if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) ) 3737 if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) )
3738 goto LABEL_13; 3738 goto LABEL_13;
3739 if ( ((Actor *)(v7 - 176))->IsAlive() == 1 ) 3739 if ( v7->IsAlive() == 1 )
3740 { 3740 {
3741 v24 = v4; 3741 v24 = v4;
3742 v3->uLastCharacterIDToHit = v4; 3742 v3->uLastCharacterIDToHit = v4;
3743 LABEL_13: 3743 LABEL_13:
3744 v10 = v3->GetActorsRelation((Actor *)(v7 - 176)); 3744 v10 = v3->GetActorsRelation(v7);
3745 if ( v10 == v4 ) 3745 if ( v10 == v4 )
3746 goto LABEL_23; 3746 goto LABEL_23;
3747 goto LABEL_14; 3747 goto LABEL_14;
3748 } 3748 }
3749 v18 = *((unsigned int *)v7 + 133); 3749 v18 = v7->uGroup;
3750 if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup ) 3750 if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup )
3751 goto LABEL_23; 3751 goto LABEL_23;
3752 v10 = 4; 3752 v10 = 4;
3753 LABEL_14: 3753 LABEL_14:
3754 if ( v3->pMonsterInfo.uHostilityType ) 3754 if ( v3->pMonsterInfo.uHostilityType )
3755 v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType; 3755 v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType;
3756 v11 = dword_4DF380[v10]; 3756 v11 = dword_4DF380[v10];
3757 v23 = abs(v3->vPosition.x - *((short *)v7 - 17)); 3757 v23 = abs(v3->vPosition.x - v7->vPosition.x);
3758 v27 = abs(v3->vPosition.y - *((short *)v7 - 16)); 3758 v27 = abs(v3->vPosition.y - v7->vPosition.y);
3759 v12 = abs(v3->vPosition.z - *((short *)v7 - 15)); 3759 v12 = abs(v3->vPosition.z - v7->vPosition.z);
3760 v19 = v12; 3760 v19 = v12;
3761 if ( v23 <= v11 3761 if ( v23 <= v11
3762 && v27 <= v11 3762 && v27 <= v11
3763 && v12 <= v11 3763 && v12 <= v11
3764 && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3) 3764 && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3)
3767 v25 = v23 * v23 + v27 * v27 + v19 * v19; 3767 v25 = v23 * v23 + v27 * v27 + v19 * v19;
3768 v21 = v26; 3768 v21 = v26;
3769 } 3769 }
3770 v4 = 0; 3770 v4 = 0;
3771 LABEL_23: 3771 LABEL_23:
3772 v7 += 836; 3772 ++v7;
3773 v5 = v26++ + 1; 3773 v5 = v26++ + 1;
3774 } 3774 }
3775 while ( v26 < (signed int)uNumActors ); 3775 while ( v26 < (signed int)uNumActors );
3776 if ( v25 != -1 ) 3776 if ( v25 != -1 )
3777 { 3777 {