summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2019-06-30 18:22:44 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2019-06-30 18:22:44 +0200
commit69918d4145b26325473ed608b34e37bee19cfa10 (patch)
tree8912fba883115ebe41c4d2adaa9c9410d1b066fd
parentMerge pull request #79 from Nick007J/master (diff)
downloadre3-69918d4145b26325473ed608b34e37bee19cfa10.tar
re3-69918d4145b26325473ed608b34e37bee19cfa10.tar.gz
re3-69918d4145b26325473ed608b34e37bee19cfa10.tar.bz2
re3-69918d4145b26325473ed608b34e37bee19cfa10.tar.lz
re3-69918d4145b26325473ed608b34e37bee19cfa10.tar.xz
re3-69918d4145b26325473ed608b34e37bee19cfa10.tar.zst
re3-69918d4145b26325473ed608b34e37bee19cfa10.zip
Diffstat (limited to '')
-rw-r--r--src/Camera.cpp1
-rw-r--r--src/Camera.h1
-rw-r--r--src/control/Replay.cpp121
-rw-r--r--src/control/Replay.h2
-rw-r--r--src/entities/Vehicle.h2
5 files changed, 112 insertions, 15 deletions
diff --git a/src/Camera.cpp b/src/Camera.cpp
index e2dd12ff..e5e50ef2 100644
--- a/src/Camera.cpp
+++ b/src/Camera.cpp
@@ -19,6 +19,7 @@ CCamera &TheCamera = *(CCamera*)0x6FACF8;
bool &CCamera::m_bUseMouse3rdPerson = *(bool *)0x5F03D8;
WRAPPER void CCamera::DrawBordersForWideScreen(void) { EAXJMP(0x46B430); }
+WRAPPER void CCamera::CalculateDerivedValues(void) { EAXJMP(0x46EEA0); }
bool
CCamera::IsSphereVisible(const CVector &center, float radius, const CMatrix *mat)
diff --git a/src/Camera.h b/src/Camera.h
index 2316fd5d..6d20de72 100644
--- a/src/Camera.h
+++ b/src/Camera.h
@@ -456,6 +456,7 @@ int m_iModeObbeCamIsInForCar;
void SetMotionBlur(int r, int g, int b, int a, int type);
void SetMotionBlurAlpha(int a);
void RenderMotionBlur(void);
+ void CalculateDerivedValues(void);
void DrawBordersForWideScreen(void);
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index b6a7b8c2..09cbf2d2 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -810,11 +810,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
TheCamera.GetMatrix() = TheCamera.GetMatrix() * CMatrix(split);
*TheCamera.GetMatrix().GetPosition() *= split;
TheCamera.GetMatrix() += CMatrix(interpolation) * pg->camera_pos;
- RwMatrix* pm = &RpAtomicGetFrame(&TheCamera.m_pRwCamera->object.object)->modelling;
- pm->pos = *(RwV3d*)TheCamera.GetMatrix().GetPosition();
- pm->at = *(RwV3d*)TheCamera.GetMatrix().GetForward();
- pm->up = *(RwV3d*)TheCamera.GetMatrix().GetUp();
- pm->right = *(RwV3d*)TheCamera.GetMatrix().GetRight();
+ *RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)) = TheCamera.GetMatrix().m_matrix;
CameraFocusX = split * CameraFocusX + interpolation * pg->player_pos.x;
CameraFocusY = split * CameraFocusY + interpolation * pg->player_pos.y;
CameraFocusZ = split * CameraFocusZ + interpolation * pg->player_pos.z;
@@ -932,7 +928,41 @@ void CReplay::EmptyReplayBuffer(void)
}
#endif
+#if 0
WRAPPER void CReplay::ProcessReplayCamera(void) { EAXJMP(0x595C40); }
+#else
+void CReplay::ProcessReplayCamera(void)
+{
+ switch (CameraMode) {
+ case REPLAYCAMMODE_TOPDOWN:
+ *TheCamera.GetMatrix().GetPosition() = CVector(CameraFocusX, CameraFocusY, CameraFocusZ + 15.0f);
+ *TheCamera.GetMatrix().GetForward() = CVector(0.0f, 0.0f, -1.0f);
+ *TheCamera.GetMatrix().GetUp() = CVector(0.0f, 1.0f, 0.0f);
+ *TheCamera.GetMatrix().GetRight() = CVector(1.0f, 0.0f, 0.0f);
+ *RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)) = TheCamera.GetMatrix().m_matrix;
+ break;
+ case REPLAYCAMMODE_FIXED:
+ *TheCamera.GetMatrix().GetPosition() = CVector(CameraFixedX, CameraFixedY, CameraFixedZ);
+ CVector forward(CameraFocusX - CameraFixedX, CameraFocusY - CameraFixedY, CameraFocusZ - CameraFixedZ);
+ forward.Normalise();
+ CVector right = CrossProduct(CVector(0.0f, 0.0f, 1.0f), forward);
+ right.Normalise();
+ CVector up = CrossProduct(forward, right);
+ up.Normalise();
+ *TheCamera.GetMatrix().GetForward() = forward;
+ *TheCamera.GetMatrix().GetUp() = up;
+ *TheCamera.GetMatrix().GetRight() = right;
+ *RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)) = TheCamera.GetMatrix().m_matrix;
+ break;
+ default:
+ break;
+ }
+ TheCamera.m_vecGameCamPos = *TheCamera.GetMatrix().GetPosition();
+ TheCamera.CalculateDerivedValues();
+ RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
+ RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));
+}
+#endif
#if 0
WRAPPER void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene) { EAXJMP(0x596030); }
@@ -1070,7 +1100,7 @@ void CReplay::RestoreStuffFromMem(void)
FindPlayerPed()->m_pWanted = new CWanted(PlayerWanted); /* Nice memory leak */
CWorld::Players[0] = PlayerInfo;
int i = CPools::GetPedPool()->GetSize();
- while (--i){
+ while (i--){
CPed* ped = CPools::GetPedPool()->GetSlot(i);
if (!ped)
continue;
@@ -1088,7 +1118,7 @@ void CReplay::RestoreStuffFromMem(void)
ped->AddWeaponModel(ped->m_wepModelID);
}
i = CPools::GetVehiclePool()->GetSize();
- while (--i){
+ while (i--){
CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!vehicle)
continue;
@@ -1147,7 +1177,7 @@ void CReplay::RestoreStuffFromMem(void)
}
PrintElementsInPtrList();
i = CPools::GetObjectPool()->GetSize();
- while (--i){
+ while (i--){
CObject* object = CPools::GetObjectPool()->GetSlot(i);
if (!object)
continue;
@@ -1162,7 +1192,7 @@ void CReplay::RestoreStuffFromMem(void)
object->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame(object->m_rwObject)), false);
}
i = CPools::GetDummyPool()->GetSize();
- while (--i){
+ while (i--){
CDummy* dummy = CPools::GetDummyPool()->GetSlot(i);
if (!dummy)
continue;
@@ -1201,9 +1231,77 @@ void CReplay::RestoreStuffFromMem(void)
DMAudio.ChangeMusicMode(1);
}
#endif
+
+#if 0
WRAPPER void CReplay::EmptyPedsAndVehiclePools(void) { EAXJMP(0x5970E0); }
+#else
+void CReplay::EmptyPedsAndVehiclePools(void)
+{
+ int i = CPools::GetVehiclePool()->GetSize();
+ while (i--) {
+ CVehicle* v = CPools::GetVehiclePool()->GetSlot(i);
+ if (!v)
+ continue;
+ CWorld::Remove(v);
+ delete v;
+ }
+ i = CPools::GetPedPool()->GetSize();
+ while (i--) {
+ CPed* p = CPools::GetPedPool()->GetSlot(i);
+ if (!p)
+ continue;
+ CWorld::Remove(p);
+ delete p;
+ }
+}
+#endif
+
+#if 0
WRAPPER void CReplay::EmptyAllPools(void) { EAXJMP(0x5971B0); }
+#else
+void CReplay::EmptyAllPools(void)
+{
+ EmptyPedsAndVehiclePools();
+ int i = CPools::GetObjectPool()->GetSize();
+ while (i--) {
+ CObject* o = CPools::GetObjectPool()->GetSlot(i);
+ if (!o)
+ continue;
+ CWorld::Remove(o);
+ delete o;
+ }
+ i = CPools::GetDummyPool()->GetSize();
+ while (i--) {
+ CDummy* d = CPools::GetDummyPool()->GetSlot(i);
+ if (!d)
+ continue;
+ CWorld::Remove(d);
+ delete d;
+ }
+}
+#endif
+
+#if 0
WRAPPER void CReplay::MarkEverythingAsNew(void) { EAXJMP(0x597280); }
+#else
+void CReplay::MarkEverythingAsNew(void)
+{
+ int i = CPools::GetVehiclePool()->GetSize();
+ while (i--) {
+ CVehicle* v = CPools::GetVehiclePool()->GetSlot(i);
+ if (!v)
+ continue;
+ v->bRecordedForReplay = false;
+ }
+ i = CPools::GetPedPool()->GetSize();
+ while (i--) {
+ CPed* p = CPools::GetPedPool()->GetSlot(i);
+ if (!p)
+ continue;
+ p->bRecordedForReplay = false;
+ }
+}
+#endif
WRAPPER void CReplay::SaveReplayToHD(void) { EAXJMP(0x597330); }
WRAPPER void PlayReplayFromHD(void) { EAXJMP(0x597420); }
WRAPPER void CReplay::StreamAllNecessaryCarsAndPeds(void) { EAXJMP(0x597560); }
@@ -1236,9 +1334,6 @@ 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(0x595BD0, CReplay::EmptyReplayBuffer, PATCH_JUMP);
InjectHook(0x596030, CReplay::TriggerPlayback, PATCH_JUMP);
ENDPATCHES
diff --git a/src/control/Replay.h b/src/control/Replay.h
index 18701293..3a2ecc7f 100644
--- a/src/control/Replay.h
+++ b/src/control/Replay.h
@@ -261,7 +261,7 @@ public:
inline static bool IsPlayingBack() { return Mode == MODE_PLAYBACK; }
inline static bool IsPlayingBackFromFile() { return bPlayingBackFromFile; }
-//private:
+private:
static void RecordThisFrame(void);
static void StorePedUpdate(CPed *ped, int id);
static void StorePedAnimation(CPed *ped, CStoredAnimationState *state);
diff --git a/src/entities/Vehicle.h b/src/entities/Vehicle.h
index 997720f6..27641e47 100644
--- a/src/entities/Vehicle.h
+++ b/src/entities/Vehicle.h
@@ -77,7 +77,7 @@ public:
uint8 m_veh_flagD2 : 1;
uint8 m_veh_flagD4 : 1;
uint8 m_veh_flagD8 : 1;
- uint8 m_veh_flagD10 : 1;
+ uint8 bRecordedForReplay : 1;
uint8 m_veh_flagD20 : 1;
uint8 m_veh_flagD40 : 1;
uint8 m_veh_flagD80 : 1;