Skip to content

Commit 80aceab

Browse files
Merge pull request #279 from MiranDMC/master
CPlantMgr and updates CColStore
2 parents abc450e + 26ce080 commit 80aceab

File tree

8 files changed

+187
-29
lines changed

8 files changed

+187
-29
lines changed

plugin_sa/game_sa/CCarCtrl.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,31 @@
55
Do not delete this comment block. Respect others' work!
66
*/
77
#include "CCarCtrl.h"
8+
9+
bool& CCarCtrl::bCarIsBeingCreated = *(bool*)0x9690CC;
10+
unsigned int& CCarCtrl::NumLawEnforcerCars = *(unsigned int*)0x969098;
11+
unsigned int& CCarCtrl::NumParkedCars = *(unsigned int*)0x9690A0;
12+
unsigned int& CCarCtrl::NumAmbulancesOnDuty = *(unsigned int*)0x9690A8;
13+
unsigned int& CCarCtrl::NumFireTrucksOnDuty = *(unsigned int*)0x9690AC;
14+
unsigned int& CCarCtrl::MaxNumberOfCarsInUse = *(unsigned int*)0x8A5B24;
15+
float& CCarCtrl::CarDensityMultiplier = *(float*)0x8A5B20;
16+
int& CCarCtrl::NumRandomCars = *(int*)0x969094;
17+
int& CCarCtrl::NumMissionCars = *(int*)0x96909C;
18+
int& CCarCtrl::NumPermanentVehicles = *(int*)0x9690A4;
19+
int& CCarCtrl::LastTimeAmbulanceCreated = *(int*)0x9690B0;
20+
int& CCarCtrl::LastTimeFireTruckCreated = *(int*)0x9690B4;
21+
bool& CCarCtrl::bAllowEmergencyServicesToBeCreated = *(bool*)0x8A5B28;
22+
bool& CCarCtrl::bCarsGeneratedAroundCamera = *(bool*)0x9690C1;
23+
char& CCarCtrl::CountDownToCarsAtStart = *(char*)0x9690C0;
24+
float& CCarCtrl::TimeNextMadDriverChaseCreated = *(float*)0x9690BC;
25+
int& CCarCtrl::SequenceElements = *(int*)0x969078;
26+
int& CCarCtrl::SequenceRandomOffset = *(int*)0x969074;
27+
bool& CCarCtrl::bSequenceOtherWay = *(bool*)0x969070;
28+
int& CCarCtrl::LastTimeLawEnforcerCreated = *(int*)0x9690B8;
29+
30+
CVehicle* (&CCarCtrl::apCarsToKeep)[2] = *(CVehicle*(*)[2])0x969084;
31+
unsigned int (&CCarCtrl::aCarsToKeepTime)[2] = *(unsigned int(*)[2])0x96907C;
32+
833
// Converted from cdecl int CCarCtrl::ChooseBoatModel(void) 0x421970
934
int CCarCtrl::ChooseBoatModel() {
1035
return plugin::CallAndReturn<int, 0x421970>();

plugin_sa/game_sa/CCarCtrl.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,30 @@
1515
class PLUGIN_API CCarCtrl
1616
{
1717
public:
18+
static bool& bCarIsBeingCreated;
19+
static unsigned int& NumLawEnforcerCars;
20+
static unsigned int& NumParkedCars;
21+
static unsigned int& NumAmbulancesOnDuty;
22+
static unsigned int& NumFireTrucksOnDuty;
23+
static unsigned int& MaxNumberOfCarsInUse;
24+
static float& CarDensityMultiplier;
25+
static int& NumRandomCars;
26+
static int& NumMissionCars;
27+
static int& NumPermanentVehicles;
28+
static int& LastTimeAmbulanceCreated;
29+
static int& LastTimeFireTruckCreated;
30+
static bool& bAllowEmergencyServicesToBeCreated;
31+
static bool& bCarsGeneratedAroundCamera;
32+
static char& CountDownToCarsAtStart;
33+
static float& TimeNextMadDriverChaseCreated;
34+
static int& SequenceElements;
35+
static int& SequenceRandomOffset;
36+
static bool& bSequenceOtherWay;
37+
static int& LastTimeLawEnforcerCreated;
38+
39+
static CVehicle* (&apCarsToKeep)[2];
40+
static unsigned int (&aCarsToKeepTime)[2];
41+
1842
static int ChooseBoatModel();
1943
static int ChooseCarModelToLoad(int arg1);
2044
static int ChooseGangCarModel(int arg1);
@@ -123,5 +147,4 @@ class PLUGIN_API CCarCtrl
123147
static void WeaveThroughCarsSectorList(CPtrList& PtrList, CVehicle* pVehicle, CPhysical* pPhysical, float arg4, float arg5, float arg6, float arg7, float* arg8, float* arg9);
124148
static void WeaveThroughObjectsSectorList(CPtrList& PtrList, CVehicle* pVehicle, float arg3, float arg4, float arg5, float arg6, float* arg7, float* arg8);
125149
static void WeaveThroughPedsSectorList(CPtrList& PtrList, CVehicle* pVehicle, CPhysical* pPhysical, float arg4, float arg5, float arg6, float arg7, float* arg8, float* arg9);
126-
127150
};

plugin_sa/game_sa/CColStore.cpp

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,87 @@ int CColStore::ms_nRequiredCollisionArea = *(int*)0x965554;
1313
CColPool*& CColStore::ms_pColPool = *(CColPool**)0x965560;
1414
CQuadTreeNode*& CColStore::ms_pQuadTree = *(CQuadTreeNode**)0x96555C;
1515

16+
void CColStore::Initialise() {
17+
plugin::Call<0x4113F0>();
18+
}
19+
20+
void CColStore::Shutdown() {
21+
plugin::Call<0x4114D0>();
22+
}
23+
24+
int CColStore::AddColSlot(const char* name) {
25+
return plugin::CallAndReturn<int, 0x411140, const char*>(name);
26+
}
27+
28+
void CColStore::AddCollisionNeededAtPosn(const CVector& pos) {
29+
plugin::Call<0x4103A0, const CVector&>(pos);
30+
}
31+
32+
void CColStore::AddRef(int colNum) {
33+
plugin::Call<0x4107A0, int>(colNum);
34+
}
35+
36+
void CColStore::BoundingBoxesPostProcess() {
37+
plugin::Call<0x410EC0>();
38+
}
39+
40+
void CColStore::EnsureCollisionIsInMemory(const CVector& pos) {
41+
plugin::Call<0x410AD0, const CVector&>(pos);
42+
}
43+
44+
CRect* CColStore::GetBoundingBox(int colSlot) {
45+
return plugin::CallAndReturn<CRect*, 0x410800, int>(colSlot);
46+
}
47+
48+
void CColStore::IncludeModelIndex(int colSlot, int modelId) {
49+
plugin::Call<0x410820, int, int>(colSlot, modelId);
50+
}
51+
52+
bool CColStore::HasCollisionLoaded(const CVector& pos, int areaCode) {
53+
return plugin::CallAndReturn<bool, 0x410CE0, const CVector&, int>(pos, areaCode);
54+
}
55+
56+
void CColStore::LoadAllBoundingBoxes() {
57+
plugin::Call<0x4113D0>();
58+
}
59+
60+
void CColStore::LoadAllCollision() {
61+
plugin::Call<0x410E60>();
62+
}
63+
64+
void CColStore::LoadCol(int colSlot, const char* filename) {
65+
plugin::Call<0x410690, int, const char*>(colSlot, filename);
66+
}
67+
68+
bool CColStore::LoadCol(int colSlot, unsigned char* data, int dataSize) {
69+
return plugin::CallAndReturn<bool, 0x4106D0, int, unsigned char*, int>(colSlot, data, dataSize);
70+
}
71+
72+
void CColStore::LoadCollision(const CVector& pos, bool bIgnorePlayerVeh) {
73+
plugin::Call<0x410860, const CVector&, bool>(pos, bIgnorePlayerVeh);
74+
}
75+
76+
void CColStore::RemoveAllCollision() {
77+
plugin::Call<0x410E00>();
78+
}
79+
80+
void CColStore::RemoveCol(int colSlot) {
81+
plugin::Call<0x410730, int>(colSlot);
82+
}
83+
84+
void CColStore::RemoveColSlot(int colSlot) {
85+
plugin::Call<0x411330, int>(colSlot);
86+
}
87+
88+
void CColStore::RemoveRef(int colNum) {
89+
plugin::Call<0x4107D0, int>(colNum);
90+
}
91+
92+
void CColStore::RequestCollision(const CVector& pos, int areaCode) {
93+
plugin::Call<0x410C00, const CVector&, int>(pos, areaCode);
94+
}
95+
96+
void CColStore::SetCollisionRequired(const CVector& pos, int areaCode) {
97+
plugin::Call<0x4104E0, const CVector&, int>(pos, areaCode);
98+
}
99+

plugin_sa/game_sa/CColStore.h

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212

1313
struct ColDef {
1414
CRect m_Area;
15-
unsigned int field_10;
16-
unsigned int field_14;
17-
unsigned int field_18;
18-
unsigned int field_1C;
19-
unsigned short field_20;
15+
char name[18];
2016
short m_nModelIdStart;
2117
short m_nModelIdEnd;
2218
unsigned short m_nRefCount;
@@ -25,7 +21,6 @@ struct ColDef {
2521
bool m_bProcedural;
2622
bool m_bInterior;
2723
};
28-
2924
VALIDATE_SIZE(ColDef, 0x2C);
3025

3126
typedef CPool<ColDef> CColPool;
@@ -41,4 +36,25 @@ class CColStore {
4136
static bool& ms_bCollisionNeeded;
4237
static int ms_nRequiredCollisionArea;
4338

39+
static void Initialise();
40+
static void Shutdown();
41+
static int AddColSlot(const char* name);
42+
static void AddCollisionNeededAtPosn(const CVector& pos);
43+
static void AddRef(int colNum);
44+
static void BoundingBoxesPostProcess();
45+
static void EnsureCollisionIsInMemory(const CVector& pos);
46+
static CRect* GetBoundingBox(int colSlot);
47+
static void IncludeModelIndex(int colSlot, int modelId);
48+
static bool HasCollisionLoaded(const CVector& pos, int areaCode);
49+
static void LoadAllBoundingBoxes();
50+
static void LoadAllCollision();
51+
static void LoadCol(int colSlot, const char* filename);
52+
static bool LoadCol(int colSlot, unsigned char* data, int dataSize);
53+
static void LoadCollision(const CVector& pos, bool bIgnorePlayerVeh);
54+
static void RemoveAllCollision();
55+
static void RemoveCol(int colSlot);
56+
static void RemoveColSlot(int colSlot);
57+
static void RemoveRef(int colNum);
58+
static void RequestCollision(const CVector& pos, int areaCode);
59+
static void SetCollisionRequired(const CVector& pos, int areaCode);
4460
};

plugin_sa/game_sa/CPathFind.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ void CPathFind::DoPathSearch(unsigned char pathType, CVector origin, CNodeAddres
2020
waterPath);
2121
}
2222

23+
void CPathFind::SetPathsNeededAtPosition(const CVector& pos) {
24+
plugin::CallMethod<0x44DCD0, CPathFind*, const CVector&>(this, pos);
25+
}
26+
27+
void CPathFind::UpdateStreaming(bool bForceStreaming) {
28+
plugin::CallMethod<0x450A60, CPathFind*, bool>(this, bForceStreaming);
29+
}
30+
2331
CPathNode *CPathFind::GetPathNode(CNodeAddress address)
2432
{
2533
return ((CPathNode *(__thiscall *)(CPathFind *, CNodeAddress))0x420AC0)(this, address);

plugin_sa/game_sa/CPathFind.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ class PLUGIN_API CPathFind
5555
float maxSearchDistance, CNodeAddress *targetAddr, float maxUnkLimit, bool oneSideOnly,
5656
CNodeAddress forbiddenNodeAddr, bool includeNodesWithoutLinks, bool waterPath);
5757

58+
void SetPathsNeededAtPosition(const CVector& pos);
59+
void UpdateStreaming(bool bForceStreaming);
60+
5861
CPathNode *GetPathNode(CNodeAddress address);
5962
};
60-
6163
VALIDATE_SIZE(CPathFind, 0x3C80);
6264

6365
extern PLUGIN_API CPathFind& ThePaths;

plugin_sa/game_sa/CPlantMgr.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,32 @@ void CPlantMgr::Render() {
2626
plugin::CallDynGlobal(0x5DBAE0);
2727
}
2828

29-
void CPlantMgr::_ProcessEntryCollisionDataSections_RemoveLocTris(CPlantColEntEntry* col, CVector const& camPos, int triProcessSkipMask, int colStartIndex, int colEndIndex) {
30-
plugin::CallDynGlobal(0x5DBF20, col, camPos, triProcessSkipMask, colStartIndex, colEndIndex);
29+
void CPlantMgr::_ProcessEntryCollisionDataSections_RemoveLocTris(CPlantColEntEntry* col, const CVector& camPos, int triProcessSkipMask, int colStartIndex, int colEndIndex) {
30+
plugin::CallDynGlobal(0x5DBF20, col, &camPos, triProcessSkipMask, colStartIndex, colEndIndex);
3131
}
3232

33-
void CPlantMgr::_ColEntityCache_Update(CVector const& camPos, uint8_t quickUpdate) {
34-
plugin::CallDynGlobal(0x5DC510, camPos, quickUpdate);
33+
void CPlantMgr::_ColEntityCache_Update(const CVector& camPos, uint8_t quickUpdate) {
34+
plugin::CallDynGlobal(0x5DC510, &camPos, quickUpdate);
3535
}
3636

37-
void CPlantMgr::_ProcessEntryCollisionDataSections_AddLocTris(CPlantColEntEntry* col, CVector const& camPos, int processSkipMask, int colStartIndex, int colEndIndex) {
38-
plugin::CallDynGlobal(0x5DC8B0, col, camPos, processSkipMask, colStartIndex, colEndIndex);
37+
void CPlantMgr::_ProcessEntryCollisionDataSections_AddLocTris(CPlantColEntEntry* col, const CVector& camPos, int processSkipMask, int colStartIndex, int colEndIndex) {
38+
plugin::CallDynGlobal(0x5DC8B0, col, &camPos, processSkipMask, colStartIndex, colEndIndex);
3939
}
4040

41-
void CPlantMgr::_ProcessEntryCollisionDataSections(CPlantColEntEntry* col, CVector const& camPos, int processSkipMask) {
42-
plugin::CallDynGlobal(0x5DCD80, col, camPos, processSkipMask);
41+
void CPlantMgr::_ProcessEntryCollisionDataSections(CPlantColEntEntry* col, const CVector& camPos, int processSkipMask) {
42+
plugin::CallDynGlobal(0x5DCD80, col, &camPos, processSkipMask);
4343
}
4444

45-
void CPlantMgr::_UpdateLocTris(CVector const& camPos, int processSkipMask) {
46-
plugin::CallDynGlobal(0x5DCF00, camPos, processSkipMask);
45+
void CPlantMgr::_UpdateLocTris(const CVector& camPos, int processSkipMask) {
46+
plugin::CallDynGlobal(0x5DCF00, &camPos, processSkipMask);
4747
}
4848

49-
bool CPlantMgr::PreUpdateOnceForNewCameraPos(CVector const& camPos) {
50-
return plugin::CallAndReturnDynGlobal<bool>(0x5DCF30, camPos);
49+
void CPlantMgr::PreUpdateOnceForNewCameraPos(const CVector& camPos) {
50+
plugin::CallDynGlobal(0x5DCF30, &camPos);
5151
}
5252

53-
void CPlantMgr::Update(CVector const& camPos) {
54-
plugin::CallDynGlobal(0x5DCFA0, camPos);
53+
void CPlantMgr::Update(const CVector& camPos) {
54+
plugin::CallDynGlobal(0x5DCFA0, &camPos);
5555
}
5656

5757
bool CPlantMgr::ReloadConfig() {

plugin_sa/game_sa/CPlantMgr.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ class CPlantMgr {
6363
static void SetPlantFriendlyFlagInAtomicMI(CAtomicModelInfo*);
6464
static void Shutdown();
6565
static void Render();
66-
static void _ProcessEntryCollisionDataSections_RemoveLocTris(CPlantColEntEntry*, CVector const&, int, int, int);
67-
static void _ColEntityCache_Update(CVector const&, uint8_t);
68-
static void _ProcessEntryCollisionDataSections_AddLocTris(CPlantColEntEntry*, CVector const&, int, int, int);
69-
static void _ProcessEntryCollisionDataSections(CPlantColEntEntry*, CVector const&, int);
70-
static void _UpdateLocTris(CVector const&, int);
71-
static bool PreUpdateOnceForNewCameraPos(CVector const&);
72-
static void Update(CVector const&);
66+
static void _ProcessEntryCollisionDataSections_RemoveLocTris(CPlantColEntEntry*, const CVector&, int, int, int);
67+
static void _ColEntityCache_Update(const CVector&, uint8_t);
68+
static void _ProcessEntryCollisionDataSections_AddLocTris(CPlantColEntEntry*, const CVector&, int, int, int);
69+
static void _ProcessEntryCollisionDataSections(CPlantColEntEntry*, const CVector&, int);
70+
static void _UpdateLocTris(const CVector&, int);
71+
static void PreUpdateOnceForNewCameraPos(const CVector&);
72+
static void Update(const CVector&);
7373
static bool ReloadConfig();
7474
static bool Initialise();
7575
};

0 commit comments

Comments
 (0)