ProcessPedUpdate

This commit is contained in:
Nikolay Korolev 2019-06-29 14:38:37 +03:00
parent 4c2f74c313
commit 9b5392d3a1
7 changed files with 73 additions and 6 deletions

View File

@ -8,6 +8,7 @@
#include "World.h"
WRAPPER void CWorld::Add(CEntity *entity) { EAXJMP(0x4AE930); }
WRAPPER void CWorld::Remove(CEntity *entity) { EAXJMP(0x4AE9D0); }
CPtrList *CWorld::ms_bigBuildingsList = (CPtrList*)0x6FAB60;
CPtrList &CWorld::ms_listMovingEntityPtrs = *(CPtrList*)0x8F433C;

View File

@ -67,6 +67,7 @@ public:
static bool &bForceProcessControl;
static bool &bProcessCutsceneOnly;
static void Remove(CEntity *entity);
static void Add(CEntity *entity);
static CSector *GetSector(int x, int y) { return &ms_aSectors[y][x]; }
@ -103,6 +104,8 @@ public:
static int GetSectorIndexY(float f) { return (int)GetSectorY(f); }
static float GetWorldX(int x) { return x*SECTOR_SIZE_X + WORLD_MIN_X; }
static float GetWorldY(int y) { return y*SECTOR_SIZE_Y + WORLD_MIN_Y; }
static void Remove(void);
};
class CPlayerPed;

View File

@ -165,8 +165,6 @@ void CReplay::Init(void)
bDoLoadSceneWhenDone = false;
}
WRAPPER void CReplay::EmptyReplayBuffer(void) { EAXJMP(0x595BD0); }
void CReplay::DisableReplays(void)
{
bReplayEnabled = false;
@ -406,7 +404,46 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
}
}
#endif
#if 0
WRAPPER void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayBuffer *buffer) { EAXJMP(0x594050); }
#else
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;
float coeff = 1.0f - interpolation;
pp->matrix.DecompressIntoFullMatrix(ped_matrix);
ped->GetMatrix() = ped->GetMatrix() * CMatrix(coeff);
*ped->GetMatrix().GetPosition() *= coeff;
ped->GetMatrix() += CMatrix(coeff) * 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->IsPlayer())
((CPlayerPed*)ped)->ReApplyMoveAnims();
}
RetrievePedAnimation(ped, &pp->anim_state);
ped->RemoveWeaponModel(-1);
if (pp->weapon_model != -1)
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
WRAPPER void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state) { EAXJMP(0x5942A0); }
WRAPPER void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state) { EAXJMP(0x5944B0); }
WRAPPER void CReplay::PlaybackThisFrame(void) { EAXJMP(0x5946B0); }
@ -453,7 +490,7 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
WRAPPER void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer) { EAXJMP(0x594D10); }
WRAPPER bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer) { EAXJMP(0x595240); }
WRAPPER void CReplay::FinishPlayback(void) { EAXJMP(0x595B20); }
WRAPPER void CReplay::Shutdown(void) { EAXJMP(0x595BD0); }
WRAPPER void CReplay::EmptyReplayBuffer(void) { EAXJMP(0x595BD0); }
WRAPPER void CReplay::ProcessReplayCamera(void) { EAXJMP(0x595C40); }
#if 0

View File

@ -155,7 +155,7 @@ class CReplay
int8 vehicle_index;
CStoredAnimationState anim_state;
CCompressedMatrixNotAligned matrix;
uint8 assoc_group_id;
int8 assoc_group_id;
uint8 weapon_model;
};
static_assert(sizeof(tPedUpdatePacket) == 40, "tPedUpdatePacket: error");
@ -244,12 +244,11 @@ private:
public:
static void Init(void);
static void EmptyReplayBuffer(void);
static void DisableReplays(void);
static void EnableReplays(void);
static void Update(void);
static void FinishPlayback(void);
static void Shutdown(void);
static void EmptyReplayBuffer(void);
static void Display(void);
static void TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene);
static void StreamAllNecessaryCarsAndPeds(void);

View File

@ -0,0 +1,5 @@
#include "common.h"
#include "patcher.h"
#include "PlayerPed.h"
WRAPPER void CPlayerPed::ReApplyMoveAnims(void) { EAXJMP(0x4F07C0); }

View File

@ -38,6 +38,8 @@ public:
int32 field_1488[6];
float field_1512;
float m_fFPSMoveHeading;
void ReApplyMoveAnims(void);
};
static_assert(sizeof(CPlayerPed) == 0x5F0, "CPlayerPed: error");

View File

@ -20,6 +20,11 @@ public:
m_attachment = nil;
Attach(matrix, owner);
}
CMatrix(float scale){
m_attachment = nil;
m_hasRwMatrix = false;
SetScale(scale);
}
~CMatrix(void){
if(m_hasRwMatrix && m_attachment)
RwMatrixDestroy(m_attachment);
@ -57,6 +62,21 @@ public:
if(m_attachment)
UpdateRW();
}
CMatrix& operator+=(CMatrix const &rhs){
m_matrix.right.x += rhs.m_matrix.right.x;
m_matrix.up.x += rhs.m_matrix.up.x;
m_matrix.at.x += rhs.m_matrix.at.x;
m_matrix.right.y += rhs.m_matrix.right.y;
m_matrix.up.y += rhs.m_matrix.up.y;
m_matrix.at.y += rhs.m_matrix.at.y;
m_matrix.right.z += rhs.m_matrix.right.z;
m_matrix.up.z += rhs.m_matrix.up.z;
m_matrix.at.z += rhs.m_matrix.at.z;
m_matrix.pos.x += rhs.m_matrix.pos.x;
m_matrix.pos.y += rhs.m_matrix.pos.y;
m_matrix.pos.y += rhs.m_matrix.pos.z;
return *this;
}
CVector *GetPosition(void){ return (CVector*)&m_matrix.pos; }
CVector *GetRight(void) { return (CVector*)&m_matrix.right; }