diff options
author | Sergeanur <s.anureev@yandex.ua> | 2021-06-28 04:16:21 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2021-06-28 04:16:21 +0200 |
commit | eaebaa6db32f4f6f310ea2746ed03da23f4c8ea9 (patch) | |
tree | 140cc1e91a53777cdcb38c4cdacdcd101740965b /src/control | |
parent | Merge pull request #1153 from kusst/texread (diff) | |
parent | Redo ReadSaveBuf + common.h cleanup (diff) | |
download | re3-eaebaa6db32f4f6f310ea2746ed03da23f4c8ea9.tar re3-eaebaa6db32f4f6f310ea2746ed03da23f4c8ea9.tar.gz re3-eaebaa6db32f4f6f310ea2746ed03da23f4c8ea9.tar.bz2 re3-eaebaa6db32f4f6f310ea2746ed03da23f4c8ea9.tar.lz re3-eaebaa6db32f4f6f310ea2746ed03da23f4c8ea9.tar.xz re3-eaebaa6db32f4f6f310ea2746ed03da23f4c8ea9.tar.zst re3-eaebaa6db32f4f6f310ea2746ed03da23f4c8ea9.zip |
Diffstat (limited to 'src/control')
-rw-r--r-- | src/control/AutoPilot.cpp | 60 | ||||
-rw-r--r-- | src/control/GameLogic.cpp | 11 | ||||
-rw-r--r-- | src/control/Garages.cpp | 24 | ||||
-rw-r--r-- | src/control/Phones.cpp | 7 | ||||
-rw-r--r-- | src/control/Pickups.cpp | 9 | ||||
-rw-r--r-- | src/control/Restart.cpp | 32 | ||||
-rw-r--r-- | src/control/Script5.cpp | 1 | ||||
-rw-r--r-- | src/control/SetPieces.cpp | 5 |
8 files changed, 80 insertions, 69 deletions
diff --git a/src/control/AutoPilot.cpp b/src/control/AutoPilot.cpp index d3de6ac2..db72548f 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) { @@ -92,43 +93,44 @@ 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); - m_nCruiseSpeedMultiplierType = 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); + ReadSaveBuf(&m_nCruiseSpeedMultiplierType, buf); SkipSaveBuf(buf, 2); - m_fCruiseSpeedMultiplier = ReadSaveBuf<float>(buf); - uint8 flags = ReadSaveBuf<uint8>(buf); + ReadSaveBuf(&m_fCruiseSpeedMultiplier, 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)); - m_nSwitchDistance = ReadSaveBuf<uint8>(buf); + ReadSaveBuf(&m_nSwitchDistance, buf); 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/GameLogic.cpp b/src/control/GameLogic.cpp index e238a8b3..72e84897 100644 --- a/src/control/GameLogic.cpp +++ b/src/control/GameLogic.cpp @@ -30,6 +30,7 @@ #include "Automobile.h" #include "MBlur.h" #include "screendroplets.h" +#include "SaveBuf.h" uint8 CGameLogic::ActivePlayers; uint8 CGameLogic::ShortCutState; @@ -612,12 +613,12 @@ void CGameLogic::Load(uint8* buf, uint32 size) { INITSAVEBUF - NumAfterDeathStartPoints = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&NumAfterDeathStartPoints, buf); for (int i = 0; i < NUM_SHORTCUT_START_POINTS; i++) { - AfterDeathStartPoints[i].x = ReadSaveBuf<float>(buf); - AfterDeathStartPoints[i].y = ReadSaveBuf<float>(buf); - AfterDeathStartPoints[i].z = ReadSaveBuf<float>(buf); - AfterDeathStartPointOrientation[i] = ReadSaveBuf<float>(buf); + ReadSaveBuf(&AfterDeathStartPoints[i].x, buf); + ReadSaveBuf(&AfterDeathStartPoints[i].y, buf); + ReadSaveBuf(&AfterDeathStartPoints[i].z, buf); + ReadSaveBuf(&AfterDeathStartPointOrientation[i], buf); } VALIDATESAVEBUF(size) } diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index e7da2eff..73d0781c 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -27,6 +27,7 @@ #include "Wanted.h" #include "World.h" #include "VarConsole.h" +#include "SaveBuf.h" #define CRUSHER_GARAGE_X1 (1135.5f) #define CRUSHER_GARAGE_Y1 (57.0f) @@ -2650,22 +2651,25 @@ void CGarages::Load(uint8* buf, uint32 size) assert(size == 10692); //assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage))); 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++) { for (int j = 0; j < TOTAL_HIDEOUT_GARAGES; j++) { - aCarsInSafeHouses[j][i] = ReadSaveBuf<CStoredCar>(buf); + ReadSaveBuf(&aCarsInSafeHouses[j][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 9b50a7ec..a962052f 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 @@ -197,10 +198,10 @@ void CPhoneInfo::Load(uint8 *buf, uint32 size) { INITSAVEBUF - m_nMax = ReadSaveBuf<int32>(buf); - m_nScriptPhonesMax = ReadSaveBuf<int32>(buf); + ReadSaveBuf(&m_nMax, buf); + ReadSaveBuf(&m_nScriptPhonesMax, buf); 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 6d0aa415..b0b0952f 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -33,6 +33,7 @@ #include "Hud.h" #include "Messages.h" #include "Streaming.h" +#include "SaveBuf.h" CPickup CPickups::aPickUps[NUMPICKUPS]; int16 CPickups::NumMessages; @@ -1441,7 +1442,7 @@ 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) { if (aPickUps[i].m_pObject != nil) @@ -1452,12 +1453,12 @@ INITSAVEBUF } - 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 e1950a29..39c9a234 100644 --- a/src/control/Restart.cpp +++ b/src/control/Restart.cpp @@ -3,6 +3,7 @@ #include "Restart.h" #include "Zones.h" #include "PathFind.h" +#include "SaveBuf.h" uint8 CRestart::OverrideHospitalLevel; uint8 CRestart::OverridePoliceStationLevel; @@ -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 d9991388..6208b79f 100644 --- a/src/control/Script5.cpp +++ b/src/control/Script5.cpp @@ -16,6 +16,7 @@ #include "SpecialFX.h" #include "World.h" #include "main.h" +#include "SaveBuf.h" // LCS: file done except TODOs diff --git a/src/control/SetPieces.cpp b/src/control/SetPieces.cpp index 0409a8bf..5edcd335 100644 --- a/src/control/SetPieces.cpp +++ b/src/control/SetPieces.cpp @@ -11,6 +11,7 @@ #include "Wanted.h" #include "World.h" #include "VarConsole.h" +#include "SaveBuf.h" #define TIME_BETWEEN_SETPIECE_SPAWNS 20000 @@ -67,9 +68,9 @@ VALIDATESAVEBUF(*size) void CSetPieces::Load(uint8* buf, uint32 size) { INITSAVEBUF - NumSetPieces = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&NumSetPieces, buf); for (int i = 0; i < NUM_SETPIECES; i++) - aSetPieces[i] = ReadSaveBuf<CSetPiece>(buf); + ReadSaveBuf(&aSetPieces[i], buf); VALIDATESAVEBUF(size) } |