changeset 1077:2210109f280d

DecalBuilder, AI_SpellAttack sparkles
author zipi
date Sat, 25 May 2013 18:46:48 +0100
parents 9b6e252658e8
children b44dee7e70e8 9456f2ed5ff9
files Actor.cpp DecalBuilder.cpp DecalBuilder.h mm7_data.cpp
diffstat 4 files changed, 157 insertions(+), 155 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sat May 25 14:43:27 2013 +0100
+++ b/Actor.cpp	Sat May 25 18:46:48 2013 +0100
@@ -875,9 +875,7 @@
               v6 + 5,
               0,
               0);
-            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
-              v5,
-              (unsigned int)((char *)&pDecalBuilder->std__vector_pDecals[557].pVertices[57].vWorldPosition.x + 1));
+            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
             v106 = 0;
             v104 = 0;
             v103 = 0;
@@ -914,9 +912,7 @@
               v6 + 5,
               0,
               0);
-            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
-              v5,
-              (unsigned int)((char *)&pLevelEVT_Index[4335].uEventID + 2));
+            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x5C310Eu);
             v106 = 0;
             v104 = 0;
             v103 = 0;
@@ -956,9 +952,7 @@
         LOWORD(v48) = 2 * (3 * v6 + 60);
 LABEL_114:
         v5->pActorBuffs[11].Apply(pParty->uTimePlayed + 1280, v7, v48, 0, 0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
-          v5,
-          (unsigned int)((char *)&pDecalBuilder->std__vector_pDecals[557].pVertices[57].vWorldPosition.x + 1));
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
 LABEL_127:
         v106 = v47;
         v104 = v47;
@@ -1092,9 +1086,7 @@
           v6 + 5,
           0,
           0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
-          v5,
-          (unsigned int)((char *)&pDecalBuilder->std__vector_pDecals[557].pVertices[57].vWorldPosition.x + 1));
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
         v106 = 0;
         v104 = 0;
         v103 = 0;
@@ -1226,9 +1218,7 @@
           0,
           0,
           0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
-          v5,
-          (unsigned int)((char *)&array_77EC08[1607].v_18.z + 2));
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x7E7E7Eu);
         v106 = 0;
         v104 = 0;
         v103 = 0;
--- a/DecalBuilder.cpp	Sat May 25 14:43:27 2013 +0100
+++ b/DecalBuilder.cpp	Sat May 25 18:46:48 2013 +0100
@@ -128,11 +128,11 @@
   double v26; // st7@21
   int v27; // edi@21
   double v28; // st7@21
-  int v29; // ST10_4@21
+  float v29; // ST10_4@21
   int v30; // ST08_4@21
   //DecalBuilder *v31; // esi@21
   int v32; // [sp+4h] [bp-44h]@18
-  RenderVertexSoft *v33; // [sp+8h] [bp-40h]@21
+  float v33; // [sp+8h] [bp-40h]@21
   stru314 *v34; // [sp+Ch] [bp-3Ch]@21
   float v35; // [sp+10h] [bp-38h]@21
   float v36; // [sp+14h] [bp-34h]@17
@@ -237,12 +237,12 @@
       v39 = v27;
       LODWORD(v35) = a5;
       v34 = &static_AE4F60;
-      *(float *)&v33 = v28;
+      v33 = v28;
       v32 = v23 | (v22 << 8);
-      *(float *)&v29 = v21->radius;
-      v30 = (int)v21;
+      v29 = v21->radius;
+      //v30 = (int)v21;
       //v31 = thisa;
-      if ( !this->_49B790_build_decal_geometry(v42, a3, v30, (int)&a5a, v29, v43, v33, &static_AE4F60, a5, a6, a8) )
+      if ( !this->_49B790_build_decal_geometry(v42, a3, (DecalBuilder_stru0 *)v21, (int)&a5a, SLODWORD(v29), v43, v33, &static_AE4F60, a5, a6, a8) )
       {
       MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0);
       }
@@ -255,11 +255,11 @@
 }
 
 //----- (0049B790) --------------------------------------------------------
-char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, unsigned int uColorMultiplier, RenderVertexSoft *a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
+char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, DecalBuilder_stru0 *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
 {
   DecalBuilder *v12; // esi@1
   Decal *v13; // edi@2
-  char *v14; // eax@2
+  int *v14; // eax@2
   double v15; // st7@4
   double v16; // st7@4
   int v17; // eax@4
@@ -285,30 +285,34 @@
   std::string v37; // [sp-4h] [bp-24h]@15
   float v38; // [sp+8h] [bp-18h]@6
   RenderVertexSoft *v39; // [sp+Ch] [bp-14h]@6
-  unsigned int *v40; // [sp+10h] [bp-10h]@6
+  unsigned int v40; // [sp+10h] [bp-10h]@6
+
+  int a6a;
+  RenderVertexSoft *a8a;
+  unsigned int a8b = 0;
 
   v12 = this;
-  if ( *(float *)&a6 == 0.0 )
-    goto LABEL_24;
+  if ( a6 == 0.0 )
+    return 1;
   v13 = &this->std__vector_pDecals[this->field_308008];
-  v14 = (char *)&this->std__vector_pDecals[this->field_308008].field_C1C;
-  this->std__vector_pDecals[this->field_308008].field_C18 = (DecalBuilder_stru0 *)a4;
-  *(int *)v14 = 0;
+  v14 = &this->std__vector_pDecals[this->field_308008].field_C1C;
+  this->std__vector_pDecals[this->field_308008].field_C18 = a4;
+  *v14 = 0;
   if ( a3 & 2 )
-    *(int *)v14 = 1;
-  v15 = *(float *)&a6 - *(float *)&a8;
-  *(float *)&this->field_30C028 = v15;
-  v16 = sqrt((*(float *)&a6 + *(float *)&a6 - v15) * v15);
-  *(float *)&v12->field_30C02C = v16;
+    *v14 = 1;
+  v15 = a6 - a8;
+  this->field_30C028 = v15;
+  v16 = sqrt((a6 + a6 - v15) * v15);
+  v12->field_30C02C = v16;
   v17 = a5;
   v18 = a9;
-  v12->flt_30C030 = 1.0 - (*(float *)&a6 - v16) / *(float *)&a6;
-  v13->field_C08 = (signed __int64)((double)*(signed int *)v17 - *(float *)&a8 * v18->field_4.x);
-  v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - *(float *)&a8 * v18->field_4.y);
-  v19 = *(float *)&a6;
-  v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - *(float *)&a8 * v18->field_4.z);
+  v12->flt_30C030 = 1.0 - (a6 - v16) / a6;
+  v13->field_C08 = (signed __int64)((double)*(signed int *)v17 - a8 * v18->field_4.x);
+  v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - a8 * v18->field_4.y);
+  v19 = a6;
+  v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - a8 * v18->field_4.z);
   v20 = v19 * v12->flt_30C030;
-  a8 = v13->pVertices;
+  a8a = v13->pVertices;
   v12->field_30C034 = v20;
   v12->field_30C010 = v20 * v18->field_10.x;
   v12->field_30C014 = v20 * v18->field_10.y;
@@ -316,19 +320,19 @@
   v12->field_30C01C = v20 * v18->field_1C.x;
   v12->field_30C020 = v20 * v18->field_1C.y;
   v12->field_30C024 = v20 * v18->field_1C.z;
-  a6 = v13->field_C08;
-  v21 = (double)a6;
+  a6a = v13->field_C08;
+  v21 = (double)a6a;
   v22 = v21 - v12->field_30C01C;
-  a6 = v13->field_C0A;
+  a6a = v13->field_C0A;
   v13->pVertices[0].vWorldPosition.x = v22 + v12->field_30C010;
-  v23 = (double)a6;
+  v23 = (double)a6a;
   v24 = v23 - v12->field_30C020 + v12->field_30C014;
   v25 = (char *)&v13->pVertices[0].vWorldPosition.y;
   a6 = v13->field_C0C;
   v26 = 4;
   v13->pVertices[0].vWorldPosition.y = v24;
-  v27 = (double)a6;
-  *(float *)&a6 = v27;
+  v27 = (double)a6a;
+  a6 = v27;
   v13->pVertices[0].vWorldPosition.z = v27 - v12->field_30C024 + v12->field_30C018;
   v13->pVertices[0].u = 0.0;
   v13->pVertices[0].v = 0.0;
@@ -344,7 +348,7 @@
   v13->pVertices[2].v = 1.0;
   v13->pVertices[3].vWorldPosition.x = v21 + v12->field_30C01C + v12->field_30C010;
   v13->pVertices[3].vWorldPosition.y = v23 + v12->field_30C020 + v12->field_30C014;
-  v13->pVertices[3].vWorldPosition.z = *(float *)&a6 + v12->field_30C024 + v12->field_30C018;
+  v13->pVertices[3].vWorldPosition.z = a6 + v12->field_30C024 + v12->field_30C018;
   v13->pVertices[3].u = 1.0;
   v13->pVertices[3].v = 0.0;
   do
@@ -361,28 +365,27 @@
   }
   while ( v26 );
   v13->uColorMultiplier = uColorMultiplier;
-  v40 = (unsigned int *)&v13->uNumVertices;
+  //v40 = (unsigned int *)&v13->uNumVertices;
   v39 = v13->pVertices;
   v13->uNumVertices = 4;
   v13->field_C14 = a2;
   v29 = v18->field_4.z;
-  a6 = (int)&v13->uNumVertices;
+  //a6a = (unsigned int *)&v13->uNumVertices;
   v38 = v29;
-  result = pGame->pStru9Instance->_4980B9(a11, a10, v18->field_4.x, v18->field_4.y, v38, v39, v40);
+  result = pGame->pStru9Instance->_4980B9(a11, a10, v18->field_4.x, v18->field_4.y, v38, v39, (unsigned int*)&v13->uNumVertices);
   if ( result )
   {
-    v31 = (unsigned int *)a6;
-    if ( !*(int *)a6 )
-      goto LABEL_24;
-    v32 = a8;
-    v40 = *(unsigned int **)a6;
-    v39 = a8;
-    pGame->pIndoorCameraD3D->ViewTransform(a8, (unsigned int)v40);
+    //v31 = a6a;
+    if ( !v13->uNumVertices )
+      return 1;
+    v32 = a8a;
+    //v40 = *a6a;
+    v39 = a8a;
+    pGame->pIndoorCameraD3D->ViewTransform(a8a, (unsigned int)v13->uNumVertices);
     v40 = 0;
     pGame->pIndoorCameraD3D->Project(v32, *v31, 0);
     if ( !(uClipFlags & 1) )
     {
-LABEL_19:
       ++v12->field_308008;
       v34 = 1024;
       if ( v12->field_308008 == 1024 )
@@ -390,41 +393,52 @@
       if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 )
         v34 = v12->std__vector_pDecals_size + 1;
       v12->std__vector_pDecals_size = v34;
-      goto LABEL_24;
+      return 1;
     }
     if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
     {
       if ( uClipFlags & 2 )
       {
-        v40 = (unsigned int *)&a8;
+        v40 = (int)&a8;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, (unsigned int *)&a8);
-LABEL_14:
-        v40 = v31;
+        pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, &a8b);
+        v40 = (int)v31;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_437143((unsigned int)a8, v32, v12->pVertices, v31);
-        goto LABEL_18;
+        pGame->pIndoorCameraD3D->_437143(a8b, v32, v12->pVertices, v31);
       }
-      if ( uClipFlags & 4 )
+      else if ( uClipFlags & 4 )
       {
-        v40 = (unsigned int *)&a8;
+        v40 = (int)&a8;
+        v39 = v12->pVertices;
+        pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, &a8b);
+        v40 = (int)v31;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, (unsigned int *)&a8);
-        goto LABEL_14;
+        pGame->pIndoorCameraD3D->_437143(a8b, v32, v12->pVertices, v31);
       }
-      v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
-      v35 = "Undefined clip flag specified";
+	  else
+	  {
+        v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
+        v35 = "Undefined clip flag specified";
+	    MessageBoxA(nullptr, v35, (const char *)v39, 0);
+	  }
     }
     else
     {
       v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:263";
       v35 = "Lightpoly builder native indoor clipping not implemented";
+	  MessageBoxA(nullptr, v35, (const char *)v39, 0);
     }
-      MessageBoxA(nullptr, v35, (const char *)v39, 0);
-LABEL_18:
-    if ( *(float *)&a8 != 0.0 )
-      goto LABEL_19;
-LABEL_24:
+    if ( a8b != 0 )
+	{
+      ++v12->field_308008;
+      v34 = 1024;
+      if ( v12->field_308008 == 1024 )
+        v12->field_308008 = 0;
+      if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 )
+        v34 = v12->std__vector_pDecals_size + 1;
+      v12->std__vector_pDecals_size = v34;
+      return 1;
+	}
     result = 1;
   }
   return result;
--- a/DecalBuilder.h	Sat May 25 14:43:27 2013 +0100
+++ b/DecalBuilder.h	Sat May 25 18:46:48 2013 +0100
@@ -1,6 +1,79 @@
 #pragma once
 #include "Render.h"
 
+/*  158 */
+#pragma pack(push, 1)
+struct Bloodsplat
+{
+  //----- (0043B538) --------------------------------------------------------
+  inline Bloodsplat()
+  {
+    this->field_1C = 0;
+    this->field_20 = 0;
+    //this->field_24 = 0;
+    //this->vdestructor_ptr = &Bloodsplat_pvdtor;
+  }
+
+  //----- (0043B54C) --------------------------------------------------------
+  //void __thiscall Bloodsplat::vdtor(Bloodsplat *this, char a2)
+
+  //----- (0043B569) --------------------------------------------------------
+  virtual ~Bloodsplat()
+  {
+  }
+
+  //void (__thiscall ***vdestructor_ptr)(Bloodsplat *, bool);
+  float x;
+  float y;
+  float z;
+  float radius;
+  float dot_dist;
+  char r;
+  char g;
+  char b;
+  char field_1B;
+  int field_1C;
+  unsigned long long field_20;
+  //int field_24;
+};
+#pragma pack(pop)
+
+/*  159 */
+#pragma pack(push, 1)
+struct BloodsplatContainer
+{
+  //----- (0043B688) --------------------------------------------------------
+  inline BloodsplatContainer()
+  {
+  /*_eh_vector_constructor_iterator_(
+    this->std__vector_pBloodsplats,
+    40,
+    64,
+    (void (__thiscall *)(void *))Bloodsplat::Bloodsplat,
+    (void (__thiscall *)(void *))Bloodsplat::dtor);
+  v1->std__vector_pBloodsplats_size = 0;*/
+    uNumBloodsplats = 0;
+  }
+  //----- (0043B6D6) --------------------------------------------------------
+  virtual ~BloodsplatContainer()
+  {
+    //this->vdestructor_ptr = &BloodsplatContainer_pvdtor;
+    //_eh_vector_destructor_iterator_(this->std__vector_pBloodsplats, 40, 64, Bloodsplat::dtor);
+  }
+
+
+  bool AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9);
+  bool AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b);
+
+
+  //void (__thiscall ***vdestructor_ptr)(BloodsplatContainer *, bool);
+  Bloodsplat std__vector_pBloodsplats[64];
+  unsigned int std__vector_pBloodsplats_size;
+  int uNumBloodsplats;
+};
+#pragma pack(pop)
+
+extern struct BloodsplatContainer *pBloodsplatContainer; // idb
 
 #pragma pack(push, 1)
 struct DecalBuilder_stru0
@@ -92,7 +165,7 @@
   bool AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9);
   void Reset(unsigned int bPreserveBloodsplats);
   char ApplyDecals(int light_level, char a3, struct stru154 *a4, int a5, struct RenderVertexSoft *a6, struct IndoorCameraD3D_Vec4 *a7, char a8, unsigned int uSectorID);
-  char _49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, unsigned int uColorMultiplier, struct RenderVertexSoft *a8, struct stru314 *a9, signed int a10, struct RenderVertexSoft *a11, char uClipFlags);
+  char _49B790_build_decal_geometry(int a2, char a3, DecalBuilder_stru0 *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, struct stru314 *a9, signed int a10, struct RenderVertexSoft *a11, char uClipFlags);
   bool ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID);
   char ApplyDecals_OutdoorFace(ODMFace *pFace);
   bool _49BE8A(struct stru148 *a2, Vec3_float_ *a3, float *a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7);
@@ -116,8 +189,8 @@
   float field_30C01C;
   float field_30C020;
   float field_30C024;
-  int field_30C028;
-  int field_30C02C;
+  float field_30C028;
+  float field_30C02C;
   float flt_30C030;
   float field_30C034;
 };
@@ -129,78 +202,3 @@
 
 
 
-/*  158 */
-#pragma pack(push, 1)
-struct Bloodsplat
-{
-  //----- (0043B538) --------------------------------------------------------
-  inline Bloodsplat()
-  {
-    this->field_1C = 0;
-    this->field_20 = 0;
-    //this->field_24 = 0;
-    //this->vdestructor_ptr = &Bloodsplat_pvdtor;
-  }
-
-  //----- (0043B54C) --------------------------------------------------------
-  //void __thiscall Bloodsplat::vdtor(Bloodsplat *this, char a2)
-
-  //----- (0043B569) --------------------------------------------------------
-  virtual ~Bloodsplat()
-  {
-  }
-
-  //void (__thiscall ***vdestructor_ptr)(Bloodsplat *, bool);
-  float x;
-  float y;
-  float z;
-  float radius;
-  float dot_dist;
-  char r;
-  char g;
-  char b;
-  char field_1B;
-  int field_1C;
-  unsigned long long field_20;
-  //int field_24;
-};
-#pragma pack(pop)
-
-/*  159 */
-#pragma pack(push, 1)
-struct BloodsplatContainer
-{
-  //----- (0043B688) --------------------------------------------------------
-  inline BloodsplatContainer()
-  {
-  /*_eh_vector_constructor_iterator_(
-    this->std__vector_pBloodsplats,
-    40,
-    64,
-    (void (__thiscall *)(void *))Bloodsplat::Bloodsplat,
-    (void (__thiscall *)(void *))Bloodsplat::dtor);
-  v1->std__vector_pBloodsplats_size = 0;*/
-    uNumBloodsplats = 0;
-  }
-  //----- (0043B6D6) --------------------------------------------------------
-  virtual ~BloodsplatContainer()
-  {
-    //this->vdestructor_ptr = &BloodsplatContainer_pvdtor;
-    //_eh_vector_destructor_iterator_(this->std__vector_pBloodsplats, 40, 64, Bloodsplat::dtor);
-  }
-
-
-  bool AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9);
-  bool AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b);
-
-
-  //void (__thiscall ***vdestructor_ptr)(BloodsplatContainer *, bool);
-  Bloodsplat std__vector_pBloodsplats[64];
-  unsigned int std__vector_pBloodsplats_size;
-  int uNumBloodsplats;
-};
-#pragma pack(pop)
-
-
-
-extern struct BloodsplatContainer *pBloodsplatContainer; // idb
\ No newline at end of file
--- a/mm7_data.cpp	Sat May 25 14:43:27 2013 +0100
+++ b/mm7_data.cpp	Sat May 25 18:46:48 2013 +0100
@@ -1208,7 +1208,7 @@
 int dword_50B570[50]; // weak
 int dword_50B638[50]; // weak
 int dword_50B700; // weak
-int dword_50B738[2]; // idb
+int dword_50B738[777]; // idb
 int _50B744_view_transformed_ys[45];
 int dword_50B828[777];
 int _50B834_view_transformed_zs[45];