Write XCC compatible mix files.
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace OpenRA.FileFormats
|
namespace OpenRA.FileFormats
|
||||||
{
|
{
|
||||||
@@ -33,5 +35,33 @@ namespace OpenRA.FileFormats
|
|||||||
Entries[i] = new string(chars.ToArray());
|
Entries[i] = new string(chars.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public XccLocalDatabase(IEnumerable<string> filenames)
|
||||||
|
{
|
||||||
|
Entries = filenames.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] Data()
|
||||||
|
{
|
||||||
|
var data = new MemoryStream();
|
||||||
|
using (var writer = new BinaryWriter(data))
|
||||||
|
{
|
||||||
|
writer.Write(Encoding.ASCII.GetBytes("XCC by Olaf van der Spek"));
|
||||||
|
writer.Write(new byte[] {0x1A,0x04,0x17,0x27,0x10,0x19,0x80,0x00});
|
||||||
|
|
||||||
|
writer.Write((int)(Entries.Aggregate(Entries.Length, (a,b) => a + b.Length) + 52)); // Size
|
||||||
|
writer.Write((int)0); // Type
|
||||||
|
writer.Write((int)0); // Version
|
||||||
|
writer.Write((int)0); // Game/Format (0 == TD)
|
||||||
|
writer.Write((int)Entries.Length); // Entries
|
||||||
|
foreach (var e in Entries)
|
||||||
|
{
|
||||||
|
writer.Write(Encoding.ASCII.GetBytes(e));
|
||||||
|
writer.Write((byte)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,8 +39,8 @@ namespace OpenRA.FileFormats
|
|||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
|
|
||||||
s = File.Create(filename);
|
s = File.Create(filename);
|
||||||
|
index = new Dictionary<uint, PackageEntry>();
|
||||||
// TODO: Add a local mix database.dat for compatibility with XCC Mixer
|
contents.Add("local mix database.dat", new XccLocalDatabase(contents.Keys.Append("local mix database.dat")).Data());
|
||||||
Write(contents);
|
Write(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user