changeset 1173:0158f383b492

m
author Ritor1
date Fri, 31 May 2013 09:54:33 +0600
parents d5dae0b4b98a
children 05247ad19710
files Vis.cpp
diffstat 1 files changed, 48 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/Vis.cpp	Fri May 24 10:53:46 2013 +0600
+++ b/Vis.cpp	Fri May 31 09:54:33 2013 +0600
@@ -27,7 +27,7 @@
 
 
 //----- (004C1026) --------------------------------------------------------
-Vis_ObjectInfo *Vis::DetermineFacetIntersection(BLVFace *face, unsigned int a3, float pick_depth)
+Vis_ObjectInfo *Vis::DetermineFacetIntersection(BLVFace *face, unsigned int pid, float pick_depth)
 {
   char *v4; // eax@4
   signed int v5; // ecx@4
@@ -60,7 +60,7 @@
   }
   else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
   {
-    uint bmodel_id = a3 >> 9;
+    uint bmodel_id = pid >> 9;
     auto v = (Vec3_int_ *)pOutdoor->pBModels[bmodel_id].pVertices.pVertices;
     for (uint i = 0; i < face->uNumVertices; ++i)
     {
@@ -97,7 +97,7 @@
   if (!SelectionFacetIntersectionList.uNumPointers)
     return nullptr;
 
-  if (!SelectionFacetIntersectionList.sub_4C2551(2, a3))
+  if (!SelectionFacetIntersectionList.sub_4C2551(VisObjectType_Face, pid))
     return nullptr;
 
   if (SelectionFacetIntersectionList.uNumPointers)
@@ -899,30 +899,39 @@
 }
 
 //----- (004C2551) --------------------------------------------------------
-Vis_ObjectInfo *Vis_SelectionList::sub_4C2551(int a2, int a3)
+Vis_ObjectInfo *Vis_SelectionList::sub_4C2551(int pVisObjectType, int pid)
 {
   //unsigned int v3; // esi@1
-  signed int v4; // edx@1
-  char *v5; // eax@2
-  Vis_ObjectInfo *result; // eax@6
+  //signed int v4; // edx@1
+  //char *v5; // eax@2
+  //Vis_ObjectInfo *result; // eax@6
 
   //v3 = this->uNumPointers;
-  v4 = 0;
+  if ( this->uNumPointers > 0 )
+  {
+    for ( uint i = 0; i < this->uNumPointers; ++i )
+    {
+      if ( this->object_pool[i].object_type == pVisObjectType && (this->object_pool[i].sZValue & 0xFFFF) == pid )
+        return &this->object_pool[i];
+    }
+  }
+  return false;
+  /*v4 = 0;
   if ( this->uNumPointers <= 0 )
     return false;
   else
   {
-    v5 = (char *)&this->object_pool[0].sZValue;
-    while ( *((int *)v5 + 1) != a2 || (*(int *)v5 & 0xFFFF) != a3 )
+    //v5 = (char *)&this->object_pool[0].sZValue;
+    while ( this->object_pool[v4].object_type != a2 || (this->object_pool[v4].sZValue & 0xFFFF) != a3 )
     {
       ++v4;
-      v5 += 12;
+      //v5 += 12;
       if ( v4 >= this->uNumPointers )
        return false;
     }
     result = &this->object_pool[v4];
   }
-  return result;
+  return result;*/
 }
 
 //----- (004C2591) --------------------------------------------------------
@@ -966,58 +975,62 @@
 //----- (004C264A) --------------------------------------------------------
 void Vis::sort_object_pointers(Vis_ObjectInfo **pPointers, int left, int right)
 {
-  int v4; // edx@1
-  int v5; // ebx@1
+  //int v4; // edx@1
+  //int v5; // ebx@1
   int v6; // esi@2
   signed int i; // ecx@2
   int v8; // eax@3
-  int v9; // ebx@4
+  //int v9; // ebx@4
   int v10; // ebx@6
   Vis_ObjectInfo *v11; // eax@7
-  Vis *thisa; // [sp+4h] [bp-4h]@1
+  //Vis *thisa; // [sp+4h] [bp-4h]@1
   Vis_ObjectInfo *a3a; // [sp+14h] [bp+Ch]@2
 
-  v4 = left;
-  v5 = right;
-  thisa = this;
-  if ( right > left )
+  //v4 = left;
+  //v5 = right;
+  //thisa = this;
+  if ( right > left )//left == 0
   {
-    do
+    //do
+    for ( left; right > left; ++left )
     {
-      v6 = v4 - 1;
-      a3a = pPointers[v5];
-      for ( i = v5; ; pPointers[i] = v11 )
+      v6 = left;
+      //a3a = pPointers[right];
+      for ( i = right; ; pPointers[i] = v11 )
       {
         v8 = a3a->sZValue;
         LOWORD(v8) = 0;
-        do
+
+        //do
+        while ( pPointers[v6]->sZValue < pPointers[right]->sZValue );
         {
           ++v6;
-          v9 = pPointers[v6]->sZValue;
-          LOWORD(v9) = 0;
+          //v9 = pPointers[v6]->sZValue;
+          //LOWORD(v9) = 0;
         }
-        while ( v9 < (unsigned int)v8 );
+
         do
         {
           if ( i < 1 )
             break;
           --i;
-          v10 = pPointers[i]->sZValue;
-          LOWORD(v10) = 0;
+          //v10 = pPointers[i]->sZValue;
+          //LOWORD(v10) = 0;
         }
-        while ( v10 > (unsigned int)v8 );
+        while ( pPointers[i]->sZValue > pPointers[right]->sZValue );
+
         v11 = pPointers[v6];
         if ( v6 >= i )
           break;
         pPointers[v6] = pPointers[i];
       }
-      v5 = right;
+      //v5 = right;
       pPointers[v6] = pPointers[right];
       pPointers[right] = v11;
-      sort_object_pointers(pPointers, v4, v6 - 1);
-      v4 = v6 + 1;
+      sort_object_pointers(pPointers, left, v6 - 1);
+      //left = v6 + 1;
     }
-    while ( right > v6 + 1 );
+    //while ( right > left );
   }
 }