diff DecalBuilder.cpp @ 1077:2210109f280d

DecalBuilder, AI_SpellAttack sparkles
author zipi
date Sat, 25 May 2013 18:46:48 +0100
parents 9b6e252658e8
children 81a30c2e3e0a
line wrap: on
line diff
--- 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;