Mercurial > might-and-magic-trilogy
changeset 95:b5e26a133fae
Merge
author | Nomad |
---|---|
date | Fri, 02 Nov 2012 14:45:06 +0200 |
parents | 6c42178c226e (diff) 2d3f4e0379ce (current diff) |
children | d7e68aebe0b3 f76e4ea4a224 |
files | Indoor.cpp Outdoor.cpp Outdoor.h mm7_2.cpp mm7_data.h |
diffstat | 11 files changed, 152 insertions(+), 137 deletions(-) [+] |
line wrap: on
line diff
--- a/GameUIs.cpp Fri Nov 02 00:44:18 2012 +0600 +++ b/GameUIs.cpp Fri Nov 02 14:45:06 2012 +0200 @@ -1,5 +1,6 @@ #include <direct.h> #include <io.h> +#include <assert.h> #include "GUIWindow.h" #include "GUIFont.h" @@ -15,18 +16,18 @@ { unsigned int v1; // ebp@5 unsigned int v2; // eax@5 - signed int v3; // ebp@11 + //signed int v3; // ebp@11 FILE *v4; // eax@14 FILE *v5; // eax@18 unsigned int v6; // eax@25 GUIButton *v7; // eax@27 const char *v8; // [sp-8h] [bp-26Ch]@25 - char *v9; // [sp-4h] [bp-268h]@19 + //char *v9; // [sp-4h] [bp-268h]@19 enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25 unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1 - RGBTexture *pTex; // [sp+10h] [bp-254h]@12 - SavegameHeader *Dest; // [sp+14h] [bp-250h]@12 - const char *Str1; // [sp+18h] [bp-24Ch]@12 + //RGBTexture *pTex; // [sp+10h] [bp-254h]@12 + //SavegameHeader *Dest; // [sp+14h] [bp-250h]@12 + //const char *Str1; // [sp+18h] [bp-24Ch]@12 LODWriteableFile v15; // [sp+1Ch] [bp-248h]@1 int v16; // [sp+260h] [bp-4h]@1 @@ -51,7 +52,7 @@ pRenderer->DrawTextureIndexed( 8u, 8u, - (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); + (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); if ( pCurrentScreen == 11 ) { v1 = uTextureID_save_up; @@ -67,7 +68,7 @@ pRenderer->DrawTextureIndexed( 351u, 302u, - (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0)); + (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0)); } else { @@ -90,46 +91,55 @@ uLoadGameUI_SelectedSlot = 0; } v15.AllocSubIndicesAndIO(0x12Cu, 0); - v3 = 0; - if ( (signed int)uNumSavegameFiles > 0 ) + + assert(sizeof(SavegameHeader) == 0x64); + + //v3 = 0; + for (uint i = 0; i < uNumSavegameFiles; ++i) { - Dest = pSavegameHeader; - pTex = pSavegameThumbnails; - Str1 = (const char *)pSavegameList->pSavesNames; - while ( 1 ) + //Dest = pSavegameHeader; + //pTex = pSavegameThumbnails; + //Str1 = (const char *)pSavegameList->pSavesNames; + //while ( 1 ) + //{ + sprintf(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[i]); + if (_access(pTmpBuf, 6)) { - sprintf(pTmpBuf, "saves\\%s", Str1); - if ( _access(pTmpBuf, 6) ) - break; - v15.LoadFile(pTmpBuf, 1); - v4 = v15.FindContainer("header.bin", true); - if ( v4 ) - fread(Dest, 0x64u, 1u, v4); - if ( !_strcmpi(Str1, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" - strcpy(Dest->pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave" - v5 = v15.FindContainer("image.pcx", true); - if ( !v5 ) - { - v9 = ""; -LABEL_22: - pSavegameUsedSlots[v3] = 0; - strcpy(Dest->pName, v9); - goto LABEL_23; - } - pTex->LoadFromFILE(v5, 0, true); + pSavegameUsedSlots[i] = 0; + strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty" + continue; + } + + v15.LoadFile(pTmpBuf, 1); + v4 = v15.FindContainer("header.bin", true); + if ( v4 ) + fread(&pSavegameHeader[i], 0x64u, 1u, v4); + if ( !_strcmpi(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" + strcpy(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[16]);// "Autosave" + + v5 = v15.FindContainer("image.pcx", true); + if ( !v5 ) + { + pSavegameUsedSlots[i] = 0; + strcpy(pSavegameList->pSavesNames[i], ""); + } + else + { + pSavegameThumbnails[i].LoadFromFILE(v5, 0, true); v15.CloseWriteFile(); - pSavegameUsedSlots[v3] = 1; -LABEL_23: - Str1 += 280; - ++pTex; - ++Dest; - ++v3; - if ( v3 >= (signed int)uNumSavegameFiles ) - goto LABEL_24; + pSavegameUsedSlots[i] = 1; } - v9 = pGlobalTXT_LocalizationStrings[72]; // "Empty" - goto LABEL_22; +//LABEL_23: + //Str1 += 280; + //++pTex; + //++Dest; + //++v3; + //if ( v3 >= (signed int)uNumSavegameFiles ) + // goto LABEL_24; + //} + //goto LABEL_22; } + LABEL_24: v15.FreeSubIndexAndIO(); if ( pCurrentScreen == 11 )
--- a/Indoor.cpp Fri Nov 02 00:44:18 2012 +0600 +++ b/Indoor.cpp Fri Nov 02 14:45:06 2012 +0200 @@ -453,8 +453,8 @@ //char v21; // dl@27 //unsigned int v22; // eax@44 unsigned int v23; // eax@35 - DWORD v24; // eax@37 - int v25; // eax@38 + //DWORD v24; // eax@37 + //int v25; // eax@38 //char *v26; // edi@38 IDirect3DTexture2 *v27; // eax@42 Texture *v28; // [sp+Ch] [bp-1Ch]@15 @@ -503,7 +503,7 @@ static_vertices_F7C228[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y; static_vertices_F7C228[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z; static_vertices_F7C228[i].u = (signed short)pFace->pVertexUIDs[i]; - static_vertices_F7C228[i].v = (signed short)pFace->pVertexUIDs[i]; + static_vertices_F7C228[i].v = (signed short)pFace->pVertexVIDs[i]; } if (!pVertices || @@ -568,19 +568,21 @@ if (pFace->Animated()) { - v24 = GetTickCount() / 4; - v25 = v24 - stru_5C6E00->uIntegerHalfPi; - + //auto v24 = GetTickCount() / 4; + //auto v25 = v24 - stru_5C6E00->uIntegerHalfPi; + uint eightSeconds = GetTickCount() % 8000; + float angle = (eightSeconds / 8000.0f) * 2 * 3.1415f; + + //animte lava back and forth 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)); + //array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8)); + array_507D30[i].v += pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 * cosf(angle); v23 = pFace->uBitmapID; goto LABEL_42; } - else + else if (pFace->uAttributes & 0x4000) { - if (pFace->uAttributes & 0x4000) - { v23 = pTextureFrameTable->GetFrameTexture( pFace->uBitmapID, pBLVRenderParams->field_0_timer_); @@ -591,7 +593,6 @@ else pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | 6, v17, 0); return; - } } } }
--- a/LightmapBuilder.cpp Fri Nov 02 00:44:18 2012 +0600 +++ b/LightmapBuilder.cpp Fri Nov 02 14:45:06 2012 +0200 @@ -264,6 +264,7 @@ } } + __debugbreak(); // foil if (!pGame->pStru9Instance->_4980B9(a9, uNumVertices, a7->field_4.x, a7->field_4.y, a7->field_4.z, v11->pVertices, &v11->uNumVertices))
--- a/Outdoor.cpp Fri Nov 02 00:44:18 2012 +0600 +++ b/Outdoor.cpp Fri Nov 02 14:45:06 2012 +0200 @@ -703,28 +703,27 @@ //----- (0047C7C2) -------------------------------------------------------- void OutdoorLocationTerrain::Release() { - OutdoorLocationTerrain *v1; // esi@1 - void *v2; // ST00_4@1 - void *v3; // ST00_4@1 - void *v4; // ST00_4@1 + if (pHeightmap) + { + pAllocator->FreeChunk(this->pHeightmap); + pHeightmap = nullptr; + } + if (pTilemap) + { + pAllocator->FreeChunk(pTilemap); + pTilemap = nullptr; + } + if (pAttributemap) + { + pAllocator->FreeChunk(pAttributemap); + pAttributemap = nullptr; + } + if (ptr_C) + { + pAllocator->FreeChunk(ptr_C); + ptr_C = nullptr; + } - v1 = this; - pAllocator->FreeChunk(this->pHeightmap); - v2 = v1->pTilemap; - v1->pHeightmap = 0; - pAllocator->FreeChunk(v2); - v3 = v1->pAttributemap; - v1->pTilemap = 0; - if (v3) - { - pAllocator->FreeChunk(v3); - v3 = nullptr; - } - //pAllocator->FreeChunk(v3); - v4 = v1->ptr_C; - v1->pAttributemap = 0; - pAllocator->FreeChunk(v4); - v1->ptr_C = 0; _47C7A9(); } @@ -1116,49 +1115,59 @@ //----- (0047CF9C) -------------------------------------------------------- void OutdoorLocation::Release() { - OutdoorLocation *v1; // esi@1 - signed int v2; // edi@1 - int v3; // ebx@2 - void *v4; // ST24_4@4 - char *v5; // ebx@4 - void **v6; // esi@4 + //OutdoorLocation *v1; // esi@1 + //signed int v2; // edi@1 + //int v3; // ebx@2 + //void *v4; // ST24_4@4 + //char *v5; // ebx@4 + //void **v6; // esi@4 - v1 = this; - strcpy(this->pLevelFilename, "blank"); - strcpy(v1->pLocationFileName, "default.odm"); - strcpy(v1->pLocationFileDescription, "MM6 Outdoor v1.00"); - strcpy(v1->pSkyTextureName, "sky043"); - strcpy(v1->pGroundTileset, "hm005"); - v2 = 0; - if ( (signed int)v1->uNumBModels > 0 ) + //v1 = this; + strcpy(pLevelFilename, "blank"); + strcpy(pLocationFileName, "default.odm"); + strcpy(pLocationFileDescription, "MM6 Outdoor v1.00"); + strcpy(pSkyTextureName, "sky043"); + strcpy(pGroundTileset, "hm005"); + + if (pBModels) + { + for (uint i = 0; i < uNumBModels; ++i) + pBModels[i].Release(); + + pAllocator->FreeChunk(pBModels); + pBModels = nullptr; + uNumBModels = 0; + } + + if (pSpawnPoints) { - v3 = 0; - do - { - ((BSPModel *)((char *)&v1->pBModels[v3] + 68))->Release(); - ++v2; - ++v3; - } - while ( v2 < (signed int)v1->uNumBModels ); + pAllocator->FreeChunk(pSpawnPoints); + pSpawnPoints = nullptr; + } + uNumSpawnPoints = 0; + + pTerrain.Release(); + + if (ptr_D4) + { + pAllocator->FreeChunk(ptr_D4); + ptr_D4 = nullptr; } - v1->uNumBModels = 0; - v4 = v1->pBModels; - v1->uNumSpawnPoints = 0; - pAllocator->FreeChunk(v4); - pAllocator->FreeChunk(v1->pSpawnPoints); - v1->pBModels = 0; - v1->pSpawnPoints = 0; - v1->pTerrain.Release(); - pAllocator->FreeChunk(v1->ptr_D4); - v1->ptr_D4 = 0; - v5 = (char *)&v1->pOMAP; - pAllocator->FreeChunk(v1->pOMAP); - v6 = (void **)&v1->pFaceIDLIST; - *(int *)v5 = 0; - pAllocator->FreeChunk(*v6); - *v6 = 0; - pAllocator->FreeChunk(pTerrainNormals); - pTerrainNormals = 0; + if (pOMAP) + { + pAllocator->FreeChunk(pOMAP); + pOMAP = nullptr; + } + if (pFaceIDLIST) + { + pAllocator->FreeChunk(pFaceIDLIST); + pFaceIDLIST = nullptr; + } + if (pTerrainNormals) + { + pAllocator->FreeChunk(pTerrainNormals); + pTerrainNormals = nullptr; + } } //----- (0047D0A6) --------------------------------------------------------
--- a/Outdoor.h Fri Nov 02 00:44:18 2012 +0600 +++ b/Outdoor.h Fri Nov 02 14:45:06 2012 +0200 @@ -42,7 +42,8 @@ this->ptr_C = 0; this->field_10 = 0; this->field_12 = 0; - this->pAttributemap = nullptr; + + pAttributemap = nullptr; } void _47C7A9();
--- a/SaveLoad.cpp Fri Nov 02 00:44:18 2012 +0600 +++ b/SaveLoad.cpp Fri Nov 02 14:45:06 2012 +0200 @@ -27,8 +27,8 @@ struct SavegameList *pSavegameList = new SavegameList; unsigned int uNumSavegameFiles; unsigned int pSavegameUsedSlots[45]; -struct RGBTexture *pSavegameThumbnails = new RGBTexture[45]; -SavegameHeader *pSavegameHeader = new SavegameHeader[45]; +struct RGBTexture pSavegameThumbnails[45]; +SavegameHeader pSavegameHeader[45];
--- a/SaveLoad.h Fri Nov 02 00:44:18 2012 +0600 +++ b/SaveLoad.h Fri Nov 02 14:45:06 2012 +0200 @@ -29,5 +29,6 @@ extern unsigned int uNumSavegameFiles; extern unsigned int pSavegameUsedSlots[45]; -extern struct SavegameList *pSavegameList; -extern struct RGBTexture *pSavegameThumbnails; \ No newline at end of file +extern struct SavegameList *pSavegameList; +extern struct RGBTexture pSavegameThumbnails[]; +extern struct SavegameHeader pSavegameHeader[]; \ No newline at end of file
--- a/mm7_2.cpp Fri Nov 02 00:44:18 2012 +0600 +++ b/mm7_2.cpp Fri Nov 02 14:45:06 2012 +0200 @@ -11471,7 +11471,7 @@ pRenderer->DrawTextureIndexed( 8u, 8u, - (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); + uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0); if ( a4 ) { v2 = uTextureID_save_up; @@ -11482,23 +11482,20 @@ v2 = uTextureID_load_up; v3 = uTextureID_LS_loadU; } - pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0)); - pRenderer->DrawTextureIndexed(0x12u, 0x8Bu, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0)); - pRenderer->DrawTextureIndexed( - 0x15Fu, - 0x12Eu, - (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0)); + pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0)); + pRenderer->DrawTextureIndexed(18, 139, (Texture *)(v2 != -1 ? &pIcons_LOD->pTextures[v2] : 0)); + pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0)); v1 = 255; } if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] ) { memset(&Dst, 0, 0x54u); Dst.uFrameX = pGUIWindow_CurrentMenu->uFrameX + 240; - v4 = pGUIWindow_CurrentMenu->uFrameY - LOBYTE(pFontSmallnum->uFontHeight); + v4 = pGUIWindow_CurrentMenu->uFrameY - pFontSmallnum->uFontHeight; Dst.uFrameWidth = 220; v4 += 157; Dst.uFrameY = v4; - v5 = LOBYTE(pFontSmallnum->uFontHeight); + v5 = pFontSmallnum->uFontHeight; Dst.uFrameZ = Dst.uFrameX + 219; Dst.uFrameHeight = v5; Dst.uFrameW = v5 + v4 - 1; @@ -11592,10 +11589,10 @@ v18 = pGlobalTXT_LocalizationStrings[135]; v19 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[135]); pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v19 + 25, 220, 0, v18, 0, 0, 0); - v20 = (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot); + v20 = (const char *)(pSavegameHeader + uLoadGameUI_SelectedSlot); v21 = pFontSmallnum->AlignText_Center( 0xBAu, - (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot); + (const char *)pSavegameHeader + 100 * uLoadGameUI_SelectedSlot); pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v21 + 25, 0x106u, 0, v20, 185, 0); v22 = pGlobalTXT_LocalizationStrings[165]; v23 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[165]);
--- a/mm7_3.cpp Fri Nov 02 00:44:18 2012 +0600 +++ b/mm7_3.cpp Fri Nov 02 14:45:06 2012 +0200 @@ -2174,10 +2174,6 @@ goto LABEL_74; } } -// 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); -// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); -// 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); -
--- a/mm7_4.cpp Fri Nov 02 00:44:18 2012 +0600 +++ b/mm7_4.cpp Fri Nov 02 14:45:06 2012 +0200 @@ -7244,7 +7244,7 @@ } //----- (004A597D) -------------------------------------------------------- -void __cdecl Present_NoColorKey() +void Present_NoColorKey() { //unsigned __int16 *v0; // eax@4 unsigned __int16 *v1; // esi@4 @@ -7334,7 +7334,7 @@ auto uHalfWidth = v20 = (pViewport->uViewportZ - pViewport->uViewportX) / 2; v13 = v24; - for (uint y = pViewport->uViewportY; y < pViewport->uViewportW; ++y) + for (uint y = pViewport->uViewportY; y < pViewport->uViewportW + 1; ++y) { //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2, // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16));
--- a/mm7_data.h Fri Nov 02 00:44:18 2012 +0600 +++ b/mm7_data.h Fri Nov 02 14:45:06 2012 +0200 @@ -2224,7 +2224,6 @@ extern int dword_69B010[64]; extern float flt_69B138_dist; // weak extern char byte_69BD41_unused; // weak -extern struct SavegameHeader *pSavegameHeader; extern unsigned int uTextureID_x_u; extern unsigned int uTextureID_LS_saveU; extern unsigned int uTextureID_LS_loadU;