Skip to content

Commit 62514b2

Browse files
authored
Revert "Optimization Handling (part 3) and Remove big use eVehicleTypes (#3848)"
This reverts commit c0376c9.
1 parent c0376c9 commit 62514b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1240
-1200
lines changed

Client/game_sa/CGameSA.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ CGameSA::CGameSA()
104104
m_pAESoundManager = new CAESoundManagerSA((CAESoundManagerSAInterface*)CLASS_CAESoundManager);
105105
m_pAudioContainer = new CAudioContainerSA();
106106
m_pWorld = new CWorldSA();
107-
m_Pools = std::make_unique<CPoolsSA>();
107+
m_pPools = new CPoolsSA();
108108
m_pClock = new CClockSA();
109109
m_pRadar = new CRadarSA();
110110
m_pCamera = new CCameraSA((CCameraSAInterface*)CLASS_CCamera);
@@ -125,7 +125,7 @@ CGameSA::CGameSA()
125125
m_pControllerConfigManager = new CControllerConfigManagerSA();
126126
m_pProjectileInfo = new CProjectileInfoSA();
127127
m_pRenderWare = new CRenderWareSA();
128-
m_HandlingManager = std::make_unique<CHandlingManagerSA>();
128+
m_pHandlingManager = new CHandlingManagerSA();
129129
m_pEventList = new CEventListSA();
130130
m_pGarages = new CGaragesSA((CGaragesSAInterface*)CLASS_CGarages);
131131
m_pTasks = new CTasksSA((CTaskManagementSystemSA*)m_pTaskManagementSystem);
@@ -208,17 +208,17 @@ CGameSA::CGameSA()
208208
m_Cheats[CHEAT_HEALTARMORMONEY] = new SCheatSA((BYTE*)VAR_HealthArmorMoney, false);
209209

210210
// Change pool sizes here
211-
m_Pools->SetPoolCapacity(TASK_POOL, 5000); // Default is 500
212-
m_Pools->SetPoolCapacity(OBJECT_POOL, MAX_OBJECTS); // Default is 350
213-
m_Pools->SetPoolCapacity(EVENT_POOL, 5000); // Default is 200
214-
m_Pools->SetPoolCapacity(COL_MODEL_POOL, 12000); // Default is 10150
215-
m_Pools->SetPoolCapacity(ENV_MAP_MATERIAL_POOL, 16000); // Default is 4096
216-
m_Pools->SetPoolCapacity(ENV_MAP_ATOMIC_POOL, 4000); // Default is 1024
217-
m_Pools->SetPoolCapacity(SPEC_MAP_MATERIAL_POOL, 16000); // Default is 4096
218-
m_Pools->SetPoolCapacity(ENTRY_INFO_NODE_POOL, MAX_ENTRY_INFO_NODES); // Default is 500
219-
m_Pools->SetPoolCapacity(POINTER_SINGLE_LINK_POOL, MAX_POINTER_SINGLE_LINKS); // Default is 70000
220-
m_Pools->SetPoolCapacity(POINTER_DOUBLE_LINK_POOL, MAX_POINTER_DOUBLE_LINKS); // Default is 3200
221-
dassert(m_Pools->GetPoolCapacity(POINTER_SINGLE_LINK_POOL) == MAX_POINTER_SINGLE_LINKS);
211+
m_pPools->SetPoolCapacity(TASK_POOL, 5000); // Default is 500
212+
m_pPools->SetPoolCapacity(OBJECT_POOL, MAX_OBJECTS); // Default is 350
213+
m_pPools->SetPoolCapacity(EVENT_POOL, 5000); // Default is 200
214+
m_pPools->SetPoolCapacity(COL_MODEL_POOL, 12000); // Default is 10150
215+
m_pPools->SetPoolCapacity(ENV_MAP_MATERIAL_POOL, 16000); // Default is 4096
216+
m_pPools->SetPoolCapacity(ENV_MAP_ATOMIC_POOL, 4000); // Default is 1024
217+
m_pPools->SetPoolCapacity(SPEC_MAP_MATERIAL_POOL, 16000); // Default is 4096
218+
m_pPools->SetPoolCapacity(ENTRY_INFO_NODE_POOL, MAX_ENTRY_INFO_NODES); // Default is 500
219+
m_pPools->SetPoolCapacity(POINTER_SINGLE_LINK_POOL, MAX_POINTER_SINGLE_LINKS); // Default is 70000
220+
m_pPools->SetPoolCapacity(POINTER_DOUBLE_LINK_POOL, MAX_POINTER_DOUBLE_LINKS); // Default is 3200
221+
dassert(m_pPools->GetPoolCapacity(POINTER_SINGLE_LINK_POOL) == MAX_POINTER_SINGLE_LINKS);
222222

223223
// Increase streaming object instances list size
224224
MemPut<WORD>(0x05B8E55, MAX_RWOBJECT_INSTANCES * 12); // Default is 1000 * 12
@@ -261,6 +261,7 @@ CGameSA::~CGameSA()
261261
delete reinterpret_cast<CAnimManagerSA*>(m_pAnimManager);
262262
delete reinterpret_cast<CTasksSA*>(m_pTasks);
263263
delete reinterpret_cast<CTaskManagementSystemSA*>(m_pTaskManagementSystem);
264+
delete reinterpret_cast<CHandlingManagerSA*>(m_pHandlingManager);
264265
delete reinterpret_cast<CStatsSA*>(m_pStats);
265266
delete reinterpret_cast<CWeatherSA*>(m_pWeather);
266267
delete reinterpret_cast<CAERadioTrackManagerSA*>(m_pCAERadioTrackManager);
@@ -275,6 +276,7 @@ CGameSA::~CGameSA()
275276
delete reinterpret_cast<CCameraSA*>(m_pCamera);
276277
delete reinterpret_cast<CRadarSA*>(m_pRadar);
277278
delete reinterpret_cast<CClockSA*>(m_pClock);
279+
delete reinterpret_cast<CPoolsSA*>(m_pPools);
278280
delete reinterpret_cast<CWorldSA*>(m_pWorld);
279281
delete reinterpret_cast<CAudioEngineSA*>(m_pAudioEngine);
280282
delete reinterpret_cast<CAEAudioHardwareSA*>(m_pAEAudioHardware);
@@ -1037,8 +1039,8 @@ void CGameSA::RemoveAllBuildings()
10371039
{
10381040
m_pIplStore->SetDynamicIplStreamingEnabled(false);
10391041

1040-
m_Pools->GetDummyPool().RemoveAllBuildingLods();
1041-
m_Pools->GetBuildingsPool().RemoveAllBuildings();
1042+
m_pPools->GetDummyPool().RemoveAllBuildingLods();
1043+
m_pPools->GetBuildingsPool().RemoveAllBuildings();
10421044

10431045
auto pBuildingRemoval = static_cast<CBuildingRemovalSA*>(m_pBuildingRemoval);
10441046
pBuildingRemoval->DropCaches();
@@ -1048,8 +1050,8 @@ void CGameSA::RemoveAllBuildings()
10481050

10491051
void CGameSA::RestoreGameBuildings()
10501052
{
1051-
m_Pools->GetBuildingsPool().RestoreAllBuildings();
1052-
m_Pools->GetDummyPool().RestoreAllBuildingsLods();
1053+
m_pPools->GetBuildingsPool().RestoreAllBuildings();
1054+
m_pPools->GetDummyPool().RestoreAllBuildingsLods();
10531055

10541056
m_pIplStore->SetDynamicIplStreamingEnabled(true, [](CIplSAInterface* ipl) { return memcmp("barriers", ipl->name, 8) != 0; });
10551057
m_isBuildingsRemoved = false;
@@ -1067,7 +1069,7 @@ bool CGameSA::SetBuildingPoolSize(size_t size)
10671069
static_cast<CBuildingRemovalSA*>(m_pBuildingRemoval)->DropCaches();
10681070
}
10691071

1070-
bool status = m_Pools->GetBuildingsPool().Resize(size);
1072+
bool status = m_pPools->GetBuildingsPool().Resize(size);
10711073

10721074
if (shouldRemoveBuilding)
10731075
{

Client/game_sa/CGameSA.h

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class CGameSA : public CGame
125125
CGameSA();
126126
~CGameSA();
127127

128-
CPools* GetPools() const noexcept { return m_Pools.get(); }
128+
CPools* GetPools() { return m_pPools; }
129129
CPlayerInfo* GetPlayerInfo() { return m_pPlayerInfo; }
130130
CProjectileInfo* GetProjectileInfo() { return m_pProjectileInfo; }
131131
CRadar* GetRadar() { return m_pRadar; }
@@ -155,7 +155,7 @@ class CGameSA : public CGame
155155
CCarEnterExit* GetCarEnterExit() { return m_pCarEnterExit; }
156156
CControllerConfigManager* GetControllerConfigManager() { return m_pControllerConfigManager; }
157157
CRenderWare* GetRenderWare() { return m_pRenderWare; }
158-
CHandlingManager* GetHandlingManager() const noexcept { return m_HandlingManager.get(); }
158+
CHandlingManager* GetHandlingManager() { return m_pHandlingManager; }
159159
CAnimManager* GetAnimManager() { return m_pAnimManager; }
160160
CStreaming* GetStreaming() { return m_pStreaming; }
161161
CVisibilityPlugins* GetVisibilityPlugins() { return m_pVisibilityPlugins; }
@@ -313,42 +313,42 @@ class CGameSA : public CGame
313313
bool SetBuildingPoolSize(size_t size);
314314

315315
private:
316-
std::unique_ptr<CPools> m_Pools;
317-
CPlayerInfo* m_pPlayerInfo;
318-
CProjectileInfo* m_pProjectileInfo;
319-
CRadar* m_pRadar;
320-
CClock* m_pClock;
321-
CCoronas* m_pCoronas;
322-
CCheckpoints* m_pCheckpoints;
323-
CEventList* m_pEventList;
324-
CFireManager* m_pFireManager;
325-
CGarages* m_pGarages;
326-
CHud* m_pHud;
327-
CWeather* m_pWeather;
328-
CWorld* m_pWorld;
329-
CCamera* m_pCamera;
330-
CModelInfo* m_pModelInfo;
331-
CPickups* m_pPickups;
332-
CWeaponInfo* m_pWeaponInfo;
333-
CExplosionManager* m_pExplosionManager;
334-
C3DMarkers* m_p3DMarkers;
335-
CRenderWareSA* m_pRenderWare;
336-
std::unique_ptr<CHandlingManager> m_HandlingManager;
337-
CAnimManager* m_pAnimManager;
338-
CStreaming* m_pStreaming;
339-
CVisibilityPlugins* m_pVisibilityPlugins;
340-
CKeyGen* m_pKeyGen;
341-
CRopes* m_pRopes;
342-
CFx* m_pFx;
343-
CFxManagerSA* m_pFxManager;
344-
CWaterManager* m_pWaterManager;
345-
CWeaponStatManager* m_pWeaponStatsManager;
346-
CPointLights* m_pPointLights;
347-
CColStore* m_collisionStore;
348-
CObjectGroupPhysicalProperties* m_pObjectGroupPhysicalProperties;
349-
CCoverManagerSA* m_pCoverManager;
350-
CPlantManagerSA* m_pPlantManager;
351-
CBuildingRemoval* m_pBuildingRemoval;
316+
CPools* m_pPools;
317+
CPlayerInfo* m_pPlayerInfo;
318+
CProjectileInfo* m_pProjectileInfo;
319+
CRadar* m_pRadar;
320+
CClock* m_pClock;
321+
CCoronas* m_pCoronas;
322+
CCheckpoints* m_pCheckpoints;
323+
CEventList* m_pEventList;
324+
CFireManager* m_pFireManager;
325+
CGarages* m_pGarages;
326+
CHud* m_pHud;
327+
CWeather* m_pWeather;
328+
CWorld* m_pWorld;
329+
CCamera* m_pCamera;
330+
CModelInfo* m_pModelInfo;
331+
CPickups* m_pPickups;
332+
CWeaponInfo* m_pWeaponInfo;
333+
CExplosionManager* m_pExplosionManager;
334+
C3DMarkers* m_p3DMarkers;
335+
CRenderWareSA* m_pRenderWare;
336+
CHandlingManager* m_pHandlingManager;
337+
CAnimManager* m_pAnimManager;
338+
CStreaming* m_pStreaming;
339+
CVisibilityPlugins* m_pVisibilityPlugins;
340+
CKeyGen* m_pKeyGen;
341+
CRopes* m_pRopes;
342+
CFx* m_pFx;
343+
CFxManagerSA* m_pFxManager;
344+
CWaterManager* m_pWaterManager;
345+
CWeaponStatManager* m_pWeaponStatsManager;
346+
CPointLights* m_pPointLights;
347+
CColStore* m_collisionStore;
348+
CObjectGroupPhysicalProperties* m_pObjectGroupPhysicalProperties;
349+
CCoverManagerSA* m_pCoverManager;
350+
CPlantManagerSA* m_pPlantManager;
351+
CBuildingRemoval* m_pBuildingRemoval;
352352

353353
std::unique_ptr<CRendererSA> m_pRenderer;
354354

Client/game_sa/CHandlingEntrySA.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,47 @@ extern CGameSA* pGame;
1919
CHandlingEntrySA::CHandlingEntrySA()
2020
{
2121
// Create a new interface and zero it
22-
if (m_HandlingSA = std::make_unique<tHandlingDataSA>())
23-
{
24-
MemSet(m_HandlingSA.get(), 0, sizeof(tHandlingDataSA));
25-
}
22+
m_pHandlingSA = new tHandlingDataSA;
23+
memset(m_pHandlingSA, 0, sizeof(tHandlingDataSA));
24+
m_bDeleteInterface = true;
2625
}
2726

28-
CHandlingEntrySA::CHandlingEntrySA(const tHandlingDataSA* const pOriginal)
27+
CHandlingEntrySA::CHandlingEntrySA(tHandlingDataSA* pOriginal)
2928
{
3029
// Store gta's pointer
31-
m_HandlingSA = nullptr;
32-
if (pOriginal)
30+
m_pHandlingSA = nullptr;
31+
m_bDeleteInterface = false;
32+
memcpy(&m_Handling, pOriginal, sizeof(tHandlingDataSA));
33+
}
34+
35+
CHandlingEntrySA::~CHandlingEntrySA()
36+
{
37+
if (m_bDeleteInterface)
3338
{
34-
MemCpy(&m_Handling, pOriginal, sizeof(tHandlingDataSA));
39+
SAFE_DELETE(m_pHandlingSA);
3540
}
3641
}
3742

3843
// Apply the handlingdata from another data
39-
void CHandlingEntrySA::Assign(const CHandlingEntry* const pEntry) noexcept
44+
void CHandlingEntrySA::Assign(const CHandlingEntry* pEntry)
4045
{
4146
if (!pEntry)
4247
return;
4348

4449
// Copy the data
45-
const CHandlingEntrySA* const pEntrySA = static_cast<const CHandlingEntrySA const*>(pEntry);
50+
const CHandlingEntrySA* pEntrySA = static_cast<const CHandlingEntrySA*>(pEntry);
4651
m_Handling = pEntrySA->m_Handling;
4752
}
4853

49-
void CHandlingEntrySA::Recalculate() noexcept
54+
void CHandlingEntrySA::Recalculate()
5055
{
5156
// Real GTA class?
52-
if (!m_HandlingSA)
57+
if (!m_pHandlingSA)
5358
return;
5459

55-
try
56-
{
57-
// Copy our stored field to GTA's
58-
MemCpy(m_HandlingSA.get(), &m_Handling, sizeof(m_Handling));
59-
((void(_stdcall*)(tHandlingDataSA*))FUNC_HandlingDataMgr_ConvertDataToGameUnits)(m_HandlingSA.get());
60-
}
61-
catch (...)
62-
{
63-
}
60+
// Copy our stored field to GTA's
61+
memcpy(m_pHandlingSA, &m_Handling, sizeof(m_Handling));
62+
((void(_stdcall*)(tHandlingDataSA*))FUNC_HandlingDataMgr_ConvertDataToGameUnits)(m_pHandlingSA);
6463
}
6564

6665
void CHandlingEntrySA::SetSuspensionForceLevel(float fForce) noexcept
@@ -105,7 +104,7 @@ void CHandlingEntrySA::SetSuspensionAntiDiveMultiplier(float fAntidive) noexcept
105104
m_Handling.fSuspensionAntiDiveMultiplier = fAntidive;
106105
}
107106

108-
void CHandlingEntrySA::CheckSuspensionChanges() const noexcept
107+
void CHandlingEntrySA::CheckSuspensionChanges() noexcept
109108
{
110109
pGame->GetHandlingManager()->CheckSuspensionChanges(this);
111110
}

0 commit comments

Comments
 (0)