Mercurial > might-and-magic-trilogy
diff mm7_4.cpp @ 77:8b0c4d626477
Party movement
author | Nomad |
---|---|
date | Sun, 28 Oct 2012 18:51:52 +0200 |
parents | 75994455e457 |
children | 517e33e08d93 |
line wrap: on
line diff
--- a/mm7_4.cpp Sat Oct 27 22:25:38 2012 +0200 +++ b/mm7_4.cpp Sun Oct 28 18:51:52 2012 +0200 @@ -234,15 +234,15 @@ // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; //----- (0046CEC3) -------------------------------------------------------- -int __fastcall _46CEC3_get_floor_level(signed int a1, signed int a2, int a3, 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 _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 v13; // ecx@13 signed int v14; // ebx@14 @@ -254,9 +254,9 @@ PolygonType v20; // al@25 int v21; // eax@27 int v22; // ecx@29 - BLVFace *v23; // eax@33 - int v24; // esi@39 - int v25; // edi@39 + //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 @@ -270,80 +270,86 @@ int result; // eax@57 int v37; // edi@61 int v38; // edx@62 - int v39; // [sp+Ch] [bp-34h]@1 - int v40; // [sp+10h] [bp-30h]@2 + //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 + //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 + //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 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 - - __debugbreak(); - - v5 = &pIndoor->pSectors[uSectorID]; - v57 = a2; - v56 = a1; - v6 = 0; + //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 ) - { - v40 = (int)&v42[v6]; - v8 = &pIndoor->pFaces[*(short *)v40]; - if ( !(BYTE3(v8->uAttributes) & 0x20) - && v56 <= v8->pBounding.x2 - && v56 >= v8->pBounding.x1 - && v57 <= v8->pBounding.y2 - && v57 >= v8->pBounding.y1 ) - { - v52 = 0; - if ( v8->uNumVertices ) - { - do - { - v9 = v52; - v10 = 2 * v52; - word_721460[2 * v52] = v8->pXInterceptDisplacements[v52] + v7[v8->pVertexIDs[v52]].x; - word_721390[2 * v52] = v8->pYInterceptDisplacements[v9] + v7[v8->pVertexIDs[v9]].y; - word_721460[2 * v52++ + 1] = v8->pXInterceptDisplacements[v9] + v7[v8->pVertexIDs[v9 + 1]].x; - word_721390[v10 + 1] = v8->pYInterceptDisplacements[v9] + v7[v8->pVertexIDs[v9 + 1]].y; - } - while ( v52 < v8->uNumVertices ); - v5 = v43; - } - v44 = 2 * v8->uNumVertices; - v11 = 2 * v8->uNumVertices; - word_721460[v11] = word_721460[0]; - word_721390[v11] = word_721390[0]; - v48 = word_721390[0] >= v57; + //v43 = v5; + //v42 = v5->pFloors; + //v7 = pIndoor->pVertices; + //v39 = v5->uNumFloors; + //for ( uSectorIDa = 0; uSectorIDa < v39; ++uSectorIDa ) + 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; + + 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 ( v44 > 0 ) + if ( pFloor->uNumVertices > 0 ) { do { if ( v53 >= 2 ) break; v41 = word_721390[v12 + 1]; - v50 = word_721390[v12 + 1] >= v57; + v50 = word_721390[v12 + 1] >= y; if ( v48 == v50 ) { v13 = v45; @@ -351,24 +357,24 @@ else { v13 = v45; - if ( word_721460[v45 + 1] >= v56 ) + if ( word_721460[v45 + 1] >= x ) v14 = 0; else v14 = 2; - v15 = v14 | word_721460[v45] < v56; + v15 = v14 | word_721460[v45] < x; if ( v15 != 3 ) { if ( !v15 || (v16 = word_721390[v45], v17 = v41 - v16, - v18 = v57 - v16, + v18 = y - v16, LODWORD(v19) = v18 << 16, HIDWORD(v19) = v18 >> 16, - v7 = pIndoor->pVertices, + //v7 = pIndoor->pVertices, (signed int)(((unsigned __int64)(((signed int)word_721460[v45 + 1] - (signed int)word_721460[v45]) * v19 / v17) >> 16) - + word_721460[v45]) >= v56) ) + + word_721460[v45]) >= x) ) ++v53; } } @@ -377,62 +383,66 @@ v45 = v12; } while ( v12 < v44 ); + if ( v53 == 1 ) { if ( v55 >= 50 ) break; - v20 = v8->uPolygonType; + v20 = pFloor->uPolygonType; if ( v20 == 3 || v20 == 5 ) { - v21 = v7[*v8->pVertexIDs].z; + v21 = pIndoor->pVertices[*pFloor->pVertexIDs].z; } else { - v7 = pIndoor->pVertices; - v21 = ((unsigned __int64)(v8->zCalc1 * (signed __int64)v56) >> 16) - + ((unsigned __int64)(v8->zCalc2 * (signed __int64)v57) >> 16) - + HIWORD(v8->zCalc3); + //v7 = pIndoor->pVertices; + v21 = ((unsigned __int64)(pFloor->zCalc1 * (signed __int64)x) >> 16) + + ((unsigned __int64)(pFloor->zCalc2 * (signed __int64)y) >> 16) + + HIWORD(pFloor->zCalc3); } v22 = v55++; dword_7212C8[v22] = v21; - dword_721200[v22] = *(short *)v40; - } - } - } - v6 = uSectorIDa + 1; - } - if ( v5->field_0 & 8 ) - { - for ( uSectorIDb = 0; uSectorIDb < v5->uNumPortals; ++uSectorIDb ) - { - v23 = &pIndoor->pFaces[v5->pPortals[uSectorIDb]]; - if ( v23->uPolygonType == 3 - && v56 <= v23->pBounding.x2 - && v56 >= v23->pBounding.x1 - && v57 <= v23->pBounding.y2 - && v57 >= v23->pBounding.y1 ) - { - v46 = 0; - if ( v23->uNumVertices ) - { - do - { - v24 = v46; - v25 = 2 * v46; - word_721460[2 * v46] = v23->pXInterceptDisplacements[v46] + v7[v23->pVertexIDs[v46]].x; - word_721390[2 * v46] = v23->pYInterceptDisplacements[v24] + v7[v23->pVertexIDs[v24]].y; - word_721460[2 * v46++ + 1] = v23->pXInterceptDisplacements[v24 + 1] + v7[v23->pVertexIDs[v24 + 1]].x; - word_721390[v25 + 1] = v23->pYInterceptDisplacements[v24 + 1] + v7[v23->pVertexIDs[v24 + 1]].y; - } - while ( v46 < v23->uNumVertices ); - v5 = v43; - } - v26 = 2 * v23->uNumVertices; - word_721460[2 * v23->uNumVertices] = word_721460[0]; - word_721390[v26] = word_721390[0]; + dword_721200[v22] = pSector->pFloors[i]; + } + } + } + //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; + 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] >= v57; + v49 = word_721390[0] >= y; if ( v26 > 0 ) { do @@ -440,27 +450,27 @@ if ( v54 >= 2 ) break; v27 = v51; - v47 = word_721390[v51 + 1] >= v57; + v47 = word_721390[v51 + 1] >= y; if ( v49 != v47 ) { - if ( word_721460[v27 + 1] >= v56 ) + if ( word_721460[v27 + 1] >= x ) v28 = 0; else v28 = 2; - v29 = v28 | word_721460[v27] < v56; + v29 = v28 | word_721460[v27] < x; if ( v29 != 3 ) { if ( !v29 || (v30 = word_721390[v27], v31 = word_721390[v51 + 1] - v30, - v32 = v57 - v30, + v32 = y - v30, LODWORD(v33) = v32 << 16, HIDWORD(v33) = v32 >> 16, - v7 = pIndoor->pVertices, + //v7 = pIndoor->pVertices, (signed int)(((unsigned __int64)(((signed int)word_721460[v27 + 1] - (signed int)word_721460[v27]) * v33 / v31) >> 16) - + word_721460[v27]) >= v56) ) + + word_721460[v27]) >= x) ) ++v54; } } @@ -474,12 +484,13 @@ break; v34 = v55++; dword_7212C8[v34] = -29000; - dword_721200[v34] = v5->pPortals[uSectorIDb]; - } - } - } - } - } + dword_721200[v34] = pSector->pPortals[i]; + } + } + } + } + } + v35 = 1; if ( v55 == 1 ) { @@ -492,7 +503,7 @@ result = dword_7212C8[0]; if ( v55 > 1 ) { - v37 = a3 + 5; + v37 = z + 5; while ( 1 ) { v38 = dword_7212C8[v35];