summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DamageManager.cpp22
-rw-r--r--src/DamageManager.h13
-rw-r--r--src/control/Replay.cpp133
-rw-r--r--src/control/Replay.h7
-rw-r--r--src/entities/Automobile.h4
-rw-r--r--src/entities/Boat.h4
6 files changed, 146 insertions, 37 deletions
diff --git a/src/DamageManager.cpp b/src/DamageManager.cpp
index d4c8f16e..a065e187 100644
--- a/src/DamageManager.cpp
+++ b/src/DamageManager.cpp
@@ -1 +1,21 @@
-#include "DamageManager.h" \ No newline at end of file
+#include "common.h"
+#include "patcher.h"
+#include "DamageManager.h"
+
+#if 0
+WRAPPER void CDamageManager::SetDoorStatus(int door, unsigned int status) { EAXJMP(0x545920); }
+#else
+void CDamageManager::SetDoorStatus(int door, unsigned int status)
+{
+ m_bDoorStatus[door] = status;
+}
+#endif
+
+#if 0
+WRAPPER unsigned int CDamageManager::GetDoorStatus(int door) { EAXJMP(0x545930); }
+#else
+unsigned int CDamageManager::GetDoorStatus(int door)
+{
+ return m_bDoorStatus[door];
+}
+#endif \ No newline at end of file
diff --git a/src/DamageManager.h b/src/DamageManager.h
index 4f1fa640..01269a42 100644
--- a/src/DamageManager.h
+++ b/src/DamageManager.h
@@ -5,6 +5,16 @@
class CDamageManager
{
public:
+
+ enum {
+ CAR_DOOR_BONNET = 0,
+ CAR_DOOR_BUMPER,
+ CAR_DOOR_LF,
+ CAR_DOOR_RF,
+ CAR_DOOR_LR,
+ CAR_DOOR_RR
+ };
+
float field_0;
char m_bEngineStatus;
char m_bWheelStatus[4];
@@ -15,4 +25,7 @@ public:
char field_25;
char field_26;
char field_27;
+
+ void SetDoorStatus(int, unsigned int);
+ unsigned int GetDoorStatus(int);
}; \ No newline at end of file
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index f3435ece..9f74734c 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -1,6 +1,7 @@
#include "common.h"
#include "patcher.h"
#include "AnimBlendAssociation.h"
+#include "Boat.h"
#include "BulletTraces.h"
#include "CarCtrl.h"
#include "Clock.h"
@@ -411,36 +412,37 @@ WRAPPER void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressI
void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayBuffer *buffer)
{
tPedUpdatePacket *pp = (tPedUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset];
- if (ped){
- ped->m_fRotationCur = pp->heading * M_PI / 128.0f;
- ped->m_fRotationDest = pp->heading * M_PI / 128.0f;
- CMatrix ped_matrix;
- pp->matrix.DecompressIntoFullMatrix(ped_matrix);
- ped->GetMatrix() = ped->GetMatrix() * CMatrix(1.0f - interpolation);
- *ped->GetMatrix().GetPosition() *= (1.0f - interpolation);
- ped->GetMatrix() += CMatrix(interpolation) * ped_matrix;
- if (pp->vehicle_index) {
- ped->m_pMyVehicle = CPools::GetVehiclePool()->GetSlot(pp->vehicle_index - 1);
- ped->bInVehicle = pp->vehicle_index;
- }
- else {
- ped->m_pMyVehicle = nil;
- ped->bInVehicle = false;
- }
- if (pp->assoc_group_id != ped->m_animGroup) {
- ped->m_animGroup = (AssocGroupId)pp->assoc_group_id;
- if (ped == FindPlayerPed())
- ((CPlayerPed*)ped)->ReApplyMoveAnims();
- }
- RetrievePedAnimation(ped, &pp->anim_state);
- ped->RemoveWeaponModel(-1);
- if (pp->weapon_model != (uint8)-1)
- ped->AddWeaponModel(pp->weapon_model);
- CWorld::Remove(ped);
- CWorld::Add(ped);
- }else{
+ if (!ped){
debug("Replay:Ped wasn't there\n");
+ buffer->m_nOffset += sizeof(tPedUpdatePacket);
+ return;
+ }
+ ped->m_fRotationCur = pp->heading * M_PI / 128.0f;
+ ped->m_fRotationDest = pp->heading * M_PI / 128.0f;
+ CMatrix ped_matrix;
+ pp->matrix.DecompressIntoFullMatrix(ped_matrix);
+ ped->GetMatrix() = ped->GetMatrix() * CMatrix(1.0f - interpolation);
+ *ped->GetMatrix().GetPosition() *= (1.0f - interpolation);
+ ped->GetMatrix() += CMatrix(interpolation) * ped_matrix;
+ if (pp->vehicle_index) {
+ ped->m_pMyVehicle = CPools::GetVehiclePool()->GetSlot(pp->vehicle_index - 1);
+ ped->bInVehicle = pp->vehicle_index;
+ }
+ else {
+ ped->m_pMyVehicle = nil;
+ ped->bInVehicle = false;
}
+ if (pp->assoc_group_id != ped->m_animGroup) {
+ ped->m_animGroup = (AssocGroupId)pp->assoc_group_id;
+ if (ped == FindPlayerPed())
+ ((CPlayerPed*)ped)->ReApplyMoveAnims();
+ }
+ RetrievePedAnimation(ped, &pp->anim_state);
+ ped->RemoveWeaponModel(-1);
+ if (pp->weapon_model != (uint8)-1)
+ ped->AddWeaponModel(pp->weapon_model);
+ CWorld::Remove(ped);
+ CWorld::Add(ped);
buffer->m_nOffset += sizeof(tPedUpdatePacket);
}
#endif
@@ -603,7 +605,81 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
Record.m_nOffset += sizeof(tVehicleUpdatePacket);
}
#endif
+
+#if 0
WRAPPER void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer) { EAXJMP(0x594D10); }
+#else
+void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer)
+{
+ tVehicleUpdatePacket* vp = (tVehicleUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset];
+ if (!vehicle){
+ debug("Replay:Car wasn't there");
+ return;
+ }
+ CMatrix vehicle_matrix;
+ vp->matrix.DecompressIntoFullMatrix(vehicle_matrix);
+ vehicle->GetMatrix() = vehicle->GetMatrix() * CMatrix(1.0f - interpolation);
+ *vehicle->GetMatrix().GetPosition() *= (1.0f - interpolation);
+ vehicle->GetMatrix() += CMatrix(interpolation) * vehicle_matrix;
+ vehicle->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
+ vehicle->m_fHealth = 4 * vp->health;
+ vehicle->m_fGasPedal = vp->acceleration / 100.0f;
+ if (vehicle->IsCar())
+ ApplyPanelDamageToCar(vp->panels, (CAutomobile*)vehicle, true);
+ vehicle->m_vecMoveSpeed = CVector(vp->velocityX / 8000.0f, vp->velocityY / 8000.0f, vp->velocityZ / 8000.0f);
+ if (vehicle->GetModelIndex() == MI_RHINO) {
+ ((CAutomobile*)vehicle)->m_fCarGunLR = vp->car_gun * M_PI / 128.0f;
+ vehicle->m_fSteerAngle = 0.0f;
+ }else{
+ vehicle->m_fSteerAngle = vp->wheel_state / 50.0f;
+ }
+ if (vehicle->IsCar()) {
+ CAutomobile* car = (CAutomobile*)vehicle;
+ for (int i = 0; i < 4; i++) {
+ car->m_afWheelSuspDist[i] = vp->wheel_susp_dist[i] / 50.0f;
+ car->m_afWheelRotation[i] = vp->wheel_rotation[i] * M_PI / 128.0f;
+ }
+ car->m_aDoors[2].m_fAngle = car->m_aDoors[2].m_fPreviousAngle = vp->door_angles[0] * M_PI / 127.0f;
+ car->m_aDoors[3].m_fAngle = car->m_aDoors[3].m_fPreviousAngle = vp->door_angles[1] * M_PI / 127.0f;
+ if (vp->door_angles[0])
+ car->m_DamageManager.m_bDoorStatus[2] = 2;
+ if (vp->door_angles[1])
+ car->m_DamageManager.m_bDoorStatus[3] = 2;
+ if (vp->door_status & 1 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_BONNET) != 3){
+ car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_BONNET, 3);
+ car->SetDoorDamage(17, CDamageManager::CAR_DOOR_BONNET, true);
+ }
+ if (vp->door_status & 2 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_BUMPER) != 3) {
+ car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_BUMPER, 3);
+ car->SetDoorDamage(18, CDamageManager::CAR_DOOR_BUMPER, true);
+ }
+ if (vp->door_status & 4 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_LF) != 3) {
+ car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_LF, 3);
+ car->SetDoorDamage(15, CDamageManager::CAR_DOOR_LF, true);
+ }
+ if (vp->door_status & 8 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_RF) != 3) {
+ car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_RF, 3);
+ car->SetDoorDamage(11, CDamageManager::CAR_DOOR_RF, true);
+ }
+ if (vp->door_status & 0x10 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_LR) != 3) {
+ car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_LR, 3);
+ car->SetDoorDamage(16, CDamageManager::CAR_DOOR_LR, true);
+ }
+ if (vp->door_status & 0x20 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_RR) != 3) {
+ car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_RR, 3);
+ car->SetDoorDamage(12, CDamageManager::CAR_DOOR_RR, true);
+ }
+ vehicle->m_veh_flagA10 = true;
+ if (vehicle->IsCar())
+ ((CAutomobile*)vehicle)->m_nDriveWheelsOnGround = 4;
+ CWorld::Remove(vehicle);
+ CWorld::Add(vehicle);
+ if (vehicle->IsBoat())
+ ((CBoat*)vehicle)->m_bIsAnchored = false;
+ }
+}
+#endif
+
WRAPPER bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer) { EAXJMP(0x595240); }
WRAPPER void CReplay::FinishPlayback(void) { EAXJMP(0x595B20); }
WRAPPER void CReplay::EmptyReplayBuffer(void) { EAXJMP(0x595BD0); }
@@ -912,6 +988,7 @@ InjectHook(0x593150, CReplay::DisableReplays, PATCH_JUMP);
InjectHook(0x593160, CReplay::EnableReplays, PATCH_JUMP);
InjectHook(0x593170, CReplay::Update, 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);
diff --git a/src/control/Replay.h b/src/control/Replay.h
index 0448a829..37342d41 100644
--- a/src/control/Replay.h
+++ b/src/control/Replay.h
@@ -257,26 +257,21 @@ 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);
-public:
static void StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state);
-
static void ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayBuffer *buffer);
static void RetrievePedAnimation(CPed *ped, CStoredAnimationState *state);
static void RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state);
-private:
static void PlaybackThisFrame(void);
static void StoreCarUpdate(CVehicle *vehicle, int id);
static void ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer);
static bool PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer);
static void ProcessReplayCamera(void);
static void StoreStuffInMem(void);
-public: /* temp */
static void RestoreStuffFromMem(void);
-private:
static void EmptyPedsAndVehiclePools(void);
static void EmptyAllPools(void);
static void MarkEverythingAsNew(void);
diff --git a/src/entities/Automobile.h b/src/entities/Automobile.h
index 7422112b..1b5e74d5 100644
--- a/src/entities/Automobile.h
+++ b/src/entities/Automobile.h
@@ -18,7 +18,9 @@ public:
float m_afWheelRotation[4];
uint8 stuff3[200];
float m_fCarGunLR;
- uint8 stuff4[36];
+ uint8 stuff4[13];
+ uint8 m_nDriveWheelsOnGround;
+ uint8 stuff5[22];
void SetDoorDamage(int32, uint32, bool); /* TODO: eDoors */
};
diff --git a/src/entities/Boat.h b/src/entities/Boat.h
index b66ab107..26de0cdc 100644
--- a/src/entities/Boat.h
+++ b/src/entities/Boat.h
@@ -6,6 +6,8 @@ class CBoat : public CVehicle
{
public:
// 0x288
- uint8 stuff[508];
+ uint8 stuff1[57];
+ bool m_bIsAnchored;
+ uint8 stuff[450];
};
static_assert(sizeof(CBoat) == 0x484, "CBoat: error");