mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Add the possibility to have null entity instances intentionally.
This commit is contained in:
parent
5c26ba62df
commit
29b0f8d4c9
@ -254,6 +254,37 @@ bool Core::Initialize()
|
||||
NullTable() = Table();
|
||||
NullObject() = Object();
|
||||
NullFunction() = Function();
|
||||
// Create the null entity instances
|
||||
{
|
||||
// The Blip constructor validates the ID. So we must take this route
|
||||
CBlip * nblip = new CBlip(0);
|
||||
nblip->m_ID = -1;
|
||||
m_NullBlip = Object(nblip);
|
||||
// The Checkpoint constructor validates the ID. So we must take this route
|
||||
CCheckpoint * ncheckpoint = new CCheckpoint(0);
|
||||
ncheckpoint->m_ID = -1;
|
||||
m_NullCheckpoint = Object(ncheckpoint);
|
||||
// The Keybind constructor validates the ID. So we must take this route
|
||||
CKeybind * nkeybind = new CKeybind(0);
|
||||
nkeybind->m_ID = -1;
|
||||
m_NullKeybind = Object(nkeybind);
|
||||
// The Object constructor validates the ID. So we must take this route
|
||||
CObject * nobject = new CObject(0);
|
||||
nobject->m_ID = -1;
|
||||
m_NullObject = Object(nobject);
|
||||
// The Pickup constructor validates the ID. So we must take this route
|
||||
CPickup * npickup = new CPickup(0);
|
||||
npickup->m_ID = -1;
|
||||
m_NullPickup = Object(npickup);
|
||||
// The Player constructor validates the ID. So we must take this route
|
||||
CPlayer * nplayer = new CPlayer(0);
|
||||
nplayer->m_ID = -1;
|
||||
m_NullPlayer = Object(nplayer);
|
||||
// The Vehicle constructor validates the ID. So we must take this route
|
||||
CVehicle * nvehicle = new CVehicle(0);
|
||||
nvehicle->m_ID = -1;
|
||||
m_NullVehicle = Object(nvehicle);
|
||||
}
|
||||
|
||||
LogDbg("Registering the standard libraries");
|
||||
// Push the root table on the stack
|
||||
@ -471,6 +502,14 @@ void Core::Terminate(bool shutdown)
|
||||
NullTable().Release();
|
||||
NullObject().Release();
|
||||
NullFunction().ReleaseGently();
|
||||
// Release null entity instances
|
||||
m_NullBlip.Release();
|
||||
m_NullCheckpoint.Release();
|
||||
m_NullKeybind.Release();
|
||||
m_NullObject.Release();
|
||||
m_NullPickup.Release();
|
||||
m_NullPlayer.Release();
|
||||
m_NullVehicle.Release();
|
||||
// Is there a VM to close?
|
||||
if (m_VM)
|
||||
{
|
||||
|
@ -534,6 +534,15 @@ private:
|
||||
bool m_Executed; // Whether the scripts were executed.
|
||||
bool m_Shutdown; // Whether the server currently shutting down.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Object m_NullBlip; // Null Blips instance.
|
||||
Object m_NullCheckpoint; // Null Checkpoints instance.
|
||||
Object m_NullKeybind; // Null Key-instance pool.
|
||||
Object m_NullObject; // Null Objects instance.
|
||||
Object m_NullPickup; // Null Pickups instance.
|
||||
Object m_NullPlayer; // Null Players instance.
|
||||
Object m_NullVehicle; // Null Vehicles instance.
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -808,6 +817,17 @@ public:
|
||||
const Players & GetPlayers() const { return m_Players; }
|
||||
const Vehicles & GetVehicles() const { return m_Vehicles; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Null instance retrievers.
|
||||
*/
|
||||
Object & GetNullBlip() { return m_NullBlip; }
|
||||
Object & GetNullCheckpoint() { return m_NullCheckpoint; }
|
||||
Object & GetNullKeybind() { return m_NullKeybind; }
|
||||
Object & GetNullObject() { return m_NullObject; }
|
||||
Object & GetNullPickup() { return m_NullPickup; }
|
||||
Object & GetNullPlayer() { return m_NullPlayer; }
|
||||
Object & GetNullVehicle() { return m_NullVehicle; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Container cleaner.
|
||||
*/
|
||||
|
@ -16,6 +16,19 @@ SQInteger CBlip::Typename(HSQUIRRELVM vm)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger CBlip::SqGetNull(HSQUIRRELVM vm)
|
||||
{
|
||||
sq_pushobject(vm, Core::Get().GetNullBlip().GetObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object & CBlip::GetNull()
|
||||
{
|
||||
return Core::Get().GetNullBlip();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CBlip::CBlip(Int32 id)
|
||||
: m_ID(VALID_ENTITYGETEX(id, SQMOD_BLIP_POOL))
|
||||
@ -350,6 +363,8 @@ void Register_CBlip(HSQUIRRELVM vm)
|
||||
(_SC("Create"), &Blip_Create)
|
||||
.StaticOverload< Object & (*)(Int32, Int32, const Vector3 &, Int32, const Color4 &, Int32, Int32, Object &) >
|
||||
(_SC("Create"), &Blip_Create)
|
||||
// Raw Squirrel Methods
|
||||
.SquirrelFunc(_SC("NullInst"), &CBlip::SqGetNull)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,16 @@ public:
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static SQInteger SqGetNull(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static Object & GetNull();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the identifier of the entity managed by this instance.
|
||||
*/
|
||||
|
@ -29,6 +29,19 @@ SQInteger CCheckpoint::Typename(HSQUIRRELVM vm)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger CCheckpoint::SqGetNull(HSQUIRRELVM vm)
|
||||
{
|
||||
sq_pushobject(vm, Core::Get().GetNullCheckpoint().GetObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object & CCheckpoint::GetNull()
|
||||
{
|
||||
return Core::Get().GetNullCheckpoint();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CCheckpoint::CCheckpoint(Int32 id)
|
||||
: m_ID(VALID_ENTITYGETEX(id, SQMOD_CHECKPOINT_POOL))
|
||||
@ -546,6 +559,8 @@ void Register_CCheckpoint(HSQUIRRELVM vm)
|
||||
(_SC("Create"), &Checkpoint_Create)
|
||||
.StaticOverload< Object & (*)(Int32, bool, const Vector3 &, const Color4 &, Float32, Int32, Object &) >
|
||||
(_SC("Create"), &Checkpoint_Create)
|
||||
// Raw Squirrel Methods
|
||||
.SquirrelFunc(_SC("NullInst"), &CCheckpoint::SqGetNull)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,16 @@ public:
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static SQInteger SqGetNull(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static Object & GetNull();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the identifier of the entity managed by this instance.
|
||||
*/
|
||||
|
@ -16,6 +16,19 @@ SQInteger CKeybind::Typename(HSQUIRRELVM vm)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger CKeybind::SqGetNull(HSQUIRRELVM vm)
|
||||
{
|
||||
sq_pushobject(vm, Core::Get().GetNullKeybind().GetObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object & CKeybind::GetNull()
|
||||
{
|
||||
return Core::Get().GetNullKeybind();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CKeybind::CKeybind(Int32 id)
|
||||
: m_ID(VALID_ENTITYGETEX(id, SQMOD_KEYBIND_POOL))
|
||||
@ -233,6 +246,8 @@ void Register_CKeybind(HSQUIRRELVM vm)
|
||||
(_SC("Create"), &Keybind_Create)
|
||||
.StaticOverload< Object & (*)(bool, Int32, Int32, Int32, Int32, Object &) >
|
||||
(_SC("Create"), &Keybind_Create)
|
||||
// Raw Squirrel Methods
|
||||
.SquirrelFunc(_SC("NullInst"), &CKeybind::SqGetNull)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,16 @@ public:
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static SQInteger SqGetNull(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static Object & GetNull();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the identifier of the entity managed by this instance.
|
||||
*/
|
||||
|
@ -23,6 +23,19 @@ SQInteger CObject::Typename(HSQUIRRELVM vm)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger CObject::SqGetNull(HSQUIRRELVM vm)
|
||||
{
|
||||
sq_pushobject(vm, Core::Get().GetNullObject().GetObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object & CObject::GetNull()
|
||||
{
|
||||
return Core::Get().GetNullObject();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CObject::CObject(Int32 id)
|
||||
: m_ID(VALID_ENTITYGETEX(id, SQMOD_OBJECT_POOL))
|
||||
@ -927,6 +940,8 @@ void Register_CObject(HSQUIRRELVM vm)
|
||||
(_SC("Create"), &Object_Create)
|
||||
.StaticOverload< Object & (*)(Int32, Int32, const Vector3 &, Int32, Int32, Object &) >
|
||||
(_SC("Create"), &Object_Create)
|
||||
// Raw Squirrel Methods
|
||||
.SquirrelFunc(_SC("NullInst"), &CObject::SqGetNull)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -117,6 +117,16 @@ public:
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static SQInteger SqGetNull(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static Object & GetNull();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the identifier of the entity managed by this instance.
|
||||
*/
|
||||
|
@ -21,6 +21,19 @@ SQInteger CPickup::Typename(HSQUIRRELVM vm)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger CPickup::SqGetNull(HSQUIRRELVM vm)
|
||||
{
|
||||
sq_pushobject(vm, Core::Get().GetNullPickup().GetObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object & CPickup::GetNull()
|
||||
{
|
||||
return Core::Get().GetNullPickup();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CPickup::CPickup(Int32 id)
|
||||
: m_ID(VALID_ENTITYGETEX(id, SQMOD_PICKUP_POOL))
|
||||
@ -427,6 +440,8 @@ void Register_CPickup(HSQUIRRELVM vm)
|
||||
(_SC("Create"), &Pickup_Create)
|
||||
.StaticOverload< Object & (*)(Int32, Int32, Int32, const Vector3 &, Int32, bool, Int32, Object &) >
|
||||
(_SC("Create"), &Pickup_Create)
|
||||
// Raw Squirrel Methods
|
||||
.SquirrelFunc(_SC("NullInst"), &CPickup::SqGetNull)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,16 @@ public:
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static SQInteger SqGetNull(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static Object & GetNull();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the identifier of the entity managed by this instance.
|
||||
*/
|
||||
|
@ -37,6 +37,19 @@ SQInteger CPlayer::Typename(HSQUIRRELVM vm)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger CPlayer::SqGetNull(HSQUIRRELVM vm)
|
||||
{
|
||||
sq_pushobject(vm, Core::Get().GetNullPlayer().GetObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object & CPlayer::GetNull()
|
||||
{
|
||||
return Core::Get().GetNullPlayer();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CPlayer::CPlayer(Int32 id)
|
||||
: m_ID(VALID_ENTITYGETEX(id, SQMOD_PLAYER_POOL))
|
||||
@ -2357,6 +2370,7 @@ void Register_CPlayer(HSQUIRRELVM vm)
|
||||
.SquirrelFunc(_SC("AnnounceEx"), &CPlayer::AnnounceEx)
|
||||
.SquirrelFunc(_SC("Text"), &CPlayer::Announce)
|
||||
.SquirrelFunc(_SC("TextEx"), &CPlayer::AnnounceEx)
|
||||
.SquirrelFunc(_SC("NullInst"), &CPlayer::SqGetNull)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -174,6 +174,16 @@ public:
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static SQInteger SqGetNull(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static Object & GetNull();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the identifier of the entity managed by this instance.
|
||||
*/
|
||||
|
@ -25,6 +25,19 @@ SQInteger CVehicle::Typename(HSQUIRRELVM vm)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger CVehicle::SqGetNull(HSQUIRRELVM vm)
|
||||
{
|
||||
sq_pushobject(vm, Core::Get().GetNullVehicle().GetObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object & CVehicle::GetNull()
|
||||
{
|
||||
return Core::Get().GetNullVehicle();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CVehicle::CVehicle(Int32 id)
|
||||
: m_ID(VALID_ENTITYGETEX(id, SQMOD_VEHICLE_POOL))
|
||||
@ -1811,7 +1824,8 @@ void Register_CVehicle(HSQUIRRELVM vm)
|
||||
(_SC("Create"), &Vehicle_Create)
|
||||
.StaticOverload< Object & (*)(Int32, Int32, const Vector3 &, Float32, Int32, Int32, Int32, Object &) >
|
||||
(_SC("Create"), &Vehicle_Create)
|
||||
|
||||
// Raw Squirrel Methods
|
||||
.SquirrelFunc(_SC("NullInst"), &CVehicle::SqGetNull)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,16 @@ public:
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static SQInteger SqGetNull(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated null entity instance.
|
||||
*/
|
||||
static Object & GetNull();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the identifier of the entity managed by this instance.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user