1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-10-29 13:27:18 +01:00

Restructure some files.

This commit is contained in:
Sandu Liviu Catalin
2018-07-29 12:25:44 +03:00
parent 526538fdb9
commit 0ad290ca34
27 changed files with 96 additions and 132 deletions

826
source/Core/Entity.inc Normal file
View File

@@ -0,0 +1,826 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// --------------------------------------------------------------------------------------------
void Core::ImportBlips()
{
// Information about the blip entity
Int32 world = -1, scale = -1, sprid = -1;
Uint32 color = 0;
Float32 x = 0.0, y = 0.0, z = 0.0;
for (Int32 i = 0; i < SQMOD_BLIP_POOL; ++i)
{
// See if this entity exists on the server and whether was not allocated already
if (_Func->CheckEntityExists(vcmpEntityPoolBlip, i) && INVALID_ENTITY(m_Blips[i].mID))
{
_Func->GetCoordBlipInfo(i, &world, &x, &y, &z, &scale, &color, &sprid);
// Make the properties available before triggering the event
m_Blips[i].mWorld = world;
m_Blips[i].mScale = scale;
m_Blips[i].mSprID = sprid;
m_Blips[i].mPosition.SetVector3Ex(x, y, z);
m_Blips[i].mColor.SetRGBA(color);
// Attempt to allocate the instance
AllocBlip(i, false, SQMOD_CREATE_IMPORT, NullLightObj());
}
}
}
// ------------------------------------------------------------------------------------------------
void Core::ImportCheckpoints()
{
for (Int32 i = 0; i < SQMOD_CHECKPOINT_POOL; ++i)
{
// See if this entity exists on the server and whether was not allocated already
if (_Func->CheckEntityExists(vcmpEntityPoolCheckPoint, i) && INVALID_ENTITY(m_Checkpoints[i].mID))
{
AllocCheckpoint(i, false, SQMOD_CREATE_IMPORT, NullLightObj());
}
}
}
// ------------------------------------------------------------------------------------------------
void Core::ImportKeybinds()
{
/* @NOTE This function is disabled because VC:MP server seems bugged
* and does not return vcmpErrorNoSuchEntity when the keybind does not exist.
* Therefore causing incorrect behavior in the plugin.
*/
return;
// Information about the key-bind entity
Uint8 release = 0;
Int32 first = -1, second = -1, third = -1;
for (Int32 i = 0; i < SQMOD_KEYBIND_POOL; ++i)
{
// See if this entity exists on the server and whether was not allocated already
if ((_Func->GetKeyBindData(i, &release, &first, &second, &third) != vcmpErrorNoSuchEntity)
&& (INVALID_ENTITY(m_Keybinds[i].mID)))
{
// Make the properties available before triggering the event
m_Keybinds[i].mFirst = first;
m_Keybinds[i].mSecond = second;
m_Keybinds[i].mThird = third;
m_Keybinds[i].mRelease = release;
// Attempt to allocate the instance
AllocKeybind(i, false, SQMOD_CREATE_IMPORT, NullLightObj());
}
}
}
// ------------------------------------------------------------------------------------------------
void Core::ImportObjects()
{
for (Int32 i = 0; i < SQMOD_OBJECT_POOL; ++i)
{
// See if this entity exists on the server and whether was not allocated already
if (_Func->CheckEntityExists(vcmpEntityPoolObject, i) && INVALID_ENTITY(m_Objects[i].mID))
{
AllocObject(i, false, SQMOD_CREATE_IMPORT, NullLightObj());
}
}
}
// ------------------------------------------------------------------------------------------------
void Core::ImportPickups()
{
for (Int32 i = 0; i < SQMOD_PICKUP_POOL; ++i)
{
// See if this entity exists on the server and whether was not allocated already
if (_Func->CheckEntityExists(vcmpEntityPoolPickup, i) && (INVALID_ENTITY(m_Pickups[i].mID)))
{
AllocPickup(i, false, SQMOD_CREATE_IMPORT, NullLightObj());
}
}
}
// ------------------------------------------------------------------------------------------------
void Core::ImportPlayers()
{
for (Int32 i = 0; i < SQMOD_PLAYER_POOL; ++i)
{
// See if this entity exists on the server and whether was not allocated already
if (_Func->IsPlayerConnected(i) && (INVALID_ENTITY(m_Players[i].mID)))
{
ConnectPlayer(i, SQMOD_CREATE_IMPORT, NullLightObj());
}
}
}
// ------------------------------------------------------------------------------------------------
void Core::ImportVehicles()
{
for (Int32 i = 0; i < SQMOD_VEHICLE_POOL; ++i)
{
// See if this entity exists on the server and whether was not allocated already
if (_Func->CheckEntityExists(vcmpEntityPoolVehicle, i) && INVALID_ENTITY(m_Vehicles[i].mID))
{
AllocVehicle(i, false, SQMOD_CREATE_IMPORT, NullLightObj());
}
}
}
// --------------------------------------------------------------------------------------------
Core::BlipInst & Core::AllocBlip(Int32 id, bool owned, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_BLIP_POOL))
{
STHROWF("Cannot allocate blip with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
BlipInst & inst = m_Blips[id];
// Make sure that the instance isn't already allocated
if (VALID_ENTITY(inst.mID))
{
return inst; // Return the existing instance
}
// Instantiate the entity manager
DeleteGuard< CBlip > dg(new CBlip(id));
// Create the script object
inst.mObj = LightObj(dg.Get(), m_VM);
// Store the manager instance itself
inst.mInst = dg.Get();
// The instance is now managed by the script
dg.Release();
// Make sure that both the instance and script object could be created
if (!inst.mInst || inst.mObj.IsNull())
{
inst.ResetInstance();
// Now we can throw the error
STHROWF("Unable to create a blip instance for: %d", id);
}
// Assign the specified entity identifier
inst.mID = id;
// Specify whether the entity is owned by this plug-in
if (owned)
{
inst.mFlags |= ENF_OWNED;
}
else if (inst.mFlags & ENF_OWNED)
{
inst.mFlags ^= ENF_OWNED;
}
// Initialize the instance events
inst.InitEvents();
// Let the script callbacks know about this entity
EmitBlipCreated(id, header, payload);
// Return the allocated instance
return inst;
}
// --------------------------------------------------------------------------------------------
Core::CheckpointInst & Core::AllocCheckpoint(Int32 id, bool owned, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_CHECKPOINT_POOL))
{
STHROWF("Cannot allocate checkpoint with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
CheckpointInst & inst = m_Checkpoints[id];
// Make sure that the instance isn't already allocated
if (VALID_ENTITY(inst.mID))
{
return inst; // Return the existing instance
}
// Instantiate the entity manager
DeleteGuard< CCheckpoint > dg(new CCheckpoint(id));
// Create the script object
inst.mObj = LightObj(dg.Get(), m_VM);
// Store the manager instance itself
inst.mInst = dg.Get();
// The instance is now managed by the script
dg.Release();
// Make sure that both the instance and script object could be created
if (!inst.mInst || inst.mObj.IsNull())
{
inst.ResetInstance();
// Now we can throw the error
STHROWF("Unable to create a checkpoint instance for: %d", id);
}
// Assign the specified entity identifier
inst.mID = id;
// Specify whether the entity is owned by this plug-in
if (owned)
{
inst.mFlags |= ENF_OWNED;
}
else if (inst.mFlags & ENF_OWNED)
{
inst.mFlags ^= ENF_OWNED;
}
// Initialize the instance events
inst.InitEvents();
// Let the script callbacks know about this entity
EmitCheckpointCreated(id, header, payload);
// Return the allocated instance
return inst;
}
// --------------------------------------------------------------------------------------------
Core::KeybindInst & Core::AllocKeybind(Int32 id, bool owned, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_KEYBIND_POOL))
{
STHROWF("Cannot allocate keybind with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
KeybindInst & inst = m_Keybinds[id];
// Make sure that the instance isn't already allocated
if (VALID_ENTITY(inst.mID))
{
return inst; // Return the existing instance
}
// Instantiate the entity manager
DeleteGuard< CKeybind > dg(new CKeybind(id));
// Create the script object
inst.mObj = LightObj(dg.Get(), m_VM);
// Store the manager instance itself
inst.mInst = dg.Get();
// The instance is now managed by the script
dg.Release();
// Make sure that both the instance and script object could be created
if (!inst.mInst || inst.mObj.IsNull())
{
inst.ResetInstance();
// Now we can throw the error
STHROWF("Unable to create a keybind instance for: %d", id);
}
// Assign the specified entity identifier
inst.mID = id;
// Specify whether the entity is owned by this plug-in
if (owned)
{
inst.mFlags |= ENF_OWNED;
}
else if (inst.mFlags & ENF_OWNED)
{
inst.mFlags ^= ENF_OWNED;
}
// Initialize the instance events
inst.InitEvents();
// Let the script callbacks know about this entity
EmitKeybindCreated(id, header, payload);
// Return the allocated instance
return inst;
}
// --------------------------------------------------------------------------------------------
Core::ObjectInst & Core::AllocObject(Int32 id, bool owned, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_OBJECT_POOL))
{
STHROWF("Cannot allocate object with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
ObjectInst & inst = m_Objects[id];
// Make sure that the instance isn't already allocated
if (VALID_ENTITY(inst.mID))
{
return inst; // Return the existing instance
}
// Instantiate the entity manager
DeleteGuard< CObject > dg(new CObject(id));
// Create the script object
inst.mObj = LightObj(dg.Get(), m_VM);
// Store the manager instance itself
inst.mInst = dg.Get();
// The instance is now managed by the script
dg.Release();
// Make sure that both the instance and script object could be created
if (!inst.mInst || inst.mObj.IsNull())
{
inst.ResetInstance();
// Now we can throw the error
STHROWF("Unable to create a object instance for: %d", id);
}
// Assign the specified entity identifier
inst.mID = id;
// Specify whether the entity is owned by this plug-in
if (owned)
{
inst.mFlags |= ENF_OWNED;
}
else if (inst.mFlags & ENF_OWNED)
{
inst.mFlags ^= ENF_OWNED;
}
// Initialize the instance events
inst.InitEvents();
// Let the script callbacks know about this entity
EmitObjectCreated(id, header, payload);
// Return the allocated instance
return inst;
}
// --------------------------------------------------------------------------------------------
Core::PickupInst & Core::AllocPickup(Int32 id, bool owned, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_PICKUP_POOL))
{
STHROWF("Cannot allocate pickup with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
PickupInst & inst = m_Pickups[id];
// Make sure that the instance isn't already allocated
if (VALID_ENTITY(inst.mID))
{
return inst; // Return the existing instance
}
// Instantiate the entity manager
DeleteGuard< CPickup > dg(new CPickup(id));
// Create the script object
inst.mObj = LightObj(dg.Get(), m_VM);
// Store the manager instance itself
inst.mInst = dg.Get();
// The instance is now managed by the script
dg.Release();
// Make sure that both the instance and script object could be created
if (!inst.mInst || inst.mObj.IsNull())
{
inst.ResetInstance();
// Now we can throw the error
STHROWF("Unable to create a pickup instance for: %d", id);
}
// Assign the specified entity identifier
inst.mID = id;
// Specify whether the entity is owned by this plug-in
if (owned)
{
inst.mFlags |= ENF_OWNED;
}
else if (inst.mFlags & ENF_OWNED)
{
inst.mFlags ^= ENF_OWNED;
}
// Initialize the instance events
inst.InitEvents();
// Let the script callbacks know about this entity
EmitPickupCreated(id, header, payload);
// Return the allocated instance
return inst;
}
// --------------------------------------------------------------------------------------------
Core::VehicleInst & Core::AllocVehicle(Int32 id, bool owned, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
{
STHROWF("Cannot allocate vehicle with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
VehicleInst & inst = m_Vehicles[id];
// Make sure that the instance isn't already allocated
if (VALID_ENTITY(inst.mID))
{
return inst; // Return the existing instance
}
// Instantiate the entity manager
DeleteGuard< CVehicle > dg(new CVehicle(id));
// Create the script object
inst.mObj = LightObj(dg.Get(), m_VM);
// Store the manager instance itself
inst.mInst = dg.Get();
// The instance is now managed by the script
dg.Release();
// Make sure that both the instance and script object could be created
if (!inst.mInst || inst.mObj.IsNull())
{
inst.ResetInstance();
// Now we can throw the error
STHROWF("Unable to create a vehicle instance for: %d", id);
}
// Assign the specified entity identifier
inst.mID = id;
// Specify whether the entity is owned by this plug-in
if (owned)
{
inst.mFlags |= ENF_OWNED;
}
else if (inst.mFlags & ENF_OWNED)
{
inst.mFlags ^= ENF_OWNED;
}
// Should we enable area tracking?
if (m_AreasEnabled)
{
inst.mFlags |= ENF_AREA_TRACK;
}
// Initialize the instance events
inst.InitEvents();
// Let the script callbacks know about this entity
EmitVehicleCreated(id, header, payload);
// Return the allocated instance
return inst;
}
// --------------------------------------------------------------------------------------------
void Core::DeallocBlip(Int32 id, bool destroy, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_BLIP_POOL))
{
STHROWF("Cannot deallocate blip with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
BlipInst & inst = m_Blips[id];
// Make sure that the instance is even allocated and we are allowed to destroy it
if (VALID_ENTITY(inst.mID) && !(inst.mFlags & ENF_LOCKED))
{
inst.Destroy(destroy, header, payload); // Now attempt to destroy the entity from the server
}
}
// --------------------------------------------------------------------------------------------
void Core::DeallocCheckpoint(Int32 id, bool destroy, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_CHECKPOINT_POOL))
{
STHROWF("Cannot deallocate checkpoint with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
CheckpointInst & inst = m_Checkpoints[id];
// Make sure that the instance is even allocated and we are allowed to destroy it
if (VALID_ENTITY(inst.mID) && !(inst.mFlags & ENF_LOCKED))
{
inst.Destroy(destroy, header, payload); // Now attempt to destroy the entity from the server
}
}
// --------------------------------------------------------------------------------------------
void Core::DeallocKeybind(Int32 id, bool destroy, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_KEYBIND_POOL))
{
STHROWF("Cannot deallocate keybind with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
KeybindInst & inst = m_Keybinds[id];
// Make sure that the instance is even allocated and we are allowed to destroy it
if (VALID_ENTITY(inst.mID) && !(inst.mFlags & ENF_LOCKED))
{
inst.Destroy(destroy, header, payload); // Now attempt to destroy the entity from the server
}
}
// --------------------------------------------------------------------------------------------
void Core::DeallocObject(Int32 id, bool destroy, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_OBJECT_POOL))
{
STHROWF("Cannot deallocate object with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
ObjectInst & inst = m_Objects[id];
// Make sure that the instance is even allocated and we are allowed to destroy it
if (VALID_ENTITY(inst.mID) && !(inst.mFlags & ENF_LOCKED))
{
inst.Destroy(destroy, header, payload); // Now attempt to destroy the entity from the server
}
}
// --------------------------------------------------------------------------------------------
void Core::DeallocPickup(Int32 id, bool destroy, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_PICKUP_POOL))
{
STHROWF("Cannot deallocate pickup with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
PickupInst & inst = m_Pickups[id];
// Make sure that the instance is even allocated and we are allowed to destroy it
if (VALID_ENTITY(inst.mID) && !(inst.mFlags & ENF_LOCKED))
{
inst.Destroy(destroy, header, payload); // Now attempt to destroy the entity from the server
}
}
// --------------------------------------------------------------------------------------------
void Core::DeallocVehicle(Int32 id, bool destroy, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
{
STHROWF("Cannot deallocate vehicle with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
VehicleInst & inst = m_Vehicles[id];
// Make sure that the instance is even allocated and we are allowed to destroy it
if (VALID_ENTITY(inst.mID) && !(inst.mFlags & ENF_LOCKED))
{
inst.Destroy(destroy, header, payload); // Now attempt to destroy the entity from the server
}
}
// --------------------------------------------------------------------------------------------
LightObj & Core::NewBlip(Int32 index, Int32 world, Float32 x, Float32 y, Float32 z,
Int32 scale, Uint32 color, Int32 sprid,
Int32 header, LightObj & payload)
{
// Request the server to create this entity
const Int32 id = _Func->CreateCoordBlip(index, world, x, y, z, scale, color, sprid);
// See if the entity creation failed on the server
if (_Func->GetLastError() == vcmpErrorPoolExhausted)
{
STHROWF("Blip pool was exhausted: %d", id);
}
// Validate the identifier returned by the server
else if (INVALID_ENTITYEX(id, SQMOD_BLIP_POOL))
{
STHROWF("Server returned invalid blip: %d", id);
}
// Attempt to allocate this entity and grab the reference to the instance
BlipInst & inst = AllocBlip(id, true, header, payload);
// Just in case it was created during the notification for changes in entity pool
if (VALID_ENTITY(inst.mID))
{
inst.mFlags |= ENF_OWNED;
}
// Now we can return the script object
return inst.mObj;
}
// --------------------------------------------------------------------------------------------
LightObj & Core::NewCheckpoint(Int32 player, Int32 world, bool sphere, Float32 x, Float32 y, Float32 z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius,
Int32 header, LightObj & payload)
{
// Request the server to create this entity
const Int32 id = _Func->CreateCheckPoint(player, world, sphere, x, y, z, r, g, b, a, radius);
// See if the entity creation failed on the server
if (_Func->GetLastError() == vcmpErrorNoSuchEntity)
{
STHROWF("Invalid player reference: %d", player);
}
else if (_Func->GetLastError() == vcmpErrorPoolExhausted)
{
STHROWF("Checkpoint pool was exhausted: %d", id);
}
// Validate the identifier returned by the server
else if (INVALID_ENTITYEX(id, SQMOD_CHECKPOINT_POOL))
{
STHROWF("Server returned invalid checkpoint: %d", id);
}
// Attempt to allocate this entity and grab the reference to the instance
CheckpointInst & inst = AllocCheckpoint(id, true, header, payload);
// Just in case it was created during the notification for changes in entity pool
if (VALID_ENTITY(inst.mID))
{
inst.mFlags |= ENF_OWNED;
}
// Now we can return the script object
return inst.mObj;
}
// --------------------------------------------------------------------------------------------
LightObj & Core::NewKeybind(Int32 slot, bool release, Int32 primary, Int32 secondary, Int32 alternative,
Int32 header, LightObj & payload)
{
// Should we obtain a new keybind slot automatically?
if (slot < 0)
{
slot = _Func->GetKeyBindUnusedSlot();
}
// Validate the keybind slot returned by the server
if (INVALID_ENTITYEX(slot, SQMOD_KEYBIND_POOL))
{
STHROWF("Server returned invalid keybind slot: %d", slot);
}
// Request the server to create this entity
const vcmpError result = _Func->RegisterKeyBind(slot, release, primary, secondary, alternative);
// See if the entity creation failed on the server
if (result == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Out of bounds keybind argument: %d", slot);
}
// Attempt to allocate this entity and grab the reference to the instance
KeybindInst & inst = AllocKeybind(slot, true, header, payload);
// Just in case it was created during the notification for changes in entity pool
if (VALID_ENTITY(inst.mID))
{
inst.mFlags |= ENF_OWNED;
}
// Now we can return the script object
return inst.mObj;
}
// --------------------------------------------------------------------------------------------
LightObj & Core::NewObject(Int32 model, Int32 world, Float32 x, Float32 y, Float32 z, Int32 alpha,
Int32 header, LightObj & payload)
{
// Request the server to create this entity
const Int32 id = _Func->CreateObject(model, world, x, y, z, alpha);
// See if the entity creation failed on the server
if (_Func->GetLastError() == vcmpErrorPoolExhausted)
{
STHROWF("Object pool was exhausted: %d", id);
}
// Validate the identifier returned by the server
else if (INVALID_ENTITYEX(id, SQMOD_OBJECT_POOL))
{
STHROWF("Server returned invalid object: %d", id);
}
// Attempt to allocate this entity and grab the reference to the instance
ObjectInst & inst = AllocObject(id, true, header, payload);
// Just in case it was created during the notification for changes in entity pool
if (VALID_ENTITY(inst.mID))
{
inst.mFlags |= ENF_OWNED;
}
// Now we can return the script object
return inst.mObj;
}
// --------------------------------------------------------------------------------------------
LightObj & Core::NewPickup(Int32 model, Int32 world, Int32 quantity,
Float32 x, Float32 y, Float32 z, Int32 alpha, bool automatic,
Int32 header, LightObj & payload)
{
// Request the server to create this entity
const Int32 id = _Func->CreatePickup(model, world, quantity, x, y, z, alpha, automatic);
// See if the entity creation failed on the server
if (_Func->GetLastError() == vcmpErrorPoolExhausted)
{
STHROWF("Pickup pool was exhausted: %d", id);
}
// Validate the identifier returned by the server
else if (INVALID_ENTITYEX(id, SQMOD_PICKUP_POOL))
{
STHROWF("Server returned invalid pickup: %d", id);
}
// Attempt to allocate this entity and grab the reference to the instance
PickupInst & inst = AllocPickup(id, true, header, payload);
// Just in case it was created during the notification for changes in entity pool
if (VALID_ENTITY(inst.mID))
{
inst.mFlags |= ENF_OWNED;
}
// Now we can return the script object
return inst.mObj;
}
// --------------------------------------------------------------------------------------------
LightObj & Core::NewVehicle(Int32 model, Int32 world, Float32 x, Float32 y, Float32 z,
Float32 angle, Int32 primary, Int32 secondary,
Int32 header, LightObj & payload)
{
// Request the server to create this entity
const Int32 id = _Func->CreateVehicle(model, world, x, y, z, angle, primary, secondary);
// See if the entity creation failed on the server
if (_Func->GetLastError() == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Out of bounds vehicle argument: %d", id);
}
else if (_Func->GetLastError() == vcmpErrorPoolExhausted)
{
STHROWF("Vehicle pool was exhausted: %d", id);
}
// Validate the identifier returned by the server
else if (INVALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
{
STHROWF("Server returned invalid vehicle: %d", id);
}
// Attempt to allocate this entity and grab the reference to the instance
VehicleInst & inst = AllocVehicle(id, true, header, payload);
// Just in case it was created during the notification for changes in entity pool
if (VALID_ENTITY(inst.mID))
{
inst.mFlags |= ENF_OWNED;
}
// Now we can return the script object
return inst.mObj;
}
// --------------------------------------------------------------------------------------------
bool Core::DelBlip(Int32 id, Int32 header, LightObj & payload)
{
// Attempt to destroy and deallocate the specified entity instance
DeallocBlip(id, true, header, payload);
// The entity could be destroyed
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DelCheckpoint(Int32 id, Int32 header, LightObj & payload)
{
// Attempt to destroy and deallocate the specified entity instance
DeallocCheckpoint(id, true, header, payload);
// The entity could be destroyed
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DelKeybind(Int32 id, Int32 header, LightObj & payload)
{
// Attempt to destroy and deallocate the specified entity instance
DeallocKeybind(id, true, header, payload);
// The entity could be destroyed
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DelObject(Int32 id, Int32 header, LightObj & payload)
{
// Attempt to destroy and deallocate the specified entity instance
DeallocObject(id, true, header, payload);
// The entity could be destroyed
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DelPickup(Int32 id, Int32 header, LightObj & payload)
{
// Attempt to destroy and deallocate the specified entity instance
DeallocPickup(id, true, header, payload);
// The entity could be destroyed
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DelVehicle(Int32 id, Int32 header, LightObj & payload)
{
// Attempt to destroy and deallocate the specified entity instance
DeallocVehicle(id, true, header, payload);
// The entity could be destroyed
return true;
}
// ------------------------------------------------------------------------------------------------
void Core::ConnectPlayer(Int32 id, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
{
STHROWF("Cannot allocate player with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
PlayerInst & inst = m_Players[id];
// Make sure that the instance isn't already allocated
if (VALID_ENTITY(inst.mID))
{
return; // Nothing to allocate!
}
// Instantiate the entity manager
DeleteGuard< CPlayer > dg(new CPlayer(id));
// Create the script object
inst.mObj = LightObj(dg.Get(), m_VM);
// Store the manager instance itself
inst.mInst = dg.Get();
// The instance is now managed by the script
dg.Release();
// Make sure that both the instance and script object could be created
if (!inst.mInst || inst.mObj.IsNull())
{
inst.ResetInstance();
STHROWF("Unable to create a player instance for: %d", id);
}
// Assign the specified entity identifier
inst.mID = id;
// Should we enable area tracking?
if (m_AreasEnabled)
{
inst.mFlags |= ENF_AREA_TRACK;
}
// Initialize the position
_Func->GetPlayerPosition(id, &inst.mLastPosition.x, &inst.mLastPosition.y, &inst.mLastPosition.z);
// Initialize the remaining attributes
inst.mLastWeapon = _Func->GetPlayerWeapon(id);
inst.mLastHealth = _Func->GetPlayerHealth(id);
inst.mLastArmour = _Func->GetPlayerArmour(id);
inst.mLastHeading = _Func->GetPlayerHeading(id);
// Initialize the instance events
inst.InitEvents();
// Let the script callbacks know about this entity
EmitPlayerCreated(id, header, payload);
}
// ------------------------------------------------------------------------------------------------
void Core::DisconnectPlayer(Int32 id, Int32 header, LightObj & payload)
{
// Make sure that the specified entity identifier is valid
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
{
STHROWF("Cannot deallocate player with invalid identifier: %d", id);
}
// Retrieve the specified entity instance
PlayerInst & inst = m_Players[id];
// Make sure that the instance is even allocated and we are allowed to destroy it
if (VALID_ENTITY(inst.mID) && !(inst.mFlags & ENF_LOCKED))
{
inst.Destroy(false, header, payload); // Now attempt to destroy the entity from the server
}
}
} // Namespace:: SqMod

1447
source/Core/Events.inc Normal file

File diff suppressed because it is too large Load Diff

360
source/Core/Funcs.inc Normal file
View File

@@ -0,0 +1,360 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
extern bool GetReloadStatus();
extern void SetReloadStatus(bool toggle);
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(CoreStateTypename, _SC("SqCoreState"))
// ------------------------------------------------------------------------------------------------
static SQInteger SqLoadScript(HSQUIRRELVM vm)
{
const Int32 top = sq_gettop(vm);
// Was the delay option specified?
if (top <= 1)
{
return sq_throwerror(vm, "Missing delay parameter");
}
// Was the script path specified?
else if (top <= 2)
{
return sq_throwerror(vm, "Missing script path");
}
// Whether the script execution is delayed
SQBool delay = SQFalse;
// Attempt to generate the string value
StackStrF val(vm, 3, true);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
{
return val.mRes; // Propagate the error!
}
else if (SQ_FAILED(sq_getbool(vm, 2, &delay)))
{
return sq_throwerror(vm, "Failed to retrieve the delay parameter");
}
// Forward the call to the actual implementation
sq_pushbool(vm, Core::Get().LoadScript(val.mPtr, static_cast< bool >(delay)));
// We have an argument on the stack
return 1;
}
// ------------------------------------------------------------------------------------------------
static SQInteger SqGetEvents(HSQUIRRELVM vm)
{
// Push the events table object on the stack
sq_pushobject(vm, Core::Get().GetEvents().mObj);
// Specify that we're returning a value
return 1;
}
// ------------------------------------------------------------------------------------------------
static LightObj & SqGetPreLoadEvent()
{
return Core::Get().GetPreLoadEvent();
}
// ------------------------------------------------------------------------------------------------
static LightObj & SqGetPostLoadEvent()
{
return Core::Get().GetPostLoadEvent();
}
// ------------------------------------------------------------------------------------------------
static LightObj & SqGetUnloadEvent()
{
return Core::Get().GetUnloadEvent();
}
// ------------------------------------------------------------------------------------------------
static bool SqGetReloadStatus()
{
return GetReloadStatus();
}
// ------------------------------------------------------------------------------------------------
static void SqSetReloadStatus(bool toggle)
{
SetReloadStatus(toggle);
}
// ------------------------------------------------------------------------------------------------
static void SqReloadBecause(Int32 header, LightObj & payload)
{
// Assign the reload info
Core::Get().SetReloadInfo(header, payload);
// Enable reloading
SetReloadStatus(true);
}
// ------------------------------------------------------------------------------------------------
static void SqSetReloadInfo(Int32 header, LightObj & payload)
{
Core::Get().SetReloadInfo(header, payload);
}
// ------------------------------------------------------------------------------------------------
static Int32 SqGetReloadHeader()
{
return Core::Get().GetReloadHeader();
}
// ------------------------------------------------------------------------------------------------
static LightObj & SqGetReloadPayload()
{
return Core::Get().GetReloadPayload();
}
// ------------------------------------------------------------------------------------------------
static Int32 SqGetState()
{
return Core::Get().GetState();
}
// ------------------------------------------------------------------------------------------------
static void SqSetState(Int32 value)
{
return Core::Get().SetState(value);
}
// ------------------------------------------------------------------------------------------------
static bool SqGetAreasEnabled()
{
return Core::Get().AreasEnabled();
}
// ------------------------------------------------------------------------------------------------
static void SqSetAreasEnabled(bool toggle)
{
Core::Get().AreasEnabled(toggle);
}
// ------------------------------------------------------------------------------------------------
static CSStr SqGetOption(CSStr name)
{
return Core::Get().GetOption(name);
}
// ------------------------------------------------------------------------------------------------
static CSStr SqGetOptionOr(CSStr name, CSStr value)
{
return Core::Get().GetOption(name, value);
}
// ------------------------------------------------------------------------------------------------
static void SqSetOption(CSStr name, CSStr value)
{
return Core::Get().SetOption(name, value);
}
// ------------------------------------------------------------------------------------------------
static LightObj & SqGetBlip(Int32 id)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_BLIP_POOL))
{
STHROWF("Out of range blip identifier: %d", id);
}
// Return the requested information
return Core::Get().GetBlip(id).mObj;
}
// ------------------------------------------------------------------------------------------------
static LightObj & SqGetCheckpoint(Int32 id)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_CHECKPOINT_POOL))
{
STHROWF("Out of range checkpoint identifier: %d", id);
}
// Return the requested information
return Core::Get().GetCheckpoint(id).mObj;
}
// ------------------------------------------------------------------------------------------------
static LightObj & SqGetKeybind(Int32 id)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_KEYBIND_POOL))
{
STHROWF("Out of range keybind identifier: %d", id);
}
// Return the requested information
return Core::Get().GetKeybind(id).mObj;
}
// ------------------------------------------------------------------------------------------------
static LightObj & SqGetObject(Int32 id)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_OBJECT_POOL))
{
STHROWF("Out of range object identifier: %d", id);
}
// Return the requested information
return Core::Get().GetObject(id).mObj;
}
// ------------------------------------------------------------------------------------------------
static LightObj & SqGetPickup(Int32 id)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_PICKUP_POOL))
{
STHROWF("Out of range blip identifier: %d", id);
}
// Return the requested information
return Core::Get().GetPickup(id).mObj;
}
// ------------------------------------------------------------------------------------------------
static LightObj & SqGetPlayer(Int32 id)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
{
STHROWF("Out of range player identifier: %d", id);
}
// Return the requested information
return Core::Get().GetPlayer(id).mObj;
}
// ------------------------------------------------------------------------------------------------
static LightObj & SqGetVehicle(Int32 id)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
{
STHROWF("Out of range vehicle identifier: %d", id);
}
// Return the requested information
return Core::Get().GetVehicle(id).mObj;
}
// ------------------------------------------------------------------------------------------------
static bool SqDelBlip(Int32 id, Int32 header, LightObj & payload)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_BLIP_POOL))
{
STHROWF("Out of range blip identifier: %d", id);
}
// Perform the requested operation
return Core::Get().DelBlip(id, header, payload);
}
// ------------------------------------------------------------------------------------------------
static bool SqDelCheckpoint(Int32 id, Int32 header, LightObj & payload)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_CHECKPOINT_POOL))
{
STHROWF("Out of range checkpoint identifier: %d", id);
}
// Perform the requested operation
return Core::Get().DelCheckpoint(id, header, payload);
}
// ------------------------------------------------------------------------------------------------
static bool SqDelKeybind(Int32 id, Int32 header, LightObj & payload)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_KEYBIND_POOL))
{
STHROWF("Out of range keybind identifier: %d", id);
}
// Perform the requested operation
return Core::Get().DelKeybind(id, header, payload);
}
// ------------------------------------------------------------------------------------------------
static bool SqDelObject(Int32 id, Int32 header, LightObj & payload)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_OBJECT_POOL))
{
STHROWF("Out of range object identifier: %d", id);
}
// Perform the requested operation
return Core::Get().DelObject(id, header, payload);
}
// ------------------------------------------------------------------------------------------------
static bool SqDelPickup(Int32 id, Int32 header, LightObj & payload)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_PICKUP_POOL))
{
STHROWF("Out of range blip identifier: %d", id);
}
// Perform the requested operation
return Core::Get().DelPickup(id, header, payload);
}
// ------------------------------------------------------------------------------------------------
static bool SqDelVehicle(Int32 id, Int32 header, LightObj & payload)
{
// Validate the identifier first
if (INVALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
{
STHROWF("Out of range vehicle identifier: %d", id);
}
// Perform the requested operation
return Core::Get().DelVehicle(id, header, payload);
}
// ================================================================================================
void Register_Core(HSQUIRRELVM vm)
{
Table corens(vm);
corens.Bind(_SC("State"),
Class< CoreState, NoCopy< CoreState > >(vm, CoreStateTypename::Str)
// Constructors
.Ctor()
.Ctor< int >()
// Meta-methods
.SquirrelFunc(_SC("_typename"), &CoreStateTypename::Fn)
// Member Properties
.Prop(_SC("Value"), &CoreState::GetValue)
);
corens
.Func(_SC("Reload"), &SqSetReloadStatus)
.Func(_SC("Reloading"), &SqGetReloadStatus)
.Func(_SC("ReloadBecause"), &SqReloadBecause)
.Func(_SC("SetReloadInfo"), &SqSetReloadInfo)
.Func(_SC("GetReloadHeader"), &SqGetReloadHeader)
.Func(_SC("GetReloadPayload"), &SqGetReloadPayload)
.Func(_SC("GetState"), &SqGetState)
.Func(_SC("SetState"), &SqSetState)
.Func(_SC("AreasEnabled"), &SqGetAreasEnabled)
.Func(_SC("SetAreasEnabled"), &SqSetAreasEnabled)
.Func(_SC("GetOption"), &SqGetOption)
.Func(_SC("GetOptionOr"), &SqGetOptionOr)
.Func(_SC("SetOption"), &SqSetOption)
.Func(_SC("GetBlip"), &SqGetBlip)
.Func(_SC("GetCheckpoint"), &SqGetCheckpoint)
.Func(_SC("GetKeybind"), &SqGetKeybind)
.Func(_SC("GetObject"), &SqGetObject)
.Func(_SC("GetPickup"), &SqGetPickup)
.Func(_SC("GetPlayer"), &SqGetPlayer)
.Func(_SC("GetVehicle"), &SqGetVehicle)
.Func(_SC("DestroyBlip"), &SqDelBlip)
.Func(_SC("DestroyCheckpoint"), &SqDelCheckpoint)
.Func(_SC("DestroyKeybind"), &SqDelKeybind)
.Func(_SC("DestroyObject"), &SqDelObject)
.Func(_SC("DestroyPickup"), &SqDelPickup)
.Func(_SC("DestroyVehicle"), &SqDelVehicle)
.Func(_SC("OnPreLoad"), &SqGetPreLoadEvent)
.Func(_SC("OnPostLoad"), &SqGetPostLoadEvent)
.Func(_SC("OnUnload"), &SqGetUnloadEvent)
.SquirrelFunc(_SC("LoadScript"), &SqLoadScript)
.SquirrelFunc(_SC("On"), &SqGetEvents);
RootTable(vm).Bind(_SC("SqCore"), corens);
}
} // Namespace:: SqMod

789
source/Core/Inst.inc Normal file
View File

@@ -0,0 +1,789 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// --------------------------------------------------------------------------------------------
#define SQMOD_CATCH_EVENT_EXCEPTION(action) /*
*/ catch (const Sqrat::Exception & e) /*
*/ { /*
*/ LogErr("Squirrel exception caught " action); /*
*/ Logger::Get().Debug("%s", e.what()); /*
*/ } /*
*/
// ------------------------------------------------------------------------------------------------
extern void CleanupTasks(Int32 id, Int32 type);
// ------------------------------------------------------------------------------------------------
void Core::BlipInst::Destroy(bool destroy, Int32 header, LightObj & payload)
{
// Should we notify that this entity is being cleaned up?
if (VALID_ENTITY(mID))
{
// Don't leave exceptions to prevent us from releasing this instance
try
{
Core::Get().EmitBlipDestroyed(mID, header, payload);
}
SQMOD_CATCH_EVENT_EXCEPTION("while destroying blip")
}
// Is there a manager instance associated with this entity?
if (mInst)
{
// Prevent further use of this entity
mInst->m_ID = -1;
// Release user data to avoid dangling or circular references
mInst->m_Data.Release();
}
// Prevent further use of the manager instance
mInst = nullptr;
// Release the script object, if any
mObj.Release();
// Release tasks, if any
CleanupTasks(mID, ENT_BLIP);
// Are we supposed to clean up this entity? (only at reload)
if (destroy && VALID_ENTITY(mID) && (mFlags & ENF_OWNED))
{
// Block the entity pool changes notification from triggering the destroy event
const BitGuardU32 bg(mFlags, static_cast< Uint32 >(ENF_LOCKED));
// Now attempt to destroy this entity from the server
_Func->DestroyCoordBlip(mID);
}
// Reset the instance to it's initial state
ResetInstance();
// Don't release the callbacks abruptly
DropEvents();
}
// ------------------------------------------------------------------------------------------------
void Core::CheckpointInst::Destroy(bool destroy, Int32 header, LightObj & payload)
{
// Should we notify that this entity is being cleaned up?
if (VALID_ENTITY(mID))
{
// Don't leave exceptions to prevent us from releasing this instance
try
{
Core::Get().EmitCheckpointDestroyed(mID, header, payload);
}
SQMOD_CATCH_EVENT_EXCEPTION("while destroying checkpoint")
}
// Is there a manager instance associated with this entity?
if (mInst)
{
// Prevent further use of this entity
mInst->m_ID = -1;
// Release user data to avoid dangling or circular references
mInst->m_Data.Release();
}
// Prevent further use of the manager instance
mInst = nullptr;
// Release the script object, if any
mObj.Release();
// Release tasks, if any
CleanupTasks(mID, ENT_CHECKPOINT);
// Are we supposed to clean up this entity? (only at reload)
if (destroy && VALID_ENTITY(mID) && (mFlags & ENF_OWNED))
{
// Block the entity pool changes notification from triggering the destroy event
const BitGuardU32 bg(mFlags, static_cast< Uint32 >(ENF_LOCKED));
// Now attempt to destroy this entity from the server
_Func->DeleteCheckPoint(mID);
}
// Reset the instance to it's initial state
ResetInstance();
// Don't release the callbacks abruptly
DropEvents();
}
// ------------------------------------------------------------------------------------------------
void Core::KeybindInst::Destroy(bool destroy, Int32 header, LightObj & payload)
{
// Should we notify that this entity is being cleaned up?
if (VALID_ENTITY(mID))
{
// Don't leave exceptions to prevent us from releasing this instance
try
{
Core::Get().EmitKeybindDestroyed(mID, header, payload);
}
SQMOD_CATCH_EVENT_EXCEPTION("while destroying keybind")
}
// Is there a manager instance associated with this entity?
if (mInst)
{
// Prevent further use of this entity
mInst->m_ID = -1;
// Release user data to avoid dangling or circular references
mInst->m_Data.Release();
}
// Prevent further use of the manager instance
mInst = nullptr;
// Release the script object, if any
mObj.Release();
// Release tasks, if any
CleanupTasks(mID, ENT_KEYBIND);
// Are we supposed to clean up this entity? (only at reload)
if (destroy && VALID_ENTITY(mID) && (mFlags & ENF_OWNED))
{
// Block the entity pool changes notification from triggering the destroy event
const BitGuardU32 bg(mFlags, static_cast< Uint32 >(ENF_LOCKED));
// Now attempt to destroy this entity from the server
_Func->RemoveKeyBind(mID);
}
// Reset the instance to it's initial state
ResetInstance();
// Don't release the callbacks abruptly
DropEvents();
}
// ------------------------------------------------------------------------------------------------
void Core::ObjectInst::Destroy(bool destroy, Int32 header, LightObj & payload)
{
// Should we notify that this entity is being cleaned up?
if (VALID_ENTITY(mID))
{
// Don't leave exceptions to prevent us from releasing this instance
try
{
Core::Get().EmitObjectDestroyed(mID, header, payload);
}
SQMOD_CATCH_EVENT_EXCEPTION("while destroying object")
}
// Is there a manager instance associated with this entity?
if (mInst)
{
// Prevent further use of this entity
mInst->m_ID = -1;
// Release user data to avoid dangling or circular references
mInst->m_Data.Release();
}
// Prevent further use of the manager instance
mInst = nullptr;
// Release the script object, if any
mObj.Release();
// Release tasks, if any
CleanupTasks(mID, ENT_OBJECT);
// Are we supposed to clean up this entity? (only at reload)
if (destroy && VALID_ENTITY(mID) && (mFlags & ENF_OWNED))
{
// Block the entity pool changes notification from triggering the destroy event
const BitGuardU32 bg(mFlags, static_cast< Uint32 >(ENF_LOCKED));
// Now attempt to destroy this entity from the server
_Func->DeleteObject(mID);
}
// Reset the instance to it's initial state
ResetInstance();
// Don't release the callbacks abruptly
DropEvents();
}
// ------------------------------------------------------------------------------------------------
void Core::PickupInst::Destroy(bool destroy, Int32 header, LightObj & payload)
{
// Should we notify that this entity is being cleaned up?
if (VALID_ENTITY(mID))
{
// Don't leave exceptions to prevent us from releasing this instance
try
{
Core::Get().EmitPickupDestroyed(mID, header, payload);
}
SQMOD_CATCH_EVENT_EXCEPTION("while destroying pickup")
}
// Is there a manager instance associated with this entity?
if (mInst)
{
// Prevent further use of this entity
mInst->m_ID = -1;
// Release user data to avoid dangling or circular references
mInst->m_Data.Release();
}
// Prevent further use of the manager instance
mInst = nullptr;
// Release the script object, if any
mObj.Release();
// Release tasks, if any
CleanupTasks(mID, ENT_PICKUP);
// Are we supposed to clean up this entity? (only at reload)
if (destroy && VALID_ENTITY(mID) && (mFlags & ENF_OWNED))
{
// Block the entity pool changes notification from triggering the destroy event
const BitGuardU32 bg(mFlags, static_cast< Uint32 >(ENF_LOCKED));
// Now attempt to destroy this entity from the server
_Func->DeletePickup(mID);
}
// Reset the instance to it's initial state
ResetInstance();
// Don't release the callbacks abruptly
DropEvents();
}
// ------------------------------------------------------------------------------------------------
void Core::PlayerInst::Destroy(bool /*destroy*/, Int32 header, LightObj & payload)
{
// Should we notify that this entity is being cleaned up?
if (VALID_ENTITY(mID))
{
// Don't leave exceptions to prevent us from releasing this instance
try
{
Core::Get().EmitPlayerDestroyed(mID, header, payload);
}
SQMOD_CATCH_EVENT_EXCEPTION("while destroying player")
}
// Is there a manager instance associated with this entity?
if (mInst)
{
// Prevent further use of this entity
mInst->m_ID = -1;
// Release user data to avoid dangling or circular references
mInst->m_Data.Release();
// Release the used memory buffer
mInst->m_Buffer.ResetAll();
}
// Prevent further use of the manager instance
mInst = nullptr;
// Release the script object, if any
mObj.Release();
// Release tasks, if any
CleanupTasks(mID, ENT_PLAYER);
// Reset the instance to it's initial state
ResetInstance();
// Don't release the callbacks abruptly
DropEvents();
}
// ------------------------------------------------------------------------------------------------
void Core::VehicleInst::Destroy(bool destroy, Int32 header, LightObj & payload)
{
// Should we notify that this entity is being cleaned up?
if (VALID_ENTITY(mID))
{
// Don't leave exceptions to prevent us from releasing this instance
try
{
Core::Get().EmitVehicleDestroyed(mID, header, payload);
}
SQMOD_CATCH_EVENT_EXCEPTION("while destroying vehicle")
}
// Is there a manager instance associated with this entity?
if (mInst)
{
// Prevent further use of this entity
mInst->m_ID = -1;
// Release user data to avoid dangling or circular references
mInst->m_Data.Release();
}
// Prevent further use of the manager instance
mInst = nullptr;
// Release the script object, if any
mObj.Release();
// Release tasks, if any
CleanupTasks(mID, ENT_VEHICLE);
// Are we supposed to clean up this entity? (only at reload)
if (destroy && VALID_ENTITY(mID) && (mFlags & ENF_OWNED))
{
// Block the entity pool changes notification from triggering the destroy event
const BitGuardU32 bg(mFlags, static_cast< Uint32 >(ENF_LOCKED));
// Now attempt to destroy this entity from the server
_Func->DeleteVehicle(mID);
}
// Reset the instance to it's initial state
ResetInstance();
// Don't release the callbacks abruptly
DropEvents();
}
// ------------------------------------------------------------------------------------------------
void Core::BlipInst::ResetInstance()
{
mID = -1;
mFlags = ENF_DEFAULT;
mWorld = -1;
mScale = -1;
mSprID = -1;
mPosition.Clear();
mColor.Clear();
}
// ------------------------------------------------------------------------------------------------
void Core::CheckpointInst::ResetInstance()
{
mID = -1;
mFlags = ENF_DEFAULT;
}
// ------------------------------------------------------------------------------------------------
void Core::KeybindInst::ResetInstance()
{
mID = -1;
mFlags = ENF_DEFAULT;
mFirst = -1;
mSecond = -1;
mThird = -1;
mRelease = -1;
}
// ------------------------------------------------------------------------------------------------
void Core::ObjectInst::ResetInstance()
{
mID = -1;
mFlags = ENF_DEFAULT;
}
// ------------------------------------------------------------------------------------------------
void Core::PickupInst::ResetInstance()
{
mID = -1;
mFlags = ENF_DEFAULT;
}
// ------------------------------------------------------------------------------------------------
void Core::PlayerInst::ResetInstance()
{
mID = -1;
mFlags = ENF_DEFAULT;
mAreas.clear();
mTrackPosition = 0;
mTrackHeading = 0;
mTrackPositionHeader = 0;
mTrackPositionPayload.Release();
mKickBanHeader = 0;
mKickBanPayload.Release();
mLastWeapon = -1;
mLastHealth = 0.0;
mLastArmour = 0.0;
mLastHeading = 0.0;
mLastPosition.Clear();
mAuthority = 0;
}
// ------------------------------------------------------------------------------------------------
void Core::VehicleInst::ResetInstance()
{
mID = -1;
mFlags = ENF_DEFAULT;
mAreas.clear();
mTrackPosition = 0;
mTrackRotation = 0;
mLastPrimaryColor = -1;
mLastSecondaryColor = -1;
mLastHealth = 0.0;
mLastPosition.Clear();
mLastRotation.Clear();
}
// ------------------------------------------------------------------------------------------------
void Core::BlipInst::InitEvents()
{
// Ignore the call if already initialized
if (!mEvents.IsNull())
{
return;
}
// Create a new table on the stack
sq_newtableex(DefaultVM::Get(), 4);
// Grab the table object from the stack
mEvents = LightObj(-1, DefaultVM::Get());
// Pop the table object from the stack
sq_pop(DefaultVM::Get(), 1);
// Proceed to initializing the events
InitSignalPair(mOnDestroyed, mEvents, "Destroyed");
InitSignalPair(mOnCustom, mEvents, "Custom");
}
// ------------------------------------------------------------------------------------------------
void Core::BlipInst::DropEvents()
{
ResetSignalPair(mOnDestroyed);
ResetSignalPair(mOnCustom);
mEvents.Release();
}
// ------------------------------------------------------------------------------------------------
void Core::CheckpointInst::InitEvents()
{
// Ignore the call if already initialized
if (!mEvents.IsNull())
{
return;
}
// Create a new table on the stack
sq_newtableex(DefaultVM::Get(), 8);
// Grab the table object from the stack
mEvents = LightObj(-1, DefaultVM::Get());
// Pop the table object from the stack
sq_pop(DefaultVM::Get(), 1);
// Proceed to initializing the events
InitSignalPair(mOnDestroyed, mEvents, "Destroyed");
InitSignalPair(mOnCustom, mEvents, "Custom");
InitSignalPair(mOnEntered, mEvents, "Entered");
InitSignalPair(mOnExited, mEvents, "Exited");
InitSignalPair(mOnWorld, mEvents, "World");
InitSignalPair(mOnRadius, mEvents, "Radius");
}
// ------------------------------------------------------------------------------------------------
void Core::CheckpointInst::DropEvents()
{
ResetSignalPair(mOnDestroyed);
ResetSignalPair(mOnCustom);
ResetSignalPair(mOnEntered);
ResetSignalPair(mOnExited);
ResetSignalPair(mOnWorld);
ResetSignalPair(mOnRadius);
mEvents.Release();
}
// ------------------------------------------------------------------------------------------------
void Core::KeybindInst::InitEvents()
{
// Ignore the call if already initialized
if (!mEvents.IsNull())
{
return;
}
// Create a new table on the stack
sq_newtableex(DefaultVM::Get(), 8);
// Grab the table object from the stack
mEvents = LightObj(-1, DefaultVM::Get());
// Pop the table object from the stack
sq_pop(DefaultVM::Get(), 1);
// Proceed to initializing the events
InitSignalPair(mOnDestroyed, mEvents, "Destroyed");
InitSignalPair(mOnCustom, mEvents, "Custom");
InitSignalPair(mOnKeyPress, mEvents, "KeyPress");
InitSignalPair(mOnKeyRelease, mEvents, "KeyRelease");
}
// ------------------------------------------------------------------------------------------------
void Core::KeybindInst::DropEvents()
{
ResetSignalPair(mOnDestroyed);
ResetSignalPair(mOnCustom);
ResetSignalPair(mOnKeyPress);
ResetSignalPair(mOnKeyRelease);
mEvents.Release();
}
// ------------------------------------------------------------------------------------------------
void Core::ObjectInst::InitEvents()
{
// Ignore the call if already initialized
if (!mEvents.IsNull())
{
return;
}
// Create a new table on the stack
sq_newtableex(DefaultVM::Get(), 12);
// Grab the table object from the stack
mEvents = LightObj(-1, DefaultVM::Get());
// Pop the table object from the stack
sq_pop(DefaultVM::Get(), 1);
// Proceed to initializing the events
InitSignalPair(mOnDestroyed, mEvents, "Destroyed");
InitSignalPair(mOnCustom, mEvents, "Custom");
InitSignalPair(mOnShot, mEvents, "Shot");
InitSignalPair(mOnTouched, mEvents, "Touched");
InitSignalPair(mOnWorld, mEvents, "World");
InitSignalPair(mOnAlpha, mEvents, "Alpha");
InitSignalPair(mOnReport, mEvents, "Report");
}
// ------------------------------------------------------------------------------------------------
void Core::ObjectInst::DropEvents()
{
ResetSignalPair(mOnDestroyed);
ResetSignalPair(mOnCustom);
ResetSignalPair(mOnShot);
ResetSignalPair(mOnTouched);
ResetSignalPair(mOnWorld);
ResetSignalPair(mOnAlpha);
ResetSignalPair(mOnReport);
mEvents.Release();
}
// ------------------------------------------------------------------------------------------------
void Core::PickupInst::InitEvents()
{
// Ignore the call if already initialized
if (!mEvents.IsNull())
{
return;
}
// Create a new table on the stack
sq_newtableex(DefaultVM::Get(), 16);
// Grab the table object from the stack
mEvents = LightObj(-1, DefaultVM::Get());
// Pop the table object from the stack
sq_pop(DefaultVM::Get(), 1);
// Proceed to initializing the events
InitSignalPair(mOnDestroyed, mEvents, "Destroyed");
InitSignalPair(mOnCustom, mEvents, "Custom");
InitSignalPair(mOnRespawn, mEvents, "Respawn");
InitSignalPair(mOnClaimed, mEvents, "Claimed");
InitSignalPair(mOnCollected, mEvents, "Collected");
InitSignalPair(mOnWorld, mEvents, "World");
InitSignalPair(mOnAlpha, mEvents, "Alpha");
InitSignalPair(mOnAutomatic, mEvents, "Automatic");
InitSignalPair(mOnAutoTimer, mEvents, "AutoTimer");
InitSignalPair(mOnOption, mEvents, "Option");
}
// ------------------------------------------------------------------------------------------------
void Core::PickupInst::DropEvents()
{
ResetSignalPair(mOnDestroyed);
ResetSignalPair(mOnCustom);
ResetSignalPair(mOnRespawn);
ResetSignalPair(mOnClaimed);
ResetSignalPair(mOnCollected);
ResetSignalPair(mOnWorld);
ResetSignalPair(mOnAlpha);
ResetSignalPair(mOnAutomatic);
ResetSignalPair(mOnAutoTimer);
ResetSignalPair(mOnOption);
mEvents.Release();
}
// ------------------------------------------------------------------------------------------------
void Core::PlayerInst::InitEvents()
{
// Ignore the call if already initialized
if (!mEvents.IsNull())
{
return;
}
// Create a new table on the stack
sq_newtableex(DefaultVM::Get(), 86);
// Grab the table object from the stack
mEvents = LightObj(-1, DefaultVM::Get());
// Pop the table object from the stack
sq_pop(DefaultVM::Get(), 1);
// Proceed to initializing the events
InitSignalPair(mOnDestroyed, mEvents, "Destroyed");
InitSignalPair(mOnCustom, mEvents, "Custom");
InitSignalPair(mOnRequestClass, mEvents, "RequestClass");
InitSignalPair(mOnRequestSpawn, mEvents, "RequestSpawn");
InitSignalPair(mOnSpawn, mEvents, "Spawn");
InitSignalPair(mOnWasted, mEvents, "Wasted");
InitSignalPair(mOnKilled, mEvents, "Killed");
InitSignalPair(mOnEmbarking, mEvents, "Embarking");
InitSignalPair(mOnEmbarked, mEvents, "Embarked");
InitSignalPair(mOnDisembark, mEvents, "Disembark");
InitSignalPair(mOnRename, mEvents, "Rename");
InitSignalPair(mOnState, mEvents, "State");
InitSignalPair(mOnStateNone, mEvents, "StateNone");
InitSignalPair(mOnStateNormal, mEvents, "StateNormal");
InitSignalPair(mOnStateAim, mEvents, "StateAim");
InitSignalPair(mOnStateDriver, mEvents, "StateDriver");
InitSignalPair(mOnStatePassenger, mEvents, "StatePassenger");
InitSignalPair(mOnStateEnterDriver, mEvents, "StateEnterDriver");
InitSignalPair(mOnStateEnterPassenger, mEvents, "StateEnterPassenger");
InitSignalPair(mOnStateExit, mEvents, "StateExit");
InitSignalPair(mOnStateUnspawned, mEvents, "StateUnspawned");
InitSignalPair(mOnAction, mEvents, "Action");
InitSignalPair(mOnActionNone, mEvents, "ActionNone");
InitSignalPair(mOnActionNormal, mEvents, "ActionNormal");
InitSignalPair(mOnActionAiming, mEvents, "ActionAiming");
InitSignalPair(mOnActionShooting, mEvents, "ActionShooting");
InitSignalPair(mOnActionJumping, mEvents, "ActionJumping");
InitSignalPair(mOnActionLieDown, mEvents, "ActionLieDown");
InitSignalPair(mOnActionGettingUp, mEvents, "ActionGettingUp");
InitSignalPair(mOnActionJumpVehicle, mEvents, "ActionJumpVehicle");
InitSignalPair(mOnActionDriving, mEvents, "ActionDriving");
InitSignalPair(mOnActionDying, mEvents, "ActionDying");
InitSignalPair(mOnActionWasted, mEvents, "ActionWasted");
InitSignalPair(mOnActionEmbarking, mEvents, "ActionEmbarking");
InitSignalPair(mOnActionDisembarking, mEvents, "ActionDisembarking");
InitSignalPair(mOnBurning, mEvents, "Burning");
InitSignalPair(mOnCrouching, mEvents, "Crouching");
InitSignalPair(mOnGameKeys, mEvents, "GameKeys");
InitSignalPair(mOnStartTyping, mEvents, "StartTyping");
InitSignalPair(mOnStopTyping, mEvents, "StopTyping");
InitSignalPair(mOnAway, mEvents, "Away");
InitSignalPair(mOnMessage, mEvents, "Message");
InitSignalPair(mOnCommand, mEvents, "Command");
InitSignalPair(mOnPrivateMessage, mEvents, "PrivateMessage");
InitSignalPair(mOnKeyPress, mEvents, "KeyPress");
InitSignalPair(mOnKeyRelease, mEvents, "KeyRelease");
InitSignalPair(mOnSpectate, mEvents, "Spectate");
InitSignalPair(mOnUnspectate, mEvents, "Unspectate");
InitSignalPair(mOnCrashreport, mEvents, "Crashreport");
InitSignalPair(mOnModuleList, mEvents, "ModuleList");
InitSignalPair(mOnObjectShot, mEvents, "ObjectShot");
InitSignalPair(mOnObjectTouched, mEvents, "ObjectTouched");
InitSignalPair(mOnPickupClaimed, mEvents, "PickupClaimed");
InitSignalPair(mOnPickupCollected, mEvents, "PickupCollected");
InitSignalPair(mOnCheckpointEntered, mEvents, "CheckpointEntered");
InitSignalPair(mOnCheckpointExited, mEvents, "CheckpointExited");
InitSignalPair(mOnClientScriptData, mEvents, "ClientScriptData");
InitSignalPair(mOnUpdate, mEvents, "Update");
InitSignalPair(mOnHealth, mEvents, "Health");
InitSignalPair(mOnArmour, mEvents, "Armour");
InitSignalPair(mOnWeapon, mEvents, "Weapon");
InitSignalPair(mOnHeading, mEvents, "Heading");
InitSignalPair(mOnPosition, mEvents, "Position");
InitSignalPair(mOnOption, mEvents, "Option");
InitSignalPair(mOnAdmin, mEvents, "Admin");
InitSignalPair(mOnWorld, mEvents, "World");
InitSignalPair(mOnTeam, mEvents, "Team");
InitSignalPair(mOnSkin, mEvents, "Skin");
InitSignalPair(mOnMoney, mEvents, "Money");
InitSignalPair(mOnScore, mEvents, "Score");
InitSignalPair(mOnWantedLevel, mEvents, "WantedLevel");
InitSignalPair(mOnImmunity, mEvents, "Immunity");
InitSignalPair(mOnAlpha, mEvents, "Alpha");
InitSignalPair(mOnEnterArea, mEvents, "EnterArea");
InitSignalPair(mOnLeaveArea, mEvents, "LeaveArea");
}
// ------------------------------------------------------------------------------------------------
void Core::PlayerInst::DropEvents()
{
ResetSignalPair(mOnDestroyed);
ResetSignalPair(mOnCustom);
ResetSignalPair(mOnRequestClass);
ResetSignalPair(mOnRequestSpawn);
ResetSignalPair(mOnSpawn);
ResetSignalPair(mOnWasted);
ResetSignalPair(mOnKilled);
ResetSignalPair(mOnEmbarking);
ResetSignalPair(mOnEmbarked);
ResetSignalPair(mOnDisembark);
ResetSignalPair(mOnRename);
ResetSignalPair(mOnState);
ResetSignalPair(mOnStateNone);
ResetSignalPair(mOnStateNormal);
ResetSignalPair(mOnStateAim);
ResetSignalPair(mOnStateDriver);
ResetSignalPair(mOnStatePassenger);
ResetSignalPair(mOnStateEnterDriver);
ResetSignalPair(mOnStateEnterPassenger);
ResetSignalPair(mOnStateExit);
ResetSignalPair(mOnStateUnspawned);
ResetSignalPair(mOnAction);
ResetSignalPair(mOnActionNone);
ResetSignalPair(mOnActionNormal);
ResetSignalPair(mOnActionAiming);
ResetSignalPair(mOnActionShooting);
ResetSignalPair(mOnActionJumping);
ResetSignalPair(mOnActionLieDown);
ResetSignalPair(mOnActionGettingUp);
ResetSignalPair(mOnActionJumpVehicle);
ResetSignalPair(mOnActionDriving);
ResetSignalPair(mOnActionDying);
ResetSignalPair(mOnActionWasted);
ResetSignalPair(mOnActionEmbarking);
ResetSignalPair(mOnActionDisembarking);
ResetSignalPair(mOnBurning);
ResetSignalPair(mOnCrouching);
ResetSignalPair(mOnGameKeys);
ResetSignalPair(mOnStartTyping);
ResetSignalPair(mOnStopTyping);
ResetSignalPair(mOnAway);
ResetSignalPair(mOnMessage);
ResetSignalPair(mOnCommand);
ResetSignalPair(mOnPrivateMessage);
ResetSignalPair(mOnKeyPress);
ResetSignalPair(mOnKeyRelease);
ResetSignalPair(mOnSpectate);
ResetSignalPair(mOnUnspectate);
ResetSignalPair(mOnCrashreport);
ResetSignalPair(mOnModuleList);
ResetSignalPair(mOnObjectShot);
ResetSignalPair(mOnObjectTouched);
ResetSignalPair(mOnPickupClaimed);
ResetSignalPair(mOnPickupCollected);
ResetSignalPair(mOnCheckpointEntered);
ResetSignalPair(mOnCheckpointExited);
ResetSignalPair(mOnClientScriptData);
ResetSignalPair(mOnUpdate);
ResetSignalPair(mOnHealth);
ResetSignalPair(mOnArmour);
ResetSignalPair(mOnWeapon);
ResetSignalPair(mOnHeading);
ResetSignalPair(mOnPosition);
ResetSignalPair(mOnOption);
ResetSignalPair(mOnAdmin);
ResetSignalPair(mOnWorld);
ResetSignalPair(mOnTeam);
ResetSignalPair(mOnSkin);
ResetSignalPair(mOnMoney);
ResetSignalPair(mOnScore);
ResetSignalPair(mOnWantedLevel);
ResetSignalPair(mOnImmunity);
ResetSignalPair(mOnAlpha);
ResetSignalPair(mOnEnterArea);
ResetSignalPair(mOnLeaveArea);
mEvents.Release();
}
// ------------------------------------------------------------------------------------------------
void Core::VehicleInst::InitEvents()
{
// Ignore the call if already initialized
if (!mEvents.IsNull())
{
return;
}
// Create a new table on the stack
sq_newtableex(DefaultVM::Get(), 32);
// Grab the table object from the stack
mEvents = LightObj(-1, DefaultVM::Get());
// Pop the table object from the stack
sq_pop(DefaultVM::Get(), 1);
// Proceed to initializing the events
InitSignalPair(mOnDestroyed, mEvents, "Destroyed");
InitSignalPair(mOnCustom, mEvents, "Custom");
InitSignalPair(mOnEmbarking, mEvents, "Embarking");
InitSignalPair(mOnEmbarked, mEvents, "Embarked");
InitSignalPair(mOnDisembark, mEvents, "Disembark");
InitSignalPair(mOnExplode, mEvents, "Explode");
InitSignalPair(mOnRespawn, mEvents, "Respawn");
InitSignalPair(mOnUpdate, mEvents, "Update");
InitSignalPair(mOnColor, mEvents, "Color");
InitSignalPair(mOnHealth, mEvents, "Health");
InitSignalPair(mOnPosition, mEvents, "Position");
InitSignalPair(mOnRotation, mEvents, "Rotation");
InitSignalPair(mOnOption, mEvents, "Option");
InitSignalPair(mOnWorld, mEvents, "World");
InitSignalPair(mOnImmunity, mEvents, "Immunity");
InitSignalPair(mOnPartStatus, mEvents, "PartStatus");
InitSignalPair(mOnTyreStatus, mEvents, "TyreStatus");
InitSignalPair(mOnDamageData, mEvents, "DamageData");
InitSignalPair(mOnRadio, mEvents, "Radio");
InitSignalPair(mOnHandlingRule, mEvents, "HandlingRule");
InitSignalPair(mOnEnterArea, mEvents, "EnterArea");
InitSignalPair(mOnLeaveArea, mEvents, "LeaveArea");
}
// ------------------------------------------------------------------------------------------------
void Core::VehicleInst::DropEvents()
{
ResetSignalPair(mOnDestroyed);
ResetSignalPair(mOnCustom);
ResetSignalPair(mOnEmbarking);
ResetSignalPair(mOnEmbarked);
ResetSignalPair(mOnDisembark);
ResetSignalPair(mOnExplode);
ResetSignalPair(mOnRespawn);
ResetSignalPair(mOnUpdate);
ResetSignalPair(mOnColor);
ResetSignalPair(mOnHealth);
ResetSignalPair(mOnPosition);
ResetSignalPair(mOnRotation);
ResetSignalPair(mOnOption);
ResetSignalPair(mOnWorld);
ResetSignalPair(mOnImmunity);
ResetSignalPair(mOnPartStatus);
ResetSignalPair(mOnTyreStatus);
ResetSignalPair(mOnDamageData);
ResetSignalPair(mOnRadio);
ResetSignalPair(mOnHandlingRule);
ResetSignalPair(mOnEnterArea);
ResetSignalPair(mOnLeaveArea);
mEvents.Release();
}
} // Namespace:: SqMod

325
source/Core/Utils.inc Normal file
View File

@@ -0,0 +1,325 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
void Core::ClearContainer(EntityType type)
{
switch (type)
{
case ENT_BLIP:
{
m_Blips.clear();
} break;
case ENT_CHECKPOINT:
{
m_Checkpoints.clear();
} break;
case ENT_KEYBIND:
{
m_Keybinds.clear();
} break;
case ENT_OBJECT:
{
m_Objects.clear();
} break;
case ENT_PICKUP:
{
m_Pickups.clear();
} break;
case ENT_PLAYER:
{
m_Players.clear();
} break;
case ENT_VEHICLE:
{
m_Vehicles.clear();
} break;
default: STHROWF("Cannot clear unknown entity type container");
}
}
// ------------------------------------------------------------------------------------------------
void Core::InitEvents()
{
// Ignore the call if already initialized
if (!m_Events.IsNull())
{
return;
}
// Create a new table on the stack
sq_newtableex(DefaultVM::Get(), 128);
// Grab the table object from the stack
m_Events = LightObj(-1, DefaultVM::Get());
// Pop the table object from the stack
sq_pop(DefaultVM::Get(), 1);
// Proceed to initializing the events
InitSignalPair(mOnCustomEvent, m_Events, "CustomEvent");
InitSignalPair(mOnBlipCreated, m_Events, "BlipCreated");
InitSignalPair(mOnCheckpointCreated, m_Events, "CheckpointCreated");
InitSignalPair(mOnKeybindCreated, m_Events, "KeybindCreated");
InitSignalPair(mOnObjectCreated, m_Events, "ObjectCreated");
InitSignalPair(mOnPickupCreated, m_Events, "PickupCreated");
InitSignalPair(mOnPlayerCreated, m_Events, "PlayerCreated");
InitSignalPair(mOnVehicleCreated, m_Events, "VehicleCreated");
InitSignalPair(mOnBlipDestroyed, m_Events, "BlipDestroyed");
InitSignalPair(mOnCheckpointDestroyed, m_Events, "CheckpointDestroyed");
InitSignalPair(mOnKeybindDestroyed, m_Events, "KeybindDestroyed");
InitSignalPair(mOnObjectDestroyed, m_Events, "ObjectDestroyed");
InitSignalPair(mOnPickupDestroyed, m_Events, "PickupDestroyed");
InitSignalPair(mOnPlayerDestroyed, m_Events, "PlayerDestroyed");
InitSignalPair(mOnVehicleDestroyed, m_Events, "VehicleDestroyed");
InitSignalPair(mOnBlipCustom, m_Events, "BlipCustom");
InitSignalPair(mOnCheckpointCustom, m_Events, "CheckpointCustom");
InitSignalPair(mOnKeybindCustom, m_Events, "KeybindCustom");
InitSignalPair(mOnObjectCustom, m_Events, "ObjectCustom");
InitSignalPair(mOnPickupCustom, m_Events, "PickupCustom");
InitSignalPair(mOnPlayerCustom, m_Events, "PlayerCustom");
InitSignalPair(mOnVehicleCustom, m_Events, "VehicleCustom");
InitSignalPair(mOnServerStartup, m_Events, "ServerStartup");
InitSignalPair(mOnServerShutdown, m_Events, "ServerShutdown");
InitSignalPair(mOnServerFrame, m_Events, "ServerFrame");
InitSignalPair(mOnIncomingConnection, m_Events, "IncomingConnection");
InitSignalPair(mOnPlayerRequestClass, m_Events, "PlayerRequestClass");
InitSignalPair(mOnPlayerRequestSpawn, m_Events, "PlayerRequestSpawn");
InitSignalPair(mOnPlayerSpawn, m_Events, "PlayerSpawn");
InitSignalPair(mOnPlayerWasted, m_Events, "PlayerWasted");
InitSignalPair(mOnPlayerKilled, m_Events, "PlayerKilled");
InitSignalPair(mOnPlayerEmbarking, m_Events, "PlayerEmbarking");
InitSignalPair(mOnPlayerEmbarked, m_Events, "PlayerEmbarked");
InitSignalPair(mOnPlayerDisembark, m_Events, "PlayerDisembark");
InitSignalPair(mOnPlayerRename, m_Events, "PlayerRename");
InitSignalPair(mOnPlayerState, m_Events, "PlayerState");
InitSignalPair(mOnStateNone, m_Events, "StateNone");
InitSignalPair(mOnStateNormal, m_Events, "StateNormal");
InitSignalPair(mOnStateAim, m_Events, "StateAim");
InitSignalPair(mOnStateDriver, m_Events, "StateDriver");
InitSignalPair(mOnStatePassenger, m_Events, "StatePassenger");
InitSignalPair(mOnStateEnterDriver, m_Events, "StateEnterDriver");
InitSignalPair(mOnStateEnterPassenger, m_Events, "StateEnterPassenger");
InitSignalPair(mOnStateExit, m_Events, "StateExit");
InitSignalPair(mOnStateUnspawned, m_Events, "StateUnspawned");
InitSignalPair(mOnPlayerAction, m_Events, "PlayerAction");
InitSignalPair(mOnActionNone, m_Events, "ActionNone");
InitSignalPair(mOnActionNormal, m_Events, "ActionNormal");
InitSignalPair(mOnActionAiming, m_Events, "ActionAiming");
InitSignalPair(mOnActionShooting, m_Events, "ActionShooting");
InitSignalPair(mOnActionJumping, m_Events, "ActionJumping");
InitSignalPair(mOnActionLieDown, m_Events, "ActionLieDown");
InitSignalPair(mOnActionGettingUp, m_Events, "ActionGettingUp");
InitSignalPair(mOnActionJumpVehicle, m_Events, "ActionJumpVehicle");
InitSignalPair(mOnActionDriving, m_Events, "ActionDriving");
InitSignalPair(mOnActionDying, m_Events, "ActionDying");
InitSignalPair(mOnActionWasted, m_Events, "ActionWasted");
InitSignalPair(mOnActionEmbarking, m_Events, "ActionEmbarking");
InitSignalPair(mOnActionDisembarking, m_Events, "ActionDisembarking");
InitSignalPair(mOnPlayerBurning, m_Events, "PlayerBurning");
InitSignalPair(mOnPlayerCrouching, m_Events, "PlayerCrouching");
InitSignalPair(mOnPlayerGameKeys, m_Events, "PlayerGameKeys");
InitSignalPair(mOnPlayerStartTyping, m_Events, "PlayerStartTyping");
InitSignalPair(mOnPlayerStopTyping, m_Events, "PlayerStopTyping");
InitSignalPair(mOnPlayerAway, m_Events, "PlayerAway");
InitSignalPair(mOnPlayerMessage, m_Events, "PlayerMessage");
InitSignalPair(mOnPlayerCommand, m_Events, "PlayerCommand");
InitSignalPair(mOnPlayerPrivateMessage, m_Events, "PlayerPrivateMessage");
InitSignalPair(mOnPlayerKeyPress, m_Events, "PlayerKeyPress");
InitSignalPair(mOnPlayerKeyRelease, m_Events, "PlayerKeyRelease");
InitSignalPair(mOnPlayerSpectate, m_Events, "PlayerSpectate");
InitSignalPair(mOnPlayerUnspectate, m_Events, "PlayerUnspectate");
InitSignalPair(mOnPlayerCrashreport, m_Events, "PlayerCrashreport");
InitSignalPair(mOnPlayerModuleList, m_Events, "PlayerModuleList");
InitSignalPair(mOnVehicleExplode, m_Events, "VehicleExplode");
InitSignalPair(mOnVehicleRespawn, m_Events, "VehicleRespawn");
InitSignalPair(mOnObjectShot, m_Events, "ObjectShot");
InitSignalPair(mOnObjectTouched, m_Events, "ObjectTouched");
InitSignalPair(mOnObjectWorld, m_Events, "ObjectWorld");
InitSignalPair(mOnObjectAlpha, m_Events, "ObjectAlpha");
InitSignalPair(mOnObjectReport, m_Events, "ObjectReport");
InitSignalPair(mOnPickupClaimed, m_Events, "PickupClaimed");
InitSignalPair(mOnPickupCollected, m_Events, "PickupCollected");
InitSignalPair(mOnPickupRespawn, m_Events, "PickupRespawn");
InitSignalPair(mOnPickupWorld, m_Events, "PickupWorld");
InitSignalPair(mOnPickupAlpha, m_Events, "PickupAlpha");
InitSignalPair(mOnPickupAutomatic, m_Events, "PickupAutomatic");
InitSignalPair(mOnPickupAutoTimer, m_Events, "PickupAutoTimer");
InitSignalPair(mOnPickupOption, m_Events, "PickupOption");
InitSignalPair(mOnCheckpointEntered, m_Events, "CheckpointEntered");
InitSignalPair(mOnCheckpointExited, m_Events, "CheckpointExited");
InitSignalPair(mOnCheckpointWorld, m_Events, "CheckpointWorld");
InitSignalPair(mOnCheckpointRadius, m_Events, "CheckpointRadius");
InitSignalPair(mOnEntityPool, m_Events, "EntityPool");
InitSignalPair(mOnClientScriptData, m_Events, "ClientScriptData");
InitSignalPair(mOnPlayerUpdate, m_Events, "PlayerUpdate");
InitSignalPair(mOnVehicleUpdate, m_Events, "VehicleUpdate");
InitSignalPair(mOnPlayerHealth, m_Events, "PlayerHealth");
InitSignalPair(mOnPlayerArmour, m_Events, "PlayerArmour");
InitSignalPair(mOnPlayerWeapon, m_Events, "PlayerWeapon");
InitSignalPair(mOnPlayerHeading, m_Events, "PlayerHeading");
InitSignalPair(mOnPlayerPosition, m_Events, "PlayerPosition");
InitSignalPair(mOnPlayerOption, m_Events, "PlayerOption");
InitSignalPair(mOnPlayerAdmin, m_Events, "PlayerAdmin");
InitSignalPair(mOnPlayerWorld, m_Events, "PlayerWorld");
InitSignalPair(mOnPlayerTeam, m_Events, "PlayerTeam");
InitSignalPair(mOnPlayerSkin, m_Events, "PlayerSkin");
InitSignalPair(mOnPlayerMoney, m_Events, "PlayerMoney");
InitSignalPair(mOnPlayerScore, m_Events, "PlayerScore");
InitSignalPair(mOnPlayerWantedLevel, m_Events, "PlayerWantedLevel");
InitSignalPair(mOnPlayerImmunity, m_Events, "PlayerImmunity");
InitSignalPair(mOnPlayerAlpha, m_Events, "PlayerAlpha");
InitSignalPair(mOnPlayerEnterArea, m_Events, "PlayerEnterArea");
InitSignalPair(mOnPlayerLeaveArea, m_Events, "PlayerLeaveArea");
InitSignalPair(mOnVehicleColor, m_Events, "VehicleColor");
InitSignalPair(mOnVehicleHealth, m_Events, "VehicleHealth");
InitSignalPair(mOnVehiclePosition, m_Events, "VehiclePosition");
InitSignalPair(mOnVehicleRotation, m_Events, "VehicleRotation");
InitSignalPair(mOnVehicleOption, m_Events, "VehicleOption");
InitSignalPair(mOnVehicleWorld, m_Events, "VehicleWorld");
InitSignalPair(mOnVehicleImmunity, m_Events, "VehicleImmunity");
InitSignalPair(mOnVehiclePartStatus, m_Events, "VehiclePartStatus");
InitSignalPair(mOnVehicleTyreStatus, m_Events, "VehicleTyreStatus");
InitSignalPair(mOnVehicleDamageData, m_Events, "VehicleDamageData");
InitSignalPair(mOnVehicleRadio, m_Events, "VehicleRadio");
InitSignalPair(mOnVehicleHandlingRule, m_Events, "VehicleHandlingRule");
InitSignalPair(mOnVehicleEnterArea, m_Events, "VehicleEnterArea");
InitSignalPair(mOnVehicleLeaveArea, m_Events, "VehicleLeaveArea");
InitSignalPair(mOnServerOption, m_Events, "ServerOption");
InitSignalPair(mOnScriptReload, m_Events, "ScriptReload");
InitSignalPair(mOnScriptLoaded, m_Events, "ScriptLoaded");
}
// ------------------------------------------------------------------------------------------------
void Core::DropEvents()
{
ResetSignalPair(mOnCustomEvent);
ResetSignalPair(mOnBlipCreated);
ResetSignalPair(mOnCheckpointCreated);
ResetSignalPair(mOnKeybindCreated);
ResetSignalPair(mOnObjectCreated);
ResetSignalPair(mOnPickupCreated);
ResetSignalPair(mOnPlayerCreated);
ResetSignalPair(mOnVehicleCreated);
ResetSignalPair(mOnBlipDestroyed);
ResetSignalPair(mOnCheckpointDestroyed);
ResetSignalPair(mOnKeybindDestroyed);
ResetSignalPair(mOnObjectDestroyed);
ResetSignalPair(mOnPickupDestroyed);
ResetSignalPair(mOnPlayerDestroyed);
ResetSignalPair(mOnVehicleDestroyed);
ResetSignalPair(mOnBlipCustom);
ResetSignalPair(mOnCheckpointCustom);
ResetSignalPair(mOnKeybindCustom);
ResetSignalPair(mOnObjectCustom);
ResetSignalPair(mOnPickupCustom);
ResetSignalPair(mOnPlayerCustom);
ResetSignalPair(mOnVehicleCustom);
ResetSignalPair(mOnServerStartup);
ResetSignalPair(mOnServerShutdown);
ResetSignalPair(mOnServerFrame);
ResetSignalPair(mOnIncomingConnection);
ResetSignalPair(mOnPlayerRequestClass);
ResetSignalPair(mOnPlayerRequestSpawn);
ResetSignalPair(mOnPlayerSpawn);
ResetSignalPair(mOnPlayerWasted);
ResetSignalPair(mOnPlayerKilled);
ResetSignalPair(mOnPlayerEmbarking);
ResetSignalPair(mOnPlayerEmbarked);
ResetSignalPair(mOnPlayerDisembark);
ResetSignalPair(mOnPlayerRename);
ResetSignalPair(mOnPlayerState);
ResetSignalPair(mOnStateNone);
ResetSignalPair(mOnStateNormal);
ResetSignalPair(mOnStateAim);
ResetSignalPair(mOnStateDriver);
ResetSignalPair(mOnStatePassenger);
ResetSignalPair(mOnStateEnterDriver);
ResetSignalPair(mOnStateEnterPassenger);
ResetSignalPair(mOnStateExit);
ResetSignalPair(mOnStateUnspawned);
ResetSignalPair(mOnPlayerAction);
ResetSignalPair(mOnActionNone);
ResetSignalPair(mOnActionNormal);
ResetSignalPair(mOnActionAiming);
ResetSignalPair(mOnActionShooting);
ResetSignalPair(mOnActionJumping);
ResetSignalPair(mOnActionLieDown);
ResetSignalPair(mOnActionGettingUp);
ResetSignalPair(mOnActionJumpVehicle);
ResetSignalPair(mOnActionDriving);
ResetSignalPair(mOnActionDying);
ResetSignalPair(mOnActionWasted);
ResetSignalPair(mOnActionEmbarking);
ResetSignalPair(mOnActionDisembarking);
ResetSignalPair(mOnPlayerBurning);
ResetSignalPair(mOnPlayerCrouching);
ResetSignalPair(mOnPlayerGameKeys);
ResetSignalPair(mOnPlayerStartTyping);
ResetSignalPair(mOnPlayerStopTyping);
ResetSignalPair(mOnPlayerAway);
ResetSignalPair(mOnPlayerMessage);
ResetSignalPair(mOnPlayerCommand);
ResetSignalPair(mOnPlayerPrivateMessage);
ResetSignalPair(mOnPlayerKeyPress);
ResetSignalPair(mOnPlayerKeyRelease);
ResetSignalPair(mOnPlayerSpectate);
ResetSignalPair(mOnPlayerUnspectate);
ResetSignalPair(mOnPlayerCrashreport);
ResetSignalPair(mOnPlayerModuleList);
ResetSignalPair(mOnVehicleExplode);
ResetSignalPair(mOnVehicleRespawn);
ResetSignalPair(mOnObjectShot);
ResetSignalPair(mOnObjectTouched);
ResetSignalPair(mOnObjectWorld);
ResetSignalPair(mOnObjectAlpha);
ResetSignalPair(mOnObjectReport);
ResetSignalPair(mOnPickupClaimed);
ResetSignalPair(mOnPickupCollected);
ResetSignalPair(mOnPickupRespawn);
ResetSignalPair(mOnPickupWorld);
ResetSignalPair(mOnPickupAlpha);
ResetSignalPair(mOnPickupAutomatic);
ResetSignalPair(mOnPickupAutoTimer);
ResetSignalPair(mOnPickupOption);
ResetSignalPair(mOnCheckpointEntered);
ResetSignalPair(mOnCheckpointExited);
ResetSignalPair(mOnCheckpointWorld);
ResetSignalPair(mOnCheckpointRadius);
ResetSignalPair(mOnEntityPool);
ResetSignalPair(mOnClientScriptData);
ResetSignalPair(mOnPlayerUpdate);
ResetSignalPair(mOnVehicleUpdate);
ResetSignalPair(mOnPlayerHealth);
ResetSignalPair(mOnPlayerArmour);
ResetSignalPair(mOnPlayerWeapon);
ResetSignalPair(mOnPlayerHeading);
ResetSignalPair(mOnPlayerPosition);
ResetSignalPair(mOnPlayerOption);
ResetSignalPair(mOnPlayerAdmin);
ResetSignalPair(mOnPlayerWorld);
ResetSignalPair(mOnPlayerTeam);
ResetSignalPair(mOnPlayerSkin);
ResetSignalPair(mOnPlayerMoney);
ResetSignalPair(mOnPlayerScore);
ResetSignalPair(mOnPlayerWantedLevel);
ResetSignalPair(mOnPlayerImmunity);
ResetSignalPair(mOnPlayerAlpha);
ResetSignalPair(mOnPlayerEnterArea);
ResetSignalPair(mOnPlayerLeaveArea);
ResetSignalPair(mOnVehicleColor);
ResetSignalPair(mOnVehicleHealth);
ResetSignalPair(mOnVehiclePosition);
ResetSignalPair(mOnVehicleRotation);
ResetSignalPair(mOnVehicleOption);
ResetSignalPair(mOnVehicleWorld);
ResetSignalPair(mOnVehicleImmunity);
ResetSignalPair(mOnVehiclePartStatus);
ResetSignalPair(mOnVehicleTyreStatus);
ResetSignalPair(mOnVehicleDamageData);
ResetSignalPair(mOnVehicleRadio);
ResetSignalPair(mOnVehicleHandlingRule);
ResetSignalPair(mOnVehicleEnterArea);
ResetSignalPair(mOnVehicleLeaveArea);
ResetSignalPair(mOnServerOption);
ResetSignalPair(mOnScriptReload);
ResetSignalPair(mOnScriptLoaded);
m_Events.Release();
}
} // Namespace:: SqMod