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.cpp180
1 files changed, 160 insertions, 20 deletions
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 1283ecd1..7043a5b2 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -90,6 +90,7 @@
#include "custompipes.h"
#include "screendroplets.h"
#include "crossplatform.h"
+#include "MemoryHeap.h"
eLevelName CGame::currLevel;
bool CGame::bDemoMode = true;
@@ -264,16 +265,19 @@ void CGame::ShutdownRenderWare(void)
#endif
}
+// missing altogether on PS2
bool CGame::InitialiseOnceAfterRW(void)
{
+#if GTA_VERSION > GTA3_PS2_160
TheText.Load();
- DMAudio.Initialise();
+ DMAudio.Initialise(); // before TheGame() on PS2
CTimer::Initialise();
CTempColModels::Initialise();
mod_HandlingManager.Initialise();
CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
CPedStats::Initialise();
CTimeCycle::Initialise();
+#endif
if ( DMAudio.GetNum3DProvidersAvailable() == 0 )
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = -1;
@@ -327,21 +331,40 @@ CGame::FinalShutdown(void)
bool CGame::Initialise(const char* datFile)
{
+#ifdef GTA_PS2
+ // TODO: upload VU0 collision code here
+#endif
+
+#if GTA_VERSION > GTA3_PS2_160
ResetLoadingScreenBar();
strcpy(aDatFile, datFile);
- CPools::Initialise();
+ CPools::Initialise(); // done in CWorld on PS2
+#endif
+
+#ifndef GTA_PS2
CIniFile::LoadIniFile();
+#endif
+
currLevel = LEVEL_INDUSTRIAL;
+
+ PUSH_MEMID(MEMID_TEXTURES);
LoadingScreen("Loading the Game", "Loading generic textures", GetRandomSplashScreen());
gameTxdSlot = CTxdStore::AddTxdSlot("generic");
CTxdStore::Create(gameTxdSlot);
CTxdStore::AddRef(gameTxdSlot);
+
LoadingScreen("Loading the Game", "Loading particles", nil);
int particleTxdSlot = CTxdStore::AddTxdSlot("particle");
CTxdStore::LoadTxd(particleTxdSlot, "MODELS/PARTICLE.TXD");
CTxdStore::AddRef(particleTxdSlot);
CTxdStore::SetCurrentTxd(gameTxdSlot);
LoadingScreen("Loading the Game", "Setup game variables", nil);
+ POP_MEMID();
+
+#ifdef GTA_PS2
+ CDma::SyncChannel(0, true);
+#endif
+
CGameLogic::InitAtStartOfGame();
CReferences::Init();
TheCamera.Init();
@@ -352,32 +375,72 @@ bool CGame::Initialise(const char* datFile)
CWeather::Init();
CCullZones::Init();
CCollision::Init();
-#ifdef PS2_MENU
+#ifdef PS2_MENU // TODO: is this the right define?
TheText.Load();
#endif
CTheZones::Init();
CUserDisplay::Init();
CMessages::Init();
+#if GTA_VERSION > GTA3_PS2_160
CMessages::ClearAllMessagesDisplayedByGame();
+#endif
CRecordDataForGame::Init();
CRestart::Initialise();
+
+ PUSH_MEMID(MEMID_WORLD);
CWorld::Initialise();
+ POP_MEMID();
+
+#if GTA_VERSION <= GTA3_PS2_160
+ mod_HandlingManager.Initialise();
+ CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
+ CTempColModels::Initialise();
+#endif
+
+ PUSH_MEMID(MEMID_TEXTURES);
CParticle::Initialise();
-#ifdef PS2
+ POP_MEMID();
+
+#if GTA_VERSION <= GTA3_PS2_160
gStartX = -180.0f;
gStartY = 180.0f;
gStartZ = 14.0f;
#endif
+
+ PUSH_MEMID(MEMID_ANIMATION);
CAnimManager::Initialise();
CCutsceneMgr::Initialise();
+ POP_MEMID();
+
+ PUSH_MEMID(MEMID_CARS);
CCarCtrl::Init();
+ POP_MEMID();
+
+#if GTA_VERSION > GTA3_PS2_160
InitModelIndices();
+#endif
+
+ PUSH_MEMID(MEMID_DEF_MODELS);
CModelInfo::Initialise();
+#if GTA_VERSION <= GTA3_PS2_160
+ CPedStats::Initialise(); // InitialiseOnceAfterRW
+#else
+ // probably moved before LoadLevel for multiplayer maps?
CPickups::Init();
CTheCarGenerators::Init();
+#endif
+
+#ifndef GTA_PS2 // or GTA_VERSION?
CdStreamAddImage("MODELS\\GTA3.IMG");
+#endif
+
+#if GTA_VERSION > GTA3_PS2_160
CFileLoader::LoadLevel("DATA\\DEFAULT.DAT");
CFileLoader::LoadLevel(datFile);
+#else
+ CFileLoader::LoadLevel("GTA3.DAT");
+#endif
+
#ifdef EXTENDED_PIPELINES
// for generic fallback
CustomPipes::SetTxdFindCallback();
@@ -386,17 +449,30 @@ bool CGame::Initialise(const char* datFile)
CVehicleModelInfo::LoadVehicleColours();
CVehicleModelInfo::LoadEnvironmentMaps();
CTheZones::PostZoneCreation();
+ POP_MEMID();
+
+#if GTA_VERSION <= GTA3_PS2_160
+ TestModelIndices();
+#endif
LoadingScreen("Loading the Game", "Setup paths", GetRandomSplashScreen());
ThePaths.PreparePathData();
+#if GTA_VERSION > GTA3_PS2_160
for (int i = 0; i < NUMPLAYERS; i++)
CWorld::Players[i].Clear();
CWorld::Players[0].LoadPlayerSkin();
TestModelIndices();
+#endif
+
LoadingScreen("Loading the Game", "Setup water", nil);
CWaterLevel::Initialise("DATA\\WATER.DAT");
+#if GTA_VERSION <= GTA3_PS2_160
+ CTimeCycle::Initialise(); // InitialiseOnceAfterRW
+#else
TheConsole.Init();
+#endif
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
+
LoadingScreen("Loading the Game", "Setup streaming", nil);
CStreaming::Init();
CStreaming::LoadInitialVehicles();
@@ -404,8 +480,12 @@ bool CGame::Initialise(const char* datFile)
CStreaming::RequestBigBuildings(LEVEL_GENERIC);
CStreaming::LoadAllRequestedModels(false);
printf("Streaming uses %zuK of its memory", CStreaming::ms_memoryUsed / 1024); // original modifier was %d
+
LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen());
+ PUSH_MEMID(MEMID_ANIMATION);
CAnimManager::LoadAnimFiles();
+ POP_MEMID();
+
CPed::Initialise();
CRouteNode::Initialise();
CEventList::Initialise();
@@ -414,15 +494,23 @@ bool CGame::Initialise(const char* datFile)
#endif
LoadingScreen("Loading the Game", "Find big buildings", nil);
CRenderer::Init();
+
LoadingScreen("Loading the Game", "Setup game variables", nil);
CRadar::Initialise();
CRadar::LoadTextures();
CWeapon::InitialiseWeapons();
+
LoadingScreen("Loading the Game", "Setup traffic lights", nil);
CTrafficLights::ScanForLightsOnMap();
CRoadBlocks::Init();
+
LoadingScreen("Loading the Game", "Setup game variables", nil);
CPopulation::Initialise();
+#if GTA_VERSION <= GTA3_PS2_160
+ for (int i = 0; i < NUMPLAYERS; i++)
+ CWorld::Players[i].Clear();
+// CWorld::Players[0].LoadPlayerSkin(); // TODO: use a define for this
+#endif
CWorld::PlayerInFocus = 0;
CCoronas::Init();
CShadows::Init();
@@ -431,44 +519,76 @@ bool CGame::Initialise(const char* datFile)
CAntennas::Init();
CGlass::Init();
gPhoneInfo.Initialise();
+#ifndef GTA_PS2 // TODO: define for this
CSceneEdit::Initialise();
+#endif
+
LoadingScreen("Loading the Game", "Load scripts", nil);
+ PUSH_MEMID(MEMID_SCRIPT);
CTheScripts::Init();
CGangs::Initialise();
+ POP_MEMID();
+
LoadingScreen("Loading the Game", "Setup game variables", nil);
+#if GTA_VERSION <= GTA3_PS2_160
+ CTimer::Initialise();
+#endif
CClock::Initialise(1000);
+#if GTA_VERSION <= GTA3_PS2_160
+ CTheCarGenerators::Init();
+#endif
CHeli::InitHelis();
CCranes::InitCranes();
CMovingThings::Init();
CDarkel::Init();
CStats::Init();
+#if GTA_VERSION <= GTA3_PS2_160
+ CPickups::Init();
+#endif
CPacManPickups::Init();
+#if GTA_VERSION <= GTA3_PS2_160
+ CGarages::Init();
+#endif
CRubbish::Init();
CClouds::Init();
+#if GTA_VERSION <= GTA3_PS2_160
+ CRemote::Init();
+#endif
CSpecialFX::Init();
CWaterCannons::Init();
CBridge::Init();
+#if GTA_VERSION > GTA3_PS2_160
CGarages::Init();
+#endif
+
LoadingScreen("Loading the Game", "Position dynamic objects", nil);
CWorld::RepositionCertainDynamicObjects();
+#if GTA_VERSION <= GTA3_PS2_160
+ CCullZones::ResolveVisibilities();
+#endif
+
LoadingScreen("Loading the Game", "Initialise vehicle paths", nil);
+#if GTA_VERSION > GTA3_PS2_160
CCullZones::ResolveVisibilities();
+#endif
CTrain::InitTrains();
CPlane::InitPlanes();
CCredits::Init();
CRecordDataForChase::Init();
+#ifndef GTA_PS2 // TODO: define for that
CReplay::Init();
+#endif
+
#ifdef PS2_MENU
if ( !TheMemoryCard.m_bWantToLoad )
- {
#endif
- LoadingScreen("Loading the Game", "Start script", nil);
- CTheScripts::StartTestScript();
- CTheScripts::Process();
- TheCamera.Process();
-#ifdef PS2_MENU
+ {
+ LoadingScreen("Loading the Game", "Start script", nil);
+ CTheScripts::StartTestScript();
+ CTheScripts::Process();
+ TheCamera.Process();
}
-#endif
+
LoadingScreen("Loading the Game", "Load scene", nil);
CModelInfo::RemoveColModelsFromOtherLevels(currLevel);
CCollision::ms_collisionInMemory = currLevel;
@@ -483,7 +603,7 @@ bool CGame::ShutDown(void)
CPlane::Shutdown();
CTrain::Shutdown();
CSpecialFX::Shutdown();
-#ifndef PS2
+#if GTA_VERSION > GTA3_PS2_160
CGarages::Shutdown();
#endif
CMovingThings::Shutdown();
@@ -524,7 +644,9 @@ bool CGame::ShutDown(void)
CSkidmarks::Shutdown();
CWeaponEffects::Shutdown();
CParticle::Shutdown();
+#if GTA_VERSION > GTA3_PS2_160
CPools::ShutDown();
+#endif
CTxdStore::RemoveTxdSlot(gameTxdSlot);
CdStreamRemoveImages();
return true;
@@ -550,7 +672,7 @@ void CGame::ReInitGameObjectVariables(void)
CWorld::bDoingCarCollisions = false;
CHud::ReInitialise();
CRadar::Initialise();
-#ifdef PS2
+#if GTA_VERSION <= GTA3_PS2_160
gStartX = -180.0f;
gStartY = 180.0f;
gStartZ = 14.0f;
@@ -573,15 +695,19 @@ void CGame::ReInitGameObjectVariables(void)
CWorld::Players[i].Clear();
CWorld::PlayerInFocus = 0;
-#ifdef PS2
+#if GTA_VERSION <= GTA3_PS2_160
CWeaponEffects::Init();
CSkidmarks::Init();
#endif
CAntennas::Init();
CGlass::Init();
gPhoneInfo.Initialise();
+
+ PUSH_MEMID(MEMID_SCRIPT);
CTheScripts::Init();
CGangs::Initialise();
+ POP_MEMID();
+
CTimer::Initialise();
CClock::Initialise(1000);
CTheCarGenerators::Init();
@@ -592,7 +718,7 @@ void CGame::ReInitGameObjectVariables(void)
CPickups::Init();
CPacManPickups::Init();
CGarages::Init();
-#ifdef PS2
+#if GTA_VERSION <= GTA3_PS2_160
CClouds::Init();
CRemote::Init();
#endif
@@ -807,7 +933,7 @@ void CGame::InitialiseWhenRestarting(void)
void CGame::Process(void)
{
CPad::UpdatePads();
-#ifdef GTA_PS2
+#ifdef USE_CUSTOM_ALLOCATOR
ProcessTidyUpMemory();
#endif
TheCamera.SetMotionBlurAlpha(0);
@@ -817,8 +943,12 @@ void CGame::Process(void)
DebugMenuProcess();
#endif
CCutsceneMgr::Update();
+
+ PUSH_MEMID(MEMID_FRONTEND);
if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused())
FrontEndMenuManager.Process();
+ POP_MEMID();
+
CStreaming::Update();
if (!CTimer::GetIsPaused())
{
@@ -831,7 +961,11 @@ void CGame::Process(void)
CPad::DoCheats();
CClock::Update();
CWeather::Update();
+
+ PUSH_MEMID(MEMID_SCRIPT);
CTheScripts::Process();
+ POP_MEMID();
+
CCollision::Update();
CTrain::UpdateTrains();
CPlane::UpdatePlanes();
@@ -855,7 +989,11 @@ void CGame::Process(void)
CWaterCannons::Update();
CUserDisplay::Process();
CReplay::Update();
+
+ PUSH_MEMID(MEMID_WORLD);
CWorld::Process();
+ POP_MEMID();
+
gAccidentManager.Update();
CPacManPickups::Update();
CPickups::Update();
@@ -876,33 +1014,35 @@ void CGame::Process(void)
gPhoneInfo.Update();
if (!CReplay::IsPlayingBack())
{
+ PUSH_MEMID(MEMID_CARS);
CCarCtrl::GenerateRandomCars();
CRoadBlocks::GenerateRoadBlocks();
CCarCtrl::RemoveDistantCars();
+ POP_MEMID();
}
}
-#ifdef PS2
+#ifdef GTA_PS2
CMemCheck::DoTest();
#endif
}
void CGame::DrasticTidyUpMemory(bool)
{
-#ifdef PS2
+#ifdef USE_CUSTOM_ALLOCATOR
// meow
#endif
}
void CGame::TidyUpMemory(bool, bool)
{
-#ifdef PS2
+#ifdef USE_CUSTOM_ALLOCATOR
// meow
#endif
}
void CGame::ProcessTidyUpMemory(void)
{
-#ifdef PS2
+#ifdef USE_CUSTOM_ALLOCATOR
// meow
#endif
}