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 radio has changed.
This commit is contained in:
@ -964,12 +964,27 @@ Int32 CVehicle::GetRadio() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CVehicle::SetRadio(Int32 radio) const
|
||||
void CVehicle::SetRadio(Int32 radio)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const Int32 current = _Func->GetVehicleRadio(m_ID);
|
||||
// Don't even bother if it's the same value
|
||||
if (current == radio)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->SetVehicleRadio(m_ID, radio);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_RADIO))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_RADIO);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitVehicleRadio(m_ID, current, radio);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -17,7 +17,8 @@ enum VehicleCircularLocks
|
||||
VEHICLECL_EMIT_VEHICLE_IMMUNITY = (3 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_PARTSTATUS = (4 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_TYRESTATUS = (5 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_DAMAGEDATA = (6 << 0)
|
||||
VEHICLECL_EMIT_VEHICLE_DAMAGEDATA = (6 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_RADIO = (7 << 0)
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@ -563,7 +564,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the radio of the managed vehicle entity.
|
||||
*/
|
||||
void SetRadio(Int32 radio) const;
|
||||
void SetRadio(Int32 radio);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the turret rotation of the managed vehicle entity.
|
||||
|
Reference in New Issue
Block a user