1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-07-06 08:57:11 +02: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

@ -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();