diff mm7_3.cpp @ 45:bcc051713d20

BLV render & seffects
author Nomad
date Mon, 22 Oct 2012 20:45:14 +0200
parents f4450ff595fe
children 79a30ee1ecdb
line wrap: on
line diff
--- a/mm7_3.cpp	Sun Oct 21 23:26:23 2012 +0600
+++ b/mm7_3.cpp	Mon Oct 22 20:45:14 2012 +0200
@@ -1011,7 +1011,7 @@
       v72 = 1;
     if ( v0->uAIState == 5 && v76 && !v72 )
     {
-      v0->uAIState = 11;
+      v0->uAIState = Removed;
       goto LABEL_121;
     }
     if ( v0->uCurrentActionAnimation == 1 )
@@ -1114,7 +1114,7 @@
       v0->vVelocity.y += rand() % 100 - 50;
       v0->vVelocity.z += rand() % 100 - 20;
       v25 = rand();
-      v0->uAIState = 8;
+      v0->uAIState = Stunned;
       v0->uYawAngle += v25 % 32 - 16;
       v0->UpdateAnimation();
     }
@@ -1191,7 +1191,7 @@
             else
               v61 = v68 + 60;
             sub_42F960_create_object(v0->vPosition.x, v0->vPosition.y, v61);
-            v0->uAIState = 11;
+            v0->uAIState = Removed;
             return;
           }
         }
@@ -1372,7 +1372,7 @@
           v0->uYawAngle -= 32;
           v0->uCurrentActionTime = 0;
           v0->uCurrentActionLength = 128;
-          v0->uAIState = 7;
+          v0->uAIState = Fleeing;
         }
       }
     }
@@ -1559,7 +1559,7 @@
           v34 = (TEXTURE_TYPE)v8;
           v32 = "effpar03";
         }
-        Dst.field_20 = (unsigned __int8)(v30 & 0x80) + 128;
+        Dst.timeToLive = (unsigned __int8)(v30 & 0x80) + 128;
         Dst.uTextureID = pBitmaps_LOD->LoadTexture(v32, v34);
         goto LABEL_71;
       }
@@ -1733,7 +1733,7 @@
 LABEL_70:
           Dst.bFree = 512;
           Dst.uDiffuse = rand();
-          Dst.field_20 = 64;
+          Dst.timeToLive = 64;
           Dst.uTextureID = v8;
 LABEL_71:
           Dst.flt_28 = 1.0;
@@ -1746,7 +1746,7 @@
         v33 = (TEXTURE_TYPE)v8;
         v31 = "effpar03";
       }
-      Dst.field_20 = (unsigned __int8)(v11 & 0x80) + 128;
+      Dst.timeToLive = (unsigned __int8)(v11 & 0x80) + 128;
       Dst.uTextureID = pBitmaps_LOD->LoadTexture(v31, v33);
 LABEL_72:
       pGame->pParticleEngine->AddParticle(&Dst);
@@ -1927,7 +1927,7 @@
       {
         Dst.bFree = 512;
         Dst.uDiffuse = rand();
-        Dst.field_20 = 64;
+        Dst.timeToLive = 64;
         Dst.uTextureID = 0;
 LABEL_89:
         Dst.flt_28 = 1.0;
@@ -1941,7 +1941,7 @@
 LABEL_87:
       v47 = "effpar03";
     }
-    Dst.field_20 = (unsigned __int8)(v24 & 0x80) + 128;
+    Dst.timeToLive = (unsigned __int8)(v24 & 0x80) + 128;
     Dst.uTextureID = pBitmaps_LOD->LoadTexture(v47, v48);
     goto LABEL_89;
   }
@@ -2066,7 +2066,7 @@
           v46 = rand();
           Dst.uTextureID = 0;
           Dst.uDiffuse = v46;
-          Dst.field_20 = 64;
+          Dst.timeToLive = 64;
           goto LABEL_89;
         }
         Dst.bFree = 1032;
@@ -8522,7 +8522,7 @@
       {
         v15 = 0;
       }
-      v17 = sub_43F55F(a1, v15);
+      v17 = _43F55F_get_billboard_light_level(a1, v15);
       if ( v17 > 27 )
         v17 = 27;
       if ( !a3 )
@@ -8539,7 +8539,7 @@
     a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20)
         * pOutdoor->fFogDensity;
     v13 = a3a + 6.7553994e15;
-    v10 = sub_43F55F(a1, LODWORD(v13) + v11);
+    v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11);
     if ( v10 > 27 )
       v10 = 27;
     if ( v10 < a4 )
@@ -8567,7 +8567,7 @@
     {
       v6 = 27;
     }
-    v10 = sub_43F55F(a1, v6);
+    v10 = _43F55F_get_billboard_light_level(a1, v6);
     if ( v10 > 27 || !a3 )
       v10 = 27;
     return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1);
@@ -9080,7 +9080,7 @@
     {
 LABEL_20:
       if ( a5 )
-        v6 = 8 * sub_43F55F(a5, v6 >> 3);
+        v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
       if ( v6 > 216 )
         v6 = 216;
       return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
@@ -9120,7 +9120,7 @@
     }
     v6 = a4a + v12;
     if ( a5 )
-      v6 = 8 * sub_43F55F(a5, v6 >> 3);
+      v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
     if ( v6 > 216 )
       v6 = 216;
     if ( v6 < v12 )
@@ -9346,7 +9346,7 @@
   pOutdoorCamera->uNumEdges = 0;
   pOutdoorCamera->uNumSpans = 0;
   pOutdoorCamera->uNumSurfs = 0;
-  pOutdoorCamera->field_3C = 0;
+  pOutdoorCamera->uNumBillboards = 0;
   pOutdoorCamera->field_44 = 0;
 }
 
@@ -12901,7 +12901,7 @@
 
 
 //----- (0043F953) --------------------------------------------------------
-int __cdecl PrepareWallsRenderList_BLV()
+void PrepareWallsRenderList_BLV()
 {
   pStru170->uNumFaceIDs = 0;
   if ( pBLVRenderParams->uRadius )
@@ -12921,7 +12921,7 @@
     pStru170->std__vector_000FA8 = 1;
     sub_440639(0);
   }
-  return pStru170->RenderWalls();
+  pStru170->RenderWalls();
 }
 
 //----- (0043F9E1) --------------------------------------------------------
@@ -13084,15 +13084,15 @@
               HIWORD(v22) = HIWORD(x);
               v15->field_4 = v37;
               v15->field_1E = v30;
-              v15->field_20 = a1;
-              v15->field_22 = a2;
-              v15->field_24 = a3;
-              v15->field_26 = a5;
-              v15->field_28 = a6;
+              v15->some_x = a1;
+              v15->some_y = a2;
+              v15->some_z = a3;
+              v15->uScreenSpaceX = a5;
+              v15->uScreenSpaceY = a6;
               v23 = 8 * v26;
               LOBYTE(v23) = 8 * v26 | 5;
               LOWORD(v22) = 0;
-              v15->field_2C_prolly_tint = 0;
+              v15->uTintColor = 0;
               v15->sZValue = v22 + v23;
               v15->pSpriteFrame = v12;
             }
@@ -13113,7 +13113,7 @@
       local_0.flt_14 = 0.0;
       local_0.flt_18 = 0.0;
       local_0.flt_28 = 1.0;
-      local_0.field_20 = (rand() & 0x80) + 128;
+      local_0.timeToLive = (rand() & 0x80) + 128;
       local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01");
       pGame->pParticleEngine->AddParticle(&local_0);
     }
@@ -13122,9 +13122,8 @@
 
 
 //----- (0044028F) --------------------------------------------------------
-void __cdecl PrepareItemsRenderList_BLV()
-{
-  char *v0; // edi@2
+void PrepareItemsRenderList_BLV()
+{
   ObjectDesc *v1; // ebx@4
   __int16 v2; // ax@5
   RenderBillboard *v3; // esi@12
@@ -13137,11 +13136,6 @@
   unsigned __int16 v10; // ax@12
   int *v11; // eax@20
   char v12; // zf@26
-  IndoorCameraD3D **v13; // eax@27
-  double v14; // st7@27
-  float v15; // eax@27
-  double v16; // ST30_8@27
-  signed __int64 v17; // qtt@27
   int v18; // ST5C_4@27
   signed __int64 v19; // qtt@28
   int v20; // ST5C_4@28
@@ -13149,14 +13143,12 @@
   __int16 v22; // ax@29
   int v23; // eax@29
   SpriteFrame *v24; // [sp+1Ch] [bp-40h]@12
-  ObjectDesc *v25; // [sp+20h] [bp-3Ch]@4
   __int16 a5; // [sp+28h] [bp-34h]@12
   int a6; // [sp+2Ch] [bp-30h]@12
   int a2; // [sp+30h] [bp-2Ch]@12
   int a1; // [sp+34h] [bp-28h]@12
   int v30; // [sp+38h] [bp-24h]@12
   int v31; // [sp+38h] [bp-24h]@27
-  signed int v32; // [sp+3Ch] [bp-20h]@1
   int a3; // [sp+40h] [bp-1Ch]@12
   signed __int16 v34; // [sp+44h] [bp-18h]@14
   int v35; // [sp+48h] [bp-14h]@25
@@ -13165,37 +13157,33 @@
   signed int y; // [sp+54h] [bp-8h]@24
   signed int x; // [sp+58h] [bp-4h]@24
 
-  v32 = 0;
-  if ( (signed int)uNumLayingItems > 0 )
-  {
-    v0 = (char *)&pLayingItems[0].uSectorID;
-    do
-    {
-      if ( *((short *)v0 - 13) )
-      {
-        v1 = &pObjectList->pObjects[*((short *)v0 - 13)];
-        v25 = v1;
+  for (uint i = 0; i < uNumLayingItems; ++i)
+  {
+    auto p = pLayingItems + i;
+    if (p->uObjectDescID)
+    {
+      v1 = &pObjectList->pObjects[p->uObjectDescID];
         if ( !(v1->uFlags & 1) )
-        {
-          if ( ((v2 = *((short *)v0 - 14), v2 < 1000) || v2 >= 10000)
+         {
+          if ( ((v2 = p->uItemType, v2 < 1000) || v2 >= 10000)
             && (v2 < 500 || v2 >= 600)
             && (v2 < 811 || v2 >= 815)
-            || pGame->pStru6Instance->_4A81CA((LayingItem *)(v0 - 28)) )
-          {
-            a5 = *(short *)v0;
-            a1 = *((int *)v0 - 6);
-            a2 = *((int *)v0 - 5);
-            a3 = *((int *)v0 - 4);
+            || pGame->pStru6Instance->_4A81CA(p))
+          {
+            a5 = p->uSectorID;
+            a1 = p->vPosition.x;
+            a2 = p->vPosition.y;
+            a3 = p->vPosition.z;
             v3 = &pBillboardRenderList[uNumBillboardsToDraw];
-            v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, *((short *)v0 + 1));
+            v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, p->uSpriteFrameID);
             v5 = v4;
             v24 = v4;
             v30 = v4->uFlags;
-            a6 = v4->uGlowRadius * *((short *)v0 + 3);
+            a6 = v4->uGlowRadius * p->field_22;
             v6 = stru_5C6E00->Atan2(
-                   *((int *)v0 - 6) - pBLVRenderParams->vPartyPos.x,
-                   *((int *)v0 - 5) - pBLVRenderParams->vPartyPos.y);
-            LOWORD(v7) = *((short *)v0 - 3);
+                   p->vPosition.x - pBLVRenderParams->vPartyPos.x,
+                   p->vPosition.y - pBLVRenderParams->vPartyPos.y);
+            LOWORD(v7) = p->uFacing;
             v8 = v30;
             v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7;
             v10 = v5->pHwSpriteIDs[v9];
@@ -13225,9 +13213,9 @@
                 a3,
                 a5,
                 a6,
-                v25->uParticleTrailColorR,
-                v25->uParticleTrailColorG,
-                v25->uParticleTrailColorB,
+                v1->uParticleTrailColorR,
+                v1->uParticleTrailColorG,
+                v1->uParticleTrailColorB,
                 v11);
             }
             if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
@@ -13244,7 +13232,7 @@
                 return;
               ++uNumBillboardsToDraw;
               ++uNumSpritesDrawnThisFrame;
-              *(v0 - 2) |= 1u;
+              p->uAttributes |= 1u;
               v12 = pRenderer->pRenderD3D == 0;
               v3->uPalette = v24->uPaletteIndex;
               v3->uIndoorSectorID = a5;
@@ -13258,33 +13246,27 @@
               }
               else
               {
-                v13 = &pGame->pIndoorCameraD3D;
                 v3->flt_8 = pGame->pIndoorCameraD3D->flt_D0;
-                v14 = (*v13)->flt_D4;
-                v15 = v3->flt_8;
-                v3->flt_C = v14;
-                v16 = v15 + 6.7553994e15;
-                LODWORD(v17) = 0;
-                HIDWORD(v17) = SLOWORD(v16);
-                v18 = v17 / x;
-                v3->field_0 = (unsigned __int64)(v24->scale * v17 / x) >> 16;
-                v31 = (unsigned __int64)(v24->scale * (signed __int64)v18) >> 16;
+                v3->flt_C = pGame->pIndoorCameraD3D->flt_D4;
+                v18 = (int)floorf(v3->flt_8 + 0.5f) / x;
+                v3->field_0 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16;
+                v31 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16;
               }
               HIWORD(v21) = HIWORD(x);
               v3->field_4 = v31;
               v3->field_1E = v34;
-              v3->field_20 = a1;
-              v3->field_22 = a2;
-              v3->field_24 = a3;
-              v3->field_26 = v36;
+              v3->some_x = a1;
+              v3->some_y = a2;
+              v3->some_z = a3;
+              v3->uScreenSpaceX = v36;
               v22 = v35;
-              v3->field_2C_prolly_tint = 0;
-              v3->field_28 = v22;
+              v3->uTintColor = 0;
+              v3->uScreenSpaceY = v22;
               LOWORD(v21) = 0;
-              v23 = 8 * v32;
-              LOBYTE(v23) = 8 * v32 | 2;
+              v23 = 8 * i;
+              LOBYTE(v23) = 8 * i | 2;
               v3->pSpriteFrame = v24;
-              v12 = (*(v0 - 2) & 0x20) == 0;
+              v12 = (p->uAttributes & 0x20) == 0;
               v3->sZValue = v21 + v23;
               if ( !v12 )
               {
@@ -13295,10 +13277,6 @@
           }
         }
       }
-      ++v32;
-      v0 += 112;
-    }
-    while ( v32 < (signed int)uNumLayingItems );
   }
 }
 
@@ -13393,20 +13371,18 @@
 //----- (00440DF5) --------------------------------------------------------
 int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr)
 {
-  stru167_wrap *v6; // esi@1
   int result; // eax@1
 
-  v6 = this;
-  v6->pElements[v6->uNumElements].field_6 = a2;
-  this->pElements[this->uNumElements].field_8 = a3;
-  this->pElements[this->uNumElements].field_A = a4;
-  v6->pElements[v6->uNumElements].field_C = rand() % 64 + 256;
-  v6->pElements[v6->uNumElements].field_E = v6->pElements[v6->uNumElements].field_C;
-  result = 3 * v6->uNumElements;
-  v6->pElements[v6->uNumElements++].bgr16 = bgr;
-  if ( v6->uNumElements >= 100 )
-    v6->uNumElements = 0;
-  return result;
+  pElements[uNumElements].field_6_rnd_value = a2;
+  pElements[uNumElements].field_8_rnd_value = a3;
+  pElements[uNumElements].field_A_rnd_value = a4;
+  pElements[uNumElements].field_C_time_left = rand() % 64 + 256;
+  pElements[uNumElements].field_E_time_to_live = pElements[uNumElements].field_C_time_left;
+  result = 3 * uNumElements;
+  pElements[uNumElements++].bgr16 = bgr;
+  if (uNumElements >= 100 )
+    uNumElements = 0;
+   return result;
 }
 
 //----- (00440E91) --------------------------------------------------------
@@ -13431,24 +13407,16 @@
 //----- (00440F07) --------------------------------------------------------
 void stru167_wrap::_440F07()
 {
-  char *v1; // esi@1
-  signed int v2; // edi@1
-
-  v1 = (char *)&this->pElements[0].field_6;
-  v2 = 100;
-  do
-  {
-    if ( *((short *)v1 + 3) > 0 )
-    {
-      *((short *)v1 + 2) += rand() % 5 + 4;
-      *(short *)v1 += rand() % 5 - 2;
-      *((short *)v1 + 1) += rand() % 5 - 2;
-      *((short *)v1 + 3) -= LOWORD(pEventTimer->uTimeElapsed);
-    }
-    v1 += 24;
-    --v2;
-  }
-  while ( v2 );
+  for (uint i = 0; i < 100; ++i)
+  {
+    if (pElements[i].field_C_time_left > 0)
+    {
+      pElements[i].field_A_rnd_value += rand() % 5 + 4;
+      pElements[i].field_6_rnd_value += rand() % 5 - 2;
+      pElements[i].field_8_rnd_value += rand() % 5 - 2;
+      pElements[i].field_C_time_left -= (short)pEventTimer->uTimeElapsed;
+    }
+  }
 }
 
 //----- (0044100D) --------------------------------------------------------
@@ -13687,17 +13655,17 @@
             v11 = *((int *)v3 + 1);
             v13 = v6->scale;
             v13 = (unsigned __int64)(v11 * (signed __int64)v13) >> 16;
-            v10.field_8 = *((short *)v3 - 2);
-            v10.field_C = *((short *)v3 - 1);
+            v10.uScreenSpaceX = *((short *)v3 - 2);
+            v10.uScreenSpaceY = *((short *)v3 - 1);
             v10.field_10 = v13;
             v10.field_14 = v13;
             v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v6->uPaletteIndex, 0, 1);
             v8 = *((short *)v3 - 5);
-            v10.field_28 = 0;
+            v10.sZValue = 0;
             v10.uFlags = 0;
             v9 = pOverlayList->pOverlays[v8].uOverlayType;
             if ( !v9 || v9 == 2 )
-              v10.field_C += pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]].uHeight >> 1;
+              v10.uScreenSpaceY += pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]].uHeight >> 1;
             result = pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]]._4AD2D1(&v10, 0);
             ++v12;
             if ( v12 == 5 )
@@ -16511,7 +16479,7 @@
       pInString = 0;
       if ( (signed int)uNumActors > 0 )
       {
-        v55 = &pActors[0].uAIState;
+        v55 = (unsigned short *)&pActors[0].uAIState;
         *(int *)v54 = uNumActors;
         do
         {
@@ -18549,8 +18517,6 @@
 //----- (00448A40) --------------------------------------------------------
 void Actor::ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle)
 {
-  unsigned __int16 *pState; // eax@6
-
   if ( uActorID >= 0 && uActorID <= (signed int)(uNumActors - 1) )
   {
     if ( bToggle )
@@ -18561,9 +18527,8 @@
     {
       if ( uFlag == 0x10000 )
       {
-        pState = &pActors[uActorID].uAIState;
-        if ( *pState == Disabled )
-          *pState = Standing;
+        if (pActors[uActorID].uAIState == Disabled )
+          pActors[uActorID].uAIState = Standing;
       }
       pActors[uActorID].uAttributes &= ~uFlag;
     }
@@ -20616,7 +20581,7 @@
           Actor::_403F58(uActorID, Dying, 256, 0);
           goto LABEL_78;
         }
-        pActor->uAIState = 0;
+        pActor->uAIState = Standing;
       }
       pActor->uCurrentActionTime = 0;
       pActor->uCurrentActionLength = 0;
@@ -20701,7 +20666,7 @@
         && (SHIDWORD(v21->pActorBuffs[2].uExpireTime) < (signed int)v24
          || LODWORD(v21->pActorBuffs[2].uExpireTime) <= v24) )
       {
-        v21->uAIState = 11;
+        v21->uAIState = Removed;
         goto LABEL_254;
       }
       if ( v21->pActorBuffs[5].uExpireTime || v21->pActorBuffs[6].uExpireTime )