Right click lobby spawns to disable or remove players.

This commit is contained in:
Trevor Nichols
2020-07-19 11:11:27 +10:00
committed by abcdefg30
parent 13581c030d
commit d66e0bb22e
30 changed files with 165 additions and 45 deletions

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Network
"Mod", "Version", "ModTitle", "ModWebsite", "ModIcon32",
// Current server state
"Map", "State", "MaxPlayers", "Protected", "Authentication"
"Map", "State", "MaxPlayers", "Protected", "Authentication", "DisabledSpawnPoints"
};
public const int ProtocolVersion = 2;
@@ -132,6 +132,9 @@ namespace OpenRA.Network
[FieldLoader.LoadUsing("LoadClients")]
public readonly GameClient[] Clients;
/// <summary>The list of spawnpoints that are disabled for this game</summary>
public readonly int[] DisabledSpawnPoints = { };
public string ModLabel { get { return "{0} ({1})".F(ModTitle, Version); } }
static object LoadClients(MiniYaml yaml)
@@ -226,6 +229,7 @@ namespace OpenRA.Network
Protected = !string.IsNullOrEmpty(server.Settings.Password);
Authentication = server.Settings.RequireAuthentication || server.Settings.ProfileIDWhitelist.Any();
Clients = server.LobbyInfo.Clients.Select(c => new GameClient(c)).ToArray();
DisabledSpawnPoints = server.LobbyInfo.DisabledSpawnPoints?.ToArray() ?? Array.Empty<int>();
}
public string ToPOSTData(bool lanGame)

View File

@@ -26,6 +26,8 @@ namespace OpenRA.Network
// Keyed by the PlayerReference id that the slot corresponds to
public Dictionary<string, Slot> Slots = new Dictionary<string, Slot>();
public List<int> DisabledSpawnPoints = new List<int>();
public Global GlobalSettings = new Global();
public static string AnonymizeIP(IPAddress ip)
@@ -69,6 +71,9 @@ namespace OpenRA.Network
var s = Slot.Deserialize(node.Value);
session.Slots.Add(s.PlayerReference, s);
break;
case "DisabledSpawnPoints":
session.DisabledSpawnPoints = FieldLoader.GetValue<List<int>>("DisabledSpawnPoints", node.Value.Value);
break;
}
}
@@ -267,7 +272,10 @@ namespace OpenRA.Network
public string Serialize()
{
var sessionData = new List<MiniYamlNode>();
var sessionData = new List<MiniYamlNode>()
{
new MiniYamlNode("DisabledSpawnPoints", FieldSaver.FormatValue(DisabledSpawnPoints))
};
foreach (var client in Clients)
sessionData.Add(client.Serialize());