Mercurial > mm7
diff mm7_2.cpp @ 2225:080fd5a5433d
Merge
author | Grumpy7 |
---|---|
date | Wed, 19 Feb 2014 22:30:39 +0100 |
parents | e6771956e74a |
children | 6ab7d7c112bb |
line wrap: on
line diff
--- a/mm7_2.cpp Wed Feb 19 22:26:10 2014 +0100 +++ b/mm7_2.cpp Wed Feb 19 22:30:39 2014 +0100 @@ -256,7 +256,7 @@ uDialogueType = 83; pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0); + pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 350, WINDOW_MainMenu, 0, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel" pIcons_LOD->GetTexture(uExitCancelTextureId), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); @@ -730,7 +730,7 @@ pRenderer->EndScene(); free(_this.pPixels); _this.pPixels = 0; - window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); + window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); pWindow.uFrameX = 75; pWindow.uFrameY = 60; pWindow.uFrameWidth = 469; @@ -916,11 +916,11 @@ result = (int)pDst; v193 = pDst; - v231 = 0; if ( dstHeight <= 0 ) return result; - do + //do + for ( v231 = 0; v231 < dstHeight; v231++ ) { for (int counter = 0; counter < dstWidth; counter++) { @@ -976,10 +976,10 @@ v193 = (unsigned __int16 *)((char *)v193 + field_20_bits); } v193 = (unsigned __int16 *)((char *)v193 + field_20_bits * (dstPitch - dstWidth)); - ++v231; + //++v231; result = v231; } - while(v231 < dstHeight); + //while(v231 < dstHeight); return result; } @@ -1581,9 +1581,6 @@ //----- (0045063B) -------------------------------------------------------- int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) { - signed int v2; // edi@1 - Actor *v3; // esi@2 - //signed __int64 v4; // qax@3 int result; // eax@8 int v6; // edi@11 int v7; // ebx@11 @@ -1599,11 +1596,7 @@ int v17; // eax@20 int v18; // eax@21 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 - int v20; // [sp+24h] [bp-20h]@11 - //MapInfo *v21; // [sp+28h] [bp-1Ch]@1 int v22; // [sp+2Ch] [bp-18h]@3 - int v23; // [sp+30h] [bp-14h]@11 - //int v24; // [sp+34h] [bp-10h]@1 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 int v26; // [sp+3Ch] [bp-8h]@11 int v27; // [sp+40h] [bp-4h]@11 @@ -1611,27 +1604,85 @@ if (!uNumActors) return 0; - //v21 = a1; - //v24 = a2; - v2 = 0; - v3 = pActors.data(); - while ( 1 ) + for ( uint mon_id = 0; mon_id < uNumActors; ++mon_id ) { - if (v3->pMonsterInfo.uID >= 121 && v3->pMonsterInfo.uID <= 123 || // Dwarf FemaleC A-C - v3->pMonsterInfo.uID >= 124 && v3->pMonsterInfo.uID <= 126 || // Dwarf MaleA A-C - v3->pMonsterInfo.uID >= 133 && v3->pMonsterInfo.uID <= 135 || // Peasant Elf FemaleA A-C - !v3->CanAct()) + if ((pActors[mon_id].pMonsterInfo.uID < 121 || pActors[mon_id].pMonsterInfo.uID > 123) && // Dwarf FemaleC A-C + (pActors[mon_id].pMonsterInfo.uID < 124 || pActors[mon_id].pMonsterInfo.uID > 126) && // Dwarf MaleA A-C + (pActors[mon_id].pMonsterInfo.uID < 133 || pActors[mon_id].pMonsterInfo.uID > 135) && // Peasant Elf FemaleA A-C + pActors[mon_id].CanAct()) { - ++v2; - ++v3; - - if (v2 >= uNumActors) - return 0; - - continue; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) + { + v22 = 0; + uint face_id = 0; + for ( face_id; face_id < 100; ++face_id ) + { + v6 = rand() % 1024 + 512; + v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; + v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v7), v6); + v8 = 0; + v19.uIndex = a2; + v19.vPosition.y = fixpoint_mul(stru_5C6E00->Sin(v7), v6) + pParty->vPosition.y; + v19.vPosition.z = pParty->vPosition.z; + v26 = 0; + v27 = 0; + v19.vPosition.z = ODM_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z, 0, &v26, &v27, 0); + for( int i = 0; i < pOutdoor->uNumBModels; i++ ) + { + v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); + v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); + if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) + { + v22 = 1; + break; + } + } + if ( v22 ) + { + v11 = face_id == 100; + break; + } + } + v11 = face_id == 100; + } + else if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + for ( uint i = 0; i < 100; ++i ) + { + v12 = rand() % 512 + 256; + v13 = rand(); + v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; + v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); + v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(v15, v12); + v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); + v19.vPosition.y = fixpoint_mul(v16, v12) + pParty->vPosition.y; + v19.vPosition.z = pParty->vPosition.z; + v19.uIndex = a2; + v17 = pIndoor->GetSector(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z); + if ( v17 == v22 ) + { + v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); + v19.vPosition.z = v18; + if ( v18 != -30000 ) + { + if ( abs(v18 - pParty->vPosition.z) <= 1024 ) + break; + } + } + } + v11 = v26 == 100; + } + if ( v11 ) + result = 0; + else + { + SpawnEncounter(a1, &v19, 0, 0, 1); + result = a2; + } } - break; + //break; //v22 = v3->pMonsterInfo.uID - 1; //v4 = (signed __int64)((double)v22 * 0.3333333333333333); //if ( (int)v4 != 40 ) @@ -1644,99 +1695,6 @@ //if ( v2 >= (signed int)uNumActors ) // goto LABEL_8; } - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - { - v22 = 0; - uFaceID = 0; - while ( 1 ) - { - ++uFaceID; - v6 = rand() % 1024 + 512; - v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; - v20 = stru_5C6E00->Cos(v7); - v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; - v19.vPosition.x = pParty->vPosition.x + v23; - v20 = stru_5C6E00->Sin(v7); - v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; - v8 = 0; - v19.uIndex = a2; - v19.vPosition.y = v23 + pParty->vPosition.y; - v19.vPosition.z = pParty->vPosition.z; - v26 = 0; - v27 = 0; - v19.vPosition.z = ODM_GetFloorLevel( - v19.vPosition.x, - v23 + pParty->vPosition.y, - pParty->vPosition.z, - 0, - &v26, - &v27, - 0); - v23 = 0; - for( int i = 0; i < pOutdoor->uNumBModels; i++ ) - { - v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); - v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); - if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) - { - v22 = 1; - break; - } - } - v11 = uFaceID == 100; - if ( uFaceID >= 100 ) - break; - if ( v22 ) - { - v11 = uFaceID == 100; - break; - } - } - } - else - { - v26 = 0; - v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - do - { - ++v26; - v12 = rand() % 512 + 256; - v13 = rand(); - v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; - v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); - v20 = v15; - v23 = (unsigned __int64)(v15 * (signed __int64)v12) >> 16; - v19.vPosition.x = pParty->vPosition.x + v23; - v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); - v20 = v16; - v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16; - v19.vPosition.y = v23 + pParty->vPosition.y; - v19.vPosition.z = pParty->vPosition.z; - v19.uIndex = a2; - v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z); - if ( v17 == v22 ) - { - v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); - v19.vPosition.z = v18; - if ( v18 != -30000 ) - { - if ( abs(v18 - pParty->vPosition.z) <= 1024 ) - break; - } - } - } - while ( v26 < 100 ); - v11 = v26 == 100; - } - if ( v11 ) - { - result = 0; - } - else - { - SpawnEncounter(a1, &v19, 0, 0, 1); - result = a2; - } return result; } @@ -2267,8 +2225,6 @@ return result; } - - //----- (00452B2E) -------------------------------------------------------- int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides) { @@ -2905,12 +2861,12 @@ pCurrentScreen = SCREEN_GAME; pGUIWindow2 = 0; - pAudioPlayer->StopChannels(-1, -1); - pMouse->RemoveHoldingItem(); + pAudioPlayer->StopChannels(-1, -1);//остановить/подготовить канал + pMouse->RemoveHoldingItem();//избавить курсор от вещи pIcons_LOD->_inlined_sub2(); - pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); + pWindow_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); @@ -2937,7 +2893,7 @@ { pTexture_PCX.Release(); pTexture_PCX.Load("lsave640.pcx", 0); - pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); + pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); pCurrentScreen = SCREEN_LOADGAME; LoadUI_Load(0); } @@ -4190,7 +4146,6 @@ bNoMargareth = true; } - /*v8 = _4AC1C9_get_cpu_speed(0, (Vec4_int_ *)a2); Rect.left = *(int *)v8; Rect.top = *(int *)(v8 + 4); @@ -4201,141 +4156,134 @@ constructors(); - if (!MM7_Initialize(640, 480)) + if (!MM7_Initialize(640, 480))//задаётся размер окна { Log::Warning(L"MM init: failed"); pGame->Deinitialize(); return 1; } - pEventTimer->Pause(); - - SetUserInterface(PartyAlignment_Neutral, false); - ShowIntroVideo_and_LoadingScreen(); - WriteWindowsRegistryInt("Ran once", 1); - dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; - pGame->InitializeGammaController(); - SecondaryInitialization(); - pRenderer->SetRasterClipRect(0, 0, 639, 479); - FinalInitialization(); - - Log::Warning(L"MM: entering main loop"); + pEventTimer->Pause(); + + SetUserInterface(PartyAlignment_Neutral, false); + ShowIntroVideo_and_LoadingScreen(); + WriteWindowsRegistryInt("Ran once", 1); + dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; + pGame->InitializeGammaController(); + SecondaryInitialization(); + pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1); + FinalInitialization(); + Log::Warning(L"MM: entering main loop"); + while ( 1 ) + { + MainMenuWindow* main_menu_window = MainMenuWindow::Create(); + window->AddControl(main_menu_window); + MainMenu_Loop(); + uGameState = GAME_STATE_PLAYING; while ( 1 ) { - MainMenuWindow* main_menu_window = MainMenuWindow::Create(); - window->AddControl(main_menu_window); - - MainMenu_Loop(); - uGameState = GAME_STATE_PLAYING; - while ( 1 ) + if (uGameState == GAME_FINISHED || GetCurrentMenuID() == MENU_EXIT_GAME) + { + pGame->Deinitialize(); + return true; + } + + if (GetCurrentMenuID() == MENU_NEWGAME) { - if (uGameState == GAME_FINISHED || GetCurrentMenuID() == MENU_EXIT_GAME) + if ( pAudioPlayer->hAILRedbook ) + AIL_redbook_stop(pAudioPlayer->hAILRedbook); + pParty->Reset(); + pOtherOverlayList->Reset(); + strcpy(pCurrentMapName, pStartingMapName); + pParty->CreateDefaultParty(0); + PlayerCreationUI_Initialize(); + if ( PlayerCreationUI_Loop() ) { - pGame->Deinitialize(); - return true; - } - - if (GetCurrentMenuID() == MENU_NEWGAME) - { - if ( pAudioPlayer->hAILRedbook ) - AIL_redbook_stop(pAudioPlayer->hAILRedbook); - pParty->Reset(); - pOtherOverlayList->Reset(); - - strcpy(pCurrentMapName, pStartingMapName); - pParty->CreateDefaultParty(0); - PlayerCreationUI_Initialize(); - if ( PlayerCreationUI_Loop() ) - { - DeleteCCharFont(); - break; - } DeleteCCharFont(); - bFlashQuestBook = true; - PlayFullscreenMovie(MOVIE_Emerald); - //pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); - SaveNewGame(); - - if (bNoMargareth) - _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1); - pGame->Loop(); - - if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) - { - SetCurrentMenuID(MENU_NEWGAME); - uGameState = GAME_STATE_PLAYING; - continue; - } - else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) - break; - - assert(false && "Invalid game state"); - } - if (GetCurrentMenuID() == MENU_CREDITS) - { - if ( pAudioPlayer->hAILRedbook ) - AIL_redbook_stop(pAudioPlayer->hAILRedbook); - MainMenuUI_Credits_Loop(); - break; - } - if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) - { - uGameState = GAME_STATE_PLAYING; - pGame->Loop(); + break; } - else - { - if (GetCurrentMenuID() == MENU_DebugBLVLevel) - { - pMouse->Activate(0); - - pParty->Reset(); - pParty->CreateDefaultParty(1); - - __debugbreak(); - /*extern void CreateDefaultBLVLevel(); - CreateDefaultBLVLevel(); - - OPENFILENAMEA ofn; - if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) - { - pMouse->Activate(1); - break; - } - _chdir("..\\"); - strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/ - pMouse->Activate(1); - pGame->Loop(); - } - } - if ( uGameState == GAME_STATE_LOADING_GAME ) - { - SetCurrentMenuID(MENU_5); - uGameState = GAME_STATE_PLAYING; - continue; - } - if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU ) + DeleteCCharFont(); + bFlashQuestBook = true; + PlayFullscreenMovie(MOVIE_Emerald); + //pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); + SaveNewGame(); + if (bNoMargareth) + _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1); + pGame->Loop(); + if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) { SetCurrentMenuID(MENU_NEWGAME); uGameState = GAME_STATE_PLAYING; continue; } - if ( uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game + else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) + break; + assert(false && "Invalid game state"); + } + if (GetCurrentMenuID() == MENU_CREDITS) + { + if ( pAudioPlayer->hAILRedbook ) + AIL_redbook_stop(pAudioPlayer->hAILRedbook); + MainMenuUI_Credits_Loop(); + break; + } + if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) + { + uGameState = GAME_STATE_PLAYING; + pGame->Loop(); + } + else + { + if (GetCurrentMenuID() == MENU_DebugBLVLevel) { - pAudioPlayer->StopChannels(-1, -1); - uGameState = GAME_STATE_PLAYING; - break; + pMouse->ChangeActivation(0); + pParty->Reset(); + pParty->CreateDefaultParty(1); + + __debugbreak(); + /*extern void CreateDefaultBLVLevel(); + CreateDefaultBLVLevel(); + + OPENFILENAMEA ofn; + if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) + { + pMouse->ChangeActivation(1); + break; + } + _chdir("..\\"); + strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/ + pMouse->ChangeActivation(1); + pGame->Loop(); } } - if (!bNoSound && pAudioPlayer->hAILRedbook) + if ( uGameState == GAME_STATE_LOADING_GAME ) + { + SetCurrentMenuID(MENU_5); + uGameState = GAME_STATE_PLAYING; + continue; + } + if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU ) { - pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); - AIL_redbook_stop(pAudioPlayer->hAILRedbook); - unsigned int startms, end_ms; - AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xE, &startms, &end_ms); - AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms); + SetCurrentMenuID(MENU_NEWGAME); + uGameState = GAME_STATE_PLAYING; + continue; + } + if ( uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game + { + pAudioPlayer->StopChannels(-1, -1); + uGameState = GAME_STATE_PLAYING; + break; } } + if (!bNoSound && pAudioPlayer->hAILRedbook) + { + pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); + AIL_redbook_stop(pAudioPlayer->hAILRedbook); + unsigned int startms, end_ms; + AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &startms, &end_ms); + AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms); + } + } //lua_close(L); pGame->Deinitialize(); return 1; @@ -4495,9 +4443,7 @@ } } else - { LOBYTE(viewparams->field_20) = 0; - } pParty->uFlags |= 2; viewparams->uSomeY = viewparams->uScreen_topL_Y; viewparams->uSomeX = viewparams->uScreen_topL_X;