summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/peds/Gangs.cpp (renamed from src/control/Gangs.cpp)2
-rw-r--r--src/peds/Gangs.h (renamed from src/control/Gangs.h)0
-rw-r--r--src/save/GenericGameStorage.cpp2
-rw-r--r--src/vehicles/CarGen.cpp (renamed from src/control/CarGen.cpp)86
-rw-r--r--src/vehicles/CarGen.h (renamed from src/control/CarGen.h)12
-rw-r--r--src/vehicles/Cranes.cpp (renamed from src/control/Cranes.cpp)94
-rw-r--r--src/vehicles/Cranes.h (renamed from src/control/Cranes.h)9
7 files changed, 69 insertions, 136 deletions
diff --git a/src/control/Gangs.cpp b/src/peds/Gangs.cpp
index 57d9c67e..c67fe599 100644
--- a/src/control/Gangs.cpp
+++ b/src/peds/Gangs.cpp
@@ -4,7 +4,6 @@
#include "Gangs.h"
#include "Weapon.h"
-//CGangInfo(&CGangs::Gang)[NUM_GANGS] = *(CGangInfo(*)[NUM_GANGS])*(uintptr*)0x6EDF78;
CGangInfo CGangs::Gang[NUM_GANGS];
CGangInfo::CGangInfo() :
@@ -70,7 +69,6 @@ void CGangs::LoadAllGangData(uint8 *buf, uint32 size)
Initialise();
INITSAVEBUF
- // original: SkipSaveBuf(buf, SAVE_HEADER_SIZE);
CheckSaveHeader(buf, 'G','N','G','\0', size - SAVE_HEADER_SIZE);
for (int i = 0; i < NUM_GANGS; i++)
diff --git a/src/control/Gangs.h b/src/peds/Gangs.h
index dd7a7f93..dd7a7f93 100644
--- a/src/control/Gangs.h
+++ b/src/peds/Gangs.h
diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp
index 4cfa75b3..0ec0b117 100644
--- a/src/save/GenericGameStorage.cpp
+++ b/src/save/GenericGameStorage.cpp
@@ -283,7 +283,7 @@ GenericLoad()
LoadSaveDataBlock();
ReadDataFromBlock("Loading Paths \n", ThePaths.Load);
LoadSaveDataBlock();
- ReadDataFromBlock("Loading Cranes \n", CranesLoad);
+ ReadDataFromBlock("Loading Cranes \n", CCranes::Load);
LoadSaveDataBlock();
ReadDataFromBlock("Loading Pickups \n", CPickups::Load);
LoadSaveDataBlock();
diff --git a/src/control/CarGen.cpp b/src/vehicles/CarGen.cpp
index 721ac35a..43f77fb7 100644
--- a/src/control/CarGen.cpp
+++ b/src/vehicles/CarGen.cpp
@@ -14,11 +14,11 @@
#include "Vehicle.h"
#include "World.h"
-uint8 &CTheCarGenerators::ProcessCounter = *(uint8*)0x95CDAF;
-uint32 &CTheCarGenerators::NumOfCarGenerators = *(uint32*)0x8E2C1C;
-CCarGenerator (&CTheCarGenerators::CarGeneratorArray)[NUM_CARGENS] = *(CCarGenerator(*)[NUM_CARGENS])*(uintptr*)0x87CB18;
-uint8 &CTheCarGenerators::GenerateEvenIfPlayerIsCloseCounter = *(uint8*)0x95CDC6;
-uint32 &CTheCarGenerators::CurrentActiveCount = *(uint32*)0x8F2C5C;
+uint8 CTheCarGenerators::ProcessCounter;
+uint32 CTheCarGenerators::NumOfCarGenerators;
+CCarGenerator CTheCarGenerators::CarGeneratorArray[NUM_CARGENS];
+uint8 CTheCarGenerators::GenerateEvenIfPlayerIsCloseCounter;
+uint32 CTheCarGenerators::CurrentActiveCount;
void CCarGenerator::SwitchOff()
{
@@ -187,59 +187,6 @@ bool CCarGenerator::CheckIfWithinRangeOfAnyPlayer()
return DotProduct2D(direction, FindPlayerSpeed()) <= 0;
}
-void CCarGenerator::Save(uint8 *&buffer)
-{
- WriteSaveBuf(buffer, m_nModelIndex);
- WriteSaveBuf(buffer, m_vecPos);
- WriteSaveBuf(buffer, m_fAngle);
- WriteSaveBuf(buffer, m_nColor1);
- WriteSaveBuf(buffer, m_nColor2);
- WriteSaveBuf(buffer, m_bForceSpawn);
- WriteSaveBuf(buffer, m_nAlarm);
- WriteSaveBuf(buffer, m_nDoorlock);
- WriteSaveBuf(buffer, (uint8)0);
- WriteSaveBuf(buffer, m_nMinDelay);
- WriteSaveBuf(buffer, m_nMaxDelay);
- WriteSaveBuf(buffer, m_nTimer);
- WriteSaveBuf(buffer, m_nVehicleHandle);
- WriteSaveBuf(buffer, m_nUsesRemaining);
- WriteSaveBuf(buffer, m_bIsBlocking);
- WriteSaveBuf(buffer, (uint8)0);
- WriteSaveBuf(buffer, m_vecInf);
- WriteSaveBuf(buffer, m_vecSup);
- WriteSaveBuf(buffer, m_fSize);
-
- // or
- //WriteSaveBuf(buffer, *this);
-
-}
-
-void CCarGenerator::Load(uint8 *&buffer)
-{
- m_nModelIndex = ReadSaveBuf<uint32>(buffer);
- m_vecPos = ReadSaveBuf<CVector>(buffer);
- m_fAngle = ReadSaveBuf<float>(buffer);
- m_nColor1 = ReadSaveBuf<int16>(buffer);
- m_nColor2 = ReadSaveBuf<int16>(buffer);
- m_bForceSpawn = ReadSaveBuf<uint8>(buffer);
- m_nAlarm = ReadSaveBuf<uint8>(buffer);
- m_nDoorlock = ReadSaveBuf<uint8>(buffer);
- ReadSaveBuf<uint8>(buffer);
- m_nMinDelay = ReadSaveBuf<uint16>(buffer);
- m_nMaxDelay = ReadSaveBuf<uint16>(buffer);
- m_nTimer = ReadSaveBuf<uint32>(buffer);
- m_nVehicleHandle = ReadSaveBuf<int32>(buffer);
- m_nUsesRemaining = ReadSaveBuf<uint16>(buffer);
- m_bIsBlocking = ReadSaveBuf<bool>(buffer);
- ReadSaveBuf<uint8>(buffer);
- m_vecInf = ReadSaveBuf<CVector>(buffer);
- m_vecSup = ReadSaveBuf<CVector>(buffer);
- m_fSize = ReadSaveBuf<float>(buffer);
-
- // or
- //*this = ReadSaveBuf<CCarGenerator>(buffer);
-}
-
void CTheCarGenerators::Process()
{
if (FindPlayerTrain() || CCutsceneMgr::IsCutsceneProcessing())
@@ -268,39 +215,38 @@ void CTheCarGenerators::Init()
void CTheCarGenerators::SaveAllCarGenerators(uint8 *buffer, uint32 *size)
{
- *size = 20 + sizeof(CarGeneratorArray) + SAVE_HEADER_SIZE;
+ const uint32 nGeneralDataSize = sizeof(NumOfCarGenerators) + sizeof(CurrentActiveCount) + sizeof(ProcessCounter) + sizeof(GenerateEvenIfPlayerIsCloseCounter) + sizeof(int16);
+ *size = sizeof(int) + nGeneralDataSize + sizeof(CarGeneratorArray) + SAVE_HEADER_SIZE;
INITSAVEBUF
WriteSaveHeader(buffer, 'C','G','N','\0', *size - SAVE_HEADER_SIZE);
- WriteSaveBuf(buffer, 12); /* what is this? */
+ WriteSaveBuf(buffer, nGeneralDataSize);
WriteSaveBuf(buffer, NumOfCarGenerators);
WriteSaveBuf(buffer, CurrentActiveCount);
WriteSaveBuf(buffer, ProcessCounter);
WriteSaveBuf(buffer, GenerateEvenIfPlayerIsCloseCounter);
- WriteSaveBuf(buffer, (int16)0);
+ WriteSaveBuf(buffer, (int16)0); // alignment
WriteSaveBuf(buffer, sizeof(CarGeneratorArray));
- for (int i = 0; i < NUM_CARGENS; i++){
- CarGeneratorArray[i].Save(buffer);
- }
+ for (int i = 0; i < NUM_CARGENS; i++)
+ WriteSaveBuf(buffer, CarGeneratorArray[i]);
VALIDATESAVEBUF(*size)
}
void CTheCarGenerators::LoadAllCarGenerators(uint8* buffer, uint32 size)
{
+ const int32 nGeneralDataSize = sizeof(NumOfCarGenerators) + sizeof(CurrentActiveCount) + sizeof(ProcessCounter) + sizeof(GenerateEvenIfPlayerIsCloseCounter) + sizeof(int16);
Init();
INITSAVEBUF
- assert(size == 20 + sizeof(CarGeneratorArray) + SAVE_HEADER_SIZE);
CheckSaveHeader(buffer, 'C','G','N','\0', size - SAVE_HEADER_SIZE);
- ReadSaveBuf<uint32>(buffer);
+ assert(ReadSaveBuf<uint32>(buffer) == nGeneralDataSize);
NumOfCarGenerators = ReadSaveBuf<uint32>(buffer);
CurrentActiveCount = ReadSaveBuf<uint32>(buffer);
ProcessCounter = ReadSaveBuf<uint8>(buffer);
GenerateEvenIfPlayerIsCloseCounter = ReadSaveBuf<uint8>(buffer);
- ReadSaveBuf<int16>(buffer);
+ ReadSaveBuf<int16>(buffer); // alignment
assert(ReadSaveBuf<uint32>(buffer) == sizeof(CarGeneratorArray));
- for (int i = 0; i < NUM_CARGENS; i++) {
- CarGeneratorArray[i].Load(buffer);
- }
+ for (int i = 0; i < NUM_CARGENS; i++)
+ CarGeneratorArray[i] = ReadSaveBuf<CCarGenerator>(buffer);
VALIDATESAVEBUF(size)
}
diff --git a/src/control/CarGen.h b/src/vehicles/CarGen.h
index 75acdd56..9d645318 100644
--- a/src/control/CarGen.h
+++ b/src/vehicles/CarGen.h
@@ -34,19 +34,17 @@ public:
void Setup(float x, float y, float z, float angle, int32 mi, int16 color1, int16 color2, uint8 force, uint8 alarm, uint8 lock, uint16 min_delay, uint16 max_delay);
bool CheckForBlockage();
bool CheckIfWithinRangeOfAnyPlayer();
- void Save(uint8*&);
- void Load(uint8*&);
void SetUsesRemaining(uint16 uses) { m_nUsesRemaining = uses; }
};
class CTheCarGenerators
{
public:
- static uint8 &ProcessCounter;
- static uint32 &NumOfCarGenerators;
- static CCarGenerator (&CarGeneratorArray)[NUM_CARGENS];
- static uint8 &GenerateEvenIfPlayerIsCloseCounter;
- static uint32 &CurrentActiveCount;
+ static uint8 ProcessCounter;
+ static uint32 NumOfCarGenerators;
+ static CCarGenerator CarGeneratorArray[NUM_CARGENS];
+ static uint8 GenerateEvenIfPlayerIsCloseCounter;
+ static uint32 CurrentActiveCount;
static void Process();
static int32 CreateCarGenerator(float x, float y, float z, float angle, int32 mi, int16 color1, int16 color2, uint8 force, uint8 alarm, uint8 lock, uint16 min_delay, uint16 max_delay);
diff --git a/src/control/Cranes.cpp b/src/vehicles/Cranes.cpp
index 33385dae..dbc3c340 100644
--- a/src/control/Cranes.cpp
+++ b/src/vehicles/Cranes.cpp
@@ -38,9 +38,9 @@
uint32 TimerForCamInterpolation;
-uint32& CCranes::CarsCollectedMilitaryCrane = *(uint32*)0x8F6248;
-int32& CCranes::NumCranes = *(int32*)0x8E28AC;
-CCrane(&CCranes::aCranes)[NUM_CRANES] = *(CCrane(*)[NUM_CRANES])*(uintptr*)0x6FA4E0;
+uint32 CCranes::CarsCollectedMilitaryCrane;
+int32 CCranes::NumCranes;
+CCrane CCranes::aCranes[NUM_CRANES];
void CCranes::InitCranes(void)
{
@@ -466,13 +466,13 @@ bool CCrane::DoesCranePickUpThisCarType(uint32 mi)
bool CCranes::DoesMilitaryCraneHaveThisOneAlready(uint32 mi)
{
switch (mi) {
- case MI_FIRETRUCK: return (CCranes::CarsCollectedMilitaryCrane & 1);
- case MI_AMBULAN: return (CCranes::CarsCollectedMilitaryCrane & 2);
- case MI_ENFORCER: return (CCranes::CarsCollectedMilitaryCrane & 4);
- case MI_FBICAR: return (CCranes::CarsCollectedMilitaryCrane & 8);
- case MI_RHINO: return (CCranes::CarsCollectedMilitaryCrane & 0x10);
- case MI_BARRACKS: return (CCranes::CarsCollectedMilitaryCrane & 0x20);
- case MI_POLICE: return (CCranes::CarsCollectedMilitaryCrane & 0x40);
+ case MI_FIRETRUCK: return (CarsCollectedMilitaryCrane & 1);
+ case MI_AMBULAN: return (CarsCollectedMilitaryCrane & 2);
+ case MI_ENFORCER: return (CarsCollectedMilitaryCrane & 4);
+ case MI_FBICAR: return (CarsCollectedMilitaryCrane & 8);
+ case MI_RHINO: return (CarsCollectedMilitaryCrane & 0x10);
+ case MI_BARRACKS: return (CarsCollectedMilitaryCrane & 0x20);
+ case MI_POLICE: return (CarsCollectedMilitaryCrane & 0x40);
default: break;
}
return false;
@@ -481,20 +481,20 @@ bool CCranes::DoesMilitaryCraneHaveThisOneAlready(uint32 mi)
void CCranes::RegisterCarForMilitaryCrane(uint32 mi)
{
switch (mi) {
- case MI_FIRETRUCK: CCranes::CarsCollectedMilitaryCrane |= 1; break;
- case MI_AMBULAN: CCranes::CarsCollectedMilitaryCrane |= 2; break;
- case MI_ENFORCER: CCranes::CarsCollectedMilitaryCrane |= 4; break;
- case MI_FBICAR: CCranes::CarsCollectedMilitaryCrane |= 8; break;
- case MI_RHINO: CCranes::CarsCollectedMilitaryCrane |= 0x10; break;
- case MI_BARRACKS: CCranes::CarsCollectedMilitaryCrane |= 0x20; break;
- case MI_POLICE: CCranes::CarsCollectedMilitaryCrane |= 0x40; break;
+ case MI_FIRETRUCK: CarsCollectedMilitaryCrane |= 1; break;
+ case MI_AMBULAN: CarsCollectedMilitaryCrane |= 2; break;
+ case MI_ENFORCER: CarsCollectedMilitaryCrane |= 4; break;
+ case MI_FBICAR: CarsCollectedMilitaryCrane |= 8; break;
+ case MI_RHINO: CarsCollectedMilitaryCrane |= 0x10; break;
+ case MI_BARRACKS: CarsCollectedMilitaryCrane |= 0x20; break;
+ case MI_POLICE: CarsCollectedMilitaryCrane |= 0x40; break;
default: break;
}
}
bool CCranes::HaveAllCarsBeenCollectedByMilitaryCrane()
{
- return (CCranes::CarsCollectedMilitaryCrane & 0x7F) == 0x7F;
+ return (CarsCollectedMilitaryCrane & 0x7F) == 0x7F;
}
bool CCrane::GoTowardsTarget(float fAngleToTarget, float fDistanceToTarget, float fTargetHeight, float fSpeedMultiplier)
@@ -509,8 +509,7 @@ bool CCrane::GoTowardsTarget(float fAngleToTarget, float fDistanceToTarget, floa
if (Abs(fHookAngleDelta) < fHookAngleChangeThisFrame) {
m_fHookAngle = fAngleToTarget;
bAngleMovementFinished = true;
- }
- else {
+ } else {
if (fHookAngleDelta < 0.0f) {
m_fHookAngle -= fHookAngleChangeThisFrame;
if (m_fHookAngle < 0.0f)
@@ -528,8 +527,7 @@ bool CCrane::GoTowardsTarget(float fAngleToTarget, float fDistanceToTarget, floa
if (Abs(fHookOffsetDelta) < fHookOffsetChangeThisFrame) {
m_fHookOffset = fDistanceToTarget;
bOffsetMovementFinished = true;
- }
- else {
+ } else {
if (fHookOffsetDelta < 0.0f)
m_fHookOffset -= fHookOffsetChangeThisFrame;
else
@@ -541,8 +539,7 @@ bool CCrane::GoTowardsTarget(float fAngleToTarget, float fDistanceToTarget, floa
if (Abs(fHookHeightDelta) < fHookHeightChangeThisFrame) {
m_fHookHeight = fTargetHeight;
bHeightMovementFinished = true;
- }
- else {
+ } else {
if (fHookHeightDelta < 0.0f)
m_fHookHeight -= fHookHeightChangeThisFrame;
else
@@ -560,8 +557,7 @@ bool CCrane::GoTowardsHeightTarget(float fTargetHeight, float fSpeedMultiplier)
if (Abs(fHookHeightDelta) < fHookHeightChangeThisFrame) {
m_fHookHeight = fTargetHeight;
bHeightMovementFinished = true;
- }
- else {
+ } else {
if (fHookHeightDelta < 0.0f)
m_fHookHeight -= fHookHeightChangeThisFrame;
else
@@ -587,7 +583,7 @@ void CCrane::CalcHookCoordinates(float* pX, float* pY, float* pZ)
void CCrane::SetHookMatrix()
{
- if (!m_pHook)
+ if (m_pHook == nil)
return;
m_pHook->GetPosition() = m_vecHookCurPos;
CVector up(m_vecHookInitPos.x - m_vecHookCurPos.x, m_vecHookInitPos.y - m_vecHookCurPos.y, 20.0f);
@@ -632,48 +628,44 @@ void CCranes::Save(uint8* buf, uint32* size)
{
INITSAVEBUF
- *size = 2 * sizeof(uint32) + NUM_CRANES * sizeof(CCrane);
+ *size = 2 * sizeof(uint32) + sizeof(aCranes);
WriteSaveBuf(buf, NumCranes);
WriteSaveBuf(buf, CarsCollectedMilitaryCrane);
for (int i = 0; i < NUM_CRANES; i++) {
- CCrane* pCrane = WriteSaveBuf(buf, aCranes[i]);
- if (pCrane->m_pCraneEntity)
- pCrane->m_pCraneEntity = (CBuilding*)(CPools::GetBuildingPool()->GetJustIndex((CBuilding*)pCrane->m_pCraneEntity) + 1);
- if (pCrane->m_pHook)
- pCrane->m_pHook = (CObject*)(CPools::GetObjectPool()->GetJustIndex((CObject*)pCrane->m_pHook) + 1);
- if (pCrane->m_pVehiclePickedUp)
- pCrane->m_pVehiclePickedUp = (CVehicle*)(CPools::GetVehiclePool()->GetJustIndex((CVehicle*)pCrane->m_pVehiclePickedUp) + 1);
+ CCrane *pCrane = WriteSaveBuf(buf, aCranes[i]);
+ if (pCrane->m_pCraneEntity != nil)
+ pCrane->m_pCraneEntity = (CBuilding*)(CPools::GetBuildingPool()->GetJustIndex(pCrane->m_pCraneEntity) + 1);
+ if (pCrane->m_pHook != nil)
+ pCrane->m_pHook = (CObject*)(CPools::GetObjectPool()->GetJustIndex(pCrane->m_pHook) + 1);
+ if (pCrane->m_pVehiclePickedUp != nil)
+ pCrane->m_pVehiclePickedUp = (CVehicle*)(CPools::GetVehiclePool()->GetJustIndex(pCrane->m_pVehiclePickedUp) + 1);
}
VALIDATESAVEBUF(*size);
}
-void CranesLoad(uint8* buf, uint32 size)
+void CCranes::Load(uint8* buf, uint32 size)
{
INITSAVEBUF
- CCranes::NumCranes = ReadSaveBuf<int32>(buf);
- CCranes::CarsCollectedMilitaryCrane = ReadSaveBuf<uint32>(buf);
+ NumCranes = ReadSaveBuf<int32>(buf);
+ CarsCollectedMilitaryCrane = ReadSaveBuf<uint32>(buf);
for (int i = 0; i < NUM_CRANES; i++)
- CCranes::aCranes[i] = ReadSaveBuf<CCrane>(buf);
+ aCranes[i] = ReadSaveBuf<CCrane>(buf);
for (int i = 0; i < NUM_CRANES; i++) {
- CCrane* pCrane = &CCranes::aCranes[i];
- if (pCrane->m_pCraneEntity)
+ CCrane *pCrane = &aCranes[i];
+ if (pCrane->m_pCraneEntity != nil)
pCrane->m_pCraneEntity = CPools::GetBuildingPool()->GetSlot((uint32)pCrane->m_pCraneEntity - 1);
- if (pCrane->m_pHook)
+ if (pCrane->m_pHook != nil)
pCrane->m_pHook = CPools::GetObjectPool()->GetSlot((uint32)pCrane->m_pHook - 1);
- if (pCrane->m_pVehiclePickedUp)
- pCrane->m_pVehiclePickedUp = CPools::GetVehiclePool()->GetSlot((uint32)pCrane->m_pVehiclePickedUp + 1);
+ if (pCrane->m_pVehiclePickedUp != nil)
+ pCrane->m_pVehiclePickedUp = CPools::GetVehiclePool()->GetSlot((uint32)pCrane->m_pVehiclePickedUp - 1);
}
for (int i = 0; i < NUM_CRANES; i++) {
- CCranes::aCranes[i].m_nAudioEntity = DMAudio.CreateEntity(AUDIOTYPE_CRANE, &CCranes::aCranes[i]);
- if (CCranes::aCranes[i].m_nAudioEntity)
- DMAudio.SetEntityStatus(CCranes::aCranes[i].m_nAudioEntity, 1);
+ aCranes[i].m_nAudioEntity = DMAudio.CreateEntity(AUDIOTYPE_CRANE, &aCranes[i]);
+ if (aCranes[i].m_nAudioEntity != 0)
+ DMAudio.SetEntityStatus(aCranes[i].m_nAudioEntity, 1);
}
VALIDATESAVEBUF(size);
}
-
-STARTPATCHES
- InjectHook(0x5454D0, CranesLoad, PATCH_JUMP); // GenericLoad
-ENDPATCHES
diff --git a/src/control/Cranes.h b/src/vehicles/Cranes.h
index d9817282..c0502638 100644
--- a/src/control/Cranes.h
+++ b/src/vehicles/Cranes.h
@@ -89,10 +89,9 @@ public:
static bool IsThisCarBeingCarriedByAnyCrane(CVehicle* pVehicle);
static bool IsThisCarBeingTargettedByAnyCrane(CVehicle* pVehicle);
static void Save(uint8* buf, uint32* size);
+ static void Load(uint8* buf, uint32 size); // on mobile it's CranesLoad outside of the class
- static uint32& CarsCollectedMilitaryCrane;
- static int32& NumCranes;
- static CCrane(&aCranes)[NUM_CRANES];
+ static uint32 CarsCollectedMilitaryCrane;
+ static int32 NumCranes;
+ static CCrane aCranes[NUM_CRANES];
};
-
-void CranesLoad(uint8*, uint32); // is this really outside CCranes?