mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
Allow the user to controll when the null entity instances are created. Creating them before executing any scripts will lock entity classes and prevent the user from adding custom elements.
This commit is contained in:
parent
e1ce21962e
commit
863948eb2e
@ -380,15 +380,6 @@ bool Core::Initialize()
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool Core::Execute()
|
bool Core::Execute()
|
||||||
{
|
{
|
||||||
// Create the null entity instances
|
|
||||||
m_NullBlip = LightObj(new CBlip(-1));
|
|
||||||
m_NullCheckpoint = LightObj(new CCheckpoint(-1));
|
|
||||||
m_NullKeybind = LightObj(new CKeybind(-1));
|
|
||||||
m_NullObject = LightObj(new CObject(-1));
|
|
||||||
m_NullPickup = LightObj(new CPickup(-1));
|
|
||||||
m_NullPlayer = LightObj(new CPlayer(-1));
|
|
||||||
m_NullVehicle = LightObj(new CVehicle(-1));
|
|
||||||
|
|
||||||
// Are there any scripts to execute?
|
// Are there any scripts to execute?
|
||||||
if (m_PendingScripts.empty())
|
if (m_PendingScripts.empty())
|
||||||
{
|
{
|
||||||
@ -431,6 +422,8 @@ bool Core::Execute()
|
|||||||
cLogDbg(m_Verbosity >= 2, "Completed execution of stage (%u) scripts. Pending scripts %" PRINT_SZ_FMT,
|
cLogDbg(m_Verbosity >= 2, "Completed execution of stage (%u) scripts. Pending scripts %" PRINT_SZ_FMT,
|
||||||
levels, static_cast< SQUnsignedInteger >(m_PendingScripts.size()));
|
levels, static_cast< SQUnsignedInteger >(m_PendingScripts.size()));
|
||||||
}
|
}
|
||||||
|
// Force enable null entities if not already enabled by script
|
||||||
|
EnableNullEntities();
|
||||||
|
|
||||||
m_LockPreLoadSignal = true;
|
m_LockPreLoadSignal = true;
|
||||||
// Trigger callbacks that must initialize stuff before the loaded event is triggered
|
// Trigger callbacks that must initialize stuff before the loaded event is triggered
|
||||||
@ -569,6 +562,19 @@ bool Core::Reload()
|
|||||||
return (Initialize() && Execute());
|
return (Initialize() && Execute());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Core::EnableNullEntities()
|
||||||
|
{
|
||||||
|
// Create the null entity instances
|
||||||
|
if (m_NullBlip.IsNull()) m_NullBlip = LightObj(new CBlip(-1));
|
||||||
|
if (m_NullCheckpoint.IsNull()) m_NullBlip = LightObj(new CCheckpoint(-1));
|
||||||
|
if (m_NullKeybind.IsNull()) m_NullBlip = LightObj(new CKeybind(-1));
|
||||||
|
if (m_NullObject.IsNull()) m_NullBlip = LightObj(new CObject(-1));
|
||||||
|
if (m_NullPickup.IsNull()) m_NullBlip = LightObj(new CPickup(-1));
|
||||||
|
if (m_NullPlayer.IsNull()) m_NullBlip = LightObj(new CPlayer(-1));
|
||||||
|
if (m_NullVehicle.IsNull()) m_NullBlip = LightObj(new CVehicle(-1));
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
CSStr Core::GetOption(CSStr name) const
|
CSStr Core::GetOption(CSStr name) const
|
||||||
{
|
{
|
||||||
|
@ -767,6 +767,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool Reload();
|
bool Reload();
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Create the null instances of entity classes. Thus, locking them from further changes.
|
||||||
|
*/
|
||||||
|
void EnableNullEntities();
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the current plug-in state.
|
* Modify the current plug-in state.
|
||||||
*/
|
*/
|
||||||
|
@ -50,6 +50,13 @@ static SQInteger SqGetEvents(HSQUIRRELVM vm)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static SQInteger SqEnableNullEntities(HSQUIRRELVM vm)
|
||||||
|
{
|
||||||
|
Core::Get().EnableNullEntities();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static LightObj & SqGetPreLoadEvent()
|
static LightObj & SqGetPreLoadEvent()
|
||||||
{
|
{
|
||||||
@ -351,6 +358,7 @@ void Register_Core(HSQUIRRELVM vm)
|
|||||||
.Func(_SC("OnPreLoad"), &SqGetPreLoadEvent)
|
.Func(_SC("OnPreLoad"), &SqGetPreLoadEvent)
|
||||||
.Func(_SC("OnPostLoad"), &SqGetPostLoadEvent)
|
.Func(_SC("OnPostLoad"), &SqGetPostLoadEvent)
|
||||||
.Func(_SC("OnUnload"), &SqGetUnloadEvent)
|
.Func(_SC("OnUnload"), &SqGetUnloadEvent)
|
||||||
|
.SquirrelFunc(_SC("EnableNullEntities"), &SqEnableNullEntities)
|
||||||
.SquirrelFunc(_SC("LoadScript"), &SqLoadScript)
|
.SquirrelFunc(_SC("LoadScript"), &SqLoadScript)
|
||||||
.SquirrelFunc(_SC("On"), &SqGetEvents);
|
.SquirrelFunc(_SC("On"), &SqGetEvents);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user