changeset 136:f07a29f328e8

Слияние
author Ritor1
date Thu, 15 Nov 2012 18:08:18 +0600
parents fcf3209727a4 (current diff) 05b2d9653abc (diff)
children 0afe11853c77
files LOD.cpp Outdoor.cpp mm7_2.cpp
diffstat 3 files changed, 131 insertions(+), 210 deletions(-) [+]
line wrap: on
line diff
--- a/Render.cpp	Thu Nov 15 18:08:01 2012 +0600
+++ b/Render.cpp	Thu Nov 15 18:08:18 2012 +0600
@@ -906,9 +906,9 @@
 //----- (0047F5C6) --------------------------------------------------------
 float Render::DrawBezierTerrain()
 {
-  __debugbreak();
-  return 0;
-  /*
+//  __debugbreak();
+ // return 0;
+  
   unsigned int v0; // ebx@1
   unsigned int v1; // edi@1
   unsigned int v2; // eax@1
@@ -988,6 +988,7 @@
   IndoorCameraD3D *v76; // ecx@184
   int v77; // ecx@184
   int v79; // ebx@185
+  int v127; // esi@185
   int v86; // edi@196
   int v87; // eax@196
   int v88; // ecx@196
@@ -1585,68 +1586,41 @@
       v77 = v73 - 2;
       if ( v73 - 2 < v75 )
       {
-        _ESI = 0;
+        v127 = 0;
         v79 = (v73 - 66) << 9;
         v116 = v77;
         v105 = v79;
         v111 = v75 - v77;
         do
         {
-          __asm { fild    [ebp+var_58] }
-          _EAX = ptr_801A08;
-          __asm
-          {
-            fst     [ebp+var_54]
-            fstp    dword ptr [esi+eax]
-          }
-          v105 = (64 - terrain_76D9C8[v70]) << 9;
-          _EAX = ptr_801A08;
-          __asm
-          {
-            fild    [ebp+var_58]
-            fstp    dword ptr [esi+eax+4]
-          }
-          v105 = pOutdoor->GetHeightOnTerrain(v116, terrain_76D9C8[v70]);
-          _EAX = ptr_801A08;
-          __asm
-          {
-            fild    [ebp+var_58]
-            fstp    dword ptr [esi+eax+8]
-            fld     [ebp+var_54]
-          }
-          _EAX = ptr_801A04;
-          __asm { fstp    dword ptr [esi+eax] }
-          v105 = (63 - terrain_76D9C8[v70]) << 9;
-          _EAX = ptr_801A04;
-          __asm
-          {
-            fild    [ebp+var_58]
-            fstp    dword ptr [esi+eax+4]
-          }
-          v105 = pOutdoor->GetHeightOnTerrain(v116, terrain_76D9C8[v70] + 1);
-          _EAX = ptr_801A04;
-          __asm
-          {
-            fild    [ebp+var_58]
-            fstp    dword ptr [esi+eax+8]
-          }
+		  *(float *)&v106 = (double)v105;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.x + v127) = *(float *)&v106;
+          v105 = (64 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v127) = (double)v105;
+          v105 = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70));
+          *(float *)((char *)&ptr_801A08->vWorldPosition.z + v127) = (double)v105;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.x + v127) = *(float *)&v106;
+          v105 = (63 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v127) = (double)v105;
+          v105 = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70) + 1);
+          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v127) = (double)v105;
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
-            a1->ViewTransform(&ptr_801A08[_ESI], 1u);
-            a1->ViewTransform(&ptr_801A04[_ESI], 1u);
-            a1->Project(&ptr_801A08[_ESI], 1u, 0);
-            a1->Project(&ptr_801A04[_ESI], 1u, 0);
+            a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v127, 1);
+            a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v127, 1);
+            a1->Project((RenderVertexSoft *)(char *)ptr_801A08 + v127, 1, 0);
+            a1->Project((RenderVertexSoft *)(char *)ptr_801A04 + v127, 1, 0);
           }
           v79 += 512;
-          ++_ESI;
+          v127 += 48;
           ++v116;
           v105 = v79;
-        }
+		}
         while ( v116 < v107 );
       }
-      v103 = abs(pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v70]);
-      v104 = abs(pIndoorCamera->uMapGridCellX - terrain_76DBC8[v70]);
-      if ( pRenderer->pRenderD3D )
+	  v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v70]);
+      v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v70]);
+	  if ( pRenderer->pRenderD3D )
         Render::DrawTerrainD3D(v111, 0, (int)&v102);
       else
         Render::DrawTerrainSW(v111, 0, (int)&v102);
@@ -1675,7 +1649,7 @@
       v107 = v90 + 2;
       if ( v89 - 2 < v90 + 2 )
       {
-        _ESI = 0;
+        v86 = 0;
         v116 = v89 - 2;
         v92 = (66 - v89) << 9;
         v105 = (66 - v89) << 9;
@@ -1683,59 +1657,35 @@
         do
         {
           v93 = v116;
-          v106 = (terrain_76DBC8[v86] - 64) << 9;
-          _EAX = ptr_801A08;
-          __asm
-          {
-            fild    [ebp+var_54]
-            fstp    dword ptr [esi+eax]
-            fild    [ebp+var_58]
-          }
-          _EAX = ptr_801A08;
-          __asm
-          {
-            fst     [ebp+var_58]
-            fstp    dword ptr [esi+eax+4]
-          }
-          v106 = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v93);
-          _EAX = ptr_801A08;
-          __asm { fild    [ebp+var_54] }
+          v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.x + v86) = (double)v106;
+          *(float *)&v105 = (double)v105;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v86) = *(float *)&v105;
+          v106 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86), v93);
           v97 = v116;
-          __asm { fstp    dword ptr [esi+eax+8] }
-          v106 = (terrain_76DBC8[v86] - 63) << 9;
-          _EAX = ptr_801A04;
-          __asm
-          {
-            fild    [ebp+var_54]
-            fstp    dword ptr [esi+eax]
-            fld     [ebp+var_58]
-          }
-          _EAX = ptr_801A04;
-          __asm { fstp    dword ptr [esi+eax+4] }
-          v105 = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v97);
-          _EAX = ptr_801A04;
-          __asm
-          {
-            fild    [ebp+var_58]
-            fstp    dword ptr [esi+eax+8]
-          }
+          *(float *)((char *)&ptr_801A08->vWorldPosition.z + v86) = (double)v106;
+          v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.x + v86) = (double)v106;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v86) = *(float *)&v105;
+          v105 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97);
+          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v86) = (double)v105;
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
-            a1->ViewTransform(&ptr_801A08[_ESI], 1u);
-            a1->ViewTransform(&ptr_801A04[_ESI], 1u);
-            a1->Project(&ptr_801A08[_ESI], 1u, 0);
-            a1->Project(&ptr_801A04[_ESI], 1u, 0);
+           a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1);
+           a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1);
+           a1->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0);
+           a1->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0);
           }
           v92 -= 512;
-          ++_ESI;
+          v86 += 48;
           ++v116;
           v105 = v92;
-        }
+		}
         while ( v116 < v107 );
       }
-      v103 = abs(pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]);
-      v104 = abs(pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]);
-      if ( pRenderer->pRenderD3D )
+      v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]);
+	  v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]);
+	  if ( pRenderer->pRenderD3D )
         Render::DrawTerrainD3D(v111, 1, (int)&v102);
       else
         Render::DrawTerrainSW(v111, 1, (int)&v102);
@@ -1743,7 +1693,7 @@
   }
   result = v126;
   pOutdoorCamera->field_40 = v126;
-  return result;*/
+  return result;
 }
 // 47FFC4: inconsistent fpu stack
 // 4D864C: using guessed type char byte_4D864C;
@@ -1854,7 +1804,7 @@
   int sY; // [sp+B0h] [bp-20h]@6
   RenderVertexSoft *a2; // [sp+B4h] [bp-1Ch]@3
   unsigned int a5; // [sp+B8h] [bp-18h]@21
-  RenderVertexSoft *_ECX; // [sp+BCh] [bp-14h]@6
+  RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6
   Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17
   RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6
   RenderVertexSoft *a8; // [sp+C8h] [bp-8h]@6
@@ -1889,32 +1839,29 @@
       v6 = abs(v83);
       --X;
       v93 = &stru_76E5C8[(v5 << 7) + v6];
-      if ( !v93->field_0
-        || ((v7 = v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = &pVerticesSR_801A10[v7],
-                                                                      v10 = &pVerticesSR_806210[v7 + 1]) : (v9 = &pVerticesSR_806210[v7 + 1], v10 = &pVerticesSR_801A10[v7]),
+      if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7),
+                                                                      v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)),
             ((a8 = v9,
-              pVertices = &pVerticesSR_801A10[v7 + 1],
+              pVertices = &pVerticesSR_801A10[1] + v7,
               v11 = v8->vWorldPosition.x,
-              _ECX = v10,
-              v12 = v11 + 6.7553994e15,
+              v101 = v10,
+              v12 = v11 + 6.755399441055744e15,
               sX = LODWORD(v12),
-              v13 = v8->vWorldPosition.y + 6.7553994e15,
+              v13 = v8->vWorldPosition.y + 6.755399441055744e15,
               sY = LODWORD(v13),
               thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5,
-              v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(thisd + 6.7553994e15)),
+              v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(thisd + 6.755399441055744e15)),
               v15 = v9->vWorldPosition.y + v8->vWorldPosition.y,
               v89 = v14,
               thise = v15 * 0.5,
-              _this = (LightmapBuilder *)WorldPosToGridCellZ(COERCE_UNSIGNED_INT64(thise + 6.7553994e15)),
+              _this = (LightmapBuilder *)WorldPosToGridCellZ(COERCE_UNSIGNED_INT64(thise + 6.755399441055744e15)),
               WorldPosToGridCellX(sX),
               WorldPosToGridCellZ(sY),
               !byte_4D864C)
           || !(pGame->uFlags & 0x80))
-         && !sub_481EFA(v8, v9, _ECX, pVertices, 1)) )
+         && !sub_481EFA(v8, v9, v101, pVertices, 1)) )
         goto LABEL_162;
-      if ( v8->vWorldPosition.z != v9->vWorldPosition.z
-        || v9->vWorldPosition.z != pVertices->vWorldPosition.z
-        || pVertices->vWorldPosition.z != _ECX->vWorldPosition.z )
+      if ( v8->vWorldPosition.z != v9->vWorldPosition.z || v9->vWorldPosition.z != pVertices->vWorldPosition.z || pVertices->vWorldPosition.z != v101->vWorldPosition.z )
         break;
       v16 = &array_77EC08[pOutdoorCamera->numStru148s];
       v17 = pOutdoor->GetTileTexture(sX, sY);
@@ -1940,13 +1887,13 @@
         v99 = v23;
         thisf = 20.0 - (-v24 - v91 * v23->y - v90 * v23->x) * 20.0;
         v25 = thisf + 6.7553994e15;
-        v27 = __OFSUB__(pOutdoorCamera->numStru148s, 1999);
+        v27 = pOutdoorCamera->numStru148s > 1999;
         v26 = pOutdoorCamera->numStru148s - 1999 < 0;
         v16->field_58 = LOBYTE(v25);
         if ( !(v26 ^ v27) )
           return;
         ++pOutdoorCamera->numStru148s;
-        if ( !sub_481FC9(v8, a8, _ECX, v16) )
+        if ( !sub_481FC9(v8, a8, v101, v16) )
           goto LABEL_126;
         v28 = 1.0 / (a2->vWorldViewPosition.x + 0.0000001);
         memcpy(array_50AC10, a2, 0x30u);
@@ -1963,8 +1910,8 @@
         array_50AC10[2].flt_20 = 1.0 / v30;
         array_50AC10[2].u = 1.0;
         array_50AC10[2].v = 1.0;
-        v31 = _ECX->vWorldViewPosition.x + 0.0000001;
-        memcpy(&array_50AC10[3], _ECX, sizeof(array_50AC10[3]));
+        v31 = v101->vWorldViewPosition.x + 0.0000001;
+        memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3]));
         array_50AC10[3].flt_20 = 1.0 / v31;
         array_50AC10[3].u = 1.0;
         array_50AC10[3].v = 0.0;
@@ -1992,12 +1939,12 @@
         }
         this_3 = a2->vWorldViewPosition.x < 8.0
               || a8->vWorldViewPosition.x < 8.0
-              || _ECX->vWorldViewPosition.x < 8.0
+              || v101->vWorldViewPosition.x < 8.0
               || pVertices->vWorldViewPosition.x < 8.0;
         v32 = (double)pOutdoorCamera->shading_dist_mist;
         v108 = v32 < a2->vWorldViewPosition.x
             || v32 < a8->vWorldViewPosition.x
-            || v32 < _ECX->vWorldViewPosition.x
+            || v32 < v101->vWorldViewPosition.x
             || v32 < pVertices->vWorldViewPosition.x;
         LOBYTE(v33) = 0;
         pGame->pLightmapBuilder->std__vector_000004_size = 0;
@@ -2238,7 +2185,7 @@
     if ( pOutdoorCamera->numStru148s >= 1999 )
       return;
     ++pOutdoorCamera->numStru148s;
-    if ( !sub_481FC9(_ECX, a2, pVertices, v59) )
+    if ( !sub_481FC9(v101, a2, pVertices, v59) )
     {
 LABEL_126:
       --pOutdoorCamera->numStru148s;
@@ -2254,8 +2201,8 @@
     array_50AC10[1].flt_20 = 1.0 / v67;
     array_50AC10[1].u = 1.0;
     array_50AC10[1].v = 1.0;
-    v68 = _ECX->vWorldViewPosition.x + 0.0000001;
-    memcpy(&array_50AC10[2], _ECX, sizeof(array_50AC10[2]));
+    v68 = v101->vWorldViewPosition.x + 0.0000001;
+    memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2]));
     array_50AC10[2].flt_20 = 1.0 / v68;
     array_50AC10[2].u = 1.0;
     array_50AC10[2].v = 0.0;
@@ -2283,9 +2230,9 @@
     }
     this_3b = a2->vWorldViewPosition.x < 8.0
            || pVertices->vWorldViewPosition.x < 8.0
-           || _ECX->vWorldViewPosition.x < 8.0;
+           || v101->vWorldViewPosition.x < 8.0;
     v69 = (double)pOutdoorCamera->shading_dist_mist;
-    v108 = v69 < a2->vWorldViewPosition.x || v69 < pVertices->vWorldViewPosition.x || v69 < _ECX->vWorldViewPosition.x;
+    v108 = v69 < a2->vWorldViewPosition.x || v69 < pVertices->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x;
     LOBYTE(v70) = 0;
     v96->std__vector_000004_size = 0;
     if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
@@ -7140,7 +7087,7 @@
 //----- (004A2031) --------------------------------------------------------
 unsigned int Render::GetActorTintColor(float a2, int a3, int a4, int a5, RenderBillboard *a6)
 {
-  return GetActorTintColor(a3, a4, a2, a5, a6);
+  return ::GetActorTintColor(a3, a4, a2, a5, a6);
 }
 
 
--- a/mm7_2.cpp	Thu Nov 15 18:08:01 2012 +0600
+++ b/mm7_2.cpp	Thu Nov 15 18:08:18 2012 +0600
@@ -7520,10 +7520,10 @@
   int v16; // eax@19
   int v17; // ecx@19
   int v18; // esi@31
-  int v19; // ecx@32
-  int v20; // edx@32
-  int v21; // eax@32
-  Actor *v22; // esi@35
+  //int pPosX; // ecx@32
+  //int v20; // edx@32
+  //int v21; // eax@32
+  Actor *pMonster; // esi@35
   int v23; // edx@36
   signed int v24; // edi@36
   int v25; // ecx@36
@@ -7546,7 +7546,7 @@
   //void *v42; // [sp-10h] [bp-F8h]@50
   //size_t v43; // [sp-Ch] [bp-F4h]@50
   const char *v44; // [sp-8h] [bp-F0h]@13
-  char *v45; // [sp-4h] [bp-ECh]@9
+  char *pTexture; // [sp-4h] [bp-ECh]@9
   char Str[32]; // [sp+Ch] [bp-DCh]@60
   char Str2[120]; // [sp+2Ch] [bp-BCh]@29
   unsigned int uFaceID; // [sp+A4h] [bp-44h]@52
@@ -7555,13 +7555,12 @@
   char Source[32]; // [sp+B0h] [bp-38h]@20
   int v52; // [sp+D0h] [bp-18h]@34
   int v53; // [sp+D4h] [bp-14h]@34
-  int v54; // [sp+D8h] [bp-10h]@32
-  int v55; // [sp+DCh] [bp-Ch]@32
+  int pSector; // [sp+D8h] [bp-10h]@32
+  int pPosX; // [sp+DCh] [bp-Ch]@32
   int v56; // [sp+E0h] [bp-8h]@8
   int v57; // [sp+E4h] [bp-4h]@1
 
   //auto a2 = spawn;
-
   v57 = 0;
   //v5 = pMapInfo;
   //v6 = spawn;
@@ -7571,15 +7570,12 @@
     v7 = pIndoor->dlv.field_C_alert;
   else
     v7 = 0;
-
   if (v7)
     v8 = (spawn->uAttributes & 1) == 0;
   else
     v8 = (spawn->uAttributes & 1) == 1;
-
   if (v8)
     return;
-
     //result = (void *)(spawn->uIndex - 1);
   v56 = 1;
   switch (spawn->uIndex - 1)
@@ -7588,82 +7584,70 @@
         v9 = pMapInfo->uEncounterMonster1AtLeast;
         v10 = rand();
         v11 = pMapInfo->uEncounterMonster1AtMost;
-        v45 = pMapInfo->pEncounterMonster1Texture;
+        pTexture = pMapInfo->pEncounterMonster1Texture;
         v12 = v10 % (v11 - v9 + 1);
         v13 = pMapInfo->field_34;
         goto LABEL_20;
-
     case 3u:
-        v45 = pMapInfo->pEncounterMonster1Texture;
+        pTexture = pMapInfo->pEncounterMonster1Texture;
         v44 = "%s A";
         goto LABEL_25;
-
     case 4u:
-        v45 = pMapInfo->pEncounterMonster2Texture;
+        pTexture = pMapInfo->pEncounterMonster2Texture;
         v44 = "%s A";
         goto LABEL_25;
-
     case 5u:
-        v45 = pMapInfo->pEncounterMonster3Texture;
+        pTexture = pMapInfo->pEncounterMonster3Texture;
         v44 = "%s A";
         goto LABEL_25;
-
     case 1u:
         v9 = pMapInfo->uEncounterMonster2AtLeast;
         v14 = rand();
         v15 = pMapInfo->uEncounterMonster2AtMost;
-        v45 = pMapInfo->pEncounterMonster2Texture;
+        pTexture = pMapInfo->pEncounterMonster2Texture;
         v12 = v14 % (v15 - v9 + 1);
         v13 = pMapInfo->field_37;
         goto LABEL_20;
-
     case 6u:
-        v45 = pMapInfo->pEncounterMonster1Texture;
+        pTexture = pMapInfo->pEncounterMonster1Texture;
         v44 = "%s B";
         goto LABEL_25;
-
     case 7u:
-        v45 = pMapInfo->pEncounterMonster2Texture;
+        pTexture = pMapInfo->pEncounterMonster2Texture;
         v44 = "%s B";
         goto LABEL_25;
-
     case 8u:
-        v45 = pMapInfo->pEncounterMonster3Texture;
+        pTexture = pMapInfo->pEncounterMonster3Texture;
         v44 = "%s B";
         goto LABEL_25;
-
     case 2u:
         v9 = pMapInfo->uEncounterMonster3AtLeast;
         v16 = rand();
         v17 = pMapInfo->uEncounterMonster3AtMost;
-        v45 = pMapInfo->pEncounterMonster3Texture;
+        pTexture = pMapInfo->pEncounterMonster3Texture;
         v12 = v16 % (v17 - v9 + 1);
         v13 = pMapInfo->field_3A;
 LABEL_20:
         v57 = v13;
         v56 = v9 + v12;
-        strcpy(Source, v45);
+        strcpy(Source, pTexture);
         goto LABEL_26;
-
     case 9u:
-        v45 = pMapInfo->pEncounterMonster1Texture;
+        pTexture = pMapInfo->pEncounterMonster1Texture;
         v44 = "%s C";
         goto LABEL_25;
-
     case 0xAu:
-        v45 = pMapInfo->pEncounterMonster2Texture;
+        pTexture = pMapInfo->pEncounterMonster2Texture;
         v44 = "%s C";
         goto LABEL_25;
-
     case 0xBu:
-        v45 = pMapInfo->pEncounterMonster3Texture;
+        pTexture = pMapInfo->pEncounterMonster3Texture;
         v44 = "%s C";
 LABEL_25:
-        sprintf(Source, v44, v45);
+        sprintf(Source, v44, pTexture);
 LABEL_26:
         if (Source[0] == '0')
           return;
-
         v57 += a3;
         if ( v57 > 4 )
           v57 = 4;
@@ -7673,15 +7657,12 @@
         v18 = v56;
         if ( (signed int)(v56 + uNumActors) >= 500 )
           return;
-        v19 = spawn->vPosition.x;
-        v20 = spawn->vPosition.y;
-        v21 = spawn->vPosition.z;
-        v54 = 0;
-        v55 = v19;
-        a4 = v20;
-        a3 = v21;
+        pSector = 0;
+        pPosX = spawn->vPosition.x;
+        a4 = spawn->vPosition.y;
+        a3 = spawn->vPosition.z;
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-          v54 = pIndoor->GetSector(v19, v20, v21);
+          pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z);
         v53 = 0;
         v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
         if ( v18 <= 0 )
@@ -7690,10 +7671,9 @@
       default:
         return;
   }
-
   for (uint i = v53; i < v56; ++i)
   {
-      v22 = &pActors[uNumActors];
+      pMonster = &pActors[uNumActors];
       pActors[uNumActors].Reset();
       if ( v57 )
       {
@@ -7711,72 +7691,66 @@
         }
         if ( v24 == 1 )
         {
-          v45 = Source;
+          pTexture = Source;
           v44 = "%s A";
         }
         else
         {
           if ( v24 == 2 )
           {
-            v45 = Source;
+            pTexture = Source;
             v44 = "%s B";
           }
           else
           {
             if ( v24 != 3 )
               goto LABEL_58;
-            v45 = Source;
+            pTexture = Source;
             v44 = "%s C";
           }
         }
-        sprintf(Str2, v44, v45);
+        sprintf(Str2, v44, pTexture);
       }
       v26 = pMonsterList->GetMonsterByName(Str2);
       v50 = (signed __int16)v26;
-      v45 = Str2;
+      pTexture = Str2;
       if ( (signed __int16)v26 == -1 )
       {
-        sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", v45);
+        sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", pTexture);
         MessageBoxA(nullptr, Str, nullptr, 0);
         ExitProcess(0);
       }
       v27 = &pMonsterList->pMonsters[(signed __int16)v26];
-      v28 = pMonsterStats->_4563FF(v45);
+      v28 = pMonsterStats->_4563FF(pTexture);
       if ( !v28 )
         v28 = 1;
       Src = &pMonsterStats->pInfos[v28];
-      strcpy(v22->pActorName, Src->pName);
-      //v43 = 88;
-      //v42 = Src;
-      v29 = Src->uHP;
-      v41 = &v22->pMonsterInfo;
-      v22->sCurrentHP = v29;
+      strcpy(pMonster->pActorName, Src->pName);
+      pMonster->sCurrentHP = Src->uHP;
       assert(sizeof(MonsterInfo) == 88);
-      memcpy(v41, Src, sizeof(MonsterInfo));
-      v22->word_000086_some_monster_id = v50 + 1;
-      v22->uActorRadius = v27->uMonsterRadius;
-      v22->uActorHeight = v27->uMonsterHeight;
-      v22->uMovementSpeed = v27->uMovementSpeed;
-      v30 = v55;
-      v22->vInitialPosition.x = v55;
-      v22->vPosition.x = v30;
-      v31 = a4;
-      v22->uTetherDistance = 256;
-      v22->vInitialPosition.y = v31;
-      v22->vPosition.y = v31;
-      v45 = 0;
-      v22->vInitialPosition.z = a3;
-      v22->vPosition.z = a3;
-      v22->uSectorID = v54;
-      v22->uGroup = spawn->uGroup;
-      v22->PrepareSprites((char)v45);
-      v22->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+      memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo));
+      pMonster->word_000086_some_monster_id = v50 + 1;
+      pMonster->uActorRadius = v27->uMonsterRadius;
+      pMonster->uActorHeight = v27->uMonsterHeight;
+      pMonster->uMovementSpeed = v27->uMovementSpeed;
+      pMonster->vInitialPosition.x = spawn->vPosition.x;
+      pMonster->vPosition.x = spawn->vPosition.x;
+      pMonster->uTetherDistance = 256;
+      pMonster->vInitialPosition.y = a4;
+      pMonster->vPosition.y = a4;
+      pTexture = 0;
+      pMonster->vInitialPosition.z = a3;
+      pMonster->vPosition.z = a3;
+      pMonster->uSectorID = pSector;
+      pMonster->uGroup = spawn->uGroup;
+      pMonster->PrepareSprites((char)pTexture);
+      pMonster->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
       v32 = rand();
       v33 = v32 % 2048;
       v34 = stru_5C6E00->SinCos(v32 % 2048);
       a4 = v34;
       a3 = (unsigned __int64)(v34 * (signed __int64)v52) >> 16;
-      v55 = a3 + spawn->vPosition.x;
+      pPosX = a3 + spawn->vPosition.x;
       v35 = stru_5C6E00->SinCos(v33 - stru_5C6E00->uIntegerHalfPi);
       a4 = v35;
       a3 = (unsigned __int64)(v35 * (signed __int64)v52) >> 16;
@@ -7785,10 +7759,10 @@
       a3 = spawn->vPosition.z;
       if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
         goto LABEL_55;
-      v37 = pIndoor->GetSector(v55, a4, v36);
-      if ( v37 == v54 )
-      {
-        v38 = _46CEC3_get_floor_level(v55, a4, a3, v37, &uFaceID);
+      v37 = pIndoor->GetSector(pPosX, a4, v36);
+      if ( v37 == pSector )
+      {
+        v38 = _46CEC3_get_floor_level(pPosX, a4, a3, v37, &uFaceID);
         v39 = v38;
         if ( v38 != -30000 )
         {
@@ -7797,7 +7771,7 @@
             a3 = v39;
 LABEL_55:
             if ( a5 )
-              v22->uAttributes |= 0x080000;
+              pMonster->uAttributes |= 0x080000;
             ++uNumActors;
             goto LABEL_58;
           }
--- a/mm7_3.cpp	Thu Nov 15 18:08:01 2012 +0600
+++ b/mm7_3.cpp	Thu Nov 15 18:08:18 2012 +0600
@@ -7854,7 +7854,7 @@
       HIDWORD(v36) = v19->uTextureHeight;
       v22 = (double)SHIDWORD(v36);
       HIDWORD(v36) = v18 >> 16;
-      v24 = __OFSUB__(v31, _this.uNumVertices);
+      v24 = _this.uNumVertices > v31;
       v23 = ((v31 - _this.uNumVertices) & 0x80000000u) != 0;
       *((float *)v7 - 9) = v21 / (v22 * 65536.0);
       *((float *)v7 - 16) = (double)pOutdoorCamera->shading_dist_mist;
@@ -18704,7 +18704,7 @@
   if ( v10 )
   {
     v11 = uNumActors;
-    SpawnEncounter((MapInfo *)&pMapStats + v10, &v16, 0, count, 0);
+    SpawnEncounter((MapInfo *)&pMapStats->pInfos[v10], &v16, 0, count, 0);
     memcpy(&v15, Actor::GetDirectionInfo(8 * v11 | AI_OBJECT_ACTOR, 4u, &a3, 1), sizeof(v15));
     v12 = v11;
     if ( (signed int)v11 < (signed int)uNumActors )