From 1914a8adbe0c7be1cba6976f4cf11e859accfc82 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 4 Mar 2010 10:17:59 +1300 Subject: [PATCH] cnc map tib support --- OpenRA.FileFormats/Map.cs | 22 ++++++++++++++++++-- OpenRA.Game/Shroud.cs | 4 +--- OpenRA.Game/Traits/World/ResourceLayer.cs | 6 ++++-- mods/cnc/system.yaml | 25 ++++++++++++++++++++--- mods/cnc/trees.yaml | 6 ++++-- 5 files changed, 51 insertions(+), 12 deletions(-) diff --git a/OpenRA.FileFormats/Map.cs b/OpenRA.FileFormats/Map.cs index bbe274b8d5..c1e9d9db1b 100644 --- a/OpenRA.FileFormats/Map.cs +++ b/OpenRA.FileFormats/Map.cs @@ -86,6 +86,7 @@ namespace OpenRA.FileFormats else // CNC { UnpackCncTileData(FileSystem.Open(filename.Substring(0,filename.Length-4)+".bin")); + ReadCncOverlay(file); ReadCncTrees(file); } @@ -171,7 +172,7 @@ namespace OpenRA.FileFormats } } - static string[] overlaySpriteNames = + static string[] raOverlayNames = { "sbag", "cycl", "brik", "fenc", "wood", "gold01", "gold02", "gold03", "gold04", @@ -186,7 +187,7 @@ namespace OpenRA.FileFormats for( int j = 0 ; j < MapSize ; j++ ) { byte o = ReadByte( ms ); - MapTiles[ j, i ].overlay = (o == 255) ? null : overlaySpriteNames[o]; + MapTiles[ j, i ].overlay = (o == 255) ? null : raOverlayNames[o]; } } @@ -215,7 +216,24 @@ namespace OpenRA.FileFormats MapTiles[ j, i ].image = (byte)( i % 4 + ( j % 4 ) * 4 ); } } + + void ReadCncOverlay( IniFile file ) + { + IniSection overlay = file.GetSection( "OVERLAY", true ); + if( overlay == null ) + return; + + foreach( KeyValuePair kv in overlay ) + { + var loc = int.Parse( kv.Key ); + int2 cell = new int2(loc % MapSize, loc / MapSize); + Log.Write("Overlay {0} at ({1},{2})",kv.Value,cell.X,cell.Y); + MapTiles[ cell.X, cell.Y ].overlay = kv.Value.ToLower(); + } + } + + void ReadCncTrees( IniFile file ) { IniSection terrain = file.GetSection( "TERRAIN", true ); diff --git a/OpenRA.Game/Shroud.cs b/OpenRA.Game/Shroud.cs index cca332c978..d074091040 100644 --- a/OpenRA.Game/Shroud.cs +++ b/OpenRA.Game/Shroud.cs @@ -34,9 +34,7 @@ namespace OpenRA Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow"); Sprite[,] sprites = new Sprite[128, 128]; bool dirty = true; - - // TODO: Testing - bool hasGPS = true; + bool hasGPS = false; Player owner; Map map; public Rectangle? bounds; diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Game/Traits/World/ResourceLayer.cs index 8797ce3336..4ec36e9a9b 100644 --- a/OpenRA.Game/Traits/World/ResourceLayer.cs +++ b/OpenRA.Game/Traits/World/ResourceLayer.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. @@ -35,7 +35,7 @@ namespace OpenRA.Traits World w; public ResourceTypeInfo[] resourceTypes; - CellContents[,] content = new CellContents[128, 128]; + CellContents[,] content; public ResourceLayer(Actor self) { @@ -65,6 +65,8 @@ namespace OpenRA.Traits public void WorldLoaded(World w) { this.w = w; + content = new CellContents[w.Map.MapSize, w.Map.MapSize]; + resourceTypes = w.WorldActor.Info.Traits.WithInterface().ToArray(); foreach (var rt in resourceTypes) rt.Sprites = rt.SpriteNames.Select(a => SpriteSheetBuilder.LoadAllSprites(a)).ToArray(); diff --git a/mods/cnc/system.yaml b/mods/cnc/system.yaml index a819443999..c224da4140 100644 --- a/mods/cnc/system.yaml +++ b/mods/cnc/system.yaml @@ -177,12 +177,31 @@ World: Race: nod SellButton: RepairButton: + ChoosePaletteOnSelect: + WallLoadHook@sbag: + ActorType: sbag + OverlayTypes: sbag + WallLoadHook@cycl: + ActorType: cycl + OverlayTypes: cycl + WallLoadHook@brik: + ActorType: brik + OverlayTypes: brik + WallLoadHook@fenc: + ActorType: fenc + OverlayTypes: fenc + WallLoadHook@wood: + ActorType: wood + OverlayTypes: wood + WallLoadHook@barb: + ActorType: barb + OverlayTypes: barb ResourceLayer: ResourceType@green-tib: - Overlays: 5,6,7,8,9,10,11,12 + Overlays: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12 Palette: player SpriteNames: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12 ValuePerUnit: 30 Name: Tiberium - GrowthInterval: .1 - SpreadInterval: .1 + GrowthInterval: 1 + SpreadInterval: 6 diff --git a/mods/cnc/trees.yaml b/mods/cnc/trees.yaml index 766a6649e9..68abcec4ec 100644 --- a/mods/cnc/trees.yaml +++ b/mods/cnc/trees.yaml @@ -2,13 +2,15 @@ SPLIT2: Inherits: ^Building RenderBuilding: Palette: terrain - SeedsOre: + SeedsResource: + ResourceType:Tiberium -Selectable: SPLIT3: Inherits: ^Building RenderBuilding: Palette: terrain - SeedsOre: + SeedsResource: + ResourceType:Tiberium -Selectable: ROCK1: Inherits: ^Tree