Disallow same/similar colors (fixes #2820)
This commit is contained in:
@@ -144,7 +144,7 @@ namespace OpenRA
|
||||
public readonly Dictionary<ushort, TileTemplate> Templates = new Dictionary<ushort, TileTemplate>();
|
||||
public readonly string[] EditorTemplateOrder;
|
||||
|
||||
readonly TerrainTypeInfo[] terrainInfo;
|
||||
public readonly TerrainTypeInfo[] TerrainInfo;
|
||||
readonly Dictionary<string, int> terrainIndexByType = new Dictionary<string, int>();
|
||||
readonly int defaultWalkableTerrainIndex;
|
||||
|
||||
@@ -158,13 +158,13 @@ namespace OpenRA
|
||||
FieldLoader.Load(this, yaml["General"]);
|
||||
|
||||
// TerrainTypes
|
||||
terrainInfo = yaml["Terrain"].ToDictionary().Values
|
||||
TerrainInfo = yaml["Terrain"].ToDictionary().Values
|
||||
.Select(y => new TerrainTypeInfo(y))
|
||||
.OrderBy(tt => tt.Type)
|
||||
.ToArray();
|
||||
for (var i = 0; i < terrainInfo.Length; i++)
|
||||
for (var i = 0; i < TerrainInfo.Length; i++)
|
||||
{
|
||||
var tt = terrainInfo[i].Type;
|
||||
var tt = TerrainInfo[i].Type;
|
||||
|
||||
if (terrainIndexByType.ContainsKey(tt))
|
||||
throw new InvalidDataException("Duplicate terrain type '{0}' in '{1}'.".F(tt, filepath));
|
||||
@@ -185,7 +185,7 @@ namespace OpenRA
|
||||
this.Id = id;
|
||||
this.Palette = palette;
|
||||
this.Extensions = extensions;
|
||||
this.terrainInfo = terrainInfo;
|
||||
this.TerrainInfo = terrainInfo;
|
||||
|
||||
for (var i = 0; i < terrainInfo.Length; i++)
|
||||
{
|
||||
@@ -201,12 +201,12 @@ namespace OpenRA
|
||||
|
||||
public TerrainTypeInfo this[int index]
|
||||
{
|
||||
get { return terrainInfo[index]; }
|
||||
get { return TerrainInfo[index]; }
|
||||
}
|
||||
|
||||
public int TerrainsCount
|
||||
{
|
||||
get { return terrainInfo.Length; }
|
||||
get { return TerrainInfo.Length; }
|
||||
}
|
||||
|
||||
public bool TryGetTerrainIndex(string type, out int index)
|
||||
@@ -254,7 +254,7 @@ namespace OpenRA
|
||||
root.Add(new MiniYamlNode("General", null, gen));
|
||||
|
||||
root.Add(new MiniYamlNode("Terrain", null,
|
||||
terrainInfo.Select(t => new MiniYamlNode("TerrainType@{0}".F(t.Type), t.Save())).ToList()));
|
||||
TerrainInfo.Select(t => new MiniYamlNode("TerrainType@{0}".F(t.Type), t.Save())).ToList()));
|
||||
|
||||
root.Add(new MiniYamlNode("Templates", null,
|
||||
Templates.Select(t => new MiniYamlNode("Template@{0}".F(t.Value.Id), t.Value.Save(this))).ToList()));
|
||||
@@ -263,7 +263,7 @@ namespace OpenRA
|
||||
|
||||
public TerrainTypeInfo GetTerrainInfo(TerrainTile r)
|
||||
{
|
||||
return terrainInfo[GetTerrainIndex(r)];
|
||||
return TerrainInfo[GetTerrainIndex(r)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,30 @@ namespace OpenRA.Server
|
||||
c.Team = pr.Team;
|
||||
}
|
||||
|
||||
static void SendData(Socket s, byte[] data)
|
||||
{
|
||||
var start = 0;
|
||||
var length = data.Length;
|
||||
SocketError error;
|
||||
|
||||
// Non-blocking sends are free to send only part of the data
|
||||
while (start < length)
|
||||
{
|
||||
var sent = s.Send(data, start, length - start, SocketFlags.None, out error);
|
||||
if (error == SocketError.WouldBlock)
|
||||
{
|
||||
Log.Write("server", "Non-blocking send of {0} bytes failed. Falling back to blocking send.", length - start);
|
||||
s.Blocking = true;
|
||||
sent = s.Send(data, start, length - start, SocketFlags.None);
|
||||
s.Blocking = false;
|
||||
}
|
||||
else if (error != SocketError.Success)
|
||||
throw new SocketException((int)error);
|
||||
|
||||
start += sent;
|
||||
}
|
||||
}
|
||||
|
||||
protected volatile ServerState internalState = new ServerState();
|
||||
public ServerState State
|
||||
{
|
||||
@@ -683,29 +707,5 @@ namespace OpenRA.Server
|
||||
gameTimeout.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void SendData(Socket s, byte[] data)
|
||||
{
|
||||
var start = 0;
|
||||
var length = data.Length;
|
||||
SocketError error;
|
||||
|
||||
// Non-blocking sends are free to send only part of the data
|
||||
while (start < length)
|
||||
{
|
||||
var sent = s.Send(data, start, length - start, SocketFlags.None, out error);
|
||||
if (error == SocketError.WouldBlock)
|
||||
{
|
||||
Log.Write("server", "Non-blocking send of {0} bytes failed. Falling back to blocking send.", length - start);
|
||||
s.Blocking = true;
|
||||
sent = s.Send(data, start, length - start, SocketFlags.None);
|
||||
s.Blocking = false;
|
||||
}
|
||||
else if (error != SocketError.Success)
|
||||
throw new SocketException((int)error);
|
||||
|
||||
start += sent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace OpenRA.Server
|
||||
int TickTimeout { get; }
|
||||
}
|
||||
|
||||
public abstract class ServerTrait {}
|
||||
public abstract class ServerTrait { }
|
||||
|
||||
public class DebugServerTrait : ServerTrait, IInterpretCommand, IStartGame, INotifySyncLobbyInfo, INotifyServerStart, INotifyServerShutdown, IEndGame
|
||||
{
|
||||
public bool InterpretCommand(Server server, Connection conn, Session.Client client, string cmd)
|
||||
{
|
||||
Console.WriteLine("Server received command from player {1}: {0}",cmd, conn.PlayerIndex);
|
||||
Console.WriteLine("Server received command from player {1}: {0}", cmd, conn.PlayerIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user