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 part status has changed.
This commit is contained in:
parent
732769aff2
commit
23948b5903
@ -497,6 +497,7 @@ protected:
|
|||||||
Function mOnOption;
|
Function mOnOption;
|
||||||
Function mOnWorld;
|
Function mOnWorld;
|
||||||
Function mOnImmunity;
|
Function mOnImmunity;
|
||||||
|
Function mOnPartStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -1019,6 +1020,7 @@ public:
|
|||||||
void EmitVehicleOption(Int32 vehicle_id, Int32 option_id, bool value, Int32 header, Object & payload);
|
void EmitVehicleOption(Int32 vehicle_id, Int32 option_id, bool value, Int32 header, Object & payload);
|
||||||
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 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();
|
||||||
@ -1167,6 +1169,7 @@ private:
|
|||||||
Function mOnVehicleOption;
|
Function mOnVehicleOption;
|
||||||
Function mOnVehicleWorld;
|
Function mOnVehicleWorld;
|
||||||
Function mOnVehicleImmunity;
|
Function mOnVehicleImmunity;
|
||||||
|
Function mOnVehiclePartStatus;
|
||||||
Function mOnServerOption;
|
Function mOnServerOption;
|
||||||
Function mOnScriptReload;
|
Function mOnScriptReload;
|
||||||
Function mOnScriptLoaded;
|
Function mOnScriptLoaded;
|
||||||
|
@ -854,6 +854,14 @@ void Core::EmitVehicleImmunity(Int32 vehicle_id, Int32 old_immunity, Int32 new_i
|
|||||||
Emit(mOnVehicleImmunity, _vehicle.mObj, old_immunity, new_immunity);
|
Emit(mOnVehicleImmunity, _vehicle.mObj, old_immunity, new_immunity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Core::EmitVehiclePartStatus(Int32 vehicle_id, Int32 old_status, Int32 new_status)
|
||||||
|
{
|
||||||
|
VehicleInst & _vehicle = m_Vehicles.at(vehicle_id);
|
||||||
|
Emit(_vehicle.mOnPartStatus, old_status, new_status);
|
||||||
|
Emit(mOnVehiclePartStatus, _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)
|
||||||
{
|
{
|
||||||
|
@ -256,6 +256,7 @@ void Core::ResetFunc(VehicleInst & inst)
|
|||||||
inst.mOnOption.ReleaseGently();
|
inst.mOnOption.ReleaseGently();
|
||||||
inst.mOnWorld.ReleaseGently();
|
inst.mOnWorld.ReleaseGently();
|
||||||
inst.mOnImmunity.ReleaseGently();
|
inst.mOnImmunity.ReleaseGently();
|
||||||
|
inst.mOnPartStatus.ReleaseGently();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -368,6 +369,7 @@ void Core::ResetFunc()
|
|||||||
Core::Get().mOnVehicleOption.ReleaseGently();
|
Core::Get().mOnVehicleOption.ReleaseGently();
|
||||||
Core::Get().mOnVehicleWorld.ReleaseGently();
|
Core::Get().mOnVehicleWorld.ReleaseGently();
|
||||||
Core::Get().mOnVehicleImmunity.ReleaseGently();
|
Core::Get().mOnVehicleImmunity.ReleaseGently();
|
||||||
|
Core::Get().mOnVehiclePartStatus.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();
|
||||||
@ -485,6 +487,7 @@ Function & Core::GetEvent(Int32 evid)
|
|||||||
case EVT_VEHICLEOPTION: return mOnVehicleOption;
|
case EVT_VEHICLEOPTION: return mOnVehicleOption;
|
||||||
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_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;
|
||||||
@ -669,6 +672,7 @@ Function & Core::GetVehicleEvent(Int32 id, Int32 evid)
|
|||||||
case EVT_VEHICLEOPTION: return inst.mOnOption;
|
case EVT_VEHICLEOPTION: return inst.mOnOption;
|
||||||
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;
|
||||||
default: return NullFunction();
|
default: return NullFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -865,12 +865,27 @@ Int32 CVehicle::GetPartStatus(Int32 part) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CVehicle::SetPartStatus(Int32 part, Int32 status) const
|
void CVehicle::SetPartStatus(Int32 part, Int32 status)
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
// Perform the requested operation
|
// Grab the current value for this property
|
||||||
_Func->SetVehiclePartStatus(m_ID, part, status);
|
const Int32 current = _Func->GetVehiclePartStatus(m_ID);
|
||||||
|
// Don't even bother if it's the same value
|
||||||
|
if (current == status)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetVehiclePartStatus(m_ID, status);
|
||||||
|
// Avoid infinite recursive event loops
|
||||||
|
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_PARTSTATUS))
|
||||||
|
{
|
||||||
|
// Prevent this event from triggering while executed
|
||||||
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_PARTSTATUS);
|
||||||
|
// Now forward the event call
|
||||||
|
Core::Get().EmitVehiclePartStatus(m_ID, current, status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -14,7 +14,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)
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@ -530,7 +531,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the part status of the managed vehicle entity.
|
* Modify the part status of the managed vehicle entity.
|
||||||
*/
|
*/
|
||||||
void SetPartStatus(Int32 part, Int32 status) const;
|
void SetPartStatus(Int32 part, Int32 status);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the tyre status of the managed vehicle entity.
|
* Retrieve the tyre status of the managed vehicle entity.
|
||||||
|
@ -392,6 +392,7 @@ enum EventType
|
|||||||
EVT_VEHICLEOPTION,
|
EVT_VEHICLEOPTION,
|
||||||
EVT_VEHICLEWORLD,
|
EVT_VEHICLEWORLD,
|
||||||
EVT_VEHICLEIMMUNITY,
|
EVT_VEHICLEIMMUNITY,
|
||||||
|
EVT_VEHICLEPARTSTATUS,
|
||||||
EVT_SERVEROPTION,
|
EVT_SERVEROPTION,
|
||||||
EVT_SCRIPTRELOAD,
|
EVT_SCRIPTRELOAD,
|
||||||
EVT_SCRIPTLOADED,
|
EVT_SCRIPTLOADED,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user