Mercurial > mm7
changeset 1443:a8b1bbac95d4
Слияние
author | Ritor1 |
---|---|
date | Fri, 02 Aug 2013 23:59:25 +0600 |
parents | c3bfa7e7cee1 (current diff) ff495bf260d9 (diff) |
children | 7b1a94270756 |
files | Chest.cpp Render.cpp mm7_2.cpp mm7_3.cpp |
diffstat | 15 files changed, 1010 insertions(+), 1186 deletions(-) [+] |
line wrap: on
line diff
--- a/AudioPlayer.h Fri Aug 02 23:58:57 2013 +0600 +++ b/AudioPlayer.h Fri Aug 02 23:59:25 2013 +0600 @@ -102,13 +102,16 @@ SOUND_Arcomage_131 = 0x83, SOUND_Arcomage_WallUpgrade = 0x84, SOUND_GoldReceived = 0xC8, - SOUND_206 =206, - SOUND_207 =207, + SOUND_203 = 203, + SOUND_206 = 206, + SOUND_207 = 207, SOUND_OpenChest = 208, SOUND_PlayerCantCastSpell = 0xD1, SOUND_Bell = 0xD9, SOUND_OpenBook = 230, SOUND_CloseBook = 231, + SOUND_11090 = 11090, + SOUND_12040 = 12040, SOUND_20001 = 0x4E21, };
--- a/Chest.cpp Fri Aug 02 23:58:57 2013 +0600 +++ b/Chest.cpp Fri Aug 02 23:59:25 2013 +0600 @@ -22,6 +22,7 @@ #include "ObjectList.h" #include "GUIWindow.h" #include "Time.h" +#include "Overlays.h" #include "mm7_data.h" #include "MM7.h" @@ -195,6 +196,35 @@ return true; } + +//----- (0042038D) -------------------------------------------------------- +void __cdecl ChestUI_WritePointedObjectStatusString() +{ + POINT *v0; // esi@2 + int v1; // ecx@2 + const char *v2; // eax@3 + POINT v3; // [sp+0h] [bp-10h]@2 + POINT a2; // [sp+8h] [bp-8h]@1 + + __debugbreak(); // invalid indexing + if ( pMouse->GetCursorPos(&a2)->y < 350 ) + { + v0 = pMouse->GetCursorPos(&a2); + v1 = pRenderer->pActiveZBuffer[v0->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v3)->y]]; + if ( v1 ) + { + auto _w = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + + 18 * *((short *)&pChests[0].igChestItems[139].uExpireTime + + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); + + _w = (ItemGen *)(&pChests[(unsigned int)pChestWindow->ptr_1C] -32 + + 18 * *((short *)&pChests[(unsigned int)pChestWindow->ptr_1C].igChestItems[139].uExpireTime + v1 + 3)); + v2 = _w->GetDisplayName(); + GameUI_SetFooterString(v2); + } + } +} + //----- (0042092D) -------------------------------------------------------- void Chest::DrawChestUI(signed int uChestID) {
--- a/GUIWindow.h Fri Aug 02 23:58:57 2013 +0600 +++ b/GUIWindow.h Fri Aug 02 23:59:25 2013 +0600 @@ -19,7 +19,7 @@ UIMSG_MouseLeftClickInScreen = 14, UIMSG_F = 15, - UIMSG_11 = 17, + UIMSG_ChangeCursor = 17, UIMSG_Attack = 23, @@ -229,7 +229,7 @@ enum DIALOGUE_TYPE { - DIALOGUE_9 = 9, + DIALOGUE_USE_NPC_ABILITY = 9, DIALOGUE_13 = 0xD, DIALOGUE_18 = 0x12, DIALOGUE_19 = 19,
--- a/NPC.h Fri Aug 02 23:58:57 2013 +0600 +++ b/NPC.h Fri Aug 02 23:59:25 2013 +0600 @@ -193,3 +193,5 @@ bool PartyHasDragon(); bool CheckHiredNPCSpeciality(unsigned int uProfession); + +int UseNPCSkill(NPCProf profession);
--- a/Outdoor.cpp Fri Aug 02 23:58:57 2013 +0600 +++ b/Outdoor.cpp Fri Aug 02 23:59:25 2013 +0600 @@ -3167,7 +3167,7 @@ return true; } //----- (0046D49E) -------------------------------------------------------- -int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int __unused, int *pIsOnWater, int *a6, int bWaterWalk) +int ODM_GetFloorLevel(int X, signed int Y, int Z, int __unused, int *pIsOnWater, int *bmodel_pid, int bWaterWalk) { BSPModel *pBModel; // esi@4 ODMFace *pFace; // ecx@11 @@ -3284,12 +3284,12 @@ } if ( v46 == 1 ) { - *a6 = 0; + *bmodel_pid = 0; return odm_floor_level[0]; } v27 = 0; if ( v46 <= 1 ) - *a6 = 0; + *bmodel_pid = 0; else { //v29 = 1; @@ -3319,9 +3319,9 @@ } } if ( !v27 ) - *a6 = 0; + *bmodel_pid = 0; else - *a6 = dword_721110[v27] | (dword_721160[v27] << 6); + *bmodel_pid = dword_721110[v27] | (dword_721160[v27] << 6); } if ( v27 ) { @@ -3334,6 +3334,7 @@ odm_floor_level[0] = odm_floor_level[v27]; return odm_floor_level[0]; } + //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) --------------------------------------------------------
--- a/Render.cpp Fri Aug 02 23:58:57 2013 +0600 +++ b/Render.cpp Fri Aug 02 23:59:25 2013 +0600 @@ -50,22 +50,11 @@ int uNumSpritesDrawnThisFrame; // weak RenderVertexSoft array_507D30[50]; -RenderVertexSoft array_508690[50]; -RenderVertexSoft array_508FF0[50]; -RenderVertexSoft array_509950[50]; -RenderVertexSoft array_50A2B0[50]; RenderVertexSoft array_50AC10[50]; - RenderVertexSoft array_73D150[20]; RenderVertexD3D3 d3d_vertex_buffer[50]; -RenderVertexSoft *ptr_801A04; -RenderVertexSoft *ptr_801A08; - -RenderVertexSoft pVerticesSR_801A10[384]; -RenderVertexSoft pVerticesSR_806210[384]; - void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); /* 384 */ @@ -383,588 +372,6 @@ } } -//----- (0048034E) -------------------------------------------------------- -void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4) -{ - //int v3; // esi@1 - int v4; // edi@1 - int v5; // ebx@2 - int v6; // eax@2 - int v7; // eax@3 - RenderVertexSoft *v8; // edi@3 - RenderVertexSoft *v9; // ebx@4 - RenderVertexSoft *v10; // ecx@4 - float v11; // eax@6 - double v12; // ST5C_8@6 - double v13; // ST2C_8@6 - int v14; // eax@6 - double v15; // st7@6 - struct Polygon *pTile; // ebx@12 - unsigned __int16 v17; // ax@12 - int v18; // eax@13 - signed int v22; // eax@13 - Vec3_float_ *norm; // eax@15 - //double v24; // st6@17 - double v25; // ST54_8@17 - unsigned __int8 v26; // sf@17 - unsigned __int8 v27; // of@17 - double v28; // st5@19 - double v29; // st5@19 - double v30; // st5@19 - double v31; // st5@19 - struct struct8 *v32; // esi@21 - double v3a; // st7@32 - int v33; // edi@38 - unsigned int v34; // ecx@47 - char v35; // zf@47 - unsigned int v36; // eax@50 - int v37; // eax@54 - //Polygon *v38; // ecx@55 - unsigned int v39; // eax@59 - struct Polygon *v40; // ebx@62 - unsigned __int16 pTileBitmapsID; // ax@62 - int v42; // eax@63 - LightmapBuilder *v43; // ecx@63 - int v44; // eax@63 - int v45; // eax@63 - int v46; // eax@63 - signed int v47; // eax@63 - Vec3_float_ *v48; // eax@65 - double v49; // st6@67 - double v50; // ST4C_8@67 - double v51; // st5@71 - double v52; // st5@71 - double v53; // st5@71 - double v54; // st7@84 - unsigned int v55; // ecx@98 - unsigned int v56; // eax@101 - int v57; // eax@105 - unsigned int v58; // eax@109 - struct Polygon *v59; // esi@112 - unsigned __int16 v60; // ax@112 - int v61; // eax@113 - signed int v62; // eax@113 - Vec3_float_ *v63; // eax@114 - double v64; // st6@116 - double v65; // ST3C_8@116 - double v66; // st5@120 - double v67; // st5@120 - double v68; // st5@120 - double v69; // st7@133 - int v70; // edi@138 - struct Polygon *v71; // esi@147 - unsigned int v72; // ecx@147 - unsigned int v73; // eax@150 - int v74; // eax@154 - unsigned int v75; // eax@158 - //unsigned int v76; // [sp-10h] [bp-E0h]@61 - int v77; // [sp-Ch] [bp-DCh]@61 - IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 - //int v79; // [sp-4h] [bp-D4h]@61 - bool v80; // [sp+0h] [bp-D0h]@59 - bool v81; // [sp+0h] [bp-D0h]@109 - int v82; // [sp+54h] [bp-7Ch]@1 - int v83; // [sp+60h] [bp-70h]@1 - int v84; // [sp+6Ch] [bp-64h]@1 - int v85; // [sp+70h] [bp-60h]@63 - float a4; // [sp+74h] [bp-5Ch]@73 - float v87; // [sp+78h] [bp-58h]@122 - int v88; // [sp+7Ch] [bp-54h]@1 - int v89; // [sp+80h] [bp-50h]@6 - int v93; // [sp+90h] [bp-40h]@2 - int X; // [sp+94h] [bp-3Ch]@1 - float v95; // [sp+98h] [bp-38h]@21 - LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 - int v97; // [sp+A0h] [bp-30h]@6 - int sX; // [sp+A4h] [bp-2Ch]@6 - unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 - int v100; // [sp+ACh] [bp-24h]@122 - int sY; // [sp+B0h] [bp-20h]@6 - RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 - unsigned int a5; // [sp+B8h] [bp-18h]@21 - RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 - Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 - RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 - RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 - char v108; // [sp+CFh] [bp-1h]@36 - float thisd; // [sp+D8h] [bp+8h]@6 - float thise; // [sp+D8h] [bp+8h]@6 - float thisf; // [sp+D8h] [bp+8h]@17 - IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 - float thisg; // [sp+D8h] [bp+8h]@67 - IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 - float thish; // [sp+D8h] [bp+8h]@116 - IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 - char this_3; // [sp+DBh] [bp+Bh]@30 - char this_3a; // [sp+DBh] [bp+Bh]@82 - char this_3b; // [sp+DBh] [bp+Bh]@131 - - static stru154 static_sub_0048034E_stru_154; - static stru154 stru_76D5A8; - //v3 = a1; - v82 = a2; - v83 = a3; - X = abs(unk4); - v4 = 0; - v88 = 0; - v84 = a1 - 1; -/* if ( a1 - 1 > 0 ) - { - while ( 1 ) - { - v5 = abs(X);//v5 = 13108 - v6 = abs(v83);//v6 = 13108 - --X; - //__debugbreak(); // uncoment & refactor following large if - v93 = (int)&terrain_76E5C8[(v5 << 7) + v6]; - /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), - v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), - ((a8 = v9, - pVertices = &pVerticesSR_801A10[1] + v7, - v11 = v8->vWorldPosition.x, - v101 = v10, - v12 = v11 + 6.755399441055744e15, - sX = LODWORD(v12), - v13 = v8->vWorldPosition.y + 6.755399441055744e15, - sY = LODWORD(v13), - thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, - v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X - v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, - v89 = v14, - thise = v15 * 0.5, - _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z - WorldPosToGridCellX(sX), - WorldPosToGridCellZ(sY), - !byte_4D864C) - || !(pGame->uFlags & 0x80)) - && !_481EFA_clip_terrain_poly(v8, v9, v101, pVertices, 1)) )*/ - /*if ( !&terrain_76E5C8[(v5 << 7) + v6] ) - goto LABEL_162*/ - v8 = &pVerticesSR_806210[v4]; - //pVertices2 = &pVerticesSR_801A10[v4 + 1]; - //v102 = v8; - if (!v82) - { - pVertices = &pVerticesSR_801A10[v4]; - v101 = &pVerticesSR_806210[v4 + 1]; - } - else - { - pVertices = &pVerticesSR_801A10[v4 + 1]; - v101 = &pVerticesSR_806210[v4]; - } - sX = floorf(v8->vWorldPosition.x + 0.5f); - sY = floorf(v8->vWorldPosition.z + 0.5f); - v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); - v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); - /*WorldPosToGridCellX(sX); - WorldPosToGridCellZ(sY); - if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !_481EFA_clip_terrain_poly(v8, pVertices, v101, pVertices2, 1)) - if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y - || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) - break;*/ - pTile = &array_77EC08[pOutdoorCamera->uNumPolygons]; - pTile->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( pTile->uTileBitmapID != -1 ) - { - pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); - pTile->field_32 = 0; - pTile->field_59 = 1; - pTile->terrain_grid_x = (char)v97; - __debugbreak(); // warning C4700: uninitialized local variable 'v93' used - pTile->field_34 = *(_WORD *)(v93 + 2); - pTile->terrain_grid_z = v89; - v22 = pTerrainNormalIndices[2 * (v97 + 128 * v89) + 1]; - if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) - norm = 0; - else - norm = &pTerrainNormals[v22]; - thisf = 20.0 - ( -(((float)pOutdoor->vSunlight.x / 65536.0) * norm->x) - - (((float)pOutdoor->vSunlight.y / 65536.0) * norm->y) - - (((float)pOutdoor->vSunlight.z / 65536.0) * norm->z)) * 20.0; - //v25 = thisf + 6.7553994e15; - //v27 = pOutdoorCamera->uNumPolygons > 1999; - //v26 = pOutdoorCamera->uNumPolygons - 1999 < 0; - pTile->dimming_level = floorf(thisf + 0.5f); - if ( pOutdoorCamera->uNumPolygons >= 1999 ) - return; - ++pOutdoorCamera->uNumPolygons; - //if ( !_481FC9_terrain(v8, pVertices, v101, v16) )//Ritor1: It's temporary - //goto LABEL_126; - //{ - //--pOutdoorCamera->uNumPolygons; - //goto LABEL_162; - //} - __debugbreak(); // warning C4700: uninitialized local variable 'v102' used - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - __debugbreak(); // warning C4700: uninitialized local variable 'pVertices2' used - memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); - array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[3].u = 1.0; - array_50AC10[3].v = 0.0; - /*if ( !(byte_76D5C0 & 1) ) - { - byte_76D5C0 |= 1u; - stru154(stru_76D5A8); - atexit(loc_481199); - }*/ - v32 = (struct8 *)array_50AC10; - v97 = (int)pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &v95, array_50AC10, 4, 1); - pDecalBuilder->_49BE8A(pTile, norm, &v95, array_50AC10, 4, 1); - a5 = 4; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisa = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) - goto LABEL_162; - thisa->ViewTransform(array_50AC10, a5); - thisa->Project(array_50AC10, a5, 0); - } - this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 - || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; - v3a = (double)pOutdoorCamera->shading_dist_mist; - v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x - || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; - v33 = 0; - pGame->pLightmapBuilder->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3 ) - v33 = 3; - else - v33 = v108 != 0 ? 5 : 0; - static_sub_0048034E_stru_154.ClassifyPolygon(norm, v95); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - pTile->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); - v34 = a5; - //v35 = byte_4D864C == 0; - pTile->uNumVertices = a5; - if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) - { - if ( this_3 ) - { - v36 = sr_424CD7(v34); - pTile->uNumVertices = v36; - OutdoorCamera::Project(v36); - } - if ( v108 ) - { - v36 = sr_424EE0_MakeFanFromTriangle(v34); - pTile->uNumVertices = v36; - OutdoorCamera::Project(v36); - } - } - //v37 = *(int *)&v16->flags; - if ( ~pTile->flags & 1 ) - { - if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v80 = false; - v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v39 = pTile->uTileBitmapID; - v80 = true; - } - //v79 = 0; - //v78 = pBitmaps_LOD->pHardwareTextures[v39]; - pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary - v77 = (int)pTile; - //v76 = v16->uNumVertices; -//LABEL_161: - pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v39], false, v80); - goto LABEL_162; - } -LABEL_56: - pTile->DrawBorderTiles(); - } -LABEL_162: - v4 = v88 + 1; - if ( ++v88 >= v84 ) - return; - } - /* v40 = &array_77EC08[pOutdoorCamera->uNumPolygons]; - v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( v40->uTileBitmapID == -1 ) - goto LABEL_162; - v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); - BYTE1(v42) |= 0x80u; - v43 = pGame->pLightmapBuilder; - *(int *)&v40->flags = v42; - v44 = v93; - v40->field_59 = 1; - v40->terrain_grid_x = (char)v43; - v40->field_34 = *(_WORD *)(v44 + 2); - v45 = v89; - v40->terrain_grid_z = v89; - v46 = 4 * ((char)v43 + (v45 << 7)); - v85 = v46; - v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; - if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) - v48 = 0; - else - v48 = &pTerrainNormals[v47]; - v49 = v92 * v48->y; - //v99 = v48; - thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; - v50 = thisg + 6.755399441055744e15; - v40->dimming_level = LOBYTE(v50); - if ( LOBYTE(v50) < 0 ) - v40->dimming_level = 0; - if ( pOutdoorCamera->uNumPolygons >= 1999 ) - return; - ++pOutdoorCamera->uNumPolygons; - /*if ( !_481FC9_terrain(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary - //goto LABEL_77; - { - --pOutdoorCamera->uNumPolygons; - goto LABEL_112; - }*/ - /*memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - static stru154 static_sub_0048034E_stru_76D590; - /*static bool __init_flag2 = false; - if (!__init_flag2) - { - __init_flag2 = true; - stru154::stru154(&static_sub_0048034E_stru_76D590); - }*/ - /*if ( !(byte_76D5C0 & 2) ) - { - byte_76D5C0 |= 2; - Polygon(stru_76D590); - atexit(loc_48118F); - }*/ - /*v96 = pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); - pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); - uNumVertices = 3; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisb = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) - { -//LABEL_77: - --pOutdoorCamera->uNumPolygons; - goto LABEL_112; - } - thisb->ViewTransform(array_50AC10, uNumVertices); - thisb->Project(array_50AC10, uNumVertices, 0); - } - this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; - v54 = (double)pOutdoorCamera->shading_dist_mist; - v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; - pVertices = 0; - v96->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3a ) - pVertices = (RenderVertexSoft *)3; - else - pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); - //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); - static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); - v55 = uNumVertices; - //v35 = byte_4D864C == 0; - v40->uNumVertices = uNumVertices; - if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) - { - if ( this_3a ) - { - v56 = sr_424CD7(v55); - } - else - { - if ( !v108 ) - goto LABEL_105; - v56 = sr_424EE0_MakeFanFromTriangle(v55); - } - v40->uNumVertices = v56; - OutdoorCamera::Project(v56); - } -LABEL_105: - v57 = *(int *)&v40->flags; - if ( BYTE1(v57) & 1 ) - { - v40->DrawBorderTiles(); - } - else - { - if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v81 = false; - v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v58 = v40->uTileBitmapID; - v81 = true; - } - pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); - } -LABEL_112: - v59 = &array_77EC08[pOutdoorCamera->uNumPolygons]; - //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->uNumPolygons]; - v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( v59->uTileBitmapID == -1 ) - goto LABEL_162; - *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); - v61 = v93; - v59->field_59 = 1; - v59->field_34 = *(_WORD *)(v61 + 2); - v59->terrain_grid_z = v89; - v59->terrain_grid_x = v97; - v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); - if ( v62 > (signed int)(uNumTerrainNormals - 1) ) - v63 = 0; - else - v63 = &pTerrainNormals[v62]; - v64 = v92 * v63->y; - //v99 = v63; - thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; - v59->dimming_level = floorf(thish + 0.5f); - if ( v59->dimming_level < 0 ) - v59->dimming_level = 0; - if ( pOutdoorCamera->uNumPolygons >= 1999 ) - return; - ++pOutdoorCamera->uNumPolygons; - if ( !_481FC9_terrain(v101, v102, pVertices2, v59) ) - { -//LABEL_126: - --pOutdoorCamera->uNumPolygons; - goto LABEL_162; - } - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[1].u = 1.0; - array_50AC10[1].v = 1.0; - memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 0.0; - static stru154 static_sub_0048034E_stru_76D578; - /*static bool __init_flag1 = false; - if (!__init_flag1) - { - __init_flag1 = true; - stru154::stru154(&static_sub_0048034E_stru_76D578); - }*/ - /* v96 = pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); - pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1); - v100 = 3; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisc = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) - //goto LABEL_126; - { - --pOutdoorCamera->uNumPolygons; - goto LABEL_162; - } - thisc->ViewTransform(array_50AC10, v100); - thisc->Project(array_50AC10, v100, 0); - } - this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 - || v101->vWorldViewPosition.x < 8.0; - v69 = (double)pOutdoorCamera->shading_dist_mist; - v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; - v70 = 0; - v96->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3b ) - v70 = 3; - else - v70 = v108 != 0 ? 5 : 0; - static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); - v71 = v59; - v72 = v100; - //v35 = byte_4D864C == 0; - v59->uNumVertices = v100;//??? - if ( !byte_4D864C && pGame->uFlags & 0x80 ) - goto LABEL_154; - if ( this_3b ) - { - v73 = sr_424CD7(v72); - } - else - { - if ( !v108 ) - { -LABEL_154: - v74 = v71->flags; - if ( !(BYTE1(v74) & 1) ) - { - if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v80 = false; - v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v75 = v71->uTileBitmapID; - v80 = true; - } - //v79 = 0; - v78 = pBitmaps_LOD->pHardwareTextures[v75]; - v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary - //v77 = (int)v71; - //v76 = v71->uNumVertices; - //goto LABEL_161; - pRenderer->DrawTerrainPolygon(v71->uNumVertices, (Polygon *)v71, v78, 0, v80); - goto LABEL_162; - } - v38 = (Polygon *)v71; - goto LABEL_56; - } - v73 = sr_424EE0_MakeFanFromTriangle(v72); - } - v71->uNumVertices = v73; - OutdoorCamera::Project(v73); - goto LABEL_154; - } - }*/ //----- (0047BACF) --------------------------------------------------------
--- a/Render.h Fri Aug 02 23:58:57 2013 +0600 +++ b/Render.h Fri Aug 02 23:59:25 2013 +0600 @@ -510,18 +510,7 @@ extern RenderVertexSoft array_507D30[50]; -extern RenderVertexSoft array_508690[50]; -extern RenderVertexSoft array_508FF0[50]; -extern RenderVertexSoft array_509950[50]; -extern RenderVertexSoft array_50A2B0[50]; extern RenderVertexSoft array_50AC10[50]; - extern RenderVertexSoft array_73D150[20]; -extern RenderVertexD3D3 d3d_vertex_buffer[50]; - -extern RenderVertexSoft *ptr_801A04; -extern RenderVertexSoft *ptr_801A08; - -extern RenderVertexSoft pVerticesSR_801A10[384]; -extern RenderVertexSoft pVerticesSR_806210[384]; \ No newline at end of file +extern RenderVertexD3D3 d3d_vertex_buffer[50]; \ No newline at end of file
--- a/UI/UiGame.cpp Fri Aug 02 23:58:57 2013 +0600 +++ b/UI/UiGame.cpp Fri Aug 02 23:59:25 2013 +0600 @@ -1901,7 +1901,7 @@ { if ( pCurrentScreen == SCREEN_CHEST ) { - sub_42038D(); + ChestUI_WritePointedObjectStatusString(); //goto _return; if ( pMouse->uPointingObjectID == 0 ) {
--- a/_deleted.cpp Fri Aug 02 23:58:57 2013 +0600 +++ b/_deleted.cpp Fri Aug 02 23:59:25 2013 +0600 @@ -726,7 +726,7 @@ v27 = -10000.0; if ( (signed int)v1 > 0 ) { - v4 = (char *)&array_508690[0].vWorldViewProjY; + v4 = (char *)&sr_508690[0].vWorldViewProjY; do { if ( *((float *)v4 - 1) < (double)v26 ) @@ -769,20 +769,20 @@ *(&v19 + v10) = i; } } - v11 = &array_508690[v19]; - v12 = &array_508690[v20]; - v13 = &array_508690[v21]; + v11 = &sr_508690[v19]; + v12 = &sr_508690[v20]; + v13 = &sr_508690[v21]; if ( LODWORD(v29) != 3 ) { - v11 = array_508690; - v13 = (RenderVertexSoft *)((char *)array_508690 + 16 * (3 * v1 - 3)); - v12 = &array_508690[1]; - v28 = array_508690[1].vWorldPosition.x - array_508690[0].vWorldPosition.x; - v27 = array_508690[1].vWorldPosition.y - array_508690[0].vWorldPosition.y; - v29 = array_508690[1].vWorldPosition.z - array_508690[0].vWorldPosition.z; - v26 = v13->vWorldPosition.x - array_508690[0].vWorldPosition.x; - v25 = v13->vWorldPosition.y - array_508690[0].vWorldPosition.y; - v24 = v13->vWorldPosition.z - array_508690[0].vWorldPosition.z; + v11 = sr_508690; + v13 = (RenderVertexSoft *)((char *)sr_508690 + 16 * (3 * v1 - 3)); + v12 = &sr_508690[1]; + v28 = sr_508690[1].vWorldPosition.x - sr_508690[0].vWorldPosition.x; + v27 = sr_508690[1].vWorldPosition.y - sr_508690[0].vWorldPosition.y; + v29 = sr_508690[1].vWorldPosition.z - sr_508690[0].vWorldPosition.z; + v26 = v13->vWorldPosition.x - sr_508690[0].vWorldPosition.x; + v25 = v13->vWorldPosition.y - sr_508690[0].vWorldPosition.y; + v24 = v13->vWorldPosition.z - sr_508690[0].vWorldPosition.z; if ( v24 * v27 - v25 * v29 == 0.0 ) { if ( v26 * v29 - v24 * v28 == 0.0 ) @@ -793,12 +793,12 @@ LODWORD(v26) = v14; if ( v14 >= 2 ) { - v15 = &array_508690[v14]; + v15 = &sr_508690[v14]; do { - v16 = v15->vWorldPosition.x - array_508690[0].vWorldPosition.x; - v17 = v15->vWorldPosition.y - array_508690[0].vWorldPosition.y; - v18 = v15->vWorldPosition.z - array_508690[0].vWorldPosition.z; + v16 = v15->vWorldPosition.x - sr_508690[0].vWorldPosition.x; + v17 = v15->vWorldPosition.y - sr_508690[0].vWorldPosition.y; + v18 = v15->vWorldPosition.z - sr_508690[0].vWorldPosition.z; v13 = v15; if ( v27 * v18 - v17 * v29 != 0.0 ) break; @@ -880,7 +880,7 @@ v5 = 0; if ( (signed int)a3->uNumVertices > 0 ) { - v6 = (char *)&array_508690[0].vWorldViewProjY; + v6 = (char *)&sr_508690[0].vWorldViewProjY; do { v7 = *((float *)v6 - 1) + 6.7553994e15; @@ -1587,7 +1587,7 @@ v39 = 0; if ( (signed int)v12->uNumVertices > 0 ) { - v40 = (char *)&array_508690[0].vWorldViewProjY; + v40 = (char *)&sr_508690[0].vWorldViewProjY; do { LODWORD(v64) = *((int *)v40 - 1); @@ -1615,7 +1615,7 @@ v46 = 0; if ( (signed int)v12->uNumVertices > 0 ) { - v47 = (char *)&array_508690[0].vWorldViewProjY; + v47 = (char *)&sr_508690[0].vWorldViewProjY; do { LODWORD(v61) = *((int *)v47 - 1); @@ -1646,7 +1646,7 @@ v51 = 0; if ( (signed int)v12->uNumVertices > 0 ) { - v52 = (char *)&array_508690[0].vWorldViewProjY; + v52 = (char *)&sr_508690[0].vWorldViewProjY; do { LODWORD(v62) = *((int *)v52 - 1); @@ -1663,7 +1663,7 @@ } } } - sr_sub_486B4E_push_outdoor_edges(array_508690, dword_50B638.data(), dword_50B570.data(), v12); + sr_sub_486B4E_push_outdoor_edges(sr_508690, dword_50B638.data(), dword_50B570.data(), v12); } LABEL_72: ++v79; @@ -4198,7 +4198,7 @@ { sr_sub_4829B9((RenderVertexSoft *)HIDWORD(v101), v52, v104, v38, 0); LABEL_68: - sr_sub_481DB2(array_508690, v54, v38); + sr_sub_481DB2(sr_508690, v54, v38); LABEL_75: v17 = &array_77EC08[pOutdoorCamera->uNumPolygons]; v57 = pOutdoor->GetTileTexture(v101, v100); @@ -4301,7 +4301,7 @@ LABEL_37: sr_sub_4829B9(v35, v34, v67, v68, v69); LABEL_38: - sr_sub_481DB2(array_508690, v33, v17); + sr_sub_481DB2(sr_508690, v33, v17); goto LABEL_105; } goto LABEL_74; @@ -8051,7 +8051,7 @@ return v117; v127 = a1; v1 = a1; - memcpy(array_508690, array_50AC10, 4 * ((unsigned int)(48 * a1) >> 2)); + memcpy(sr_508690, array_50AC10, 4 * ((unsigned int)(48 * a1) >> 2)); v2 = 0; do { @@ -8350,12 +8350,12 @@ v62 = SLODWORD(v61) <= (signed int)pViewport->uViewportBR_Y, v123 < 1) ) goto LABEL_112; - v63 = (char *)&array_508690[0].vWorldViewProjX; - v131 = array_508690; - v120 = (char *)&array_508690[0].vWorldViewProjX; - v140 = (char *)&array_508690[0].vWorldViewProjY; - v126 = (char *)&array_508690[0].flt_2C; - v135 = (char *)&array_508690[0]._rhw; + v63 = (char *)&sr_508690[0].vWorldViewProjX; + v131 = sr_508690; + v120 = (char *)&sr_508690[0].vWorldViewProjX; + v140 = (char *)&sr_508690[0].vWorldViewProjY; + v126 = (char *)&sr_508690[0].flt_2C; + v135 = (char *)&sr_508690[0]._rhw; v64 = (char *)&array_508FF0[0].flt_2C; v113 = v123; while ( 2 ) @@ -8437,10 +8437,10 @@ if ( v116 < 3 ) goto LABEL_112; v80 = v116; - memcpy(&array_508690[v116], array_508690, sizeof(array_508690[v116])); + memcpy(&sr_508690[v116], sr_508690, sizeof(sr_508690[v116])); if ( v116 > 0 ) { - v81 = (char *)&array_508690[0].vWorldViewProjX; + v81 = (char *)&sr_508690[0].vWorldViewProjX; v82 = v116; do { @@ -8484,7 +8484,7 @@ v90 = v116 - 3 < 0; if ( v116 > 3 ) { - memcpy(&array_508690[v116 + 1], &array_508690[1], sizeof(array_508690[v116 + 1])); + memcpy(&sr_508690[v116 + 1], &sr_508690[1], sizeof(sr_508690[v116 + 1])); if ( v116 > 0 ) { v105 = 1; @@ -8500,10 +8500,10 @@ v92 = v105 - v80; if ( v94 >= v80 ) v95 = v94 - v80; - if ( (array_508690[v92].vWorldViewProjX - array_508690[v93].vWorldViewProjX) - * (array_508690[v95].vWorldViewProjY - array_508690[v93].vWorldViewProjY) - - (array_508690[v95].vWorldViewProjX - array_508690[v93].vWorldViewProjX) - * (array_508690[v92].vWorldViewProjY - array_508690[v93].vWorldViewProjY) < 0.0 ) + if ( (sr_508690[v92].vWorldViewProjX - sr_508690[v93].vWorldViewProjX) + * (sr_508690[v95].vWorldViewProjY - sr_508690[v93].vWorldViewProjY) + - (sr_508690[v95].vWorldViewProjX - sr_508690[v93].vWorldViewProjX) + * (sr_508690[v92].vWorldViewProjY - sr_508690[v93].vWorldViewProjY) < 0.0 ) { ++v105; } @@ -8511,7 +8511,7 @@ { v96 = v105; if ( v105 < v80 || (v96 = v105 - v80, v105 - v80 < v80) ) - memcpy(&array_508690[v96], &array_508690[v96 + 1], 4 * ((unsigned int)(48 * v80 - 48 * v96) >> 2)); + memcpy(&sr_508690[v96], &sr_508690[v96 + 1], 4 * ((unsigned int)(48 * v80 - 48 * v96) >> 2)); --v80; } } @@ -8528,7 +8528,589 @@ return result; } - +//----- (0048034E) -------------------------------------------------------- +void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4) +{ + //int v3; // esi@1 + int v4; // edi@1 + int v5; // ebx@2 + int v6; // eax@2 + int v7; // eax@3 + RenderVertexSoft *v8; // edi@3 + RenderVertexSoft *v9; // ebx@4 + RenderVertexSoft *v10; // ecx@4 + float v11; // eax@6 + double v12; // ST5C_8@6 + double v13; // ST2C_8@6 + int v14; // eax@6 + double v15; // st7@6 + struct Polygon *pTile; // ebx@12 + unsigned __int16 v17; // ax@12 + int v18; // eax@13 + signed int v22; // eax@13 + Vec3_float_ *norm; // eax@15 + //double v24; // st6@17 + double v25; // ST54_8@17 + unsigned __int8 v26; // sf@17 + unsigned __int8 v27; // of@17 + double v28; // st5@19 + double v29; // st5@19 + double v30; // st5@19 + double v31; // st5@19 + struct struct8 *v32; // esi@21 + double v3a; // st7@32 + int v33; // edi@38 + unsigned int v34; // ecx@47 + char v35; // zf@47 + unsigned int v36; // eax@50 + int v37; // eax@54 + //Polygon *v38; // ecx@55 + unsigned int v39; // eax@59 + struct Polygon *v40; // ebx@62 + unsigned __int16 pTileBitmapsID; // ax@62 + int v42; // eax@63 + LightmapBuilder *v43; // ecx@63 + int v44; // eax@63 + int v45; // eax@63 + int v46; // eax@63 + signed int v47; // eax@63 + Vec3_float_ *v48; // eax@65 + double v49; // st6@67 + double v50; // ST4C_8@67 + double v51; // st5@71 + double v52; // st5@71 + double v53; // st5@71 + double v54; // st7@84 + unsigned int v55; // ecx@98 + unsigned int v56; // eax@101 + int v57; // eax@105 + unsigned int v58; // eax@109 + struct Polygon *v59; // esi@112 + unsigned __int16 v60; // ax@112 + int v61; // eax@113 + signed int v62; // eax@113 + Vec3_float_ *v63; // eax@114 + double v64; // st6@116 + double v65; // ST3C_8@116 + double v66; // st5@120 + double v67; // st5@120 + double v68; // st5@120 + double v69; // st7@133 + int v70; // edi@138 + struct Polygon *v71; // esi@147 + unsigned int v72; // ecx@147 + unsigned int v73; // eax@150 + int v74; // eax@154 + unsigned int v75; // eax@158 + //unsigned int v76; // [sp-10h] [bp-E0h]@61 + int v77; // [sp-Ch] [bp-DCh]@61 + IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 + //int v79; // [sp-4h] [bp-D4h]@61 + bool v80; // [sp+0h] [bp-D0h]@59 + bool v81; // [sp+0h] [bp-D0h]@109 + int v82; // [sp+54h] [bp-7Ch]@1 + int v83; // [sp+60h] [bp-70h]@1 + int v84; // [sp+6Ch] [bp-64h]@1 + int v85; // [sp+70h] [bp-60h]@63 + float a4; // [sp+74h] [bp-5Ch]@73 + float v87; // [sp+78h] [bp-58h]@122 + int v88; // [sp+7Ch] [bp-54h]@1 + int v89; // [sp+80h] [bp-50h]@6 + int v93; // [sp+90h] [bp-40h]@2 + int X; // [sp+94h] [bp-3Ch]@1 + float v95; // [sp+98h] [bp-38h]@21 + LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 + int v97; // [sp+A0h] [bp-30h]@6 + int sX; // [sp+A4h] [bp-2Ch]@6 + unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 + int v100; // [sp+ACh] [bp-24h]@122 + int sY; // [sp+B0h] [bp-20h]@6 + RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 + unsigned int a5; // [sp+B8h] [bp-18h]@21 + RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 + Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 + RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 + RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 + char v108; // [sp+CFh] [bp-1h]@36 + float thisd; // [sp+D8h] [bp+8h]@6 + float thise; // [sp+D8h] [bp+8h]@6 + float thisf; // [sp+D8h] [bp+8h]@17 + IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 + float thisg; // [sp+D8h] [bp+8h]@67 + IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 + float thish; // [sp+D8h] [bp+8h]@116 + IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 + char this_3; // [sp+DBh] [bp+Bh]@30 + char this_3a; // [sp+DBh] [bp+Bh]@82 + char this_3b; // [sp+DBh] [bp+Bh]@131 + + __debugbreak(); + static stru154 static_sub_0048034E_stru_154; + static stru154 stru_76D5A8; + //v3 = a1; + v82 = a2; + v83 = a3; + X = abs(unk4); + v4 = 0; + v88 = 0; + v84 = a1 - 1; + if ( a1 - 1 > 0 ) + { + while ( 1 ) + { + v5 = abs(X);//v5 = 13108 + v6 = abs(v83);//v6 = 13108 + --X; + //__debugbreak(); // uncoment & refactor following large if + v93 = (int)&terrain_76E5C8[(v5 << 7) + v6]; + if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), + v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), + ((a8 = v9, + pVertices = &pVerticesSR_801A10[1] + v7, + v11 = v8->vWorldPosition.x, + v101 = v10, + v12 = v11 + 6.755399441055744e15, + sX = LODWORD(v12), + v13 = v8->vWorldPosition.y + 6.755399441055744e15, + sY = LODWORD(v13), + thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, + v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X + v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, + v89 = v14, + thise = v15 * 0.5, + _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z + WorldPosToGridCellX(sX), + WorldPosToGridCellZ(sY), + !byte_4D864C) + || !(pGame->uFlags & 0x80)) + && !_481EFA_clip_terrain_poly(v8, v9, v101, pVertices, 1)) ) + if ( !&terrain_76E5C8[(v5 << 7) + v6] ) + goto LABEL_162 + v8 = &pVerticesSR_806210[v4]; + //pVertices2 = &pVerticesSR_801A10[v4 + 1]; + //v102 = v8; + if (!v82) + { + pVertices = &pVerticesSR_801A10[v4]; + v101 = &pVerticesSR_806210[v4 + 1]; + } + else + { + pVertices = &pVerticesSR_801A10[v4 + 1]; + v101 = &pVerticesSR_806210[v4]; + } + sX = floorf(v8->vWorldPosition.x + 0.5f); + sY = floorf(v8->vWorldPosition.z + 0.5f); + v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); + v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); + /*WorldPosToGridCellX(sX); + WorldPosToGridCellZ(sY); + if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !_481EFA_clip_terrain_poly(v8, pVertices, v101, pVertices2, 1)) + if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y + || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) + break; + pTile = &array_77EC08[pOutdoorCamera->uNumPolygons]; + pTile->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( pTile->uTileBitmapID != -1 ) + { + pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); + pTile->field_32 = 0; + pTile->field_59 = 1; + pTile->terrain_grid_x = (char)v97; + __debugbreak(); // warning C4700: uninitialized local variable 'v93' used + pTile->field_34 = *(_WORD *)(v93 + 2); + pTile->terrain_grid_z = v89; + v22 = pTerrainNormalIndices[2 * (v97 + 128 * v89) + 1]; + if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) + norm = 0; + else + norm = &pTerrainNormals[v22]; + thisf = 20.0 - ( -(((float)pOutdoor->vSunlight.x / 65536.0) * norm->x) - + (((float)pOutdoor->vSunlight.y / 65536.0) * norm->y) - + (((float)pOutdoor->vSunlight.z / 65536.0) * norm->z)) * 20.0; + //v25 = thisf + 6.7553994e15; + //v27 = pOutdoorCamera->uNumPolygons > 1999; + //v26 = pOutdoorCamera->uNumPolygons - 1999 < 0; + pTile->dimming_level = floorf(thisf + 0.5f); + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + //if ( !_481FC9_terrain(v8, pVertices, v101, v16) )//Ritor1: It's temporary + //goto LABEL_126; + //{ + //--pOutdoorCamera->uNumPolygons; + //goto LABEL_162; + //} + __debugbreak(); // warning C4700: uninitialized local variable 'v102' used + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + __debugbreak(); // warning C4700: uninitialized local variable 'pVertices2' used + memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); + array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[3].u = 1.0; + array_50AC10[3].v = 0.0; + if ( !(byte_76D5C0 & 1) ) + { + byte_76D5C0 |= 1u; + stru154(stru_76D5A8); + atexit(loc_481199); + } + v32 = (struct8 *)array_50AC10; + v97 = (int)pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &v95, array_50AC10, 4, 1); + pDecalBuilder->_49BE8A(pTile, norm, &v95, array_50AC10, 4, 1); + a5 = 4; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisa = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) + goto LABEL_162; + thisa->ViewTransform(array_50AC10, a5); + thisa->Project(array_50AC10, a5, 0); + } + this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 + || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; + v3a = (double)pOutdoorCamera->shading_dist_mist; + v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x + || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; + v33 = 0; + pGame->pLightmapBuilder->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3 ) + v33 = 3; + else + v33 = v108 != 0 ? 5 : 0; + static_sub_0048034E_stru_154.ClassifyPolygon(norm, v95); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - pTile->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); + v34 = a5; + //v35 = byte_4D864C == 0; + pTile->uNumVertices = a5; + if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) + { + if ( this_3 ) + { + v36 = sr_424CD7(v34); + pTile->uNumVertices = v36; + OutdoorCamera::Project(v36); + } + if ( v108 ) + { + v36 = sr_424EE0_MakeFanFromTriangle(v34); + pTile->uNumVertices = v36; + OutdoorCamera::Project(v36); + } + } + //v37 = *(int *)&v16->flags; + if ( ~pTile->flags & 1 ) + { + if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v80 = false; + v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v39 = pTile->uTileBitmapID; + v80 = true; + } + //v79 = 0; + //v78 = pBitmaps_LOD->pHardwareTextures[v39]; + pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary + v77 = (int)pTile; + //v76 = v16->uNumVertices; +//LABEL_161: + pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v39], false, v80); + goto LABEL_162; + } +LABEL_56: + pTile->DrawBorderTiles(); + } +LABEL_162: + v4 = v88 + 1; + if ( ++v88 >= v84 ) + return; + } + v40 = &array_77EC08[pOutdoorCamera->uNumPolygons]; + v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( v40->uTileBitmapID == -1 ) + goto LABEL_162; + v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); + BYTE1(v42) |= 0x80u; + v43 = pGame->pLightmapBuilder; + *(int *)&v40->flags = v42; + v44 = v93; + v40->field_59 = 1; + v40->terrain_grid_x = (char)v43; + v40->field_34 = *(_WORD *)(v44 + 2); + v45 = v89; + v40->terrain_grid_z = v89; + v46 = 4 * ((char)v43 + (v45 << 7)); + v85 = v46; + v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; + if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) + v48 = 0; + else + v48 = &pTerrainNormals[v47]; + v49 = v92 * v48->y; + //v99 = v48; + thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; + v50 = thisg + 6.755399441055744e15; + v40->dimming_level = LOBYTE(v50); + if ( LOBYTE(v50) < 0 ) + v40->dimming_level = 0; + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + if ( !_481FC9_terrain(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary + //goto LABEL_77; + { + --pOutdoorCamera->uNumPolygons; + goto LABEL_112; + } + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + static stru154 static_sub_0048034E_stru_76D590; + static bool __init_flag2 = false; + if (!__init_flag2) + { + __init_flag2 = true; + stru154::stru154(&static_sub_0048034E_stru_76D590); + } + if ( !(byte_76D5C0 & 2) ) + { + byte_76D5C0 |= 2; + Polygon(stru_76D590); + atexit(loc_48118F); + } + v96 = pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); + pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); + uNumVertices = 3; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisb = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) + { +//LABEL_77: + --pOutdoorCamera->uNumPolygons; + goto LABEL_112; + } + thisb->ViewTransform(array_50AC10, uNumVertices); + thisb->Project(array_50AC10, uNumVertices, 0); + } + this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; + v54 = (double)pOutdoorCamera->shading_dist_mist; + v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; + pVertices = 0; + v96->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3a ) + pVertices = (RenderVertexSoft *)3; + else + pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); + //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); + static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); + v55 = uNumVertices; + //v35 = byte_4D864C == 0; + v40->uNumVertices = uNumVertices; + if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) + { + if ( this_3a ) + { + v56 = sr_424CD7(v55); + } + else + { + if ( !v108 ) + goto LABEL_105; + v56 = sr_424EE0_MakeFanFromTriangle(v55); + } + v40->uNumVertices = v56; + OutdoorCamera::Project(v56); + } +LABEL_105: + v57 = *(int *)&v40->flags; + if ( BYTE1(v57) & 1 ) + { + v40->DrawBorderTiles(); + } + else + { + if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v81 = false; + v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v58 = v40->uTileBitmapID; + v81 = true; + } + pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); + } +LABEL_112: + v59 = &array_77EC08[pOutdoorCamera->uNumPolygons]; + //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->uNumPolygons]; + v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( v59->uTileBitmapID == -1 ) + goto LABEL_162; + *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); + v61 = v93; + v59->field_59 = 1; + v59->field_34 = *(_WORD *)(v61 + 2); + v59->terrain_grid_z = v89; + v59->terrain_grid_x = v97; + v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); + if ( v62 > (signed int)(uNumTerrainNormals - 1) ) + v63 = 0; + else + v63 = &pTerrainNormals[v62]; + v64 = v92 * v63->y; + //v99 = v63; + thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; + v59->dimming_level = floorf(thish + 0.5f); + if ( v59->dimming_level < 0 ) + v59->dimming_level = 0; + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + if ( !_481FC9_terrain(v101, v102, pVertices2, v59) ) + { +//LABEL_126: + --pOutdoorCamera->uNumPolygons; + goto LABEL_162; + } + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1].u = 1.0; + array_50AC10[1].v = 1.0; + memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 0.0; + static stru154 static_sub_0048034E_stru_76D578; + static bool __init_flag1 = false; + if (!__init_flag1) + { + __init_flag1 = true; + stru154::stru154(&static_sub_0048034E_stru_76D578); + } + v96 = pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); + pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1); + v100 = 3; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisc = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) + //goto LABEL_126; + { + --pOutdoorCamera->uNumPolygons; + goto LABEL_162; + } + thisc->ViewTransform(array_50AC10, v100); + thisc->Project(array_50AC10, v100, 0); + } + this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 + || v101->vWorldViewPosition.x < 8.0; + v69 = (double)pOutdoorCamera->shading_dist_mist; + v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; + v70 = 0; + v96->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3b ) + v70 = 3; + else + v70 = v108 != 0 ? 5 : 0; + static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); + v71 = v59; + v72 = v100; + //v35 = byte_4D864C == 0; + v59->uNumVertices = v100;//??? + if ( !byte_4D864C && pGame->uFlags & 0x80 ) + goto LABEL_154; + if ( this_3b ) + { + v73 = sr_424CD7(v72); + } + else + { + if ( !v108 ) + { +LABEL_154: + v74 = v71->flags; + if ( !(BYTE1(v74) & 1) ) + { + if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v80 = false; + v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v75 = v71->uTileBitmapID; + v80 = true; + } + //v79 = 0; + v78 = pBitmaps_LOD->pHardwareTextures[v75]; + v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary + //v77 = (int)v71; + //v76 = v71->uNumVertices; + //goto LABEL_161; + pRenderer->DrawTerrainPolygon(v71->uNumVertices, (Polygon *)v71, v78, 0, v80); + goto LABEL_162; + } + v38 = (Polygon *)v71; + goto LABEL_56; + } + v73 = sr_424EE0_MakeFanFromTriangle(v72); + } + v71->uNumVertices = v73; + OutdoorCamera::Project(v73); + goto LABEL_154; + } + } //----- (00424579) -------------------------------------------------------- int __fastcall sr_424579(int uFaceID, stru320 *a2) {
--- a/mm7_1.cpp Fri Aug 02 23:58:57 2013 +0600 +++ b/mm7_1.cpp Fri Aug 02 23:59:25 2013 +0600 @@ -135,34 +135,6 @@ a1->DrawText(a2, 32, uY, 0, pTmpBuf.data(), 0, 0, 0); } -//----- (0042038D) -------------------------------------------------------- -void __cdecl sub_42038D() -{ - POINT *v0; // esi@2 - int v1; // ecx@2 - const char *v2; // eax@3 - POINT v3; // [sp+0h] [bp-10h]@2 - POINT a2; // [sp+8h] [bp-8h]@1 - - __debugbreak(); // invalid indexing - if ( pMouse->GetCursorPos(&a2)->y < 350 ) - { - v0 = pMouse->GetCursorPos(&a2); - v1 = pRenderer->pActiveZBuffer[v0->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v3)->y]]; - if ( v1 ) - { - auto _w = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C - + 18 * *((short *)&pChests[0].igChestItems[139].uExpireTime - + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); - - _w = (ItemGen *)(&pChests[(unsigned int)pChestWindow->ptr_1C] -32 - + 18 * *((short *)&pChests[(unsigned int)pChestWindow->ptr_1C].igChestItems[139].uExpireTime + v1 + 3)); - v2 = _w->GetDisplayName(); - GameUI_SetFooterString(v2); - } - } -} - //----- (004226C2) -------------------------------------------------------- bool PauseGameDrawing() { @@ -434,78 +406,14 @@ - - -//----- (00423AEE) -------------------------------------------------------- -void __cdecl reset_some_strus_flt_2Cs() +//----- (00424CD7) -------------------------------------------------------- +int sr_424CD7(unsigned int num_vertices) { - float *v0; // eax@1 - signed int v1; // ecx@1 - signed int v2; // edx@1 - float *v3; // eax@3 - signed int v4; // edx@3 - float *v5; // eax@5 - signed int v6; // edx@5 - float *v7; // eax@7 - signed int v8; // edx@7 - float *v9; // eax@9 - - v0 = &array_50AC10[0].flt_2C; - v1 = 50; - v2 = 50; - do - { - *v0 = 0.0; - v0 += 12; - --v2; - } - while ( v2 ); - v3 = &array_50A2B0[0].flt_2C; - v4 = 50; - do - { - *v3 = 0.0; - v3 += 12; - --v4; - } - while ( v4 ); - v5 = &array_509950[0].flt_2C; - v6 = 50; - do - { - *v5 = 0.0; - v5 += 12; - --v6; - } - while ( v6 ); - v7 = &array_508FF0[0].flt_2C; - v8 = 50; - do - { - *v7 = 0.0; - v7 += 12; - --v8; - } - while ( v8 ); - v9 = &array_508690[0].flt_2C; - do - { - *v9 = 0.0; - v9 += 12; - --v1; - } - while ( v1 ); -} - - -//----- (00424CD7) -------------------------------------------------------- -signed int __fastcall sr_424CD7(unsigned int uVertexID) -{ - unsigned int v1; // edx@1 + //unsigned int v1; // edx@1 signed int v2; // edi@1 char *v3; // esi@4 char *v4; // ecx@4 - unsigned int v5; // eax@4 + //unsigned int v5; // eax@4 char *v6; // edx@4 double v7; // st6@10 double v8; // st5@10 @@ -515,29 +423,30 @@ RenderVertexSoft *v12; // edi@22 char *v13; // eax@22 double v14; // st6@22 - signed int result; // eax@24 - unsigned int v16; // [sp+8h] [bp-28h]@4 + //signed int result; // eax@24 + //unsigned int v16; // [sp+8h] [bp-28h]@4 bool v17; // [sp+Ch] [bp-24h]@6 char *v18; // [sp+10h] [bp-20h]@4 char *v19; // [sp+14h] [bp-1Ch]@4 - signed int v20; // [sp+18h] [bp-18h]@1 + //signed int v20; // [sp+18h] [bp-18h]@1 RenderVertexSoft *v21; // [sp+1Ch] [bp-14h]@4 char *v22; // [sp+20h] [bp-10h]@4 char *v23; // [sp+24h] [bp-Ch]@4 char *v24; // [sp+28h] [bp-8h]@4 char *v25; // [sp+2Ch] [bp-4h]@4 + + if (!num_vertices) + return 0; - v1 = uVertexID; - memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID])); + //v1 = uVertexID; + memcpy(&array_50AC10[num_vertices], array_50AC10, sizeof(array_50AC10[0])); v2 = 0; - v20 = 0; + //v20 = 0; if ( array_50AC10[0].vWorldViewPosition.x >= 8.0 ) v2 = 1; - if ( (signed int)(uVertexID + 1) <= 1 ) - return 0; v3 = (char *)&array_507D30[0].vWorldViewPosition.z; v4 = (char *)&array_507D30[0].vWorldViewPosition.y; - v5 = v1; + //v5 = v1; v23 = (char *)&array_507D30[0]._rhw; v21 = array_507D30; v18 = (char *)&array_507D30[0].vWorldViewPosition.z; @@ -546,8 +455,10 @@ v24 = (char *)&array_507D30[0].v; v25 = (char *)&array_507D30[0].u; v6 = (char *)&array_50AC10[0].v; - v16 = v5; - do + //v16 = v1; + + int out_num_vertices = 0; + for (int i = 0; i < num_vertices; ++i) { v17 = *((float *)v6 + 5) >= 8.0; if ( v2 != v17 ) @@ -599,7 +510,7 @@ v25 += 48; v4 += 48; v3 += 48; - ++v20; + ++out_num_vertices; v23 += 48; v19 = v4; v18 = v3; @@ -612,7 +523,7 @@ v19 += 48; v18 += 48; v14 = 1.0 / (*((float *)v6 + 5) + 0.0000001); - ++v20; + ++out_num_vertices; v25 += 48; v24 += 48; v22 += 48; @@ -625,11 +536,7 @@ } v2 = v17; v6 += 48; - --v16; } - while ( v16 ); - result = v20; - if ( v20 < 3 ) - return 0; - return result; + + return out_num_vertices >= 3 ? out_num_vertices : 0; }
--- a/mm7_2.cpp Fri Aug 02 23:58:57 2013 +0600 +++ b/mm7_2.cpp Fri Aug 02 23:59:25 2013 +0600 @@ -69,225 +69,153 @@ #include "Lights.h" //----- (004BB756) -------------------------------------------------------- -signed int __fastcall sub_4BB756(signed int a1) +int UseNPCSkill(NPCProf profession) { - unsigned int v1; // esi@8 - unsigned int v3; // ecx@10 - Player *v4; // esi@15 - int v5; // ebx@16 - int v6; // ST38_4@16 - Player *v7; // esi@18 - int v8; // ebx@19 - int v9; // ST30_4@19 - int v10; // ST44_4@19 - int v11; // ST48_4@19 - int v12; // ST4C_4@19 - int v13; // ST50_4@19 - int v14; // ST3C_4@19 - int v15; // ST40_4@19 - int v16; // ST34_4@19 - int v17; // ST38_4@19 - Player *v18; // esi@21 - int v19; // eax@26 - int v20; // eax@39 - SoundID v21; // [sp-20h] [bp-54h]@25 - signed int v22; // [sp-1Ch] [bp-50h]@25 - unsigned int v23; // [sp-18h] [bp-4Ch]@25 - signed int v24; // [sp-14h] [bp-48h]@25 - signed int v25; // [sp-10h] [bp-44h]@25 - int v26; // [sp-10h] [bp-44h]@32 - int v27; // [sp-Ch] [bp-40h]@25 - unsigned int v28; // [sp-Ch] [bp-40h]@32 - unsigned int v29; // [sp-8h] [bp-3Ch]@25 - __int16 v30; // [sp-8h] [bp-3Ch]@32 - int v31; // [sp-4h] [bp-38h]@25 - int v32; // [sp-4h] [bp-38h]@32 - - if ( a1 > 39 ) - { - if ( a1 != 40 ) + switch (profession) + { + case Healer: + { + for (int i = 0; i < 4; ++i) + pParty->pPlayers[i].sHealth = pParty->pPlayers[i].GetMaxHealth(); + } + break; + + case ExpertHealer: + { + for (int i = 0; i < 4; ++i) + { + auto player = &pParty->pPlayers[i]; + player->sHealth = player->GetMaxHealth(); + + for (int j = 0; j < 14; ++j) + player->pConditions[i] = 0; + player->pConditions[18] = 0; + } + } + break; + + case MasterHealer: { - if ( a1 == 41 ) + for (int i = 0; i < 4; ++i) { - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - dword_50C9DC = 195; - ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID); - return 0; + auto player = &pParty->pPlayers[i]; + player->sHealth = player->GetMaxHealth(); + + auto v5 = LODWORD(player->pConditions[19]);//*((int *)v4 - 32); + auto v6 = HIDWORD(player->pConditions[19]);//*((int *)v4 - 31); + memset(player->pConditions, 0, 0xA0u); + + __debugbreak(); + *(int *)&player->pActiveSkills[8] = v5; + *(int *)&player->pActiveSkills[10] = v6; } - if ( a1 == 42 ) + } + break; + + case Cook: + { + if (pParty->uNumFoodRations >= 13) + return 1; + + Party::GiveFood(1); + } + break; + + case Chef: + { + if (pParty->uNumFoodRations >= 13) + return 1; + + if (pParty->uNumFoodRations == 13) + Party::GiveFood(1); + else + Party::GiveFood(2); + } + break; + + case WindMaster: + { + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) { - v32 = 0; - v30 = 0; - v28 = 133; - v26 = 46; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); + pAudioPlayer->PlaySound(SOUND_203, 0, 0, -1, 0, 0, 0, 0); } else { - if ( a1 == 43 ) - { - v32 = 0; - v30 = 0; - v28 = 133; - v26 = 51; - } - else - { - if ( a1 != 52 ) - return 0; - v32 = 0; - v30 = 0; - v28 = 133; - v26 = 86; - } + auto v19 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); + pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + 60 * (256 * 2), 3, 1, v19, 0); + pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags |= 1u; + pAudioPlayer->PlaySound(SOUND_11090, 0, 0, -1, 0, 0, 0, 0); } - _42777D_CastSpell_UseWand_ShootArrow(v26, 0, v28, v30, v32); - return 0; } - v20 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); - pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + 46080, 3u, 0, v20, 0); - pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags |= 1u; - v31 = 0; - v29 = 0; - v27 = 0; - v25 = 0; - v24 = -1; - v23 = 0; - v22 = 0; - v21 = (SoundID)12040; -LABEL_40: - pAudioPlayer->PlaySound(v21, v22, v23, v24, v25, v27, v29, v31); - return 0; - } - if ( a1 == 39 ) - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + break; + + case WaterMaster: { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2u); - v31 = 0; - v29 = 0; - v27 = 0; - v25 = 0; - v24 = -1; - v23 = 0; - v22 = 0; - v21 = (SoundID)203; + auto v20 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + 60 * (256 * (2 + 1)), 3, 0, v20, 0); + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags |= 1u; + pAudioPlayer->PlaySound(SOUND_12040, 0, 0, -1, 0, 0, 0, 0); } - else + break; + + case GateMaster: { - v19 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); - pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + 30720, 3u, 1u, v19, 0); - pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags |= 1u; - v31 = 0; - v29 = 0; - v27 = 0; - v25 = 0; - v24 = -1; - v23 = 0; - v22 = 0; - v21 = (SoundID)11090; - } - pAudioPlayer->PlaySound(v21, v22, v23, v24, v25, v27, v29, v31); - return 0; - } - if ( a1 == 10 ) - { - v18 = pParty->pPlayers; - do - { - v18->sHealth = v18->GetMaxHealth(); - ++v18; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + dword_50C9DC = 195; + ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID); } - while ( (signed int)v18 < (signed int)pParty->pHirelings ); - return 0; - } - if ( a1 == 11 ) - { - v7 = pParty->pPlayers;//(char *)&pParty->pPlayers[0].pConditions[15]; - do - { - /*v8 = *((int *)v7 - 2); - v9 = *((int *)v7 - 1); - v10 = *(int *)v7; - v11 = *((int *)v7 + 1); - v12 = *((int *)v7 + 2); - v13 = *((int *)v7 + 3); - v14 = *((int *)v7 + 8); - v15 = *((int *)v7 + 9); - v16 = *((int *)v7 + 4); - v17 = *((int *)v7 + 5);*/ - v8 = LODWORD(v7->pConditions[14]); - v9 = HIDWORD(v7->pConditions[14]); - v10 = LODWORD(v7->pConditions[15]); - v11 = HIDWORD(v7->pConditions[15]); - v12 = LODWORD(v7->pConditions[16]); - v13 = HIDWORD(v7->pConditions[16]); - v14 = LODWORD(v7->pConditions[19]); - v15 = HIDWORD(v7->pConditions[19]); - v16 = LODWORD(v7->pConditions[17]); - v17 = HIDWORD(v7->pConditions[17]); - memset(v7, 0, 0xA0u); - LODWORD(v7->pConditions[16]) = v12; - HIDWORD(v7->pConditions[16]) = v13; - LODWORD(v7->pConditions[15]) = v10; - HIDWORD(v7->pConditions[15]) = v11; - HIDWORD(v7->pConditions[14]) = v9; - LODWORD(v7->pConditions[19]) = v14; - HIDWORD(v7->pConditions[19]) = v15; - LODWORD(v7->pConditions[17]) = v16; - LODWORD(v7->pConditions[14]) = v8; - HIDWORD(v7->pConditions[17]) = v17; - v7->sHealth = v7->GetMaxHealth(); - ++v7; - } - while ( v7 <= pPlayers[3] ); - return 0; - } - if ( a1 == 12 ) - { - v4 = pParty->pPlayers;//(char *)&pParty->pPlayers[0].pActiveSkills[8]; - do - { - v5 = LODWORD(v4->pConditions[19]);//*((int *)v4 - 32); - v6 = HIDWORD(v4->pConditions[19]);//*((int *)v4 - 31); - memset(v4->pConditions, 0, 0xA0u); - v4->pActiveSkills[8] = v5; - v4->pActiveSkills[10] = v6; - v4->sHealth = v4->GetMaxHealth(); - ++v4; - } - while ( v4 <= pPlayers[3] ); - return 0; - } - if ( a1 == 33 ) - { - v1 = 14; - if ( pParty->uNumFoodRations >= 0xE ) - return 1; - v3 = 1; -LABEL_13: - Party::GiveFood(v3); - if ( pParty->uNumFoodRations > v1 ) - pParty->uNumFoodRations = v1; - return 0; - } - if ( a1 == 34 ) - { - v1 = 14; - if ( pParty->uNumFoodRations >= 0xE ) - return 1; - v3 = 2; - goto LABEL_13; + break; + + case Acolyte: _42777D_CastSpell_UseWand_ShootArrow(46, 0, 133, 0, 0); break; + case Piper: _42777D_CastSpell_UseWand_ShootArrow(51, 0, 133, 0, 0); break; + case FallenWizard: _42777D_CastSpell_UseWand_ShootArrow(86, 0, 133, 0, 0); break; + + case Teacher: + case Instructor: + case Armsmaster: + case Weaponsmaster: + case Apprentice: + case Mystic: + case Spellmaster: + case Trader: + case Merchant: + case Scout: + case Herbalist: + case Apothecary: + case Tinker: + case Locksmith: + case Fool: + case ChimneySweep: + case Porter: + case QuarterMaster: + case Factor: + case Banker: + case Horseman: + case Bard: + case Enchanter: + case Cartographer: + case Explorer: + case Pirate: + case Squire: + case Psychic: + case Gypsy: + case Diplomat: + case Duper: + case Burglar: + case Acolyte2: + case Initiate: + case Prelate: + case Monk: + case Sage: + case Hunter: + break; + + default: + assert(false && "Invalid enum value"); } return 0; } -// 50C9DC: using guessed type int dword_50C9DC; //----- (004BBA85) -------------------------------------------------------- const char *sub_4BBA85_bounties() @@ -457,9 +385,6 @@ pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 1); } } -// F8B1B4: using guessed type int dword_F8B1B4; - -// 4EE088: using guessed type __int16 word_4EE088_sound_ids[]; //----- (004BC109) -------------------------------------------------------- void __cdecl ArenaFight() @@ -1715,11 +1640,11 @@ } //----- (0045063B) -------------------------------------------------------- -int __fastcall sub_45063B(MapInfo *a1, int a2) +int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) { signed int v2; // edi@1 Actor *v3; // esi@2 - signed __int64 v4; // qax@3 + //signed __int64 v4; // qax@3 int result; // eax@8 int v6; // edi@11 int v7; // ebx@11 @@ -1736,33 +1661,49 @@ int v18; // eax@21 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 int v20; // [sp+24h] [bp-20h]@11 - MapInfo *v21; // [sp+28h] [bp-1Ch]@1 + //MapInfo *v21; // [sp+28h] [bp-1Ch]@1 int v22; // [sp+2Ch] [bp-18h]@3 int v23; // [sp+30h] [bp-14h]@11 - int v24; // [sp+34h] [bp-10h]@1 + //int v24; // [sp+34h] [bp-10h]@1 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 int v26; // [sp+3Ch] [bp-8h]@11 int v27; // [sp+40h] [bp-4h]@11 - - v21 = a1; - v24 = a2; + + if (!uNumActors) + return 0; + + //v21 = a1; + //v24 = a2; v2 = 0; - if ( (signed int)uNumActors <= 0 ) - goto LABEL_8; v3 = pActors.data(); while ( 1 ) { - v22 = v3->pMonsterInfo.uID - 1; - v4 = (signed __int64)((double)v22 * 0.3333333333333333); - if ( (int)v4 != 40 ) + if (v3->pMonsterInfo.uID >= 121 && v3->pMonsterInfo.uID <= 123 || // Dwarf FemaleC A-C + v3->pMonsterInfo.uID >= 124 && v3->pMonsterInfo.uID <= 126 || // Dwarf MaleA A-C + v3->pMonsterInfo.uID >= 133 && v3->pMonsterInfo.uID <= 135 || // Peasant Elf FemaleA A-C + !v3->CanAct()) { - if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) - break; + ++v2; + ++v3; + + if (v2 >= uNumActors) + return 0; + + continue; } - ++v2; - ++v3; - if ( v2 >= (signed int)uNumActors ) - goto LABEL_8; + + break; + //v22 = v3->pMonsterInfo.uID - 1; + //v4 = (signed __int64)((double)v22 * 0.3333333333333333); + //if ( (int)v4 != 40 ) + //{ + // if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) + // break; + //} + //++v2; + //++v3; + //if ( v2 >= (signed int)uNumActors ) + // goto LABEL_8; } if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) { @@ -1779,7 +1720,7 @@ v20 = stru_5C6E00->Sin(v7); v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; v8 = 0; - v19.uIndex = v24; + v19.uIndex = a2; v19.vPosition.y = v23 + pParty->vPosition.y; v19.vPosition.z = pParty->vPosition.z; v26 = 0; @@ -1838,7 +1779,7 @@ v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16; v19.vPosition.y = v23 + pParty->vPosition.y; v19.vPosition.z = pParty->vPosition.z; - v19.uIndex = v24; + v19.uIndex = a2; v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z); if ( v17 == v22 ) { @@ -1861,8 +1802,8 @@ } else { - SpawnEncounter(v21, &v19, 0, 0, 1); - result = v24; + SpawnEncounter(a1, &v19, 0, 0, 1); + result = a2; } return result; } @@ -1884,108 +1825,90 @@ int v12; // eax@21 int v13; // eax@22 - v1 = this; - rand(); - v2 = v1->uDecorationDescID; - if ( v2 > 208 ) - { - switch ( v2 ) - { - case 209: - result = rand() % 7 + 183; - break; - case 210: - result = 150; - break; - case 211: - result = 151; - break; - case 212: - result = 152; - break; - case 213: - result = 153; - break; - case 214: - result = 154; - break; - case 215: - result = 155; - break; - case 216: - result = 156; - break; - case 217: - result = 157; - break; - case 218: - result = 158; - break; - case 219: - result = 159; - break; - case 220: - result = 160; - break; - case 221: - result = 161; - break; - default: - goto LABEL_45; - } - } - else - { - if ( v2 == 208 ) - { - result = rand() % 7 + 176; - } - else - { - if ( v2 > 24 ) - { - v9 = v2 - 34; - if ( !v9 ) - return rand() % 6 + 4; - v10 = v9 - 150; - if ( !v10 ) - return 33; - v11 = v10 - 3; - if ( !v11 || (v12 = v11 - 3) == 0 ) - return 37; - v13 = v12 - 16; - if ( !v13 ) - return rand() % 7 + 162; - if ( v13 == 1 ) - return rand() % 7 + 169; - } - else - { - if ( v2 == 24 ) - return 36; - v3 = v2 - 4; - if ( !v3 ) - return 16; - v4 = v3 - 1; - if ( !v4 ) - return 32; - v5 = v4 - 1; - if ( !v5 ) - return rand() % 4 + 12; - v6 = v5 - 5; - if ( !v6 ) - return 34; - v7 = v6 - 2; - if ( !v7 ) - return 17; - if ( v7 == 1 ) - return 18; - } -LABEL_45: - result = 0; - } - } - return result; + switch (uDecorationDescID) + { + case 0: case 1: + case 2: case 3: + return 0; + + case 4: return 16; // dec01 "Trash Pile" + case 5: return 32; // dec02 "Campfire" + case 6: return 12 + rand() % 4; // dec03 "Cauldron" + case 7: case 8: + case 9: case 10: + return 0; + + case 11: return 34; // dec08 "Fruit plate" + case 12: + return 0; + + case 13: return 17; // dec10 "Trash Pile" + case 14: return 18; // dec11 "Filth" + case 15: case 16: case 17: + case 18: case 19: case 20: + case 21: case 22: case 23: + return 0; + + case 24: return 36; // dec21 "Keg" + case 25: case 26: case 27: case 28: case 29: + case 30: case 31: case 32: case 33: + return 0; + + case 34: return 4 + rand() % 6; // dec32 "Barrel" + case 35: case 36: case 37: case 38: case 39: + case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: + case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: + case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: + case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: + case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: + case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: + case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: + case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: + case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129: + case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139: + case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149: + case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159: + case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169: + case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: + case 180: case 181: case 182: case 183: + + case 184: return 33; // dec24 "Campfire" + case 185: case 186: + return 0; + + case 187: // dec88 "Mushroom" + case 190: // dec91 "Mushroom" + return 37; + + case 188: case 189: + case 191: case 192: case 193: case 194: case 195: case 196: + case 197: case 198: case 199: case 200: case 201: case 202: + case 203: case 204: case 205: + return 0; + + case 206: return 162 + rand() % 7; // dec60 + case 207: return 169 + rand() % 7; // dec61 + case 208: return 176 + rand() % 7; // dec62 + case 209: return 183 + rand() % 7; // dec63 + case 210: return 150; // dec64 "Magic Pedistal" + case 211: return 151; // dec65 "Magic Pedistal" + case 212: return 152; // dec66 "Magic Pedistal" + case 213: return 153; // dec67 "Magic Pedistal" + case 214: return 154; // dec68 "Magic Pedistal" + case 215: return 155; // dec69 "Magic Pedistal" + case 216: return 156; // dec70 "Magic Pedistal" + case 217: return 157; // dec71 "Magic Pedistal" + case 218: return 158; // dec72 "Magic Pedistal" + case 219: return 159; // dec73 "Magic Pedistal" + case 220: return 160; // dec74 "Magic Pedistal" + case 221: return 161; // dec75 "Magic Pedistal" + + case 222: case 223: case 224: + case 225: case 226: case 227: + return 0; + + default: assert(false && "Invalid Decoration"); + } } //----- (00450AAA) --------------------------------------------------------
--- a/mm7_3.cpp Fri Aug 02 23:58:57 2013 +0600 +++ b/mm7_3.cpp Fri Aug 02 23:59:25 2013 +0600 @@ -2207,8 +2207,8 @@ int bFeatherFall; // [sp+28h] [bp-6Ch]@4 int v105; // [sp+2Ch] [bp-68h]@24 int bWaterWalk; // [sp+30h] [bp-64h]@1 - bool v107; // [sp+34h] [bp-60h]@30 - int v108; // [sp+38h] [bp-5Ch]@1 + //bool v107; // [sp+34h] [bp-60h]@30 + //int v108; // [sp+38h] [bp-5Ch]@1 int v109; // [sp+3Ch] [bp-58h]@28 int v110; // [sp+40h] [bp-54h]@180 int v111; // [sp+44h] [bp-50h]@14 @@ -2230,7 +2230,7 @@ BSPModel *v127; // [sp+84h] [bp-10h]@1 int v128; // [sp+88h] [bp-Ch]@1 int v129; // [sp+8Ch] [bp-8h]@92 - int v130; // [sp+90h] [bp-4h]@14 + //int v130; // [sp+90h] [bp-4h]@14 v121 = pParty->uFallSpeed; pZ = pParty->vPosition.z; @@ -2247,22 +2247,12 @@ auto partyAtHighSlope = IsTerrainSlopeTooHigh(pParty->vPosition.x, pParty->vPosition.y); v114 = 0; v124 = 0; - v108 = 0; v102 = 0; v127 = 0; bWaterWalk = 0; if (!pParty->FeatherFallActive()) - //SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0 - //|| SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 && LODWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 ) { bFeatherFall = 0; - /*v119 = &pPlayers[1]; - while ( !(*v119)->WearsItem(536, 16) ) - { - ++v119; - if ( (signed int)v119 > (signed int)&pPlayers[4] ) - goto LABEL_9; - }*/ for (int i = 0; i < 4; ++i) if (pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY)) // seems like flying boots { @@ -2285,7 +2275,11 @@ pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].sMana <= 0 ) bWaterWalk = 0; } - v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &v130, &v108, bWaterWalk); + int bmodel_standing_on_pid; + int is_on_water = false; + v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk); + int is_not_on_bmodel = bmodel_standing_on_pid == 0; + v111 = v3; if ( bFeatherFall ) pParty->uFallStartY = v3; @@ -2316,7 +2310,7 @@ v109 = -1; if ( pParty->bFlying ) v109 = sub_46D8E3(pX, pY, pZ + pParty->uPartyHeight, (int)&v102); - v107 = v108 == 0; + //v107 = bmodel_standing_on_pid == 0; v105 = v111 + 1; if ( pZ <= v111 + 1 ) { @@ -2334,20 +2328,18 @@ pParty->walk_sound_timer -= pEventTimer->uTimeElapsed; else pParty->walk_sound_timer = 0; } - if (!bUnderwater - && SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0 - && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) < 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0) ) + if (!bUnderwater && pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime <= 0) pParty->bFlying = false; if (!bJumping) { - if ( pParty->floor_face_pid != PID(OBJECT_BModel, v108) ) + if ( pParty->floor_face_pid != PID(OBJECT_BModel, bmodel_standing_on_pid) ) { - if (v108) + if (bmodel_standing_on_pid) { - if ( v108 >> 6 < pOutdoor->uNumBModels ) + if ( (bmodel_standing_on_pid >> 6) < pOutdoor->uNumBModels ) { - v7 = pOutdoor->pBModels[v108 >> 6].pFaces; - v6 = v108 & 0x3F; + v7 = pOutdoor->pBModels[bmodel_standing_on_pid >> 6].pFaces; + v6 = bmodel_standing_on_pid & 0x3F; /*if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 ) { pParty->field_6F4_packedid = PID(OBJECT_BModel,v108); @@ -2355,13 +2347,13 @@ }*/ if ( BYTE3(v7[v6].uAttributes) & 4 ) { - pParty->floor_face_pid = PID(OBJECT_BModel, v108); + pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); v103 = v7[v6].sCogTriggeredID; } } } } - pParty->floor_face_pid = PID(OBJECT_BModel, v108); + pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); } _walk_speed = pParty->uWalkSpeed; _angle_y = pParty->sRotationY; @@ -2547,7 +2539,7 @@ v128 = v1; } - else if (partyAtHighSlope && !v108) + else if (partyAtHighSlope && !bmodel_standing_on_pid) { v2 += dx; v1 += dy; @@ -2633,7 +2625,7 @@ break; case PARTY_Jump: - if ( (!partyAtHighSlope || v108) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) + if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) { v126 = pParty->field_24 << 6; bJumping = 1; @@ -2677,7 +2669,7 @@ } else { - if ( v130 && v121 ) + if ( is_on_water && v121 ) sub_42F960_create_object(pX, pY, v111); v121 = 0; pZ = v111; @@ -2707,7 +2699,7 @@ } else if (!bJumping) { - if ( !v108 ) + if ( !bmodel_standing_on_pid ) { // rolling down the hill // how it's done: you get a little bit pushed in the air along terrain normal, getting in the air @@ -2801,18 +2793,18 @@ v40 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + pZ; } v122 = v40; - ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0); - v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &v130, &v97, 0); - auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &v130, &v110, 0); + ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); + v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &is_on_water, &v97, 0); + auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &v110, 0); v127 = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY); v42 = IsTerrainSlopeTooHigh(pX, _angle_y); - v107 = 0; + is_not_on_bmodel = false; v118 = v42; - if ( !v97 && !v110 && !v108 ) - v107 = 1; + if ( !v97 && !v110 && !bmodel_standing_on_pid ) + is_not_on_bmodel = true; v43 = 1; v44 = 1; - if ( bUnderwater || !v107 ) + if ( bUnderwater || !is_not_on_bmodel ) { pX = _angle_x; if ( v43 ) @@ -2834,7 +2826,7 @@ pY = _angle_y; else { - v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0); + v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= pZ ) { v43 = 1; @@ -2846,7 +2838,7 @@ } if ( stru_721530.field_7C >= stru_721530.field_6C ) { - if ( !v107 ) + if ( !is_not_on_bmodel ) { pX = stru_721530.normal2.x; pY = stru_721530.normal2.y; @@ -2877,9 +2869,8 @@ { v56 = integer_sqrt(v2 * v2 + v128 * v128); v118 = v56; - v57 = stru_5C6E00->Atan2( - _angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, - _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y); + v57 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, + _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y); v129 = v57; v58 = (BSPModel *)stru_5C6E00->Cos(v57); v127 = v58; @@ -2920,7 +2911,7 @@ v2 = 0; *(float *)&v128 = 0.0; } - if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 ) + if ( pParty->floor_face_pid != v45 && (v47->uAttributes & FACE_PRESSURE_PLATE)) { pParty->floor_face_pid = v45; v103 = v47->sCogTriggeredID; @@ -3035,7 +3026,7 @@ { if ( v114 && (!bJumping || v101) ) { - if ( !v107 + if ( !is_not_on_bmodel && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) ) { pAudioPlayer->PlaySound((SoundID)64, 804, 1, -1, 0, 0, 0, 0); @@ -3052,7 +3043,7 @@ { if ( v124 && (!bJumping || v101) ) { - if ( v107 + if ( is_not_on_bmodel || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 ) { v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; @@ -3079,14 +3070,14 @@ v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; v114 = WorldPosToGridCellX(pX); v66 = WorldPosToGridCellZ(pY) - 1; - v127 = (BSPModel *)(((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1); - v122 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1; + v127 = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1); + v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1; v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66); v68 = 0; - v69 = ((unsigned int)~v67 >> 1) & 1; + v69 = (~(unsigned int)v67 >> 1) & 1; if ( v114 == v126 && v66 == v65 && v122 && v69 ) v68 = 1; - if ( !v107 ) + if ( !is_not_on_bmodel ) v68 = 1; if ( v68 ) { @@ -5975,16 +5966,17 @@ // 6BE3C4: using guessed type char bUnderwater; //----- (0047F44B) -------------------------------------------------------- -unsigned int __stdcall WorldPosToGridCellX(signed int sWorldPosX) +unsigned int WorldPosToGridCellX(int sWorldPosX) { - return (sWorldPosX / 512) + 64; + return (sWorldPosX >> 9) + 64; // sar is in original exe, resulting -880 / 512 = -1 + // and -880 sar 9 = -2 } -// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); //----- (0047F458) -------------------------------------------------------- -unsigned int __stdcall WorldPosToGridCellZ(signed int sWorldPosZ) +unsigned int WorldPosToGridCellZ(int sWorldPosZ) { - return 64 - (sWorldPosZ / 512); + return 64 - (sWorldPosZ >> 9); // sar is in original exe, resulting -880 / 512 = -1 + // and -880 sar 9 = -2 } //----- (0047F469) --------------------------------------------------------
--- a/mm7_4.cpp Fri Aug 02 23:58:57 2013 +0600 +++ b/mm7_4.cpp Fri Aug 02 23:59:25 2013 +0600 @@ -530,15 +530,8 @@ //----- (00487DA9) -------------------------------------------------------- void __cdecl sub_487DA9() { - char *v0; // eax@1 - - v0 = &array_77EC08[0].field_108; - do - { - *v0 = 0; - v0 += 268; - } - while ( (signed int)v0 < (signed int)&pVerticesSR_801A10[4] ); + for (int i = 0; i < 20000; ++i) + array_77EC08[i].field_108 = 0; } //----- (00487DBE) -------------------------------------------------------- @@ -585,9 +578,9 @@ 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); + return (((uint)round(r * 255.0f) & 0xFF) << 16) | + (((uint)round(g * 255.0f) & 0xFF) << 8) | + (((uint)round(b * 255.0f) & 0xFF)); } //----- (0048B561) -------------------------------------------------------- @@ -3735,19 +3728,17 @@ ArenaFight(); return; } - else if(newDialogueType == DIALOGUE_9) + else if(newDialogueType == DIALOGUE_USE_NPC_ABILITY) { - if ( !sub_4BB756(speakingNPC->uProfession) ) + if (UseNPCSkill((NPCProf)speakingNPC->uProfession) == 0) { - if ( speakingNPC->uProfession != 41 ) + if ( speakingNPC->uProfession != GateMaster ) speakingNPC->bHasUsedTheAbility = 1; pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); } else - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u); //"Your packs are already full!" - } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2); //"Your packs are already full!" } else if(newDialogueType == DIALOGUE_13) {
--- a/mm7_5.cpp Fri Aug 02 23:58:57 2013 +0600 +++ b/mm7_5.cpp Fri Aug 02 23:59:25 2013 +0600 @@ -2265,7 +2265,7 @@ GameUI_SetFooterString(pTmpBuf.data()); continue; case UIMSG_ShowFinalWindow: - sprintf(pFinalMessage.data(), "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer." + sprintfex(pFinalMessage.data(), "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer." pGlobalTXT_LocalizationStrings[118],// "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment." pGlobalTXT_LocalizationStrings[167]);// "- The Might and Magic VII Development Team." ModalWindow(pFinalMessage.data(), 196); @@ -2569,7 +2569,7 @@ pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->EncM2percent) + 2); else pNPCData4 = (NPCData *)1; - if ( !sub_45063B(pMapInfo, (int)pNPCData4) ) + if ( !_45063B_spawn_some_monster(pMapInfo, (int)pNPCData4) ) pNPCData4 = 0; if ( pNPCData4 ) { @@ -3435,7 +3435,7 @@ case UIMSG_ChangeGameState: uGameState = GAME_FINISHED; break; - case UIMSG_11: + case UIMSG_ChangeCursor: pMouse->SetCursorBitmap("MICON2"); break; case UIMSG_3A: @@ -3583,6 +3583,7 @@ break; case UIMSG_PlayerCreationRemoveDownSkill: uPlayerCreationUI_SelectedCharacter = pParam; + __debugbreak(); pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(3) @@ -3599,13 +3600,10 @@ //----- (00436427) -------------------------------------------------------- double __cdecl get_shading_dist_mist() { - double result; // st7@2 - - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - result = (double)pOutdoorCamera->shading_dist_mist; + if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + return (double)pOutdoorCamera->shading_dist_mist; else - result = 16192.0; - return result; + return 16192.0; } //----- (0043648F) --------------------------------------------------------
--- a/mm7_data.h Fri Aug 02 23:58:57 2013 +0600 +++ b/mm7_data.h Fri Aug 02 23:59:25 2013 +0600 @@ -1130,7 +1130,7 @@ void __cdecl nullsub_3(); // idb void __cdecl LoadActualSkyFrame(); void __cdecl Sleep6Hours(); -void __cdecl sub_42038D(); +void __cdecl ChestUI_WritePointedObjectStatusString(); void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal); // idb void OnChestLeftClick(); @@ -1146,7 +1146,7 @@ int __fastcall GetPortalScreenCoord(unsigned int uFaceID); signed int __fastcall sr_424579(int uFaceID, struct stru320 *a2); bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID); -signed int __fastcall sr_424CD7(unsigned int uVertexID); // idb +int sr_424CD7(unsigned int uVertexID); // idb signed int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID); // idb signed int __fastcall sr_4250FE(unsigned int uVertexID); // idb bool sr_42620A(struct RenderVertexSoft *p); @@ -1256,7 +1256,7 @@ int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6); -int __fastcall sub_45063B(struct MapInfo *a1, int a2); +int __fastcall _45063B_spawn_some_monster(struct MapInfo *a1, int a2); void RespawnGlobalDecorations(); bool __fastcall SpawnActor(unsigned int uMonsterID); int __cdecl GetAlertStatus(); @@ -1343,7 +1343,7 @@ bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2); void __cdecl check_event_triggers(); int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID); -int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int, int *pOnWater, int *a6, int bWaterWalk); +int ODM_GetFloorLevel(int X, signed int Y, int Z, int, int *pOnWater, int *bmodel_pid, int bWaterWalk); int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4); void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out); unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID); @@ -1379,8 +1379,8 @@ unsigned int GetLevelFogColor(); int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3); signed int __fastcall GetActorTintColor(int max_dim, int min_dim, float distance, int a4, struct RenderBillboard *a5); -unsigned int __stdcall WorldPosToGridCellX(int); // weak -unsigned int __stdcall WorldPosToGridCellZ(int); // weak +unsigned int WorldPosToGridCellX(int); // weak +unsigned int WorldPosToGridCellZ(int); // weak int __stdcall GridCellToWorldPosX(int); // weak int __stdcall GridCellToWorldPosZ(int); // weak void __cdecl loc_48118F(); // idb @@ -1452,7 +1452,6 @@ void __fastcall DrawTextAtStatusBar(const char *Str, int a5); int __fastcall sub_4B46F8(int a1); -signed int __fastcall sub_4BB756(signed int a1); const char *sub_4BBA85_bounties(); void __cdecl sub_4BBCDD(); void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z); // idb