From dbebbfb922613d36ba575319a65bda080ab56fe7 Mon Sep 17 00:00:00 2001 From: chrisf Date: Tue, 26 Jun 2007 10:16:36 +0000 Subject: [PATCH] git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1078 993157c7-ee19-0410-b2c4-bb4e9862e678 --- MapViewer/Program.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/MapViewer/Program.cs b/MapViewer/Program.cs index 69a788000e..b20d653012 100644 --- a/MapViewer/Program.cs +++ b/MapViewer/Program.cs @@ -40,6 +40,12 @@ namespace MapViewer map.GetValue("X", "0"), map.GetValue("Y", "0"), map.GetValue("Width", "0"), map.GetValue("Height", "0")); + int width = int.Parse(map.GetValue("Width", "0")); + int height = int.Parse(map.GetValue("Height", "0")); + + int x = int.Parse(map.GetValue("X", "0")); + int y = int.Parse(map.GetValue("Y", "0")); + // parse MapPack section IniSection mapPackSection = iniFile.GetSection("MapPack"); @@ -75,6 +81,30 @@ namespace MapViewer } } catch (EndOfStreamException) { } + + MemoryStream ms = new MemoryStream(); + foreach (byte[] chunk in chunks) + ms.Write(chunk, 0, chunk.Length); + + ms.Position = 0; + + TileReference[,] tiles = new TileReference[width, height]; + for( int i = 0; i < width; i++ ) + for (int j = 0; j < height; j++) + tiles[i, j].tile = (ushort)((ms.ReadByte() << 8) | ms.ReadByte()); + + for (int i = 0; i < width; i++) + for (int j = 0; j < height; j++) + tiles[i, j].image = (byte)ms.ReadByte(); + + foreach( TileReference r in tiles ) + Console.Write("{0:x4}.{1:x2} ", r.tile, r.image); } } + + struct TileReference + { + public ushort tile; + public byte image; + } }