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/peds/PedType.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/peds/PedType.cpp')
-rw-r--r-- | src/peds/PedType.cpp | 57 |
1 files changed, 13 insertions, 44 deletions
diff --git a/src/peds/PedType.cpp b/src/peds/PedType.cpp index 66eb49a1..a8e052c7 100644 --- a/src/peds/PedType.cpp +++ b/src/peds/PedType.cpp @@ -181,56 +181,25 @@ CPedType::FindPedFlag(char *type) } void -CPedType::Save(uint8 *buffer, uint32 *length) +CPedType::Save(uint8 *buf, uint32 *size) { - int i; - - *length = 8 + NUM_PEDTYPES*32; - - buffer[0] = 'P'; - buffer[1] = 'T'; - buffer[2] = 'P'; - buffer[3] = '\0'; - *(uint32*)(buffer+4) = *length - 8; - buffer += 8; - - for(i = 0; i < NUM_PEDTYPES; i++){ - *(uint32*)(buffer) = ms_apPedType[i]->m_flag; - *(float*)(buffer+4) = ms_apPedType[i]->unknown1; - *(float*)(buffer+8) = ms_apPedType[i]->unknown2; - *(float*)(buffer+12) = ms_apPedType[i]->unknown3; - *(float*)(buffer+16) = ms_apPedType[i]->unknown4; - *(float*)(buffer+20) = ms_apPedType[i]->unknown5; - *(uint32*)(buffer+24) = ms_apPedType[i]->m_threats; - *(uint32*)(buffer+28) = ms_apPedType[i]->m_avoid; - buffer += 32; - } + *size = sizeof(CPedType) * NUM_PEDTYPES + SAVE_HEADER_SIZE; +INITSAVEBUF + WriteSaveHeader(buf, 'P','T','P','\0', *size - SAVE_HEADER_SIZE); + for(int i = 0; i < NUM_PEDTYPES; i++) + WriteSaveBuf(buf, *ms_apPedType[i]); +VALIDATESAVEBUF(*size) } void -CPedType::Load(uint8 *buffer, uint32 length) +CPedType::Load(uint8 *buf, uint32 size) { - int i; - - assert(length == 8 + NUM_PEDTYPES*32); - assert(buffer[0] == 'P'); - assert(buffer[1] == 'T'); - assert(buffer[2] == 'P'); - assert(buffer[3] == '\0'); - assert(*(uint32*)(buffer+4) == length - 8); - buffer += 8; +INITSAVEBUF + CheckSaveHeader(buf, 'P','T','P','\0', size - SAVE_HEADER_SIZE); - for(i = 0; i < NUM_PEDTYPES; i++){ - ms_apPedType[i]->m_flag = *(uint32*)(buffer); - ms_apPedType[i]->unknown1 = *(float*)(buffer+4); - ms_apPedType[i]->unknown2 = *(float*)(buffer+8); - ms_apPedType[i]->unknown3 = *(float*)(buffer+12); - ms_apPedType[i]->unknown4 = *(float*)(buffer+16); - ms_apPedType[i]->unknown5 = *(float*)(buffer+20); - ms_apPedType[i]->m_threats = *(uint32*)(buffer+24); - ms_apPedType[i]->m_avoid = *(uint32*)(buffer+28); - buffer += 32; - } + for(int i = 0; i < NUM_PEDTYPES; i++) + *ms_apPedType[i] = ReadSaveBuf<CPedType>(buf); +VALIDATESAVEBUF(size) } STARTPATCHES |