summaryrefslogtreecommitdiffstats
path: root/src/peds
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/peds
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/peds/PedType.cpp57
-rw-r--r--src/peds/PedType.h4
2 files changed, 15 insertions, 46 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
diff --git a/src/peds/PedType.h b/src/peds/PedType.h
index 455d8d8d..9d284318 100644
--- a/src/peds/PedType.h
+++ b/src/peds/PedType.h
@@ -79,8 +79,8 @@ public:
static void LoadPedData(void);
static int32 FindPedType(char *type);
static uint32 FindPedFlag(char *type);
- static void Save(uint8 *buffer, uint32 *length);
- static void Load(uint8 *buffer, uint32 length);
+ static void Save(uint8 *buf, uint32 *size);
+ static void Load(uint8 *buf, uint32 size);
static uint32 GetFlag(int type) { return ms_apPedType[type]->m_flag; }
static uint32 GetAvoid(int type) { return ms_apPedType[type]->m_avoid; }