diff mm7_5.cpp @ 49:25fabc49627b

Слияние
author Ritor1
date Tue, 23 Oct 2012 17:34:20 +0600
parents 6a62c4005f0e 79a30ee1ecdb
children 4211cceb3813 c28452924144 38025d9ab757
line wrap: on
line diff
--- a/mm7_5.cpp	Tue Oct 23 17:33:33 2012 +0600
+++ b/mm7_5.cpp	Tue Oct 23 17:34:20 2012 +0600
@@ -8957,120 +8957,79 @@
 
 
 //----- (0043F333) --------------------------------------------------------
-int stru170::RenderWalls()
-{
-  signed int result; // eax@1
-  unsigned __int8 v2; // zf@1
-  unsigned __int8 v3; // sf@1
-  stru170_stru0 *v4; // edx@2
-  int v5; // eax@3
+void stru170::RenderWalls()
+{
   int v6; // ebx@3
-  char *v7; // esi@4
-  signed int v8; // [sp+0h] [bp-4h]@1
-
-  result = 0;
-  v2 = this->std__vector_000FA8 == 0;
-  v3 = (this->std__vector_000FA8 & 0x80000000u) != 0;
-  this->field_53730 = 0;
-  v8 = 0;
-  if ( !(v3 | v2) )
-  {
-    v4 = this->field_FA8;
-    do
-    {
-      v5 = this->field_53730;
+
+  field_53730 = 0;
+  for (uint i = 0; i < std__vector_000FA8; ++i)
+  {
       v6 = 0;
-      if ( v5 <= 0 )
+      if (!field_53730)
       {
 LABEL_7:
-        this->pSectorIDs_toDrawDecorationsFrom[v5] = v4->uSectorID;
-        ++this->field_53730;
+        pSectorIDs_toDrawDecorationsFrom[field_53730++] = field_FA8[i].uSectorID;
       }
       else
       {
-        v7 = (char *)this->pSectorIDs_toDrawDecorationsFrom;
-        while ( *(short *)v7 != v4->uSectorID )
+        while (pSectorIDs_toDrawDecorationsFrom[v6] != field_FA8[i].uSectorID )
         {
           ++v6;
-          v7 += 2;
-          if ( v6 >= v5 )
-            goto LABEL_7;
-        }
-      }
-      ++v8;
-      ++v4;
-      result = v8;
-    }
-    while ( v8 < (signed int)this->std__vector_000FA8 );
-  }
-  return result;
+          if ( v6 >= field_53730)
+          {
+            pSectorIDs_toDrawDecorationsFrom[field_53730++] = field_FA8[i].uSectorID;
+            continue;
+          }
+        }
+      }
+  }
 }
 
 
 //----- (0043F515) --------------------------------------------------------
-void __cdecl MessWithBillboards_BLV()
-{
-  signed int v0; // edi@1
-  char *v1; // esi@2
-
-  v0 = 0;
-  if ( (signed int)uNumBillboardsToDraw > 0 )
-  {
-    v1 = (char *)&pBillboardRenderList[0].field_2A;
-    do
-    {
-      if ( *(v1 - 12) & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !*((short *)v1 - 7) )
-        *(short *)v1 = 0;
-      else
-        *(short *)v1 = sub_43F55F((RenderBillboard *)(v1 - 42), -1);
-      ++v0;
-      v1 += 52;
-    }
-    while ( v0 < (signed int)uNumBillboardsToDraw );
+void MessWithBillboards_BLV()
+{
+  for (uint i = 0; i < uNumBillboardsToDraw; ++i)
+  {
+    auto p = pBillboardRenderList + i;
+
+    if (p->field_1E & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !p->uIndoorSectorID)
+      p->uPaletteSubindex = 0;
+    else
+      p->uPaletteSubindex = _43F55F_get_billboard_light_level(p, -1);
   }
 }
 
 //----- (0043F55F) --------------------------------------------------------
-signed int __fastcall sub_43F55F(RenderBillboard *a1, signed int a2)
-{
-  RenderBillboard *v2; // eax@1
+int __fastcall _43F55F_get_billboard_light_level(RenderBillboard *a1, int uBaseLightLevel)
+{
   signed int v3; // ecx@2
-  float v4; // ST08_4@6
-  float v5; // ST04_4@6
-  float v6; // ST00_4@6
-
-  v2 = a1;
+
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
     v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel;
   }
   else
   {
-    if ( a2 == -1 )
-      v3 = a1->field_2A;
+    if ( uBaseLightLevel == -1 )
+      v3 = a1->uPaletteSubindex;
     else
-      v3 = a2;
-  }
-  v4 = (double)v2->field_24;
-  v5 = (double)v2->field_22;
-  v6 = (double)v2->field_20;
-  return sub_43F5C8(v3, v2->uIndoorSectorID, v6, v5, v4);
+      v3 = uBaseLightLevel;
+  }
+  return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->some_x, a1->some_y, a1->some_z);
 }
 
 //----- (0043F5C8) --------------------------------------------------------
-signed int __fastcall sub_43F5C8(signed int a1, int a2, float a3, float a4, float a5)
+int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z)
 {
   int v5; // esi@1
   signed int v6; // edi@1
-  char *v7; // ebx@2
   int v8; // eax@6
   int v9; // ebx@6
   unsigned int v10; // ecx@6
   unsigned int v11; // edx@9
   unsigned int v12; // edx@11
   signed int v13; // ecx@12
-  BLVSector *v14; // esi@17
-  int v15; // ecx@17
   BLVLightMM7 *v16; // esi@20
   int v17; // ebx@21
   int v18; // eax@24
@@ -9080,7 +9039,6 @@
   unsigned int v22; // edx@27
   unsigned int v23; // edx@29
   signed int v24; // ecx@30
-  char *v25; // esi@34
   int v26; // ebx@35
   int v27; // eax@38
   int v28; // ebx@38
@@ -9089,53 +9047,41 @@
   unsigned int v31; // edx@41
   unsigned int v32; // edx@43
   signed int v33; // ecx@44
-  int v35; // [sp+Ch] [bp-18h]@4
-  BLVSector *v36; // [sp+Ch] [bp-18h]@17
   int v37; // [sp+Ch] [bp-18h]@37
   int v38; // [sp+10h] [bp-14h]@5
   int v39; // [sp+10h] [bp-14h]@23
   int v40; // [sp+10h] [bp-14h]@36
-  int v41; // [sp+14h] [bp-10h]@3
   int v42; // [sp+14h] [bp-10h]@22
   unsigned int v43; // [sp+18h] [bp-Ch]@12
   unsigned int v44; // [sp+18h] [bp-Ch]@30
   unsigned int v45; // [sp+18h] [bp-Ch]@44
-  char *v46; // [sp+1Ch] [bp-8h]@2
-  int v47; // [sp+1Ch] [bp-8h]@17
-  int v48; // [sp+20h] [bp-4h]@1
-  int v49; // [sp+20h] [bp-4h]@17
-  int v50; // [sp+20h] [bp-4h]@33
-
-  v48 = 0;
-  v5 = a2;
-  v6 = a1;
-  if ( uNumMobileLightsApplied > 0 )
-  {
-    v7 = (char *)&pMobileLights[0].uRadius;
-    v46 = (char *)&pMobileLights[0].uRadius;
-    do
-    {
-      v41 = abs((signed __int64)((double)*((short *)v7 - 3) - a3));
-      if ( v41 <= *(short *)v7 )
-      {
-        v35 = abs((signed __int64)((double)*((short *)v7 - 2) - a4));
-        if ( v35 <= *(short *)v7 )
-        {
-          v38 = abs((signed __int64)((double)*((short *)v7 - 1) - a5));
-          if ( v38 <= *(short *)v7 )
-          {
-            v8 = v41;
-            v9 = v35;
-            v10 = v38;
-            if ( v41 < v35 )
-            {
-              v8 = v35;
-              v9 = v41;
-            }
-            if ( v8 < v38 )
+
+  v6 = uBaseLightLevel;
+  for (uint i = 0; i < uNumMobileLightsApplied; ++i)
+  {
+    auto p = pMobileLights + i;
+
+      auto distX = abs(p->vPosition.x - x);
+      if ( distX <= p->uRadius)
+      {
+        auto distY = abs(p->vPosition.y - y);
+        if ( distY <= p->uRadius)
+        {
+          auto distZ = abs(p->vPosition.z - z);
+          if ( distZ <= p->uRadius)
+          {
+            v8 = distX;
+            v9 = distY;
+            v10 = distZ;
+            if (distX < distY)
+            {
+              v8 = distY;
+              v9 = distX;
+            }
+            if ( v8 < distZ )
             {
               v11 = v8;
-              v8 = v38;
+              v8 = distZ;
               v10 = v11;
             }
             if ( v9 < (signed int)v10 )
@@ -9144,41 +9090,31 @@
               v10 = v9;
               v9 = v12;
             }
-            v43 = ((unsigned int)(11 * v9) >> 5) + (v10 >> 2) + v8;
-            v13 = *(short *)v46;
+            v43 = ((unsigned int)(11 * v9) / 32) + (v10 / 4) + v8;
+            v13 = p->uRadius;
             if ( (signed int)v43 < v13 )
-              v6 = v6 + ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30;
-            v7 = v46;
-          }
-        }
-      }
-      ++v48;
-      v7 += 18;
-      v46 = v7;
-    }
-    while ( v48 < uNumMobileLightsApplied );
-  }
+              v6 += ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30;
+          }
+        }
+      }
+  }
+
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
-    v14 = &pIndoor->pSectors[v5];
-    v15 = 0;
-    v49 = 0;
-    v36 = v14;
-    v47 = v14->uNumLights;
-    if ( v14->uNumLights > 0 )
-    {
-      while ( 1 )
-      {
-        v16 = &pIndoor->pLights[*(&v14->pLights->vPosition.x + v15)];
+    auto pSector = pIndoor->pSectors + uSectorID;
+
+    for (uint i = 0; i < pSector->uNumLights; ++i)
+    {
+        v16 = pIndoor->pLights + *(&pSector->pLights->vPosition.x + i);
         if ( !(v16->uAtributes & 8) )
         {
-          v17 = abs((signed __int64)((double)v16->vPosition.x - a3));
+          v17 = abs(v16->vPosition.x - x);
           if ( v17 <= v16->uRadius )
           {
-            v42 = abs((signed __int64)((double)v16->vPosition.y - a4));
+            v42 = abs(v16->vPosition.y - y);
             if ( v42 <= v16->uRadius )
             {
-              v39 = abs((signed __int64)((double)v16->vPosition.z - a5));
+              v39 = abs(v16->vPosition.z - z);
               if ( v39 <= v16->uRadius )
               {
                 v18 = v17;
@@ -9205,32 +9141,25 @@
                 v44 = ((unsigned int)(11 * v19) >> 5) + (v20 >> 2) + v18;
                 v24 = v16->uRadius;
                 if ( (signed int)v44 < v24 )
-                  v6 = v6 + ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30;
+                  v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30;
               }
             }
           }
         }
-        v15 = v49++ + 1;
-        if ( v49 >= v47 )
-          break;
-        v14 = v36;
-      }
-    }
-  }
-  v50 = 0;
-  if ( uNumStationaryLightsApplied > 0 )
-  {
-    v25 = (char *)&pStationaryLights[0].uRadius;
-    do
-    {
-      v26 = abs((signed __int64)((double)*((short *)v25 - 3) - a3));
-      if ( v26 <= *(short *)v25 )
-      {
-        v40 = abs((signed __int64)((double)*((short *)v25 - 2) - a4));
-        if ( v40 <= *(short *)v25 )
-        {
-          v37 = abs((signed __int64)((double)*((short *)v25 - 1) - a5));
-          if ( v37 <= *(short *)v25 )
+    }
+  }
+
+  for (uint i = 0; i < uNumStationaryLightsApplied; ++i)
+  {
+    auto p = pStationaryLights + i;
+      v26 = abs(p->vPosition.x - x);
+      if ( v26 <= p->uRadius)
+      {
+        v40 = abs(p->vPosition.y - y);
+        if ( v40 <= p->uRadius)
+        {
+          v37 = abs(p->vPosition.z - z);
+          if ( v37 <= p->uRadius)
           {
             v27 = v26;
             v28 = v40;
@@ -9254,17 +9183,14 @@
               v28 = v32;
             }
             v45 = ((unsigned int)(11 * v28) >> 5) + (v29 >> 2) + v27;
-            v33 = *(short *)v25;
+            v33 = p->uRadius;
             if ( (signed int)v45 < v33 )
-              v6 = v6 + ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / v33) >> 16) - 30;
-          }
-        }
-      }
-      ++v50;
-      v25 += 12;
-    }
-    while ( v50 < uNumStationaryLightsApplied );
-  }
+              v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / v33) >> 16) - 30;
+          }
+        }
+      }
+  }
+
   if ( v6 <= 31 )
   {
     if ( v6 < 0 )
@@ -9276,7 +9202,6 @@
   }
   return v6;
 }
-// 519AB4: using guessed type int uNumStationaryLightsApplied;
 
 //----- (00406051) --------------------------------------------------------
 __int16 stru262_TurnBased::StartTurn()
@@ -9483,7 +9408,7 @@
         if ( (signed __int16)v6 == 4 )
         {
           v3 = 0;
-          v5->uAIState = 5;
+          v5->uAIState = Dead;
           v5->uCurrentActionTime = 0;
           v5->uCurrentActionLength = 0;
           v5->UpdateAnimation();
@@ -10235,7 +10160,7 @@
             {
               v6->uCurrentActionTime = 0;
               v6->uCurrentActionLength = 0;
-              v6->uAIState = 5;
+              v6->uAIState = Dead;
               v6->UpdateAnimation();
             }
             if ( !thisa->_406D10(a2) )
@@ -10506,11 +10431,11 @@
                 v5->uCurrentActionTime += pMiscTimer->uTimeElapsed;
                 if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength )
                 {
-                  if ( v5->uAIState == 4 )
+                  if (v5->uAIState == Dying)
                   {
                     v5->uCurrentActionTime = 0;
                     v5->uCurrentActionLength = 0;
-                    v5->uAIState = 5;
+                    v5->uAIState = Dead;
                     v5->UpdateAnimation();
                     return;
                   }
@@ -11915,7 +11840,7 @@
 }
 
 //----- (00408896) --------------------------------------------------------
-char *__cdecl UpdateLayingItems()
+void UpdateLayingItems()
 {
   unsigned int v0; // edi@1
   char *v1; // esi@1
@@ -11931,14 +11856,9 @@
     ++v0;
   }
   while ( (signed int)v1 < (signed int)((char *)&pObjectList->uNumObjects + 2) );
-  result = (char *)&array_5118E8.pElements[0].field_C;
-  do
-  {
-    *(short *)result = 0;
-    result += 24;
-  }
-  while ( (signed int)result < (signed int)&pBillboardRenderList[0].field_4 );
-  return result;
+
+  for (uint i = 0; i < 100; ++i)
+    array_5118E8.pElements[i].field_C_time_left = 0;
 }
 
 //----- (004088E9) --------------------------------------------------------
@@ -17286,7 +17206,7 @@
     v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
   else
     v4 = 0xFFFFu;
-  sprintfex(pTmpBuf2, &byte_4E2F14, pGlobalTXT_LocalizationStrings[207], v4, pPlayer->uSkillPoints);
+  sprintfex(pTmpBuf2, "\xC" "00000\xD" "180%s: \xC%05d%d\xC" "00000\n\n\n", pGlobalTXT_LocalizationStrings[207], v4, pPlayer->uSkillPoints);
   strcat(pTmpBuf, pTmpBuf2);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 18, 0, pTmpBuf, 0, 0, 0);
   v5 = pPlayer->GetBaseStrength();