Mercurial > mm7
diff mm7_4.cpp @ 723:256211e8243a
ODM_GetFloorLevel & BLV_GetFloorLevel
author | Ritor1 |
---|---|
date | Thu, 21 Mar 2013 16:09:44 +0600 |
parents | 70c5a87a1307 |
children | 7037f22cd716 |
line wrap: on
line diff
--- a/mm7_4.cpp Wed Mar 20 17:49:15 2013 +0600 +++ b/mm7_4.cpp Thu Mar 21 16:09:44 2013 +0600 @@ -238,16 +238,8 @@ // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; //----- (0046CEC3) -------------------------------------------------------- -int _46CEC3_get_floor_level(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID) -{ - //BLVSector *v5; // edi@1 - //int v6; // ecx@1 - //Vec3_short_ *v7; // edx@1 - //BLVFace *v8; // esi@2 - //int v9; // eax@8 - //int v10; // edi@8 - //int v11; // eax@10 - int v12; // ecx@10 +int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID) +{ int v13; // ecx@13 signed int v14; // ebx@14 int v15; // eax@16 @@ -255,14 +247,8 @@ int v17; // ST18_4@19 signed int v18; // edx@19 signed __int64 v19; // qtt@19 - PolygonType v20; // al@25 int v21; // eax@27 int v22; // ecx@29 - //BLVFace *v23; // eax@33 - //int v24; // esi@39 - //int v25; // edi@39 - //int v26; // esi@41 - int v27; // ecx@43 signed int v28; // eax@45 int v29; // ebx@47 int v30; // edx@49 @@ -272,51 +258,22 @@ signed int v34; // eax@54 signed int v35; // esi@56 int result; // eax@57 - int pPartyOpp; // edi@61 int v38; // edx@62 - //int v39; // [sp+Ch] [bp-34h]@1 - //int v40; // [sp+10h] [bp-30h]@2 - int v41; // [sp+14h] [bp-2Ch]@12 - //unsigned __int16 *v42; // [sp+18h] [bp-28h]@1 - //BLVSector *v43; // [sp+1Ch] [bp-24h]@1 int v44; // [sp+20h] [bp-20h]@10 - int v45; // [sp+24h] [bp-1Ch]@10 - //signed int v46; // [sp+24h] [bp-1Ch]@38 bool v47; // [sp+24h] [bp-1Ch]@43 bool v48; // [sp+28h] [bp-18h]@10 bool v49; // [sp+28h] [bp-18h]@41 bool v50; // [sp+2Ch] [bp-14h]@12 - int v51; // [sp+2Ch] [bp-14h]@41 - //signed int v52; // [sp+30h] [bp-10h]@7 signed int v53; // [sp+30h] [bp-10h]@10 signed int v54; // [sp+30h] [bp-10h]@41 signed int v55; // [sp+34h] [bp-Ch]@1 - //signed int v56; // [sp+38h] [bp-8h]@1 - //signed int v57; // [sp+3Ch] [bp-4h]@1 - //int uSectorIDa; // [sp+4Ch] [bp+Ch]@1 - //signed int uSectorIDb; // [sp+4Ch] [bp+Ch]@32 LOG_DECOMPILATION_WARNING(); - //auto a1 = x; - //auto a2 = y; - //auto a3 = z; - - //v5 = &pIndoor->pSectors[uSectorID]; auto pSector = &pIndoor->pSectors[uSectorID]; - //v57 = y; - //v56 = x; - //v6 = 0; - v55 = 0; - //v43 = v5; - //v42 = v5->pFloors; - //v7 = pIndoor->pVertices; - //v39 = v5->uNumFloors; - //for ( uSectorIDa = 0; uSectorIDa < v39; ++uSectorIDa ) + v55 = 1; for (uint i = 0; i < pSector->uNumFloors; ++i) { - //v40 = (int)&v42[v6]; - //v8 = &pIndoor->pFaces[pSector->pFloors[i]]; auto pFloor = &pIndoor->pFaces[pSector->pFloors[i]]; if (pFloor->Clickable()) continue; @@ -324,85 +281,60 @@ if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 && y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1) { - //v52 = 0; for (uint j = 0; j < pFloor->uNumVertices; ++j) { - //v9 = v52; - //v10 = 2 * v52; word_721460[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; word_721460[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; word_721390[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; word_721390[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; - //} - //while ( v52 < v8->uNumVertices ); - //v5 = v43; } v44 = 2 * pFloor->uNumVertices; - //v11 = 2 * pFloor->uNumVertices; word_721460[2 * pFloor->uNumVertices] = word_721460[0]; word_721390[2 * pFloor->uNumVertices] = word_721390[0]; v48 = word_721390[0] >= y; - v12 = 0; v53 = 0; - v45 = 0; if ( pFloor->uNumVertices > 0 ) { - do + for ( int i = 0; i < v44; i++ ) { if ( v53 >= 2 ) break; - v41 = word_721390[v12 + 1]; - v50 = word_721390[v12 + 1] >= y; + v50 = word_721390[i + 1] >= y; if ( v48 == v50 ) { - v13 = v45; + v13 = i; } else { - v13 = v45; - if ( word_721460[v45 + 1] >= x ) - v14 = 0; - else - v14 = 2; - v15 = v14 | word_721460[v45] < x; + v13 = i; + v14 = word_721460[i + 1] >= x ? 0 : 2; + v15 = v14 | word_721460[i] < x; if ( v15 != 3 ) { - if ( !v15 - || (v16 = word_721390[v45], - v17 = v41 - v16, - v18 = y - v16, - LODWORD(v19) = v18 << 16, - HIDWORD(v19) = v18 >> 16, - //v7 = pIndoor->pVertices, - (signed int)(((unsigned __int64)(((signed int)word_721460[v45 + 1] - (signed int)word_721460[v45]) - * v19 - / v17) >> 16) - + word_721460[v45]) >= x) ) - ++v53; + if ( !v15 ) + { + LODWORD(v19) = (y - word_721390[i]) << 16; + HIDWORD(v19) = (y - word_721390[i]) >> 16; + v16 = ((((word_721460[i + 1] - word_721460[i]) * v19 / (word_721390[i + 1] - word_721390[i])) >> 16) + word_721460[i]); + if ( v16 >= x) + ++v53; + } } } - v12 = v13 + 1; v48 = v50; - v45 = v12; - } - while ( v12 < v44 ); - + } if ( v53 == 1 ) { if ( v55 >= 50 ) break; - v20 = pFloor->uPolygonType; - if ( v20 == 3 || v20 == 5 ) + if ( pFloor->uPolygonType == POLYGON_Floor || pFloor->uPolygonType == POLYGON_Ceiling ) { v21 = pIndoor->pVertices[*pFloor->pVertexIDs].z; } else { - //v7 = pIndoor->pVertices; - v21 = ((unsigned __int64)(pFloor->zCalc1 * (signed __int64)x) >> 16) - + ((unsigned __int64)(pFloor->zCalc2 * (signed __int64)y) >> 16) - + HIWORD(pFloor->zCalc3); + v21 = ((pFloor->zCalc1 * x) >> 16) + ((pFloor->zCalc2 * y) >> 16) + pFloor->zCalc3; } v22 = v55++; dword_7212C8[v22] = v21; @@ -410,79 +342,53 @@ } } } - //v6 = uSectorIDa + 1; } if ( pSector->field_0 & 8 ) { for (uint i = 0; i < pSector->uNumPortals; ++i) { - //v23 = &pIndoor->pFaces[v5->pPortals[uSectorIDb]]; auto portal = &pIndoor->pFaces[pSector->pPortals[i]]; if (portal->uPolygonType != POLYGON_Floor) continue; - if (x <= portal->pBounding.x2 && - x >= portal->pBounding.x1 && - y <= portal->pBounding.y2 && - y >= portal->pBounding.y1 ) - { - //v46 = 0; + if (x <= portal->pBounding.x2 && x >= portal->pBounding.x1 && + y <= portal->pBounding.y2 && y >= portal->pBounding.y1 ) + { for (uint j = 0; j < portal->uNumVertices; ++j) { - //v24 = v46; - //v25 = 2 * v46; word_721460[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; word_721460[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; word_721390[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; word_721390[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; - //} - //while ( v46 < v23->uNumVertices ); - //v5 = v43; - } - - //v26 = 2 * v23->uNumVertices; + } word_721460[2 * portal->uNumVertices] = word_721460[0]; word_721390[2 * portal->uNumVertices] = word_721390[0]; v54 = 0; - v51 = 0; v49 = word_721390[0] >= y; if ( portal->uNumVertices > 0 ) { - do + for ( int i = 0; i < 2 * portal->uNumVertices; ++i ) { if ( v54 >= 2 ) break; - v27 = v51; - v47 = word_721390[v51 + 1] >= y; + v47 = word_721390[i + 1] >= y; if ( v49 != v47 ) { - if ( word_721460[v27 + 1] >= x ) - v28 = 0; - else - v28 = 2; - v29 = v28 | word_721460[v27] < x; + v28 = word_721460[i + 1] >= x ? 0 : 2; + v29 = v28 | word_721460[i] < x; if ( v29 != 3 ) { - if ( !v29 - || (v30 = word_721390[v27], - v31 = word_721390[v51 + 1] - v30, - v32 = y - v30, - LODWORD(v33) = v32 << 16, - HIDWORD(v33) = v32 >> 16, - //v7 = pIndoor->pVertices, - (signed int)(((unsigned __int64)(((signed int)word_721460[v27 + 1] - (signed int)word_721460[v27]) - * v33 - / v31) >> 16) - + word_721460[v27]) >= x) ) - ++v54; + if ( !v29 ) + LODWORD(v33) = (y - word_721390[i]) << 16; + HIDWORD(v33) = (y - word_721390[i]) >> 16; + v30 = ((((word_721460[i + 1] - word_721460[i]) * v33 / (word_721390[i + 1] - word_721390[i])) >> 16) + word_721460[i]); + if ( v30 >= x) + ++v54; } } - ++v51; v49 = v47; } - while ( v51 < 2 * portal->uNumVertices ); - if ( v54 == 1 ) { if ( v55 >= 50 ) @@ -495,8 +401,6 @@ } } } - - //v35 = 1; if ( v55 == 1 ) { *pFaceID = dword_721200[0]; @@ -508,47 +412,32 @@ result = dword_7212C8[0]; if ( v55 > 1 ) { - pPartyOpp = z + 5; - //while ( 1 ) for ( v35 = 1; v35 < v55; ++v35 ) { - v38 = dword_7212C8[v35]; - if ( result <= pPartyOpp ) - { - if ( v38 >= result || v38 > pPartyOpp ) + if ( result <= z + 5 ) + { + if ( dword_7212C8[v35] >= result || dword_7212C8[v35] > z + 5 ) continue; result = dword_7212C8[v35]; *pFaceID = dword_721200[v35]; continue; } - if ( v38 < result ) + if ( dword_7212C8[v35] < result ) { result = dword_7212C8[v35]; *pFaceID = dword_721200[v35]; } -//LABEL_68: - //++v35; - //if ( v35 >= v55 ) - //return result; } } return result; } //----- (0046D49E) -------------------------------------------------------- -int __fastcall sub_46D49E_prolly_get_world_y_under_party(int a1, signed int a2, int a3, int a4, int *a5, int *a6, int a7) -{ - signed int v7; // edi@1 - int v8; // ebx@1 - int v9; // eax@1 - BSPModel *v10; // esi@4 - ODMFace *v11; // ecx@11 - unsigned __int8 v12; // al@11 - char *v13; // eax@19 +int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int a4, int *a5, int *a6, int a7) +{ + BSPModel *pBModel; // esi@4 + ODMFace *pFace; // ecx@11 int v14; // edx@20 - int v15; // eax@22 - int v16; // edx@22 - int v17; // edi@24 signed int v18; // edx@26 int v19; // eax@28 int v20; // edx@30 @@ -565,201 +454,149 @@ int v31; // eax@45 ODMFace *v32; // eax@57 int v33; // ecx@59 - int v34; // [sp+Ch] [bp-34h]@8 - int v35; // [sp+10h] [bp-30h]@22 int v36; // [sp+14h] [bp-2Ch]@24 - int v37; // [sp+18h] [bp-28h]@22 int v38; // [sp+1Ch] [bp-24h]@2 int v39; // [sp+20h] [bp-20h]@9 - int v40; // [sp+24h] [bp-1Ch]@1 - signed int v41; // [sp+28h] [bp-18h]@1 - int v42; // [sp+2Ch] [bp-14h]@8 + signed int pBModelNum; // [sp+28h] [bp-18h]@1 + int pFaceNum; // [sp+2Ch] [bp-14h]@8 bool v43; // [sp+30h] [bp-10h]@22 bool v44; // [sp+34h] [bp-Ch]@24 - signed int v45; // [sp+38h] [bp-8h]@1 signed int v46; // [sp+3Ch] [bp-4h]@1 - signed int v47; // [sp+58h] [bp+18h]@18 signed int v48; // [sp+58h] [bp+18h]@22 signed int v49; // [sp+58h] [bp+18h]@43 - v7 = a2; - v8 = a1; - v45 = a2; - v40 = a1; v46 = 1; - v9 = GetTerrainHeightsAroundParty2(a1, a2, a5, a7); dword_721160[0] = -1; dword_721110[0] = -1; - dword_7211B0[0] = v9; - v41 = 0; + floor_level[0] = GetTerrainHeightsAroundParty2(X, Y, a5, a7); if ( (signed int)pOutdoor->uNumBModels <= 0 ) - goto LABEL_63; + { + *a6 = 0; + return floor_level[0]; + } v38 = 0; - while ( 1 ) - { - v10 = &pOutdoor->pBModels[v38]; - if ( v8 <= pOutdoor->pBModels[v38].sMaxX ) - { - if ( v8 >= v10->sMinX ) - { - if ( v7 <= v10->sMaxY ) - { - if ( v7 >= v10->sMinY ) + for ( pBModelNum = 0; pBModelNum < (signed int)pOutdoor->uNumBModels; ++pBModelNum ) + { + pBModel = &pOutdoor->pBModels[v38]; + if ( X <= pBModel->sMaxX && X >= pBModel->sMinX && Y <= pBModel->sMaxY && Y >= pBModel->sMinY ) + { + if ( (signed int)pBModel->uNumFaces > 0 ) + { + v39 = 0; + for ( pFaceNum = 0; pFaceNum < pBModel->uNumFaces; ++pFaceNum ) + { + pFace = &pBModel->pFaces[v39]; + if ( (pFace->uPolygonType == POLYGON_Floor || pFace->uPolygonType == POLYGON_InBetweenFloorAndWall) + && !(pFace->uAttributes & 0x20000000) + && X <= pFace->pBoundingBox.x2 && X >= pFace->pBoundingBox.x1 + && Y <= pFace->pBoundingBox.y2 && Y >= pFace->pBoundingBox.y1 ) { - v42 = 0; - v34 = v10->uNumFaces; - if ( (signed int)v10->uNumFaces > 0 ) + if ( pFace->uNumVertices ) { - v39 = 0; - while ( 1 ) + for ( uint i = 0; i < pFace->uNumVertices; ++i) { - v11 = &v10->pFaces[v39]; - v12 = v11->uPolygonType; - if ( (v12 == 3 || v12 == 4) - && !(v11->uAttributes & 0x20000000) - && v8 <= v11->pBoundingBox.x2 - && v8 >= v11->pBoundingBox.x1 - && v7 <= v11->pBoundingBox.y2 - && v7 >= v11->pBoundingBox.y1 ) + word_721040[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].x; + word_720F70[2 * i] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].y; + word_721040[2 * i + 1] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; + word_720F70[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; + } + } + word_721040[2 * pFace->uNumVertices] = word_721040[0]; + word_720F70[2 * pFace->uNumVertices] = word_720F70[0]; + v43 = word_720F70[0] >= Y; + v48 = 0; + if ( 2 * pFace->uNumVertices > 0 ) + { + for ( int i = 0; i < 2 * pFace->uNumVertices; ++i ) + { + if ( v48 >= 2 ) + break; + v36 = word_720F70[i + 1]; + v44 = word_720F70[i + 1] >= Y; + if ( v43 != v44 ) { - v47 = 0; - if ( v11->uNumVertices ) + v18 = word_721040[i + 1] >= X ? 0 : 2; + v19 = v18 | word_721040[i] < X; + if ( v19 != 3 ) { - v13 = (char *)v11->pXInterceptDisplacements; - do + if ( !v19 ) { - v14 = 2 * v47; - word_721040[2 * v47] = *(short *)v13 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 60)].x); - word_720F70[2 * v47] = *((short *)v13 + 20) - + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 60)].y); - word_721040[2 * v47++ + 1] = *(short *)v13 - + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 59)].x); - word_720F70[v14 + 1] = *((short *)v13 + 20) - + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 59)].y); - v13 += 2; - } - while ( v47 < v11->uNumVertices ); - v8 = v40; - } - v15 = 2 * v11->uNumVertices; - word_721040[2 * v11->uNumVertices] = word_721040[0]; - word_720F70[v15] = word_720F70[0]; - v35 = v15; - v16 = 0; - v43 = word_720F70[0] >= v45; - v48 = 0; - v37 = 0; - if ( v15 > 0 ) - { - do - { - if ( v48 >= 2 ) - break; - v17 = v16; - v8 = v40; - v36 = word_720F70[v16 + 1]; - v44 = word_720F70[v16 + 1] >= v45; - if ( v43 != v44 ) - { - v18 = word_721040[v17 + 1] >= v40 ? 0 : 2; - v19 = v18 | word_721040[v17] < v40; - if ( v19 != 3 ) - { - if ( !v19 - || (v20 = word_720F70[v17], - v21 = v36 - v20, - v22 = v45 - v20, - LODWORD(v23) = v22 << 16, - HIDWORD(v23) = v22 >> 16, - (signed int)(((unsigned __int64)(((signed int)word_721040[v17 + 1] - - (signed int)word_721040[v17]) - * v23 - / v21) >> 16) - + word_721040[v17]) >= v40) ) - ++v48; - } - } - v16 = v37 + 1; - v43 = v44; - ++v37; - } - while ( v37 < v35 ); - if ( v48 == 1 ) - { - if ( v46 >= 20 ) - break; - if ( v11->uPolygonType == 3 ) - v24 = v10->pVertices.pVertices[v11->pVertexIDs[0]].z; - else - v24 = ((unsigned __int64)(v11->zCalc1 * (signed __int64)v8) >> 16) - + ((unsigned __int64)(v11->zCalc2 * (signed __int64)v45) >> 16) - + HIWORD(v11->zCalc3); - v25 = v46++; - dword_7211B0[v25] = v24; - dword_721160[v25] = v41; - dword_721110[v25] = v42; + LODWORD(v23) = (Y - word_720F70[i]) << 16; + HIDWORD(v23) = (Y - word_720F70[i]) >> 16; + v22 = ((((word_721040[i + 1] - word_721040[i]) * v23 / (v36 - word_720F70[i])) >> 16) + word_721040[i]); + if ( v22 >= X) + ++v48; } } } - ++v42; - ++v39; - if ( v42 >= v34 ) + v43 = v44; + } + if ( v48 == 1 ) + { + if ( v46 >= 20 ) break; - v7 = v45; + if ( pFace->uPolygonType == POLYGON_Floor ) + v24 = pBModel->pVertices.pVertices[pFace->pVertexIDs[0]].z; + else + v24 = ((pFace->zCalc1 * X) >> 16) + ((pFace->zCalc2 * Y) >> 16) + pFace->zCalc3; + v25 = v46++; + floor_level[v25] = v24; + dword_721160[v25] = pBModelNum; + dword_721110[v25] = pFaceNum; } } } - } - } - } - ++v41; + ++v39; + } + } + } ++v38; - if ( v41 >= (signed int)pOutdoor->uNumBModels ) - break; - v7 = v45; } if ( v46 == 1 ) { -LABEL_63: *a6 = 0; - return dword_7211B0[0]; + return floor_level[0]; } v27 = 0; - v49 = 1; if ( v46 <= 1 ) - { -LABEL_55: *a6 = 0; - goto LABEL_56; - } - v28 = 0; - v29 = 1; - do - { - v30 = dword_7211B0[v29]; - v31 = *(int *)((char *)dword_7211B0 + v28); - if ( v30 == v31 ) - goto LABEL_51; - if ( v31 > a3 + 5 ) - { - if ( v30 >= v31 ) - goto LABEL_52; -LABEL_51: - v27 = v49; - v28 = v29 * 4; - goto LABEL_52; - } - if ( v30 > v31 && v30 <= a3 + 5 ) - goto LABEL_51; -LABEL_52: - ++v49; - ++v29; - } - while ( v49 < v46 ); - if ( !v27 ) - goto LABEL_55; - *a6 = dword_721110[v27] | (dword_721160[v27] << 6); -LABEL_56: + else + { + v28 = 0; + v29 = 1; + for ( v49 = 1; v49 < v46; ++v49 ) + { + if ( floor_level[v29] == floor_level[v28] ) + { + v27 = v49; + v28 = v29 * 4; + ++v29; + break; + } + if ( floor_level[v28] > Z + 5 ) + { + if ( floor_level[v29] >= floor_level[v28] ) + { + ++v29; + break; + } + v27 = v49; + v28 = v29 * 4; + ++v29; + break; + } + if ( floor_level[v29] > floor_level[v28] && floor_level[v29] <= Z + 5 ) + { + v27 = v49; + v28 = v29 * 4; + ++v29; + } + } + if ( !v27 ) + *a6 = 0; + else + *a6 = dword_721110[v27] | (dword_721160[v27] << 6); + } if ( v27 ) { v32 = &pOutdoor->pBModels[dword_721160[v27]].pFaces[dword_721110[v27]]; @@ -767,9 +604,9 @@ if ( v32->uAttributes & 0x10 ) *a5 = 1; } - v33 = dword_7211B0[v27]; - result = dword_7211B0[0]; - if ( v33 >= dword_7211B0[0] ) + v33 = floor_level[v27]; + result = floor_level[0]; + if ( v33 >= floor_level[0] ) result = v33; return result; }