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"
|
2020-03-28 21:55:23 +01:00
|
|
|
#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 "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"
|
2020-03-28 21:55:23 +01:00
|
|
|
#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"
|
2020-12-27 21:46:15 +01:00
|
|
|
#include "frontendoption.h"
|
2019-10-19 00:23:40 +02:00
|
|
|
#include "GameLogic.h"
|
|
|
|
#include "Garages.h"
|
2020-03-28 21:55:23 +01:00
|
|
|
#include "GenericGameStorage.h"
|
2019-10-19 00:23:40 +02:00
|
|
|
#include "Glass.h"
|
2020-03-28 21:55:23 +01:00
|
|
|
#include "HandlingMgr.h"
|
2019-10-19 00:23:40 +02:00
|
|
|
#include "Heli.h"
|
2020-03-28 21:55:23 +01:00
|
|
|
#include "Hud.h"
|
2020-03-22 15:23:40 +01:00
|
|
|
#include "IniFile.h"
|
2020-03-28 21:55:23 +01:00
|
|
|
#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"
|
2020-12-19 01:21:04 +01:00
|
|
|
#include "MemoryHeap.h"
|
2019-10-19 00:23:40 +02:00
|
|
|
#include "Pad.h"
|
|
|
|
#include "Particle.h"
|
2020-03-28 21:55:23 +01:00
|
|
|
#include "ParticleObject.h"
|
|
|
|
#include "PedRoutes.h"
|
2019-10-19 00:23:40 +02:00
|
|
|
#include "Phones.h"
|
|
|
|
#include "Pickups.h"
|
|
|
|
#include "Plane.h"
|
2020-03-28 21:55:23 +01:00
|
|
|
#include "PlayerSkin.h"
|
2019-10-19 00:23:40 +02:00
|
|
|
#include "Population.h"
|
2020-03-28 21:55:23 +01:00
|
|
|
#include "Radar.h"
|
2019-10-19 00:23:40 +02:00
|
|
|
#include "Record.h"
|
2020-03-28 21:55:23 +01:00
|
|
|
#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"
|
2020-03-22 15:23:40 +01:00
|
|
|
#include "Stats.h"
|
2019-10-19 00:23:40 +02:00
|
|
|
#include "Streaming.h"
|
2020-03-28 21:55:23 +01:00
|
|
|
#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"
|
2020-03-28 21:55:23 +01:00
|
|
|
#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"
|
2020-05-19 10:23:08 +02:00
|
|
|
#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"
|
2021-01-02 10:38:54 +01:00
|
|
|
#include "VarConsole.h"
|
2020-11-23 21:46:07 +01:00
|
|
|
#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;
|
2020-05-05 17:04:43 +02:00
|
|
|
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
|
2021-01-02 10:38:54 +01:00
|
|
|
#ifndef MASTER
|
|
|
|
CVector CGame::PlayerCoords;
|
|
|
|
bool8 CGame::VarUpdatePlayerCoords;
|
|
|
|
#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
|
|
|
|
2021-01-14 23:16:42 +01:00
|
|
|
#ifdef SECUROM
|
|
|
|
uint8 gameProcessPirateCheck = 0;
|
|
|
|
#endif
|
|
|
|
|
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);
|
2020-08-03 03:00:12 +02:00
|
|
|
#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();
|
2020-11-08 18:49:47 +01:00
|
|
|
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();
|
|
|
|
}
|
2020-08-03 03:00:12 +02:00
|
|
|
#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();
|
2020-12-27 21:46:15 +01:00
|
|
|
#endif
|
|
|
|
#ifdef CUSTOM_FRONTEND_OPTIONS
|
|
|
|
// Not needed here but may be needed in future
|
|
|
|
// if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0)
|
|
|
|
CustomFrontendOptionsPopulate();
|
2020-08-11 18:39:53 +02:00
|
|
|
#endif
|
2019-07-24 18:55:43 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-07-29 14:24:42 +02:00
|
|
|
#ifndef LIBRW
|
|
|
|
#ifdef PS2_MATFX
|
2020-07-22 02:23:12 +02:00
|
|
|
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
|
2020-07-22 02:23:12 +02:00
|
|
|
|
2020-03-28 21:55:23 +01:00
|
|
|
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
|
2020-03-28 21:55:23 +01:00
|
|
|
_TexturePoolsInitialise();
|
2020-04-17 07:54:14 +02:00
|
|
|
#endif
|
2020-12-04 01:12:58 +01:00
|
|
|
|
2020-03-28 21:55:23 +01:00
|
|
|
CTxdStore::Initialise();
|
|
|
|
CVisibilityPlugins::Initialise();
|
2020-12-04 01:12:58 +01:00
|
|
|
|
|
|
|
#ifdef GTA_PS2
|
|
|
|
RpSkySelectTrueTSClipper(TRUE);
|
|
|
|
RpSkySelectTrueTLClipper(TRUE);
|
|
|
|
|
|
|
|
// PS2ManagerApplyDirectionalLightingCB() uploads the GTA lights
|
|
|
|
// directly without going through RpWorld and all that
|
|
|
|
SetupPS2ManagerDefaultLightingCallback();
|
|
|
|
PreAllocateRwObjects();
|
|
|
|
#endif
|
|
|
|
|
2020-03-28 21:55:23 +01:00
|
|
|
/* Create camera */
|
2020-12-13 12:53:19 +01:00
|
|
|
Scene.camera = CameraCreate(SCREEN_WIDTH, SCREEN_HEIGHT, TRUE);
|
2020-03-29 15:32:11 +02:00
|
|
|
ASSERT(Scene.camera != nil);
|
2020-03-28 21:55:23 +01:00
|
|
|
if (!Scene.camera)
|
|
|
|
{
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
|
2020-12-20 19:13:37 +01:00
|
|
|
RwCameraSetFarClipPlane(Scene.camera, 2000.0f);
|
2020-03-29 15:32:11 +02:00
|
|
|
RwCameraSetNearClipPlane(Scene.camera, 0.9f);
|
2020-03-28 21:55:23 +01:00
|
|
|
|
2020-03-29 15:32:11 +02:00
|
|
|
CameraSize(Scene.camera, nil, DEFAULT_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
|
2020-03-28 21:55:23 +01:00
|
|
|
|
|
|
|
/* 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;
|
2020-03-28 21:55:23 +01:00
|
|
|
|
|
|
|
Scene.world = RpWorldCreate(&bbox);
|
2020-03-29 15:32:11 +02:00
|
|
|
ASSERT(Scene.world != nil);
|
2020-03-28 21:55:23 +01:00
|
|
|
if (!Scene.world)
|
|
|
|
{
|
|
|
|
CameraDestroy(Scene.camera);
|
2020-03-29 15:32:11 +02:00
|
|
|
Scene.camera = nil;
|
2020-03-28 21:55:23 +01:00
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the camera to the world */
|
|
|
|
RpWorldAddCamera(Scene.world, Scene.camera);
|
|
|
|
LightsCreate(Scene.world);
|
2020-12-04 01:12:58 +01:00
|
|
|
|
2020-03-28 21:55:23 +01:00
|
|
|
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
|
2020-07-22 02:23:12 +02:00
|
|
|
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
|
2020-12-04 01:12:58 +01:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_TEXTURES);
|
2020-03-28 21:55:23 +01:00
|
|
|
CFont::Initialise();
|
|
|
|
CHud::Initialise();
|
2020-12-20 14:27:48 +01:00
|
|
|
CPlayerSkin::Initialise();
|
2020-12-04 01:12:58 +01:00
|
|
|
POP_MEMID();
|
2020-12-19 01:21:04 +01:00
|
|
|
|
2020-12-29 20:31:06 +01:00
|
|
|
#ifdef EXTENDED_PIPELINES
|
|
|
|
CustomPipes::CustomPipeInit(); // need Scene.world for this
|
|
|
|
#endif
|
|
|
|
#ifdef SCREEN_DROPLETS
|
|
|
|
ScreenDroplets::InitDraw();
|
|
|
|
#endif
|
|
|
|
|
2020-03-28 21:55:23 +01:00
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGame::ShutdownRenderWare(void)
|
|
|
|
{
|
2020-12-29 20:31:06 +01:00
|
|
|
#ifdef SCREEN_DROPLETS
|
|
|
|
ScreenDroplets::Shutdown();
|
|
|
|
#endif
|
|
|
|
#ifdef EXTENDED_PIPELINES
|
|
|
|
CustomPipes::CustomPipeShutdown();
|
|
|
|
#endif
|
|
|
|
|
2020-03-28 21:55:23 +01:00
|
|
|
DestroySplashScreen();
|
|
|
|
CHud::Shutdown();
|
|
|
|
CFont::Shutdown();
|
|
|
|
|
|
|
|
for ( int32 i = 0; i < NUMPLAYERS; i++ )
|
|
|
|
CWorld::Players[i].DeletePlayerSkin();
|
2020-12-04 01:12:58 +01:00
|
|
|
|
2020-03-28 21:55:23 +01:00
|
|
|
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;
|
2020-03-28 21:55:23 +01:00
|
|
|
|
|
|
|
CVisibilityPlugins::Shutdown();
|
|
|
|
|
2020-04-17 07:54:14 +02:00
|
|
|
#ifdef USE_TEXTURE_POOL
|
2020-03-28 21:55:23 +01:00
|
|
|
_TexturePoolsShutdown();
|
2020-04-17 07:54:14 +02:00
|
|
|
#endif
|
2020-03-28 21:55:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CGame::InitialiseOnceAfterRW(void)
|
|
|
|
{
|
|
|
|
TheText.Load();
|
|
|
|
CTimer::Initialise();
|
|
|
|
CTempColModels::Initialise();
|
|
|
|
mod_HandlingManager.Initialise();
|
|
|
|
CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
|
|
|
|
CPedStats::Initialise();
|
|
|
|
CTimeCycle::Initialise();
|
2020-12-20 14:27:48 +01:00
|
|
|
#ifdef GTA_PS2
|
|
|
|
LoadingScreen("Loading the Game", "Initialising audio", GetRandomSplashScreen());
|
|
|
|
#endif
|
2020-07-06 18:26:06 +02:00
|
|
|
DMAudio.Initialise();
|
2020-12-20 14:27:48 +01:00
|
|
|
|
|
|
|
#ifndef GTA_PS2
|
2020-03-28 21:55:23 +01:00
|
|
|
if ( DMAudio.GetNum3DProvidersAvailable() == 0 )
|
2020-07-06 18:26:06 +02:00
|
|
|
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = NO_AUDIO_PROVIDER;
|
2020-03-28 21:55:23 +01:00
|
|
|
|
2020-07-06 18:26:06 +02:00
|
|
|
if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == AUDIO_PROVIDER_NOT_DETERMINED || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 )
|
2020-03-28 21:55:23 +01:00
|
|
|
{
|
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();
|
2020-03-28 21:55:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2020-03-28 21:55:23 +01:00
|
|
|
DMAudio.SetEffectsFadeVol(127);
|
|
|
|
DMAudio.SetMusicFadeVol(127);
|
2020-12-20 14:27:48 +01:00
|
|
|
#endif
|
2020-03-28 21:55:23 +01:00
|
|
|
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)
|
|
|
|
{
|
2020-12-20 14:27:48 +01:00
|
|
|
ResetLoadingScreenBar();
|
|
|
|
strcpy(aDatFile, datFile);
|
|
|
|
|
2020-11-26 16:47:19 +01:00
|
|
|
#ifdef GTA_PS2
|
|
|
|
// TODO: upload VU0 collision code here
|
2020-12-01 00:22:57 +01:00
|
|
|
#endif
|
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
CPools::Initialise();
|
2020-12-01 00:22:57 +01:00
|
|
|
|
|
|
|
#ifndef GTA_PS2
|
2020-03-22 15:23:40 +01:00
|
|
|
CIniFile::LoadIniFile();
|
2020-11-26 16:47:19 +01:00
|
|
|
#endif
|
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-11-26 16:47:19 +01:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_TEXTURES);
|
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);
|
2020-11-26 16:47:19 +01:00
|
|
|
|
2020-03-22 15:23:40 +01: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 16:47:19 +01:00
|
|
|
POP_MEMID();
|
|
|
|
|
|
|
|
#ifdef GTA_PS2
|
|
|
|
CDma::SyncChannel(0, true);
|
|
|
|
#endif
|
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
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();
|
2020-05-19 10:23:08 +02:00
|
|
|
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();
|
2020-11-26 16:47:19 +01:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_WORLD);
|
2020-03-22 15:23:40 +01:00
|
|
|
CWorld::Initialise();
|
2020-11-26 16:47:19 +01:00
|
|
|
POP_MEMID();
|
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_TEXTURES);
|
2020-03-22 15:23:40 +01:00
|
|
|
CParticle::Initialise();
|
2020-11-26 16:47:19 +01:00
|
|
|
POP_MEMID();
|
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_ANIMATION);
|
2020-03-22 15:23:40 +01:00
|
|
|
CAnimManager::Initialise();
|
|
|
|
CCutsceneMgr::Initialise();
|
2020-11-26 16:47:19 +01:00
|
|
|
POP_MEMID();
|
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_CARS);
|
2020-03-22 15:23:40 +01:00
|
|
|
CCarCtrl::Init();
|
2020-11-26 16:47:19 +01:00
|
|
|
POP_MEMID();
|
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_DEF_MODELS);
|
2020-12-20 14:27:48 +01:00
|
|
|
InitModelIndices();
|
2020-03-22 15:23:40 +01:00
|
|
|
CModelInfo::Initialise();
|
|
|
|
CPickups::Init();
|
|
|
|
CTheCarGenerators::Init();
|
2020-12-01 00:22:57 +01:00
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
CdStreamAddImage("MODELS\\GTA3.IMG");
|
2020-12-01 00:22:57 +01:00
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
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-12-20 14:27:48 +01:00
|
|
|
POP_MEMID();
|
|
|
|
|
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();
|
2020-12-20 14:27:48 +01:00
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
LoadingScreen("Loading the Game", "Setup water", nil);
|
2021-01-13 00:18:58 +01:00
|
|
|
CWaterLevel::Initialise("DATA\\WATER.DAT");
|
2020-03-22 15:23:40 +01:00
|
|
|
TheConsole.Init();
|
|
|
|
CDraw::SetFOV(120.0f);
|
|
|
|
CDraw::ms_fLODDistance = 500.0f;
|
2020-12-20 14:27:48 +01:00
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
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-12-19 01:21:04 +01:00
|
|
|
|
2020-12-20 14:27:48 +01:00
|
|
|
LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen());
|
2020-11-26 16:47:19 +01:00
|
|
|
PUSH_MEMID(MEMID_ANIMATION);
|
2020-03-22 15:23:40 +01:00
|
|
|
CAnimManager::LoadAnimFiles();
|
2020-12-20 14:27:48 +01:00
|
|
|
POP_MEMID();
|
|
|
|
|
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();
|
2020-11-26 16:47:19 +01:00
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
LoadingScreen("Loading the Game", "Setup game variables", nil);
|
|
|
|
CRadar::Initialise();
|
|
|
|
CRadar::LoadTextures();
|
|
|
|
CWeapon::InitialiseWeapons();
|
2020-11-26 16:47:19 +01:00
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
LoadingScreen("Loading the Game", "Setup traffic lights", nil);
|
|
|
|
CTrafficLights::ScanForLightsOnMap();
|
|
|
|
CRoadBlocks::Init();
|
2020-11-26 16:47:19 +01:00
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
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-12-18 13:50:26 +01:00
|
|
|
#ifdef GTA_SCENE_EDIT
|
2020-04-12 11:06:33 +02:00
|
|
|
CSceneEdit::Initialise();
|
2020-12-18 13:50:26 +01:00
|
|
|
#endif
|
2020-12-20 14:27:48 +01:00
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
LoadingScreen("Loading the Game", "Load scripts", nil);
|
2020-11-26 16:47:19 +01:00
|
|
|
PUSH_MEMID(MEMID_SCRIPT);
|
2020-03-22 15:23:40 +01:00
|
|
|
CTheScripts::Init();
|
2020-03-28 21:55:23 +01:00
|
|
|
CGangs::Initialise();
|
2020-11-26 16:47:19 +01:00
|
|
|
POP_MEMID();
|
|
|
|
|
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-11-26 16:47:19 +01:00
|
|
|
|
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);
|
2020-12-19 01:21:04 +01:00
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
CTrain::InitTrains();
|
|
|
|
CPlane::InitPlanes();
|
|
|
|
CCredits::Init();
|
|
|
|
CRecordDataForChase::Init();
|
|
|
|
CReplay::Init();
|
2020-11-26 16:47:19 +01:00
|
|
|
|
2020-12-20 14:27:48 +01:00
|
|
|
LoadingScreen("Loading the Game", "Start script", nil);
|
2020-06-27 23:01:51 +02:00
|
|
|
#ifdef PS2_MENU
|
|
|
|
if ( !TheMemoryCard.m_bWantToLoad )
|
|
|
|
#endif
|
2020-12-01 00:22:57 +01:00
|
|
|
{
|
|
|
|
CTheScripts::StartTestScript();
|
|
|
|
CTheScripts::Process();
|
|
|
|
TheCamera.Process();
|
2020-06-27 23:01:51 +02:00
|
|
|
}
|
2020-11-26 16:47:19 +01:00
|
|
|
|
2020-03-22 15:23:40 +01:00
|
|
|
LoadingScreen("Loading the Game", "Load scene", nil);
|
2020-03-28 21:55:23 +01:00
|
|
|
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
|
2021-01-02 10:38:54 +01:00
|
|
|
|
|
|
|
#ifndef MASTER
|
|
|
|
PlayerCoords = FindPlayerCoors();
|
|
|
|
VarConsole.Add("X PLAYER COORD", &PlayerCoords.x, 10.0f, -10000.0f, 10000.0f, true);
|
|
|
|
VarConsole.Add("Y PLAYER COORD", &PlayerCoords.y, 10.0f, -10000.0f, 10000.0f, true);
|
|
|
|
VarConsole.Add("Z PLAYER COORD", &PlayerCoords.z, 10.0f, -10000.0f, 10000.0f, true);
|
|
|
|
VarConsole.Add("UPDATE PLAYER COORD", &VarUpdatePlayerCoords, true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2020-09-09 18:37:44 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-03-28 21:55:23 +01:00
|
|
|
bool CGame::ShutDown(void)
|
|
|
|
{
|
2020-08-29 18:22:25 +02:00
|
|
|
#ifdef USE_TEXTURE_POOL
|
|
|
|
_TexturePoolsUnknown(false);
|
|
|
|
#endif
|
2020-03-28 21:55:23 +01:00
|
|
|
CReplay::FinishPlayback();
|
2020-08-29 18:22:25 +02:00
|
|
|
CReplay::EmptyReplayBuffer();
|
2020-03-28 21:55:23 +01:00
|
|
|
CPlane::Shutdown();
|
|
|
|
CTrain::Shutdown();
|
2020-08-19 20:11:19 +02:00
|
|
|
CScriptPaths::Shutdown();
|
2020-10-09 14:53:22 +02:00
|
|
|
CWaterCreatures::RemoveAll();
|
2020-03-28 21:55:23 +01:00
|
|
|
CSpecialFX::Shutdown();
|
|
|
|
CGarages::Shutdown();
|
|
|
|
CMovingThings::Shutdown();
|
|
|
|
gPhoneInfo.Shutdown();
|
|
|
|
CWeapon::ShutdownWeapons();
|
|
|
|
CPedType::Shutdown();
|
|
|
|
|
|
|
|
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;
|
2020-03-28 21:55:23 +01: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();
|
2021-01-29 13:43:50 +01:00
|
|
|
CWaterLevel::Shutdown();
|
2020-03-28 21:55:23 +01:00
|
|
|
CRubbish::Shutdown();
|
|
|
|
CClouds::Shutdown();
|
|
|
|
CShadows::Shutdown();
|
|
|
|
CCoronas::Shutdown();
|
|
|
|
CSkidmarks::Shutdown();
|
|
|
|
CWeaponEffects::Shutdown();
|
|
|
|
CParticle::Shutdown();
|
|
|
|
CPools::ShutDown();
|
2021-01-29 13:43:50 +01:00
|
|
|
CHud::ReInitialise();
|
2020-03-28 21:55:23 +01:00
|
|
|
CTxdStore::RemoveTxdSlot(gameTxdSlot);
|
2020-08-29 18:22:25 +02:00
|
|
|
CMBlur::MotionBlurClose();
|
2020-03-28 21:55:23 +01:00
|
|
|
CdStreamRemoveImages();
|
2020-08-29 18:22:25 +02:00
|
|
|
#ifdef USE_TEXTURE_POOL
|
|
|
|
_TexturePoolsFinalShutdown();
|
|
|
|
#endif
|
2020-03-28 21:55:23 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGame::ReInitGameObjectVariables(void)
|
|
|
|
{
|
|
|
|
CGameLogic::InitAtStartOfGame();
|
2020-06-27 23:01:51 +02:00
|
|
|
#ifdef PS2_MENU
|
|
|
|
if ( !TheMemoryCard.m_bWantToLoad )
|
|
|
|
#endif
|
2020-12-01 17:42:18 +01:00
|
|
|
{
|
|
|
|
TheCamera.Init();
|
|
|
|
TheCamera.SetRwCamera(Scene.camera);
|
2020-06-27 23:01:51 +02:00
|
|
|
}
|
2020-03-28 21:55:23 +01:00
|
|
|
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;
|
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);
|
2020-03-28 21:55:23 +01:00
|
|
|
CStreaming::LoadAllRequestedModels(false);
|
2020-08-29 18:22:25 +02:00
|
|
|
currArea = AREA_MAIN_MAP;
|
2020-03-28 21:55:23 +01:00
|
|
|
CPed::Initialise();
|
|
|
|
CEventList::Initialise();
|
2020-11-19 19:07:32 +01:00
|
|
|
#ifdef SCREEN_DROPLETS
|
|
|
|
ScreenDroplets::Initialise();
|
|
|
|
#endif
|
2020-03-28 21:55:23 +01:00
|
|
|
CWeapon::InitialiseWeapons();
|
|
|
|
CPopulation::Initialise();
|
|
|
|
|
|
|
|
for (int i = 0; i < NUMPLAYERS; i++)
|
|
|
|
CWorld::Players[i].Clear();
|
|
|
|
|
|
|
|
CWorld::PlayerInFocus = 0;
|
|
|
|
CAntennas::Init();
|
|
|
|
CGlass::Init();
|
|
|
|
gPhoneInfo.Initialise();
|
2020-11-26 16:47:19 +01:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_SCRIPT);
|
2020-03-28 21:55:23 +01:00
|
|
|
CTheScripts::Init();
|
|
|
|
CGangs::Initialise();
|
2020-11-26 16:47:19 +01:00
|
|
|
POP_MEMID();
|
|
|
|
|
2020-03-28 21:55:23 +01:00
|
|
|
CTimer::Initialise();
|
|
|
|
CClock::Initialise(1000);
|
|
|
|
CTheCarGenerators::Init();
|
|
|
|
CHeli::InitHelis();
|
|
|
|
CMovingThings::Init();
|
|
|
|
CDarkel::Init();
|
|
|
|
CStats::Init();
|
|
|
|
CPickups::Init();
|
|
|
|
CPacManPickups::Init();
|
|
|
|
CGarages::Init();
|
|
|
|
CSpecialFX::Init();
|
2020-07-27 15:04:05 +02:00
|
|
|
CRopes::Init();
|
2020-03-28 21:55:23 +01:00
|
|
|
CWaterCannons::Init();
|
2020-08-19 20:11:19 +02:00
|
|
|
CScriptPaths::Init();
|
2020-03-28 21:55:23 +01:00
|
|
|
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
|
2020-04-09 01:52:38 +02:00
|
|
|
if ( !FrontEndMenuManager.m_bWantToLoad )
|
2020-06-27 23:01:51 +02:00
|
|
|
#endif
|
2020-03-28 21:55:23 +01: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)
|
|
|
|
{
|
2020-06-01 16:52:40 +02:00
|
|
|
// Empty and unused
|
2020-03-28 21:55:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGame::ShutDownForRestart(void)
|
|
|
|
{
|
2020-08-29 18:22:25 +02:00
|
|
|
#ifdef USE_TEXTURE_POOL
|
|
|
|
_TexturePoolsUnknown(false);
|
|
|
|
#endif
|
2020-03-28 21:55:23 +01:00
|
|
|
CReplay::FinishPlayback();
|
|
|
|
CReplay::EmptyReplayBuffer();
|
|
|
|
DMAudio.DestroyAllGameCreatedEntities();
|
2020-08-29 18:22:25 +02:00
|
|
|
CMovingThings::Shutdown();
|
2020-03-28 21:55:23 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < NUMPLAYERS; i++)
|
|
|
|
CWorld::Players[i].Clear();
|
2020-03-29 15:32:11 +02:00
|
|
|
|
2020-03-28 21:55:23 +01:00
|
|
|
CGarages::SetAllDoorsBackToOriginalHeight();
|
|
|
|
CTheScripts::UndoBuildingSwaps();
|
|
|
|
CTheScripts::UndoEntityInvisibilitySettings();
|
|
|
|
CWorld::ClearForRestart();
|
2020-05-31 19:59:01 +02:00
|
|
|
CGameLogic::ClearShortCut();
|
2020-03-28 21:55:23 +01:00
|
|
|
CTimer::Shutdown();
|
2020-08-20 23:43:13 +02:00
|
|
|
CStreaming::ReInit();
|
2020-03-28 21:55:23 +01:00
|
|
|
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();
|
2020-03-28 21:55:23 +01:00
|
|
|
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");
|
2020-11-23 23:25:44 +01:00
|
|
|
#ifndef XBOX_MESSAGE_SCREEN
|
2020-05-24 01:59:30 +02:00
|
|
|
if (FrontEndMenuManager.m_bWantToLoad)
|
|
|
|
FrontEndMenuManager.MessageScreen("FELD_WR", true);
|
2020-11-23 23:25:44 +01:00
|
|
|
#endif
|
2020-05-24 01:59:30 +02:00
|
|
|
}
|
|
|
|
|
2020-03-28 21:55:23 +01:00
|
|
|
b_FoundRecentSavedGameWantToLoad = false;
|
|
|
|
|
|
|
|
TheCamera.Init();
|
|
|
|
|
2020-04-09 01:52:38 +02:00
|
|
|
if ( FrontEndMenuManager.m_bWantToLoad == true )
|
2020-03-28 21:55:23 +01:00
|
|
|
{
|
2020-11-23 23:25:44 +01:00
|
|
|
#ifdef XBOX_MESSAGE_SCREEN
|
|
|
|
FrontEndMenuManager.SetDialogTimer(1000);
|
|
|
|
DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 0);
|
|
|
|
CSprite2d::InitPerFrame();
|
|
|
|
CFont::InitPerFrame();
|
|
|
|
FrontEndMenuManager.DrawOverlays();
|
|
|
|
DoRWStuffEndOfFrame();
|
|
|
|
#endif
|
2020-03-28 21:55:23 +01:00
|
|
|
RestoreForStartLoad();
|
|
|
|
}
|
|
|
|
|
|
|
|
ReInitGameObjectVariables();
|
|
|
|
|
2020-04-09 01:52:38 +02:00
|
|
|
if ( FrontEndMenuManager.m_bWantToLoad == true )
|
2020-03-28 21:55:23 +01:00
|
|
|
{
|
2020-08-29 18:22:25 +02:00
|
|
|
FrontEndMenuManager.m_bWantToLoad = false;
|
2020-12-20 12:41:29 +01:00
|
|
|
InitRadioStationPositionList();
|
2020-03-28 21:55:23 +01:00
|
|
|
if ( GenericLoad() == true )
|
|
|
|
{
|
|
|
|
DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds());
|
|
|
|
CTrain::InitTrains();
|
|
|
|
CPlane::InitPlanes();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ( int32 i = 0; i < 50; i++ )
|
|
|
|
{
|
|
|
|
HandleExit();
|
2020-06-01 16:52:40 +02:00
|
|
|
FrontEndMenuManager.MessageScreen("FED_LFL", true); // Loading save game has failed. The game will restart now.
|
2020-03-28 21:55:23 +01:00
|
|
|
}
|
|
|
|
|
2020-08-29 18:22:25 +02:00
|
|
|
TheCamera.SetFadeColour(0, 0, 0);
|
2020-03-28 21:55:23 +01:00
|
|
|
ShutDownForRestart();
|
|
|
|
CTimer::Stop();
|
|
|
|
CTimer::Initialise();
|
2020-04-09 01:52:38 +02:00
|
|
|
FrontEndMenuManager.m_bWantToLoad = false;
|
2020-03-28 21:55:23 +01:00
|
|
|
ReInitGameObjectVariables();
|
2020-07-13 17:10:17 +02:00
|
|
|
currLevel = LEVEL_GENERIC;
|
2020-03-28 21:55:23 +01:00
|
|
|
CCollision::SortOutCollisionAfterLoad();
|
|
|
|
}
|
2020-11-23 23:25:44 +01:00
|
|
|
#ifdef XBOX_MESSAGE_SCREEN
|
|
|
|
FrontEndMenuManager.ProcessDialogTimer();
|
|
|
|
#endif
|
2020-03-28 21:55:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CTimer::Update();
|
|
|
|
|
|
|
|
DMAudio.ChangeMusicMode(MUSICMODE_GAME);
|
2020-08-29 18:22:25 +02:00
|
|
|
#ifdef USE_TEXTURE_POOL
|
|
|
|
_TexturePoolsUnknown(true);
|
|
|
|
#endif
|
2020-03-28 21:55:23 +01:00
|
|
|
}
|
|
|
|
|
2019-10-19 00:23:40 +02:00
|
|
|
void CGame::Process(void)
|
|
|
|
{
|
|
|
|
CPad::UpdatePads();
|
2020-11-26 16:47:19 +01:00
|
|
|
#ifdef USE_CUSTOM_ALLOCATOR
|
2020-04-09 01:52:38 +02:00
|
|
|
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();
|
2020-11-26 16:47:19 +01:00
|
|
|
|
2019-10-19 13:12:18 +02:00
|
|
|
if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused())
|
2019-10-19 00:23:40 +02:00
|
|
|
FrontEndMenuManager.Process();
|
2020-12-20 14:27:48 +01:00
|
|
|
|
2020-08-29 18:22:25 +02:00
|
|
|
CTheZones::Update();
|
2021-01-14 23:16:42 +01:00
|
|
|
#ifdef SECUROM
|
|
|
|
if (CTimer::GetTimeInMilliseconds() >= (35 * 60 * 1000) && gameProcessPirateCheck == 0){
|
|
|
|
// if game not pirated
|
|
|
|
// gameProcessPirateCheck = 1;
|
|
|
|
// else
|
|
|
|
gameProcessPirateCheck = 2;
|
|
|
|
}
|
|
|
|
#endif
|
2020-08-29 18:22:25 +02:00
|
|
|
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())
|
|
|
|
{
|
2021-01-02 10:38:54 +01:00
|
|
|
#ifndef MASTER
|
|
|
|
if (VarUpdatePlayerCoords) {
|
|
|
|
FindPlayerPed()->Teleport(PlayerCoords);
|
|
|
|
VarUpdatePlayerCoords = false;
|
|
|
|
}
|
|
|
|
#endif
|
2019-10-19 00:23:40 +02:00
|
|
|
CSprite2d::SetRecipNearClip();
|
|
|
|
CSprite2d::InitPerFrame();
|
|
|
|
CFont::InitPerFrame();
|
|
|
|
CRecordDataForGame::SaveOrRetrieveDataForThisFrame();
|
|
|
|
CRecordDataForChase::SaveOrRetrieveDataForThisFrame();
|
|
|
|
CPad::DoCheats();
|
|
|
|
CClock::Update();
|
|
|
|
CWeather::Update();
|
2020-11-26 16:47:19 +01:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_SCRIPT);
|
2019-10-19 00:23:40 +02:00
|
|
|
CTheScripts::Process();
|
2020-11-26 16:47:19 +01:00
|
|
|
POP_MEMID();
|
|
|
|
|
2019-10-19 00:23:40 +02:00
|
|
|
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();
|
2020-12-18 13:50:26 +01:00
|
|
|
#ifdef GTA_SCENE_EDIT
|
2019-10-19 00:23:40 +02:00
|
|
|
CSceneEdit::Update();
|
2020-12-18 13:50:26 +01:00
|
|
|
#endif
|
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();
|
2020-11-26 16:47:19 +01:00
|
|
|
|
|
|
|
PUSH_MEMID(MEMID_WORLD);
|
2019-10-19 00:23:40 +02:00
|
|
|
CWorld::Process();
|
2020-11-26 16:47:19 +01:00
|
|
|
POP_MEMID();
|
|
|
|
|
2019-10-19 00:23:40 +02:00
|
|
|
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-12-20 14:27:48 +01:00
|
|
|
PUSH_MEMID(MEMID_CARS);
|
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();
|
2020-12-20 14:27:48 +01:00
|
|
|
POP_MEMID();
|
2019-10-19 00:23:40 +02:00
|
|
|
}
|
|
|
|
}
|
2020-11-26 16:47:19 +01:00
|
|
|
#ifdef GTA_PS2
|
2020-06-27 23:01:51 +02:00
|
|
|
CMemCheck::DoTest();
|
|
|
|
#endif
|
2019-10-19 00:23:40 +02:00
|
|
|
}
|
2019-07-24 18:55:43 +02:00
|
|
|
|
2020-12-03 16:56:32 +01:00
|
|
|
#ifdef USE_CUSTOM_ALLOCATOR
|
|
|
|
|
2020-12-20 14:27:48 +01:00
|
|
|
// TODO(MIAMI)
|
|
|
|
|
2020-12-01 17:42:18 +01:00
|
|
|
int32 gNumMemMoved;
|
|
|
|
|
2020-12-03 16:04:59 +01:00
|
|
|
bool
|
2020-12-19 01:21:04 +01:00
|
|
|
MoveMem(void** ptr)
|
2020-05-21 13:23:12 +02:00
|
|
|
{
|
2020-12-19 01:21:04 +01:00
|
|
|
if (*ptr) {
|
2020-12-03 16:04:59 +01:00
|
|
|
gNumMemMoved++;
|
2020-12-19 01:21:04 +01:00
|
|
|
void* newPtr = gMainHeap.MoveMemory(*ptr);
|
|
|
|
if (*ptr != newPtr) {
|
2020-12-03 16:04:59 +01:00
|
|
|
*ptr = newPtr;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2020-05-21 13:23:12 +02:00
|
|
|
|
2020-12-03 16:04:59 +01:00
|
|
|
// Some convenience structs
|
|
|
|
struct SkyDataPrefix
|
|
|
|
{
|
|
|
|
uint32 pktSize1;
|
|
|
|
uint32 data; // pointer to data as read from TXD
|
|
|
|
uint32 pktSize2;
|
|
|
|
uint32 unused;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DMAGIFUpload
|
|
|
|
{
|
|
|
|
uint32 tag1_qwc, tag1_addr; // dmaref
|
|
|
|
uint32 nop1, vif_direct1;
|
|
|
|
|
|
|
|
uint32 giftag[4];
|
|
|
|
uint32 gs_bitbltbuf[4];
|
|
|
|
|
|
|
|
uint32 tag2_qwc, tag2_addr; // dmaref
|
|
|
|
uint32 nop2, vif_direct2;
|
|
|
|
};
|
|
|
|
|
|
|
|
// This is very scary. it depends on the exact memory layout of the DMA chains and whatnot
|
2020-12-19 01:21:04 +01:00
|
|
|
RwTexture*
|
|
|
|
MoveTextureMemoryCB(RwTexture* texture, void* pData)
|
2020-12-01 17:42:18 +01:00
|
|
|
{
|
2020-12-03 16:04:59 +01:00
|
|
|
#ifdef GTA_PS2
|
2020-12-19 01:21:04 +01:00
|
|
|
bool* pRet = (bool*)pData;
|
|
|
|
RwRaster* raster = RwTextureGetRaster(texture);
|
|
|
|
_SkyRasterExt* rasterExt = RASTEREXTFROMRASTER(raster);
|
|
|
|
if (raster->originalPixels == nil || // the raw data
|
|
|
|
raster->cpPixels == raster->originalPixels || // old format, can't handle it
|
|
|
|
rasterExt->dmaRefCount != 0 && rasterExt->dmaClrCount != 0)
|
2020-12-03 16:04:59 +01:00
|
|
|
return texture;
|
|
|
|
|
|
|
|
// this is the allocated pointer we will move
|
2020-12-19 01:21:04 +01:00
|
|
|
SkyDataPrefix* prefix = (SkyDataPrefix*)raster->originalPixels;
|
|
|
|
DMAGIFUpload* uploads = (DMAGIFUpload*)(prefix + 1);
|
2020-12-03 16:04:59 +01:00
|
|
|
|
|
|
|
// We have 4qw for each upload,
|
|
|
|
// i.e. for each buffer width of mip levels,
|
|
|
|
// and the palette if there is one.
|
|
|
|
// NB: this code does NOT support mipmaps!
|
|
|
|
// so we assume two uploads (pixels and palette)
|
|
|
|
//
|
|
|
|
// each upload looks like this:
|
|
|
|
// (DMAcnt; NOP; VIF DIRECT(2))
|
|
|
|
// giftag (1, A+D)
|
|
|
|
// GS_BITBLTBUF
|
|
|
|
// (DMAref->pixel data; NOP; VIF DIRECT(5))
|
|
|
|
// the DMArefs are what we have to adjust
|
|
|
|
uintptr dataDiff, upload1Diff, upload2Diff, pixelDiff, paletteDiff;
|
|
|
|
dataDiff = prefix->data - (uintptr)raster->originalPixels;
|
|
|
|
upload1Diff = uploads[0].tag2_addr - (uintptr)raster->originalPixels;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (raster->palette)
|
2020-12-03 16:04:59 +01:00
|
|
|
upload2Diff = uploads[1].tag2_addr - (uintptr)raster->originalPixels;
|
|
|
|
pixelDiff = (uintptr)raster->cpPixels - (uintptr)raster->originalPixels;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (raster->palette)
|
2020-12-03 16:04:59 +01:00
|
|
|
paletteDiff = (uintptr)raster->palette - (uintptr)raster->originalPixels;
|
2020-12-19 01:21:04 +01:00
|
|
|
uint8* newptr = (uint8*)gMainHeap.MoveMemory(raster->originalPixels);
|
|
|
|
if (newptr != raster->originalPixels) {
|
2020-12-03 16:04:59 +01:00
|
|
|
// adjust everything
|
|
|
|
prefix->data = (uintptr)newptr + dataDiff;
|
|
|
|
uploads[0].tag2_addr = (uintptr)newptr + upload1Diff;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (raster->palette)
|
2020-12-03 16:04:59 +01:00
|
|
|
uploads[1].tag2_addr = (uintptr)newptr + upload2Diff;
|
|
|
|
raster->originalPixels = newptr;
|
|
|
|
raster->cpPixels = newptr + pixelDiff;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (raster->palette)
|
2020-12-03 16:04:59 +01:00
|
|
|
raster->palette = newptr + paletteDiff;
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
if (pRet) {
|
2020-12-03 16:04:59 +01:00
|
|
|
*pRet = true;
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
// nothing to do here really, everything should be in videomemory
|
|
|
|
#endif
|
2020-12-01 17:42:18 +01:00
|
|
|
return texture;
|
2020-05-21 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
2020-05-27 20:50:01 +02:00
|
|
|
bool
|
2020-12-19 01:21:04 +01:00
|
|
|
MoveAtomicMemory(RpAtomic* atomic, bool onlyOne)
|
2020-05-27 20:50:01 +02:00
|
|
|
{
|
2020-12-19 01:21:04 +01:00
|
|
|
RpGeometry* geo = RpAtomicGetGeometry(atomic);
|
2020-12-03 16:04:59 +01:00
|
|
|
|
|
|
|
#if THIS_IS_COMPATIBLE_WITH_GTA3_RW31
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&geo->triangles) && onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&geo->matList.materials) && onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&geo->preLitLum) && onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&geo->texCoords[0]) && onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&geo->texCoords[1]) && onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
// verts and normals of morph target are allocated together
|
|
|
|
int vertDiff;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (geo->morphTarget->normals)
|
2020-12-03 16:04:59 +01:00
|
|
|
vertDiff = geo->morphTarget->normals - geo->morphTarget->verts;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&geo->morphTarget->verts)) {
|
|
|
|
if (geo->morphTarget->normals)
|
2020-12-03 16:04:59 +01:00
|
|
|
geo->morphTarget->normals = geo->morphTarget->verts + vertDiff;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
RpMeshHeader* oldmesh = geo->mesh;
|
|
|
|
if (MoveMem((void**)&geo->mesh)) {
|
2020-12-03 16:04:59 +01:00
|
|
|
// index pointers are allocated together with meshes,
|
|
|
|
// have to relocate those too
|
2020-12-19 01:21:04 +01:00
|
|
|
RpMesh* mesh = (RpMesh*)(geo->mesh + 1);
|
2020-12-03 16:04:59 +01:00
|
|
|
uintptr reloc = (uintptr)geo->mesh - (uintptr)oldmesh;
|
2020-12-19 01:21:04 +01:00
|
|
|
for (int i = 0; i < geo->mesh->numMeshes; i++)
|
2020-12-03 16:04:59 +01:00
|
|
|
mesh[i].indices = (RxVertexIndex*)((uintptr)mesh[i].indices + reloc);
|
2020-12-19 01:21:04 +01:00
|
|
|
if (onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
// we could do something in librw here
|
|
|
|
#endif
|
|
|
|
return false;
|
2020-05-27 20:50:01 +02:00
|
|
|
}
|
|
|
|
|
2020-05-12 16:27:26 +02:00
|
|
|
bool
|
2020-12-19 01:21:04 +01:00
|
|
|
MoveColModelMemory(CColModel& colModel, bool onlyOne)
|
2020-05-12 16:27:26 +02:00
|
|
|
{
|
2020-12-03 16:04:59 +01:00
|
|
|
#if GTA_VERSION >= GTA3_PS2_160
|
|
|
|
// hm...should probably only do this if ownsCollisionVolumes
|
|
|
|
// but it doesn't exist on PS2...
|
2020-12-19 01:21:04 +01:00
|
|
|
if (!colModel.ownsCollisionVolumes)
|
2020-12-03 16:04:59 +01:00
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&colModel.spheres) && onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&colModel.lines) && onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&colModel.boxes) && onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&colModel.vertices) && onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&colModel.triangles) && onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (MoveMem((void**)&colModel.trianglePlanes) && onlyOne)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
|
|
|
return false;
|
2020-05-12 16:27:26 +02:00
|
|
|
}
|
|
|
|
|
2020-12-03 16:04:59 +01:00
|
|
|
RpAtomic*
|
2020-12-19 01:21:04 +01:00
|
|
|
MoveAtomicMemoryCB(RpAtomic* atomic, void* pData)
|
2019-10-19 00:23:40 +02:00
|
|
|
{
|
2020-12-19 01:21:04 +01:00
|
|
|
bool* pRet = (bool*)pData;
|
|
|
|
if (pRet == nil)
|
2020-12-03 16:04:59 +01:00
|
|
|
MoveAtomicMemory(atomic, false);
|
2020-12-19 01:21:04 +01:00
|
|
|
else if (MoveAtomicMemory(atomic, true)) {
|
2020-12-03 16:04:59 +01:00
|
|
|
*pRet = true;
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
return atomic;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2020-12-19 01:21:04 +01:00
|
|
|
TidyUpModelInfo(CBaseModelInfo* modelInfo, bool onlyone)
|
2020-12-03 16:04:59 +01:00
|
|
|
{
|
2020-12-19 01:21:04 +01:00
|
|
|
if (modelInfo->GetColModel() && modelInfo->DoesOwnColModel())
|
|
|
|
if (MoveColModelMemory(*modelInfo->GetColModel(), onlyone))
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
RwObject* rwobj = modelInfo->GetRwObject();
|
|
|
|
if (RwObjectGetType(rwobj) == rpATOMIC)
|
|
|
|
if (MoveAtomicMemory((RpAtomic*)rwobj, onlyone))
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (RwObjectGetType(rwobj) == rpCLUMP) {
|
2020-12-03 16:04:59 +01:00
|
|
|
bool ret = false;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (onlyone)
|
2020-12-03 16:04:59 +01:00
|
|
|
RpClumpForAllAtomics((RpClump*)rwobj, MoveAtomicMemoryCB, &ret);
|
|
|
|
else
|
|
|
|
RpClumpForAllAtomics((RpClump*)rwobj, MoveAtomicMemoryCB, nil);
|
2020-12-19 01:21:04 +01:00
|
|
|
if (ret)
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
if (modelInfo->GetModelType() == MITYPE_PED && ((CPedModelInfo*)modelInfo)->m_hitColModel)
|
|
|
|
if (MoveColModelMemory(*((CPedModelInfo*)modelInfo)->m_hitColModel, onlyone))
|
2020-12-03 16:04:59 +01:00
|
|
|
return true;
|
|
|
|
|
2020-12-01 17:42:18 +01:00
|
|
|
return false;
|
|
|
|
}
|
2020-08-29 18:22:25 +02:00
|
|
|
#endif
|
2020-12-01 17:42:18 +01:00
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
|
2020-12-01 17:42:18 +01:00
|
|
|
void CGame::DrasticTidyUpMemory(bool flushDraw)
|
2019-10-19 00:23:40 +02:00
|
|
|
{
|
2020-11-26 16:47:19 +01:00
|
|
|
#ifdef USE_CUSTOM_ALLOCATOR
|
2020-12-01 17:42:18 +01:00
|
|
|
bool removedCol = false;
|
|
|
|
|
|
|
|
TidyUpMemory(true, flushDraw);
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
if (gMainHeap.GetLargestFreeBlock() < 200000 && !playingIntro) {
|
2020-12-01 17:42:18 +01:00
|
|
|
CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL);
|
|
|
|
CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL);
|
|
|
|
CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN);
|
|
|
|
TidyUpMemory(true, flushDraw);
|
|
|
|
}
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
if (gMainHeap.GetLargestFreeBlock() < 200000 && !playingIntro) {
|
2020-12-01 17:42:18 +01:00
|
|
|
CModelInfo::RemoveColModelsFromOtherLevels(LEVEL_GENERIC);
|
|
|
|
TidyUpMemory(true, flushDraw);
|
|
|
|
removedCol = true;
|
|
|
|
}
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
if (gMainHeap.GetLargestFreeBlock() < 200000 && !playingIntro) {
|
2020-12-01 17:42:18 +01:00
|
|
|
CStreaming::RemoveBigBuildings(LEVEL_INDUSTRIAL);
|
|
|
|
CStreaming::RemoveBigBuildings(LEVEL_COMMERCIAL);
|
|
|
|
CStreaming::RemoveBigBuildings(LEVEL_SUBURBAN);
|
|
|
|
TidyUpMemory(true, flushDraw);
|
|
|
|
}
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
if (removedCol) {
|
2020-12-01 17:42:18 +01:00
|
|
|
// different on PS2
|
|
|
|
CFileLoader::LoadCollisionFromDatFile(CCollision::ms_collisionInMemory);
|
|
|
|
}
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
if (!playingIntro)
|
2020-12-01 17:42:18 +01:00
|
|
|
CStreaming::RequestBigBuildings(currLevel);
|
|
|
|
|
|
|
|
CStreaming::LoadAllRequestedModels(true);
|
2020-03-28 21:55:23 +01:00
|
|
|
#endif
|
2019-10-19 00:23:40 +02:00
|
|
|
}
|
2019-07-24 18:55:43 +02:00
|
|
|
|
2020-12-01 17:42:18 +01:00
|
|
|
void CGame::TidyUpMemory(bool moveTextures, bool flushDraw)
|
2019-10-21 15:47:08 +02:00
|
|
|
{
|
2020-11-26 16:47:19 +01:00
|
|
|
#ifdef USE_CUSTOM_ALLOCATOR
|
2020-12-01 17:42:18 +01:00
|
|
|
printf("Largest free block before tidy %d\n", gMainHeap.GetLargestFreeBlock());
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
if (moveTextures) {
|
|
|
|
if (flushDraw) {
|
2020-12-01 17:42:18 +01:00
|
|
|
#ifdef GTA_PS2
|
2020-12-19 01:21:04 +01:00
|
|
|
for (int i = 0; i < sweMaxFlips + 1; i++) {
|
2020-12-01 17:42:18 +01:00
|
|
|
#else
|
2020-12-19 01:21:04 +01:00
|
|
|
for (int i = 0; i < 5; i++) { // probably more than needed
|
2020-12-01 17:42:18 +01:00
|
|
|
#endif
|
|
|
|
RwCameraBeginUpdate(Scene.camera);
|
|
|
|
RwCameraEndUpdate(Scene.camera);
|
|
|
|
RwCameraShowRaster(Scene.camera, nil, 0);
|
|
|
|
}
|
2020-12-19 01:21:04 +01:00
|
|
|
}
|
2020-12-01 17:42:18 +01:00
|
|
|
int fontSlot = CTxdStore::FindTxdSlot("fonts");
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
for (int i = 0; i < TXDSTORESIZE; i++) {
|
|
|
|
if (i == fontSlot ||
|
|
|
|
CTxdStore::GetSlot(i) == nil)
|
2020-12-01 17:42:18 +01:00
|
|
|
continue;
|
2020-12-19 01:21:04 +01:00
|
|
|
RwTexDictionary* txd = CTxdStore::GetSlot(i)->texDict;
|
|
|
|
if (txd)
|
2020-12-01 17:42:18 +01:00
|
|
|
RwTexDictionaryForAllTextures(txd, MoveTextureMemoryCB, nil);
|
|
|
|
}
|
2020-12-19 01:21:04 +01:00
|
|
|
}
|
2020-12-01 17:42:18 +01:00
|
|
|
|
|
|
|
// animations
|
2020-12-19 01:21:04 +01:00
|
|
|
for (int i = 0; i < NUMANIMATIONS; i++) {
|
|
|
|
CAnimBlendHierarchy* anim = CAnimManager::GetAnimation(i);
|
|
|
|
if (anim == nil)
|
2020-12-01 17:42:18 +01:00
|
|
|
continue; // cannot happen
|
|
|
|
anim->MoveMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
// model info
|
2020-12-19 01:21:04 +01:00
|
|
|
for (int i = 0; i < MODELINFOSIZE; i++) {
|
|
|
|
CBaseModelInfo* mi = CModelInfo::GetModelInfo(i);
|
|
|
|
if (mi == nil)
|
2020-12-01 17:42:18 +01:00
|
|
|
continue;
|
|
|
|
TidyUpModelInfo(mi, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Largest free block after tidy %d\n", gMainHeap.GetLargestFreeBlock());
|
2019-10-21 15:47:08 +02:00
|
|
|
#endif
|
2020-08-29 18:22:25 +02:00
|
|
|
}
|
2019-10-19 00:23:40 +02:00
|
|
|
|
2020-04-09 01:52:38 +02:00
|
|
|
void CGame::ProcessTidyUpMemory(void)
|
|
|
|
{
|
2020-11-26 16:47:19 +01:00
|
|
|
#ifdef USE_CUSTOM_ALLOCATOR
|
2020-12-01 17:42:18 +01:00
|
|
|
static int32 modelIndex = 0;
|
|
|
|
static int32 animIndex = 0;
|
|
|
|
static int32 txdIndex = 0;
|
|
|
|
bool txdReturn = false;
|
2020-12-19 01:21:04 +01:00
|
|
|
RwTexDictionary* txd = nil;
|
2020-12-01 17:42:18 +01:00
|
|
|
gNumMemMoved = 0;
|
|
|
|
|
|
|
|
// model infos
|
2020-12-19 01:21:04 +01:00
|
|
|
for (int numCleanedUp = 0; numCleanedUp < 10; numCleanedUp++) {
|
|
|
|
CBaseModelInfo* mi;
|
|
|
|
do {
|
2020-12-01 17:42:18 +01:00
|
|
|
mi = CModelInfo::GetModelInfo(modelIndex);
|
|
|
|
modelIndex++;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (modelIndex >= MODELINFOSIZE)
|
2020-12-01 17:42:18 +01:00
|
|
|
modelIndex = 0;
|
2020-12-19 01:21:04 +01:00
|
|
|
} while (mi == nil);
|
2020-12-01 17:42:18 +01:00
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
if (TidyUpModelInfo(mi, true))
|
2020-12-01 17:42:18 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// tex dicts
|
2020-12-19 01:21:04 +01:00
|
|
|
for (int numCleanedUp = 0; numCleanedUp < 3; numCleanedUp++) {
|
|
|
|
if (gNumMemMoved > 80)
|
2020-12-01 17:42:18 +01:00
|
|
|
break;
|
|
|
|
|
2020-12-19 01:21:04 +01:00
|
|
|
do {
|
2020-12-01 17:42:18 +01:00
|
|
|
#ifdef FIX_BUGS
|
|
|
|
txd = nil;
|
|
|
|
#endif
|
2020-12-19 01:21:04 +01:00
|
|
|
if (CTxdStore::GetSlot(txdIndex))
|
2020-12-01 17:42:18 +01:00
|
|
|
txd = CTxdStore::GetSlot(txdIndex)->texDict;
|
|
|
|
txdIndex++;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (txdIndex >= TXDSTORESIZE)
|
2020-12-01 17:42:18 +01:00
|
|
|
txdIndex = 0;
|
2020-12-19 01:21:04 +01:00
|
|
|
} while (txd == nil);
|
2020-12-01 17:42:18 +01:00
|
|
|
|
|
|
|
RwTexDictionaryForAllTextures(txd, MoveTextureMemoryCB, &txdReturn);
|
2020-12-19 01:21:04 +01:00
|
|
|
if (txdReturn)
|
2020-12-01 17:42:18 +01:00
|
|
|
return;
|
2020-12-19 01:21:04 +01:00
|
|
|
}
|
2020-12-01 17:42:18 +01:00
|
|
|
|
|
|
|
// animations
|
2020-12-19 01:21:04 +01:00
|
|
|
CAnimBlendHierarchy* anim;
|
|
|
|
do {
|
2020-12-01 17:42:18 +01:00
|
|
|
anim = CAnimManager::GetAnimation(animIndex);
|
|
|
|
animIndex++;
|
2020-12-19 01:21:04 +01:00
|
|
|
if (animIndex >= NUMANIMATIONS)
|
2020-12-01 17:42:18 +01:00
|
|
|
animIndex = 0;
|
2020-12-19 01:21:04 +01:00
|
|
|
} while (anim == nil); // always != nil
|
2020-12-01 17:42:18 +01:00
|
|
|
anim->MoveMemory(true);
|
2020-04-09 01:52:38 +02:00
|
|
|
#endif
|
|
|
|
}
|
2020-12-19 01:21:04 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
CGame::InitAfterFocusLoss()
|
|
|
|
{
|
|
|
|
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = FrontEndMenuManager.m_lastWorking3DAudioProvider;
|
|
|
|
DMAudio.SetCurrent3DProvider(FrontEndMenuManager.m_lastWorking3DAudioProvider);
|
|
|
|
|
|
|
|
if (!FrontEndMenuManager.m_bGameNotLoaded && !FrontEndMenuManager.m_bMenuActive)
|
|
|
|
FrontEndMenuManager.m_bStartUpFrontEndRequested = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CGame::CanSeeWaterFromCurrArea(void)
|
|
|
|
{
|
|
|
|
return currArea == AREA_MAIN_MAP || currArea == AREA_MANSION
|
|
|
|
|| currArea == AREA_HOTEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CGame::CanSeeOutSideFromCurrArea(void)
|
|
|
|
{
|
|
|
|
return currArea == AREA_MAIN_MAP || currArea == AREA_MALL ||
|
|
|
|
currArea == AREA_MANSION || currArea == AREA_HOTEL;
|
|
|
|
}
|