From 0c34fb1bb2239b1433719bb410b71e0c28840c85 Mon Sep 17 00:00:00 2001 From: _AG Date: Sun, 7 Jul 2019 15:26:55 +0200 Subject: blah --- src/peds/Ped.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index e4cc848e..016fea2f 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -2702,9 +2702,9 @@ CPed::QuitEnteringCar(void) bUsesCollision = true; if (IsPlayer() && GetWeapon()->m_eWeaponType == WEAPONTYPE_UZI) { - if (IsPlayer() && m_storedWeapon != NO_STORED_WEAPON) { + if (IsPlayer() && m_storedWeapon != WEAPONTYPE_UNIDENTIFIED) { SetCurrentWeapon(m_storedWeapon); - m_storedWeapon = NO_STORED_WEAPON; + m_storedWeapon = WEAPONTYPE_UNIDENTIFIED; } } else { CWeaponInfo *curWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType); -- cgit v1.2.3 From 12af85ca3d29e155f40323ad07a77f96a4aececf Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 8 Jul 2019 08:46:42 +0200 Subject: cleaned up patching of virtual functions; started CAutomobile --- src/peds/CivilianPed.cpp | 13 ++++++++++--- src/peds/CivilianPed.h | 7 ++----- src/peds/CopPed.cpp | 10 ++++++++-- src/peds/CopPed.h | 1 - src/peds/EmergencyPed.cpp | 10 ++++++++-- src/peds/EmergencyPed.h | 2 -- src/peds/Ped.cpp | 28 +++++++++++++++++++++------- src/peds/Ped.h | 35 +++++++++++++---------------------- src/peds/PlayerPed.cpp | 13 +++++++++---- src/peds/PlayerPed.h | 1 - 10 files changed, 71 insertions(+), 49 deletions(-) (limited to 'src/peds') diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp index a4881e71..cf8a0580 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -13,7 +13,14 @@ CCivilianPed::CCivilianPed(int pedtype, int mi) : CPed(pedtype) } } +class CCivilianPed_ : public CCivilianPed +{ +public: + CCivilianPed *ctor(int pedtype, int mi) { return ::new (this) CCivilianPed(pedtype, mi); }; + void dtor(void) { CCivilianPed::~CCivilianPed(); } +}; + STARTPATCHES - InjectHook(0x4BFF30, &CCivilianPed::ctor, PATCH_JUMP); - InjectHook(0x4BFFC0, &CCivilianPed::dtor, PATCH_JUMP); -ENDPATCHES \ No newline at end of file + InjectHook(0x4BFF30, &CCivilianPed_::ctor, PATCH_JUMP); + InjectHook(0x4BFFC0, &CCivilianPed_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/peds/CivilianPed.h b/src/peds/CivilianPed.h index 8d004ad7..14859a5c 100644 --- a/src/peds/CivilianPed.h +++ b/src/peds/CivilianPed.h @@ -6,11 +6,8 @@ class CCivilianPed : public CPed { public: CCivilianPed(int, int); - virtual ~CCivilianPed(void) { } + ~CCivilianPed(void) { } - virtual void ProcessControl(void); - - CCivilianPed *ctor(int pedtype, int mi) { return ::new (this) CCivilianPed(pedtype, mi); }; - void dtor(void) { this->CCivilianPed::~CCivilianPed(); } + void ProcessControl(void); }; static_assert(sizeof(CCivilianPed) == 0x53C, "CCivilianPed: error"); diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp index 041185ee..0ac0473f 100644 --- a/src/peds/CopPed.cpp +++ b/src/peds/CopPed.cpp @@ -9,6 +9,12 @@ CCopPed::~CCopPed() WRAPPER void CCopPed::ClearPursuit(void) { EAXJMP(0x4C28C0); } +class CCopPed_ : public CCopPed +{ +public: + void dtor(void) { CCopPed::~CCopPed(); } +}; + STARTPATCHES - InjectHook(0x4C13E0, &CCopPed::dtor, PATCH_JUMP); -ENDPATCHES \ No newline at end of file + InjectHook(0x4C13E0, &CCopPed_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/peds/CopPed.h b/src/peds/CopPed.h index b938dfc2..5827f9bc 100644 --- a/src/peds/CopPed.h +++ b/src/peds/CopPed.h @@ -65,7 +65,6 @@ public: int8 field_1367; ~CCopPed(); - void dtor(void) { this->CCopPed::~CCopPed(); } void ClearPursuit(void); }; diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp index 7b847896..664bd6f6 100644 --- a/src/peds/EmergencyPed.cpp +++ b/src/peds/EmergencyPed.cpp @@ -2,6 +2,12 @@ #include "patcher.h" #include "EmergencyPed.h" +class CEmergencyPed_ : public CEmergencyPed +{ +public: + void dtor(void) { CEmergencyPed::~CEmergencyPed(); } +}; + STARTPATCHES -InjectHook(0x4C2EF0, &CEmergencyPed::dtor, PATCH_JUMP); -ENDPATCHES \ No newline at end of file + InjectHook(0x4C2EF0, &CEmergencyPed_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/peds/EmergencyPed.h b/src/peds/EmergencyPed.h index fa07f3ee..f21996e8 100644 --- a/src/peds/EmergencyPed.h +++ b/src/peds/EmergencyPed.h @@ -7,7 +7,5 @@ class CEmergencyPed : public CPed public: // 0x53C uint8 stuff[24]; - - void dtor(void) { this->CEmergencyPed::~CEmergencyPed(); } }; static_assert(sizeof(CEmergencyPed) == 0x554, "CEmergencyPed: error"); diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 016fea2f..20f26688 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -2893,9 +2893,28 @@ WRAPPER void CPed::PedLandCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0 WRAPPER void FinishFuckUCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4C6580); } WRAPPER void CPed::RestoreHeadingRateCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D6550); } +class CPed_ : public CPed +{ +public: + CPed* ctor(uint32 pedType) { return ::new (this) CPed(pedType); } + void dtor(void) { CPed::~CPed(); } + + void SetModelIndex_(uint32 mi) { CPed::SetModelIndex(mi); } + void FlagToDestroyWhenNextProcessed_(void) { CPed::FlagToDestroyWhenNextProcessed(); } + bool SetupLighting_(void) { return CPed::SetupLighting(); } + void RemoveLighting_(bool reset) { CPed::RemoveLighting(reset); } + void Teleport_(CVector pos) { CPed::Teleport(pos); } +}; + STARTPATCHES - InjectHook(0x4C41C0, &CPed::ctor, PATCH_JUMP); - InjectHook(0x4C50D0, &CPed::dtor, PATCH_JUMP); + InjectHook(0x4C41C0, &CPed_::ctor, PATCH_JUMP); + InjectHook(0x4C50D0, &CPed_::dtor, PATCH_JUMP); + InjectHook(0x4C52A0, &CPed_::SetModelIndex_, PATCH_JUMP); + InjectHook(0x4D6570, &CPed_::FlagToDestroyWhenNextProcessed_, PATCH_JUMP); + InjectHook(0x4A7D30, &CPed_::SetupLighting_, PATCH_JUMP); + InjectHook(0x4A7DC0, &CPed_::RemoveLighting_, PATCH_JUMP); + InjectHook(0x4D3E70, &CPed_::Teleport_, PATCH_JUMP); + InjectHook(0x4CF8F0, &CPed::AddWeaponModel, PATCH_JUMP); InjectHook(0x4C6AA0, &CPed::AimGun, PATCH_JUMP); InjectHook(0x4EB470, &CPed::ApplyHeadShot, PATCH_JUMP); @@ -2926,11 +2945,6 @@ STARTPATCHES InjectHook(0x4CC6C0, &CPed::PlayFootSteps, PATCH_JUMP); InjectHook(0x4C5350, &CPed::BuildPedLists, PATCH_JUMP); InjectHook(0x4CF9B0, &CPed::GiveWeapon, PATCH_JUMP); - InjectHook(0x4C52A0, &CPed::SetModelIndex_, PATCH_JUMP); - InjectHook(0x4D6570, &CPed::FlagToDestroyWhenNextProcessed_, PATCH_JUMP); - InjectHook(0x4A7D30, &CPed::SetupLighting_, PATCH_JUMP); - InjectHook(0x4A7DC0, &CPed::RemoveLighting_, PATCH_JUMP); - InjectHook(0x4D3E70, &CPed::Teleport_, PATCH_JUMP); InjectHook(0x4C7EA0, &CPed::CalculateNewOrientation, PATCH_JUMP); InjectHook(0x4C78F0, &CPed::WorkOutHeadingForMovingFirstPerson, PATCH_JUMP); InjectHook(0x4C73F0, &CPed::CalculateNewVelocity, PATCH_JUMP); diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 0493eeee..6b04404b 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -399,21 +399,19 @@ public: static void operator delete(void*, int); CPed(uint32 pedType); - virtual ~CPed(void); - - virtual void SetModelIndex(uint32 mi); - virtual void ProcessControl(void); - virtual void Teleport(CVector); - virtual void PreRender(void); - virtual void Render(void); - virtual bool SetupLighting(void); - virtual void RemoveLighting(bool); - virtual void FlagToDestroyWhenNextProcessed(void); - virtual int32 ProcessEntityCollision(CEntity*, CColPoint*); - virtual void SetMoveAnim(void); + ~CPed(void); + + void SetModelIndex(uint32 mi); + void ProcessControl(void); + void Teleport(CVector); + void PreRender(void); + void Render(void); + bool SetupLighting(void); + void RemoveLighting(bool); + void FlagToDestroyWhenNextProcessed(void); + int32 ProcessEntityCollision(CEntity*, CColPoint*); - CPed* ctor(uint32 pedType) { return ::new (this) CPed(pedType); } - void dtor(void) { this->CPed::~CPed(); } + virtual void SetMoveAnim(void); void AddWeaponModel(int id); void AimGun(void); @@ -465,7 +463,7 @@ public: void RegisterThreatWithGangPeds(CEntity*); bool TurnBody(void); void Chat(void); - void MakeChangesForNewWeapon(int8); + void MakeChangesForNewWeapon(int8); // Static methods @@ -545,13 +543,6 @@ public: PedState GetPedState(void) { return m_nPedState; } void SetPedState(PedState state) { m_nPedState = state; } - // to make patching virtual functions possible - void SetModelIndex_(uint32 mi) { CPed::SetModelIndex(mi); } - void FlagToDestroyWhenNextProcessed_(void) { CPed::FlagToDestroyWhenNextProcessed(); } - bool SetupLighting_(void) { return CPed::SetupLighting(); } - void RemoveLighting_(bool reset) { CPed::RemoveLighting(reset); } - void Teleport_(CVector pos) { CPed::Teleport(pos); } - // set by 0482:set_threat_reaction_range_multiplier opcode static uint16 &distanceMultToCountPedNear; diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 7eb01db0..07cb5541 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -21,8 +21,13 @@ void CPlayerPed::ClearWeaponTarget() ClearPointGunAt(); } -STARTPATCHES -InjectHook(0x4EFB30, &CPlayerPed::dtor, PATCH_JUMP); -InjectHook(0x4F28A0, &CPlayerPed::ClearWeaponTarget, PATCH_JUMP); +class CPlayerPed_ : public CPlayerPed +{ +public: + void dtor(void) { CPlayerPed::~CPlayerPed(); } +}; -ENDPATCHES \ No newline at end of file +STARTPATCHES + InjectHook(0x4EFB30, &CPlayerPed_::dtor, PATCH_JUMP); + InjectHook(0x4F28A0, &CPlayerPed::ClearWeaponTarget, PATCH_JUMP); +ENDPATCHES diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h index 4f325da3..1a106b38 100644 --- a/src/peds/PlayerPed.h +++ b/src/peds/PlayerPed.h @@ -41,7 +41,6 @@ public: ~CPlayerPed(); - void dtor(void) { this->CPlayerPed::~CPlayerPed(); } void ReApplyMoveAnims(void); void ClearWeaponTarget(); }; -- cgit v1.2.3 From edf5ac2626ce17b74037281aa3c9730902b4b1d4 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 8 Jul 2019 17:07:34 +0200 Subject: little changes; one more function of CAutomobile --- src/peds/Ped.cpp | 28 ++++++++++++++-------------- src/peds/Ped.h | 23 +---------------------- 2 files changed, 15 insertions(+), 36 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 20f26688..692fc4f2 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -63,7 +63,7 @@ CPed::~CPed(void) CWorld::Remove(this); CRadar::ClearBlipForEntity(BLIP_CHAR, CPools::GetPedPool()->GetIndex(this)); if (bInVehicle && m_pMyVehicle){ - uint8 door_flag = GetVehEnterExitFlag(m_vehEnterType); + uint8 door_flag = GetVehDoorFlag(m_vehEnterType); if (m_pMyVehicle->pDriver == this) m_pMyVehicle->pDriver = nil; else { @@ -309,7 +309,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) m_fRotationCur = 0.0f; m_headingRate = 15.0f; m_fRotationDest = 0.0f; - m_vehEnterType = VEHICLE_ENTER_FRONT_LEFT; + m_vehEnterType = CAR_DOOR_LF; m_walkAroundType = 0; m_pCurrentPhysSurface = nil; m_vecOffsetFromPhysSurface = CVector(0.0f, 0.0f, 0.0f); @@ -1334,7 +1334,7 @@ CPed::BeingDraggedFromCar(void) if (animAssoc) animAssoc->blendDelta = -1000.0f; - if (m_vehEnterType == VEHICLE_ENTER_FRONT_LEFT || m_vehEnterType == VEHICLE_ENTER_REAR_LEFT) { + if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR) { if (m_ped_flagF10) { enterAnim = ANIM_CAR_QJACKED; } else if (m_pMyVehicle->bLowVehicle) { @@ -1342,7 +1342,7 @@ CPed::BeingDraggedFromCar(void) } else { enterAnim = ANIM_CAR_JACKED_LHS; } - } else if (m_vehEnterType == VEHICLE_ENTER_FRONT_RIGHT || m_vehEnterType == VEHICLE_ENTER_REAR_RIGHT) { + } else if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR) { if (m_pMyVehicle->bLowVehicle) enterAnim = ANIM_CAR_LJACKED_RHS; else @@ -1396,7 +1396,7 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg) ped->m_pSeekTarget = nil; vehicle = ped->m_pMyVehicle; - vehicle->m_nGettingOutFlags &= ~GetVehEnterExitFlag(ped->m_vehEnterType); + vehicle->m_nGettingOutFlags &= ~GetVehDoorFlag(ped->m_vehEnterType); if (vehicle->pDriver == ped) { vehicle->RemoveDriver(); @@ -1448,7 +1448,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter float seatOffset; vehModel = (CVehicleModelInfo*) CModelInfo::GetModelInfo(veh->m_modelIndex); - if (veh->bIsVan && (enterType == VEHICLE_ENTER_REAR_LEFT || enterType == VEHICLE_ENTER_REAR_RIGHT)) { + if (veh->bIsVan && (enterType == CAR_DOOR_LR || enterType == CAR_DOOR_RR)) { seatOffset = 0.0f; vehDoorOffset = offsetToOpenVanDoor; } else { @@ -1461,7 +1461,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter } switch (enterType) { - case VEHICLE_ENTER_FRONT_RIGHT: + case CAR_DOOR_RF: if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_BOAT_RUDDER]; else @@ -1471,13 +1471,13 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter vehDoorOffset.x = -vehDoorOffset.x; break; - case VEHICLE_ENTER_REAR_RIGHT: + case CAR_DOOR_RR: vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_REAR_SEATS]; vehDoorPos.x += seatOffset; vehDoorOffset.x = -vehDoorOffset.x; break; - case VEHICLE_ENTER_FRONT_LEFT: + case CAR_DOOR_LF: if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_BOAT_RUDDER]; else @@ -1486,7 +1486,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter vehDoorPos.x = -(vehDoorPos.x + seatOffset); break; - case VEHICLE_ENTER_REAR_LEFT: + case CAR_DOOR_LR: vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_REAR_SEATS]; vehDoorPos.x = -(vehDoorPos.x + seatOffset); break; @@ -1584,7 +1584,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) if (veh->GetUp().z <= -0.8f) vehIsUpsideDown = true; - if (m_vehEnterType == VEHICLE_ENTER_FRONT_RIGHT || m_vehEnterType == VEHICLE_ENTER_REAR_RIGHT) { + if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR) { if (vehIsUpsideDown) { m_fRotationDest = -PI + veh->GetForward().Heading(); } else if (veh->bIsBus) { @@ -1592,7 +1592,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) } else { m_fRotationDest = veh->GetForward().Heading(); } - } else if (m_vehEnterType == VEHICLE_ENTER_FRONT_LEFT || m_vehEnterType == VEHICLE_ENTER_REAR_LEFT) { + } else if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR) { if (vehIsUpsideDown) { m_fRotationDest = veh->GetForward().Heading(); } else if (veh->bIsBus) { @@ -1763,7 +1763,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) CMatrix vehDoorMat(veh->GetMatrix()); GetLocalPositionToOpenCarDoor(&output, veh, m_vehEnterType, 0.0f); - *vehDoorMat.GetPosition() += Multiply3x3(vehDoorMat, output); + vehDoorMat.GetPosition() += Multiply3x3(vehDoorMat, output); GetMatrix() = vehDoorMat; } @@ -2696,7 +2696,7 @@ CPed::QuitEnteringCar(void) if (veh->m_nNumGettingIn != 0) veh->m_nNumGettingIn--; - veh->m_nGettingInFlags = GetVehEnterExitFlag(m_vehEnterType); + veh->m_nGettingInFlags = GetVehDoorFlag(m_vehEnterType); } bUsesCollision = true; diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 6b04404b..2390d1d4 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -76,13 +76,6 @@ enum eObjective : uint32 { OBJECTIVE_35 }; -enum eVehEnter : uint16 { - VEHICLE_ENTER_FRONT_RIGHT = 11, - VEHICLE_ENTER_REAR_RIGHT = 12, - VEHICLE_ENTER_FRONT_LEFT = 15, - VEHICLE_ENTER_REAR_LEFT = 16, -}; - enum { RANDOM_CHAR = 1, MISSION_CHAR, @@ -321,7 +314,7 @@ public: float m_fRotationCur; float m_fRotationDest; float m_headingRate; - eVehEnter m_vehEnterType; + uint16 m_vehEnterType; uint16 m_walkAroundType; CEntity *m_pCurrentPhysSurface; CVector m_vecOffsetFromPhysSurface; @@ -526,20 +519,6 @@ public: CWeapon &GetWeapon(uint8 weaponType) { return m_weapons[weaponType]; } CWeapon *GetWeapon(void) { return &m_weapons[m_currentWeapon]; } RwFrame *GetNodeFrame(int nodeId) { return m_pFrames[nodeId]->frame; } - static uint8 GetVehEnterExitFlag(eVehEnter vehEnter) { - switch (vehEnter) { - case VEHICLE_ENTER_FRONT_RIGHT: - return 4; - case VEHICLE_ENTER_REAR_RIGHT: - return 8; - case VEHICLE_ENTER_FRONT_LEFT: - return 1; - case VEHICLE_ENTER_REAR_LEFT: - return 2; - default: - return 0; - } - } PedState GetPedState(void) { return m_nPedState; } void SetPedState(PedState state) { m_nPedState = state; } -- cgit v1.2.3 From 2ae112fdf6b90bb4435dba34bcc2a23604e1e158 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 8 Jul 2019 21:37:47 +0200 Subject: more CAutomobile --- src/peds/Ped.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 692fc4f2..bf36d403 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -669,7 +669,7 @@ CPed::AimGun(void) vector.y = pos.y; vector.z = pos.z; } else { - vector = *(m_pSeekTarget->GetPosition()); + vector = m_pSeekTarget->GetPosition(); } Say(SOUND_PED_ATTACK); @@ -1540,7 +1540,7 @@ CPed::GetPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, GetLocalPositionToOpenCarDoor(output, veh, enterType, offset); doorPos = Multiply3x3(vehMat, *output); - *output = *veh->GetPosition() + doorPos; + *output = veh->GetPosition() + doorPos; } void @@ -1659,7 +1659,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) CVector neededPos; if (phase == LINE_UP_TO_CAR_2) { - neededPos = *GetPosition(); + neededPos = GetPosition(); } else { GetPositionToOpenCarDoor(&neededPos, veh, m_vehEnterType, seatPosMult); } @@ -2087,7 +2087,7 @@ CPed::CalculateNewOrientation(void) if (CReplay::IsPlayingBack() || !IsPedInControl()) return; - CVector pos = *GetPosition(); + CVector pos = GetPosition(); GetMatrix().SetRotate(0.0f, 0.0f, m_fRotationCur); -- cgit v1.2.3 From 74fcbc8c0a6bbac8e8057655c5f1133e15c63656 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 9 Jul 2019 09:57:44 +0200 Subject: more CAutomobile --- src/peds/Ped.cpp | 15 ++++++++------- src/peds/Ped.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index bf36d403..e0e0b913 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -10,6 +10,7 @@ #include "Ped.h" #include "PlayerPed.h" #include "General.h" +#include "SurfaceTable.h" #include "VisibilityPlugins.h" #include "AudioManager.h" #include "HandlingMgr.h" @@ -430,7 +431,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) m_ped_flagI1 = false; m_ped_flagI2 = false; m_ped_flagI4 = false; - bRecordedForReplay = false; + bHasAlreadyBeenRecorded = false; m_ped_flagI10 = false; #ifdef KANGAROO_CHEAT m_ped_flagI80 = false; @@ -1772,12 +1773,12 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) static void particleProduceFootDust(CPed *ped, CVector *pos, float size, int times) { - switch (ped->m_nLastCollType) + switch (ped->m_nSurfaceTouched) { - case 1: // somewhere hard - case 3: // soft dirt - case 5: // pavement - case 18:// sand + case SURFACE_TARMAC: + case SURFACE_DIRT: + case SURFACE_PAVEMENT: + case SURFACE_SAND: for (int i = 0; i < times; ++i) { CVector adjustedPos = *pos; adjustedPos.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f); @@ -1879,7 +1880,7 @@ CPed::PlayFootSteps(void) } } - if (m_nLastCollType == 19) { // Water + if (m_nSurfaceTouched == SURFACE_PUDDLE) { float pedSpeed = CVector2D(m_vecMoveSpeed).Magnitude(); if (pedSpeed > 0.03f && CTimer::GetFrameCounter() % 2 == 0 && pedSpeed > 0.13f) { float particleSize = pedSpeed * 2.0f; diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 2390d1d4..6aba79cf 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -251,7 +251,7 @@ public: uint8 m_ped_flagI1 : 1; uint8 m_ped_flagI2 : 1; uint8 m_ped_flagI4 : 1; - uint8 bRecordedForReplay : 1; + uint8 bHasAlreadyBeenRecorded : 1; uint8 m_ped_flagI10 : 1; uint8 m_ped_flagI20 : 1; uint8 m_ped_flagI40 : 1; -- cgit v1.2.3 From a65dd41da736a12866526abc1405cbaa154771a8 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 9 Jul 2019 18:50:35 +0200 Subject: yet more CAutomobile --- src/peds/Ped.cpp | 1 + src/peds/Ped.h | 1 + src/peds/PlayerPed.cpp | 13 +++++++++++++ src/peds/PlayerPed.h | 2 ++ 4 files changed, 17 insertions(+) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index e0e0b913..28cb8823 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -28,6 +28,7 @@ WRAPPER void CPed::KillPedWithCar(CVehicle *veh, float impulse) { EAXJMP(0x4EC430); } WRAPPER void CPed::Say(uint16 audio) { EAXJMP(0x4E5A10); } WRAPPER void CPed::SetDie(AnimationId anim, float arg1, float arg2) { EAXJMP(0x4D37D0); } +WRAPPER void CPed::SetDead(void) { EAXJMP(0x4D3970); } WRAPPER void CPed::SpawnFlyingComponent(int, int8) { EAXJMP(0x4EB060); } WRAPPER void CPed::RestorePreviousState(void) { EAXJMP(0x4C5E30); } WRAPPER void CPed::ClearAttack(void) { EAXJMP(0x4E6790); } diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 6aba79cf..f48c30ba 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -414,6 +414,7 @@ public: void SetLookFlag(float direction, bool unknown); void SetLookTimer(int time); void SetDie(AnimationId anim, float arg1, float arg2); + void SetDead(void); void ApplyHeadShot(eWeaponType weaponType, CVector pos, bool evenOnPlayer); void RemoveBodyPart(PedNode nodeId, int8 unknown); void SpawnFlyingComponent(int, int8 unknown); diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 07cb5541..43206e08 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -21,6 +21,19 @@ void CPlayerPed::ClearWeaponTarget() ClearPointGunAt(); } +void +CPlayerPed::SetWantedLevel(int32 level) +{ + m_pWanted->SetWantedLevel(level); +} + +void +CPlayerPed::SetWantedLevelNoDrop(int32 level) +{ + m_pWanted->SetWantedLevelNoDrop(level); +} + + class CPlayerPed_ : public CPlayerPed { public: diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h index 1a106b38..8b617a43 100644 --- a/src/peds/PlayerPed.h +++ b/src/peds/PlayerPed.h @@ -43,6 +43,8 @@ public: void ReApplyMoveAnims(void); void ClearWeaponTarget(); + void SetWantedLevel(int32 level); + void SetWantedLevelNoDrop(int32 level); }; static_assert(sizeof(CPlayerPed) == 0x5F0, "CPlayerPed: error"); -- cgit v1.2.3 From 11ae1b06ae658db4be9675dcad4da30493ff0bbc Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Tue, 9 Jul 2019 23:38:05 +0300 Subject: RunningScript: 1/12 --- src/peds/PlayerPed.cpp | 3 +++ src/peds/PlayerPed.h | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'src/peds') diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 07cb5541..9005e29f 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -10,6 +10,9 @@ CPlayerPed::~CPlayerPed() } WRAPPER void CPlayerPed::ReApplyMoveAnims(void) { EAXJMP(0x4F07C0); } +WRAPPER void CPlayerPed::SetupPlayerPed(int32) { EAXJMP(0x4EFB60); } +WRAPPER void CPlayerPed::DeactivatePlayerPed(int32) { EAXJMP(0x4EFC00); } +WRAPPER void CPlayerPed::ReactivatePlayerPed(int32) { EAXJMP(0x4EFC20); } void CPlayerPed::ClearWeaponTarget() { diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h index 1a106b38..25bbdf4a 100644 --- a/src/peds/PlayerPed.h +++ b/src/peds/PlayerPed.h @@ -43,6 +43,10 @@ public: void ReApplyMoveAnims(void); void ClearWeaponTarget(); + + static void SetupPlayerPed(int32); + static void DeactivatePlayerPed(int32); + static void ReactivatePlayerPed(int32); }; static_assert(sizeof(CPlayerPed) == 0x5F0, "CPlayerPed: error"); -- cgit v1.2.3 From 86681c6f18b5741ba25bbbb7319bb832ffa4807a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Wed, 10 Jul 2019 09:06:43 +0300 Subject: Phone start, ped spinning and cop car fix, and some love to CPed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: eray orçunus --- src/peds/Ped.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- src/peds/Ped.h | 11 ++++++----- 2 files changed, 44 insertions(+), 7 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 692fc4f2..cce5d6a9 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -23,6 +23,7 @@ #include "Lights.h" #include "PointLights.h" #include "Pad.h" +#include "Phones.h" WRAPPER void CPed::KillPedWithCar(CVehicle *veh, float impulse) { EAXJMP(0x4EC430); } WRAPPER void CPed::Say(uint16 audio) { EAXJMP(0x4E5A10); } @@ -42,6 +43,7 @@ WRAPPER void CPed::SetFollowRoute(int16, int16) { EAXJMP(0x4DD690); } WRAPPER void CPed::SetDuck(uint32) { EAXJMP(0x4E4920); } WRAPPER void CPed::RegisterThreatWithGangPeds(CEntity*) { EAXJMP(0x4E3870); } WRAPPER void CPed::MakeChangesForNewWeapon(int8) { EAXJMP(0x4F2560); } +WRAPPER bool CPed::Seek(void) { EAXJMP(0x4D1640); } bool &CPed::bNastyLimbsCheat = *(bool*)0x95CD44; bool &CPed::bPedCheat2 = *(bool*)0x95CD5A; @@ -1389,7 +1391,7 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg) if (ped->m_nPedState != PED_ARRESTED) { ped->m_nLastPedState = PED_NONE; if (dragAssoc) - dragAssoc->blendDelta = -1000.0; + dragAssoc->blendDelta = -1000.0f; } ped->RestartNonPartialAnims(); ped->m_pVehicleAnim = nil; @@ -2055,6 +2057,7 @@ CPed::SetupLighting(void) { ActivateDirectional(); SetAmbientColoursForPedsCarsAndObjects(); + if (bRenderScorched) { WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f); } else { @@ -2696,7 +2699,7 @@ CPed::QuitEnteringCar(void) if (veh->m_nNumGettingIn != 0) veh->m_nNumGettingIn--; - veh->m_nGettingInFlags = GetVehDoorFlag(m_vehEnterType); + veh->m_nGettingInFlags = ~GetVehDoorFlag(m_vehEnterType); } bUsesCollision = true; @@ -2869,6 +2872,38 @@ CPed::Chat(void) } } +void +CPed::CheckAroundForPossibleCollisions(void) +{ + CVector ourCentre, objCentre; + CEntity *objects[8]; + int16 maxObject; + + if (CTimer::GetTimeInMilliseconds() <= m_nPedStateTimer) + return; + + GetBoundCentre(ourCentre); + + CWorld::FindObjectsInRange(ourCentre, 10.0f, true, &maxObject, 6, objects, false, true, false, true, false); + for (int i = 0; i < maxObject; i++) { + CEntity *object = objects[i]; + if (field_31C) { + if (gPhoneInfo.PhoneAtThisPosition(object->GetPosition())) + break; + } + object->GetBoundCentre(objCentre); + float radius = object->GetBoundRadius(); + if (radius > 4.5f || radius < 1.0f) + radius = 1.0f; + + // According to code, developers gave up calculating Z diff. later. + float diff = CVector(ourCentre - objCentre).MagnitudeSqr2D(); + + if (sq(radius + 1.0f) > diff) + m_fRotationDest += DEGTORAD(22.5f); + } +} + WRAPPER void CPed::PedGetupCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CE810); } WRAPPER void CPed::PedStaggerCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CE8D0); } WRAPPER void CPed::PedEvadeCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D36E0); } @@ -2961,4 +2996,5 @@ STARTPATCHES InjectHook(0x4D3C80, &CPed::ClearChat, PATCH_JUMP); InjectHook(0x4D1390, &CPed::TurnBody, PATCH_JUMP); InjectHook(0x4D3AC0, &CPed::Chat, PATCH_JUMP); + InjectHook(0x4D0490, &CPed::CheckAroundForPossibleCollisions, PATCH_JUMP); ENDPATCHES diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 2390d1d4..4909a583 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -13,7 +13,7 @@ struct CPathNode; -enum eWaitState : uint32 { +enum eWaitState { WAITSTATE_FALSE, WAITSTATE_TRAFFIC_LIGHTS, WAITSTATE_CROSS_ROAD, @@ -292,10 +292,10 @@ public: int32 m_nPrevActionState; eWaitState m_nWaitState; uint32 m_nWaitTimer; - void *m_pPathNodesStates[8]; + void *m_pPathNodesStates[8]; // seems unused CVector2D m_stPathNodeStates[10]; uint16 m_nPathNodes; - uint8 m_nCurPathNode; + int16 m_nCurPathNode; int8 m_nPathState; private: int8 _pad2B5[3]; @@ -324,7 +324,7 @@ public: CVehicle *m_pMyVehicle; bool bInVehicle; uint8 pad_315[3]; - uint32 field_318; + float field_318; uint8 field_31C; uint8 field_31D; int16 m_phoneId; @@ -457,7 +457,8 @@ public: bool TurnBody(void); void Chat(void); void MakeChangesForNewWeapon(int8); - + void CheckAroundForPossibleCollisions(void); + bool Seek(void); // Static methods static void GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, float offset); -- cgit v1.2.3 From 4a36d64f15f898854bb8a76be86ac9a8c536b291 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 10 Jul 2019 17:18:26 +0200 Subject: added wrappers around math functions --- src/peds/Ped.cpp | 18 +++++++++--------- src/peds/PedIK.cpp | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 8ebe456f..c9a9cfb5 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -551,7 +551,7 @@ CheckForPedsOnGroundToAttack(CPlayerPed *player, CPed **pedOnGround) angleToFace = CGeneral::LimitRadianAngle(angleToFace); player->m_fRotationCur = CGeneral::LimitRadianAngle(player->m_fRotationCur); - angleDiff = fabs(angleToFace - player->m_fRotationCur); + angleDiff = Abs(angleToFace - player->m_fRotationCur); if (angleDiff > PI) angleDiff = 2 * PI - angleDiff; @@ -872,7 +872,7 @@ CPed::Avoid(void) // If so, we want to avoid it, so we turn our body 45 degree and look to somewhere else. // Game converts from radians to degress and back again here, doesn't make much sense - CVector2D forward(-sin(m_fRotationCur), cos(m_fRotationCur)); + CVector2D forward(-sin(m_fRotationCur), Cos(m_fRotationCur)); forward.Normalise(); // this is kinda pointless // Move forward 1.25 meters @@ -2151,10 +2151,10 @@ CPed::CalculateNewVelocity(void) } } - CVector2D forward(sin(m_fRotationCur), cos(m_fRotationCur)); + CVector2D forward(Sin(m_fRotationCur), Cos(m_fRotationCur)); - m_moved.x = CrossProduct2D(m_vecAnimMoveDelta, forward); // (m_vecAnimMoveDelta.x * cos(m_fRotationCur)) + -sin(m_fRotationCur) * m_vecAnimMoveDelta.y; - m_moved.y = DotProduct2D(m_vecAnimMoveDelta, forward); // m_vecAnimMoveDelta.y* cos(m_fRotationCur) + (m_vecAnimMoveDelta.x * sin(m_fRotationCur)); + m_moved.x = CrossProduct2D(m_vecAnimMoveDelta, forward); // (m_vecAnimMoveDelta.x * Cos(m_fRotationCur)) + -sin(m_fRotationCur) * m_vecAnimMoveDelta.y; + m_moved.y = DotProduct2D(m_vecAnimMoveDelta, forward); // m_vecAnimMoveDelta.y* Cos(m_fRotationCur) + (m_vecAnimMoveDelta.x * Sin(m_fRotationCur)); if (CTimer::GetTimeStep() >= 0.01f) { m_moved = m_moved * (1 / CTimer::GetTimeStep()); @@ -2179,7 +2179,7 @@ CPed::CalculateNewVelocity(void) // Interestingly this part is responsible for diagonal walking. if (localWalkAngle > -DEGTORAD(50.0f) && localWalkAngle < DEGTORAD(50.0f)) { TheCamera.Cams[TheCamera.ActiveCam].m_fPlayerVelocity = pedSpeed; - m_moved = CVector2D(-sin(walkAngle), cos(walkAngle)) * pedSpeed; + m_moved = CVector2D(-sin(walkAngle), Cos(walkAngle)) * pedSpeed; } CAnimBlendAssociation *idleAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_IDLE_STANCE); @@ -2239,7 +2239,7 @@ CPed::CanPedDriveOff(void) bool CPed::CanPedJumpThis(int32 unused) { - CVector2D forward(-sin(m_fRotationCur), cos(m_fRotationCur)); + CVector2D forward(-sin(m_fRotationCur), Cos(m_fRotationCur)); CVector pos = GetPosition(); // wat? CVector forwardPos( @@ -2276,7 +2276,7 @@ CPed::CanSeeEntity(CEntity *entity, float threshold) else if (ourAngle > 2 * PI) ourAngle -= 2 * PI; - float neededTurn = fabs(neededAngle - ourAngle); + float neededTurn = Abs(neededAngle - ourAngle); return neededTurn < threshold || 2 * PI - threshold < neededTurn; } @@ -2811,7 +2811,7 @@ CPed::TurnBody(void) float neededTurn = currentRot - limitedLookDir; m_fRotationDest = limitedLookDir; - if (fabs(neededTurn) > 0.05f) { + if (Abs(neededTurn) > 0.05f) { doneSmoothly = false; currentRot -= neededTurn * 0.2f; } diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp index b9baf49c..0bd49459 100644 --- a/src/peds/PedIK.cpp +++ b/src/peds/PedIK.cpp @@ -34,8 +34,8 @@ CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool c // rotation == 0 -> looking in y direction // left? vector - float c = cos(m_ped->m_fRotationCur); - float s = sin(m_ped->m_fRotationCur); + float c = Cos(m_ped->m_fRotationCur); + float s = Sin(m_ped->m_fRotationCur); rightVector.x = -(c*mat->right.x + s*mat->right.y); rightVector.y = -(c*mat->up.x + s*mat->up.y); rightVector.z = -(c*mat->at.x + s*mat->at.y); -- cgit v1.2.3 From 90e093cd47fb2af10617b1d404fc65ca813782ec Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 10 Jul 2019 17:34:11 +0200 Subject: and of course the last commit didnt fix everything --- src/peds/Ped.cpp | 8 ++++---- src/peds/PedIK.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index c9a9cfb5..4ad4ac1b 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -872,7 +872,7 @@ CPed::Avoid(void) // If so, we want to avoid it, so we turn our body 45 degree and look to somewhere else. // Game converts from radians to degress and back again here, doesn't make much sense - CVector2D forward(-sin(m_fRotationCur), Cos(m_fRotationCur)); + CVector2D forward(-Sin(m_fRotationCur), Cos(m_fRotationCur)); forward.Normalise(); // this is kinda pointless // Move forward 1.25 meters @@ -2153,7 +2153,7 @@ CPed::CalculateNewVelocity(void) CVector2D forward(Sin(m_fRotationCur), Cos(m_fRotationCur)); - m_moved.x = CrossProduct2D(m_vecAnimMoveDelta, forward); // (m_vecAnimMoveDelta.x * Cos(m_fRotationCur)) + -sin(m_fRotationCur) * m_vecAnimMoveDelta.y; + m_moved.x = CrossProduct2D(m_vecAnimMoveDelta, forward); // (m_vecAnimMoveDelta.x * Cos(m_fRotationCur)) + -Sin(m_fRotationCur) * m_vecAnimMoveDelta.y; m_moved.y = DotProduct2D(m_vecAnimMoveDelta, forward); // m_vecAnimMoveDelta.y* Cos(m_fRotationCur) + (m_vecAnimMoveDelta.x * Sin(m_fRotationCur)); if (CTimer::GetTimeStep() >= 0.01f) { @@ -2179,7 +2179,7 @@ CPed::CalculateNewVelocity(void) // Interestingly this part is responsible for diagonal walking. if (localWalkAngle > -DEGTORAD(50.0f) && localWalkAngle < DEGTORAD(50.0f)) { TheCamera.Cams[TheCamera.ActiveCam].m_fPlayerVelocity = pedSpeed; - m_moved = CVector2D(-sin(walkAngle), Cos(walkAngle)) * pedSpeed; + m_moved = CVector2D(-Sin(walkAngle), Cos(walkAngle)) * pedSpeed; } CAnimBlendAssociation *idleAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_IDLE_STANCE); @@ -2239,7 +2239,7 @@ CPed::CanPedDriveOff(void) bool CPed::CanPedJumpThis(int32 unused) { - CVector2D forward(-sin(m_fRotationCur), Cos(m_fRotationCur)); + CVector2D forward(-Sin(m_fRotationCur), Cos(m_fRotationCur)); CVector pos = GetPosition(); // wat? CVector forwardPos( diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp index 0bd49459..9b3f401f 100644 --- a/src/peds/PedIK.cpp +++ b/src/peds/PedIK.cpp @@ -51,7 +51,7 @@ CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool c float dotProduct = DotProduct(mat->at, inversedForward); if(dotProduct > 1.0f) dotProduct = 1.0f; if(dotProduct < -1.0f) dotProduct = -1.0f; - float alpha = acos(dotProduct); + float alpha = Acos(dotProduct); if(mat->at.z < 0.0f) alpha = -alpha; -- cgit v1.2.3