From 4fee2cbdd9948bd591d6e5bebd4bed827e12498a Mon Sep 17 00:00:00 2001 From: Wes Hampson Date: Thu, 5 Mar 2020 01:44:42 -0800 Subject: Begin work on GenericSave --- src/core/Radar.cpp | 4 ++-- src/core/Radar.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 6a1446da..3a706bad 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -946,9 +946,9 @@ void CRadar::RequestMapSection(int32 x, int32 y) #endif #if 1 -WRAPPER void CRadar::SaveAllRadarBlips(int32) { EAXJMP(0x4A6E30); } +WRAPPER void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size) { EAXJMP(0x4A6E30); } #else -void CRadar::SaveAllRadarBlips(int32) +void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size) { } diff --git a/src/core/Radar.h b/src/core/Radar.h index 650c6fb4..5b2174d7 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -130,7 +130,7 @@ public: static void RemoveRadarSections(); static void RemoveMapSection(int32 x, int32 y); static void RequestMapSection(int32 x, int32 y); - static void SaveAllRadarBlips(int32); + static void SaveAllRadarBlips(uint8 *buf, uint32 *size); static void SetBlipSprite(int32 i, int32 icon); static int32 SetCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay); static int32 SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay); -- cgit v1.2.3 From 28342405d37ae28fdf98546753e89d683480914f Mon Sep 17 00:00:00 2001 From: Wes Hampson Date: Tue, 10 Mar 2020 20:25:50 -0700 Subject: Add Load/Save functions --- src/core/Clock.h | 2 +- src/core/Pools.cpp | 39 +++++++++++++++++++++++---------------- src/core/Pools.h | 6 ++++++ src/core/Timer.h | 3 ++- 4 files changed, 32 insertions(+), 18 deletions(-) (limited to 'src/core') diff --git a/src/core/Clock.h b/src/core/Clock.h index ea4263bd..6b9908ba 100644 --- a/src/core/Clock.h +++ b/src/core/Clock.h @@ -2,6 +2,7 @@ class CClock { +public: static uint8 &ms_nGameClockHours; static uint8 &ms_nGameClockMinutes; static uint16 &ms_nGameClockSeconds; @@ -11,7 +12,6 @@ class CClock static uint32 &ms_nMillisecondsPerGameMinute; static uint32 &ms_nLastClockTick; static bool &ms_bClockHasBeenStored; -public: static void Initialise(uint32 scale); static void Update(void); diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index 8e66b049..75536b88 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -14,6 +14,13 @@ CObjectPool *&CPools::ms_pObjectPool = *(CObjectPool**)0x880E28; CDummyPool *&CPools::ms_pDummyPool = *(CDummyPool**)0x8F2C18; CAudioScriptObjectPool *&CPools::ms_pAudioScriptObjectPool = *(CAudioScriptObjectPool**)0x8F1B6C; +WRAPPER void CPools::LoadObjectPool(uint8* buf, uint32 size) { EAXJMP(0x4a2550); } +WRAPPER void CPools::LoadPedPool(uint8* buf, uint32 size) { EAXJMP(0x4a2b50); } +WRAPPER void CPools::LoadVehiclePool(uint8* buf, uint32 size) { EAXJMP(0x4a1b40); } +WRAPPER void CPools::SaveObjectPool(uint8* buf, uint32 *size) { EAXJMP(0x4a22d0); } +WRAPPER void CPools::SavePedPool(uint8* buf, uint32 *size) { EAXJMP(0x4a29b0); } +WRAPPER void CPools::SaveVehiclePool(uint8* buf, uint32 *size) { EAXJMP(0x4a2080); } + void CPools::Initialise(void) { @@ -30,16 +37,16 @@ CPools::Initialise(void) void CPools::ShutDown(void) -{ - debug("PtrNodes left %d\n", ms_pPtrNodePool->GetNoOfUsedSpaces()); - debug("EntryInfoNodes left %d\n", ms_pEntryInfoNodePool->GetNoOfUsedSpaces()); - debug("Peds left %d\n", ms_pPedPool->GetNoOfUsedSpaces()); - debug("Vehicles left %d\n", ms_pVehiclePool->GetNoOfUsedSpaces()); - debug("Buildings left %d\n", ms_pBuildingPool->GetNoOfUsedSpaces()); - debug("Treadables left %d\n", ms_pTreadablePool->GetNoOfUsedSpaces()); - debug("Objects left %d\n", ms_pObjectPool->GetNoOfUsedSpaces()); - debug("Dummys left %d\n", ms_pDummyPool->GetNoOfUsedSpaces()); - debug("AudioScriptObjects left %d\n", ms_pAudioScriptObjectPool->GetNoOfUsedSpaces()); +{ + debug("PtrNodes left %d\n", ms_pPtrNodePool->GetNoOfUsedSpaces()); + debug("EntryInfoNodes left %d\n", ms_pEntryInfoNodePool->GetNoOfUsedSpaces()); + debug("Peds left %d\n", ms_pPedPool->GetNoOfUsedSpaces()); + debug("Vehicles left %d\n", ms_pVehiclePool->GetNoOfUsedSpaces()); + debug("Buildings left %d\n", ms_pBuildingPool->GetNoOfUsedSpaces()); + debug("Treadables left %d\n", ms_pTreadablePool->GetNoOfUsedSpaces()); + debug("Objects left %d\n", ms_pObjectPool->GetNoOfUsedSpaces()); + debug("Dummys left %d\n", ms_pDummyPool->GetNoOfUsedSpaces()); + debug("AudioScriptObjects left %d\n", ms_pAudioScriptObjectPool->GetNoOfUsedSpaces()); printf("Shutdown pool started\n"); delete ms_pPtrNodePool; @@ -62,12 +69,12 @@ CVehicle *CPools::GetVehicle(int32 handle) { return ms_pVehiclePool->GetAt(handl int32 CPools::GetObjectRef(CObject *object) { return ms_pObjectPool->GetIndex(object); } CObject *CPools::GetObject(int32 handle) { return ms_pObjectPool->GetAt(handle); } -void -CPools::CheckPoolsEmpty() -{ - assert(ms_pPedPool->GetNoOfUsedSpaces() == 0); - assert(ms_pVehiclePool->GetNoOfUsedSpaces() == 0); - printf("pools have beem cleared \n"); +void +CPools::CheckPoolsEmpty() +{ + assert(ms_pPedPool->GetNoOfUsedSpaces() == 0); + assert(ms_pVehiclePool->GetNoOfUsedSpaces() == 0); + printf("pools have been cleared\n"); } diff --git a/src/core/Pools.h b/src/core/Pools.h index 862062ee..74b87585 100644 --- a/src/core/Pools.h +++ b/src/core/Pools.h @@ -52,4 +52,10 @@ public: static CObject *GetObject(int32 handle); static void CheckPoolsEmpty(); static void MakeSureSlotInObjectPoolIsEmpty(int32 slot); + static void LoadObjectPool(uint8 *buf, uint32 size); + static void LoadPedPool(uint8 *buf, uint32 size); + static void LoadVehiclePool(uint8 *buf, uint32 size); + static void SaveObjectPool(uint8 *buf, uint32 *size); + static void SavePedPool(uint8 *buf, uint32 *size); + static void SaveVehiclePool(uint8 *buf, uint32 *size); }; diff --git a/src/core/Timer.h b/src/core/Timer.h index 8f3b77c2..89c4a430 100644 --- a/src/core/Timer.h +++ b/src/core/Timer.h @@ -2,6 +2,7 @@ class CTimer { +public: static uint32 &m_snTimeInMilliseconds; static uint32 &m_snTimeInMillisecondsPauseMode; static uint32 &m_snTimeInMillisecondsNonClipped; @@ -12,7 +13,7 @@ class CTimer static float &ms_fTimeStepNonClipped; static bool &m_UserPause; static bool &m_CodePause; -public: + static float GetTimeStep(void) { return ms_fTimeStep; } static void SetTimeStep(float ts) { ms_fTimeStep = ts; } static float GetTimeStepInSeconds() { return ms_fTimeStep / 50.0f; } -- cgit v1.2.3 From c7f16879df25fc962b67716e1f82881595451a5f Mon Sep 17 00:00:00 2001 From: Wes Hampson Date: Wed, 11 Mar 2020 00:12:40 -0700 Subject: GenericSave complete, still needs some testing --- src/core/Stats.cpp | 3 +++ src/core/Stats.h | 1 + src/core/common.h | 8 ++++---- src/core/re3.cpp | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp index 2c27ba70..1d088e04 100644 --- a/src/core/Stats.cpp +++ b/src/core/Stats.cpp @@ -1,6 +1,9 @@ #include "common.h" +#include "patcher.h" #include "Stats.h" +WRAPPER void CStats::SaveStats(uint8 *buf, uint32 *size) { EAXJMP(0x4ab3e0); } + int32 &CStats::DaysPassed = *(int32*)0x8F2BB8; int32 &CStats::HeadsPopped = *(int32*)0x8F647C; bool& CStats::CommercialPassed = *(bool*)0x8F4334; diff --git a/src/core/Stats.h b/src/core/Stats.h index 4b558c32..7ee4aed0 100644 --- a/src/core/Stats.h +++ b/src/core/Stats.h @@ -73,4 +73,5 @@ public: static void CheckPointReachedUnsuccessfully() { KillsSinceLastCheckpoint = 0; }; static void CheckPointReachedSuccessfully() { TotalLegitimateKills += KillsSinceLastCheckpoint; KillsSinceLastCheckpoint = 0; }; static void RegisterElBurroTime(int32); + static void SaveStats(uint8 *buf, uint32 *size); }; \ No newline at end of file diff --git a/src/core/common.h b/src/core/common.h index cadcac1d..9a5cdb38 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -321,9 +321,9 @@ _TWEEKCLASS(CTweakFloat, float); #undef _TWEEKCLASS #ifdef VALIDATE_SAVE_SIZE -extern int32 _bufBytesRead; -#define INITSAVEBUF _bufBytesRead = 0; -#define VALIDATESAVEBUF(b) assert(_bufBytesRead == b); +extern int32 _saveBufCount; +#define INITSAVEBUF _saveBufCount = 0; +#define VALIDATESAVEBUF(b) assert(_saveBufCount == b); #else #define INITSAVEBUF #define VALIDATESAVEBUF(b) @@ -333,7 +333,7 @@ inline void SkipSaveBuf(uint8 *&buf, int32 skip) { buf += skip; #ifdef VALIDATE_SAVE_SIZE - _bufBytesRead += skip; + _saveBufCount += skip; #endif } diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 989a05b5..ed32632f 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -449,7 +449,7 @@ void re3_trace(const char *filename, unsigned int lineno, const char *func, cons } #ifdef VALIDATE_SAVE_SIZE -int32 _bufBytesRead; +int32 _saveBufCount; #endif void -- cgit v1.2.3 From 018fb3a9298c8c549745ad5af9fb708ef7b8cb41 Mon Sep 17 00:00:00 2001 From: Wes Hampson Date: Wed, 11 Mar 2020 14:15:27 -0700 Subject: Style fixes --- src/core/Stats.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Stats.h b/src/core/Stats.h index 7ee4aed0..4bf99c45 100644 --- a/src/core/Stats.h +++ b/src/core/Stats.h @@ -74,4 +74,4 @@ public: static void CheckPointReachedSuccessfully() { TotalLegitimateKills += KillsSinceLastCheckpoint; KillsSinceLastCheckpoint = 0; }; static void RegisterElBurroTime(int32); static void SaveStats(uint8 *buf, uint32 *size); -}; \ No newline at end of file +}; -- cgit v1.2.3 From 8280dda9cba53608be137a7e6a82ea45aca339c4 Mon Sep 17 00:00:00 2001 From: Wes Hampson Date: Fri, 13 Mar 2020 13:46:59 -0700 Subject: Add CTimeStep --- src/core/TimeStep.cpp | 5 +++++ src/core/TimeStep.h | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 src/core/TimeStep.cpp create mode 100644 src/core/TimeStep.h (limited to 'src/core') diff --git a/src/core/TimeStep.cpp b/src/core/TimeStep.cpp new file mode 100644 index 00000000..9ccf7200 --- /dev/null +++ b/src/core/TimeStep.cpp @@ -0,0 +1,5 @@ +#include "TimeStep.h" + +float &CTimeStep::ms_fTimeScale = *(float*)0x5F76C8; +float &CTimeStep::ms_fFramesPerUpdate = *(float*)0x5F76CC; +float &CTimeStep::ms_fTimeStep = *(float*)0x5F76D0; diff --git a/src/core/TimeStep.h b/src/core/TimeStep.h new file mode 100644 index 00000000..ee595383 --- /dev/null +++ b/src/core/TimeStep.h @@ -0,0 +1,10 @@ +#pragma once + +// Pretty sure this class is not used by the game +class CTimeStep +{ +public: + static float &ms_fTimeScale; + static float &ms_fFramesPerUpdate; + static float &ms_fTimeStep; +}; \ No newline at end of file -- cgit v1.2.3 From afeac5486046a4db987f2572264ed13eac1b2de2 Mon Sep 17 00:00:00 2001 From: Wes Hampson Date: Fri, 13 Mar 2020 13:50:23 -0700 Subject: Spacing fix --- src/core/TimeStep.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/TimeStep.h b/src/core/TimeStep.h index ee595383..c74df02a 100644 --- a/src/core/TimeStep.h +++ b/src/core/TimeStep.h @@ -4,7 +4,7 @@ class CTimeStep { public: - static float &ms_fTimeScale; - static float &ms_fFramesPerUpdate; + static float &ms_fTimeScale; + static float &ms_fFramesPerUpdate; static float &ms_fTimeStep; -}; \ No newline at end of file +}; -- cgit v1.2.3