2020-03-28 20:55:23 +00:00
|
|
|
#pragma warning( push )
|
|
|
|
#pragma warning( disable : 4005)
|
|
|
|
#define DIRECTINPUT_VERSION 0x0800
|
|
|
|
#include <dinput.h>
|
|
|
|
#pragma warning( pop )
|
2019-05-15 14:52:37 +00:00
|
|
|
#include "common.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "win.h"
|
2020-04-17 13:31:11 +00:00
|
|
|
|
2019-05-15 14:52:37 +00:00
|
|
|
#include "Game.h"
|
2019-07-31 15:54:18 +00:00
|
|
|
#include "main.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "RwHelper.h"
|
2020-01-11 12:50:11 +00:00
|
|
|
#include "Accident.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Antennas.h"
|
|
|
|
#include "Bridge.h"
|
|
|
|
#include "Camera.h"
|
|
|
|
#include "CarCtrl.h"
|
|
|
|
#include "CarGen.h"
|
2019-07-24 16:55:43 +00:00
|
|
|
#include "CdStream.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Clock.h"
|
|
|
|
#include "Clouds.h"
|
|
|
|
#include "Collision.h"
|
2020-03-22 14:23:40 +00:00
|
|
|
#include "Console.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Coronas.h"
|
|
|
|
#include "Cranes.h"
|
2020-03-22 14:23:40 +00:00
|
|
|
#include "Credits.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "CutsceneMgr.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "DMAudio.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Darkel.h"
|
2020-03-22 14:23:40 +00:00
|
|
|
#include "Debug.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "EventList.h"
|
|
|
|
#include "FileLoader.h"
|
2019-07-24 16:55:43 +00:00
|
|
|
#include "FileMgr.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Fire.h"
|
|
|
|
#include "Fluff.h"
|
|
|
|
#include "Font.h"
|
|
|
|
#include "Frontend.h"
|
|
|
|
#include "GameLogic.h"
|
|
|
|
#include "Garages.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "GenericGameStorage.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Glass.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "HandlingMgr.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Heli.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "Hud.h"
|
2020-03-22 14:23:40 +00:00
|
|
|
#include "IniFile.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "Lights.h"
|
|
|
|
#include "MBlur.h"
|
2020-03-22 14:23:40 +00:00
|
|
|
#include "Messages.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Pad.h"
|
|
|
|
#include "Particle.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "ParticleObject.h"
|
|
|
|
#include "PedRoutes.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Phones.h"
|
|
|
|
#include "Pickups.h"
|
|
|
|
#include "Plane.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "PlayerSkin.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Population.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "Radar.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Record.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "References.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Renderer.h"
|
|
|
|
#include "Replay.h"
|
2020-03-22 14:23:40 +00:00
|
|
|
#include "Restart.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "RoadBlocks.h"
|
|
|
|
#include "Rubbish.h"
|
|
|
|
#include "SceneEdit.h"
|
|
|
|
#include "Script.h"
|
|
|
|
#include "Shadows.h"
|
|
|
|
#include "Skidmarks.h"
|
|
|
|
#include "SpecialFX.h"
|
|
|
|
#include "Sprite2d.h"
|
2020-03-22 14:23:40 +00:00
|
|
|
#include "Stats.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Streaming.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "SurfaceTable.h"
|
|
|
|
#include "TempColModels.h"
|
2020-04-18 10:29:28 +00:00
|
|
|
#include "TimeCycle.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "TrafficLights.h"
|
|
|
|
#include "Train.h"
|
2019-10-21 13:47:08 +00:00
|
|
|
#include "TxdStore.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "User.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "VisibilityPlugins.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "WaterCannon.h"
|
2020-03-22 14:23:40 +00:00
|
|
|
#include "WaterLevel.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Weapon.h"
|
2020-03-22 14:23:40 +00:00
|
|
|
#include "WeaponEffects.h"
|
2019-10-18 22:23:40 +00:00
|
|
|
#include "Weather.h"
|
|
|
|
#include "World.h"
|
|
|
|
#include "ZoneCull.h"
|
|
|
|
#include "Zones.h"
|
2019-05-15 14:52:37 +00:00
|
|
|
|
2020-03-28 20:55:23 +00:00
|
|
|
|
|
|
|
|
2020-04-17 05:54:14 +00:00
|
|
|
eLevelName CGame::currLevel;
|
|
|
|
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 06:35:13 +00:00
|
|
|
#ifdef MORE_LANGUAGES
|
|
|
|
bool CGame::russianGame = false;
|
|
|
|
#endif
|
2019-05-31 09:44:43 +00:00
|
|
|
|
2020-04-17 05:54:14 +00:00
|
|
|
int gameTxdSlot;
|
2019-07-24 16:55:43 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
CGame::InitialiseOnceBeforeRW(void)
|
|
|
|
{
|
|
|
|
CFileMgr::Initialise();
|
|
|
|
CdStreamInit(MAX_CDCHANNELS);
|
|
|
|
ValidateVersion();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-03-28 20:55:23 +00:00
|
|
|
bool
|
|
|
|
CGame::InitialiseRenderWare(void)
|
|
|
|
{
|
2020-04-17 05:54:14 +00:00
|
|
|
#ifdef USE_TEXTURE_POOL
|
2020-03-28 20:55:23 +00:00
|
|
|
_TexturePoolsInitialise();
|
2020-04-17 05:54:14 +00:00
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
|
|
|
|
CTxdStore::Initialise();
|
|
|
|
CVisibilityPlugins::Initialise();
|
|
|
|
|
|
|
|
/* Create camera */
|
|
|
|
Scene.camera = CameraCreate(RsGlobal.width, RsGlobal.height, TRUE);
|
2020-03-29 13:32:11 +00:00
|
|
|
ASSERT(Scene.camera != nil);
|
2020-03-28 20:55:23 +00:00
|
|
|
if (!Scene.camera)
|
|
|
|
{
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
|
2020-03-29 13:32:11 +00:00
|
|
|
RwCameraSetFarClipPlane(Scene.camera, 2000.0f);
|
|
|
|
RwCameraSetNearClipPlane(Scene.camera, 0.9f);
|
2020-03-28 20:55:23 +00:00
|
|
|
|
2020-03-29 13:32:11 +00:00
|
|
|
CameraSize(Scene.camera, nil, DEFAULT_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
|
2020-03-28 20:55:23 +00:00
|
|
|
|
|
|
|
/* Create a world */
|
|
|
|
RwBBox bbox;
|
|
|
|
|
2020-03-29 13:32:11 +00:00
|
|
|
bbox.sup.x = bbox.sup.y = bbox.sup.z = 10000.0f;
|
|
|
|
bbox.inf.x = bbox.inf.y = bbox.inf.z = -10000.0f;
|
2020-03-28 20:55:23 +00:00
|
|
|
|
|
|
|
Scene.world = RpWorldCreate(&bbox);
|
2020-03-29 13:32:11 +00:00
|
|
|
ASSERT(Scene.world != nil);
|
2020-03-28 20:55:23 +00:00
|
|
|
if (!Scene.world)
|
|
|
|
{
|
|
|
|
CameraDestroy(Scene.camera);
|
2020-03-29 13:32:11 +00:00
|
|
|
Scene.camera = nil;
|
2020-03-28 20:55:23 +00:00
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the camera to the world */
|
|
|
|
RpWorldAddCamera(Scene.world, Scene.camera);
|
|
|
|
LightsCreate(Scene.world);
|
|
|
|
|
|
|
|
CreateDebugFont();
|
|
|
|
|
|
|
|
CFont::Initialise();
|
|
|
|
CHud::Initialise();
|
|
|
|
CPlayerSkin::Initialise();
|
|
|
|
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGame::ShutdownRenderWare(void)
|
|
|
|
{
|
|
|
|
CMBlur::MotionBlurClose();
|
|
|
|
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 13:32:11 +00:00
|
|
|
Scene.world = nil;
|
|
|
|
Scene.camera = nil;
|
2020-03-28 20:55:23 +00:00
|
|
|
|
|
|
|
CVisibilityPlugins::Shutdown();
|
|
|
|
|
2020-04-17 05:54:14 +00:00
|
|
|
#ifdef USE_TEXTURE_POOL
|
2020-03-28 20:55:23 +00:00
|
|
|
_TexturePoolsShutdown();
|
2020-04-17 05:54:14 +00:00
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CGame::InitialiseOnceAfterRW(void)
|
|
|
|
{
|
|
|
|
TheText.Load();
|
|
|
|
DMAudio.Initialise();
|
|
|
|
CTimer::Initialise();
|
|
|
|
CTempColModels::Initialise();
|
|
|
|
mod_HandlingManager.Initialise();
|
|
|
|
CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
|
|
|
|
CPedStats::Initialise();
|
|
|
|
CTimeCycle::Initialise();
|
|
|
|
|
|
|
|
if ( DMAudio.GetNum3DProvidersAvailable() == 0 )
|
|
|
|
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = -1;
|
|
|
|
|
|
|
|
if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -99 || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 )
|
|
|
|
{
|
|
|
|
CMenuManager::m_PrefsSpeakers = 0;
|
|
|
|
|
|
|
|
for ( int32 i = 0; i < DMAudio.GetNum3DProvidersAvailable(); i++ )
|
|
|
|
{
|
|
|
|
wchar buff[64];
|
|
|
|
|
|
|
|
char *name = DMAudio.Get3DProviderName(i);
|
|
|
|
AsciiToUnicode(name, buff);
|
|
|
|
char *providername = UnicodeToAscii(buff);
|
|
|
|
strupr(providername);
|
|
|
|
|
|
|
|
if ( !strcmp(providername, "MILES FAST 2D POSITIONAL AUDIO") )
|
|
|
|
{
|
|
|
|
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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.SetEffectsFadeVol(127);
|
|
|
|
DMAudio.SetMusicFadeVol(127);
|
|
|
|
CWorld::Players[0].SetPlayerSkin(CMenuManager::m_PrefsSkinFile);
|
2020-03-29 13:32:11 +00:00
|
|
|
|
2020-03-28 20:55:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CGame::FinalShutdown(void)
|
|
|
|
{
|
|
|
|
CTxdStore::Shutdown();
|
|
|
|
CPedStats::Shutdown();
|
|
|
|
CdStreamShutdown();
|
|
|
|
}
|
2020-03-22 14:23:40 +00:00
|
|
|
|
|
|
|
bool CGame::Initialise(const char* datFile)
|
|
|
|
{
|
|
|
|
ResetLoadingScreenBar();
|
|
|
|
strcpy(aDatFile, datFile);
|
|
|
|
CPools::Initialise();
|
|
|
|
CIniFile::LoadIniFile();
|
|
|
|
currLevel = LEVEL_INDUSTRIAL;
|
|
|
|
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);
|
|
|
|
CWeather::Init();
|
|
|
|
CCullZones::Init();
|
|
|
|
CCollision::Init();
|
|
|
|
CTheZones::Init();
|
|
|
|
CUserDisplay::Init();
|
|
|
|
CMessages::Init();
|
|
|
|
CMessages::ClearAllMessagesDisplayedByGame();
|
|
|
|
CRecordDataForGame::Init();
|
|
|
|
CRestart::Initialise();
|
|
|
|
CWorld::Initialise();
|
|
|
|
CParticle::Initialise();
|
|
|
|
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);
|
|
|
|
CWorld::AddParticles();
|
|
|
|
CVehicleModelInfo::LoadVehicleColours();
|
|
|
|
CVehicleModelInfo::LoadEnvironmentMaps();
|
|
|
|
CTheZones::PostZoneCreation();
|
|
|
|
LoadingScreen("Loading the Game", "Setup paths", GetRandomSplashScreen());
|
|
|
|
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);
|
|
|
|
CWaterLevel::Initialise("DATA\\WATER.DAT");
|
|
|
|
TheConsole.Init();
|
|
|
|
CDraw::SetFOV(120.0f);
|
|
|
|
CDraw::ms_fLODDistance = 500.0f;
|
|
|
|
LoadingScreen("Loading the Game", "Setup streaming", nil);
|
2020-04-16 08:26:16 +00:00
|
|
|
#ifdef USE_TXD_CDIMAGE
|
2020-03-22 14:23:40 +00:00
|
|
|
int txdHandle = CFileMgr::OpenFile("MODELS\\TXD.IMG", "r");
|
|
|
|
if (txdHandle)
|
|
|
|
CFileMgr::CloseFile(txdHandle);
|
|
|
|
if (!CheckVideoCardCaps() && txdHandle) {
|
|
|
|
CdStreamAddImage("MODELS\\TXD.IMG");
|
|
|
|
CStreaming::Init();
|
|
|
|
} else {
|
|
|
|
CStreaming::Init();
|
2020-03-28 20:55:23 +00:00
|
|
|
if (CreateTxdImageForVideoCard()) {
|
2020-03-22 14:23:40 +00:00
|
|
|
CStreaming::Shutdown();
|
|
|
|
CdStreamAddImage("MODELS\\TXD.IMG");
|
|
|
|
CStreaming::Init();
|
|
|
|
}
|
|
|
|
}
|
2020-04-16 08:26:16 +00:00
|
|
|
#else
|
|
|
|
CStreaming::Init();
|
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
CStreaming::LoadInitialVehicles();
|
|
|
|
CStreaming::LoadInitialPeds();
|
|
|
|
CStreaming::RequestBigBuildings(LEVEL_NONE);
|
|
|
|
CStreaming::LoadAllRequestedModels(false);
|
|
|
|
printf("Streaming uses %dK of its memory", CStreaming::ms_memoryUsed / 1024);
|
|
|
|
LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen());
|
|
|
|
CAnimManager::LoadAnimFiles();
|
|
|
|
CPed::Initialise();
|
|
|
|
CRouteNode::Initialise();
|
|
|
|
CEventList::Initialise();
|
|
|
|
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 09:06:33 +00:00
|
|
|
CSceneEdit::Initialise();
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Load scripts", nil);
|
|
|
|
CTheScripts::Init();
|
2020-03-28 20:55:23 +00:00
|
|
|
CGangs::Initialise();
|
2020-03-22 14:23:40 +00: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();
|
|
|
|
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();
|
|
|
|
CRecordDataForChase::Init();
|
|
|
|
CReplay::Init();
|
|
|
|
LoadingScreen("Loading the Game", "Start script", nil);
|
|
|
|
CTheScripts::StartTestScript();
|
|
|
|
CTheScripts::Process();
|
|
|
|
TheCamera.Process();
|
|
|
|
LoadingScreen("Loading the Game", "Load scene", nil);
|
2020-03-28 20:55:23 +00:00
|
|
|
CModelInfo::RemoveColModelsFromOtherLevels(currLevel);
|
|
|
|
CCollision::ms_collisionInMemory = currLevel;
|
2020-03-22 14:23:40 +00:00
|
|
|
for (int i = 0; i < MAX_PADS; i++)
|
|
|
|
CPad::GetPad(i)->Clear(true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-03-28 20:55:23 +00:00
|
|
|
bool CGame::ShutDown(void)
|
|
|
|
{
|
|
|
|
CReplay::FinishPlayback();
|
|
|
|
CPlane::Shutdown();
|
|
|
|
CTrain::Shutdown();
|
|
|
|
CSpecialFX::Shutdown();
|
2020-03-29 15:53:58 +00:00
|
|
|
#ifndef PS2
|
2020-03-28 20:55:23 +00:00
|
|
|
CGarages::Shutdown();
|
2020-03-29 15:53:58 +00:00
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
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 13:32:11 +00:00
|
|
|
CWorld::Players[i].m_pPed = nil;
|
2020-03-28 20:55:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
CWaterLevel::Shutdown();
|
|
|
|
CRubbish::Shutdown();
|
|
|
|
CClouds::Shutdown();
|
|
|
|
CShadows::Shutdown();
|
|
|
|
CCoronas::Shutdown();
|
|
|
|
CSkidmarks::Shutdown();
|
|
|
|
CWeaponEffects::Shutdown();
|
|
|
|
CParticle::Shutdown();
|
|
|
|
CPools::ShutDown();
|
|
|
|
CTxdStore::RemoveTxdSlot(gameTxdSlot);
|
|
|
|
CdStreamRemoveImages();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGame::ReInitGameObjectVariables(void)
|
|
|
|
{
|
|
|
|
CGameLogic::InitAtStartOfGame();
|
|
|
|
TheCamera.CCamera::Init();
|
|
|
|
TheCamera.SetRwCamera(Scene.camera);
|
|
|
|
CDebug::DebugInitTextBuffer();
|
|
|
|
CWeather::Init();
|
|
|
|
CUserDisplay::Init();
|
|
|
|
CMessages::Init();
|
|
|
|
CRestart::Initialise();
|
|
|
|
CWorld::bDoingCarCollisions = false;
|
|
|
|
CHud::ReInitialise();
|
|
|
|
CRadar::Initialise();
|
|
|
|
CCarCtrl::ReInit();
|
|
|
|
CTimeCycle::Initialise();
|
|
|
|
CDraw::SetFOV(120.0f);
|
|
|
|
CDraw::ms_fLODDistance = 500.0f;
|
|
|
|
CStreaming::RequestBigBuildings(LEVEL_NONE);
|
|
|
|
CStreaming::LoadAllRequestedModels(false);
|
|
|
|
CPed::Initialise();
|
|
|
|
CEventList::Initialise();
|
|
|
|
CWeapon::InitialiseWeapons();
|
|
|
|
CPopulation::Initialise();
|
|
|
|
|
|
|
|
for (int i = 0; i < NUMPLAYERS; i++)
|
|
|
|
CWorld::Players[i].Clear();
|
|
|
|
|
|
|
|
CWorld::PlayerInFocus = 0;
|
|
|
|
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();
|
|
|
|
CSpecialFX::Init();
|
|
|
|
CWaterCannons::Init();
|
|
|
|
CParticle::ReloadConfig();
|
|
|
|
CCullZones::ResolveVisibilities();
|
2020-03-29 13:32:11 +00:00
|
|
|
|
2020-04-08 23:52:38 +00:00
|
|
|
if ( !FrontEndMenuManager.m_bWantToLoad )
|
2020-03-28 20:55:23 +00:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGame::ShutDownForRestart(void)
|
|
|
|
{
|
|
|
|
CReplay::FinishPlayback();
|
|
|
|
CReplay::EmptyReplayBuffer();
|
|
|
|
DMAudio.DestroyAllGameCreatedEntities();
|
|
|
|
|
|
|
|
for (int i = 0; i < NUMPLAYERS; i++)
|
|
|
|
CWorld::Players[i].Clear();
|
2020-03-29 13:32:11 +00:00
|
|
|
|
2020-03-28 20:55:23 +00:00
|
|
|
CGarages::SetAllDoorsBackToOriginalHeight();
|
|
|
|
CTheScripts::UndoBuildingSwaps();
|
|
|
|
CTheScripts::UndoEntityInvisibilitySettings();
|
|
|
|
CWorld::ClearForRestart();
|
|
|
|
CTimer::Shutdown();
|
|
|
|
CStreaming::FlushRequestList();
|
|
|
|
CStreaming::DeleteAllRwObjects();
|
|
|
|
CStreaming::RemoveAllUnusedModels();
|
|
|
|
CStreaming::ms_disableStreaming = false;
|
|
|
|
CRadar::RemoveRadarSections();
|
|
|
|
FrontEndMenuManager.UnloadTextures();
|
|
|
|
CParticleObject::RemoveAllParticleObjects();
|
|
|
|
CPedType::Shutdown();
|
|
|
|
CSpecialFX::Shutdown();
|
|
|
|
TidyUpMemory(true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGame::InitialiseWhenRestarting(void)
|
|
|
|
{
|
|
|
|
CRect rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
|
|
CRGBA color(255, 255, 255, 255);
|
|
|
|
|
|
|
|
CTimer::Initialise();
|
|
|
|
CSprite2d::SetRecipNearClip();
|
|
|
|
|
|
|
|
b_FoundRecentSavedGameWantToLoad = false;
|
|
|
|
|
|
|
|
TheCamera.Init();
|
|
|
|
|
2020-04-08 23:52:38 +00:00
|
|
|
if ( FrontEndMenuManager.m_bWantToLoad == true )
|
2020-03-28 20:55:23 +00:00
|
|
|
{
|
|
|
|
RestoreForStartLoad();
|
|
|
|
CStreaming::LoadScene(TheCamera.GetPosition());
|
|
|
|
}
|
|
|
|
|
|
|
|
ReInitGameObjectVariables();
|
|
|
|
|
2020-04-08 23:52:38 +00:00
|
|
|
if ( FrontEndMenuManager.m_bWantToLoad == true )
|
2020-03-28 20:55:23 +00:00
|
|
|
{
|
|
|
|
if ( GenericLoad() == true )
|
|
|
|
{
|
|
|
|
DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds());
|
|
|
|
CTrain::InitTrains();
|
|
|
|
CPlane::InitPlanes();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ( int32 i = 0; i < 50; i++ )
|
|
|
|
{
|
|
|
|
HandleExit();
|
|
|
|
FrontEndMenuManager.MessageScreen("FED_LFL"); // Loading save game has failed. The game will restart now.
|
|
|
|
}
|
|
|
|
|
|
|
|
ShutDownForRestart();
|
|
|
|
CTimer::Stop();
|
|
|
|
CTimer::Initialise();
|
2020-04-08 23:52:38 +00:00
|
|
|
FrontEndMenuManager.m_bWantToLoad = false;
|
2020-03-28 20:55:23 +00:00
|
|
|
ReInitGameObjectVariables();
|
|
|
|
currLevel = LEVEL_INDUSTRIAL;
|
|
|
|
CCollision::SortOutCollisionAfterLoad();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CTimer::Update();
|
|
|
|
|
|
|
|
DMAudio.ChangeMusicMode(MUSICMODE_GAME);
|
|
|
|
}
|
|
|
|
|
2019-10-24 23:25:11 +00:00
|
|
|
extern void (*DebugMenuProcess)(void);
|
2019-10-18 22:23:40 +00:00
|
|
|
void CGame::Process(void)
|
|
|
|
{
|
|
|
|
CPad::UpdatePads();
|
2020-04-09 03:20:44 +00:00
|
|
|
#ifdef GTA_PS2
|
2020-04-08 23:52:38 +00:00
|
|
|
ProcessTidyUpMemory();
|
|
|
|
#endif
|
2019-10-18 22:23:40 +00:00
|
|
|
TheCamera.SetMotionBlurAlpha(0);
|
2019-10-19 11:12:18 +00:00
|
|
|
if (TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_SNIPER || TheCamera.m_BlurType == MBLUR_NORMAL)
|
2019-10-19 11:20:51 +00:00
|
|
|
TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE);
|
2019-10-24 23:25:11 +00:00
|
|
|
|
|
|
|
DebugMenuProcess();
|
2019-10-18 22:23:40 +00:00
|
|
|
CCutsceneMgr::Update();
|
2019-10-19 11:12:18 +00:00
|
|
|
if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused())
|
2019-10-18 22:23:40 +00:00
|
|
|
FrontEndMenuManager.Process();
|
|
|
|
CStreaming::Update();
|
|
|
|
if (!CTimer::GetIsPaused())
|
|
|
|
{
|
|
|
|
CTheZones::Update();
|
|
|
|
CSprite2d::SetRecipNearClip();
|
|
|
|
CSprite2d::InitPerFrame();
|
|
|
|
CFont::InitPerFrame();
|
|
|
|
CRecordDataForGame::SaveOrRetrieveDataForThisFrame();
|
|
|
|
CRecordDataForChase::SaveOrRetrieveDataForThisFrame();
|
|
|
|
CPad::DoCheats();
|
|
|
|
CClock::Update();
|
|
|
|
CWeather::Update();
|
|
|
|
CTheScripts::Process();
|
|
|
|
CCollision::Update();
|
|
|
|
CTrain::UpdateTrains();
|
|
|
|
CPlane::UpdatePlanes();
|
|
|
|
CHeli::UpdateHelis();
|
|
|
|
CDarkel::Update();
|
|
|
|
CSkidmarks::Update();
|
|
|
|
CAntennas::Update();
|
|
|
|
CGlass::Update();
|
|
|
|
CSceneEdit::Update();
|
|
|
|
CEventList::Update();
|
|
|
|
CParticle::Update();
|
|
|
|
gFireManager.Update();
|
|
|
|
CPopulation::Update();
|
|
|
|
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();
|
|
|
|
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())
|
|
|
|
{
|
|
|
|
CCarCtrl::GenerateRandomCars();
|
|
|
|
CRoadBlocks::GenerateRoadBlocks();
|
|
|
|
CCarCtrl::RemoveDistantCars();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-24 16:55:43 +00:00
|
|
|
|
2020-03-28 20:55:23 +00:00
|
|
|
void CGame::DrasticTidyUpMemory(bool)
|
2019-10-18 22:23:40 +00:00
|
|
|
{
|
2020-03-28 20:55:23 +00:00
|
|
|
#ifdef PS2
|
|
|
|
// meow
|
|
|
|
#endif
|
2019-10-18 22:23:40 +00:00
|
|
|
}
|
2019-07-24 16:55:43 +00:00
|
|
|
|
2020-03-28 20:55:23 +00:00
|
|
|
void CGame::TidyUpMemory(bool, bool)
|
2019-10-21 13:47:08 +00:00
|
|
|
{
|
2020-03-28 20:55:23 +00:00
|
|
|
#ifdef PS2
|
|
|
|
// meow
|
2019-10-21 13:47:08 +00:00
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
}
|
2019-10-18 22:23:40 +00:00
|
|
|
|
2020-04-08 23:52:38 +00:00
|
|
|
void CGame::ProcessTidyUpMemory(void)
|
|
|
|
{
|
|
|
|
#ifdef PS2
|
|
|
|
// meow
|
|
|
|
#endif
|
|
|
|
}
|