Code cleanup.

This commit is contained in:
Matthias Mailänder
2022-02-12 17:50:49 +01:00
committed by teinarss
parent 7735107deb
commit ee95d2591f
5 changed files with 6 additions and 7 deletions

View File

@@ -73,7 +73,7 @@ namespace OpenRA
public bool SuppressVisualFeedback; public bool SuppressVisualFeedback;
public ref readonly Target VisualFeedbackTarget => ref visualFeedbackTarget; public ref readonly Target VisualFeedbackTarget => ref visualFeedbackTarget;
public Player Player => Subject != null ? Subject.Owner : null; public Player Player => Subject?.Owner;
readonly Target target; readonly Target target;
readonly Target visualFeedbackTarget; readonly Target visualFeedbackTarget;

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Network
static Player FindPlayerByClient(this World world, Session.Client c) static Player FindPlayerByClient(this World world, Session.Client c)
{ {
return world.Players.FirstOrDefault(p => (p.ClientIndex == c.Index && p.PlayerReference.Playable)); return world.Players.FirstOrDefault(p => p.ClientIndex == c.Index && p.PlayerReference.Playable);
} }
internal static void ProcessOrder(OrderManager orderManager, World world, int clientId, Order order) internal static void ProcessOrder(OrderManager orderManager, World world, int clientId, Order order)
@@ -63,7 +63,7 @@ namespace OpenRA.Network
// ExtraData 0 means this is a normal chat order, everything else is team chat // ExtraData 0 means this is a normal chat order, everything else is team chat
if (order.ExtraData == 0) if (order.ExtraData == 0)
{ {
var p = world != null ? world.FindPlayerByClient(client) : null; var p = world?.FindPlayerByClient(client);
var suffix = (p != null && p.WinState == WinState.Lost) ? " (Dead)" : ""; var suffix = (p != null && p.WinState == WinState.Lost) ? " (Dead)" : "";
suffix = client.IsObserver ? " (Spectator)" : suffix; suffix = client.IsObserver ? " (Spectator)" : suffix;

View File

@@ -1076,7 +1076,7 @@ namespace OpenRA.Server
{ {
Conns.Remove(toDrop); Conns.Remove(toDrop);
var dropClient = LobbyInfo.Clients.FirstOrDefault(c1 => c1.Index == toDrop.PlayerIndex); var dropClient = LobbyInfo.Clients.FirstOrDefault(c => c.Index == toDrop.PlayerIndex);
if (dropClient == null) if (dropClient == null)
{ {
toDrop.Dispose(); toDrop.Dispose();

View File

@@ -110,7 +110,7 @@ namespace OpenRA
value = args[i + 1]; value = args[i + 1];
if (value == null) if (value == null)
throw new ArgumentNullException("args", $"Expected the argument at index {i + 1} to be a non-null value"); throw new ArgumentNullException(nameof(args), $"Expected the argument at index {i + 1} to be a non-null value");
argumentDictionary.Add(name, value); argumentDictionary.Add(name, value);
} }

View File

@@ -650,8 +650,7 @@ namespace OpenRA.Mods.Common.Server
server.SendOrderTo(kickConn, "ServerError", "You have been kicked from the server."); server.SendOrderTo(kickConn, "ServerError", "You have been kicked from the server.");
server.DropClient(kickConn); server.DropClient(kickConn);
bool.TryParse(split[1], out var tempBan); if (bool.TryParse(split[1], out var tempBan) && tempBan)
if (tempBan)
{ {
Log.Write("server", "Temporarily banning client {0} ({1}).", kickClientID, kickClient.IPAddress); Log.Write("server", "Temporarily banning client {0} ({1}).", kickClientID, kickClient.IPAddress);
server.SendMessage($"{client.Name} temporarily banned {kickClient.Name} from the server."); server.SendMessage($"{client.Name} temporarily banned {kickClient.Name} from the server.");