comparison 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
comparison
equal deleted inserted replaced
796:14beae4f1723 812:9d2b911ef526
7762 } 7762 }
7763 return y3 - v10 > 512;*/ 7763 return y3 - v10 > 512;*/
7764 } 7764 }
7765 7765
7766 //----- (0048257A) -------------------------------------------------------- 7766 //----- (0048257A) --------------------------------------------------------
7767 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int a4) 7767 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int bFloatAboveWater)
7768 { 7768 {
7769 unsigned int v4; // ebx@1 7769 //unsigned int v4; // ebx@1
7770 unsigned int v5; // edi@1 7770 //unsigned int v5; // edi@1
7771 int result; // eax@9 7771 int result; // eax@9
7772 int v7; // ebx@10 7772 //int v7; // ebx@10
7773 int v8; // ebx@11 7773 int v8; // ebx@11
7774 int v9; // eax@11 7774 int v9; // eax@11
7775 int v10; // ecx@11 7775 int v10; // ecx@11
7776 int v11; // [sp+Ch] [bp-Ch]@1 7776 //int v11; // [sp+Ch] [bp-Ch]@1
7777 int v12; // [sp+10h] [bp-8h]@1 7777 //int v12; // [sp+10h] [bp-8h]@1
7778 int v13; // [sp+10h] [bp-8h]@11 7778 int v13; // [sp+10h] [bp-8h]@11
7779 signed int v14; // [sp+14h] [bp-4h]@3 7779 signed int v14; // [sp+14h] [bp-4h]@3
7780 int v15; // [sp+24h] [bp+Ch]@11 7780 int v15; // [sp+24h] [bp+Ch]@11
7781 7781
7782 v11 = a1; 7782 //v11 = a1;
7783 v12 = a2; 7783 //v12 = a2;
7784 v4 = WorldPosToGridCellX(a1); 7784 auto grid_x = WorldPosToGridCellX(a1);
7785 v5 = WorldPosToGridCellZ(v12) - 1; 7785 auto grid_z = WorldPosToGridCellZ(a2) - 1;
7786 dword_76D538_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4); 7786
7787 dword_76D53C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1); 7787 auto grid_x1 = GridCellToWorldPosX(grid_x),
7788 dword_76D540_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1); 7788 grid_x2 = GridCellToWorldPosX(grid_x + 1);
7789 dword_76D544_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4); 7789 auto grid_z1 = GridCellToWorldPosZ(grid_z),
7790 dword_76D528_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5); 7790 grid_z2 = GridCellToWorldPosZ(grid_z + 1);
7791 dword_76D52C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5); 7791
7792 dword_76D530_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1); 7792 auto y_x1z1 = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z),
7793 dword_76D534_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1); 7793 y_x2z1 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z),
7794 dword_76D518_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5); 7794 y_x2z2 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1),
7795 dword_76D51C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5); 7795 y_x1z2 = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1);
7796 dword_76D520_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5 + 1); 7796 //v4 = WorldPosToGridCellX(a1);
7797 dword_76D524_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5 + 1); 7797 //v5 = WorldPosToGridCellZ(v12) - 1;
7798 //dword_76D538_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
7799 //dword_76D53C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
7800 //dword_76D540_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
7801 //dword_76D544_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
7802 //dword_76D528_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
7803 //dword_76D52C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
7804 //dword_76D530_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
7805 //dword_76D534_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
7806 //dword_76D518_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5);
7807 //dword_76D51C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5);
7808 //dword_76D520_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5 + 1);
7809 //dword_76D524_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5 + 1);
7798 *pIsOnWater = false; 7810 *pIsOnWater = false;
7799 if ( pOutdoor->ActuallyGetSomeOtherTileInfo(v4, v5) & 2 ) 7811 if ( pOutdoor->ActuallyGetSomeOtherTileInfo(grid_x, grid_z) & 2 )
7800 *pIsOnWater = true; 7812 *pIsOnWater = true;
7801 v14 = 0; 7813 v14 = 0;
7802 if ( !a4 && *pIsOnWater ) 7814 if ( !bFloatAboveWater && *pIsOnWater )
7803 v14 = -60; 7815 v14 = -60;
7804 if ( dword_76D518_terrain_cell_world_pos_around_party_y != dword_76D51C_terrain_cell_world_pos_around_party_y 7816 if ( y_x1z1 != y_x2z1 ||
7805 || dword_76D51C_terrain_cell_world_pos_around_party_y != dword_76D520_terrain_cell_world_pos_around_party_y 7817 y_x2z1 != y_x2z2 ||
7806 || dword_76D520_terrain_cell_world_pos_around_party_y != dword_76D524_terrain_cell_world_pos_around_party_y ) 7818 y_x2z2 != y_x1z2 )
7807 { 7819 {
7808 v7 = abs(v11 - dword_76D538_terrain_cell_world_pos_around_party_x); 7820 if ( abs(grid_z1 - a2) >= abs(a1 - grid_x1) )
7809 if ( abs(dword_76D528_terrain_cell_world_pos_around_party_z - v12) >= v7 ) 7821 {
7810 { 7822 v8 = y_x1z2;
7811 v8 = dword_76D524_terrain_cell_world_pos_around_party_y; 7823 v9 = y_x2z2;
7812 v9 = dword_76D520_terrain_cell_world_pos_around_party_y; 7824 v10 = y_x1z1;
7813 v10 = dword_76D518_terrain_cell_world_pos_around_party_y; 7825 v15 = a1 - grid_x1;
7814 v15 = v11 - dword_76D544_terrain_cell_world_pos_around_party_x; 7826 v13 = a2 - grid_z2;
7815 v13 = v12 - dword_76D534_terrain_cell_world_pos_around_party_z;
7816 } 7827 }
7817 else 7828 else
7818 { 7829 {
7819 v8 = dword_76D51C_terrain_cell_world_pos_around_party_y; 7830 v8 = y_x2z1;
7820 v9 = dword_76D518_terrain_cell_world_pos_around_party_y; 7831 v9 = y_x1z1;
7821 v10 = dword_76D520_terrain_cell_world_pos_around_party_y; 7832 v10 = y_x2z2;
7822 v15 = dword_76D53C_terrain_cell_world_pos_around_party_x - v11; 7833 v15 = grid_x2 - a1;
7823 v13 = dword_76D52C_terrain_cell_world_pos_around_party_z - v12; 7834 v13 = grid_z1 - a2;
7824 } 7835 }
7825 result = v14 7836 return v14 + v8 + fixpoint_mul(v13, (v10 - v8) * 128) + fixpoint_mul(v15, (v9 - v8) * 128);
7826 + v8
7827 + ((unsigned __int64)(v13 * (signed __int64)((v10 - v8) << 7)) >> 16)
7828 + ((unsigned __int64)(v15 * (signed __int64)((v9 - v8) << 7)) >> 16);
7829 } 7837 }
7830 else 7838 else
7831 { 7839 return y_x1z1;
7832 result = v14 + dword_76D518_terrain_cell_world_pos_around_party_y;
7833 }
7834 return result;
7835 } 7840 }
7836 7841
7837 //----- (0048276F) -------------------------------------------------------- 7842 //----- (0048276F) --------------------------------------------------------
7838 void stru148::_48276F_sr() 7843 void stru148::_48276F_sr()
7839 { 7844 {