diff options
Diffstat (limited to 'src/core/Game.cpp')
-rw-r--r-- | src/core/Game.cpp | 194 |
1 files changed, 62 insertions, 132 deletions
diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 08623c65..6825c247 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -65,6 +65,7 @@ #include "Script.h" #include "Shadows.h" #include "Skidmarks.h" +#include "SetPieces.h" #include "SpecialFX.h" #include "Sprite2d.h" #include "Stats.h" @@ -85,10 +86,12 @@ #include "World.h" #include "ZoneCull.h" #include "Zones.h" +#include "Occlusion.h" #include "debugmenu.h" -#include "frontendoption.h" +#include "Ropes.h" eLevelName CGame::currLevel; +int32 CGame::currArea; bool CGame::bDemoMode = true; bool CGame::nastyGame = true; bool CGame::frenchGame; @@ -261,33 +264,30 @@ void CGame::ShutdownRenderWare(void) bool CGame::InitialiseOnceAfterRW(void) { TheText.Load(); - DMAudio.Initialise(); CTimer::Initialise(); CTempColModels::Initialise(); mod_HandlingManager.Initialise(); CSurfaceTable::Initialise("DATA\\SURFACE.DAT"); CPedStats::Initialise(); CTimeCycle::Initialise(); - + DMAudio.Initialise(); if ( DMAudio.GetNum3DProvidersAvailable() == 0 ) - FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = -1; + FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = NO_AUDIO_PROVIDER; - if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -99 || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 ) + if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == AUDIO_PROVIDER_NOT_DETERMINED || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 ) { - CMenuManager::m_PrefsSpeakers = 0; - int8 provider = DMAudio.AutoDetect3DProviders(); - if ( provider != -1 ) - FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = provider; + FrontEndMenuManager.m_PrefsSpeakers = 0; + FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = DMAudio.AutoDetect3DProviders(); } DMAudio.SetCurrent3DProvider(FrontEndMenuManager.m_nPrefsAudio3DProviderIndex); - DMAudio.SetSpeakerConfig(CMenuManager::m_PrefsSpeakers); - DMAudio.SetDynamicAcousticModelingStatus(CMenuManager::m_PrefsDMA); - DMAudio.SetMusicMasterVolume(CMenuManager::m_PrefsMusicVolume); - DMAudio.SetEffectsMasterVolume(CMenuManager::m_PrefsSfxVolume); + DMAudio.SetSpeakerConfig(FrontEndMenuManager.m_PrefsSpeakers); + DMAudio.SetDynamicAcousticModelingStatus(FrontEndMenuManager.m_PrefsDMA); + DMAudio.SetMusicMasterVolume(FrontEndMenuManager.m_PrefsMusicVolume); + DMAudio.SetEffectsMasterVolume(FrontEndMenuManager.m_PrefsSfxVolume); DMAudio.SetEffectsFadeVol(127); DMAudio.SetMusicFadeVol(127); - CWorld::Players[0].SetPlayerSkin(CMenuManager::m_PrefsSkinFile); + CWorld::Players[0].SetPlayerSkin(FrontEndMenuManager.m_PrefsSkinFile); #ifdef CUSTOM_FRONTEND_OPTIONS CustomFrontendOptionsPopulate(); @@ -309,7 +309,7 @@ bool CGame::Initialise(const char* datFile) strcpy(aDatFile, datFile); CPools::Initialise(); CIniFile::LoadIniFile(); - currLevel = LEVEL_INDUSTRIAL; + currLevel = LEVEL_BEACH; LoadingScreen("Loading the Game", "Loading generic textures", GetRandomSplashScreen()); gameTxdSlot = CTxdStore::AddTxdSlot("generic"); CTxdStore::Create(gameTxdSlot); @@ -329,10 +329,9 @@ bool CGame::Initialise(const char* datFile) ThePaths.AllocatePathFindInfoMem(4500); CWeather::Init(); CCullZones::Init(); + COcclusion::Init(); CCollision::Init(); -#ifdef PS2_MENU - TheText.Load(); -#endif + CSetPieces::Init(); CTheZones::Init(); CUserDisplay::Init(); CMessages::Init(); @@ -367,12 +366,11 @@ bool CGame::Initialise(const char* datFile) CWorld::Players[0].LoadPlayerSkin(); TestModelIndices(); LoadingScreen("Loading the Game", "Setup water", nil); - CWaterLevel::Initialise("DATA\\WATER.DAT"); + WaterLevelInitialise("DATA\\WATER.DAT"); TheConsole.Init(); CDraw::SetFOV(120.0f); CDraw::ms_fLODDistance = 500.0f; LoadingScreen("Loading the Game", "Setup streaming", nil); - CStreaming::Init(); CStreaming::LoadInitialVehicles(); CStreaming::LoadInitialPeds(); CStreaming::RequestBigBuildings(LEVEL_GENERIC); @@ -380,6 +378,7 @@ bool CGame::Initialise(const char* datFile) printf("Streaming uses %zuK of its memory", CStreaming::ms_memoryUsed / 1024); // original modifier was %d LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen()); CAnimManager::LoadAnimFiles(); + CStreaming::LoadInitialWeapons(); CPed::Initialise(); CRouteNode::Initialise(); CEventList::Initialise(); @@ -417,13 +416,12 @@ bool CGame::Initialise(const char* datFile) CRubbish::Init(); CClouds::Init(); CSpecialFX::Init(); + CRopes::Init(); CWaterCannons::Init(); CBridge::Init(); CGarages::Init(); LoadingScreen("Loading the Game", "Position dynamic objects", nil); - CWorld::RepositionCertainDynamicObjects(); LoadingScreen("Loading the Game", "Initialise vehicle paths", nil); - CCullZones::ResolveVisibilities(); CTrain::InitTrains(); CPlane::InitPlanes(); CCredits::Init(); @@ -441,10 +439,12 @@ bool CGame::Initialise(const char* datFile) } #endif LoadingScreen("Loading the Game", "Load scene", nil); - CModelInfo::RemoveColModelsFromOtherLevels(currLevel); CCollision::ms_collisionInMemory = currLevel; for (int i = 0; i < MAX_PADS; i++) CPad::GetPad(i)->Clear(true); + // TODO(Miami) + // DMAudio.SetStartingTrackPositions(1); + DMAudio.ChangeMusicMode(MUSICMODE_GAME); return true; } @@ -565,9 +565,9 @@ void CGame::ReInitGameObjectVariables(void) CRemote::Init(); #endif CSpecialFX::Init(); + CRopes::Init(); CWaterCannons::Init(); CParticle::ReloadConfig(); - CCullZones::ResolveVisibilities(); #ifdef PS2_MENU if ( !TheMemoryCard.m_bWantToLoad ) @@ -589,24 +589,7 @@ void CGame::ReInitGameObjectVariables(void) void CGame::ReloadIPLs(void) { - CTimer::Stop(); - CWorld::RemoveStaticObjects(); - ThePaths.Init(); - CCullZones::Init(); - CFileLoader::ReloadPaths("GTA3.IDE"); - CFileLoader::LoadScene("INDUST.IPL"); - CFileLoader::LoadScene("COMMER.IPL"); - CFileLoader::LoadScene("SUBURBAN.IPL"); - CFileLoader::LoadScene("CULL.IPL"); - ThePaths.PreparePathData(); - CTrafficLights::ScanForLightsOnMap(); - CRoadBlocks::Init(); - CCranes::InitCranes(); - CGarages::Init(); - CWorld::RepositionCertainDynamicObjects(); - CCullZones::ResolveVisibilities(); - CRenderer::SortBIGBuildings(); - CTimer::Update(); + // Empty and unused } void CGame::ShutDownForRestart(void) @@ -622,6 +605,7 @@ void CGame::ShutDownForRestart(void) CTheScripts::UndoBuildingSwaps(); CTheScripts::UndoEntityInvisibilitySettings(); CWorld::ClearForRestart(); + CGameLogic::ClearShortCut(); CTimer::Shutdown(); CStreaming::FlushRequestList(); CStreaming::DeleteAllRwObjects(); @@ -629,11 +613,11 @@ void CGame::ShutDownForRestart(void) CStreaming::ms_disableStreaming = false; CRadar::RemoveRadarSections(); FrontEndMenuManager.UnloadTextures(); - CParticleObject::RemoveAllParticleObjects(); -#ifndef PS2 + CParticleObject::RemoveAllExpireableParticleObjects(); + //CWaterCreatures::RemoveAll(); //TODO VC + CSetPieces::Init(); CPedType::Shutdown(); CSpecialFX::Shutdown(); -#endif TidyUpMemory(true, false); } @@ -645,101 +629,25 @@ void CGame::InitialiseWhenRestarting(void) CTimer::Initialise(); CSprite2d::SetRecipNearClip(); -#ifdef PS2_MENU - if ( TheMemoryCard.b_FoundRecentSavedGameWantToLoad == true || TheMemoryCard.m_bWantToLoad == false ) + if (b_FoundRecentSavedGameWantToLoad || FrontEndMenuManager.m_bWantToLoad) { - if ( TheMemoryCard.m_bWantToLoad == true ) - MessageScreen("MCLOAD"); // Loading Data. Please do not remove the Memory Card (PS2) in MEMORY CARD slot 1, reset or switch off the console. - else - MessageScreen("RESTART"); // Starting new game + LoadSplash("splash1"); + if (FrontEndMenuManager.m_bWantToLoad) + FrontEndMenuManager.MessageScreen("FELD_WR", true); } -#endif - -#ifdef PS2_MENU - TheMemoryCard.b_FoundRecentSavedGameWantToLoad = false; -#else + b_FoundRecentSavedGameWantToLoad = false; -#endif TheCamera.Init(); -#ifdef PS2_MENU - if ( TheMemoryCard.m_bWantToLoad == true ) - { - TheMemoryCard.RestoreForStartLoad(); - CStreaming::LoadScene(TheCamera.GetPosition()); - } -#else if ( FrontEndMenuManager.m_bWantToLoad == true ) { RestoreForStartLoad(); CStreaming::LoadScene(TheCamera.GetPosition()); } -#endif ReInitGameObjectVariables(); -#ifdef PS2_MENU - if ( TheMemoryCard.m_bWantToLoad == true ) - { - if ( TheMemoryCard.LoadSavedGame() == CMemoryCard::RES_SUCCESS ) - { - for ( int32 i = 0; i < 35; i++ ) - { - MessageScreen("FESZ_LS"); // Load Successful. - } - - DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); - CTrain::InitTrains(); - CPlane::InitPlanes(); - } - else - { - for ( int32 i = 0; i < 50; i++ ) - { - DoRWStuffStartOfFrame(50, 50, 50, 0, 0, 0, 255); - - CSprite2d::InitPerFrame(); - CFont::InitPerFrame(); - DefinedState(); - - CSprite2d *splash = LoadSplash(NULL); - splash->Draw(rect, color, color, color, color); - splash->DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(110.0f), SCREEN_SCALE_X(620.0f), SCREEN_SCALE_Y(300.0f)), CRGBA(50, 50, 50, 192)); - - //CFont::SetFontStyle(?); - CFont::SetBackgroundOff(); - CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(160.0f)); // 480.0f - CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f)); - CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(160.0f)); // 480.0f - CFont::SetJustifyOff(); - CFont::SetColor(CRGBA(255, 255, 255, 255)); - CFont::SetBackGroundOnlyTextOff(); - CFont::SetDropColor(CRGBA(32, 32, 32, 255)); - CFont::SetDropShadowPosition(3); - CFont::SetPropOn(); - CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(130.0f), TheText.Get("MC_LDFL")); // Load Failed! - CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(170.0f), TheText.Get("FES_NOC")); // No Memory Card (PS2) in MEMORY CARD slot 1. - CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(240.0f), TheText.Get("MC_NWRE")); // Now Restarting Game. - CFont::DrawFonts(); - - DoRWStuffEndOfFrame(); - } - - ShutDownForRestart(); - CTimer::Stop(); - CTimer::Initialise(); - TheMemoryCard.m_bWantToLoad = false; - ReInitGameObjectVariables(); - currLevel = LEVEL_INDUSTRIAL; - CCollision::SortOutCollisionAfterLoad(); - - FrontEndMenuManager.SetSoundLevelsForMusicMenu(); - FrontEndMenuManager.InitialiseMenuContentsAfterLoadingGame(); - } - } -#else if ( FrontEndMenuManager.m_bWantToLoad == true ) { if ( GenericLoad() == true ) @@ -753,7 +661,7 @@ void CGame::InitialiseWhenRestarting(void) for ( int32 i = 0; i < 50; i++ ) { HandleExit(); - FrontEndMenuManager.MessageScreen("FED_LFL"); // Loading save game has failed. The game will restart now. + FrontEndMenuManager.MessageScreen("FED_LFL", true); // Loading save game has failed. The game will restart now. } ShutDownForRestart(); @@ -761,11 +669,10 @@ void CGame::InitialiseWhenRestarting(void) CTimer::Initialise(); FrontEndMenuManager.m_bWantToLoad = false; ReInitGameObjectVariables(); - currLevel = LEVEL_INDUSTRIAL; + currLevel = LEVEL_GENERIC; CCollision::SortOutCollisionAfterLoad(); } } -#endif CTimer::Update(); @@ -809,6 +716,7 @@ void CGame::Process(void) CAntennas::Update(); CGlass::Update(); CSceneEdit::Update(); + CSetPieces::Update(); CEventList::Update(); CParticle::Update(); gFireManager.Update(); @@ -830,6 +738,7 @@ void CGame::Process(void) CGarages::Update(); CRubbish::Update(); CSpecialFX::Update(); + CRopes::Update(); CTimeCycle::Update(); if (CReplay::ShouldStandardCameraBeProcessed()) TheCamera.Process(); @@ -849,9 +758,30 @@ void CGame::Process(void) CCarCtrl::RemoveDistantCars(); } } -#ifdef PS2 - CMemCheck::DoTest(); -#endif +} + +void +CGame::InitAfterFocusLoss() +{ + FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = FrontEndMenuManager.m_lastWorking3DAudioProvider; + DMAudio.SetCurrent3DProvider(FrontEndMenuManager.m_lastWorking3DAudioProvider); + + if (!FrontEndMenuManager.m_bGameNotLoaded && !FrontEndMenuManager.m_bMenuActive) + FrontEndMenuManager.m_bStartUpFrontEndRequested = true; +} + +bool +CGame::CanSeeWaterFromCurrArea(void) +{ + return currArea == AREA_MAIN_MAP || currArea == AREA_MANSION + || currArea == AREA_HOTEL; +} + +bool +CGame::CanSeeOutSideFromCurrArea(void) +{ + return currArea == AREA_MAIN_MAP || currArea == AREA_MALL || + currArea == AREA_MANSION || currArea == AREA_HOTEL; } void CGame::DrasticTidyUpMemory(bool) |