Replace terniary null checks with coalescing.

This commit is contained in:
Paul Chote
2021-03-07 21:22:00 +00:00
committed by teinarss
parent 2473b8763b
commit d52ba83f96
43 changed files with 72 additions and 73 deletions

View File

@@ -116,9 +116,9 @@ namespace OpenRA.Mods.Common.Traits
var myTeam = self.World.LobbyInfo.ClientWithIndex(self.Owner.ClientIndex).Team;
var teams = self.World.Players.Where(p => !p.NonCombatant && p.Playable)
.Select(p => (Player: p, PlayerStatistics: p.PlayerActor.TraitOrDefault<PlayerStatistics>()))
.OrderByDescending(p => p.PlayerStatistics != null ? p.PlayerStatistics.Experience : 0)
.OrderByDescending(p => p.PlayerStatistics?.Experience ?? 0)
.GroupBy(p => (self.World.LobbyInfo.ClientWithIndex(p.Player.ClientIndex) ?? new Session.Client()).Team)
.OrderByDescending(g => g.Sum(gg => gg.PlayerStatistics != null ? gg.PlayerStatistics.Experience : 0));
.OrderByDescending(g => g.Sum(gg => gg.PlayerStatistics?.Experience ?? 0));
if (teams.First().Key == myTeam && (myTeam != 0 || teams.First().First().Player == self.Owner))
{