re3-wiiu/src/core/Game.cpp

887 lines
22 KiB
C++
Raw Normal View History

#pragma warning( push )
#pragma warning( disable : 4005)
#pragma warning( pop )
2019-05-15 16:52:37 +02:00
#include "common.h"
2020-05-11 04:55:57 +02:00
#include "platform.h"
2020-04-17 15:31:11 +02:00
2019-05-15 16:52:37 +02:00
#include "Game.h"
2019-07-31 17:54:18 +02:00
#include "main.h"
#include "RwHelper.h"
2020-01-11 13:50:11 +01:00
#include "Accident.h"
2019-10-19 00:23:40 +02:00
#include "Antennas.h"
#include "Bridge.h"
#include "Camera.h"
#include "CarCtrl.h"
#include "CarGen.h"
2019-07-24 18:55:43 +02:00
#include "CdStream.h"
2019-10-19 00:23:40 +02:00
#include "Clock.h"
#include "Clouds.h"
#include "Collision.h"
2020-03-22 15:23:40 +01:00
#include "Console.h"
2019-10-19 00:23:40 +02:00
#include "Coronas.h"
#include "Cranes.h"
2020-03-22 15:23:40 +01:00
#include "Credits.h"
2019-10-19 00:23:40 +02:00
#include "CutsceneMgr.h"
#include "DMAudio.h"
2019-10-19 00:23:40 +02:00
#include "Darkel.h"
2020-03-22 15:23:40 +01:00
#include "Debug.h"
2019-10-19 00:23:40 +02:00
#include "EventList.h"
#include "FileLoader.h"
2019-07-24 18:55:43 +02:00
#include "FileMgr.h"
2019-10-19 00:23:40 +02:00
#include "Fire.h"
#include "Fluff.h"
#include "Font.h"
#include "Frontend.h"
#include "GameLogic.h"
#include "Garages.h"
#include "GenericGameStorage.h"
2019-10-19 00:23:40 +02:00
#include "Glass.h"
#include "HandlingMgr.h"
2019-10-19 00:23:40 +02:00
#include "Heli.h"
#include "Hud.h"
2020-03-22 15:23:40 +01:00
#include "IniFile.h"
#include "Lights.h"
#include "MBlur.h"
2020-03-22 15:23:40 +01:00
#include "Messages.h"
2020-06-27 23:01:51 +02:00
#include "MemoryCard.h"
2019-10-19 00:23:40 +02:00
#include "Pad.h"
#include "Particle.h"
#include "ParticleObject.h"
#include "PedRoutes.h"
2019-10-19 00:23:40 +02:00
#include "Phones.h"
#include "Pickups.h"
#include "Plane.h"
#include "PlayerSkin.h"
2019-10-19 00:23:40 +02:00
#include "Population.h"
#include "Radar.h"
2019-10-19 00:23:40 +02:00
#include "Record.h"
#include "References.h"
2019-10-19 00:23:40 +02:00
#include "Renderer.h"
#include "Replay.h"
2020-03-22 15:23:40 +01:00
#include "Restart.h"
2019-10-19 00:23:40 +02:00
#include "RoadBlocks.h"
#include "Rubbish.h"
#include "SceneEdit.h"
#include "Script.h"
#include "Shadows.h"
#include "Skidmarks.h"
2020-05-23 19:06:52 +02:00
#include "SetPieces.h"
2019-10-19 00:23:40 +02:00
#include "SpecialFX.h"
#include "Sprite2d.h"
2020-03-22 15:23:40 +01:00
#include "Stats.h"
2019-10-19 00:23:40 +02:00
#include "Streaming.h"
#include "SurfaceTable.h"
#include "TempColModels.h"
2020-04-19 18:34:08 +02:00
#include "Timecycle.h"
2019-10-19 00:23:40 +02:00
#include "TrafficLights.h"
#include "Train.h"
2019-10-21 15:47:08 +02:00
#include "TxdStore.h"
2019-10-19 00:23:40 +02:00
#include "User.h"
#include "VisibilityPlugins.h"
2019-10-19 00:23:40 +02:00
#include "WaterCannon.h"
2020-03-22 15:23:40 +01:00
#include "WaterLevel.h"
2019-10-19 00:23:40 +02:00
#include "Weapon.h"
2020-03-22 15:23:40 +01:00
#include "WeaponEffects.h"
2019-10-19 00:23:40 +02:00
#include "Weather.h"
#include "World.h"
#include "ZoneCull.h"
#include "Zones.h"
#include "Occlusion.h"
2020-04-24 13:27:02 +02:00
#include "debugmenu.h"
2020-07-27 15:04:05 +02:00
#include "Ropes.h"
2020-08-05 04:11:42 +02:00
#include "WindModifiers.h"
2020-10-09 14:53:22 +02:00
#include "WaterCreatures.h"
2020-08-11 18:39:53 +02:00
#include "postfx.h"
2020-08-19 16:10:22 +02:00
#include "custompipes.h"
2020-11-19 19:07:32 +01:00
#include "screendroplets.h"
#ifdef USE_TEXTURE_POOL
#include "TexturePools.h"
#endif
2019-05-15 16:52:37 +02:00
2020-04-17 07:54:14 +02:00
eLevelName CGame::currLevel;
int32 CGame::currArea;
2020-04-17 07:54:14 +02:00
bool CGame::bDemoMode = true;
bool CGame::nastyGame = true;
bool CGame::frenchGame;
bool CGame::germanGame;
bool CGame::noProstitutes;
bool CGame::playingIntro;
char CGame::aDatFile[32];
2020-03-29 08:35:13 +02:00
#ifdef MORE_LANGUAGES
bool CGame::russianGame = false;
2020-04-26 22:49:24 +02:00
bool CGame::japaneseGame = false;
2020-03-29 08:35:13 +02:00
#endif
2019-05-31 11:44:43 +02:00
2020-04-17 07:54:14 +02:00
int gameTxdSlot;
2019-07-24 18:55:43 +02:00
2020-08-29 18:22:25 +02:00
// --MIAMI: File done
2020-06-27 23:01:51 +02:00
bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
void DoRWStuffEndOfFrame(void);
#ifdef PS2_MENU
2020-06-27 23:01:51 +02:00
void MessageScreen(char *msg)
{
//TODO: stretch_screen
CRect rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
CRGBA color(255, 255, 255, 255);
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(FONT_BANK);
CFont::SetBackgroundOff();
CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(190.0f)); // 450.0f
CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f));
CFont::SetCentreOn();
CFont::SetCentreSize(SCREEN_SCALE_X(450.0f));
2020-06-27 23:01:51 +02:00
CFont::SetJustifyOff();
CFont::SetColor(CRGBA(255, 255, 255, 255));
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(msg));
CFont::DrawFonts();
DoRWStuffEndOfFrame();
}
#endif
2020-06-27 23:01:51 +02:00
2019-07-24 18:55:43 +02:00
bool
CGame::InitialiseOnceBeforeRW(void)
{
CFileMgr::Initialise();
CdStreamInit(MAX_CDCHANNELS);
2020-08-29 18:22:25 +02:00
debug("size of matrix %d\n", sizeof(CMatrix));
debug("size of placeable %d\n", sizeof(CPlaceable));
debug("size of entity %d\n", sizeof(CEntity));
debug("size of building %d\n", sizeof(CBuilding));
debug("size of dummy %d\n", sizeof(CDummy));
2020-08-11 18:39:53 +02:00
#ifdef EXTENDED_COLOURFILTER
CPostFX::InitOnce();
#endif
2019-07-24 18:55:43 +02:00
return true;
}
2020-07-29 14:24:42 +02:00
#ifndef LIBRW
#ifdef PS2_MATFX
void ReplaceMatFxCallback();
2020-07-29 14:24:42 +02:00
#endif // PS2_MATFX
2020-07-29 14:31:34 +02:00
#ifdef PS2_ALPHA_TEST
2020-07-29 14:24:42 +02:00
void ReplaceAtomicPipeCallback();
2020-07-29 14:31:34 +02:00
#endif // PS2_ALPHA_TEST
2020-07-29 14:24:42 +02:00
#endif // !LIBRW
bool
CGame::InitialiseRenderWare(void)
{
2020-08-29 18:22:25 +02:00
ValidateVersion();
2020-04-17 07:54:14 +02:00
#ifdef USE_TEXTURE_POOL
_TexturePoolsInitialise();
2020-04-17 07:54:14 +02:00
#endif
CTxdStore::Initialise();
CVisibilityPlugins::Initialise();
/* Create camera */
Scene.camera = CameraCreate(RsGlobal.width, RsGlobal.height, TRUE);
2020-03-29 15:32:11 +02:00
ASSERT(Scene.camera != nil);
if (!Scene.camera)
{
return (false);
}
2020-03-29 15:32:11 +02:00
RwCameraSetFarClipPlane(Scene.camera, 2000.0f);
RwCameraSetNearClipPlane(Scene.camera, 0.9f);
2020-03-29 15:32:11 +02:00
CameraSize(Scene.camera, nil, DEFAULT_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
/* Create a world */
RwBBox bbox;
2020-03-29 15:32:11 +02:00
bbox.sup.x = bbox.sup.y = bbox.sup.z = 10000.0f;
bbox.inf.x = bbox.inf.y = bbox.inf.z = -10000.0f;
Scene.world = RpWorldCreate(&bbox);
2020-03-29 15:32:11 +02:00
ASSERT(Scene.world != nil);
if (!Scene.world)
{
CameraDestroy(Scene.camera);
2020-03-29 15:32:11 +02:00
Scene.camera = nil;
return (false);
}
/* Add the camera to the world */
RpWorldAddCamera(Scene.world, Scene.camera);
LightsCreate(Scene.world);
CreateDebugFont();
2020-04-20 16:05:39 +02:00
#ifdef LIBRW
#ifdef PS2_MATFX
rw::MatFX::modulateEnvMap = true;
#else
rw::MatFX::modulateEnvMap = false;
#endif
2020-07-29 14:24:42 +02:00
#else
#ifdef PS2_MATFX
ReplaceMatFxCallback();
2020-07-29 14:24:42 +02:00
#endif // PS2_MATFX
2020-07-29 14:31:34 +02:00
#ifdef PS2_ALPHA_TEST
2020-07-29 14:24:42 +02:00
ReplaceAtomicPipeCallback();
2020-07-29 14:31:34 +02:00
#endif // PS2_ALPHA_TEST
2020-07-29 14:24:42 +02:00
#endif // LIBRW
CFont::Initialise();
CHud::Initialise();
CPlayerSkin::Initialise();
return (true);
}
void CGame::ShutdownRenderWare(void)
{
DestroySplashScreen();
CHud::Shutdown();
CFont::Shutdown();
for ( int32 i = 0; i < NUMPLAYERS; i++ )
CWorld::Players[i].DeletePlayerSkin();
CPlayerSkin::Shutdown();
DestroyDebugFont();
/* Destroy world */
LightsDestroy(Scene.world);
RpWorldRemoveCamera(Scene.world, Scene.camera);
RpWorldDestroy(Scene.world);
/* destroy camera */
CameraDestroy(Scene.camera);
2020-03-29 15:32:11 +02:00
Scene.world = nil;
Scene.camera = nil;
CVisibilityPlugins::Shutdown();
2020-04-17 07:54:14 +02:00
#ifdef USE_TEXTURE_POOL
_TexturePoolsShutdown();
2020-04-17 07:54:14 +02:00
#endif
}
bool CGame::InitialiseOnceAfterRW(void)
{
TheText.Load();
CTimer::Initialise();
CTempColModels::Initialise();
mod_HandlingManager.Initialise();
CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
CPedStats::Initialise();
CTimeCycle::Initialise();
2020-07-06 18:26:06 +02:00
DMAudio.Initialise();
if ( DMAudio.GetNum3DProvidersAvailable() == 0 )
2020-07-06 18:26:06 +02:00
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = NO_AUDIO_PROVIDER;
2020-07-06 18:26:06 +02:00
if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == AUDIO_PROVIDER_NOT_DETERMINED || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 )
{
2020-05-22 01:44:01 +02:00
FrontEndMenuManager.m_PrefsSpeakers = 0;
2020-07-06 18:26:06 +02:00
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = DMAudio.AutoDetect3DProviders();
}
DMAudio.SetCurrent3DProvider(FrontEndMenuManager.m_nPrefsAudio3DProviderIndex);
2020-05-22 01:44:01 +02:00
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);
return true;
}
void
CGame::FinalShutdown(void)
{
CTxdStore::Shutdown();
CPedStats::Shutdown();
CdStreamShutdown();
}
2020-03-22 15:23:40 +01:00
bool CGame::Initialise(const char* datFile)
{
ResetLoadingScreenBar();
strcpy(aDatFile, datFile);
CPools::Initialise();
CIniFile::LoadIniFile();
2020-08-29 18:22:25 +02:00
#ifdef USE_TEXTURE_POOL
_TexturePoolsUnknown(false);
#endif
2020-05-05 23:27:43 +02:00
currLevel = LEVEL_BEACH;
2020-08-29 18:22:25 +02:00
currArea = AREA_MAIN_MAP;
2020-03-22 15:23:40 +01:00
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);
CGameLogic::InitAtStartOfGame();
CReferences::Init();
TheCamera.Init();
TheCamera.SetRwCamera(Scene.camera);
CDebug::DebugInitTextBuffer();
ThePaths.Init();
ThePaths.AllocatePathFindInfoMem(4500);
2020-08-19 20:11:19 +02:00
CScriptPaths::Init();
2020-03-22 15:23:40 +01:00
CWeather::Init();
CCullZones::Init();
COcclusion::Init();
2020-03-22 15:23:40 +01:00
CCollision::Init();
2020-05-23 19:06:52 +02:00
CSetPieces::Init();
2020-03-22 15:23:40 +01:00
CTheZones::Init();
CUserDisplay::Init();
CMessages::Init();
CMessages::ClearAllMessagesDisplayedByGame();
CRecordDataForGame::Init();
CRestart::Initialise();
CWorld::Initialise();
CParticle::Initialise();
2020-06-27 23:01:51 +02:00
#ifdef PS2
gStartX = -180.0f;
gStartY = 180.0f;
gStartZ = 14.0f;
#endif
2020-03-22 15:23:40 +01:00
CAnimManager::Initialise();
CCutsceneMgr::Initialise();
CCarCtrl::Init();
InitModelIndices();
CModelInfo::Initialise();
CPickups::Init();
CTheCarGenerators::Init();
CdStreamAddImage("MODELS\\GTA3.IMG");
CFileLoader::LoadLevel("DATA\\DEFAULT.DAT");
CFileLoader::LoadLevel(datFile);
2020-08-19 16:10:22 +02:00
#ifdef EXTENDED_PIPELINES
// for generic fallback
CustomPipes::SetTxdFindCallback();
#endif
2020-08-29 18:22:25 +02:00
LoadingScreen("Loading the Game", "Add Particles", nil);
2020-03-22 15:23:40 +01:00
CWorld::AddParticles();
CVehicleModelInfo::LoadVehicleColours();
CVehicleModelInfo::LoadEnvironmentMaps();
CTheZones::PostZoneCreation();
2020-08-29 18:22:25 +02:00
LoadingScreen("Loading the Game", "Setup paths", nil);
2020-03-22 15:23:40 +01:00
ThePaths.PreparePathData();
for (int i = 0; i < NUMPLAYERS; i++)
CWorld::Players[i].Clear();
CWorld::Players[0].LoadPlayerSkin();
TestModelIndices();
LoadingScreen("Loading the Game", "Setup water", nil);
2020-05-27 20:50:01 +02:00
WaterLevelInitialise("DATA\\WATER.DAT");
2020-03-22 15:23:40 +01:00
TheConsole.Init();
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
LoadingScreen("Loading the Game", "Setup streaming", nil);
CStreaming::LoadInitialVehicles();
CStreaming::LoadInitialPeds();
2020-07-13 16:43:09 +02:00
CStreaming::RequestBigBuildings(LEVEL_GENERIC);
2020-03-22 15:23:40 +01:00
CStreaming::LoadAllRequestedModels(false);
2020-08-29 18:22:25 +02:00
CStreaming::RemoveIslandsNotUsed(currLevel);
2020-07-22 13:56:28 +02:00
printf("Streaming uses %zuK of its memory", CStreaming::ms_memoryUsed / 1024); // original modifier was %d
2020-03-22 15:23:40 +01:00
LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen());
CAnimManager::LoadAnimFiles();
2020-05-15 16:30:25 +02:00
CStreaming::LoadInitialWeapons();
2020-08-29 18:22:25 +02:00
CStreaming::LoadAllRequestedModels(0);
2020-03-22 15:23:40 +01:00
CPed::Initialise();
CRouteNode::Initialise();
CEventList::Initialise();
2020-11-19 19:07:32 +01:00
#ifdef SCREEN_DROPLETS
ScreenDroplets::Initialise();
#endif
2020-03-22 15:23:40 +01:00
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();
CWorld::PlayerInFocus = 0;
CCoronas::Init();
CShadows::Init();
CWeaponEffects::Init();
CSkidmarks::Init();
CAntennas::Init();
CGlass::Init();
gPhoneInfo.Initialise();
2020-04-12 11:06:33 +02:00
CSceneEdit::Initialise();
2020-03-22 15:23:40 +01:00
LoadingScreen("Loading the Game", "Load scripts", nil);
CTheScripts::Init();
CGangs::Initialise();
2020-03-22 15:23:40 +01:00
LoadingScreen("Loading the Game", "Setup game variables", nil);
CClock::Initialise(1000);
CHeli::InitHelis();
CCranes::InitCranes();
CMovingThings::Init();
CDarkel::Init();
CStats::Init();
CPacManPickups::Init();
CRubbish::Init();
CClouds::Init();
CSpecialFX::Init();
2020-07-27 15:04:05 +02:00
CRopes::Init();
2020-03-22 15:23:40 +01:00
CWaterCannons::Init();
CBridge::Init();
CGarages::Init();
2020-07-27 15:04:05 +02:00
LoadingScreen("Loading the Game", "Position dynamic objects", nil);
2020-03-22 15:23:40 +01:00
LoadingScreen("Loading the Game", "Initialise vehicle paths", nil);
CTrain::InitTrains();
CPlane::InitPlanes();
CCredits::Init();
CRecordDataForChase::Init();
CReplay::Init();
2020-06-27 23:01:51 +02:00
#ifdef PS2_MENU
if ( !TheMemoryCard.m_bWantToLoad )
{
#endif
2020-07-27 15:04:05 +02:00
LoadingScreen("Loading the Game", "Start script", nil);
2020-03-22 15:23:40 +01:00
CTheScripts::StartTestScript();
CTheScripts::Process();
TheCamera.Process();
2020-06-27 23:01:51 +02:00
#ifdef PS2_MENU
}
#endif
2020-03-22 15:23:40 +01:00
LoadingScreen("Loading the Game", "Load scene", nil);
CCollision::ms_collisionInMemory = currLevel;
2020-03-22 15:23:40 +01:00
for (int i = 0; i < MAX_PADS; i++)
CPad::GetPad(i)->Clear(true);
2020-08-29 18:22:25 +02:00
#ifdef USE_TEXTURE_POOL
_TexturePoolsUnknown(true);
#endif
DMAudio.SetStartingTrackPositions(true);
2020-07-27 15:04:05 +02:00
DMAudio.ChangeMusicMode(MUSICMODE_GAME);
2020-03-22 15:23:40 +01:00
return true;
}
bool CGame::ShutDown(void)
{
2020-08-29 18:22:25 +02:00
#ifdef USE_TEXTURE_POOL
_TexturePoolsUnknown(false);
#endif
CReplay::FinishPlayback();
2020-08-29 18:22:25 +02:00
CReplay::EmptyReplayBuffer();
CPlane::Shutdown();
CTrain::Shutdown();
2020-08-19 20:11:19 +02:00
CScriptPaths::Shutdown();
2020-10-09 14:53:22 +02:00
CWaterCreatures::RemoveAll();
CSpecialFX::Shutdown();
2020-03-29 17:53:58 +02:00
#ifndef PS2
CGarages::Shutdown();
2020-03-29 17:53:58 +02:00
#endif
CMovingThings::Shutdown();
gPhoneInfo.Shutdown();
CWeapon::ShutdownWeapons();
CPedType::Shutdown();
CMBlur::MotionBlurClose();
for (int32 i = 0; i < NUMPLAYERS; i++)
{
if ( CWorld::Players[i].m_pPed )
{
CWorld::Remove(CWorld::Players[i].m_pPed);
delete CWorld::Players[i].m_pPed;
2020-03-29 15:32:11 +02:00
CWorld::Players[i].m_pPed = nil;
}
CWorld::Players[i].Clear();
}
CRenderer::Shutdown();
CWorld::ShutDown();
DMAudio.DestroyAllGameCreatedEntities();
CModelInfo::ShutDown();
CAnimManager::Shutdown();
CCutsceneMgr::Shutdown();
CVehicleModelInfo::DeleteVehicleColourTextures();
CVehicleModelInfo::ShutdownEnvironmentMaps();
CRadar::Shutdown();
CStreaming::Shutdown();
CTxdStore::GameShutdown();
CCollision::Shutdown();
2020-08-29 18:22:25 +02:00
CWaterLevel::DestroyWavyAtomic();
CRubbish::Shutdown();
CClouds::Shutdown();
CShadows::Shutdown();
CCoronas::Shutdown();
CSkidmarks::Shutdown();
CWeaponEffects::Shutdown();
CParticle::Shutdown();
CPools::ShutDown();
CTxdStore::RemoveTxdSlot(gameTxdSlot);
2020-08-29 18:22:25 +02:00
CMBlur::MotionBlurClose();
CdStreamRemoveImages();
2020-08-29 18:22:25 +02:00
#ifdef USE_TEXTURE_POOL
_TexturePoolsFinalShutdown();
#endif
return true;
}
void CGame::ReInitGameObjectVariables(void)
{
CGameLogic::InitAtStartOfGame();
2020-06-27 23:01:51 +02:00
#ifdef PS2_MENU
if ( !TheMemoryCard.m_bWantToLoad )
{
#endif
TheCamera.Init();
TheCamera.SetRwCamera(Scene.camera);
2020-06-27 23:01:51 +02:00
#ifdef PS2_MENU
}
#endif
CDebug::DebugInitTextBuffer();
CWeather::Init();
CUserDisplay::Init();
CMessages::Init();
CRestart::Initialise();
CWorld::bDoingCarCollisions = false;
CHud::ReInitialise();
CRadar::Initialise();
2020-06-27 23:01:51 +02:00
#ifdef PS2
gStartX = -180.0f;
gStartY = 180.0f;
gStartZ = 14.0f;
#endif
CCarCtrl::ReInit();
CTimeCycle::Initialise();
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
2020-07-13 16:43:09 +02:00
CStreaming::RequestBigBuildings(LEVEL_GENERIC);
2020-08-29 18:22:25 +02:00
CStreaming::RemoveIslandsNotUsed(LEVEL_BEACH);
CStreaming::RemoveIslandsNotUsed(LEVEL_MAINLAND);
CStreaming::LoadAllRequestedModels(false);
2020-08-29 18:22:25 +02:00
currArea = AREA_MAIN_MAP;
CPed::Initialise();
CEventList::Initialise();
2020-11-19 19:07:32 +01:00
#ifdef SCREEN_DROPLETS
ScreenDroplets::Initialise();
#endif
CWeapon::InitialiseWeapons();
CPopulation::Initialise();
for (int i = 0; i < NUMPLAYERS; i++)
CWorld::Players[i].Clear();
CWorld::PlayerInFocus = 0;
2020-06-27 23:01:51 +02:00
#ifdef PS2
CWeaponEffects::Init();
CSkidmarks::Init();
#endif
CAntennas::Init();
CGlass::Init();
gPhoneInfo.Initialise();
CTheScripts::Init();
CGangs::Initialise();
CTimer::Initialise();
CClock::Initialise(1000);
CTheCarGenerators::Init();
CHeli::InitHelis();
CMovingThings::Init();
CDarkel::Init();
CStats::Init();
CPickups::Init();
CPacManPickups::Init();
CGarages::Init();
2020-06-27 23:01:51 +02:00
#ifdef PS2
CClouds::Init();
CRemote::Init();
#endif
CSpecialFX::Init();
2020-07-27 15:04:05 +02:00
CRopes::Init();
CWaterCannons::Init();
2020-08-19 20:11:19 +02:00
CScriptPaths::Init();
CParticle::ReloadConfig();
2020-03-29 15:32:11 +02:00
2020-06-27 23:01:51 +02:00
#ifdef PS2_MENU
if ( !TheMemoryCard.m_bWantToLoad )
#else
if ( !FrontEndMenuManager.m_bWantToLoad )
2020-06-27 23:01:51 +02:00
#endif
{
CCranes::InitCranes();
CTheScripts::StartTestScript();
CTheScripts::Process();
TheCamera.Process();
CTrain::InitTrains();
CPlane::InitPlanes();
}
for (int32 i = 0; i < MAX_PADS; i++)
CPad::GetPad(i)->Clear(true);
}
void CGame::ReloadIPLs(void)
{
// Empty and unused
}
void CGame::ShutDownForRestart(void)
{
2020-08-29 18:22:25 +02:00
#ifdef USE_TEXTURE_POOL
_TexturePoolsUnknown(false);
#endif
CReplay::FinishPlayback();
CReplay::EmptyReplayBuffer();
DMAudio.DestroyAllGameCreatedEntities();
2020-08-29 18:22:25 +02:00
CMovingThings::Shutdown();
for (int i = 0; i < NUMPLAYERS; i++)
CWorld::Players[i].Clear();
2020-03-29 15:32:11 +02:00
CGarages::SetAllDoorsBackToOriginalHeight();
CTheScripts::UndoBuildingSwaps();
CTheScripts::UndoEntityInvisibilitySettings();
CWorld::ClearForRestart();
2020-05-31 19:59:01 +02:00
CGameLogic::ClearShortCut();
CTimer::Shutdown();
2020-08-20 23:43:13 +02:00
CStreaming::ReInit();
CRadar::RemoveRadarSections();
FrontEndMenuManager.UnloadTextures();
2020-07-03 01:18:06 +02:00
CParticleObject::RemoveAllExpireableParticleObjects();
2020-10-09 14:53:22 +02:00
CWaterCreatures::RemoveAll();
2020-05-23 19:06:52 +02:00
CSetPieces::Init();
CPedType::Shutdown();
CSpecialFX::Shutdown();
}
void CGame::InitialiseWhenRestarting(void)
{
CRect rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
CRGBA color(255, 255, 255, 255);
CTimer::Initialise();
CSprite2d::SetRecipNearClip();
2020-05-24 01:59:30 +02:00
if (b_FoundRecentSavedGameWantToLoad || FrontEndMenuManager.m_bWantToLoad)
{
LoadSplash("splash1");
#ifndef XBOX_MESSAGE_SCREEN
2020-05-24 01:59:30 +02:00
if (FrontEndMenuManager.m_bWantToLoad)
FrontEndMenuManager.MessageScreen("FELD_WR", true);
#endif
2020-05-24 01:59:30 +02:00
}
b_FoundRecentSavedGameWantToLoad = false;
TheCamera.Init();
if ( FrontEndMenuManager.m_bWantToLoad == true )
{
#ifdef XBOX_MESSAGE_SCREEN
FrontEndMenuManager.SetDialogTimer(1000);
DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 0);
CSprite2d::InitPerFrame();
CFont::InitPerFrame();
FrontEndMenuManager.DrawOverlays();
DoRWStuffEndOfFrame();
#endif
RestoreForStartLoad();
}
ReInitGameObjectVariables();
if ( FrontEndMenuManager.m_bWantToLoad == true )
{
2020-08-29 18:22:25 +02:00
FrontEndMenuManager.m_bWantToLoad = false;
// TODO(Miami)
//InitRadioStationPositionList();
if ( GenericLoad() == true )
{
DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds());
CTrain::InitTrains();
CPlane::InitPlanes();
}
else
{
for ( int32 i = 0; i < 50; i++ )
{
HandleExit();
FrontEndMenuManager.MessageScreen("FED_LFL", true); // Loading save game has failed. The game will restart now.
}
2020-08-29 18:22:25 +02:00
TheCamera.SetFadeColour(0, 0, 0);
ShutDownForRestart();
CTimer::Stop();
CTimer::Initialise();
FrontEndMenuManager.m_bWantToLoad = false;
ReInitGameObjectVariables();
currLevel = LEVEL_GENERIC;
CCollision::SortOutCollisionAfterLoad();
}
#ifdef XBOX_MESSAGE_SCREEN
FrontEndMenuManager.ProcessDialogTimer();
#endif
}
CTimer::Update();
DMAudio.ChangeMusicMode(MUSICMODE_GAME);
2020-08-29 18:22:25 +02:00
#ifdef USE_TEXTURE_POOL
_TexturePoolsUnknown(true);
#endif
}
2019-10-19 00:23:40 +02:00
void CGame::Process(void)
{
CPad::UpdatePads();
2020-04-09 05:20:44 +02:00
#ifdef GTA_PS2
ProcessTidyUpMemory();
#endif
2020-05-09 15:06:13 +02:00
#ifdef DEBUGMENU
2019-10-25 01:25:11 +02:00
DebugMenuProcess();
2020-05-09 15:06:13 +02:00
#endif
2019-10-19 00:23:40 +02:00
CCutsceneMgr::Update();
2019-10-19 13:12:18 +02:00
if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused())
2019-10-19 00:23:40 +02:00
FrontEndMenuManager.Process();
2020-08-29 18:22:25 +02:00
CTheZones::Update();
// DRM call in here
uint32 startTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond();
2019-10-19 00:23:40 +02:00
CStreaming::Update();
2020-08-29 18:22:25 +02:00
uint32 processTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond() - startTime;
2020-08-05 04:11:42 +02:00
CWindModifiers::Number = 0;
2019-10-19 00:23:40 +02:00
if (!CTimer::GetIsPaused())
{
CSprite2d::SetRecipNearClip();
CSprite2d::InitPerFrame();
CFont::InitPerFrame();
CRecordDataForGame::SaveOrRetrieveDataForThisFrame();
CRecordDataForChase::SaveOrRetrieveDataForThisFrame();
CPad::DoCheats();
CClock::Update();
CWeather::Update();
CTheScripts::Process();
CCollision::Update();
2020-08-19 20:11:19 +02:00
CScriptPaths::Update();
2019-10-19 00:23:40 +02:00
CTrain::UpdateTrains();
CPlane::UpdatePlanes();
CHeli::UpdateHelis();
CDarkel::Update();
CSkidmarks::Update();
CAntennas::Update();
CGlass::Update();
CSceneEdit::Update();
2020-05-23 19:06:52 +02:00
CSetPieces::Update();
2019-10-19 00:23:40 +02:00
CEventList::Update();
CParticle::Update();
gFireManager.Update();
2020-08-29 18:22:25 +02:00
if (processTime >= 2) {
CPopulation::Update(false);
} else {
uint32 startTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond();
CPopulation::Update(true);
processTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond() - startTime;
}
2019-10-19 00:23:40 +02:00
CWeapon::UpdateWeapons();
if (!CCutsceneMgr::IsRunning())
CTheCarGenerators::Process();
if (!CReplay::IsPlayingBack())
CCranes::UpdateCranes();
CClouds::Update();
CMovingThings::Update();
CWaterCannons::Update();
CUserDisplay::Process();
CReplay::Update();
CWorld::Process();
gAccidentManager.Update();
CPacManPickups::Update();
CPickups::Update();
CGarages::Update();
CRubbish::Update();
CSpecialFX::Update();
2020-07-27 15:04:05 +02:00
CRopes::Update();
2019-10-19 00:23:40 +02:00
CTimeCycle::Update();
if (CReplay::ShouldStandardCameraBeProcessed())
TheCamera.Process();
CCullZones::Update();
if (!CReplay::IsPlayingBack())
CGameLogic::Update();
CBridge::Update();
CCoronas::DoSunAndMoon();
CCoronas::Update();
CShadows::UpdateStaticShadows();
CShadows::UpdatePermanentShadows();
gPhoneInfo.Update();
if (!CReplay::IsPlayingBack())
{
2020-08-29 18:22:25 +02:00
if (processTime < 2)
CCarCtrl::GenerateRandomCars();
2019-10-19 00:23:40 +02:00
CRoadBlocks::GenerateRoadBlocks();
CCarCtrl::RemoveDistantCars();
2020-08-29 18:22:25 +02:00
CCarCtrl::RemoveCarsIfThePoolGetsFull();
2019-10-19 00:23:40 +02:00
}
}
}
2019-07-24 18:55:43 +02:00
void
CGame::InitAfterFocusLoss()
{
2020-05-24 01:59:30 +02:00
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = FrontEndMenuManager.m_lastWorking3DAudioProvider;
DMAudio.SetCurrent3DProvider(FrontEndMenuManager.m_lastWorking3DAudioProvider);
if (!FrontEndMenuManager.m_bGameNotLoaded && !FrontEndMenuManager.m_bMenuActive)
2020-05-22 15:04:52 +02:00
FrontEndMenuManager.m_bStartUpFrontEndRequested = true;
}
2020-05-27 20:50:01 +02:00
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)
2019-10-19 00:23:40 +02:00
{
2020-08-29 18:22:25 +02:00
#ifdef USE_TEXTURE_POOL
// TODO
#endif
#ifdef PS2
// meow
#endif
2019-10-19 00:23:40 +02:00
}
2019-07-24 18:55:43 +02:00
2020-08-29 18:22:25 +02:00
void CGame::TidyUpMemory(bool unk1, bool unk2)
2019-10-21 15:47:08 +02:00
{
#ifdef PS2
// meow
2019-10-21 15:47:08 +02:00
#endif
2020-08-29 18:22:25 +02:00
if (unk2) {
DrasticTidyUpMemory(true); // parameter is unknown too
}
}
2019-10-19 00:23:40 +02:00
void CGame::ProcessTidyUpMemory(void)
{
#ifdef PS2
// meow
#endif
}