diff options
author | Sergeanur <s.anureev@yandex.ua> | 2021-06-28 03:59:07 +0300 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2021-06-28 05:12:54 +0300 |
commit | f8297df9c5a7d65d5658d1a8d85d391fbb15b95a (patch) | |
tree | 9dcfac13fc3be99320ca7b546c4ff2007bff4121 /src/vehicles | |
parent | 3587cb029e179fe08e572811e467227193e423d5 (diff) |
Redo ReadSaveBuf + common.h cleanup
Diffstat (limited to 'src/vehicles')
-rw-r--r-- | src/vehicles/Automobile.cpp | 5 | ||||
-rw-r--r-- | src/vehicles/Bike.cpp | 1 | ||||
-rw-r--r-- | src/vehicles/Boat.cpp | 1 | ||||
-rw-r--r-- | src/vehicles/CarGen.cpp | 20 | ||||
-rw-r--r-- | src/vehicles/Cranes.cpp | 7 | ||||
-rw-r--r-- | src/vehicles/Vehicle.cpp | 65 |
6 files changed, 55 insertions, 44 deletions
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 041db625..14f2909b 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -50,6 +50,7 @@ #include "Automobile.h" #include "Bike.h" #include "Wanted.h" +#include "SaveBuf.h" bool bAllCarCheat; @@ -5869,7 +5870,7 @@ void CAutomobile::Save(uint8*& buf) { CVehicle::Save(buf); - WriteSaveBuf<CDamageManager>(buf, Damage); + WriteSaveBuf(buf, Damage); SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager)); } @@ -5877,7 +5878,7 @@ void CAutomobile::Load(uint8*& buf) { CVehicle::Load(buf); - Damage = ReadSaveBuf<CDamageManager>(buf); + ReadSaveBuf(&Damage, buf); SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager)); SetupDamageAfterLoad(); } diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp index 0b6d4e3a..e5bb3622 100644 --- a/src/vehicles/Bike.cpp +++ b/src/vehicles/Bike.cpp @@ -36,6 +36,7 @@ #include "Automobile.h" #include "Bike.h" #include "Debug.h" +#include "SaveBuf.h" const uint32 CBike::nSaveStructSize = #ifdef COMPATIBLE_SAVES diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index 0bc653c6..b768db29 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -28,6 +28,7 @@ #include "Record.h" #include "Shadows.h" #include "Wanted.h" +#include "SaveBuf.h" #define INVALID_ORIENTATION (-9999.99f) diff --git a/src/vehicles/CarGen.cpp b/src/vehicles/CarGen.cpp index 78e67d49..29d0c5c7 100644 --- a/src/vehicles/CarGen.cpp +++ b/src/vehicles/CarGen.cpp @@ -17,6 +17,7 @@ #include "World.h" #include "Zones.h" #include "Occlusion.h" +#include "SaveBuf.h" uint8 CTheCarGenerators::ProcessCounter; uint32 CTheCarGenerators::NumOfCarGenerators; @@ -292,14 +293,17 @@ void CTheCarGenerators::LoadAllCarGenerators(uint8* buffer, uint32 size) Init(); INITSAVEBUF CheckSaveHeader(buffer, 'C','G','N','\0', size - SAVE_HEADER_SIZE); - assert(ReadSaveBuf<uint32>(buffer) == nGeneralDataSize); - NumOfCarGenerators = ReadSaveBuf<uint32>(buffer); - CurrentActiveCount = ReadSaveBuf<uint32>(buffer); - ProcessCounter = ReadSaveBuf<uint8>(buffer); - GenerateEvenIfPlayerIsCloseCounter = ReadSaveBuf<uint8>(buffer); - ReadSaveBuf<int16>(buffer); // alignment - assert(ReadSaveBuf<uint32>(buffer) == sizeof(CarGeneratorArray)); + uint32 tmp; + ReadSaveBuf(&tmp, buffer); + assert(tmp == nGeneralDataSize); + ReadSaveBuf(&NumOfCarGenerators, buffer); + ReadSaveBuf(&CurrentActiveCount, buffer); + ReadSaveBuf(&ProcessCounter, buffer); + ReadSaveBuf(&GenerateEvenIfPlayerIsCloseCounter, buffer); + SkipSaveBuf(buffer, 2); + ReadSaveBuf(&tmp, buffer); + assert(tmp == sizeof(CarGeneratorArray)); for (int i = 0; i < NUM_CARGENS; i++) - CarGeneratorArray[i] = ReadSaveBuf<CCarGenerator>(buffer); + ReadSaveBuf(&CarGeneratorArray[i], buffer); VALIDATESAVEBUF(size) } diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp index b5926867..f217f055 100644 --- a/src/vehicles/Cranes.cpp +++ b/src/vehicles/Cranes.cpp @@ -11,6 +11,7 @@ #include "Replay.h" #include "Object.h" #include "World.h" +#include "SaveBuf.h" #define MAX_DISTANCE_TO_FIND_CRANE (10.0f) #define CRANE_UPDATE_RADIUS (300.0f) @@ -641,10 +642,10 @@ void CCranes::Load(uint8* buf, uint32 size) { INITSAVEBUF - NumCranes = ReadSaveBuf<int32>(buf); - CarsCollectedMilitaryCrane = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&NumCranes, buf); + ReadSaveBuf(&CarsCollectedMilitaryCrane, buf); for (int i = 0; i < NUM_CRANES; i++) - aCranes[i] = ReadSaveBuf<CCrane>(buf); + ReadSaveBuf(&aCranes[i], buf); for (int i = 0; i < NUM_CRANES; i++) { CCrane *pCrane = &aCranes[i]; if (pCrane->m_pCraneEntity != nil) diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index c95d0659..8fbf8224 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -32,6 +32,7 @@ #include "Timecycle.h" #include "Weather.h" #include "Coronas.h" +#include "SaveBuf.h" bool CVehicle::bWheelsOnlyCheat; bool CVehicle::bAllDodosCheat; @@ -2426,43 +2427,44 @@ CVehicle::Load(uint8*& buf) { CMatrix tmp; SkipSaveBuf(buf, 4); - tmp.GetRight().x = ReadSaveBuf<float>(buf); - tmp.GetRight().y = ReadSaveBuf<float>(buf); - tmp.GetRight().z = ReadSaveBuf<float>(buf); + ReadSaveBuf(&tmp.GetRight().x, buf); + ReadSaveBuf(&tmp.GetRight().y, buf); + ReadSaveBuf(&tmp.GetRight().z, buf); SkipSaveBuf(buf, 4); - tmp.GetForward().x = ReadSaveBuf<float>(buf); - tmp.GetForward().y = ReadSaveBuf<float>(buf); - tmp.GetForward().z = ReadSaveBuf<float>(buf); + ReadSaveBuf(&tmp.GetForward().x, buf); + ReadSaveBuf(&tmp.GetForward().y, buf); + ReadSaveBuf(&tmp.GetForward().z, buf); SkipSaveBuf(buf, 4); - tmp.GetUp().x = ReadSaveBuf<float>(buf); - tmp.GetUp().y = ReadSaveBuf<float>(buf); - tmp.GetUp().z = ReadSaveBuf<float>(buf); + ReadSaveBuf(&tmp.GetUp().x, buf); + ReadSaveBuf(&tmp.GetUp().y, buf); + ReadSaveBuf(&tmp.GetUp().z, buf); SkipSaveBuf(buf, 4); - tmp.GetPosition().x = ReadSaveBuf<float>(buf); - tmp.GetPosition().y = ReadSaveBuf<float>(buf); - tmp.GetPosition().z = ReadSaveBuf<float>(buf); + ReadSaveBuf(&tmp.GetPosition().x, buf); + ReadSaveBuf(&tmp.GetPosition().y, buf); + ReadSaveBuf(&tmp.GetPosition().z, buf); m_matrix = tmp; SkipSaveBuf(buf, 16); LoadEntityFlags(buf); SkipSaveBuf(buf, 208); AutoPilot.Load(buf); - m_currentColour1 = ReadSaveBuf<int8>(buf); - m_currentColour2 = ReadSaveBuf<int8>(buf); + ReadSaveBuf(&m_currentColour1, buf); + ReadSaveBuf(&m_currentColour2, buf); SkipSaveBuf(buf, 2); - m_nAlarmState = ReadSaveBuf<int16>(buf); + ReadSaveBuf(&m_nAlarmState, buf); SkipSaveBuf(buf, 42); - m_nNumMaxPassengers = ReadSaveBuf<int8>(buf); + ReadSaveBuf(&m_nNumMaxPassengers, buf); SkipSaveBuf(buf, 3); - field_1D0[0] = ReadSaveBuf<float>(buf); - field_1D0[1] = ReadSaveBuf<float>(buf); - field_1D0[2] = ReadSaveBuf<float>(buf); - field_1D0[3] = ReadSaveBuf<float>(buf); + ReadSaveBuf(&field_1D0[0], buf); + ReadSaveBuf(&field_1D0[1], buf); + ReadSaveBuf(&field_1D0[2], buf); + ReadSaveBuf(&field_1D0[3], buf); SkipSaveBuf(buf, 8); - m_fSteerAngle = ReadSaveBuf<float>(buf); - m_fGasPedal = ReadSaveBuf<float>(buf); - m_fBrakePedal = ReadSaveBuf<float>(buf); - VehicleCreatedBy = ReadSaveBuf<uint8>(buf); - uint8 flags = ReadSaveBuf<uint8>(buf); + ReadSaveBuf(&m_fSteerAngle, buf); + ReadSaveBuf(&m_fGasPedal, buf); + ReadSaveBuf(&m_fBrakePedal, buf); + ReadSaveBuf(&VehicleCreatedBy, buf); + uint8 flags; + ReadSaveBuf(&flags, buf); bIsLawEnforcer = !!(flags & BIT(0)); bIsLocked = !!(flags & BIT(3)); bEngineOn = !!(flags & BIT(4)); @@ -2470,16 +2472,17 @@ CVehicle::Load(uint8*& buf) bLightsOn = !!(flags & BIT(6)); bFreebies = !!(flags & BIT(7)); SkipSaveBuf(buf, 10); - m_fHealth = ReadSaveBuf<float>(buf); - m_nCurrentGear = ReadSaveBuf<uint8>(buf); + ReadSaveBuf(&m_fHealth, buf); + ReadSaveBuf(&m_nCurrentGear, buf); SkipSaveBuf(buf, 3); - m_fChangeGearTime = ReadSaveBuf<float>(buf); + ReadSaveBuf(&m_fChangeGearTime, buf); SkipSaveBuf(buf, 12); - m_nTimeOfDeath = ReadSaveBuf<uint32>(buf); + ReadSaveBuf(&m_nTimeOfDeath, buf); SkipSaveBuf(buf, 2); - m_nBombTimer = ReadSaveBuf<int16>(buf); + ReadSaveBuf(&m_nBombTimer, buf); SkipSaveBuf(buf, 12); - m_nDoorLock = (eCarLock)ReadSaveBuf<int8>(buf); + ReadSaveBuf(&flags, buf); + m_nDoorLock = (eCarLock)flags; SkipSaveBuf(buf, 111); } #endif |