diff options
author | Sergeanur <s.anureev@yandex.ua> | 2021-06-25 18:03:05 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2021-06-25 18:03:51 +0200 |
commit | 2b67aba94cb6448fb24c869559465eddf2bad069 (patch) | |
tree | 5c68ff4f8ce3153640a7b864495e167bec04cce8 /src/control | |
parent | Update invite link (diff) | |
download | re3-2b67aba94cb6448fb24c869559465eddf2bad069.tar re3-2b67aba94cb6448fb24c869559465eddf2bad069.tar.gz re3-2b67aba94cb6448fb24c869559465eddf2bad069.tar.bz2 re3-2b67aba94cb6448fb24c869559465eddf2bad069.tar.lz re3-2b67aba94cb6448fb24c869559465eddf2bad069.tar.xz re3-2b67aba94cb6448fb24c869559465eddf2bad069.tar.zst re3-2b67aba94cb6448fb24c869559465eddf2bad069.zip |
Diffstat (limited to 'src/control')
-rw-r--r-- | src/control/AutoPilot.cpp | 54 | ||||
-rw-r--r-- | src/control/Garages.cpp | 28 | ||||
-rw-r--r-- | src/control/Phones.cpp | 11 | ||||
-rw-r--r-- | src/control/Pickups.cpp | 9 | ||||
-rw-r--r-- | src/control/Restart.cpp | 32 | ||||
-rw-r--r-- | src/control/Script5.cpp | 85 |
6 files changed, 120 insertions, 99 deletions
diff --git a/src/control/AutoPilot.cpp b/src/control/AutoPilot.cpp index 77cbd0b4..22a73179 100644 --- a/src/control/AutoPilot.cpp +++ b/src/control/AutoPilot.cpp @@ -5,6 +5,7 @@ #include "CarCtrl.h" #include "Curves.h" #include "PathFind.h" +#include "SaveBuf.h" void CAutoPilot::ModifySpeed(float speed) { @@ -88,39 +89,40 @@ void CAutoPilot::Save(uint8*& buf) void CAutoPilot::Load(uint8*& 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); + 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_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); - m_vecDestinationCoors.x = ReadSaveBuf<float>(buf); - m_vecDestinationCoors.y = ReadSaveBuf<float>(buf); - m_vecDestinationCoors.z = ReadSaveBuf<float>(buf); + ReadSaveBuf(&m_vecDestinationCoors.x, buf); + ReadSaveBuf(&m_vecDestinationCoors.y, buf); + ReadSaveBuf(&m_vecDestinationCoors.z, buf); SkipSaveBuf(buf, 32); - m_nPathFindNodesCount = ReadSaveBuf<int16>(buf); + ReadSaveBuf(&m_nPathFindNodesCount, buf); SkipSaveBuf(buf, 6); } #endif
\ No newline at end of file diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 792d3bda..3410c881 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -24,6 +24,7 @@ #include "Vehicle.h" #include "Wanted.h" #include "World.h" +#include "SaveBuf.h" #define CRUSHER_GARAGE_X1 (1135.5f) #define CRUSHER_GARAGE_Y1 (57.0f) @@ -2361,22 +2362,25 @@ void CGarages::Load(uint8* buf, uint32 size) assert(size == 5484); #endif CloseHideOutGaragesBeforeSave(); - NumGarages = ReadSaveBuf<uint32>(buf); - BombsAreFree = ReadSaveBuf<uint32>(buf); - RespraysAreFree = ReadSaveBuf<uint32>(buf); - CarsCollected = ReadSaveBuf<int32>(buf); - BankVansCollected = ReadSaveBuf<int32>(buf); - PoliceCarsCollected = ReadSaveBuf<int32>(buf); + 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); for (int i = 0; i < TOTAL_COLLECTCARS_GARAGES; i++) - CarTypesCollected[i] = ReadSaveBuf<uint32>(buf); - LastTimeHelpMessage = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&CarTypesCollected[i], buf); + ReadSaveBuf(&LastTimeHelpMessage, buf); for (int i = 0; i < NUM_GARAGE_STORED_CARS; i++) { - aCarsInSafeHouse1[i] = ReadSaveBuf<CStoredCar>(buf); - aCarsInSafeHouse2[i] = ReadSaveBuf<CStoredCar>(buf); - aCarsInSafeHouse3[i] = ReadSaveBuf<CStoredCar>(buf); + ReadSaveBuf(&aCarsInSafeHouse1[i], buf); + ReadSaveBuf(&aCarsInSafeHouse2[i], buf); + ReadSaveBuf(&aCarsInSafeHouse3[i], buf); } for (int i = 0; i < NUM_GARAGES; i++) { - aGarages[i] = ReadSaveBuf<CGarage>(buf); + ReadSaveBuf(&aGarages[i], 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 ef7ecead..f9cb1421 100644 --- a/src/control/Phones.cpp +++ b/src/control/Phones.cpp @@ -13,6 +13,7 @@ #include "RpAnimBlend.h" #include "AnimBlendAssociation.h" #include "soundlist.h" +#include "SaveBuf.h" #ifdef FIX_BUGS #include "Replay.h" #endif @@ -212,8 +213,9 @@ void CPhoneInfo::Load(uint8 *buf, uint32 size) { INITSAVEBUF - int max = ReadSaveBuf<int32>(buf); - int scriptPhonesMax = ReadSaveBuf<int32>(buf); + int32 max, scriptPhonesMax; + ReadSaveBuf(&max, buf); + ReadSaveBuf(&scriptPhonesMax, buf); #ifdef PEDS_REPORT_CRIMES_ON_PHONE m_nMax = Min(NUMPHONES, max); @@ -223,7 +225,8 @@ 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<CPhone>(buf); + CPhone phoneToLoad; + ReadSaveBuf(&phoneToLoad, buf); if (ignoreOtherPhones) continue; @@ -249,7 +252,7 @@ INITSAVEBUF m_nScriptPhonesMax = scriptPhonesMax; for (int i = 0; i < NUMPHONES; i++) { - m_aPhones[i] = ReadSaveBuf<CPhone>(buf); + ReadSaveBuf(&m_aPhones[i], 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 a1e2a851..10175fba 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -23,6 +23,7 @@ #ifdef FIX_BUGS #include "Replay.h" #endif +#include "SaveBuf.h" #include "Script.h" #include "Shadows.h" #include "SpecialFX.h" @@ -999,18 +1000,18 @@ CPickups::Load(uint8 *buf, uint32 size) INITSAVEBUF for (int32 i = 0; i < NUMPICKUPS; i++) { - aPickUps[i] = ReadSaveBuf<CPickup>(buf); + ReadSaveBuf(&aPickUps[i], 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); } - CollectedPickUpIndex = ReadSaveBuf<uint16>(buf); - ReadSaveBuf<uint16>(buf); + ReadSaveBuf(&CollectedPickUpIndex, buf); + SkipSaveBuf(buf, 2); NumMessages = 0; for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++) - aPickUpsCollected[i] = ReadSaveBuf<int32>(buf); + ReadSaveBuf(&aPickUpsCollected[i], buf); VALIDATESAVEBUF(size) } diff --git a/src/control/Restart.cpp b/src/control/Restart.cpp index 4ca18c3b..2f5e3d45 100644 --- a/src/control/Restart.cpp +++ b/src/control/Restart.cpp @@ -1,6 +1,7 @@ #include "common.h" #include "Restart.h" +#include "SaveBuf.h" #include "Zones.h" #include "PathFind.h" @@ -173,29 +174,28 @@ INITSAVEBUF CheckSaveHeader(buf, 'R','S','T','\0', size - SAVE_HEADER_SIZE); for (int i = 0; i < NUM_RESTART_POINTS; i++) { - HospitalRestartPoints[i] = ReadSaveBuf<CVector>(buf); - HospitalRestartHeadings[i] = ReadSaveBuf<float>(buf); + ReadSaveBuf(&HospitalRestartPoints[i], buf); + ReadSaveBuf(&HospitalRestartHeadings[i], buf); } for (int i = 0; i < NUM_RESTART_POINTS; i++) { - PoliceRestartPoints[i] = ReadSaveBuf<CVector>(buf); - PoliceRestartHeadings[i] = ReadSaveBuf<float>(buf); + ReadSaveBuf(&PoliceRestartPoints[i], buf); + ReadSaveBuf(&PoliceRestartHeadings[i], buf); } - NumberOfHospitalRestarts = ReadSaveBuf<uint16>(buf); - NumberOfPoliceRestarts = ReadSaveBuf<uint16>(buf); - bOverrideRestart = ReadSaveBuf<bool>(buf); + ReadSaveBuf(&NumberOfHospitalRestarts, buf); + ReadSaveBuf(&NumberOfPoliceRestarts, buf); + ReadSaveBuf(&bOverrideRestart, buf); // skip something unused - 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); + SkipSaveBuf(buf, 3); + + ReadSaveBuf(&OverridePosition, buf); + ReadSaveBuf(&OverrideHeading, buf); + ReadSaveBuf(&bFadeInAfterNextDeath, buf); + ReadSaveBuf(&bFadeInAfterNextArrest, buf); + ReadSaveBuf(&OverrideHospitalLevel, buf); + ReadSaveBuf(&OverridePoliceStationLevel, buf); VALIDATESAVEBUF(size); } diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp index c83c3edc..a9aec18e 100644 --- a/src/control/Script5.cpp +++ b/src/control/Script5.cpp @@ -12,6 +12,7 @@ #include "Pools.h" #include "Population.h" #include "RpAnimBlend.h" +#include "SaveBuf.h" #include "Shadows.h" #include "SpecialFX.h" #include "World.h" @@ -2002,21 +2003,25 @@ void CTheScripts::LoadAllScripts(uint8* buf, uint32 size) Init(); INITSAVEBUF CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE); - uint32 varSpace = ReadSaveBuf<uint32>(buf); + uint32 varSpace, type, handle; + uint32 tmp; + + ReadSaveBuf(&varSpace, buf); for (uint32 i = 0; i < varSpace; i++) - ScriptSpace[i] = ReadSaveBuf<uint8>(buf); - script_assert(ReadSaveBuf<uint32>(buf) == SCRIPT_DATA_SIZE); - OnAMissionFlag = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&ScriptSpace[i], buf); + ReadSaveBuf(&tmp, buf); + script_assert(tmp == SCRIPT_DATA_SIZE); + ReadSaveBuf(&OnAMissionFlag, buf); for (uint32 i = 0; i < MAX_NUM_CONTACTS; i++) { - OnAMissionForContactFlag[i] = ReadSaveBuf<uint32>(buf); - BaseBriefIdForContact[i] = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&OnAMissionForContactFlag[i], buf); + ReadSaveBuf(&BaseBriefIdForContact[i], buf); } for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++) - CollectiveArray[i] = ReadSaveBuf<tCollectiveData>(buf); - NextFreeCollectiveIndex = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&CollectiveArray[i], buf); + ReadSaveBuf(&NextFreeCollectiveIndex, buf); for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) { - uint32 type = ReadSaveBuf<uint32>(buf); - uint32 handle = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&type, buf); + ReadSaveBuf(&handle, buf); switch (type) { case 0: BuildingSwapArray[i].m_pBuilding = nil; @@ -2030,14 +2035,14 @@ INITSAVEBUF default: script_assert(false); } - BuildingSwapArray[i].m_nNewModel = ReadSaveBuf<uint32>(buf); - BuildingSwapArray[i].m_nOldModel = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&BuildingSwapArray[i].m_nNewModel, buf); + ReadSaveBuf(&BuildingSwapArray[i].m_nOldModel, 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++) { - uint32 type = ReadSaveBuf<uint32>(buf); - uint32 handle = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&type, buf); + ReadSaveBuf(&handle, buf); switch (type) { case 0: InvisibilitySettingArray[i] = nil; @@ -2060,14 +2065,20 @@ INITSAVEBUF if (InvisibilitySettingArray[i]) InvisibilitySettingArray[i]->bIsVisible = false; } - 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); + 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); for (uint32 i = 0; i < runningScripts; i++) StartNewScript(0)->Load(buf); VALIDATESAVEBUF(size) @@ -2115,35 +2126,35 @@ void CRunningScript::Load(uint8*& buf) #ifdef COMPATIBLE_SAVES SkipSaveBuf(buf, 8); for (int i = 0; i < 8; i++) - m_abScriptName[i] = ReadSaveBuf<char>(buf); - m_nIp = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&m_abScriptName[i], buf); + ReadSaveBuf(&m_nIp, 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++) - m_anStack[i] = ReadSaveBuf<uint32>(buf); - m_nStackPointer = ReadSaveBuf<uint16>(buf); + ReadSaveBuf(&m_anStack[i], buf); + ReadSaveBuf(&m_nStackPointer, 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++) - m_anLocalVariables[i] = ReadSaveBuf<int32>(buf); - m_bCondResult = ReadSaveBuf<bool>(buf); - m_bIsMissionScript = ReadSaveBuf<bool>(buf); - m_bSkipWakeTime = ReadSaveBuf<bool>(buf); + ReadSaveBuf(&m_anLocalVariables[i], buf); + ReadSaveBuf(&m_bCondResult, buf); + ReadSaveBuf(&m_bIsMissionScript, buf); + ReadSaveBuf(&m_bSkipWakeTime, buf); SkipSaveBuf(buf, 1); - 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); + ReadSaveBuf(&m_nWakeTime, buf); + ReadSaveBuf(&m_nAndOrState, buf); + ReadSaveBuf(&m_bNotFlag, buf); + ReadSaveBuf(&m_bDeatharrestEnabled, buf); + ReadSaveBuf(&m_bDeatharrestExecuted, buf); + ReadSaveBuf(&m_bMissionFlag, buf); SkipSaveBuf(buf, 2); #else CRunningScript* n = next; CRunningScript* p = prev; - *this = ReadSaveBuf<CRunningScript>(buf); + ReadSaveBuf(this, buf); next = n; prev = p; #endif |