1
0
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 tyre status has changed.

This commit is contained in:
Sandu Liviu Catalin
2016-08-18 14:56:38 +03:00
parent 23948b5903
commit 05443ba2d4
6 changed files with 38 additions and 6 deletions

View File

@ -894,16 +894,31 @@ Int32 CVehicle::GetTyreStatus(Int32 tyre) const
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetVehicleTyreStatus(m_ID, tyre);
return _Func->(m_ID, tyre);
}
// ------------------------------------------------------------------------------------------------
void CVehicle::SetTyreStatus(Int32 tyre, Int32 status) const
void CVehicle::SetTyreStatus(Int32 tyre, Int32 status)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleTyreStatus(m_ID, tyre, status);
// Grab the current value for this property
const Int32 current = _Func->GetVehicleTyreStatus(m_ID);
// Don't even bother if it's the same value
if (current == status)
{
return;
}
// Avoid property unwind from a recursive call
_Func->SetVehicleTyreStatus(m_ID, status);
// Avoid infinite recursive event loops
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_TYRESTATUS))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_TYRESTATUS);
// Now forward the event call
Core::Get().EmitVehicleTyreStatus(m_ID, current, status);
}
}
// ------------------------------------------------------------------------------------------------

View File

@ -15,7 +15,8 @@ enum VehicleCircularLocks
VEHICLECL_EMIT_VEHICLE_OPTION = (1 << 0),
VEHICLECL_EMIT_VEHICLE_WORLD = (2 << 0),
VEHICLECL_EMIT_VEHICLE_IMMUNITY = (3 << 0),
VEHICLECL_EMIT_VEHICLE_PARTSTATUS = (4 << 0)
VEHICLECL_EMIT_VEHICLE_PARTSTATUS = (4 << 0),
VEHICLECL_EMIT_VEHICLE_TYRESTATUS = (5 << 0)
};
/* ------------------------------------------------------------------------------------------------
@ -541,7 +542,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the tyre status of the managed vehicle entity.
*/
void SetTyreStatus(Int32 tyre, Int32 status) const;
void SetTyreStatus(Int32 tyre, Int32 status);
/* --------------------------------------------------------------------------------------------
* Retrieve the damage data of the managed vehicle entity.