closer to map parsing!
git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1076 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using OpenRa.FileFormats;
|
||||
|
||||
namespace MapViewer
|
||||
{
|
||||
@@ -38,6 +39,40 @@ namespace MapViewer
|
||||
Console.WriteLine("X: {0} Y: {1} Width: {2} Height: {3}",
|
||||
map.GetValue("X", "0"), map.GetValue("Y", "0"),
|
||||
map.GetValue("Width", "0"), map.GetValue("Height", "0"));
|
||||
|
||||
// parse MapPack section
|
||||
IniSection mapPackSection = iniFile.GetSection("MapPack");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 1; ; i++)
|
||||
{
|
||||
string line = mapPackSection.GetValue(i.ToString(), null);
|
||||
if (line == null)
|
||||
break;
|
||||
|
||||
sb.Append(line.Trim());
|
||||
}
|
||||
|
||||
byte[] data = Convert.FromBase64String(sb.ToString());
|
||||
Console.WriteLine("Format80 data: {0}", data.Length);
|
||||
|
||||
List<byte[]> chunks = new List<byte[]>();
|
||||
|
||||
BinaryReader 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);
|
||||
|
||||
int actualLength = Format80.DecodeInto(new MemoryStream(src), dest);
|
||||
Console.WriteLine("Chunk length: {0}", actualLength);
|
||||
}
|
||||
}
|
||||
catch (EndOfStreamException) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user