2020-03-28 20:55:23 +00:00
|
|
|
#pragma warning( push )
|
|
|
|
#pragma warning( disable : 4005)
|
|
|
|
#pragma warning( pop )
|
2019-05-15 14:52:37 +00:00
|
|
|
#include "common.h"
|
2020-05-11 02:55:57 +00:00
|
|
|
#include "platform.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"
|
2020-06-27 21:01:51 +00:00
|
|
|
#include "MemoryCard.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-19 16:34:08 +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"
|
2020-04-24 11:27:02 +00:00
|
|
|
#include "debugmenu.h"
|
2020-08-13 16:14:24 +00:00
|
|
|
#include "postfx.h"
|
2020-08-18 08:58:15 +00:00
|
|
|
#include "custompipes.h"
|
2020-11-19 15:23:52 +00:00
|
|
|
#include "screendroplets.h"
|
2020-10-25 10:38:08 +00:00
|
|
|
#include "crossplatform.h"
|
2020-11-26 15:47:19 +00:00
|
|
|
#include "MemoryHeap.h"
|
2020-11-23 20:46:07 +00:00
|
|
|
#ifdef USE_TEXTURE_POOL
|
|
|
|
#include "TexturePools.h"
|
|
|
|
#endif
|
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;
|
2020-04-26 20:49:24 +00:00
|
|
|
bool CGame::japaneseGame = false;
|
2020-03-29 06:35:13 +00:00
|
|
|
#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
|
|
|
|
2020-06-27 21:01:51 +00:00
|
|
|
|
|
|
|
bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
|
|
|
|
void DoRWStuffEndOfFrame(void);
|
2020-08-03 01:00:12 +00:00
|
|
|
#ifdef PS2_MENU
|
2020-06-27 21:01:51 +00: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();
|
2020-11-08 18:11:55 +00:00
|
|
|
CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(190.0f)); // 450.0f
|
2020-06-27 21:01:51 +00:00
|
|
|
CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f));
|
|
|
|
CFont::SetCentreOn();
|
2020-11-09 22:41:21 +00:00
|
|
|
CFont::SetCentreSize(SCREEN_SCALE_X(450.0f)); // 450.0f
|
2020-06-27 21:01:51 +00: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();
|
|
|
|
}
|
2020-08-03 01:00:12 +00:00
|
|
|
#endif
|
2020-06-27 21:01:51 +00:00
|
|
|
|
2019-07-24 16:55:43 +00:00
|
|
|
bool
|
|
|
|
CGame::InitialiseOnceBeforeRW(void)
|
|
|
|
{
|
|
|
|
CFileMgr::Initialise();
|
|
|
|
CdStreamInit(MAX_CDCHANNELS);
|
|
|
|
ValidateVersion();
|
2020-08-13 16:14:24 +00:00
|
|
|
#ifdef EXTENDED_COLOURFILTER
|
|
|
|
CPostFX::InitOnce();
|
|
|
|
#endif
|
2019-07-24 16:55:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-07-29 12:24:42 +00:00
|
|
|
#ifndef LIBRW
|
|
|
|
#ifdef PS2_MATFX
|
2020-07-22 00:23:12 +00:00
|
|
|
void ReplaceMatFxCallback();
|
2020-07-29 12:24:42 +00:00
|
|
|
#endif // PS2_MATFX
|
2020-07-29 12:31:34 +00:00
|
|
|
#ifdef PS2_ALPHA_TEST
|
2020-07-29 12:24:42 +00:00
|
|
|
void ReplaceAtomicPipeCallback();
|
2020-07-29 12:31:34 +00:00
|
|
|
#endif // PS2_ALPHA_TEST
|
2020-07-29 12:24:42 +00:00
|
|
|
#endif // !LIBRW
|
2020-07-22 00:23:12 +00:00
|
|
|
|
2020-12-01 16:42:18 +00:00
|
|
|
// missing altogether on PS2, mostly done in GameInit there it seems
|
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();
|
2020-04-20 14:05:39 +00:00
|
|
|
|
|
|
|
#ifdef LIBRW
|
|
|
|
#ifdef PS2_MATFX
|
|
|
|
rw::MatFX::modulateEnvMap = true;
|
|
|
|
#else
|
|
|
|
rw::MatFX::modulateEnvMap = false;
|
|
|
|
#endif
|
2020-07-29 12:24:42 +00:00
|
|
|
#else
|
|
|
|
#ifdef PS2_MATFX
|
2020-07-22 00:23:12 +00:00
|
|
|
ReplaceMatFxCallback();
|
2020-07-29 12:24:42 +00:00
|
|
|
#endif // PS2_MATFX
|
2020-07-29 12:31:34 +00:00
|
|
|
#ifdef PS2_ALPHA_TEST
|
2020-07-29 12:24:42 +00:00
|
|
|
ReplaceAtomicPipeCallback();
|
2020-07-29 12:31:34 +00:00
|
|
|
#endif // PS2_ALPHA_TEST
|
2020-07-29 12:24:42 +00:00
|
|
|
#endif // LIBRW
|
2020-03-28 20:55:23 +00:00
|
|
|
|
|
|
|
CFont::Initialise();
|
|
|
|
CHud::Initialise();
|
|
|
|
CPlayerSkin::Initialise();
|
|
|
|
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
|
2020-12-01 16:42:18 +00:00
|
|
|
// missing altogether on PS2
|
2020-03-28 20:55:23 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-11-30 23:22:57 +00:00
|
|
|
// missing altogether on PS2
|
2020-03-28 20:55:23 +00:00
|
|
|
bool CGame::InitialiseOnceAfterRW(void)
|
|
|
|
{
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION > GTA3_PS2_160
|
2020-03-28 20:55:23 +00:00
|
|
|
TheText.Load();
|
2020-11-30 23:22:57 +00:00
|
|
|
DMAudio.Initialise(); // before TheGame() on PS2
|
2020-03-28 20:55:23 +00:00
|
|
|
CTimer::Initialise();
|
|
|
|
CTempColModels::Initialise();
|
|
|
|
mod_HandlingManager.Initialise();
|
|
|
|
CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
|
|
|
|
CPedStats::Initialise();
|
|
|
|
CTimeCycle::Initialise();
|
2020-11-30 23:22:57 +00:00
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
|
|
|
|
if ( DMAudio.GetNum3DProvidersAvailable() == 0 )
|
|
|
|
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = -1;
|
|
|
|
|
2020-10-25 07:39:04 +00:00
|
|
|
if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -99 || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 ) {
|
2020-03-28 20:55:23 +00:00
|
|
|
CMenuManager::m_PrefsSpeakers = 0;
|
2020-10-25 07:39:04 +00:00
|
|
|
int32 i;
|
|
|
|
for (i = 0; i < DMAudio.GetNum3DProvidersAvailable(); i++) {
|
|
|
|
wchar buff[64];
|
|
|
|
|
|
|
|
#ifdef AUDIO_OAL
|
|
|
|
extern int defaultProvider;
|
|
|
|
if (defaultProvider >= 0 && defaultProvider < DMAudio.GetNum3DProvidersAvailable())
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
char *name = DMAudio.Get3DProviderName(i);
|
|
|
|
AsciiToUnicode(name, buff);
|
|
|
|
char *providername = UnicodeToAscii(buff);
|
|
|
|
strupr(providername);
|
|
|
|
#if defined(AUDIO_MSS)
|
|
|
|
if (strcmp(providername, "MILES FAST 2D POSITIONAL AUDIO") == 0)
|
|
|
|
break;
|
|
|
|
#elif defined(AUDIO_OAL)
|
|
|
|
if (strcmp(providername, "OPENAL SOFT") == 0)
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = i;
|
2020-03-28 20:55:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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-08-19 17:30:57 +00:00
|
|
|
|
2020-03-28 20:55:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-12-01 16:42:18 +00:00
|
|
|
// missing altogether on PS2
|
2020-03-28 20:55:23 +00:00
|
|
|
void
|
|
|
|
CGame::FinalShutdown(void)
|
|
|
|
{
|
|
|
|
CTxdStore::Shutdown();
|
|
|
|
CPedStats::Shutdown();
|
|
|
|
CdStreamShutdown();
|
|
|
|
}
|
2020-03-22 14:23:40 +00:00
|
|
|
|
|
|
|
bool CGame::Initialise(const char* datFile)
|
|
|
|
{
|
2020-11-26 15:47:19 +00:00
|
|
|
#ifdef GTA_PS2
|
|
|
|
// TODO: upload VU0 collision code here
|
2020-11-30 23:22:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if GTA_VERSION > GTA3_PS2_160
|
2020-03-22 14:23:40 +00:00
|
|
|
ResetLoadingScreenBar();
|
|
|
|
strcpy(aDatFile, datFile);
|
2020-11-26 15:47:19 +00:00
|
|
|
CPools::Initialise(); // done in CWorld on PS2
|
2020-11-30 23:22:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GTA_PS2
|
2020-03-22 14:23:40 +00:00
|
|
|
CIniFile::LoadIniFile();
|
2020-11-26 15:47:19 +00:00
|
|
|
#endif
|
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
currLevel = LEVEL_INDUSTRIAL;
|
2020-11-26 15:47:19 +00:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_TEXTURES);
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Loading generic textures", GetRandomSplashScreen());
|
|
|
|
gameTxdSlot = CTxdStore::AddTxdSlot("generic");
|
|
|
|
CTxdStore::Create(gameTxdSlot);
|
|
|
|
CTxdStore::AddRef(gameTxdSlot);
|
2020-11-26 15:47:19 +00:00
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
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);
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
|
|
|
#ifdef GTA_PS2
|
|
|
|
CDma::SyncChannel(0, true);
|
|
|
|
#endif
|
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
CGameLogic::InitAtStartOfGame();
|
|
|
|
CReferences::Init();
|
|
|
|
TheCamera.Init();
|
|
|
|
TheCamera.SetRwCamera(Scene.camera);
|
|
|
|
CDebug::DebugInitTextBuffer();
|
|
|
|
ThePaths.Init();
|
|
|
|
ThePaths.AllocatePathFindInfoMem(4500);
|
|
|
|
CWeather::Init();
|
|
|
|
CCullZones::Init();
|
|
|
|
CCollision::Init();
|
2020-11-30 23:22:57 +00:00
|
|
|
#ifdef PS2_MENU // TODO: is this the right define?
|
2020-06-27 21:01:51 +00:00
|
|
|
TheText.Load();
|
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
CTheZones::Init();
|
|
|
|
CUserDisplay::Init();
|
|
|
|
CMessages::Init();
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION > GTA3_PS2_160
|
2020-03-22 14:23:40 +00:00
|
|
|
CMessages::ClearAllMessagesDisplayedByGame();
|
2020-11-30 23:22:57 +00:00
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
CRecordDataForGame::Init();
|
|
|
|
CRestart::Initialise();
|
2020-11-26 15:47:19 +00:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_WORLD);
|
2020-03-22 14:23:40 +00:00
|
|
|
CWorld::Initialise();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
|
|
|
mod_HandlingManager.Initialise();
|
|
|
|
CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
|
|
|
|
CTempColModels::Initialise();
|
|
|
|
#endif
|
|
|
|
|
2020-11-26 15:47:19 +00:00
|
|
|
PUSH_MEMID(MEMID_TEXTURES);
|
2020-03-22 14:23:40 +00:00
|
|
|
CParticle::Initialise();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
2020-06-27 21:01:51 +00:00
|
|
|
gStartX = -180.0f;
|
|
|
|
gStartY = 180.0f;
|
|
|
|
gStartZ = 14.0f;
|
|
|
|
#endif
|
2020-11-26 15:47:19 +00:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_ANIMATION);
|
2020-03-22 14:23:40 +00:00
|
|
|
CAnimManager::Initialise();
|
|
|
|
CCutsceneMgr::Initialise();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_CARS);
|
2020-03-22 14:23:40 +00:00
|
|
|
CCarCtrl::Init();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION > GTA3_PS2_160
|
2020-03-22 14:23:40 +00:00
|
|
|
InitModelIndices();
|
2020-11-26 15:47:19 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_DEF_MODELS);
|
2020-03-22 14:23:40 +00:00
|
|
|
CModelInfo::Initialise();
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
|
|
|
CPedStats::Initialise(); // InitialiseOnceAfterRW
|
|
|
|
#else
|
2020-11-26 15:47:19 +00:00
|
|
|
// probably moved before LoadLevel for multiplayer maps?
|
2020-03-22 14:23:40 +00:00
|
|
|
CPickups::Init();
|
|
|
|
CTheCarGenerators::Init();
|
2020-11-26 15:47:19 +00:00
|
|
|
#endif
|
2020-11-30 23:22:57 +00:00
|
|
|
|
|
|
|
#ifndef GTA_PS2 // or GTA_VERSION?
|
2020-03-22 14:23:40 +00:00
|
|
|
CdStreamAddImage("MODELS\\GTA3.IMG");
|
2020-11-30 23:22:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if GTA_VERSION > GTA3_PS2_160
|
2020-03-22 14:23:40 +00:00
|
|
|
CFileLoader::LoadLevel("DATA\\DEFAULT.DAT");
|
|
|
|
CFileLoader::LoadLevel(datFile);
|
2020-11-30 23:22:57 +00:00
|
|
|
#else
|
|
|
|
CFileLoader::LoadLevel("GTA3.DAT");
|
|
|
|
#endif
|
|
|
|
|
2020-08-18 08:58:15 +00:00
|
|
|
#ifdef EXTENDED_PIPELINES
|
|
|
|
// for generic fallback
|
|
|
|
CustomPipes::SetTxdFindCallback();
|
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
CWorld::AddParticles();
|
|
|
|
CVehicleModelInfo::LoadVehicleColours();
|
|
|
|
CVehicleModelInfo::LoadEnvironmentMaps();
|
|
|
|
CTheZones::PostZoneCreation();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
|
|
|
TestModelIndices();
|
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Setup paths", GetRandomSplashScreen());
|
|
|
|
ThePaths.PreparePathData();
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION > GTA3_PS2_160
|
2020-03-22 14:23:40 +00:00
|
|
|
for (int i = 0; i < NUMPLAYERS; i++)
|
|
|
|
CWorld::Players[i].Clear();
|
|
|
|
CWorld::Players[0].LoadPlayerSkin();
|
|
|
|
TestModelIndices();
|
2020-11-30 23:22:57 +00:00
|
|
|
#endif
|
2020-11-26 15:47:19 +00:00
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Setup water", nil);
|
|
|
|
CWaterLevel::Initialise("DATA\\WATER.DAT");
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
|
|
|
CTimeCycle::Initialise(); // InitialiseOnceAfterRW
|
|
|
|
#else
|
2020-03-22 14:23:40 +00:00
|
|
|
TheConsole.Init();
|
2020-11-30 23:22:57 +00:00
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
CDraw::SetFOV(120.0f);
|
|
|
|
CDraw::ms_fLODDistance = 500.0f;
|
2020-11-26 15:47:19 +00:00
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Setup streaming", nil);
|
2020-04-16 08:26:16 +00:00
|
|
|
CStreaming::Init();
|
2020-03-22 14:23:40 +00:00
|
|
|
CStreaming::LoadInitialVehicles();
|
|
|
|
CStreaming::LoadInitialPeds();
|
2020-07-13 14:43:09 +00:00
|
|
|
CStreaming::RequestBigBuildings(LEVEL_GENERIC);
|
2020-03-22 14:23:40 +00:00
|
|
|
CStreaming::LoadAllRequestedModels(false);
|
2020-07-25 12:13:27 +00:00
|
|
|
printf("Streaming uses %zuK of its memory", CStreaming::ms_memoryUsed / 1024); // original modifier was %d
|
2020-11-26 15:47:19 +00:00
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen());
|
2020-11-26 15:47:19 +00:00
|
|
|
PUSH_MEMID(MEMID_ANIMATION);
|
2020-03-22 14:23:40 +00:00
|
|
|
CAnimManager::LoadAnimFiles();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
CPed::Initialise();
|
|
|
|
CRouteNode::Initialise();
|
|
|
|
CEventList::Initialise();
|
2020-11-19 15:23:52 +00:00
|
|
|
#ifdef SCREEN_DROPLETS
|
|
|
|
ScreenDroplets::Initialise();
|
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Find big buildings", nil);
|
|
|
|
CRenderer::Init();
|
2020-11-26 15:47:19 +00:00
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Setup game variables", nil);
|
|
|
|
CRadar::Initialise();
|
|
|
|
CRadar::LoadTextures();
|
|
|
|
CWeapon::InitialiseWeapons();
|
2020-11-26 15:47:19 +00:00
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Setup traffic lights", nil);
|
|
|
|
CTrafficLights::ScanForLightsOnMap();
|
|
|
|
CRoadBlocks::Init();
|
2020-11-26 15:47:19 +00:00
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Setup game variables", nil);
|
|
|
|
CPopulation::Initialise();
|
2020-11-30 23:22:57 +00:00
|
|
|
#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
|
2020-03-22 14:23:40 +00:00
|
|
|
CWorld::PlayerInFocus = 0;
|
|
|
|
CCoronas::Init();
|
|
|
|
CShadows::Init();
|
|
|
|
CWeaponEffects::Init();
|
|
|
|
CSkidmarks::Init();
|
|
|
|
CAntennas::Init();
|
|
|
|
CGlass::Init();
|
|
|
|
gPhoneInfo.Initialise();
|
2020-11-30 23:22:57 +00:00
|
|
|
#ifndef GTA_PS2 // TODO: define for this
|
2020-04-12 09:06:33 +00:00
|
|
|
CSceneEdit::Initialise();
|
2020-11-26 15:47:19 +00:00
|
|
|
#endif
|
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Load scripts", nil);
|
2020-11-26 15:47:19 +00:00
|
|
|
PUSH_MEMID(MEMID_SCRIPT);
|
2020-03-22 14:23:40 +00:00
|
|
|
CTheScripts::Init();
|
2020-03-28 20:55:23 +00:00
|
|
|
CGangs::Initialise();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Setup game variables", nil);
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
2020-11-26 15:47:19 +00:00
|
|
|
CTimer::Initialise();
|
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
CClock::Initialise(1000);
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
2020-11-26 15:47:19 +00:00
|
|
|
CTheCarGenerators::Init();
|
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
CHeli::InitHelis();
|
|
|
|
CCranes::InitCranes();
|
|
|
|
CMovingThings::Init();
|
|
|
|
CDarkel::Init();
|
|
|
|
CStats::Init();
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
2020-11-26 15:47:19 +00:00
|
|
|
CPickups::Init();
|
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
CPacManPickups::Init();
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
|
|
|
CGarages::Init();
|
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
CRubbish::Init();
|
|
|
|
CClouds::Init();
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
2020-11-26 15:47:19 +00:00
|
|
|
CRemote::Init();
|
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
CSpecialFX::Init();
|
|
|
|
CWaterCannons::Init();
|
|
|
|
CBridge::Init();
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION > GTA3_PS2_160
|
2020-03-22 14:23:40 +00:00
|
|
|
CGarages::Init();
|
2020-11-30 23:22:57 +00:00
|
|
|
#endif
|
2020-11-26 15:47:19 +00:00
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Position dynamic objects", nil);
|
|
|
|
CWorld::RepositionCertainDynamicObjects();
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
|
|
|
CCullZones::ResolveVisibilities();
|
|
|
|
#endif
|
2020-11-26 15:47:19 +00:00
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
LoadingScreen("Loading the Game", "Initialise vehicle paths", nil);
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION > GTA3_PS2_160
|
2020-03-22 14:23:40 +00:00
|
|
|
CCullZones::ResolveVisibilities();
|
2020-11-30 23:22:57 +00:00
|
|
|
#endif
|
2020-03-22 14:23:40 +00:00
|
|
|
CTrain::InitTrains();
|
|
|
|
CPlane::InitPlanes();
|
|
|
|
CCredits::Init();
|
|
|
|
CRecordDataForChase::Init();
|
2020-11-30 23:22:57 +00:00
|
|
|
#ifndef GTA_PS2 // TODO: define for that
|
2020-03-22 14:23:40 +00:00
|
|
|
CReplay::Init();
|
2020-11-30 23:22:57 +00:00
|
|
|
#endif
|
2020-11-26 15:47:19 +00:00
|
|
|
|
2020-06-27 21:01:51 +00:00
|
|
|
#ifdef PS2_MENU
|
|
|
|
if ( !TheMemoryCard.m_bWantToLoad )
|
|
|
|
#endif
|
2020-11-30 23:22:57 +00:00
|
|
|
{
|
|
|
|
LoadingScreen("Loading the Game", "Start script", nil);
|
|
|
|
CTheScripts::StartTestScript();
|
|
|
|
CTheScripts::Process();
|
|
|
|
TheCamera.Process();
|
2020-06-27 21:01:51 +00:00
|
|
|
}
|
2020-11-26 15:47:19 +00:00
|
|
|
|
2020-03-22 14:23:40 +00:00
|
|
|
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-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION > GTA3_PS2_160
|
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();
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION > GTA3_PS2_160
|
2020-03-28 20:55:23 +00:00
|
|
|
CPools::ShutDown();
|
2020-11-30 23:22:57 +00:00
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
CTxdStore::RemoveTxdSlot(gameTxdSlot);
|
|
|
|
CdStreamRemoveImages();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGame::ReInitGameObjectVariables(void)
|
|
|
|
{
|
|
|
|
CGameLogic::InitAtStartOfGame();
|
2020-06-27 21:01:51 +00:00
|
|
|
#ifdef PS2_MENU
|
|
|
|
if ( !TheMemoryCard.m_bWantToLoad )
|
|
|
|
#endif
|
2020-12-01 16:42:18 +00:00
|
|
|
{
|
|
|
|
TheCamera.Init();
|
|
|
|
TheCamera.SetRwCamera(Scene.camera);
|
2020-06-27 21:01:51 +00:00
|
|
|
}
|
2020-03-28 20:55:23 +00:00
|
|
|
CDebug::DebugInitTextBuffer();
|
|
|
|
CWeather::Init();
|
|
|
|
CUserDisplay::Init();
|
|
|
|
CMessages::Init();
|
|
|
|
CRestart::Initialise();
|
|
|
|
CWorld::bDoingCarCollisions = false;
|
|
|
|
CHud::ReInitialise();
|
|
|
|
CRadar::Initialise();
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
2020-06-27 21:01:51 +00:00
|
|
|
gStartX = -180.0f;
|
|
|
|
gStartY = 180.0f;
|
|
|
|
gStartZ = 14.0f;
|
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
CCarCtrl::ReInit();
|
|
|
|
CTimeCycle::Initialise();
|
|
|
|
CDraw::SetFOV(120.0f);
|
|
|
|
CDraw::ms_fLODDistance = 500.0f;
|
2020-07-13 14:43:09 +00:00
|
|
|
CStreaming::RequestBigBuildings(LEVEL_GENERIC);
|
2020-03-28 20:55:23 +00:00
|
|
|
CStreaming::LoadAllRequestedModels(false);
|
|
|
|
CPed::Initialise();
|
|
|
|
CEventList::Initialise();
|
2020-11-19 15:23:52 +00:00
|
|
|
#ifdef SCREEN_DROPLETS
|
|
|
|
ScreenDroplets::Initialise();
|
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
CWeapon::InitialiseWeapons();
|
|
|
|
CPopulation::Initialise();
|
|
|
|
|
|
|
|
for (int i = 0; i < NUMPLAYERS; i++)
|
|
|
|
CWorld::Players[i].Clear();
|
|
|
|
|
|
|
|
CWorld::PlayerInFocus = 0;
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
2020-06-27 21:01:51 +00:00
|
|
|
CWeaponEffects::Init();
|
|
|
|
CSkidmarks::Init();
|
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
CAntennas::Init();
|
|
|
|
CGlass::Init();
|
|
|
|
gPhoneInfo.Initialise();
|
2020-11-26 15:47:19 +00:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_SCRIPT);
|
2020-03-28 20:55:23 +00:00
|
|
|
CTheScripts::Init();
|
|
|
|
CGangs::Initialise();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
2020-03-28 20:55:23 +00:00
|
|
|
CTimer::Initialise();
|
|
|
|
CClock::Initialise(1000);
|
|
|
|
CTheCarGenerators::Init();
|
|
|
|
CHeli::InitHelis();
|
|
|
|
CMovingThings::Init();
|
|
|
|
CDarkel::Init();
|
|
|
|
CStats::Init();
|
|
|
|
CPickups::Init();
|
|
|
|
CPacManPickups::Init();
|
|
|
|
CGarages::Init();
|
2020-11-30 23:22:57 +00:00
|
|
|
#if GTA_VERSION <= GTA3_PS2_160
|
2020-06-27 21:01:51 +00:00
|
|
|
CClouds::Init();
|
|
|
|
CRemote::Init();
|
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
CSpecialFX::Init();
|
|
|
|
CWaterCannons::Init();
|
|
|
|
CParticle::ReloadConfig();
|
|
|
|
CCullZones::ResolveVisibilities();
|
2020-03-29 13:32:11 +00:00
|
|
|
|
2020-06-27 21:01:51 +00:00
|
|
|
#ifdef PS2_MENU
|
|
|
|
if ( !TheMemoryCard.m_bWantToLoad )
|
|
|
|
#else
|
2020-04-08 23:52:38 +00:00
|
|
|
if ( !FrontEndMenuManager.m_bWantToLoad )
|
2020-06-27 21:01:51 +00:00
|
|
|
#endif
|
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)
|
|
|
|
{
|
2020-12-01 16:42:18 +00:00
|
|
|
#ifndef GTA_PS2 // TODO: right define
|
2020-03-28 20:55:23 +00:00
|
|
|
CReplay::FinishPlayback();
|
|
|
|
CReplay::EmptyReplayBuffer();
|
2020-12-01 16:42:18 +00:00
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
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();
|
2020-12-01 16:42:18 +00:00
|
|
|
#if GTA_VERSION >= GTA3_PS2_160
|
2020-03-28 20:55:23 +00:00
|
|
|
CPedType::Shutdown();
|
|
|
|
CSpecialFX::Shutdown();
|
2020-06-27 21:01:51 +00:00
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
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();
|
2020-06-27 21:01:51 +00:00
|
|
|
|
|
|
|
#ifdef PS2_MENU
|
|
|
|
if ( TheMemoryCard.b_FoundRecentSavedGameWantToLoad == true || TheMemoryCard.m_bWantToLoad == false )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
|
2020-06-27 21:01:51 +00:00
|
|
|
#ifdef PS2_MENU
|
|
|
|
TheMemoryCard.b_FoundRecentSavedGameWantToLoad = false;
|
|
|
|
#else
|
2020-03-28 20:55:23 +00:00
|
|
|
b_FoundRecentSavedGameWantToLoad = false;
|
2020-06-27 21:01:51 +00:00
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
|
|
|
|
TheCamera.Init();
|
|
|
|
|
2020-06-27 21:01:51 +00:00
|
|
|
#ifdef PS2_MENU
|
|
|
|
if ( TheMemoryCard.m_bWantToLoad == true )
|
|
|
|
{
|
|
|
|
TheMemoryCard.RestoreForStartLoad();
|
|
|
|
CStreaming::LoadScene(TheCamera.GetPosition());
|
|
|
|
}
|
|
|
|
#else
|
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());
|
|
|
|
}
|
2020-06-27 21:01:51 +00:00
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
|
|
|
|
ReInitGameObjectVariables();
|
|
|
|
|
2020-06-27 21:01:51 +00:00
|
|
|
#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();
|
2020-11-08 18:11:55 +00:00
|
|
|
CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(160.0f)); // 480.0f
|
2020-06-27 21:01:51 +00:00
|
|
|
CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f));
|
|
|
|
CFont::SetCentreOn();
|
2020-11-09 22:41:21 +00:00
|
|
|
CFont::SetCentreSize(SCREEN_SCALE_X(480.0f));
|
2020-06-27 21:01:51 +00:00
|
|
|
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
|
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();
|
|
|
|
}
|
|
|
|
}
|
2020-06-27 21:01:51 +00:00
|
|
|
#endif
|
2020-03-28 20:55:23 +00:00
|
|
|
|
|
|
|
CTimer::Update();
|
|
|
|
|
|
|
|
DMAudio.ChangeMusicMode(MUSICMODE_GAME);
|
|
|
|
}
|
|
|
|
|
2019-10-18 22:23:40 +00:00
|
|
|
void CGame::Process(void)
|
|
|
|
{
|
|
|
|
CPad::UpdatePads();
|
2020-11-26 15:47:19 +00:00
|
|
|
#ifdef USE_CUSTOM_ALLOCATOR
|
2020-04-08 23:52:38 +00:00
|
|
|
ProcessTidyUpMemory();
|
|
|
|
#endif
|
2019-10-18 22:23:40 +00:00
|
|
|
TheCamera.SetMotionBlurAlpha(0);
|
2020-06-27 21:01:51 +00:00
|
|
|
if (TheCamera.m_BlurType == MOTION_BLUR_NONE || TheCamera.m_BlurType == MOTION_BLUR_SNIPER || TheCamera.m_BlurType == MOTION_BLUR_LIGHT_SCENE)
|
|
|
|
TheCamera.SetMotionBlur(0, 0, 0, 0, MOTION_BLUR_NONE);
|
2020-05-09 13:06:13 +00:00
|
|
|
#ifdef DEBUGMENU
|
2019-10-24 23:25:11 +00:00
|
|
|
DebugMenuProcess();
|
2020-05-09 13:06:13 +00:00
|
|
|
#endif
|
2019-10-18 22:23:40 +00:00
|
|
|
CCutsceneMgr::Update();
|
2020-11-26 15:47:19 +00:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_FRONTEND);
|
2019-10-19 11:12:18 +00:00
|
|
|
if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused())
|
2019-10-18 22:23:40 +00:00
|
|
|
FrontEndMenuManager.Process();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
2019-10-18 22:23:40 +00:00
|
|
|
CStreaming::Update();
|
|
|
|
if (!CTimer::GetIsPaused())
|
|
|
|
{
|
|
|
|
CTheZones::Update();
|
|
|
|
CSprite2d::SetRecipNearClip();
|
|
|
|
CSprite2d::InitPerFrame();
|
|
|
|
CFont::InitPerFrame();
|
|
|
|
CRecordDataForGame::SaveOrRetrieveDataForThisFrame();
|
|
|
|
CRecordDataForChase::SaveOrRetrieveDataForThisFrame();
|
|
|
|
CPad::DoCheats();
|
|
|
|
CClock::Update();
|
|
|
|
CWeather::Update();
|
2020-11-26 15:47:19 +00:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_SCRIPT);
|
2019-10-18 22:23:40 +00:00
|
|
|
CTheScripts::Process();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
2019-10-18 22:23:40 +00:00
|
|
|
CCollision::Update();
|
|
|
|
CTrain::UpdateTrains();
|
|
|
|
CPlane::UpdatePlanes();
|
|
|
|
CHeli::UpdateHelis();
|
|
|
|
CDarkel::Update();
|
|
|
|
CSkidmarks::Update();
|
|
|
|
CAntennas::Update();
|
|
|
|
CGlass::Update();
|
2020-12-01 16:42:18 +00:00
|
|
|
#ifndef GTA_PS2 // TODO: define
|
2019-10-18 22:23:40 +00:00
|
|
|
CSceneEdit::Update();
|
2020-12-01 16:42:18 +00:00
|
|
|
#endif
|
2019-10-18 22:23:40 +00:00
|
|
|
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();
|
2020-12-01 16:42:18 +00:00
|
|
|
#ifndef GTA_PS2 // TODO: define
|
2019-10-18 22:23:40 +00:00
|
|
|
CReplay::Update();
|
2020-12-01 16:42:18 +00:00
|
|
|
#endif
|
2020-11-26 15:47:19 +00:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_WORLD);
|
2019-10-18 22:23:40 +00:00
|
|
|
CWorld::Process();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
|
|
|
|
2019-10-18 22:23:40 +00:00
|
|
|
gAccidentManager.Update();
|
|
|
|
CPacManPickups::Update();
|
|
|
|
CPickups::Update();
|
|
|
|
CGarages::Update();
|
|
|
|
CRubbish::Update();
|
|
|
|
CSpecialFX::Update();
|
|
|
|
CTimeCycle::Update();
|
2020-12-01 16:42:18 +00:00
|
|
|
#ifndef GTA_PS2 // TODO: define
|
2019-10-18 22:23:40 +00:00
|
|
|
if (CReplay::ShouldStandardCameraBeProcessed())
|
2020-12-01 16:42:18 +00:00
|
|
|
#endif
|
2019-10-18 22:23:40 +00:00
|
|
|
TheCamera.Process();
|
|
|
|
CCullZones::Update();
|
2020-12-01 16:42:18 +00:00
|
|
|
#ifndef GTA_PS2 // TODO: define
|
2019-10-18 22:23:40 +00:00
|
|
|
if (!CReplay::IsPlayingBack())
|
2020-12-01 16:42:18 +00:00
|
|
|
#endif
|
2019-10-18 22:23:40 +00:00
|
|
|
CGameLogic::Update();
|
|
|
|
CBridge::Update();
|
|
|
|
CCoronas::DoSunAndMoon();
|
|
|
|
CCoronas::Update();
|
|
|
|
CShadows::UpdateStaticShadows();
|
|
|
|
CShadows::UpdatePermanentShadows();
|
|
|
|
gPhoneInfo.Update();
|
2020-12-01 16:42:18 +00:00
|
|
|
#ifndef GTA_PS2 // TODO: define
|
2019-10-18 22:23:40 +00:00
|
|
|
if (!CReplay::IsPlayingBack())
|
2020-12-01 16:42:18 +00:00
|
|
|
#endif
|
2019-10-18 22:23:40 +00:00
|
|
|
{
|
2020-11-26 15:47:19 +00:00
|
|
|
PUSH_MEMID(MEMID_CARS);
|
2019-10-18 22:23:40 +00:00
|
|
|
CCarCtrl::GenerateRandomCars();
|
|
|
|
CRoadBlocks::GenerateRoadBlocks();
|
|
|
|
CCarCtrl::RemoveDistantCars();
|
2020-11-26 15:47:19 +00:00
|
|
|
POP_MEMID();
|
2019-10-18 22:23:40 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-26 15:47:19 +00:00
|
|
|
#ifdef GTA_PS2
|
2020-06-27 21:01:51 +00:00
|
|
|
CMemCheck::DoTest();
|
|
|
|
#endif
|
2019-10-18 22:23:40 +00:00
|
|
|
}
|
2019-07-24 16:55:43 +00:00
|
|
|
|
2020-12-01 16:42:18 +00:00
|
|
|
int32 gNumMemMoved;
|
|
|
|
|
|
|
|
RwTexture *
|
|
|
|
MoveTextureMemoryCB(RwTexture *texture, void *pData)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return texture;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TidyUpModelInfo(CBaseModelInfo *,bool)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGame::DrasticTidyUpMemory(bool flushDraw)
|
2019-10-18 22:23:40 +00:00
|
|
|
{
|
2020-11-26 15:47:19 +00:00
|
|
|
#ifdef USE_CUSTOM_ALLOCATOR
|
2020-12-01 16:42:18 +00:00
|
|
|
bool removedCol = false;
|
|
|
|
|
|
|
|
TidyUpMemory(true, flushDraw);
|
|
|
|
|
|
|
|
if(gMainHeap.GetLargestFreeBlock() < 200000 && !playingIntro){
|
|
|
|
CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL);
|
|
|
|
CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL);
|
|
|
|
CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN);
|
|
|
|
TidyUpMemory(true, flushDraw);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(gMainHeap.GetLargestFreeBlock() < 200000 && !playingIntro){
|
|
|
|
CModelInfo::RemoveColModelsFromOtherLevels(LEVEL_GENERIC);
|
|
|
|
TidyUpMemory(true, flushDraw);
|
|
|
|
removedCol = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(gMainHeap.GetLargestFreeBlock() < 200000 && !playingIntro){
|
|
|
|
CStreaming::RemoveBigBuildings(LEVEL_INDUSTRIAL);
|
|
|
|
CStreaming::RemoveBigBuildings(LEVEL_COMMERCIAL);
|
|
|
|
CStreaming::RemoveBigBuildings(LEVEL_SUBURBAN);
|
|
|
|
TidyUpMemory(true, flushDraw);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(removedCol){
|
|
|
|
// different on PS2
|
|
|
|
CFileLoader::LoadCollisionFromDatFile(CCollision::ms_collisionInMemory);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!playingIntro)
|
|
|
|
CStreaming::RequestBigBuildings(currLevel);
|
|
|
|
|
|
|
|
CStreaming::LoadAllRequestedModels(true);
|
2020-03-28 20:55:23 +00:00
|
|
|
#endif
|
2019-10-18 22:23:40 +00:00
|
|
|
}
|
2019-07-24 16:55:43 +00:00
|
|
|
|
2020-12-01 16:42:18 +00:00
|
|
|
void CGame::TidyUpMemory(bool moveTextures, bool flushDraw)
|
2019-10-21 13:47:08 +00:00
|
|
|
{
|
2020-11-26 15:47:19 +00:00
|
|
|
#ifdef USE_CUSTOM_ALLOCATOR
|
2020-12-01 16:42:18 +00:00
|
|
|
printf("Largest free block before tidy %d\n", gMainHeap.GetLargestFreeBlock());
|
|
|
|
|
|
|
|
if(moveTextures){
|
|
|
|
if(flushDraw){
|
|
|
|
#ifdef GTA_PS2
|
|
|
|
for(int i = 0; i < sweMaxFlips+1; i++){
|
|
|
|
#else
|
|
|
|
for(int i = 0; i < 5; i++){ // probably more than needed
|
|
|
|
#endif
|
|
|
|
RwCameraBeginUpdate(Scene.camera);
|
|
|
|
RwCameraEndUpdate(Scene.camera);
|
|
|
|
RwCameraShowRaster(Scene.camera, nil, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int fontSlot = CTxdStore::FindTxdSlot("fonts");
|
|
|
|
|
|
|
|
for(int i = 0; i < TXDSTORESIZE; i++){
|
|
|
|
if(i == fontSlot ||
|
|
|
|
CTxdStore::GetSlot(i) == nil)
|
|
|
|
continue;
|
|
|
|
RwTexDictionary *txd = CTxdStore::GetSlot(i)->texDict;
|
|
|
|
if(txd)
|
|
|
|
RwTexDictionaryForAllTextures(txd, MoveTextureMemoryCB, nil);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// animations
|
|
|
|
for(int i = 0; i < NUMANIMATIONS; i++){
|
|
|
|
CAnimBlendHierarchy *anim = CAnimManager::GetAnimation(i);
|
|
|
|
if(anim == nil)
|
|
|
|
continue; // cannot happen
|
|
|
|
anim->MoveMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
// model info
|
|
|
|
for(int i = 0; i < MODELINFOSIZE; i++){
|
|
|
|
CBaseModelInfo *mi = CModelInfo::GetModelInfo(i);
|
|
|
|
if(mi == nil)
|
|
|
|
continue;
|
|
|
|
TidyUpModelInfo(mi, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Largest free block after tidy %d\n", gMainHeap.GetLargestFreeBlock());
|
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)
|
|
|
|
{
|
2020-11-26 15:47:19 +00:00
|
|
|
#ifdef USE_CUSTOM_ALLOCATOR
|
2020-12-01 16:42:18 +00:00
|
|
|
static int32 modelIndex = 0;
|
|
|
|
static int32 animIndex = 0;
|
|
|
|
static int32 txdIndex = 0;
|
|
|
|
bool txdReturn = false;
|
|
|
|
RwTexDictionary *txd = nil;
|
|
|
|
gNumMemMoved = 0;
|
|
|
|
|
|
|
|
// model infos
|
|
|
|
for(int numCleanedUp = 0; numCleanedUp < 10; numCleanedUp++){
|
|
|
|
CBaseModelInfo *mi;
|
|
|
|
do{
|
|
|
|
mi = CModelInfo::GetModelInfo(modelIndex);
|
|
|
|
modelIndex++;
|
|
|
|
if(modelIndex >= MODELINFOSIZE)
|
|
|
|
modelIndex = 0;
|
|
|
|
}while(mi == nil);
|
|
|
|
|
|
|
|
if(TidyUpModelInfo(mi, true))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// tex dicts
|
|
|
|
for(int numCleanedUp = 0; numCleanedUp < 3; numCleanedUp++){
|
|
|
|
if(gNumMemMoved > 80)
|
|
|
|
break;
|
|
|
|
|
|
|
|
do{
|
|
|
|
#ifdef FIX_BUGS
|
|
|
|
txd = nil;
|
|
|
|
#endif
|
|
|
|
if(CTxdStore::GetSlot(txdIndex))
|
|
|
|
txd = CTxdStore::GetSlot(txdIndex)->texDict;
|
|
|
|
txdIndex++;
|
|
|
|
if(txdIndex >= TXDSTORESIZE)
|
|
|
|
txdIndex = 0;
|
|
|
|
}while(txd == nil);
|
|
|
|
|
|
|
|
RwTexDictionaryForAllTextures(txd, MoveTextureMemoryCB, &txdReturn);
|
|
|
|
if(txdReturn)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// animations
|
|
|
|
CAnimBlendHierarchy *anim;
|
|
|
|
do{
|
|
|
|
anim = CAnimManager::GetAnimation(animIndex);
|
|
|
|
animIndex++;
|
|
|
|
if(animIndex >= NUMANIMATIONS)
|
|
|
|
animIndex = 0;
|
|
|
|
}while(anim == nil); // always != nil
|
|
|
|
anim->MoveMemory(true);
|
2020-04-08 23:52:38 +00:00
|
|
|
#endif
|
|
|
|
}
|