From 9862992af0b415b3bfb4685196d35347ddd9397b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 25 Jun 2023 17:36:44 +0200 Subject: [PATCH] Use alternative guard Early-returning from ctors feels pretty bad. Also saves on some nested accesses. --- .../Components/TournamentMatchChatDisplay.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tournament/Components/TournamentMatchChatDisplay.cs b/osu.Game.Tournament/Components/TournamentMatchChatDisplay.cs index bb8d86e7e2..15c37474f5 100644 --- a/osu.Game.Tournament/Components/TournamentMatchChatDisplay.cs +++ b/osu.Game.Tournament/Components/TournamentMatchChatDisplay.cs @@ -90,12 +90,13 @@ namespace osu.Game.Tournament.Components public MatchMessage(Message message, LadderInfo info) : base(message) { - if (info.CurrentMatch.Value == null) return; - - if (info.CurrentMatch.Value.Team1.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID)) - UsernameColour = TournamentGame.COLOUR_RED; - else if (info.CurrentMatch.Value.Team2.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID)) - UsernameColour = TournamentGame.COLOUR_BLUE; + if (info.CurrentMatch.Value is TournamentMatch match) + { + if (match.Team1.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID)) + UsernameColour = TournamentGame.COLOUR_RED; + else if (match.Team2.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID)) + UsernameColour = TournamentGame.COLOUR_BLUE; + } } } }