changeset 830:08d90b633131

some BLV floor collisions
author Nomad
date Wed, 27 Mar 2013 11:59:37 +0200
parents d5b1870df3ab
children 9c3f28b31b4a
files Indoor.cpp mm7_4.cpp mm7_6.cpp
diffstat 3 files changed, 58 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Wed Mar 27 00:28:45 2013 +0200
+++ b/Indoor.cpp	Wed Mar 27 11:59:37 2013 +0200
@@ -1291,6 +1291,7 @@
   //v39 = &pIndoor->pFaces[uFaceID];
 
   auto pFace = &pIndoor->pFaces[uFaceID];
+  auto p = &nodes[node_id];
 
   if (!pFace->Portal())
   {
@@ -1302,9 +1303,8 @@
     return;
   }
 
-    auto p = &nodes[node_id];
-    //v6 = (int)((char *)this + 2252 * a2);
-    //a0 = v6;
+
+
     if (p->uFaceID == uFaceID)
       return;
     if (!node_id &&
@@ -1316,8 +1316,8 @@
         pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 )
     {
       if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x
-                                       + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y
-                                       + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane
+                                          + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y
+                                          + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane
       {
         v7 = pFace->uSectorID;
         if ( nodes[0].uSectorID == v7 )  // draw back sector
@@ -1328,11 +1328,11 @@
         nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ;
         nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY;
         nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW;
-        nodes[num_nodes++].field_C._43F9E1(pBLVRenderParams->uViewportX,
-                                           pBLVRenderParams->uViewportY,
-                                           pBLVRenderParams->uViewportZ,
-                                           pBLVRenderParams->uViewportW);
-        AddBspNodeToRenderList(num_nodes - 1);
+        nodes[num_nodes].field_C._43F9E1(pBLVRenderParams->uViewportX,
+                                         pBLVRenderParams->uViewportY,
+                                         pBLVRenderParams->uViewportZ,
+                                         pBLVRenderParams->uViewportW);
+        AddBspNodeToRenderList(++num_nodes - 1);
         return;
       }
       //v5 = v39;
@@ -1368,40 +1368,7 @@
       if (face_max_screenspace_y < _50B9D8_screen_space_y[i])
         face_max_screenspace_y = _50B9D8_screen_space_y[i];
     }
-      //v10 = sub_423B5D(uFaceID);
-      //v34 = v10;
-      //if ( v10 )
-      //{
-       /* v11 = _50BAC8_screen_space_x[0];
-        v12 = _50B9D8_screen_space_y[0];
-        a2 = _50BAC8_screen_space_x[0];
-        v13 = 1;
-        v37 = _50B9D8_screen_space_y[0];
-        if ( v10 > 1 )
-        {
-          do
-          {
-            v14 = _50BAC8_screen_space_x[v13];
-            if ( v14 < a2 )
-              a2 = _50BAC8_screen_space_x[v13];
-            if ( v14 > v11 )
-              v11 = v14;
-            v15 = _50B9D8_screen_space_y[v13];
-            if ( v15 < v37 )
-              v37 = _50B9D8_screen_space_y[v13];
-            if ( v15 > v12 )
-              v12 = _50B9D8_screen_space_y[v13];
-            v10 = v34;
-            ++v13;
-          }
-          while ( v13 < v34 );
-        }
-        //v16 = a0;
-        if (v11 >= p->uViewportX &&
-            a2 <= p->uViewportZ &&
-            v12 >= p->uViewportY &&
-            v37 <= p->uViewportW &&
-            sub_424829(v10, &nodes[num_nodes].field_C, &p->field_C, uFaceID))*/
+
       if (face_max_screenspace_x >= p->uViewportX &&
           face_min_screenspace_x <= p->uViewportZ &&
           face_max_screenspace_y >= p->uViewportY &&
--- a/mm7_4.cpp	Wed Mar 27 00:28:45 2013 +0200
+++ b/mm7_4.cpp	Wed Mar 27 11:59:37 2013 +0200
@@ -236,12 +236,12 @@
   signed int v28; // eax@45
   int v29; // ebx@47
   int v30; // edx@49
-  int v31; // ST10_4@49
-  signed int v32; // edx@49
+  //int v31; // ST10_4@49
+  //signed int v32; // edx@49
   signed __int64 v33; // qtt@49
-  signed int v34; // eax@54
-  signed int v35; // esi@56
-  int result; // eax@57
+  //signed int v34; // eax@54
+  //signed int v35; // esi@56
+  //int result; // eax@57
   int v38; // edx@62
   //int v44; // [sp+20h] [bp-20h]@10
   bool v47; // [sp+24h] [bp-1Ch]@43
@@ -343,6 +343,9 @@
       if (portal->uPolygonType != POLYGON_Floor)
         continue;
 
+      if (!portal->uNumVertices)
+        continue;
+
       if (x <= portal->pBounding.x2 && x >= portal->pBounding.x1 &&
           y <= portal->pBounding.y2 && y >= portal->pBounding.y1 )
       {
@@ -356,45 +359,40 @@
         word_721460_xs[2 * portal->uNumVertices] = word_721460_xs[0];
         word_721390_ys[2 * portal->uNumVertices] = word_721390_ys[0];
         v54 = 0;
-        v49 = word_721390_ys[0] >= y;
-        if ( portal->uNumVertices > 0 )
-        {
-          for ( int i = 0; i < 2 * portal->uNumVertices; ++i )
+        v47 = word_721390_ys[0] >= y;
+
+          for (uint j = 0; j < 2 * portal->uNumVertices; ++j)
           {
+            v49 = v47;
             if ( v54 >= 2 )
               break;
-            v47 = word_721390_ys[i + 1] >= y;
+            v47 = word_721390_ys[j + 1] >= y;
             if ( v49 != v47 )
             {
-              v28 = word_721460_xs[i + 1] >= x ? 0 : 2;
-              v29 = v28 | word_721460_xs[i] < x;
+              v28 = word_721460_xs[j + 1] >= x ? 0 : 2;
+              v29 = v28 | (word_721460_xs[j] < x);
               if ( v29 != 3 )
               {
                 if ( !v29 )
                   ++v54;
                 else
                 {
-                  //v30 = word_721390_ys[v27];
-                  v31 = word_721390_ys[i + 1] - word_721390_ys[i];
-                  v32 = y - word_721390_ys[i];
-                  LODWORD(v33) = v32 << 16;
-                  HIDWORD(v33) = v32 >> 16;
-                  if ((signed int)(((unsigned __int64)(((signed int)word_721460_xs[i + 1] - (signed int)word_721460_xs[i]) * v33 / v31) >> 16) + word_721460_xs[i]) >= x)
+                  auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]);
+                  auto res = fixpoint_mul(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b);
+                  if (res + word_721460_xs[j] >= x)
                     ++v54;
                 }
               }
             }
-            v49 = v47;
           }
           if ( v54 == 1 )
           {
             if ( v55 >= 50 )
               break;
-            v34 = v55++;
-            blv_floor_level[v34] = -29000;
-            blv_floor_id[v34] = pSector->pPortals[i];
+            blv_floor_level[v55] = -29000;
+            blv_floor_id[v55] = pSector->pPortals[i];
+            v55++;
           }
-        }
       }
     }
   }
@@ -407,9 +405,8 @@
     return -30000;
   *pFaceID = blv_floor_id[0];
   //result = blv_floor_level[0];
-  if ( v55 > 1 )
-  {
-    for ( v35 = 1; v35 < v55; ++v35 )
+
+    /*for ( v35 = 1; v35 < v55; ++v35 )
     {
       if ( blv_floor_level[0] <= z + 5 )
       {
@@ -424,9 +421,29 @@
         blv_floor_level[0] = blv_floor_level[v35];
         *pFaceID = blv_floor_id[v35];
       }
-    }
-  }
-  return blv_floor_level[0];
+    }*/
+
+    
+  int result = blv_floor_level[0];
+  for (uint i = 1; i < v55; ++i)
+  {
+      v38 = blv_floor_level[i];
+      if ( result <= z + 5 )
+      {
+        if ( v38 > result && v38 <= z + 5 )
+        {
+          result = blv_floor_level[i];
+          *pFaceID = blv_floor_id[i];
+        }
+      }
+      else if ( v38 < result )
+      {
+        result = blv_floor_level[i];
+        *pFaceID = blv_floor_id[i];
+      }
+  }
+
+  return result;
 }
 
 //----- (0046D49E) --------------------------------------------------------
--- a/mm7_6.cpp	Wed Mar 27 00:28:45 2013 +0200
+++ b/mm7_6.cpp	Wed Mar 27 11:59:37 2013 +0200
@@ -3248,7 +3248,7 @@
     {
       if (PID_TYPE(a2) == OBJECT_Actor)
       {
-        memcpy(&v715, Actor::GetDirectionInfo(PID(OBJECT_Player, v3->uPlayerID + 8), a2, &a3, 0), sizeof(v715));
+        memcpy(&v715, Actor::GetDirectionInfo(PID(OBJECT_Player, v3->uPlayerID + 1), a2, &a3, 0), sizeof(v715));
         v2 = v723;
       }
       else