changeset 619:574cc56e05e9

ParticleEngine crash in temple
author Nomad
date Fri, 08 Mar 2013 17:08:08 +0200
parents 5cfb5dadf330
children ba08b9403e04 1b813023fcbd
files ParticleEngine.cpp ParticleEngine.h Render.cpp SpriteObject.cpp mm7_2.cpp mm7_3.cpp stru6.cpp
diffstat 7 files changed, 179 insertions(+), 172 deletions(-) [+]
line wrap: on
line diff
--- a/ParticleEngine.cpp	Fri Mar 08 16:06:49 2013 +0200
+++ b/ParticleEngine.cpp	Fri Mar 08 17:08:08 2013 +0200
@@ -29,13 +29,13 @@
 }
 
 //----- (0048AB23) --------------------------------------------------------
-void ParticleEngine::AddParticle(Particle_ *a2)
+void ParticleEngine::AddParticle(Particle_sw *a2)
 {
   signed int v2; // eax@2
   Particle *v3; // edx@2
   Particle *v4; // esi@10
   int v5; // ecx@10
-  char v6; // zf@10
+  //char v6; // zf@10
 
   if ( !pMiscTimer->bPaused )
   {
@@ -43,7 +43,7 @@
     v3 = (Particle *)this;
     do
     {
-      if ( !v3->uType )
+      if (v3->type == ParticleType_Invalid)
         break;
       ++v2;
       ++v3;
@@ -56,7 +56,7 @@
       if ( v2 > this->uEndParticle )
         this->uEndParticle = v2;
       v4 = &this->pParticles[v2];
-      v4->uType = a2->bFree;
+      v4->type = a2->type;
       v4->x = a2->x;
       v4->y = a2->y;
       v4->z = a2->z;
@@ -69,20 +69,20 @@
       v5 = a2->uDiffuse;
       v4->uParticleColor = v5;
       v4->uLightColor = v5;
-      v6 = (v4->uType & 4) == 0;
+      //v6 = (v4->uType & 4) == 0;
       v4->timeToLive = a2->timeToLive;
       v4->uTextureID = a2->uTextureID;
       v4->flt_28 = a2->flt_28;
-      if ( v6 )
+      if (v4->type & ParticleType_Rotating)
+      {
+        v4->field_38 = (unsigned __int8)rand() - 128;
+        v4->_rotation = rand();
+      }
+      else
       {
         v4->field_38 = 0;
         v4->_rotation = 0;
       }
-      else
-      {
-        v4->field_38 = (unsigned __int8)rand() - 128;
-        v4->_rotation = rand();
-      }
     }
   }
 }
@@ -137,14 +137,14 @@
   {
     auto p = pParticles + i;
 
-      v5 = p->uType;
-      if (!p->uType)
+      v5 = p->type;
+      if (p->type == ParticleType_Invalid)
         continue;
 
         v6 = (p->timeToLive - time) < 0;
         p->timeToLive -= time;
         if (v6)
-          p->uType = 0;
+          p->type = ParticleType_Invalid;
         else
         {
           if ( BYTE1(v5) & 2 )
@@ -190,16 +190,16 @@
 bool ParticleEngine::ViewProject_TrueIfStillVisible(unsigned int uParticleID)
 {
   Particle *pParticle; // esi@1
-  double v56; // ST28_8@2
+  //double v56; // ST28_8@2
   float v4; // eax@4
   double v5; // ST34_8@4
   signed __int64 v6; // qtt@4
-  double v7; // st7@4
-  float v8; // ST18_4@4
+  //double v7; // st7@4
+  //float v8; // ST18_4@4
   int v9; // ecx@4
-  int v10; // eax@4
-  double v11; // ST44_8@7
-  double v12; // ST4C_8@7
+  //int v10; // eax@4
+  //double v11; // ST44_8@7
+  //double v12; // ST4C_8@7
   double v13; // ST4C_8@7
   int v14; // ecx@7
   signed __int64 v15; // qtt@7
@@ -235,10 +235,10 @@
   int v46; // ecx@18
   float v47; // ST18_4@18
   unsigned __int64 v48; // qax@18
-  double y_int_; // [sp+10h] [bp-40h]@2
+  int y_int_; // [sp+10h] [bp-40h]@2
   int a2; // [sp+18h] [bp-38h]@10
   int x_int; // [sp+20h] [bp-30h]@2
-  double z_int_; // [sp+24h] [bp-2Ch]@2
+  int z_int_; // [sp+24h] [bp-2Ch]@2
   int z_int_4; // [sp+28h] [bp-28h]@8
   int z; // [sp+3Ch] [bp-14h]@3
   double a5; // [sp+40h] [bp-10h]@4
@@ -246,83 +246,85 @@
   int y; // [sp+4Ch] [bp-4h]@3
 
   pParticle = &this->pParticles[uParticleID];
-  if ( !pParticle->uType )
+  if (pParticle->type == ParticleType_Invalid)
     return 0;
-  uParticleID = LODWORD(pParticle->x);
-  v56 = *(float *)&uParticleID + 6.7553994e15;
-  x_int = LODWORD(v56);
-  uParticleID = LODWORD(pParticle->y);
-  y_int_ = *(float *)&uParticleID + 6.7553994e15;
-  uParticleID = LODWORD(pParticle->z);
-  z_int_ = *(float *)&uParticleID + 6.7553994e15;
+  //uParticleID = LODWORD(pParticle->x);
+  //v56 = *(float *)&uParticleID + 6.7553994e15;
+  x_int = floorf(pParticle->x + 0.5f);
+  //uParticleID = LODWORD(pParticle->y);
+  //y_int_ = *(float *)&uParticleID + 6.7553994e15;
+  y_int_ = floorf(pParticle->y + 0.5f);
+  //uParticleID = LODWORD(pParticle->z);
+  //z_int_ = *(float *)&uParticleID + 6.7553994e15;
+  z_int_ = floorf(pParticle->z + 0.5f);
   if ( !pRenderer->pRenderD3D )
   {
     if ( pBLVRenderParams->sPartyRotX )
     {
-      if ( BYTE1(pParticle->uType) & 2 )
+      if (pParticle->type & ParticleType_Line)
       {
-        v11 = pParticle->_x + 6.7553994e15;
-        uParticleID = (LODWORD(v11) - pBLVRenderParams->vPartyPos.x) << 16;
-        v12 = pParticle->_y + 6.7553994e15;
-        y = (LODWORD(v12) - pBLVRenderParams->vPartyPos.y) << 16;
+        //v11 = pParticle->_x + 6.7553994e15;
+        int _uParticleID = (int)(floorf(pParticle->_x + 0.5f) - pBLVRenderParams->vPartyPos.x) << 16;
+        //v12 = pParticle->_y + 6.7553994e15;
+        y = (int)(floorf(pParticle->_y + 0.5f) - pBLVRenderParams->vPartyPos.y) << 16;
         z = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
-        HIDWORD(a5) = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
+        HIDWORD(a5) = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
                     - z;
-        a6 = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
-        v13 = pParticle->_z + 6.7553994e15;
-        uParticleID = (LODWORD(v13) - pBLVRenderParams->vPartyPos.z) << 16;
+        a6 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
+        //v13 = pParticle->_z + 6.7553994e15;
+        _uParticleID = (int)(floorf(pParticle->_z + 0.5f) - pBLVRenderParams->vPartyPos.z) << 16;
         z = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16)
-          - ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineNegX) >> 16);
+          - ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sSineNegX) >> 16);
         v14 = z;
         HIDWORD(v13) = (unsigned __int64)(SHIDWORD(a5) * (signed __int64)pBLVRenderParams->sSineNegX) >> 16;
-        HIDWORD(a5) = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16;
+        HIDWORD(a5) = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16;
         LODWORD(v15) = pBLVRenderParams->field_40 << 16;
         HIDWORD(v15) = pBLVRenderParams->field_40 >> 16;
         v16 = v15 / z;
         v17 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
         pParticle->_screenspace_scale = v16;
-        uParticleID = (unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16;
+        _uParticleID = (unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16;
         LODWORD(v18) = pBLVRenderParams->uViewportCenterX
                      - ((signed int)((unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16) >> 16);
         v19 = pParticle->_screenspace_scale;
         pParticle->uScreenSpaceZ = v18;
-        uParticleID = (unsigned __int64)(v19 * (signed __int64)(HIDWORD(v13) + HIDWORD(a5))) >> 16;
+        _uParticleID = (unsigned __int64)(v19 * (signed __int64)(HIDWORD(v13) + HIDWORD(a5))) >> 16;
         v20 = pBLVRenderParams->uViewportCenterY
             - ((signed int)((unsigned __int64)(v19 * (signed __int64)(HIDWORD(v13) + HIDWORD(a5))) >> 16) >> 16);
         pParticle->sZValue2 = v14;
         pParticle->uScreenSpaceW = v20;
       }
-      uParticleID = (x_int - pBLVRenderParams->vPartyPos.x) << 16;
-      y = (LODWORD(y_int_) - pBLVRenderParams->vPartyPos.y) << 16;
-      HIDWORD(a5) = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
+      int _uParticleID = (x_int - pBLVRenderParams->vPartyPos.x) << 16;
+      y = (y_int_ - pBLVRenderParams->vPartyPos.y) << 16;
+      HIDWORD(a5) = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
                   - ((unsigned __int64)(y * (signed __int64)pBLVRenderParams->sSineY) >> 16);
-      a6 = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
-      HIDWORD(z_int_) = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
-      uParticleID = (LODWORD(z_int_) - pBLVRenderParams->vPartyPos.z) << 16;
-      v21 = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineNegX) >> 16;
+      a6 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
+      z_int_4 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
+      _uParticleID = (z_int_ - pBLVRenderParams->vPartyPos.z) << 16;
+      v21 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sSineNegX) >> 16;
       v22 = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v21;
       z = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v21;
       if ( v22 < (signed int)0x40000u || v22 > (signed int)0x1F400000u )
         return 0;
       v23 = a6 + z_int_4;
       a2 = a6 + z_int_4;
-      v24 = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16)
+      v24 = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16)
           + ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pBLVRenderParams->sSineNegX) >> 16);
     }
     else
     {
-      if ( BYTE1(pParticle->uType) & 2 )
+      if (pParticle->type & ParticleType_Line)
       {
         v25 = pParticle->_x + 6.7553994e15;
-        uParticleID = (LODWORD(v25) - pBLVRenderParams->vPartyPos.x) << 16;
+        int _uParticleID = (LODWORD(v25) - pBLVRenderParams->vPartyPos.x) << 16;
         v26 = pParticle->_y + 6.7553994e15;
         y = (LODWORD(v26) - pBLVRenderParams->vPartyPos.y) << 16;
         HIDWORD(v25) = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
-        v27 = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
+        v27 = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
             - HIDWORD(v25);
-        z = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
+        z = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
           - HIDWORD(v25);
-        v28 = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
+        v28 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
         a5 = pParticle->_z + 6.7553994e15;
         v29 = (LODWORD(a5) - pBLVRenderParams->vPartyPos.z) << 16;
         LODWORD(v30) = pBLVRenderParams->field_40 << 16;
@@ -330,7 +332,7 @@
         v31 = v30 / z;
         v32 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
         pParticle->_screenspace_scale = v31;
-        uParticleID = (unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16;
+        _uParticleID = (unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16;
         LODWORD(v33) = pBLVRenderParams->uViewportCenterX
                      - ((signed int)((unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16) >> 16);
         v34 = pParticle->_screenspace_scale;
@@ -340,72 +342,70 @@
         pParticle->sZValue2 = v27;
         pParticle->uScreenSpaceW = v35;
       }
-      uParticleID = (x_int - pBLVRenderParams->vPartyPos.x) << 16;
-      y = (LODWORD(y_int_) - pBLVRenderParams->vPartyPos.y) << 16;
+      int _uParticleID = (x_int - pBLVRenderParams->vPartyPos.x) << 16;
+      y = (y_int_ - pBLVRenderParams->vPartyPos.y) << 16;
       v36 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
-      v22 = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v36;
-      z = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v36;
+      v22 = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v36;
+      z = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v36;
       if ( v22 < 262144 || v22 > 524288000 )
         return 0;
-      v37 = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
-      uParticleID = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
+      v37 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
+      _uParticleID = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
       v23 = v37 + ((unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
       a2 = v37 + ((unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
-      v24 = (LODWORD(z_int_) - pBLVRenderParams->vPartyPos.z) << 16;
+      v24 = (z_int_ - pBLVRenderParams->vPartyPos.z) << 16;
     }
-    uParticleID = abs(v23);
+    int _uParticleID = abs(v23);
     v38 = abs(v22);
-    if ( v38 >= (signed int)uParticleID )
+    if ( v38 >= (signed int)_uParticleID )
     {
       LODWORD(v40) = pBLVRenderParams->field_40 << 16;
       HIDWORD(v40) = pBLVRenderParams->field_40 >> 16;
       v41 = v40 / z;
       pParticle->_screenspace_scale = v41;
-      uParticleID = (unsigned __int64)(v41 * (signed __int64)a2) >> 16;
+      _uParticleID = (unsigned __int64)(v41 * (signed __int64)a2) >> 16;
       v42 = pBLVRenderParams->uViewportCenterX - ((signed int)((unsigned __int64)(v41 * (signed __int64)a2) >> 16) >> 16);
       v43 = pParticle->_screenspace_scale;
       pParticle->uScreenSpaceX = v42;
       v44 = v43 * (signed __int64)v24;
-      uParticleID = v44 >> 16;
+      //uParticleID = v44 >> 16;
       v45 = pParticle->flt_28;
       LODWORD(v44) = (signed int)(v44 >> 16) >> 16;
       v46 = pBLVRenderParams->uViewportCenterY - v44;
       pParticle->uScreenSpaceY = pBLVRenderParams->uViewportCenterY - v44;
       v47 = v45;
       v48 = _48B561_mess_with_scaling_along_z(/*v46, */v47) * (signed __int64)pParticle->_screenspace_scale;
-      uParticleID = v48 >> 16;
+      //_uParticleID = v48 >> 16;
       pParticle->_screenspace_scale = v48 >> 16;
-      v10 = z;
-      goto LABEL_19;
+      pParticle->sZValue = z;
+      return true;
     }
-    return 0;
+    return false;
   }
+
+  int x;
   if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
           x_int,
-          SLODWORD(y_int_),
-          COERCE_UNSIGNED_INT64(*(float *)&uParticleID + 6.7553994e15),
-          (signed int *)&uParticleID,
+          y_int_,
+          z_int_,
+          &x,
           &y,
           &z,
           1) )
-    return 0;
-  pGame->pIndoorCameraD3D->Project(uParticleID, y, z, (int *)&a5 + 1, &a6);
+    return false;
+  pGame->pIndoorCameraD3D->Project(x, y, z, &pParticle->uScreenSpaceX, &pParticle->uScreenSpaceY);
   pParticle->flt_5C = pGame->pIndoorCameraD3D->fov_x;
   v4 = pParticle->flt_5C;
   pParticle->flt_60 = pGame->pIndoorCameraD3D->fov_y;
   v5 = v4 + 6.7553994e15;
   LODWORD(v6) = 0;
   HIDWORD(v6) = SLOWORD(v5);
-  v7 = pParticle->flt_28;
-  pParticle->_screenspace_scale = v6 / (signed int)uParticleID;
-  v8 = v7;
-  pParticle->uScreenSpaceX = HIDWORD(a5);
-  pParticle->uScreenSpaceY = a6;
-  pParticle->_screenspace_scale = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v9, */v8) * (signed __int64)pParticle->_screenspace_scale) >> 16;
-  v10 = uParticleID;
-LABEL_19:
-  pParticle->sZValue = v10;
-  return 1;
+  //v7 = pParticle->flt_28;
+  pParticle->_screenspace_scale = v6 / x;
+  //v8 = v7;
+  pParticle->_screenspace_scale = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v9, */pParticle->flt_28) * (signed __int64)pParticle->_screenspace_scale) >> 16;
+  pParticle->sZValue = x;
+  return true;
 }
 
 
@@ -473,7 +473,7 @@
   v4 = stru_5C6E00->Cos(pIndoorCamera->sRotationY);
   v5 = stru_5C6E00->Sin(pIndoorCamera->sRotationY);
   v6 = &v2->pParticles[uID];
-  if ( v6->uType )
+  if (v6->type != ParticleType_Invalid)
   {
     v7 = v6->x + 6.7553994e15;
     v41 = LODWORD(v7);
@@ -481,7 +481,7 @@
     v42 = v6->z + 6.7553994e15;
     if ( v3 )
     {
-      if ( BYTE1(v6->uType) & 2 )
+      if (v6->type & ParticleType_Line)
       {
         v8 = v6->_x + 6.7553994e15;
         uIDc = (LODWORD(v8) - pIndoorCamera->pos.x) << 16;
@@ -524,7 +524,7 @@
     }
     else
     {
-      if ( BYTE1(v6->uType) & 2 )
+      if (v6->type & ParticleType_Line)
       {
         v18 = v6->_x + 6.7553994e15;
         uIDf = (LODWORD(v18) - pIndoorCamera->pos.x) << 16;
@@ -600,7 +600,7 @@
   int v11; // eax@18
   int v12; // ecx@20
   int v13; // edx@20
-  Particle *v14; // eax@28
+  //Particle *v14; // eax@28
   RenderBillboardTransform_local0 v15; // [sp+Ch] [bp-58h]@1
 
   v15.uParentBillboardID = -1;
@@ -609,7 +609,7 @@
   {
     auto p = pParticles + i;
 
-    if (!p->uType)
+    if (p->type == ParticleType_Invalid)
       continue;
 
     if (!ViewProject_TrueIfStillVisible(i))
@@ -622,18 +622,18 @@
     {
       if (pRenderer->pRenderD3D)
       {
-        if (p->uType & 0x0100)
+        if (p->type & ParticleType_Diffuse)
         {
-          v14 = &pParticles[i];
-          v15._screenspace_x_scaler_packedfloat = v14->_screenspace_scale / 4;
-          v15._screenspace_y_scaler_packedfloat = v14->_screenspace_scale / 4;
-          v15.uScreenSpaceX = v14->uScreenSpaceX;
-          v15.uScreenSpaceY = v14->uScreenSpaceY;
-          v15.sZValue = v14->sZValue;
-          pRenderer->MakeParticleBillboardAndPush_BLV(&v15, 0, v14->uLightColor, v14->_rotation);
+          //v14 = &pParticles[i];
+          v15._screenspace_x_scaler_packedfloat = p->_screenspace_scale / 4;
+          v15._screenspace_y_scaler_packedfloat = p->_screenspace_scale / 4;
+          v15.uScreenSpaceX = p->uScreenSpaceX;
+          v15.uScreenSpaceY = p->uScreenSpaceY;
+          v15.sZValue = p->sZValue;
+          pRenderer->MakeParticleBillboardAndPush_BLV(&v15, 0, p->uLightColor, p->_rotation);
           return;
         }
-        if (p->uType & 0x0200)
+        if (p->type & ParticleType_Line)
         {
           if (pLines.uNumLines < 100)
           {
@@ -656,28 +656,26 @@
             pLines.pLineVertices[2 * pLines.uNumLines++ + 1].texcoord.y = 0.0;
           }
         }
-        if (p->uType & 0x0400)
+        if (p->type & ParticleType_Bitmap)
         {
           v15._screenspace_x_scaler_packedfloat = p->_screenspace_scale;
           v15._screenspace_y_scaler_packedfloat = p->_screenspace_scale;
           v15.uScreenSpaceX = p->uScreenSpaceX;
           v15.uScreenSpaceY = p->uScreenSpaceY;
           v15.sZValue = p->sZValue;
-          pRenderer->MakeParticleBillboardAndPush_BLV(&v15,
-                        pBitmaps_LOD->pHardwareTextures[p->uTextureID],
-                        v14->uLightColor,
+          pRenderer->MakeParticleBillboardAndPush_BLV(&v15, pBitmaps_LOD->pHardwareTextures[p->uTextureID],
+                        p->uLightColor,
                         p->_rotation);
         }
-        if (p->uType & 0x0800)
+        if (p->type & ParticleType_Sprite)
         {
           v15._screenspace_x_scaler_packedfloat = p->_screenspace_scale;
           v15._screenspace_y_scaler_packedfloat = p->_screenspace_scale;
           v15.uScreenSpaceX = p->uScreenSpaceX;
           v15.uScreenSpaceY = p->uScreenSpaceY;
           v15.sZValue = p->sZValue;
-          pRenderer->MakeParticleBillboardAndPush_BLV(&v15,
-                        pSprites_LOD->pHardwareSprites[p->uTextureID].pTexture,
-                        v14->uLightColor,
+          pRenderer->MakeParticleBillboardAndPush_BLV(&v15, pSprites_LOD->pHardwareSprites[p->uTextureID].pTexture,
+                        p->uLightColor,
                         p->_rotation);
         }
       }
@@ -764,7 +762,7 @@
               pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].diffuse = *(_DWORD *)(v7 + 18);
               pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].specular = 0;
               pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].texcoord.x = 0.0;
-              *((float *)&pParticleEngine->pParticles[0].uType + 16 * (pParticleEngine->pLines.uNumLines + 813)) = 0.0;
+              *((float *)&pParticleEngine->pParticles[0].type + 16 * (pParticleEngine->pLines.uNumLines + 813)) = 0.0;
               pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].pos.x = (double)*(signed int *)(v7 - 10);
               pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].pos.y = (double)*(signed int *)(v7 - 6);
               v15 = *(_DWORD *)v7;
--- a/ParticleEngine.h	Fri Mar 08 16:06:49 2013 +0200
+++ b/ParticleEngine.h	Fri Mar 08 17:08:08 2013 +0200
@@ -3,11 +3,23 @@
 
 
 
+enum ParticleType: unsigned __int32
+{
+  ParticleType_Invalid = 0,
+  ParticleType_1 = 0x0001,
+  ParticleType_Rotating = 0x0004,
+  ParticleType_8 = 0x0008,
+  ParticleType_Diffuse = 0x0100,  // colored plane
+  ParticleType_Line = 0x0200,     // line
+  ParticleType_Bitmap = 0x0400,   // textured planed
+  ParticleType_Sprite = 0x0800
+};
+
 /*  305 */
 #pragma pack(push, 1)
-struct Particle_
+struct Particle_sw
 {
-  int bFree;
+  unsigned int type;
   float x;
   float y;
   float z;
@@ -26,15 +38,12 @@
 #pragma pack(pop)
 
 
+
 /*  109 */
 #pragma pack(push, 1)
 struct Particle
 {
-  int uType; // 0x0000: empty
-             // 0x0100: color plane
-             // 0x0200: line
-             // 0x0400: bitmap plane
-             // 0x0800: sprite plane
+  unsigned int type;
   float x;
   float y;
   float z;
@@ -101,9 +110,9 @@
   ParticleEngine();
 
   void ResetParticles();
-  void AddParticle(Particle_ *a2);
+  void AddParticle(Particle_sw *a2);
   void Draw();
-  void   UpdateParticles();
+  void UpdateParticles();
   bool ViewProject_TrueIfStillVisible(unsigned int uParticleID);
   bool _48B5B3(unsigned int uID);
   void DrawParticles_BLV();
--- a/Render.cpp	Fri Mar 08 16:06:49 2013 +0200
+++ b/Render.cpp	Fri Mar 08 17:08:08 2013 +0200
@@ -3506,7 +3506,7 @@
   __int16 v29; // cx@37
   int v30; // ecx@37
   int v31; // ebx@37
-  Particle_ local_0; // [sp+Ch] [bp-98h]@7
+  Particle_sw local_0; // [sp+Ch] [bp-98h]@7
   int x; // [sp+74h] [bp-30h]@9
   int y; // [sp+78h] [bp-2Ch]@9
   //int v35; // [sp+7Ch] [bp-28h]@1
@@ -3700,8 +3700,8 @@
         {
           memset(&local_0, 0, 0x68u);
           v3 = (double)*((signed int *)v0 - 1);
-          local_0.bFree = 1036;
-          local_0.uDiffuse = 0xFF3C1Eu;
+          local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
+          local_0.uDiffuse = 0xFF3C1E;
           local_0.x = v3;
           local_0.y = (double)*(signed int *)v0;
           local_0.z = (double)*((signed int *)v0 + 1);
--- a/SpriteObject.cpp	Fri Mar 08 16:06:49 2013 +0200
+++ b/SpriteObject.cpp	Fri Mar 08 17:08:08 2013 +0200
@@ -221,7 +221,7 @@
   int v49; // [sp+Ch] [bp-9Ch]@52
   int v50; // [sp+10h] [bp-98h]@52
   Vec3_int_ v51; // [sp+14h] [bp-94h]@11
-  Particle_ Dst; // [sp+20h] [bp-88h]@45
+  Particle_sw Dst; // [sp+20h] [bp-88h]@45
   unsigned int uLayingItemID_; // [sp+88h] [bp-20h]@1
   int v54; // [sp+8Ch] [bp-1Ch]@1
   int v55; // [sp+90h] [bp-18h]@1
@@ -324,8 +324,8 @@
     Dst.flt_18 = 0.0;
     if ( HIBYTE(v23) & 2 )
     {
-      Dst.bFree = 1036;
-      Dst.uDiffuse = 16727070;
+      Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
+      Dst.uDiffuse = 0xFF3C1E;
       v24 = rand();
       v48 = (TEXTURE_TYPE)0;
 LABEL_83:
@@ -335,7 +335,7 @@
     {
       if ( HIBYTE(v23) & 4 )
       {
-        Dst.bFree = 512;
+        Dst.type = ParticleType_Line;
         Dst.uDiffuse = rand();
         Dst.timeToLive = 64;
         Dst.uTextureID = 0;
@@ -344,7 +344,7 @@
         pGame->pParticleEngine->AddParticle(&Dst);
         return;
       }
-      Dst.bFree = 1032;
+      Dst.type = ParticleType_Bitmap | ParticleType_8;
       Dst.uDiffuse = rand();
       v24 = rand();
       v48 = (TEXTURE_TYPE)0;
@@ -464,22 +464,22 @@
         Dst.flt_18 = 0.0;
         if ( HIBYTE(v45) & 2 )
         {
-          Dst.bFree = 1036;
-          Dst.uDiffuse = 16727070;
+          Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
+          Dst.uDiffuse = 0xFF3C1E;
           v24 = rand();
           v48 = (TEXTURE_TYPE)0;
           goto LABEL_83;
         }
         if ( HIBYTE(v45) & 4 )
         {
-          Dst.bFree = 512;
+          Dst.type = ParticleType_Line;
           v46 = rand();
           Dst.uTextureID = 0;
           Dst.uDiffuse = v46;
           Dst.timeToLive = 64;
           goto LABEL_89;
         }
-        Dst.bFree = 1032;
+        Dst.type = ParticleType_Bitmap | ParticleType_8;
         Dst.uDiffuse = rand();
         v24 = rand();
         v48 = (TEXTURE_TYPE)0;
@@ -628,7 +628,7 @@
   const char *v32; // [sp-8h] [bp-98h]@68
   enum TEXTURE_TYPE v33; // [sp-4h] [bp-94h]@19
   enum TEXTURE_TYPE v34; // [sp-4h] [bp-94h]@68
-  Particle_ Dst; // [sp+Ch] [bp-84h]@18
+  Particle_sw Dst; // [sp+Ch] [bp-84h]@18
   unsigned int uLayingItemID_; // [sp+74h] [bp-1Ch]@1
   ObjectDesc *v37; // [sp+78h] [bp-18h]@1
   unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4
@@ -749,8 +749,8 @@
         Dst.flt_18 = 0.0;
         if ( v29 & 0x200 )
         {
-          Dst.bFree = 1036;
-          Dst.uDiffuse = 0xFF3C1Eu;
+          Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
+          Dst.uDiffuse = 0xFF3C1E;
           v30 = rand();
           v34 = (TEXTURE_TYPE)v8;
           v32 = "effpar01";
@@ -759,7 +759,7 @@
         {
           if ( v29 & 0x400 )
             goto LABEL_70;
-          Dst.bFree = 1032;
+          Dst.type = ParticleType_Bitmap | ParticleType_8;
           Dst.uDiffuse = rand();
           v30 = rand();
           v34 = (TEXTURE_TYPE)v8;
@@ -925,8 +925,8 @@
       Dst.flt_18 = 0.0;
       if ( v10 & 0x200 )
       {
-        Dst.bFree = 1036;
-        Dst.uDiffuse = 0xFF3C1Eu;
+        Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
+        Dst.uDiffuse = 0xFF3C1E;
         Dst.flt_28 = 1.0;
         v11 = rand();
         v33 = (TEXTURE_TYPE)v8;
@@ -937,7 +937,7 @@
         if ( v10 & 0x400 )
         {
 LABEL_70:
-          Dst.bFree = 512;
+          Dst.type = ParticleType_Line;
           Dst.uDiffuse = rand();
           Dst.timeToLive = 64;
           Dst.uTextureID = v8;
@@ -945,7 +945,7 @@
           Dst.flt_28 = 1.0;
           goto LABEL_72;
         }
-        Dst.bFree = 1032;
+        Dst.type = ParticleType_Bitmap | ParticleType_8;
         Dst.uDiffuse = rand();
         Dst.flt_28 = 1.0;
         v11 = rand();
--- a/mm7_2.cpp	Fri Mar 08 16:06:49 2013 +0200
+++ b/mm7_2.cpp	Fri Mar 08 17:08:08 2013 +0200
@@ -13373,7 +13373,7 @@
   assert(sizeof(IndoorLocation) == 0x690);
   assert(sizeof(OutdoorCamera) == 0x74);
   assert(sizeof(Mouse) == 0x114);
-  assert(sizeof(Particle_) == 0x68);
+  assert(sizeof(Particle_sw) == 0x68);
   assert(sizeof(Particle) == 0x68);
   assert(sizeof(ParticleEngine) == 0xE430);
   assert(sizeof(Lightmap) == 0xC1C);
--- a/mm7_3.cpp	Fri Mar 08 16:06:49 2013 +0200
+++ b/mm7_3.cpp	Fri Mar 08 17:08:08 2013 +0200
@@ -11207,7 +11207,7 @@
   signed __int64 v21; // qtt@20
   int v22; // edx@21
   int v23; // eax@21
-  Particle_ local_0; // [sp+Ch] [bp-A0h]@3
+  Particle_sw local_0; // [sp+Ch] [bp-A0h]@3
   double v25; // [sp+74h] [bp-38h]@19
   unsigned int v26; // [sp+7Ch] [bp-30h]@1
   int a2; // [sp+80h] [bp-2Ch]@5
@@ -11332,8 +11332,8 @@
     {
       memset(&local_0, 0, 0x68u);               // fire,  like at the Pit's tavern
       v5 = (double)v2->vPosition.x;
-      local_0.bFree = 1036;
-      local_0.uDiffuse = 0xFF3C1Eu;
+      local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
+      local_0.uDiffuse = 0xFF3C1E;
       local_0.x = v5;
       local_0.y = (double)v2->vPosition.y;
       local_0.z = (double)v2->vPosition.z;
--- a/stru6.cpp	Fri Mar 08 16:06:49 2013 +0200
+++ b/stru6.cpp	Fri Mar 08 17:08:08 2013 +0200
@@ -155,7 +155,7 @@
   double v8; // st7@2
   double v9; // st6@2
   double v10; // st7@3
-  Particle_ local_0; // [sp+8h] [bp-68h]@1
+  Particle_sw local_0; // [sp+8h] [bp-68h]@1
   float x; // [sp+78h] [bp+8h]@2
 
   v4 = this;
@@ -168,7 +168,7 @@
     x = ((double)a2->vPosition.x - v7->flt_0_x) * 0.5 + v7->flt_0_x;
     v8 = ((double)v5->vPosition.y - v7->flt_4_y) * 0.5 + v7->flt_4_y;
     v9 = ((double)v5->vPosition.z - v7->flt_8_z) * 0.5 + v7->flt_8_z;
-    local_0.bFree = 1036;
+    local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
     local_0.uDiffuse = uDiffuse;
     local_0.x = x + 4.0;
     local_0.y = v8;
@@ -199,7 +199,7 @@
     v4->array_4[a2->field_54 & 0x1F].flt_4_y = (double)a2->vPosition.y;
     v4->array_4[a2->field_54 & 0x1F].flt_8_z = (double)a2->vPosition.z;
     v10 = (double)a2->vPosition.x;
-    local_0.bFree = 1036;
+    local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
     local_0.uDiffuse = uDiffuse;
     local_0.x = v10 + 4.0;
     local_0.y = (double)a2->vPosition.y;
@@ -221,10 +221,10 @@
 {
   double v4; // st7@1
   signed int v5; // edi@1
-  Particle_ local_0; // [sp+8h] [bp-68h]@1
+  Particle_sw local_0; // [sp+8h] [bp-68h]@1
 
   memset(&local_0, 0, 0x68u);
-  local_0.bFree = 1029;
+  local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_1;
   local_0.x = (double)a1->vPosition.x;
   local_0.y = (double)a1->vPosition.y;
   v4 = (double)a1->vPosition.z;
@@ -257,7 +257,7 @@
   float v8; // ST08_4@6
   float v9; // ST04_4@6
   float v10; // ST00_4@6
-  Particle_ local_0; // [sp+1Ch] [bp-7Ch]@1
+  Particle_sw local_0; // [sp+1Ch] [bp-7Ch]@1
   stru6 *v12; // [sp+84h] [bp-14h]@1
   float v13; // [sp+88h] [bp-10h]@1
   double v14; // [sp+8Ch] [bp-Ch]@5
@@ -276,8 +276,8 @@
     v4 = v3 * 1.333333333333333;
   v15 = v4;
   v5 = (double)a2->vPosition.x;
-  local_0.bFree = 1029;
-  local_0.uDiffuse = 0xFF3C1Eu;
+  local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_1;
+  local_0.uDiffuse = 0xFF3C1E;
   local_0.x = v5;
   local_0.y = (double)a2->vPosition.y;
   local_0.z = (double)a2->vPosition.z;
@@ -348,15 +348,15 @@
   ObjectDesc *v2; // esi@1
   unsigned int v3; // eax@1
   double v4; // st7@1
-  Particle_ local_0; // [sp+8h] [bp-68h]@1
+  Particle_sw local_0; // [sp+8h] [bp-68h]@1
 
   v2 = &pObjectList->pObjects[a1->uObjectDescID];
   memset(&local_0, 0, 0x68u);
   v3 = a1->uSpriteFrameID;
   local_0.x = (double)a1->vPosition.x;
   v4 = (double)a1->vPosition.y;
-  local_0.bFree = 2048;
-  local_0.uDiffuse = 0x7F7F7Fu;
+  local_0.type = ParticleType_Sprite;
+  local_0.uDiffuse = 0x7F7F7F;
   local_0.timeToLive = 1;
   local_0.y = v4;
   local_0.z = (double)a1->vPosition.z;
@@ -376,15 +376,15 @@
   double v4; // st7@1
   char v5; // al@1
   signed int v6; // edi@1
-  Particle_ Dst; // [sp+8h] [bp-68h]@1
+  Particle_sw Dst; // [sp+8h] [bp-68h]@1
 
   v2 = &pObjectList->pObjects[a1->uObjectDescID];
   memset(&Dst, 0, 0x68u);
   v3 = a1->uSpriteFrameID;
   Dst.x = (double)a1->vPosition.x;
   v4 = (double)a1->vPosition.y;
-  Dst.bFree = 2053;
-  Dst.uDiffuse = 0x7F7F7Fu;
+  Dst.type = ParticleType_Sprite | ParticleType_Rotating | ParticleType_1;
+  Dst.uDiffuse = 0x7F7F7F;
   Dst.y = v4;
   Dst.z = (double)a1->vPosition.z;
   Dst.uTextureID = pSpriteFrameTable->GetFrame(v2->uSpriteID, v3)->pHwSpriteIDs[0];
@@ -428,14 +428,14 @@
   double v8; // st6@1
   double v9; // st7@1
   double v10; // st6@1
-  Particle_ local_0; // [sp+0h] [bp-6Ch]@1
+  Particle_sw local_0; // [sp+0h] [bp-6Ch]@1
   float v12; // [sp+68h] [bp-4h]@1
   float a1a; // [sp+74h] [bp+8h]@1
   float uDiffusea; // [sp+78h] [bp+Ch]@1
   float uTextureIDa; // [sp+7Ch] [bp+10h]@1
 
   memset(&local_0, 0, 0x68u);
-  local_0.bFree = 1029;
+  local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_1;
   local_0.x = (double)a1->vPosition.x;
   v5 = a1->vPosition.z;
   local_0.y = (double)a1->vPosition.y;
@@ -501,7 +501,7 @@
   char v10; // al@2
   double v11; // st7@2
   double v12; // st7@3
-  Particle_ local_0; // [sp+Ch] [bp-68h]@1
+  Particle_sw local_0; // [sp+Ch] [bp-68h]@1
   float a2a; // [sp+7Ch] [bp+8h]@2
 
   v2 = this;
@@ -515,8 +515,8 @@
     v7 = ((double)a2->vPosition.x - v6->flt_0_x) * 0.5 + v6->flt_0_x;
     v8 = ((double)a2->vPosition.y - v6->flt_4_y) * 0.5 + v6->flt_4_y;
     v9 = ((double)a2->vPosition.z - v6->flt_8_z) * 0.5 + v6->flt_8_z;
-    local_0.bFree = 2048;
-    local_0.uDiffuse = 0xFFFFFFu;
+    local_0.type = ParticleType_Sprite;
+    local_0.uDiffuse = 0xFFFFFF;
     a2a = v9;
     local_0.x = v7;
     local_0.z = a2a;
@@ -547,8 +547,8 @@
     v2->array_4[a2->field_54 & 0x1F].flt_4_y = (double)a2->vPosition.y;
     v2->array_4[a2->field_54 & 0x1F].flt_8_z = (double)a2->vPosition.z;
     v12 = (double)a2->vPosition.x;
-    local_0.bFree = 2048;
-    local_0.uDiffuse = 0xFFFFFFu;
+    local_0.type = ParticleType_Sprite;
+    local_0.uDiffuse = 0xFFFFFF;
     LODWORD(local_0.flt_28) = 0x40000000u;
     local_0.x = v12;
     local_0.y = (double)a2->vPosition.y;
@@ -600,12 +600,12 @@
   Actor *v3; // edi@1
   int v4; // ebx@3
   //int result; // eax@5
-  Particle_ Dst; // [sp+Ch] [bp-6Ch]@1
+  Particle_sw Dst; // [sp+Ch] [bp-6Ch]@1
   int v7; // [sp+74h] [bp-4h]@2
   signed int pActora; // [sp+80h] [bp+8h]@1
 
   memset(&Dst, 0, 0x68u);
-  Dst.bFree = 1036;
+  Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
   Dst.timeToLive = (rand() & 0x7F) + 128;
   v3 = pActor;
   Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar02", TEXTURE_DEFAULT);
@@ -643,15 +643,15 @@
   unsigned int v7; // eax@1
   double v8; // st7@2
   double v9; // st7@2
-  Particle_ local_0; // [sp+8h] [bp-78h]@1
+  Particle_sw local_0; // [sp+8h] [bp-78h]@1
   double v11; // [sp+70h] [bp-10h]@1
   double v12; // [sp+78h] [bp-8h]@1
   float z1; // [sp+88h] [bp+8h]@2
 
   v4 = this;
   memset(&local_0, 0, 0x68u);
-  local_0.bFree = 1029;
-  local_0.uDiffuse = 0x7E7E7Eu;
+  local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_1;
+  local_0.uDiffuse = 0x7E7E7E;
   v5 = rand();
   local_0.flt_28 = 1.0;
   v6 = 8;
@@ -714,12 +714,12 @@
 {
   stru6 *v2; // esi@1
   signed int v3; // ebx@1
-  Particle_ local_0; // [sp+Ch] [bp-68h]@1
+  Particle_sw local_0; // [sp+Ch] [bp-68h]@1
 
   v2 = this;
   memset(&local_0, 0, 0x68u);
-  local_0.bFree = 1029;
-  local_0.uDiffuse = 0x7E7E7Eu;
+  local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_1;
+  local_0.uDiffuse = 0x7E7E7E;
   local_0.timeToLive = (rand() & 0x7F) + 128;
   local_0.uTextureID = v2->uTextureID_effpar1;
   v3 = 8;