1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-19 16:47:14 +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

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