diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj
index 676a011a4d..a32c50975a 100644
--- a/OpenRA.Game/OpenRA.Game.csproj
+++ b/OpenRA.Game/OpenRA.Game.csproj
@@ -278,16 +278,11 @@
-
-
-
-
-
diff --git a/OpenRA.Game/FileFormats/IniFile.cs b/OpenRA.Mods.Common/FileFormats/IniFile.cs
similarity index 98%
rename from OpenRA.Game/FileFormats/IniFile.cs
rename to OpenRA.Mods.Common/FileFormats/IniFile.cs
index 3be88101c1..c914d0bb1e 100644
--- a/OpenRA.Game/FileFormats/IniFile.cs
+++ b/OpenRA.Mods.Common/FileFormats/IniFile.cs
@@ -14,7 +14,7 @@ using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
-namespace OpenRA.FileFormats
+namespace OpenRA.Mods.Common.FileFormats
{
public class IniFile
{
diff --git a/OpenRA.Game/FileFormats/Format80.cs b/OpenRA.Mods.Common/FileFormats/LCWCompression.cs
similarity index 96%
rename from OpenRA.Game/FileFormats/Format80.cs
rename to OpenRA.Mods.Common/FileFormats/LCWCompression.cs
index 7706b199a9..4f7517d817 100644
--- a/OpenRA.Game/FileFormats/Format80.cs
+++ b/OpenRA.Mods.Common/FileFormats/LCWCompression.cs
@@ -11,7 +11,7 @@
using System;
using System.IO;
-namespace OpenRA.FileFormats
+namespace OpenRA.Mods.Common.FileFormats
{
class FastByteReader
{
@@ -41,7 +41,8 @@ namespace OpenRA.FileFormats
public int Remaining() { return src.Length - offset; }
}
- public static class Format80
+ // Lempel - Castle - Welch algorithm (aka Format80)
+ public static class LCWCompression
{
static void ReplicatePrevious(byte[] dest, int destIndex, int srcIndex, int count)
{
@@ -156,7 +157,7 @@ namespace OpenRA.FileFormats
}
}
- // Quick and dirty Format80 encoder version 2
+ // Quick and dirty LCW encoder version 2
// Uses raw copy and RLE compression
public static byte[] Encode(byte[] src)
{
diff --git a/OpenRA.Game/FileFormats/Format2.cs b/OpenRA.Mods.Common/FileFormats/RLEZerosCompression.cs
similarity index 83%
rename from OpenRA.Game/FileFormats/Format2.cs
rename to OpenRA.Mods.Common/FileFormats/RLEZerosCompression.cs
index 9c67dc61f3..40c67762da 100644
--- a/OpenRA.Game/FileFormats/Format2.cs
+++ b/OpenRA.Mods.Common/FileFormats/RLEZerosCompression.cs
@@ -8,9 +8,10 @@
*/
#endregion
-namespace OpenRA.FileFormats
+namespace OpenRA.Mods.Common.FileFormats
{
- public static class Format2
+ // Run length encoded sequences of zeros (aka Format2)
+ public static class RLEZerosCompression
{
public static void DecodeInto(byte[] src, byte[] dest, int destIndex)
{
diff --git a/OpenRA.Game/FileFormats/VqaReader.cs b/OpenRA.Mods.Common/FileFormats/VqaReader.cs
similarity index 97%
rename from OpenRA.Game/FileFormats/VqaReader.cs
rename to OpenRA.Mods.Common/FileFormats/VqaReader.cs
index 630f37a8ae..1916067608 100644
--- a/OpenRA.Game/FileFormats/VqaReader.cs
+++ b/OpenRA.Mods.Common/FileFormats/VqaReader.cs
@@ -10,8 +10,9 @@
using System;
using System.IO;
+using OpenRA.FileFormats;
-namespace OpenRA.FileFormats
+namespace OpenRA.Mods.Common.FileFormats
{
public class VqaReader
{
@@ -329,7 +330,7 @@ namespace OpenRA.FileFormats
Array.Clear(cbf, 0, cbf.Length);
Array.Clear(cbfBuffer, 0, cbfBuffer.Length);
var decodeCount = 0;
- decodeCount = Format80.DecodeInto(fileBuffer, cbfBuffer, decodeMode ? 1 : 0, decodeMode);
+ decodeCount = LCWCompression.DecodeInto(fileBuffer, cbfBuffer, decodeMode ? 1 : 0, decodeMode);
if ((videoFlags & 0x10) == 16)
{
var p = 0;
@@ -365,7 +366,7 @@ namespace OpenRA.FileFormats
if (type == "CBP0")
cbf = (byte[])cbp.Clone();
else
- Format80.DecodeInto(cbp, cbf);
+ LCWCompression.DecodeInto(cbp, cbf);
chunkBufferOffset = currentChunkBuffer = 0;
}
@@ -390,7 +391,7 @@ namespace OpenRA.FileFormats
// Frame data
case "VPTZ":
- Format80.DecodeInto(s.ReadBytes(subchunkLength), origData);
+ LCWCompression.DecodeInto(s.ReadBytes(subchunkLength), origData);
// This is the last subchunk
return;
@@ -398,9 +399,9 @@ namespace OpenRA.FileFormats
Array.Clear(origData, 0, origData.Length);
s.ReadBytes(fileBuffer, 0, subchunkLength);
if (fileBuffer[0] != 0)
- vtprSize = Format80.DecodeInto(fileBuffer, origData);
+ vtprSize = LCWCompression.DecodeInto(fileBuffer, origData);
else
- Format80.DecodeInto(fileBuffer, origData, 1, true);
+ LCWCompression.DecodeInto(fileBuffer, origData, 1, true);
return;
case "VPTR":
Array.Clear(origData, 0, origData.Length);
diff --git a/OpenRA.Game/FileFormats/Format40.cs b/OpenRA.Mods.Common/FileFormats/XORDeltaCompression.cs
similarity index 91%
rename from OpenRA.Game/FileFormats/Format40.cs
rename to OpenRA.Mods.Common/FileFormats/XORDeltaCompression.cs
index cb1ee1b8e9..995bcfc2ef 100644
--- a/OpenRA.Game/FileFormats/Format40.cs
+++ b/OpenRA.Mods.Common/FileFormats/XORDeltaCompression.cs
@@ -8,9 +8,10 @@
*/
#endregion
-namespace OpenRA.FileFormats
+namespace OpenRA.Mods.Common.FileFormats
{
- public static class Format40
+ // Data that is to be XORed against another set of data (aka Format40)
+ public static class XORDeltaCompression
{
public static int DecodeInto(byte[] src, byte[] dest, int srcOffset)
{
diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
index 810e1ea4ae..28f9e444aa 100644
--- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
+++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
@@ -719,6 +719,11 @@
+
+
+
+
+
diff --git a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs
index 7c4ef02d8b..a11e7e5f5f 100644
--- a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs
+++ b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs
@@ -13,10 +13,10 @@ using System.Drawing;
using System.IO;
using Eluant;
using OpenRA.Effects;
-using OpenRA.FileFormats;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Effects;
+using OpenRA.Mods.Common.FileFormats;
using OpenRA.Mods.Common.Traits;
using OpenRA.Scripting;
diff --git a/OpenRA.Mods.Common/Scripting/Media.cs b/OpenRA.Mods.Common/Scripting/Media.cs
index 1d9f7ef69d..fd0ef42946 100644
--- a/OpenRA.Mods.Common/Scripting/Media.cs
+++ b/OpenRA.Mods.Common/Scripting/Media.cs
@@ -10,7 +10,7 @@
using System;
using System.IO;
-using OpenRA.FileFormats;
+using OpenRA.Mods.Common.FileFormats;
using OpenRA.Mods.Common.Widgets;
using OpenRA.Widgets;
diff --git a/OpenRA.Mods.Common/SpriteLoaders/ShpD2Loader.cs b/OpenRA.Mods.Common/SpriteLoaders/ShpD2Loader.cs
index de1e79fa44..01732868b4 100644
--- a/OpenRA.Mods.Common/SpriteLoaders/ShpD2Loader.cs
+++ b/OpenRA.Mods.Common/SpriteLoaders/ShpD2Loader.cs
@@ -11,8 +11,8 @@
using System;
using System.Drawing;
using System.IO;
-using OpenRA.FileFormats;
using OpenRA.Graphics;
+using OpenRA.Mods.Common.FileFormats;
namespace OpenRA.Mods.Common.SpriteLoaders
{
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
[Flags] enum FormatFlags : int
{
PaletteTable = 1,
- SkipFormat80 = 2,
+ NotLCWCompressed = 2,
VariableLengthTable = 4
}
@@ -70,14 +70,14 @@ namespace OpenRA.Mods.Common.SpriteLoaders
// Decode image data
var compressed = s.ReadBytes(dataLeft);
- if ((flags & FormatFlags.SkipFormat80) == 0)
+ if ((flags & FormatFlags.NotLCWCompressed) == 0)
{
var temp = new byte[dataSize];
- Format80.DecodeInto(compressed, temp);
+ LCWCompression.DecodeInto(compressed, temp);
compressed = temp;
}
- Format2.DecodeInto(compressed, Data, 0);
+ RLEZerosCompression.DecodeInto(compressed, Data, 0);
// Lookup values in lookup table
for (var j = 0; j < Data.Length; j++)
diff --git a/OpenRA.Mods.Common/SpriteLoaders/ShpTDLoader.cs b/OpenRA.Mods.Common/SpriteLoaders/ShpTDLoader.cs
index dee2ce5a88..34b0009e26 100644
--- a/OpenRA.Mods.Common/SpriteLoaders/ShpTDLoader.cs
+++ b/OpenRA.Mods.Common/SpriteLoaders/ShpTDLoader.cs
@@ -13,8 +13,8 @@ using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
-using OpenRA.FileFormats;
using OpenRA.Graphics;
+using OpenRA.Mods.Common.FileFormats;
namespace OpenRA.Mods.Common.SpriteLoaders
{
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
public class ShpTDSprite
{
- enum Format { Format20 = 0x20, Format40 = 0x40, Format80 = 0x80 }
+ enum Format { XORPrev = 0x20, XORLCW = 0x40, LCW = 0x80 }
class ImageHeader : ISpriteFrame
{
@@ -142,9 +142,9 @@ namespace OpenRA.Mods.Common.SpriteLoaders
for (var i = 0; i < imageCount; i++)
{
var h = headers[i];
- if (h.Format == Format.Format20)
+ if (h.Format == Format.XORPrev)
h.RefImage = headers[i - 1];
- else if (h.Format == Format.Format40 && !offsets.TryGetValue(h.RefOffset, out h.RefImage))
+ else if (h.Format == Format.XORLCW && !offsets.TryGetValue(h.RefOffset, out h.RefImage))
throw new InvalidDataException("Reference doesn't point to image data {0}->{1}".F(h.FileOffset, h.RefOffset));
}
@@ -166,8 +166,8 @@ namespace OpenRA.Mods.Common.SpriteLoaders
switch (h.Format)
{
- case Format.Format20:
- case Format.Format40:
+ case Format.XORPrev:
+ case Format.XORLCW:
{
if (h.RefImage.Data == null)
{
@@ -177,14 +177,14 @@ namespace OpenRA.Mods.Common.SpriteLoaders
}
h.Data = CopyImageData(h.RefImage.Data);
- Format40.DecodeInto(shpBytes, h.Data, (int)(h.FileOffset - shpBytesFileOffset));
+ XORDeltaCompression.DecodeInto(shpBytes, h.Data, (int)(h.FileOffset - shpBytesFileOffset));
break;
}
- case Format.Format80:
+ case Format.LCW:
{
var imageBytes = new byte[Size.Width * Size.Height];
- Format80.DecodeInto(shpBytes, imageBytes, (int)(h.FileOffset - shpBytesFileOffset));
+ LCWCompression.DecodeInto(shpBytes, imageBytes, (int)(h.FileOffset - shpBytesFileOffset));
h.Data = imageBytes;
break;
}
@@ -203,7 +203,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
public static void Write(Stream s, Size size, IEnumerable frames)
{
- var compressedFrames = frames.Select(f => Format80.Encode(f)).ToList();
+ var compressedFrames = frames.Select(f => LCWCompression.Encode(f)).ToList();
// note: end-of-file and all-zeroes headers
var dataOffset = 14 + (compressedFrames.Count + 2) * 8;
@@ -219,7 +219,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
foreach (var f in compressedFrames)
{
- var ih = new ImageHeader { Format = Format.Format80, FileOffset = (uint)dataOffset };
+ var ih = new ImageHeader { Format = Format.LCW, FileOffset = (uint)dataOffset };
dataOffset += f.Length;
ih.WriteTo(bw);
diff --git a/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs b/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs
index 5f821aa869..3e8ba08711 100644
--- a/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs
+++ b/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs
@@ -10,8 +10,8 @@
using System.Drawing;
using System.IO;
-using OpenRA.FileFormats;
using OpenRA.Graphics;
+using OpenRA.Mods.Common.FileFormats;
namespace OpenRA.Mods.Common.SpriteLoaders
{
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
for (var j = 0; j < height; j++)
{
var length = s.ReadUInt16() - 2;
- Format2.DecodeInto(s.ReadBytes(length), Data, dataWidth * j);
+ RLEZerosCompression.DecodeInto(s.ReadBytes(length), Data, dataWidth * j);
}
}
else
diff --git a/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs b/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs
index 4fd92de815..c72209eb13 100644
--- a/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs
+++ b/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs
@@ -13,8 +13,8 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
-using OpenRA.FileFormats;
using OpenRA.Graphics;
+using OpenRA.Mods.Common.FileFormats;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
@@ -242,7 +242,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
var src = reader.ReadBytes((int)length);
/*int actualLength =*/
- Format80.DecodeInto(src, dest);
+ LCWCompression.DecodeInto(src, dest);
chunks.Add(dest);
}
diff --git a/OpenRA.Mods.Common/Widgets/VqaPlayerWidget.cs b/OpenRA.Mods.Common/Widgets/VqaPlayerWidget.cs
index 45be7bae6b..373a746f41 100644
--- a/OpenRA.Mods.Common/Widgets/VqaPlayerWidget.cs
+++ b/OpenRA.Mods.Common/Widgets/VqaPlayerWidget.cs
@@ -10,8 +10,8 @@
using System;
using System.Drawing;
-using OpenRA.FileFormats;
using OpenRA.Graphics;
+using OpenRA.Mods.Common.FileFormats;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets
diff --git a/OpenRA.Mods.TS/UtilityCommands/LegacyTilesetImporter.cs b/OpenRA.Mods.TS/UtilityCommands/LegacyTilesetImporter.cs
index de4722fc82..0c0243dc20 100644
--- a/OpenRA.Mods.TS/UtilityCommands/LegacyTilesetImporter.cs
+++ b/OpenRA.Mods.TS/UtilityCommands/LegacyTilesetImporter.cs
@@ -11,7 +11,7 @@
using System;
using System.Collections.Generic;
using System.IO;
-using OpenRA.FileFormats;
+using OpenRA.Mods.Common.FileFormats;
namespace OpenRA.Mods.TS.UtilityCommands
{