ProcessCarUpdate
This commit is contained in:
parent
647db5cf34
commit
b2b750bc90
@ -1 +1,21 @@
|
||||
#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
|
@ -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);
|
||||
};
|
@ -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,7 +412,11 @@ 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){
|
||||
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;
|
||||
@ -438,9 +443,6 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB
|
||||
ped->AddWeaponModel(pp->weapon_model);
|
||||
CWorld::Remove(ped);
|
||||
CWorld::Add(ped);
|
||||
}else{
|
||||
debug("Replay:Ped wasn't there\n");
|
||||
}
|
||||
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);
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
};
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user