logged the complete incoming bad session yaml
to investigate #3343 also made StyleCop happy
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -18,10 +19,49 @@ namespace OpenRA.Network
|
|||||||
public class Session
|
public class Session
|
||||||
{
|
{
|
||||||
public List<Client> Clients = new List<Client>();
|
public List<Client> Clients = new List<Client>();
|
||||||
|
|
||||||
// Keyed by the PlayerReference id that the slot corresponds to
|
// Keyed by the PlayerReference id that the slot corresponds to
|
||||||
public Dictionary<string, Slot> Slots = new Dictionary<string, Slot>();
|
public Dictionary<string, Slot> Slots = new Dictionary<string, Slot>();
|
||||||
|
|
||||||
public Global GlobalSettings = new Global();
|
public Global GlobalSettings = new Global();
|
||||||
|
|
||||||
|
public static Session Deserialize(string data)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var session = new Session(Game.Settings.Game.Mods);
|
||||||
|
|
||||||
|
var ys = MiniYaml.FromString(data);
|
||||||
|
foreach (var y in ys)
|
||||||
|
{
|
||||||
|
var yy = y.Key.Split('@');
|
||||||
|
|
||||||
|
switch (yy[0])
|
||||||
|
{
|
||||||
|
case "GlobalSettings":
|
||||||
|
FieldLoader.Load(session.GlobalSettings, y.Value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Client":
|
||||||
|
session.Clients.Add(FieldLoader.Load<Session.Client>(y.Value));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Slot":
|
||||||
|
var s = FieldLoader.Load<Session.Slot>(y.Value);
|
||||||
|
session.Slots.Add(s.PlayerReference, s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
Log.Write("exception", "Session deserialized invalid MiniYaml:\n{0}".F(data));
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Client ClientWithIndex(int clientID)
|
public Client ClientWithIndex(int clientID)
|
||||||
{
|
{
|
||||||
return Clients.SingleOrDefault(c => c.Index == clientID);
|
return Clients.SingleOrDefault(c => c.Index == clientID);
|
||||||
@@ -64,7 +104,7 @@ namespace OpenRA.Network
|
|||||||
public bool IsObserver { get { return Slot == null; } }
|
public bool IsObserver { get { return Slot == null; } }
|
||||||
public int Latency = -1;
|
public int Latency = -1;
|
||||||
public int LatencyJitter = -1;
|
public int LatencyJitter = -1;
|
||||||
public int[] LatencyHistory = {};
|
public int[] LatencyHistory = { };
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Slot
|
public class Slot
|
||||||
@@ -119,34 +159,5 @@ namespace OpenRA.Network
|
|||||||
|
|
||||||
return clientData.WriteToString();
|
return clientData.WriteToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Session Deserialize(string data)
|
|
||||||
{
|
|
||||||
var session = new Session(Game.Settings.Game.Mods);
|
|
||||||
|
|
||||||
var ys = MiniYaml.FromString(data);
|
|
||||||
foreach (var y in ys)
|
|
||||||
{
|
|
||||||
var yy = y.Key.Split('@');
|
|
||||||
|
|
||||||
switch (yy[0])
|
|
||||||
{
|
|
||||||
case "GlobalSettings":
|
|
||||||
FieldLoader.Load(session.GlobalSettings, y.Value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "Client":
|
|
||||||
session.Clients.Add(FieldLoader.Load<Session.Client>(y.Value));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "Slot":
|
|
||||||
var s = FieldLoader.Load<Session.Slot>(y.Value);
|
|
||||||
session.Slots.Add(s.PlayerReference, s);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return session;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user