comparison Engine/Engine.cpp @ 2543:b6140dfeac27

GameOver h/cpp
author a.parshin
date Sun, 10 May 2015 03:21:14 +0200
parents a902abdfc7f2
children c674d547cc7c
comparison
equal deleted inserted replaced
2542:bacf9809126a 2543:b6140dfeac27
66 #include "Engine/Graphics/RenderD3D11.h" 66 #include "Engine/Graphics/RenderD3D11.h"
67 #include "Engine/MMT.h" 67 #include "Engine/MMT.h"
68 #include "GUI/NewUI\MainMenu.h" 68 #include "GUI/NewUI\MainMenu.h"
69 69
70 #include "Game/Game.h" 70 #include "Game/Game.h"
71 #include "Game/MainMenu.h"
71 72
72 #include <direct.h> 73 #include <direct.h>
73 74
74 75
75 76
162 163
163 uFlags2 &= ~0x02; 164 uFlags2 &= ~0x02;
164 if (pParty->_497FC5_check_party_perception_against_level()) 165 if (pParty->_497FC5_check_party_perception_against_level())
165 uFlags2 |= 2; 166 uFlags2 |= 2;
166 167
167 pEngine->pIndoorCameraD3D->sRotationX = pParty->sRotationX; 168 pIndoorCameraD3D->sRotationX = pParty->sRotationX;
168 pEngine->pIndoorCameraD3D->sRotationY = pParty->sRotationY; 169 pIndoorCameraD3D->sRotationY = pParty->sRotationY;
169 pEngine->pIndoorCameraD3D->vPartyPos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * pi_double * pParty->sRotationY / 2048.0); 170 pIndoorCameraD3D->vPartyPos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * pi_double * pParty->sRotationY / 2048.0);
170 pEngine->pIndoorCameraD3D->vPartyPos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * pi_double * pParty->sRotationY / 2048.0); 171 pIndoorCameraD3D->vPartyPos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * pi_double * pParty->sRotationY / 2048.0);
171 pEngine->pIndoorCameraD3D->vPartyPos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353 172 pIndoorCameraD3D->vPartyPos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353
172 173
173 //pIndoorCamera->Initialize2(); 174 //pIndoorCamera->Initialize2();
174 pIndoorCameraD3D->CalculateRotations(pParty->sRotationX, pParty->sRotationY); 175 pIndoorCameraD3D->CalculateRotations(pParty->sRotationX, pParty->sRotationY);
175 pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff(); 176 pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff();
176 pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum(); 177 pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum();
438 //y = cursor.x; 439 //y = cursor.x;
439 if (sub_4637E0_is_there_popup_onscreen()) 440 if (sub_4637E0_is_there_popup_onscreen())
440 { 441 {
441 v11 = &vis_face_filter; 442 v11 = &vis_face_filter;
442 v10 = &vis_sprite_filter_2; 443 v10 = &vis_sprite_filter_2;
443 depth = pEngine->pIndoorCameraD3D->GetPickDepth(); 444 depth = pIndoorCameraD3D->GetPickDepth();
444 } 445 }
445 else 446 else
446 { 447 {
447 if (uFlags2 & GAME_FLAGS_2_TARGETING_MODE) 448 if (uFlags2 & GAME_FLAGS_2_TARGETING_MODE)
448 { 449 {
1856 } 1857 }
1857 else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) 1858 else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)
1858 break; 1859 break;
1859 assert(false && "Invalid game state"); 1860 assert(false && "Invalid game state");
1860 } 1861 }
1861 if (GetCurrentMenuID() == MENU_CREDITS) 1862 else if (GetCurrentMenuID() == MENU_CREDITS)
1862 { 1863 {
1863 if (use_music_folder) 1864 if (use_music_folder)
1864 alSourceStop(mSourceID); 1865 alSourceStop(mSourceID);
1865 else 1866 else
1866 { 1867 {
1868 AIL_redbook_stop(pAudioPlayer->hAILRedbook); 1869 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
1869 } 1870 }
1870 MainMenuUI_Credits_Loop(); 1871 MainMenuUI_Credits_Loop();
1871 break; 1872 break;
1872 } 1873 }
1873 if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) 1874 else if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu)
1874 { 1875 {
1875 uGameState = GAME_STATE_PLAYING; 1876 uGameState = GAME_STATE_PLAYING;
1876 Game_Loop(); 1877 Game_Loop();
1877 } 1878 }
1878 else 1879 else if (GetCurrentMenuID() == MENU_DebugBLVLevel)
1879 { 1880 {
1880 if (GetCurrentMenuID() == MENU_DebugBLVLevel) 1881 pMouse->ChangeActivation(0);
1882 pParty->Reset();
1883 pParty->CreateDefaultParty(1);
1884
1885 __debugbreak();
1886 /*extern void CreateDefaultBLVLevel();
1887 CreateDefaultBLVLevel();
1888
1889 OPENFILENAMEA ofn;
1890 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
1881 { 1891 {
1882 pMouse->ChangeActivation(0); 1892 pMouse->ChangeActivation(1);
1883 pParty->Reset(); 1893 break;
1884 pParty->CreateDefaultParty(1);
1885
1886 __debugbreak();
1887 /*extern void CreateDefaultBLVLevel();
1888 CreateDefaultBLVLevel();
1889
1890 OPENFILENAMEA ofn;
1891 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
1892 {
1893 pMouse->ChangeActivation(1);
1894 break;
1895 }
1896 _chdir("..\\");
1897 strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/
1898 pMouse->ChangeActivation(1);
1899 Game_Loop();
1900 } 1894 }
1895 _chdir("..\\");
1896 strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/
1897 pMouse->ChangeActivation(1);
1898 Game_Loop();
1901 } 1899 }
1902 if (uGameState == GAME_STATE_LOADING_GAME) 1900 if (uGameState == GAME_STATE_LOADING_GAME)
1903 { 1901 {
1904 SetCurrentMenuID(MENU_5); 1902 SetCurrentMenuID(MENU_5);
1905 uGameState = GAME_STATE_PLAYING; 1903 uGameState = GAME_STATE_PLAYING;
1998 pODMRenderParams = new ODMRenderParams; 1996 pODMRenderParams = new ODMRenderParams;
1999 pODMRenderParams->outdoor_no_mist = GetPrivateProfileIntW(L"debug", L"noMist", 0, pIniFilename); 1997 pODMRenderParams->outdoor_no_mist = GetPrivateProfileIntW(L"debug", L"noMist", 0, pIniFilename);
2000 pODMRenderParams->bNoSky = GetPrivateProfileIntW(L"outdoor", L"nosky", 0, pIniFilename); 1998 pODMRenderParams->bNoSky = GetPrivateProfileIntW(L"outdoor", L"nosky", 0, pIniFilename);
2001 pODMRenderParams->bDoNotRenderDecorations = GetPrivateProfileIntW(L"render", L"nodecorations", 0, pIniFilename); 1999 pODMRenderParams->bDoNotRenderDecorations = GetPrivateProfileIntW(L"render", L"nodecorations", 0, pIniFilename);
2002 pODMRenderParams->outdoor_no_wavy_water = GetPrivateProfileIntW(L"outdoor", L"nowavywater", 0, pIniFilename); 2000 pODMRenderParams->outdoor_no_wavy_water = GetPrivateProfileIntW(L"outdoor", L"nowavywater", 0, pIniFilename);
2003 outdoor_grid_band_1 = GetPrivateProfileIntW(L"outdoor", L"gridband1", 10, pIniFilename); 2001 //outdoor_grid_band_1 = GetPrivateProfileIntW(L"outdoor", L"gridband1", 10, pIniFilename);
2004 outdoor_grid_band_2 = GetPrivateProfileIntW(L"outdoor", L"gridband2", 15, pIniFilename); 2002 //outdoor_grid_band_2 = GetPrivateProfileIntW(L"outdoor", L"gridband2", 15, pIniFilename);
2005 outdoor_grid_band_3 = GetPrivateProfileIntW(L"outdoor", L"gridband3", 25, pIniFilename); 2003 //outdoor_grid_band_3 = GetPrivateProfileIntW(L"outdoor", L"gridband3", 25, pIniFilename);
2006 pODMRenderParams->terrain_gamma = GetPrivateProfileIntW(L"outdoor", L"ter_gamma", 0, pIniFilename); 2004 pODMRenderParams->terrain_gamma = GetPrivateProfileIntW(L"outdoor", L"ter_gamma", 0, pIniFilename);
2007 pODMRenderParams->building_gamme = GetPrivateProfileIntW(L"outdoor", L"bld_gamma", 0, pIniFilename); 2005 pODMRenderParams->building_gamme = GetPrivateProfileIntW(L"outdoor", L"bld_gamma", 0, pIniFilename);
2008 pODMRenderParams->shading_dist_shade = GetPrivateProfileIntW(L"shading", L"dist_shade", 2048, pIniFilename); 2006 pODMRenderParams->shading_dist_shade = GetPrivateProfileIntW(L"shading", L"dist_shade", 2048, pIniFilename);
2009 pODMRenderParams->shading_dist_shademist = GetPrivateProfileIntW(L"shading", L"dist_shademist", 4096, pIniFilename); 2007 pODMRenderParams->shading_dist_shademist = GetPrivateProfileIntW(L"shading", L"dist_shademist", 4096, pIniFilename);
2010 2008
2070 pODMRenderParams->building_gamme = 0; 2068 pODMRenderParams->building_gamme = 0;
2071 pODMRenderParams->shading_dist_shademist = 4096; 2069 pODMRenderParams->shading_dist_shademist = 4096;
2072 pODMRenderParams->outdoor_no_wavy_water = 0; 2070 pODMRenderParams->outdoor_no_wavy_water = 0;
2073 //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); 2071 //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3);
2074 { 2072 {
2075 pODMRenderParams->outdoor_grid_band_3 = outdoor_grid_band_3; 2073 pODMRenderParams->outdoor_grid_band_3 = 25;//outdoor_grid_band_3;
2076 pODMRenderParams->uPickDepth = outdoor_grid_band_3 * 512; 2074 pODMRenderParams->uPickDepth = 25 * 512;//outdoor_grid_band_3 * 512;
2077 } 2075 }
2078 } 2076 }
2079 else 2077 else
2080 LOBYTE(viewparams->field_20) = 0; 2078 LOBYTE(viewparams->field_20) = 0;
2079
2081 pParty->uFlags |= 2; 2080 pParty->uFlags |= 2;
2082 viewparams->uSomeY = viewparams->uScreen_topL_Y; 2081 viewparams->uSomeY = viewparams->uScreen_topL_Y;
2083 viewparams->uSomeX = viewparams->uScreen_topL_X; 2082 viewparams->uSomeX = viewparams->uScreen_topL_X;
2084 viewparams->uSomeZ = viewparams->uScreen_BttmR_X; 2083 viewparams->uSomeZ = viewparams->uScreen_BttmR_X;
2085 viewparams->uSomeW = viewparams->uScreen_BttmR_Y; 2084 viewparams->uSomeW = viewparams->uScreen_BttmR_Y;
2099 if (!bLoading) 2098 if (!bLoading)
2100 TeleportToStartingPoint(uLevel_StartingPointType); 2099 TeleportToStartingPoint(uLevel_StartingPointType);
2101 viewparams->_443365(); 2100 viewparams->_443365();
2102 PlayLevelMusic(); 2101 PlayLevelMusic();
2103 } 2102 }
2104 // 6BE35C: using guessed type int uLevel_StartingPointType; 2103
2105
2106
2107
2108 //----- (004BF91E) --------------------------------------------------------
2109 unsigned int GameOverMenu(void *ecx0)
2110 {
2111 const char *v1; // eax@2
2112 unsigned int result; // eax@3
2113 const char *v6; // eax@10
2114 const char *v7; // edx@10
2115 const char *v8; // ecx@12
2116 const char *v9; // eax@14
2117 unsigned int v10; // eax@25
2118 GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1
2119 unsigned int v14; // [sp+A4h] [bp-2Ch]@5
2120 void *v15; // [sp+A8h] [bp-28h]@1
2121 const char *pInString; // [sp+ACh] [bp-24h]@5
2122 unsigned int v17; // [sp+B0h] [bp-20h]@5
2123 unsigned int v18; // [sp+B4h] [bp-1Ch]@5
2124 unsigned int v19; // [sp+B8h] [bp-18h]@5
2125 int v20; // [sp+BCh] [bp-14h]@7
2126 GUIFont *pFont; // [sp+C4h] [bp-Ch]@1
2127 unsigned __int64 v23; // [sp+C8h] [bp-8h]@5
2128 MSG msg;
2129
2130 v15 = ecx0;
2131
2132 RGBTexture _this; // [sp+Ch] [bp-C4h]@1
2133 //RGBTexture::RGBTexture(&this);
2134
2135 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_4000;
2136 bGameoverLoop = 1;
2137 pMediaPlayer->bStopBeforeSchedule = 0;
2138 pAudioPlayer->StopChannels(-1, -1);
2139 pRenderer->BeginScene();
2140 pRenderer->ClearBlack();
2141 pRenderer->EndScene();
2142 pRenderer->Present();
2143 //pMediaPlayer->pResetflag = 0;
2144 _449B57_test_bit(pParty->_quest_bits, 99);
2145 _this.Load("winbg.pcx", 2);
2146 pRenderer->BeginScene();
2147 pRenderer->DrawTextureRGB(0, 0, &_this);
2148 pRenderer->EndScene();
2149 free(_this.pPixels);
2150 _this.pPixels = 0;
2151 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
2152 pWindow.uFrameX = 75;
2153 pWindow.uFrameY = 60;
2154 pWindow.uFrameWidth = 469;
2155 pWindow.uFrameHeight = 338;
2156 pWindow.uFrameZ = 543;
2157 pWindow.uFrameW = 397;
2158 pFont = LoadFont("endgame.fnt", "FONTPAL", NULL);
2159 if (pParty->IsPartyGood())
2160 v1 = pGlobalTXT_LocalizationStrings[675];//"Splendid job! With the activation of the Gate, a thousand worlds lie at your feet. Perhaps on one of them you will find the Ancients themselves, and return with the fruits their great civilization has to offer your world and your kingdom."
2161 else
2162 {
2163 result = pParty->IsPartyEvil();
2164 if (!(short)result)
2165 return result;
2166 v1 = pGlobalTXT_LocalizationStrings[676];//"Brilliant! The completion of the Heavenly Forge has provided enough Ancient weapons to crush all resistance to your plans. Soon the world will bow to your every whim! Still, you can't help but wonder what was beyond the Gate the other side was trying so hard to build."
2167 }
2168 pInString = v1;
2169 v23 = pParty->uTimePlayed - 138240;
2170 v19 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24;
2171 v14 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24 / 0x1C / 0xC;
2172 v18 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24 / 0x1C % 0xC;
2173 v17 = v19 % 0x1C;
2174 if (!v19)
2175 v19 = 1;
2176 pRenderer->BeginScene();
2177 pWindow.DrawTitleText(pFont, 1, 0x23, 1, pGlobalTXT_LocalizationStrings[9], 3);//Congratulations!
2178 v23 = 0i64;
2179 v20 = 0;
2180 for (uint i = 0; i < 4; i++)
2181 {
2182 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[129], pParty->pPlayers[i].pName, pParty->pPlayers[i].GetBaseLevel(), pClassNames[pParty->pPlayers[i].classType]);//%s the Level %u %s
2183 pWindow.DrawTitleText(pFont, 1, i * (LOBYTE(pFont->uFontHeight) - 2) + LOBYTE(pFont->uFontHeight) + 46, 1, pTmpBuf.data(), 3);
2184 v23 += pParty->pPlayers[i].uExperience;//__PAIR__(*(int *)(i - 4), *(int *)(i - 8));
2185 }
2186 v23 = (signed __int64)v23 / v19;
2187 v6 = FitTextInAWindow(pInString, pFont, &pWindow, 0xC, 0);
2188 pWindow.DrawTitleText(pFont, 1, 5 * (LOBYTE(pFont->uFontHeight) + 11), 1, v6, 0);
2189 strcpy(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[37]);//Total Time:
2190
2191 v7 = pGlobalTXT_LocalizationStrings[56];
2192 if (v17 != 1)
2193 v7 = pGlobalTXT_LocalizationStrings[57];
2194
2195 v8 = pGlobalTXT_LocalizationStrings[146];//Month
2196 if (v18 != 1)
2197 v8 = pGlobalTXT_LocalizationStrings[148];//Months
2198
2199 v9 = pGlobalTXT_LocalizationStrings[245];
2200 if (v14 != 1)
2201 v9 = pGlobalTXT_LocalizationStrings[132];
2202
2203 sprintf(pTmpBuf2.data(), " %lu %s, %lu %s, %lu %s ", v14, v9, v18, v8, v17, v7);
2204 strcat(pTmpBuf.data(), pTmpBuf2.data());
2205 pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight - 2 * LOBYTE(pFont->uFontHeight) - 5, 1, pTmpBuf.data(), 3);
2206 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[94], v23);
2207 pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight, 1, pTmpBuf.data(), 3);
2208 dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000;
2209 pRenderer->EndScene();
2210 pRenderer->Present();
2211 //if ( pRenderer->pRenderD3D )
2212 pRenderer->pBeforePresentFunction();
2213 pRenderer->SaveWinnersCertificate("MM7_Win.Pcx");
2214 free(pFont);
2215 window_SpeakInHouse->Release();
2216 window_SpeakInHouse = 0;
2217 if (v15 == (void *)2)
2218 result = pMessageQueue_50CBD0->uNumMessages;
2219 else
2220 {
2221 LODWORD(v23) = GetTickCount() + 5000;
2222 while ((unsigned int)v23 > GetTickCount())
2223 ;
2224 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
2225 {
2226 if (msg.message == WM_QUIT)
2227 Engine_DeinitializeAndTerminate(0);
2228 TranslateMessage(&msg);
2229 DispatchMessage(&msg);
2230 }
2231 if (pMessageQueue_50CBD0->uNumMessages)
2232 {
2233 LOBYTE(v10) = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2234 pMessageQueue_50CBD0->uNumMessages = v10;
2235 }
2236 pKeyActionMap->ResetKeys();
2237 pKeyActionMap->uLastKeyPressed = 0;
2238 do
2239 {
2240 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
2241 {
2242 if (msg.message == WM_QUIT)
2243 Engine_DeinitializeAndTerminate(0);
2244 TranslateMessage(&msg);
2245 DispatchMessage(&msg);
2246 }
2247 } while (!pKeyActionMap->uLastKeyPressed);
2248 result = pMessageQueue_50CBD0->uNumMessages;
2249 if (pMessageQueue_50CBD0->uNumMessages)
2250 {
2251 result = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2252 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2253 }
2254 }
2255 if (v15)
2256 {
2257 /*if ( (signed int)result < 40 )
2258 {
2259 pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit;
2260 }*/
2261 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Quit, 1, 0);
2262 }
2263 else
2264 {
2265 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ShowFinalWindow, 1, 0);
2266 /*if ( (signed int)result < 40 )
2267 {
2268 pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5;
2269 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
2270 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
2271 *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
2272 ++pMessageQueue_50CBD0->uNumMessages;
2273 }*/
2274 }
2275 bGameoverLoop = 0;
2276 return result;
2277 }
2278 2104
2279 //----- (00464479) -------------------------------------------------------- 2105 //----- (00464479) --------------------------------------------------------
2280 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() 2106 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows()
2281 { 2107 {
2282 int v0; // esi@9 2108 int v0; // esi@9
2426 uNumLevelDecorations = 0; 2252 uNumLevelDecorations = 0;
2427 init_event_triggers(); 2253 init_event_triggers();
2428 2254
2429 pGameLoadingUI_ProgressBar->Progress(); 2255 pGameLoadingUI_ProgressBar->Progress();
2430 2256
2431 pEngine->pIndoorCameraD3D->vPartyPos.x = 0; 2257 pIndoorCameraD3D->vPartyPos.x = 0;
2432 pEngine->pIndoorCameraD3D->vPartyPos.y = 0; 2258 pIndoorCameraD3D->vPartyPos.y = 0;
2433 pEngine->pIndoorCameraD3D->vPartyPos.z = 100; 2259 pIndoorCameraD3D->vPartyPos.z = 100;
2434 pEngine->pIndoorCameraD3D->sRotationX = 0; 2260 pIndoorCameraD3D->sRotationX = 0;
2435 pEngine->pIndoorCameraD3D->sRotationY = 0; 2261 pIndoorCameraD3D->sRotationY = 0;
2436 viewparams->bRedrawGameUI = true; 2262 viewparams->bRedrawGameUI = true;
2437 uLevel_StartingPointType = MapStartPoint_Party; 2263 uLevel_StartingPointType = MapStartPoint_Party;
2438 pSprites_LOD->_461397(); 2264 pSprites_LOD->_461397();
2439 pPaletteManager->LockTestAll(); 2265 pPaletteManager->LockTestAll();
2440 if (pParty->pPickedItem.uItemID != 0) 2266 if (pParty->pPickedItem.uItemID != 0)