summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2019-06-27 22:45:06 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2019-06-27 22:45:06 +0200
commit1c7fee4b9fc1684f83b62705573a34218b3159d3 (patch)
treeb39c31b36fd8a81bb6abf2c2089d2be5fefad86e /src
parentfixed newline (diff)
downloadre3-1c7fee4b9fc1684f83b62705573a34218b3159d3.tar
re3-1c7fee4b9fc1684f83b62705573a34218b3159d3.tar.gz
re3-1c7fee4b9fc1684f83b62705573a34218b3159d3.tar.bz2
re3-1c7fee4b9fc1684f83b62705573a34218b3159d3.tar.lz
re3-1c7fee4b9fc1684f83b62705573a34218b3159d3.tar.xz
re3-1c7fee4b9fc1684f83b62705573a34218b3159d3.tar.zst
re3-1c7fee4b9fc1684f83b62705573a34218b3159d3.zip
Diffstat (limited to 'src')
-rw-r--r--src/control/Gangs.cpp46
-rw-r--r--src/control/Gangs.h13
2 files changed, 35 insertions, 24 deletions
diff --git a/src/control/Gangs.cpp b/src/control/Gangs.cpp
index 2cb8a8a1..80ecd816 100644
--- a/src/control/Gangs.cpp
+++ b/src/control/Gangs.cpp
@@ -2,7 +2,7 @@
#include "patcher.h"
#include "Gangs.h"
-CGangInfo(&CGangs::Gang)[TOTAL_GANGS] = *(CGangInfo(*)[9])*(uintptr*)0x6EDF78;
+CGangInfo(&CGangs::Gang)[NUM_GANGS] = *(CGangInfo(*)[9])*(uintptr*)0x6EDF78;
void CGangs::Initialize(void)
{
@@ -41,23 +41,43 @@ int8 CGangs::GetGangPedModelOverride(int16 gang)
void CGangs::SaveAllGangData(uint8 *buffer, uint32 *size)
{
- tGangSaveData *data = (tGangSaveData*)buffer;
- data->tag[0] = 'G';
- data->tag[1] = 'N';
- data->tag[2] = 'G';
- data->tag[3] = '\0';
- data->size = *size = sizeof(tGangSaveData);
- for (int i = 0; i < TOTAL_GANGS; i++)
- data->gangs[i] = *GetGangInfo(i);
- buffer += sizeof(tGangSaveData);
+ buffer[0] = 'G';
+ buffer[1] = 'N';
+ buffer[2] = 'G';
+ buffer[3] = '\0';
+ *size = 8 + NUM_GANGS * 16;
+ *(uint32*)(buffer + 4) = *size - 8;
+ buffer += 8;
+ for (int i = 0; i < NUM_GANGS; i++) {
+ *(uint32*)(buffer) = GetGangInfo(i)->m_nVehicleMI;
+ *(int8*)(buffer + 4) = GetGangInfo(i)->m_nPedModelOverride;
+ *(int8*)(buffer + 5) = GetGangInfo(i)->field_5;
+ *(int16*)(buffer + 6) = GetGangInfo(i)->field_6;
+ *(eWeaponType*)(buffer + 8) = GetGangInfo(i)->m_Weapon1;
+ *(eWeaponType*)(buffer + 12) = GetGangInfo(i)->m_Weapon2;
+ buffer += 16;
+ }
}
void CGangs::LoadAllGangData(uint8 *buffer, uint32 size)
{
Initialize();
- tGangSaveData* data = (tGangSaveData*)buffer;
- for (int i = 0; i < TOTAL_GANGS; i++)
- *GetGangInfo(i) = data->gangs[i];
+ assert(size == 8 + NUM_GANGS * 16);
+ assert(buffer[0] == 'G');
+ assert(buffer[1] == 'N');
+ assert(buffer[2] == 'G');
+ assert(buffer[3] == '\0');
+ assert(*(uint32*)(buffer + 4) == size - 8);
+ buffer += 8;
+ for (int i = 0; i < NUM_GANGS; i++){
+ GetGangInfo(i)->m_nVehicleMI = *(uint32*)(buffer);
+ GetGangInfo(i)->m_nPedModelOverride = *(int8*)(buffer + 4);
+ GetGangInfo(i)->field_5 = *(int8*)(buffer + 5);
+ GetGangInfo(i)->field_6 = *(int16*)(buffer + 6);
+ GetGangInfo(i)->m_Weapon1 = *(eWeaponType*)(buffer + 8);
+ GetGangInfo(i)->m_Weapon2 = *(eWeaponType*)(buffer + 12);
+ buffer += 16;
+ }
}
STARTPATCHES
diff --git a/src/control/Gangs.h b/src/control/Gangs.h
index 96066a3e..db14ca64 100644
--- a/src/control/Gangs.h
+++ b/src/control/Gangs.h
@@ -36,7 +36,7 @@ public:
GANG_HOODS,
GANG_7,
GANG_8,
- TOTAL_GANGS
+ NUM_GANGS
};
static void Initialize(void);
static void SetGangVehicleModel(int16, int);
@@ -49,14 +49,5 @@ public:
private:
static CGangInfo* GetGangInfo(int16 gang) { return &Gang[gang]; }
- static CGangInfo(&Gang)[TOTAL_GANGS];
+ static CGangInfo(&Gang)[NUM_GANGS];
};
-
-struct tGangSaveData
-{
- char tag[4];
- int32 size;
- CGangInfo gangs[CGangs::TOTAL_GANGS];
-};
-
-static_assert(sizeof(tGangSaveData) == 0x98, "tGangSaveData: error");