Skip to content

Commit e1f190a

Browse files
authored
fix: improve null safety in ReadySystem, MatchManager, and MatchUtility (#135)
Co-authored-by: Flegma <Flegma@users.noreply.github.com>
1 parent 362b3e4 commit e1f190a

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/FiveStack.Services/MatchManager.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,15 @@ public void Init(MatchData match)
8383

8484
public MatchMap? GetCurrentMap()
8585
{
86-
if (_matchData == null || _matchData.current_match_map_id == null)
86+
var matchData = _matchData;
87+
if (matchData == null || matchData.current_match_map_id == null)
8788
{
8889
return null;
8990
}
9091

91-
return _matchData?.match_maps.FirstOrDefault(match_map =>
92+
return matchData.match_maps.FirstOrDefault(match_map =>
9293
{
93-
return match_map.id == _matchData.current_match_map_id;
94+
return match_map.id == matchData.current_match_map_id;
9495
});
9596
}
9697

src/FiveStack.Services/ReadySystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public void SendReadyMessage(CCSPlayerController player)
233233
return;
234234
}
235235

236-
bool isReady = _readyPlayers[player.UserId.Value];
236+
_readyPlayers.TryGetValue(player.UserId.Value, out bool isReady);
237237

238238
string readyWord = isReady ? _localizer["ready.ready"] : _localizer["ready.not_ready"];
239239
string colored = isReady

src/FiveStack.Utilities/MatchUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ string playerName
5757
? matchData.lineup_1.tag
5858
: matchData.lineup_2.tag;
5959

60-
if (tag == null || tag == "")
60+
if (string.IsNullOrEmpty(tag))
6161
{
6262
return null;
6363
}

0 commit comments

Comments
 (0)