1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-21 20:27:13 +01:00

Make the occupant retrieval more error proof.

This commit is contained in:
Sandu Liviu Catalin 2017-05-25 22:15:32 +03:00
parent 40c16ca5fc
commit 59f64e9532

View File

@ -258,8 +258,28 @@ LightObj & CVehicle::GetOccupant(Int32 slot) const
{
// Validate the managed identifier
Validate();
// Attempt to retrieve the requested information
const int id = _Func->GetVehicleOccupant(m_ID, slot);
// Was there an issue with the given value?
if (INVALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
{
const vcmpError err = _Func->GetLastError();
// Identify the type of error
if (err == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Out of range slot [%d]", slot);
}
else if (err == vcmpErrorNoSuchEntity)
{
STHROWF("Unoccupied slot [%d]", id);
}
else
{
STHROWF("Error while getting occupant at [%d] for [%s]", slot, m_Tag.c_str());
}
}
// Return the requested information
return Core::Get().GetPlayer(_Func->GetVehicleOccupant(m_ID, slot)).mObj;
return Core::Get().GetPlayer(id).mObj;
}
// ------------------------------------------------------------------------------------------------