1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-18 04:37:45 +00:00

Reactivated Store(Restore)StuffIn(From)Mem, fixed bugs

This commit is contained in:
Nikolay Korolev 2019-06-30 16:20:11 +03:00
parent e2bd3573b4
commit 90bcb888e8
7 changed files with 42 additions and 38 deletions

View file

@ -1736,8 +1736,6 @@ CColModel::operator=(const CColModel &other)
int i; int i;
int numVerts; int numVerts;
assert(0);
boundingSphere = other.boundingSphere; boundingSphere = other.boundingSphere;
boundingBox = other.boundingBox; boundingBox = other.boundingBox;

View file

@ -47,13 +47,13 @@ uint8 *&CReplay::pBuf8 = *(uint8**)0x8E2C54;
CEntryInfoNode *&CReplay::pBuf9 = *(CEntryInfoNode**)0x8E2C58; CEntryInfoNode *&CReplay::pBuf9 = *(CEntryInfoNode**)0x8E2C58;
uint8 *&CReplay::pBuf10 = *(uint8**)0x8F2C28; uint8 *&CReplay::pBuf10 = *(uint8**)0x8F2C28;
CDummyPed *&CReplay::pBuf11 = *(CDummyPed**)0x8F2C2C; CDummyPed *&CReplay::pBuf11 = *(CDummyPed**)0x8F2C2C;
CBlip *&CReplay::pRadarBlips = *(CBlip**)0x8F29F8; uint8 *&CReplay::pRadarBlips = *(uint8**)0x8F29F8;
CCamera *&CReplay::pStoredCam = *(CCamera**)0x8F2C34; uint8 *&CReplay::pStoredCam = *(uint8**)0x8F2C34;
CSector *&CReplay::pWorld1 = *(CSector**)0x8E29C4; uint8 *&CReplay::pWorld1 = *(uint8**)0x8E29C4;
CReference *&CReplay::pEmptyReferences = *(CReference**)0x8F256C; CReference *&CReplay::pEmptyReferences = *(CReference**)0x8F256C;
CStoredDetailedAnimationState *&CReplay::pPedAnims = *(CStoredDetailedAnimationState**)0x8F6260; CStoredDetailedAnimationState *&CReplay::pPedAnims = *(CStoredDetailedAnimationState**)0x8F6260;
CPickup *&CReplay::pPickups = *(CPickup**)0x8F1A48; uint8 *&CReplay::pPickups = *(uint8**)0x8F1A48;
CReference *&CReplay::pReferences = *(CReference**)0x880FAC; uint8 *&CReplay::pReferences = *(uint8**)0x880FAC;
uint8(&CReplay::BufferStatus)[8] = *(uint8(*)[8])*(uintptr*)0x8804D8; uint8(&CReplay::BufferStatus)[8] = *(uint8(*)[8])*(uintptr*)0x8804D8;
uint8(&CReplay::Buffers)[8][100000] = *(uint8(*)[8][100000])*(uintptr*)0x779958; uint8(&CReplay::Buffers)[8][100000] = *(uint8(*)[8][100000])*(uintptr*)0x779958;
bool &CReplay::bPlayingBackFromFile = *(bool*)0x95CD58; bool &CReplay::bPlayingBackFromFile = *(bool*)0x95CD58;
@ -988,7 +988,7 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca
} }
#endif #endif
#if 1 #if 0
WRAPPER void CReplay::StoreStuffInMem(void) { EAXJMP(0x5961F0); } WRAPPER void CReplay::StoreStuffInMem(void) { EAXJMP(0x5961F0); }
#else #else
void CReplay::StoreStuffInMem(void) void CReplay::StoreStuffInMem(void)
@ -999,19 +999,19 @@ void CReplay::StoreStuffInMem(void)
CPools::GetPtrNodePool()->Store(pBuf6, pBuf7); CPools::GetPtrNodePool()->Store(pBuf6, pBuf7);
CPools::GetEntryInfoNodePool()->Store(pBuf8, pBuf9); CPools::GetEntryInfoNodePool()->Store(pBuf8, pBuf9);
CPools::GetDummyPool()->Store(pBuf10, pBuf11); CPools::GetDummyPool()->Store(pBuf10, pBuf11);
pWorld1 = (CSector*)malloc(sizeof(CSector) * NUMSECTORS_X * NUMSECTORS_Y); pWorld1 = new uint8[sizeof(CSector) * NUMSECTORS_X * NUMSECTORS_Y];
memcpy(pWorld1, CWorld::GetSector(0, 0), NUMSECTORS_X * NUMSECTORS_Y * sizeof(CSector)); memcpy(pWorld1, CWorld::GetSector(0, 0), NUMSECTORS_X * NUMSECTORS_Y * sizeof(CSector));
WorldPtrList = CWorld::GetMovingEntityList(); /* Interesting way to copy a list... */ WorldPtrList = CWorld::GetMovingEntityList();
BigBuildingPtrList = CWorld::GetBigBuildingList(LEVEL_NONE); BigBuildingPtrList = CWorld::GetBigBuildingList(LEVEL_NONE);
pPickups = (CPickup*)malloc(sizeof(CPickup) * NUMPICKUPS); pPickups = new uint8[sizeof(CPickup) * NUMPICKUPS];
memcpy(pPickups, CPickups::aPickUps, NUMPICKUPS * sizeof(CPickup)); memcpy(pPickups, CPickups::aPickUps, NUMPICKUPS * sizeof(CPickup));
pReferences = (CReference*)malloc(sizeof(CReference) * NUMREFERENCES); pReferences = new uint8[(sizeof(CReference) * NUMREFERENCES)];
memcpy(pReferences, CReferences::aRefs, NUMREFERENCES * sizeof(CReference)); memcpy(pReferences, CReferences::aRefs, NUMREFERENCES * sizeof(CReference));
pEmptyReferences = CReferences::pEmptyList; pEmptyReferences = CReferences::pEmptyList;
pStoredCam = (CCamera*)malloc(sizeof(CCamera)); pStoredCam = new uint8[sizeof(CCamera)];
memcpy(pStoredCam, &TheCamera, sizeof(CCamera)); memcpy(pStoredCam, &TheCamera, sizeof(CCamera));
pRadarBlips = (CBlip*)malloc(sizeof(CBlip) * NUMBLIPS); pRadarBlips = new uint8[sizeof(CBlip) * NUMRADARBLIPS];
memcpy(pRadarBlips, CRadar::ms_RadarTrace, NUMBLIPS * sizeof(CBlip)); memcpy(pRadarBlips, CRadar::ms_RadarTrace, NUMRADARBLIPS * sizeof(CBlip));
PlayerWanted = *FindPlayerPed()->m_pWanted; PlayerWanted = *FindPlayerPed()->m_pWanted;
PlayerInfo = CWorld::Players[0]; PlayerInfo = CWorld::Players[0];
Time1 = CTimer::GetTimeInMilliseconds(); Time1 = CTimer::GetTimeInMilliseconds();
@ -1037,7 +1037,7 @@ void CReplay::StoreStuffInMem(void)
} }
#endif #endif
#if 1 #if 0
WRAPPER void CReplay::RestoreStuffFromMem(void) { EAXJMP(0x5966E0); } WRAPPER void CReplay::RestoreStuffFromMem(void) { EAXJMP(0x5966E0); }
#else #else
void CReplay::RestoreStuffFromMem(void) void CReplay::RestoreStuffFromMem(void)
@ -1049,28 +1049,28 @@ void CReplay::RestoreStuffFromMem(void)
CPools::GetEntryInfoNodePool()->CopyBack(pBuf8, pBuf9); CPools::GetEntryInfoNodePool()->CopyBack(pBuf8, pBuf9);
CPools::GetDummyPool()->CopyBack(pBuf10, pBuf11); CPools::GetDummyPool()->CopyBack(pBuf10, pBuf11);
memcpy(CWorld::GetSector(0, 0), pWorld1, sizeof(CSector) * NUMSECTORS_X * NUMSECTORS_Y); memcpy(CWorld::GetSector(0, 0), pWorld1, sizeof(CSector) * NUMSECTORS_X * NUMSECTORS_Y);
free(pWorld1); delete[] pWorld1;
pWorld1 = nil; pWorld1 = nil;
CWorld::GetMovingEntityList() = WorldPtrList; CWorld::GetMovingEntityList() = WorldPtrList;
CWorld::GetBigBuildingList(LEVEL_NONE) = BigBuildingPtrList; CWorld::GetBigBuildingList(LEVEL_NONE) = BigBuildingPtrList;
memcpy(CPickups::aPickUps, pPickups, sizeof(CPickup) * NUMPICKUPS); memcpy(CPickups::aPickUps, pPickups, sizeof(CPickup) * NUMPICKUPS);
free(pPickups); delete[] pPickups;
pPickups = nil; pPickups = nil;
memcpy(CReferences::aRefs, pReferences, sizeof(CReference) * NUMREFERENCES); memcpy(CReferences::aRefs, pReferences, sizeof(CReference) * NUMREFERENCES);
free(pReferences); delete[] pReferences;
pReferences = nil; pReferences = nil;
CReferences::pEmptyList = pEmptyReferences; CReferences::pEmptyList = pEmptyReferences;
pEmptyReferences = nil; pEmptyReferences = nil;
memcpy(&TheCamera, pStoredCam, sizeof(CCamera)); memcpy(&TheCamera, pStoredCam, sizeof(CCamera));
free(pStoredCam); delete[] pStoredCam;
pStoredCam = nil; pStoredCam = nil;
memcpy(CRadar::ms_RadarTrace, pRadarBlips, sizeof(CBlip) * NUMBLIPS); memcpy(CRadar::ms_RadarTrace, pRadarBlips, sizeof(CBlip) * NUMRADARBLIPS);
free(pRadarBlips); delete[] pRadarBlips;
pRadarBlips = nil; pRadarBlips = nil;
FindPlayerPed()->m_pWanted = new CWanted(PlayerWanted); /* Nice memory leak */ FindPlayerPed()->m_pWanted = new CWanted(PlayerWanted); /* Nice memory leak */
CWorld::Players[0] = PlayerInfo; CWorld::Players[0] = PlayerInfo;
int size = CPools::GetPedPool()->GetSize(); int i = CPools::GetPedPool()->GetSize();
for (int i = size - 1; i >= 0; i--){ while (--i){
CPed* ped = CPools::GetPedPool()->GetSlot(i); CPed* ped = CPools::GetPedPool()->GetSlot(i);
if (!ped) if (!ped)
continue; continue;
@ -1087,8 +1087,8 @@ void CReplay::RestoreStuffFromMem(void)
if (ped->m_wepModelID >= 0) if (ped->m_wepModelID >= 0)
ped->AddWeaponModel(ped->m_wepModelID); ped->AddWeaponModel(ped->m_wepModelID);
} }
size = CPools::GetVehiclePool()->GetSize(); i = CPools::GetVehiclePool()->GetSize();
for (int i = size - 1; i >= 0; i--) { while (--i){
CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i); CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!vehicle) if (!vehicle)
continue; continue;
@ -1146,8 +1146,8 @@ void CReplay::RestoreStuffFromMem(void)
} }
} }
PrintElementsInPtrList(); PrintElementsInPtrList();
size = CPools::GetObjectPool()->GetSize(); i = CPools::GetObjectPool()->GetSize();
for (int i = size - 1; i >= 0; i--) { while (--i){
CObject* object = CPools::GetObjectPool()->GetSlot(i); CObject* object = CPools::GetObjectPool()->GetSlot(i);
if (!object) if (!object)
continue; continue;
@ -1161,8 +1161,8 @@ void CReplay::RestoreStuffFromMem(void)
if (RwObjectGetType(object->m_rwObject) == rpATOMIC) if (RwObjectGetType(object->m_rwObject) == rpATOMIC)
object->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame(object->m_rwObject)), false); object->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame(object->m_rwObject)), false);
} }
size = CPools::GetDummyPool()->GetSize(); i = CPools::GetDummyPool()->GetSize();
for (int i = size - 1; i >= 0; i--) { while (--i){
CDummy* dummy = CPools::GetDummyPool()->GetSlot(i); CDummy* dummy = CPools::GetDummyPool()->GetSlot(i);
if (!dummy) if (!dummy)
continue; continue;
@ -1188,8 +1188,7 @@ void CReplay::RestoreStuffFromMem(void)
CWeather::OldWeatherType = OldWeatherType; CWeather::OldWeatherType = OldWeatherType;
CWeather::NewWeatherType = NewWeatherType; CWeather::NewWeatherType = NewWeatherType;
CWeather::InterpolationValue = WeatherInterpolationValue; CWeather::InterpolationValue = WeatherInterpolationValue;
size = CPools::GetPedPool()->GetSize(); for (int i = 0; i < CPools::GetPedPool()->GetSize(); i++) {
for (int i = 0; i < size; i++) {
CPed* ped = CPools::GetPedPool()->GetSlot(i); CPed* ped = CPools::GetPedPool()->GetSlot(i);
if (!ped) if (!ped)
continue; continue;
@ -1236,9 +1235,10 @@ InjectHook(0x592FE0, CReplay::Init, PATCH_JUMP);
InjectHook(0x593150, CReplay::DisableReplays, PATCH_JUMP); InjectHook(0x593150, CReplay::DisableReplays, PATCH_JUMP);
InjectHook(0x593160, CReplay::EnableReplays, PATCH_JUMP); InjectHook(0x593160, CReplay::EnableReplays, PATCH_JUMP);
InjectHook(0x593170, CReplay::Update, PATCH_JUMP); InjectHook(0x593170, CReplay::Update, PATCH_JUMP);
InjectHook(0x595B20, CReplay::FinishPlayback, PATCH_JUMP);
InjectHook(0x594050, CReplay::ProcessPedUpdate, PATCH_JUMP); InjectHook(0x594050, CReplay::ProcessPedUpdate, PATCH_JUMP);
InjectHook(0x594D10, CReplay::ProcessCarUpdate, PATCH_JUMP); InjectHook(0x594D10, CReplay::ProcessCarUpdate, PATCH_JUMP);
InjectHook(0x593BB0, CReplay::StoreDetailedPedAnimation, PATCH_JUMP); InjectHook(0x593BB0, CReplay::StoreDetailedPedAnimation, PATCH_JUMP);
InjectHook(0x5944B0, CReplay::RetrieveDetailedPedAnimation, PATCH_JUMP); InjectHook(0x5944B0, CReplay::RetrieveDetailedPedAnimation, PATCH_JUMP);
//InjectHook(0x5966E0, CReplay::RestoreStuffFromMem, PATCH_JUMP); InjectHook(0x596030, CReplay::TriggerPlayback, PATCH_JUMP);
ENDPATCHES ENDPATCHES

View file

@ -201,13 +201,13 @@ private:
static CEntryInfoNode *&pBuf9; static CEntryInfoNode *&pBuf9;
static uint8 *&pBuf10; static uint8 *&pBuf10;
static CDummyPed *&pBuf11; static CDummyPed *&pBuf11;
static CBlip *&pRadarBlips; static uint8 *&pRadarBlips;
static CCamera *&pStoredCam; static uint8 *&pStoredCam;
static CSector *&pWorld1; static uint8 *&pWorld1;
static CReference *&pEmptyReferences; static CReference *&pEmptyReferences;
static CStoredDetailedAnimationState *&pPedAnims; static CStoredDetailedAnimationState *&pPedAnims;
static CPickup *&pPickups; static uint8 *&pPickups;
static CReference *&pReferences; static uint8 *&pReferences;
static uint8 (&BufferStatus)[8]; static uint8 (&BufferStatus)[8];
static uint8 (&Buffers)[8][100000]; static uint8 (&Buffers)[8][100000];
static bool &bPlayingBackFromFile; static bool &bPlayingBackFromFile;

View file

@ -30,6 +30,7 @@ CVector &CPed::offsetToOpenVanDoor = *(CVector*)0x62E048;
void *CPed::operator new(size_t sz) { return CPools::GetPedPool()->New(); } void *CPed::operator new(size_t sz) { return CPools::GetPedPool()->New(); }
void *CPed::operator new(size_t sz, int handle) { return CPools::GetPedPool()->New(handle); } void *CPed::operator new(size_t sz, int handle) { return CPools::GetPedPool()->New(handle); }
void CPed::operator delete(void *p, size_t sz) { CPools::GetPedPool()->Delete((CPed*)p); } void CPed::operator delete(void *p, size_t sz) { CPools::GetPedPool()->Delete((CPed*)p); }
void CPed::operator delete(void *p, int handle) { CPools::GetPedPool()->Delete((CPed*)p); }
CPed::~CPed(void) CPed::~CPed(void)
{ {

View file

@ -272,6 +272,7 @@ public:
static void *operator new(size_t); static void *operator new(size_t);
static void *operator new(size_t, int); static void *operator new(size_t, int);
static void operator delete(void*, size_t); static void operator delete(void*, size_t);
static void operator delete(void*, int);
~CPed(void); ~CPed(void);
void FlagToDestroyWhenNextProcessed(void); void FlagToDestroyWhenNextProcessed(void);

View file

@ -16,6 +16,7 @@ bool &CVehicle::bCheat5 = *(bool *)0x95CD64;
void *CVehicle::operator new(size_t sz) { return CPools::GetVehiclePool()->New(); } void *CVehicle::operator new(size_t sz) { return CPools::GetVehiclePool()->New(); }
void *CVehicle::operator new(size_t sz, int handle) { return CPools::GetVehiclePool()->New(handle); } void *CVehicle::operator new(size_t sz, int handle) { return CPools::GetVehiclePool()->New(handle); }
void CVehicle::operator delete(void *p, size_t sz) { CPools::GetVehiclePool()->Delete((CVehicle*)p); } void CVehicle::operator delete(void *p, size_t sz) { CPools::GetVehiclePool()->Delete((CVehicle*)p); }
void CVehicle::operator delete(void *p, int handle) { CPools::GetVehiclePool()->Delete((CVehicle*)p); }
CVehicle::~CVehicle() CVehicle::~CVehicle()
{ {
@ -25,6 +26,8 @@ CVehicle::~CVehicle()
m_audioEntityId = -5; m_audioEntityId = -5;
} }
CRadar::ClearBlipForEntity(BLIP_CAR, CPools::GetVehiclePool()->GetIndex(this)); CRadar::ClearBlipForEntity(BLIP_CAR, CPools::GetVehiclePool()->GetIndex(this));
if (pDriver)
pDriver->FlagToDestroyWhenNextProcessed();
for (int i = 0; i < m_nNumMaxPassengers; i++){ for (int i = 0; i < m_nNumMaxPassengers; i++){
if (pPassengers[i]) if (pPassengers[i])
pPassengers[i]->FlagToDestroyWhenNextProcessed(); pPassengers[i]->FlagToDestroyWhenNextProcessed();

View file

@ -113,6 +113,7 @@ public:
static void *operator new(size_t); static void *operator new(size_t);
static void *operator new(size_t sz, int slot); static void *operator new(size_t sz, int slot);
static void operator delete(void*, size_t); static void operator delete(void*, size_t);
static void operator delete(void*, int);
~CVehicle(void); ~CVehicle(void);