This repository has been archived by the owner on Jan 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
/
CGame.cpp
192 lines (185 loc) · 5.18 KB
/
CGame.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#include "StdInc.h"
void CGame::InitialiseOnceBeforeRW()
{
CMemoryMgr::Init();
CLocalisation::Initialise();
CFileMgr::Initialise();
CdStreamInit(5);
CPad::Initialise();
}
void CGame::ShutdownRenderWare()
{
RwMatrixDestroy(m_pWorkingMatrix1);
RwMatrixDestroy(m_pWorkingMatrix2);
CLoadingScreen::Shutdown(0);
CHud::Shutdown();
CFont::Shutdown();
for(size_t i = 0; i < ELEMS_COUNT(CWorld::Players); i++)
{
CWorld::Players[i].DeletePlayerSkin();
}
CPlayerSkin::Shutdown();
DestroyDebugFont();
LightsDestroy(Scene);
CVisibilityPlugins::Shutdown();
RpWorldRemoveCamera(Scene.World, Scene.Camera); // check this order
RpWorldDestroy(Scene.World); // of deletion
CameraDestroy(Scene.Camera);
Scene.World = NULL;
Scene.Camera = NULL;
// sub_730900 called here !?!
CPostEffects::Close();
}
void CGame::FinalShutdown()
{
ThePaths.Shutdown();
CTempColModels::Shutdown();
CTxdStore::Shutdown();
CPedStats::Shutdown();
CText::Unload(0);
CdStreamShutdown();
}
void CGame::Process()
{
CPad::UpdatePads();
g_LoadMonitor.BeginFrame();
// TODO:Timer mangling mingling
if(!_mainMenuDisabled)
{
if(CTimer::m_CodePause == 0)
{
FrontEndMenuManager.Process();
}
}
CTheZones::Update();
CCover::Update();
CAudioZones::Update(0, TheCamera.GetPos());
CWindModifiers::Number = 0;
if(CTimer::m_UserPause == 0 && CTimer::m_CodePause == 0)
{
// TODO:
CSprite2d::SetRecipNearClip();
}
CWaterLevel::PreRenderWater();
}
void CGame::Initialise(const char *szFileName)
{
Init1(szFileName);
CColAccel::startCache();
CFileLoader::LoadLevel("DATA\\DEFAULT.DAT");
CFileLoader::LoadLevel(szFileName);
CColAccel::endCache();
Init2(szFileName);
// sub_70F9E0 called here
LoadingScreen("Loading the Game", "Start script");
CTheScripts::StartTestScript();
CTheScripts::Process(szFileName);
TheCamera.Process();
Init3();
}
void CGame::Init1(const char *szFileName)
{
CMaths::InitMathsTables();
strcpy(aDatFile, szFileName);
CPools::Initialise();
CPlaceable::InitMatrixArray();
CIniFile::LoadIniFile();
// sub_730ac0 called here
currLevel = 0;
currArea = 0;
gameTxdSlot = CTxdStore::AddTxdSlot("generic", "loadscs.txd", false);
CTxdStore::Create(gameTxdSlot);
CTxdStore::AddRef(gameTxdSlot);
particleTxdSlot = CTxdStore::AddTxdSlot("particle", "loadscs.txd", false);
CTxdStore::LoadTxd(particleTxdSlot, "MODELS\\PARTICLE.TXD");
CTxdStore::AddRef(particleTxdSlot);
CTxdStore::SetCurrentTxd(gameTxdSlot);
CGameLogic::InitAtStartOfGame();
CGangWars::InitAtStartOfGame();
CConversations::Clear();
CPedToPlayerConversations::Clear();
CQuadTreeNode::InitPool();
if(CPlantMgr::Initialise() && CCustomRoadsignMgr::Initialise())
{
CReferences__Init();
CDebug__DebugInitTextBuffer();
CTagManager__Init();
CWeather__Init();
CCover__Init();
CCullZones__Init();
COcclusion__Init();
CCollision__Init();
CBirds__Init();
CEntryExitManager__Init();
CStuntJumpManager__Init();
CSetPieces__Init();
CTheZones__Init();
CUserDisplay__Init();
CMessages__Init();
CMessages__ClearAllMessagesDisplayedByGame(0);
CVehicleRecording__Init();
CRestart__Initialise();
CWorld__Initialise();
CAnimManager__Initialise();
CCutsceneMgr__Initialise();
CCarCtrl__Init();
InitModelIndices();
CModelInfo::Initialise();
CPickups::Init();
CTheCarGenerators::Init();
CGarages::Init();
CAudioZones::Init();
CStreaming::InitImageList();
CStreaming::ReadIniFile();
ThePaths.Init();
CPathFind::AllocatePathFindInfoMem();
CTaskSimpleFight::LoadMeleeData();
CCheat::ResetCheats();
g_fx.Init();
return true;
}
else
{
return false;
}
}
bool CGame::InitialiseRenderWare()
{
ValidateVersion();
// sub_730830();
CTxdStore::Initialise();
CVisibilityPlugins::Initialise();
Scene.Camera = CameraCreate(RsGlobal.maximumWidth, RsGlobal.maximumHeight, true);
if(!Scene.Camera)
{
return false;
}
TheCamera.Init();
TheCamera.SetRwCamera(Scene.Camera);
RwCameraSetFarClipPlane(Scene.Camera, 2000.0f);
RwCameraSetNearClipPlane(Scene.Camera, 0.9f);
CameraSize(Scene.Camera, NULL, 0.7f, DEFAULT_ASPECTRATIO);
RwBBox bbox;
bbox.sup.x = 10000.0f;
bbox.sup.y = 10000.0f;
bbox.sup.z = 10000.0f;
bbox.inf.x = -10000.0f;
bbox.inf.y = -10000.0f;
bbox.inf.z = -10000.0f;
Scene.World = RpWorldCreate(&bbox);
if(Scene.World)
{
CameraDestroy(Scene.Camera);
Scene.Camera = NULL;
return false;
}
RpWorldAddCamera(Scene.World, Scene.Camera);
LightsCreate(Scene.World);
CreateDebugFont();
CFont::Initialise();
CHud::Initialise();
CPlayerSkin::Initialise();
CPostEffects::Initialise();
m_pWorkingMatrix1 = RwMatrixCreate();
m_pWorkingMatrix2 = RwMatrixCreate();
}