mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-19 03:57:14 +01:00
More validations on identifiers obtained from the server.
Prevent out_of_range exceptions leak into the script as it would end up in a crash since Sqrat doesn't know how to handle them.
This commit is contained in:
parent
ef41d0d243
commit
bca0e1f3c6
@ -1140,8 +1140,16 @@ Object & CPlayer::GetSpectator() const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Return the requested information
|
||||
return Core::Get().GetPlayer(_Func->GetPlayerSpectateTarget(m_ID)).mObj;
|
||||
// Retrieve the identifier of the player
|
||||
const Int32 id = _Func->GetPlayerSpectateTarget(m_ID);
|
||||
// Validated the obtained identifier
|
||||
if (_Func->GetLastError() != vcmpErrorNoSuchEntity && VALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
|
||||
{
|
||||
// Return the requested information
|
||||
return Core::Get().GetPlayer(id).mObj;
|
||||
}
|
||||
// Default to a null object
|
||||
return NullObject();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user