diff Viewport.cpp @ 711:a5e587c8e30e

some cleaning
author Gloval
date Thu, 21 Mar 2013 23:10:57 +0400
parents e0a1fccc89b1
children cf2fbac6edc9
line wrap: on
line diff
--- a/Viewport.cpp	Thu Mar 21 12:37:49 2013 +0200
+++ b/Viewport.cpp	Thu Mar 21 23:10:57 2013 +0400
@@ -14,7 +14,6 @@
     unsigned int br_x; // esi@1
     unsigned int tl_y; // edi@3
     unsigned int br_y; // eax@3
-    int v10; // eax@7
 
     tl_x = sTL_X;
     br_x = sBR_X;
@@ -25,7 +24,7 @@
         }
     tl_y = sTL_Y;
     br_y = sBR_Y;
-    if ( (signed int)sTL_Y > (signed int)sBR_Y )
+    if ( sTL_Y > sBR_Y )
         {
         br_y = sBR_Y ^ sTL_Y ^ sBR_Y;                           // swap y's 
         tl_y = br_y ^ sBR_Y ^ sTL_Y;
@@ -150,13 +149,13 @@
 
 
     v1 = this;
-    v2 = this->field_3A;
+    v2 = this->indoor_center_y;
     v3 = 88 >> this->field_2C / 384;
     v4 = (44 - v3) << 9;
     if ( v1->sViewCenterY > v2 + v4 )
         v1->sViewCenterY = v2 + v4;
 
-    v5 = v1->field_38;
+    v5 = v1->indoor_center_x;
     v6 = (v3 - 44) << 9;
     if ( v1->sViewCenterX < v5 + v6 )
         v1->sViewCenterX = v5 + v6;
@@ -179,80 +178,60 @@
 //----- (00443365) --------------------------------------------------------
 void ViewingParams::_443365()
     {
-    ViewingParams *v1; // esi@1
-    __int16 *v2; // edi@3
+  
     Vec3_short_ *v3; // eax@4
-    unsigned int v4; // edx@4
-    signed int v5; // eax@8
     Vec3_short_ *v6; // eax@12
-    signed int v7; // edi@12
-    signed int v8; // eax@16
-    char v9; // zf@20
-    int result; // eax@21
-    unsigned int v11; // [sp+4h] [bp-1Ch]@3
-    unsigned int *v12; // [sp+8h] [bp-18h]@3
-    unsigned int v13; // [sp+Ch] [bp-14h]@8
-    unsigned int v14; // [sp+10h] [bp-10h]@2
-    unsigned int v15; // [sp+14h] [bp-Ch]@2
-    unsigned int v16; // [sp+18h] [bp-8h]@2
-    unsigned int v17; // [sp+1Ch] [bp-4h]@2
+    int minimum_y; // [sp+10h] [bp-10h]@2
+    int maximum_y; // [sp+14h] [bp-Ch]@2
+    int minimum_x; // [sp+18h] [bp-8h]@2
+     int maximum_x; // [sp+1Ch] [bp-4h]@2
 
-    v1 = this;
+ 
     InitGrayPalette();
     if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
         {
-        v16 = 0x40000000u;
-        v14 = 0x40000000u;
-        v17 = 0xC0000000u;
-        v15 = 0xC0000000u;
-        if ( (signed int)pIndoor->pMapOutlines->uNumOutlines > 0 )
+        minimum_x = 0x40000000;
+        minimum_y = 0x40000000;
+
+        maximum_x = -0x40000000;
+        maximum_y = -0x40000000;
+        for (int i=0; i<pIndoor->pMapOutlines->uNumOutlines; ++i)
             {
-            v2 = (__int16 *)(pIndoor->pMapOutlines->pOutlines);
-            v11 = pIndoor->pMapOutlines->uNumOutlines;
-            v12 = (uint *)pIndoor->pMapOutlines->pOutlines;
-            do
-                {
-                v3 = &pIndoor->pVertices[*v2];
-                v4 = v3->x;
-                if ( (signed int)v4 < (signed int)v16 )
-                    v16 = v3->x;
-                if ( (signed int)v4 > (signed int)v17 )
-                    v17 = v3->x;
-                v5 = v3->y;
-                v13 = v5;
-                if ( v5 < (signed int)v14 )
-                    v14 = v4;
-                if ( v5 > (signed int)v15 )
-                    v15 = v4;
-                v6 = &pIndoor->pVertices[v2[1]];
-                v7 = v6->x;
-                if ( v7 < (signed int)v16 )
-                    v16 = v4;
-                if ( v7 > (signed int)v17 )
-                    v17 = v4;
-                v8 = v6->y;
-                if ( v8 < (signed int)v14 )
-                    v14 = v13;
-                if ( v8 > (signed int)v15 )
-                    v15 = v13;
-                v2 = (__int16 *)(v12 + 3);
-                v9 = v11-- == 1;
-                v12 += 3;
-                }
-                while ( !v9 );
+            v3 = &pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uFace1ID];
+
+            if ( v3->x < minimum_x )
+                minimum_x = v3->x;
+            if ( v3->x > maximum_x )
+                maximum_x = v3->x;
+            if ( v3->y < minimum_y )
+                minimum_y = v3->x;
+            if ( v3->y > maximum_y )
+                maximum_y = v3->x;
+
+            v6 = &pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uFace2ID];
+
+            if ( v6->x < minimum_x )
+                minimum_x = v3->x;
+            if ( v6->x > maximum_x )
+                maximum_x = v3->x;
+ 
+            if ( v6->y < minimum_y )
+                minimum_y = v3->y;
+            if ( v6->y > maximum_y )
+                maximum_y = v3->y;
             }
-        v1->uMinimapZoom = 1024;
-        v1->field_38 = (signed int)(v16 + v17) / 2;
-        v1->field_28 = 10;
-        result = (signed int)(v14 + v15) / 2;
-        v1->field_3A = result;
+
+        uMinimapZoom = 1024;
+        indoor_center_x = (signed int)(minimum_x + maximum_x) / 2;
+        field_28 = 10;
+        indoor_center_y = (signed int)(minimum_y + maximum_y) / 2;
         }
     else
         {
-        v1->field_38 = 0;
-        v1->field_3A = 0;
-        v1->uMinimapZoom = dword_576E2C;
-        v1->field_28 = dword_576E28;
+        indoor_center_x = 0;
+        indoor_center_y = 0;
+        uMinimapZoom = dword_576E2C;
+        field_28 = dword_576E28;
         }
-    v1->field_2C = 384;
+    field_2C = 384;
     }
\ No newline at end of file