summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2021-06-25 23:25:59 +0200
committererorcun <erorcunerorcun@hotmail.com.tr>2021-06-25 23:25:59 +0200
commitaf7573ddbe38e0aaa485877e7ccb2e704b0f5a7f (patch)
tree75a719bb1ab82b354f464562ecc1fae9c55f64d0 /src/control
parentMerge pull request #1147 from withmorten/githash (diff)
downloadre3-af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f.tar
re3-af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f.tar.gz
re3-af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f.tar.bz2
re3-af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f.tar.lz
re3-af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f.tar.xz
re3-af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f.tar.zst
re3-af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f.zip
Diffstat (limited to 'src/control')
-rw-r--r--src/control/AutoPilot.cpp54
-rw-r--r--src/control/Garages.cpp28
-rw-r--r--src/control/Phones.cpp11
-rw-r--r--src/control/Pickups.cpp9
-rw-r--r--src/control/Restart.cpp32
-rw-r--r--src/control/Script5.cpp85
6 files changed, 99 insertions, 120 deletions
diff --git a/src/control/AutoPilot.cpp b/src/control/AutoPilot.cpp
index 22a73179..77cbd0b4 100644
--- a/src/control/AutoPilot.cpp
+++ b/src/control/AutoPilot.cpp
@@ -5,7 +5,6 @@
#include "CarCtrl.h"
#include "Curves.h"
#include "PathFind.h"
-#include "SaveBuf.h"
void CAutoPilot::ModifySpeed(float speed)
{
@@ -89,40 +88,39 @@ void CAutoPilot::Save(uint8*& buf)
void CAutoPilot::Load(uint8*& buf)
{
- ReadSaveBuf(&m_nCurrentRouteNode, buf);
- ReadSaveBuf(&m_nNextRouteNode, buf);
- ReadSaveBuf(&m_nPrevRouteNode, buf);
- ReadSaveBuf(&m_nTimeEnteredCurve, buf);
- ReadSaveBuf(&m_nTimeToSpendOnCurrentCurve, buf);
- ReadSaveBuf(&m_nCurrentPathNodeInfo, buf);
- ReadSaveBuf(&m_nNextPathNodeInfo, buf);
- ReadSaveBuf(&m_nPreviousPathNodeInfo, buf);
- ReadSaveBuf(&m_nAntiReverseTimer, buf);
- ReadSaveBuf(&m_nTimeToStartMission, buf);
- ReadSaveBuf(&m_nPreviousDirection, buf);
- ReadSaveBuf(&m_nCurrentDirection, buf);
- ReadSaveBuf(&m_nNextDirection, buf);
- ReadSaveBuf(&m_nCurrentLane, buf);
- ReadSaveBuf(&m_nNextLane, buf);
- ReadSaveBuf(&m_nDrivingStyle, buf);
- ReadSaveBuf(&m_nCarMission, buf);
- ReadSaveBuf(&m_nTempAction, buf);
- ReadSaveBuf(&m_nTimeTempAction, buf);
- ReadSaveBuf(&m_fMaxTrafficSpeed, buf);
- ReadSaveBuf(&m_nCruiseSpeed, buf);
- uint8 flags;
- ReadSaveBuf(&flags, buf);
+ m_nCurrentRouteNode = ReadSaveBuf<int32>(buf);
+ m_nNextRouteNode = ReadSaveBuf<int32>(buf);
+ m_nPrevRouteNode = ReadSaveBuf<int32>(buf);
+ m_nTimeEnteredCurve = ReadSaveBuf<int32>(buf);
+ m_nTimeToSpendOnCurrentCurve = ReadSaveBuf<int32>(buf);
+ m_nCurrentPathNodeInfo = ReadSaveBuf<uint32>(buf);
+ m_nNextPathNodeInfo = ReadSaveBuf<uint32>(buf);
+ m_nPreviousPathNodeInfo = ReadSaveBuf<uint32>(buf);
+ m_nAntiReverseTimer = ReadSaveBuf<uint32>(buf);
+ m_nTimeToStartMission = ReadSaveBuf<uint32>(buf);
+ m_nPreviousDirection = ReadSaveBuf<int8>(buf);
+ m_nCurrentDirection = ReadSaveBuf<int8>(buf);
+ m_nNextDirection = ReadSaveBuf<int8>(buf);
+ m_nCurrentLane = ReadSaveBuf<int8>(buf);
+ m_nNextLane = ReadSaveBuf<int8>(buf);
+ m_nDrivingStyle = ReadSaveBuf<uint8>(buf);
+ m_nCarMission = ReadSaveBuf<uint8>(buf);
+ m_nTempAction = ReadSaveBuf<uint8>(buf);
+ m_nTimeTempAction = ReadSaveBuf<uint32>(buf);
+ m_fMaxTrafficSpeed = ReadSaveBuf<float>(buf);
+ m_nCruiseSpeed = ReadSaveBuf<uint8>(buf);
+ uint8 flags = ReadSaveBuf<uint8>(buf);
m_bSlowedDownBecauseOfCars = !!(flags & BIT(0));
m_bSlowedDownBecauseOfPeds = !!(flags & BIT(1));
m_bStayInCurrentLevel = !!(flags & BIT(2));
m_bStayInFastLane = !!(flags & BIT(3));
m_bIgnorePathfinding = !!(flags & BIT(4));
SkipSaveBuf(buf, 2);
- ReadSaveBuf(&m_vecDestinationCoors.x, buf);
- ReadSaveBuf(&m_vecDestinationCoors.y, buf);
- ReadSaveBuf(&m_vecDestinationCoors.z, buf);
+ m_vecDestinationCoors.x = ReadSaveBuf<float>(buf);
+ m_vecDestinationCoors.y = ReadSaveBuf<float>(buf);
+ m_vecDestinationCoors.z = ReadSaveBuf<float>(buf);
SkipSaveBuf(buf, 32);
- ReadSaveBuf(&m_nPathFindNodesCount, buf);
+ m_nPathFindNodesCount = ReadSaveBuf<int16>(buf);
SkipSaveBuf(buf, 6);
}
#endif \ No newline at end of file
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index 3410c881..792d3bda 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -24,7 +24,6 @@
#include "Vehicle.h"
#include "Wanted.h"
#include "World.h"
-#include "SaveBuf.h"
#define CRUSHER_GARAGE_X1 (1135.5f)
#define CRUSHER_GARAGE_Y1 (57.0f)
@@ -2362,25 +2361,22 @@ void CGarages::Load(uint8* buf, uint32 size)
assert(size == 5484);
#endif
CloseHideOutGaragesBeforeSave();
- ReadSaveBuf(&NumGarages, buf);
- int32 tempInt;
- ReadSaveBuf(&tempInt, buf);
- BombsAreFree = tempInt ? true : false;
- ReadSaveBuf(&tempInt, buf);
- RespraysAreFree = tempInt ? true : false;
- ReadSaveBuf(&CarsCollected, buf);
- ReadSaveBuf(&BankVansCollected, buf);
- ReadSaveBuf(&PoliceCarsCollected, buf);
+ NumGarages = ReadSaveBuf<uint32>(buf);
+ BombsAreFree = ReadSaveBuf<uint32>(buf);
+ RespraysAreFree = ReadSaveBuf<uint32>(buf);
+ CarsCollected = ReadSaveBuf<int32>(buf);
+ BankVansCollected = ReadSaveBuf<int32>(buf);
+ PoliceCarsCollected = ReadSaveBuf<int32>(buf);
for (int i = 0; i < TOTAL_COLLECTCARS_GARAGES; i++)
- ReadSaveBuf(&CarTypesCollected[i], buf);
- ReadSaveBuf(&LastTimeHelpMessage, buf);
+ CarTypesCollected[i] = ReadSaveBuf<uint32>(buf);
+ LastTimeHelpMessage = ReadSaveBuf<uint32>(buf);
for (int i = 0; i < NUM_GARAGE_STORED_CARS; i++) {
- ReadSaveBuf(&aCarsInSafeHouse1[i], buf);
- ReadSaveBuf(&aCarsInSafeHouse2[i], buf);
- ReadSaveBuf(&aCarsInSafeHouse3[i], buf);
+ aCarsInSafeHouse1[i] = ReadSaveBuf<CStoredCar>(buf);
+ aCarsInSafeHouse2[i] = ReadSaveBuf<CStoredCar>(buf);
+ aCarsInSafeHouse3[i] = ReadSaveBuf<CStoredCar>(buf);
}
for (int i = 0; i < NUM_GARAGES; i++) {
- ReadSaveBuf(&aGarages[i], buf);
+ aGarages[i] = ReadSaveBuf<CGarage>(buf);
aGarages[i].m_pDoor1 = nil;
aGarages[i].m_pDoor2 = nil;
aGarages[i].m_pTarget = nil;
diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp
index f9cb1421..ef7ecead 100644
--- a/src/control/Phones.cpp
+++ b/src/control/Phones.cpp
@@ -13,7 +13,6 @@
#include "RpAnimBlend.h"
#include "AnimBlendAssociation.h"
#include "soundlist.h"
-#include "SaveBuf.h"
#ifdef FIX_BUGS
#include "Replay.h"
#endif
@@ -213,9 +212,8 @@ void
CPhoneInfo::Load(uint8 *buf, uint32 size)
{
INITSAVEBUF
- int32 max, scriptPhonesMax;
- ReadSaveBuf(&max, buf);
- ReadSaveBuf(&scriptPhonesMax, buf);
+ int max = ReadSaveBuf<int32>(buf);
+ int scriptPhonesMax = ReadSaveBuf<int32>(buf);
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
m_nMax = Min(NUMPHONES, max);
@@ -225,8 +223,7 @@ INITSAVEBUF
// We can do it without touching saves. We'll only load script phones, others are already loaded in Initialise
for (int i = 0; i < 50; i++) {
- CPhone phoneToLoad;
- ReadSaveBuf(&phoneToLoad, buf);
+ CPhone phoneToLoad = ReadSaveBuf<CPhone>(buf);
if (ignoreOtherPhones)
continue;
@@ -252,7 +249,7 @@ INITSAVEBUF
m_nScriptPhonesMax = scriptPhonesMax;
for (int i = 0; i < NUMPHONES; i++) {
- ReadSaveBuf(&m_aPhones[i], buf);
+ m_aPhones[i] = ReadSaveBuf<CPhone>(buf);
// It's saved as building pool index in save file, convert it to true entity
if (m_aPhones[i].m_pEntity) {
m_aPhones[i].m_pEntity = CPools::GetBuildingPool()->GetSlot((uintptr)m_aPhones[i].m_pEntity - 1);
diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp
index 10175fba..a1e2a851 100644
--- a/src/control/Pickups.cpp
+++ b/src/control/Pickups.cpp
@@ -23,7 +23,6 @@
#ifdef FIX_BUGS
#include "Replay.h"
#endif
-#include "SaveBuf.h"
#include "Script.h"
#include "Shadows.h"
#include "SpecialFX.h"
@@ -1000,18 +999,18 @@ CPickups::Load(uint8 *buf, uint32 size)
INITSAVEBUF
for (int32 i = 0; i < NUMPICKUPS; i++) {
- ReadSaveBuf(&aPickUps[i], buf);
+ aPickUps[i] = ReadSaveBuf<CPickup>(buf);
if (aPickUps[i].m_eType != PICKUP_NONE && aPickUps[i].m_pObject != nil)
aPickUps[i].m_pObject = CPools::GetObjectPool()->GetSlot((uintptr)aPickUps[i].m_pObject - 1);
}
- ReadSaveBuf(&CollectedPickUpIndex, buf);
- SkipSaveBuf(buf, 2);
+ CollectedPickUpIndex = ReadSaveBuf<uint16>(buf);
+ ReadSaveBuf<uint16>(buf);
NumMessages = 0;
for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++)
- ReadSaveBuf(&aPickUpsCollected[i], buf);
+ aPickUpsCollected[i] = ReadSaveBuf<int32>(buf);
VALIDATESAVEBUF(size)
}
diff --git a/src/control/Restart.cpp b/src/control/Restart.cpp
index 2f5e3d45..4ca18c3b 100644
--- a/src/control/Restart.cpp
+++ b/src/control/Restart.cpp
@@ -1,7 +1,6 @@
#include "common.h"
#include "Restart.h"
-#include "SaveBuf.h"
#include "Zones.h"
#include "PathFind.h"
@@ -174,28 +173,29 @@ INITSAVEBUF
CheckSaveHeader(buf, 'R','S','T','\0', size - SAVE_HEADER_SIZE);
for (int i = 0; i < NUM_RESTART_POINTS; i++) {
- ReadSaveBuf(&HospitalRestartPoints[i], buf);
- ReadSaveBuf(&HospitalRestartHeadings[i], buf);
+ HospitalRestartPoints[i] = ReadSaveBuf<CVector>(buf);
+ HospitalRestartHeadings[i] = ReadSaveBuf<float>(buf);
}
for (int i = 0; i < NUM_RESTART_POINTS; i++) {
- ReadSaveBuf(&PoliceRestartPoints[i], buf);
- ReadSaveBuf(&PoliceRestartHeadings[i], buf);
+ PoliceRestartPoints[i] = ReadSaveBuf<CVector>(buf);
+ PoliceRestartHeadings[i] = ReadSaveBuf<float>(buf);
}
- ReadSaveBuf(&NumberOfHospitalRestarts, buf);
- ReadSaveBuf(&NumberOfPoliceRestarts, buf);
- ReadSaveBuf(&bOverrideRestart, buf);
+ NumberOfHospitalRestarts = ReadSaveBuf<uint16>(buf);
+ NumberOfPoliceRestarts = ReadSaveBuf<uint16>(buf);
+ bOverrideRestart = ReadSaveBuf<bool>(buf);
// skip something unused
- SkipSaveBuf(buf, 3);
-
- ReadSaveBuf(&OverridePosition, buf);
- ReadSaveBuf(&OverrideHeading, buf);
- ReadSaveBuf(&bFadeInAfterNextDeath, buf);
- ReadSaveBuf(&bFadeInAfterNextArrest, buf);
- ReadSaveBuf(&OverrideHospitalLevel, buf);
- ReadSaveBuf(&OverridePoliceStationLevel, buf);
+ ReadSaveBuf<uint8>(buf);
+ ReadSaveBuf<uint16>(buf);
+
+ OverridePosition = ReadSaveBuf<CVector>(buf);
+ OverrideHeading = ReadSaveBuf<float>(buf);
+ bFadeInAfterNextDeath = ReadSaveBuf<bool>(buf);
+ bFadeInAfterNextArrest = ReadSaveBuf<bool>(buf);
+ OverrideHospitalLevel = ReadSaveBuf<uint8>(buf);
+ OverridePoliceStationLevel = ReadSaveBuf<uint8>(buf);
VALIDATESAVEBUF(size);
}
diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp
index a9aec18e..c83c3edc 100644
--- a/src/control/Script5.cpp
+++ b/src/control/Script5.cpp
@@ -12,7 +12,6 @@
#include "Pools.h"
#include "Population.h"
#include "RpAnimBlend.h"
-#include "SaveBuf.h"
#include "Shadows.h"
#include "SpecialFX.h"
#include "World.h"
@@ -2003,25 +2002,21 @@ void CTheScripts::LoadAllScripts(uint8* buf, uint32 size)
Init();
INITSAVEBUF
CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE);
- uint32 varSpace, type, handle;
- uint32 tmp;
-
- ReadSaveBuf(&varSpace, buf);
+ uint32 varSpace = ReadSaveBuf<uint32>(buf);
for (uint32 i = 0; i < varSpace; i++)
- ReadSaveBuf(&ScriptSpace[i], buf);
- ReadSaveBuf(&tmp, buf);
- script_assert(tmp == SCRIPT_DATA_SIZE);
- ReadSaveBuf(&OnAMissionFlag, buf);
+ ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
+ script_assert(ReadSaveBuf<uint32>(buf) == SCRIPT_DATA_SIZE);
+ OnAMissionFlag = ReadSaveBuf<uint32>(buf);
for (uint32 i = 0; i < MAX_NUM_CONTACTS; i++) {
- ReadSaveBuf(&OnAMissionForContactFlag[i], buf);
- ReadSaveBuf(&BaseBriefIdForContact[i], buf);
+ OnAMissionForContactFlag[i] = ReadSaveBuf<uint32>(buf);
+ BaseBriefIdForContact[i] = ReadSaveBuf<uint32>(buf);
}
for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++)
- ReadSaveBuf(&CollectiveArray[i], buf);
- ReadSaveBuf(&NextFreeCollectiveIndex, buf);
+ CollectiveArray[i] = ReadSaveBuf<tCollectiveData>(buf);
+ NextFreeCollectiveIndex = ReadSaveBuf<uint32>(buf);
for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
- ReadSaveBuf(&type, buf);
- ReadSaveBuf(&handle, buf);
+ uint32 type = ReadSaveBuf<uint32>(buf);
+ uint32 handle = ReadSaveBuf<uint32>(buf);
switch (type) {
case 0:
BuildingSwapArray[i].m_pBuilding = nil;
@@ -2035,14 +2030,14 @@ INITSAVEBUF
default:
script_assert(false);
}
- ReadSaveBuf(&BuildingSwapArray[i].m_nNewModel, buf);
- ReadSaveBuf(&BuildingSwapArray[i].m_nOldModel, buf);
+ BuildingSwapArray[i].m_nNewModel = ReadSaveBuf<uint32>(buf);
+ BuildingSwapArray[i].m_nOldModel = ReadSaveBuf<uint32>(buf);
if (BuildingSwapArray[i].m_pBuilding)
BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nNewModel);
}
for (uint32 i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
- ReadSaveBuf(&type, buf);
- ReadSaveBuf(&handle, buf);
+ uint32 type = ReadSaveBuf<uint32>(buf);
+ uint32 handle = ReadSaveBuf<uint32>(buf);
switch (type) {
case 0:
InvisibilitySettingArray[i] = nil;
@@ -2065,20 +2060,14 @@ INITSAVEBUF
if (InvisibilitySettingArray[i])
InvisibilitySettingArray[i]->bIsVisible = false;
}
- bool tmpBool;
- ReadSaveBuf(&tmpBool, buf);
- script_assert(tmpBool == bUsingAMultiScriptFile);
- SkipSaveBuf(buf, 3);
- ReadSaveBuf(&tmp, buf);
- script_assert(tmp == MainScriptSize);
- ReadSaveBuf(&tmp, buf);
- script_assert(tmp == LargestMissionScriptSize);
- uint16 tmp16;
- ReadSaveBuf(&tmp16, buf);
- script_assert(tmp16 == NumberOfMissionScripts);
- SkipSaveBuf(buf, 2);
- uint32 runningScripts;
- ReadSaveBuf(&runningScripts, buf);
+ script_assert(ReadSaveBuf<bool>(buf) == bUsingAMultiScriptFile);
+ ReadSaveBuf<uint8>(buf);
+ ReadSaveBuf<uint16>(buf);
+ script_assert(ReadSaveBuf<uint32>(buf) == MainScriptSize);
+ script_assert(ReadSaveBuf<uint32>(buf) == LargestMissionScriptSize);
+ script_assert(ReadSaveBuf<uint16>(buf) == NumberOfMissionScripts);
+ ReadSaveBuf<uint16>(buf);
+ uint32 runningScripts = ReadSaveBuf<uint32>(buf);
for (uint32 i = 0; i < runningScripts; i++)
StartNewScript(0)->Load(buf);
VALIDATESAVEBUF(size)
@@ -2126,35 +2115,35 @@ void CRunningScript::Load(uint8*& buf)
#ifdef COMPATIBLE_SAVES
SkipSaveBuf(buf, 8);
for (int i = 0; i < 8; i++)
- ReadSaveBuf(&m_abScriptName[i], buf);
- ReadSaveBuf(&m_nIp, buf);
+ m_abScriptName[i] = ReadSaveBuf<char>(buf);
+ m_nIp = ReadSaveBuf<uint32>(buf);
#ifdef CHECK_STRUCT_SIZES
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
#endif
for (int i = 0; i < MAX_STACK_DEPTH; i++)
- ReadSaveBuf(&m_anStack[i], buf);
- ReadSaveBuf(&m_nStackPointer, buf);
+ m_anStack[i] = ReadSaveBuf<uint32>(buf);
+ m_nStackPointer = ReadSaveBuf<uint16>(buf);
SkipSaveBuf(buf, 2);
#ifdef CHECK_STRUCT_SIZES
static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
#endif
for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
- ReadSaveBuf(&m_anLocalVariables[i], buf);
- ReadSaveBuf(&m_bCondResult, buf);
- ReadSaveBuf(&m_bIsMissionScript, buf);
- ReadSaveBuf(&m_bSkipWakeTime, buf);
+ m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
+ m_bCondResult = ReadSaveBuf<bool>(buf);
+ m_bIsMissionScript = ReadSaveBuf<bool>(buf);
+ m_bSkipWakeTime = ReadSaveBuf<bool>(buf);
SkipSaveBuf(buf, 1);
- ReadSaveBuf(&m_nWakeTime, buf);
- ReadSaveBuf(&m_nAndOrState, buf);
- ReadSaveBuf(&m_bNotFlag, buf);
- ReadSaveBuf(&m_bDeatharrestEnabled, buf);
- ReadSaveBuf(&m_bDeatharrestExecuted, buf);
- ReadSaveBuf(&m_bMissionFlag, buf);
+ m_nWakeTime = ReadSaveBuf<uint32>(buf);
+ m_nAndOrState = ReadSaveBuf<uint16>(buf);
+ m_bNotFlag = ReadSaveBuf<bool>(buf);
+ m_bDeatharrestEnabled = ReadSaveBuf<bool>(buf);
+ m_bDeatharrestExecuted = ReadSaveBuf<bool>(buf);
+ m_bMissionFlag = ReadSaveBuf<bool>(buf);
SkipSaveBuf(buf, 2);
#else
CRunningScript* n = next;
CRunningScript* p = prev;
- ReadSaveBuf(this, buf);
+ *this = ReadSaveBuf<CRunningScript>(buf);
next = n;
prev = p;
#endif