From 303613b052ab904e585bea39fc8ad69ef0818aa3 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 15 Sep 2010 19:27:39 +1200 Subject: [PATCH] Create valid maps for custom tilesets --- OpenRA.Editor/Form1.cs | 3 +-- OpenRA.Game/Map.cs | 18 +++++++++++++----- mods/d2k/maps/test/map.bin | Bin 81925 -> 81925 bytes mods/d2k/maps/test/map.uid | 2 +- mods/d2k/maps/test/map.yaml | 18 +----------------- mods/d2k/mod.yaml | 2 +- mods/d2k/tilesets/arrakis.yaml | 7 ------- 7 files changed, 17 insertions(+), 33 deletions(-) diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index b9a387ac59..3a8f98058b 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -362,13 +362,12 @@ namespace OpenRA.Editor if (DialogResult.OK == nmd.ShowDialog()) { - var map = new Map(); + var map = new Map(nmd.theater.SelectedItem as string); map.Resize((int)nmd.width.Value, (int)nmd.height.Value); map.TopLeft = new int2((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value); map.BottomRight = new int2((int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value); - map.Tileset = nmd.theater.SelectedItem as string; map.Players.Add("Neutral", new PlayerReference("Neutral", Rules.Info["world"].Traits.WithInterface().First().Race, true, true)); NewMap(map); } diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index a108bee8c1..cc456aa894 100755 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -62,14 +62,22 @@ namespace OpenRA public Rectangle Bounds { get { return Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y); } } public Map() + { + // Do nothing; not a valid map (editor hack) + } + + public Map(string tileset) { MapSize = new int2(1, 1); + Tileset = tileset; MapResources = new TileReference[1, 1]; - MapTiles = new TileReference[1, 1] - { { new TileReference { - type = (ushort)0xffffu, - image = (byte)0xffu, - index = (byte)0xffu } } }; + + var tile = OpenRA.Rules.TileSets[Tileset].Templates.First(); + MapTiles = new TileReference[1, 1] + { { new TileReference { + type = tile.Key, + image = (byte)(tile.Value.PickAny ? 0xffu : 0), + index = (byte)(tile.Value.PickAny ? 0xffu : 0) } } }; PlayerCount = 0; TopLeft = new int2(0, 0); diff --git a/mods/d2k/maps/test/map.bin b/mods/d2k/maps/test/map.bin index f804ba89a4c60bab6c8c8ccbf5427842528109f2..4d976970b4c67577ef2958dee6cbd7786f260a34 100644 GIT binary patch delta 146 zcmZo|U~O$+WnpY!XxJ=xV51}(4+8@a0~3&4#Rz0G@-Q$%*t`r3yfATI21Z_T#rYT* Y_+aMnF);Fh&G}NlS>eD_5b;q00K51hM*si- literal 81925 zcmeI%ISK$U2n0a$^ZYyq0n3!y%wn