static Map() { Map.Felucca = new Map(0, 0, 6144, 4096); Map.Trammel = new Map(0, 1, 6144, 4096); Map.Ilshenar = new Map(2, 2, 2304, 1600); Map.Malas = new Map(3, 3, 2560, 2048); }
private void malasToolStripMenuItem_Click(object sender, EventArgs e) { if (pictureBox1.Image != null) { pictureBox1.Refresh(); } DrawMap(); facet = Ultima.Map.InitializeMap("Malas"); }
public BlockWriter(int facetId, Map mappa, String apppath, Dictionary<ushort, ushort> grMap) { sw = new StreamWriter(apppath.Replace("Temp\\","") + "error_graphic.log"); this.facetId = facetId; this.apppath = apppath; this.mappa = mappa; this.grMap = grMap; this.mapheight = mappa.Height; this.mapwidth = ((facetId == 0 || facetId == 1) ? 7168 : mappa.Width); }
private void ChangeMapIlshenar(object sender, EventArgs e) { if (!ilshenarToolStripMenuItem.Checked) { ResetCheckedMap(); ilshenarToolStripMenuItem.Checked = true; currmap = Ultima.Map.Ilshenar; currmapint = 2; ChangeMap(); } }
private void ChangeMapTrammel(object sender, EventArgs e) { if (!trammelToolStripMenuItem.Checked) { ResetCheckedMap(); trammelToolStripMenuItem.Checked = true; currmap = Ultima.Map.Trammel; currmapint = 1; ChangeMap(); } }
private void ChangeMapFelucca(object sender, EventArgs e) { if (!feluccaToolStripMenuItem.Checked) { ResetCheckedMap(); feluccaToolStripMenuItem.Checked = true; currmap = Ultima.Map.Felucca; currmapint = 0; ChangeMap(); } }
public MapDiffInsert(Ultima.Map currmap) { InitializeComponent(); this.Icon = FiddlerControls.Options.GetFiddlerIcon(); workingmap = currmap; numericUpDownX1.Maximum = workingmap.Width; numericUpDownX2.Maximum = workingmap.Width; numericUpDownY1.Maximum = workingmap.Height; numericUpDownY2.Maximum = workingmap.Height; this.Text = String.Format("Map Diff Insert ID:{0}",workingmap.FileIndex); }
public MapDiffInsert(Ultima.Map currmap) { InitializeComponent(); this.Icon = FiddlerControls.Options.GetFiddlerIcon(); workingmap = currmap; numericUpDownX1.Maximum = workingmap.Width; numericUpDownX2.Maximum = workingmap.Width; numericUpDownY1.Maximum = workingmap.Height; numericUpDownY2.Maximum = workingmap.Height; this.Text = String.Format("Map Diff Insert ID:{0}", workingmap.FileIndex); }
private void ChangeMapTokuno(object sender, EventArgs e) { if (!tokunoToolStripMenuItem.Checked) { ResetCheckedMap(); tokunoToolStripMenuItem.Checked = true; currmap = Ultima.Map.Tokuno; currmapint = 4; ChangeMap(); } }
private void ChangeMapMalas(object sender, EventArgs e) { if (!malasToolStripMenuItem.Checked) { ResetCheckedMap(); malasToolStripMenuItem.Checked = true; currmap = Ultima.Map.Malas; currmapint = 3; ChangeMap(); } }
private void ChangeMapTerMur(object sender, EventArgs e) { if (!terMurToolStripMenuItem.Checked) { ResetCheckedMap(); terMurToolStripMenuItem.Checked = true; currmap = Ultima.Map.TerMur; currmapint = 5; ChangeMap(); } }
private void OnClickGotoMarker(object sender, EventArgs e) { if (OverlayObjectTree.SelectedNode == null) { return; } if (OverlayObjectTree.SelectedNode.Parent == null) { return; } OverlayObject o = (OverlayObject)OverlayObjectTree.SelectedNode.Tag; if (currmapint != o.DefMap) { ResetCheckedMap(); switch (o.DefMap) { case 0: feluccaToolStripMenuItem.Checked = true; currmap = Ultima.Map.Felucca; break; case 1: trammelToolStripMenuItem.Checked = true; currmap = Ultima.Map.Trammel; break; case 2: ilshenarToolStripMenuItem.Checked = true; currmap = Ultima.Map.Ilshenar; break; case 3: malasToolStripMenuItem.Checked = true; currmap = Ultima.Map.Malas; break; case 4: tokunoToolStripMenuItem.Checked = true; currmap = Ultima.Map.Tokuno; break; case 5: terMurToolStripMenuItem.Checked = true; currmap = Ultima.Map.TerMur; break; } currmapint = o.DefMap; } SetScrollBarValues(); hScrollBar.Value = (int)Math.Max(0, o.Loc.X - pictureBox.Right / Zoom / 2); vScrollBar.Value = (int)Math.Max(0, o.Loc.Y - pictureBox.Bottom / Zoom / 2); pictureBox.Invalidate(); }
private void ChangeMapMalas(object sender, EventArgs e) { if (malasToolStripMenuItem.Checked) { return; } ResetCheckedMap(); malasToolStripMenuItem.Checked = true; _currMap = Ultima.Map.Malas; _currMapInt = 3; ChangeMap(); }
private void ChangeMapIlshenar(object sender, EventArgs e) { if (ilshenarToolStripMenuItem.Checked) { return; } ResetCheckedMap(); ilshenarToolStripMenuItem.Checked = true; _currMap = Ultima.Map.Ilshenar; _currMapInt = 2; ChangeMap(); }
private void ChangeMapTrammel(object sender, EventArgs e) { if (trammelToolStripMenuItem.Checked) { return; } ResetCheckedMap(); trammelToolStripMenuItem.Checked = true; _currMap = Ultima.Map.Trammel; _currMapInt = 1; ChangeMap(); }
private void ChangeMapFelucca(object sender, EventArgs e) { if (feluccaToolStripMenuItem.Checked) { return; } ResetCheckedMap(); feluccaToolStripMenuItem.Checked = true; _currMap = Ultima.Map.Felucca; _currMapInt = 0; ChangeMap(); }
private void ChangeMapTerMur(object sender, EventArgs e) { if (terMurToolStripMenuItem.Checked) { return; } ResetCheckedMap(); terMurToolStripMenuItem.Checked = true; _currMap = Ultima.Map.TerMur; _currMapInt = 5; ChangeMap(); }
private void ChangeMapTokuno(object sender, EventArgs e) { if (tokunoToolStripMenuItem.Checked) { return; } ResetCheckedMap(); tokunoToolStripMenuItem.Checked = true; _currMap = Ultima.Map.Tokuno; _currMapInt = 4; ChangeMap(); }
private static void GetAverageZ(Ultima.Map map, int x, int y, ref int z, ref int avg, ref int top) { try { int zTop = map.Tiles.GetLandTile(x, y).Z; int zLeft = map.Tiles.GetLandTile(x, y + 1).Z; int zRight = map.Tiles.GetLandTile(x + 1, y).Z; int zBottom = map.Tiles.GetLandTile(x + 1, y + 1).Z; z = zTop; if (zLeft < z) { z = zLeft; } if (zRight < z) { z = zRight; } if (zBottom < z) { z = zBottom; } top = zTop; if (zLeft > top) { top = zLeft; } if (zRight > top) { top = zRight; } if (zBottom > top) { top = zBottom; } if (Math.Abs(zTop - zBottom) > Math.Abs(zLeft - zRight)) { avg = (int)Math.Floor((zLeft + zRight) / 2.0); } else { avg = (int)Math.Floor((zTop + zBottom) / 2.0); } } catch { } }
private void PreLoadDoWork(object sender, DoWorkEventArgs e) { Ultima.Map workmap = (Ultima.Map)((Object[])e.Argument)[0]; bool statics = (bool)((Object[])e.Argument)[1]; int width = currmap.Width >> 3; int height = currmap.Height >> 3; for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { currmap.PreloadRenderedBlock(x, y, statics); PreloadWorker.ReportProgress(1); } } }
public static sbyte ZTop(int mapNum, int xCheck, int yCheck, int oldZ) { try { Ultima.Map map = GetMap(mapNum); Tile landTile = map.Tiles.GetLandTile(xCheck, yCheck); int landZ = 0, landCenter = 0, zTop = 0; GetAverageZ(map, xCheck, yCheck, ref landZ, ref landCenter, ref zTop); if (zTop > oldZ) { oldZ = zTop; } bool isSet = false; HuedTile[] staticTiles = map.Tiles.GetStaticTiles(xCheck, yCheck); for (int i = 0; i < staticTiles.Length; ++i) { HuedTile tile = staticTiles[i]; ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; int calcTop = (tile.Z + id.CalcHeight); if (calcTop <= oldZ + 5 && (!isSet || calcTop > zTop) && ((id.Flags & TileFlag.Surface) != 0 || (id.Flags & TileFlag.Wet) != 0)) { zTop = calcTop; isSet = true; } } return((sbyte)zTop); } catch { return((sbyte)oldZ); } }
private void DrawMap() { if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); } pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(pictureBox1.Image); //4704>>3, 3747>>3 if (facet == null) { facet = Ultima.Map.InitializeMap("Felucca"); } g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; g.PageUnit = GraphicsUnit.Pixel; g.DrawImage(facet.GetImage(x >> 3, y >> 3, pictureBox1.Width >> 3, pictureBox1.Height >> 3, true), 0, 0); g.Dispose(); pictureBox1.Refresh(); }
public MapReplace(Ultima.Map currmap) { InitializeComponent(); this.Icon = FiddlerControls.Options.GetFiddlerIcon(); workingmap = currmap; numericUpDownX1.Maximum = workingmap.Width; numericUpDownX2.Maximum = workingmap.Width; numericUpDownY1.Maximum = workingmap.Height; numericUpDownY2.Maximum = workingmap.Height; numericUpDownToX1.Maximum = workingmap.Width; numericUpDownToY1.Maximum = workingmap.Height; this.Text = String.Format("MapReplace ID:{0}", workingmap.FileIndex); comboBoxMapID.BeginUpdate(); comboBoxMapID.Items.Add(new R_FeluccaOld()); comboBoxMapID.Items.Add(new R_Felucca()); comboBoxMapID.Items.Add(new R_Trammel()); comboBoxMapID.Items.Add(new R_Ilshenar()); comboBoxMapID.Items.Add(new R_Malas()); comboBoxMapID.Items.Add(new R_Tokuno()); comboBoxMapID.Items.Add(new R_TerMur()); comboBoxMapID.EndUpdate(); comboBoxMapID.SelectedIndex = 0; }
public MapReplace(Ultima.Map currmap) { InitializeComponent(); this.Icon = FiddlerControls.Options.GetFiddlerIcon(); workingmap = currmap; numericUpDownX1.Maximum = workingmap.Width; numericUpDownX2.Maximum = workingmap.Width; numericUpDownY1.Maximum = workingmap.Height; numericUpDownY2.Maximum = workingmap.Height; numericUpDownToX1.Maximum = workingmap.Width; numericUpDownToY1.Maximum = workingmap.Height; this.Text = String.Format("MapReplace ID:{0}",workingmap.FileIndex); comboBoxMapID.BeginUpdate(); comboBoxMapID.Items.Add(new R_FeluccaOld()); comboBoxMapID.Items.Add(new R_Felucca()); comboBoxMapID.Items.Add(new R_Trammel()); comboBoxMapID.Items.Add(new R_Ilshenar()); comboBoxMapID.Items.Add(new R_Malas()); comboBoxMapID.Items.Add(new R_Tokuno()); comboBoxMapID.Items.Add(new R_TerMur()); comboBoxMapID.EndUpdate(); comboBoxMapID.SelectedIndex = 0; }
public static HuedTile GetTileNear(int mapNum, int x, int y, int z) { try { Ultima.Map map = GetMap(mapNum); HuedTile[] tiles = map.Tiles.GetStaticTiles(x, y); if (tiles != null && tiles.Length > 0) { for (int i = 0; i < tiles.Length; i++) { if (tiles[i].Z >= z - 5 && tiles[i].Z <= z + 5) { return(tiles[i]); } } } } catch { } return(new HuedTile(0, 0, (sbyte)z)); }
internal static HuedTile GetTileNear(int mapNum, int x, int y, int z) { try { Ultima.Map map = GetMap(mapNum); HuedTile[] tiles = map.Tiles.GetStaticTiles(x, y); if (tiles != null && tiles.Length > 0) { foreach (HuedTile tile in tiles) { if (tile.Z >= z - 5 && tile.Z <= z + 5) { return(tile); } } } } catch { } return(new HuedTile(0, 0, (sbyte)z)); }
private void onClick_GotoClientLoc(object sender, EventArgs e) { int x = 0; int y = 0; int z = 0; int mapClient = 0; if (!Ultima.Client.Running) return; Ultima.Client.Calibrate(); if (!Ultima.Client.FindLocation(ref x, ref y, ref z, ref mapClient)) return; if (currmapint != mapClient) { ResetCheckedMap(); switch (mapClient) { case 0: feluccaToolStripMenuItem.Checked = true; currmap = Ultima.Map.Felucca; break; case 1: trammelToolStripMenuItem.Checked = true; currmap = Ultima.Map.Trammel; break; case 2: ilshenarToolStripMenuItem.Checked = true; currmap = Ultima.Map.Ilshenar; break; case 3: malasToolStripMenuItem.Checked = true; currmap = Ultima.Map.Malas; break; case 4: tokunoToolStripMenuItem.Checked = true; currmap = Ultima.Map.Tokuno; break; case 5: terMurToolStripMenuItem.Checked = true; currmap = Ultima.Map.TerMur; break; } currmapint = mapClient; } ClientX = x; ClientY = y; ClientZ = z; ClientMap = mapClient; SetScrollBarValues(); hScrollBar.Value = (int)Math.Max(0, x - pictureBox.Right / Zoom / 2); vScrollBar.Value = (int)Math.Max(0, y - pictureBox.Bottom / Zoom / 2); pictureBox.Invalidate(); ClientLocLabel.Text = String.Format("ClientLoc: {0},{1},{2},{3}", x, y, z, Options.MapNames[mapClient]); }
private static void ResetMaps() { if (Compatibility) { MyFelucca = Map.Felucca; MyTrammel = Map.Trammel; } else { MyFelucca = new Map(0, 0, 7168, 4096); MyTrammel = new Map(1, 1, 7168, 4096); } Ultima.Map.Reload(); }
/// <summary> /// Generate in memmory new Facet from map & statics mul files /// </summary> /// <param name="map">source map for generating facet</param> /// <param name="algorithm">type of algorithm which will be used for converting map to facet</param> public unsafe Facet(Map map, FacetGenAlgorithm algorithm) { if (map == null) throw new ArgumentNullException(); m_Width = map.Width; m_Height = map.Height; m_FileIndex = map.FileIndex; m_FileName = Files.GetFilePath(String.Format("facet{0:D2}.mul", FileIndex)); #region FacetGenAlgorithm.UltimaMap if (algorithm == FacetGenAlgorithm.UltimaMap) { Bitmap bmp = map.GetImage(0, 0, Width, Height, true); m_Bitmap = bmp.Clone(new Rectangle(0, 0, Width, Height), PixelFormat.Format16bppRgb555); bmp.Dispose(); return; } #endregion FacetGenAlgorithm.UltimaMap m_Bitmap = new Bitmap(Width, Height, PixelFormat.Format16bppRgb555); BitmapData data = m_Bitmap.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.WriteOnly, PixelFormat.Format16bppRgb555); ushort* cur = (ushort*)data.Scan0; int stride = data.Stride >> 1; switch (algorithm) { #region FacetGenAlgorithm.Simple case FacetGenAlgorithm.Simple: { TileMatrix matrix = new TileMatrix(FileIndex, FileIndex, Width, Height, null); int blocklength = Width >> 3; Tile[][] land = new Tile[blocklength][]; HuedTile[][][][] item = new HuedTile[blocklength][][][]; HuedTileComparer comparator = new HuedTileComparer(); for (int h = 0; h < (Height >> 3); ++h) { for (int b = 0; b < blocklength; ++b) { land[b] = matrix.GetLandBlock(b, h); item[b] = matrix.GetStaticBlock(b, h); } for (int y = 0; y < 8; ++y) { int i = -1; for (int b = 0; b < blocklength; ++b) { for (int x = 0; x < 8; ++x) { Tile landtile = land[b][(y << 3) + x]; HuedTile[] itemtile = item[b][x][y]; if (itemtile == null || itemtile.Length == 0) { if (Array.BinarySearch(nodrawland, landtile.ID) < 0) cur[++i] = (ushort)RadarCol.Colors[landtile.ID]; else cur[++i] = 0x0000; continue; } Array.Sort(itemtile, comparator); cur[++i] = itemtile[0].Z < landtile.Z ? (ushort)RadarCol.Colors[landtile.ID] : (ushort)RadarCol.Colors[0x4000 + itemtile[0].ID]; if (cur[i] == 0x0421 || cur[i] == 0x0000) if (Array.BinarySearch(nodrawland, landtile.ID) < 0) cur[++i] = (ushort)RadarCol.Colors[landtile.ID]; else cur[++i] = 0x0000; } } cur += stride; } } break; } #endregion FacetGenAlgorithm.Simple #region FacetGenAlgorithm.AltMask case FacetGenAlgorithm.AltMask: { TileMatrix matrix = new TileMatrix(FileIndex, FileIndex, Width, Height, null); int blocklength = Width >> 3; Tile[][] land = new Tile[blocklength][]; HuedTile[][][][] item = new HuedTile[blocklength][][][]; HuedTileComparer comparator = new HuedTileComparer(); for (int h = 0; h < (Height >> 3); ++h) { for (int b = 0; b < blocklength; ++b) { land[b] = matrix.GetLandBlock(b, h); item[b] = matrix.GetStaticBlock(b, h); } matrix.Dispose(); for (int y = 0; y < 8; ++y) { int i = -1; for (int b = 0; b < blocklength; ++b) { for (int x = 0; x < 8; ++x) { Tile landtile = land[b][(y << 3) + x]; HuedTile[] itemtile = item[b][x][y]; bool drawland = false; if (itemtile == null || itemtile.Length == 0) { if (Array.BinarySearch(nodrawland, landtile.ID) >= 0) cur[++i] = 0x0000; else { cur[++i] = (ushort)RadarCol.Colors[landtile.ID]; drawland = true; } } else { Array.Sort(itemtile, comparator); ushort landcolor = (ushort)RadarCol.Colors[landtile.ID]; ushort itemcolor = 0x0000; int iu = 0; for (int u = 0; u < itemtile.Length; ++u) { iu = u; if (Array.BinarySearch(nodrawitem, itemtile[u].ID) >= 0) continue; itemcolor = (ushort)RadarCol.Colors[0x4000 + itemtile[u].ID]; if (itemcolor == 0x0000 || itemcolor == 0x0421) if ((u + 1 < itemtile.Length) && (itemtile[u].Z >= landtile.Z)) continue; else { itemcolor = 0x0000; break; } break; } if (itemcolor == 0x0000 || itemtile[iu].Z < landtile.Z) { if (Array.BinarySearch(nodrawland, landtile.ID) >= 0) cur[++i] = 0x0000; else { cur[++i] = landcolor; drawland = true; } } else cur[++i] = itemcolor; } if (drawland && ((TileData.LandTable[landtile.ID].Flags & TileFlag.Wet) == 0)) { short inc = (short)(0 - (landtile.Z / 20)); short maskR = (short)(((cur[i] & 0x7C00) >> 10) + inc); maskR = Math.Min(Math.Max((short)0x00, maskR), (short)0x1F); short maskG = (short)(((cur[i] & 0x03E0) >> 5) + inc); maskG = Math.Min(Math.Max((short)0x00, maskG), (short)0x1F); short maskB = (short)(((cur[i] & 0x001F) >> 0) + inc); maskB = Math.Min(Math.Max((short)0x00, maskB), (short)0x1F); cur[i] = (ushort)((maskR << 10) | (maskG << 5) | (maskB << 0)); } else { ushort maskR = (ushort)((cur[i] & 0x7C00) >> 10); if (maskR > 0) --maskR; ushort maskG = (ushort)((cur[i] & 0x03E0) >> 5); if (maskG > 0) --maskG; ushort maskB = (ushort)((cur[i] & 0x001F) >> 0); if (maskB > 0) --maskB; cur[i] = (ushort)((maskR << 10) | (maskG << 5) | (maskB << 0)); } } } cur += stride; } } break; } #endregion FacetGenAlgorithm.AltMask #region FacetGenAlgorithm.AltMaskNoise case FacetGenAlgorithm.AltMaskNoise: { Random random = new Random(); TileMatrix matrix = new TileMatrix(FileIndex, FileIndex, Width, Height, null); int blocklength = Width >> 3; Tile[][] land = new Tile[blocklength][]; HuedTile[][][][] item = new HuedTile[blocklength][][][]; HuedTileComparer comparator = new HuedTileComparer(); for (int h = 0; h < (Height >> 3); ++h) { for (int b = 0; b < blocklength; ++b) { land[b] = matrix.ReadLandBlock(b, h); item[b] = matrix.ReadStaticBlock(b, h); } for (int y = 0; y < 8; ++y) { int i = -1; for (int b = 0; b < blocklength; ++b) { for (int x = 0; x < 8; ++x) { Tile landtile = land[b][(y << 3) + x]; HuedTile[] itemtile = item[b][x][y]; bool drawland = false; if (itemtile == null || itemtile.Length == 0) { if (Array.BinarySearch(nodrawland, landtile.ID) >= 0) cur[++i] = 0x0000; else { cur[++i] = (ushort)RadarCol.Colors[landtile.ID]; drawland = true; } } else { Array.Sort(itemtile, comparator); ushort landcolor = (ushort)RadarCol.Colors[landtile.ID]; ushort itemcolor = 0x0000; int iu = 0; for (int u = 0; u < itemtile.Length; ++u) { iu = u; if (Array.BinarySearch(nodrawitem, itemtile[u].ID) >= 0) continue; itemcolor = (ushort)RadarCol.Colors[0x4000 + itemtile[u].ID]; if (itemcolor == 0x0000 || itemcolor == 0x0421 ) if ((u + 1 < itemtile.Length) && (itemtile[u].Z >= landtile.Z)) continue; else { itemcolor = 0x0000; break; } break; } if (itemcolor == 0x0000 || itemtile[iu].Z < landtile.Z) { if (Array.BinarySearch(nodrawland, landtile.ID) >= 0) cur[++i] = 0x0000; else { cur[++i] = landcolor; drawland = true; } } else cur[++i] = itemcolor; } if (drawland && ((TileData.LandTable[landtile.ID].Flags & TileFlag.Wet) == 0)) { short inc = (short)(0 - (landtile.Z / 25)); short maskR = (short)(((cur[i] & 0x7C00) >> 10) + inc); short maskG = (short)(((cur[i] & 0x03E0) >> 5) + inc); short maskB = (short)(((cur[i] & 0x001F) >> 0) + inc); inc = (short)(random.Next(-1, 2)); maskR += inc; inc = (short)(random.Next(-1, 2)); maskG += inc; inc = (short)(random.Next(-1, 2)); maskB += inc; maskR = Math.Min(Math.Max((short)0x00, maskR), (short)0x1F); maskG = Math.Min(Math.Max((short)0x00, maskG), (short)0x1F); maskB = Math.Min(Math.Max((short)0x00, maskB), (short)0x1F); cur[i] = (ushort)((maskR << 10) | (maskG << 5) | (maskB << 0)); } else { ushort maskR = (ushort)((cur[i] & 0x7C00) >> 10); if (maskR > 0) --maskR; ushort maskG = (ushort)((cur[i] & 0x03E0) >> 5); if (maskG > 0) --maskG; ushort maskB = (ushort)((cur[i] & 0x001F) >> 0); if (maskB > 0) --maskB; cur[i] = (ushort)((maskR << 10) | (maskG << 5) | (maskB << 0)); } } } cur += stride; } } break; } #endregion FacetGenAlgorithm.AltMaskNoise #region FacetGenAlgorithm.Improved case FacetGenAlgorithm.Improved: { Random random = new Random(); TileMatrix matrix = new TileMatrix(FileIndex, FileIndex, Width, Height, null); int blocklength = Width >> 3; Tile[][] land = new Tile[blocklength][]; HuedTile[][][][] item = new HuedTile[blocklength][][][]; HuedTileComparer comparator = new HuedTileComparer(); for (int h = 0; h < (Height >> 3); ++h) { for (int b = 0; b < blocklength; ++b) { land[b] = matrix.GetLandBlock(b, h); item[b] = matrix.GetStaticBlock(b, h); } for (int y = 0; y < 8; ++y) { int i = -1; for (int b = 0; b < blocklength; ++b) { for (int x = 0; x < 8; ++x) { Tile landtile = land[b][(y << 3) + x]; HuedTile[] itemtile = item[b][x][y]; bool drawland = false; if (itemtile == null || itemtile.Length == 0) { cur[++i] = (ushort)RadarCol.Colors[landtile.ID]; drawland = true; } else { Array.Sort(itemtile, comparator); ushort landcolor = (ushort)RadarCol.Colors[landtile.ID]; ushort itemcolor = 0x0000; int iu = 0; for (int u = 0; u < itemtile.Length; ++u) { iu = u; itemcolor = (ushort)RadarCol.Colors[0x4000 + itemtile[u].ID]; if (itemcolor == 0x0000 || itemcolor == 0x0421) if ((u + 1 < itemtile.Length) && (itemtile[u].Z >= landtile.Z)) continue; else { itemcolor = 0x0000; break; } break; } if (itemcolor == 0x0000 || itemtile[iu].Z < landtile.Z) { cur[++i] = landcolor; drawland = true; } else cur[++i] = itemcolor; } if (drawland) { short inc = (short)(0 - (landtile.Z / 20)); // inc *= 3; if (inc == 0) switch (random.Next(0, 2)) { case 0: inc = -1; break; case 1: inc = 1; break; } short dir = (short)((inc >= 0) ? 1 : -1); short maskR = (short)((cur[i] & 0x7C00) >> 10); short maskG = (short)((cur[i] & 0x03E0) >> 5); short maskB = (short)((cur[i] & 0x001F) >> 0); for (short rand = 0; rand < dir * inc; ++rand) switch (random.Next(0, 3)) { case 0: maskR += dir; break; case 1: maskG += dir; break; case 2: maskB += dir; break; } maskR = Math.Min(Math.Max((short)0x00, maskR), (short)0x1F); maskG = Math.Min(Math.Max((short)0x00, maskG), (short)0x1F); maskB = Math.Min(Math.Max((short)0x00, maskB), (short)0x1F); /* short maskR = (short)(((cur[i] & 0x7C00) >> 10) + inc); maskR = Math.Min(Math.Max((short)0x00, maskR), (short)0x1F); short maskG = (short)(((cur[i] & 0x03E0) >> 5) + inc); maskG = Math.Min(Math.Max((short)0x00, maskG), (short)0x1F); short maskB = (short)(((cur[i] & 0x001F) >> 0) + inc); maskB = Math.Min(Math.Max((short)0x00, maskB), (short)0x1F); */ cur[i] = (ushort)((maskR << 10) | (maskG << 5) | (maskB << 0)); } else { ushort maskR = (ushort)((cur[i] & 0x7C00) >> 10); if (maskR > 0) --maskR; ushort maskG = (ushort)((cur[i] & 0x03E0) >> 5); if (maskG > 0) --maskG; ushort maskB = (ushort)((cur[i] & 0x001F) >> 0); if (maskB > 0) --maskB; cur[i] = (ushort)((maskR << 10) | (maskG << 5) | (maskB << 0)); } } } cur += stride; } } break; } #endregion FacetGenAlgorithm.Improved } m_Bitmap.UnlockBits(data); }
/// <summary> /// Generate in memmory new Facet from map & statics mul files /// More fast and much less memmory needed than Map.GetImage() /// </summary> /// <param name="map">source map for generating facet</param> public Facet(Map map) : this(map, FacetGenAlgorithm.Simple) { }
private void OnClickGotoClient(object sender, EventArgs e) { int x = 0; int y = 0; int z = 0; int mapClient = 0; if (!Ultima.Client.Running) { return; } Ultima.Client.Calibrate(); if (!Ultima.Client.FindLocation(ref x, ref y, ref z, ref mapClient)) { return; } if (currmapint != mapClient) { ResetCheckedMap(); switch (mapClient) { case 0: feluccaToolStripMenuItem.Checked = true; currmap = Ultima.Map.Felucca; break; case 1: trammelToolStripMenuItem.Checked = true; currmap = Ultima.Map.Trammel; break; case 2: ilshenarToolStripMenuItem.Checked = true; currmap = Ultima.Map.Ilshenar; break; case 3: malasToolStripMenuItem.Checked = true; currmap = Ultima.Map.Malas; break; case 4: tokunoToolStripMenuItem.Checked = true; currmap = Ultima.Map.Tokuno; break; case 5: terMurToolStripMenuItem.Checked = true; currmap = Ultima.Map.TerMur; break; } currmapint = mapClient; } clientcursor.X = x; clientcursor.Y = y; clientcursor.Z = z; clientcursor.IntMap = mapClient; clientcursor.Map = currmap; SetScrollBarValues(); hScrollBar.Value = (int)Math.Max(0, x - pictureBox.Width / Zoom / 2); vScrollBar.Value = (int)Math.Max(0, y - pictureBox.Height / Zoom / 2); pictureBox.Invalidate(); ClientLocLabel.Text = String.Format("ClientLoc: {0},{1},{2},{3}", x, y, z, FiddlerControls.Options.MapNames[mapClient]); }
public MapCombine(Ultima.Map currmap) { InitializeComponent(); textBoxPath0.Text = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; }
private void OnClickGotoMarker(object sender, EventArgs e) { if (OverlayObjectTree.SelectedNode == null) return; if (OverlayObjectTree.SelectedNode.Parent == null) return; OverlayObject o = (OverlayObject)OverlayObjectTree.SelectedNode.Tag; if (currmapint != o.DefMap) { ResetCheckedMap(); switch (o.DefMap) { case 0: feluccaToolStripMenuItem.Checked = true; currmap = Ultima.Map.Felucca; break; case 1: trammelToolStripMenuItem.Checked = true; currmap = Ultima.Map.Trammel; break; case 2: ilshenarToolStripMenuItem.Checked = true; currmap = Ultima.Map.Ilshenar; break; case 3: malasToolStripMenuItem.Checked = true; currmap = Ultima.Map.Malas; break; case 4: tokunoToolStripMenuItem.Checked = true; currmap = Ultima.Map.Tokuno; break; case 5: terMurToolStripMenuItem.Checked = true; currmap = Ultima.Map.TerMur; break; } currmapint = o.DefMap; } SetScrollBarValues(); hScrollBar.Value = (int)Math.Max(0, o.Loc.X - pictureBox.Right / Zoom / 2); vScrollBar.Value = (int)Math.Max(0, o.Loc.Y - pictureBox.Bottom / Zoom / 2); pictureBox.Invalidate(); }
public MapReplaceTiles(Ultima.Map map) { InitializeComponent(); Map = map; }
private void OnLoad(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; LoadMapOverlays(); Options.LoadedUltimaClass["Map"] = true; Options.LoadedUltimaClass["RadarColor"] = true; currmap = Ultima.Map.Felucca; feluccaToolStripMenuItem.Checked = true; trammelToolStripMenuItem.Checked = false; ilshenarToolStripMenuItem.Checked = false; malasToolStripMenuItem.Checked = false; tokunoToolStripMenuItem.Checked = false; PreloadMap.Visible = true; ChangeMapNames(); ZoomLabel.Text = String.Format("Zoom: {0}", Zoom); SetScrollBarValues(); Refresh(); pictureBox.Invalidate(); Cursor.Current = Cursors.Default; if (!Loaded) { FiddlerControls.Events.MapDiffChangeEvent += new FiddlerControls.Events.MapDiffChangeHandler(OnMapDiffChangeEvent); FiddlerControls.Events.MapNameChangeEvent += new FiddlerControls.Events.MapNameChangeHandler(OnMapNameChangeEvent); FiddlerControls.Events.MapSizeChangeEvent += new FiddlerControls.Events.MapSizeChangeHandler(OnMapSizeChangeEvent); FiddlerControls.Events.FilePathChangeEvent += new FiddlerControls.Events.FilePathChangeHandler(OnFilePathChangeEvent); } Loaded = true; }
private void OnClick_GotoClientLoc(object sender, EventArgs e) { int x = 0; int y = 0; int z = 0; int mapClient = 0; if (!Client.Running) { return; } Client.Calibrate(); if (!Client.FindLocation(ref x, ref y, ref z, ref mapClient)) { return; } if (_currMapInt != mapClient) { ResetCheckedMap(); switch (mapClient) { case 0: feluccaToolStripMenuItem.Checked = true; _currMap = Ultima.Map.Felucca; break; case 1: trammelToolStripMenuItem.Checked = true; _currMap = Ultima.Map.Trammel; break; case 2: ilshenarToolStripMenuItem.Checked = true; _currMap = Ultima.Map.Ilshenar; break; case 3: malasToolStripMenuItem.Checked = true; _currMap = Ultima.Map.Malas; break; case 4: tokunoToolStripMenuItem.Checked = true; _currMap = Ultima.Map.Tokuno; break; case 5: terMurToolStripMenuItem.Checked = true; _currMap = Ultima.Map.TerMur; break; } _currMapInt = mapClient; } _clientX = x; _clientY = y; _clientZ = z; _clientMap = mapClient; SetScrollBarValues(); hScrollBar.Value = (int)Math.Max(0, x - pictureBox.Right / Zoom / 2); vScrollBar.Value = (int)Math.Max(0, y - pictureBox.Bottom / Zoom / 2); pictureBox.Invalidate(); ClientLocLabel.Text = $"ClientLoc: {x},{y},{z},{Options.MapNames[mapClient]}"; }
private void OnLoad(object sender, EventArgs e) { int y = Ultima.Map.Trammel.Width; Cursor.Current = Cursors.WaitCursor; LoadMapOverlays(); Options.LoadedUltimaClass["Map"] = true; Options.LoadedUltimaClass["RadarColor"] = true; currmap = Ultima.Map.Sosaria; //currmap = Ultima.Map.Britania; feluccaToolStripMenuItem.Checked = false; trammelToolStripMenuItem.Checked = true; ilshenarToolStripMenuItem.Checked = false; malasToolStripMenuItem.Checked = false; tokunoToolStripMenuItem.Checked = false; PreloadMap.Visible = true; ChangeMapNames(); ZoomLabel.Text = String.Format("Масштаб: {0}%", 100 * Zoom); SetScrollBarValues(); Refresh(); pictureBox.Invalidate(); //OnClickSwitchFacetMap(this, new EventArgs()); // Переключаем на показ Facet по умолчанию if (currmap == Ultima.Map.Sosaria && Ultima.Map.Sosaria.Width == 12288) { // Скролим к форту Бронби при открытии карты Соссарии hScrollBar.Value = (int)Math.Max(0, 7215 - pictureBox.Right / Zoom / 2); vScrollBar.Value = (int)Math.Max(0, 3115 - pictureBox.Bottom / Zoom / 2); } Cursor.Current = Cursors.Default; if (!Loaded) { FiddlerControls.Events.MapDiffChangeEvent += new FiddlerControls.Events.MapDiffChangeHandler(OnMapDiffChangeEvent); FiddlerControls.Events.MapNameChangeEvent += new FiddlerControls.Events.MapNameChangeHandler(OnMapNameChangeEvent); FiddlerControls.Events.MapSizeChangeEvent += new FiddlerControls.Events.MapSizeChangeHandler(OnMapSizeChangeEvent); FiddlerControls.Events.FilePathChangeEvent += new FiddlerControls.Events.FilePathChangeHandler(OnFilePathChangeEvent); } Loaded = true; }
public static void DefragStatics(string path, Map map, int width, int height, bool remove) { string indexPath = Files.GetFilePath("staidx{0}.mul", map.FileIndex); FileStream m_Index; BinaryReader m_IndexReader; if (indexPath != null) { m_Index = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read); m_IndexReader = new BinaryReader(m_Index); } else return; string staticsPath = Files.GetFilePath("statics{0}.mul", map.FileIndex); FileStream m_Statics; BinaryReader m_StaticsReader; if (staticsPath != null) { m_Statics = new FileStream(staticsPath, FileMode.Open, FileAccess.Read, FileShare.Read); m_StaticsReader = new BinaryReader(m_Statics); } else return; int blockx = width >> 3; int blocky = height >> 3; string idx = Path.Combine(path, String.Format("staidx{0}.mul", map.FileIndex)); string mul = Path.Combine(path, String.Format("statics{0}.mul", map.FileIndex)); using (FileStream fsidx = new FileStream(idx, FileMode.Create, FileAccess.Write, FileShare.Write), fsmul = new FileStream(mul, FileMode.Create, FileAccess.Write, FileShare.Write)) { MemoryStream memidx = new MemoryStream(); MemoryStream memmul = new MemoryStream(); using (BinaryWriter binidx = new BinaryWriter(memidx), binmul = new BinaryWriter(memmul)) { for (int x = 0; x < blockx; ++x) { for (int y = 0; y < blocky; ++y) { try { m_IndexReader.BaseStream.Seek(((x * blocky) + y) * 12, SeekOrigin.Begin); int lookup = m_IndexReader.ReadInt32(); int length = m_IndexReader.ReadInt32(); int extra = m_IndexReader.ReadInt32(); if (((lookup < 0 || length <= 0) && (!map.Tiles.PendingStatic(x, y))) || (map.Tiles.IsStaticBlockRemoved(x, y))) { binidx.Write((int)-1); // lookup binidx.Write((int)-1); // length binidx.Write((int)-1); // extra } else { if ((lookup >= 0) && (length > 0)) m_Statics.Seek(lookup, SeekOrigin.Begin); int fsmullength = (int)binmul.BaseStream.Position; int count = length / 7; if (!remove) //without duplicate remove { bool firstitem = true; for (int i = 0; i < count; ++i) { ushort graphic = m_StaticsReader.ReadUInt16(); byte sx = m_StaticsReader.ReadByte(); byte sy = m_StaticsReader.ReadByte(); sbyte sz = m_StaticsReader.ReadSByte(); short shue = m_StaticsReader.ReadInt16(); if ((graphic >= 0) && (graphic <= Art.GetMaxItemID())) { if (shue < 0) shue = 0; if (firstitem) { binidx.Write((int)binmul.BaseStream.Position); //lookup firstitem = false; } binmul.Write(graphic); binmul.Write(sx); binmul.Write(sy); binmul.Write(sz); binmul.Write(shue); } } StaticTile[] tilelist = map.Tiles.GetPendingStatics(x, y); if (tilelist != null) { for (int i = 0; i < tilelist.Length; ++i) { if ((tilelist[i].m_ID >= 0) && (tilelist[i].m_ID <= Art.GetMaxItemID())) { if (tilelist[i].m_Hue < 0) tilelist[i].m_Hue = 0; if (firstitem) { binidx.Write((int)binmul.BaseStream.Position); //lookup firstitem = false; } binmul.Write(tilelist[i].m_ID); binmul.Write(tilelist[i].m_X); binmul.Write(tilelist[i].m_Y); binmul.Write(tilelist[i].m_Z); binmul.Write(tilelist[i].m_Hue); } } } } else //with duplicate remove { StaticTile[] tilelist = new StaticTile[count]; int j = 0; for (int i = 0; i < count; ++i) { StaticTile tile = new StaticTile(); tile.m_ID = m_StaticsReader.ReadUInt16(); tile.m_X = m_StaticsReader.ReadByte(); tile.m_Y = m_StaticsReader.ReadByte(); tile.m_Z = m_StaticsReader.ReadSByte(); tile.m_Hue = m_StaticsReader.ReadInt16(); if ((tile.m_ID >= 0) && (tile.m_ID <= Art.GetMaxItemID())) { if (tile.m_Hue < 0) tile.m_Hue = 0; bool first = true; for (int k = 0; k < j; ++k) { if ((tilelist[k].m_ID == tile.m_ID) && ((tilelist[k].m_X == tile.m_X) && (tilelist[k].m_Y == tile.m_Y)) && (tilelist[k].m_Z == tile.m_Z) && (tilelist[k].m_Hue == tile.m_Hue)) { first = false; break; } } if (first) { tilelist[j] = tile; j++; } } } if (map.Tiles.PendingStatic(x, y)) { StaticTile[] pending = map.Tiles.GetPendingStatics(x, y); StaticTile[] old = tilelist; tilelist = new StaticTile[old.Length + pending.Length]; old.CopyTo(tilelist, 0); for (int i = 0; i < pending.Length; ++i) { if ((pending[i].m_ID >= 0) && (pending[i].m_ID <= Art.GetMaxItemID())) { if (pending[i].m_Hue < 0) pending[i].m_Hue = 0; bool first = true; for (int k = 0; k < j; ++k) { if ((tilelist[k].m_ID == pending[i].m_ID) && ((tilelist[k].m_X == pending[i].m_X) && (tilelist[k].m_Y == pending[i].m_Y)) && (tilelist[k].m_Z == pending[i].m_Z) && (tilelist[k].m_Hue == pending[i].m_Hue)) { first = false; break; } } if (first) tilelist[j++] = pending[i]; } } } if (j > 0) { binidx.Write((int)binmul.BaseStream.Position); //lookup for (int i = 0; i < j; ++i) { binmul.Write(tilelist[i].m_ID); binmul.Write(tilelist[i].m_X); binmul.Write(tilelist[i].m_Y); binmul.Write(tilelist[i].m_Z); binmul.Write(tilelist[i].m_Hue); } } } fsmullength = (int)binmul.BaseStream.Position - fsmullength; if (fsmullength > 0) { binidx.Write(fsmullength); //length if (extra == -1) extra = 0; binidx.Write(extra); //extra } else { binidx.Write((int)-1); //lookup binidx.Write((int)-1); //length binidx.Write((int)-1); //extra } } } catch // fill the rest { binidx.BaseStream.Seek(((x * blocky) + y) * 12, SeekOrigin.Begin); for (; x < blockx; ++x) { for (; y < blocky; ++y) { binidx.Write((int)-1); //lookup binidx.Write((int)-1); //length binidx.Write((int)-1); //extra } y = 0; } } } } memidx.WriteTo(fsidx); memmul.WriteTo(fsmul); } } m_IndexReader.Close(); m_StaticsReader.Close(); }
public ModArea(Ultima.Map map, int sx, int sy, int ex, int ey, Dictionary <ushort, ushort> toConvLand, Dictionary <ushort, ushort> toConvStatic) { area = new RectangleArea(map, sx, sy, ex, ey); ConvertDictLand = toConvLand; ConvertDictStatic = toConvStatic; }