[Bug]: "Regression" in `ReferenceToIndex` after #1323
Prerequisites
- [x] I have checked that my issue doesn't exist yet in the issue tracker
Operating System and Version
WSL Ubuntu 22.04
Game / AppID and Version
L4D2 (550) version 2.2.4.3
SourceMod Version
1.13.0.7199
Metamod:Source Version
No response
Version Verification
- [ ] I have updated SourceMod to the latest version and the issue persists
- [ ] I have updated SourceMod to the latest snapshot and the issue persists
- [ ] I have updated Metamod:Source to the latest snapshot and the issue persists
Updated SourceMod Version
No response
Updated Metamod:Source Version
No response
Description
Similar to #2260.
Some functions rely on ReferenceToIndex to retrieve client indices, and thus an error per a client during connection.
Steps to Reproduce
#include <sourcemod>
public void OnClientConnected(int client)
{
int ref = EntRefToEntIndex(client);
PrintToServer("OnClientConnected %d -> %X", client, ref);
}
Relevant Log Output
OnClientConnected 1 -> FFFFFFFF
Use this on entity "index" https://sm.alliedmods.net/new-api/halflife/EntIndexToEntRef
However, if you are handling client "indexes", please use these instead https://sm.alliedmods.net/new-api/clients/GetClientUserId https://sm.alliedmods.net/new-api/clients/GetClientOfUserId
Use this on entity "index" https://sm.alliedmods.net/new-api/halflife/EntIndexToEntRef
However, if you are handling client "indexes", please use these instead https://sm.alliedmods.net/new-api/clients/GetClientUserId https://sm.alliedmods.net/new-api/clients/GetClientOfUserId
Thanks, but I was referring to some uses like: https://github.com/alliedmodders/sourcemod/blob/87653bf780996e1e41a259c78c339c7f23028e69/core/logic/smn_banning.cpp#L249-L261 Calling this on a connecting client should throw an error.
I'm torn on this. It shouldn't work. Client aren't attached to an entity that early, and thus also can't possibly have a valid entity reference that points to them. However, I think it probably does make more sense for us to just re-relax this check rather than trying to hunt down each usage of it to adjust accordingly since plugins also rely on this.