Advertisement
fastman92

CPathFind::FindNodeClosestInRegion

Apr 3rd, 2015
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.20 KB | None | 0 0
  1. void __thiscall CPathFind::FindNodeClosestInRegion(CPathFind *this, int a2, unsigned __int16 region, float a4, float a5, float a6, int pathType, float *a8, char a9, char a10, char a11, int a12)
  2. {
  3.   CPathFind *v12; // esi@1
  4.   int i; // eax@4
  5.   int v14; // ebp@7
  6.   float *v15; // edi@8
  7.   int v16; // eax@8
  8.   CPathNode *v17; // ecx@9
  9.   float v18; // ST24_4@14
  10.   long double v19; // fst7@14
  11.   long double v20; // fst7@15
  12.   int v21; // [sp+0h] [bp-10h]@8
  13.   float a8a; // [sp+2Ch] [bp+1Ch]@15
  14.  
  15.   v12 = this;
  16.   if ( this->m_pPathNodes[region] )
  17.   {
  18.     if ( (_BYTE)pathType )
  19.     {
  20.       if ( (unsigned __int8)pathType == 1 )
  21.       {
  22.         i = this->NumVehicleNodes[region];      // start
  23.         pathType = this->NumNodes[region];      // end
  24.       }
  25.       else
  26.       {
  27.         i = pathType;                           // wrong option - loop will be terminated
  28.       }
  29.     }
  30.     else
  31.     {
  32.       // Scan vehicle nodes.
  33.       i = 0;                                    // start
  34.       pathType = this->NumVehicleNodes[region]; // end
  35.     }
  36.     v14 = i;
  37.     if ( i < pathType )
  38.     {
  39.       v15 = a8;
  40.       v16 = 28 * i;
  41.       v21 = v16;
  42.       do
  43.       {
  44.         v17 = (CPathNode *)((char *)v12->m_pPathNodes[region] + v16);
  45.         if ( (!a9 || !(v17->m_dwFlags[0] & 0x20)) && (!a10 || !(v17->m_dwFlags[1] & 2)) )
  46.         {
  47.           if ( a11 == (unsigned __int8)v17->m_dwFlags[0] >> 7 )
  48.           {
  49.             v18 = (long double)v17->m_posn.x * 0.125;
  50.             v19 = (fabs((long double)v17->m_posn.z * 0.125 - a6) * 3.0
  51.                  + fabs((long double)v17->m_posn.y * 0.125 - a5)
  52.                  + fabs(v18 - a4))
  53.                 * 0.30000001;
  54.             if ( v19 < *v15 )
  55.             {
  56.               a8a = v19;
  57.               v20 = CPathFind::CalcDistToAnyConnectingLinks(v12, v17, SLODWORD(a4), SLODWORD(a5), SLODWORD(a6)) * 0.2
  58.                   + a8a;
  59.               if ( v20 < *v15 )
  60.               {
  61.                 *v15 = v20;
  62.                 *(_WORD *)a2 = region;
  63.                 *(_WORD *)(a2 + 2) = v14;
  64.               }
  65.             }
  66.           }
  67.         }
  68.         ++v14;
  69.         v16 = v21 + 28;
  70.         v21 += 28;
  71.       }
  72.       while ( v14 < pathType );
  73.     }
  74.   }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement