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 immunity has changed.
This commit is contained in:
parent
ebc168e558
commit
732769aff2
@ -496,6 +496,7 @@ protected:
|
|||||||
Function mOnRotation;
|
Function mOnRotation;
|
||||||
Function mOnOption;
|
Function mOnOption;
|
||||||
Function mOnWorld;
|
Function mOnWorld;
|
||||||
|
Function mOnImmunity;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -1017,6 +1018,7 @@ public:
|
|||||||
void EmitVehicleRotation(Int32 vehicle_id);
|
void EmitVehicleRotation(Int32 vehicle_id);
|
||||||
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 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();
|
||||||
@ -1164,6 +1166,7 @@ private:
|
|||||||
Function mOnVehicleRotation;
|
Function mOnVehicleRotation;
|
||||||
Function mOnVehicleOption;
|
Function mOnVehicleOption;
|
||||||
Function mOnVehicleWorld;
|
Function mOnVehicleWorld;
|
||||||
|
Function mOnVehicleImmunity;
|
||||||
Function mOnServerOption;
|
Function mOnServerOption;
|
||||||
Function mOnScriptReload;
|
Function mOnScriptReload;
|
||||||
Function mOnScriptLoaded;
|
Function mOnScriptLoaded;
|
||||||
|
@ -846,6 +846,14 @@ void Core::EmitVehicleWorld(Int32 vehicle_id, Int32 old_world, Int32 new_world)
|
|||||||
Emit(mOnVehicleWorld, _vehicle.mObj, old_world, new_world);
|
Emit(mOnVehicleWorld, _vehicle.mObj, old_world, new_world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Core::EmitVehicleImmunity(Int32 vehicle_id, Int32 old_immunity, Int32 new_immunity)
|
||||||
|
{
|
||||||
|
VehicleInst & _vehicle = m_Vehicles.at(vehicle_id);
|
||||||
|
Emit(_vehicle.mOnImmunity, old_immunity, new_immunity);
|
||||||
|
Emit(mOnVehicleImmunity, _vehicle.mObj, old_immunity, new_immunity);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Core::EmitServerOption(Int32 option, bool value, Int32 header, Object & payload)
|
void Core::EmitServerOption(Int32 option, bool value, Int32 header, Object & payload)
|
||||||
{
|
{
|
||||||
|
@ -255,6 +255,7 @@ void Core::ResetFunc(VehicleInst & inst)
|
|||||||
inst.mOnRotation.ReleaseGently();
|
inst.mOnRotation.ReleaseGently();
|
||||||
inst.mOnOption.ReleaseGently();
|
inst.mOnOption.ReleaseGently();
|
||||||
inst.mOnWorld.ReleaseGently();
|
inst.mOnWorld.ReleaseGently();
|
||||||
|
inst.mOnImmunity.ReleaseGently();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -366,6 +367,7 @@ void Core::ResetFunc()
|
|||||||
Core::Get().mOnVehicleRotation.ReleaseGently();
|
Core::Get().mOnVehicleRotation.ReleaseGently();
|
||||||
Core::Get().mOnVehicleOption.ReleaseGently();
|
Core::Get().mOnVehicleOption.ReleaseGently();
|
||||||
Core::Get().mOnVehicleWorld.ReleaseGently();
|
Core::Get().mOnVehicleWorld.ReleaseGently();
|
||||||
|
Core::Get().mOnVehicleImmunity.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();
|
||||||
@ -482,6 +484,7 @@ Function & Core::GetEvent(Int32 evid)
|
|||||||
case EVT_VEHICLEROTATION: return mOnVehicleRotation;
|
case EVT_VEHICLEROTATION: return mOnVehicleRotation;
|
||||||
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_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;
|
||||||
@ -665,6 +668,7 @@ Function & Core::GetVehicleEvent(Int32 id, Int32 evid)
|
|||||||
case EVT_VEHICLEROTATION: return inst.mOnRotation;
|
case EVT_VEHICLEROTATION: return inst.mOnRotation;
|
||||||
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;
|
||||||
default: return NullFunction();
|
default: return NullFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,12 +312,22 @@ Int32 CVehicle::GetImmunity() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CVehicle::SetImmunity(Int32 flags) const
|
void CVehicle::SetImmunity(Int32 flags)
|
||||||
{
|
{
|
||||||
// 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->GetVehicleImmunityFlags(m_ID);
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
_Func->SetVehicleImmunityFlags(m_ID, flags);
|
_Func->SetVehicleImmunityFlags(m_ID, flags);
|
||||||
|
// Avoid infinite recursive event loops
|
||||||
|
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_IMMUNITY))
|
||||||
|
{
|
||||||
|
// Prevent this event from triggering while executed
|
||||||
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_IMMUNITY);
|
||||||
|
// Now forward the event call
|
||||||
|
Core::Get().EmitVehicleImmunity(m_ID, current, flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -13,7 +13,8 @@ namespace SqMod {
|
|||||||
enum VehicleCircularLocks
|
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)
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@ -259,7 +260,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the immunity flags of the managed vehicle entity.
|
* Modify the immunity flags of the managed vehicle entity.
|
||||||
*/
|
*/
|
||||||
void SetImmunity(Int32 flags) const;
|
void SetImmunity(Int32 flags);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Explode the managed vehicle entity.
|
* Explode the managed vehicle entity.
|
||||||
|
@ -391,6 +391,7 @@ enum EventType
|
|||||||
EVT_VEHICLEROTATION,
|
EVT_VEHICLEROTATION,
|
||||||
EVT_VEHICLEOPTION,
|
EVT_VEHICLEOPTION,
|
||||||
EVT_VEHICLEWORLD,
|
EVT_VEHICLEWORLD,
|
||||||
|
EVT_VEHICLEIMMUNITY,
|
||||||
EVT_SERVEROPTION,
|
EVT_SERVEROPTION,
|
||||||
EVT_SCRIPTRELOAD,
|
EVT_SCRIPTRELOAD,
|
||||||
EVT_SCRIPTLOADED,
|
EVT_SCRIPTLOADED,
|
||||||
|
Loading…
Reference in New Issue
Block a user