diff --git a/OpenRA.FileFormats/Map.cs b/OpenRA.FileFormats/Map.cs index f179faf619..d42d60ea88 100644 --- a/OpenRA.FileFormats/Map.cs +++ b/OpenRA.FileFormats/Map.cs @@ -32,6 +32,7 @@ namespace OpenRA.FileFormats public readonly string Title; public readonly string Theater; + public readonly int MapSize; public readonly int XOffset; public readonly int YOffset; public int2 Offset { get { return new int2( XOffset, YOffset ); } } @@ -40,7 +41,7 @@ namespace OpenRA.FileFormats public readonly int Height; public int2 Size { get { return new int2(Width, Height); } } - public readonly TileReference[ , ] MapTiles = new TileReference[ 128, 128 ]; + public readonly TileReference[ , ] MapTiles; public readonly List Trees = new List(); public readonly IEnumerable SpawnPoints; @@ -54,10 +55,8 @@ namespace OpenRA.FileFormats public Map(IniFile file) { - for (int j = 0; j < 128; j++) - for (int i = 0; i < 128; i++) - MapTiles[i, j] = new TileReference(); - + + IniSection basic = file.GetSection("Basic"); Title = basic.GetValue("Name", "(null)"); BinaryPart = basic.GetValue("BinaryPart", "scm02ea.bin"); @@ -70,25 +69,45 @@ namespace OpenRA.FileFormats Width = int.Parse(map.GetValue("Width", "0")); Height = int.Parse(map.GetValue("Height", "0")); + if (false) // RA map + { + MapSize = 128; + } + else + { + MapSize = 64; + } + MapTiles = new TileReference[ MapSize, MapSize ]; + for (int j = 0; j < MapSize; j++) + for (int i = 0; i < MapSize; i++) + MapTiles[i, j] = new TileReference(); - //UnpackTileData(ReadPackedSection(file.GetSection("MapPack"))); - //UnpackOverlayData(ReadPackedSection(file.GetSection("OverlayPack"))); - //ReadTrees(file); - UnpackCncTileData(FileSystem.Open(BinaryPart)); + if (false) // RA map + { + UnpackTileData(ReadPackedSection(file.GetSection("MapPack"))); + UnpackOverlayData(ReadPackedSection(file.GetSection("OverlayPack"))); + ReadTrees(file); + + } + else // CNC + { + UnpackBinaryTileData(FileSystem.Open(BinaryPart)); + ReadCncTrees(file); + } SpawnPoints = file.GetSection("Waypoints") - .Select(kv => Pair.New(int.Parse(kv.Key), new int2(int.Parse(kv.Value) % 128, int.Parse(kv.Value) / 128))) - .Where(a => a.First < 8) - .Select(a => a.Second) - .ToArray(); + .Select(kv => Pair.New(int.Parse(kv.Key), new int2(int.Parse(kv.Value) % MapSize, int.Parse(kv.Value) / MapSize))) + .Where(a => a.First < 8) + .Select(a => a.Second) + .ToArray(); } - void UnpackCncTileData( Stream ms ) + void UnpackBinaryTileData( Stream ms ) { - for( int i = 0 ; i < 64 ; i++ ) - for( int j = 0 ; j < 64 ; j++ ) + for( int i = 0 ; i < MapSize ; i++ ) + for( int j = 0 ; j < MapSize ; j++ ) { MapTiles[j, i].tile = (byte)ms.ReadByte(); MapTiles[j, i].image = (byte)ms.ReadByte(); @@ -156,12 +175,12 @@ namespace OpenRA.FileFormats void UnpackTileData( MemoryStream ms ) { - for( int i = 0 ; i < 128 ; i++ ) - for( int j = 0 ; j < 128 ; j++ ) + for( int i = 0 ; i < MapSize ; i++ ) + for( int j = 0 ; j < MapSize ; j++ ) MapTiles[j, i].tile = ReadWord(ms); - for( int i = 0 ; i < 128 ; i++ ) - for( int j = 0 ; j < 128 ; j++ ) + for( int i = 0 ; i < MapSize ; i++ ) + for( int j = 0 ; j < MapSize ; j++ ) { MapTiles[j, i].image = (byte)ms.ReadByte(); if( MapTiles[ j, i ].tile == 0xff || MapTiles[ j, i ].tile == 0xffff ) @@ -171,8 +190,8 @@ namespace OpenRA.FileFormats void UnpackOverlayData( MemoryStream ms ) { - for( int i = 0 ; i < 128 ; i++ ) - for( int j = 0 ; j < 128 ; j++ ) + for( int i = 0 ; i < MapSize ; i++ ) + for( int j = 0 ; j < MapSize ; j++ ) MapTiles[ j, i ].overlay = ReadByte( ms ); } @@ -183,9 +202,20 @@ namespace OpenRA.FileFormats return; foreach( KeyValuePair kv in terrain ) - Trees.Add( new TreeReference( int.Parse( kv.Key ), kv.Value ) ); + Trees.Add( new TreeReference( int.Parse( kv.Key ), kv.Value, MapSize ) ); } + + void ReadCncTrees( IniFile file ) + { + IniSection terrain = file.GetSection( "TERRAIN", true ); + if( terrain == null ) + return; + foreach( KeyValuePair kv in terrain ) + // HACK: remove the ,none from the end + Trees.Add( new TreeReference( int.Parse( kv.Key ), kv.Value.Substring(0,kv.Value.Length-5), MapSize ) ); + } + public bool IsInMap(int x, int y) { return (x >= XOffset && y >= YOffset && x < XOffset + Width && y < YOffset + Height); diff --git a/OpenRA.FileFormats/Session.cs b/OpenRA.FileFormats/Session.cs index 076b24be40..89a896baca 100644 --- a/OpenRA.FileFormats/Session.cs +++ b/OpenRA.FileFormats/Session.cs @@ -47,7 +47,7 @@ namespace OpenRA.FileFormats public class Global { - public string Map = "scm01ea.ini"; + public string Map = "scm02ea.ini"; public string[] Packages = {}; // filename:sha1 pairs. public string[] Mods = { "ra" }; // mod names public int OrderLatency = 3; diff --git a/OpenRA.FileFormats/TileSet.cs b/OpenRA.FileFormats/TileSet.cs index 964809d5b0..6d5b6def43 100644 --- a/OpenRA.FileFormats/TileSet.cs +++ b/OpenRA.FileFormats/TileSet.cs @@ -89,10 +89,9 @@ namespace OpenRA.FileFormats public byte[] GetBytes(TileReference r) { Terrain tile; - try { - if( tiles.TryGetValue( r.tile, out tile ) ) - return tile.TileBitmapBytes[ r.image ]; - } catch (System.ArgumentOutOfRangeException) {} + + if( tiles.TryGetValue( r.tile, out tile ) ) + return tile.TileBitmapBytes[ r.image ]; byte[] missingTile = new byte[ 24 * 24 ]; for( int i = 0 ; i < missingTile.Length ; i++ ) diff --git a/OpenRA.FileFormats/TreeReference.cs b/OpenRA.FileFormats/TreeReference.cs index 24163be6c3..8b54830d19 100644 --- a/OpenRA.FileFormats/TreeReference.cs +++ b/OpenRA.FileFormats/TreeReference.cs @@ -28,10 +28,10 @@ namespace OpenRA.FileFormats public readonly int Y; public readonly string Image; - public TreeReference(int xy, string image) + public TreeReference(int xy, string image, int mapSize) { - X = xy % 128; - Y = xy / 128; + X = xy % mapSize; + Y = xy / mapSize; Image = image; } diff --git a/OpenRA.Game/GameRules/UserSettings.cs b/OpenRA.Game/GameRules/UserSettings.cs index 4fffb5766c..f14383f2f9 100644 --- a/OpenRA.Game/GameRules/UserSettings.cs +++ b/OpenRA.Game/GameRules/UserSettings.cs @@ -39,7 +39,7 @@ namespace OpenRA.GameRules // External game settings public readonly string NetworkHost = ""; public readonly int NetworkPort = 0; - public readonly string Map = "scm01ea.ini"; + public readonly string Map = "scm02ea.ini"; public readonly int Player = 1; public readonly string Replay = ""; public readonly string PlayerName = ""; diff --git a/OpenRA.Game/Graphics/Minimap.cs b/OpenRA.Game/Graphics/Minimap.cs index 8810b58755..3dd872fbbd 100644 --- a/OpenRA.Game/Graphics/Minimap.cs +++ b/OpenRA.Game/Graphics/Minimap.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -93,9 +93,9 @@ namespace OpenRA.Graphics public static Bitmap RenderTerrainBitmap(Map map, TileSet tileset) { var colors = terrainTypeColors[map.Theater.ToLowerInvariant()]; - var terrain = new Bitmap(128, 128); - for (var y = 0; y < 128; y++) - for (var x = 0; x < 128; x++) + var terrain = new Bitmap(map.MapSize, map.MapSize); + for (var y = 0; y < map.MapSize; y++) + for (var x = 0; x < map.MapSize; x++) terrain.SetPixel(x, y, map.IsInMap(x, y) ? colors[tileset.GetWalkability(map.MapTiles[x, y])] : shroudColor); diff --git a/OpenRA.Game/PathFinder.cs b/OpenRA.Game/PathFinder.cs index 0540c6ea59..f4200c1472 100644 --- a/OpenRA.Game/PathFinder.cs +++ b/OpenRA.Game/PathFinder.cs @@ -35,10 +35,11 @@ namespace OpenRA public PathFinder( World world ) { this.world = world; + var map = world.Map; for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++) - passableCost[(int)umt] = new float[128, 128]; - for( int x = 0 ; x < 128 ; x++ ) - for( int y = 0 ; y < 128 ; y++ ) + passableCost[(int)umt] = new float[map.MapSize, map.MapSize]; + for( int x = 0 ; x < map.MapSize ; x++ ) + for( int y = 0 ; y < map.MapSize ; y++ ) for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++ ) passableCost[(int)umt][ x, y ] = ( world.Map.IsInMap( x, y ) ) ? (float)TerrainCosts.Cost( umt, world.TileSet.GetWalkability( world.Map.MapTiles[ x, y ] ) ) diff --git a/OpenRA.Game/Traits/World/UnitInfluence.cs b/OpenRA.Game/Traits/World/UnitInfluence.cs index 1f9fb559d5..7d2eff0287 100644 --- a/OpenRA.Game/Traits/World/UnitInfluence.cs +++ b/OpenRA.Game/Traits/World/UnitInfluence.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -36,8 +36,8 @@ namespace OpenRA.Traits public UnitInfluence( Actor self ) { - for (int i = 0; i < 128; i++) - for (int j = 0; j < 128; j++) + for (int i = 0; i < self.World.Map.MapSize; i++) + for (int j = 0; j < self.World.Map.MapSize; j++) influence[ i, j ] = new List(); self.World.ActorRemoved += a => Remove( a, a.traits.GetOrDefault() ); @@ -73,8 +73,8 @@ namespace OpenRA.Traits [Conditional( "SANITY_CHECKS" )] void SanityCheck( Actor self ) { - for( int y = 0 ; y < 128 ; y++ ) - for( int x = 0 ; x < 128 ; x++ ) + for( int y = 0 ; y < self.World.Map.MapSize ; y++ ) + for( int x = 0 ; x < self.World.Map.MapSize ; x++ ) if( influence[ x, y ] != null ) foreach (var a in influence[ x, y ]) if (!a.traits.Get().OccupiedCells().Contains( new int2( x, y ) ) ) diff --git a/OpenRA.Game/UiOverlay.cs b/OpenRA.Game/UiOverlay.cs index 6e7293f3f9..4a36b6d170 100644 --- a/OpenRA.Game/UiOverlay.cs +++ b/OpenRA.Game/UiOverlay.cs @@ -56,8 +56,8 @@ namespace OpenRA public void Draw( World world ) { if (ShowUnitDebug) - for (var j = 0; j < 128; j++) - for (var i = 0; i < 128; i++) + for (var j = 0; j < world.Map.MapSize; j++) + for (var i = 0; i < world.Map.MapSize; i++) if (world.WorldActor.traits.Get().GetUnitsAt(new int2(i, j)).Any()) spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), "terrain"); } diff --git a/mods/cnc/compat.yaml b/mods/cnc/compat.yaml index 5911658d77..23a66dab33 100644 --- a/mods/cnc/compat.yaml +++ b/mods/cnc/compat.yaml @@ -32,11 +32,3 @@ BR3: Footprint: ____ ____ Dimensions: 4,2 HP: 1000 - -MINE: - Inherits: ^Building - RenderBuilding: - Palette: terrain - SeedsResource: - ResourceType: Tiberium - -Selectable: diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 76711e9ecb..504c74e4e1 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -47,6 +47,7 @@ Sequences: mods/cnc/sequences-structures.xml: mods/cnc/sequences-vehicles.xml: mods/cnc/sequences-infantry.xml: + mods/cnc/sequences-map.xml: mods/cnc/sequences.xml: Obsolete; will disappear once done converting Chrome: diff --git a/mods/cnc/sequences-map.xml b/mods/cnc/sequences-map.xml new file mode 100644 index 0000000000..e9e626bc75 --- /dev/null +++ b/mods/cnc/sequences-map.xml @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mods/cnc/sequences.xml b/mods/cnc/sequences.xml index 4722751583..a2cde9c9e3 100644 --- a/mods/cnc/sequences.xml +++ b/mods/cnc/sequences.xml @@ -85,116 +85,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -210,90 +100,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mods/cnc/trees.yaml b/mods/cnc/trees.yaml index 3899166ed8..3007aab123 100644 --- a/mods/cnc/trees.yaml +++ b/mods/cnc/trees.yaml @@ -1,3 +1,23 @@ +SPLIT3: + Inherits: ^Building + RenderBuilding: + Palette: terrain + SeedsOre: + -Selectable: +ROCK1: + Inherits: ^Tree +ROCK2: + Inherits: ^Tree +ROCK3: + Inherits: ^Tree +ROCK4: + Inherits: ^Tree +ROCK5: + Inherits: ^Tree +ROCK6: + Inherits: ^Tree +ROCK7: + Inherits: ^Tree T01: Inherits: ^Tree @@ -55,7 +75,12 @@ T16: T17: Inherits: ^Tree - + Building: + Footprint: ___ xx_ + Dimensions: 3,2 +T18: + Inherits: ^Tree + TC01: Inherits: ^Tree Building: