diff mm7_3.cpp @ 1083:ddf53a2d0bf5

pointer cleaning
author zipi
date Sat, 25 May 2013 22:28:13 +0100
parents 9456f2ed5ff9
children 8b59f13c9c3e
line wrap: on
line diff
--- a/mm7_3.cpp	Sun May 26 00:03:16 2013 +0400
+++ b/mm7_3.cpp	Sat May 25 22:28:13 2013 +0100
@@ -1334,7 +1334,7 @@
 {
   unsigned int v0; // ebx@0
   //unsigned int v1; // edi@1
-  char *v2; // esi@2
+  //char *v2; // esi@2
   //__int16 v3; // dx@5
   ObjectDesc *v4; // eax@5
   int v5; // ecx@6
@@ -1359,7 +1359,7 @@
   for (uint i = 0; i < uNumSpriteObjects; ++i)
   {
     auto item = pSpriteObjects + i;
-    v2 = (char *)&item->uSpriteFrameID;
+    //v2 = (char *)&item->uSpriteFrameID;
     //do
     //{
       //LOWORD(v0) = item->uAttributes;
@@ -1372,20 +1372,22 @@
       if (item->AttachedToActor())
       {
           v5 = PID_ID(item->spell_target_pid);
-          *(int *)(v2 - 26) = pActors[v5].vPosition.x;
-          *(int *)(v2 - 22) = pActors[v5].vPosition.y;
-          *(int *)(v2 - 18) = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
-          if ( !item->uObjectDescID || (v6 = LOWORD(pEventTimer->uTimeElapsed) + *(short *)v2, *(short *)v2 = v6, !(v4->uFlags & 4)) )
-            goto LABEL_36;
+		  item->vPosition.x = pActors[v5].vPosition.x;
+          item->vPosition.y = pActors[v5].vPosition.y;
+          item->vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
+		  if ( !item->uObjectDescID || (v6 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID, item->uSpriteFrameID = v6, !(v4->uFlags & 4)) )
+            continue;
           if ( v6 >= 0 )
           {
             v7 = v4->uLifetime;
             if (item->uAttributes & 2)
-              v7 = *((short *)v2 + 1);
+              v7 = item->field_20;
             if ( v6 < v7 )
-              goto LABEL_36;
-          }
-          goto LABEL_34;
+              continue;
+          }
+            v10 = i;
+            SpriteObject::OnInteraction(v10);
+            continue;
       }
 
         if ( item->uObjectDescID )
@@ -1393,30 +1395,29 @@
           v8 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID;
           item->uSpriteFrameID = v8;
           v9 = v4->uFlags;
-          if ( !(v9 & 4) )
-            goto LABEL_22;
-          if ( v8 < 0 )
-          {
-            v10 = i;
-LABEL_35:
-            SpriteObject::OnInteraction(v10);
-            goto LABEL_36;
-          }
-          v11 = v4->uLifetime;
-          if (item->uAttributes & 2)
-            v11 = *((short *)v2 + 1);
-          if ( v8 < v11 )
-          {
-LABEL_22:
+          if ( v9 & 4 )
+		  {    
+			  if ( v8 < 0 )
+			  {
+				v10 = i;
+				SpriteObject::OnInteraction(v10);
+				continue;
+			  }
+			  v11 = v4->uLifetime;
+			  if (item->uAttributes & 2)
+				v11 = item->field_20;
+		  }
+		  if ( !(v9 & 4) || v8 < v11 )
+          {
             if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
               SpriteObject::UpdateObject_fn0_BLV(i);
             else
               SpriteObject::UpdateObject_fn0_ODM(i);
-            if ( pParty->bTurnBasedModeOn != 1 || !(*(v2 - 4) & 4) )
-              goto LABEL_36;
-            v12 = abs(pParty->vPosition.x - *(int *)(v2 - 26));
-            v18 = abs(pParty->vPosition.y - *(int *)(v2 - 22));
-            v19 = abs(pParty->vPosition.z - *(int *)(v2 - 18));
+			if ( pParty->bTurnBasedModeOn != 1 || !(item->uSectorID & 4) )
+              continue;
+			v12 = abs(pParty->vPosition.x - item->vPosition.x);
+			v18 = abs(pParty->vPosition.y - item->vPosition.y);
+			v19 = abs(pParty->vPosition.z - item->vPosition.z);
             v13 = v12;
             v14 = v18;
             v15 = v19;
@@ -1439,19 +1440,20 @@
             }
             v0 = (unsigned int)(11 * v14) >> 5;
             if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
-              goto LABEL_36;
-LABEL_34:
+              continue;
             v10 = i;
-            goto LABEL_35;
+            SpriteObject::OnInteraction(v10);
+            continue;
           }
           v10 = i;
           if ( !(v9 & 0x40) )
-            goto LABEL_35;
+		  {
+            SpriteObject::OnInteraction(v10);
+            continue;
+		  }
           _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i));
         }
     }
-LABEL_36:
-    ;
       //v2 += 112;
       //v1 = v20++ + 1;
     //}