Skip to content

Commit

Permalink
Don't Assume Sessions Are Real (#1655)
Browse files Browse the repository at this point in the history
# Description

This system was just blindly assuming a session couldn't be null without
proving it wasn't, and two different functions both incorrectly made
this assumption. I have no idea how the hell they managed to sneak it
past the compiler's null reference test.
  • Loading branch information
VMSolidus authored Jan 25, 2025
1 parent 9353794 commit 53aaba2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Content.Server/Administration/Systems/AdminSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,11 @@ private void OnRoundRestartCleanup(RoundRestartCleanupEvent ev)

foreach (var (id, data) in _playerList)
{
if (!data.ActiveThisRound)
if (!data.ActiveThisRound
|| !_playerManager.TryGetPlayerData(id, out var playerData)
|| !_playerManager.TryGetSessionById(id, out var session))
continue;

if (!_playerManager.TryGetPlayerData(id, out var playerData))
return;

_playerManager.TryGetSessionById(id, out var session);
_playerList[id] = GetPlayerInfo(playerData, session);
}

Expand Down Expand Up @@ -218,7 +216,7 @@ private void SendFullPlayerList(ICommonSession playerSession)
RaiseNetworkEvent(ev, playerSession.Channel);
}

private PlayerInfo GetPlayerInfo(SessionData data, ICommonSession? session)
private PlayerInfo GetPlayerInfo(SessionData data, ICommonSession session)
{
var name = data.UserName;
var entityName = string.Empty;
Expand Down

0 comments on commit 53aaba2

Please sign in to comment.