mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
Move most of the reload implementation to the central core.
This commit is contained in:
parent
e628428ab7
commit
f05e562708
@ -38,9 +38,6 @@ extern void TerminateRoutines();
|
|||||||
extern void InitializeCmdManager();
|
extern void InitializeCmdManager();
|
||||||
extern void TerminateCmdManager();
|
extern void TerminateCmdManager();
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
extern Object & ReloadPayload();
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Core Core::s_Inst;
|
Core Core::s_Inst;
|
||||||
|
|
||||||
@ -58,6 +55,8 @@ Core::Core()
|
|||||||
, m_Players()
|
, m_Players()
|
||||||
, m_Vehicles()
|
, m_Vehicles()
|
||||||
, m_CircularLocks(0)
|
, m_CircularLocks(0)
|
||||||
|
, m_ReloadHeader(0)
|
||||||
|
, m_ReloadPayload()
|
||||||
, m_IncomingNameBuffer(nullptr)
|
, m_IncomingNameBuffer(nullptr)
|
||||||
, m_IncomingNameCapacity(0)
|
, m_IncomingNameCapacity(0)
|
||||||
{
|
{
|
||||||
@ -340,7 +339,7 @@ void Core::Terminate()
|
|||||||
// Release all resources from command manager
|
// Release all resources from command manager
|
||||||
TerminateCmdManager();
|
TerminateCmdManager();
|
||||||
// In case there's a payload for reload
|
// In case there's a payload for reload
|
||||||
ReloadPayload().Release();
|
m_ReloadPayload.Release();
|
||||||
// Release null objects in case any reference to valid objects is stored in them
|
// Release null objects in case any reference to valid objects is stored in them
|
||||||
NullArray().Release();
|
NullArray().Release();
|
||||||
NullTable().Release();
|
NullTable().Release();
|
||||||
@ -362,7 +361,7 @@ void Core::Terminate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool Core::Reload(Int32 header, Object & payload)
|
bool Core::Reload()
|
||||||
{
|
{
|
||||||
// Are we already reloading?
|
// Are we already reloading?
|
||||||
if (m_CircularLocks & CCL_RELOAD_SCRIPTS)
|
if (m_CircularLocks & CCL_RELOAD_SCRIPTS)
|
||||||
@ -374,7 +373,7 @@ bool Core::Reload(Int32 header, Object & payload)
|
|||||||
// Allow reloading by default
|
// Allow reloading by default
|
||||||
Core::Get().SetState(1);
|
Core::Get().SetState(1);
|
||||||
// Emit the reload event
|
// Emit the reload event
|
||||||
Core::Get().EmitScriptReload(header, payload);
|
Core::Get().EmitScriptReload(m_ReloadHeader, m_ReloadPayload);
|
||||||
// Are we allowed to reload?
|
// Are we allowed to reload?
|
||||||
if (!Core::Get().GetState())
|
if (!Core::Get().GetState())
|
||||||
{
|
{
|
||||||
@ -382,18 +381,10 @@ bool Core::Reload(Int32 header, Object & payload)
|
|||||||
}
|
}
|
||||||
// Terminate the current VM and release resources
|
// Terminate the current VM and release resources
|
||||||
Terminate();
|
Terminate();
|
||||||
// Attempt to initialize it the central core
|
// Reset the reload header after termination
|
||||||
if (!Initialize())
|
m_ReloadHeader = -1;
|
||||||
{
|
// Attempt to initialize the central core and load resources
|
||||||
return false; // Reload failed!
|
return (Initialize() && Execute());
|
||||||
}
|
|
||||||
// Attempt to load resources
|
|
||||||
else if (!Execute())
|
|
||||||
{
|
|
||||||
return false; // Reload failed!
|
|
||||||
}
|
|
||||||
// At this point the reload is complete
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -372,6 +372,10 @@ private:
|
|||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
Uint32 m_CircularLocks; // Prevent events from triggering themselves.
|
Uint32 m_CircularLocks; // Prevent events from triggering themselves.
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Int32 m_ReloadHeader; // The specified reload header.
|
||||||
|
Object m_ReloadPayload; // The specified reload payload.
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
CStr m_IncomingNameBuffer; // Name of an incomming connection.
|
CStr m_IncomingNameBuffer; // Name of an incomming connection.
|
||||||
size_t m_IncomingNameCapacity; // Incomming connection name size.
|
size_t m_IncomingNameCapacity; // Incomming connection name size.
|
||||||
@ -404,7 +408,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Reload the plug-in core.
|
* Reload the plug-in core.
|
||||||
*/
|
*/
|
||||||
bool Reload(Int32 header, Object & payload);
|
bool Reload();
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the current plug-in state.
|
* Modify the current plug-in state.
|
||||||
@ -461,6 +465,40 @@ public:
|
|||||||
return (m_CircularLocks & lock);
|
return (m_CircularLocks & lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Set the header and payload for the reload.
|
||||||
|
*/
|
||||||
|
void SetReloadInfo(Int32 header, Object & payload)
|
||||||
|
{
|
||||||
|
m_ReloadHeader = header;
|
||||||
|
m_ReloadPayload = payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Reset the header and payload for the reload.
|
||||||
|
*/
|
||||||
|
void ResetReloadInfo()
|
||||||
|
{
|
||||||
|
m_ReloadHeader = -1;
|
||||||
|
m_ReloadPayload.Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the specified reload header.
|
||||||
|
*/
|
||||||
|
Int32 GetReloadHeader() const
|
||||||
|
{
|
||||||
|
return m_ReloadHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the specified reload header.
|
||||||
|
*/
|
||||||
|
Object & GetReloadPayload()
|
||||||
|
{
|
||||||
|
return m_ReloadPayload;
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Adds a script to the load queue.
|
* Adds a script to the load queue.
|
||||||
*/
|
*/
|
||||||
|
@ -6,49 +6,8 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
extern void EnableReload(Int32 header, Object & payload);
|
extern bool GetReloadStatus();
|
||||||
extern void DisableReload();
|
extern void SetReloadStatus(bool toggle);
|
||||||
extern bool ReloadEnabled();
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
static Object & GetBlip(Int32 id) { return Core::Get().GetBlip(id).mObj; }
|
|
||||||
static Object & GetCheckpoint(Int32 id) { return Core::Get().GetCheckpoint(id).mObj; }
|
|
||||||
static Object & GetKeybind(Int32 id) { return Core::Get().GetKeybind(id).mObj; }
|
|
||||||
static Object & GetObject(Int32 id) { return Core::Get().GetObject(id).mObj; }
|
|
||||||
static Object & GetPickup(Int32 id) { return Core::Get().GetPickup(id).mObj; }
|
|
||||||
static Object & GetPlayer(Int32 id) { return Core::Get().GetPlayer(id).mObj; }
|
|
||||||
static Object & GetVehicle(Int32 id) { return Core::Get().GetVehicle(id).mObj; }
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
static bool DelBlip(Int32 id, Int32 header, Object & payload)
|
|
||||||
{
|
|
||||||
return Core::Get().DelBlip(id, header, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool DelCheckpoint(Int32 id, Int32 header, Object & payload)
|
|
||||||
{
|
|
||||||
return Core::Get().DelCheckpoint(id, header, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool DelKeybind(Int32 id, Int32 header, Object & payload)
|
|
||||||
{
|
|
||||||
return Core::Get().DelKeybind(id, header, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool DelObject(Int32 id, Int32 header, Object & payload)
|
|
||||||
{
|
|
||||||
return Core::Get().DelObject(id, header, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool DelPickup(Int32 id, Int32 header, Object & payload)
|
|
||||||
{
|
|
||||||
return Core::Get().DelPickup(id, header, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool DelVehicle(Int32 id, Int32 header, Object & payload)
|
|
||||||
{
|
|
||||||
return Core::Get().DelVehicle(id, header, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static void BindEvent(Int32 id, Object & env, Function & func)
|
static void BindEvent(Int32 id, Object & env, Function & func)
|
||||||
@ -62,12 +21,52 @@ static void CustomEvent(Int32 group, Int32 header, Object & payload)
|
|||||||
Core::Get().EmitCustomEvent(group, header, payload);
|
Core::Get().EmitCustomEvent(group, header, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static bool SqGetReloadStatus()
|
||||||
|
{
|
||||||
|
return GetReloadStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static void SqSetReloadStatus(bool toggle)
|
||||||
|
{
|
||||||
|
SetReloadStatus(toggle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static void SqReloadBecause(Int32 header, Object & payload)
|
||||||
|
{
|
||||||
|
// Assign the reload info
|
||||||
|
Core::Get().SetReloadInfo(header, payload);
|
||||||
|
// Enable reloading
|
||||||
|
SetReloadStatus(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static void SqSetReloadInfo(Int32 header, Object & payload)
|
||||||
|
{
|
||||||
|
Core::Get().SetReloadInfo(header, payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static Int32 SqGetReloadHeader()
|
||||||
|
{
|
||||||
|
return Core::Get().GetReloadHeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static Object & SqGetReloadPayload()
|
||||||
|
{
|
||||||
|
return Core::Get().GetReloadPayload();
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static Int32 GetState()
|
static Int32 GetState()
|
||||||
{
|
{
|
||||||
return Core::Get().GetState();
|
return Core::Get().GetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
static void SetState(Int32 value)
|
static void SetState(Int32 value)
|
||||||
{
|
{
|
||||||
return Core::Get().SetState(value);
|
return Core::Get().SetState(value);
|
||||||
@ -79,39 +78,172 @@ static CSStr GetOption(CSStr name)
|
|||||||
return Core::Get().GetOption(name);
|
return Core::Get().GetOption(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
static CSStr GetOptionOr(CSStr name, CSStr value)
|
static CSStr GetOptionOr(CSStr name, CSStr value)
|
||||||
{
|
{
|
||||||
return Core::Get().GetOption(name, value);
|
return Core::Get().GetOption(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
static void SetOption(CSStr name, CSStr value)
|
static void SetOption(CSStr name, CSStr value)
|
||||||
{
|
{
|
||||||
return Core::Get().SetOption(name, value);
|
return Core::Get().SetOption(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static void SetReload(bool toggle)
|
static Object & GetBlip(Int32 id)
|
||||||
{
|
{
|
||||||
if (toggle)
|
// Validate the identifier first
|
||||||
|
if (INVALID_ENTITYEX(id, SQMOD_BLIP_POOL))
|
||||||
{
|
{
|
||||||
EnableReload(0, NullObject());
|
STHROWF("Out of range blip identifier: %d", id);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DisableReload();
|
|
||||||
}
|
}
|
||||||
|
// Return the requested information
|
||||||
|
return Core::Get().GetBlip(id).mObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static void SetReloadBecause(Int32 header, Object & payload)
|
static Object & GetCheckpoint(Int32 id)
|
||||||
{
|
{
|
||||||
EnableReload(header, payload);
|
// 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 bool IsReloading()
|
static Object & GetKeybind(Int32 id)
|
||||||
{
|
{
|
||||||
return ReloadEnabled();
|
// 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 Object & GetObject(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 Object & GetPickup(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 Object & GetPlayer(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 Object & GetVehicle(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 DelBlip(Int32 id, Int32 header, Object & 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 DelCheckpoint(Int32 id, Int32 header, Object & 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 DelKeybind(Int32 id, Int32 header, Object & 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 DelObject(Int32 id, Int32 header, Object & 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 DelPickup(Int32 id, Int32 header, Object & 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 DelVehicle(Int32 id, Int32 header, Object & 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
@ -121,9 +253,12 @@ void Register_Core(HSQUIRRELVM vm)
|
|||||||
.Bind(_SC("SqCore"), Table(vm)
|
.Bind(_SC("SqCore"), Table(vm)
|
||||||
.Func(_SC("Bind"), &BindEvent)
|
.Func(_SC("Bind"), &BindEvent)
|
||||||
.Func(_SC("CustomEvent"), &CustomEvent)
|
.Func(_SC("CustomEvent"), &CustomEvent)
|
||||||
.Func(_SC("Reload"), &SetReload)
|
.Func(_SC("Reload"), &SqSetReloadStatus)
|
||||||
.Func(_SC("ReloadBecause"), &SetReloadBecause)
|
.Func(_SC("Reloading"), &SqGetReloadStatus)
|
||||||
.Func(_SC("Reloading"), &IsReloading)
|
.Func(_SC("ReloadBecause"), &SqReloadBecause)
|
||||||
|
.Func(_SC("SetReloadInfo"), &SqSetReloadInfo)
|
||||||
|
.Func(_SC("GetReloadHeader"), &SqGetReloadHeader)
|
||||||
|
.Func(_SC("GetReloadPayload"), &SqGetReloadPayload)
|
||||||
.Func(_SC("GetState"), &GetState)
|
.Func(_SC("GetState"), &GetState)
|
||||||
.Func(_SC("SetState"), &SetState)
|
.Func(_SC("SetState"), &SetState)
|
||||||
.Func(_SC("GetOption"), &GetOption)
|
.Func(_SC("GetOption"), &GetOption)
|
||||||
|
@ -10,50 +10,27 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static bool g_Reload = false;
|
static bool g_Reload = false;
|
||||||
static Int32 g_ReloadHeader = -1;
|
|
||||||
static Object g_ReloadPayload;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
extern void InitExports();
|
extern void InitExports();
|
||||||
extern void ProcessRoutines();
|
extern void ProcessRoutines();
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
|
||||||
* Perform a scripts reload at the end of the current event.
|
|
||||||
*/
|
|
||||||
void EnableReload(Int32 header, Object & payload)
|
|
||||||
{
|
|
||||||
g_Reload = true;
|
|
||||||
g_ReloadHeader = header;
|
|
||||||
g_ReloadPayload = payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
|
||||||
* Do not perform a scripts reload at the end of the current event.
|
|
||||||
*/
|
|
||||||
void DisableReload()
|
|
||||||
{
|
|
||||||
g_Reload = false;
|
|
||||||
g_ReloadHeader = -1;
|
|
||||||
g_ReloadPayload.Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Will the scripts be reloaded at the end of the current event?
|
* Will the scripts be reloaded at the end of the current event?
|
||||||
*/
|
*/
|
||||||
bool ReloadEnabled()
|
bool GetReloadStatus()
|
||||||
{
|
{
|
||||||
return g_Reload;
|
return g_Reload;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the payload that will be sent to the reload callback.
|
* Toggles the reload status.
|
||||||
*/
|
*/
|
||||||
Object & ReloadPayload()
|
void SetReloadStatus(bool toggle)
|
||||||
{
|
{
|
||||||
return g_ReloadPayload;
|
g_Reload = toggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Helper class to make sure that the reload is disabled and the payload is released.
|
* Helper class to make sure that the reload is disabled and the payload is released.
|
||||||
*/
|
*/
|
||||||
@ -61,7 +38,7 @@ struct ReloadGuard
|
|||||||
{
|
{
|
||||||
~ReloadGuard()
|
~ReloadGuard()
|
||||||
{
|
{
|
||||||
DisableReload();
|
g_Reload = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,10 +52,10 @@ void DoReload()
|
|||||||
{
|
{
|
||||||
return; // Don't even bother!
|
return; // Don't even bother!
|
||||||
}
|
}
|
||||||
// Release resources at the end of this function
|
// Make sure reloading is disabled at the end of this function
|
||||||
const ReloadGuard rg;
|
const ReloadGuard rg;
|
||||||
// Tell the central core to attempt to reload
|
// Tell the central core to attempt to reload
|
||||||
if (!Core::Get().Reload(g_ReloadHeader, g_ReloadPayload))
|
if (!Core::Get().Reload())
|
||||||
{
|
{
|
||||||
LogFtl("Unable to reload scripts");
|
LogFtl("Unable to reload scripts");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user