mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
Implement signal for executed scripts.
This commit is contained in:
parent
0ed82f66e1
commit
3bef7e9419
@ -356,6 +356,7 @@ bool Core::Initialize()
|
|||||||
InitSignalPair(mOnPreLoad, NullLightObj(), nullptr);
|
InitSignalPair(mOnPreLoad, NullLightObj(), nullptr);
|
||||||
InitSignalPair(mOnPostLoad, NullLightObj(), nullptr);
|
InitSignalPair(mOnPostLoad, NullLightObj(), nullptr);
|
||||||
InitSignalPair(mOnUnload, NullLightObj(), nullptr);
|
InitSignalPair(mOnUnload, NullLightObj(), nullptr);
|
||||||
|
InitSignalPair(mOnScript, NullLightObj(), nullptr);
|
||||||
|
|
||||||
CSimpleIniA::TNamesDepend scripts;
|
CSimpleIniA::TNamesDepend scripts;
|
||||||
// Attempt to retrieve the list of keys to make sure there's actually something to process
|
// Attempt to retrieve the list of keys to make sure there's actually something to process
|
||||||
@ -510,6 +511,7 @@ void Core::Terminate(bool shutdown)
|
|||||||
// Tell modules to do their monkey business
|
// Tell modules to do their monkey business
|
||||||
//_Func->SendPluginCommand(0xDEADC0DE, "");
|
//_Func->SendPluginCommand(0xDEADC0DE, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
cLogDbg(m_Verbosity >= 1, "Clearing the entity containers");
|
cLogDbg(m_Verbosity >= 1, "Clearing the entity containers");
|
||||||
// Release all entity resources by clearing the containers
|
// Release all entity resources by clearing the containers
|
||||||
const ContainerCleaner cc_players(m_Players, ENT_PLAYER, !shutdown);
|
const ContainerCleaner cc_players(m_Players, ENT_PLAYER, !shutdown);
|
||||||
@ -571,6 +573,7 @@ void Core::Terminate(bool shutdown)
|
|||||||
{
|
{
|
||||||
cLogDbg(m_Verbosity >= 1, "Releasing any final resources and all loaded scripts");
|
cLogDbg(m_Verbosity >= 1, "Releasing any final resources and all loaded scripts");
|
||||||
// Release all script callbacks
|
// Release all script callbacks
|
||||||
|
ResetSignalPair(mOnScript);
|
||||||
DropEvents();
|
DropEvents();
|
||||||
// Release the script instances
|
// Release the script instances
|
||||||
m_Scripts.clear();
|
m_Scripts.clear();
|
||||||
@ -793,6 +796,8 @@ bool Core::LoadScript(const SQChar * filepath, Function & cb, LightObj & ctx, bo
|
|||||||
// Release callback since we know it exists
|
// Release callback since we know it exists
|
||||||
s.mFunc.Release();
|
s.mFunc.Release();
|
||||||
}
|
}
|
||||||
|
// Invoke the global callback
|
||||||
|
(*mOnScript.first)(s.mPath, s.mCtx);
|
||||||
// Release context, if any
|
// Release context, if any
|
||||||
s.mCtx.Release();
|
s.mCtx.Release();
|
||||||
}
|
}
|
||||||
@ -926,6 +931,8 @@ bool Core::DoScripts(Scripts::iterator itr, Scripts::iterator end)
|
|||||||
// Release callback since we know it exists
|
// Release callback since we know it exists
|
||||||
s.mFunc.Release();
|
s.mFunc.Release();
|
||||||
}
|
}
|
||||||
|
// Invoke the global callback
|
||||||
|
(*Core::Get().mOnScript.first)(s.mPath, s.mCtx);
|
||||||
// Release context, if any
|
// Release context, if any
|
||||||
s.mCtx.Release();
|
s.mCtx.Release();
|
||||||
}
|
}
|
||||||
@ -966,6 +973,8 @@ bool Core::DoScripts(Scripts::iterator itr, Scripts::iterator end)
|
|||||||
// Release callback since we know it exists
|
// Release callback since we know it exists
|
||||||
s.mFunc.Release();
|
s.mFunc.Release();
|
||||||
}
|
}
|
||||||
|
// Invoke the global callback
|
||||||
|
(*Core::Get().mOnScript.first)(s.mPath, s.mCtx);
|
||||||
// Release context, if any
|
// Release context, if any
|
||||||
s.mCtx.Release();
|
s.mCtx.Release();
|
||||||
}
|
}
|
||||||
@ -2339,7 +2348,7 @@ void Core::InitEvents()
|
|||||||
#endif
|
#endif
|
||||||
InitSignalPair(mOnServerOption, m_Events, "ServerOption");
|
InitSignalPair(mOnServerOption, m_Events, "ServerOption");
|
||||||
InitSignalPair(mOnScriptReload, m_Events, "ScriptReload");
|
InitSignalPair(mOnScriptReload, m_Events, "ScriptReload");
|
||||||
InitSignalPair(mOnScriptLoaded, m_Events, "ScriptLoaded");
|
InitSignalPair(mOnScript, m_Events, "ScriptLoaded");
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Core::DropEvents()
|
void Core::DropEvents()
|
||||||
@ -2484,7 +2493,7 @@ void Core::DropEvents()
|
|||||||
#endif
|
#endif
|
||||||
ResetSignalPair(mOnServerOption);
|
ResetSignalPair(mOnServerOption);
|
||||||
ResetSignalPair(mOnScriptReload);
|
ResetSignalPair(mOnScriptReload);
|
||||||
ResetSignalPair(mOnScriptLoaded);
|
ResetSignalPair(mOnScript);
|
||||||
m_Events.Release();
|
m_Events.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2545,6 +2554,15 @@ static SQInteger SqGetEvents(HSQUIRRELVM vm)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static SQInteger SqGetOnScript(HSQUIRRELVM vm)
|
||||||
|
{
|
||||||
|
// Push the events table object on the stack
|
||||||
|
sq_pushobject(vm, Core::Get().mOnScript.second);
|
||||||
|
// Specify that we're returning a value
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static void SqEmitCustomEvent(int32_t group, int32_t header, LightObj & payload)
|
static void SqEmitCustomEvent(int32_t group, int32_t header, LightObj & payload)
|
||||||
{
|
{
|
||||||
@ -2869,6 +2887,7 @@ void Register_Core(HSQUIRRELVM vm)
|
|||||||
.CbFunc(_SC("LoadScriptNotify"), &SqLoadScriptNotify)
|
.CbFunc(_SC("LoadScriptNotify"), &SqLoadScriptNotify)
|
||||||
.SquirrelFunc(_SC("ForceEnableNullEntities"), &SqForceEnableNullEntities)
|
.SquirrelFunc(_SC("ForceEnableNullEntities"), &SqForceEnableNullEntities)
|
||||||
.SquirrelFunc(_SC("LoadScript"), &SqLoadScript, -3, ".b.")
|
.SquirrelFunc(_SC("LoadScript"), &SqLoadScript, -3, ".b.")
|
||||||
|
.SquirrelFunc(_SC("OnScript"), &SqGetOnScript)
|
||||||
.SquirrelFunc(_SC("On"), &SqGetEvents);
|
.SquirrelFunc(_SC("On"), &SqGetEvents);
|
||||||
|
|
||||||
RootTable(vm).Bind(_SC("SqCore"), corens);
|
RootTable(vm).Bind(_SC("SqCore"), corens);
|
||||||
|
281
module/Core.hpp
281
module/Core.hpp
@ -704,154 +704,155 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Module signals.
|
* Module signals.
|
||||||
*/
|
*/
|
||||||
SignalPair mOnPreLoad;
|
SignalPair mOnPreLoad{};
|
||||||
SignalPair mOnPostLoad;
|
SignalPair mOnPostLoad{};
|
||||||
SignalPair mOnUnload;
|
SignalPair mOnUnload{};
|
||||||
|
SignalPair mOnScript{}; // Callback to be invoked for each loaded script.
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Server signals.
|
* Server signals.
|
||||||
*/
|
*/
|
||||||
SignalPair mOnCustomEvent;
|
SignalPair mOnCustomEvent{};
|
||||||
SignalPair mOnBlipCreated;
|
SignalPair mOnBlipCreated{};
|
||||||
SignalPair mOnCheckpointCreated;
|
SignalPair mOnCheckpointCreated{};
|
||||||
SignalPair mOnKeyBindCreated;
|
SignalPair mOnKeyBindCreated{};
|
||||||
SignalPair mOnObjectCreated;
|
SignalPair mOnObjectCreated{};
|
||||||
SignalPair mOnPickupCreated;
|
SignalPair mOnPickupCreated{};
|
||||||
SignalPair mOnPlayerCreated;
|
SignalPair mOnPlayerCreated{};
|
||||||
SignalPair mOnVehicleCreated;
|
SignalPair mOnVehicleCreated{};
|
||||||
SignalPair mOnBlipDestroyed;
|
SignalPair mOnBlipDestroyed{};
|
||||||
SignalPair mOnCheckpointDestroyed;
|
SignalPair mOnCheckpointDestroyed{};
|
||||||
SignalPair mOnKeyBindDestroyed;
|
SignalPair mOnKeyBindDestroyed{};
|
||||||
SignalPair mOnObjectDestroyed;
|
SignalPair mOnObjectDestroyed{};
|
||||||
SignalPair mOnPickupDestroyed;
|
SignalPair mOnPickupDestroyed{};
|
||||||
SignalPair mOnPlayerDestroyed;
|
SignalPair mOnPlayerDestroyed{};
|
||||||
SignalPair mOnVehicleDestroyed;
|
SignalPair mOnVehicleDestroyed{};
|
||||||
SignalPair mOnBlipCustom;
|
SignalPair mOnBlipCustom{};
|
||||||
SignalPair mOnCheckpointCustom;
|
SignalPair mOnCheckpointCustom{};
|
||||||
SignalPair mOnKeyBindCustom;
|
SignalPair mOnKeyBindCustom{};
|
||||||
SignalPair mOnObjectCustom;
|
SignalPair mOnObjectCustom{};
|
||||||
SignalPair mOnPickupCustom;
|
SignalPair mOnPickupCustom{};
|
||||||
SignalPair mOnPlayerCustom;
|
SignalPair mOnPlayerCustom{};
|
||||||
SignalPair mOnVehicleCustom;
|
SignalPair mOnVehicleCustom{};
|
||||||
#if SQMOD_SDK_LEAST(2, 1)
|
#if SQMOD_SDK_LEAST(2, 1)
|
||||||
SignalPair mOnCheckpointStream;
|
SignalPair mOnCheckpointStream{};
|
||||||
SignalPair mOnObjectStream;
|
SignalPair mOnObjectStream{};
|
||||||
SignalPair mOnPickupStream;
|
SignalPair mOnPickupStream{};
|
||||||
SignalPair mOnPlayerStream;
|
SignalPair mOnPlayerStream{};
|
||||||
SignalPair mOnVehicleStream;
|
SignalPair mOnVehicleStream{};
|
||||||
#endif
|
#endif
|
||||||
SignalPair mOnServerStartup;
|
SignalPair mOnServerStartup{};
|
||||||
SignalPair mOnServerShutdown;
|
SignalPair mOnServerShutdown{};
|
||||||
SignalPair mOnServerFrame;
|
SignalPair mOnServerFrame{};
|
||||||
SignalPair mOnIncomingConnection;
|
SignalPair mOnIncomingConnection{};
|
||||||
SignalPair mOnPlayerRequestClass;
|
SignalPair mOnPlayerRequestClass{};
|
||||||
SignalPair mOnPlayerRequestSpawn;
|
SignalPair mOnPlayerRequestSpawn{};
|
||||||
SignalPair mOnPlayerSpawn;
|
SignalPair mOnPlayerSpawn{};
|
||||||
SignalPair mOnPlayerWasted;
|
SignalPair mOnPlayerWasted{};
|
||||||
SignalPair mOnPlayerKilled;
|
SignalPair mOnPlayerKilled{};
|
||||||
SignalPair mOnPlayerEmbarking;
|
SignalPair mOnPlayerEmbarking{};
|
||||||
SignalPair mOnPlayerEmbarked;
|
SignalPair mOnPlayerEmbarked{};
|
||||||
SignalPair mOnPlayerDisembark;
|
SignalPair mOnPlayerDisembark{};
|
||||||
SignalPair mOnPlayerRename;
|
SignalPair mOnPlayerRename{};
|
||||||
SignalPair mOnPlayerState;
|
SignalPair mOnPlayerState{};
|
||||||
SignalPair mOnStateNone;
|
SignalPair mOnStateNone{};
|
||||||
SignalPair mOnStateNormal;
|
SignalPair mOnStateNormal{};
|
||||||
SignalPair mOnStateAim;
|
SignalPair mOnStateAim{};
|
||||||
SignalPair mOnStateDriver;
|
SignalPair mOnStateDriver{};
|
||||||
SignalPair mOnStatePassenger;
|
SignalPair mOnStatePassenger{};
|
||||||
SignalPair mOnStateEnterDriver;
|
SignalPair mOnStateEnterDriver{};
|
||||||
SignalPair mOnStateEnterPassenger;
|
SignalPair mOnStateEnterPassenger{};
|
||||||
SignalPair mOnStateExit;
|
SignalPair mOnStateExit{};
|
||||||
SignalPair mOnStateUnspawned;
|
SignalPair mOnStateUnspawned{};
|
||||||
SignalPair mOnPlayerAction;
|
SignalPair mOnPlayerAction{};
|
||||||
SignalPair mOnActionNone;
|
SignalPair mOnActionNone{};
|
||||||
SignalPair mOnActionNormal;
|
SignalPair mOnActionNormal{};
|
||||||
SignalPair mOnActionAiming;
|
SignalPair mOnActionAiming{};
|
||||||
SignalPair mOnActionShooting;
|
SignalPair mOnActionShooting{};
|
||||||
SignalPair mOnActionJumping;
|
SignalPair mOnActionJumping{};
|
||||||
SignalPair mOnActionLieDown;
|
SignalPair mOnActionLieDown{};
|
||||||
SignalPair mOnActionGettingUp;
|
SignalPair mOnActionGettingUp{};
|
||||||
SignalPair mOnActionJumpVehicle;
|
SignalPair mOnActionJumpVehicle{};
|
||||||
SignalPair mOnActionDriving;
|
SignalPair mOnActionDriving{};
|
||||||
SignalPair mOnActionDying;
|
SignalPair mOnActionDying{};
|
||||||
SignalPair mOnActionWasted;
|
SignalPair mOnActionWasted{};
|
||||||
SignalPair mOnActionEmbarking;
|
SignalPair mOnActionEmbarking{};
|
||||||
SignalPair mOnActionDisembarking;
|
SignalPair mOnActionDisembarking{};
|
||||||
SignalPair mOnPlayerBurning;
|
SignalPair mOnPlayerBurning{};
|
||||||
SignalPair mOnPlayerCrouching;
|
SignalPair mOnPlayerCrouching{};
|
||||||
SignalPair mOnPlayerGameKeys;
|
SignalPair mOnPlayerGameKeys{};
|
||||||
SignalPair mOnPlayerStartTyping;
|
SignalPair mOnPlayerStartTyping{};
|
||||||
SignalPair mOnPlayerStopTyping;
|
SignalPair mOnPlayerStopTyping{};
|
||||||
SignalPair mOnPlayerAway;
|
SignalPair mOnPlayerAway{};
|
||||||
SignalPair mOnPlayerMessage;
|
SignalPair mOnPlayerMessage{};
|
||||||
SignalPair mOnPlayerCommand;
|
SignalPair mOnPlayerCommand{};
|
||||||
SignalPair mOnPlayerPrivateMessage;
|
SignalPair mOnPlayerPrivateMessage{};
|
||||||
SignalPair mOnPlayerKeyPress;
|
SignalPair mOnPlayerKeyPress{};
|
||||||
SignalPair mOnPlayerKeyRelease;
|
SignalPair mOnPlayerKeyRelease{};
|
||||||
SignalPair mOnPlayerSpectate;
|
SignalPair mOnPlayerSpectate{};
|
||||||
SignalPair mOnPlayerUnspectate;
|
SignalPair mOnPlayerUnspectate{};
|
||||||
SignalPair mOnPlayerCrashReport;
|
SignalPair mOnPlayerCrashReport{};
|
||||||
SignalPair mOnPlayerModuleList;
|
SignalPair mOnPlayerModuleList{};
|
||||||
SignalPair mOnVehicleExplode;
|
SignalPair mOnVehicleExplode{};
|
||||||
SignalPair mOnVehicleRespawn;
|
SignalPair mOnVehicleRespawn{};
|
||||||
SignalPair mOnObjectShot;
|
SignalPair mOnObjectShot{};
|
||||||
SignalPair mOnObjectTouched;
|
SignalPair mOnObjectTouched{};
|
||||||
SignalPair mOnObjectWorld;
|
SignalPair mOnObjectWorld{};
|
||||||
SignalPair mOnObjectAlpha;
|
SignalPair mOnObjectAlpha{};
|
||||||
SignalPair mOnObjectReport;
|
SignalPair mOnObjectReport{};
|
||||||
SignalPair mOnPickupClaimed;
|
SignalPair mOnPickupClaimed{};
|
||||||
SignalPair mOnPickupCollected;
|
SignalPair mOnPickupCollected{};
|
||||||
SignalPair mOnPickupRespawn;
|
SignalPair mOnPickupRespawn{};
|
||||||
SignalPair mOnPickupWorld;
|
SignalPair mOnPickupWorld{};
|
||||||
SignalPair mOnPickupAlpha;
|
SignalPair mOnPickupAlpha{};
|
||||||
SignalPair mOnPickupAutomatic;
|
SignalPair mOnPickupAutomatic{};
|
||||||
SignalPair mOnPickupAutoTimer;
|
SignalPair mOnPickupAutoTimer{};
|
||||||
SignalPair mOnPickupOption;
|
SignalPair mOnPickupOption{};
|
||||||
SignalPair mOnCheckpointEntered;
|
SignalPair mOnCheckpointEntered{};
|
||||||
SignalPair mOnCheckpointExited;
|
SignalPair mOnCheckpointExited{};
|
||||||
SignalPair mOnCheckpointWorld;
|
SignalPair mOnCheckpointWorld{};
|
||||||
SignalPair mOnCheckpointRadius;
|
SignalPair mOnCheckpointRadius{};
|
||||||
SignalPair mOnEntityPool;
|
SignalPair mOnEntityPool{};
|
||||||
SignalPair mOnClientScriptData;
|
SignalPair mOnClientScriptData{};
|
||||||
SignalPair mOnPlayerUpdate;
|
SignalPair mOnPlayerUpdate{};
|
||||||
SignalPair mOnVehicleUpdate;
|
SignalPair mOnVehicleUpdate{};
|
||||||
SignalPair mOnPlayerHealth;
|
SignalPair mOnPlayerHealth{};
|
||||||
SignalPair mOnPlayerArmour;
|
SignalPair mOnPlayerArmour{};
|
||||||
SignalPair mOnPlayerWeapon;
|
SignalPair mOnPlayerWeapon{};
|
||||||
SignalPair mOnPlayerHeading;
|
SignalPair mOnPlayerHeading{};
|
||||||
SignalPair mOnPlayerPosition;
|
SignalPair mOnPlayerPosition{};
|
||||||
SignalPair mOnPlayerOption;
|
SignalPair mOnPlayerOption{};
|
||||||
SignalPair mOnPlayerAdmin;
|
SignalPair mOnPlayerAdmin{};
|
||||||
SignalPair mOnPlayerWorld;
|
SignalPair mOnPlayerWorld{};
|
||||||
SignalPair mOnPlayerTeam;
|
SignalPair mOnPlayerTeam{};
|
||||||
SignalPair mOnPlayerSkin;
|
SignalPair mOnPlayerSkin{};
|
||||||
SignalPair mOnPlayerMoney;
|
SignalPair mOnPlayerMoney{};
|
||||||
SignalPair mOnPlayerScore;
|
SignalPair mOnPlayerScore{};
|
||||||
SignalPair mOnPlayerWantedLevel;
|
SignalPair mOnPlayerWantedLevel{};
|
||||||
SignalPair mOnPlayerImmunity;
|
SignalPair mOnPlayerImmunity{};
|
||||||
SignalPair mOnPlayerAlpha;
|
SignalPair mOnPlayerAlpha{};
|
||||||
SignalPair mOnPlayerEnterArea;
|
SignalPair mOnPlayerEnterArea{};
|
||||||
SignalPair mOnPlayerLeaveArea;
|
SignalPair mOnPlayerLeaveArea{};
|
||||||
SignalPair mOnVehicleColor;
|
SignalPair mOnVehicleColor{};
|
||||||
SignalPair mOnVehicleHealth;
|
SignalPair mOnVehicleHealth{};
|
||||||
SignalPair mOnVehiclePosition;
|
SignalPair mOnVehiclePosition{};
|
||||||
SignalPair mOnVehicleRotation;
|
SignalPair mOnVehicleRotation{};
|
||||||
SignalPair mOnVehicleOption;
|
SignalPair mOnVehicleOption{};
|
||||||
SignalPair mOnVehicleWorld;
|
SignalPair mOnVehicleWorld{};
|
||||||
SignalPair mOnVehicleImmunity;
|
SignalPair mOnVehicleImmunity{};
|
||||||
SignalPair mOnVehiclePartStatus;
|
SignalPair mOnVehiclePartStatus{};
|
||||||
SignalPair mOnVehicleTyreStatus;
|
SignalPair mOnVehicleTyreStatus{};
|
||||||
SignalPair mOnVehicleDamageData;
|
SignalPair mOnVehicleDamageData{};
|
||||||
SignalPair mOnVehicleRadio;
|
SignalPair mOnVehicleRadio{};
|
||||||
SignalPair mOnVehicleHandlingRule;
|
SignalPair mOnVehicleHandlingRule{};
|
||||||
SignalPair mOnVehicleEnterArea;
|
SignalPair mOnVehicleEnterArea{};
|
||||||
SignalPair mOnVehicleLeaveArea;
|
SignalPair mOnVehicleLeaveArea{};
|
||||||
#if SQMOD_SDK_LEAST(2, 1)
|
#if SQMOD_SDK_LEAST(2, 1)
|
||||||
SignalPair mOnEntityStream;
|
SignalPair mOnEntityStream{};
|
||||||
#endif
|
#endif
|
||||||
SignalPair mOnServerOption;
|
SignalPair mOnServerOption{};
|
||||||
SignalPair mOnScriptReload;
|
SignalPair mOnScriptReload{};
|
||||||
SignalPair mOnScriptLoaded;
|
SignalPair mOnScriptLoaded{};
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user