summaryrefslogtreecommitdiffstats
path: root/src/control/Phones.cpp
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2019-10-11 00:51:25 +0200
committerGitHub <noreply@github.com>2019-10-11 00:51:25 +0200
commit0408b30a9ffba583f0437c294a98a2cecef74e1d (patch)
tree5fc346badb4cac417ea73b457831c3de89bc450f /src/control/Phones.cpp
parentSingle-wagon train fix (diff)
parentFix CCarGenerator Load/Save (diff)
downloadre3-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/Phones.cpp')
-rw-r--r--src/control/Phones.cpp43
1 files changed, 15 insertions, 28 deletions
diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp
index e2a9ee13..f8005899 100644
--- a/src/control/Phones.cpp
+++ b/src/control/Phones.cpp
@@ -65,27 +65,19 @@ CPhoneInfo::IsMessageBeingDisplayed(int phoneId)
}
void
-CPhoneInfo::Load(CPhoneInfo *source, uint8 buffer)
+CPhoneInfo::Load(uint8 *buf, uint32 size)
{
- // Buffer isn't used.
-
- m_nMax = source->m_nMax;
- m_nNum = source->m_nNum;
- for (int phoneId = 0; phoneId < 50; phoneId++) {
- CPhone *phone = &source->m_aPhones[phoneId];
-
- m_aPhones[phoneId].m_vecPos = phone->m_vecPos;
- memcpy(m_aPhones[phoneId].m_apMessages, phone->m_apMessages, sizeof(wchar*) * 6);
- m_aPhones[phoneId].m_lastTimeRepeatedMsgShown = phone->m_lastTimeRepeatedMsgShown;
- m_aPhones[phoneId].m_pEntity = phone->m_pEntity;
- m_aPhones[phoneId].m_nState = phone->m_nState;
- m_aPhones[phoneId].field_30 = phone->field_30;
-
+INITSAVEBUF
+ m_nMax = ReadSaveBuf<int32>(buf);
+ m_nNum = ReadSaveBuf<int32>(buf);
+ for (int i = 0; i < 50; i++) {
+ m_aPhones[i] = ReadSaveBuf<CPhone>(buf);
// It's saved as building pool index in save file, convert it to true entity
- if (phone->m_pEntity) {
- m_aPhones[phoneId].m_pEntity = CPools::GetBuildingPool()->GetSlot((int)phone->m_pEntity - 1);
+ if (m_aPhones[i].m_pEntity) {
+ m_aPhones[i].m_pEntity = CPools::GetBuildingPool()->GetSlot((int)m_aPhones[i].m_pEntity - 1);
}
}
+VALIDATESAVEBUF(size)
}
void
@@ -174,26 +166,21 @@ CPhoneInfo::Initialise(void)
}
void
-CPhoneInfo::Save(CPhoneInfo *destination, uint32 *size)
+CPhoneInfo::Save(uint8 *buf, uint32 *size)
{
*size = sizeof(CPhoneInfo);
- destination->m_nMax = this->m_nMax;
- destination->m_nNum = m_nNum;
+INITSAVEBUF
+ WriteSaveBuf(buf, m_nMax);
+ WriteSaveBuf(buf, m_nNum);
for(int phoneId = 0; phoneId < 50; phoneId++) {
- CPhone* phone = &destination->m_aPhones[phoneId];
-
- phone->m_vecPos = m_aPhones[phoneId].m_vecPos;
- memcpy(phone->m_apMessages, m_aPhones[phoneId].m_apMessages, sizeof(wchar*) * 6);
- phone->m_lastTimeRepeatedMsgShown = m_aPhones[phoneId].m_lastTimeRepeatedMsgShown;
- phone->m_pEntity = m_aPhones[phoneId].m_pEntity;
- phone->m_nState = m_aPhones[phoneId].m_nState;
- phone->field_30 = m_aPhones[phoneId].field_30;
+ CPhone* phone = WriteSaveBuf(buf, m_aPhones[phoneId]);
// Convert entity pointer to building pool index while saving
if (phone->m_pEntity) {
phone->m_pEntity = (CEntity*) (CPools::GetBuildingPool()->GetJustIndex((CBuilding*)phone->m_pEntity) + 1);
}
}
+VALIDATESAVEBUF(*size)
}
void