private void WaterMap_BTN_Click(object sender, EventArgs e) { image = new Bitmap(512, 512); var idx = MapFormatter.GetIndex("tileinfo", "WaterType"); var temp = (_DatData[2] as object[]).Select(x => (uint)(x as object[])[idx]).ToArray(); for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { switch (temp[x + 256 * y]) { case 1: image.SetPixel(2 * (255 - y) + i, 2 * x + j, Color.LightBlue); break; default: image.SetPixel(2 * (255 - y) + i, 2 * x + j, Color.Green); break; } } } } } pictureBox2.Image = image; }
private void makebitmap(PictureBox box, BitmapType btype) { try { image = new Bitmap(512, 512); if (btype == BitmapType.SMA) { var idx = SmaFormatter.GetIndex("tileinfo", "EventType"); var temp = (_SmaData[1] as object[]).Select(x => (byte)(x as object[])[idx]).ToArray(); for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { image.SetPixel(2 * (255 - y) + i, 2 * x + j, temp[x + 256 * y] == 0 ? Color.LightBlue : Color.Black); } } } } box.Image = image; } if (btype == BitmapType.DAT) { var idx = MapFormatter.GetIndex("tileinfo", "EventType"); var temp = (_DatData[2] as object[]).Select(x => (byte)(x as object[])[idx]).ToArray(); for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { image.SetPixel(2 * (255 - y) + i, 2 * x + j, temp[x + 256 * y] == 0 ? Color.LightBlue : Color.Black); } } } } box.Image = image; } }catch (Exception ex) { ErrorLogger.LogException(ex); } }
private void PadMap_BTN_Click(object sender, EventArgs e) { image = new Bitmap(512, 512); var idx = MapFormatter.GetIndex("tileinfo", "EventType"); var temp = (_DatData[2] as object[]).Select(x => (byte)(x as object[])[idx]).ToArray(); for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { image.SetPixel(2 * (255 - y) + i, 2 * x + j, temp[x + 256 * y] == 0 ? Color.LightBlue : Color.Black); } } } } pictureBox2.Image = image; }
/// <summary> /// Generates an array of map ideces and monster unique numbers /// from dat and sma files. 2017-01-05 panoskj /// </summary> public static object[] SomeQuery() { var dats = Directory.GetFiles(@"..\..\..\map", "*.dat"); var smas = Directory.GetFiles(@"..\..\..\map", "*.sma"); // data from map config var mapcfg = GetMapConfig(@"..\..\..\config\map.cfg"). ToDictionary(x => x.Item1, x => new Tuple <int, int>(x.Item2, x.Item3)); // reads a dat file Func <string, Tuple <int, object> > readDat = (s) => { int idx = int.Parse(Path.GetFileNameWithoutExtension(s)); using (AtumZip.ZippedFile zpf = File.OpenRead(s)) return(new Tuple <int, object>(idx, MapFormatter.Read(zpf.At(0)))); }; // reads a sma file Func <string, Tuple <int, object> > readSma = (s) => { int idx = int.Parse(Path.GetFileNameWithoutExtension(s)); using (var src = File.OpenRead(s)) if (mapcfg.ContainsKey(idx) && mapcfg[idx].Item1 == mapcfg[idx].Item2) { return(new Tuple <int, object>(idx, SmaFormatter.Read(src, (uint)mapcfg[idx].Item1))); } else { return(null); } }; // collects all tables containing spawn information var datmondata = dats.Select(x => readDat(x)).Where(x => x != null). Select(x => new { Index = x.Item1, Data = (x.Item2 as object[])[3] as object[][] }); // collects all tables containing spawn information var smamondata = smas.Select(x => readSma(x)).Where(x => x != null). Select(x => new { Index = x.Item1, Data = (x.Item2 as object[])[2] as object[][] }); // indeces for later use var idx1 = MapFormatter.GetIndex("objectinfo", "ObjectMonsterUniqueNumber"); var idx2 = SmaFormatter.GetIndex("monsterinfo", "Monster Num"); // from each object spawn row of each collected table // select the map index and ObjectMonsterUniqueNumber // if ObjectMonsterUniqueNumber is in range [2000000, 3000000) var res1 = from data in datmondata from spawn in data.Data where (uint)spawn[idx1] >= 2000000 && (uint)spawn[idx1] < 3000000 // or check for EventType == 6 select new { Index = data.Index, Monster = (uint)spawn[idx1] }; // from each monster spawn of each collected table // select the map index and Monster Num // if Monster Num is not 0 var res2 = from data in smamondata from spawn in data.Data where (uint)spawn[idx2] != 0 select new { Index = data.Index, Monster = (uint)spawn[idx2] }; // return the distinct results return(res1.Concat(res2).Distinct().ToArray()); }