diff options
author | Sergeanur <s.anureev@yandex.ua> | 2019-10-11 00:51:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-11 00:51:25 +0200 |
commit | 0408b30a9ffba583f0437c294a98a2cecef74e1d (patch) | |
tree | 5fc346badb4cac417ea73b457831c3de89bc450f /src/control/Pickups.cpp | |
parent | Single-wagon train fix (diff) | |
parent | Fix CCarGenerator Load/Save (diff) | |
download | re3-0408b30a9ffba583f0437c294a98a2cecef74e1d.tar re3-0408b30a9ffba583f0437c294a98a2cecef74e1d.tar.gz re3-0408b30a9ffba583f0437c294a98a2cecef74e1d.tar.bz2 re3-0408b30a9ffba583f0437c294a98a2cecef74e1d.tar.lz re3-0408b30a9ffba583f0437c294a98a2cecef74e1d.tar.xz re3-0408b30a9ffba583f0437c294a98a2cecef74e1d.tar.zst re3-0408b30a9ffba583f0437c294a98a2cecef74e1d.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 d77975e6..0646e0f6 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
|