Save disconnect frame in the GameInformation
This information is useful to infer a winner in case the winstate is unknown.
This commit is contained in:
@@ -179,6 +179,9 @@ namespace OpenRA
|
|||||||
/// <summary>The time when this player won or lost the game.</summary>
|
/// <summary>The time when this player won or lost the game.</summary>
|
||||||
public DateTime OutcomeTimestampUtc;
|
public DateTime OutcomeTimestampUtc;
|
||||||
|
|
||||||
|
/// <summary>The frame at which this player disconnected.</summary>
|
||||||
|
public int DisconnectFrame;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,13 @@ namespace OpenRA.Network
|
|||||||
{
|
{
|
||||||
var client = orderManager.LobbyInfo.ClientWithIndex(clientId);
|
var client = orderManager.LobbyInfo.ClientWithIndex(clientId);
|
||||||
if (client != null)
|
if (client != null)
|
||||||
|
{
|
||||||
client.State = Session.ClientState.Disconnected;
|
client.State = Session.ClientState.Disconnected;
|
||||||
|
var player = world?.FindPlayerByClient(client);
|
||||||
|
if (player != null)
|
||||||
|
world.OnPlayerDisconnected(player);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1044,6 +1044,12 @@ namespace OpenRA.Server
|
|||||||
// Send disconnected order, even if still in the lobby
|
// Send disconnected order, even if still in the lobby
|
||||||
DispatchOrdersToClients(toDrop, 0, Order.FromTargetString("Disconnected", "", true).Serialize());
|
DispatchOrdersToClients(toDrop, 0, Order.FromTargetString("Disconnected", "", true).Serialize());
|
||||||
|
|
||||||
|
if (gameInfo != null && !dropClient.IsObserver)
|
||||||
|
{
|
||||||
|
var disconnectedPlayer = gameInfo.Players.First(p => p.ClientIndex == toDrop.PlayerIndex);
|
||||||
|
disconnectedPlayer.DisconnectFrame = toDrop.MostRecentFrame;
|
||||||
|
}
|
||||||
|
|
||||||
LobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex);
|
LobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex);
|
||||||
LobbyInfo.ClientPings.RemoveAll(p => p.Index == toDrop.PlayerIndex);
|
LobbyInfo.ClientPings.RemoveAll(p => p.Index == toDrop.PlayerIndex);
|
||||||
|
|
||||||
|
|||||||
@@ -552,6 +552,15 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnPlayerDisconnected(Player player)
|
||||||
|
{
|
||||||
|
var pi = gameInfo.GetPlayer(player);
|
||||||
|
if (pi == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pi.DisconnectFrame = OrderManager.NetFrameNumber;
|
||||||
|
}
|
||||||
|
|
||||||
public void RequestGameSave(string filename)
|
public void RequestGameSave(string filename)
|
||||||
{
|
{
|
||||||
// Allow traits to save arbitrary data that will be passed back via IGameSaveTraitData.ResolveTraitData
|
// Allow traits to save arbitrary data that will be passed back via IGameSaveTraitData.ResolveTraitData
|
||||||
|
|||||||
Reference in New Issue
Block a user