summaryrefslogtreecommitdiffstats
path: root/src/core/Game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/Game.cpp')
-rw-r--r--src/core/Game.cpp173
1 files changed, 49 insertions, 124 deletions
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 4c8aaa72..e3ef8aed 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,11 @@
#include "World.h"
#include "ZoneCull.h"
#include "Zones.h"
+#include "Occlusion.h"
#include "debugmenu.h"
-#include "frontendoption.h"
eLevelName CGame::currLevel;
+int32 CGame::currArea;
bool CGame::bDemoMode = true;
bool CGame::nastyGame = true;
bool CGame::frenchGame;
@@ -256,20 +258,20 @@ bool CGame::InitialiseOnceAfterRW(void)
if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -99 || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 )
{
- CMenuManager::m_PrefsSpeakers = 0;
+ FrontEndMenuManager.m_PrefsSpeakers = 0;
int8 provider = DMAudio.AutoDetect3DProviders();
if ( provider != -1 )
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = provider;
}
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();
@@ -291,7 +293,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);
@@ -311,10 +313,10 @@ bool CGame::Initialise(const char* datFile)
ThePaths.AllocatePathFindInfoMem(4500);
CWeather::Init();
CCullZones::Init();
+ COcclusion::Init();
CCollision::Init();
-#ifdef PS2_MENU
+ CSetPieces::Init();
TheText.Load();
-#endif
CTheZones::Init();
CUserDisplay::Init();
CMessages::Init();
@@ -349,12 +351,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_NONE);
@@ -362,6 +363,7 @@ bool CGame::Initialise(const char* datFile)
printf("Streaming uses %dK of its memory", CStreaming::ms_memoryUsed / 1024);
LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen());
CAnimManager::LoadAnimFiles();
+ CStreaming::LoadInitialWeapons();
CPed::Initialise();
CRouteNode::Initialise();
CEventList::Initialise();
@@ -402,10 +404,7 @@ bool CGame::Initialise(const char* datFile)
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();
@@ -422,7 +421,6 @@ 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);
@@ -548,7 +546,6 @@ void CGame::ReInitGameObjectVariables(void)
CSpecialFX::Init();
CWaterCannons::Init();
CParticle::ReloadConfig();
- CCullZones::ResolveVisibilities();
#ifdef PS2_MENU
if ( !TheMemoryCard.m_bWantToLoad )
@@ -570,24 +567,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)
@@ -603,6 +583,7 @@ void CGame::ShutDownForRestart(void)
CTheScripts::UndoBuildingSwaps();
CTheScripts::UndoEntityInvisibilitySettings();
CWorld::ClearForRestart();
+ CGameLogic::ClearShortCut();
CTimer::Shutdown();
CStreaming::FlushRequestList();
CStreaming::DeleteAllRwObjects();
@@ -611,10 +592,9 @@ void CGame::ShutDownForRestart(void)
CRadar::RemoveRadarSections();
FrontEndMenuManager.UnloadTextures();
CParticleObject::RemoveAllParticleObjects();
-#ifndef PS2
+ CSetPieces::Init();
CPedType::Shutdown();
CSpecialFX::Shutdown();
-#endif
TidyUpMemory(true, false);
}
@@ -626,101 +606,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 )
@@ -734,7 +638,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();
@@ -742,11 +646,10 @@ void CGame::InitialiseWhenRestarting(void)
CTimer::Initialise();
FrontEndMenuManager.m_bWantToLoad = false;
ReInitGameObjectVariables();
- currLevel = LEVEL_INDUSTRIAL;
+ currLevel = LEVEL_NONE;
CCollision::SortOutCollisionAfterLoad();
}
}
-#endif
CTimer::Update();
@@ -790,6 +693,7 @@ void CGame::Process(void)
CAntennas::Update();
CGlass::Update();
CSceneEdit::Update();
+ CSetPieces::Update();
CEventList::Update();
CParticle::Update();
gFireManager.Update();
@@ -830,9 +734,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)