Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions plugin_sa/game_sa/CCarCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@
Do not delete this comment block. Respect others' work!
*/
#include "CCarCtrl.h"

bool& CCarCtrl::bCarIsBeingCreated = *(bool*)0x9690CC;
unsigned int& CCarCtrl::NumLawEnforcerCars = *(unsigned int*)0x969098;
unsigned int& CCarCtrl::NumParkedCars = *(unsigned int*)0x9690A0;
unsigned int& CCarCtrl::NumAmbulancesOnDuty = *(unsigned int*)0x9690A8;
unsigned int& CCarCtrl::NumFireTrucksOnDuty = *(unsigned int*)0x9690AC;
unsigned int& CCarCtrl::MaxNumberOfCarsInUse = *(unsigned int*)0x8A5B24;
float& CCarCtrl::CarDensityMultiplier = *(float*)0x8A5B20;
int& CCarCtrl::NumRandomCars = *(int*)0x969094;
int& CCarCtrl::NumMissionCars = *(int*)0x96909C;
int& CCarCtrl::NumPermanentVehicles = *(int*)0x9690A4;
int& CCarCtrl::LastTimeAmbulanceCreated = *(int*)0x9690B0;
int& CCarCtrl::LastTimeFireTruckCreated = *(int*)0x9690B4;
bool& CCarCtrl::bAllowEmergencyServicesToBeCreated = *(bool*)0x8A5B28;
bool& CCarCtrl::bCarsGeneratedAroundCamera = *(bool*)0x9690C1;
char& CCarCtrl::CountDownToCarsAtStart = *(char*)0x9690C0;
float& CCarCtrl::TimeNextMadDriverChaseCreated = *(float*)0x9690BC;
int& CCarCtrl::SequenceElements = *(int*)0x969078;
int& CCarCtrl::SequenceRandomOffset = *(int*)0x969074;
bool& CCarCtrl::bSequenceOtherWay = *(bool*)0x969070;
int& CCarCtrl::LastTimeLawEnforcerCreated = *(int*)0x9690B8;

CVehicle* (&CCarCtrl::apCarsToKeep)[2] = *(CVehicle*(*)[2])0x969084;
unsigned int (&CCarCtrl::aCarsToKeepTime)[2] = *(unsigned int(*)[2])0x96907C;

// Converted from cdecl int CCarCtrl::ChooseBoatModel(void) 0x421970
int CCarCtrl::ChooseBoatModel() {
return plugin::CallAndReturn<int, 0x421970>();
Expand Down
25 changes: 24 additions & 1 deletion plugin_sa/game_sa/CCarCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@
class PLUGIN_API CCarCtrl
{
public:
static bool& bCarIsBeingCreated;
static unsigned int& NumLawEnforcerCars;
static unsigned int& NumParkedCars;
static unsigned int& NumAmbulancesOnDuty;
static unsigned int& NumFireTrucksOnDuty;
static unsigned int& MaxNumberOfCarsInUse;
static float& CarDensityMultiplier;
static int& NumRandomCars;
static int& NumMissionCars;
static int& NumPermanentVehicles;
static int& LastTimeAmbulanceCreated;
static int& LastTimeFireTruckCreated;
static bool& bAllowEmergencyServicesToBeCreated;
static bool& bCarsGeneratedAroundCamera;
static char& CountDownToCarsAtStart;
static float& TimeNextMadDriverChaseCreated;
static int& SequenceElements;
static int& SequenceRandomOffset;
static bool& bSequenceOtherWay;
static int& LastTimeLawEnforcerCreated;

static CVehicle* (&apCarsToKeep)[2];
static unsigned int (&aCarsToKeepTime)[2];

static int ChooseBoatModel();
static int ChooseCarModelToLoad(int arg1);
static int ChooseGangCarModel(int arg1);
Expand Down Expand Up @@ -123,5 +147,4 @@ class PLUGIN_API CCarCtrl
static void WeaveThroughCarsSectorList(CPtrList& PtrList, CVehicle* pVehicle, CPhysical* pPhysical, float arg4, float arg5, float arg6, float arg7, float* arg8, float* arg9);
static void WeaveThroughObjectsSectorList(CPtrList& PtrList, CVehicle* pVehicle, float arg3, float arg4, float arg5, float arg6, float* arg7, float* arg8);
static void WeaveThroughPedsSectorList(CPtrList& PtrList, CVehicle* pVehicle, CPhysical* pPhysical, float arg4, float arg5, float arg6, float arg7, float* arg8, float* arg9);

};
84 changes: 84 additions & 0 deletions plugin_sa/game_sa/CColStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,87 @@ int CColStore::ms_nRequiredCollisionArea = *(int*)0x965554;
CColPool*& CColStore::ms_pColPool = *(CColPool**)0x965560;
CQuadTreeNode*& CColStore::ms_pQuadTree = *(CQuadTreeNode**)0x96555C;

void CColStore::Initialise() {
plugin::Call<0x4113F0>();
}

void CColStore::Shutdown() {
plugin::Call<0x4114D0>();
}

int CColStore::AddColSlot(const char* name) {
return plugin::CallAndReturn<int, 0x411140, const char*>(name);
}

void CColStore::AddCollisionNeededAtPosn(const CVector& pos) {
plugin::Call<0x4103A0, const CVector&>(pos);
}

void CColStore::AddRef(int colNum) {
plugin::Call<0x4107A0, int>(colNum);
}

void CColStore::BoundingBoxesPostProcess() {
plugin::Call<0x410EC0>();
}

void CColStore::EnsureCollisionIsInMemory(const CVector& pos) {
plugin::Call<0x410AD0, const CVector&>(pos);
}

CRect* CColStore::GetBoundingBox(int colSlot) {
return plugin::CallAndReturn<CRect*, 0x410800, int>(colSlot);
}

void CColStore::IncludeModelIndex(int colSlot, int modelId) {
plugin::Call<0x410820, int, int>(colSlot, modelId);
}

bool CColStore::HasCollisionLoaded(const CVector& pos, int areaCode) {
return plugin::CallAndReturn<bool, 0x410CE0, const CVector&, int>(pos, areaCode);
}

void CColStore::LoadAllBoundingBoxes() {
plugin::Call<0x4113D0>();
}

void CColStore::LoadAllCollision() {
plugin::Call<0x410E60>();
}

void CColStore::LoadCol(int colSlot, const char* filename) {
plugin::Call<0x410690, int, const char*>(colSlot, filename);
}

bool CColStore::LoadCol(int colSlot, unsigned char* data, int dataSize) {
return plugin::CallAndReturn<bool, 0x4106D0, int, unsigned char*, int>(colSlot, data, dataSize);
}

void CColStore::LoadCollision(const CVector& pos, bool bIgnorePlayerVeh) {
plugin::Call<0x410860, const CVector&, bool>(pos, bIgnorePlayerVeh);
}

void CColStore::RemoveAllCollision() {
plugin::Call<0x410E00>();
}

void CColStore::RemoveCol(int colSlot) {
plugin::Call<0x410730, int>(colSlot);
}

void CColStore::RemoveColSlot(int colSlot) {
plugin::Call<0x411330, int>(colSlot);
}

void CColStore::RemoveRef(int colNum) {
plugin::Call<0x4107D0, int>(colNum);
}

void CColStore::RequestCollision(const CVector& pos, int areaCode) {
plugin::Call<0x410C00, const CVector&, int>(pos, areaCode);
}

void CColStore::SetCollisionRequired(const CVector& pos, int areaCode) {
plugin::Call<0x4104E0, const CVector&, int>(pos, areaCode);
}

28 changes: 22 additions & 6 deletions plugin_sa/game_sa/CColStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@

struct ColDef {
CRect m_Area;
unsigned int field_10;
unsigned int field_14;
unsigned int field_18;
unsigned int field_1C;
unsigned short field_20;
char name[18];
short m_nModelIdStart;
short m_nModelIdEnd;
unsigned short m_nRefCount;
Expand All @@ -25,7 +21,6 @@ struct ColDef {
bool m_bProcedural;
bool m_bInterior;
};

VALIDATE_SIZE(ColDef, 0x2C);

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

static void Initialise();
static void Shutdown();
static int AddColSlot(const char* name);
static void AddCollisionNeededAtPosn(const CVector& pos);
static void AddRef(int colNum);
static void BoundingBoxesPostProcess();
static void EnsureCollisionIsInMemory(const CVector& pos);
static CRect* GetBoundingBox(int colSlot);
static void IncludeModelIndex(int colSlot, int modelId);
static bool HasCollisionLoaded(const CVector& pos, int areaCode);
static void LoadAllBoundingBoxes();
static void LoadAllCollision();
static void LoadCol(int colSlot, const char* filename);
static bool LoadCol(int colSlot, unsigned char* data, int dataSize);
static void LoadCollision(const CVector& pos, bool bIgnorePlayerVeh);
static void RemoveAllCollision();
static void RemoveCol(int colSlot);
static void RemoveColSlot(int colSlot);
static void RemoveRef(int colNum);
static void RequestCollision(const CVector& pos, int areaCode);
static void SetCollisionRequired(const CVector& pos, int areaCode);
};
8 changes: 8 additions & 0 deletions plugin_sa/game_sa/CPathFind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ void CPathFind::DoPathSearch(unsigned char pathType, CVector origin, CNodeAddres
waterPath);
}

void CPathFind::SetPathsNeededAtPosition(const CVector& pos) {
plugin::CallMethod<0x44DCD0, CPathFind*, const CVector&>(this, pos);
}

void CPathFind::UpdateStreaming(bool bForceStreaming) {
plugin::CallMethod<0x450A60, CPathFind*, bool>(this, bForceStreaming);
}

CPathNode *CPathFind::GetPathNode(CNodeAddress address)
{
return ((CPathNode *(__thiscall *)(CPathFind *, CNodeAddress))0x420AC0)(this, address);
Expand Down
4 changes: 3 additions & 1 deletion plugin_sa/game_sa/CPathFind.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ class PLUGIN_API CPathFind
float maxSearchDistance, CNodeAddress *targetAddr, float maxUnkLimit, bool oneSideOnly,
CNodeAddress forbiddenNodeAddr, bool includeNodesWithoutLinks, bool waterPath);

void SetPathsNeededAtPosition(const CVector& pos);
void UpdateStreaming(bool bForceStreaming);

CPathNode *GetPathNode(CNodeAddress address);
};

VALIDATE_SIZE(CPathFind, 0x3C80);

extern PLUGIN_API CPathFind& ThePaths;
28 changes: 14 additions & 14 deletions plugin_sa/game_sa/CPlantMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,32 @@ void CPlantMgr::Render() {
plugin::CallDynGlobal(0x5DBAE0);
}

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

void CPlantMgr::_ColEntityCache_Update(CVector const& camPos, uint8_t quickUpdate) {
plugin::CallDynGlobal(0x5DC510, camPos, quickUpdate);
void CPlantMgr::_ColEntityCache_Update(const CVector& camPos, uint8_t quickUpdate) {
plugin::CallDynGlobal(0x5DC510, &camPos, quickUpdate);
}

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

void CPlantMgr::_ProcessEntryCollisionDataSections(CPlantColEntEntry* col, CVector const& camPos, int processSkipMask) {
plugin::CallDynGlobal(0x5DCD80, col, camPos, processSkipMask);
void CPlantMgr::_ProcessEntryCollisionDataSections(CPlantColEntEntry* col, const CVector& camPos, int processSkipMask) {
plugin::CallDynGlobal(0x5DCD80, col, &camPos, processSkipMask);
}

void CPlantMgr::_UpdateLocTris(CVector const& camPos, int processSkipMask) {
plugin::CallDynGlobal(0x5DCF00, camPos, processSkipMask);
void CPlantMgr::_UpdateLocTris(const CVector& camPos, int processSkipMask) {
plugin::CallDynGlobal(0x5DCF00, &camPos, processSkipMask);
}

bool CPlantMgr::PreUpdateOnceForNewCameraPos(CVector const& camPos) {
return plugin::CallAndReturnDynGlobal<bool>(0x5DCF30, camPos);
void CPlantMgr::PreUpdateOnceForNewCameraPos(const CVector& camPos) {
plugin::CallDynGlobal(0x5DCF30, &camPos);
}

void CPlantMgr::Update(CVector const& camPos) {
plugin::CallDynGlobal(0x5DCFA0, camPos);
void CPlantMgr::Update(const CVector& camPos) {
plugin::CallDynGlobal(0x5DCFA0, &camPos);
}

bool CPlantMgr::ReloadConfig() {
Expand Down
14 changes: 7 additions & 7 deletions plugin_sa/game_sa/CPlantMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ class CPlantMgr {
static void SetPlantFriendlyFlagInAtomicMI(CAtomicModelInfo*);
static void Shutdown();
static void Render();
static void _ProcessEntryCollisionDataSections_RemoveLocTris(CPlantColEntEntry*, CVector const&, int, int, int);
static void _ColEntityCache_Update(CVector const&, uint8_t);
static void _ProcessEntryCollisionDataSections_AddLocTris(CPlantColEntEntry*, CVector const&, int, int, int);
static void _ProcessEntryCollisionDataSections(CPlantColEntEntry*, CVector const&, int);
static void _UpdateLocTris(CVector const&, int);
static bool PreUpdateOnceForNewCameraPos(CVector const&);
static void Update(CVector const&);
static void _ProcessEntryCollisionDataSections_RemoveLocTris(CPlantColEntEntry*, const CVector&, int, int, int);
static void _ColEntityCache_Update(const CVector&, uint8_t);
static void _ProcessEntryCollisionDataSections_AddLocTris(CPlantColEntEntry*, const CVector&, int, int, int);
static void _ProcessEntryCollisionDataSections(CPlantColEntEntry*, const CVector&, int);
static void _UpdateLocTris(const CVector&, int);
static void PreUpdateOnceForNewCameraPos(const CVector&);
static void Update(const CVector&);
static bool ReloadConfig();
static bool Initialise();
};