summaryrefslogtreecommitdiffstats
path: root/src/peds
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/peds/Ped.cpp42
-rw-r--r--src/peds/Ped.h5
-rw-r--r--src/peds/PlayerPed.cpp37
-rw-r--r--src/peds/PlayerPed.h7
4 files changed, 91 insertions, 0 deletions
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 20fa93da..e7972541 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -17732,3 +17732,45 @@ CPed::SetExitBoat(CVehicle *boat)
// Not there in VC.
CWaterLevel::FreeBoatWakeArray();
}
+
+#ifdef COMPATIBLE_SAVES
+void
+CPed::Save(uint8*& buf)
+{
+ SkipSaveBuf(buf, 52);
+ WriteSaveBuf<float>(buf, GetPosition().x);
+ WriteSaveBuf<float>(buf, GetPosition().y);
+ WriteSaveBuf<float>(buf, GetPosition().z);
+ SkipSaveBuf(buf, 288);
+ WriteSaveBuf<uint8>(buf, CharCreatedBy);
+ SkipSaveBuf(buf, 351);
+ WriteSaveBuf<float>(buf, m_fHealth);
+ WriteSaveBuf<float>(buf, m_fArmour);
+ SkipSaveBuf(buf, 148);
+ for (int i = 0; i < 13; i++) // has to be hardcoded
+ m_weapons[i].Save(buf);
+ SkipSaveBuf(buf, 5);
+ WriteSaveBuf<uint8>(buf, m_maxWeaponTypeAllowed);
+ SkipSaveBuf(buf, 162);
+}
+
+void
+CPed::Load(uint8*& buf)
+{
+ SkipSaveBuf(buf, 52);
+ GetPosition().x = ReadSaveBuf<float>(buf);
+ GetPosition().y = ReadSaveBuf<float>(buf);
+ GetPosition().z = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 288);
+ CharCreatedBy = ReadSaveBuf<uint8>(buf);
+ SkipSaveBuf(buf, 351);
+ m_fHealth = ReadSaveBuf<float>(buf);
+ m_fArmour = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 148);
+ for (int i = 0; i < 13; i++) // has to be hardcoded
+ m_weapons[i].Load(buf);
+ SkipSaveBuf(buf, 5);
+ m_maxWeaponTypeAllowed = ReadSaveBuf<uint8>(buf);
+ SkipSaveBuf(buf, 162);
+}
+#endif
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index 91322151..9f105e7a 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -886,6 +886,11 @@ public:
#ifdef PED_SKIN
void renderLimb(int node);
#endif
+
+#ifdef COMPATIBLE_SAVES
+ virtual void Save(uint8*& buf);
+ virtual void Load(uint8*& buf);
+#endif
};
void FinishFuckUCB(CAnimBlendAssociation *assoc, void *arg);
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index dc44983d..6d0d394d 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -19,6 +19,13 @@
#define PAD_MOVE_TO_GAME_WORLD_MOVE 60.0f
+const uint32 CPlayerPed::nSaveStructSize =
+#ifdef COMPATIBLE_SAVES
+ 1520;
+#else
+ sizeof(CPlayerPed);
+#endif
+
CPlayerPed::~CPlayerPed()
{
delete m_pWanted;
@@ -1504,3 +1511,33 @@ CPlayerPed::ProcessControl(void)
UpdateRpHAnim();
#endif
}
+
+#ifdef COMPATIBLE_SAVES
+void
+CPlayerPed::Save(uint8*& buf)
+{
+ CPed::Save(buf);
+ SkipSaveBuf(buf, 16);
+ WriteSaveBuf<float>(buf, m_fMaxStamina);
+ SkipSaveBuf(buf, 28);
+ WriteSaveBuf<int32>(buf, m_nTargettableObjects[0]);
+ WriteSaveBuf<int32>(buf, m_nTargettableObjects[1]);
+ WriteSaveBuf<int32>(buf, m_nTargettableObjects[2]);
+ WriteSaveBuf<int32>(buf, m_nTargettableObjects[3]);
+ SkipSaveBuf(buf, 116);
+}
+
+void
+CPlayerPed::Load(uint8*& buf)
+{
+ CPed::Load(buf);
+ SkipSaveBuf(buf, 16);
+ m_fMaxStamina = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 28);
+ m_nTargettableObjects[0] = ReadSaveBuf<int32>(buf);
+ m_nTargettableObjects[1] = ReadSaveBuf<int32>(buf);
+ m_nTargettableObjects[2] = ReadSaveBuf<int32>(buf);
+ m_nTargettableObjects[3] = ReadSaveBuf<int32>(buf);
+ SkipSaveBuf(buf, 116);
+}
+#endif
diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h
index b8bd57e4..61b70f89 100644
--- a/src/peds/PlayerPed.h
+++ b/src/peds/PlayerPed.h
@@ -75,6 +75,13 @@ public:
static void SetupPlayerPed(int32);
static void DeactivatePlayerPed(int32);
static void ReactivatePlayerPed(int32);
+
+#ifdef COMPATIBLE_SAVES
+ virtual void Save(uint8*& buf);
+ virtual void Load(uint8*& buf);
+#endif
+
+ static const uint32 nSaveStructSize;
};
#ifndef PED_SKIN