commit
1ab6702ea6
@ -3,6 +3,8 @@
|
||||
#include "AudioScriptObject.h"
|
||||
#include "Pools.h"
|
||||
|
||||
WRAPPER void cAudioScriptObject::SaveAllAudioScriptObjects(uint8 *buf, uint32 *size) { EAXJMP(0x57c460); }
|
||||
|
||||
void
|
||||
cAudioScriptObject::Reset()
|
||||
{
|
||||
|
@ -141,6 +141,8 @@ public:
|
||||
static void* operator new(size_t, int);
|
||||
static void operator delete(void*, size_t);
|
||||
static void operator delete(void*, int);
|
||||
|
||||
static void SaveAllAudioScriptObjects(uint8 *buf, uint32 *size);
|
||||
};
|
||||
|
||||
static_assert(sizeof(cAudioScriptObject) == 20, "cAudioScriptObject: error");
|
||||
|
@ -10,3 +10,5 @@ WRAPPER void CCranes::ActivateCrane(float, float, float, float, float, float, fl
|
||||
WRAPPER void CCranes::DeActivateCrane(float, float) { EAXJMP(0x543890); }
|
||||
WRAPPER void CCranes::InitCranes(void) { EAXJMP(0x543360); }
|
||||
WRAPPER void CCranes::UpdateCranes(void) { EAXJMP(0x5439E0); }
|
||||
WRAPPER void CCranes::Save(uint8*, uint32*) { EAXJMP(0x545210); }
|
||||
WRAPPER void CranesLoad(uint8*, uint32) { EAXJMP(0x5454d0); }
|
||||
|
@ -14,4 +14,7 @@ public:
|
||||
static void DeActivateCrane(float, float);
|
||||
static void InitCranes(void);
|
||||
static void UpdateCranes(void);
|
||||
static void Save(uint8*, uint32*);
|
||||
};
|
||||
|
||||
void CranesLoad(uint8*, uint32); // is this really outside CCranes?
|
||||
|
@ -31,6 +31,8 @@ CGarage(&CGarages::Garages)[NUM_GARAGES] = *(CGarage(*)[NUM_GARAGES])(uintptr*)0
|
||||
|
||||
WRAPPER void CGarages::Init(void) { EAXJMP(0x421C60); }
|
||||
WRAPPER void CGarages::Update(void) { EAXJMP(0x421E40); }
|
||||
WRAPPER void CGarages::Load(uint8* buf, uint32 size) { EAXJMP(0x428940); }
|
||||
WRAPPER void CGarages::Save(uint8* buf, uint32 *size) { EAXJMP(0x4284e0); }
|
||||
|
||||
bool
|
||||
CGarages::IsModelIndexADoor(uint32 id)
|
||||
|
@ -147,6 +147,8 @@ public:
|
||||
static void PlayerArrestedOrDied();
|
||||
static void Init(void);
|
||||
static void Update(void);
|
||||
static void Load(uint8 *buf, uint32 size);
|
||||
static void Save(uint8 *buf, uint32 *size);
|
||||
static int16 AddOne(float, float, float, float, float, float, uint8, uint32);
|
||||
static void SetTargetCarForMissonGarage(int16, CVehicle*);
|
||||
static bool HasCarBeenDroppedOffYet(int16);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
@ -67,7 +74,7 @@ CPools::CheckPoolsEmpty()
|
||||
{
|
||||
assert(ms_pPedPool->GetNoOfUsedSpaces() == 0);
|
||||
assert(ms_pVehiclePool->GetNoOfUsedSpaces() == 0);
|
||||
printf("pools have beem cleared \n");
|
||||
printf("pools have been cleared\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
};
|
5
src/core/TimeStep.cpp
Normal file
5
src/core/TimeStep.cpp
Normal file
@ -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;
|
10
src/core/TimeStep.h
Normal file
10
src/core/TimeStep.h
Normal file
@ -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;
|
||||
};
|
@ -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; }
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,21 +1,40 @@
|
||||
#include "common.h"
|
||||
#include "main.h"
|
||||
#include "patcher.h"
|
||||
#include "AudioScriptObject.h"
|
||||
#include "Camera.h"
|
||||
#include "CarGen.h"
|
||||
#include "Cranes.h"
|
||||
#include "Clock.h"
|
||||
#include "Date.h"
|
||||
#include "FileMgr.h"
|
||||
#include "GameLogic.h"
|
||||
#include "Gangs.h"
|
||||
#include "Garages.h"
|
||||
#include "GenericGameStorage.h"
|
||||
#include "Pad.h"
|
||||
#include "ParticleObject.h"
|
||||
#include "PathFind.h"
|
||||
#include "PCSave.h"
|
||||
#include "Phones.h"
|
||||
#include "Pickups.h"
|
||||
#include "PlayerPed.h"
|
||||
#include "Pools.h"
|
||||
#include "Radar.h"
|
||||
#include "Restart.h"
|
||||
#include "Script.h"
|
||||
#include "Stats.h"
|
||||
#include "Streaming.h"
|
||||
#include "Timer.h"
|
||||
#include "TimeStep.h"
|
||||
#include "Weather.h"
|
||||
#include "World.h"
|
||||
#include "Zones.h"
|
||||
|
||||
const int SIZE_OF_ONE_GAME_IN_BYTES = 201729;
|
||||
#define BLOCK_COUNT 20
|
||||
#define SIZE_OF_SIMPLEVARS 0xBC
|
||||
|
||||
const uint32 SIZE_OF_ONE_GAME_IN_BYTES = 201729;
|
||||
|
||||
char (&DefaultPCSaveFileName)[260] = *(char(*)[260])*(uintptr*)0x8E28C0;
|
||||
char (&ValidSaveName)[260] = *(char(*)[260])*(uintptr*)0x8E2CBC;
|
||||
@ -31,9 +50,152 @@ CDate &CompileDateAndTime = *(CDate*)0x72BCB8;
|
||||
#define ReadDataFromBufferPointer(buf, to) memcpy(&to, buf, sizeof(to)); buf += align4bytes(sizeof(to));
|
||||
#define WriteDataToBufferPointer(buf, from) memcpy(buf, &from, sizeof(from)); buf += align4bytes(sizeof(from));
|
||||
|
||||
WRAPPER bool GenericSave(int file) { EAXJMP(0x58F8D0); }
|
||||
//WRAPPER bool GenericSave(int file) { EAXJMP(0x58F8D0); }
|
||||
WRAPPER bool GenericLoad() { EAXJMP(0x590A00); }
|
||||
|
||||
|
||||
#define WRITE_BLOCK(save_func)\
|
||||
do {\
|
||||
buf = work_buff;\
|
||||
reserved = 0;\
|
||||
MakeSpaceForSizeInBufferPointer(presize, buf, postsize);\
|
||||
save_func(buf, &size);\
|
||||
CopySizeAndPreparePointer(presize, buf, postsize, reserved, size);\
|
||||
if (!PcSaveHelper.PcClassSaveRoutine(file, work_buff, size + 4))\
|
||||
return false;\
|
||||
totalSize += size;\
|
||||
} while (0)
|
||||
|
||||
bool
|
||||
GenericSave(int file)
|
||||
{
|
||||
uint8 *buf, *presize, *postsize;
|
||||
uint32 size;
|
||||
uint32 reserved;
|
||||
|
||||
uint32 totalSize;
|
||||
uint32 i;
|
||||
|
||||
wchar *lastMissionPassed;
|
||||
wchar suffix[6];
|
||||
wchar saveName[24];
|
||||
SYSTEMTIME saveTime;
|
||||
CPad *currPad;
|
||||
|
||||
CheckSum = 0;
|
||||
buf = work_buff;
|
||||
reserved = 0;
|
||||
totalSize = 0;
|
||||
|
||||
// Save simple vars
|
||||
INITSAVEBUF
|
||||
lastMissionPassed = TheText.Get(CStats::LastMissionPassedName);
|
||||
if (*lastMissionPassed) {
|
||||
AsciiToUnicode("'...", suffix);
|
||||
TextCopy(saveName, lastMissionPassed);
|
||||
int len = UnicodeStrlen(saveName);
|
||||
saveName[len] = '\0';
|
||||
if (len > 22)
|
||||
TextCopy(saveName + 18, suffix);
|
||||
saveName[23] = '\0';
|
||||
}
|
||||
WriteDataToBufferPointer(buf, saveName);
|
||||
GetLocalTime(&saveTime);
|
||||
WriteDataToBufferPointer(buf, saveTime);
|
||||
WriteDataToBufferPointer(buf, SIZE_OF_ONE_GAME_IN_BYTES);
|
||||
WriteDataToBufferPointer(buf, CGame::currLevel);
|
||||
WriteDataToBufferPointer(buf, TheCamera.m_matrix.m_matrix.pos.x);
|
||||
WriteDataToBufferPointer(buf, TheCamera.m_matrix.m_matrix.pos.y);
|
||||
WriteDataToBufferPointer(buf, TheCamera.m_matrix.m_matrix.pos.z);
|
||||
WriteDataToBufferPointer(buf, CClock::ms_nMillisecondsPerGameMinute);
|
||||
WriteDataToBufferPointer(buf, CClock::ms_nLastClockTick);
|
||||
WriteDataToBufferPointer(buf, CClock::ms_nGameClockHours);
|
||||
WriteDataToBufferPointer(buf, CClock::ms_nGameClockMinutes);
|
||||
currPad = CPad::GetPad(0);
|
||||
WriteDataToBufferPointer(buf, currPad->Mode);
|
||||
WriteDataToBufferPointer(buf, CTimer::m_snTimeInMilliseconds);
|
||||
WriteDataToBufferPointer(buf, CTimer::ms_fTimeScale);
|
||||
WriteDataToBufferPointer(buf, CTimer::ms_fTimeStep);
|
||||
WriteDataToBufferPointer(buf, CTimer::ms_fTimeStepNonClipped);
|
||||
WriteDataToBufferPointer(buf, CTimer::m_FrameCounter);
|
||||
WriteDataToBufferPointer(buf, CTimeStep::ms_fTimeStep);
|
||||
WriteDataToBufferPointer(buf, CTimeStep::ms_fFramesPerUpdate);
|
||||
WriteDataToBufferPointer(buf, CTimeStep::ms_fTimeScale);
|
||||
WriteDataToBufferPointer(buf, CWeather::OldWeatherType);
|
||||
WriteDataToBufferPointer(buf, CWeather::NewWeatherType);
|
||||
WriteDataToBufferPointer(buf, CWeather::ForcedWeatherType);
|
||||
WriteDataToBufferPointer(buf, CWeather::InterpolationValue);
|
||||
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nSecond);
|
||||
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nMinute);
|
||||
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nHour);
|
||||
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nDay);
|
||||
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nMonth);
|
||||
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nYear);
|
||||
WriteDataToBufferPointer(buf, CWeather::WeatherTypeInList);
|
||||
WriteDataToBufferPointer(buf, TheCamera.CarZoomIndicator);
|
||||
WriteDataToBufferPointer(buf, TheCamera.PedZoomIndicator);
|
||||
#ifdef VALIDATE_SAVE_SIZE
|
||||
_saveBufCount = buf - work_buff;
|
||||
#endif
|
||||
VALIDATESAVEBUF(SIZE_OF_SIMPLEVARS);
|
||||
|
||||
// Save scripts, block is nested within the same block as simple vars for some reason
|
||||
presize = buf;
|
||||
buf += 4;
|
||||
postsize = buf;
|
||||
CTheScripts::SaveAllScripts(buf, &size);
|
||||
CopySizeAndPreparePointer(presize, buf, postsize, reserved, size);
|
||||
if (!PcSaveHelper.PcClassSaveRoutine(file, work_buff, size + SIZE_OF_SIMPLEVARS + 4))
|
||||
return false;
|
||||
totalSize += size + SIZE_OF_SIMPLEVARS;
|
||||
|
||||
// Save the rest
|
||||
WRITE_BLOCK(CPools::SavePedPool);
|
||||
WRITE_BLOCK(CGarages::Save);
|
||||
WRITE_BLOCK(CPools::SaveVehiclePool);
|
||||
WRITE_BLOCK(CPools::SaveObjectPool);
|
||||
WRITE_BLOCK(ThePaths.Save);
|
||||
WRITE_BLOCK(CCranes::Save);
|
||||
WRITE_BLOCK(CPickups::Save);
|
||||
WRITE_BLOCK(gPhoneInfo.Save);
|
||||
WRITE_BLOCK(CRestart::SaveAllRestartPoints);
|
||||
WRITE_BLOCK(CRadar::SaveAllRadarBlips);
|
||||
WRITE_BLOCK(CTheZones::SaveAllZones);
|
||||
WRITE_BLOCK(CGangs::SaveAllGangData);
|
||||
WRITE_BLOCK(CTheCarGenerators::SaveAllCarGenerators);
|
||||
WRITE_BLOCK(CParticleObject::SaveParticle);
|
||||
WRITE_BLOCK(cAudioScriptObject::SaveAllAudioScriptObjects);
|
||||
WRITE_BLOCK(CWorld::Players[CWorld::PlayerInFocus].SavePlayerInfo);
|
||||
WRITE_BLOCK(CStats::SaveStats);
|
||||
WRITE_BLOCK(CStreaming::MemoryCardSave);
|
||||
WRITE_BLOCK(CPedType::Save);
|
||||
|
||||
// Write padding
|
||||
i = 0;
|
||||
do {
|
||||
size = align4bytes(SIZE_OF_ONE_GAME_IN_BYTES - totalSize - 4);
|
||||
if (size > sizeof(work_buff))
|
||||
size = sizeof(work_buff);
|
||||
if (size > 4) {
|
||||
if (!PcSaveHelper.PcClassSaveRoutine(file, work_buff, size))
|
||||
return false;
|
||||
totalSize += size;
|
||||
}
|
||||
i++;
|
||||
} while (i < 4);
|
||||
|
||||
// Write checksum and close
|
||||
CFileMgr::Write(file, (const char *) &CheckSum, sizeof(CheckSum));
|
||||
if (CFileMgr::GetErrorReadWrite(file)) {
|
||||
PcSaveHelper.nErrorCode = SAVESTATUS_ERR_SAVE_WRITE;
|
||||
if (CloseFile(file))
|
||||
PcSaveHelper.nErrorCode = SAVESTATUS_ERR_SAVE_CLOSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ReadInSizeofSaveFileBuffer(int32 &file, uint32 &size)
|
||||
{
|
||||
@ -246,7 +408,7 @@ align4bytes(int32 size)
|
||||
}
|
||||
|
||||
STARTPATCHES
|
||||
//InjectHook(0x58F8D0, GenericSave, PATCH_JUMP);
|
||||
InjectHook(0x58F8D0, GenericSave, PATCH_JUMP);
|
||||
//InjectHook(0x590A00, GenericLoad, PATCH_JUMP);
|
||||
InjectHook(0x591910, ReadInSizeofSaveFileBuffer, PATCH_JUMP);
|
||||
InjectHook(0x591990, ReadDataFromFile, PATCH_JUMP);
|
||||
|
Loading…
Reference in New Issue
Block a user