changeset 813:d37b03507b3b

Merge
author Nomad
date Tue, 26 Mar 2013 06:40:04 +0200
parents 9d2b911ef526 (diff) d6e84d158052 (current diff)
children ee75f497a579 cfc65feef029
files Outdoor.cpp mm7_3.cpp mm7_data.h
diffstat 4 files changed, 66 insertions(+), 121 deletions(-) [+]
line wrap: on
line diff
--- a/Outdoor.cpp	Tue Mar 26 00:58:16 2013 +0400
+++ b/Outdoor.cpp	Tue Mar 26 06:40:04 2013 +0200
@@ -2504,41 +2504,29 @@
 //----- (0047ED83) --------------------------------------------------------
 int OutdoorLocation::_47ED83(signed int a2, signed int a3)
 {
-  int result; // eax@5
+  assert(a2 < 128 && a3 < 128);
 
-  if ( a2 < 0 || a2 > 127 || a3 < 0 || a3 > 127 )
-    result = 0;
-  else
-    result = *(&this->pTerrain.pTilemap[128 * a3] + a2);
-  return result;
+  return *(&this->pTerrain.pTilemap[128 * a3] + a2);
 }
 
 //----- (0047EDB3) --------------------------------------------------------
 int OutdoorLocation::ActuallyGetSomeOtherTileInfo(unsigned int uX, unsigned int uY)
 {
+  assert(uX < 128 && uY < 128);
   int v3; // esi@5
 
-  if (uX < 0 || uX > 127 || uY < 0 || uY > 127)
-    return 0;
-  else
-  {
-    v3 = this->pTerrain.pTilemap[uY * 128 + uX];
-    if ( v3 >= 90 )
-      v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * ((v3 - 90) / 36) - 90;
+  v3 = this->pTerrain.pTilemap[uY * 128 + uX];
+  if ( v3 >= 90 )
+    v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * ((v3 - 90) / 36) - 90;
   return pTileTable->pTiles[v3].uAttributes;
-  }
 }
 
 //----- (0047EE16) --------------------------------------------------------
 int OutdoorLocation::DoGetHeightOnTerrain(unsigned int uX, unsigned int uZ)
 {
-  int result; // eax@5
+  assert(uX < 128 && uZ < 128);
 
-  if ( (signed int)uX < 0 || (signed int)uX > 127 || (signed int)uZ < 0 || (signed int)uZ > 127 )
-    result = 0;
-  else
-    result = 32 * *(&this->pTerrain.pHeightmap[uZ * 128 + uX]);
-  return result;
+  return 32 * pTerrain.pHeightmap[uZ * 128 + uX];
 }
 
 //----- (0047EE49) --------------------------------------------------------
--- a/mm7_3.cpp	Tue Mar 26 00:58:16 2013 +0400
+++ b/mm7_3.cpp	Tue Mar 26 06:40:04 2013 +0200
@@ -7724,74 +7724,79 @@
 }
 
 //----- (0048257A) --------------------------------------------------------
-int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int a4)
-{
-  unsigned int v4; // ebx@1
-  unsigned int v5; // edi@1
+int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int bFloatAboveWater)
+{
+  //unsigned int v4; // ebx@1
+  //unsigned int v5; // edi@1
   int result; // eax@9
-  int v7; // ebx@10
+  //int v7; // ebx@10
   int v8; // ebx@11
   int v9; // eax@11
   int v10; // ecx@11
-  int v11; // [sp+Ch] [bp-Ch]@1
-  int v12; // [sp+10h] [bp-8h]@1
+  //int v11; // [sp+Ch] [bp-Ch]@1
+  //int v12; // [sp+10h] [bp-8h]@1
   int v13; // [sp+10h] [bp-8h]@11
   signed int v14; // [sp+14h] [bp-4h]@3
   int v15; // [sp+24h] [bp+Ch]@11
 
-  v11 = a1;
-  v12 = a2;
-  v4 = WorldPosToGridCellX(a1);
-  v5 = WorldPosToGridCellZ(v12) - 1;
-  dword_76D538_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
-  dword_76D53C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
-  dword_76D540_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
-  dword_76D544_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
-  dword_76D528_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
-  dword_76D52C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
-  dword_76D530_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
-  dword_76D534_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
-  dword_76D518_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5);
-  dword_76D51C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5);
-  dword_76D520_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5 + 1);
-  dword_76D524_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5 + 1);
+  //v11 = a1;
+  //v12 = a2;
+  auto grid_x = WorldPosToGridCellX(a1);
+  auto grid_z = WorldPosToGridCellZ(a2) - 1;
+
+  auto grid_x1 = GridCellToWorldPosX(grid_x),
+       grid_x2 = GridCellToWorldPosX(grid_x + 1);
+  auto grid_z1 = GridCellToWorldPosZ(grid_z),
+       grid_z2 = GridCellToWorldPosZ(grid_z + 1);
+
+  auto y_x1z1 = pOutdoor->DoGetHeightOnTerrain(grid_x,     grid_z),
+       y_x2z1 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z),
+       y_x2z2 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1),
+       y_x1z2 = pOutdoor->DoGetHeightOnTerrain(grid_x,     grid_z + 1);
+  //v4 = WorldPosToGridCellX(a1);
+  //v5 = WorldPosToGridCellZ(v12) - 1;
+  //dword_76D538_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
+  //dword_76D53C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
+  //dword_76D540_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
+  //dword_76D544_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
+  //dword_76D528_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
+  //dword_76D52C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
+  //dword_76D530_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
+  //dword_76D534_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
+  //dword_76D518_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5);
+  //dword_76D51C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5);
+  //dword_76D520_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5 + 1);
+  //dword_76D524_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5 + 1);
   *pIsOnWater = false;
-  if ( pOutdoor->ActuallyGetSomeOtherTileInfo(v4, v5) & 2 )
+  if ( pOutdoor->ActuallyGetSomeOtherTileInfo(grid_x, grid_z) & 2 )
     *pIsOnWater = true;
   v14 = 0;
-  if ( !a4 && *pIsOnWater )
+  if ( !bFloatAboveWater && *pIsOnWater )
     v14 = -60;
-  if ( dword_76D518_terrain_cell_world_pos_around_party_y != dword_76D51C_terrain_cell_world_pos_around_party_y
-    || dword_76D51C_terrain_cell_world_pos_around_party_y != dword_76D520_terrain_cell_world_pos_around_party_y
-    || dword_76D520_terrain_cell_world_pos_around_party_y != dword_76D524_terrain_cell_world_pos_around_party_y )
-  {
-    v7 = abs(v11 - dword_76D538_terrain_cell_world_pos_around_party_x);
-    if ( abs(dword_76D528_terrain_cell_world_pos_around_party_z - v12) >= v7 )
-    {
-      v8 = dword_76D524_terrain_cell_world_pos_around_party_y;
-      v9 = dword_76D520_terrain_cell_world_pos_around_party_y;
-      v10 = dword_76D518_terrain_cell_world_pos_around_party_y;
-      v15 = v11 - dword_76D544_terrain_cell_world_pos_around_party_x;
-      v13 = v12 - dword_76D534_terrain_cell_world_pos_around_party_z;
+  if ( y_x1z1 != y_x2z1 ||
+       y_x2z1 != y_x2z2 ||
+       y_x2z2 != y_x1z2 )
+  {
+    if ( abs(grid_z1 - a2) >= abs(a1 - grid_x1) )
+    {
+      v8 = y_x1z2;
+      v9 = y_x2z2;
+      v10 = y_x1z1;
+      v15 = a1 - grid_x1;
+      v13 = a2 - grid_z2;
     }
     else
     {
-      v8 = dword_76D51C_terrain_cell_world_pos_around_party_y;
-      v9 = dword_76D518_terrain_cell_world_pos_around_party_y;
-      v10 = dword_76D520_terrain_cell_world_pos_around_party_y;
-      v15 = dword_76D53C_terrain_cell_world_pos_around_party_x - v11;
-      v13 = dword_76D52C_terrain_cell_world_pos_around_party_z - v12;
-    }
-    result = v14
-           + v8
-           + ((unsigned __int64)(v13 * (signed __int64)((v10 - v8) << 7)) >> 16)
-           + ((unsigned __int64)(v15 * (signed __int64)((v9 - v8) << 7)) >> 16);
-  }
-  else
-  {
-    result = v14 + dword_76D518_terrain_cell_world_pos_around_party_y;
-  }
-  return result;
+      v8 = y_x2z1;
+      v9 = y_x1z1;
+      v10 = y_x2z2;
+      v15 = grid_x2 - a1;
+      v13 = grid_z1 - a2;
+    }
+    return v14 + v8 + fixpoint_mul(v13, (v10 - v8) * 128) + fixpoint_mul(v15, (v9 - v8) * 128);
+  }
+  else
+    return y_x1z1;
 }
 
 //----- (0048276F) --------------------------------------------------------
--- a/mm7_data.cpp	Tue Mar 26 00:58:16 2013 +0400
+++ b/mm7_data.cpp	Tue Mar 26 06:40:04 2013 +0200
@@ -1911,30 +1911,6 @@
  struct Vec3_float_ *pTerrainNormals;
  unsigned short  pTerrainNormalIndices[128 * 128 * 2];
  unsigned int    pTerrainSomeOtherData[128 * 128 * 2];
-int dword_76D518_terrain_cell_world_pos_around_party_y; // weak
-int dword_76D51C_terrain_cell_world_pos_around_party_y; // weak
-int dword_76D520_terrain_cell_world_pos_around_party_y; // weak
-int dword_76D524_terrain_cell_world_pos_around_party_y; // weak
-int dword_76D528_terrain_cell_world_pos_around_party_z; // weak
-int dword_76D52C_terrain_cell_world_pos_around_party_z; // weak
-int dword_76D530_terrain_cell_world_pos_around_party_z; // weak
-int dword_76D534_terrain_cell_world_pos_around_party_z; // weak
-int dword_76D538_terrain_cell_world_pos_around_party_x; // weak
-int dword_76D53C_terrain_cell_world_pos_around_party_x; // weak
-int dword_76D540_terrain_cell_world_pos_around_party_x; // weak
-int dword_76D544_terrain_cell_world_pos_around_party_x; // weak
-//int dword_76D548_terrain_cell_world_pos_around_party_y; // weak
-//int dword_76D54C_terrain_cell_world_pos_around_party_y; // weak
-//int dword_76D550_terrain_cell_world_pos_around_party_y; // weak
-//int dword_76D554_terrain_cell_world_pos_around_party_y; // weak
-//int dword_76D558_terrain_cell_world_pos_around_party_z; // weak
-//int dword_76D55C_terrain_cell_world_pos_around_party_z; // weak
-//int dword_76D560_terrain_cell_world_pos_around_party_z; // weak
-//int dword_76D564_terrain_cell_world_pos_around_party_z; // weak
-//int dword_76D568_terrain_cell_world_pos_around_party_x; // weak
-//int dword_76D56C_terrain_cell_world_pos_around_party_x; // weak
-//int dword_76D570_terrain_cell_world_pos_around_party_x; // weak
-//int dword_76D574_terrain_cell_world_pos_around_party_x; // weak
 struct unk_F7B60C stru_76D578; // struct @ MM7.exe::0076D578
 struct unk_F7B60C stru_76D590; // struct @ MM7.exe::0076D590
 struct unk_F7B60C stru_76D5A8; // struct @ MM7.exe::0076D5A8
--- a/mm7_data.h	Tue Mar 26 00:58:16 2013 +0400
+++ b/mm7_data.h	Tue Mar 26 06:40:04 2013 +0200
@@ -1418,30 +1418,6 @@
 extern struct Vec3_float_ *pTerrainNormals;
 extern unsigned short  pTerrainNormalIndices[128 * 128 * 2];
 extern unsigned int    pTerrainSomeOtherData[128 * 128 * 2];
-extern int dword_76D518_terrain_cell_world_pos_around_party_y; // weak
-extern int dword_76D51C_terrain_cell_world_pos_around_party_y; // weak
-extern int dword_76D520_terrain_cell_world_pos_around_party_y; // weak
-extern int dword_76D524_terrain_cell_world_pos_around_party_y; // weak
-extern int dword_76D528_terrain_cell_world_pos_around_party_z; // weak
-extern int dword_76D52C_terrain_cell_world_pos_around_party_z; // weak
-extern int dword_76D530_terrain_cell_world_pos_around_party_z; // weak
-extern int dword_76D534_terrain_cell_world_pos_around_party_z; // weak
-extern int dword_76D538_terrain_cell_world_pos_around_party_x; // weak
-extern int dword_76D53C_terrain_cell_world_pos_around_party_x; // weak
-extern int dword_76D540_terrain_cell_world_pos_around_party_x; // weak
-extern int dword_76D544_terrain_cell_world_pos_around_party_x; // weak
-//extern int dword_76D548_terrain_cell_world_pos_around_party_y; // weak
-//extern int dword_76D54C_terrain_cell_world_pos_around_party_y; // weak
-//extern int dword_76D550_terrain_cell_world_pos_around_party_y; // weak
-//extern int dword_76D554_terrain_cell_world_pos_around_party_y; // weak
-//extern int dword_76D558_terrain_cell_world_pos_around_party_z; // weak
-//extern int dword_76D55C_terrain_cell_world_pos_around_party_z; // weak
-//extern int dword_76D560_terrain_cell_world_pos_around_party_z; // weak
-//extern int dword_76D564_terrain_cell_world_pos_around_party_z; // weak
-//extern int dword_76D568_terrain_cell_world_pos_around_party_x; // weak
-//extern int dword_76D56C_terrain_cell_world_pos_around_party_x; // weak
-//extern int dword_76D570_terrain_cell_world_pos_around_party_x; // weak
-//extern int dword_76D574_terrain_cell_world_pos_around_party_x; // weak
 extern char byte_76D5C0;
 extern struct unk_F7B60C stru_76D578;
 extern struct unk_F7B60C stru_76D590;