summaryrefslogtreecommitdiffstats
path: root/src/control/Phones.cpp
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2019-10-08 22:07:11 +0200
committerSergeanur <s.anureev@yandex.ua>2019-10-08 22:07:11 +0200
commit101192dd322197d1f9e4aa4e48e38b43e05cd72b (patch)
treeae00316a66f04bd5459dcd8b7b325fb819c7ba06 /src/control/Phones.cpp
parentFull CGameLogic (diff)
downloadre3-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 '')
-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