Mercurial > might-and-magic-trilogy
changeset 27:be2066176d89
On level initialization
author | Nomad |
---|---|
date | Tue, 16 Oct 2012 01:31:05 +0200 |
parents | 93bf1d5f6a6d |
children | 18f7a1b94448 f2686b090917 |
files | AudioPlayer.cpp AudioPlayer.h DecalBuilder.cpp GUIProgressBar.cpp GUIProgressBar.h Game.cpp Outdoor.cpp Party.cpp Render.cpp Render.h SaveLoad.cpp TurnEngine.h mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_data.cpp mm7_data.h |
diffstat | 18 files changed, 235 insertions(+), 281 deletions(-) [+] |
line wrap: on
line diff
--- a/AudioPlayer.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/AudioPlayer.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -78,7 +78,7 @@ { if ( v1->pSounds[v2].eType != SOUND_DESC_SYSTEM || (sprintf(pSoundName, "%s", pSounds[v2].pSoundName), - v1->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (char *)0xFFFFFFFF, pSounds[v2].uSoundID), + v1->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[v2].uSoundID), !pAudioPlayer->b3DSoundInitialized) || (v3 = &v1->pSounds[v2], !(v3->uFlags & 2)) || !v3->pSoundData[0] ) @@ -122,104 +122,76 @@ //----- (004A9A67) -------------------------------------------------------- __int16 SoundList::_4A9A67(int a1, unsigned int a3) { - SoundList *v3; // edi@1 - unsigned int v4; // edx@2 - int v5; // esi@2 - unsigned __int8 v6; // zf@2 - char v7; // sf@2 - unsigned __int8 v8; // of@2 - SoundDesc *v9; // eax@3 - int v10; // ecx@3 - int v12; // esi@8 - SoundDesc *v13; // eax@8 - SoundDesc *v14; // eax@12 - SoundDesc *v15; // eax@14 - SoundDesc *v16; // eax@18 - void *v17; // ebx@20 - unsigned int v18; // eax@20 - char *v19; // ebx@20 - AILFILETYPE eType; // eax@20 - int v21; // eax@21 - int v22; // ST04_4@26 - char pSoundName[120]; // [sp+Ch] [bp-A0h]@12 AILSOUNDINFO v24; // [sp+84h] [bp-28h]@23 - int a2; // [sp+A8h] [bp-4h]@2 + + if (bNoSound || !uNumSounds) + return 0; + + uint uSoundIdx = 0; + SoundDesc *pSound = nullptr; + for (uint i = 1; i < uNumSounds; ++i) + if (pSounds[i].uSoundID == a1) + { + uSoundIdx = i; + pSound = &pSounds[i]; + break; + } + if (!pSound) + return 0; - v3 = this; - if (bNoSound - || (v4 = this->uNumSounds, - v5 = 1, - v8 = __OFSUB__(this->uNumSounds, 1), - v6 = this->uNumSounds == 1, - v7 = ((this->uNumSounds - 1) & 0x80000000u) != 0, - a2 = 1, - (unsigned __int8)(v7 ^ v8) | v6) ) + if (pSound->uFlags & 2 && pSound->p3DSound || + ~pSound->uFlags & 2 && pSound->pSoundData[0]) + return uSoundIdx; + + if (!pSound->pSoundData[0]) + pSound->pSoundData[0] = ::LoadSound(pSound->pSoundName, (SoundData *)0xFFFFFFFF, pSound->uSoundID); + + if (!pSound->pSoundData[0]) return 0; - v9 = this->pSounds; - v10 = (int)&v9[1].uSoundID; - while ( a1 != *(int *)v10 ) + + if (a3) + pSound->uFlags |= 1u; + + if (!pAudioPlayer->b3DSoundInitialized) + return uSoundIdx; + + if (~pSound->uFlags & 2 || !pSound->pSoundData[0]) + return uSoundIdx; + + + auto pSoundData = pSound->pSoundData[0]; + switch (AIL_file_type((void *)pSoundData->pData, pSoundData->uDataSize)) { - ++v5; - v10 += 120; - a2 = v5; - if ( v5 >= (signed int)v4 ) + default: + case AILFILETYPE_UNKNOWN: + pSound->bDecompressed = false; return 0; - } - v12 = v5; - v13 = &v9[v12]; - if ( v13->uFlags & 2 && v13->p3DSound || !(v13->uFlags & 2) && v13->pSoundData[0] ) - return a2; - sprintfex(pSoundName, "%s", v13); - v14 = &v3->pSounds[v12]; - if ( !v14->pSoundData[0] ) - v3->pSounds[v12].pSoundData[0] = ::LoadSound(pSoundName, (char *)0xFFFFFFFF, v14->uSoundID); - v15 = &v3->pSounds[v12]; - if ( !v15->pSoundData[0] ) - return 0; - if ( a3 ) - v15->uFlags |= 1u; - if ( !pAudioPlayer->b3DSoundInitialized || (v16 = &v3->pSounds[v12], !(v16->uFlags & 2)) || !v16->pSoundData[0] ) - return a2; - v17 = v16->pSoundData[0]; - v18 = *(int *)v17; - v19 = (char *)v17 + 4; - eType = AIL_file_type(v19, v18); - if ( !eType ) - { -LABEL_29: - LOBYTE(v3->pSounds[v12].bDecompressed) = 0; - return 0; - } - v21 = eType - 1; - if ( v21 ) // eType == AILFILETYPE_PCM_WAV - { - if ( v21 == 1 ) // eType != AILFILETYPE_ADPCM_WAV - { - if ( AIL_WAV_info(v19, &v24) && v24.uChannels != 2 ) + + case AILFILETYPE_PCM_WAV: + pSound->p3DSound = pSound->pSoundData[0]; + return uSoundIdx; + + case AILFILETYPE_ADPCM_WAV: + if (AIL_WAV_info((void *)pSoundData->pData, &v24) && v24.uChannels != 2) { - if ( !AIL_decompress_ADPCM(&v24, &v3->pSounds[v12].p3DSound, &a1) ) + if (!AIL_decompress_ADPCM(&v24, &pSound->p3DSound, &a1) ) { - v22 = a2; - v3->pSounds[v12].p3DSound = 0; - LOBYTE(v3->pSounds[v12].bDecompressed) = 1; - v3->_4A9DCD(v22, 0); + pSound->p3DSound = nullptr; + pSound->bDecompressed = true; + _4A9DCD(uSoundIdx, 0); } } - return a2; - } - goto LABEL_29; - } - v3->pSounds[v12].p3DSound = v3->pSounds[v12].pSoundData[0]; - return a2; + return uSoundIdx; + }; } //----- (004A9BBD) -------------------------------------------------------- int SoundList::LoadSound(unsigned int a2, LPVOID lpBuffer, int uBufferSizeLeft, int *pOutSoundSize, int a6) { - SoundList *v6; // edi@1 + //SoundList *v6; // edi@1 signed int v7; // esi@1 - unsigned __int8 v8; // zf@1 - unsigned __int8 v9; // sf@1 + //unsigned __int8 v8; // zf@1 + //unsigned __int8 v9; // sf@1 SoundDesc *v10; // eax@3 SoundDesc *v11; // ecx@3 int v12; // ebx@7 @@ -232,30 +204,27 @@ std::string v19; // [sp-18h] [bp-38h]@22 const char *v20; // [sp-8h] [bp-28h]@22 int v21; // [sp-4h] [bp-24h]@22 - SoundList *v22; // [sp+Ch] [bp-14h]@1 + //SoundList *v22; // [sp+Ch] [bp-14h]@1 SoundDesc *Args; // [sp+10h] [bp-10h]@3 unsigned int v24; // [sp+14h] [bp-Ch]@2 int v25; // [sp+18h] [bp-8h]@2 int v26; // [sp+1Ch] [bp-4h]@1 - v6 = this; + //v6 = this; v7 = 0; - v22 = this; - v8 = this->uNumSounds == 0; - v9 = (this->uNumSounds & 0x80000000u) != 0; + //v22 = this; + //v8 = this->uNumSounds == 0; + //v9 = (this->uNumSounds & 0x80000000u) != 0; v26 = 0; - if ( v9 | v8 ) - { -LABEL_13: - result = 0; - } - else - { + if (!uNumSounds) + return 0; + + v24 = 0; v25 = 44; while ( 1 ) { - v10 = v6->pSounds; + v10 = pSounds; v11 = &v10[v24 / 0x78]; Args = &v10[v24 / 0x78]; if ( a2 == v10[v24 / 0x78].uSoundID ) @@ -269,8 +238,8 @@ ++v26; v25 += 120; v24 += 120; - if ( v26 >= (signed int)v6->uNumSounds ) - goto LABEL_13; + if ( v26 >= (signed int)uNumSounds ) + return 0; } v12 = 0; while ( _strcmpi(pAudioPlayer->pSoundHeaders[v12].pSoundName, v11->pSoundName) ) @@ -312,9 +281,9 @@ v16 = a2; } result = v26; - v22->pSounds->pSoundData[a6 + 30 * v26] = lpBuffer; + pSounds->pSoundData[a6 + 30 * v26] = (SoundData *)lpBuffer; *pOutSoundSize = v16; - } + return result; } @@ -2575,16 +2544,16 @@ // F1B4C8: using guessed type int uFindSound_BinSearch_ResultID; //----- (004A97C6) -------------------------------------------------------- -unsigned int *__fastcall LoadSound(const char *pSoundName, char *pOutBuff, unsigned int uID) +SoundData *LoadSound(const char *pSoundName, SoundData *pOutBuff, unsigned int uID) { - void *v3; // edi@1 + SoundData *v3; // edi@1 int v4; // ecx@1 - Sound *v5; // eax@1 + //Sound *v5; // eax@1 SoundHeader *v6; // esi@5 unsigned int *pDecompressedSize; // ebx@5 unsigned int v8; // eax@5 unsigned int v9; // eax@7 - unsigned int *result; // eax@9 + SoundData *result; // eax@9 int v11; // esi@15 int v12; // eax@15 char *v13; // ecx@16 @@ -2600,15 +2569,10 @@ pSoundName_ = pSoundName; v3 = pOutBuff; v4 = 0; - v5 = pSounds; - do - { - if ( v5->uID == uID ) - return pSounds[v4].pSoundData; - ++v5; - ++v4; - } - while ( (signed int)v5 < (signed int)&pAudioPlayer ); + for (uint i = 0; i < 3000; ++i) + if (pSounds[i].uID == uID) + return pSounds[i].pSoundData; + FindSound_BinSearch(0, pAudioPlayer->uNumSoundHeaders, pSoundName_); if ( uFindSound_BinSearch_ResultID == -1 ) goto LABEL_22; @@ -2616,8 +2580,8 @@ pDecompressedSize = &v6->uDecompressedSize; v8 = v6->uDecompressedSize; v19 = v6->uDecompressedSize; - if ( v3 == (void *)-1 ) - v3 = pAllocator->AllocNamedChunk(0, v8 + 4, pSoundName_); + if ( v3 == (SoundData *)-1 ) + v3 = (SoundData *)pAllocator->AllocNamedChunk(0, v8 + 4, pSoundName_); SetFilePointer(pAudioPlayer->hAudioSnd, v6->uFileOffset, 0, 0); v9 = *pDecompressedSize; if ( (signed int)v6->uCompressedSize >= (signed int)*pDecompressedSize ) @@ -2660,8 +2624,8 @@ strcpy((char *)v16, pSoundName_); v14 = uLastLoadedSoundID++ << 7; pSoundList->uTotalLoadedSoundSize += v11; - *(unsigned int **)((char *)&pSounds[0].pSoundData + v14) = (unsigned int *)v3; - result = (unsigned int *)v3; + pSounds[uLastLoadedSoundID].pSoundData = v3; + result = v3; } else { @@ -2670,5 +2634,3 @@ } return result; } -// F1B4C8: using guessed type int uFindSound_BinSearch_ResultID; -// F1B4D0: using guessed type int uLastLoadedSoundID;
--- a/AudioPlayer.h Tue Oct 16 00:05:53 2012 +0200 +++ b/AudioPlayer.h Tue Oct 16 01:31:05 2012 +0200 @@ -204,13 +204,19 @@ #pragma pack(push, 1) +struct SoundData +{ + unsigned int uDataSize; + char pData[1]; +}; + struct SoundDesc { char pSoundName[32]; unsigned int uSoundID; SOUND_DESC_TYPE eType; int uFlags; - void *pSoundData[17]; + SoundData *pSoundData[17]; void *p3DSound; int bDecompressed; }; @@ -251,7 +257,7 @@ { unsigned int uID; char field_4[120]; - unsigned int *pSoundData; + SoundData *pSoundData; }; #pragma pack(pop)
--- a/DecalBuilder.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/DecalBuilder.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -11,8 +11,8 @@ -struct DecalBuilder *pDecalBuilder; -struct BloodsplatContainer *pBloodsplatContainer; // idb +struct DecalBuilder *pDecalBuilder = new DecalBuilder; +struct BloodsplatContainer *pBloodsplatContainer = new BloodsplatContainer; //----- (0043B570) -------------------------------------------------------- @@ -105,7 +105,7 @@ pBloodsplatContainer->std__vector_pBloodsplats_size = 0; pBloodsplatContainer->uNumBloodsplats = 0; } - this->std__vector_pDecals_size = 0; + std__vector_pDecals_size = 0; } //----- (0049B540) --------------------------------------------------------
--- a/GUIProgressBar.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/GUIProgressBar.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -10,15 +10,15 @@ -struct GUIProgressBar *pGameLoadingUI_ProgressBar; +struct GUIProgressBar *pGameLoadingUI_ProgressBar = new GUIProgressBar; //----- (00443484) -------------------------------------------------------- -bool GUIProgressBar::_443484(int a2) +bool GUIProgressBar::_443484(Type type) { - GUIProgressBar *v2; // esi@1 + //GUIProgressBar *v2; // esi@1 signed int v4; // eax@7 int v5; // ecx@8 int v6; // edi@8 @@ -27,18 +27,25 @@ unsigned int v9; // [sp-4h] [bp-80h]@20 char Str1[64]; // [sp+4h] [bp-78h]@16 - v2 = this; + if (type < 1 || type > 1) + { + __debugbreak(); + return false; + } + + //v2 = this; if (pAsyncMouse) pAsyncMouse->Suspend(); - if ( v2->pLoadingBg.pPixels ) - return 0; - if ( a2 ) - v2->uType = a2; + if (pLoadingBg.pPixels) + return false; + + uType = type; + v4 = 1; - if ( v2->uType == 1 ) + if (uType == TYPE_Fullscreen) { v5 = 0; - v6 = (int)&v2->field_10; + v6 = (int)&field_10; do { if ( *(char *)(v6 + v4) == 1 ) @@ -47,25 +54,25 @@ } while ( v4 <= 5 ); if ( v5 == 5 ) - memset(&v2->field_10, 0, 8u); + memset(&field_10, 0, 8u); v7 = rand() % 5 + 1; - if ( *(&v2->field_10 + v7) == 1 ) + if ( *(&field_10 + v7) == 1 ) { do v7 = rand() % 5 + 1; while ( *(char *)(v6 + v7) == 1 ); } - sprintfex(Str1, "loading%d.pcx", v7); - v2->pLoadingBg.Load(Str1, 2); - v2->uProgressCurrent = 0; - v2->uX = 122; - v2->uY = 151; - v2->uWidth = 449; - v2->uHeight = 56; - v2->uProgressMax = 26; - pIcons_LOD->_410522(&v2->pLoadingProgress, "loadprog", 2u); + sprintf(Str1, "loading%d.pcx", v7); + pLoadingBg.Load(Str1, 2); + uProgressCurrent = 0; + uX = 122; + uY = 151; + uWidth = 449; + uHeight = 56; + uProgressMax = 26; + pIcons_LOD->_410522(&pLoadingProgress, "loadprog", 2u); Draw(); - return 1; + return true; } if ( !pParty->uAlignment ) { @@ -84,12 +91,12 @@ v9 = 2; v8 = "bardata-c"; LABEL_23: - pIcons_LOD->_410522(&v2->pBardata, v8, v9); + pIcons_LOD->_410522(&pBardata, v8, v9); } - v2->uProgressCurrent = 0; - v2->uProgressMax = 26; + uProgressCurrent = 0; + uProgressMax = 26; Draw(); - return 1; + return true; } //----- (004435BB) -------------------------------------------------------- @@ -154,26 +161,24 @@ //----- (00443670) -------------------------------------------------------- void GUIProgressBar::Draw() { - GUIProgressBar *v1; // edi@1 - Render *v2; // ecx@2 IconFrame *v3; // eax@10 float v4; // ST2C_4@10 - v1 = this; + //v1 = this; pRenderer->BeginScene(); - if ( v1->uType != 1 ) + if (uType != TYPE_Fullscreen) { - if ( v1->pBardata.pLevelOfDetail0 ) + if (pBardata.pLevelOfDetail0) { - if ( pRenderer->pRenderD3D ) + if (pRenderer->pRenderD3D) { - if ( !pRenderer->bWindowMode ) - pRenderer->_49FD3A((int)v1); + if (!pRenderer->bWindowMode) + pRenderer->_49FD3A(); } - pRenderer->DrawTextureIndexed(0x50u, 0x7Au, &v1->pBardata); + pRenderer->DrawTextureIndexed(0x50u, 0x7Au, &pBardata); v3 = pIconsFrameTable->GetFrame(uIconID_TurnHour, 0); pRenderer->DrawTextureTransparent(0x64u, 0x92u, &pIcons_LOD->pTextures[v3->uTextureID]); - v4 = (double)(113 * v1->uProgressCurrent) / (double)v1->uProgressMax; + v4 = (double)(113 * uProgressCurrent) / (double)uProgressMax; pRenderer->FillRect2( 0, 174, @@ -183,22 +188,20 @@ LOWORD(pRenderer->uTargetRMask)); goto LABEL_11; } - v2 = pRenderer; LABEL_6: pRenderer->EndScene(); return; } - v2 = pRenderer; - if ( !v1->pLoadingBg.pPixels ) + + if (!pLoadingBg.pPixels) goto LABEL_6; - pRenderer->DrawTextureRGB(0, 0, &v1->pLoadingBg); + + pRenderer->DrawTextureRGB(0, 0, &pLoadingBg); pRenderer->Clip_v2(0, 0, 0x27Fu, 0x1DFu); - pRenderer->Clip( - 0xACu, - 0x1CBu, - 15 * (signed int)(signed __int64)((double)(300 * v1->uProgressCurrent) / (double)v1->uProgressMax) / 15 + 172, + pRenderer->Clip(0xACu, 0x1CBu, + 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172, 0x1D7u); - pRenderer->DrawTextureTransparent(0xACu, 0x1CBu, &v1->pLoadingProgress); + pRenderer->DrawTextureTransparent(0xACu, 0x1CBu, &pLoadingProgress); pRenderer->ResetClip(); LABEL_11: pRenderer->EndScene();
--- a/GUIProgressBar.h Tue Oct 16 00:05:53 2012 +0200 +++ b/GUIProgressBar.h Tue Oct 16 01:31:05 2012 +0200 @@ -6,7 +6,12 @@ #pragma pack(push, 1) struct GUIProgressBar { - bool _443484(int a2); + enum Type: unsigned __int32 + { + TYPE_Fullscreen = 1 + }; + + bool _443484(Type type); void Reset(unsigned __int8 uMaxProgress); void Progress(); void Release(); @@ -20,7 +25,7 @@ char field_9; char uProgressMax; char uProgressCurrent; - int uType; + Type uType; char field_10; char field_11; char field_12;
--- a/Game.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/Game.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -198,8 +198,8 @@ { //signed int v0; // ebp@3 //signed int v1; // esi@4 - Render *v2; // edi@7 - signed int v3; // esi@7 + //Render *v2; // edi@7 + //signed int v3; // esi@7 signed int v4; // ecx@58 char *v5; // eax@59 Player *v6; // esi@65 @@ -236,21 +236,21 @@ LoadPlayerPortraintsAndVoices(); pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles; - pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0)); - v2 = pRenderer; - v3 = 1; + pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0); + while ( 2 ) { - v16 = v3; - if ( pMessageQueue_50CBD0->uNumMessages ) + v16 = 1; + if (pMessageQueue_50CBD0->uNumMessages) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pPartyActionQueue->uNumActions = 0; - if ( pParty->bTurnBasedModeOn == v3 ) + if (pParty->bTurnBasedModeOn) { - pTurnEngine->End(0); - pParty->bTurnBasedModeOn = 0; + pTurnEngine->End(false); + pParty->bTurnBasedModeOn = false; } - DoPrepareWorld(bLoading, v3); + DoPrepareWorld(bLoading, 1); pEventTimer->Resume(); dword_6BE364_game_settings_1 |= 0x80; dword_6BE340 = 2; @@ -264,7 +264,7 @@ bLoadinga = 0; do { - while ( PeekMessageA(&Msg, 0, 0, 0, v3) ) + while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) ) { if ( Msg.message == WM_QUIT ) Game_DeinitializeAndTerminate(0); @@ -284,26 +284,26 @@ { ArcomageGame::Loop(); LABEL_89: - v2->Present(); + pRenderer->Present(); continue; } if (pAsyncMouse) - pAsyncMouse->_46B736_consume_click_lists(v3); + pAsyncMouse->_46B736_consume_click_lists(1); if ( pVideoPlayer->pSmackerMovie && !SmackWait(pVideoPlayer->pSmackerMovie) ) { - v2->BeginScene(); + pRenderer->BeginScene(); pMouse->_469E3B(); pVideoPlayer->SmackUpdatePalette(pVideoPlayer->hWindow); pMouse->_469EA4(); - v2->EndScene(); + pRenderer->EndScene(); } if ( pVideoPlayer->pBinkMovie && !BinkWait(pVideoPlayer->pBinkMovie) ) { - v2->BeginScene(); + pRenderer->BeginScene(); pMouse->_469E3B(); pVideoPlayer->BinkUpdatePalette(pVideoPlayer->hWindow); pMouse->_469EA4(); - v2->EndScene(); + pRenderer->EndScene(); } pEventTimer->Update(); pMiscTimer->Update(); @@ -330,12 +330,12 @@ if ( v16 ) { v16 = 0; - viewparams->bRedrawGameUI = v3; + viewparams->bRedrawGameUI = true; } pAudioPlayer->_4AAFCF(); - if ( uGameState == v3 ) + if (uGameState == 1) goto LABEL_96; - if ( uGameState == 2 ) + if (uGameState == 2) { pAudioPlayer->StopChannels(-1, -1); PrepareWorld(0); @@ -347,7 +347,7 @@ if ( (signed int)uGameState <= 5 || uGameState == 7 ) { LABEL_96: - bLoadinga = v3; + bLoadinga = 1; continue; } if ( uGameState != 8 ) @@ -470,7 +470,6 @@ } ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2u);// "Once again you've cheated death!.." uGameState = 0; - v3 = 1; } while ( !bLoadinga ); dword_6BE340 = 0; @@ -482,7 +481,7 @@ LoadPlayerPortraintsAndVoices(); uGameState = 0; pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles; - bLoading = v3; + bLoading = true; continue; } break;
--- a/Outdoor.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/Outdoor.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -274,10 +274,6 @@ } return result; } -// 6BE030: using guessed type int day_attrib; -// 6BE040: using guessed type int day_fogrange_1; -// 6BE044: using guessed type int day_fogrange_2; -// 6BE134: using guessed type int _6BE134_odm_main_tile_group; //----- (0048901B) -------------------------------------------------------- bool OutdoorLocation::Release2()
--- a/Party.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/Party.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -21,7 +21,7 @@ Party *pParty; // idb -struct ActionQueue *pPartyActionQueue; +struct ActionQueue *pPartyActionQueue = new ActionQueue;
--- a/Render.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/Render.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -5523,7 +5523,7 @@ } //----- (0049FD3A) -------------------------------------------------------- -void Render::_49FD3A(int a2) +void Render::_49FD3A() { Render *v2; // esi@1 IDirectDrawSurface4 *v3; // eax@6 @@ -5534,9 +5534,9 @@ v2 = a1; if ( a1->pRenderD3D ) { - if (pFrontBuffer4->IsLost() == -2005532222 ) + if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) pFrontBuffer4->Restore(); - if (pBackBuffer4->IsLost() == -2005532222 ) + if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) pBackBuffer4->Restore(); v3 = v2->pBackBuffer4; v4 = v2->pFrontBuffer4;
--- a/Render.h Tue Oct 16 00:05:53 2012 +0200 +++ b/Render.h Tue Oct 16 01:31:05 2012 +0200 @@ -258,7 +258,7 @@ void ClearTarget(unsigned int uColor); void Release2(); void Present(); - void _49FD3A(int a2); + void _49FD3A(); void CreateZBuffer(); void Release(); void CreateSomeTexture();
--- a/SaveLoad.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/SaveLoad.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -251,8 +251,8 @@ if (uTurnSpeed) pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed; MM7Initialization(); - bFlashQuestBook = 0; - viewparams->bRedrawGameUI = 1; + bFlashQuestBook = false; + viewparams->bRedrawGameUI = true; }
--- a/TurnEngine.h Tue Oct 16 00:05:53 2012 +0200 +++ b/TurnEngine.h Tue Oct 16 01:31:05 2012 +0200 @@ -20,7 +20,7 @@ signed int _404544(); int _40471C(); signed int Start(); - void End(unsigned int bPlaySound); + void End(bool bPlaySound); void _405E14(); __int16 StartTurn(); void NextTurn();
--- a/mm7_2.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/mm7_2.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -11717,8 +11717,6 @@ fclose(v1); } } -// 6A0D0C: using guessed type int 6A0D0C_txt_lod_loading; -// 6A0D10: using guessed type int 6A0D10_txt_lod_loading__unused; //----- (0046080D) -------------------------------------------------------- void __cdecl sub_46080D() @@ -11727,7 +11725,6 @@ ptr_6A0D08 = 0; _6A0D0C_txt_lod_loading = 0; } -// 6A0D0C: using guessed type int 6A0D0C_txt_lod_loading; //----- (0046082C) -------------------------------------------------------- bool Initialize_GamesLOD_NewLOD() @@ -13343,28 +13340,27 @@ { int v0; // esi@9 - if ( pMouse ) + if (pMouse) pMouse->SetCursorBitmap("MICON1"); + pPaletteManager->ResetNonLocked(); pBitmaps_LOD->ReleaseAll2(); pSprites_LOD->DeleteSomeOtherSprites(); pIcons_LOD->ReleaseAll2(); - if ( pRenderer->pRenderD3D ) + if (pRenderer->pRenderD3D) { pRenderer->field_1036B8 = 0; pRenderer->_gpu_memory_used = 0; } sub_46080D(); - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) pIndoor->Release(); - } - else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - pOutdoor->Release2(); + else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + pOutdoor->Release2(); pAudioPlayer->StopChannels(-1, -1); pSoundList->_4A9D79(0); - uCurrentlyLoadedLevelType = (LEVEL_TYPE)0; + uCurrentlyLoadedLevelType = LEVEL_null; pSpriteFrameTable->ResetSomeSpriteFlags(); v0 = uNumVisibleWindows; pParty->field_1613C = 0; @@ -13441,8 +13437,8 @@ day_fogrange_1 = 50; day_fogrange_2 = 5000; } -// 6BE040: using guessed type int day_fogrange_1; -// 6BE044: using guessed type int day_fogrange_2; + + //----- (00464866) -------------------------------------------------------- void __fastcall DoPrepareWorld(unsigned int bLoading, int a2) @@ -13460,7 +13456,7 @@ v9 = bLoading; ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); pDecalBuilder->Reset(0); - pGameLoadingUI_ProgressBar->_443484(v2); + pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)v2); strcpy(Str1, pCurrentMapName); v3 = strtok(Str1, "."); strcpy(Str1, v3);
--- a/mm7_3.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/mm7_3.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -18170,7 +18170,7 @@ { uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = v128; if ( v128 == 3 ) - pGameLoadingUI_ProgressBar->uType = 1; + pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; if ( v128 == 13 ) pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u); } @@ -18997,7 +18997,7 @@ if ( v10->f[29] || v10->f[30] ) { if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode ) - pRenderer->_49FD3A(v9); + pRenderer->_49FD3A(); sub_444839_move_map( (unsigned __int8)pSomeEVT[v9 + 29], (unsigned __int8)pSomeEVT[v9 + 30], @@ -19062,7 +19062,7 @@ } else { - pGameLoadingUI_ProgressBar->uType = (_5C3420_pDecoration == 0) + 1; + pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((_5C3420_pDecoration == 0) + 1); sub_44987B(v99, 0); v133 = 1; if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 13 ) @@ -19115,7 +19115,7 @@ if ( EnterHouse((enum HOUSE_TYPE)(v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8))) ) { if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode ) - pRenderer->_49FD3A(v103); + pRenderer->_49FD3A(); pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0); pAudioPlayer->PlaySound(SOUND_EnteringAHouse, 814, 0, -1, 0, 0, 0, 0); v104 = 187; @@ -20270,7 +20270,7 @@ v2 = pMapName; v3 = uStartingPointType; pAudioPlayer->StopChannels(-1, -1); - pGameLoadingUI_ProgressBar->_443484(0); + pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)0); if ( _strcmpi(pCurrentMapName, v2) ) SaveGame(1, 0); uGameState = 2; @@ -20580,21 +20580,14 @@ _5B65B8_npcdata_hiword_house_or_other = 0; dword_5B65BC = 0; dword_5B65C0 = 0; - pGameLoadingUI_ProgressBar->uType = 1; + pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; sub_44987B("nwc.blv", 0); uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; result = 1; } return result; } -// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions; -// 5B65A8: using guessed type int _5B65A8_npcdata_uflags_or_other; -// 5B65AC: using guessed type int _5B65AC_npcdata_fame_or_other; -// 5B65B0: using guessed type int _5B65B0_npcdata_rep_or_other; -// 5B65B4: using guessed type int _5B65B4_npcdata_loword_house_or_other; -// 5B65B8: using guessed type int _5B65B8_npcdata_hiword_house_or_other; -// 5B65BC: using guessed type int dword_5B65BC; -// 5B65C0: using guessed type int dword_5B65C0; + //----- (0044C2F4) -------------------------------------------------------- int LevelDecoration::IsInteractive()
--- a/mm7_4.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/mm7_4.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -2910,52 +2910,38 @@ //----- (00491CB5) -------------------------------------------------------- void __cdecl LoadPlayerPortraintsAndVoices() { - Texture **v0; // ebx@1 - int v1; // eax@2 - int v2; // edi@3 + //Texture **v0; // ebx@1 + //int v1; // eax@2 + //int v2; // edi@3 char *v3; // esi@5 char *v4; // [sp+10h] [bp-4h]@1 pIcons_LOD->dword_011BA0 = pIcons_LOD->uNumLoadedFiles; - v0 = (Texture **)pTextures_PlayerFaces; - v4 = (char *)&pParty->pPlayers[0].uFace; - do - { - v1 = 0; - do - { - v2 = v1 + 1; - sprintfex(pTmpBuf, "%s%02d", pPlayerPortraitsNames[*v4], v1 + 1); - *v0 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)]; - v1 = v2; - ++v0; - } - while ( v2 < 56 ); - v4 += 6972; - } - while ( (signed int)v4 < (signed int)((char *)&pParty->pPickedItem.uExpireTime + 6) ); - pTexture_PlayerFaceEradicated = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ERADCATE", TEXTURE_16BIT_PALETTE)]; - pTexture_PlayerFaceDead = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("DEAD", TEXTURE_16BIT_PALETTE)]; - v3 = (char *)&pParty->pPlayers[0].uVoiceID; - pTexture_PlayerFaceMask = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("FACEMASK", TEXTURE_16BIT_PALETTE)]; - do - { - if ( byte_4ED498 ) - { - pSoundList->_4A9A67(2 * ((unsigned __int8)byte_4ED498 + 50 * *(int *)v3) + 4998, 0); - pSoundList->_4A9A67(2 * ((unsigned __int8)byte_4ED498 + 50 * *(int *)v3) + 4999, 0); - } - v3 += 6972; - } - while ( (signed int)v3 < (signed int)&pParty->field_871C[560] ); -} -// 4ED498: using guessed type char byte_4ED498; + + for (uint i = 0; i < 4; ++i) + for (uint j = 0; j < 56; ++j) + { + sprintf(pTmpBuf, "%s%02d", pPlayerPortraitsNames[pParty->pPlayers[i].uFace], j + 1); + pTextures_PlayerFaces[i][j] = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE); + } + + pTexture_PlayerFaceEradicated = pIcons_LOD->LoadTexturePtr("ERADCATE", TEXTURE_16BIT_PALETTE); + pTexture_PlayerFaceDead = pIcons_LOD->LoadTexturePtr("DEAD", TEXTURE_16BIT_PALETTE); + pTexture_PlayerFaceMask = pIcons_LOD->LoadTexturePtr("FACEMASK", TEXTURE_16BIT_PALETTE); + + if (byte_4ED498) + for (uint i = 0; i < 4; ++i) + { + pSoundList->_4A9A67(2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4998, 0); + pSoundList->_4A9A67(2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4999, 0); + } +} //----- (00491DE7) -------------------------------------------------------- int __fastcall ReloadPlayerPortraits(int a1, int a2) { int result; // eax@1 - char **v3; // ebp@1 + const char **v3; // ebp@1 Texture **v4; // ebx@1 int v5; // esi@2 @@ -2973,7 +2959,7 @@ while ( v5 < 56 ); return result; } -// 491DE7: using guessed type int __fastcall ReloadPlayerPortraits(int, int); + //----- (00491E3A) -------------------------------------------------------- void __cdecl sub_491E3A() @@ -15031,7 +15017,7 @@ //----- (00405CFF) -------------------------------------------------------- -void stru262_TurnBased::End(unsigned int bPlaySound) +void stru262_TurnBased::End(bool bPlaySound) { stru262_TurnBased *v2; // edi@1 int v3; // ebx@1
--- a/mm7_5.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/mm7_5.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -1766,7 +1766,7 @@ } if ( *dword_591164_teleport_map_name != 48 ) { - pGameLoadingUI_ProgressBar->uType = 2; + pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)2; dword_5B65C0 = _5B65A8_npcdata_uflags_or_other | _5B65AC_npcdata_fame_or_other | _5B65B0_npcdata_rep_or_other | _5B65B4_npcdata_loword_house_or_other | _5B65B8_npcdata_hiword_house_or_other | v38; OnMapLeave(); sub_44987B(dword_591164_teleport_map_name, 0); @@ -1823,7 +1823,7 @@ pStru277->_427D48(v0); sub_44603D(); pEventTimer->Pause(); - pGameLoadingUI_ProgressBar->_443484(2); + pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)2); ++pGameLoadingUI_ProgressBar->uProgressMax; SaveGame(v0, 0); pGameLoadingUI_ProgressBar->Progress();
--- a/mm7_data.cpp Tue Oct 16 00:05:53 2012 +0200 +++ b/mm7_data.cpp Tue Oct 16 01:31:05 2012 +0200 @@ -30,7 +30,7 @@ struct MapStats *pMapStats; #include "TurnEngine.h" -struct stru262_TurnBased *pTurnEngine; +struct stru262_TurnBased *pTurnEngine = new stru262_TurnBased; #include "stru277.h" stru277 pStru277[10]; @@ -1925,7 +1925,15 @@ char aLun12[777]; // idb char aLun14[777]; // idb char aPal03i[777]; // idb -char *pPlayerPortraitsNames[25]; +const char *pPlayerPortraitsNames[25] = +{ + "pc01-", "pc02", "pc03", "pc04", "pc05-", + "pc06", "pc07", "pc08", "pc09-", "pc10", + "pc11-", "pc12", "pc13", "pc14", "pc15", + "pc16", "pc17-", "pc18", "pc19", "pc20", + "pc21-", "pc22-", "pc23", "pc24-", "pc25-" +}; + const char *dlad_texnames_by_face[25]; const char *dlau_texnames_by_face[25]; const char *dbod_texnames_by_face[25];
--- a/mm7_data.h Tue Oct 16 00:05:53 2012 +0200 +++ b/mm7_data.h Tue Oct 16 01:31:05 2012 +0200 @@ -1913,7 +1913,7 @@ extern char aLun12[]; // idb extern char aLun14[]; // idb extern char aPal03i[]; // idb -extern char *pPlayerPortraitsNames[25]; +extern const char *pPlayerPortraitsNames[25]; extern const char *dlad_texnames_by_face[25]; extern const char *dlau_texnames_by_face[25]; extern const char *dbod_texnames_by_face[25]; @@ -3426,7 +3426,7 @@ void __cdecl Present_NoColorKey(); int __thiscall sub_4A7063(unsigned int uDiffuse, float a2); // idb struct SoundHeader *__fastcall FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName); -unsigned int *__fastcall LoadSound(const char *pSoundName, char *pOutBuff, unsigned int uID); +struct SoundData *LoadSound(const char *pSoundName, struct SoundData *pOutBuff, unsigned int uID); int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1); int __fastcall sub_4AB66C(int, int); // weak int __fastcall GetSoundStrengthByDistanceFromParty(int a1, int a2, int a3);