public override void OnDoubleClick( Mobile from ) { Utility.TimeCheck tc = new Utility.TimeCheck(); tc.Start(); Place(from, new Point3D(from.Location.X, from.Location.Y, from.Location.Z), true); tc.End(); LogHelper Logger = new LogHelper("TownshipPlacementTime.log", false); //from.SendMessage(String.Format("Stone placement took {0}", tc.TimeTaken)); Logger.Log(LogType.Text, String.Format("Stone placement check at {0} took {1}", from.Location, tc.TimeTaken)); Logger.Finish(); }
public override void OnResponse( NetState state, RelayInfo info ) { if ( info.ButtonID == 1 ) { try { Utility.TimeCheck tc = new Utility.TimeCheck(); tc.Start(); m_TSDeed.Place(m_From, m_Location, false); tc.End(); LogHelper Logger = new LogHelper("TownshipPlacementTime.log", false); //from.SendMessage(String.Format("Stone placement took {0}", tc.TimeTaken)); Logger.Log(LogType.Text, String.Format("Stone placement ACTUAL at {0} took {1}", m_Location, tc.TimeTaken)); Logger.Finish(); } catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); } } }
public static Spawner GetRandomSpawner(SpawnerType type) { // if still empty, fail if (m_Spawners.Count == 0) return null; Spawner spawner = null; Utility.TimeCheck tc = new Utility.TimeCheck(); tc.Start(); //try to find an appropriate spawner for (int count = 0; count < m_Spawners.Count * 2; ++count) { // pick one at random.. Spawner random = m_Spawners[Utility.Random(m_Spawners.Count)] as Spawner; Region region = Server.Region.Find(random.Location, Map.Felucca); // test if this spawner satisfies type required switch (type) { case SpawnerType.Overland: { // Must be running if (!random.Running) continue; if (region != null) { // No Towns if (IsTown(region.Name)) continue; // no green acres, inside houses, etc.. if (IsValidRegion(random.Location, region) == false) continue; } break; } default: { if (region != null) { // no green acres, inside houses, etc.. if (IsValidRegion(random.Location, region) == false) continue; } break; } } //this is a good candidate! spawner = random; break; } tc.End(); if (tc.Elapsed() > 30) { LogHelper logger = new LogHelper("SpawnerCache"); logger.Log("Warning: Spawner overland search took " + tc.Elapsed().ToString() + "ms"); } return spawner; }
public static List<Spawner> GetSpawnersByRegion(Region region) { if (region == null) return null; List<Spawner> spawners = new List<Spawner>(); //time this search, log if it takes longer than .30 seconds Utility.TimeCheck tc = new Utility.TimeCheck(); tc.Start(); foreach (Spawner s in m_Spawners) if (Region.Find(s.Location, s.Map) == region) spawners.Add(s); tc.End(); if (tc.Elapsed() > 30) { LogHelper logger = new LogHelper("SpawnerCache"); logger.Log("Warning: Spawner search by region for " + region.Name + " took " + tc.Elapsed().ToString() + "ms"); } return spawners; }
public static void PackMemory_OnCommand(CommandEventArgs e) { if (e.Arguments.Length == 0 || ((e.Arguments[0] != "true" && e.Arguments[0] != "false"))) { e.Mobile.SendMessage("Usage: PackMemory <true|false>"); e.Mobile.SendMessage("Where: true means to WaitForPendingFinalizers."); return; } Utility.TimeCheck tc = new Utility.TimeCheck(); e.Mobile.SendMessage("Packing memory..."); tc.Start(); System.GC.Collect(); if (e.Arguments[0] == "true") System.GC.WaitForPendingFinalizers(); tc.End(); e.Mobile.SendMessage("{0} bytes in allocated memory", System.GC.GetTotalMemory(false)); e.Mobile.SendMessage("PackMemory took {0}", tc.TimeTaken); }
// called from baseguard to manage trash pick-up in the area of the guard. public static void DoGroundskeeper(Mobile m) { GroundskeeperStatus al; if (m_managers.Contains(m)) // if we have it already al = m_managers[m] as GroundskeeperStatus; // get the GroundskeeperStatus for this manager else { m_managers[m] = new GroundskeeperStatus(); // start a new list of clients at this IP address DoGroundskeeper(m); return; } // now we have a GroundskeeperStatus for this manager // if we've spawned a groundskeeper recently, no need to continue // if we've scanned recently, no need to continue if (DateTime.Now > al.LastSpawn + al.SpawnFreq && DateTime.Now > al.LastScan + al.ScanFreq) { ArrayList list = new ArrayList(); if (DoScan(m, al, list)) { System.Console.WriteLine("Groundskeeper spawn started ... "); Utility.TimeCheck tc = new Utility.TimeCheck(); tc.Start(); DoSpawn(al, list); tc.End(); System.Console.WriteLine("checked {0} items in {1}", list.Count, tc.TimeTaken); } } }