workaround for userid
in player_connect
#537
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since the last update, I've been encountering many demos in which after a player has disconnected, and then reconnected, they wouldn't be registered in the
rawPlayers
field. Thus, in many cases, there werenil
players in some events (e. g. all grenade events).I investigated this a little and found out that seemingly the only place we could get information to add the player back to the
rawPlayers
(at least in particular demos I've been using) is inside theplayer_connect
handler, which was disabled for s2 demos in #499. I'm assuming this was done because the user ids for players have been changed in the February, 6 update from being in the lower digits to 652xx.I'm not sure what exactly has been changed in the last update (my guess is the
userinfo
string table is not parsed as often or not at all in some situations anymore?), but I've implemented a workaround that allows us to use theplayer_connect
again by noticing that the old used ids are still present in the new ones -- they are the least significant byte of the two, and the other one is just set to 255.Here's an example demo. On tick number 48430
kefu_.
disconnects, then at tick 50731 we get aplayer_connect
event, and then at tick 51237, when them_iConnected
is updated,PlayerConnect
is dispatched (but, notably, we don't know the new user id at this point so therawPlayers
field doesn't get updated). This leads toThrower
beingnil
in the dispatchedHeExplode
event on tick 53754, which breaks at least my application 馃槃This PR is more of an attempt to get some attention to the problem. There probably is a proper way to handle the situation without resorting to this hacky method, which might or might not work in the future. But I've already tested this implementation (and by "tested" I mean I've been using it in the production since yesterday) and was able to lower the error count in the parsed matches tenfold, so maybe that would help someone else in a similar situation.