Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

more general tidying

  • Loading branch information...
commit e84d90fc3a473ae71bb9c9abc37a1883c2daac2d 1 parent 418b8d4
@chrisforbes authored
View
29 OpenRA.Editor/LegacyMapImporter.cs
@@ -189,27 +189,27 @@ static int2 LocationFromMapOffset(int offset, int mapSize)
static MemoryStream ReadPackedSection(IniSection mapPackSection)
{
- StringBuilder sb = new StringBuilder();
+ var sb = new StringBuilder();
for (int i = 1; ; i++)
{
- string line = mapPackSection.GetValue(i.ToString(), null);
+ var line = mapPackSection.GetValue(i.ToString(), null);
if (line == null)
break;
sb.Append(line.Trim());
}
- byte[] data = Convert.FromBase64String(sb.ToString());
- List<byte[]> chunks = new List<byte[]>();
- BinaryReader reader = new BinaryReader(new MemoryStream(data));
+ var data = Convert.FromBase64String(sb.ToString());
+ var chunks = new List<byte[]>();
+ var reader = new BinaryReader(new MemoryStream(data));
try
{
while (true)
{
- uint length = reader.ReadUInt32() & 0xdfffffff;
- byte[] dest = new byte[8192];
- byte[] src = reader.ReadBytes((int)length);
+ var length = reader.ReadUInt32() & 0xdfffffff;
+ var dest = new byte[8192];
+ var src = reader.ReadBytes((int)length);
/*int actualLength =*/
Format80.DecodeInto(src, dest);
@@ -219,8 +219,8 @@ static MemoryStream ReadPackedSection(IniSection mapPackSection)
}
catch (EndOfStreamException) { }
- MemoryStream ms = new MemoryStream();
- foreach (byte[] chunk in chunks)
+ var ms = new MemoryStream();
+ foreach (var chunk in chunks)
ms.Write(chunk, 0, chunk.Length);
ms.Position = 0;
@@ -284,7 +284,7 @@ void UnpackRAOverlayData(MemoryStream ms)
void ReadRATrees(IniFile file)
{
- IniSection terrain = file.GetSection("TERRAIN", true);
+ var terrain = file.GetSection("TERRAIN", true);
if (terrain == null)
return;
@@ -316,14 +316,14 @@ void UnpackCncTileData(Stream ms)
void ReadCncOverlay(IniFile file)
{
- IniSection overlay = file.GetSection("OVERLAY", true);
+ var overlay = file.GetSection("OVERLAY", true);
if (overlay == null)
return;
foreach (KeyValuePair<string, string> kv in overlay)
{
var loc = int.Parse(kv.Key);
- int2 cell = new int2(loc % MapSize, loc / MapSize);
+ var cell = new int2(loc % MapSize, loc / MapSize);
var res = Pair.New((byte)0, (byte)0);
if (overlayResourceMapping.ContainsKey(kv.Value.ToLower()))
@@ -343,7 +343,7 @@ void ReadCncOverlay(IniFile file)
void ReadCncTrees(IniFile file)
{
- IniSection terrain = file.GetSection("TERRAIN", true);
+ var terrain = file.GetSection("TERRAIN", true);
if (terrain == null)
return;
@@ -375,7 +375,6 @@ void LoadActors(IniFile file, string section)
if (parts[0] == "")
parts[0] = "Neutral";
-
if (!Players.Contains(parts[0]))
Players.Add(parts[0]);
View
4 OpenRA.FileFormats/ColorRamp.cs
@@ -21,8 +21,6 @@ public ColorRamp(byte h, byte s, byte l, byte r)
H = h; S = s; L = l; R = r;
}
- public static readonly ColorRamp Empty = new ColorRamp(0,0,0,0);
-
/* returns a color along the Lum ramp */
public Color GetColor( float t )
{
@@ -35,7 +33,7 @@ public override string ToString()
}
// hk is hue in the range [0,1] instead of [0,360]
- public static Color ColorFromHSL(float hk, float s, float l)
+ static Color ColorFromHSL(float hk, float s, float l)
{
// Convert from HSL to RGB
var q = (l < 0.5f) ? l * (1 + s) : l + s - (l * s);
View
12 OpenRA.Game/Map.cs
@@ -56,16 +56,9 @@ public int2[] GetSpawnPoints()
[FieldLoader.Ignore] public Dictionary<string, PlayerReference> Players = new Dictionary<string, PlayerReference>();
[FieldLoader.Ignore] public Lazy<List<SmudgeReference>> Smudges;
- // Rules overrides
[FieldLoader.Ignore] public List<MiniYamlNode> Rules = new List<MiniYamlNode>();
-
- // Sequences overrides
[FieldLoader.Ignore] public List<MiniYamlNode> Sequences = new List<MiniYamlNode>();
-
- // Weapon overrides
[FieldLoader.Ignore] public List<MiniYamlNode> Weapons = new List<MiniYamlNode>();
-
- // Voices overrides
[FieldLoader.Ignore] public List<MiniYamlNode> Voices = new List<MiniYamlNode>();
// Binary map data
@@ -76,10 +69,7 @@ public int2[] GetSpawnPoints()
[FieldLoader.Ignore] public Lazy<TileReference<byte, byte>[,]> MapResources;
[FieldLoader.Ignore] public string [,] CustomTerrain;
- public Map()
- {
- // Do nothing; not a valid map (editor hack)
- }
+ public Map() {} /* doesn't really produce a valid map, but enough for loading a mod */
public static Map FromTileset(string tileset)
{
Please sign in to comment.
Something went wrong with that request. Please try again.