mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Implement a new event to receive notifications when a vehicle handling rule has changed.
This commit is contained in:
parent
db522913d3
commit
f86c12bff2
@ -501,6 +501,7 @@ protected:
|
||||
Function mOnTyreStatus;
|
||||
Function mOnDamageData;
|
||||
Function mOnRadio;
|
||||
Function mOnHandlingRule;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -1027,6 +1028,7 @@ public:
|
||||
void EmitVehicleTyreStatus(Int32 vehicle_id, Int32 old_status, Int32 new_status);
|
||||
void EmitVehicleDamageData(Int32 vehicle_id, Uint32 old_data, Uint32 new_data);
|
||||
void EmitVehicleRadio(Int32 vehicle_id, Int32 old_radio, Int32 new_radio);
|
||||
void EmitVehicleHandlingRule(Int32 vehicle_id, Float32 old_data, Float32 new_data);
|
||||
void EmitServerOption(Int32 option, bool value, Int32 header, Object & payload);
|
||||
void EmitScriptReload(Int32 header, Object & payload);
|
||||
void EmitScriptLoaded();
|
||||
@ -1179,6 +1181,7 @@ private:
|
||||
Function mOnVehicleTyreStatus;
|
||||
Function mOnVehicleDamageData;
|
||||
Function mOnVehicleRadio;
|
||||
Function mOnVehicleHandlingRule;
|
||||
Function mOnServerOption;
|
||||
Function mOnScriptReload;
|
||||
Function mOnScriptLoaded;
|
||||
|
@ -885,6 +885,15 @@ void Core::EmitVehicleRadio(Int32 vehicle_id, Int32 old_radio, Int32 new_radio)
|
||||
Emit(_vehicle.mOnRadio, old_radio, new_radio);
|
||||
Emit(mOnVehicleRadio, _vehicle.mObj, old_radio, new_radio);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Core::EmitVehicleHandlingRule(Int32 vehicle_id, Float32 old_data, Float32 new_data)
|
||||
{
|
||||
VehicleInst & _vehicle = m_Vehicles.at(vehicle_id);
|
||||
Emit(_vehicle.mOnHandlingRule, old_data, new_data);
|
||||
Emit(mOnVehicleHandlingRule, _vehicle.mObj, old_data, new_data);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Core::EmitServerOption(Int32 option, bool value, Int32 header, Object & payload)
|
||||
{
|
||||
|
@ -260,6 +260,7 @@ void Core::ResetFunc(VehicleInst & inst)
|
||||
inst.mOnTyreStatus.ReleaseGently();
|
||||
inst.mOnDamageData.ReleaseGently();
|
||||
inst.mOnRadio.ReleaseGently();
|
||||
inst.mOnHandlingRule.ReleaseGently();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -376,6 +377,7 @@ void Core::ResetFunc()
|
||||
Core::Get().mOnVehicleTyreStatus.ReleaseGently();
|
||||
Core::Get().mOnVehicleDamageData.ReleaseGently();
|
||||
Core::Get().mOnVehicleRadio.ReleaseGently();
|
||||
Core::Get().mOnVehicleHandlingRule.ReleaseGently();
|
||||
Core::Get().mOnServerOption.ReleaseGently();
|
||||
Core::Get().mOnScriptReload.ReleaseGently();
|
||||
Core::Get().mOnScriptLoaded.ReleaseGently();
|
||||
@ -497,6 +499,7 @@ Function & Core::GetEvent(Int32 evid)
|
||||
case EVT_VEHICLETYRESTATUS: return mOnVehicleTyreStatus;
|
||||
case EVT_VEHICLEDAMAGEDATA: return mOnVehicleDamageData;
|
||||
case EVT_VEHICLERADIO: return mOnVehicleRadio;
|
||||
case EVT_VEHICLEHANDLINGRULE: return mOnVehicleHandlingRule;
|
||||
case EVT_SERVEROPTION: return mOnServerOption;
|
||||
case EVT_SCRIPTRELOAD: return mOnScriptReload;
|
||||
case EVT_SCRIPTLOADED: return mOnScriptLoaded;
|
||||
@ -685,6 +688,7 @@ Function & Core::GetVehicleEvent(Int32 id, Int32 evid)
|
||||
case EVT_VEHICLETYRESTATUS: return inst.mOnTyreStatus;
|
||||
case EVT_VEHICLEDAMAGEDATA: return inst.mOnDamageData;
|
||||
case EVT_VEHICLERADIO: return inst.mOnRadio;
|
||||
case EVT_VEHICLEHANDLINGRULE: return inst.mOnHandlingRule;
|
||||
default: return NullFunction();
|
||||
}
|
||||
}
|
||||
|
@ -1045,21 +1045,41 @@ Float32 CVehicle::GetHandlingRule(Int32 rule) const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CVehicle::SetHandlingRule(Int32 rule, Float32 data) const
|
||||
void CVehicle::SetHandlingRule(Int32 rule, Float32 data)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const Float32 current = _Func->GetInstHandlingRule(m_ID, rule);
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->SetInstHandlingRule(m_ID, rule, data);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_HANDLINGRULE))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_HANDLINGRULE);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitVehicleHandlingRule(m_ID, current, data);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CVehicle::ResetHandlingRule(Int32 rule) const
|
||||
void CVehicle::ResetHandlingRule(Int32 rule)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const Float32 current = _Func->GetInstHandlingRule(m_ID, rule);
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->ResetInstHandlingRule(m_ID, rule);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_HANDLINGRULE))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_HANDLINGRULE);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitVehicleHandlingRule(m_ID, current, _Func->GetInstHandlingRule(m_ID, rule));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -18,7 +18,8 @@ enum VehicleCircularLocks
|
||||
VEHICLECL_EMIT_VEHICLE_PARTSTATUS = (4 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_TYRESTATUS = (5 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_DAMAGEDATA = (6 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_RADIO = (7 << 0)
|
||||
VEHICLECL_EMIT_VEHICLE_RADIO = (7 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_HANDLINGRULE = (8 << 0)
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@ -594,12 +595,12 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the handling data of the managed vehicle entity.
|
||||
*/
|
||||
void SetHandlingRule(Int32 rule, Float32 data) const;
|
||||
void SetHandlingRule(Int32 rule, Float32 data);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Reset the specified handling rule for the managed vehicle entity.
|
||||
*/
|
||||
void ResetHandlingRule(Int32 rule) const;
|
||||
void ResetHandlingRule(Int32 rule);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Reset all the handling rules for the managed vehicle entity.
|
||||
|
@ -396,6 +396,7 @@ enum EventType
|
||||
EVT_VEHICLETYRESTATUS,
|
||||
EVT_VEHICLEDAMAGEDATA,
|
||||
EVT_VEHICLERADIO,
|
||||
EVT_VEHICLEHANDLINGRULE,
|
||||
EVT_SERVEROPTION,
|
||||
EVT_SCRIPTRELOAD,
|
||||
EVT_SCRIPTLOADED,
|
||||
|
Loading…
Reference in New Issue
Block a user