diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2021-07-12 09:32:01 +0200 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2021-07-12 09:32:01 +0200 |
commit | 91d958bf2748b94acf370c7bc57b4ef061bcee2d (patch) | |
tree | f9dcbdb25b9cf741b2cb280c2067990ae6c829cd /src/vehicles | |
parent | small changes (diff) | |
parent | Merge branch 'miami' into lcs (diff) | |
download | re3-91d958bf2748b94acf370c7bc57b4ef061bcee2d.tar re3-91d958bf2748b94acf370c7bc57b4ef061bcee2d.tar.gz re3-91d958bf2748b94acf370c7bc57b4ef061bcee2d.tar.bz2 re3-91d958bf2748b94acf370c7bc57b4ef061bcee2d.tar.lz re3-91d958bf2748b94acf370c7bc57b4ef061bcee2d.tar.xz re3-91d958bf2748b94acf370c7bc57b4ef061bcee2d.tar.zst re3-91d958bf2748b94acf370c7bc57b4ef061bcee2d.zip |
Diffstat (limited to 'src/vehicles')
-rw-r--r-- | src/vehicles/Automobile.cpp | 2 | ||||
-rw-r--r-- | src/vehicles/Bike.cpp | 2 | ||||
-rw-r--r-- | src/vehicles/Boat.cpp | 2 | ||||
-rw-r--r-- | src/vehicles/Cranes.cpp | 84 | ||||
-rw-r--r-- | src/vehicles/Vehicle.cpp | 99 | ||||
-rw-r--r-- | src/vehicles/Vehicle.h | 2 |
6 files changed, 135 insertions, 56 deletions
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index ef7fded0..2c199030 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -5725,7 +5725,7 @@ CAutomobile::Save(uint8*& buf) { CVehicle::Save(buf); WriteSaveBuf(buf, Damage); - SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager)); + ZeroSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager)); } void diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp index 627cddbb..39612a15 100644 --- a/src/vehicles/Bike.cpp +++ b/src/vehicles/Bike.cpp @@ -2953,7 +2953,7 @@ void CBike::Save(uint8*& buf) { CVehicle::Save(buf); - SkipSaveBuf(buf, 1260 - 672); + ZeroSaveBuf(buf, 1260 - 672); } void diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index ab70f19b..a3aec041 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -1478,7 +1478,7 @@ void CBoat::Save(uint8*& buf) { CVehicle::Save(buf); - SkipSaveBuf(buf, 1216 - 672); + ZeroSaveBuf(buf, 1216 - 672); } void diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp index 857b846f..d4b58f05 100644 --- a/src/vehicles/Cranes.cpp +++ b/src/vehicles/Cranes.cpp @@ -37,6 +37,12 @@ #define MIN_VALID_POSITION (-10000.0f) #define DEFAULT_OFFSET (20.0f) +#ifdef COMPATIBLE_SAVES +#define CRANES_SAVE_SIZE 0x3E0 +#else +#define CRANES_SAVE_SIZE sizeof(aCranes) +#endif + uint32 TimerForCamInterpolation; uint32 CCranes::CarsCollectedMilitaryCrane; @@ -624,10 +630,45 @@ void CCranes::Save(uint8* buf, uint32* size) { INITSAVEBUF - *size = 2 * sizeof(uint32) + sizeof(aCranes); + *size = 2 * sizeof(uint32) + CRANES_SAVE_SIZE; WriteSaveBuf(buf, NumCranes); WriteSaveBuf(buf, CarsCollectedMilitaryCrane); for (int i = 0; i < NUM_CRANES; i++) { +#ifdef COMPATIBLE_SAVES + int32 tmp = aCranes[i].m_pCraneEntity != nil ? CPools::GetBuildingPool()->GetJustIndex_NoFreeAssert(aCranes[i].m_pCraneEntity) + 1 : 0; + WriteSaveBuf(buf, tmp); + tmp = aCranes[i].m_pHook != nil ? CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(aCranes[i].m_pHook) + 1 : 0; + WriteSaveBuf(buf, tmp); + WriteSaveBuf(buf, aCranes[i].m_fPickupX1); + WriteSaveBuf(buf, aCranes[i].m_fPickupX2); + WriteSaveBuf(buf, aCranes[i].m_fPickupY1); + WriteSaveBuf(buf, aCranes[i].m_fPickupY2); + WriteSaveBuf(buf, aCranes[i].m_vecDropoffTarget); + WriteSaveBuf(buf, aCranes[i].m_fDropoffHeading); + WriteSaveBuf(buf, aCranes[i].m_fPickupAngle); + WriteSaveBuf(buf, aCranes[i].m_fDropoffAngle); + WriteSaveBuf(buf, aCranes[i].m_fPickupDistance); + WriteSaveBuf(buf, aCranes[i].m_fDropoffDistance); + WriteSaveBuf(buf, aCranes[i].m_fPickupHeight); + WriteSaveBuf(buf, aCranes[i].m_fDropoffHeight); + WriteSaveBuf(buf, aCranes[i].m_fHookAngle); + WriteSaveBuf(buf, aCranes[i].m_fHookOffset); + WriteSaveBuf(buf, aCranes[i].m_fHookHeight); + WriteSaveBuf(buf, aCranes[i].m_vecHookInitPos); + WriteSaveBuf(buf, aCranes[i].m_vecHookCurPos); + WriteSaveBuf(buf, aCranes[i].m_vecHookVelocity); + tmp = aCranes[i].m_pVehiclePickedUp != nil ? CPools::GetVehiclePool()->GetJustIndex_NoFreeAssert(aCranes[i].m_pVehiclePickedUp) + 1 : 0; + WriteSaveBuf(buf, tmp); + WriteSaveBuf(buf, aCranes[i].m_nTimeForNextCheck); + WriteSaveBuf(buf, aCranes[i].m_nCraneStatus); + WriteSaveBuf(buf, aCranes[i].m_nCraneState); + WriteSaveBuf(buf, aCranes[i].m_nVehiclesCollected); + WriteSaveBuf(buf, aCranes[i].m_bIsCrusher); + WriteSaveBuf(buf, aCranes[i].m_bIsMilitaryCrane); + WriteSaveBuf(buf, aCranes[i].m_bWasMilitaryCrane); + WriteSaveBuf(buf, aCranes[i].m_bIsTop); + ZeroSaveBuf(buf, 1); +#else CCrane *pCrane = WriteSaveBuf(buf, aCranes[i]); if (pCrane->m_pCraneEntity != nil) pCrane->m_pCraneEntity = (CBuilding*)(CPools::GetBuildingPool()->GetJustIndex_NoFreeAssert(pCrane->m_pCraneEntity) + 1); @@ -635,6 +676,7 @@ void CCranes::Save(uint8* buf, uint32* size) pCrane->m_pHook = (CObject*)(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(pCrane->m_pHook) + 1); if (pCrane->m_pVehiclePickedUp != nil) pCrane->m_pVehiclePickedUp = (CVehicle*)(CPools::GetVehiclePool()->GetJustIndex_NoFreeAssert(pCrane->m_pVehiclePickedUp) + 1); +#endif } VALIDATESAVEBUF(*size); @@ -646,8 +688,45 @@ void CCranes::Load(uint8* buf, uint32 size) ReadSaveBuf(&NumCranes, buf); ReadSaveBuf(&CarsCollectedMilitaryCrane, buf); - for (int i = 0; i < NUM_CRANES; i++) + for (int i = 0; i < NUM_CRANES; i++) { +#ifdef COMPATIBLE_SAVES + int32 tmp; + ReadSaveBuf(&tmp, buf); + aCranes[i].m_pCraneEntity = tmp != 0 ? CPools::GetBuildingPool()->GetSlot(tmp - 1) : nil; + ReadSaveBuf(&tmp, buf); + aCranes[i].m_pHook = tmp != 0 ? CPools::GetObjectPool()->GetSlot(tmp - 1) : nil; + ReadSaveBuf(&aCranes[i].m_fPickupX1, buf); + ReadSaveBuf(&aCranes[i].m_fPickupX2, buf); + ReadSaveBuf(&aCranes[i].m_fPickupY1, buf); + ReadSaveBuf(&aCranes[i].m_fPickupY2, buf); + ReadSaveBuf(&aCranes[i].m_vecDropoffTarget, buf); + ReadSaveBuf(&aCranes[i].m_fDropoffHeading, buf); + ReadSaveBuf(&aCranes[i].m_fPickupAngle, buf); + ReadSaveBuf(&aCranes[i].m_fDropoffAngle, buf); + ReadSaveBuf(&aCranes[i].m_fPickupDistance, buf); + ReadSaveBuf(&aCranes[i].m_fDropoffDistance, buf); + ReadSaveBuf(&aCranes[i].m_fPickupHeight, buf); + ReadSaveBuf(&aCranes[i].m_fDropoffHeight, buf); + ReadSaveBuf(&aCranes[i].m_fHookAngle, buf); + ReadSaveBuf(&aCranes[i].m_fHookOffset, buf); + ReadSaveBuf(&aCranes[i].m_fHookHeight, buf); + ReadSaveBuf(&aCranes[i].m_vecHookInitPos, buf); + ReadSaveBuf(&aCranes[i].m_vecHookCurPos, buf); + ReadSaveBuf(&aCranes[i].m_vecHookVelocity, buf); + ReadSaveBuf(&tmp, buf); + aCranes[i].m_pVehiclePickedUp = tmp != 0 ? CPools::GetVehiclePool()->GetSlot(tmp - 1) : nil; + ReadSaveBuf(&aCranes[i].m_nTimeForNextCheck, buf); + ReadSaveBuf(&aCranes[i].m_nCraneStatus, buf); + ReadSaveBuf(&aCranes[i].m_nCraneState, buf); + ReadSaveBuf(&aCranes[i].m_nVehiclesCollected, buf); + ReadSaveBuf(&aCranes[i].m_bIsCrusher, buf); + ReadSaveBuf(&aCranes[i].m_bIsMilitaryCrane, buf); + ReadSaveBuf(&aCranes[i].m_bWasMilitaryCrane, buf); + ReadSaveBuf(&aCranes[i].m_bIsTop, buf); + SkipSaveBuf(buf, 1); +#else ReadSaveBuf(&aCranes[i], buf); + } for (int i = 0; i < NUM_CRANES; i++) { CCrane *pCrane = &aCranes[i]; if (pCrane->m_pCraneEntity != nil) @@ -656,6 +735,7 @@ void CCranes::Load(uint8* buf, uint32 size) pCrane->m_pHook = CPools::GetObjectPool()->GetSlot((uintptr)pCrane->m_pHook - 1); if (pCrane->m_pVehiclePickedUp != nil) pCrane->m_pVehiclePickedUp = CPools::GetVehiclePool()->GetSlot((uintptr)pCrane->m_pVehiclePickedUp - 1); +#endif } VALIDATESAVEBUF(size); diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 49427476..a4c983f7 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -2377,42 +2377,42 @@ DestroyVehicleAndDriverAndPassengers(CVehicle* pVehicle) void CVehicle::Save(uint8*& buf) { - SkipSaveBuf(buf, 4); - WriteSaveBuf<float>(buf, GetRight().x); - WriteSaveBuf<float>(buf, GetRight().y); - WriteSaveBuf<float>(buf, GetRight().z); - SkipSaveBuf(buf, 4); - WriteSaveBuf<float>(buf, GetForward().x); - WriteSaveBuf<float>(buf, GetForward().y); - WriteSaveBuf<float>(buf, GetForward().z); - SkipSaveBuf(buf, 4); - WriteSaveBuf<float>(buf, GetUp().x); - WriteSaveBuf<float>(buf, GetUp().y); - WriteSaveBuf<float>(buf, GetUp().z); - SkipSaveBuf(buf, 4); - WriteSaveBuf<float>(buf, GetPosition().x); - WriteSaveBuf<float>(buf, GetPosition().y); - WriteSaveBuf<float>(buf, GetPosition().z); - SkipSaveBuf(buf, 16); + ZeroSaveBuf(buf, 4); + WriteSaveBuf(buf, GetRight().x); + WriteSaveBuf(buf, GetRight().y); + WriteSaveBuf(buf, GetRight().z); + ZeroSaveBuf(buf, 4); + WriteSaveBuf(buf, GetForward().x); + WriteSaveBuf(buf, GetForward().y); + WriteSaveBuf(buf, GetForward().z); + ZeroSaveBuf(buf, 4); + WriteSaveBuf(buf, GetUp().x); + WriteSaveBuf(buf, GetUp().y); + WriteSaveBuf(buf, GetUp().z); + ZeroSaveBuf(buf, 4); + WriteSaveBuf(buf, GetPosition().x); + WriteSaveBuf(buf, GetPosition().y); + WriteSaveBuf(buf, GetPosition().z); + ZeroSaveBuf(buf, 16); SaveEntityFlags(buf); - SkipSaveBuf(buf, 208); + ZeroSaveBuf(buf, 208); AutoPilot.Save(buf); - WriteSaveBuf<int8>(buf, m_currentColour1); - WriteSaveBuf<int8>(buf, m_currentColour2); - SkipSaveBuf(buf, 2); - WriteSaveBuf<int16>(buf, m_nAlarmState); - SkipSaveBuf(buf, 42); - WriteSaveBuf<uint8>(buf, m_nNumMaxPassengers); - SkipSaveBuf(buf, 3); - WriteSaveBuf<float>(buf, field_1D0[0]); - WriteSaveBuf<float>(buf, field_1D0[1]); - WriteSaveBuf<float>(buf, field_1D0[2]); - WriteSaveBuf<float>(buf, field_1D0[3]); - SkipSaveBuf(buf, 8); - WriteSaveBuf<float>(buf, m_fSteerAngle); - WriteSaveBuf<float>(buf, m_fGasPedal); - WriteSaveBuf<float>(buf, m_fBrakePedal); - WriteSaveBuf<uint8>(buf, VehicleCreatedBy); + WriteSaveBuf(buf, m_currentColour1); + WriteSaveBuf(buf, m_currentColour2); + ZeroSaveBuf(buf, 2); + WriteSaveBuf(buf, m_nAlarmState); + ZeroSaveBuf(buf, 42); + WriteSaveBuf(buf, m_nNumMaxPassengers); + ZeroSaveBuf(buf, 3); + WriteSaveBuf(buf, field_1D0[0]); + WriteSaveBuf(buf, field_1D0[1]); + WriteSaveBuf(buf, field_1D0[2]); + WriteSaveBuf(buf, field_1D0[3]); + ZeroSaveBuf(buf, 8); + WriteSaveBuf(buf, m_fSteerAngle); + WriteSaveBuf(buf, m_fGasPedal); + WriteSaveBuf(buf, m_fBrakePedal); + WriteSaveBuf(buf, VehicleCreatedBy); uint8 flags = 0; if (bIsLawEnforcer) flags |= BIT(0); if (bIsLocked) flags |= BIT(3); @@ -2420,19 +2420,19 @@ CVehicle::Save(uint8*& buf) if (bIsHandbrakeOn) flags |= BIT(5); if (bLightsOn) flags |= BIT(6); if (bFreebies) flags |= BIT(7); - WriteSaveBuf<uint8>(buf, flags); - SkipSaveBuf(buf, 10); - WriteSaveBuf<float>(buf, m_fHealth); - WriteSaveBuf<uint8>(buf, m_nCurrentGear); - SkipSaveBuf(buf, 3); - WriteSaveBuf<float>(buf, m_fChangeGearTime); - SkipSaveBuf(buf, 12); - WriteSaveBuf<uint32>(buf, m_nTimeOfDeath); - SkipSaveBuf(buf, 2); - WriteSaveBuf<int16>(buf, m_nBombTimer); - SkipSaveBuf(buf, 12); - WriteSaveBuf<int8>(buf, m_nDoorLock); - SkipSaveBuf(buf, 111); + WriteSaveBuf(buf, flags); + ZeroSaveBuf(buf, 10); + WriteSaveBuf(buf, m_fHealth); + WriteSaveBuf(buf, m_nCurrentGear); + ZeroSaveBuf(buf, 3); + WriteSaveBuf(buf, m_fChangeGearTime); + ZeroSaveBuf(buf, 12); + WriteSaveBuf(buf, m_nTimeOfDeath); + ZeroSaveBuf(buf, 2); + WriteSaveBuf(buf, m_nBombTimer); + ZeroSaveBuf(buf, 12); + WriteSaveBuf(buf, m_nDoorLock); + ZeroSaveBuf(buf, 108); } void @@ -2494,9 +2494,8 @@ CVehicle::Load(uint8*& buf) SkipSaveBuf(buf, 2); ReadSaveBuf(&m_nBombTimer, buf); SkipSaveBuf(buf, 12); - ReadSaveBuf(&flags, buf); - m_nDoorLock = (eCarLock)flags; - SkipSaveBuf(buf, 111); + ReadSaveBuf(&m_nDoorLock, buf); + SkipSaveBuf(buf, 108); } #endif diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index d29c2dc0..5458590f 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -279,7 +279,7 @@ public: int8 m_comedyControlState; CStoredCollPoly m_aCollPolys[2]; // poly which is under front/rear part of car float m_fSteerInput; - uint8 m_vehType; + eVehicleType m_vehType; static void *operator new(size_t) throw(); static void *operator new(size_t sz, int slot) throw(); |