Replace direct uses of GameTicker dictionary with TryGetValue
#33222
+2
−2
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.
About the PR
Why / Balance
Apparently if a player's
SessionStatus
stays onConnected
for whatever reason, station events and antag selection might break in some way. The issue is some functions try to get a value fromPlayerGameStatuses
dictionary without checking if the player exists or not. For example:The thing is that
_playerManager.Sessions
contains any sessions (including theConnected
ones) whilePlayerGameStatuses
does not, meaning that if there's a player stuck (intentionally or not) onConnected
, that specific line would throw an errorThe key 'blahblah' was not present in the dictionary
.And this possibly can lead to station events spam.
Not sure exactly this is the issue of events spam, but I've been reported about this and when looking at the logs the only errors I could find is
The key 'blahblahblah' was not present in the dictionary
and the stacktrace leading toUserHasJoinedGame(NetUserId userId)
which is basically this:Technical details
Replaced all*
PlayerGameStatuses[user] == Something
withPlayerGameStatuses.TryGetValue(user, out var status) && status == Something
* — except its usages in integration tests because I believe there is no chance to get the error in the tests (lmk if I'm wrong thinking that way)
Media
N/A
Requirements
Breaking changes
N/A
Changelog
N/A