Mercurial > mm7
changeset 2446:063d194e0881
Слияние
author | Ritor1 |
---|---|
date | Thu, 24 Jul 2014 12:44:32 +0600 |
parents | b10125a9c772 (diff) c59a8fddb5e8 (current diff) |
children | 45dcf81c5b1c |
files | |
diffstat | 18 files changed, 245 insertions(+), 327 deletions(-) [+] |
line wrap: on
line diff
--- a/CShow.h Wed Jul 23 17:36:56 2014 +0600 +++ b/CShow.h Thu Jul 24 12:44:32 2014 +0600 @@ -23,13 +23,13 @@ switch (movie) { - case MOVIE_3DOLogo: pVideoPlayer->MovieLoop("3dologo", 0, 0, 1); break; - case MOVIE_NWCLogo: pVideoPlayer->MovieLoop("new world logo", 0, 1, 1); break; - case MOVIE_JVC: pVideoPlayer->MovieLoop("jvc", 0, 1, 1); break; - case MOVIE_Intro: pVideoPlayer->MovieLoop("Intro", 0, 1, 1); break; - case MOVIE_Emerald: pVideoPlayer->MovieLoop("Intro Post", 0, 1, 1); break; - case MOVIE_Death: pVideoPlayer->MovieLoop("losegame", 2, 1, 1); break; - case MOVIE_Outro: pVideoPlayer->MovieLoop("end_seq1", 20, 1, 1); break; + case MOVIE_3DOLogo: pVideoPlayer->MovieLoop("3dologo", 0); break; + case MOVIE_NWCLogo: pVideoPlayer->MovieLoop("new world logo", 0); break; + case MOVIE_JVC: pVideoPlayer->MovieLoop("jvc", 0); break; + case MOVIE_Intro: pVideoPlayer->MovieLoop("Intro", 0); break; + case MOVIE_Emerald: pVideoPlayer->MovieLoop("Intro Post", 0); break; + case MOVIE_Death: pVideoPlayer->MovieLoop("losegame", 2); break; + case MOVIE_Outro: pVideoPlayer->MovieLoop("end_seq1", 20); break; default: Error("Invalid movie requested: %u", movie);
--- a/Events.cpp Wed Jul 23 17:36:56 2014 +0600 +++ b/Events.cpp Thu Jul 24 12:44:32 2014 +0600 @@ -465,7 +465,7 @@ v128 = pCurrentScreen; strcpy(Str, Source); v16 = RemoveQuotes(Str); - pVideoPlayer->MovieLoop(v16, 0, _evt->v5, 1); + pVideoPlayer->MovieLoop(v16, 0/*, _evt->v5*/); if ( !_stricmp(v16, "arbiter good") ) { pParty->alignment = PartyAlignment_Good;
--- a/GUIProgressBar.cpp Wed Jul 23 17:36:56 2014 +0600 +++ b/GUIProgressBar.cpp Thu Jul 24 12:44:32 2014 +0600 @@ -27,7 +27,7 @@ //GUIProgressBar *v2; // esi@1 signed int v4; // eax@7 int v5; // ecx@8 - int v6; // edi@8 + //int v6; // edi@8 int v7; // edx@14 //const char *v8; // [sp-8h] [bp-84h]@20 //unsigned int v9; // [sp-4h] [bp-80h]@20 @@ -56,22 +56,22 @@ if (uType == TYPE_Fullscreen) { v5 = 0; - v6 = (int)&field_10; + //v6 = (int)&field_10; do { - if ( *(char *)(v6 + v4) == 1 ) //Uninitialized memory access (v6) + if ( field_10[v4] == 1 ) ++v5; ++v4; } while ( v4 <= 5 ); if ( v5 == 5 ) - memset(&field_10, 0, 8); + memset(field_10, 0, 8); v7 = rand() % 5 + 1; - if ( *(&field_10 + v7) == 1 ) + if ( field_10[v7] == 1 ) { do v7 = rand() % 5 + 1; - while ( *(char *)(v6 + v7) == 1 ); + while ( field_10[v7] == 1 ); } sprintf(Str1, "loading%d.pcx", v7); pLoadingBg.Load(Str1, 2); @@ -86,25 +86,6 @@ return true; } - /*if ( !pParty->uAlignment ) - { - v9 = 2; - v8 = "bardata-b"; - goto LABEL_23; - } - if ( pParty->uAlignment == 1 ) - { - v9 = 2; - v8 = "bardata"; - goto LABEL_23; - } - if ( pParty->uAlignment == 2 ) - { - v9 = 2; - v8 = "bardata-c"; -LABEL_23: - pIcons_LOD->_410522(&pBardata, v8, v9); - }*/ switch (pParty->alignment) { case PartyAlignment_Good: pIcons_LOD->_410522(&pBardata, "bardata-b", 2); break; @@ -141,21 +122,18 @@ { int v3; // edi@7 + pLoadingBg.Release(); if ( this->uType == 1 ) { - if ( !this->pLoadingBg.pPixels ) - return; if ( this->uProgressCurrent != this->uProgressMax ) { this->uProgressCurrent = this->uProgressMax - 1; Progress(); } - free(this->pLoadingBg.pPixels); v3 = (int)&this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask; free(this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask); free(this->pLoadingProgress.pPalette16); this->pLoadingProgress.pPalette16 = 0; - this->pLoadingBg.pPixels = 0; } else {
--- a/GUIProgressBar.h Wed Jul 23 17:36:56 2014 +0600 +++ b/GUIProgressBar.h Thu Jul 24 12:44:32 2014 +0600 @@ -28,14 +28,14 @@ char uProgressMax; char uProgressCurrent; Type uType; - char field_10; - char field_11; - char field_12; - char field_13; - char field_14; - char field_15; - char field_16; - char field_17; + char field_10[8]; + //char field_11; + //char field_12; + //char field_13; + //char field_14; + //char field_15; + //char field_16; + //char field_17; RGBTexture pLoadingBg; RGBTexture field_40; RGBTexture field_68;
--- a/GUIWindow.cpp Wed Jul 23 17:36:56 2014 +0600 +++ b/GUIWindow.cpp Thu Jul 24 12:44:32 2014 +0600 @@ -112,18 +112,17 @@ //----- (0041B4E1) -------------------------------------------------------- int __fastcall GUI_ReplaceHotkey(unsigned __int8 uOldHotkey, unsigned __int8 uNewHotkey, char bFirstCall) { - unsigned __int8 v3; // bl@1 int result; // eax@1 int i; // edx@2 GUIButton *j; // ecx@3 int k; // edx@7 GUIButton *l; // ecx@8 unsigned __int8 v9; // [sp+4h] [bp-8h]@1 - char v10; // [sp+8h] [bp-4h]@1 + char old_hot_key; // [sp+8h] [bp-4h]@1 - v3 = uNewHotkey; - v10 = toupper(uOldHotkey); - result = toupper(v3); + //v3 = uNewHotkey; + old_hot_key = toupper(uOldHotkey); + result = toupper(uNewHotkey); v9 = result; if ( bFirstCall ) { @@ -139,8 +138,8 @@ result = 84 * pVisibleWindowsIdxs[k]; for ( l = pWindowList[pVisibleWindowsIdxs[k] - 1].pControlsHead; l; l = l->pNext ) { - LOBYTE(result) = v10; - if ( l->uHotkey == v10 ) + LOBYTE(result) = old_hot_key; + if ( l->uHotkey == old_hot_key ) { if ( !l->field_28 ) { @@ -157,28 +156,24 @@ //----- (0041B438) -------------------------------------------------------- GUIButton *__fastcall GUI_HandleHotkey(unsigned __int8 uHotkey) { - char v1; // al@1 - int v2; // esi@1 - char v3; // dl@1 - GUIWindow *v4; // ecx@2 + char Hot_key_num; // al@1 + GUIWindow *current_window; // ecx@2 GUIButton *result; // eax@2 - //int v6; // edx@12 - v1 = toupper(uHotkey); - v2 = uNumVisibleWindows; - v3 = v1; - for( v2 = uNumVisibleWindows; v2 >= 0 && pVisibleWindowsIdxs[v2] > 0; v2-- ) + Hot_key_num = toupper(uHotkey); + for( int i = uNumVisibleWindows; i >= 0 && pVisibleWindowsIdxs[i] > 0; i-- ) { - v4 = &pWindowList[pVisibleWindowsIdxs[v2] - 1]; - for ( result = v4->pControlsHead; result; result = result->pNext ) + current_window = &pWindowList[pVisibleWindowsIdxs[i] - 1]; + for ( result = current_window->pControlsHead; result; result = result->pNext ) { - if ( result->uHotkey == v3 ) + if ( result->uHotkey == Hot_key_num ) { pMessageQueue_50CBD0->AddGUIMessage(result->msg, result->msg_param, 0); return result; } } - if ( !v4->uFrameX && !v4->uFrameY && (v4->uFrameWidth == window->GetWidth() && v4->uFrameHeight == window->GetWidth()) ) + if ( !current_window->uFrameX && !current_window->uFrameY + && (current_window->uFrameWidth == window->GetWidth() && current_window->uFrameHeight == window->GetWidth()) ) break; } return 0; @@ -294,7 +289,7 @@ } case WINDOW_Transition: { - pVideoPlayer->Unload(); + //pVideoPlayer->Unload(); pTexture_outside->Release(); pTexture_Dialogue_Background->Release(); pIcons_LOD->SyncLoadedFilesCount();
--- a/Game.cpp Wed Jul 23 17:36:56 2014 +0600 +++ b/Game.cpp Thu Jul 24 12:44:32 2014 +0600 @@ -709,6 +709,7 @@ pGames_LOD->FreeSubIndexAndIO(); ClipCursor(0); Game::Destroy(); + delete pEventTimer; } //----- (0044EE7C) -------------------------------------------------------- @@ -1088,50 +1089,24 @@ //----- (004304E7) -------------------------------------------------------- void GameUI_MsgProc() { - //signed int v0; // edi@6 - //char *v1; // esi@6 unsigned int v2; // edx@7 Actor *pActor; // ecx@13 int v4; // ecx@18 - //NPCData *pNPCData0; // eax@18 - //int v6; // edx@20 - //int v7; // ecx@29 - //unsigned int v8; // edx@59 - //unsigned int v9; // ecx@60 unsigned int v10; // ecx@73 - //unsigned int v11; // eax@75 - unsigned __int8 v12; // sf@75 - unsigned __int8 v13; // of@75 int v14; // eax@98 - unsigned int v15; // eax@102 - unsigned __int8 v16; // al@104 - unsigned __int8 v17; // al@105 int v18; // eax@106 float v19; // ST64_4@121 -// unsigned int v20; // ecx@121 float v21; // ST64_4@126 float v22; // ST64_4@127 -// unsigned int v23; // ecx@135 unsigned int v24; // ecx@149 -// unsigned int v25; // ecx@165 -// GUIWindow *pWindow; // eax@204 -// unsigned int v27; // edx@204 -// unsigned int v28; // ecx@204 GUIWindow *pWindow2; // ecx@248 - //int v30; // edx@258 - //const char *v31; // ecx@262 - signed int v32; // eax@269 + bool pKeyBindingFlag; // eax@269 unsigned int v33; // eax@277 - unsigned __int8 v34; // al@279 - unsigned __int8 v35; // al@280 - //GUIWindow *pWindow3; // ecx@332 int v37; // eax@341 int v38; // eax@358 SHORT v39; // ax@365 - //signed int v40; // eax@365 char *v41; // eax@380 int v42; // eax@396 -// POINT *pPoint; // eax@397 signed int v44; // eax@398 int v45; // edx@398 signed int v46; // ecx@398 @@ -1140,7 +1115,6 @@ BLVFace *pBLVFace; // ecx@410 ODMFace *pODMFace; // ecx@412 CastSpellInfo *pSpellInfo; // ecx@415 -// void *v52; // eax@424 __int16 v53; // ax@431 int v54; // eax@432 int v55; // ecx@432 @@ -1149,8 +1123,6 @@ Player *pPlayer; // edx@442 unsigned int pMapNum; // eax@445 signed int v60; // ST64_4@459 - //NPCData *pNPCData2; // eax@467 - //unsigned __int64 v62; // kr00_8@467 __int16 v63; // dx@479 unsigned int v64; // eax@486 int v65; // ecx@486 @@ -1167,30 +1139,21 @@ int v76; // esi@535 int v77; // eax@537 Player *pPlayer2; // ecx@549 - //int v79; // ecx@550 - //unsigned int v80; // edx@550 signed int v81; // eax@552 -// POINT *pPoint2; // eax@553 signed int v83; // ecx@554 signed int v84; // ecx@554 GUIButton *pButton; // eax@578 unsigned int v86; // eax@583 const char *v87; // ecx@595 const char *v88; // ecx@596 - //unsigned int v89; // eax@598 unsigned int v90; // eax@602 int v91; // edx@605 int v92; // eax@605 int v93; // edx@605 int pPlayerNum; // edx@611 int v95; // eax@611 - //const char *v96; // ecx@621 unsigned int v97; // eax@624 int v98; // eax@636 -// unsigned __int8 v99; // al@643 -// Player *pPlayer3; // eax@648 -// int v101; // ecx@648 -// int v102; // edx@652 int v103; // eax@671 Player *pPlayer4; // ecx@718 int v105; // eax@718 @@ -1199,71 +1162,20 @@ unsigned int v108; // eax@758 unsigned int v115; // eax@764 int v116; // eax@776 -// POINT *pPoint3; // eax@777 unsigned int v118; // eax@785 unsigned int v119; // ecx@786 -// unsigned int v120; // [sp-28h] [bp-624h]@86 unsigned int v121; // [sp-28h] [bp-624h]@711 -// unsigned int v122; // [sp-24h] [bp-620h]@86 unsigned int v123; // [sp-24h] [bp-620h]@711 -// unsigned int v124; // [sp-20h] [bp-61Ch]@86 unsigned int v125; // [sp-20h] [bp-61Ch]@711 -// unsigned int v126; // [sp-1Ch] [bp-618h]@86 int v127; // [sp-1Ch] [bp-618h]@107 unsigned int v128; // [sp-1Ch] [bp-618h]@711 -// int v129; // [sp-18h] [bp-614h]@86 - //signed int v130; // [sp-18h] [bp-614h]@107 -// int v131; // [sp-14h] [bp-610h]@86 - //unsigned int v132; // [sp-14h] [bp-610h]@107 - //unsigned int v133; // [sp-10h] [bp-60Ch]@60 -// unsigned int v134; // [sp-10h] [bp-60Ch]@86 - //signed int v135; // [sp-10h] [bp-60Ch]@107 -// unsigned int v136; // [sp-10h] [bp-60Ch]@121 - //unsigned int v137; // [sp-Ch] [bp-608h]@60 -// unsigned int v138; // [sp-Ch] [bp-608h]@86 - //signed int v139; // [sp-Ch] [bp-608h]@107 -// unsigned int v140; // [sp-Ch] [bp-608h]@121 -// enum WindowType pWindowType; // [sp-8h] [bp-604h]@56 - //enum WindowType pWindowType1; // [sp-8h] [bp-604h]@60 -// unsigned __int8 v143; // [sp-8h] [bp-604h]@86 - //int v144; // [sp-8h] [bp-604h]@107 -// enum WindowType pWindowType2; // [sp-8h] [bp-604h]@121 - //const char *v146; // [sp-8h] [bp-604h]@449 - //unsigned int v147; // [sp-8h] [bp-604h]@550 - //int v148; // [sp-4h] [bp-600h]@56 GUIButton *pButton2; // [sp-4h] [bp-600h]@59 -// const char *v150; // [sp-4h] [bp-600h]@86 - //unsigned int v151; // [sp-4h] [bp-600h]@107 -// int v152; // [sp-4h] [bp-600h]@121 -// int v153; // [sp-4h] [bp-600h]@135 - //int v154; // [sp-4h] [bp-600h]@149 -// int v155; // [sp-4h] [bp-600h]@165 -// int v156; // [sp-4h] [bp-600h]@204 - //const char *v157; // [sp-4h] [bp-600h]@444 - //unsigned int v158; // [sp-4h] [bp-600h]@449 - //__int16 v159; // [sp-4h] [bp-600h]@550 -// int v160; // [sp-4h] [bp-600h]@599 const char *v161; // [sp-4h] [bp-600h]@637 - //int v162; // [sp+0h] [bp-5FCh]@56 - //int v163; // [sp+0h] [bp-5FCh]@59 -// Texture *pTexture; // [sp+0h] [bp-5FCh]@86 - //int v165; // [sp+0h] [bp-5FCh]@107 -// int v166; // [sp+0h] [bp-5FCh]@121 -// int v167; // [sp+0h] [bp-5FCh]@135 - //int v168; // [sp+0h] [bp-5FCh]@149 -// int v169; // [sp+0h] [bp-5FCh]@165 -// int v170; // [sp+0h] [bp-5FCh]@204 - //signed int v171; // [sp+0h] [bp-5FCh]@259 KeyToggleType pKeyToggleType; // [sp+0h] [bp-5FCh]@287 char *v173; // [sp+0h] [bp-5FCh]@444 char *v174; // [sp+0h] [bp-5FCh]@449 - //int v175; // [sp+0h] [bp-5FCh]@550 -// int v176; // [sp+0h] [bp-5FCh]@599 const char *v177; // [sp+0h] [bp-5FCh]@629 char *v178; // [sp+0h] [bp-5FCh]@637 -// int v179; // [sp+4h] [bp-5F8h]@0 - //signed int _this; // [sp+14h] [bp-5E8h]@22 -// signed int thisa; // [sp+14h] [bp-5E8h]@251 signed int thisb; // [sp+14h] [bp-5E8h]@272 Player *pPlayer7; // [sp+14h] [bp-5E8h]@373 Player *pPlayer8; // [sp+14h] [bp-5E8h]@377 @@ -1274,7 +1186,6 @@ signed int thisi; // [sp+14h] [bp-5E8h]@535 MapInfo *pMapInfo; // [sp+14h] [bp-5E8h]@604 Player *pPlayer10; // [sp+14h] [bp-5E8h]@641 -// int thisl; // [sp+14h] [bp-5E8h]@648 int uMessageParam; // [sp+18h] [bp-5E4h]@7 int uAction; // [sp+1Ch] [bp-5E0h]@18 NPCData *pNPCData4; // [sp+20h] [bp-5DCh]@23 @@ -1283,18 +1194,11 @@ enum UIMessageType uMessage; // [sp+2Ch] [bp-5D0h]@7 unsigned int v199; // [sp+30h] [bp-5CCh]@7 char *v200; // [sp+34h] [bp-5C8h]@518 -// POINT v201; // [sp+38h] [bp-5C4h]@553 POINT v202; // [sp+40h] [bp-5BCh]@141 POINT a2; // [sp+48h] [bp-5B4h]@127 -// POINT v204; // [sp+50h] [bp-5ACh]@777 POINT v205; // [sp+58h] [bp-5A4h]@171 -// POINT v206; // [sp+60h] [bp-59Ch]@553 POINT v207; // [sp+68h] [bp-594h]@155 -// POINT v208; // [sp+70h] [bp-58Ch]@397 -// POINT v209; // [sp+78h] [bp-584h]@777 -// POINT v210; // [sp+80h] [bp-57Ch]@397 POINT v211; // [sp+88h] [bp-574h]@704 - //__int64 v212; // [sp+90h] [bp-56Ch]@467 int v213; // [sp+98h] [bp-564h]@385 char pLevelName[32]; // [sp+9Ch] [bp-560h]@380 char pOut[32]; // [sp+BCh] [bp-540h]@370 @@ -1304,7 +1208,6 @@ char a1[64]; // [sp+1F8h] [bp-404h]@467 char Str2[128]; // [sp+238h] [bp-3C4h]@527 Actor actor; // [sp+2B8h] [bp-344h]@4 - //unsigned short* screenshot; int currHour; dword_50CDC8 = 0; @@ -1437,7 +1340,7 @@ } else { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[201], 2u);// "Are you sure? Click again to start a New Game" + ShowStatusBarString(pGlobalTXT_LocalizationStrings[201], 2);// "Are you sure? Click again to start a New Game" pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0); dword_6BE138 = 124; } @@ -1632,32 +1535,34 @@ uTextureID_Optkb[3] = pIcons_LOD->LoadTexture("optkb_1", TEXTURE_16BIT_PALETTE); uTextureID_Optkb[4] = pIcons_LOD->LoadTexture("optkb_2", TEXTURE_16BIT_PALETTE); pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_KeyMappingOptions, 0, 0); - pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, UIMSG_Escape, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(19u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, UIMSG_SelectKeyPage1, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(127u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, UIMSG_SelectKeyPage2, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(127u, 0x144u, 0x6Cu, 0x14u, 1, 0, UIMSG_ResetKeyMapping, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(19u, 0x144u, 0x6Cu, 0x14u, 1, 0, UIMSG_Game_OpenOptionsDialog, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129u, 0x94u, 0x46u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129u, 0xA7u, 0x46u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 1u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129u, 0xBAu, 0x46u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 2u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129u, 0xCDu, 0x46u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 3u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129u, 224u, 70u, 19u, 1, 0, UIMSG_ChangeKeyButton, 4u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129u, 243u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 5u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129u, 262u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 6u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350u, 148u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 7u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350u, 167u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 8u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350u, 186u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 9u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350u, 205u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 0xAu, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350u, 224u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 0xBu, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350u, 243u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 0xCu, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350u, 262u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 0xDu, 0, "", 0); + + pGUIWindow_CurrentMenu->CreateButton(241, 302, 214, 40, 1, 0, UIMSG_Escape, 0, 0, "", 0); + + pGUIWindow_CurrentMenu->CreateButton(19, 302, 108, 20, 1, 0, UIMSG_SelectKeyPage1, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(127, 302, 108, 20, 1, 0, UIMSG_SelectKeyPage2, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(127, 324, 108, 20, 1, 0, UIMSG_ResetKeyMapping, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(19, 324, 108, 20, 1, 0, UIMSG_Game_OpenOptionsDialog, 0, 0, "", 0); + + pGUIWindow_CurrentMenu->CreateButton(129, 148, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 167, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 1, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 186, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 2, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 205, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 3, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 224, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 4, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 243, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 5, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 262, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 6, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 148, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 7, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 167, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 8, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 186, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 9, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 205, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 10, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 224, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 11, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 243, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 12, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 262, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 13, 0, "", 0); + uGameMenuUI_CurentlySelectedKeyIdx = -1; KeyboardPageNum = 1; memset(GameMenuUI_InvaligKeyBindingsFlags.data(), 0, sizeof(GameMenuUI_InvaligKeyBindingsFlags)); //*(_WORD *)KeyButtonArray[28] = 0; memcpy(pPrevVirtualCidesMapping.data(), pKeyActionMap->pVirtualKeyCodesMapping, 0x78u); - //v1 = ""; - //v0 = 1; continue; case UIMSG_ChangeKeyButton: if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 ) @@ -1674,31 +1579,21 @@ case UIMSG_ResetKeyMapping: v197 = 1; pKeyActionMap->SetDefaultMapping(); - uAction = 0; - do + for ( uint i = 0; i < 28; i++ ) { - v15 = pKeyActionMap->GetActionVKey((enum InputAction)uAction); - if ( v15 != pPrevVirtualCidesMapping[uAction] ) + if ( pKeyActionMap->GetActionVKey((enum InputAction)i) != pPrevVirtualCidesMapping[i] ) { if ( v197 ) { - v16 = pKeyActionMap->GetActionVKey((enum InputAction)uAction); - GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[uAction]), v16, 1); + GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[i]), pKeyActionMap->GetActionVKey((enum InputAction)i), 1); v197 = 0; } else - { - v17 = pKeyActionMap->GetActionVKey((enum InputAction)uAction); - GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[uAction]), v17, 0); - } + GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[i]), pKeyActionMap->GetActionVKey((enum InputAction)i), 0); } - pPrevVirtualCidesMapping[uAction] = pKeyActionMap->GetActionVKey((enum InputAction)uAction); - v18 = uAction++; - v13 = uAction > 28; - v12 = uAction - 28 < 0; - GameMenuUI_InvaligKeyBindingsFlags[v18] = 0; + pPrevVirtualCidesMapping[i] = pKeyActionMap->GetActionVKey((enum InputAction)i); + GameMenuUI_InvaligKeyBindingsFlags[i] = false; } - while ( v12 ^ v13 ); pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0); continue; case UIMSG_SelectKeyPage1: @@ -2220,52 +2115,44 @@ case SCREEN_KEYBOARD_OPTIONS://Return to game v197 = 1; - v32 = 0; - while ( !GameMenuUI_InvaligKeyBindingsFlags[v32]) + pKeyBindingFlag = false; + for ( uint i = 0; i < 28; ++i ) + { + if ( GameMenuUI_InvaligKeyBindingsFlags[i] ) + pKeyBindingFlag = true; + } + if ( !pKeyBindingFlag ) { - ++v32; - if ( v32 >= 28 ) + for ( uint i = 0; i < 5; i++ ) { - thisb = (signed int)&uTextureID_Optkb; - assert(false && "Invalid condition values"); - do + if ( uTextureID_Optkb[i] ) + pIcons_LOD->pTextures[uTextureID_Optkb[i]].Release(); + } + memset(&uTextureID_Optkb, 0, 20); + pIcons_LOD->SyncLoadedFilesCount(); + for ( uint i = 0; i < 28; ++i ) + { + if ( pKeyActionMap->GetActionVKey((enum InputAction)i) != pPrevVirtualCidesMapping[i] ) { - if ( *(int *)thisb ) - pIcons_LOD->pTextures[*(int *)thisb].Release(); - thisb += 4; - } - while ( thisb < (signed int)0x00507C08 ); - - memset(&uTextureID_Optkb, 0, 0x14u); - pIcons_LOD->SyncLoadedFilesCount(); - for ( uAction = 0; uAction < 28; ++uAction ) - { - v33 = pKeyActionMap->GetActionVKey((enum InputAction)uAction); - if ( v33 != pPrevVirtualCidesMapping[uAction] ) + if ( v197 ) { - if ( v197 ) - { - v34 = pKeyActionMap->GetActionVKey((enum InputAction)uAction); - GUI_ReplaceHotkey(v34, LOBYTE(pPrevVirtualCidesMapping[uAction]), 1); - v197 = 0; - } - else - { - v35 = pKeyActionMap->GetActionVKey((enum InputAction)uAction); - GUI_ReplaceHotkey(v35, LOBYTE(pPrevVirtualCidesMapping[uAction]), 0); - } + GUI_ReplaceHotkey(pKeyActionMap->GetActionVKey((enum InputAction)i), LOBYTE(pPrevVirtualCidesMapping[i]), 1); + v197 = 0; } - if ( uAction && uAction != 2 && uAction != 3 && uAction != 1 && uAction != 25 && uAction != 26 ) - pKeyToggleType = TOGGLE_OneTimePress; else - pKeyToggleType = TOGGLE_Continuously; - pKeyActionMap->SetKeyMapping(uAction, pPrevVirtualCidesMapping[uAction], pKeyToggleType); + GUI_ReplaceHotkey(pKeyActionMap->GetActionVKey((enum InputAction)i), LOBYTE(pPrevVirtualCidesMapping[i]), 0); } - pKeyActionMap->StoreMappings(); - stru_506E40.Release(); - break; + if ( i > 3 && i != 25 && i != 26 ) + pKeyToggleType = TOGGLE_OneTimePress; + else + pKeyToggleType = TOGGLE_Continuously; + pKeyActionMap->SetKeyMapping(i, pPrevVirtualCidesMapping[i], pKeyToggleType); } + pKeyActionMap->StoreMappings(); + stru_506E40.Release(); + break; } + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); break; case SCREEN_REST://close rest screen if ( dword_506F14 ) @@ -2614,7 +2501,9 @@ dword_50CDC8 = 1; sub_42FBDD(); PlayHouseSound(uCurrentHouse_Animation, HouseSound_NotEnoughMoney_TrainingSuccessful); - pVideoPlayer->Unload(); + + if (pVideoPlayer->AnyMovieLoaded()) + pVideoPlayer->Unload(); DialogueEnding(); viewparams->bRedrawGameUI = true; if ( dword_59117C_teleportx | dword_591178_teleporty | dword_591174_teleportz | dword_591170_teleport_directiony | dword_59116C_teleport_directionx | dword_591168_teleport_speedz ) @@ -4534,7 +4423,7 @@ } if ( pCurrentScreen == SCREEN_VIDEO ) { - pVideoPlayer->Unload(); + //pVideoPlayer->Unload(); } else {
--- a/Indoor.h Wed Jul 23 17:36:56 2014 +0600 +++ b/Indoor.h Thu Jul 24 12:44:32 2014 +0600 @@ -417,6 +417,7 @@ pMapOutlines = 0; uNumSpawnPoints = 0; pSpawnPoints = 0; + uNumSectors = 0; } int GetSector(int sX, int sY, int sZ);
--- a/Items.h Wed Jul 23 17:36:56 2014 +0600 +++ b/Items.h Thu Jul 24 12:44:32 2014 +0600 @@ -225,6 +225,7 @@ static void PopulateSpecialBonusMap(); static void PopulateRegularBonusMap(); static void PopulateArtifactBonusMap(); + static void ClearItemBonusMaps(); void GetItemBonusSpecialEnchantment(Player* owner, CHARACTER_ATTRIBUTE_TYPE attrToGet, int* additiveBonus, int* halfSkillBonus); void GetItemBonusArtifact(Player* owner, CHARACTER_ATTRIBUTE_TYPE attrToGet, int* bonusSum);
--- a/LOD.cpp Wed Jul 23 17:36:56 2014 +0600 +++ b/LOD.cpp Thu Jul 24 12:44:32 2014 +0600 @@ -1151,6 +1151,9 @@ this->pHardwareSurfaces = 0; this->pHardwareTextures = 0; this->ptr_011BB4 = 0; + this->uTextureRedBits = 0; + this->uTextureGreenBits = 0; + this->uTextureBlueBits = 0; } //----- (004621A7) --------------------------------------------------------
--- a/MediaPlayer.cpp Wed Jul 23 17:36:56 2014 +0600 +++ b/MediaPlayer.cpp Thu Jul 24 12:44:32 2014 +0600 @@ -786,15 +786,21 @@ memset(last_resampled_frame_data, 0, sizeof(last_resampled_frame_data)); memset(last_resampled_frame_linesize, 0, sizeof(last_resampled_frame_linesize)); + audio_data_in_device = nullptr; decoding_packet = nullptr; ioBuffer = nullptr; format_ctx = nullptr; avioContext = nullptr; } + + virtual ~Movie() {} - inline void Release() + virtual void Release() { ReleaseAVCodec(); + + if (audio_data_in_device) + provider->DeleteStreamingTrack(&audio_data_in_device); } inline void ReleaseAVCodec() @@ -880,7 +886,7 @@ { current_movie_width = width; current_movie_height = height; - } + } // decoding_packet = new AVPacket; av_init_packet(decoding_packet); @@ -975,6 +981,7 @@ __debugbreak(); } while (!frameFinished); } + else __debugbreak(); // unknown stream } while (avpacket->stream_index != video.stream_idx || avpacket->pts != desired_frame_number); @@ -1033,8 +1040,8 @@ AVAudioStream audio; int num_audio_frames; int num_audio_samples; - unsigned char * ioBuffer; - AVIOContext *avioContext; + unsigned char *ioBuffer; + AVIOContext *avioContext; OpenALSoundProvider::StreamingTrackBuffer *audio_data_in_device; AVVideoStream video;
--- a/MediaPlayer.h Wed Jul 23 17:36:56 2014 +0600 +++ b/MediaPlayer.h Thu Jul 24 12:44:32 2014 +0600 @@ -5,14 +5,20 @@ class ITrack { public: - virtual void Play(bool loop = false) = 0; + virtual ~ITrack() {} + + virtual void Play(bool loop = false) = 0; + virtual void Release() = 0; }; class IMovie { public: - virtual void Play() = 0; - virtual void GetNextFrame(double dt, void *target_surface) = 0; + virtual ~IMovie() {} + + virtual void Play() = 0; + virtual void GetNextFrame(double dt, void *target_surface) = 0; + virtual void Release() = 0; }; class MPlayer
--- a/OSWindow.h Wed Jul 23 17:36:56 2014 +0600 +++ b/OSWindow.h Thu Jul 24 12:44:32 2014 +0600 @@ -43,7 +43,7 @@ bool Initialize(const wchar_t *title, int window_width, int window_height); bool WinApiMessageProc(UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *result); - HWND api_handle; + HWND api_handle; private: static LPARAM __stdcall WinApiMsgRouter(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
--- a/OpenALSoundProvider.h Wed Jul 23 17:36:56 2014 +0600 +++ b/OpenALSoundProvider.h Thu Jul 24 12:44:32 2014 +0600 @@ -27,11 +27,19 @@ this->context = nullptr; } + inline ~OpenALSoundProvider() + { + Release(); + } + inline bool Initialize() { + auto device_names = alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER); if (!device_names) + { device_names = alcGetString(nullptr, ALC_DEVICE_SPECIFIER); + } if (device_names) { for (auto device_name = device_names; device_name[0]; device_name += strlen(device_name)) @@ -68,15 +76,47 @@ if (context) { alcDestroyContext(context); - context = nullptr; } if (device) { alcCloseDevice(device); - device = nullptr; } } + void DeleteStreamingTrack(StreamingTrackBuffer **buffer) + { + if (!buffer && !*buffer) + return; + auto track = *buffer; + + int status; + alGetSourcei(track->source_id, AL_SOURCE_STATE, &status); + if (status == AL_PLAYING) + { + alSourceStop(track->source_id); + if (CheckError()) __debugbreak(); + } + + int num_processed_buffers = 0; + int num_queued_buffers = 0; + alGetSourcei(track->source_id, AL_BUFFERS_PROCESSED, &num_processed_buffers); + alGetSourcei(track->source_id, AL_BUFFERS_QUEUED, &num_queued_buffers); + int num_track_buffers = num_queued_buffers + num_processed_buffers; + for (int i = 0; i < num_processed_buffers; ++i) + { + unsigned int buffer_id; + alSourceUnqueueBuffers(track->source_id, 1, &buffer_id); + if (!CheckError()) + alDeleteBuffers(1, &buffer_id); + else __debugbreak(); + } + + alDeleteSources(1, &track->source_id); + CheckError(); + + delete *buffer; + *buffer = nullptr; + } void DeleteBuffer16(TrackBuffer **buffer) { @@ -125,6 +165,7 @@ } unsigned int al_source = -1; + alGetError(); alGenSources(1, &al_source); if (CheckError()) return nullptr;
--- a/Render.cpp Wed Jul 23 17:36:56 2014 +0600 +++ b/Render.cpp Thu Jul 24 12:44:32 2014 +0600 @@ -728,21 +728,16 @@ { size_t v4; // eax@1 size_t v5; // eax@1 - IUnknown *v6; // eax@10 size_t v7; // eax@13 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 - DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 - int v11; // [sp+430h] [bp-CCh]@16 - int v12; // [sp+434h] [bp-C8h]@16 - int v13; // [sp+438h] [bp-C4h]@16 - int v14; // [sp+474h] [bp-88h]@16*/ + DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16*/ DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 int is_there_a_compatible_screen_mode; // [sp+4C8h] [bp-34h]@16 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 - LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 + LPDIRECTDRAW pDirectDraw = nullptr; // [sp+4F4h] [bp-8h]@4 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 v4 = strlen(lpDriverName); @@ -772,7 +767,7 @@ delete [] v20.pDriverName; delete [] v20.pDeviceDesc; delete v20.pGUID; - v6 = (IUnknown *)pDirectDraw; + pDirectDraw->Release(); } else { @@ -805,7 +800,7 @@ //free(v20.pDDraw4DevDesc); delete [] v20.pDDraw4DevDesc; delete v20.pGUID; - v6 = (IUnknown *)pDirectDraw4; + pDirectDraw4->Release(); } else { @@ -814,15 +809,13 @@ pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); delete [] v20.pDriverName; delete [] v20.pDeviceDesc; - //free(v20.pDDraw4DevDesc); delete [] v20.pDDraw4DevDesc; delete v20.pGUID; pDirectDraw4->Release(); - v6 = (IUnknown *)pDirect3D3; pDirectDraw4 = 0; - } - } - v6->Release(); + pDirect3D3->Release(); + } + } } return 1; } @@ -1259,24 +1252,24 @@ v3 = 0; do { - free(v1->pAvailableDevices[v3].pDriverName); + delete[] v1->pAvailableDevices[v3].pDriverName; v1->pAvailableDevices[v3].pDriverName = nullptr; - free(v1->pAvailableDevices[v3].pDeviceDesc); + delete[] v1->pAvailableDevices[v3].pDeviceDesc; v1->pAvailableDevices[v3].pDeviceDesc = nullptr; - free(v1->pAvailableDevices[v3].pDDraw4DevDesc); + delete[] v1->pAvailableDevices[v3].pDDraw4DevDesc; v1->pAvailableDevices[v3].pDDraw4DevDesc = nullptr; - free(v1->pAvailableDevices[v3].pDirectDrawGUID); + delete v1->pAvailableDevices[v3].pDirectDrawGUID; v1->pAvailableDevices[v3].pDirectDrawGUID = nullptr; - free(v1->pAvailableDevices[v3].pName); + delete[] v1->pAvailableDevices[v3].pName; v1->pAvailableDevices[v3].pName = nullptr; - free(v1->pAvailableDevices[v3].pDescription); + delete[] v1->pAvailableDevices[v3].pDescription; v1->pAvailableDevices[v3].pDescription = nullptr; - free(v1->pAvailableDevices[v3].pGUID); + delete v1->pAvailableDevices[v3].pGUID; v1->pAvailableDevices[v3].pGUID = nullptr; ++v3; } while ( v3 < 4 ); - free(v1->pAvailableDevices); + delete[] v1->pAvailableDevices; v1->pAvailableDevices = 0; v4 = v1->pViewport; if ( v4 ) @@ -6281,8 +6274,22 @@ if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) { - Dst.sub_451007_scale_image_bicubic(pHWLTexture->pPixels, pHWLTexture->uWidth, pHWLTexture->uHeight, pHWLTexture->uWidth, - (unsigned short *)desc.lpSurface, desc.dwWidth, desc.dwHeight, desc.lPitch >> 1, 0, 0); + // linear scaling + for (int s = 0; s < desc.dwHeight; ++s) + for (int t = 0; t < desc.dwWidth; ++t) + { + unsigned int resampled_x = t * pHWLTexture->uWidth / desc.dwWidth, + resampled_y = s * pHWLTexture->uHeight / desc.dwHeight; + unsigned short sample = pHWLTexture->pPixels[resampled_y * pHWLTexture->uWidth + resampled_x]; + + ((unsigned short *)desc.lpSurface)[s * (desc.lPitch >> 1) + t] = sample; + } + + + //bicubic sampling + //Dst.sub_451007_scale_image_bicubic(pHWLTexture->pPixels, pHWLTexture->uWidth, pHWLTexture->uHeight, pHWLTexture->uWidth, + // (unsigned short *)desc.lpSurface, desc.dwWidth, desc.dwHeight, desc.lPitch >> 1, 0, 0); + ErrD3D(pNextSurf->Unlock(0)); //bMipMaps = 0x4D86ACu; } @@ -8433,7 +8440,7 @@ fclose(this->pFile); for (uint i = 0; i < this->uNumItems; i++) { - free(this->pSpriteNames[i]); + delete[] this->pSpriteNames[i]; } } return true;
--- a/Spells.cpp Wed Jul 23 17:36:56 2014 +0600 +++ b/Spells.cpp Thu Jul 24 12:44:32 2014 +0600 @@ -332,9 +332,10 @@ pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0); strtok(pSpellsTXT_Raw, "\r"); - strtok(NULL, "\r"); for(int i=1; i<100; ++i) - { + { + if ((i % (11 - 1) )==0) + strtok(NULL, "\r"); test_string=strtok(NULL, "\r")+1; auto tokens = Tokenize(test_string, '\t'); pInfos[i].pName=RemoveQuotes(tokens[2]); @@ -350,8 +351,6 @@ pSpellDatas[i].stats |= strchr(tokens[10], 'e') || strchr(tokens[10], 'E') ? 2 : 0; pSpellDatas[i].stats |= strchr(tokens[10], 'c') || strchr(tokens[10], 'C') ? 4 : 0; pSpellDatas[i].stats |= strchr(tokens[10], 'x') || strchr(tokens[10], 'X') ? 8 : 0; - if ((i % 11)==0) - strtok(NULL, "\r"); } } //----- (00448DF8) --------------------------------------------------------
--- a/Sprites.cpp Wed Jul 23 17:36:56 2014 +0600 +++ b/Sprites.cpp Thu Jul 24 12:44:32 2014 +0600 @@ -406,17 +406,9 @@ memcpy(pSpriteSFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 8, mm8_frames_size); memcpy(pSpriteEFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 8 + mm8_frames_size, 2 * num_mm8_eframes); - for (uint i = 0; i < num_mm7_frames; ++i) - pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i]];//Uninitialized memory access - - for (uint i = num_mm7_frames; i < num_mm6_frames + num_mm7_frames; ++i) - pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i] + num_mm7_frames]; - - for (uint i = num_mm6_frames + num_mm7_frames; i < num_mm6_frames + num_mm7_frames + num_mm8_frames; ++i) - pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i] + num_mm6_frames + num_mm7_frames]; - - //for (uint i = 0; i < uNumSpriteFrames; ++i) - // pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i]]; + //the original was using num_mmx_frames, but never accessed any element beyond num_mmx_eframes, but boing beyong eframes caused invalid memory accesses + for (uint i = 0; i < num_mm6_eframes + num_mm7_eframes + num_mm8_eframes; ++i) + pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i]]; } //----- (0044DA92) --------------------------------------------------------
--- a/VideoPlayer.cpp Wed Jul 23 17:36:56 2014 +0600 +++ b/VideoPlayer.cpp Thu Jul 24 12:44:32 2014 +0600 @@ -94,24 +94,27 @@ } //----- (004BE70E) -------------------------------------------------------- -void VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4) +void VideoPlayer::MovieLoop(const char *pMovieName, int a2/*, int ScreenSizeFlag, int a4*/) { int v4; // ebp@1 MSG Msg; // [sp+Ch] [bp-1Ch]@12 v4 = a2; - if ( !(dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO)) ) - { + if ( dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO) || + bNoVideo) + return; + if ( a2 == 2 ) v4 = 0; ShowCursor(0);// - OpenGlobalMovie(pMovieName, 0, ScreenSizeFlag); + OpenGlobalMovie(pMovieName, 0); bPlayingMovie = 1; field_44 = v4; pRenderer->ClearTarget(0); pCurrentScreen = SCREEN_VIDEO; auto hwnd = pVideoPlayer->window->GetApiHandle(); + RECT rc_client; GetClientRect(hwnd, &rc_client); int client_width = rc_client.right - rc_client.left, @@ -120,6 +123,7 @@ HDC dc = GetDC(hwnd); HDC back_dc = CreateCompatibleDC(dc); HBITMAP back_bmp = CreateCompatibleBitmap(dc, client_width, client_height); + auto frame_buffer = new char[client_width * client_height * 4]; SelectObject(back_dc, back_bmp); DWORD t = GetTickCount();// @@ -128,32 +132,27 @@ while (true) // { - if ( pVideoPlayer->bStopBeforeSchedule ) + if (pVideoPlayer->bStopBeforeSchedule) break; while (PeekMessageA(&Msg, hwnd, 0, 0, PM_REMOVE)) { - if (Msg.message == 18) + if (Msg.message == WM_QUIT) Game_DeinitializeAndTerminate(0); - if (Msg.message == 15) + if (Msg.message == WM_PAINT) break; TranslateMessage(&Msg); DispatchMessageA(&Msg); } double dt = (GetTickCount() - t) / 1000.0; // - //dt = 1.0/15.0; t = GetTickCount(); - //log("dt=%.5f\n", dt); - - auto image = new char[client_width * client_height * 4]; - - pMovie_Track->GetNextFrame(dt, image); // + pMovie_Track->GetNextFrame(dt, frame_buffer); // if (end_current_file)// ? break; - if (image) + if (frame_buffer) { // draw to hwnd BITMAPINFO bmi; @@ -169,32 +168,31 @@ bmi.bmiHeader.biClrUsed = 0; bmi.bmiHeader.biClrImportant = 0; GetDIBits(back_dc, back_bmp, 0, client_height, 0, &bmi, DIB_RGB_COLORS); - SetDIBits(back_dc, back_bmp, 0, client_height, image, &bmi, DIB_RGB_COLORS); + SetDIBits(back_dc, back_bmp, 0, client_height, frame_buffer, &bmi, DIB_RGB_COLORS); BitBlt(dc, 0, 0, client_width, client_height, back_dc, 0, 0, SRCCOPY); - } - delete[] image;// - GUI_MainMenuMessageProc(); // , .. dt = 0.03, image - ??? if (pVideoPlayer->bStopBeforeSchedule == 1)// Sleep(1000); // } + delete [] frame_buffer; DeleteObject(back_bmp); DeleteObject(back_dc); + ReleaseDC(hwnd, dc); + pVideoPlayer->Unload(); - if (a4 == 1) + //if (a4 == 1) pCurrentScreen = SCREEN_GAME; pVideoPlayer->bPlayingMovie = 0; ShowCursor(1);// - if ( pCurrentScreen == SCREEN_VIDEO ) - pCurrentScreen = SCREEN_GAME; - } + /*if ( pCurrentScreen == SCREEN_VIDEO ) + pCurrentScreen = SCREEN_GAME;*/ } //----- (004BE9D8) -------------------------------------------------------- @@ -260,14 +258,14 @@ AIL_redbook_resume(pAudioPlayer->hAILRedbook); pEventTimer->Resume(); + pMovie_Track->Release(); delete pMovie_Track; - Log::Warning(L"delete dynamic memory for pMovie_Track\n"); pMovie_Track = nullptr; } void VideoPlayer::_inlined_in_463149() { - if (pMovie_Track) + if (pMovie_Track && !bNoVideo) { pRenderer->BeginScene(); pMouse->DrawCursorToTarget(); @@ -355,14 +353,15 @@ //----- (004BF3F9) -------------------------------------------------------- bool VideoPlayer::AnyMovieLoaded() { - if (pMovie_Track) + return pMovie_Track != 0; + /*if (pMovie_Track) return pMovie_Track;// pSmackerMovie || pBinkMovie; else - return false; + return false;*/ } //----- (004BF411) -------------------------------------------------------- -void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) +void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop/*, int ScreenSizeFlag*/) { // unsigned int v10; // eax@11 @@ -435,7 +434,7 @@ if ( this->uMovieFormatSwapped == 1 ) OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); else if ( this->uMovieFormatSwapped == 2 ) - OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); + OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying)); else __debugbreak(); } @@ -487,7 +486,7 @@ return li.QuadPart; } -void VideoPlayer::LoadMovie(const char * pFilename) +void VideoPlayer::LoadMovie(const char *pFilename) { char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2 char pVideoNameSmk[120]; // [sp+Ch] [bp-28h]@2 @@ -540,7 +539,5 @@ int client_width = rc_client.right - rc_client.left, client_height = rc_client.bottom - rc_client.top; - pMovie_Track = pMediaPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, client_width, client_height); - }
--- a/VideoPlayer.h Wed Jul 23 17:36:56 2014 +0600 +++ b/VideoPlayer.h Thu Jul 24 12:44:32 2014 +0600 @@ -50,15 +50,13 @@ void OpenHouseMovie(const char *pMovieName, unsigned int a3_1);//0x4BF28F void PlayDeathMovie(); bool AnyMovieLoaded(); - void OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4); + void OpenGlobalMovie(const char *pFilename, unsigned int bLoop); void _4BF5B2(); void SelectMovieType();//0x4BF73A void _inlined_in_463149(); - void MovieLoop(const char *pMovieName, int a2, int a3, int a4); + void MovieLoop(const char *pMovieName, int a2); void UpdatePalette(); - static int readFunction(void *, uint8_t *, int); - static int64_t seekFunction(void *, int64_t, int); void LoadMovie(const char *); RGBTexture pVideoFrame; @@ -88,6 +86,10 @@ HANDLE hVidFile; int uSize; int uOffset; + + protected: + static int readFunction(void *, uint8_t *, int); + static int64_t seekFunction(void *, int64_t, int); }; #pragma pack(pop)