diff Party.cpp @ 89:98cd93e14777

pointer fixes
author zipi
date Wed, 06 Feb 2013 21:19:42 +0000
parents be45fc285970
children d61f6bc04bf2
line wrap: on
line diff
--- a/Party.cpp	Mon Feb 04 17:21:02 2013 +0600
+++ b/Party.cpp	Wed Feb 06 21:19:42 2013 +0000
@@ -82,9 +82,9 @@
   Party *v1; // esi@1
   int v2; // eax@4
   signed int v4; // ecx@6
-  char *v5; // edx@6
+  Player *v5; // edx@6
   Player *v6; // eax@7
-  char *v7; // ecx@23
+  Player *v7; // ecx@23
   signed int v8; // esi@23
   signed int v9; // edx@23
   Player **v10; // edi@23
@@ -101,7 +101,7 @@
     return v2 + 1;
   }
   v4 = 0;
-  v5 = (char *)&v1->pPlayers[0].uTimeToRecovery;
+  v5 = v1->pPlayers;//[0].uTimeToRecovery;
   while ( 1 )
   {
     v6 = ::pPlayers[v4 + 1];
@@ -111,28 +111,28 @@
       || v6->pConditions[14]
       || v6->pConditions[15]
       || v6->pConditions[16]
-      || *(short *)v5 )
+	  || v5->uTimeToRecovery )
     {
       byte_AE3368[v4] = 1;
-      goto LABEL_21;
     }
-    if ( !byte_AE3368[v4] )
+    else if ( !byte_AE3368[v4] )
       break;
-LABEL_21:
     ++v4;
-    v5 += 6972;
+    ++v5;
     if ( v4 >= 4 )
-      goto LABEL_16;
+      break;
   }
-  v12 = v4;
-  byte_AE3368[v4] = 1;
-LABEL_16:
+  if(v4<4)
+  {
+	  v12 = v4;
+	  byte_AE3368[v4] = 1;
+  }
   if ( (unsigned __int8)(byte_AE3369 & byte_AE336A & byte_AE336B) & byte_AE3368[0] )
     memset(byte_AE3368, 0, 4u);
   v2 = v12;
   if ( v12 )
     return v2 + 1;
-  v7 = (char *)&v1->pPlayers[0].uSpeedBonus;
+  v7 = v1->pPlayers;//[0].uSpeedBonus;
   v8 = 0;
   v9 = 1;
   v10 = &::pPlayers[1];
@@ -145,26 +145,25 @@
       && !v11->pConditions[14]
       && !v11->pConditions[15]
       && !v11->pConditions[16]
-      && !*((short *)v7 + 3123) )
+	  && !v7->uTimeToRecovery )
     {
       if ( v12 )
       {
-        if ( *(short *)v7 > v8 )
+		if ( v7->uSpeedBonus > v8 )
         {
-          v8 = *(short *)v7;
-          goto LABEL_35;
+          v8 = v7->uSpeedBonus;
+          v12 = v9;
         }
       }
       else
       {
         v8 = *(short *)v7;
-LABEL_35:
         v12 = v9;
       }
     }
     ++v10;
     ++v9;
-    v7 += 6972;
+    ++v7;
     if ( v9 - 1 < 4 )
       continue;
     return v12;
@@ -175,15 +174,15 @@
 //----- (00493244) --------------------------------------------------------
 bool Party::HasItem(unsigned int uItemID)
 {
-  char *v2; // edx@1
+  Player *v2; // edx@1
   signed int v3; // ecx@2
   ItemGen *v4; // eax@2
 
-  v2 = (char *)pParty->pPlayers[0].pInventoryItems;
-  while ( 2 )
+  v2 = pParty->pPlayers;//[0].pInventoryItems;
+  while ( v2 <= &pParty->pPlayers[3] )
   {
     v3 = 0;
-    v4 = (ItemGen *)v2;
+	v4 = v2->pInventoryItems;
     do
     {
       if ( v4->uItemID == uItemID )
@@ -192,10 +191,7 @@
       ++v4;
     }
     while ( v3 < 138 );
-    v2 += 6972;
-    if ( (signed int)v2 < (signed int)&pParty->field_777C[85] )
-      continue;
-    break;
+    ++v2;
   }
   return 0;
 }
@@ -261,16 +257,16 @@
 unsigned int Party::GetPartyFame()
 {
   signed int v1; // eax@1
-  char *v2; // ecx@1
+  Player *v2; // ecx@1
   signed int v3; // edx@1
 
   v1 = 0;
-  v2 = (char *)&this->pPlayers[0].uExperience;
+  v2 = this->pPlayers;//[0].uExperience;
   v3 = 4;                                       // (E exp) / 1000
   do
   {
-    v1 += *(int *)v2;
-    v2 += 6972;
+	v1 += (int)v2->uExperience; // needs review
+    ++v2;
     --v3;
   }
   while ( v3 );
@@ -814,7 +810,7 @@
 void Party::ResetPosMiscAndSpellBuffs()
 {
   Party *v1; // esi@1
-  char *v2; // edi@1
+  Player *v2; // edi@1
   SpellBuff *v3; // ebx@2
   SpellBuff *v4; // esi@5
   signed int v5; // edi@5
@@ -839,11 +835,11 @@
   this->field_6FC = 0;
   this->field_708 = 15;
   this->field_0 = 25;
-  v2 = (char *)this->pPlayers[0].pPlayerBuffs;
+  v2 = this->pPlayers;//[0].pPlayerBuffs;
   v6 = 4;
   do
   {
-    v3 = (SpellBuff *)v2;
+    v3 = v2->pPlayerBuffs;
     v7 = 24;
     do
     {
@@ -852,7 +848,7 @@
       --v7;
     }
     while ( v7 );
-    v2 += 6972;
+    ++v2;
     --v6;
   }
   while ( v6 );