public Map(Map clone, Byte newLight) { if (clone == null) return; this.type = clone.type; this.light = newLight; this.misc = clone.misc; this.misc2 = clone.misc2; }
public static void DumpNewTiles() { Dictionary<int, TileInfo> tiles = Global.Instance.Info.Tiles; TileInfo ti; Map useMap = new Map(); useMap.active(true); String tileXML; FileStream stream = new FileStream("newTileXML.txt", FileMode.Create); StreamWriter writer = new StreamWriter(stream); string[] tileNames = null;// Enum.GetNames(typeof(MoreTerra.Enums.TileEnum)); for (int i = 0; i < 420; i++) { if (!tiles.TryGetValue(i, out ti)) { ti = new TileInfo(); ti.name = tileNames[i]; ti.tileImage = i; ti.colorName = "Unknown"; } useMap.type = (ushort)i; tileXML = " <tile "; if (ti.name != null) tileXML = tileXML + "name=\"" + ti.name + "\" "; tileXML = tileXML + "tileImage=\"" + i + "\" "; if (ti.important) tileXML = tileXML + "important=\"true\" "; if (!String.IsNullOrEmpty(ti.colorName)) tileXML = tileXML + "color=\"" + ti.colorName + "\" "; else tileXML = tileXML + String.Format("color=\"#{0:X2}{1:X2}{2:X2}\" ", ti.color.R, ti.color.G, ti.color.B); OfficialColor c = useMap.tileColor(0); if (c == null) c = new OfficialColor(ti.officialColor); tileXML = tileXML + String.Format("officialColor=\"#{0:X2}{1:X2}{2:X2}\" ", c.R, c.G, c.B); if (!String.IsNullOrEmpty(ti.markerName)) tileXML = tileXML + "marker=\"" + ti.markerName + "\" "; tileXML = tileXML + "/>"; writer.WriteLine(tileXML); } writer.Close(); }
public Boolean compare(Map compareTo) { if (this.type != compareTo.type) return false; if (this.light != compareTo.light) return false; if (this.misc != compareTo.misc) return false; if (this.misc2 != compareTo.misc2) return false; return true; }
public static void DumpNewWalls() { Dictionary<int, WallInfo> walls = Global.Instance.Info.Walls; WallInfo wi; Map useMap = new Map(); useMap.wall(true); String tileXML; FileStream stream = new FileStream("newWallXML.txt", FileMode.Create); StreamWriter writer = new StreamWriter(stream); string[] wallNames = null;// Enum.GetNames(typeof(MoreTerra.Enums.WallEnum)); for (int i = 1; i <= 224; i++) { useMap.type = (byte)i; if (!walls.TryGetValue(i, out wi)) { wi = new WallInfo(); wi.name = wallNames[i]; wi.wallImage = i; wi.colorName = "Unknown"; } tileXML = " <wall "; if (wi.name != null) tileXML = tileXML + "name=\"" + wi.name + "\" "; tileXML = tileXML + "wallImage=\"" + i + "\" "; if (!String.IsNullOrEmpty(wi.colorName)) tileXML = tileXML + "color=\"" + wi.colorName + "\" "; else tileXML = tileXML + String.Format("color=\"#{0:X2}{1:X2}{2:X2}\" ", wi.color.R, wi.color.G, wi.color.B); OfficialColor c = useMap.tileColor(0); tileXML = tileXML + String.Format("officialColor=\"#{0:X2}{1:X2}{2:X2}\" ", c.R, c.G, c.B); tileXML = tileXML + "/>"; // <wall name="Blue Dungeon Brick" wallImage="7" unsafe="true" color="Wall Dungeon Blue" /> writer.WriteLine(tileXML); } writer.Close(); }
public static void LoadMap(String mapName, MemoryStream mStream = null) { int maxX, maxY; Map mapTile = null; int RLECount = 0; Boolean active; int i, j; FileStream stream; BinaryReader reader; if (mStream == null) { stream = new FileStream(mapName, FileMode.Open); reader = new BinaryReader(stream); } else { mStream.Position = 0; reader = new BinaryReader(mStream); } Stopwatch sw = new Stopwatch(); sw.Start(); Map.release = reader.ReadInt32(); Map.worldName = reader.ReadString(); Map.worldId = reader.ReadInt32(); Map.maxTilesY = maxY = reader.ReadInt32(); Map.maxTilesX = maxX = reader.ReadInt32(); Map.mapData = new Map[maxX, maxY]; for (i = 0; i < maxX; i++) { for (j = 0; j < maxY; j++) { active = reader.ReadBoolean(); if (active) { mapTile = new Map(); mapTile.type = reader.ReadByte(); mapTile.light = reader.ReadByte(); mapTile.misc = reader.ReadByte(); mapTile.misc2 = reader.ReadByte(); Map.mapData[i, j] = mapTile; RLECount = reader.ReadInt16(); if (RLECount > 0) { if (mapTile.light == 255) { while (RLECount > 0) { j++; Map.mapData[i, j] = new Map(mapTile, 255); RLECount--; } } else { while (RLECount > 0) { j++; Map.mapData[i, j] = new Map(mapTile, reader.ReadByte()); RLECount--; } } } } else { Map.mapData[i, j] = new Map(); // This is wrong but we have to mimic what the offical version does to compare. mapTile = null; j += reader.ReadInt16(); } } } sw.Stop(); reader.Close(); }