From 3f1001b86bffe6c5de8b7c6ce047d0f2bc3472b4 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 13 May 2020 16:24:00 +0300 Subject: More save/load alignment fixes --- src/weapons/Weapon.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/weapons/Weapon.cpp') diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 67e01a2e..88c4788c 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -2284,27 +2284,32 @@ CWeapon::ProcessLineOfSight(CVector const &point1, CVector const &point2, CColPo } #ifdef COMPATIBLE_SAVES +#define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); SkipSaveBuf(buf, sizeof(data)); +#define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); SkipSaveBuf(buf, sizeof(data)); void CWeapon::Save(uint8*& buf) { - WriteSaveBuf(buf, m_eWeaponType); - WriteSaveBuf(buf, m_eWeaponState); - WriteSaveBuf(buf, m_nAmmoInClip); - WriteSaveBuf(buf, m_nAmmoTotal); - WriteSaveBuf(buf, m_nTimer); - WriteSaveBuf(buf, m_bAddRotOffset); + CopyToBuf(buf, m_eWeaponType); + CopyToBuf(buf, m_eWeaponState); + CopyToBuf(buf, m_nAmmoInClip); + CopyToBuf(buf, m_nAmmoTotal); + CopyToBuf(buf, m_nTimer); + CopyToBuf(buf, m_bAddRotOffset); SkipSaveBuf(buf, 3); } void CWeapon::Load(uint8*& buf) { - m_eWeaponType = (eWeaponType)ReadSaveBuf(buf); - m_eWeaponState = (eWeaponState)ReadSaveBuf(buf); - m_nAmmoInClip = ReadSaveBuf(buf); - m_nAmmoTotal = ReadSaveBuf(buf); - m_nTimer = ReadSaveBuf(buf); - m_bAddRotOffset = ReadSaveBuf(buf); + CopyFromBuf(buf, m_eWeaponType); + CopyFromBuf(buf, m_eWeaponState); + CopyFromBuf(buf, m_nAmmoInClip); + CopyFromBuf(buf, m_nAmmoTotal); + CopyFromBuf(buf, m_nTimer); + CopyFromBuf(buf, m_bAddRotOffset); SkipSaveBuf(buf, 3); } + +#undef CopyFromBuf +#undef CopyToBuf #endif -- cgit v1.2.3