diff options
author | Sergeanur <s.anureev@yandex.ua> | 2019-10-08 22:07:11 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2019-10-08 22:07:11 +0200 |
commit | 101192dd322197d1f9e4aa4e48e38b43e05cd72b (patch) | |
tree | ae00316a66f04bd5459dcd8b7b325fb819c7ba06 /src/control/Pickups.cpp | |
parent | Full CGameLogic (diff) | |
download | re3-101192dd322197d1f9e4aa4e48e38b43e05cd72b.tar re3-101192dd322197d1f9e4aa4e48e38b43e05cd72b.tar.gz re3-101192dd322197d1f9e4aa4e48e38b43e05cd72b.tar.bz2 re3-101192dd322197d1f9e4aa4e48e38b43e05cd72b.tar.lz re3-101192dd322197d1f9e4aa4e48e38b43e05cd72b.tar.xz re3-101192dd322197d1f9e4aa4e48e38b43e05cd72b.tar.zst re3-101192dd322197d1f9e4aa4e48e38b43e05cd72b.zip |
Diffstat (limited to 'src/control/Pickups.cpp')
-rw-r--r-- | src/control/Pickups.cpp | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 8a67e248..2e5706f7 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -961,53 +961,47 @@ CPickups::RenderPickUpText() }
void
-CPickups::Load(uint8 *buffer, uint32 size)
+CPickups::Load(uint8 *buf, uint32 size)
{
+INITSAVEBUF
+
for (int32 i = 0; i < NUMPICKUPS; i++) {
- CPickup *buf_pickup = (CPickup*)buffer;
- aPickUps[i] = *buf_pickup;
+ aPickUps[i] = ReadSaveBuf<CPickup>(buf);
if (aPickUps[i].m_eType != PICKUP_NONE && aPickUps[i].m_pObject != nil)
aPickUps[i].m_pObject = CPools::GetObjectPool()->GetSlot((int32)aPickUps[i].m_pObject - 1);
-
- buffer += sizeof(CPickup);
}
- CollectedPickUpIndex = *(uint16*)buffer;
- buffer += sizeof(uint16);
+ CollectedPickUpIndex = ReadSaveBuf<uint16>(buf);
+ ReadSaveBuf<uint16>(buf);
NumMessages = 0;
- buffer += sizeof(uint16);
- for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++) {
- aPickUpsCollected[i] = *(int32*)buffer;
- buffer += sizeof(int32);
- }
+ for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++)
+ aPickUpsCollected[i] = ReadSaveBuf<int32>(buf);
+
+VALIDATESAVEBUF(size)
}
void
-CPickups::Save(uint8 *buffer, uint32 *size)
+CPickups::Save(uint8 *buf, uint32 *size)
{
- *size = sizeof(CPickup) * NUMPICKUPS;
- *size += sizeof(uint32) * NUMCOLLECTEDPICKUPS + 4;
+ *size = sizeof(CPickup) * NUMPICKUPS + sizeof(uint16) + sizeof(uint16) + sizeof(uint32) * NUMCOLLECTEDPICKUPS;
+
+INITSAVEBUF
for (int32 i = 0; i < NUMPICKUPS; i++) {
- CPickup *buf_pickup = (CPickup*)buffer;
- *buf_pickup = aPickUps[i];
+ CPickup *buf_pickup = WriteSaveBuf(buf, aPickUps[i]);
if (buf_pickup->m_eType != PICKUP_NONE && buf_pickup->m_pObject != nil)
buf_pickup->m_pObject = (CObject*)(CPools::GetObjectPool()->GetJustIndex(buf_pickup->m_pObject) + 1);
-
- buffer += sizeof(CPickup);
}
- *(uint16*)buffer = CollectedPickUpIndex;
- buffer += sizeof(uint16);
- *(uint16*)buffer = 0; // possibly was NumMessages
- buffer += sizeof(uint16);
+ WriteSaveBuf(buf, CollectedPickUpIndex);
+ WriteSaveBuf(buf, (uint16)0); // possibly was NumMessages
- for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++) {
- *(int32*)buffer = aPickUpsCollected[i];
- buffer += sizeof(int32);
- }
+ for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++)
+ WriteSaveBuf(buf, aPickUpsCollected[i]);
+
+VALIDATESAVEBUF(*size)
}
STARTPATCHES
|