diff mm7_3.cpp @ 112:909822c91d47

pointer fixes
author zipi
date Sat, 09 Feb 2013 18:46:06 +0000
parents 98cd93e14777
children be3c07c98861
line wrap: on
line diff
--- a/mm7_3.cpp	Sun Feb 10 00:17:23 2013 +0600
+++ b/mm7_3.cpp	Sat Feb 09 18:46:06 2013 +0000
@@ -1426,6 +1426,7 @@
   ObjectDesc *v37; // [sp+78h] [bp-18h]@1
   unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4
   int v39; // [sp+80h] [bp-10h]@33
+  Actor *v39b;
   int v40; // [sp+84h] [bp-Ch]@28
   int v41; // [sp+88h] [bp-8h]@34
   int v42; // [sp+8Ch] [bp-4h]@4
@@ -1488,16 +1489,18 @@
         {
           if ( (signed int)uNumActors > v8 )
           {
-            v39 = (int)&pActors[0].word_000086_some_monster_id;
+            v39b = pActors;//[0].word_000086_some_monster_id;
             do
             {
-              v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1;
-              v14 = (signed __int64)((double)v41 * 0.3333333333333333);
-              v41 = *(short *)(v39 - 38) - 1;
-              if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) )
-                _46DF1A_collide_against_actor(v42, *((short *)&pMonsterList->pMonsters[*(short *)v39] - 73));
+              //v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1;
+              //v14 = (signed __int64)((double)v41 * 0.3333333333333333);
+              //v41 = *(short *)(v39 - 38) - 1;
+              //if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) )
+				if( pActors[v1->field_58 >> 3].pMonsterInfo.uID != v39b->pMonsterInfo.uID )
+					//not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius
+					_46DF1A_collide_against_actor(v42, *((short *)&pMonsterList->pMonsters[v39b->word_000086_some_monster_id] - 73));
               ++v42;
-              v39 += 836;
+              ++v39b;// += 836;
             }
             while ( v42 < (signed int)uNumActors );
             v8 = 0;
@@ -1507,11 +1510,11 @@
         {
           if ( (signed int)uNumActors > v8 )
           {
-            v39 = (int)&pActors[0].word_000086_some_monster_id;
+            v39b = pActors;//[0].word_000086_some_monster_id;
             do
             {
-              _46DF1A_collide_against_actor(v42++, *((short *)&pMonsterList->pMonsters[*(short *)v39] - 73));
-              v39 += 836;
+              _46DF1A_collide_against_actor(v42++, *((short *)&pMonsterList->pMonsters[*(short *)v39b] - 73));
+              ++v39b;
             }
             while ( v42 < (signed int)uNumActors );
           }
@@ -3163,7 +3166,7 @@
     bWaterWalk = 1;
     *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u;
     if ( !(pParty->pPartyBuffs[18].uFlags & 1)
-      && *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[18].uCaster + 10] <= 0 )
+		&& pParty->pPlayers[pParty->pPartyBuffs[18].uCaster-1].sMana <= 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[18].uCaster + 10] <= 0 )
       bWaterWalk = 0;
   }
   v3 = sub_46D49E_prolly_get_world_y_under_party(v116, v117, v123, pParty->uPartyHeight, &v130, &v108, bWaterWalk);
@@ -3264,7 +3267,7 @@
           pParty->bFlying = 0;
           if ( bUnderwater
             || pParty->pPartyBuffs[7].uFlags & 1
-            || *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
+            || pParty->pPlayers[pParty->pPartyBuffs[7].uCaster-1].sMana <= 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
           {
             if ( pParty->vPosition.z < 4000 || bJumping )
             {
@@ -3304,7 +3307,7 @@
           pParty->bFlying = 0;
           if ( bUnderwater
             || pParty->pPartyBuffs[7].uFlags & 1
-            || *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
+            || pParty->pPlayers[pParty->pPartyBuffs[7].uCaster-1].sMana <= 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
           {
             v123 -= 30;
             v113 -= 30;
@@ -13627,7 +13630,7 @@
   float uZooma; // [sp+64h] [bp+10h]@117
   signed int flagsa; // [sp+68h] [bp+14h]@42
   unsigned int flagsb; // [sp+68h] [bp+14h]@66
-  char *flagsc; // [sp+68h] [bp+14h]@86
+  Actor *flagsc; // [sp+68h] [bp+14h]@86
   unsigned int flagsd; // [sp+68h] [bp+14h]@105
 
   //a3 = uY;
@@ -13949,16 +13952,16 @@
     uZf = v33;
     if ( (signed int)uNumActors > v33 )
     {
-      flagsc = (char *)&pActors[0].uAIState;
+      flagsc = pActors;//[0].uAIState;
       do
       {
-        v39 = *(short *)flagsc;
-        if ( *(short *)flagsc != 11 && v39 != 19 && (v39 == 5 || *(flagsc - 139) & 0x80) )
-        {
-          v40 = ((unsigned __int64)(((signed int)*((short *)flagsc - 17) - pParty->vPosition.x)
+		v39 = flagsc->uAIState;
+		if ( flagsc->uAIState != 11 && v39 != 19 && (v39 == 5 || BYTE1(flagsc->uAttributes) & 0x80) )
+        {
+		  v40 = ((unsigned __int64)(( flagsc->vPosition.x - pParty->vPosition.x)
                                   * (signed __int64)(signed int)uZoom) >> 16)
               + uCenterX;
-          v76 = (unsigned __int64)(((signed int)*((short *)flagsc - 16) - pParty->vPosition.y)
+          v76 = (unsigned __int64)(( flagsc->vPosition.y - pParty->vPosition.y)
                                  * (signed __int64)(signed int)uZoom) >> 16;
           v41 = uCenterY - v76;
           if ( v40 >= pRenderer->field_1C_clipx )
@@ -13966,9 +13969,9 @@
             if ( v40 <= pRenderer->field_24_clipz && v41 >= pRenderer->field_20_clipy && v41 <= pRenderer->field_28_clipw )
             {
               uWd = v61;
-              if ( *(flagsc - 137) & 1 )
+			  if ( BYTE3(flagsc->uAttributes) & 1 )
                 uWd = v63;
-              if ( *(short *)flagsc == 5 )
+              if ( flagsc->uAIState == 5 )
                 uWd = v65;
               if ( (signed int)uZoom > 1024 )
               {
@@ -13998,7 +14001,7 @@
           }
         }
         ++uZf;
-        flagsc += 836;
+        ++flagsc;
       }
       while ( uZf < (signed int)uNumActors );
       v36 = 255;
@@ -16863,11 +16866,11 @@
   int v38; // eax@78
   int v39; // ecx@78
   size_t v40; // edx@78
-  char *v41; // esi@79
+  Actor *v41; // esi@79
   int v42; // eax@84
   int v43; // ecx@84
   size_t v44; // edx@84
-  char *v45; // esi@85
+  Actor *v45; // esi@85
   void *v46; // eax@91
   GUIWindow *v47; // eax@93
   GUIButton *v48; // ecx@93
@@ -17251,12 +17254,12 @@
             __debugbreak();
             if ( (signed int)uNumActors > 0 )
             {
-              v41 = (char *)&pActors[0].uGroup;
+              v41 = pActors;//[0].uGroup;
               do
               {
-                if ( *(int *)v41 == v38 )
-                  *(int *)v41 = v39;
-                v41 += 836;
+				if ( v41->uGroup == v38 )
+				  v41->uGroup = v39;
+                ++v41;
                 --v40;
               }
               while ( v40 );
@@ -17269,12 +17272,12 @@
             __debugbreak();
             if ( (signed int)uNumActors > 0 )
             {
-              v45 = (char *)&pActors[0].uAlly;
+              v45 = pActors;//[0].uAlly;
               do
               {
-                if ( *((int *)v45 - 1) == v42 )
-                  *(int *)v45 = v43;
-                v45 += 836;
+				if ( v45->uGroup == v42 )
+				  v45->uAlly = v43;
+                ++v45;
                 --v44;
               }
               while ( v44 );
@@ -19752,7 +19755,7 @@
 //----- (004014E6) --------------------------------------------------------
 int __cdecl ODM_4014E6_AI()
 {
-  int v0; // esi@2
+  Actor *v0; // esi@2
   int v1; // eax@4
   int v2; // ebx@4
   unsigned int v3; // ecx@4
@@ -19786,15 +19789,16 @@
   v25 = 0;
   if ( (signed int)uNumActors > 0 )
   {
-    v0 = (int)&pActors[0].uAttributes;
-    do
-    {
-      *(char *)(v0 + 1) &= 0xFBu;
-      if ( ! ((Actor *)(v0 - offsetof(Actor, uAttributes)))->CanAct() )
+    v0 = pActors;//[0].uAttributes;
+    do
+    {
+	  //*(char *)(v0 + 1) &= 0xFBu;
+	  BYTE1(v0->uAttributes) &= 0xFBu;
+      if ( ! v0->CanAct() )
         goto LABEL_37;
-      v22 = abs(pParty->vPosition.z - *(short *)(v0 + 110));
-      v21 = abs(pParty->vPosition.y - *(short *)(v0 + 108));
-      v1 = abs(pParty->vPosition.x - *(short *)(v0 + 106));
+	  v22 = abs(pParty->vPosition.z - v0->vPosition.z);
+      v21 = abs(pParty->vPosition.y - v0->vPosition.y);
+      v1 = abs(pParty->vPosition.x - v0->vPosition.x);
       v2 = v21;
       v3 = v22;
       if ( v1 < v21 )
@@ -19816,7 +19820,7 @@
         v2 = v6;
       }
       v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1;
-      v8 = *(short *)(v0 + 100);
+	  v8 = v0->uActorRadius;
       v9 = v7 - v8;
       v23 = v7 - v8;
       if ( v23 < 0 )
@@ -19826,18 +19830,18 @@
       }
       if ( v9 < 5632 )
       {
-        v10 = *(int *)v0 & 0xFEFFFFFF;
-        *(int *)v0 = v10;
-        if ( v10 & 0x80000 || ((Actor *)(v0 - offsetof(Actor, uAttributes)))->GetActorsRelation(0) )
+        v10 = v0->uAttributes & 0xFEFFFFFF;
+        v0->uAttributes = v10;
+        if ( v10 & 0x80000 || v0->GetActorsRelation(0) )
         {
           v11 = (pParty->uFlags & 0x10) == 0;
-          *(int *)v0 = v10 | 0x1000000;
+          v0->uAttributes = v10 | 0x1000000;
           if ( v11 && (double)v23 < 307.2 )
             pParty->uFlags |= 0x10u;
           if ( !(pParty->uFlags & 0x20) && v9 < 5120 )
             pParty->uFlags |= 0x20u;
         }
-        *(char *)(v0 + 1) |= 0x40u;
+		BYTE1(v0->uAttributes) |= 0x40u;
         v12 = v27++;
         ai_array_4F75E0[v12] = v9;
         ai_array_4F7DB0_actor_ids[v12] = v25;
@@ -19845,10 +19849,10 @@
       else
       {
 LABEL_37:
-        *(char *)(v0 + 1) &= 0xBFu;
+		  BYTE1(v0->uAttributes) &= 0xBFu;
       }
       ++v25;
-      v0 += 836;
+      ++v0;
     }
     while ( v25 < (signed int)uNumActors );
   }