mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-22 04:37:13 +01:00
Implement a new event to receive notifications when a vehicle radio has changed.
This commit is contained in:
parent
69325ed2cc
commit
db522913d3
@ -500,6 +500,7 @@ protected:
|
|||||||
Function mOnPartStatus;
|
Function mOnPartStatus;
|
||||||
Function mOnTyreStatus;
|
Function mOnTyreStatus;
|
||||||
Function mOnDamageData;
|
Function mOnDamageData;
|
||||||
|
Function mOnRadio;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -1025,6 +1026,7 @@ public:
|
|||||||
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 EmitVehicleTyreStatus(Int32 vehicle_id, Int32 old_status, Int32 new_status);
|
||||||
void EmitVehicleDamageData(Int32 vehicle_id, Uint32 old_data, Uint32 new_data);
|
void EmitVehicleDamageData(Int32 vehicle_id, Uint32 old_data, Uint32 new_data);
|
||||||
|
void EmitVehicleRadio(Int32 vehicle_id, Int32 old_radio, Int32 new_radio);
|
||||||
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();
|
||||||
@ -1176,6 +1178,7 @@ private:
|
|||||||
Function mOnVehiclePartStatus;
|
Function mOnVehiclePartStatus;
|
||||||
Function mOnVehicleTyreStatus;
|
Function mOnVehicleTyreStatus;
|
||||||
Function mOnVehicleDamageData;
|
Function mOnVehicleDamageData;
|
||||||
|
Function mOnVehicleRadio;
|
||||||
Function mOnServerOption;
|
Function mOnServerOption;
|
||||||
Function mOnScriptReload;
|
Function mOnScriptReload;
|
||||||
Function mOnScriptLoaded;
|
Function mOnScriptLoaded;
|
||||||
|
@ -878,6 +878,13 @@ void Core::EmitVehicleDamageData(Int32 vehicle_id, Uint32 old_data, Uint32 new_d
|
|||||||
Emit(mOnVehicleDamageData, _vehicle.mObj, old_data, new_data);
|
Emit(mOnVehicleDamageData, _vehicle.mObj, old_data, new_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Core::EmitVehicleRadio(Int32 vehicle_id, Int32 old_radio, Int32 new_radio)
|
||||||
|
{
|
||||||
|
VehicleInst & _vehicle = m_Vehicles.at(vehicle_id);
|
||||||
|
Emit(_vehicle.mOnRadio, old_radio, new_radio);
|
||||||
|
Emit(mOnVehicleRadio, _vehicle.mObj, old_radio, new_radio);
|
||||||
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Core::EmitServerOption(Int32 option, bool value, Int32 header, Object & payload)
|
void Core::EmitServerOption(Int32 option, bool value, Int32 header, Object & payload)
|
||||||
{
|
{
|
||||||
|
@ -259,6 +259,7 @@ void Core::ResetFunc(VehicleInst & inst)
|
|||||||
inst.mOnPartStatus.ReleaseGently();
|
inst.mOnPartStatus.ReleaseGently();
|
||||||
inst.mOnTyreStatus.ReleaseGently();
|
inst.mOnTyreStatus.ReleaseGently();
|
||||||
inst.mOnDamageData.ReleaseGently();
|
inst.mOnDamageData.ReleaseGently();
|
||||||
|
inst.mOnRadio.ReleaseGently();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -374,6 +375,7 @@ void Core::ResetFunc()
|
|||||||
Core::Get().mOnVehiclePartStatus.ReleaseGently();
|
Core::Get().mOnVehiclePartStatus.ReleaseGently();
|
||||||
Core::Get().mOnVehicleTyreStatus.ReleaseGently();
|
Core::Get().mOnVehicleTyreStatus.ReleaseGently();
|
||||||
Core::Get().mOnVehicleDamageData.ReleaseGently();
|
Core::Get().mOnVehicleDamageData.ReleaseGently();
|
||||||
|
Core::Get().mOnVehicleRadio.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();
|
||||||
@ -494,6 +496,7 @@ Function & Core::GetEvent(Int32 evid)
|
|||||||
case EVT_VEHICLEPARTSTATUS: return mOnVehiclePartStatus;
|
case EVT_VEHICLEPARTSTATUS: return mOnVehiclePartStatus;
|
||||||
case EVT_VEHICLETYRESTATUS: return mOnVehicleTyreStatus;
|
case EVT_VEHICLETYRESTATUS: return mOnVehicleTyreStatus;
|
||||||
case EVT_VEHICLEDAMAGEDATA: return mOnVehicleDamageData;
|
case EVT_VEHICLEDAMAGEDATA: return mOnVehicleDamageData;
|
||||||
|
case EVT_VEHICLERADIO: return mOnVehicleRadio;
|
||||||
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;
|
||||||
@ -681,6 +684,7 @@ Function & Core::GetVehicleEvent(Int32 id, Int32 evid)
|
|||||||
case EVT_VEHICLEPARTSTATUS: return inst.mOnPartStatus;
|
case EVT_VEHICLEPARTSTATUS: return inst.mOnPartStatus;
|
||||||
case EVT_VEHICLETYRESTATUS: return inst.mOnTyreStatus;
|
case EVT_VEHICLETYRESTATUS: return inst.mOnTyreStatus;
|
||||||
case EVT_VEHICLEDAMAGEDATA: return inst.mOnDamageData;
|
case EVT_VEHICLEDAMAGEDATA: return inst.mOnDamageData;
|
||||||
|
case EVT_VEHICLERADIO: return inst.mOnRadio;
|
||||||
default: return NullFunction();
|
default: return NullFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -964,12 +964,27 @@ Int32 CVehicle::GetRadio() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CVehicle::SetRadio(Int32 radio) const
|
void CVehicle::SetRadio(Int32 radio)
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
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);
|
_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_IMMUNITY = (3 << 0),
|
||||||
VEHICLECL_EMIT_VEHICLE_PARTSTATUS = (4 << 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)
|
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.
|
* 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.
|
* Retrieve the turret rotation of the managed vehicle entity.
|
||||||
|
@ -395,6 +395,7 @@ enum EventType
|
|||||||
EVT_VEHICLEPARTSTATUS,
|
EVT_VEHICLEPARTSTATUS,
|
||||||
EVT_VEHICLETYRESTATUS,
|
EVT_VEHICLETYRESTATUS,
|
||||||
EVT_VEHICLEDAMAGEDATA,
|
EVT_VEHICLEDAMAGEDATA,
|
||||||
|
EVT_VEHICLERADIO,
|
||||||
EVT_SERVEROPTION,
|
EVT_SERVEROPTION,
|
||||||
EVT_SCRIPTRELOAD,
|
EVT_SCRIPTRELOAD,
|
||||||
EVT_SCRIPTLOADED,
|
EVT_SCRIPTLOADED,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user