# HG changeset patch # User Ritor1 # Date 1352862871 -21600 # Node ID 2546de5c70dd883dbdc4eeab70a423fec7fca542 # Parent 6c67511e2f7171f8a64bd42cded0f45567868170# Parent a2715ce5cf172f41e18f7db1e2c3e5e9e0edcb0d Слияние diff -r 6c67511e2f71 -r 2546de5c70dd LOD.cpp --- a/LOD.cpp Wed Nov 14 09:13:59 2012 +0600 +++ b/LOD.cpp Wed Nov 14 09:14:31 2012 +0600 @@ -995,34 +995,32 @@ _6A0CA8_lod_unused = 0; } } -// 6A0CA8: using guessed type int 6A0CA8_lod_unused; + + //----- (00461492) -------------------------------------------------------- int LODWriteableFile::_461492(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *Source) { - LODWriteableFile *v4; // esi@1 - FILE *v6; // eax@5 - - v4 = this; - if ( this->isFileOpened ) + if (isFileOpened) return 1; if ( !pDir->pFilename[0] ) return 2; - strcpy((char *)pHeader, "LOD"); + strcpy(pHeader->pSignature, "LOD"); pHeader->dword_0000A4 = 100; pHeader->uNumIndices = 1; pDir->pFilename[15] = 0; pDir->uDataSize = 0; pDir->uOfsetFromSubindicesStart = 288; - strcpy((char *)v4->pLODName, Source); - v6 = fopen((const char *)v4->pLODName, "wb+"); - v4->pFile = v6; - if ( !v6 ) + strcpy(pLODName, Source); + + pFile = fopen(pLODName, "wb+"); + if (!pFile) return 3; - fwrite(pHeader, 0x100, 1, v6); - fwrite(pDir, 0x20, 1, v4->pFile); - fclose(v4->pFile); - v4->pFile = 0; + + fwrite(pHeader, 0x100, 1, pFile); + fwrite(pDir, 0x20, 1, pFile); + fclose(pFile); + pFile = 0; return 0; } @@ -1644,16 +1642,17 @@ } // 6A0CA8: using guessed type int 6A0CA8_lod_unused; + //----- (00461B48) -------------------------------------------------------- -/*unsigned int LODWriteableFile::Write(const LOD::Directory *pDir, const void *pDirData, int a4) +unsigned int LODWriteableFile::Write(const LOD::Directory *pDir, const void *pDirData, int a4) { - LODWriteableFile *v4; // ebx@1 + //LODWriteableFile *v4; // ebx@1 int v5; // esi@1 - unsigned __int8 v7; // zf@7 - unsigned __int8 v8; // sf@7 + //unsigned __int8 v7; // zf@7 + //unsigned __int8 v8; // sf@7 const LOD::Directory *v9; // edi@9 int v10; // eax@9 - unsigned __int8 v11; // of@15 + //unsigned __int8 v11; // of@15 unsigned __int16 v12; // dx@17 LOD::Directory *v13; // eax@17 unsigned __int16 v14; // cx@17 @@ -1675,7 +1674,7 @@ char NewFilename[256]; // [sp+10Ch] [bp-130h]@51 //LOD::Directory Str; // [sp+20Ch] [bp-30h]@27 size_t v33; // [sp+22Ch] [bp-10h]@27 - int v34; // [sp+230h] [bp-Ch]@7 + //int v34; // [sp+230h] [bp-Ch]@7 __int32 v35; // [sp+234h] [bp-8h]@8 int v36; // [sp+238h] [bp-4h]@7 size_t Count; // [sp+244h] [bp+8h]@40 @@ -1683,63 +1682,81 @@ size_t Countb; // [sp+244h] [bp+8h]@47 FILE *pFile; // [sp+24Ch] [bp+10h]@22 - v4 = this; - v5 = 0; - if ( !this->isFileOpened ) + //v4 = this; + //v5 = 0; + + if (!isFileOpened) return 1; - if ( !this->pSubIndices ) + if (!pSubIndices) return 2; - if ( !this->pIOBuffer || !this->uIOBufferSize ) + if (!pIOBuffer || !uIOBufferSize) return 3; - v7 = this->uNumSubIndices == 0; - v8 = (this->uNumSubIndices & 0x80000000u) != 0; + + //v7 = this->uNumSubIndices == 0; + //v8 = (this->uNumSubIndices & 0x80000000u) != 0; + v35 = 0; v36 = 0; - v34 = 0; - if ( v8 | v7 ) + //v34 = 0; + for (v5 = 0; v5 < uNumSubIndices; ++v5) + /*if ( v8 | v7 ) { v9 = pDir; goto LABEL_22; } - v35 = 0; - while ( 1 ) + while ( 1 )*/ { v9 = pDir; - v10 = _strcmpi((const char *)v4->pSubIndices + v35, (const char *)pDir); - if ( v10 ) + v10 = _strcmpi(pSubIndices[v5].pFilename, pDir->pFilename); + if (v10 > 0) + break; + else if (v10 < 0) + continue; + /*if ( v10 ) { if ( v10 > 0 ) goto LABEL_22; goto LABEL_15; - } + }*/ if ( !a4 ) - goto LABEL_20; + { + v36 = 1; + break; + } if ( a4 == 1 ) + { + v12 = pDir->uNumSubIndices; + v13 = &pSubIndices[v5]; + v14 = v13->uNumSubIndices; + if ( v14 >= v12 && (v14 != v12 || (unsigned __int16)v13->word_00001E >= pDir->word_00001E) ) + return 4; + v36 = 1; break; + } if ( a4 == 2 ) return 4; -LABEL_15: - v35 += 32; - ++v5; - v11 = __OFSUB__(v5, v4->uNumSubIndices); - v8 = ((v5 - v4->uNumSubIndices) & 0x80000000u) != 0; - v34 = v5; - if ( !(v8 ^ v11) ) - goto LABEL_22; +//LABEL_15: + //v35 += 32; + //++v5; + //v11 = __OFSUB__(v5, v4->uNumSubIndices); + //v8 = ((v5 - v4->uNumSubIndices) & 0x80000000u) != 0; + //v34 = v5; + //if ( !(v8 ^ v11) ) + //goto LABEL_22; } - v12 = pDir->uNumSubIndices; +/* v12 = pDir->uNumSubIndices; v13 = &v4->pSubIndices[v5]; v14 = v13->uNumSubIndices; if ( v14 >= v12 && (v14 != v12 || (unsigned __int16)v13->word_00001E >= pDir->word_00001E) ) return 4; LABEL_20: v36 = 1; -LABEL_22: +LABEL_22:*/ strcpy(pFilename, "lod.tmp"); pFile = fopen(pFilename, "wb+"); if ( !pFile ) return 5; if ( v36 ) - v35 = v4->pSubIndices[v5].uDataSize; + v35 = pSubIndices[v5].uDataSize; else v35 = 0; v33 = v9->uDataSize; @@ -1748,9 +1765,9 @@ LOD::Directory Str; // [sp+20Ch] [bp-30h]@27 //LOD::Directory::LOD::Directory(&Str); - strcpy((char *)&Str, "chapter"); - v16 = v4->uLODDataSize; - Str.uNumSubIndices = LOWORD(v4->uNumSubIndices); + strcpy(Str.pFilename, "chapter"); + v16 = uLODDataSize; + Str.uNumSubIndices = uNumSubIndices; Str.dword_000018 = 0; Str.word_00001E = 0; if ( !v36 ) @@ -1758,263 +1775,76 @@ ++Str.uNumSubIndices; v15 += 32; } - v7 = v36 == 0; + //v7 = v36 == 0; Str.uDataSize = v15 + v16; Str.uOfsetFromSubindicesStart = 288; v17 = (signed __int16)Str.uNumSubIndices; - v4->uNumSubIndices = (signed __int16)Str.uNumSubIndices; - if ( v7 && v17 > v5 ) + uNumSubIndices = (signed __int16)Str.uNumSubIndices; + if ( !v36 && v17 > v5 ) { v18 = v17; v19 = v17 - v5; do { - v20 = &v4->pSubIndices[v18]; + v20 = &pSubIndices[v18]; --v18; --v19; memcpy(v20, (char *)v20 - 32, 0x20u); } while ( v19 ); - v5 = v34; + //v5 = v34; } - v34 = 32 * v5; - memcpy(&v4->pSubIndices[v5], pDir, sizeof(v4->pSubIndices[v5])); - v23 = 32 * v4->uNumSubIndices; - if ( (signed int)v4->uNumSubIndices > 0 ) + //v34 = 32 * v5; + memcpy(&pSubIndices[v5], pDir, sizeof(LOD::Directory)); + v23 = 32 * uNumSubIndices; + if ( (signed int)uNumSubIndices > 0 ) { - for (int i = 0; i < (signed int)v4->uNumSubIndices; ++i) + for (int i = 0; i < (signed int)uNumSubIndices; ++i) { - v4->pSubIndices[i].uOfsetFromSubindicesStart = v23; - v23 += v4->pSubIndices[i].uDataSize; + pSubIndices[i].uOfsetFromSubindicesStart = v23; + v23 += pSubIndices[i].uDataSize; } } - fwrite(&v4->header, 0x100, 1, pFile); + fwrite(&header, 0x100, 1, pFile); fwrite(&Str, 0x20, 1, pFile); - fseek(v4->pFile, Str.uOfsetFromSubindicesStart, 0); - fwrite(v4->pSubIndices, 0x20u, v4->uNumSubIndices, pFile); - v26 = 32 * v4->uNumSubIndices; + fseek(pFile, Str.uOfsetFromSubindicesStart, 0); + fwrite(pSubIndices, 0x20u, uNumSubIndices, pFile); + v26 = 32 * uNumSubIndices; if ( !v36 ) v26 -= 32; - fseek(v4->pFile, v26, 1); - for ( i = *(unsigned int *)((char *)&v4->pSubIndices->uOfsetFromSubindicesStart + v34) - - v4->pSubIndices->uOfsetFromSubindicesStart; i > 0; i -= Count ) + fseek(pFile, v26, 1); + for ( i = pSubIndices[v5].uOfsetFromSubindicesStart + - pSubIndices->uOfsetFromSubindicesStart; i > 0; i -= Count ) { - Count = v4->uIOBufferSize; - if ( i <= (signed int)v4->uIOBufferSize ) + Count = uIOBufferSize; + if ( i <= (signed int)uIOBufferSize ) Count = i; - fread(v4->pIOBuffer, 1u, Count, v4->pFile); - fwrite(v4->pIOBuffer, 1u, Count, pFile); + fread(pIOBuffer, 1u, Count, pFile); + fwrite(pIOBuffer, 1u, Count, pFile); } fwrite(pDirData, 1u, v33, pFile); if ( v36 ) - fseek(v4->pFile, v35, 1); - Countc = ftell(v4->pFile); - fseek(v4->pFile, 0, 2); - v28 = ftell(v4->pFile) - Countc; - fseek(v4->pFile, Countc, 0); + fseek(pFile, v35, 1); + Countc = ftell(pFile); + fseek(pFile, 0, 2); + v28 = ftell(pFile) - Countc; + fseek(pFile, Countc, 0); while ( v28 > 0 ) { - Countb = v4->uIOBufferSize; - if ( v28 <= (signed int)v4->uIOBufferSize ) + Countb = uIOBufferSize; + if ( v28 <= (signed int)uIOBufferSize ) Countb = v28; - fread(v4->pIOBuffer, 1u, Countb, v4->pFile); - fwrite(v4->pIOBuffer, 1u, Countb, pFile); + fread(pIOBuffer, 1u, Countb, pFile); + fwrite(pIOBuffer, 1u, Countb, pFile); v28 -= Countb; } - strcpy(NewFilename, (const char *)v4->pLODName); + strcpy(NewFilename, (const char *)pLODName); fclose(pFile); - v4->CloseWriteFile(); + CloseWriteFile(); remove(NewFilename); rename(pFilename, NewFilename); - v4->CloseWriteFile(); - v4->LoadFile(v4->pLODName, 0); - return 0; -} -*/ - -unsigned int LODWriteableFile::Write(const LOD::Directory *pDir, const void *pDirData, int a4) -{ - LODWriteableFile *v4; // ebx@1 - int v5; // esi@1 - unsigned __int8 v7; // zf@7 - unsigned __int8 v8; // sf@7 - const LOD::Directory *v9; // edi@9 - int v10; // eax@9 - unsigned __int8 v11; // of@15 - unsigned __int16 v12; // dx@17 - LOD::Directory *v13; // eax@17 - unsigned __int16 v14; // cx@17 - int v15; // edi@27 - unsigned int v16; // eax@27 - int v17; // eax@29 - int v18; // edx@31 - int v19; // eax@31 - void *v20; // edi@32 - LOD::Directory *v21; // edi@34 - signed int v22; // esi@34 - int v23; // eax@34 - LOD::Directory *v24; // ecx@35 - int v25; // edx@35 - __int32 v26; // eax@37 - int i; // esi@39 - __int32 v28; // esi@46 - char pFilename[256]; // [sp+Ch] [bp-230h]@22 - char NewFilename[256]; // [sp+10Ch] [bp-130h]@51 - //LOD::Directory Str; // [sp+20Ch] [bp-30h]@27 - size_t v33; // [sp+22Ch] [bp-10h]@27 - int v34; // [sp+230h] [bp-Ch]@7 - __int32 v35; // [sp+234h] [bp-8h]@8 - int v36; // [sp+238h] [bp-4h]@7 - size_t Count; // [sp+244h] [bp+8h]@40 - __int32 Countc; // [sp+244h] [bp+8h]@46 - size_t Countb; // [sp+244h] [bp+8h]@47 - FILE *pFile; // [sp+24Ch] [bp+10h]@22 - - v4 = this; - v5 = 0; - if ( !this->isFileOpened ) - return 1; - if ( !this->pSubIndices ) - return 2; - if ( !this->pIOBuffer || !this->uIOBufferSize ) - return 3; - v7 = this->uNumSubIndices == 0; - v8 = (this->uNumSubIndices & 0x80000000u) != 0; - v36 = 0; - v34 = 0; - if ( v8 | v7 ) - { - v9 = pDir; - goto LABEL_22; - } - v35 = 0; - while ( 1 ) - { - v9 = pDir; - v10 = _strcmpi((const char *)v4->pSubIndices + v35, (const char *)pDir); - if ( v10 ) - { - if ( v10 > 0 ) - goto LABEL_22; - goto LABEL_15; - } - if ( !a4 ) - goto LABEL_20; - if ( a4 == 1 ) - break; - if ( a4 == 2 ) - return 4; -LABEL_15: - v35 += 32; - ++v5; - v11 = __OFSUB__(v5, v4->uNumSubIndices); - v8 = ((v5 - v4->uNumSubIndices) & 0x80000000u) != 0; - v34 = v5; - if ( !(v8 ^ v11) ) - goto LABEL_22; - } - v12 = pDir->uNumSubIndices; - v13 = &v4->pSubIndices[v5]; - v14 = v13->uNumSubIndices; - if ( v14 >= v12 && (v14 != v12 || (unsigned __int16)v13->word_00001E >= pDir->word_00001E) ) - return 4; -LABEL_20: - v36 = 1; -LABEL_22: - strcpy(pFilename, "lod.tmp"); - pFile = fopen(pFilename, "wb+"); - if ( !pFile ) - return 5; - if ( v36 ) - v35 = v4->pSubIndices[v5].uDataSize; - else - v35 = 0; - v33 = v9->uDataSize; - v15 = v33 - v35; - - LOD::Directory Str; // [sp+20Ch] [bp-30h]@27 - //LOD::Directory::LOD::Directory(&Str); - - strcpy((char *)&Str, "chapter"); - v16 = v4->uLODDataSize; - Str.uNumSubIndices = LOWORD(v4->uNumSubIndices); - Str.dword_000018 = 0; - Str.word_00001E = 0; - if ( !v36 ) - { - ++Str.uNumSubIndices; - v15 += 32; - } - v7 = v36 == 0; - Str.uDataSize = v15 + v16; - Str.uOfsetFromSubindicesStart = 288; - v17 = (signed __int16)Str.uNumSubIndices; - v4->uNumSubIndices = (signed __int16)Str.uNumSubIndices; - if ( v7 && v17 > v5 ) - { - v18 = v17; - v19 = v17 - v5; - do - { - v20 = &v4->pSubIndices[v18]; - --v18; - --v19; - memcpy(v20, (char *)v20 - 32, 0x20u); - } - while ( v19 ); - v5 = v34; - } - v34 = 32 * v5; - memcpy(&v4->pSubIndices[v5], pDir, sizeof(v4->pSubIndices[v5])); - v23 = 32 * v4->uNumSubIndices; - if ( (signed int)v4->uNumSubIndices > 0 ) - { - for (int i = 0; i < (signed int)v4->uNumSubIndices; ++i) - { - v4->pSubIndices[i].uOfsetFromSubindicesStart = v23; - v23 += v4->pSubIndices[i].uDataSize; - } - } - fwrite(&v4->header, 0x100, 1, pFile); - fwrite(&Str, 0x20, 1, pFile); - fseek(v4->pFile, Str.uOfsetFromSubindicesStart, 0); - fwrite(v4->pSubIndices, 0x20u, v4->uNumSubIndices, pFile); - v26 = 32 * v4->uNumSubIndices; - if ( !v36 ) - v26 -= 32; - fseek(v4->pFile, v26, 1); - for ( i = *(unsigned int *)((char *)&v4->pSubIndices->uOfsetFromSubindicesStart + v34) - - v4->pSubIndices->uOfsetFromSubindicesStart; i > 0; i -= Count ) - { - Count = v4->uIOBufferSize; - if ( i <= (signed int)v4->uIOBufferSize ) - Count = i; - fread(v4->pIOBuffer, 1u, Count, v4->pFile); - fwrite(v4->pIOBuffer, 1u, Count, pFile); - } - fwrite(pDirData, 1u, v33, pFile); - if ( v36 ) - fseek(v4->pFile, v35, 1); - Countc = ftell(v4->pFile); - fseek(v4->pFile, 0, 2); - v28 = ftell(v4->pFile) - Countc; - fseek(v4->pFile, Countc, 0); - while ( v28 > 0 ) - { - Countb = v4->uIOBufferSize; - if ( v28 <= (signed int)v4->uIOBufferSize ) - Countb = v28; - fread(v4->pIOBuffer, 1u, Countb, v4->pFile); - fwrite(v4->pIOBuffer, 1u, Countb, pFile); - v28 -= Countb; - } - strcpy(NewFilename, (const char *)v4->pLODName); - fclose(pFile); - v4->CloseWriteFile(); - remove(NewFilename); - rename(pFilename, NewFilename); - v4->CloseWriteFile(); - v4->LoadFile(v4->pLODName, 0); + CloseWriteFile(); + LoadFile(pLODName, 0); return 0; } diff -r 6c67511e2f71 -r 2546de5c70dd LOD.h --- a/LOD.h Wed Nov 14 09:13:59 2012 +0600 +++ b/LOD.h Wed Nov 14 09:14:31 2012 +0600 @@ -23,14 +23,18 @@ { inline FileHeader() { + memset(LodVersion, 0, 8); + memset(field_2C, 0, 40); memset(array_0000B0, 0, 28); memset(array_0000CC, 0, 52); } void Reset(); - unsigned __int8 pSignature[4]; - char LodVersion[80]; + char pSignature[4]; + char LodVersion[8]; + char field_C[32]; + char field_2C[40]; char LodDescription[80]; int dword_0000A4; int dword_0000A8; diff -r 6c67511e2f71 -r 2546de5c70dd SaveLoad.cpp --- a/SaveLoad.cpp Wed Nov 14 09:13:59 2012 +0600 +++ b/SaveLoad.cpp Wed Nov 14 09:14:31 2012 +0600 @@ -1,5 +1,6 @@ #include #include +#include #include "SaveLoad.h" #include "NPC.h" @@ -46,7 +47,7 @@ bool v26; // eax@62 int v30; // [sp-Ch] [bp-FCh]@65 int v31; // [sp-8h] [bp-F8h]@4 - char DstBuf[100]; // [sp+Ch] [bp-E4h]@23 + SavegameHeader header; // [sp+Ch] [bp-E4h]@23 char Str[123]; // [sp+70h] [bp-80h]@25 dword_5B65C8 = 0; @@ -97,7 +98,8 @@ Log::Warning(L"%S", Str); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0); } - fread(&DstBuf, 0x64u, 1u, f); + assert(sizeof(SavegameHeader) == 100); + fread(&header, sizeof(SavegameHeader), 1, f); f = pNew_LOD->FindContainer("party.bin", 1); if (!f) @@ -198,16 +200,16 @@ pEventTimer->Resume(); pEventTimer->StopGameTime(); - v25 = pGames_LOD->DoesContainerExist(&DstBuf[20]); - sprintf(pTmpBuf, "levels\\%s", &DstBuf[20]); + v25 = pGames_LOD->DoesContainerExist(header.pLocationName); + sprintf(pTmpBuf, "levels\\%s", header.pLocationName); v26 = _access(pTmpBuf, 4) != -1; if ( !v25 && !v26 ) { - sprintf(pTmpBuf, "Unable to find: %s!", &DstBuf[20]); + sprintf(pTmpBuf, "Unable to find: %s!", header.pLocationName); Abortf(pTmpBuf); } - strcpy(pCurrentMapName, &DstBuf[20]); + strcpy(pCurrentMapName, header.pLocationName); dword_6BE364_game_settings_1 |= 0x2001; for (uint i = 0; i < uNumSavegameFiles; ++i) @@ -260,16 +262,17 @@ int v32; // esi@51 int v33; // eax@51 DWORD v34; // eax@59 - std::string v35; // [sp-18h] [bp-288h]@8 + //std::string v35; // [sp-18h] [bp-288h]@8 const char *v36; // [sp-10h] [bp-280h]@6 const char *v37; // [sp-Ch] [bp-27Ch]@6 const char *v38; // [sp-8h] [bp-278h]@8 CHAR Buffer; // [sp+Ch] [bp-264h]@59 char Dir; // [sp+8Ch] [bp-1E4h]@51 char Drive; // [sp+ACh] [bp-1C4h]@51 - int v43; // [sp+CCh] [bp-1A4h]@10 - char Dest[20]; // [sp+E0h] [bp-190h]@10 - unsigned __int64 pTimePlayed; // [sp+F4h] [bp-17Ch]@10 + SavegameHeader header; // [sp+CCh] [bp-1A4h]@10 + //int v43; // [sp+CCh] [bp-1A4h]@10 + //char Dest[20]; // [sp+E0h] [bp-190h]@10 + //unsigned __int64 pTimePlayed; // [sp+F4h] [bp-17Ch]@10 char Filename; // [sp+130h] [bp-140h]@51 char Ext; // [sp+150h] [bp-120h]@51 char v48; // [sp+151h] [bp-11Fh]@51 @@ -322,7 +325,7 @@ strcpy(pDir.pFilename, "image.pcx"); pRenderer->_49F5A2((int)pScreenshot, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize); free(pScreenshot); - if ( pCurrentScreen == 11 )//SaveScreen + if (pCurrentScreen == 11) //SaveScreen { pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); pRenderer->DrawTextureIndexed(0x12, 0x8D, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0)); @@ -334,49 +337,51 @@ pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //, pRenderer->Present(); } - if ( pNew_LOD->Write(&pDir, DstBuf, 0) ) + if (pNew_LOD->Write(&pDir, DstBuf, 0)) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); // ! Code=%d MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); } - strcpy(Dest, pCurrentMapName); - pTimePlayed = pParty->uTimePlayed; - strcpy((char *)&pDir, "header.bin"); - pDir.uDataSize = 100; - if ( pNew_LOD->Write(&pDir, &v43, 0) ) + + assert(sizeof(SavegameHeader) == 100); + strcpy(header.pLocationName, pCurrentMapName); + header.uWordTime = pParty->uTimePlayed; + strcpy(pDir.pFilename, "header.bin"); + pDir.uDataSize = sizeof(SavegameHeader); + if (pNew_LOD->Write(&pDir, &header, 0)) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); } - strcpy((char *)&pDir, "party.bin"); + strcpy(pDir.pFilename, "party.bin"); pDir.uDataSize = 90680; - if ( pNew_LOD->Write(&pDir, &pParty, 0) ) + if ( pNew_LOD->Write(&pDir, pParty, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); } - strcpy((char *)&pDir, "clock.bin"); + strcpy(pDir.pFilename, "clock.bin"); pDir.uDataSize = 40; - if ( pNew_LOD->Write(&pDir, &pEventTimer, 0) ) + if ( pNew_LOD->Write(&pDir, pEventTimer, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); } - strcpy((char *)&pDir, "overlay.bin"); + strcpy(pDir.pFilename, "overlay.bin"); pDir.uDataSize = 1008; - if ( pNew_LOD->Write(&pDir, &pOtherOverlayList, 0) ) + if ( pNew_LOD->Write(&pDir, pOtherOverlayList, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); } - strcpy((char *)&pDir, "npcdata.bin"); + strcpy(pDir.pFilename, "npcdata.bin"); pDir.uDataSize = 38076; if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); } - strcpy((char *)&pDir, "npcgroup.bin"); + strcpy(pDir.pFilename, "npcgroup.bin"); pDir.uDataSize = 102; if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) ) { @@ -391,6 +396,7 @@ v8 = fopen(Str, "rb"); if ( v8 ) { + __debugbreak(); sprintf(Str, "lloyd%d%d.pcx", i, j); fseek(v8, 0, 2); pDir.uDataSize = ftell(v8); @@ -410,6 +416,7 @@ } if ( !a2 ) { + __debugbreak(); sub_42FA22_mess_with_laying_item_list(); v9 = (int)malloc(0xF4240); v71 = (std::string *)v9; @@ -423,6 +430,7 @@ memcpy((void *)v9, &Src, 0x10); if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) { + __debugbreak(); pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; pIndoor->dlv.uNumBModels = 0; pIndoor->dlv.uNumDecorations = uNumLevelDecorations; @@ -603,6 +611,8 @@ int bNotArena; // [sp+2Ch] [bp-8h]@1 unsigned int v6; // [sp+30h] [bp-4h]@1 + __debugbreak(); + v1 = uSlot; v6 = uSlot; bNotArena = _strcmpi(pCurrentMapName, "d05.blv"); diff -r 6c67511e2f71 -r 2546de5c70dd mm7_2.cpp --- a/mm7_2.cpp Wed Nov 14 09:13:59 2012 +0600 +++ b/mm7_2.cpp Wed Nov 14 09:14:31 2012 +0600 @@ -11280,7 +11280,7 @@ v27 = height; v23 = 452.0 / (double)width; v25 = 336.0 / (double)height; - pPixels = (unsigned __int16 *)operator new(2 * height * width); + pPixels = (unsigned __int16 *)malloc(2 * height * width); v3 = pPixels; if ( pRenderer->pRenderD3D ) { @@ -11754,16 +11754,17 @@ pNew_LOD->CreateTempFile(); pNew_LOD->uNumSubIndices = 0; pDir.Reset(); - for (int i = pGames_LOD->uNumSubIndices / 2; i < pGames_LOD->uNumSubIndices; ++i) - { - memcpy(&pDir, (char *)&pGames_LOD->pSubIndices[i], sizeof(pDir)); - v3 = pGames_LOD->FindContainer((const char *)&pGames_LOD->pSubIndices[i], 1); - fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, v3); - pNew_LOD->AppendDirectory(&pDir, pSave); - } + + for (int i = pGames_LOD->uNumSubIndices / 2; i < pGames_LOD->uNumSubIndices; ++i) + { + memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir)); + v3 = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1); + fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, v3); + pNew_LOD->AppendDirectory(&pDir, pSave); + } v7.Reset(); strcpy(pSavegameHeader->pLocationName, "out01.odm"); - strcpy((char *)&v7, "header.bin"); + strcpy(v7.pFilename, "header.bin"); v7.uDataSize = 100; pNew_LOD->AppendDirectory(&v7, &pSavegameHeader); pNew_LOD->Save(); diff -r 6c67511e2f71 -r 2546de5c70dd mm7_3.cpp --- a/mm7_3.cpp Wed Nov 14 09:13:59 2012 +0600 +++ b/mm7_3.cpp Wed Nov 14 09:14:31 2012 +0600 @@ -9159,34 +9159,37 @@ void __fastcall sub_47F4D3(int band1, int band2, int band3) { int v3; // edi@1 - stru220 *v4; // esi@1 + //stru220 *v4; // esi@1 double v5; // ST2C_8@3 double v6; // st7@3 - double v7; // [sp+18h] [bp-28h]@3 - double v8; // [sp+20h] [bp-20h]@2 + //double v7; // [sp+18h] [bp-28h]@3 + //double v8; // [sp+20h] [bp-20h]@2 int v9; // [sp+34h] [bp-Ch]@1 int v10; // [sp+38h] [bp-8h]@1 - signed int band3a; // [sp+48h] [bp+8h]@2 - - v9 = band2 << 9; + //signed int band3a; // [sp+48h] [bp+8h]@2 + + v9 = band2 * 512; pOutdoorCamera->outdoor_grid_band_3 = band3; - v10 = band1 << 9; - v3 = band3 << 9; - pOutdoorCamera->uPickDepth = band3 << 9; - v4 = stru_76E5C8; // v4: 0 -> 65536 - do - { - v8 = (double)(signed int)((char *)v4 + 256 - (int)stru_76E5C8); - for (band3a = 256; band3a < 65792; band3a += 512) // band3a: 0 -> 128 - { - v5 = pow((double)band3a, 2.0); - v6 = pow(v8, 2.0); - *((float *)&v5 + 1) = sqrt(v6 + v5); - v7 = *((float *)&v5 + 1) + 6.755399441055744e15; - if ( SLODWORD(v7) >= v10 ) - { - if ( SLODWORD(v7) >= v9 ) - v4->field_0 = ((SLODWORD(v7) >= v3) - 1) & 2; + v10 = band1 * 512; + v3 = band3 * 512; + pOutdoorCamera->uPickDepth = band3 * 512; + //v4 = stru_76E5C8; // v4: 0 -> 65536 + for (uint i = 0; i < 16384; ++i) + //do + { + auto v4 = stru_76E5C8 + i; + //band3a = 256; + //v8 = (double)(signed int)((char *)v4 + 256 - (int)stru_76E5C8); + for (uint j = 0; j < 128; ++j) // band3a: 0 -> 128 + { + v5 = pow(j * 512 + 256, 2.0); + v6 = pow(i * 4 + 256, 2.0); + //*((float *)&v5 + 1) = sqrt(v6 + v5); + int v7 = floorf(sqrtf(v5 + v6) + 0.5f);//*((float *)&v5 + 1) + 6.7553994e15; + if (v7 >= v10) + { + if (v7 >= v9) + v4->field_0 = ((v7 >= v3) - 1) & 2; else v4->field_0 = 2; } @@ -9194,11 +9197,13 @@ { v4->field_0 = 1; } - v4->distance = LOWORD(v7); + //band3a += 512; + v4->distance = v7; ++v4; } - } - while ( (signed int)v4 < (signed int)arary_77E5C8 ); + //while ( band3a < 65792 ); + } + //while ( (signed int)v4 < (signed int)arary_77E5C8 ); }