public static bool CheckMap(SeaChart map, bool[] FailTest) { if (map == null || map.Pins == null || map.Pins.Count == 0) { return(false); } bool failure = false; for (int ix = 0; map.Pins != null && ix < map.Pins.Count; ix++) { int WorldX = 0, WorldY = 0; map.ConvertToWorld(((Point2D)map.Pins[ix]).X, ((Point2D)map.Pins[ix]).Y, out WorldX, out WorldY); if (!Utility.BritWrap[0].Contains(new Point2D(WorldX, WorldY)) && !Utility.BritWrap[1].Contains(new Point2D(WorldX, WorldY))) { failure = true; FailTest[0] = true; } if (!ValidBounds(map, WorldX, WorldY)) { failure = true; FailTest[1] = true; } if (!ValidWater(WorldX, WorldY)) { failure = true; FailTest[2] = true; } } return(!failure); }
protected override void OnTarget(Mobile from, object targ) { if (targ is SeaChart) { bool failure = false; SeaChart map = (targ as SeaChart); for (int ix = 0; map.Pins != null && ix < map.Pins.Count; ix++) { bool[] FailTest = new bool[10]; int WorldX = 0, WorldY = 0; map.ConvertToWorld(((Point2D)map.Pins[ix]).X, ((Point2D)map.Pins[ix]).Y, out WorldX, out WorldY); if (!Utility.BritWrap[0].Contains(new Point2D(WorldX, WorldY)) && !Utility.BritWrap[1].Contains(new Point2D(WorldX, WorldY))) { failure = true; FailTest[0] = true; } if (!ValidBounds(map, WorldX, WorldY)) { failure = true; FailTest[1] = true; } if (!ValidWater(WorldX, WorldY)) { failure = true; FailTest[2] = true; } if (failure == true) { from.SendMessage("-- Pin {0} {1}", ix + 1, new Point2D(WorldX, WorldY)); if (FailTest[0] == true) { from.SendMessage(" No rects contain point {0}", (Point2D)map.Pins[ix]); } if (FailTest[1] == true) { from.SendMessage(" This point fails the validity check"); } if (FailTest[2] == true) { from.SendMessage(" This point fails the wet tile check"); } from.SendMessage(" Failed: map width({0})X({1}), map height({2})Y({3})", map.Width, ((Point2D)map.Pins[ix]).X, map.Height, ((Point2D)map.Pins[ix]).Y); from.SendMessage("-- failed"); } } if (failure == false) { from.SendMessage("Success"); } } else { from.SendMessage("The is not a SeaChart."); } return; }