Mercurial > mm7
diff mm7_3.cpp @ 812:9d2b911ef526
Fixed some odm terrain collision glitches.
author | Nomad |
---|---|
date | Tue, 26 Mar 2013 06:34:44 +0200 |
parents | 472ca68386d4 |
children | d37b03507b3b |
line wrap: on
line diff
--- a/mm7_3.cpp Mon Mar 25 14:56:50 2013 +0200 +++ b/mm7_3.cpp Tue Mar 26 06:34:44 2013 +0200 @@ -7764,74 +7764,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) --------------------------------------------------------