changeset 1051:05c62d166182

004C1D2B cleaned
author Nomad
date Thu, 23 May 2013 14:08:26 +0200
parents 4b329bf2d197
children d48c762de563 2e5220c27511
files Math.h Viewport.cpp Vis.cpp mm7_2.cpp mm7_5.cpp mm7_data.cpp mm7_data.h stru6.cpp
diffstat 8 files changed, 76 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/Math.h	Thu May 23 16:36:08 2013 +0600
+++ b/Math.h	Thu May 23 14:08:26 2013 +0200
@@ -24,5 +24,10 @@
 #pragma pack(pop)
 
 
+int fixpoint_sub0(int, int);
+int fixpoint_div(int, int);
+int fixpoint_mul(int, int);
+int fixpoint_from_float(float value);
+
 
 extern struct stru193_math *stru_5C6E00;
\ No newline at end of file
--- a/Viewport.cpp	Thu May 23 16:36:08 2013 +0600
+++ b/Viewport.cpp	Thu May 23 14:08:26 2013 +0200
@@ -4,6 +4,7 @@
 #include "VectorTypes.h"
 #include "Indoor.h"
 #include "Render.h"
+#include "Math.h"
 #include "mm7_data.h"
 
 
@@ -232,7 +233,7 @@
         {
         indoor_center_x = 0;
         indoor_center_y = 0;
-        uMinimapZoom = dword_576E2C;
+        uMinimapZoom = _576E2C_current_minimap_zoom;
         field_28 = dword_576E28;
         }
     field_2C = 384;
--- a/Vis.cpp	Thu May 23 16:36:08 2013 +0600
+++ b/Vis.cpp	Thu May 23 14:08:26 2013 +0200
@@ -603,6 +603,67 @@
   int v5; // esi@10
   bool v6; // edi@10
   signed int v10; // ebx@14
+  int v15; // [sp+10h] [bp-Ch]@10
+  signed int v16; // [sp+18h] [bp-4h]@10
+
+  int a = 0, b = 0;
+
+  if (IntersectPoint.x < pFace->pBounding.x1 || IntersectPoint.x > pFace->pBounding.x2 ||
+      IntersectPoint.y < pFace->pBounding.y1 || IntersectPoint.y > pFace->pBounding.y2 ||
+      IntersectPoint.z < pFace->pBounding.z1 || IntersectPoint.z > pFace->pBounding.z2 )
+    return false;
+
+  pFace->uAttributes |= 0x80000000;
+
+  if (uModelID != -1)
+    ODM_CreateIntersectFacesVertexCoordList(&a, &b, intersect_face_vertex_coords_list_a, intersect_face_vertex_coords_list_b,
+                                &IntersectPoint, pFace, uModelID);
+  else
+    BLV_CreateIntersectFacesVertexCoordList(&a, &b, intersect_face_vertex_coords_list_a, intersect_face_vertex_coords_list_b,
+                                  &IntersectPoint, pFace);
+  v5 = 2 * pFace->uNumVertices;
+  v16 = 0;
+  intersect_face_vertex_coords_list_a[v5] = intersect_face_vertex_coords_list_a[0];
+  intersect_face_vertex_coords_list_b[v5] = intersect_face_vertex_coords_list_b[0];
+  v6 = intersect_face_vertex_coords_list_b[0] >= b;
+  if (v5 <= 0)
+    return false;
+  for ( uint i = 0; i < v5; ++i )
+  {
+    if ( v16 >= 2 )
+      break;
+    if ( v6 ^ intersect_face_vertex_coords_list_b[i + 1] >= b )
+    {
+      if ( intersect_face_vertex_coords_list_a[i + 1] >= a )
+        v10 = 0;
+      else
+        v10 = 2;
+      v10 |= intersect_face_vertex_coords_list_a[i] < a ? 1 : 0;
+      if ( v10 != 3 )
+      {
+        if ( !v10)
+          ++v16;
+        else
+        {
+          int _v1 = fixpoint_div(intersect_face_vertex_coords_list_a[i + 1] - intersect_face_vertex_coords_list_a[i],
+                                 intersect_face_vertex_coords_list_b[i + 1] - intersect_face_vertex_coords_list_b[i]);
+          int _v2 = fixpoint_mul(b - intersect_face_vertex_coords_list_b[i], _v1) + 32768;
+
+          if (intersect_face_vertex_coords_list_a[i] + (_v2 >> 16) >= a)
+            ++v16;
+        }
+      }
+    }
+    v6 = intersect_face_vertex_coords_list_b[i + 1] >= b;
+  }
+
+  if ( v16 != 1 )
+    return false;
+  return true;
+/*
+  int v5; // esi@10
+  bool v6; // edi@10
+  signed int v10; // ebx@14
   int v11; // edi@16
   signed int v12; // ST28_4@18
   signed __int64 v13; // qtt@18
@@ -661,6 +722,7 @@
   if ( v16 != 1 )
     result = false;
   return result;
+}*/
 }
 
 //----- (004C1EE5) --------------------------------------------------------
--- a/mm7_2.cpp	Thu May 23 16:36:08 2013 +0600
+++ b/mm7_2.cpp	Thu May 23 14:08:26 2013 +0200
@@ -9173,7 +9173,7 @@
     }
 
   Initialize_GamesLOD_NewLOD();
-  dword_576E2C = 512;
+  _576E2C_current_minimap_zoom = 512;
   dword_576E28 = 9;
 }
 
--- a/mm7_5.cpp	Thu May 23 16:36:08 2013 +0600
+++ b/mm7_5.cpp	Thu May 23 14:08:26 2013 +0200
@@ -3169,13 +3169,13 @@
           v119 = 2048;
           if ( (signed int)v118 <= 2048 )
           {
-            dword_576E2C = v118;
+            _576E2C_current_minimap_zoom = v118;
             dword_576E28 = viewparams->field_28;
             break;
           }
           viewparams->field_28 = 11;
           viewparams->uMinimapZoom = v119;
-          dword_576E2C = v119;
+          _576E2C_current_minimap_zoom = v119;
           dword_576E28 = viewparams->field_28;
           break;
         case UIMSG_ClickZoomInBtn:
@@ -3196,7 +3196,7 @@
               v118 = v119;
               viewparams->uMinimapZoom = v119;
             }
-            dword_576E2C = v118;
+            _576E2C_current_minimap_zoom = v118;
             dword_576E28 = viewparams->field_28;
           }
           else
--- a/mm7_data.cpp	Thu May 23 16:36:08 2013 +0600
+++ b/mm7_data.cpp	Thu May 23 14:08:26 2013 +0200
@@ -1280,7 +1280,7 @@
 unsigned int uIconIdx_FlySpell;
 unsigned int uIconIdx_WaterWalk;
 int dword_576E28; // weak
-int dword_576E2C; // weak
+int _576E2C_current_minimap_zoom; // weak
 __int64 _5773B8_event_timer; // weak
 int _5773C0_unused; // weak
 
--- a/mm7_data.h	Thu May 23 16:36:08 2013 +0600
+++ b/mm7_data.h	Thu May 23 14:08:26 2013 +0200
@@ -773,7 +773,7 @@
 extern unsigned int uIconIdx_FlySpell;
 extern unsigned int uIconIdx_WaterWalk;
 extern int dword_576E28; // weak
-extern int dword_576E2C; // weak
+extern int _576E2C_current_minimap_zoom; // weak
 extern __int64 _5773B8_event_timer; // weak
 extern int _5773C0_unused; // weak
 
@@ -1690,11 +1690,6 @@
 signed int __fastcall SpawnRandomTreasure(struct MapInfo *a1, struct SpawnPointMM7 *a2);
 void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, struct Vec3_int_ *pVelocity);
 
-int fixpoint_sub0(int, int);
-int fixpoint_div(int, int);
-int fixpoint_mul(int, int);
-int fixpoint_from_float(float value);
-
 
 #define ErrD3D(hr) do {extern void ErrHR(HRESULT, const char *, const char *, const char *, int); ErrHR(hr, "Direct3D", __FUNCTION__, __FILE__, __LINE__);} while(0)
 
--- a/stru6.cpp	Thu May 23 16:36:08 2013 +0600
+++ b/stru6.cpp	Thu May 23 14:08:26 2013 +0200
@@ -19,6 +19,7 @@
 #include "PaletteManager.h"
 #include "Overlays.h"
 #include "stru160.h"
+#include "Math.h"
 
 #include "MM7.h"