mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-21 12:17:12 +01:00
Implement a new event to receive notifications when a vehicle tyre status has changed.
This commit is contained in:
parent
23948b5903
commit
05443ba2d4
@ -498,6 +498,7 @@ protected:
|
|||||||
Function mOnWorld;
|
Function mOnWorld;
|
||||||
Function mOnImmunity;
|
Function mOnImmunity;
|
||||||
Function mOnPartStatus;
|
Function mOnPartStatus;
|
||||||
|
Function mOnTyreStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -1021,6 +1022,7 @@ public:
|
|||||||
void EmitVehicleWorld(Int32 vehicle_id, Int32 old_world, Int32 new_world);
|
void EmitVehicleWorld(Int32 vehicle_id, Int32 old_world, Int32 new_world);
|
||||||
void EmitVehicleImmunity(Int32 vehicle_id, Int32 old_immunity, Int32 new_immunity);
|
void EmitVehicleImmunity(Int32 vehicle_id, Int32 old_immunity, Int32 new_immunity);
|
||||||
void EmitVehiclePartStatus(Int32 vehicle_id, Int32 old_status, Int32 new_status);
|
void EmitVehiclePartStatus(Int32 vehicle_id, Int32 old_status, Int32 new_status);
|
||||||
|
void EmitVehicleTyreStatus(Int32 vehicle_id, Int32 old_status, Int32 new_status);
|
||||||
void EmitServerOption(Int32 option, bool value, Int32 header, Object & payload);
|
void EmitServerOption(Int32 option, bool value, Int32 header, Object & payload);
|
||||||
void EmitScriptReload(Int32 header, Object & payload);
|
void EmitScriptReload(Int32 header, Object & payload);
|
||||||
void EmitScriptLoaded();
|
void EmitScriptLoaded();
|
||||||
@ -1170,6 +1172,7 @@ private:
|
|||||||
Function mOnVehicleWorld;
|
Function mOnVehicleWorld;
|
||||||
Function mOnVehicleImmunity;
|
Function mOnVehicleImmunity;
|
||||||
Function mOnVehiclePartStatus;
|
Function mOnVehiclePartStatus;
|
||||||
|
Function mOnVehicleTyreStatus;
|
||||||
Function mOnServerOption;
|
Function mOnServerOption;
|
||||||
Function mOnScriptReload;
|
Function mOnScriptReload;
|
||||||
Function mOnScriptLoaded;
|
Function mOnScriptLoaded;
|
||||||
|
@ -862,6 +862,14 @@ void Core::EmitVehiclePartStatus(Int32 vehicle_id, Int32 old_status, Int32 new_s
|
|||||||
Emit(mOnVehiclePartStatus, _vehicle.mObj, old_status, new_status);
|
Emit(mOnVehiclePartStatus, _vehicle.mObj, old_status, new_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Core::EmitVehicleTyreStatus(Int32 vehicle_id, Int32 old_status, Int32 new_status)
|
||||||
|
{
|
||||||
|
VehicleInst & _vehicle = m_Vehicles.at(vehicle_id);
|
||||||
|
Emit(_vehicle.mOnTyreStatus, old_status, new_status);
|
||||||
|
Emit(mOnVehicleTyreStatus, _vehicle.mObj, old_status, new_status);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Core::EmitServerOption(Int32 option, bool value, Int32 header, Object & payload)
|
void Core::EmitServerOption(Int32 option, bool value, Int32 header, Object & payload)
|
||||||
{
|
{
|
||||||
|
@ -257,6 +257,7 @@ void Core::ResetFunc(VehicleInst & inst)
|
|||||||
inst.mOnWorld.ReleaseGently();
|
inst.mOnWorld.ReleaseGently();
|
||||||
inst.mOnImmunity.ReleaseGently();
|
inst.mOnImmunity.ReleaseGently();
|
||||||
inst.mOnPartStatus.ReleaseGently();
|
inst.mOnPartStatus.ReleaseGently();
|
||||||
|
inst.mOnTyreStatus.ReleaseGently();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -370,6 +371,7 @@ void Core::ResetFunc()
|
|||||||
Core::Get().mOnVehicleWorld.ReleaseGently();
|
Core::Get().mOnVehicleWorld.ReleaseGently();
|
||||||
Core::Get().mOnVehicleImmunity.ReleaseGently();
|
Core::Get().mOnVehicleImmunity.ReleaseGently();
|
||||||
Core::Get().mOnVehiclePartStatus.ReleaseGently();
|
Core::Get().mOnVehiclePartStatus.ReleaseGently();
|
||||||
|
Core::Get().mOnVehicleTyreStatus.ReleaseGently();
|
||||||
Core::Get().mOnServerOption.ReleaseGently();
|
Core::Get().mOnServerOption.ReleaseGently();
|
||||||
Core::Get().mOnScriptReload.ReleaseGently();
|
Core::Get().mOnScriptReload.ReleaseGently();
|
||||||
Core::Get().mOnScriptLoaded.ReleaseGently();
|
Core::Get().mOnScriptLoaded.ReleaseGently();
|
||||||
@ -488,6 +490,7 @@ Function & Core::GetEvent(Int32 evid)
|
|||||||
case EVT_VEHICLEWORLD: return mOnVehicleWorld;
|
case EVT_VEHICLEWORLD: return mOnVehicleWorld;
|
||||||
case EVT_VEHICLEIMMUNITY: return mOnVehicleImmunity;
|
case EVT_VEHICLEIMMUNITY: return mOnVehicleImmunity;
|
||||||
case EVT_VEHICLEPARTSTATUS: return mOnVehiclePartStatus;
|
case EVT_VEHICLEPARTSTATUS: return mOnVehiclePartStatus;
|
||||||
|
case EVT_VEHICLETYRESTATUS: return mOnVehicleTyreStatus;
|
||||||
case EVT_SERVEROPTION: return mOnServerOption;
|
case EVT_SERVEROPTION: return mOnServerOption;
|
||||||
case EVT_SCRIPTRELOAD: return mOnScriptReload;
|
case EVT_SCRIPTRELOAD: return mOnScriptReload;
|
||||||
case EVT_SCRIPTLOADED: return mOnScriptLoaded;
|
case EVT_SCRIPTLOADED: return mOnScriptLoaded;
|
||||||
@ -673,6 +676,7 @@ Function & Core::GetVehicleEvent(Int32 id, Int32 evid)
|
|||||||
case EVT_VEHICLEWORLD: return inst.mOnWorld;
|
case EVT_VEHICLEWORLD: return inst.mOnWorld;
|
||||||
case EVT_VEHICLEIMMUNITY: return inst.mOnImmunity;
|
case EVT_VEHICLEIMMUNITY: return inst.mOnImmunity;
|
||||||
case EVT_VEHICLEPARTSTATUS: return inst.mOnPartStatus;
|
case EVT_VEHICLEPARTSTATUS: return inst.mOnPartStatus;
|
||||||
|
case EVT_VEHICLETYRESTATUS: return inst.mOnTyreStatus;
|
||||||
default: return NullFunction();
|
default: return NullFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -894,16 +894,31 @@ Int32 CVehicle::GetTyreStatus(Int32 tyre) const
|
|||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
// Return the requested information
|
// 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 the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
// Perform the requested operation
|
// Grab the current value for this property
|
||||||
_Func->SetVehicleTyreStatus(m_ID, tyre, status);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -15,7 +15,8 @@ enum VehicleCircularLocks
|
|||||||
VEHICLECL_EMIT_VEHICLE_OPTION = (1 << 0),
|
VEHICLECL_EMIT_VEHICLE_OPTION = (1 << 0),
|
||||||
VEHICLECL_EMIT_VEHICLE_WORLD = (2 << 0),
|
VEHICLECL_EMIT_VEHICLE_WORLD = (2 << 0),
|
||||||
VEHICLECL_EMIT_VEHICLE_IMMUNITY = (3 << 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.
|
* 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.
|
* Retrieve the damage data of the managed vehicle entity.
|
||||||
|
@ -393,6 +393,7 @@ enum EventType
|
|||||||
EVT_VEHICLEWORLD,
|
EVT_VEHICLEWORLD,
|
||||||
EVT_VEHICLEIMMUNITY,
|
EVT_VEHICLEIMMUNITY,
|
||||||
EVT_VEHICLEPARTSTATUS,
|
EVT_VEHICLEPARTSTATUS,
|
||||||
|
EVT_VEHICLETYRESTATUS,
|
||||||
EVT_SERVEROPTION,
|
EVT_SERVEROPTION,
|
||||||
EVT_SCRIPTRELOAD,
|
EVT_SCRIPTRELOAD,
|
||||||
EVT_SCRIPTLOADED,
|
EVT_SCRIPTLOADED,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user