Removed !this check in CVehicle::IsWrecked, added CPed::IsNotInWreckedVehicle instead

This commit is contained in:
Sergeanur 2019-10-12 17:03:32 +03:00
parent 6f96098549
commit 35add59b34
3 changed files with 15 additions and 8 deletions

View File

@ -6134,7 +6134,7 @@ CPed::EndFight(uint8 endType)
void void
CPed::EnterCar(void) CPed::EnterCar(void)
{ {
if (!m_pMyVehicle->IsWrecked() && m_fHealth > 0.0f) { if (IsNotInWreckedVehicle() && m_fHealth > 0.0f) {
CVehicle *veh = (CVehicle*)m_pSeekTarget; CVehicle *veh = (CVehicle*)m_pSeekTarget;
// Not used. // Not used.
@ -9022,7 +9022,7 @@ CPed::PedAnimAlignCB(CAnimBlendAssociation *animAssoc, void *arg)
if (animAssoc) if (animAssoc)
animAssoc->blendDelta = -1000.0f; animAssoc->blendDelta = -1000.0f;
if (veh->IsWrecked()) if (!ped->IsNotInWreckedVehicle())
return; return;
if (ped->m_nPedState != PED_ENTER_CAR && ped->m_nPedState != PED_CARJACK) { if (ped->m_nPedState != PED_ENTER_CAR && ped->m_nPedState != PED_CARJACK) {
@ -10484,7 +10484,7 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
CAutomobile *veh = (CAutomobile*)(ped->m_pMyVehicle); CAutomobile *veh = (CAutomobile*)(ped->m_pMyVehicle);
if (veh->IsWrecked() || ped->DyingOrDead()) if (!ped->IsNotInWreckedVehicle() || ped->DyingOrDead())
return; return;
if (ped->m_nPedState == PED_CARJACK || ped->m_nPedState == PED_ENTER_CAR) { if (ped->m_nPedState == PED_CARJACK || ped->m_nPedState == PED_ENTER_CAR) {
@ -10577,7 +10577,7 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg)
if (animAssoc) if (animAssoc)
animAssoc->blendDelta = -1000.0f; animAssoc->blendDelta = -1000.0f;
if (veh->IsWrecked()) if (!ped->IsNotInWreckedVehicle())
return; return;
if (ped->m_nPedState != PED_CARJACK && ped->m_nPedState != PED_ENTER_CAR) { if (ped->m_nPedState != PED_CARJACK && ped->m_nPedState != PED_ENTER_CAR) {
@ -10816,7 +10816,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
if (animAssoc) if (animAssoc)
animAssoc->blendDelta = -1000.0f; animAssoc->blendDelta = -1000.0f;
if (veh->IsWrecked() || ped->DyingOrDead()) if (!ped->IsNotInWreckedVehicle() || ped->DyingOrDead())
return; return;
if (ped->m_nPedState != PED_CARJACK && ped->m_nPedState != PED_ENTER_CAR) { if (ped->m_nPedState != PED_CARJACK && ped->m_nPedState != PED_ENTER_CAR) {
@ -10957,7 +10957,7 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg)
animAssoc->blendDelta = -1000.0f; animAssoc->blendDelta = -1000.0f;
if (ped->m_nPedState == PED_CARJACK || ped->m_nPedState == PED_ENTER_CAR) { if (ped->m_nPedState == PED_CARJACK || ped->m_nPedState == PED_ENTER_CAR) {
if (veh->IsWrecked()) if (!ped->IsNotInWreckedVehicle())
return; return;
bool isLow = veh->bLowVehicle; bool isLow = veh->bLowVehicle;
@ -11322,7 +11322,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
if (!veh) if (!veh)
return; return;
if (veh->IsWrecked() || ped->DyingOrDead()) if (!ped->IsNotInWreckedVehicle() || ped->DyingOrDead())
return; return;
ped->bInVehicle = true; ped->bInVehicle = true;
@ -14631,6 +14631,12 @@ CPed::SetRadioStation(void)
} }
} }
bool
CPed::IsNotInWreckedVehicle()
{
return m_pMyVehicle != nil && !m_pMyVehicle->IsWrecked();
}
class CPed_ : public CPed class CPed_ : public CPed
{ {
public: public:

View File

@ -764,6 +764,7 @@ public:
void SetPedState(PedState state) { m_nPedState = state; } void SetPedState(PedState state) { m_nPedState = state; }
bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; } bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
void ReplaceWeaponWhenExitingVehicle(void); void ReplaceWeaponWhenExitingVehicle(void);
bool IsNotInWreckedVehicle();
// set by 0482:set_threat_reaction_range_multiplier opcode // set by 0482:set_threat_reaction_range_multiplier opcode
static uint16 &nThreatReactionRangeMultiplier; static uint16 &nThreatReactionRangeMultiplier;

View File

@ -266,7 +266,7 @@ public:
bool ShufflePassengersToMakeSpace(void); bool ShufflePassengersToMakeSpace(void);
bool IsAlarmOn(void) { return m_nAlarmState != 0 && m_nAlarmState != -1; } bool IsAlarmOn(void) { return m_nAlarmState != 0 && m_nAlarmState != -1; }
bool IsWrecked(void) { return !this || m_status == STATUS_WRECKED; } bool IsWrecked(void) { return m_status == STATUS_WRECKED; }
CVehicleModelInfo* GetModelInfo() { return (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()); } CVehicleModelInfo* GetModelInfo() { return (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()); }
static bool &bWheelsOnlyCheat; static bool &bWheelsOnlyCheat;