From 8817fd2cc5245b51e3cc26cb334335b43e4c0e2c Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 17 May 2013 20:49:47 +1200 Subject: [PATCH] Parse XCC local mix database. --- .../FileFormats/XccLocalDatabase.cs | 37 +++++++++++++++++++ OpenRA.FileFormats/OpenRA.FileFormats.csproj | 1 + 2 files changed, 38 insertions(+) create mode 100644 OpenRA.FileFormats/FileFormats/XccLocalDatabase.cs diff --git a/OpenRA.FileFormats/FileFormats/XccLocalDatabase.cs b/OpenRA.FileFormats/FileFormats/XccLocalDatabase.cs new file mode 100644 index 0000000000..f75c5b4063 --- /dev/null +++ b/OpenRA.FileFormats/FileFormats/XccLocalDatabase.cs @@ -0,0 +1,37 @@ +#region Copyright & License Information +/* + * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System.Collections.Generic; +using System.IO; + +namespace OpenRA.FileFormats +{ + public class XccLocalDatabase + { + public readonly string[] Entries; + public XccLocalDatabase(Stream s) + { + // Skip unnecessary header data + s.Seek(48, SeekOrigin.Begin); + var reader = new BinaryReader(s); + var count = reader.ReadInt32(); + Entries = new string[count]; + for (var i = 0; i < count; i++) + { + var chars = new List(); + char c; + while ((c = reader.ReadChar()) != 0) + chars.Add(c); + + Entries[i] = new string(chars.ToArray()); + } + } + } +} \ No newline at end of file diff --git a/OpenRA.FileFormats/OpenRA.FileFormats.csproj b/OpenRA.FileFormats/OpenRA.FileFormats.csproj index 74f0b867e0..e0aa533aa9 100644 --- a/OpenRA.FileFormats/OpenRA.FileFormats.csproj +++ b/OpenRA.FileFormats/OpenRA.FileFormats.csproj @@ -139,6 +139,7 @@ +