Use out var syntax
This commit is contained in:
@@ -167,28 +167,22 @@ namespace OpenRA.Network
|
||||
|
||||
// Games advertised using the old API calculated the play time locally
|
||||
if (State == 2 && PlayTime < 0)
|
||||
{
|
||||
DateTime startTime;
|
||||
if (DateTime.TryParse(Started, out startTime))
|
||||
if (DateTime.TryParse(Started, out var startTime))
|
||||
PlayTime = (int)(DateTime.UtcNow - startTime).TotalSeconds;
|
||||
}
|
||||
|
||||
ExternalMod external;
|
||||
var externalKey = ExternalMod.MakeKey(Mod, Version);
|
||||
if (Game.ExternalMods.TryGetValue(externalKey, out external) && external.Version == Version)
|
||||
if (Game.ExternalMods.TryGetValue(externalKey, out var external) && external.Version == Version)
|
||||
IsCompatible = true;
|
||||
|
||||
// Games advertised using the old API used local mod metadata
|
||||
if (string.IsNullOrEmpty(ModTitle))
|
||||
{
|
||||
Manifest mod;
|
||||
|
||||
if (external != null && external.Version == Version)
|
||||
{
|
||||
// Use external mod registration to populate the section header
|
||||
ModTitle = external.Title;
|
||||
}
|
||||
else if (Game.Mods.TryGetValue(Mod, out mod))
|
||||
else if (Game.Mods.TryGetValue(Mod, out var mod))
|
||||
{
|
||||
// Use internal mod data to populate the section header, but
|
||||
// on-connect switching must use the external mod plumbing.
|
||||
|
||||
@@ -107,8 +107,7 @@ namespace OpenRA
|
||||
{
|
||||
case TargetType.Actor:
|
||||
{
|
||||
Actor targetActor;
|
||||
if (world != null && TryGetActorFromUInt(world, r.ReadUInt32(), out targetActor))
|
||||
if (world != null && TryGetActorFromUInt(world, r.ReadUInt32(), out var targetActor))
|
||||
target = Target.FromActor(targetActor);
|
||||
break;
|
||||
}
|
||||
@@ -118,8 +117,7 @@ namespace OpenRA
|
||||
var playerActorID = r.ReadUInt32();
|
||||
var frozenActorID = r.ReadUInt32();
|
||||
|
||||
Actor playerActor;
|
||||
if (world == null || !TryGetActorFromUInt(world, playerActorID, out playerActor))
|
||||
if (world == null || !TryGetActorFromUInt(world, playerActorID, out var playerActor))
|
||||
break;
|
||||
|
||||
if (playerActor.Owner.FrozenActorLayer == null)
|
||||
|
||||
@@ -149,8 +149,7 @@ namespace OpenRA.Network
|
||||
void CheckSync(byte[] packet)
|
||||
{
|
||||
var frame = BitConverter.ToInt32(packet, 0);
|
||||
byte[] existingSync;
|
||||
if (syncForFrame.TryGetValue(frame, out existingSync))
|
||||
if (syncForFrame.TryGetValue(frame, out var existingSync))
|
||||
{
|
||||
if (packet.Length != existingSync.Length)
|
||||
OutOfSync(frame);
|
||||
|
||||
@@ -250,8 +250,7 @@ namespace OpenRA.Network
|
||||
|
||||
public bool OptionOrDefault(string id, bool def)
|
||||
{
|
||||
LobbyOptionState option;
|
||||
if (LobbyOptions.TryGetValue(id, out option))
|
||||
if (LobbyOptions.TryGetValue(id, out var option))
|
||||
return option.IsEnabled;
|
||||
|
||||
return def;
|
||||
@@ -259,8 +258,7 @@ namespace OpenRA.Network
|
||||
|
||||
public string OptionOrDefault(string id, string def)
|
||||
{
|
||||
LobbyOptionState option;
|
||||
if (LobbyOptions.TryGetValue(id, out option))
|
||||
if (LobbyOptions.TryGetValue(id, out var option))
|
||||
return option.Value;
|
||||
|
||||
return def;
|
||||
|
||||
@@ -190,9 +190,8 @@ namespace OpenRA.Network
|
||||
var request = HandshakeRequest.Deserialize(order.TargetString);
|
||||
|
||||
var externalKey = ExternalMod.MakeKey(request.Mod, request.Version);
|
||||
ExternalMod external;
|
||||
if ((request.Mod != mod.Id || request.Version != mod.Metadata.Version)
|
||||
&& Game.ExternalMods.TryGetValue(externalKey, out external))
|
||||
if ((request.Mod != mod.Id || request.Version != mod.Metadata.Version) &&
|
||||
Game.ExternalMods.TryGetValue(externalKey, out var external))
|
||||
{
|
||||
// The ConnectionFailedLogic will prompt the user to switch mods
|
||||
orderManager.ServerExternalMod = external;
|
||||
|
||||
Reference in New Issue
Block a user