diff options
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 | 83 | ||||
-rw-r--r-- | src/control/SetPieces.cpp | 5 |
8 files changed, 127 insertions, 104 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 33c40c91..17802d95 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; @@ -611,12 +612,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 d4a42ea1..4c3ceb5c 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -24,6 +24,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) @@ -2309,22 +2310,25 @@ void CGarages::Load(uint8* buf, uint32 size) assert(size = 7876); //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 0428ddae..fd7bfe0e 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 9d14b1c4..2806ee30 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" void CRunningScript::UpdateCompareFlag(bool flag) { @@ -2184,15 +2185,19 @@ 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); - LastMissionPassedTime = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&ScriptSpace[i], buf); + ReadSaveBuf(&tmp, buf); + script_assert(tmp == SCRIPT_DATA_SIZE); + ReadSaveBuf(&OnAMissionFlag, buf); + ReadSaveBuf(&LastMissionPassedTime, 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; @@ -2206,14 +2211,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; @@ -2236,14 +2241,22 @@ INITSAVEBUF if (InvisibilitySettingArray[i]) InvisibilitySettingArray[i]->bIsVisible = false; } - script_assert(ReadSaveBuf<bool>(buf) == bUsingAMultiScriptFile); - bPlayerHasMetDebbieHarry = ReadSaveBuf<uint8>(buf); - ReadSaveBuf<uint16>(buf); - script_assert(ReadSaveBuf<uint32>(buf) == MainScriptSize); - script_assert(ReadSaveBuf<uint32>(buf) == LargestMissionScriptSize); - script_assert(ReadSaveBuf<uint16>(buf) == NumberOfMissionScripts); - script_assert(ReadSaveBuf<uint16>(buf) == NumberOfExclusiveMissionScripts); - uint32 runningScripts = ReadSaveBuf<uint32>(buf); + bool tmpBool; + ReadSaveBuf(&tmpBool, buf); + script_assert(tmpBool == bUsingAMultiScriptFile); + ReadSaveBuf(&bPlayerHasMetDebbieHarry, buf); + SkipSaveBuf(buf, 2); + ReadSaveBuf(&tmp, buf); + script_assert(tmp == MainScriptSize); + ReadSaveBuf(&tmp, buf); + script_assert(tmp == LargestMissionScriptSize); + uint16 tmp16; + ReadSaveBuf(&tmp16, buf); + script_assert(tmp16 == NumberOfMissionScripts); + ReadSaveBuf(&tmp16, buf); + script_assert(tmp16 == NumberOfExclusiveMissionScripts); + uint32 runningScripts; + ReadSaveBuf(&runningScripts, buf); for (uint32 i = 0; i < runningScripts; i++) StartNewScript(0)->Load(buf); VALIDATESAVEBUF(size) @@ -2291,35 +2304,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_bIsActive = ReadSaveBuf<bool>(buf); - m_bCondResult = ReadSaveBuf<bool>(buf); - m_bIsMissionScript = ReadSaveBuf<bool>(buf); - m_bSkipWakeTime = ReadSaveBuf<bool>(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); + ReadSaveBuf(&m_anLocalVariables[i], buf); + ReadSaveBuf(&m_bIsActive, buf); + ReadSaveBuf(&m_bCondResult, buf); + ReadSaveBuf(&m_bIsMissionScript, buf); + ReadSaveBuf(&m_bSkipWakeTime, 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 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) } |