Mercurial > might-and-magic-trilogy
changeset 73:f6758e4c6506
Слияние
author | Ritor1 |
---|---|
date | Sat, 27 Oct 2012 23:53:04 +0600 |
parents | 636f4dbd156d (current diff) 47736b43558d (diff) |
children | 08ab7b5b85d8 |
files | mm7_4.cpp |
diffstat | 19 files changed, 458 insertions(+), 749 deletions(-) [+] |
line wrap: on
line diff
--- a/DecalBuilder.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/DecalBuilder.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -146,6 +146,8 @@ DecalBuilder *thisa; // [sp+40h] [bp-8h]@1 RenderVertexSoft *a11; // [sp+44h] [bp-4h]@8 + __debugbreak(); + auto a9 = uSectorID; thisa = this;
--- a/Game.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/Game.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -667,22 +667,15 @@ //----- (0044EDE4) -------------------------------------------------------- -bool Game::_44EDE4(BLVFace *pFace, int *a3) +bool Game::AlterGamma(BLVFace *pFace, unsigned int *pColor) { - bool result; // eax@1 - - result = (bool)pGame; - if ( pGame->uFlags2 & 2 && (result = (bool)pFace, pFace->uAttributes & 2) ) + if (pGame->uFlags2 & 2 && pFace->uAttributes & 2) { - result = sub_48A959(*a3, 1.0, this->_E28_timed_gamma_strength, -1.0); - *a3 = result; - LOBYTE(result) = 1; + *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); + return true; } else - { - LOBYTE(result) = 0; - } - return result; + return false; } //----- (0044EE30) -------------------------------------------------------- @@ -690,7 +683,7 @@ { if (uFlags2 & 0x2 && a2->uAttributes & 0x02) { - *(int *)a3 = sub_48A959(*(int *)a3, 1.0, _E28_timed_gamma_strength, -1.0); + *(int *)a3 = ReplaceHSV(*(int *)a3, 1.0, fSaturation, -1.0); return true; } else @@ -763,12 +756,12 @@ v4 = (double)a4; a2a = v4; *a3 |= 2u; - a3a = (1.0 - this->_E28_timed_gamma_strength) * v4; + a3a = (1.0 - this->fSaturation) * v4; //v5 = a3a + 6.7553994e15; //if ( SLODWORD(v5) >= 0 ) if (floorf(a3a + 0.5f) >= 0 ) { - a3b = (1.0 - this->_E28_timed_gamma_strength) * a2a; + a3b = (1.0 - this->fSaturation) * a2a; //v7 = a3b + 6.7553994e15; //v6 = LODWORD(v7); v6 = floorf(a3b + 0.5f); @@ -779,12 +772,12 @@ } if ( a4 >= v6 ) { - a4a = (1.0 - _E28_timed_gamma_strength) * a2a; + a4a = (1.0 - fSaturation) * a2a; //v9 = a4a + 6.7553994e15; //if ( SLODWORD(v9) >= 0 ) if (floorf(a4a + 0.5f) >= 0) { - a4b = (1.0 - _E28_timed_gamma_strength) * a2a; + a4b = (1.0 - fSaturation) * a2a; //v10 = a4b + 6.7553994e15; //result = LODWORD(v10); result = floorf(a4b + 0.5f); @@ -843,11 +836,11 @@ v4 = (double)a4; v11 = v4; *a3 |= 2u; - v12 = (1.0 - this->_E28_timed_gamma_strength) * v4; + v12 = (1.0 - this->fSaturation) * v4; //v5 = v12 + 6.7553994e15; if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 ) { - v13 = (1.0 - this->_E28_timed_gamma_strength) * v11; + v13 = (1.0 - this->fSaturation) * v11; //v7 = v13 + 6.7553994e15; //v6 = LODWORD(v7); v6 = floorf(v13 + 0.5f); @@ -858,11 +851,11 @@ } if ( a4 >= v6 ) { - v14 = (1.0 - _E28_timed_gamma_strength) * v11; + v14 = (1.0 - fSaturation) * v11; //v9 = v14 + 6.7553994e15; if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 ) { - v15 = (1.0 - _E28_timed_gamma_strength) * v11; + v15 = (1.0 - fSaturation) * v11; //v10 = v15 + 6.7553994e15; //result = LODWORD(v10); result = floorf(v15 + 0.5f); @@ -1018,9 +1011,9 @@ v7 = 1.0; } if ( pRenderer->pRenderD3D ) - _E28_timed_gamma_strength = v7; + fSaturation = v7; else - _E28_timed_gamma_strength = (1.0 - 0.5) * v7 + 0.5; + fSaturation = (1.0 - 0.5) * v7 + 0.5; } //----- (0044EA17) --------------------------------------------------------
--- a/Game.h Sat Oct 27 23:52:40 2012 +0600 +++ b/Game.h Sat Oct 27 23:53:04 2012 +0600 @@ -92,7 +92,7 @@ void OutlineSelection(); signed int _44EC23(struct stru148 *a2, int *a3, signed int a4); signed int _44ED0A(struct BLVFace *a2, int *a3, signed int a4); - bool _44EDE4(struct BLVFace *pFace, int *a3); + bool AlterGamma(struct BLVFace *pFace, unsigned int *pColor); bool _44EE30(struct ODMFace *a2, int a3); bool draw_debug_outlines(); bool _44EEA7(); @@ -144,7 +144,7 @@ unsigned int bGammaControlInitialized; unsigned int uFlags; unsigned int uFlags2; - float _E28_timed_gamma_strength; + float fSaturation; unsigned __int64 uSomeGammaStartTime; __int64 uSomeGammaDeltaTime; ThreadWard *pThreadWardInstance;
--- a/Indoor.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/Indoor.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -451,21 +451,21 @@ //double v19; // st6@27 //double v20; // st5@27 //char v21; // dl@27 - unsigned int v22; // eax@44 + //unsigned int v22; // eax@44 unsigned int v23; // eax@35 DWORD v24; // eax@37 int v25; // eax@38 - char *v26; // edi@38 + //char *v26; // edi@38 IDirect3DTexture2 *v27; // eax@42 Texture *v28; // [sp+Ch] [bp-1Ch]@15 - int i; // [sp+10h] [bp-18h]@38 + //int i; // [sp+10h] [bp-18h]@38 //LightmapBuilder *pStru4; // [sp+14h] [bp-14h]@16 //IndoorCameraD3D *v31; // [sp+18h] [bp-10h]@16 //IndoorCameraD3D_Vec4 *a7; // [sp+1Ch] [bp-Ch]@1 //unsigned int uFaceID_; // [sp+20h] [bp-8h]@1 unsigned int uNumVerticesa; // [sp+24h] [bp-4h]@17 int a4a; // [sp+34h] [bp+Ch]@25 - unsigned int a4b; // [sp+34h] [bp+Ch]@38 + //unsigned int a4b; // [sp+34h] [bp+Ch]@38 //v4 = uFaceID; //a7 = pVertices; @@ -505,10 +505,11 @@ static_vertices_F7C228[i].u = (signed)pFace->pVertexUIDs[i]; static_vertices_F7C228[i].v = (signed)pFace->pVertexUIDs[i]; } - if ( !pVertices - || (pGame->pStru9Instance->_498377(a4, 4u, pVertices, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) ) - { - if ( pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum( + + if (!pVertices || + (pGame->pStru9Instance->_498377(a4, 4u, pVertices, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) ) + { + if (pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum( static_vertices_F7C228, &uNumVerticesa, static_vertices_F7B628, @@ -517,27 +518,28 @@ false, 0) != 1 || uNumVerticesa ) - { - a4a = SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel); - v17 = (248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | (((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | ((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) << 8)) << 8); - sub_4B0E07(uFaceID); - pGame->pLightmapBuilder->ApplyLights_IndoorFace(uFaceID); - pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID); - pGame->pIndoorCameraD3D->ViewTransfrom_OffsetUV(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28); - pGame->pIndoorCameraD3D->Project(array_507D30, uNumVerticesa, 0); - pGame->pLightmapBuilder->std__vector_000004_size = 0; - if (stru_F8AD28.uNumLightsApplied > 0 || - pDecalBuilder->uNumDecals > 0) - { - stru_F7B60C.face_plane.vNormal.x = pFace->pFacePlane.vNormal.x; - stru_F7B60C.polygonType = pFace->uPolygonType; - stru_F7B60C.face_plane.vNormal.y = pFace->pFacePlane.vNormal.y; - stru_F7B60C.face_plane.vNormal.z = pFace->pFacePlane.vNormal.z; - stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist; - } - if (stru_F8AD28.uNumLightsApplied > 0 && - !(pFace->uAttributes & 0x400000)) - pGame->pLightmapBuilder->ApplyLights( + { + a4a = SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel); + v17 = (248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | (((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | ((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) << 8)) << 8); + sub_4B0E07(uFaceID); + pGame->pLightmapBuilder->ApplyLights_IndoorFace(uFaceID); + pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID); + pGame->pIndoorCameraD3D->ViewTransfrom_OffsetUV(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28); + pGame->pIndoorCameraD3D->Project(array_507D30, uNumVerticesa, 0); + pGame->pLightmapBuilder->std__vector_000004_size = 0; + if (stru_F8AD28.uNumLightsApplied > 0 || + pDecalBuilder->uNumDecals > 0) + { + stru_F7B60C.face_plane.vNormal.x = pFace->pFacePlane.vNormal.x; + stru_F7B60C.polygonType = pFace->uPolygonType; + stru_F7B60C.face_plane.vNormal.y = pFace->pFacePlane.vNormal.y; + stru_F7B60C.face_plane.vNormal.z = pFace->pFacePlane.vNormal.z; + stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist; + } + + if (stru_F8AD28.uNumLightsApplied > 0 && + !(pFace->uAttributes & 0x400000)) + pGame->pLightmapBuilder->ApplyLights( &stru_F8AD28, &stru_F7B60C, uNumVerticesa, @@ -545,8 +547,8 @@ pVertices, 0); - if (pDecalBuilder->uNumDecals > 0) - pDecalBuilder->ApplyDecals( + if (pDecalBuilder->uNumDecals > 0) + pDecalBuilder->ApplyDecals( a4a, 1, &stru_F7B60C, @@ -555,52 +557,44 @@ pVertices, 0, pFace->uSectorID); - if (pFace->uAttributes & 0x10 && - pFace->uBitmapID == pRenderer->field_1036AC_bitmapid ) - { - v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; - goto LABEL_42; - } - if ( pFace->uAttributes & 0x10 ) - { - v24 = GetTickCount() >> 2; - if ( (signed int)uNumVerticesa > 0 ) - { - v25 = v24 - stru_5C6E00->uIntegerHalfPi; - v26 = (char *)&array_507D30[0].v; - a4b = uNumVerticesa; - for ( i = v25; ; v25 = i ) - { - *(float *)v26 = (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8)) - + *(float *)v26; - v26 += 48; - --a4b; - if ( !a4b ) - break; - } - } - } - else - { - v22 = pFace->uAttributes; - if ( BYTE1(v22) & 0x40 ) - { - v23 = pTextureFrameTable->GetFrameTexture( + + if (pFace->Animated() && + pFace->uBitmapID == pRenderer->field_1036AC_bitmapid ) + { + __debugbreak(); + v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; + goto LABEL_42; + } + + if (pFace->Animated()) + { + v24 = GetTickCount() / 4; + v25 = v24 - stru_5C6E00->uIntegerHalfPi; + + for (uint i = 0; i < uNumVerticesa; ++i) + array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8)); + + v23 = pFace->uBitmapID; + goto LABEL_42; + } + else + { + if (pFace->uAttributes & 0x4000) + { + v23 = pTextureFrameTable->GetFrameTexture( pFace->uBitmapID, pBLVRenderParams->field_0_timer_); LABEL_42: v27 = pBitmaps_LOD->pHardwareTextures[v23]; - if ( BYTE2(pFace->uAttributes) & 0x40 ) - sub_479A53(uNumVerticesa, uFaceID); + if (pFace->uAttributes & 0x400000) + _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); else pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | 6, v17, 0); return; - } - } - v23 = pFace->uBitmapID; - goto LABEL_42; - } - } + } + } + } + } } }
--- a/Indoor.h Sat Oct 27 23:52:40 2012 +0600 +++ b/Indoor.h Sat Oct 27 23:53:04 2012 +0600 @@ -251,6 +251,7 @@ #define FACE_TWO_SIDED 0x00000001 // portal/two-sided +// 0x02 color is saturated against lights #define FACE_TEXTURE_ANIMATED 0x00000010 // like wavy water #define FACE_INVISIBLE 0x00002000 #define FACE_TEXTURE_FRAME 0x00004000 // Texture ID is a frameset from TextureFrameTable, otherwise BitmapID
--- a/IndoorCameraD3D.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/IndoorCameraD3D.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -667,7 +667,7 @@ //v19 = pRenderer->pRenderD3D->pDevice; ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr)); ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_POINTLIST, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pD3DVertices, uNumD3DVertices, 16)); @@ -820,7 +820,7 @@ ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr)); ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( D3DPT_LINELIST, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v24, 2, 16));
--- a/Items.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/Items.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -1868,7 +1868,7 @@ unsigned int v48; // ecx@123 int v49; // eax@123 int v50; // eax@123 - unsigned int Dst; // [sp+Ch] [bp-C88h]@33 + unsigned char Dst[0xC80]; // [sp+Ch] [bp-C88h]@33 int v52; // [sp+C8Ch] [bp-8h]@33 int v53; // [sp+C90h] [bp-4h]@1 int v54; // [sp+C9Ch] [bp+8h]@3 @@ -2021,13 +2021,13 @@ v10 = 0; if ( v52 ) v10 = rand() % v52; - v4->uItemID = Dst; + v4->uItemID = *(uint *)Dst; if ( !Dst ) v4->uItemID = 1; v11 = *(&v5->pItems[v4->uItemID].field_2C + v54); if ( v11 < v10 ) { - v12 = &Dst; + v12 = (uint *)Dst; do { ++v12; @@ -2226,9 +2226,9 @@ while ( a2b < v5->field_11798 ); } v45 = rand(); - v4->uAdditionalValue = Dst; + v4->uAdditionalValue = *(uint *)Dst; v46 = v45 % v39 + 1; - a2c = *((unsigned char *)&v5->pItems[0].uItemID + 28 * (Dst + 1389) + v5->pItems[v4->uItemID].uEquipType); + a2c = *((unsigned char *)&v5->pItems[0].uItemID + 28 * (*(uint *)Dst + 1389) + v5->pItems[v4->uItemID].uEquipType); if ( a2c < v46 ) { for ( j = (int *)&Dst; ; j = (int *)v59 )
--- a/LightmapBuilder.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/LightmapBuilder.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -117,29 +117,11 @@ } //----- (0045BE86) -------------------------------------------------------- -bool LightmapBuilder::_45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist, int uLightType, stru314 *a7, signed int a2, RenderVertexSoft *a9, char uClipFlag) +bool LightmapBuilder::_45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist, int uLightType, stru314 *a7, unsigned int uNumVertices, RenderVertexSoft *a9, char uClipFlag) { - //LightmapBuilder *v10; // esi@1 Lightmap *v11; // edi@3 - //double v12; // st7@5 - //double v13; // st7@5 - //stru314 *v14; // ebx@5 - //double v15; // st7@5 - //RenderVertexSoft *pLightmapVertices; // edx@5 double v17; // st7@5 - //double v18; // st7@5 - //char *v19; // eax@5 - //double v20; // st6@5 - //double v21; // st5@5 - //signed int v22; // ecx@5 - //double v23; // st5@5 double v24; // st7@6 - //int v25; // ebx@8 - //double v26; // st7@8 - //int v27; // eax@8 - //double v28; // st6@8 - //double v29; // st6@8 - //double v30; // st5@8 int v31; // eax@8 int v32; // ebx@8 unsigned int v33; // ecx@8 @@ -150,61 +132,22 @@ double v38; // st7@14 double v39; // st7@16 double v40; // st7@16 - //double v41; // st7@22 - //stru9 *v42; // ecx@22 - //char result; // al@22 - //unsigned int *v44; // ebx@23 int v45; // eax@24 - //RenderVertexSoft *v46; // edi@27 - //std::string *v47; // ecx@34 - //char *v48; // esi@39 - //int v49; // eax@39 - //unsigned __int8 v50; // sf@39 - //unsigned __int8 v51; // of@39 - //const char *v52; // [sp-Ch] [bp-58h]@34 int v53; // [sp-8h] [bp-54h]@34 - //std::string v54; // [sp-4h] [bp-50h]@19 - //float v55; // [sp+0h] [bp-4Ch]@22 - //float v56; // [sp+4h] [bp-48h]@22 - //int v57; // [sp+8h] [bp-44h]@22 - //unsigned int v58; // [sp+Ch] [bp-40h]@16 - //void *v59; // [sp+10h] [bp-3Ch]@16 - //float v60; // [sp+20h] [bp-2Ch]@8 - //float v61; // [sp+24h] [bp-28h]@8 - //float v62; // [sp+28h] [bp-24h]@8 - //Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8 - //double v64; // [sp+38h] [bp-14h]@8 - //int pLightmapVertices_; // [sp+40h] [bp-Ch]@5 - //float v66; // [sp+44h] [bp-8h]@5 - //char v67; // [sp+4Bh] [bp-1h]@2 - //float arg0b; // [sp+54h] [bp+8h]@8 - //int arg0c; // [sp+54h] [bp+8h]@8 - //int arg0a; // [sp+54h] [bp+8h]@8 - //auto a4 = radius; - //auto a5 = dot_dist; - - //v10 = this; if (fabsf(radius) < 1e-6f) return true; - //v67 = uLightType & 1; v11 = uLightType & 1 ? &std__vector_000004[std__vector_000004_size] : &std__vector_183808[std__vector_183808_size]; - //v12 = radius - dot_dist; flt_3C8C24 = radius - dot_dist; - //v13 = sqrt((radius + dot_dist) * (radius - dot_dist)); flt_3C8C28 = sqrt((radius + dot_dist) * (radius - dot_dist)); - //v14 = a7; - //v66 = 1.0 / radius; flt_3C8C2C_lightmaps_brightness = 1.0 - (radius - flt_3C8C28) / radius; v11->field_C08 = (double)pos->x - dot_dist * a7->field_4.x; v11->field_C0A = (double)pos->y - dot_dist * a7->field_4.y; v11->field_C0C = (double)pos->z - dot_dist * a7->field_4.z; - //v15 = a4; - //pLightmapVertices = v11->pVertices; + v17 = radius * flt_3C8C2C_lightmaps_brightness; - //pLightmapVertices_ = (int)v11->pVertices; flt_3C8C30 = v17; flt_3C8C0C = v17 * a7->field_10.x; flt_3C8C10 = v17 * a7->field_10.y; @@ -212,17 +155,6 @@ flt_3C8C18 = v17 * a7->field_1C.x; flt_3C8C1C = v17 * a7->field_1C.y; flt_3C8C20 = v17 * a7->field_1C.z; - //LODWORD(a5) = v11->field_C08; - //v18 = (double)SLODWORD(a5); - //LODWORD(a5) = v11->field_C0A; - //v19 = (char *)&v11->pVertices[0].vWorldPosition.y; - //v20 = (double)SLODWORD(a5); - //v21 = v11->field_C0A - flt_3C8C1C; - //LODWORD(a5) = v11->field_C0C; - //v22 = 4; - //v23 = (double)SLODWORD(a5); - //a5 = v23; - /* v11->pVertices[0].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C; @@ -249,7 +181,7 @@ v11->pVertices[3].u = 1.0; v11->pVertices[3].v = 0.0; */ - //v19 = (char *)&v11->pVertices[0].vWorldPosition.y; + for (uint i = 0; i < 4; ++i) { v11->pVertices[i].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C; @@ -266,10 +198,7 @@ v11->pVertices[i].vWorldPosition.x -= v24 * a7->field_4.x; v11->pVertices[i].vWorldPosition.y -= v24 * a7->field_4.y; v11->pVertices[i].vWorldPosition.z -= v24 * a7->field_4.z; - //v19 += 48; - //--v22; } - //while ( v22 ); v11->uColorMask = uColorMask; v11->uNumVertices = 4; @@ -278,42 +207,12 @@ v11->fBrightness = flt_3C8C2C_lightmaps_brightness; else { - //LODWORD(a5) = v11->field_C0C; - //v25 = pos; - //v26 = v11->field_C0C; - //LODWORD(a5) = v11->field_C0A; - //v27 = v11->field_C08; - //a5 = v11->field_C0A; - //uColorMask = v27; - //v28 = (double)v27; - //v61 = a5; - //v60 = v27; - //v62 = v26; - //*(float *)&uColorMask = (double)pos->z; - //arg0b = (double)pos->y; - //v29 = (double)pos->x - v11->field_C08; - //v30 = (double)pos->y - v11->field_C0A; - //a5 = (double)pos->z - v11->field_C0C; Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8 a1.x = (double)pos->x - v11->field_C08; a1.y = (double)pos->y - v11->field_C0A; a1.z = (double)pos->z - v11->field_C0C; a1.Normalize(); - //v64 = v62 + 6.7553994e15; - //LODWORD(a5) = LODWORD(v64); - //LODWORD(a5) = floorf(v11->field_C0C + 0.5f); - //v64 = v61 + 6.7553994e15; - //arg0c = LODWORD(v64); - //arg0c = floorf(v11->field_C0A + 0.5f); - //v64 = v60 + 6.7553994e15; - //arg8 = LODWORD(v64); - //uColorMask = floorf(v11->field_C08 + 0.5f); - //auto _v64 /*HIDWORD(v64)*/ = abs(pos->z - v11->field_C0C); - //arg0a = abs(pos->y - v11->field_C0A); - //v31 = abs(pos->x - v11->field_C08); - //LODWORD(a5) = v31; - //v32 = arg0a; - //v33 = _v64;//HIDWORD(v64); + auto dist_x = abs(pos->x - v11->field_C08), //v31 dist_y = abs(pos->y - v11->field_C0A), //v32 arg0a dist_z = abs(pos->z - v11->field_C0C); //v33 _v64 @@ -363,31 +262,20 @@ { MessageBoxW(nullptr, L"Invalid light type!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:277", 0); } - //v14 = a7; - //pLightmapVertices = (RenderVertexSoft *)pLightmapVertices_; } - - //v41 = a7->field_4.z; - //v42 = pGame->pStru9Instance; - //v59 = &v11->uNumVertices; - //v58 = (unsigned int)pLightmapVertices; - //*(float *)&v57 = v41; - //v56 = a7->field_4.y; - //v55 = a7->field_4.x; - //result = v42->_4980B9(a9, a2, v55, v56, *(float *)&v57, pLightmapVertices, &v11->uNumVertices); - if (pGame->pStru9Instance->_4980B9(a9, a2, - a7->field_4.x, a7->field_4.y, a7->field_4.z, - v11->pVertices, &v11->uNumVertices)) + if (!pGame->pStru9Instance->_4980B9(a9, uNumVertices, + a7->field_4.x, a7->field_4.y, a7->field_4.z, + v11->pVertices, &v11->uNumVertices)) return false; //v44 = &v11->uNumVertices; if (!v11->uNumVertices) return true; - v45 = _45C6D6(a2, a9, v11); - if ( v45 != a2 && v45 > 0 ) - _45C4B9(a2, a9, v11); + v45 = _45C6D6(uNumVertices, a9, v11); + if ( v45 != uNumVertices && v45 > 0 ) + _45C4B9(uNumVertices, a9, v11); //v59 = v11->uNumVertices; //v46 = (RenderVertexSoft *)pLightmapVertices_; pGame->pIndoorCameraD3D->ViewTransform(v11->pVertices, v11->uNumVertices);
--- a/LightmapBuilder.h Sat Oct 27 23:52:40 2012 +0600 +++ b/LightmapBuilder.h Sat Oct 27 23:53:04 2012 +0600 @@ -53,7 +53,7 @@ bool ApplyLights_IndoorFace(unsigned int uFaceID); int _45C6D6(int a2, struct RenderVertexSoft *a3, Lightmap *pLightmap); int _45C4B9(int a2, struct RenderVertexSoft *a3, Lightmap *pLightmap); - bool _45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist, int uLightType, struct stru314 *a7, signed int a2, RenderVertexSoft *a9, char uClipFlag); + bool _45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist, int uLightType, struct stru314 *a7, unsigned int uNumVertices, RenderVertexSoft *a9, char uClipFlag); bool ApplyLights(struct stru320 *a2, struct stru154 *a3, unsigned int uNumVertices, struct RenderVertexSoft *a5, struct IndoorCameraD3D_Vec4 *, char uClipFlag);
--- a/Render.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/Render.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -4129,61 +4129,42 @@ //----- (0049E4FC) -------------------------------------------------------- void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) { - unsigned int flags; // esi@1 - IDirect3DViewport3 *v6; // eax@6 - D3DRECT v7; // [sp+Ch] [bp-10h]@6 - - flags = 0; - if ( bClearColor ) - flags = 1; // D3DRMCLEAR_TARGET - if ( bClearDepth ) - flags |= 2u; // D3DRMCLEAR_ZBUFFER - if ( flags ) - { - v6 = this->pViewport; - v7.x1 = 0; - v7.y1 = 0; - v7.x2 = 640; - v7.y2 = 480; // BUG - v6->Clear2( - 1, - &v7, - flags, - uClearColor, - LODWORD(z_clear), - 0); - } + uint uClearFlags = 0; + + if (bClearColor) + uClearFlags |= D3DCLEAR_TARGET; + if (bClearDepth) + uClearFlags |= D3DCLEAR_ZBUFFER; + + D3DRECT rects[] = {{0, 0, 640, 480}}; + if (uClearFlags) + pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); } //----- (0049E54D) -------------------------------------------------------- void RenderD3D::Present(bool bForceBlit) { - RenderD3D *v2; // esi@1 - char bFullscreen; // zf@1 - struct tagRECT Rect; // [sp+8h] [bp-28h]@4 RECT v5; // [sp+18h] [bp-18h]@1 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 - v2 = this; v5.left = 0; v5.top = 0; - bFullscreen = this->bWindowed == 0; v5.bottom = 480; v5.right = 640; - if ( !bFullscreen || bForceBlit ) - { - GetClientRect(this->hWindow, &Rect); + + if (bWindowed || bForceBlit) + { + RECT rc; + GetClientRect(hWindow, &rc); Point.y = 0; Point.x = 0; - ClientToScreen(v2->hWindow, &Point); - OffsetRect(&Rect, Point.x, Point.y); - v2->pFrontBuffer->Blt(&Rect, v2->pBackBuffer, &v5, DDBLT_WAIT, 0); + ClientToScreen(hWindow, &Point); + OffsetRect(&rc, Point.x, Point.y); + pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); } else - { - this->pFrontBuffer->Flip(0, 1u); - } + pFrontBuffer->Flip(0, 1); } @@ -4692,20 +4673,13 @@ //----- (0049ECC4) -------------------------------------------------------- void Render::ClearBlack() { - Render *v1; // eax@1 - RenderD3D *v2; // ecx@1 - - v1 = this; - v2 = this->pRenderD3D; - if ( v2 ) - { - if ( v1->field_40110 ) - pRenderD3D->ClearTarget(1u, 0, 0, 0.0); + if (pRenderD3D) + { + if (field_40110) + pRenderD3D->ClearTarget(true, 0, false, 0.0); } else - { - memset(pRenderer->pTargetSurface, 0, 4 * (v1->field_10 * v1->field_14 >> 1)); - } + memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); } @@ -4718,7 +4692,8 @@ RECT x; // [sp+68h] [bp-10h]@3 memset(&v3, 0, sizeof(DDBLTFX)); - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) + if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + pVersion->pVersionInfo.dwMajorVersion >= 5) { x.left = uWindowX; x.right = uWindowX + uWindowHeight; @@ -5435,20 +5410,13 @@ //----- (0049FBCD) -------------------------------------------------------- void Render::ClearTarget(unsigned int uColor) { - Render *v2; // eax@1 - RenderD3D *v3; // ecx@1 - - v2 = this; - v3 = this->pRenderD3D; - if ( v3 ) - { - if ( v2->field_40110 ) - pRenderD3D->ClearTarget(1u, uColor, 0, 0.0); + if (pRenderD3D) + { + if (field_40110) + pRenderD3D->ClearTarget(true, uColor, false, 0.0); } else - { - memset32(v2->pTargetSurface, uColor, v2->field_10 * v2->field_14 >> 1); - } + memset32(pTargetSurface, uColor, field_10 * field_14 / 2); } @@ -5479,7 +5447,7 @@ { if (pAsyncMouse) pAsyncMouse->_46BAEC(); - pRenderD3D->Present(0); + pRenderD3D->Present(false); if (pAsyncMouse) pAsyncMouse->_46BB0A(); } @@ -7113,12 +7081,12 @@ { if (pRenderD3D) { - pRenderD3D->ClearTarget(1u, 0, 1u, 1.0); + pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); pRenderer->uNumBillboardsToDraw = 0; pRenderD3D->pDevice->BeginScene(); - if ( !pRenderD3D->DoesRaiseExceptions() ) - { - MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0); + if (!pRenderD3D->DoesRaiseExceptions()) + { + MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0); } if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) uFogColor = GetLevelFogColor(); @@ -7323,7 +7291,7 @@ ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); ErrD3D(pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, arary_77E5C8, uNumVertices, 16)); @@ -7383,7 +7351,7 @@ ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); ErrD3D(pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, arary_77E5C8, uNumVertices, 16)); @@ -7414,7 +7382,7 @@ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3u)); ErrD3D(pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, arary_77E5C8, uNumVertices, 16)); @@ -7441,7 +7409,7 @@ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 5u)); ErrD3D(pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, arary_77E5C8, uNumVertices, 16)); @@ -7525,7 +7493,7 @@ ErrD3D(pRenderD3D->pDevice->SetTexture(0, a4)); ErrD3D(pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, arary_77E5C8, uNumVertices, 24)); @@ -7581,7 +7549,7 @@ ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); ErrD3D(pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, arary_77E5C8, a2, 28)); @@ -7592,81 +7560,66 @@ //----- (004A2FC0) -------------------------------------------------------- -void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int a6, int a7, int a8) -{ - Render *v8; // edi@1 - unsigned int v9; // esi@3 - HRESULT v10; // eax@8 - HRESULT v11; // eax@8 +void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) +{ + //Render *v8; // edi@1 + //unsigned int v9; // esi@3 char *v12; // ecx@9 char *v13; // eax@9 double v14; // st6@10 int v15; // edx@10 Texture *v16; // edx@10 double v17; // st6@10 - char v18; // zf@10 + //char v18; // zf@10 Texture *v19; // edx@10 - HRESULT v20; // eax@11 - HRESULT v21; // eax@11 - HRESULT v22; // eax@11 Texture *v23; // edx@16 char *v24; // ecx@16 char *v25; // eax@16 double v26; // st6@17 int v27; // esi@17 double v28; // st6@17 - HRESULT v29; // eax@18 - HRESULT v30; // eax@18 - HRESULT v31; // eax@18 - HRESULT v32; // eax@18 unsigned int v33; // ecx@18 char *v34; // eax@19 - HRESULT v35; // eax@21 - HRESULT v36; // eax@21 - HRESULT v37; // eax@21 - HRESULT v38; // eax@21 - HRESULT v39; // eax@21 - HRESULT v40; // eax@21 - HRESULT v41; // eax@21 - HRESULT v42; // eax@21 - HRESULT v43; // eax@21 - HRESULT v44; // eax@21 - Texture *v45; // edx@23 - char *v46; // ecx@23 - char *v47; // eax@23 - double v48; // st6@24 - int v49; // esi@24 - double v50; // st6@24 - HRESULT v51; // eax@25 - HRESULT v52; // eax@25 + //Texture *v45; // edx@23 + //char *v46; // ecx@23 + //char *v47; // eax@23 + //double v48; // st6@24 + //int v49; // esi@24 + //double v50; // st6@24 const char *v53; // [sp-Ch] [bp-20h]@21 - int v54; // [sp-8h] [bp-1Ch]@21 - unsigned int v55; // [sp-4h] [bp-18h]@21 + //int v54; // [sp-8h] [bp-1Ch]@21 + //unsigned int v55; // [sp-4h] [bp-18h]@21 const char *v56; // [sp+0h] [bp-14h]@0 int v57; // [sp+4h] [bp-10h]@0 unsigned int v58; // [sp+8h] [bp-Ch]@0 - LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 - int a3a; // [sp+10h] [bp-4h]@4 - - v8 = this; - if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) - { - v59 = pGame->pLightmapBuilder; - v9 = v59->std__vector_000004_size; - if ( v9 ) - a3a = -1; - else - a3a = a7; - pGame->_44EDE4(a3, &a3a); - if ( byte_4D864C && pGame->uFlags & 1 ) - { + //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 + //int a3a; // [sp+10h] [bp-4h]@4 + + //v8 = this; + if (!uNumD3DSceneBegins || uNumVertices < 3) + return; + + //auto a3 = pFace; + //auto a6 = uPackedID; + //v59 = pGame->pLightmapBuilder; + //v9 = v59->std__vector_000004_size; + + auto uCorrectedColor = uColor; + if (pGame->pLightmapBuilder->std__vector_000004_size) + uCorrectedColor = 0xFFFFFFFF; + pGame->AlterGamma(pFace, &uCorrectedColor); + + if (byte_4D864C && pGame->uFlags & 1) + { + __debugbreak(); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); if ( (signed int)uNumVertices > 0 ) { v12 = (char *)&array_507D30[0].vWorldViewPosition; v13 = (char *)&arary_77E5C8[0].pos.y; - a7 = uNumVertices; + auto a7 = uNumVertices; + uint v18; do { v14 = *(float *)v12 * 0.061758894; @@ -7674,7 +7627,7 @@ *((int *)v13 + 4) = 0; *((int *)v13 - 1) = v15; *(int *)v13 = *((int *)v12 + 4); - *((int *)v13 + 3) = a3a; + *((int *)v13 + 3) = uCorrectedColor; v16 = pTex; v13 += 32; *((float *)v13 - 7) = 1.0 - 1.0 / v14; @@ -7694,63 +7647,47 @@ ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); ErrD3D(pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, arary_77E5C8, uNumVertices, 28)); - v59->_45D74F_MessWithLight(-1, 0); - } - else - { - if ( !v9 || byte_4D864C && pGame->uFlags & 2 ) - { - if ( (signed int)uNumVertices > 0 ) - { - v45 = pTex; - v46 = (char *)&array_507D30[0].vWorldViewPosition; - v47 = (char *)&arary_77E5C8[0].pos.y; - pTex = (Texture *)uNumVertices; - do - { - v48 = *(float *)v46 * 0.061758894; - v49 = *((int *)v46 + 3); - *((int *)v47 + 4) = 0; - *((int *)v47 - 1) = v49; - *(int *)v47 = *((int *)v46 + 4); - *((int *)v47 + 3) = a3a; - v47 += 32; - *((float *)v47 - 7) = 1.0 - 1.0 / v48; - v50 = 1.0 / *(float *)v46; - v46 += 48; - v18 = pTex == (Texture *)1; - pTex = (Texture *)((char *)pTex - 1); - *((float *)v47 - 6) = v50; - a7 = v45->uTextureWidth; - *((float *)v47 - 3) = *((float *)v46 - 6) / (double)a7; - a7 = v45->uTextureHeight; - *((float *)v47 - 2) = *((float *)v46 - 5) / (double)a7; - } - while ( !v18 ); - } - ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); - ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); - v55 = 0; - v54 = 1490; - ErrD3D(pRenderD3D->pDevice->DrawPrimitive( - D3DPT_TRIANGLEFAN, - 452, + pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); + } + else + { + if (!pGame->pLightmapBuilder->std__vector_000004_size || + byte_4D864C && pGame->uFlags & 2) + { + for (uint i = 0; i < uNumVertices; ++i) + { + arary_77E5C8[i].pos.x = array_507D30[i].vWorldViewProjX; + arary_77E5C8[i].pos.y = array_507D30[i].vWorldViewProjY; + arary_77E5C8[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); + arary_77E5C8[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; + arary_77E5C8[i].diffuse = uCorrectedColor; + arary_77E5C8[i].specular = 0; + arary_77E5C8[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; + arary_77E5C8[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; + } + + ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); + ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); + ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, arary_77E5C8, uNumVertices, 28)); - } - else - { + } + else + { + __debugbreak(); if ( (signed int)uNumVertices > 0 ) { v23 = pTex; v24 = (char *)&array_507D30[0].vWorldViewPosition; v25 = (char *)&arary_77E5C8[0].pos.y; pTex = (Texture *)uNumVertices; + uint v18; do { v26 = *(float *)v24 * 0.061758894; @@ -7758,7 +7695,7 @@ *((int *)v25 + 4) = 0; *((int *)v25 - 1) = v27; *(int *)v25 = *((int *)v24 + 4); - *((int *)v25 + 3) = a7; + *((int *)v25 + 3) = uColor; v25 += 32; *((float *)v25 - 7) = 1.0 - 1.0 / v26; v28 = 1.0 / *(float *)v24; @@ -7766,10 +7703,10 @@ v18 = pTex == (Texture *)1; pTex = (Texture *)((char *)pTex - 1); *((float *)v25 - 6) = v28; - a3 = (BLVFace *)v23->uTextureWidth; - *((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)a3; - a3 = (BLVFace *)v23->uTextureHeight; - *((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)a3; + //a3 = (BLVFace *)v23->uTextureWidth; + *((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; + //a3 = (BLVFace *)v23->uTextureHeight; + *((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; } while ( !v18 ); } @@ -7778,19 +7715,19 @@ ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); ErrD3D(pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, arary_77E5C8, uNumVertices, 28)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); - v59->_45D74F_MessWithLight(-1, 0); + pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); v33 = uNumVertices; if ( (signed int)uNumVertices > 0 ) { v34 = (char *)&arary_77E5C8[0].diffuse; do { - *(int *)v34 = a3a; + *(int *)v34 = uCorrectedColor; v34 += 32; --v33; } @@ -7804,14 +7741,13 @@ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3)); ErrD3D(pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, arary_77E5C8, uNumVertices, 28)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, false)); - } } } } @@ -8614,7 +8550,7 @@ ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v29, 4, 24)); @@ -9092,7 +9028,7 @@ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 8u)); ErrD3D(pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v36, 4, 28));
--- a/Render.h Sat Oct 27 23:52:40 2012 +0600 +++ b/Render.h Sat Oct 27 23:53:04 2012 +0600 @@ -311,7 +311,7 @@ void DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, int a6, int a7); void DrawFan(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *a4); void _4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex); - void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int a6, int a7, int a8); + void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8); void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); void MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int a1a, RenderBillboard *pBillboard);
--- a/mm7_2.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/mm7_2.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -13850,7 +13850,6 @@ ClipCursor(nullptr); pRenderer->SwitchToWindow(hWnd); } - pRenderer->Present(); uSoundVolumeMultiplier = ReadWindowsRegistryInt("soundflag", 9); if (uSoundVolumeMultiplier > 9)
--- a/mm7_3.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/mm7_3.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -2384,15 +2384,15 @@ int v26; // eax@67 double v27; // st7@67 int v28; // ST40_4@67 - int v29; // eax@69 - double v30; // st7@69 - int v31; // ST3C_4@69 - int v32; // eax@71 - double v33; // st7@71 - int v34; // ST3C_4@71 + //int v29; // eax@69 + //double v30; // st7@69 + //int v31; // ST3C_4@69 + //int v32; // eax@71 + //double v33; // st7@71 + //int v34; // ST3C_4@71 unsigned int v35; // eax@74 int v36; // ecx@88 - int v37; // esi@96 + int new_party_z; // esi@96 int v38; // eax@96 int v39; // ecx@106 int v40; // eax@106 @@ -2438,30 +2438,30 @@ int i; // [sp+34h] [bp-2Ch]@1 int v81; // [sp+38h] [bp-28h]@47 int v82; // [sp+3Ch] [bp-24h]@47 - int v83; // [sp+40h] [bp-20h]@47 + int _view_angle; // [sp+40h] [bp-20h]@47 int bJumping; // [sp+44h] [bp-1Ch]@1 - int v85; // [sp+48h] [bp-18h]@1 - int v86; // [sp+4Ch] [bp-14h]@1 - int v87; // [sp+50h] [bp-10h]@1 - float v88; // [sp+54h] [bp-Ch]@62 + int new_party_y; // [sp+48h] [bp-18h]@1 + int new_party_x; // [sp+4Ch] [bp-14h]@1 + int party_z; // [sp+50h] [bp-10h]@1 + //float v88; // [sp+54h] [bp-Ch]@62 int v89; // [sp+58h] [bp-8h]@1 int angle; // [sp+5Ch] [bp-4h]@47 v0 = pParty->vPosition.z; v89 = pParty->uFallSpeed; v1 = 0; - v85 = pParty->vPosition.y; + new_party_y = pParty->vPosition.y; v70 = 0; v2 = 0; - v86 = pParty->vPosition.x; - v87 = pParty->vPosition.z; + new_party_x = pParty->vPosition.x; + party_z = pParty->vPosition.z; v77 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); v72 = 0; v78 = 0; v71 = 0; bJumping = 0; v3 = v0 + 40; - i = _46ED1B_collide_against_floor(v86, v85, v3, &v77, &v79); + i = _46ED1B_collide_against_floor(new_party_x, new_party_y, v3, &v77, &v79); if ( pParty->bFlying ) { pParty->bFlying = 0; @@ -2470,7 +2470,7 @@ } if ( i == -30000 ) { - i = _47272C_collide_agains_some_secotors_floors(v86, v85, v3, &v77, &v79); + i = _47272C_collide_agains_some_secotors_floors(new_party_x, new_party_y, v3, &v77, &v79); if ( i == -30000 ) { pParty->vPosition.x = blv_prev_party_x; @@ -2516,7 +2516,7 @@ bFeatherFall = 1; pParty->uFallStartY = i; LABEL_20: - if ( v6 - v87 > 512 && !bFeatherFall && v87 <= i + 1 ) + if ( v6 - party_z > 512 && !bFeatherFall && party_z <= i + 1 ) { if ( BYTE1(pParty->uFlags) & 1 ) { @@ -2530,7 +2530,7 @@ if ( !(*v7)->HasEnchantedItemEquipped(72) && !(*v7)->WearsItem(529, 8) ) { v8 = (signed __int64)((double)(*v7)->GetMaxHealth() * 0.1); - (*v7)->ReceiveDamage((pParty->uFallStartY - v87) * (signed int)v8 / 256, 4); + (*v7)->ReceiveDamage((pParty->uFallStartY - party_z) * (signed int)v8 / 256, 4); v9 = (*v7)->GetActualEndurance(); v10 = (double)(20 - (*v7)->_48EA1B_get_static_effect(v9)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; (*v7)->SetRecoveryTime((signed __int64)v10); @@ -2540,21 +2540,21 @@ while ( (signed int)v7 <= (signed int)&pPlayers[4] ); } } - if ( v87 > i + 1 ) + if ( party_z > i + 1 ) bJumping = 1; - bFeatherFalla = v87 - i <= 32; - if ( v87 - i <= 32 ) - pParty->uFallStartY = v87; + bFeatherFalla = party_z - i <= 32; + if ( party_z - i <= 32 ) + pParty->uFallStartY = party_z; if ( bWalkSound && pParty->field_6F8 > 0 ) pParty->field_6F8 -= pEventTimer->uTimeElapsed; - if ( v87 > i + 1 ) + if ( party_z > i + 1 ) { LABEL_43: if ( bJumping ) goto LABEL_45; goto LABEL_44; } - v87 = i + 1; + party_z = i + 1; pParty->uFallStartY = i + 1; if ( bJumping ) goto LABEL_45; @@ -2575,7 +2575,7 @@ v71 = 1; v81 = pParty->uWalkSpeed; angle = pParty->sRotationY; - v83 = pParty->sRotationX; + _view_angle = pParty->sRotationX; v82 = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed * stru_5C6E00->uIntegerPi) / 180)) >> 16; @@ -2585,18 +2585,21 @@ switch ( pPartyActionQueue->Next() ) { case PARTY_TurnLeft: + __debugbreak(); v12 = uTurnSpeed; if ( uTurnSpeed ) goto LABEL_58; v13 = (double)v82 * fTurnSpeedMultiplier; goto LABEL_51; case PARTY_TurnRight: + __debugbreak(); LODWORD(v15) = uTurnSpeed; if ( uTurnSpeed ) goto LABEL_56; v16 = (double)v82 * fTurnSpeedMultiplier; goto LABEL_55; case PARTY_FastTurnLeft: + __debugbreak(); v12 = uTurnSpeed; if ( uTurnSpeed ) { @@ -2612,6 +2615,7 @@ angle = stru_5C6E00->uDoublePiMask & v14; goto LABEL_87; case PARTY_FastTurnRight: + __debugbreak(); LODWORD(v15) = uTurnSpeed; if ( !uTurnSpeed ) { @@ -2623,80 +2627,77 @@ angle = stru_5C6E00->uDoublePiMask & (angle - v15); goto LABEL_87; case PARTY_StrafeLeft: + __debugbreak(); v17 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); v18 = (double)v81; - v88 = v18; + //v88 = v18; v78 = (unsigned __int64)(v17 * (signed __int64)((signed int)(signed __int64)(v18 * fWalkSpeedMultiplier) >> 1)) >> 16; v2 -= v78; v19 = stru_5C6E00->SinCos(angle); - v78 = (unsigned __int64)(v19 * (signed __int64)((signed int)(signed __int64)(v88 * fWalkSpeedMultiplier) >> 1)) >> 16; + v78 = (unsigned __int64)(v19 * (signed __int64)((signed int)(signed __int64)(v18 * fWalkSpeedMultiplier) >> 1)) >> 16; goto LABEL_63; case PARTY_StrafeRight: + __debugbreak(); v20 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); v21 = (double)v81; - v88 = v21; + //v88 = v21; v78 = (unsigned __int64)(v20 * (signed __int64)((signed int)(signed __int64)(v21 * fWalkSpeedMultiplier) >> 1)) >> 16; v2 += v78; v22 = stru_5C6E00->SinCos(angle); - v78 = (unsigned __int64)(v22 * (signed __int64)((signed int)(signed __int64)(v88 * fWalkSpeedMultiplier) >> 1)) >> 16; + v78 = (unsigned __int64)(v22 * (signed __int64)((signed int)(signed __int64)(v21 * fWalkSpeedMultiplier) >> 1)) >> 16; goto LABEL_68; case PARTY_WalkForward: + __debugbreak(); v23 = stru_5C6E00->SinCos(angle); v24 = (double)v81; - v88 = v24; + //v88 = v24; v78 = (unsigned __int64)(v23 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16; v2 += v78; v25 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); - v78 = (unsigned __int64)(v25 * (signed __int64)(signed int)(signed __int64)(v88 * fWalkSpeedMultiplier)) >> 16; + v78 = (unsigned __int64)(v25 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16; LABEL_63: v1 += v78; goto LABEL_64; case PARTY_WalkBackward: + __debugbreak(); v26 = stru_5C6E00->SinCos(angle); v27 = (double)v81; - v88 = v27; + //v88 = v27; v78 = (unsigned __int64)(v26 - * (signed __int64)(signed int)(signed __int64)(v27 * fBackwardMovementSlowdownMultiplier)) >> 16; + * (signed __int64)(signed int)(signed __int64)(v27 * fBackwardWalkSpeedMultiplier)) >> 16; v2 -= v78; v28 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); v78 = (unsigned __int64)(v28 - * (signed __int64)(signed int)(signed __int64)(v88 * fBackwardMovementSlowdownMultiplier)) >> 16; + * (signed __int64)(signed int)(signed __int64)(v27 * fBackwardWalkSpeedMultiplier)) >> 16; LABEL_68: v1 -= v78; LABEL_64: v78 = 1; goto LABEL_87; case PARTY_RunForward: - v29 = stru_5C6E00->SinCos(angle); - v30 = (double)v81; - v88 = v30; - v2 += (unsigned __int64)(v29 - * (signed __int64)(signed int)(2 - * (unsigned __int64)(signed __int64)(v30 - * fWalkSpeedMultiplier))) >> 16; - v31 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); - v1 += (unsigned __int64)(v31 - * (signed __int64)(signed int)(2 - * (unsigned __int64)(signed __int64)(v88 - * fWalkSpeedMultiplier))) >> 16; + //v29 = stru_5C6E00->SinCos(angle); + //v30 = (double)v81; + //v88 = (double)v81; + v2 += (unsigned __int64)(stru_5C6E00->SinCos(angle) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16; + //v31 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); + v1 += (unsigned __int64)(stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16; v72 = 1; goto LABEL_87; case PARTY_RunBackward: - v32 = stru_5C6E00->SinCos(angle); - v33 = (double)v81; - v88 = v33; - v2 -= (unsigned __int64)(v32 - * (signed __int64)(signed int)(signed __int64)(v33 * fBackwardMovementSlowdownMultiplier)) >> 16; - v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); - v1 -= (unsigned __int64)(v34 - * (signed __int64)(signed int)(signed __int64)(v88 * fBackwardMovementSlowdownMultiplier)) >> 16; + //v32 = stru_5C6E00->SinCos(angle); + //v33 = (double)v81; + //v88 = (double)v81; + v2 -= (unsigned __int64)(stru_5C6E00->SinCos(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16; + //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); + v1 -= (unsigned __int64)(stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16; //LABEL_70: v72 = 1; goto LABEL_87; case PARTY_LookUp: - v83 += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0); - if ( v83 > 128 ) - v83 = 128; + __debugbreak(); + _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0); + if ( _view_angle > 128 ) + _view_angle = 128; v35 = uActiveCharacter; if ( !uActiveCharacter ) goto LABEL_87; @@ -2704,9 +2705,10 @@ v63 = 63; goto LABEL_76; case PARTY_LookDown: - v83 += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0); - if ( v83 < -128 ) - v83 = -128; + __debugbreak(); + _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0); + if ( _view_angle < -128 ) + _view_angle = -128; v35 = uActiveCharacter; if ( uActiveCharacter ) { @@ -2717,10 +2719,12 @@ } break; case PARTY_CenterView: - v83 = 0; + __debugbreak(); + _view_angle = 0; break; case PARTY_Jump: - if ( (!bJumping || v87 <= i + 6 && v89 <= 0) && pParty->field_24 ) + __debugbreak(); + if ( (!bJumping || party_z <= i + 6 && v89 <= 0) && pParty->field_24 ) { bJumping = 1; v89 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v89); @@ -2732,7 +2736,7 @@ } v36 = 0; pParty->sRotationY = angle; - pParty->sRotationX = v83; + pParty->sRotationX = _view_angle; if ( bJumping ) { v89 += -2 * pEventTimer->uTimeElapsed * GetGravityStrength(); @@ -2764,7 +2768,7 @@ goto LABEL_93; } LABEL_92: - pParty->uFallStartY = v87; + pParty->uFallStartY = party_z; LABEL_93: if ( v2 * v2 + v1 * v1 < 400 ) { @@ -2775,20 +2779,20 @@ stru_721530.field_70 = 0; stru_721530.prolly_normal_d = pParty->field_14; stru_721530.field_8 = pParty->field_14 >> 1; - v83 = 0; + auto v83 = 0; stru_721530.field_0 = 1; stru_721530.field_C = pParty->uPartyHeight - 32; while ( 1 ) { - v37 = v87; - stru_721530.field_34.x = v86; - stru_721530.normal.x = v86; + new_party_z = party_z; + stru_721530.field_34.x = new_party_x; + stru_721530.normal.x = new_party_x; stru_721530.field_1C = v2; - stru_721530.field_34.y = v85; - stru_721530.normal.y = v85; + stru_721530.field_34.y = new_party_y; + stru_721530.normal.y = new_party_y; stru_721530.field_20 = v1; - stru_721530.normal.z = stru_721530.prolly_normal_d + v87 + 1; - stru_721530.field_34.z = stru_721530.field_C + v87 + 1; + stru_721530.normal.z = stru_721530.prolly_normal_d + party_z + 1; + stru_721530.field_34.z = stru_721530.field_C + party_z + 1; stru_721530.field_24 = v89; stru_721530.uSectorID = v77; v38 = 0; @@ -2816,26 +2820,26 @@ } else { - v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16) + v86; - v77 = v85 + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16); - v40 = v37 + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16); + v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16) + new_party_x; + v77 = new_party_y + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16); + v40 = new_party_z + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16); } v42 = _46ED1B_collide_against_floor(v39, v77, v40 + 40, &stru_721530.uSectorID, &v79); - if ( v42 == -30000 || v42 - v37 > 128 ) + if ( v42 == -30000 || v42 - new_party_z > 128 ) return; if ( stru_721530.field_7C >= stru_721530.field_6C ) { - v86 = stru_721530.normal2.x; - v85 = stru_721530.normal2.y; - v37 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; + new_party_x = stru_721530.normal2.x; + new_party_y = stru_721530.normal2.y; + new_party_z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; break; } - v86 += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; - v85 += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; + new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; + new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; v43 = stru_721530.uFaceID; v77 = stru_721530.uSectorID; stru_721530.field_70 += stru_721530.field_7C; - v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + v37; + auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + new_party_z; if ( (stru_721530.uFaceID & 7) == 3 ) { if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0 @@ -2849,8 +2853,8 @@ v53 = sub_452A9E(v2 * v2 + v1 * v1); i = v53; v54 = stru_5C6E00->Atan2( - v86 - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, - v85 - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y); + new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x, + new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y); v2 = (unsigned __int64)(stru_5C6E00->SinCos(v54) * (signed __int64)v53) >> 16; v55 = stru_5C6E00->SinCos(v54 - stru_5C6E00->uIntegerHalfPi); v1 = (unsigned __int64)(v55 * (signed __int64)i) >> 16; @@ -2895,11 +2899,11 @@ v69 = v44->pFacePlane_old.vNormal.x; i = v51; v1 += v81; - v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + v85 * v51 + v86 * v69) >> 16); + v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16); if ( v52 > 0 ) { - v86 += v52 * v69 >> 16; - v85 += v52 * i >> 16; + new_party_x += v52 * v69 >> 16; + new_party_y += v52 * i >> 16; v87 += v52 * v74 >> 16; } LABEL_142: @@ -2934,16 +2938,16 @@ v89 = (unsigned __int64)(58500i64 * v89) >> 16; if ( v83 >= 100 ) { - v37 = v87; + new_party_z = v87; break; } } if ( bWalkSound && pParty->field_6F8 <= 0 ) { - if ( sub_452A9E((pParty->vPosition.x - v86) * (pParty->vPosition.x - v86) + (pParty->vPosition.y - v85) - * (pParty->vPosition.y - v85) - + (pParty->vPosition.z - v37) - * (pParty->vPosition.z - v37)) <= 16 ) + if ( sub_452A9E((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y) + * (pParty->vPosition.y - new_party_y) + + (pParty->vPosition.z - new_party_z) + * (pParty->vPosition.z - new_party_z)) <= 16 ) goto LABEL_188; if ( v72 && (!bJumping || bFeatherFalla) ) { @@ -3002,9 +3006,9 @@ else pParty->uFlags |= 8u; BYTE1(pParty->uFlags) &= 0xFDu; - pParty->vPosition.x = v86; - pParty->vPosition.z = v37; - pParty->vPosition.y = v85; + pParty->vPosition.x = new_party_x; + pParty->vPosition.z = new_party_z; + pParty->vPosition.y = new_party_y; pParty->uFallSpeed = v89; if ( !bJumping && BYTE3(pIndoor->pFaces[v79].uAttributes) & 0x40 ) BYTE1(pParty->uFlags) |= 2u; @@ -3422,12 +3426,12 @@ v126 = v19; *(float *)&v128 = v20; v124 = (unsigned __int64)(v19 - * (signed __int64)(signed int)(signed __int64)(v20 * fBackwardMovementSlowdownMultiplier)) >> 16; + * (signed __int64)(signed int)(signed __int64)(v20 * fBackwardWalkSpeedMultiplier)) >> 16; v2 -= v124; v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); v124 = (unsigned __int64)(v126 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 - * fBackwardMovementSlowdownMultiplier)) >> 16; + * fBackwardWalkSpeedMultiplier)) >> 16; LABEL_90: v1 -= v124; goto LABEL_86; @@ -3488,7 +3492,7 @@ v28 = (double)_walk_speed; v126 = v27; *(float *)&v128 = v28; - v29 = (signed __int64)(v28 * fBackwardMovementSlowdownMultiplier); + v29 = (signed __int64)(v28 * fBackwardWalkSpeedMultiplier); if ( pParty->bFlying ) { v129 = (unsigned __int64)(v126 * (signed __int64)(4 * (signed int)v29)) >> 16; @@ -3497,7 +3501,7 @@ v129 = (unsigned __int64)(v126 * (signed __int64)(signed int)(4 * (unsigned __int64)(signed __int64)(*(float *)&v128 - * fBackwardMovementSlowdownMultiplier))) >> 16; + * fBackwardWalkSpeedMultiplier))) >> 16; v1 -= v129; LABEL_93: v128 = v1; @@ -3509,7 +3513,7 @@ v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); v129 = (unsigned __int64)(v126 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 - * fBackwardMovementSlowdownMultiplier)) >> 16; + * fBackwardWalkSpeedMultiplier)) >> 16; v1 -= v129; LABEL_86: v128 = v1; @@ -7909,7 +7913,7 @@ //----- (00479A53) -------------------------------------------------------- -void __fastcall sub_479A53(unsigned int uNumVertices, unsigned int uFaceID) +void __fastcall _479A53_draw_some_blv_poly(unsigned int uNumVertices, unsigned int uFaceID) { BLVFace *pFace; // esi@1 unsigned int v3; // edi@1 @@ -7992,6 +7996,8 @@ float v80; // [sp+16Ch] [bp-8h]@3 const void *v81; // [sp+170h] [bp-4h]@7 + __debugbreak(); + pFace = &pIndoor->pFaces[uFaceID]; v65 = uFaceID; v3 = uNumVertices;
--- a/mm7_4.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/mm7_4.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -2813,47 +2813,26 @@ //----- (0048A959) -------------------------------------------------------- -unsigned int sub_48A959(int _this, float a2, float a3, float a4) -{ - int v4; // esi@1 - double v5; // st6@1 - double v6; // st6@1 - __int64 v8; // [sp+14h] [bp-20h]@1 - double v9; // [sp+1Ch] [bp-18h]@1 - int a6; // [sp+24h] [bp-10h]@1 - float v11; // [sp+28h] [bp-Ch]@1 - float v12; // [sp+2Ch] [bp-8h]@1 - float a1; // [sp+30h] [bp-4h]@1 - float a2a; // [sp+3Ch] [bp+8h]@7 - float a2b; // [sp+3Ch] [bp+8h]@7 - float a2c; // [sp+3Ch] [bp+8h]@7 - int a3a; // [sp+40h] [bp+Ch]@7 - - v4 = _this; - v8 = ((unsigned int)_this >> 16) & 0xFFi64; - v5 = (double)v8 * 0.0039215689; - v8 = (unsigned __int16)_this >> 8; - a1 = v5; - v6 = (double)v8; - v8 = _this & 0xFFi64; - v12 = v6 * 0.0039215689; - v11 = (double)v8 * 0.0039215689; - RGB2HSV((float *)&v8 + 1, (float *)&v9 + 1, a1, v12, v11, (float *)&a6); - if ( a2 != -1.0 ) - HIDWORD(v8) = LODWORD(a2); - if ( a3 != -1.0 ) - HIDWORD(v9) = LODWORD(a3); - if ( a4 != -1.0 ) - a6 = LODWORD(a4); - HSV2RGB(&a1, &v12, &v11, *((float *)&v8 + 1), *((float *)&v9 + 1), *(float *)&a6); - a2a = a1 * 255.0; - *(double *)&v8 = a2a + 6.7553994e15; - a3a = v8; - a2b = v12 * 255.0; - *(double *)&v8 = a2b + 6.7553994e15; - a2c = v11 * 255.0; - v9 = a2c + 6.7553994e15; - return LODWORD(v9) | v4 & 0xFF000000 | (((unsigned int)v8 | (a3a << 8)) << 8); +unsigned int ReplaceHSV(unsigned int uColor, float h_replace, float s_replace, float v_replace) +{ + float r = ((uColor & 0x00FF0000) >> 16) / 255.0f, + g = ((uColor & 0x0000FF00) >> 8) / 255.0f, + b = (uColor & 0x000000FF) / 255.0f; + + float h, s, v; + RGB2HSV(&h, &s, r, g, b, &v); + + if ( h_replace != -1.0 ) + h = h_replace; + if ( s_replace != -1.0 ) + s = s_replace; + if ( v_replace != -1.0 ) + v = v_replace; + HSV2RGB(&r, &g, &b, h, s, v); + + return (((uint)floorf(r * 255.0f + 0.5f) & 0xFF) << 16) | + (((uint)floorf(g * 255.0f + 0.5f) & 0xFF) << 8) | + ((uint)floorf(b * 255.0f + 0.5f) & 0xFF); } @@ -5454,8 +5433,8 @@ //if (uPlayerCreationUI_ArrowAnim < 0) // uPlayerCreationUI_ArrowAnim = 18; - v6 = LOBYTE(pFontCreate->uFontHeight) - 2; - v128 = LOBYTE(pFontCreate->uFontHeight) - 2; + v6 = pFontCreate->uFontHeight - 2; + v128 = pFontCreate->uFontHeight - 2; strcpy(Str1, pGlobalTXT_LocalizationStrings[205]);// "Skills" uNumLet = strlen(Str1) - 1; v134 = uNumLet; @@ -7300,12 +7279,12 @@ v2 = Dst.lpSurface; - for (uint y = 0; y < 480; ++y) + /*for (uint y = 0; y < 480; ++y) { auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch); for (uint x = 0; x < 640; ++x) pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask; - } + }*/ auto pSrc = pRenderer->pTargetSurface; auto pDst = (__int16 *)Dst.lpSurface; @@ -7344,9 +7323,16 @@ v13 = v24; for (uint y = pViewport->uViewportY; y < pViewport->uViewportW; ++y) - memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2, - pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16)); - + { + //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2, + // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16)); + for (uint x = pViewport->uViewportX; x < pViewport->uViewportZ; ++x) + { + if (pSrc[y * 640 + x] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) + pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x]; + } + } + ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); /* while ( 1 )
--- a/mm7_data.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/mm7_data.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -561,7 +561,7 @@ char aButtexi1[777]; // idb char aCanTJumpToThat[777]; // idb char aNoMapFoundForS[777]; // idb -char a2[777]; // idb +char global_a2[777]; // idb char aSSS[777]; // idb char aNotInMapStats[17]; // weak char aD47_blv[777]; // idb @@ -2336,7 +2336,7 @@ int dword_6BE138; // weak int dword_6BE13C_uCurrentlyLoadedLocationID; // weak float fWalkSpeedMultiplier = 1.0f; // weak -float fBackwardMovementSlowdownMultiplier = 1.0f; // weak +float fBackwardWalkSpeedMultiplier = 1.0f; // weak float fTurnSpeedMultiplier = 1.0f; // weak float flt_6BE150_look_up_down_dangle = 1.0f; // weak HWND hWnd; // idb @@ -2548,5 +2548,4 @@ //int crt_F94004; // weak //int crtdword_F9400C; // weak -FARPROC lpfn; // idb -float flt_F942B0; // weak \ No newline at end of file +FARPROC lpfn; // idb \ No newline at end of file
--- a/mm7_data.h Sat Oct 27 23:52:40 2012 +0600 +++ b/mm7_data.h Sat Oct 27 23:53:04 2012 +0600 @@ -547,7 +547,7 @@ extern char aButtexi1[]; // idb extern char aCanTJumpToThat[]; // idb extern char aNoMapFoundForS[]; // idb -extern char a2[]; // idb +extern char global_a2[]; // idb extern char aSSS[]; // idb extern char aNotInMapStats[17]; // weak extern char aD47_blv[]; // idb @@ -2287,7 +2287,7 @@ extern int dword_6BE138; // weak extern int dword_6BE13C_uCurrentlyLoadedLocationID; // weak extern float fWalkSpeedMultiplier; // weak -extern float fBackwardMovementSlowdownMultiplier; // weak +extern float fBackwardWalkSpeedMultiplier; // weak extern float fTurnSpeedMultiplier; // weak extern float flt_6BE150_look_up_down_dangle; // weak //extern char pMM7WindowClassName[]; // idb @@ -2505,7 +2505,6 @@ //extern int crt_F94004; // weak //extern int crtdword_F9400C; // weak extern FARPROC lpfn; // idb -extern float flt_F942B0; // weak //extern int crt_F944EC; // weak //extern int crtdword_F944F0; // weak //extern void *crt_F944F4; // idb @@ -2982,7 +2981,7 @@ void __cdecl loc_4789D4(); // idb void __cdecl loc_47907F(); // idb bool __fastcall IsBModelVisible(unsigned int uModelID, int *unused); -void __fastcall sub_479A53(unsigned int uNumVertices, unsigned int uFaceID); // idb +void __fastcall _479A53_draw_some_blv_poly(unsigned int uNumVertices, unsigned int uFaceID); // idb void __thiscall ODM_LoadAndInitialize(const char *pLevelFilename, struct OutdoorCamera *thisa); unsigned __int16 *__fastcall GetBillboardPalette(struct RenderBillboard *a1, int a2, signed int a3, int a4); int __fastcall sr_sub_47BEB1(signed int a1, stru148 *a2, int terrain_gamma, int a4, int *a5, int *a6, int a7, int a8); @@ -3033,7 +3032,7 @@ int __stdcall loc_489BB3(struct stru320 *a2, int thisa, unsigned int uNumVertices, RenderVertexSoft *a5, float a6, char uClipFlag); // weak bool __fastcall HSV2RGB(float *a1, float *a2, float *a3, float a4, float a5, float a6); void __fastcall RGB2HSV(float *a1, float *a2, float a3, float a4, float a5, float *a6); -unsigned int __thiscall sub_48A959(int _this, float a2, float a3, float a4); +unsigned int ReplaceHSV(unsigned int uColor, float a2, float gamma, float a4); int _48B561_mess_with_scaling_along_z(/*int a1, */float a2); signed int __cdecl sub_4908DE(); signed int __cdecl PlayerCreation_ComputeAttributeBonus();
--- a/stru6.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/stru6.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -1565,7 +1565,7 @@ pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 8u); pRenderer->pRenderD3D->pDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, - 452, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, vd3d, 4, 28);
--- a/stru9.cpp Sat Oct 27 23:52:40 2012 +0600 +++ b/stru9.cpp Sat Oct 27 23:53:04 2012 +0600 @@ -29,6 +29,8 @@ signed int a3a; // [sp+38h] [bp+10h]@12 int a3b; // [sp+38h] [bp+10h]@25 + __debugbreak(); + thisa = this; static RenderVertexSoft static_AE3FB4; @@ -78,11 +80,11 @@ v11 = *(float *)v8; ++v21; result = 0; - static_AE3FA4.flt_0 = *((float *)v8 - 1); + static_AE3FA4.x = *((float *)v8 - 1); static_AE33A0.uNumVertices = 0; a3a = 0; - static_AE3FA4.flt_4 = v11; - static_AE3FA4.flt_8 = v10; + static_AE3FA4.y = v11; + static_AE3FA4.z = v10; if ( (signed int)*v7 <= 0 ) goto LABEL_32; do @@ -99,7 +101,7 @@ v19 = &pVertices[result]; } v20 = v12; - if ( _49895A(v12, a2, &static_AE3FA4) ) + if ( AreVectorsCollinear(v12, a2, &static_AE3FA4) ) AddVertex(&static_AE33A0, v12); v7 = pOutNumVertices; result = a3a++ + 1; @@ -225,6 +227,7 @@ //----- (00498737) -------------------------------------------------------- void stru9::AddVertex(struct VertexBuffer *pVertexBuffer, struct RenderVertexSoft *pVertex) { + __debugbreak(); RenderVertexSoft *v3; // eax@1 v3 = &pVertexBuffer->pVertices[pVertexBuffer->uNumVertices]; @@ -250,31 +253,22 @@ char v14; // c2@24 char v15; // c3@24 float a1a; // [sp+10h] [bp+8h]@5 + + __debugbreak(); static stru312 static_AE3388; - /*if ( !(static_init_flag__AE3388_bit1__AE3378_bit2 & 1) ) - { - static_init_flag__AE3388_bit1__AE3378_bit2 |= 1u; - stru312::stru312(&static_AE3388); - atexit(nullsub_16); - }*/ static stru312 static_AE3378; - /*if ( !(static_init_flag__AE3388_bit1__AE3378_bit2 & 2) ) - { - static_init_flag__AE3388_bit1__AE3378_bit2 |= 2u; - stru312::stru312(&static_AE3378); - atexit(nullsub_15); - }*/ + v6 = a1; - static_AE3378.flt_0 = a1->vWorldPosition.x - a3->vWorldPosition.x; - static_AE3378.flt_4 = a1->vWorldPosition.y - a3->vWorldPosition.y; + static_AE3378.x = a1->vWorldPosition.x - a3->vWorldPosition.x; + static_AE3378.y = a1->vWorldPosition.y - a3->vWorldPosition.y; HIWORD(result) = HIWORD(a4); - static_AE3378.flt_8 = a1->vWorldPosition.z - a3->vWorldPosition.z; - static_AE3388.flt_0 = a2->vWorldPosition.x - a1->vWorldPosition.x; - static_AE3388.flt_4 = a2->vWorldPosition.y - a1->vWorldPosition.y; - static_AE3388.flt_8 = a2->vWorldPosition.z - a1->vWorldPosition.z; - a1a = static_AE3388.flt_0 * a4->flt_0 + static_AE3388.flt_8 * a4->flt_8 + static_AE3388.flt_4 * a4->flt_4; - v8 = static_AE3378.flt_0 * a4->flt_0 + static_AE3378.flt_8 * a4->flt_8 + static_AE3378.flt_4 * a4->flt_4; + static_AE3378.z = a1->vWorldPosition.z - a3->vWorldPosition.z; + static_AE3388.x = a2->vWorldPosition.x - a1->vWorldPosition.x; + static_AE3388.y = a2->vWorldPosition.y - a1->vWorldPosition.y; + static_AE3388.z = a2->vWorldPosition.z - a1->vWorldPosition.z; + a1a = static_AE3388.x * a4->x + static_AE3388.z * a4->z + static_AE3388.y * a4->y; + v8 = static_AE3378.x * a4->x + static_AE3378.z * a4->z + static_AE3378.y * a4->y; //UNDEF(v9); if ( a1a != 0.0 ) { @@ -335,39 +329,18 @@ // AE3398: using guessed type char static_init_flag__AE3388_bit1__AE3378_bit2; //----- (0049895A) -------------------------------------------------------- -bool stru9::_49895A(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3) +bool stru9::AreVectorsCollinear(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3) { - double v4; // st7@3 - double v5; // st7@3 - __int16 v6; // fps@3 - char v7; // c0@3 - char v8; // c2@3 - char v9; // c3@3 - bool result; // eax@3 - static stru312 static_F942A0; - /*static bool __init_flag1 = false; - if (!__init_flag1) - { - __init_flag1 = true; - stru312::stru312(&static_F942A0); - }*/ + static_F942A0.x = a1->vWorldPosition.x - a2->vWorldPosition.x; + static_F942A0.y = a1->vWorldPosition.y - a2->vWorldPosition.y; + static_F942A0.z = a1->vWorldPosition.z - a2->vWorldPosition.z; - static_F942A0.flt_0 = a1->vWorldPosition.x - a2->vWorldPosition.x; - static_F942A0.flt_4 = a1->vWorldPosition.y - a2->vWorldPosition.y; - v4 = a1->vWorldPosition.z - a2->vWorldPosition.z; - HIWORD(result) = HIWORD(a3); - static_F942A0.flt_8 = v4; - v5 = v4 * a3->flt_8 + static_F942A0.flt_4 * a3->flt_4 + static_F942A0.flt_0 * a3->flt_0; - //UNDEF(v6); - flt_F942B0 = v5; - v7 = v5 < 0.0; - v8 = 0; - v9 = v5 == 0.0; - BYTE1(result) = HIBYTE(v6); - LOBYTE(result) = v5 >= 0.0; - return result; + static float flt_F942B4 = static_F942A0.z * a3->z + static_F942A0.y * a3->y + static_F942A0.x * a3->x; + if (flt_F942B4 >= 0) + return true; + return false; } @@ -377,156 +350,88 @@ bool r1; bool r2; - r1 = _49895A(a1, a3, a4); - r2 = _49895A(a2, a3, a4); + r1 = AreVectorsCollinear(a1, a3, a4); + r2 = AreVectorsCollinear(a2, a3, a4); return !r1 && r2 == 1 || r1 == 1 && !r2; } //----- (004980B9) -------------------------------------------------------- -bool stru9::_4980B9(RenderVertexSoft *a1, signed int a2, float a3, float a4, float a5, RenderVertexSoft *a6, unsigned int *pOutNumVertices) +bool stru9::_4980B9(RenderVertexSoft *a1, unsigned int uNumVertices, float a3, float a4, float a5, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices) { - bool result; // eax@7 - unsigned int *v9; // ebx@7 - char *v10; // edi@8 - RenderVertexSoft *v11; // esi@9 RenderVertexSoft *v12; // ecx@9 double v13; // st7@12 double v14; // st6@12 double v15; // st5@12 - RenderVertexSoft *v16; // edi@13 - int v17; // ecx@25 - VertexBuffer *v18; // edx@26 - char *v19; // eax@26 - unsigned int i; // ecx@26 - bool v21; // [sp+0h] [bp-24h]@9 - char *v22; // [sp+Ch] [bp-18h]@8 - RenderVertexSoft *a2a; // [sp+10h] [bp-14h]@0 - RenderVertexSoft *a1a; // [sp+14h] [bp-10h]@0 signed int v25; // [sp+18h] [bp-Ch]@7 - signed int v26; // [sp+1Ch] [bp-8h]@12 - int v27; // [sp+1Ch] [bp-8h]@25 - stru9 *thisa; // [sp+20h] [bp-4h]@1 - - __debugbreak(); - thisa = this; static RenderVertexSoft stru_AE4BFC; - static bool __init_flag1 = false; - if (!__init_flag1) - { - __init_flag1 = true; + static stru312 static_sub_4980B9_stru_AE4BEC; // idb + static VertexBuffer static_sub_4980B9_stru_AE3FE8; // idb - stru_AE4BFC.flt_2C = 0.0; - } - - static stru312 static_sub_4980B9_stru_AE4BEC; // idb - static bool __init_flag2 = false; - if (!__init_flag2) + v25 = 0; + if (uNumVertices <= 0) { - __init_flag2 = true; - - //stru312::stru312(&static_sub_4980B9_stru_AE4BEC); - } - - static VertexBuffer static_sub_4980B9_stru_AE3FE8; // idb - static bool __init_flag3 = false; - if (!__init_flag3) - { - __init_flag3 = true; - - //VertexBuffer::VertexBuffer(&static_sub_4980B9_stru_AE3FE8); + *pOutNumVertices = 0; + return true; } - result = 0; - v9 = pOutNumVertices; - v25 = 0; - if ( a2 <= 0 ) - goto LABEL_32; - v10 = (char *)&a1->vWorldPosition.z; - v22 = (char *)&a1->vWorldPosition.z; - do + for (uint i = 0; i < uNumVertices; ++i) { - v11 = (RenderVertexSoft *)(v10 - 8); - v21 = result + 1; - v12 = &a1[(result + 1) % a2]; - if ( *((float *)v10 - 2) != v12->vWorldPosition.x - || *((float *)v10 - 1) != v12->vWorldPosition.y - || *(float *)v10 != v12->vWorldPosition.z ) + v12 = &a1[(i + 1) % uNumVertices]; + if (a1[i].vWorldPosition.x != v12->vWorldPosition.x || + a1[i].vWorldPosition.y != v12->vWorldPosition.y || + a1[i].vWorldPosition.z!= v12->vWorldPosition.z) { - v13 = v12->vWorldPosition.x - v11->vWorldPosition.x; - v14 = v12->vWorldPosition.y - *((float *)v10 - 1); - v15 = v12->vWorldPosition.z - *(float *)v10; + v13 = v12->vWorldPosition.x - a1[i].vWorldPosition.x; + v14 = v12->vWorldPosition.y - a1[i].vWorldPosition.y; + v15 = v12->vWorldPosition.z - a1[i].vWorldPosition.z; ++v25; - result = 0; + static_sub_4980B9_stru_AE3FE8.uNumVertices = 0; - v26 = 0; - static_sub_4980B9_stru_AE4BEC.flt_0 = a4 * v15 - v14 * a5; - static_sub_4980B9_stru_AE4BEC.flt_4 = v13 * a5 - v15 * a3; - static_sub_4980B9_stru_AE4BEC.flt_8 = v14 * a3 - v13 * a4; - if ( (signed int)*v9 <= 0 ) - goto LABEL_32; - do + static_sub_4980B9_stru_AE4BEC.x = a4 * v15 - v14 * a5; + static_sub_4980B9_stru_AE4BEC.y = v13 * a5 - v15 * a3; + static_sub_4980B9_stru_AE4BEC.z = v14 * a3 - v13 * a4; + if (*pOutNumVertices == 0) + return true; + + for (uint j = 0; j < *pOutNumVertices; ++j) { - v16 = &a6[result]; - if ( result ) + if (j) { - if ( _4989E1(a1a, &a6[result], v11, &static_sub_4980B9_stru_AE4BEC) - && _498774(a1a, v16, v11, &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) ) - AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC); - } - else - { - a2a = &a6[result]; + if (_4989E1(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC) && + _498774(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC)) + AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC); } - a1a = v16; - if ( _49895A(v16, v11, &static_sub_4980B9_stru_AE4BEC) ) - AddVertex(&static_sub_4980B9_stru_AE3FE8, v16); - v9 = pOutNumVertices; - result = v26++ + 1; + + if (AreVectorsCollinear(&pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC)) + AddVertex(&static_sub_4980B9_stru_AE3FE8, &pOutVertices[j]); } - while ( v26 < (signed int)*pOutNumVertices ); - if ( !static_sub_4980B9_stru_AE3FE8.uNumVertices ) - goto LABEL_32; - if ( _4989E1(v16, a2a, v11, &static_sub_4980B9_stru_AE4BEC) - && _498774(v16, a2a, v11, &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) ) - AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC); - v17 = static_sub_4980B9_stru_AE3FE8.uNumVertices; - v27 = 0; - if ( static_sub_4980B9_stru_AE3FE8.uNumVertices > 0 ) + + if (!static_sub_4980B9_stru_AE3FE8.uNumVertices) { - v18 = &static_sub_4980B9_stru_AE3FE8; - v19 = (char *)&a6->vWorldPosition.y; - for ( i = (char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].flt_20 - (char *)a6; - ; - i = (char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].flt_20 - (char *)a6 ) - { - ++v27; - *((int *)v19 - 1) = LODWORD(v18->pVertices[0].vWorldPosition.x); - v18 = (VertexBuffer *)((char *)v18 + 48); - *(float *)v19 = *(float *)&v19[(char *)&static_sub_4980B9_stru_AE3FE8 - (char *)a6]; - *((float *)v19 + 1) = *(float *)&v19[(char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].vWorldPosition.y - - (char *)a6]; - *((float *)v19 + 8) = *(float *)&v19[i]; - *((float *)v19 + 9) = *(float *)&v19[(char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].u - (char *)a6]; - v17 = static_sub_4980B9_stru_AE3FE8.uNumVertices; - v19 += 48; - if ( v27 >= static_sub_4980B9_stru_AE3FE8.uNumVertices ) - break; - } + *pOutNumVertices = 0; + return true; } - v9 = pOutNumVertices; - v10 = v22; - *pOutNumVertices = v17; + if (_4989E1(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC) && + _498774(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) ) + AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC); + + for (uint j = 0; j < static_sub_4980B9_stru_AE3FE8.uNumVertices; ++j) + { + pOutVertices[j].vWorldPosition.y = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.x; + pOutVertices[j].vWorldPosition.y = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.y; + pOutVertices[j].vWorldPosition.z = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.z; + pOutVertices[j].u = static_sub_4980B9_stru_AE3FE8.pVertices[j].u; + pOutVertices[j].v = static_sub_4980B9_stru_AE3FE8.pVertices[j].v; + } + *pOutNumVertices = static_sub_4980B9_stru_AE3FE8.uNumVertices; } - result = v21; - v10 += 48; - v22 = v10; } - while ( v21 < a2 ); - if ( v25 < 3 ) -LABEL_32: - *v9 = 0; - return 1; + + if (v25 < 3) + *pOutNumVertices = 0; + + return true; } // AE4C2C: using guessed type char static_sub_4980B9_byte_AE4C2C_init_flag; \ No newline at end of file
--- a/stru9.h Sat Oct 27 23:52:40 2012 +0600 +++ b/stru9.h Sat Oct 27 23:53:04 2012 +0600 @@ -32,10 +32,11 @@ { } - float flt_0; - float flt_4; - float flt_8; + float x; + float y; + float z; char field_C; + char pad[3]; }; #pragma pack(pop) @@ -49,12 +50,12 @@ inline stru9() {} - bool _4980B9(struct RenderVertexSoft *a1, signed int a2, float a3, float a4, float a5, struct RenderVertexSoft *a6, unsigned int *pOutNumVertices); + bool _4980B9(struct RenderVertexSoft *a1, unsigned int uNumVertices, float a3, float a4, float a5, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices); bool _498377(struct RenderVertexSoft *a1, unsigned int uNumVertices, struct IndoorCameraD3D_Vec4 *a3, struct RenderVertexSoft *pVertices, unsigned int *pOutNumVertices); bool _4985FB(struct RenderVertexSoft *a1, signed int a2, struct RenderVertexSoft *a3, unsigned int *pOutNumVertices, struct Vec3_float_ *a5, float a6, char *a7, int unused); void AddVertex(struct VertexBuffer *pVertexBuffer, struct RenderVertexSoft *pVertex); bool _498774(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4, struct RenderVertexSoft *a5); - bool _49895A(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3); + bool AreVectorsCollinear(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3); bool _4989E1(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4); void (__thiscall ***vdestructor_ptr)(stru9 *, bool);