diff --git a/MapConverter/MapConverter.csproj b/MapConverter/MapConverter.csproj index c64c0f5fcb..a62e0c9f4b 100644 --- a/MapConverter/MapConverter.csproj +++ b/MapConverter/MapConverter.csproj @@ -1 +1,48 @@ - Debug AnyCPU 9.0.21022 2.0 {BA2B4C61-D5EE-4C3E-9BA1-EB32C531FA36} Exe MapConverter MapConverter v3.5 true full false bin\Debug DEBUG prompt 4 none false bin\Release prompt 4 \ No newline at end of file + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {BA2B4C61-D5EE-4C3E-9BA1-EB32C531FA36} + Exe + MapConverter + MapConverter + v3.5 + + + true + full + false + bin\Debug + DEBUG + prompt + 4 + + + none + false + bin\Release + prompt + 4 + + + + + 3.5 + + + + + + + + + + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA} + OpenRA.FileFormats + + + + \ No newline at end of file diff --git a/OpenRA.FileFormats/AudLoader.cs b/OpenRA.FileFormats/FileFormats/AudLoader.cs similarity index 100% rename from OpenRA.FileFormats/AudLoader.cs rename to OpenRA.FileFormats/FileFormats/AudLoader.cs diff --git a/OpenRA.FileFormats/Blowfish.cs b/OpenRA.FileFormats/FileFormats/Blowfish.cs similarity index 100% rename from OpenRA.FileFormats/Blowfish.cs rename to OpenRA.FileFormats/FileFormats/Blowfish.cs diff --git a/OpenRA.FileFormats/BlowfishKeyProvider.cs b/OpenRA.FileFormats/FileFormats/BlowfishKeyProvider.cs similarity index 100% rename from OpenRA.FileFormats/BlowfishKeyProvider.cs rename to OpenRA.FileFormats/FileFormats/BlowfishKeyProvider.cs diff --git a/OpenRA.FileFormats/Format2.cs b/OpenRA.FileFormats/FileFormats/Format2.cs similarity index 100% rename from OpenRA.FileFormats/Format2.cs rename to OpenRA.FileFormats/FileFormats/Format2.cs diff --git a/OpenRA.FileFormats/Format40.cs b/OpenRA.FileFormats/FileFormats/Format40.cs similarity index 100% rename from OpenRA.FileFormats/Format40.cs rename to OpenRA.FileFormats/FileFormats/Format40.cs diff --git a/OpenRA.FileFormats/Format80.cs b/OpenRA.FileFormats/FileFormats/Format80.cs similarity index 100% rename from OpenRA.FileFormats/Format80.cs rename to OpenRA.FileFormats/FileFormats/Format80.cs diff --git a/OpenRA.FileFormats/IniFile.cs b/OpenRA.FileFormats/FileFormats/IniFile.cs similarity index 100% rename from OpenRA.FileFormats/IniFile.cs rename to OpenRA.FileFormats/FileFormats/IniFile.cs diff --git a/OpenRA.FileFormats/Dune2ShpReader.cs b/OpenRA.FileFormats/Graphics/Dune2ShpReader.cs similarity index 100% rename from OpenRA.FileFormats/Dune2ShpReader.cs rename to OpenRA.FileFormats/Graphics/Dune2ShpReader.cs diff --git a/OpenRA.FileFormats/ShpReader.cs b/OpenRA.FileFormats/Graphics/ShpReader.cs similarity index 100% rename from OpenRA.FileFormats/ShpReader.cs rename to OpenRA.FileFormats/Graphics/ShpReader.cs diff --git a/OpenRA.FileFormats/ActorReference.cs b/OpenRA.FileFormats/Map/ActorReference.cs similarity index 100% rename from OpenRA.FileFormats/ActorReference.cs rename to OpenRA.FileFormats/Map/ActorReference.cs diff --git a/OpenRA.FileFormats/Map.cs b/OpenRA.FileFormats/Map/Map.cs similarity index 100% rename from OpenRA.FileFormats/Map.cs rename to OpenRA.FileFormats/Map/Map.cs diff --git a/OpenRA.FileFormats/NewMap.cs b/OpenRA.FileFormats/Map/NewMap.cs similarity index 66% rename from OpenRA.FileFormats/NewMap.cs rename to OpenRA.FileFormats/Map/NewMap.cs index 232ec980f0..5204c60c1d 100644 --- a/OpenRA.FileFormats/NewMap.cs +++ b/OpenRA.FileFormats/Map/NewMap.cs @@ -29,7 +29,7 @@ namespace OpenRA.FileFormats public class NewMap { // General info - public int MapFormat; + public byte MapFormat = 1; public string Title; public string Description; public string Author; @@ -38,6 +38,7 @@ namespace OpenRA.FileFormats // 'Simple' map data public string Tiledata; + public byte TileFormat = 1; public string Tileset; public int2 Size; public int[] Bounds; @@ -85,6 +86,54 @@ namespace OpenRA.FileFormats Rules = yaml["Rules"].Nodes; } + + public void SaveBinaryData(string filepath) + { + + FileStream dataStream = new FileStream(filepath+".tmp", FileMode.Create, FileAccess.Write); + BinaryWriter writer = new BinaryWriter( dataStream ); + writer.BaseStream.Seek(0, SeekOrigin.Begin); + + // File header consists of a version byte, followed by 2 ushorts for width and height + writer.Write(TileFormat); + writer.Write((ushort)Size.X); + writer.Write((ushort)Size.Y); + + // Tile data is stored as a base-64 encoded stream of + // {(2-byte) tile index, (1-byte) image index} pairs + for( int i = 0 ; i < Size.X ; i++ ) + for( int j = 0 ; j < Size.Y ; j++ ) + { + writer.Write( MapTiles[j,i].tile ); + // Semi-hack: Convert clear and water tiles to "pick an image for me" magic number + byte image = (MapTiles[ j, i ].tile == 0xff || MapTiles[ j, i ].tile == 0xffff) ? byte.MaxValue : MapTiles[j,i].image; + writer.Write(image); + } + + + // TODO: Need a proper resources array to write + /* + // Resource data is stored as a base-64 encoded stream of + // {(1-byte) resource index, (1-byte) image index} pairs + for( int i = 0 ; i < Size.X ; i++ ) + for( int j = 0 ; j < Size.Y ; j++ ) + { + byte type = 0; + byte image = 0; + if (MapTiles[j,i].overlay != null) + { + var res = resourceMapping[MapTiles[j,i].overlay]; + type = res.First; + image = res.Second; + } + + writer.Write(type); + writer.Write(image); + } + */ + writer.Flush(); + } + public void DebugContents() { foreach (var field in SimpleFields) diff --git a/OpenRA.FileFormats/Terrain.cs b/OpenRA.FileFormats/Map/Terrain.cs similarity index 100% rename from OpenRA.FileFormats/Terrain.cs rename to OpenRA.FileFormats/Map/Terrain.cs diff --git a/OpenRA.FileFormats/TerrainColorSet.cs b/OpenRA.FileFormats/Map/TerrainColorSet.cs similarity index 100% rename from OpenRA.FileFormats/TerrainColorSet.cs rename to OpenRA.FileFormats/Map/TerrainColorSet.cs diff --git a/OpenRA.FileFormats/TileReference.cs b/OpenRA.FileFormats/Map/TileReference.cs similarity index 100% rename from OpenRA.FileFormats/TileReference.cs rename to OpenRA.FileFormats/Map/TileReference.cs diff --git a/OpenRA.FileFormats/TileSet.cs b/OpenRA.FileFormats/Map/TileSet.cs similarity index 100% rename from OpenRA.FileFormats/TileSet.cs rename to OpenRA.FileFormats/Map/TileSet.cs diff --git a/OpenRA.FileFormats/Walkability.cs b/OpenRA.FileFormats/Map/Walkability.cs similarity index 100% rename from OpenRA.FileFormats/Walkability.cs rename to OpenRA.FileFormats/Map/Walkability.cs diff --git a/OpenRA.FileFormats/OpenRA.FileFormats.csproj b/OpenRA.FileFormats/OpenRA.FileFormats.csproj index 330667f1e9..7b7456337b 100644 --- a/OpenRA.FileFormats/OpenRA.FileFormats.csproj +++ b/OpenRA.FileFormats/OpenRA.FileFormats.csproj @@ -1,4 +1,4 @@ - + Debug @@ -52,56 +52,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + +