Fix regression in DescribePlayer (%N / %L) for players not yet having entities (#2260)

* Define a constant for ENTREF_MASK

* Fix regression in DescribePlayer for players that don't yet have entities
This commit is contained in:
Nicholas Hastings
2025-02-13 23:04:38 +00:00
committed by GitHub
parent 25faf18760
commit 6cd5bf87d8
3 changed files with 17 additions and 8 deletions
+8 -1
View File
@@ -576,7 +576,14 @@ int CoreProviderImpl::MaxClients()
bool CoreProviderImpl::DescribePlayer(int entRef, const char **namep, const char **authp, int *useridp)
{
int index = g_HL2.ReferenceToIndex(entRef);
int index = entRef;
if (entRef & ENTREF_MASK)
{
// Unless this is an explicit entity reference, we don't know nor care if the player has an entity yet,
// as long as they are currently connected. (But if it *is* an explicit ref, validate it)
index = g_HL2.ReferenceToIndex(entRef);
}
CPlayer *player = g_Players.GetPlayerByIndex(index);
if (!player || !player->IsConnected())
return false;