2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Core.hpp"
|
2016-05-22 05:20:38 +02:00
|
|
|
#include "Base/Stack.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
2016-03-24 08:32:44 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-24 18:26:43 +02:00
|
|
|
extern bool GetReloadStatus();
|
|
|
|
extern void SetReloadStatus(bool toggle);
|
2016-03-24 08:32:44 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-24 18:26:43 +02:00
|
|
|
static void BindEvent(Int32 id, Object & env, Function & func)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
Core::Get().BindEvent(id, env, func);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
|
|
|
|
2016-05-24 18:26:43 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static void CustomEvent(Int32 group, Int32 header, Object & payload)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
Core::Get().EmitCustomEvent(group, header, payload);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
|
|
|
|
2016-05-24 18:26:43 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static bool SqGetReloadStatus()
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
return GetReloadStatus();
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
|
|
|
|
2016-05-24 18:26:43 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static void SqSetReloadStatus(bool toggle)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
SetReloadStatus(toggle);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
|
|
|
|
2016-05-24 18:26:43 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static void SqReloadBecause(Int32 header, Object & payload)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
// Assign the reload info
|
|
|
|
Core::Get().SetReloadInfo(header, payload);
|
|
|
|
// Enable reloading
|
|
|
|
SetReloadStatus(true);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
|
|
|
|
2016-05-24 18:26:43 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static void SqSetReloadInfo(Int32 header, Object & payload)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
Core::Get().SetReloadInfo(header, payload);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-24 18:26:43 +02:00
|
|
|
static Int32 SqGetReloadHeader()
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
return Core::Get().GetReloadHeader();
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2016-05-23 02:51:44 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-24 18:26:43 +02:00
|
|
|
static Object & SqGetReloadPayload()
|
2016-05-23 02:51:44 +02:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
return Core::Get().GetReloadPayload();
|
2016-05-23 02:51:44 +02:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-12 21:51:44 +01:00
|
|
|
static Int32 GetState()
|
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetState();
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
|
|
|
|
2016-05-24 18:26:43 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-12 21:51:44 +01:00
|
|
|
static void SetState(Int32 value)
|
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().SetState(value);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-12 21:51:44 +01:00
|
|
|
static CSStr GetOption(CSStr name)
|
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetOption(name);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
|
|
|
|
2016-05-24 18:26:43 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-12 21:51:44 +01:00
|
|
|
static CSStr GetOptionOr(CSStr name, CSStr value)
|
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetOption(name, value);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
|
|
|
|
2016-05-24 18:26:43 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-12 21:51:44 +01:00
|
|
|
static void SetOption(CSStr name, CSStr value)
|
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().SetOption(name, value);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2016-03-24 08:32:44 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-24 18:26:43 +02:00
|
|
|
static Object & GetBlip(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 Object & GetCheckpoint(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 Object & GetKeybind(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 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)
|
2016-03-24 08:32:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
// Validate the identifier first
|
|
|
|
if (INVALID_ENTITYEX(id, SQMOD_CHECKPOINT_POOL))
|
2016-03-24 08:32:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
STHROWF("Out of range checkpoint identifier: %d", id);
|
2016-03-24 08:32:44 +01:00
|
|
|
}
|
2016-05-24 18:26:43 +02:00
|
|
|
// 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))
|
2016-03-24 08:32:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
STHROWF("Out of range object identifier: %d", id);
|
2016-03-24 08:32:44 +01:00
|
|
|
}
|
2016-05-24 18:26:43 +02:00
|
|
|
// Perform the requested operation
|
|
|
|
return Core::Get().DelObject(id, header, payload);
|
2016-03-24 08:32:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-24 18:26:43 +02:00
|
|
|
static bool DelPickup(Int32 id, Int32 header, Object & payload)
|
2016-03-24 08:32:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
// 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);
|
2016-03-24 08:32:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-24 18:26:43 +02:00
|
|
|
static bool DelVehicle(Int32 id, Int32 header, Object & payload)
|
2016-03-24 08:32:44 +01:00
|
|
|
{
|
2016-05-24 18:26:43 +02:00
|
|
|
// 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);
|
2016-03-24 08:32:44 +01:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// ================================================================================================
|
|
|
|
void Register_Core(HSQUIRRELVM vm)
|
|
|
|
{
|
|
|
|
RootTable(vm)
|
2016-03-11 19:04:26 +01:00
|
|
|
.Bind(_SC("SqCore"), Table(vm)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Bind"), &BindEvent)
|
2016-05-23 02:51:44 +02:00
|
|
|
.Func(_SC("CustomEvent"), &CustomEvent)
|
2016-05-24 18:26:43 +02:00
|
|
|
.Func(_SC("Reload"), &SqSetReloadStatus)
|
|
|
|
.Func(_SC("Reloading"), &SqGetReloadStatus)
|
|
|
|
.Func(_SC("ReloadBecause"), &SqReloadBecause)
|
|
|
|
.Func(_SC("SetReloadInfo"), &SqSetReloadInfo)
|
|
|
|
.Func(_SC("GetReloadHeader"), &SqGetReloadHeader)
|
|
|
|
.Func(_SC("GetReloadPayload"), &SqGetReloadPayload)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("GetState"), &GetState)
|
|
|
|
.Func(_SC("SetState"), &SetState)
|
|
|
|
.Func(_SC("GetOption"), &GetOption)
|
2016-03-11 19:04:26 +01:00
|
|
|
.Func(_SC("GetOptionOr"), &GetOptionOr)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("SetOption"), &SetOption)
|
|
|
|
.Func(_SC("GetBlip"), &GetBlip)
|
|
|
|
.Func(_SC("GetCheckpoint"), &GetCheckpoint)
|
|
|
|
.Func(_SC("GetKeybind"), &GetKeybind)
|
|
|
|
.Func(_SC("GetObject"), &GetObject)
|
|
|
|
.Func(_SC("GetPickup"), &GetPickup)
|
|
|
|
.Func(_SC("GetPlayer"), &GetPlayer)
|
|
|
|
.Func(_SC("GetVehicle"), &GetVehicle)
|
|
|
|
.Func(_SC("DestroyBlip"), &DelBlip)
|
|
|
|
.Func(_SC("DestroyCheckpoint"), &DelCheckpoint)
|
|
|
|
.Func(_SC("DestroyKeybind"), &DelKeybind)
|
|
|
|
.Func(_SC("DestroyObject"), &DelObject)
|
|
|
|
.Func(_SC("DestroyPickup"), &DelPickup)
|
|
|
|
.Func(_SC("DestroyVehicle"), &DelVehicle)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|