diff mm7_4.cpp @ 49:25fabc49627b

Слияние
author Ritor1
date Tue, 23 Oct 2012 17:34:20 +0600
parents 6a62c4005f0e 8a8dd0164b12
children 4211cceb3813 c28452924144
line wrap: on
line diff
--- a/mm7_4.cpp	Tue Oct 23 17:33:33 2012 +0600
+++ b/mm7_4.cpp	Tue Oct 23 17:34:20 2012 +0600
@@ -3065,12 +3065,6 @@
 //----- (00491F87) --------------------------------------------------------
 void __cdecl DrawHiredNPCs()
 {
-  int v0; // ecx@2
-  char *v1; // eax@2
-  int v2; // edx@4
-  signed int v3; // ebx@6
-  char *v4; // esi@7
-  int v5; // ecx@13
   int v6; // eax@15
   char v7; // al@17
   unsigned int v8; // eax@18
@@ -3081,7 +3075,7 @@
   unsigned int v13; // eax@23
   IconFrame *v14; // eax@24
   unsigned int v15; // eax@26
-  char pContainer; // [sp+Ch] [bp-30h]@18
+  char pContainer[20]; // [sp+Ch] [bp-30h]@18
   unsigned int v17; // [sp+20h] [bp-1Ch]@19
   signed int uFrameID; // [sp+24h] [bp-18h]@19
   int i; // [sp+28h] [bp-14h]@15
@@ -3094,38 +3088,24 @@
   {
     v23 = 0;
     v22 = 0;
-    v0 = 0;
-    v1 = (char *)pParty->pHirelings;
-    do
-    {
-      if ( *(int *)v1 )
-      {
-        v2 = v22++;
-        pTmpBuf[v2] = v0;
-      }
-      v1 += 76;
-      ++v0;
-    }
-    while ( (signed int)v1 < (signed int)&pParty->pPickedItem );
-    v3 = 0;
-    if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
-    {
-      v4 = (char *)pNPCStats->pNewNPCData;
-      do
-      {
-        if ( v4[8] & 0x80 && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v4, pParty->pHirelings[0].pName)) )
-        {
-          if ( !pParty->pHirelings[1].pName || strcmp(*(const char **)v4, pParty->pHirelings[1].pName) )
-          {
-            v5 = v22++;
-            pTmpBuf[v5] = v3 + 2;
-          }
-        }
-        ++v3;
-        v4 += 76;
-      }
-      while ( v3 < (signed int)pNPCStats->uNumNewNPCs );
-    }
+    for (uint i = 0; i < 2; ++i)
+    { 
+      if (pParty->pHirelings[i].pName)
+        pTmpBuf[v22++] = i;
+    }
+
+    for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
+    {
+      if (pNPCStats->pNewNPCData[i].uFlags & 0x80)
+      {
+        if (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName))
+        {
+          if (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName))
+            pTmpBuf[v22++] = i + 2;
+        }
+      }
+    }
+
     v6 = (unsigned __int8)pParty->field_709;
     for ( i = (unsigned __int8)pParty->field_709; i < v22; v6 = i++ + 1 )
     {
@@ -3134,22 +3114,22 @@
       v7 = pTmpBuf[v6];
       if ( (unsigned __int8)v7 >= 2u )
       {
-        sprintfex(&pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
-        v15 = pIcons_LOD->LoadTexture(&pContainer, TEXTURE_16BIT_PALETTE);
+        sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
+        v15 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         pRenderer->DrawTextureIndexed(
           pHiredNPCsIconsOffsetsX[v23],
           pHiredNPCsIconsOffsetsY[v23],
-          (Texture *)(v15 != -1 ? 72 * v15 + 7145548 : 0));
+          (Texture *)(v15 != -1 ? &pIcons_LOD->pTextures[v15] : 0));
       }
       else
       {
-        sprintfex(&pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID);
-        v8 = pIcons_LOD->LoadTexture(&pContainer, TEXTURE_16BIT_PALETTE);
+        sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID);
+        v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         v9 = v23;
         pRenderer->DrawTextureIndexed(
           pHiredNPCsIconsOffsetsX[v9],
           pHiredNPCsIconsOffsetsY[v9],
-          (Texture *)(v8 != -1 ? (int)&pIcons_LOD->pTextures[v8] : 0));
+          (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
         v10 = (unsigned __int8)pTmpBuf[i];
         if ( pParty->pHirelings[v10].bDrawSomeAnim == 1 )
         {
@@ -3190,12 +3170,7 @@
 //----- (004921C1) --------------------------------------------------------
 void GameUI_DrawPortraits(unsigned int _this)
 {
-  signed int v1; // ebx@2
-  int v2; // ebp@7
-  char *v3; // esi@7
   Texture *v4; // eax@10
-  signed int v5; // edx@13
-  PlayerFrame *v6; // eax@14
   unsigned int v7; // eax@17
   PlayerFrame *v8; // eax@21
   unsigned int v9; // eax@27
@@ -3203,21 +3178,15 @@
   bool v11; // edi@40
   bool v12; // edx@43
   bool v13; // ecx@46
-  int v14; // esi@54
-  char *v15; // edi@55
   int v16; // eax@57
-  __int16 *v17; // esi@59
-  char *v18; // edi@59
   int v19; // eax@62
   Texture *v20; // [sp-4h] [bp-1Ch]@27
-  signed int v21; // [sp+10h] [bp-8h]@7
   unsigned int v22; // [sp+14h] [bp-4h]@1
 
   v22 = _this;
   if ( qword_A750D8 )
   {
     qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed;
-    v1 = 0;
     if ( qword_A750D8 <= 0 )
     {
       if ( pPlayers[word_A750E2]->CanAct() )
@@ -3225,95 +3194,80 @@
       qword_A750D8 = 0i64;
     }
   }
-  else
-  {
-    v1 = 0;
-  }
-  v2 = 0;
-  v21 = v1;
-  v3 = (char *)&pParty->pPlayers[0].pConditions[14];
-  while ( 1 )
-  {
-    if ( *((_QWORD *)v3 + 2) )
+
+  for (uint i = 0; i < 4; ++i)
+  {
+    auto pPlayer = pParty->pPlayers + i;
+
+    if (pPlayer->Eradicated())
     {
       v4 = pTexture_PlayerFaceEradicated;
 LABEL_27:
       v20 = v4;
-      v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[v2];
+      v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i];
       if ( pParty->pPartyBuffs[11].uExpireTime )
         pRenderer->_4A6E7E(v9, 0x183u, v20);
       else
         pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, v20);
-      v10 = *((int *)v3 + 1541) >= v1 && (*((int *)v3 + 1541) > v1 || *((int *)v3 + 1540) > (unsigned int)v1);
-      if ( *((int *)v3 + 1489) >= v1 && (*((int *)v3 + 1489) > v1 || *((int *)v3 + 1488) > (unsigned int)v1) )
-        v1 = 1;
-      v11 = *((_QWORD *)v3 + 758) > 0i64;
-      v12 = *((_QWORD *)v3 + 756) > 0i64;
-      v13 = *((_QWORD *)v3 + 768) > 0i64;
-      if ( v13 | v12 | v11 | v1 | v10 )
-        sub_441A4E(v2);
+      auto _v1 = 0;
+      v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0;
+      if (pPlayer->pPlayerBuffs[1].uExpireTime > 0)
+        _v1 = 1;
+      v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0;
+      v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0;
+      v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0;
+      if ( v13 | v12 | v11 | _v1 | v10 )
+        sub_441A4E(i);
       goto LABEL_50;
     }
-    if ( *(_QWORD *)v3 )
+    if (pPlayer->Dead())
     {
       v4 = pTexture_PlayerFaceDead;
       goto LABEL_27;
     }
-    v5 = 0;
-    if ( (signed int)pPlayerFrameTable->uNumFrames <= v1 )
-    {
-LABEL_17:
+
       v7 = 0;
-    }
-    else
-    {
-      v6 = pPlayerFrameTable->pFrames;
-      while ( v6->uSequenceID != *((short *)v3 + 3350) )
-      {
-        ++v5;
-        ++v6;
-        if ( v5 >= (signed int)pPlayerFrameTable->uNumFrames )
-          goto LABEL_17;
-      }
-      v7 = v5;
-    }
-    if ( v7 == v1 )
+      for (uint j = 0; j < pPlayerFrameTable->uNumFrames; ++j)
+        if (pPlayerFrameTable->pFrames[j].uSequenceID == pPlayer->uExpressionID)
+        {
+          v7 = j;
+          break;
+        }
+
+    if ( v7 == 0 )
       v7 = 1;
-    if ( *((short *)v3 + 3350) == 21 )
+    if (pPlayer->uExpressionID == 21 )
       v8 = pPlayerFrameTable->GetFrameBy_y(
-             (int *)v3 + 1678,
-             (int *)v3 + 1677,
+             &pPlayer->field_1AA8,
+             &pPlayer->field_1AA4,
              pMiscTimer->uTimeElapsed);
     else
-      v8 = pPlayerFrameTable->GetFrameBy_x(v7, *((short *)v3 + 3351));
-    if ( *((short *)v3 + 3353) != v8->uTextureID - 1 || v22 )
-    {
-      *((short *)v3 + 3353) = v8->uTextureID - 1;
-      v1 = 0;
-      v4 = (Texture *)A74CEC_player_faces_minus1_indexing[v21 + v8->uTextureID];
+      v8 = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed);
+    if (pPlayer->field_1AA2 != v8->uTextureID - 1 || v22 )
+    {
+      pPlayer->field_1AA2 = v8->uTextureID - 1;
+      v4 = (Texture *)pTextures_PlayerFaces[i][v8->uTextureID];
       goto LABEL_27;
     }
 LABEL_50:
-    v21 += 56;
-    v3 += 6972;
-    ++v2;
-    if ( (signed int)v3 >= (signed int)&pParty->pHirelings[1].field_24 )
-      break;
-    v1 = 0;
-  }
+    ;
+  }
+
   if ( pParty->bTurnBasedModeOn == 1 )
   {
     if ( pTurnEngine->field_4 != 1 )
     {
       if ( (pTurnEngine->pQueue[0].uPackedID & 7) == 4 )
       {
-        v14 = 0;
+        //v14 = 0;
         if ( pTurnEngine->uActorQueueSize > 0 )
         {
-          v15 = (char *)pTurnEngine->pQueue;
-          do
-          {
-            if ( (*v15 & 7) != 4 )
+          //v15 = (char *)pTurnEngine->pQueue;
+          for (uint i = 0; i < pTurnEngine->uActorQueueSize; ++i)
+          {
+            auto pElem = pTurnEngine->pQueue + i;
+
+            if ( (pElem->uPackedID & 7) != 4 )
               break;
             v16 = dword_5079D0;
             if ( pParty->uFlags & 0x10 )
@@ -3326,24 +3280,20 @@
                 v16 = dword_5079C8;
             }
             pRenderer->DrawTextureTransparent(
-              pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[*(int *)v15 >> 3] - 4,
+              pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[pElem->uPackedID >> 3] - 4,
               0x181u,
-              (Texture *)(v16 != -1 ? (int)&pIcons_LOD->pTextures[v16] : 0));
-            ++v14;
-            v15 += 16;
-          }
-          while ( v14 < pTurnEngine->uActorQueueSize );
-        }
-      }
-    }
-  }
-  else
-  {
-    v17 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing;
-    v18 = (char *)pParty->pPlayers;
-    do
-    {
-      if ( ((Player *)v18)->CanAct() && !*((short *)v18 + 3226) )
+              (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0));
+          }
+        }
+      }
+    }
+  }
+  else
+  {
+    for (uint i = 0; i < 4; ++i)
+    {
+      auto pPlayer = pParty->pPlayers + i;
+      if (pPlayer->CanAct() && !pPlayer->uTimeToRecovery)
       {
         v19 = dword_5079D0;
         if ( pParty->uFlags & 0x10 )
@@ -3356,14 +3306,11 @@
             v19 = dword_5079C8;
         }
         pRenderer->DrawTextureTransparent(
-          *v17 - 4,
+          pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4,
           0x181u,
-          (Texture *)(v19 != -1 ? (int)&pIcons_LOD->pTextures[v19] : 0));
-      }
-      v18 += 6972;
-      ++v17;
-    }
-    while ( (signed int)v18 < (signed int)pParty->pHirelings );
+          (Texture *)(v19 != -1 ? &pIcons_LOD->pTextures[v19] : 0));
+      }
+    }
   }
 }
 
@@ -7134,109 +7081,9 @@
 }
 
 
-//----- (004A1C1E) --------------------------------------------------------
-void __cdecl DoRenderBillboards_D3D()
-{
-  signed int v0; // ebp@1
-  signed int *v1; // esi@2
-  //IDirect3DDevice3Vtbl *v2; // esi@7
-  unsigned int v3; // eax@7
-  unsigned int v4; // [sp+58h] [bp-4h]@2
-
-  v0 = -1;
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
-  if ( ((pRenderer->uNumBillboardsToDraw - 1) & 0x80000000u) == 0 )
-  {
-    v1 = (signed int *)&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - 1].bOpaque;
-    v4 = pRenderer->uNumBillboardsToDraw;
-    do
-    {
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(
-        0,
-        (IDirect3DTexture2 *)*(v1 - 35)));
-      if ( *v1 != v0 )
-      {
-        v0 = *v1;
-        SetBillboardBlendOptions(*v1);
-      }
-      ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
-        D3DPT_TRIANGLEFAN,
-        452,
-        v1 - 33,
-        *(v1 - 34),
-        24));
-      v1 -= 39;
-      --v4;
-    }
-    while ( v4 );
-  }
-  if ( pRenderer->turnFogOn )
-  {
-    pRenderer->turnFogOn = 0;
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
-    //v2 = pRenderer->pRenderD3D->pDevice->lpVtbl;
-    v3 = GetLevelFogColor();
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v3 & 0xFFFFFF));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
-  }
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
-}
-
-//----- (004A1DA8) --------------------------------------------------------
-void __fastcall SetBillboardBlendOptions(signed int a1)
-{
-  //IDirect3DDevice3Vtbl *v1; // edi@9
-  unsigned int v2; // eax@9
-  int v3; // [sp+0h] [bp-4h]@0
-
-  if ( !a1 )
-  {
-    if ( pRenderer->turnFogOn )
-    {
-      pRenderer->turnFogOn = 0;
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
-      //v1 = pRenderer->pRenderD3D->pDevice->lpVtbl;
-      v2 = GetLevelFogColor();
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v2 & 0xFFFFFF));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
-    }
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1));
-    return;
-  }
-  if ( a1 > 0 && a1 <= 3 )
-  {
-    if ( pRenderer->bUsingSpecular )
-    {
-      if ( !pRenderer->turnFogOn )
-      {
-        pRenderer->turnFogOn = 1;
-        ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
-      }
-    }
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
-  }
-}
-
-
-
-
-
-
 
 //----- (004A46E6) --------------------------------------------------------
-int __fastcall sub_4A46E6(unsigned int x, signed int y, signed int a3, int a4, unsigned int a5)
+int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int _z, int a4, unsigned int lightColor)
 {
   int v5; // eax@1
   int z; // eax@1
@@ -7259,7 +7106,7 @@
   signed int v23; // [sp+20h] [bp+Ch]@1
 
   v5 = a4;
-  v23 = a3 >> 16;
+  v23 = _z >> 16;
   z = x + v5;
   if ( z >= (signed int)pViewport->uViewportX
     && (signed int)x <= (signed int)pViewport->uViewportZ
@@ -7273,12 +7120,12 @@
     pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch];
     v22 = z - x;
     pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y];
-    v7 = a5 >> 3;
-    v8 = a5 & 0xF0;
+    v7 = lightColor >> 3;
+    v8 = lightColor & 0xF0;
     v9 = v7 & 0x1E0000;
     if ( pRenderer->uTargetGBits == 5 )
     {
-      v10 = (v8 | (((unsigned __int16)(a5 & 0xF000) | (unsigned int)v9) >> 3)) >> 4;
+      v10 = (v8 | (((unsigned __int16)(lightColor & 0xF000) | (unsigned int)v9) >> 3)) >> 4;
       v11 = (int *)pTarget;
       v12 = pTargetZ;
       v13 = v22;
@@ -7325,7 +7172,7 @@
     }
     else
     {
-      v15 = (v8 | (((unsigned __int16)(a5 & 0xF800) | (unsigned int)v9) >> 2)) >> 4;
+      v15 = (v8 | (((unsigned __int16)(lightColor & 0xF800) | (unsigned int)v9) >> 2)) >> 4;
       v16 = (int *)pTarget;
       v17 = pTargetZ;
       v18 = v22;
@@ -13449,7 +13296,7 @@
       ++pMessageQueue_50CBD0->uNumMessages;
     }
     if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
-      pDialogue_SpeakingActor->uAIState = 11;
+      pDialogue_SpeakingActor->uAIState = Removed;
     if ( uActiveCharacter )
       pPlayers[uActiveCharacter]->PlaySound(61, 0);
     goto LABEL_87;
@@ -15174,7 +15021,7 @@
               {
                 v4->uCurrentActionTime = 0;
                 v4->uCurrentActionLength = 0;
-                v4->uAIState = 5;
+                v4->uAIState = Dead;
                 v4->UpdateAnimation();
               }
               v1 = v18;
@@ -15251,11 +15098,9 @@
 
 
 //----- (0043FDED) --------------------------------------------------------
-unsigned int __cdecl PrepareActorRenderList_BLV()
+void PrepareActorRenderList_BLV()
 {
   RenderBillboard *v0; // esi@0
-  unsigned int result; // eax@1
-  char *v2; // edi@2
   unsigned __int16 v3; // ax@3
   unsigned int v4; // eax@5
   unsigned __int16 v5; // cx@5
@@ -15266,7 +15111,6 @@
   SpriteFrame *v10; // ebx@18
   int *v11; // eax@18
   int v12; // ecx@28
-  Actor *v13; // ecx@35
   IndoorCameraD3D **v14; // eax@36
   double v15; // st7@36
   float v16; // eax@36
@@ -15292,8 +15136,6 @@
   __int16 a5; // [sp+2Ch] [bp-28h]@5
   int a5a; // [sp+2Ch] [bp-28h]@36
   int a5b; // [sp+2Ch] [bp-28h]@40
-  unsigned int v39; // [sp+30h] [bp-24h]@1
-  int v40; // [sp+34h] [bp-20h]@2
   __int16 v41; // [sp+3Ch] [bp-18h]@18
   int a6; // [sp+40h] [bp-14h]@34
   int v43; // [sp+44h] [bp-10h]@34
@@ -15301,36 +15143,21 @@
   signed int y; // [sp+4Ch] [bp-8h]@32
   int x; // [sp+50h] [bp-4h]@32
 
-  result = 0;
-  v39 = 0;
-  if ( (signed int)uNumActors > 0 )
-  {
-    v40 = 0;
-    v2 = (char *)&pActors[0].uAttributes;
-    while ( 1 )
-    {
-      v3 = *((_WORD *)v2 + 70);
-      *(_DWORD *)v2 &= 0xFFFFFFF7u;
-      if ( v3 != 11 )
-      {
-        if ( v3 != 19 )
-          break;
-      }
-LABEL_48:
-      ++v39;
-      v40 += 32;
-      result = v39;
-      v2 += 836;
-      if ( (signed int)v39 >= (signed int)uNumActors )
-        return result;
-    }
-    a5 = *((_WORD *)v2 + 61);
-    a2 = *((_WORD *)v2 + 54);
-    a1a = *((_WORD *)v2 + 53);
-    a3 = *((_WORD *)v2 + 55);
+  for (uint i = 0; i < uNumActors; ++i)
+  {
+    auto p = pActors + i;
+
+    if (p->uAIState == Removed ||
+        p->uAIState == Disabled)
+      continue;
+
+    a5 = p->uSectorID;
+    a2 = p->vPosition.y;
+    a1a = p->vPosition.x;
+    a3 = p->vPosition.z;
     v4 = stru_5C6E00->Atan2(a1a - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y);
-    LOWORD(v0) = *((_WORD *)v2 + 59);
-    v5 = *((_WORD *)v2 + 71);
+    LOWORD(v0) = p->uYawAngle;
+    v5 = p->uCurrentActionAnimation;
     v6 = ((signed int)((char *)v0 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v4 + stru_5C6E00->uIntegerPi) >> 8) & 7;
     v32 = v6;
     if ( pParty->bTurnBasedModeOn )
@@ -15347,16 +15174,16 @@
       {
         v7 = pBLVRenderParams->field_0_timer_;
 LABEL_10:
-        v8 = v40 + v7;
+        v8 = i * 32 + v7;
         goto LABEL_12;
       }
     }
-    v8 = *((_DWORD *)v2 + 37);
+    v8 = p->uCurrentActionTime;
 LABEL_12:
-    if ( *((_QWORD *)v2 + 32) > 0i64 || *((_QWORD *)v2 + 34) > 0i64 )
+    if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 )
       v8 = 0;
-    v31 = *(_WORD *)&v2[2 * (signed __int16)v5 + 152];
-    if ( *((_WORD *)v2 + 70) == 16 )
+    v31 = p->pSpriteIDs[v5];
+    if (p->uAIState == 16 )
       v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8);
     else
       v9 = pSpriteFrameTable->GetFrame(v31, v8);
@@ -15388,25 +15215,24 @@
     }
     v12 = 0;
     if ( pStru170->field_53730 <= 0 )
-      goto LABEL_48;
-    while ( pStru170->pSectorIDs_toDrawDecorationsFrom[v12] != *((_WORD *)v2 + 61) )
+      continue;
+    while (pStru170->pSectorIDs_toDrawDecorationsFrom[v12] != p->uSectorID)
     {
       ++v12;
       if ( v12 >= pStru170->field_53730 )
-        goto LABEL_48;
+        continue;
     }
     if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1)
       || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) )
-      goto LABEL_48;
+      continue;
     pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6);
-    result = uNumBillboardsToDraw;
+
     v0 = &pBillboardRenderList[uNumBillboardsToDraw];
-    if ( (signed int)uNumBillboardsToDraw >= 500 )
-      return result;
+    if (uNumBillboardsToDraw >= 500)
+      break;
     ++uNumBillboardsToDraw;
     ++uNumSpritesDrawnThisFrame;
-    v13 = (Actor *)(v2 - 36);
-    *(_DWORD *)v2 |= 8u;
+    p->uAttributes |= 8u;
     v29 = pRenderer->pRenderD3D == 0;
     v0->uHwSpriteID = v10->pHwSpriteIDs[v32];
     v0->uPalette = v10->uPaletteIndex;
@@ -15434,21 +15260,21 @@
       a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16;
     }
     v0->field_4 = a5a;
-    if ( (signed __int64)v13->pActorBuffs[3].uExpireTime <= 0 )
-    {
-      if ( (signed __int64)v13->pActorBuffs[10].uExpireTime > 0 )
-      {
-        a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F((Actor *)(v2 - 36)) * (signed __int64)v0->field_4) >> 16;
+    if ( (signed __int64)p->pActorBuffs[3].uExpireTime <= 0 )
+    {
+      if ( (signed __int64)p->pActorBuffs[10].uExpireTime > 0 )
+      {
+        a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->field_4) >> 16;
         goto LABEL_43;
       }
     }
     else
     {
-      v22 = v13->pActorBuffs[3].uPower;
+      v22 = p->pActorBuffs[3].uPower;
       if ( v22 )
       {
         v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->field_0) >> 16;
-        v24 = *((_WORD *)v2 + 116);
+        v24 = p->pActorBuffs[3].uPower;
         v0->field_0 = v23;
         a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->field_4) >> 16;
 LABEL_43:
@@ -15458,29 +15284,27 @@
     }
 LABEL_44:
     HIWORD(v25) = HIWORD(x);
-    v0->field_20 = a1a;
-    v0->field_22 = a2;
-    v0->field_24 = a3;
-    v0->field_26 = v43;
-    v0->field_28 = a6;
+    v0->some_x = a1a;
+    v0->some_y = a2;
+    v0->some_z = a3;
+    v0->uScreenSpaceX = v43;
+    v0->uScreenSpaceY = a6;
     LOWORD(v25) = 0;
     LOBYTE(v26) = v41;
-    v0->sZValue = v25 + (8 * v39 | 3);
+    v0->sZValue = v25 + (8 * i | 3);
     v27 = pMonsterList->pMonsters;
-    v28 = *((_WORD *)v2 + 30);
-    v29 = *((_DWORD *)v2 + 65) == 0;
-    v30 = *((_DWORD *)v2 + 65) < 0;
+    v28 = p->pMonsterInfo.uID;
+    v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0;
+    v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0;
     v0->field_1E = v41;
     v0->pSpriteFrame = v10;
-    v0->field_2C_prolly_tint = *((_DWORD *)&v27[v28] - 36);
-    if ( !v30 && (!(v30 | v29) || *((_DWORD *)v2 + 64)) )
+    v0->uTintColor = *((_DWORD *)&v27[v28] - 36);
+    if ( !v30 && (!(v30 | v29) || LODWORD(p->pActorBuffs[5].uExpireTime)) )
     {
       HIBYTE(v26) = HIBYTE(v41) | 1;
       v0->field_1E = v26;
     }
-    goto LABEL_48;
-  }
-  return result;
+  }
 }