From 83c4e5ba232b641e6c2d641e3c0e70b16a483b2b Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Fri, 27 Jul 2018 19:50:18 +0300 Subject: [PATCH] Return a null entity instance instead of throwing an error. --- source/Entity/Vehicle.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/Entity/Vehicle.cpp b/source/Entity/Vehicle.cpp index e62e7ae1..6dfb876a 100644 --- a/source/Entity/Vehicle.cpp +++ b/source/Entity/Vehicle.cpp @@ -260,19 +260,21 @@ LightObj & CVehicle::GetOccupant(Int32 slot) const if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL)) { const vcmpError err = _Func->GetLastError(); - // Identify the type of error + // Identify the type of error and at least log it if (err == vcmpErrorArgumentOutOfBounds) { - STHROWF("Out of range slot [%d]", slot); + LogWrn("Out of range slot [%d]", slot); } else if (err == vcmpErrorNoSuchEntity) { - STHROWF("Unoccupied slot [%d]", id); + LogWrn("Unoccupied slot [%d]", id); } else { - STHROWF("Error while getting occupant at [%d] for [%s]", slot, m_Tag.c_str()); + LogWrn("Error while getting occupant at [%d] for [%s]", slot, m_Tag.c_str()); } + // Default to a null instance + return Core::Get().GetNullVehicle().GetObject(); } // Return the requested information return Core::Get().GetPlayer(id).mObj;