mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-16 07:07:13 +02:00
Implement a new event to receive notifications when a vehicle damage data has changed.
This commit is contained in:
@ -931,12 +931,27 @@ Uint32 CVehicle::GetDamageData() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CVehicle::SetDamageData(Uint32 data) const
|
||||
void CVehicle::SetDamageData(Uint32 data)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const Uint32 current = _Func->GetVehicleDamageData(m_ID);
|
||||
// Don't even bother if it's the same value
|
||||
if (current == data)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->SetVehicleDamageData(m_ID, data);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_DAMAGEDATA))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_DAMAGEDATA);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitVehicleDamageData(m_ID, current, data);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -16,7 +16,8 @@ enum VehicleCircularLocks
|
||||
VEHICLECL_EMIT_VEHICLE_WORLD = (2 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_IMMUNITY = (3 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_PARTSTATUS = (4 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_TYRESTATUS = (5 << 0)
|
||||
VEHICLECL_EMIT_VEHICLE_TYRESTATUS = (5 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_DAMAGEDATA = (6 << 0)
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@ -552,7 +553,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the damage data of the managed vehicle entity.
|
||||
*/
|
||||
void SetDamageData(Uint32 data) const;
|
||||
void SetDamageData(Uint32 data);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the radio of the managed vehicle entity.
|
||||
|
Reference in New Issue
Block a user