diff mm7_6.cpp @ 82:1faa29fd4c2d

many type, memory, boundary fixes
author zipi
date Sun, 03 Feb 2013 23:37:17 +0000
parents 377535d6e366
children 98cd93e14777
line wrap: on
line diff
--- a/mm7_6.cpp	Sun Feb 03 15:36:54 2013 +0000
+++ b/mm7_6.cpp	Sun Feb 03 23:37:17 2013 +0000
@@ -1296,13 +1296,13 @@
 {
   unsigned __int64 v1; // qax@1
   signed int v2; // ecx@1
-  char *v3; // esi@1
+  int *v3; // esi@1
   bool v4; // edi@6
-  char *v5; // edi@10
-  char *v6; // esi@10
+  int *v5; // edi@10
+  Player *v6; // esi@10
   int v7; // eax@13
   unsigned __int8 v8; // cf@13
-  char v10; // [sp+Ch] [bp-14h]@1
+  int v10; // [sp+Ch] [bp-14h]@1
   int v11; // [sp+1Ch] [bp-4h]@10
 
   v1 = __PAIR__((int)((char *)&pParty + 2620), a1);
@@ -1314,40 +1314,40 @@
       && !*(int *)HIDWORD(v1)
       && !*(_QWORD *)(HIDWORD(v1) + 8)
       && !*(_QWORD *)(HIDWORD(v1) + 16);
-    *(int *)v3 = v4;
+    *v3 = v4;
     HIDWORD(v1) += 6972;
     v2 += v4;
-    v3 += 4;
+    ++v3;
   }
   while ( SHIDWORD(v1) < (signed int)&pParty->pHirelings[1].field_24 );
   if ( v2 )
   {
     LODWORD(v1) = (signed int)v1 / v2;
     v5 = &v10;
-    v6 = (char *)&pParty->pPlayers[0].uExperience;
+    v6 = pParty->pPlayers;//[0].uExperience;
     v11 = v1;
     do
     {
-      if ( *(int *)v5 )
+      if ( *v5 )
       {
         if ( v11 )
         {
-          LOBYTE(v7) = ((Player *)(v6 - 160))->GetLearningPercent();
+          LOBYTE(v7) = v6->GetLearningPercent();
           v1 = v11 + v11 * v7 / 100;
-          v8 = __CFADD__((int)v1, *(int *)v6);
-          *(int *)v6 += v1;
-          *((int *)v6 + 1) += HIDWORD(v1) + v8;
-          if ( *(_QWORD *)v6 > 4000000000i64 )
+          v8 = __CFADD__((int)v1, LODWORD(v6->uExperience));
+          LODWORD(v6->uExperience) += v1;
+          HIDWORD(v6->uExperience) += HIDWORD(v1) + v8;
+          if ( v6->uExperience > 4000000000i64 )
           {
-            *((int *)v6 + 1) = 0;
-            *(int *)v6 = -294967296;
+            HIDWORD(v6->uExperience) = 0;
+            LODWORD(v6->uExperience) = -294967296;
           }
         }
       }
-      v6 += 6972;
-      v5 += 4;
+      ++v6;
+      ++v5;
     }
-    while ( (signed int)v6 < (signed int)&pParty->pPickedItem._bonus_strength );
+	while ( v6 <= &pParty->pPlayers[3] );
   }
   return v1;
 }
@@ -8292,7 +8292,7 @@
 signed int __cdecl sub_42F4DA()
 {
   signed int v0; // edi@1
-  char *v1; // esi@4
+  Actor *v1; // esi@4
   int v2; // ebx@5
   int v3; // eax@5
   int v4; // ebx@5
@@ -8317,12 +8317,12 @@
   }
   else
   {
-    v1 = (char *)&pActors[0].uAIState;
+    v1 = pActors;
     while ( 1 )
     {
-      v2 = abs(*((short *)v1 - 17) - pParty->vPosition.x);
-      v11 = abs(*((short *)v1 - 16) - pParty->vPosition.y);
-      v12 = abs(*((short *)v1 - 15) - pParty->vPosition.z);
+		v2 = abs(v1->vInitialPosition.x - pParty->vPosition.x);
+		v11 = abs(v1->vInitialPosition.y - pParty->vPosition.y);
+		v12 = abs(v1->vInitialPosition.z - pParty->vPosition.z);
       v3 = v2;
       v4 = v11;
       v5 = v12;
@@ -8346,19 +8346,19 @@
       }
       if ( (signed int)(((unsigned int)(11 * v4) >> 5) + (v5 >> 2) + v3) < v0 )
       {
-        v9 = *(short *)v1;
-        if ( *(short *)v1 != 5 )
+		v9 = v1->uAIState;
+        if ( v1->uAIState != 5 )
         {
           if ( v9 != 4
             && v9 != 11
             && v9 != 19
             && v9 != 17
-            && (*(v1 - 138) & 8 || ((Actor *)nullptr)->GetActorsRelation( (Actor *)(v1 - 176))) )
+			&& (BYTE2(v1->uAttributes) & 8 || ((Actor *)nullptr)->GetActorsRelation( v1)) )
             break;
         }
       }
       ++v13;
-      v1 += 836;
+      ++v1;
       if ( v13 >= (signed int)uNumActors )
         goto LABEL_20;
     }