summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2019-06-30 15:20:11 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2019-06-30 15:20:11 +0200
commit90bcb888e8cd3f6580984c0248e474650c350007 (patch)
tree05606ed8c2ae842f7bd7a8f766d3d566e9e6f083
parentPlayBackThisFrameInterpolation and all it required... (diff)
downloadre3-90bcb888e8cd3f6580984c0248e474650c350007.tar
re3-90bcb888e8cd3f6580984c0248e474650c350007.tar.gz
re3-90bcb888e8cd3f6580984c0248e474650c350007.tar.bz2
re3-90bcb888e8cd3f6580984c0248e474650c350007.tar.lz
re3-90bcb888e8cd3f6580984c0248e474650c350007.tar.xz
re3-90bcb888e8cd3f6580984c0248e474650c350007.tar.zst
re3-90bcb888e8cd3f6580984c0248e474650c350007.zip
-rw-r--r--src/Collision.cpp2
-rw-r--r--src/control/Replay.cpp62
-rw-r--r--src/control/Replay.h10
-rw-r--r--src/entities/Ped.cpp1
-rw-r--r--src/entities/Ped.h1
-rw-r--r--src/entities/Vehicle.cpp3
-rw-r--r--src/entities/Vehicle.h1
7 files changed, 42 insertions, 38 deletions
diff --git a/src/Collision.cpp b/src/Collision.cpp
index 6189a3fc..62b27eff 100644
--- a/src/Collision.cpp
+++ b/src/Collision.cpp
@@ -1736,8 +1736,6 @@ CColModel::operator=(const CColModel &other)
int i;
int numVerts;
- assert(0);
-
boundingSphere = other.boundingSphere;
boundingBox = other.boundingBox;
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index 4733f6f2..b6a7b8c2 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -47,13 +47,13 @@ uint8 *&CReplay::pBuf8 = *(uint8**)0x8E2C54;
CEntryInfoNode *&CReplay::pBuf9 = *(CEntryInfoNode**)0x8E2C58;
uint8 *&CReplay::pBuf10 = *(uint8**)0x8F2C28;
CDummyPed *&CReplay::pBuf11 = *(CDummyPed**)0x8F2C2C;
-CBlip *&CReplay::pRadarBlips = *(CBlip**)0x8F29F8;
-CCamera *&CReplay::pStoredCam = *(CCamera**)0x8F2C34;
-CSector *&CReplay::pWorld1 = *(CSector**)0x8E29C4;
+uint8 *&CReplay::pRadarBlips = *(uint8**)0x8F29F8;
+uint8 *&CReplay::pStoredCam = *(uint8**)0x8F2C34;
+uint8 *&CReplay::pWorld1 = *(uint8**)0x8E29C4;
CReference *&CReplay::pEmptyReferences = *(CReference**)0x8F256C;
CStoredDetailedAnimationState *&CReplay::pPedAnims = *(CStoredDetailedAnimationState**)0x8F6260;
-CPickup *&CReplay::pPickups = *(CPickup**)0x8F1A48;
-CReference *&CReplay::pReferences = *(CReference**)0x880FAC;
+uint8 *&CReplay::pPickups = *(uint8**)0x8F1A48;
+uint8 *&CReplay::pReferences = *(uint8**)0x880FAC;
uint8(&CReplay::BufferStatus)[8] = *(uint8(*)[8])*(uintptr*)0x8804D8;
uint8(&CReplay::Buffers)[8][100000] = *(uint8(*)[8][100000])*(uintptr*)0x779958;
bool &CReplay::bPlayingBackFromFile = *(bool*)0x95CD58;
@@ -988,7 +988,7 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca
}
#endif
-#if 1
+#if 0
WRAPPER void CReplay::StoreStuffInMem(void) { EAXJMP(0x5961F0); }
#else
void CReplay::StoreStuffInMem(void)
@@ -999,19 +999,19 @@ void CReplay::StoreStuffInMem(void)
CPools::GetPtrNodePool()->Store(pBuf6, pBuf7);
CPools::GetEntryInfoNodePool()->Store(pBuf8, pBuf9);
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));
- WorldPtrList = CWorld::GetMovingEntityList(); /* Interesting way to copy a list... */
+ WorldPtrList = CWorld::GetMovingEntityList();
BigBuildingPtrList = CWorld::GetBigBuildingList(LEVEL_NONE);
- pPickups = (CPickup*)malloc(sizeof(CPickup) * NUMPICKUPS);
+ pPickups = new uint8[sizeof(CPickup) * NUMPICKUPS];
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));
pEmptyReferences = CReferences::pEmptyList;
- pStoredCam = (CCamera*)malloc(sizeof(CCamera));
+ pStoredCam = new uint8[sizeof(CCamera)];
memcpy(pStoredCam, &TheCamera, sizeof(CCamera));
- pRadarBlips = (CBlip*)malloc(sizeof(CBlip) * NUMBLIPS);
- memcpy(pRadarBlips, CRadar::ms_RadarTrace, NUMBLIPS * sizeof(CBlip));
+ pRadarBlips = new uint8[sizeof(CBlip) * NUMRADARBLIPS];
+ memcpy(pRadarBlips, CRadar::ms_RadarTrace, NUMRADARBLIPS * sizeof(CBlip));
PlayerWanted = *FindPlayerPed()->m_pWanted;
PlayerInfo = CWorld::Players[0];
Time1 = CTimer::GetTimeInMilliseconds();
@@ -1037,7 +1037,7 @@ void CReplay::StoreStuffInMem(void)
}
#endif
-#if 1
+#if 0
WRAPPER void CReplay::RestoreStuffFromMem(void) { EAXJMP(0x5966E0); }
#else
void CReplay::RestoreStuffFromMem(void)
@@ -1049,28 +1049,28 @@ void CReplay::RestoreStuffFromMem(void)
CPools::GetEntryInfoNodePool()->CopyBack(pBuf8, pBuf9);
CPools::GetDummyPool()->CopyBack(pBuf10, pBuf11);
memcpy(CWorld::GetSector(0, 0), pWorld1, sizeof(CSector) * NUMSECTORS_X * NUMSECTORS_Y);
- free(pWorld1);
+ delete[] pWorld1;
pWorld1 = nil;
CWorld::GetMovingEntityList() = WorldPtrList;
CWorld::GetBigBuildingList(LEVEL_NONE) = BigBuildingPtrList;
memcpy(CPickups::aPickUps, pPickups, sizeof(CPickup) * NUMPICKUPS);
- free(pPickups);
+ delete[] pPickups;
pPickups = nil;
memcpy(CReferences::aRefs, pReferences, sizeof(CReference) * NUMREFERENCES);
- free(pReferences);
+ delete[] pReferences;
pReferences = nil;
CReferences::pEmptyList = pEmptyReferences;
pEmptyReferences = nil;
memcpy(&TheCamera, pStoredCam, sizeof(CCamera));
- free(pStoredCam);
+ delete[] pStoredCam;
pStoredCam = nil;
- memcpy(CRadar::ms_RadarTrace, pRadarBlips, sizeof(CBlip) * NUMBLIPS);
- free(pRadarBlips);
+ memcpy(CRadar::ms_RadarTrace, pRadarBlips, sizeof(CBlip) * NUMRADARBLIPS);
+ delete[] pRadarBlips;
pRadarBlips = nil;
FindPlayerPed()->m_pWanted = new CWanted(PlayerWanted); /* Nice memory leak */
CWorld::Players[0] = PlayerInfo;
- int size = CPools::GetPedPool()->GetSize();
- for (int i = size - 1; i >= 0; i--){
+ int i = CPools::GetPedPool()->GetSize();
+ while (--i){
CPed* ped = CPools::GetPedPool()->GetSlot(i);
if (!ped)
continue;
@@ -1087,8 +1087,8 @@ void CReplay::RestoreStuffFromMem(void)
if (ped->m_wepModelID >= 0)
ped->AddWeaponModel(ped->m_wepModelID);
}
- size = CPools::GetVehiclePool()->GetSize();
- for (int i = size - 1; i >= 0; i--) {
+ i = CPools::GetVehiclePool()->GetSize();
+ while (--i){
CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!vehicle)
continue;
@@ -1146,8 +1146,8 @@ void CReplay::RestoreStuffFromMem(void)
}
}
PrintElementsInPtrList();
- size = CPools::GetObjectPool()->GetSize();
- for (int i = size - 1; i >= 0; i--) {
+ i = CPools::GetObjectPool()->GetSize();
+ while (--i){
CObject* object = CPools::GetObjectPool()->GetSlot(i);
if (!object)
continue;
@@ -1161,8 +1161,8 @@ void CReplay::RestoreStuffFromMem(void)
if (RwObjectGetType(object->m_rwObject) == rpATOMIC)
object->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame(object->m_rwObject)), false);
}
- size = CPools::GetDummyPool()->GetSize();
- for (int i = size - 1; i >= 0; i--) {
+ i = CPools::GetDummyPool()->GetSize();
+ while (--i){
CDummy* dummy = CPools::GetDummyPool()->GetSlot(i);
if (!dummy)
continue;
@@ -1188,8 +1188,7 @@ void CReplay::RestoreStuffFromMem(void)
CWeather::OldWeatherType = OldWeatherType;
CWeather::NewWeatherType = NewWeatherType;
CWeather::InterpolationValue = WeatherInterpolationValue;
- size = CPools::GetPedPool()->GetSize();
- for (int i = 0; i < size; i++) {
+ for (int i = 0; i < CPools::GetPedPool()->GetSize(); i++) {
CPed* ped = CPools::GetPedPool()->GetSlot(i);
if (!ped)
continue;
@@ -1236,9 +1235,10 @@ InjectHook(0x592FE0, CReplay::Init, PATCH_JUMP);
InjectHook(0x593150, CReplay::DisableReplays, PATCH_JUMP);
InjectHook(0x593160, CReplay::EnableReplays, PATCH_JUMP);
InjectHook(0x593170, CReplay::Update, PATCH_JUMP);
+InjectHook(0x595B20, CReplay::FinishPlayback, PATCH_JUMP);
InjectHook(0x594050, CReplay::ProcessPedUpdate, PATCH_JUMP);
InjectHook(0x594D10, CReplay::ProcessCarUpdate, PATCH_JUMP);
InjectHook(0x593BB0, CReplay::StoreDetailedPedAnimation, PATCH_JUMP);
InjectHook(0x5944B0, CReplay::RetrieveDetailedPedAnimation, PATCH_JUMP);
-//InjectHook(0x5966E0, CReplay::RestoreStuffFromMem, PATCH_JUMP);
+InjectHook(0x596030, CReplay::TriggerPlayback, PATCH_JUMP);
ENDPATCHES
diff --git a/src/control/Replay.h b/src/control/Replay.h
index f44e4c41..18701293 100644
--- a/src/control/Replay.h
+++ b/src/control/Replay.h
@@ -201,13 +201,13 @@ private:
static CEntryInfoNode *&pBuf9;
static uint8 *&pBuf10;
static CDummyPed *&pBuf11;
- static CBlip *&pRadarBlips;
- static CCamera *&pStoredCam;
- static CSector *&pWorld1;
+ static uint8 *&pRadarBlips;
+ static uint8 *&pStoredCam;
+ static uint8 *&pWorld1;
static CReference *&pEmptyReferences;
static CStoredDetailedAnimationState *&pPedAnims;
- static CPickup *&pPickups;
- static CReference *&pReferences;
+ static uint8 *&pPickups;
+ static uint8 *&pReferences;
static uint8 (&BufferStatus)[8];
static uint8 (&Buffers)[8][100000];
static bool &bPlayingBackFromFile;
diff --git a/src/entities/Ped.cpp b/src/entities/Ped.cpp
index a82d4fdc..85a588dc 100644
--- a/src/entities/Ped.cpp
+++ b/src/entities/Ped.cpp
@@ -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, 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, int handle) { CPools::GetPedPool()->Delete((CPed*)p); }
CPed::~CPed(void)
{
diff --git a/src/entities/Ped.h b/src/entities/Ped.h
index 2edbd9e2..8f4939fc 100644
--- a/src/entities/Ped.h
+++ b/src/entities/Ped.h
@@ -272,6 +272,7 @@ public:
static void *operator new(size_t);
static void *operator new(size_t, int);
static void operator delete(void*, size_t);
+ static void operator delete(void*, int);
~CPed(void);
void FlagToDestroyWhenNextProcessed(void);
diff --git a/src/entities/Vehicle.cpp b/src/entities/Vehicle.cpp
index bcbaee32..8c1ef515 100644
--- a/src/entities/Vehicle.cpp
+++ b/src/entities/Vehicle.cpp
@@ -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, 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, int handle) { CPools::GetVehiclePool()->Delete((CVehicle*)p); }
CVehicle::~CVehicle()
{
@@ -25,6 +26,8 @@ CVehicle::~CVehicle()
m_audioEntityId = -5;
}
CRadar::ClearBlipForEntity(BLIP_CAR, CPools::GetVehiclePool()->GetIndex(this));
+ if (pDriver)
+ pDriver->FlagToDestroyWhenNextProcessed();
for (int i = 0; i < m_nNumMaxPassengers; i++){
if (pPassengers[i])
pPassengers[i]->FlagToDestroyWhenNextProcessed();
diff --git a/src/entities/Vehicle.h b/src/entities/Vehicle.h
index eed8f7a8..997720f6 100644
--- a/src/entities/Vehicle.h
+++ b/src/entities/Vehicle.h
@@ -113,6 +113,7 @@ public:
static void *operator new(size_t);
static void *operator new(size_t sz, int slot);
static void operator delete(void*, size_t);
+ static void operator delete(void*, int);
~CVehicle(void);