Mercurial > mm7
diff mm7_4.cpp @ 1295:86a83e12d795
moving files
author | Ritor1 |
---|---|
date | Mon, 17 Jun 2013 17:34:01 +0600 |
parents | 2767980b98bb |
children | 8c2f689b5f0b |
line wrap: on
line diff
--- a/mm7_4.cpp Mon Jun 17 09:09:30 2013 +0600 +++ b/mm7_4.cpp Mon Jun 17 17:34:01 2013 +0600 @@ -214,400 +214,6 @@ } // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; -//----- (0046CEC3) -------------------------------------------------------- -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 - //int v16; // edx@19 - //int v17; // ST18_4@19 - //signed int v18; // edx@19 - //signed __int64 v19; // qtt@19 - int v21; // eax@27 - //int v22; // ecx@29 - signed int v28; // eax@45 - int v29; // ebx@47 - int v30; // edx@49 - //int v31; // ST10_4@49 - //signed int v32; // edx@49 - signed __int64 v33; // qtt@49 - //signed int v34; // eax@54 - //signed int v35; // esi@56 - //int result; // eax@57 - int v38; // edx@62 - //int v44; // [sp+20h] [bp-20h]@10 - 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 - signed int v53; // [sp+30h] [bp-10h]@10 - signed int v54; // [sp+30h] [bp-10h]@41 - signed int v55; // [sp+34h] [bp-Ch]@1 - - //LOG_DECOMPILATION_WARNING(); - - static int blv_floor_id[50]; // 00721200 - static int blv_floor_level[50]; // 007212C8 - - static __int16 word_721390_ys[104]; // idb - static __int16 word_721460_xs[104]; // idb - - auto pSector = &pIndoor->pSectors[uSectorID]; - v55 = 0; - for (uint i = 0; i < pSector->uNumFloors; ++i) - { - auto pFloor = &pIndoor->pFaces[pSector->pFloors[i]]; - if (pFloor->Clickable()) - continue; - - assert(pFloor->uNumVertices); - if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 && - y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1) - { - for (uint j = 0; j < pFloor->uNumVertices; ++j) - { - word_721460_xs[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; - word_721460_xs[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; - word_721390_ys[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; - word_721390_ys[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; - } - word_721460_xs[2 * pFloor->uNumVertices] = word_721460_xs[0]; - word_721390_ys[2 * pFloor->uNumVertices] = word_721390_ys[0]; - - v50 = word_721390_ys[0] >= y; - v53 = 0; - - for (uint j = 0; j < 2 * pFloor->uNumVertices; ++j) - { - if (v53 >= 2) - break; - - v48 = v50; - v50 = word_721390_ys[j + 1] >= y; - - v13 = i; - if (v48 == v50) - continue; - - v14 = word_721460_xs[j + 1] >= x ? 0 : 2; - v15 = v14 | (word_721460_xs[j] < x); - - if (v15 == 3) - continue; - else if (!v15) - ++v53; - else - { - auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); - auto res = fixpoint_sub0((signed int)word_721460_xs[j + 1] - (signed int)word_721460_xs[j], a_div_b); - - if (res + word_721460_xs[j] >= x) - ++v53; - } - } - - - if ( v53 == 1 ) - { - if ( v55 >= 50 ) - break; - if ( pFloor->uPolygonType == POLYGON_Floor || pFloor->uPolygonType == POLYGON_Ceiling ) - { - v21 = pIndoor->pVertices[pFloor->pVertexIDs[0]].z; - } - else - { - v21 = fixpoint_sub0(pFloor->zCalc1, x) + fixpoint_sub0(pFloor->zCalc2, y) + (short)(pFloor->zCalc3 >> 16); - } - blv_floor_level[v55] = v21; - blv_floor_id[v55] = pSector->pFloors[i]; - v55++; - } - } - } - - - if ( pSector->field_0 & 8 ) - { - for (uint i = 0; i < pSector->uNumPortals; ++i) - { - auto portal = &pIndoor->pFaces[pSector->pPortals[i]]; - if (portal->uPolygonType != POLYGON_Floor) - continue; - - if (!portal->uNumVertices) - continue; - - 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) - { - word_721460_xs[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; - word_721460_xs[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; - word_721390_ys[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; - word_721390_ys[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; - } - word_721460_xs[2 * portal->uNumVertices] = word_721460_xs[0]; - word_721390_ys[2 * portal->uNumVertices] = word_721390_ys[0]; - v54 = 0; - v47 = word_721390_ys[0] >= y; - - for (uint j = 0; j < 2 * portal->uNumVertices; ++j) - { - v49 = v47; - if ( v54 >= 2 ) - break; - v47 = word_721390_ys[j + 1] >= y; - if ( v49 != v47 ) - { - v28 = word_721460_xs[j + 1] >= x ? 0 : 2; - v29 = v28 | (word_721460_xs[j] < x); - if ( v29 != 3 ) - { - if ( !v29 ) - ++v54; - else - { - auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); - auto res = fixpoint_sub0(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b); - if (res + word_721460_xs[j] >= x) - ++v54; - } - } - } - } - if ( v54 == 1 ) - { - if ( v55 >= 50 ) - break; - blv_floor_level[v55] = -29000; - blv_floor_id[v55] = pSector->pPortals[i]; - v55++; - } - } - } - } - if ( v55 == 1 ) - { - *pFaceID = blv_floor_id[0]; - return blv_floor_level[0]; - } - if ( !v55 ) - return -30000; - *pFaceID = blv_floor_id[0]; - //result = blv_floor_level[0]; - - /*for ( v35 = 1; v35 < v55; ++v35 ) - { - if ( blv_floor_level[0] <= z + 5 ) - { - if ( blv_floor_level[v35] >= blv_floor_level[0] || blv_floor_level[v35] > z + 5 ) - continue; - blv_floor_level[0] = blv_floor_level[v35]; - *pFaceID = blv_floor_id[v35]; - continue; - } - if ( blv_floor_level[v35] < blv_floor_level[0] ) - { - blv_floor_level[0] = blv_floor_level[v35]; - *pFaceID = blv_floor_id[v35]; - } - }*/ - - - int result = blv_floor_level[0]; - for (uint i = 1; i < v55; ++i) - { - v38 = blv_floor_level[i]; - if ( result <= z + 5 ) - { - if ( v38 > result && v38 <= z + 5 ) - { - result = blv_floor_level[i]; - *pFaceID = blv_floor_id[i]; - } - } - else if ( v38 < result ) - { - result = blv_floor_level[i]; - *pFaceID = blv_floor_id[i]; - } - } - - return result; -} - -//----- (0046D49E) -------------------------------------------------------- -int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int __unused, int *pIsOnWater, int *a6, int bWaterWalk) -{ - BSPModel *pBModel; // esi@4 - ODMFace *pFace; // ecx@11 - int v14; // edx@20 - signed int v18; // edx@26 - int v19; // eax@28 - int v20; // edx@30 - int v21; // ST1C_4@30 - signed int v22; // edx@30 - signed __int64 v23; // qtt@30 - int v24; // eax@36 - signed int v25; // ecx@38 - int result; // eax@42 - signed int v27; // ecx@43 - int v28; // edi@44 - signed int v29; // edx@44 - int v30; // esi@45 - int v31; // eax@45 - ODMFace *v32; // eax@57 - int v33; // ecx@59 - int v36; // [sp+14h] [bp-2Ch]@24 - int v38; // [sp+1Ch] [bp-24h]@2 - int v39; // [sp+20h] [bp-20h]@9 - 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 v46; // [sp+3Ch] [bp-4h]@1 - signed int v48; // [sp+58h] [bp+18h]@22 - signed int v49; // [sp+58h] [bp+18h]@43 - - v46 = 1; - dword_721160[0] = -1; - dword_721110[0] = -1; - odm_floor_level[0] = GetTerrainHeightsAroundParty2(X, Y, pIsOnWater, bWaterWalk); - - for ( pBModelNum = 0; pBModelNum < pOutdoor->uNumBModels; ++pBModelNum ) - { - pBModel = &pOutdoor->pBModels[pBModelNum]; - if ( X <= pBModel->sMaxX && X >= pBModel->sMinX && - Y <= pBModel->sMaxY && Y >= pBModel->sMinY ) - { - if ( pBModel->uNumFaces > 0 ) - { - v39 = 0; - for ( pFaceNum = 0; pFaceNum < pBModel->uNumFaces; ++pFaceNum ) - { - pFace = &pBModel->pFaces[pFaceNum]; - 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 ) - { - - for ( uint i = 0; i < pFace->uNumVertices; ++i) - { - 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 ) - { - v18 = word_721040[i + 1] >= X ? 0 : 2; - v19 = v18 | (word_721040[i] < X); - if ( v19 != 3 ) - { - if ( !v19 ) - ++v48; - else - { - 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; - } - } - } - v43 = v44; - } - if ( v48 == 1 ) - { - if ( v46 >= 20 ) - break; - if ( pFace->uPolygonType == POLYGON_Floor ) - v24 = pBModel->pVertices.pVertices[pFace->pVertexIDs[0]].z; - else - v24 = ((unsigned __int64)(pFace->zCalc1 * (signed __int64)X) >> 16) + ((unsigned __int64)(pFace->zCalc2 * (signed __int64)Y) >> 16) - + HIWORD(pFace->zCalc3); - v25 = v46++; - odm_floor_level[v25] = v24; - dword_721160[v25] = pBModelNum; - dword_721110[v25] = pFaceNum; - } - } - } - - } - } - } - } - if ( v46 == 1 ) - { - *a6 = 0; - return odm_floor_level[0]; - } - v27 = 0; - if ( v46 <= 1 ) - *a6 = 0; - else - { - //v29 = 1; - for ( v49 = 1; v49 < v46; ++v49 ) - { - if ( odm_floor_level[v49] == odm_floor_level[0] ) - { - v27 = v49; - //++v29; - break; - } - if ( odm_floor_level[0] > Z + 5 ) - { - if ( odm_floor_level[v49] >= odm_floor_level[0] ) - { - //++v29; - break; - } - v27 = v49; - //++v29; - break; - } - if ( odm_floor_level[v49] > odm_floor_level[0] && odm_floor_level[v49] <= Z + 5 ) - { - v27 = v49; - //++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]]; - *pIsOnWater = false; - if ( v32->Fluid()) - *pIsOnWater = true; - } - if ( odm_floor_level[v27] >= odm_floor_level[0] ) - odm_floor_level[0] = odm_floor_level[v27]; - return odm_floor_level[0]; -} - //----- (0046D8E3) -------------------------------------------------------- int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4) { @@ -820,79 +426,6 @@ return dword_720F20[v22]; } -//not sure if right- or left-handed coordinate space assumed, so this could be normal of inverse normal -// for a right-handed system, that would be an inverse normal -//----- (0046DCC8) -------------------------------------------------------- -void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out) -{ - auto grid_x = WorldPosToGridCellX(pos_x); - auto grid_z = WorldPosToGridCellZ(pos_z) - 1; - - auto grid_pos_x1 = GridCellToWorldPosX(grid_x); - auto grid_pos_x2 = GridCellToWorldPosX(grid_x + 1); - auto grid_pos_z1 = GridCellToWorldPosZ(grid_z); - auto grid_pos_z2 = GridCellToWorldPosZ(grid_z + 1); - - auto x1z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z); - auto x2z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z); - auto x2z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1); - auto x1z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1); - - float side1_dx, side1_dy, side1_dz, - side2_dx, side2_dy, side2_dz; - - auto dx = abs(pos_x - grid_pos_x1), - dz = abs(grid_pos_z1 - pos_z); - if (dz >= dx) - { - side1_dy = (double)(x1z1_y - x1z2_y); - side2_dy = (double)(x2z2_y - x1z2_y); - side2_dx = (double)(grid_pos_x2 - grid_pos_x1); - side1_dx = (double)(grid_pos_x1 - grid_pos_x2); - side2_dz = 0.0;//(double)(grid_pos_z2 - grid_pos_z2); // bug? z2 - z2 - side1_dz = (double)(grid_pos_z1 - grid_pos_z2); // z1 - z2 yes - //Log::Warning(L"%S %S %u\n", __FILE__, __FUNCTION__, __LINE__); - /* |\ - side1 | \ - |____\ - side 2 */ - } - else - { - side1_dy = (double)(x2z2_y - x2z1_y); - side2_dy = (double)(x1z1_y - x2z1_y); - side2_dx = (double)(grid_pos_x1 - grid_pos_x2); - side1_dx = (double)(grid_pos_x2 - grid_pos_x1); - side2_dz = 0.0;//(double)(grid_pos_z1 - grid_pos_z1); - side1_dz = (double)(grid_pos_z2 - grid_pos_z1); - - /* side 2 - _____ - \ | - \ | side 1 - \| */ - } - - float nx = side1_dy * side2_dz - side1_dz * side2_dy; - float ny = side1_dx * side2_dy - side1_dy * side2_dx; - float nz = side1_dz * side2_dx - side1_dx * side2_dz; - - float mag = sqrt(nx * nx + ny * ny + nz * nz); - if (fabsf(mag) < 1e-6f) - { - out->y = 0; - out->x = 0; - out->z = 65536; - } - else - { - float invmag = 1.0 / mag; - out->x = invmag * nx * 65536.0; - out->y = invmag * ny * 65536.0; - out->z = invmag * nz * 65536.0; - } -} - //----- (0046DEF2) -------------------------------------------------------- unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID) { @@ -904,75 +437,6 @@ return result; } -//----- (0046DF1A) -------------------------------------------------------- -signed int __fastcall _46DF1A_collide_against_actor(int a1, int a2) -{ - Actor *v2; // edi@1 - unsigned __int16 v3; // ax@1 - int v4; // esi@6 - int v5; // ecx@8 - int v6; // eax@10 - int v7; // edx@12 - int v8; // ecx@14 - int v9; // eax@14 - int v10; // ebx@14 - int v11; // esi@14 - int v12; // ebx@15 - int v13; // ebx@17 - unsigned int v14; // eax@20 - signed int result; // eax@21 - int v16; // [sp+Ch] [bp-10h]@1 - int v17; // [sp+10h] [bp-Ch]@14 - int v18; // [sp+14h] [bp-8h]@14 - int v19; // [sp+18h] [bp-4h]@14 - - v16 = a1; - v2 = &pActors[a1]; - v3 = v2->uAIState; - if ( v3 == 11 || v3 == 4 || v3 == 19 || v3 == 5 || v3 == 17 ) - goto LABEL_25; - v4 = v2->uActorRadius; - if ( a2 ) - v4 = a2; - v5 = v2->vPosition.x; - if ( stru_721530.sMaxX > v5 + v4 - || stru_721530.sMinX < v5 - v4 - || (v6 = v2->vPosition.y, stru_721530.sMaxY > v6 + v4) - || stru_721530.sMinY < v6 - v4 - || (v7 = v2->vPosition.z, stru_721530.sMaxZ > v7 + v2->uActorHeight) - || stru_721530.sMinZ < v7 - || (v8 = v5 - stru_721530.normal.x, - v9 = v6 - stru_721530.normal.y, - v10 = stru_721530.prolly_normal_d + v4, - v17 = stru_721530.prolly_normal_d + v4, - v11 = (v8 * stru_721530.field_58.y - v9 * stru_721530.field_58.x) >> 16, - v18 = v8, - v19 = v9, - abs((v8 * stru_721530.field_58.y - v9 * stru_721530.field_58.x) >> 16) > v10) - || (v12 = (v18 * stru_721530.field_58.x + v19 * stru_721530.field_58.y) >> 16, v12 <= 0) - || (signed int)(((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v12) >> 16) + stru_721530.normal.z) < v2->vPosition.z ) - { -LABEL_25: - result = 0; - } - else - { - v13 = v12 - integer_sqrt(v17 * v17 - v11 * v11); - if ( v13 < 0 ) - v13 = 0; - if ( v13 < stru_721530.field_7C ) - { - stru_721530.field_7C = v13; - v14 = 8 * v16; - LOBYTE(v14) = PID(OBJECT_Actor,v16); - stru_721530.uFaceID = v14; - } - result = 1; - } - return result; -} -// 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); - //----- (0046E0B2) -------------------------------------------------------- void __cdecl _46E0B2_collide_against_decorations() { @@ -1065,123 +529,6 @@ } } -//----- (0046E26D) -------------------------------------------------------- -void __fastcall _46E26D_collide_against_sprites(signed int a1, signed int a2) -{ - int v2; // edx@5 - unsigned __int16 *v3; // eax@5 - unsigned __int16 v4; // ax@6 - LevelDecoration *v5; // edi@7 - DecorationDesc *v6; // esi@8 - int v7; // edx@9 - int v8; // eax@9 - int v9; // ecx@11 - int v10; // ebx@13 - int v11; // esi@13 - int v12; // ebp@15 - int v13; // ebx@15 - int v14; // esi@16 - int v15; // edi@17 - int v16; // eax@17 - int v17; // esi@19 - char v18; // zf@23 - int v19; // [sp+0h] [bp-10h]@15 - unsigned __int16 *v20; // [sp+4h] [bp-Ch]@5 - int v21; // [sp+8h] [bp-8h]@15 - int v22; // [sp+Ch] [bp-4h]@13 - - if ( a1 >= 0 ) - { - if ( a1 <= 127 ) - { - if ( a2 >= 0 ) - { - if ( a2 <= 127 ) - { - v2 = a1 + (a2 << 7); - v3 = &pOutdoor->pFaceIDLIST[pOutdoor->pOMAP[v2]]; - v20 = &pOutdoor->pFaceIDLIST[pOutdoor->pOMAP[v2]]; - if ( v3 ) - { - do - { - v4 = *v3; - if ( PID_TYPE(v4) == OBJECT_Decoration) - { - v5 = &pLevelDecorations[(signed __int16)v4 >> 3]; - if ( !(v5->field_2 & 0x20) ) - { - v6 = &pDecorationList->pDecorations[v5->uDecorationDescID]; - if (!v6->CanMoveThrough()) - { - v7 = v6->uRadius; - v8 = v5->vPosition.x; - if ( stru_721530.sMaxX <= v8 + v7 ) - { - if ( stru_721530.sMinX >= v8 - v7 ) - { - v9 = v5->vPosition.y; - if ( stru_721530.sMaxY <= v9 + v7 ) - { - if ( stru_721530.sMinY >= v9 - v7 ) - { - v10 = v6->uDecorationHeight; - v11 = v5->vPosition.z; - v22 = v10; - if ( stru_721530.sMaxZ <= v11 + v10 ) - { - if ( stru_721530.sMinZ >= v11 ) - { - v12 = v8 - stru_721530.normal.x; - v19 = v9 - stru_721530.normal.y; - v13 = stru_721530.prolly_normal_d + v7; - v21 = ((v8 - stru_721530.normal.x) * stru_721530.field_58.y - - (v9 - stru_721530.normal.y) * stru_721530.field_58.x) >> 16; - if ( abs(v21) <= stru_721530.prolly_normal_d + v7 ) - { - v14 = (v12 * stru_721530.field_58.x + v19 * stru_721530.field_58.y) >> 16; - if ( v14 > 0 ) - { - v15 = v5->vPosition.z; - v16 = stru_721530.normal.z - + ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v14) >> 16); - if ( v16 >= v15 ) - { - if ( v16 <= v22 + v15 ) - { - v17 = v14 - integer_sqrt(v13 * v13 - v21 * v21); - if ( v17 < 0 ) - v17 = 0; - if ( v17 < stru_721530.field_7C ) - { - stru_721530.field_7C = v17; - stru_721530.uFaceID = (signed __int16)*v20; - } - } - } - } - } - } - } - } - } - } - } - } - } - } - v3 = v20 + 1; - v18 = *v20 == 0; - ++v20; - } - while ( !v18 ); - } - } - } - } - } -} - //----- (00486F92) -------------------------------------------------------- void __cdecl sr_sub_486F92_MessWithEdgesAndSpans() { @@ -1428,28 +775,6 @@ } // 4EC3EC: using guessed type Edge defaultEdge; -//----- (00487355) -------------------------------------------------------- -bool OutdoorCamera::_487355() -{ - int v0; // esi@1 - stru148 *v1; // edi@2 - bool result; // eax@3 - - v0 = 0; - if ( pOutdoorCamera->numStru148s > 0 ) - { - v1 = array_77EC08.data(); - do - { - result = pGame->pLightmapBuilder->_45D3C7(v1); - ++v0; - ++v1; - } - while ( v0 < pOutdoorCamera->numStru148s ); - } - return result; -} - //----- (00487DA9) -------------------------------------------------------- void __cdecl sub_487DA9() { @@ -1787,68 +1112,6 @@ } // 4ED498: using guessed type char byte_4ED498; -//----- (0049387A) -------------------------------------------------------- -int CycleCharacter(unsigned int _this) -{ - signed int result; // eax@1 - signed int v2; // ecx@2 - signed int v3; // ecx@8 - - result = uActiveCharacter; - if ( _this ) - { - v2 = 0; - while ( 1 ) - { - --result; - if ( result < 1 ) - result = 4; - if ( !pPlayers[result]->uTimeToRecovery ) - break; - ++v2; - if ( v2 >= 4 ) - return uActiveCharacter; - } - } - else - { - v3 = 0; - while ( 1 ) - { - ++result; - if ( result > 4 ) - result = 1; - if ( !pPlayers[result]->uTimeToRecovery ) - break; - ++v3; - if ( v3 >= 4 ) - return uActiveCharacter; - } - } - return result; -} -//----- (004938D1) -------------------------------------------------------- -void __fastcall Rest(unsigned int uHoursToSleep) -{ - unsigned int v1; // esi@1 - double v2; // st7@3 - Player **v3; // esi@3 - - v1 = uHoursToSleep; - if ( uHoursToSleep > 240 ) - InitializeActors(); - v2 = (double)(7680 * v1) * 0.033333335; - pParty->uTimePlayed += (signed __int64)v2; - v3 = &pPlayers[1]; - do - { - (*v3)->Recover((signed __int64)v2); - ++v3; - } - while ( (signed int)v3 <= (signed int)&pPlayers[4] ); - _494035_timed_effects__water_walking_damage__etc(); -} - //----- (00493938) -------------------------------------------------------- int __cdecl _493938_regenerate() { @@ -2980,244 +2243,6 @@ return 1; } -//----- (00494F3A) -------------------------------------------------------- -unsigned int IconFrameTable::FindIcon(const char *pIconName) -{ - IconFrameTable *v2; // esi@1 - int v3; // ebx@1 - unsigned int uID; // edi@1 - unsigned int result; // eax@4 - - v2 = this; - v3 = 0; - uID = 0; - if ( (signed int)this->uNumIcons <= 0 ) - { -LABEL_4: - result = 0; - } - else - { - while ( _stricmp(pIconName, v2->pIcons[v3].pAnimationName) ) - { - ++uID; - ++v3; - if ( (signed int)uID >= (signed int)v2->uNumIcons ) - goto LABEL_4; - } - result = uID; - } - return result; -} - -//----- (00494F70) -------------------------------------------------------- -IconFrame *IconFrameTable::GetFrame(unsigned int uIconID, unsigned int uFrameID) -{ - IconFrame *v3; // edi@1 - IconFrame *v4; // ecx@1 - __int16 v5; // dx@2 - int v6; // edx@3 - unsigned int v7; // eax@3 - char *i; // ecx@3 - int v9; // esi@5 - IconFrame *result; // eax@6 - - v3 = this->pIcons; - v4 = &v3[uIconID]; - if ( v4->uFlags & 1 && (v5 = v4->uAnimLength) != 0 ) - { - v6 = ((signed int)uFrameID >> 3) % (unsigned __int16)v5; - v7 = uIconID; - for ( i = (char *)&v4->uAnimTime; ; i += 32 ) - { - v9 = *(short *)i; - if ( v6 <= v9 ) - break; - v6 -= v9; - ++v7; - } - result = &v3[v7]; - } - else - { - result = &v3[uIconID]; - } - return result; -} - -//----- (00494FBF) -------------------------------------------------------- -void IconFrameTable::InitializeAnimation(unsigned int uIconID) -{ - IconFrameTable *v2; // esi@1 - unsigned int v3; // edi@3 - const char *i; // eax@3 - IconFrame *v5; // eax@5 - - v2 = this; - if ( (signed int)uIconID <= (signed int)this->uNumIcons && (uIconID & 0x80000000u) == 0 ) - { - v3 = uIconID; - for ( i = this->pIcons[uIconID].pTextureName; ; i = v5[v3].pTextureName ) - { - v2->pIcons[v3].uTextureID = pIcons_LOD->LoadTexture(i, TEXTURE_16BIT_PALETTE); - v5 = v2->pIcons; - if ( !(v5[v3].uFlags & 1) ) - break; - ++v3; - } - } -} - -//----- (0049500A) -------------------------------------------------------- -void IconFrameTable::ToFile() -{ - IconFrameTable *v1; // esi@1 - FILE *v2; // eax@1 - FILE *v3; // edi@1 - - auto Str = this; - - v1 = Str; - v2 = fopen("data\\dift.bin", "wb"); - v3 = v2; - if ( !v2 ) - Abortf("Unable to save dift.bin!"); - fwrite(v1, 4u, 1u, v2); - fwrite(v1->pIcons, 0x20u, v1->uNumIcons, v3); - fclose(v3); -} - -//----- (00495056) -------------------------------------------------------- -void IconFrameTable::FromFile(void *pSerialized) -{ - uNumIcons = *(int *)pSerialized; - pIcons = (IconFrame *)pAllocator->AllocNamedChunk(pIcons, 32 * uNumIcons, "I Frames"); - memcpy(pIcons, (char *)pSerialized + 4, 32 * uNumIcons); -} - -//----- (0049509D) -------------------------------------------------------- -int IconFrameTable::FromFileTxt(const char *Args) -{ - IconFrameTable *v2; // ebx@1 - FILE *v3; // eax@1 - int v4; // esi@3 - void *v5; // eax@10 - FILE *v6; // ST0C_4@12 - char *i; // eax@12 - const char *v8; // ST00_4@15 - int v9; // eax@16 - int v10; // edx@20 - int v11; // ecx@21 - int v12; // eax@22 - signed int j; // edx@25 - IconFrame *v14; // ecx@26 - int v15; // esi@26 - int k; // eax@27 - signed int result; // eax@11 - char Buf; // [sp+Ch] [bp-2F8h]@3 - FrameTableTxtLine v19; // [sp+200h] [bp-104h]@4 - FrameTableTxtLine v20; // [sp+27Ch] [bp-88h]@4 - int v21; // [sp+2F8h] [bp-Ch]@3 - int v22; // [sp+2FCh] [bp-8h]@3 - FILE *File; // [sp+300h] [bp-4h]@1 - int Argsa; // [sp+30Ch] [bp+8h]@26 - - v2 = this; - //TileTable::dtor((TileTable *)this); - v3 = fopen(Args, "r"); - File = v3; - if ( !v3 ) - Abortf("IconFrameTable::load - Unable to open file: %s.", Args); - v4 = 0; - v21 = 0; - v22 = 1; - if ( fgets(&Buf, 490, v3) ) - { - do - { - *strchr(&Buf, 10) = 0; - memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20)); - if ( v20.uPropCount && *v20.pProperties[0] != 47 ) - { - if ( v20.uPropCount < 3 ) - Abortf("IconFrameTable::loadText, too few arguments, %s line %i.", Args, v22); - ++v21; - } - ++v22; - } - while ( fgets(&Buf, 490, File) ); - v4 = v21; - } - v2->uNumIcons = v4; - v5 = pAllocator->AllocNamedChunk(v2->pIcons, 32 * v4, "I Frames"); - v2->pIcons = (IconFrame *)v5; - if ( v5 ) - { - v6 = File; - v2->uNumIcons = 0; - fseek(v6, 0, 0); - for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) - { - *strchr(&Buf, 10) = 0; - memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20)); - if ( v20.uPropCount && *v20.pProperties[0] != 47 ) - { - strcpy(v2->pIcons[v2->uNumIcons].pAnimationName, v20.pProperties[0]); - strcpy(v2->pIcons[v2->uNumIcons].pTextureName, v20.pProperties[1]); - v8 = v20.pProperties[2]; - v2->pIcons[v2->uNumIcons].uFlags = 0; - if ( !_stricmp(v8, "new") ) - { - v9 = (int)&v2->pIcons[v2->uNumIcons].uFlags; - *(char *)v9 |= 4u; - } - v2->pIcons[v2->uNumIcons].uAnimTime = atoi(v20.pProperties[3]); - v2->pIcons[v2->uNumIcons].uAnimLength = 0; - v2->pIcons[v2->uNumIcons++].uTextureID = 0; - } - } - fclose(File); - v10 = 0; - if ( (signed int)(v2->uNumIcons - 1) > 0 ) - { - v11 = 0; - do - { - v12 = (int)&v2->pIcons[v11]; - if ( !(*(char *)(v12 + 60) & 4) ) - *(char *)(v12 + 28) |= 1u; - ++v10; - ++v11; - } - while ( v10 < (signed int)(v2->uNumIcons - 1) ); - } - for ( j = 0; j < (signed int)v2->uNumIcons; *(short *)(Argsa + 26) = v15 ) - { - v14 = v2->pIcons; - Argsa = (int)&v14[j]; - v15 = *(short *)(Argsa + 24); - if ( *(char *)(Argsa + 28) & 1 ) - { - ++j; - for ( k = (int)&v14[j]; *(char *)(k + 28) & 1; k += 32 ) - { - v15 += *(short *)(k + 24); - ++j; - } - LOWORD(v15) = v14[j].uAnimTime + v15; - } - ++j; - } - result = 1; - } - else - { - fclose(File); - result = 0; - } - return result; -} - //----- (00495366) -------------------------------------------------------- char *__fastcall sub_495366(unsigned __int8 a1, unsigned __int8 a2) { @@ -6138,202 +5163,12 @@ } // F8B1E0: using guessed type int dword_F8B1E0; -//----- (004B1A2D) -------------------------------------------------------- -void __cdecl ShowPopupShopItem() -{ - POINT *v1; // esi@5 - unsigned int v2; // eax@5 - int v3; // ecx@5 - POINT *v4; // esi@12 - int v5; // eax@12 - unsigned int v6; // eax@13 - ItemGen *v7; // ecx@13 - signed int v8; // esi@17 - unsigned int v9; // eax@19 - POINT v10; // [sp+8h] [bp-44h]@12 - POINT v11; // [sp+10h] [bp-3Ch]@12 - POINT v12; // [sp+18h] [bp-34h]@18 - POINT v13; // [sp+20h] [bp-2Ch]@17 - POINT v14; // [sp+28h] [bp-24h]@17 - POINT v15; // [sp+30h] [bp-1Ch]@17 - POINT v16; // [sp+38h] [bp-14h]@5 - POINT a2; // [sp+40h] [bp-Ch]@5 - - if ( in_current_building_type <= 0 ) - return; - if ( in_current_building_type <= BildingType_AlchemistShop ) - { - if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) - { - if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_BUY_STANDARD) - return; - if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_REPAIR || dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT ) - { - v8 = pMouse->GetCursorPos(&v15)->x - 14; - v5 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos(&v14)->y - 17) >> 5); - if ( pMouse->GetCursorPos(&v13)->x <= 13 - || pMouse->GetCursorPos(&v12)->x >= 462 - || (v9 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v5)) == 0 ) - return; - GameUI_DrawItemInfo(&pPlayers[uActiveCharacter]->pInventoryItems[v9 - 1]); - return; - } - if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL ) - return; - } - v4 = pMouse->GetCursorPos(&v11); - v5 = pRenderer->pActiveZBuffer[v4->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v10)->y]] & 0xFFFF; - if ( !v5 ) - return; - v6 = 9 * (v5 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C); - v7 = (ItemGen *)((char *)&pParty->pPickedItem + 4 * v6 + 4); - if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) - v7 = &pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5 - 1]; - GameUI_DrawItemInfo(v7); - return; - } - if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) - { - v1 = pMouse->GetCursorPos(&a2); - v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y]; - v3 = pRenderer->pActiveZBuffer[v2] & 0xFFFF; - v5 = pRenderer->pActiveZBuffer[v2] & 0xFFFF; - if ( v5 ) - sub_4B1523((int *)&pParty->pPlayers[1].uExpressionTimeLength + 9 * (v3 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)); - } -} // F8B198: using guessed type int dword_F8B198; // F8B19C: using guessed type int dword_F8B19C; -//----- (004B1BDB) -------------------------------------------------------- -void __stdcall RestAndHeal(__int64 uNumMinutes) -{ - signed __int64 v1; // ST2C_8@1 - signed __int64 v2; // qax@1 - signed __int64 v3; // ST1C_8@1 - unsigned __int64 v4; // qax@1 - unsigned int v5; // ebx@1 - Player *v6; // ebx@1 - - pParty->pHirelings[0].bHasUsedTheAbility = 0; - pParty->pHirelings[1].bHasUsedTheAbility = 0; - pParty->uTimePlayed += (signed __int64)((double)(7680 * uNumMinutes) * 0.033333335); - v1 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); - v2 = v1 / 60 / 60; - v3 = v2; - v4 = (unsigned int)v2 / 0x18; - v5 = (unsigned int)(v4 / 7) >> 2; - pParty->uCurrentTimeSecond = v1 % 60; - pParty->uCurrentMinute = v1 / 60 % 60; - pParty->uCurrentHour = v3 % 24; - pParty->uCurrentMonthWeek = v4 / 7 & 3; - pParty->uDaysPlayed = (unsigned int)v4 % 0x1C; - pParty->uCurrentMonth = v5 % 0xC; - pParty->uCurrentYear = v5 / 0xC + game_starting_year; - pParty->RestAndHeal(); - dword_507B94 = 1; - v6 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay; - do - { - v6->uTimeToRecovery = 0; - memset(&v6->uTimeToRecovery, 0, 4u); - ++v6; - } - while ( v6 <= &pParty->pPlayers[3] ); - pParty->UpdatePlayersAndHirelingsEmotions(); -} + // 507B94: using guessed type int dword_507B94; -//----- (004B1D27) -------------------------------------------------------- -void __cdecl sub_4B1D27() -{ - int v0; // edx@2 - unsigned int v1; // ecx@7 - signed int v2; // edi@10 - int v3; // esi@10 - __int16 v4; // ax@15 - signed int v5; // edi@20 - int v6; // esi@20 - int v7[4]; // [sp+Ch] [bp-10h]@12 - - if ( in_current_building_type > 0 ) - { - v0 = 3; - if ( in_current_building_type > BildingType_MagicShop ) - { - if ( in_current_building_type == BildingType_Bank ) - { - if ( !dword_F8B1E4 ) - return; - } - else - { - if ( in_current_building_type != BildingType_Temple ) - return; - } - v1 = (unsigned int)window_SpeakInHouse->ptr_1C; - PlayHouseSound(v1, (HouseSoundID)v0); - return; - } - v1 = (unsigned int)window_SpeakInHouse->ptr_1C; - if ( (signed __int64)pParty->field_3C._shop_ban_times[v1 ]<= (signed __int64)pParty->uTimePlayed ) - { - if ( pParty->uNumGold <= 0x2710 ) - { - if ( !dword_F8B1E4 ) - return; - v0 = 4; - PlayHouseSound(v1, (HouseSoundID)v0); - return; - } - PlayHouseSound(v1, (HouseSoundID)(dword_F8B1E4 + 3)); - if ( !dword_F8B1E4 && !qword_A750D8 ) - { - v5 = 0; - v6 = 1; - do - { - if ( pPlayers[v6]->CanAct() ) - v7[v5++] = v6; - ++v6; - } - while ( v6 <= 4 ); - if ( v5 ) - { - qword_A750D8 = 256i64; - word_A750E0 = 80; - v4 = LOWORD(v7[rand() % v5]); - word_A750E2 = v4; - return; - } - } - } - else - { - if ( !qword_A750D8 ) - { - v2 = 0; - v3 = 1; - do - { - if ( pPlayers[v3]->CanAct() ) - v7[v2++] = v3; - ++v3; - } - while ( v3 <= 4 ); - if ( v2 ) - { - qword_A750D8 = 256i64; - word_A750E0 = 80; - v4 = LOWORD(v7[rand() % v2]); - word_A750E2 = v4; - return; - } - } - } - } -} - //----- (004B1ECE) -------------------------------------------------------- void __cdecl sub_4B1ECE() { @@ -6434,285 +5269,6 @@ // 722B44: using guessed type int dword_722B44; // F8B1A8: using guessed type int dword_F8B1A8; -//----- (004B2001) -------------------------------------------------------- -void __fastcall ClickNPCTopic(signed int uMessageParam) -{ - //signed int v1; // eax@1 - NPCData *pCurrentNPCInfo; // ebp@1 - int pEventNumber; // ecx@8 - Player *v4; // esi@20 - //int v5; // eax@28 - //int v6; // eax@31 - //int v7; // eax@34 - //int v8; // eax@37 - //int v9; // eax@40 - //unsigned int v10; // eax@43 - char *v12; // eax@53 - char *v13; // eax@56 - char *v14; // eax@57 - char *v15; // eax@58 - //unsigned int v16; // ebp@62 - char *v17; // ecx@63 - char *v18; // eax@65 - const char *v19; // ecx@68 - //unsigned int v20; // eax@69 - signed int pPrice; // ecx@70 - char *v22; // [sp-Ch] [bp-18h]@73 - //int v23; // [sp-8h] [bp-14h]@49 - char *v24; // [sp-8h] [bp-14h]@73 - //int v25; // [sp-4h] [bp-10h]@49 - - uDialogueType = uMessageParam + 1; - pCurrentNPCInfo = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 - if ( uMessageParam <= 24 ) - { - switch ( uMessageParam ) - { - case 13: - current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession); - current_npc_text = BuilDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); - NPCHireableDialogPrepare(); - dialogue_show_profession_details = false; - goto _return; - case 19: - pEventNumber = pCurrentNPCInfo->evt_A; - break; - case 20: - pEventNumber = pCurrentNPCInfo->evt_B; - break; - case 21: - pEventNumber = pCurrentNPCInfo->evt_C; - break; - case 22: - pEventNumber = pCurrentNPCInfo->evt_D; - break; - case 23: - pEventNumber = pCurrentNPCInfo->evt_E; - break; - case 24: - pEventNumber = pCurrentNPCInfo->evt_F; - break; - default: - goto _return; - } - /*switch ( pEventNumber ) - { - case 139: - sub_4B1ECE(); - goto _return; - case 311: - sub_4BBA85_bounties(); - goto _return; - }*/ - if ( pEventNumber < 200 || pEventNumber > 310 ) - { - if ( pEventNumber < 400 || pEventNumber > 410 ) - { - if ( pEventNumber == 139 ) - { - sub_4B1ECE(); - } - else - { - if ( pEventNumber == 311 ) - { - sub_4BBA85_bounties(); - } - else - { - current_npc_text = 0; - activeLevelDecoration = (LevelDecoration*)1; - EventProcessor(pEventNumber, 0, 1); - activeLevelDecoration = NULL; - } - } - } - else - { - dword_F8B1D8 = uMessageParam; - DrawJoinGuildWindow(pEventNumber - 400); - } - } - else - { - sub_4B3FE5(pEventNumber); - } - goto _return; - } - if ( uMessageParam != 76 ) - { - if ( uMessageParam == 77 ) - { - //v16 = pCurrentNPCInfo->uProfession; - if (dialogue_show_profession_details) - v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText; - else - v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pBenefits; - current_npc_text = v17; - v18 = BuilDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0); - dialogue_show_profession_details = ~dialogue_show_profession_details; - current_npc_text = v18; - } - else - { - if ( uMessageParam == 79 ) - { - if ( contract_approved ) - { - Party::TakeGold(gold_transaction_amount); - if ( uActiveCharacter ) - { - v12 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; - *(short *)v12 &= 0x3Fu; - switch ( dword_F8B1B0 ) - { - case 2: - v15 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; - *v15 |= 0x40u; - break; - case 3: - v14 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; - *v14 |= 0x80u; - break; - case 4: - v13 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; - v13[1] |= 1u; - break; - } - pPlayers[uActiveCharacter]->PlaySound(SPEECH_85, 0); - } - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - } - } - else - { - if ( uMessageParam == 82 && contract_approved ) //join guild - { - Party::TakeGold(gold_transaction_amount); - v4 = pParty->pPlayers; - do - { - v4->SetVariable(VAR_Award, dword_F8B1AC_award_bit_number); - ++v4; - } - while ( (signed int)v4 < (signed int)pParty->pHirelings ); - switch ( dword_F8B1D8 ) - { - case 19: - pEventNumber = pCurrentNPCInfo->evt_A; - if ( pEventNumber >= 400 && pEventNumber <= 416 ) - pCurrentNPCInfo->evt_A = 0; - break; - case 20: - pEventNumber = pCurrentNPCInfo->evt_B; - if ( pEventNumber >= 400 && pEventNumber <= 416 ) - pCurrentNPCInfo->evt_B = 0; - break; - case 21: - pEventNumber = pCurrentNPCInfo->evt_C; - if ( pEventNumber >= 400 && pEventNumber <= 416 ) - pCurrentNPCInfo->evt_C = 0; - break; - case 22: - pEventNumber = pCurrentNPCInfo->evt_D; - if ( pEventNumber >= 400 && pEventNumber <= 416 ) - pCurrentNPCInfo->evt_D = 0; - break; - case 23: - pEventNumber = pCurrentNPCInfo->evt_E; - if ( pEventNumber >= 400 && pEventNumber <= 416 ) - pCurrentNPCInfo->evt_E = 0; - break; - case 24: - pEventNumber = pCurrentNPCInfo->evt_F; - if ( pEventNumber >= 400 && pEventNumber <= 416) - pCurrentNPCInfo->evt_F = 0; - break; - } - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - //v11 = uActiveCharacter; - if ( uActiveCharacter ) - { - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_86, 0); - goto _return; - } - } - } - } - goto _return; - } - if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[533], 2);// ""I cannot join you, you're party is full"" - goto _return; - } - if ( pCurrentNPCInfo->uProfession != 51 ) - { - pPrice = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].uHirePrice; - if ( pParty->uNumGold < pPrice ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); - dialogue_show_profession_details = false; - uDialogueType = 13; - current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText; - current_npc_text = BuilDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); - goto _return; - } - Party::TakeGold(pPrice); - } - //LOBYTE(v2->uFlags) |= 0x80u; - pCurrentNPCInfo->uFlags |= 128; - pParty->field_709 = 0; - pParty->CountHirelings(); - if ( pParty->pHirelings[0].pName ) - { - memcpy(&pParty->pHirelings[1], pCurrentNPCInfo, sizeof(pParty->pHirelings[1])); - v24 = pCurrentNPCInfo->pName; - v22 = pParty->pHireling2Name; - } - else - { - memcpy(pParty->pHirelings, pCurrentNPCInfo, 0x4Cu); - v24 = pCurrentNPCInfo->pName; - v22 = pParty->pHireling1Name; - } - strcpy(v22, v24); - pParty->field_709 = 0; - pParty->CountHirelings(); - PrepareHouse((HOUSE_ID)(int)window_SpeakInHouse->ptr_1C); - dialog_menu_id = HOUSE_DIALOGUE_MAIN; - - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)61, 0); -_return: - pVideoPlayer->_4BF5B2();//HouseVideo -} - //----- (004B254D) -------------------------------------------------------- char *__thiscall _4B254D_SkillMasteryTeacher(int _this) { @@ -7086,366 +5642,6 @@ return pTmpBuf2.data(); } -//----- (004B29F2) -------------------------------------------------------- -const char * ContractSelectText( int pEventCode ) - { -static const int dialogue_base=110; - contract_approved = 0; - dword_F8B1AC_award_bit_number = pEventCode + 50; - gold_transaction_amount = price_for_membership[pEventCode]; - if ( pPlayers[uActiveCharacter]->CanAct() ) - { - if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_guilds_member_bits, dword_F8B1AC_award_bit_number) ) - { - return pNPCTopics[dialogue_base+13].pText; - } - else - { - if ( gold_transaction_amount <= pParty->uNumGold ) - { - contract_approved = 1; - return pNPCTopics[pEventCode + dialogue_base].pText; - } - else - { - return pNPCTopics[dialogue_base+14].pText; - } - } - } - else - { - return pNPCTopics[dialogue_base+12].pText; - } -} - -//----- (004B2A74) -------------------------------------------------------- -void SimpleHouseAndBoatsDialog() -{ - char *v0; // esi@3 - char *v1; // ST1C_4@3 - char *v2; // eax@3 - const char *v3; // ST1C_4@5 - int v4; // eax@5 - unsigned int i; // eax@5 - NPCData *v6; // esi@6 - unsigned __int16 v7; // bx@6 - unsigned int v8; // eax@6 - int v9; // eax@11 - unsigned int v10; // ecx@12 - int v11; // eax@12 - int v12; // esi@12 - char *v13; // eax@12 - GUIWindow *v14; // ebx@13 - char *v15; // esi@14 - GUIButton *v16; // eax@15 - unsigned int v17; // ecx@15 - int v18; // ecx@17 - int v19; // ecx@18 - int v20; // ecx@19 - int v21; // ecx@20 - int v22; // ecx@21 - unsigned int v23; // ecx@23 - int v24; // ecx@35 - int v25; // ecx@36 - int v26; // ecx@37 - int v27; // ecx@38 - int v28; // ecx@39 - char *v29; // esi@42 - unsigned int v30; // ST20_4@42 - int v31; // ST1C_4@42 - unsigned int v32; // eax@42 - char *v33; // eax@43 - int v34; // esi@51 - int v35; // eax@51 - unsigned int v36; // edi@51 - GUIButton *v37; // eax@52 - int v38; // eax@52 - signed int v39; // ecx@54 - int v40; // edi@57 - GUIButton *v41; // eax@60 - GUIButton *v42; // esi@60 - const char *v43; // ebx@60 - int v44; // eax@60 - unsigned int v45; // ecx@60 - unsigned __int16 v46; // ax@60 - GUIFont *v47; // ebx@64 - int v48; // esi@64 - char *v49; // eax@66 - GUIWindow w; // [sp+Ch] [bp-110h]@64 - GUIWindow v52; // [sp+60h] [bp-BCh]@13 - GUIWindow a1; // [sp+B4h] [bp-68h]@1 - unsigned int v54; // [sp+108h] [bp-14h]@14 - int v55; // [sp+10Ch] [bp-10h]@6 - int v56; // [sp+110h] [bp-Ch]@13 - char *pInString; // [sp+114h] [bp-8h]@12 - NPCData *v58; // [sp+118h] [bp-4h]@6 - - memcpy(&a1, pDialogueWindow, sizeof(a1)); - if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) - { - v0 = pMapStats->pInfos[uHouse_ExitPic].pName; - v1 = pMapStats->pInfos[uHouse_ExitPic].pName; - a1.uFrameX = 493; - a1.uFrameWidth = 126; - a1.uFrameZ = 366; - a1.DrawTitleText(pFontCreate, 0, 2u, 0, v1, 3u); - a1.uFrameX = 483; - a1.uFrameWidth = 148; - a1.uFrameZ = 334; - v2 = pTransitionStrings[uHouse_ExitPic]; - if ( !v2 ) - { - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[411], v0); - v2 = pTmpBuf.data(); - } - v3 = v2; - v4 = pFontCreate->CalcTextHeight(v2, &a1, 0, 0); - a1.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, v3, 3u); - return; - } - a1.uFrameWidth -= 10; - a1.uFrameZ -= 10; - v58 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 - v6 = v58; - v55 = TargetColor(0xE1u, 0xCDu, 0x23u); - v7 = TargetColor(0x15u, 0x99u, 0xE9u); - v8 = v6->uProfession; - if ( v8 ) - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v8]); - else - strcpy(pTmpBuf.data(), v6->pName); - a1.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, v7, pTmpBuf.data(), 3u); - if ( !dword_591080 ) - { - if ( !uDialogueType ) - { - v9 = v6->greet; - if ( v9 ) - { - v10 = v6->uFlags; - a1.uFrameWidth = game_viewport_width; - a1.uFrameZ = 452; - pInString = (char *)*(&pNPCStats->field_17884 + ((v10 & 3) == 2) + 2 * v9); - v11 = pFontArrus->CalcTextHeight(pInString, &a1, 13, 0); - v12 = v11 + 7; - pRenderer->_4A6A68(8, 352 - (v11 + 7), - pIcons_LOD->GetTexture(uTextureID_Leather), - pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - (v11 + 7)); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pFontArrus, &a1, 0xDu, 0); - pDialogueWindow->DrawText(pFontArrus, 13, 354 - v12, 0, v13, 0, 0, 0); - } - } - } - v14 = pDialogueWindow; - memcpy(&v52, pDialogueWindow, sizeof(v52)); - v52.uFrameX = 483; - v52.uFrameWidth = 148; - v52.uFrameZ = 334; - v56 = v52.pStartingPosActiveItem; - if ( v52.pStartingPosActiveItem < v52.pStartingPosActiveItem + v52.pNumPresenceButton ) - { - v15 = "";//(char *)v54; - while ( 1 ) - { - v16 = v52.GetControl(v56); - v17 = v16->msg_param; - pInString = (char *)v16; - if ( (signed int)v17 > 24 ) - { - v24 = v17 - 76; - if ( !v24 ) - { - v15 = pGlobalTXT_LocalizationStrings[406]; - goto LABEL_49; - } - v25 = v24 - 1; - if ( !v25 ) - { - v15 = pGlobalTXT_LocalizationStrings[407]; - goto LABEL_49; - } - v26 = v25 - 2; - if ( !v26 ) - { - v33 = _4B254D_SkillMasteryTeacher((int)v52.ptr_1C); -LABEL_44: - v15 = v33; -LABEL_45: - v16 = (GUIButton *)pInString; - goto LABEL_49; - } - v27 = v26 - 3; - if ( !v27 ) - { - v33 = (char *)ContractSelectText((int)v52.ptr_1C); - goto LABEL_44; - } - v28 = v27 - 1; - if ( !v28 ) - { - v29 = (char *)&pMonsterStats + 88 * word_F8B1A0; - v30 = TargetColor(0xFFu, 0xFFu, 0xFFu); - v31 = *(int *)v29; - v32 = TargetColor(0xFFu, 0xFFu, 0x9Bu); - sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", v32, v31, v30); - sprintfex(pTmpBuf2.data(), dword_F8B1A4, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]); - current_npc_text = pTmpBuf2.data(); - v15 = ""; - goto LABEL_45; - } - if ( v28 != 10 ) - goto LABEL_41; - } - else - { - if ( v17 == 24 ) - { - v23 = v58->evt_F; -LABEL_33: - v15 = (char *)pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v15 ) - { - v16->msg_param = 0; - v15 = ""; - } - goto LABEL_49; - } - v18 = v17 - 13; - if ( v18 ) - { - v19 = v18 - 6; - if ( !v19 ) - { - v23 = v58->evt_A; - goto LABEL_33; - } - v20 = v19 - 1; - if ( !v20 ) - { - v15 = (char *)pNPCTopics[v58->evt_B-1].pTopic;//(&dword_721660)[8 * v58->evtb]; - if ( !v15 ) - { - v16->msg_param = 0; - v15 = ""; - } - if ( uDialogueType != 84 ) - goto LABEL_49; - sprintf(pTmpBuf.data(), format_4E2D80, v55, pItemsTable->pItems[contract_approved].pUnidentifiedName); - sprintf(pTmpBuf2.data(), current_npc_text, pTmpBuf.data()); - current_npc_text = pTmpBuf2.data(); - goto LABEL_45; - } - v21 = v20 - 1; - if ( !v21 ) - { - v23 = v58->evt_C; - goto LABEL_33; - } - v22 = v21 - 1; - if ( !v22 ) - { - v23 = v58->evt_D; - goto LABEL_33; - } - if ( v22 == 1 ) - { - v23 = v58->evt_E; - goto LABEL_33; - } -LABEL_41: - v15 = ""; - goto LABEL_49; - } - v15 = pGlobalTXT_LocalizationStrings[122]; - } -LABEL_49: - strcpy(v16->pButtonName, v15); - ++v56; - if ( v56 >= v52.pStartingPosActiveItem + v52.pNumPresenceButton ) - { - v14 = pDialogueWindow; - break; - } - } - } - v34 = 0; - v54 = TargetColor(0xFFu, 0xFFu, 0xFFu); - v35 = TargetColor(0xE1u, 0xCDu, 0x23u); - v36 = v14->pStartingPosActiveItem; - v55 = v35; - for ( i = v36 + v14->pNumPresenceButton; (signed int)v36 < (signed int)i; i = pDialogueWindow->pNumPresenceButton - + pDialogueWindow->pStartingPosActiveItem ) - { - v37 = v14->GetControl(v36); - v38 = pFontArrus->CalcTextHeight(v37->pButtonName, &v52, 0, 0); - v14 = pDialogueWindow; - v34 += v38; - ++v36; - } - v39 = v14->pNumPresenceButton; - if ( v39 ) - { - v58 = (NPCData *)((174 - v34) / v39); - if ( (signed int)v58 > 32 ) - v58 = (NPCData *)32; - pInString = (char *)2; - v40 = (174 - (signed int)v58 * v39 - v34) / 2 - (signed int)v58 / 2 + 138; - v56 = v14->pStartingPosActiveItem; - i = v56; - if ( (signed int)i < (signed int)(i + v39) ) - { - while ( 1 ) - { - v41 = v14->GetControl(i); - v42 = v41; - v43 = v41->pButtonName; - v41->uY = (unsigned int)((char *)v58 + v40); - v44 = pFontArrus->CalcTextHeight(v41->pButtonName, &v52, 0, 0); - v45 = v42->uY; - v42->uHeight = v44; - v40 = v45 + v44 - 1; - v42->uW = v40; - v46 = v55; - if ( (char *)pDialogueWindow->pCurrentPosActiveItem != pInString ) - v46 = v54; - v52.DrawTitleText(pFontArrus, 0, v45, v46, v43, 3u); - v14 = pDialogueWindow; - ++pInString; - ++v56; - i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; - if ( v56 >= (signed int)i ) - break; - i = v56; - } - } - } - if ( current_npc_text ) - { - w.uFrameWidth = 458; - w.uFrameZ = 457; - v47 = pFontArrus; - v48 = pFontArrus->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; - if ( 352 - v48 < 8 ) - { - v47 = pFontCreate; - v48 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v48, - pIcons_LOD->GetTexture(uTextureID_Leather), - pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - v48); - pRenderer->DrawTextureIndexed(8u, 347 - v48, pTexture_591428); - v49 = FitTextInAWindow(current_npc_text, v47, &w, 0xDu, 0); - a1.DrawText(v47, 13, 354 - v48, 0, v49, 0, 0, 0); - } -} - -//----- (004B36CC) -------------------------------------------------------- -void CreateButtonInColumn( int column_pos, unsigned int control_id ) -{ - pDialogueWindow->CreateButton( 480, 30 * column_pos + 146, 140, 30, 1, 0, UIMSG_SelectShopDialogueOption, control_id, 0, "", 0); -} - //----- (004B3A72) -------------------------------------------------------- void sub_4B3A72( int a1 ) { @@ -7711,20 +5907,6 @@ pDialogueWindow->_41D08F_set_keyboard_control_group(v1 + 1, 1, 0, 1); } -//----- (004B3EF0) -------------------------------------------------------- -void DrawJoinGuildWindow( int pEventCode ) -{ - uDialogueType = 81;//enum JoinGuildDialog - current_npc_text = (char *)pNPCTopics[pEventCode + 99].pText; - ContractSelectText(pEventCode); - pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, pEventCode, 0); - pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uExitCancelTextureId), 0); // Cancel - pDialogueWindow->CreateButton( 0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); - pDialogueWindow->CreateButton(480, 160, 140, 30, 1, 0, UIMSG_ClickNPCTopic, 0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0); - pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2); - dialog_menu_id = HOUSE_DIALOGUE_OTHER; -} // F8B19C: using guessed type int dword_F8B19C; //----- (004B3FE5) -------------------------------------------------------- @@ -7752,150 +5934,6 @@ // F8B19C: using guessed type int dword_F8B19C; // F8B1A8: using guessed type int dword_F8B1A8; -//----- (004B40E6) -------------------------------------------------------- -void NPCHireableDialogPrepare() - { - signed int v0; // ebx@1 - NPCData *v1; // edi@1 - - v0 = 0; - v1 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 - pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, 0, 0); - pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, - pGlobalTXT_LocalizationStrings[34], //"Cancel" - pIcons_LOD->GetTexture(uExitCancelTextureId), - 0); - pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); - if ( pNPCStats->pProfessions[v1->uProfession].pBenefits)//*(&pNPCStats->field_13A5C + 5 * v1->uProfession) ) - { - pDialogueWindow->CreateButton( 0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Du, 0, - pGlobalTXT_LocalizationStrings[407], 0);//"More Information" - v0 = 1; - } - pDialogueWindow->CreateButton( 0x1E0u, 30 * v0 + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Cu, 0, - pGlobalTXT_LocalizationStrings[406], 0); //"Hire" - pDialogueWindow->_41D08F_set_keyboard_control_group(v0 + 1, 1, 0, 2); - dialog_menu_id = HOUSE_DIALOGUE_OTHER; -} - -//----- (004B4224) -------------------------------------------------------- -void _4B4224_UpdateNPCTopics( int _this ) - { - int num_menu_buttons; // ebx@1 - int i; // ebp@5 - // signed int v4; // ebp@9 - int v6; // eax@16 - int v8; // eax@21 - int v10; // eax@26 - int v12; // eax@31 - int v14; // eax@36 - int v16; // eax@41 - NPCData *v17; // [sp+10h] [bp-4h]@4 - - num_menu_buttons = 0; - pDialogueNPCCount = (_this + 1); - if ( _this + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic ) - { - pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); - sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S], pMapStats->pInfos[uHouse_ExitPic].pName); - pBtn_ExitCancel = pDialogueWindow->CreateButton(566, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);// "Cancel" - pBtn_YES = pDialogueWindow->CreateButton(486, 445, 75, 33, 1, 0, UIMSG_BF, 1, 'Y', sHouseName.data(), pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0); - pDialogueWindow->CreateButton( pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63u, 73u, 1, 0, UIMSG_BF, 1u, 0x20u, sHouseName.data(), 0); - pDialogueWindow->CreateButton(8, 8, 460, 344, 1, 0, UIMSG_BF, 1, 0x59u, sHouseName.data(), 0); - } - else - { - v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0) )];//+ 1 - if ( dialog_menu_id == HOUSE_DIALOGUE_OTHER ) - { - pDialogueWindow->Release(); - } - else - { - for ( i = 0; i < uNumDialogueNPCPortraits; ++i ) - dword_5913F4[i]->Release(); - } - pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); - pBtn_ExitCancel = pDialogueWindow->CreateButton( 471u, 445u, 169u, 35u, 1, 0, UIMSG_Escape, 0, 0, - pGlobalTXT_LocalizationStrings[74],// "End Conversation" - pIcons_LOD->GetTexture(uExitCancelTextureId), 0); - pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); - if ( pDialogueNPCCount == 1 && dword_591080 ) - { - sub_4B3B42(in_current_building_type); - } - else - { - if ( v17->joins ) - { - num_menu_buttons = 1; - pDialogueWindow->CreateButton(480u, 160u, 140u, 30, 1, 0, UIMSG_ClickNPCTopic, 0xDu, 0, "", 0); - } - if ( v17->evt_A) - { - if ( num_menu_buttons < 4 ) - { - v6 = NPC_EventProcessor(v17->evt_A); - if ( v6 == 1 || v6 == 2 ) - pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, UIMSG_ClickNPCTopic, 0x13u, 0, "", 0); - } - } - if ( v17->evt_B ) - { - if ( num_menu_buttons < 4 ) - { - v8 = NPC_EventProcessor(v17->evt_B); - if ( v8 == 1 || v8 == 2 ) - pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, UIMSG_ClickNPCTopic, 0x14u, 0, "", 0); - } - } - if ( v17->evt_C ) - { - if ( num_menu_buttons < 4 ) - { - v10 = NPC_EventProcessor(v17->evt_C); - if ( v10 == 1 || v10 == 2 ) - pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, UIMSG_ClickNPCTopic, 0x15u, 0, "", 0); - } - } - - if ( v17->evt_D ) - { - if ( num_menu_buttons < 4 ) - { - v12 = NPC_EventProcessor(v17->evt_D); - if ( v12 == 1 || v12 == 2 ) - pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x16u, 0, "", 0); - } - } - if ( v17->evt_E ) - { - if ( num_menu_buttons < 4 ) - { - v14 = NPC_EventProcessor(v17->evt_E); - if ( v14 == 1 || v14 == 2 ) - pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x17u, 0, "", 0); - } - } - if ( v17->evt_F ) - { - if ( num_menu_buttons < 4 ) - { - v16 = NPC_EventProcessor(v17->evt_F); - if ( v16 == 1 || v16 == 2 ) - pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x18u, 0, "", 0); - } - } - pDialogueWindow->_41D08F_set_keyboard_control_group(num_menu_buttons, 1, 0, 2); - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; - } - dialog_menu_id = HOUSE_DIALOGUE_MAIN; - } - -} - //----- (004B46A5) -------------------------------------------------------- void __fastcall DrawTextAtStatusBar( const char *Str, int a5 ) { @@ -8484,273 +6522,4 @@ v1->_406FA8(); } } -} - -//----- (0043FDED) -------------------------------------------------------- -void PrepareActorRenderList_BLV() -{ - RenderBillboard *v0; // esi@0 - unsigned __int16 v3; // ax@3 - unsigned int v4; // eax@5 - unsigned __int16 v5; // cx@5 - int v6; // esi@5 - unsigned int v7; // eax@7 - int v8; // eax@10 - SpriteFrame *v9; // eax@16 - SpriteFrame *v10; // ebx@18 - //int *v11; // eax@18 - int v12; // ecx@28 - //IndoorCameraD3D **v14; // eax@36 - double v15; // st7@36 - float v16; // eax@36 - //double v17; // ST30_8@36 - signed __int64 v18; // qtt@36 - int v19; // ST5C_4@36 - signed __int64 v20; // qtt@37 - int v21; // ST5C_4@37 - signed __int16 v22; // cx@39 - int v23; // ST50_4@40 - signed int v24; // ecx@40 - int v25; // edx@44 - __int16 v26; // ax@44 - //MonsterDesc *v27; // edx@44 - //int v28; // ecx@44 - unsigned __int8 v29; // zf@44 - unsigned __int8 v30; // sf@44 - unsigned int v31; // [sp-8h] [bp-5Ch]@15 - int v32; // [sp+1Ch] [bp-38h]@5 - int a3; // [sp+20h] [bp-34h]@5 - int a2; // [sp+24h] [bp-30h]@5 - int a1a; // [sp+28h] [bp-2Ch]@5 - __int16 a5; // [sp+2Ch] [bp-28h]@5 - int a5a; // [sp+2Ch] [bp-28h]@36 - int a5b; // [sp+2Ch] [bp-28h]@40 - __int16 v41; // [sp+3Ch] [bp-18h]@18 - int a6; // [sp+40h] [bp-14h]@34 - int v43; // [sp+44h] [bp-10h]@34 - int z; // [sp+48h] [bp-Ch]@32 - signed int y; // [sp+4Ch] [bp-8h]@32 - int x; // [sp+50h] [bp-4h]@32 - - for (uint i = 0; i < uNumActors; ++i) - { - auto p = &pActors[i]; - - if (p->uAIState == Removed || - p->uAIState == Disabled) - continue; - - a5 = p->uSectorID; - a2 = p->vPosition.y; - a1a = p->vPosition.x; - a3 = p->vPosition.z; - v4 = stru_5C6E00->Atan2(a1a - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y); - LOWORD(v0) = p->uYawAngle; - v5 = p->uCurrentActionAnimation; - v6 = ((signed int)((char *)v0 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v4 + stru_5C6E00->uIntegerPi) >> 8) & 7; - v32 = v6; - if ( pParty->bTurnBasedModeOn ) - { - if ( v5 == 1 ) - { - v7 = pMiscTimer->uTotalGameTimeElapsed; - goto LABEL_10; - } - } - else - { - if ( v5 == 1 ) - { - v7 = pBLVRenderParams->field_0_timer_; -LABEL_10: - v8 = i * 32 + v7; - goto LABEL_12; - } - } - v8 = p->uCurrentActionTime; -LABEL_12: - if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 ) - v8 = 0; - v31 = p->pSpriteIDs[v5]; - if (p->uAIState == Resurrected) - v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8); - else - v9 = pSpriteFrameTable->GetFrame(v31, v8); - v41 = 0; - v10 = v9; - //v11 = (int *)v9->uFlags; - if (v9->uFlags & 2) - v41 = 2; - if (v9->uFlags & 0x40000) - v41 |= 0x40u; - if (v9->uFlags & 0x20000) - LOBYTE(v41) = v41 | 0x80; - v0 = (RenderBillboard *)(256 << v6); - if ( (unsigned int)v0 & v9->uFlags) - v41 |= 4u; - if ( v10->uGlowRadius ) - { - //LOBYTE(v11) = byte_4E94D3; - pMobileLightsStack->AddLight( - a1a, - a2, - a3, - a5, - v10->uGlowRadius, - 0xFFu, - 0xFFu, - 0xFFu, - byte_4E94D3); - } - v12 = 0; - if ( pBspRenderer->uNumVisibleNotEmptySectors <= 0 ) - continue; - while (pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v12] != p->uSectorID) - { - ++v12; - if ( v12 >= pBspRenderer->uNumVisibleNotEmptySectors ) - goto _continue; - } - if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1) - || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) ) - continue; - pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6); - v0 = &pBillboardRenderList[uNumBillboardsToDraw]; - if (uNumBillboardsToDraw >= 500) - break; - ++uNumBillboardsToDraw; - ++uNumSpritesDrawnThisFrame; - p->uAttributes |= 8u; - v29 = pRenderer->pRenderD3D == 0; - v0->uHwSpriteID = v10->pHwSpriteIDs[v32]; - v0->uPalette = v10->uPaletteIndex; - v0->uIndoorSectorID = a5; - if ( v29 ) - { - LODWORD(v20) = pBLVRenderParams->field_40 << 16; - HIDWORD(v20) = pBLVRenderParams->field_40 >> 16; - v21 = v20 / x; - v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v20 / x) >> 16; - a5a = (unsigned __int64)(v10->scale * (signed __int64)v21) >> 16; - } - else - { - //v14 = &pGame->pIndoorCameraD3D; - v0->fov_x = pGame->pIndoorCameraD3D->fov_x; - v15 = pGame->pIndoorCameraD3D->fov_y; - v16 = v0->fov_x; - v0->fov_y = v15; - //v17 = v16 + 6.7553994e15; - LODWORD(v18) = 0; - HIDWORD(v18) = floorf(v16 + 0.5f); - v19 = v18 / x; - v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v18 / x) >> 16; - a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16; - } - v0->_screenspace_y_scaler_packedfloat = a5a; - if ( (signed __int64)p->pActorBuffs[3].uExpireTime <= 0 ) - { - if ( (signed __int64)p->pActorBuffs[10].uExpireTime > 0 ) - { - a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; - goto LABEL_43; - } - } - else - { - v22 = p->pActorBuffs[3].uPower; - if ( v22 ) - { - v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->_screenspace_x_scaler_packedfloat) >> 16; - v24 = p->pActorBuffs[3].uPower; - v0->_screenspace_x_scaler_packedfloat = v23; - a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; -LABEL_43: - v0->_screenspace_y_scaler_packedfloat = a5b; - goto LABEL_44; - } - } -LABEL_44: - HIWORD(v25) = HIWORD(x); - v0->world_x = a1a; - v0->world_y = a2; - v0->world_z = a3; - v0->uScreenSpaceX = v43; - v0->uScreenSpaceY = a6; - LOWORD(v25) = 0; - LOBYTE(v26) = v41; - - //v0->sZValue = v25 + (PID(OBJECT_Actor,i)); - v0->actual_z = HIWORD(x); - v0->object_pid = PID(OBJECT_Actor,i); - - v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0; - v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0; - v0->field_1E = v41; - v0->pSpriteFrame = v10; - v0->uTintColor = pMonsterList->pMonsters[p->pMonsterInfo.uID - 1].uTintColor; - if ( !v30 && (!(v30 | v29) || LODWORD(p->pActorBuffs[5].uExpireTime)) ) - { - HIBYTE(v26) = HIBYTE(v41) | 1; - v0->field_1E = v26; - } - -_continue: - ; - } -} - -//----- (00444732) -------------------------------------------------------- -char *GetEventHintString(unsigned int uEventID) -{ - signed int event_index; // edx@1 - int event_pos; // esi@4 - char *result; // eax@6 - unsigned int str_index; // eax@9 - int i; // esi@11 - _evt_raw* test_evt; - _evt_raw* last_evt; - - event_index = 0; - if ( uLevelEVT_NumEvents <= 0 ) - return NULL; - - //v2 = (char *)&pLevelEVT_Index[0].uEventOffsetInEVT; - while ( 1 ) - { - if ( pLevelEVT_Index[event_index].uEventID == uEventID ) - { - test_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; - last_evt=test_evt; - event_pos = pLevelEVT_Index[event_index+1].uEventOffsetInEVT; - if ( test_evt->_e_type == EVENT_MouseOver ) - break; - } - ++event_index; - if ( event_index >= uLevelEVT_NumEvents ) - return NULL; - } - test_evt=(_evt_raw*)&pLevelEVT[event_pos]; - if ( test_evt->_e_type== EVENT_SpeakInHouse ) - { - str_index = EVT_DWORD(test_evt->v5); - result = (char *)p2DEvents[str_index - 1].pName; - } - else - { - for ( i = event_index+1; pLevelEVT_Index[i].uEventID == uEventID; ++i ) - { - event_pos = pLevelEVT_Index[i].uEventOffsetInEVT; - test_evt=(_evt_raw*)&pLevelEVT[event_pos]; - if ( test_evt->_e_type == EVENT_SpeakInHouse ) - { - str_index = EVT_DWORD(test_evt->v5); - if ( str_index < 600 ) - return (char *)p2DEvents[str_index - 1].pName; - } - } - result = &pLevelStr[pLevelStrOffsets[EVT_BYTE(last_evt->v5)]]; - } - - return result; -} +} \ No newline at end of file