1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Minor changes in the entity types code style.

This commit is contained in:
Sandu Liviu Catalin 2016-03-12 22:51:44 +02:00
parent a5b353b104
commit 5c81af5026
21 changed files with 380 additions and 26 deletions

View File

@ -95,10 +95,14 @@ void CBlip::BindEvent(Int32 evid, Object & env, Function & func) const
Function & event = _Core->GetBlipEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
@ -285,7 +289,9 @@ static const Object & Blip_FindByID(Int32 id)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a blip matching the specified identifier
return NullObject();
@ -294,8 +300,10 @@ static const Object & Blip_FindByID(Int32 id)
static const Object & Blip_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
if (!tag || *tag == '\0')
{
SqThrowF("The specified blip tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
Core::Blips::const_iterator end = _Core->GetBlips().cend();
@ -304,7 +312,9 @@ static const Object & Blip_FindByTag(CSStr tag)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a blip matching the specified tag
return NullObject();
@ -315,7 +325,9 @@ static const Object & Blip_FindBySprID(Int32 sprid)
{
// Perform a range check on the specified identifier
if (sprid < 0)
{
SqThrowF("The specified sprite identifier is invalid: %d", sprid);
}
// Obtain the ends of the entity pool
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
Core::Blips::const_iterator end = _Core->GetBlips().cend();
@ -324,7 +336,9 @@ static const Object & Blip_FindBySprID(Int32 sprid)
{
// Does the identifier match the specified one?
if (itr->mSprID == sprid)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a blip matching the specified identifier
return NullObject();

View File

@ -75,7 +75,9 @@ public:
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid blip reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------

View File

@ -108,10 +108,14 @@ void CCheckpoint::BindEvent(Int32 evid, Object & env, Function & func) const
Function & event = _Core->GetCheckpointEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
@ -119,7 +123,9 @@ bool CCheckpoint::IsStreamedFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Return the requested information
@ -448,7 +454,9 @@ static const Object & Checkpoint_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_CHECKPOINT_POOL))
{
SqThrowF("The specified checkpoint identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Checkpoints::const_iterator itr = _Core->GetCheckpoints().cbegin();
Core::Checkpoints::const_iterator end = _Core->GetCheckpoints().cend();
@ -457,7 +465,9 @@ static const Object & Checkpoint_FindByID(Int32 id)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a checkpoint matching the specified identifier
return NullObject();
@ -466,8 +476,10 @@ static const Object & Checkpoint_FindByID(Int32 id)
static const Object & Checkpoint_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
if (!tag || *tag == '\0')
{
SqThrowF("The specified checkpoint tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Checkpoints::const_iterator itr = _Core->GetCheckpoints().cbegin();
Core::Checkpoints::const_iterator end = _Core->GetCheckpoints().cend();
@ -476,7 +488,9 @@ static const Object & Checkpoint_FindByTag(CSStr tag)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a checkpoint matching the specified tag
return NullObject();

View File

@ -82,7 +82,9 @@ public:
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid checkpoint reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------

View File

@ -107,10 +107,14 @@ void CForcefield::BindEvent(Int32 evid, Object & env, Function & func) const
Function & event = _Core->GetForcefieldEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
@ -118,7 +122,9 @@ bool CForcefield::IsStreamedFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Return the requested information
@ -422,7 +428,9 @@ static const Object & Forcefield_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_FORCEFIELD_POOL))
{
SqThrowF("The specified forcefield identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Forcefields::const_iterator itr = _Core->GetForcefields().cbegin();
Core::Forcefields::const_iterator end = _Core->GetForcefields().cend();
@ -431,7 +439,9 @@ static const Object & Forcefield_FindByID(Int32 id)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a forcefield matching the specified identifier
return NullObject();
@ -440,8 +450,10 @@ static const Object & Forcefield_FindByID(Int32 id)
static const Object & Forcefield_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
if (!tag || *tag == '\0')
{
SqThrowF("The specified forcefield tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Forcefields::const_iterator itr = _Core->GetForcefields().cbegin();
Core::Forcefields::const_iterator end = _Core->GetForcefields().cend();
@ -450,7 +462,9 @@ static const Object & Forcefield_FindByTag(CSStr tag)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a forcefield matching the specified tag
return NullObject();

View File

@ -82,7 +82,9 @@ public:
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid forcefield reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------

View File

@ -95,10 +95,14 @@ void CKeybind::BindEvent(Int32 evid, Object & env, Function & func) const
Function & event = _Core->GetKeybindEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
@ -169,7 +173,9 @@ static const Object & Keybind_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_KEYBIND_POOL))
{
SqThrowF("The specified keybind identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Keybinds::const_iterator itr = _Core->GetKeybinds().cbegin();
Core::Keybinds::const_iterator end = _Core->GetKeybinds().cend();
@ -178,7 +184,9 @@ static const Object & Keybind_FindByID(Int32 id)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a keybind matching the specified identifier
return NullObject();
@ -187,8 +195,10 @@ static const Object & Keybind_FindByID(Int32 id)
static const Object & Keybind_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
if (!tag || *tag == '\0')
{
SqThrowF("The specified keybind tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Keybinds::const_iterator itr = _Core->GetKeybinds().cbegin();
Core::Keybinds::const_iterator end = _Core->GetKeybinds().cend();
@ -197,7 +207,9 @@ static const Object & Keybind_FindByTag(CSStr tag)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a keybind matching the specified tag
return NullObject();

View File

@ -75,7 +75,9 @@ public:
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid keybind reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------

View File

@ -102,10 +102,14 @@ void CObject::BindEvent(Int32 evid, Object & env, Function & func) const
Function & event = _Core->GetObjectEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
@ -113,7 +117,9 @@ bool CObject::IsStreamedFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Return the requested information
@ -569,7 +575,9 @@ static const Object & Object_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_OBJECT_POOL))
{
SqThrowF("The specified object identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
Core::Objects::const_iterator end = _Core->GetObjects().cend();
@ -578,7 +586,9 @@ static const Object & Object_FindByID(Int32 id)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a object matching the specified identifier
return NullObject();
@ -587,7 +597,7 @@ static const Object & Object_FindByID(Int32 id)
static const Object & Object_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
if (!tag || *tag == '\0')
SqThrowF("The specified object tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
@ -597,7 +607,9 @@ static const Object & Object_FindByTag(CSStr tag)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a object matching the specified tag
return NullObject();

View File

@ -79,7 +79,9 @@ public:
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid object reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------

View File

@ -100,10 +100,14 @@ void CPickup::BindEvent(Int32 evid, Object & env, Function & func) const
Function & event = _Core->GetPickupEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
@ -111,7 +115,9 @@ bool CPickup::IsStreamedFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Return the requested information
@ -355,7 +361,9 @@ static const Object & Pickup_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_PICKUP_POOL))
{
SqThrowF("The specified pickup identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Pickups::const_iterator itr = _Core->GetPickups().cbegin();
Core::Pickups::const_iterator end = _Core->GetPickups().cend();
@ -364,7 +372,9 @@ static const Object & Pickup_FindByID(Int32 id)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a pickup matching the specified identifier
return NullObject();
@ -373,8 +383,10 @@ static const Object & Pickup_FindByID(Int32 id)
static const Object & Pickup_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
if (!tag || *tag == '0')
{
SqThrowF("The specified pickup tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Pickups::const_iterator itr = _Core->GetPickups().cbegin();
Core::Pickups::const_iterator end = _Core->GetPickups().cend();
@ -383,7 +395,9 @@ static const Object & Pickup_FindByTag(CSStr tag)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a pickup matching the specified tag
return NullObject();

View File

@ -78,7 +78,9 @@ public:
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid pickup reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------

View File

@ -99,10 +99,14 @@ void CPlayer::BindEvent(Int32 evid, Object & env, Function & func) const
Function & event = _Core->GetPlayerEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
@ -992,7 +996,9 @@ void CPlayer::SetSpectator(CPlayer & target) const
{
// Is the specified player even valid?
if (!target.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -1075,7 +1081,9 @@ void CPlayer::Embark(CVehicle & vehicle) const
{
// Is the specified vehicle even valid?
if (!vehicle.IsActive())
{
SqThrowF("Invalid vehicle argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -1087,7 +1095,9 @@ void CPlayer::Embark(CVehicle & vehicle, Int32 slot, bool allocate, bool warp) c
{
// Is the specified vehicle even valid?
if (!vehicle.IsActive())
{
SqThrowF("Invalid vehicle argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -1135,7 +1145,9 @@ CSStr CPlayer::GetMessagePrefix(Uint32 index) const
{
// Perform a range check on the specified prefix index
if (index >= SQMOD_PLAYER_MSG_PREFIXES)
{
SqThrowF("Prefix index is out of range: %u >= %d", index, SQMOD_PLAYER_MSG_PREFIXES);
}
// Validate the managed identifier
Validate();
// Return the requested information
@ -1147,7 +1159,9 @@ void CPlayer::SetMessagePrefix(Uint32 index, CSStr prefix) const
{
// Perform a range check on the specified prefix index
if (index >= SQMOD_PLAYER_MSG_PREFIXES)
{
SqThrowF("Prefix index is out of range: %u >= %d", index, SQMOD_PLAYER_MSG_PREFIXES);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -1268,10 +1282,14 @@ SQInteger CPlayer::Msg(HSQUIRRELVM vm)
const Int32 top = sq_gettop(vm);
// Was the message color specified?
if (top <= 1)
{
return sq_throwerror(vm, "Missing message color");
}
// Was the message value specified?
else if (top <= 2)
{
return sq_throwerror(vm, "Missing message value");
}
// The player instance
CPlayer * player = nullptr;
// The message color
@ -1289,10 +1307,14 @@ SQInteger CPlayer::Msg(HSQUIRRELVM vm)
}
// Do we have a valid player instance?
if (!player)
{
return sq_throwerror(vm, "Invalid player instance");
}
// Do we have a valid player identifier?
else if (!player->IsActive())
{
return sq_throwerror(vm, "Invalid player reference");
}
// Do we have enough values to call the format function?
else if (top > 3)
{
@ -1302,7 +1324,9 @@ SQInteger CPlayer::Msg(HSQUIRRELVM vm)
SQRESULT ret = sqstd_format(vm, 3, &len, &msg);
// Did the format failed?
if (SQ_FAILED(ret))
{
return ret; // Propagate the exception
}
// Send the resulted message string
_Func->SendClientMessage(player->GetID(), color.GetRGBA(), "%s", msg);
}
@ -1312,7 +1336,9 @@ SQInteger CPlayer::Msg(HSQUIRRELVM vm)
Var< CSStr > msg(vm, 3);
// See if the obtained value is a valid message
if (!msg.value)
{
return sq_throwerror(vm, "Unable to retrieve the message");
}
// Send the resulted message string
_Func->SendClientMessage(player->GetID(), color.GetRGBA(), "%s", msg.value);
}
@ -1326,10 +1352,14 @@ SQInteger CPlayer::MsgP(HSQUIRRELVM vm)
const Int32 top = sq_gettop(vm);
// Was the index of the message prefix specified?
if (top <= 1)
{
return sq_throwerror(vm, "Missing prefix index");
}
// Was the message value specified?
else if (top <= 2)
{
return sq_throwerror(vm, "Missing message value");
}
// The player instance
CPlayer * player = nullptr;
// The prefix index
@ -1347,14 +1377,20 @@ SQInteger CPlayer::MsgP(HSQUIRRELVM vm)
}
// Do we have a valid player instance?
if (!player)
{
return sq_throwerror(vm, "Invalid player instance");
}
// Do we have a valid player identifier?
else if (!player->IsActive())
{
return sq_throwerror(vm, "Invalid player reference");
}
// Perform a range check on the specified prefix index
else if (index > SQMOD_PLAYER_MSG_PREFIXES)
{
return sq_throwerror(vm, ToStrF("Prefix index is out of range: %u > %u",
index, SQMOD_PLAYER_MSG_PREFIXES));
}
// Do we have enough values to call the format function?
else if (top > 3)
{
@ -1364,7 +1400,9 @@ SQInteger CPlayer::MsgP(HSQUIRRELVM vm)
SQRESULT ret = sqstd_format(vm, 3, &len, &msg);
// Did the format failed?
if (SQ_FAILED(ret))
{
return ret; // Propagate the exception
}
// Retrieve the associated player structure
const auto & splayer = _Core->GetPlayer(player->GetID());
// Send the resulted message string
@ -1377,7 +1415,9 @@ SQInteger CPlayer::MsgP(HSQUIRRELVM vm)
Var< CSStr > msg(vm, 3);
// See if the obtained value is a valid message
if (!msg.value)
{
return sq_throwerror(vm, "Unable to retrieve the message");
}
// Retrieve the associated player structure
const auto & splayer = _Core->GetPlayer(player->GetID());
// Send the resulted message string
@ -1394,10 +1434,14 @@ SQInteger CPlayer::MsgEx(HSQUIRRELVM vm)
const Int32 top = sq_gettop(vm);
// Was the message color specified?
if (top <= 3)
{
return sq_throwerror(vm, "Missing message color");
}
// Was the message value specified?
else if (top <= 4)
{
return sq_throwerror(vm, "Missing message value");
}
// The player instance
CPlayer * player = nullptr;
// The message color
@ -1417,10 +1461,14 @@ SQInteger CPlayer::MsgEx(HSQUIRRELVM vm)
}
// Do we have a valid player instance?
if (!player)
{
return sq_throwerror(vm, "Invalid player instance");
}
// Do we have a valid player identifier?
else if (!player->IsActive())
{
return sq_throwerror(vm, "Invalid player reference");
}
// Do we have enough values to call the format function?
else if (top > 5)
{
@ -1430,7 +1478,9 @@ SQInteger CPlayer::MsgEx(HSQUIRRELVM vm)
SQRESULT ret = sqstd_format(vm, 5, &len, &msg);
// Did the format failed?
if (SQ_FAILED(ret))
{
return ret; // Propagate the exception
}
// Send the resulted message string
_Func->SendClientMessage(player->GetID(), SQMOD_PACK_RGBA(r, g, b, 0), "%s", msg);
}
@ -1440,7 +1490,9 @@ SQInteger CPlayer::MsgEx(HSQUIRRELVM vm)
Var< CSStr > msg(vm, 5);
// See if the obtained value is a valid message
if (!msg.value)
{
return sq_throwerror(vm, "Unable to retrieve the message");
}
// Send the resulted message string
_Func->SendClientMessage(player->GetID(), SQMOD_PACK_RGBA(r, g, b, 0), "%s", msg.value);
}
@ -1454,7 +1506,9 @@ SQInteger CPlayer::Message(HSQUIRRELVM vm)
const Int32 top = sq_gettop(vm);
// Was the message value specified?
if (top <= 1)
{
return sq_throwerror(vm, "Missing message value");
}
// The player instance
CPlayer * player = nullptr;
// Attempt to extract the argument values
@ -1469,10 +1523,14 @@ SQInteger CPlayer::Message(HSQUIRRELVM vm)
}
// Do we have a valid player instance?
if (!player)
{
return sq_throwerror(vm, "Invalid player instance");
}
// Do we have a valid player identifier?
else if (!player->IsActive())
{
return sq_throwerror(vm, "Invalid player reference");
}
// Do we have enough values to call the format function?
else if (top > 2)
{
@ -1482,7 +1540,9 @@ SQInteger CPlayer::Message(HSQUIRRELVM vm)
SQRESULT ret = sqstd_format(vm, 2, &len, &msg);
// Did the format failed?
if (SQ_FAILED(ret))
{
return ret; // Propagate the exception
}
// Send the resulted message string
_Func->SendClientMessage(player->GetID(),
_Core->GetPlayer(player->GetID()).mMessageColor, "%s", msg);
@ -1493,7 +1553,9 @@ SQInteger CPlayer::Message(HSQUIRRELVM vm)
Var< CSStr > msg(vm, 2);
// See if the obtained value is a valid message
if (!msg.value)
{
return sq_throwerror(vm, "Unable to retrieve the message");
}
// Send the resulted message string
_Func->SendClientMessage(player->GetID(),
_Core->GetPlayer(player->GetID()).mMessageColor, "%s", msg.value);
@ -1508,7 +1570,9 @@ SQInteger CPlayer::Announce(HSQUIRRELVM vm)
const Int32 top = sq_gettop(vm);
// Was the announcement value specified?
if (top <= 1)
{
return sq_throwerror(vm, "Missing announcement value");
}
// The player instance
CPlayer * player = nullptr;
// Attempt to extract the argument values
@ -1523,10 +1587,14 @@ SQInteger CPlayer::Announce(HSQUIRRELVM vm)
}
// Do we have a valid player instance?
if (!player)
{
return sq_throwerror(vm, "Invalid player instance");
}
// Do we have a valid player identifier?
else if (!player->IsActive())
{
return sq_throwerror(vm, "Invalid player reference");
}
// Do we have enough values to call the format function?
else if (top > 2)
{
@ -1536,7 +1604,9 @@ SQInteger CPlayer::Announce(HSQUIRRELVM vm)
SQRESULT ret = sqstd_format(vm, 2, &len, &msg);
// Did the format failed?
if (SQ_FAILED(ret))
{
return ret; // Propagate the exception
}
// Send the resulted announcement string
_Func->SendGameMessage(player->GetID(),
_Core->GetPlayer(player->GetID()).mAnnounceStyle, "%s", msg);
@ -1547,7 +1617,9 @@ SQInteger CPlayer::Announce(HSQUIRRELVM vm)
Var< CSStr > msg(vm, 2);
// See if the obtained value is a valid announcement
if (!msg.value)
{
return sq_throwerror(vm, "Unable to retrieve the announcement");
}
// Send the resulted announcement string
_Func->SendGameMessage(player->GetID(),
_Core->GetPlayer(player->GetID()).mAnnounceStyle, "%s", msg.value);
@ -1562,10 +1634,14 @@ SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm)
const Int32 top = sq_gettop(vm);
// Was the announcement style specified?
if (top <= 1)
{
return sq_throwerror(vm, "Missing announcement style");
}
// Was the announcement value specified?
else if (top <= 2)
{
return sq_throwerror(vm, "Missing announcement value");
}
// The player instance
CPlayer * player = nullptr;
// The announcement style
@ -1583,10 +1659,14 @@ SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm)
}
// Do we have a valid player instance?
if (!player)
{
return sq_throwerror(vm, "Invalid player instance");
}
// Do we have a valid player identifier?
else if (!player->IsActive())
{
return sq_throwerror(vm, "Invalid player reference");
}
// Do we have enough values to call the format function?
else if (top > 3)
{
@ -1596,7 +1676,9 @@ SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm)
SQRESULT ret = sqstd_format(vm, 3, &len, &msg);
// Did the format failed?
if (SQ_FAILED(ret))
{
return ret; // Propagate the exception
}
// Send the resulted announcement string
_Func->SendGameMessage(player->GetID(), style, "%s", msg);
}
@ -1606,7 +1688,9 @@ SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm)
Var< CSStr > msg(vm, 3);
// See if the obtained value is a valid announcement
if (!msg.value)
{
return sq_throwerror(vm, "Unable to retrieve the announcement");
}
// Send the resulted announcement string
_Func->SendGameMessage(player->GetID(), style, "%s", msg.value);
}
@ -1619,7 +1703,9 @@ static const Object & Player_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
{
SqThrowF("The specified player identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Players::const_iterator itr = _Core->GetPlayers().cbegin();
Core::Players::const_iterator end = _Core->GetPlayers().cend();
@ -1628,7 +1714,9 @@ static const Object & Player_FindByID(Int32 id)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a player matching the specified identifier
return NullObject();
@ -1637,8 +1725,10 @@ static const Object & Player_FindByID(Int32 id)
static const Object & Player_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
if (!tag || *tag == '\0')
{
SqThrowF("The specified player tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Players::const_iterator itr = _Core->GetPlayers().cbegin();
Core::Players::const_iterator end = _Core->GetPlayers().cend();
@ -1647,7 +1737,9 @@ static const Object & Player_FindByTag(CSStr tag)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a player matching the specified tag
return NullObject();

View File

@ -82,7 +82,9 @@ public:
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid player reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------

View File

@ -97,10 +97,14 @@ void CSprite::BindEvent(Int32 evid, Object & env, Function & func) const
Function & event = _Core->GetSpriteEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
@ -117,7 +121,9 @@ void CSprite::ShowFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -130,7 +136,9 @@ void CSprite::ShowRange(Int32 first, Int32 last) const
{
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -138,8 +146,10 @@ void CSprite::ShowRange(Int32 first, Int32 last) const
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then show this textdraw on his client
_Func->ShowSprite(m_ID, first);
}
}
}
@ -157,7 +167,9 @@ void CSprite::HideFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -169,7 +181,9 @@ void CSprite::HideRange(Int32 first, Int32 last) const
{
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -177,8 +191,10 @@ void CSprite::HideRange(Int32 first, Int32 last) const
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then hide this textdraw on his client
_Func->HideSprite(m_ID, first);
}
}
}
@ -205,7 +221,9 @@ void CSprite::SetPositionFor(CPlayer & player, const Vector2i & pos) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -217,7 +235,9 @@ void CSprite::SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -229,7 +249,9 @@ void CSprite::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) co
{
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -237,8 +259,10 @@ void CSprite::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) co
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then move this textdraw on his client
_Func->MoveSprite(m_ID, first, pos.x, pos.y);
}
}
}
@ -265,7 +289,9 @@ void CSprite::SetCenterFor(CPlayer & player, const Vector2i & pos) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -277,7 +303,9 @@ void CSprite::SetCenterForEx(CPlayer & player, Int32 x, Int32 y) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -289,7 +317,9 @@ void CSprite::SetCenterRange(Int32 first, Int32 last, const Vector2i & pos) cons
{
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -297,8 +327,10 @@ void CSprite::SetCenterRange(Int32 first, Int32 last, const Vector2i & pos) cons
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then center this textdraw on his client
_Func->SetSpriteCenter(m_ID, first, pos.x, pos.y);
}
}
}
@ -316,7 +348,9 @@ void CSprite::SetRotationFor(CPlayer & player, Float32 rot) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -328,7 +362,9 @@ void CSprite::SetRotationRange(Int32 first, Int32 last, Float32 rot) const
{
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -336,8 +372,10 @@ void CSprite::SetRotationRange(Int32 first, Int32 last, Float32 rot) const
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then rotate this textdraw on his client
_Func->RotateSprite(m_ID, first, rot);
}
}
}
@ -355,7 +393,9 @@ void CSprite::SetAlphaFor(CPlayer & player, Uint8 alpha) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -367,7 +407,9 @@ void CSprite::SetAlphaRange(Int32 first, Int32 last, Uint8 alpha) const
{
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -375,8 +417,10 @@ void CSprite::SetAlphaRange(Int32 first, Int32 last, Uint8 alpha) const
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then colorize this textdraw on his client
_Func->SetSpriteAlpha(m_ID, first, alpha);
}
}
}
@ -454,7 +498,9 @@ static const Object & Sprite_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_SPRITE_POOL))
{
SqThrowF("The specified sprite identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Sprites::const_iterator itr = _Core->GetSprites().cbegin();
Core::Sprites::const_iterator end = _Core->GetSprites().cend();
@ -463,7 +509,9 @@ static const Object & Sprite_FindByID(Int32 id)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a sprite matching the specified identifier
return NullObject();
@ -472,8 +520,10 @@ static const Object & Sprite_FindByID(Int32 id)
static const Object & Sprite_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
if (!tag || *tag == '\0')
{
SqThrowF("The specified sprite tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Sprites::const_iterator itr = _Core->GetSprites().cbegin();
Core::Sprites::const_iterator end = _Core->GetSprites().cend();
@ -482,7 +532,9 @@ static const Object & Sprite_FindByTag(CSStr tag)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a sprite matching the specified tag
return NullObject();

View File

@ -75,7 +75,9 @@ public:
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid sprite reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------

View File

@ -97,10 +97,14 @@ void CTextdraw::BindEvent(Int32 evid, Object & env, Function & func) const
Function & event = _Core->GetTextdrawEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
@ -117,7 +121,9 @@ void CTextdraw::ShowFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -129,7 +135,9 @@ void CTextdraw::ShowRange(Int32 first, Int32 last) const
{
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -137,8 +145,10 @@ void CTextdraw::ShowRange(Int32 first, Int32 last) const
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then show this textdraw on his client
_Func->ShowTextdraw(m_ID, first);
}
}
}
@ -156,11 +166,13 @@ void CTextdraw::HideFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->HideTextdraw(m_ID, player.GetID());
_Func->HideTextdraw(m_ID, player.GetID());
}
// ------------------------------------------------------------------------------------------------
@ -168,7 +180,9 @@ void CTextdraw::HideRange(Int32 first, Int32 last) const
{
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -176,8 +190,10 @@ void CTextdraw::HideRange(Int32 first, Int32 last) const
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then hide this textdraw on his client
_Func->HideTextdraw(m_ID, first);
}
}
}
@ -204,7 +220,9 @@ void CTextdraw::SetPositionFor(CPlayer & player, const Vector2i & pos) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -216,7 +234,9 @@ void CTextdraw::SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -228,7 +248,9 @@ void CTextdraw::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos)
{
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -236,8 +258,10 @@ void CTextdraw::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos)
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then move this textdraw on his client
_Func->MoveTextdraw(m_ID, first, pos.x, pos.y);
}
}
}
@ -264,7 +288,9 @@ void CTextdraw::SetColorFor(CPlayer & player, const Color4 & col) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -276,7 +302,9 @@ void CTextdraw::SetColorForEx(CPlayer & player, Uint8 r, Uint8 g, Uint8 b, Uint8
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -288,7 +316,9 @@ void CTextdraw::SetColorRange(Int32 first, Int32 last, const Color4 & col) const
{
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -296,8 +326,10 @@ void CTextdraw::SetColorRange(Int32 first, Int32 last, const Color4 & col) const
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then colorize this textdraw on his client
_Func->SetTextdrawColour(m_ID, first, color);
}
}
}
@ -379,7 +411,9 @@ static const Object & Textdraw_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_TEXTDRAW_POOL))
{
SqThrowF("The specified textdraw identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
Core::Textdraws::const_iterator end = _Core->GetTextdraws().cend();
@ -388,7 +422,9 @@ static const Object & Textdraw_FindByID(Int32 id)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a textdraw matching the specified identifier
return NullObject();
@ -397,8 +433,10 @@ static const Object & Textdraw_FindByID(Int32 id)
static const Object & Textdraw_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
if (!tag || *tag == '\0')
{
SqThrowF("The specified textdraw tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
Core::Textdraws::const_iterator end = _Core->GetTextdraws().cend();
@ -407,7 +445,9 @@ static const Object & Textdraw_FindByTag(CSStr tag)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a textdraw matching the specified tag
return NullObject();

View File

@ -75,7 +75,9 @@ public:
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid textdraw reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------

View File

@ -103,10 +103,14 @@ void CVehicle::BindEvent(Int32 evid, Object & env, Function & func) const
Function & event = _Core->GetVehicleEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
@ -114,7 +118,9 @@ bool CVehicle::IsStreamedFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Return the requested information
@ -929,7 +935,9 @@ void CVehicle::Embark(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -941,7 +949,9 @@ void CVehicle::Embark(CPlayer & player, Int32 slot, bool allocate, bool warp) co
{
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
@ -1224,7 +1234,9 @@ static const Object & Vehicle_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
{
SqThrowF("The specified vehicle identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Vehicles::const_iterator itr = _Core->GetVehicles().cbegin();
Core::Vehicles::const_iterator end = _Core->GetVehicles().cend();
@ -1233,7 +1245,9 @@ static const Object & Vehicle_FindByID(Int32 id)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a vehicle matching the specified identifier
return NullObject();
@ -1242,8 +1256,10 @@ static const Object & Vehicle_FindByID(Int32 id)
static const Object & Vehicle_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
if (!tag || *tag == '\0')
{
SqThrowF("The specified vehicle tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Vehicles::const_iterator itr = _Core->GetVehicles().cbegin();
Core::Vehicles::const_iterator end = _Core->GetVehicles().cend();
@ -1252,7 +1268,9 @@ static const Object & Vehicle_FindByTag(CSStr tag)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a vehicle matching the specified tag
return NullObject();

View File

@ -80,7 +80,9 @@ public:
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid vehicle reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------

View File

@ -22,36 +22,82 @@ static Object & GetVehicle(Int32 id) { return _Core->GetVehicle(id).mObj; }
// ------------------------------------------------------------------------------------------------
static bool DelBlip(Int32 id, Int32 header, Object & payload)
{ return _Core->DelBlip(id, header, payload); }
{
return _Core->DelBlip(id, header, payload);
}
static bool DelCheckpoint(Int32 id, Int32 header, Object & payload)
{ return _Core->DelCheckpoint(id, header, payload); }
{
return _Core->DelCheckpoint(id, header, payload);
}
static bool DelForcefield(Int32 id, Int32 header, Object & payload)
{ return _Core->DelForcefield(id, header, payload); }
{
return _Core->DelForcefield(id, header, payload);
}
static bool DelKeybind(Int32 id, Int32 header, Object & payload)
{ return _Core->DelKeybind(id, header, payload); }
{
return _Core->DelKeybind(id, header, payload);
}
static bool DelObject(Int32 id, Int32 header, Object & payload)
{ return _Core->DelObject(id, header, payload); }
{
return _Core->DelObject(id, header, payload);
}
static bool DelPickup(Int32 id, Int32 header, Object & payload)
{ return _Core->DelPickup(id, header, payload); }
{
return _Core->DelPickup(id, header, payload);
}
static bool DelSprite(Int32 id, Int32 header, Object & payload)
{ return _Core->DelSprite(id, header, payload); }
{
return _Core->DelSprite(id, header, payload);
}
static bool DelTextdraw(Int32 id, Int32 header, Object & payload)
{ return _Core->DelTextdraw(id, header, payload); }
{
return _Core->DelTextdraw(id, header, payload);
}
static bool DelVehicle(Int32 id, Int32 header, Object & payload)
{ return _Core->DelVehicle(id, header, payload); }
{
return _Core->DelVehicle(id, header, payload);
}
// ------------------------------------------------------------------------------------------------
static bool BindEvent(Int32 id, Object & env, Function & func)
{ return _Core->BindEvent(id, env, func); }
{
return _Core->BindEvent(id, env, func);
}
// ------------------------------------------------------------------------------------------------
static Int32 GetState() { return _Core->GetState(); }
static void SetState(Int32 value) { return _Core->SetState(value); }
static Int32 GetState()
{
return _Core->GetState();
}
static void SetState(Int32 value)
{
return _Core->SetState(value);
}
// ------------------------------------------------------------------------------------------------
static CSStr GetOption(CSStr name) { return _Core->GetOption(name); }
static CSStr GetOptionOr(CSStr name, CSStr value) { return _Core->GetOption(name, value); }
static void SetOption(CSStr name, CSStr value) { return _Core->SetOption(name, value); }
static CSStr GetOption(CSStr name)
{
return _Core->GetOption(name);
}
static CSStr GetOptionOr(CSStr name, CSStr value)
{
return _Core->GetOption(name, value);
}
static void SetOption(CSStr name, CSStr value)
{
return _Core->SetOption(name, value);
}
// ================================================================================================
void Register_Core(HSQUIRRELVM vm)
@ -92,7 +138,9 @@ template < Uint8 L, bool S > static SQInteger LogBasicMessage(HSQUIRRELVM vm)
const Int32 top = sq_gettop(vm);
// Was the message value specified?
if (top <= 1)
{
return sq_throwerror(vm, "Missing message value");
}
// Do we have enough values to call the format function?
else if (top > 2)
{
@ -102,7 +150,9 @@ template < Uint8 L, bool S > static SQInteger LogBasicMessage(HSQUIRRELVM vm)
SQRESULT ret = sqstd_format(vm, 2, &len, &msg);
// Did the format failed?
if (SQ_FAILED(ret))
{
return ret; // Propagate the exception
}
// Log the resulted string value
_Log->Message(L, S, "%s", msg);
}
@ -112,7 +162,9 @@ template < Uint8 L, bool S > static SQInteger LogBasicMessage(HSQUIRRELVM vm)
Var< CSStr > msg(vm, 2);
// See if the obtained value is a valid string
if (!msg.value)
{
return sq_throwerror(vm, "Unable to retrieve the value");
}
// Log the resulted string value
_Log->Message(L, S, "%s", msg.value);
}