예제 #1
0
        public static void Remap_Finish()
        {
            // Note that we're done
            RCDActivated = false;

            // Work out and log any we've missed
            for (int ipos = 0; ipos < RCDData.Count; ipos++)
            {
                RCDLogger.Log(LogType.Text, string.Format("{0}::::{1}", RCDData[ipos].ToString().Substring(0, 10), "UNFOUND"));
            }

            // Finish the logging session
            RCDLogger.Finish();
        }
예제 #2
0
		public static void FindMultiByType_OnCommand(CommandEventArgs e)
		{
			try
			{
				if (e.Length == 1)
				{
					LogHelper Logger = new LogHelper("FindMultiByType.log", e.Mobile, false);

					string name = e.GetString(0);

					foreach (ArrayList list in Server.Multis.BaseHouse.Multis.Values)
					{
						for (int i = 0; i < list.Count; i++)
						{
							BaseHouse house = list[i] as BaseHouse;
							// like Server.Multis.Tower
							if (house.GetType().ToString().ToLower().IndexOf(name.ToLower()) >= 0)
							{
								Logger.Log(house);
							}
						}
					}
					Logger.Finish();
				}
				else
				{
					e.Mobile.SendMessage("Format: FindMultiByType <type>");
				}
			}
			catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
		}
예제 #3
0
        private static void EventSink_AddItem(AddItemEventArgs e)
        {
            LogHelper lh = new LogHelper("AddItem.log", false, true);

            lh.Log(LogType.Mobile, e.from, String.Format("Used [Add Item to create ItemID:{0}, Serial:{1}", e.item.ItemID.ToString(), e.item.Serial.ToString()));
            lh.Finish();
        }
예제 #4
0
		private static void LagReport_OnCommand(CommandEventArgs arg)
		{
			Mobile from = arg.Mobile;

			if (from is PlayerMobile)
			{
				PlayerMobile pm = (PlayerMobile)from;

				// Limit to 5 minutes between lag reports
				if ((pm.LastLagTime + TimeSpan.FromMinutes(5.0)) < DateTime.Now)
				{
					// Let them log again
					LogHelper lh = new LogHelper("lagreports.log", false, true);
					lh.Log(LogType.Mobile, from, Server.Engines.CronScheduler.Cron.GetRecentTasks()); //adam: added schduled tasks!

					//Requested by Adam:
					Console.WriteLine("Lag at: {0}", DateTime.Now.ToShortTimeString());

					// Update LastLagTime on PlayerMobile
					pm.LastLagTime = DateTime.Now;

					lh.Finish();

					from.SendMessage("The fact that you are experiencing lag has been logged. We will review this with other data to try and determine the cause of this lag. Thank you for your help.");
				}
				else
				{

					from.SendMessage("It has been less than five minutes since you last reported lag. Please wait five minutes between submitting lag reports.");
				}

			}

		}
예제 #5
0
        public static void FindItemByType_OnCommand(CommandEventArgs e)
        {
            try
            {
                if (e.Length == 1)
                {
                    LogHelper Logger = new LogHelper("FindItemByType.log", e.Mobile, false);

                    string name = e.GetString(0);

                    foreach (Item item in World.Items.Values)
                    {
                        if (item != null && item.GetType().ToString().ToLower().IndexOf(name.ToLower()) >= 0)
                        {
                            Logger.Log(LogType.Item, item);
                        }
                    }
                    Logger.Finish();
                }
                else
                {
                    e.Mobile.SendMessage("Format: FindItemByType <type>");
                }
            }
            catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
        }
예제 #6
0
        public static void FindMultiByType_OnCommand(CommandEventArgs e)
        {
            try
            {
                if (e.Length == 1)
                {
                    LogHelper Logger = new LogHelper("FindMultiByType.log", e.Mobile, false);

                    string name = e.GetString(0);

                    foreach (ArrayList list in Server.Multis.BaseHouse.Multis.Values)
                    {
                        for (int i = 0; i < list.Count; i++)
                        {
                            BaseHouse house = list[i] as BaseHouse;
                            // like Server.Multis.Tower
                            if (house.GetType().ToString().ToLower().IndexOf(name.ToLower()) >= 0)
                            {
                                Logger.Log(house);
                            }
                        }
                    }
                    Logger.Finish();
                }
                else
                {
                    e.Mobile.SendMessage("Format: FindMultiByType <type>");
                }
            }
            catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
        }
예제 #7
0
        public static void FindMobileByName_OnCommand(CommandEventArgs e)
        {
            if (e.Length == 1)
            {
                LogHelper Logger = new LogHelper("findMobile.log", e.Mobile, true);

                // The name to find
                string sName = e.GetString(0);

                foreach (Mobile m in World.Mobiles.Values)
                {
                    PlayerMobile pm = m as PlayerMobile;
                    if (pm != null)
                    {
                        if (pm.Name.ToLower() == sName.ToLower())
                        {
                            Logger.Log(LogType.Mobile, m, String.Format("Online: {0}", ((bool)(pm.NetState != null)).ToString()));
                        }
                    }
                }

                Logger.Finish();
            }
            else
            {
                // Badly formatted
                e.Mobile.SendMessage("Usage: FindMobileByName <name>");
            }
        }
예제 #8
0
		public static void FindItemByType_OnCommand(CommandEventArgs e)
		{
			try
			{
				if (e.Length == 1)
				{
					LogHelper Logger = new LogHelper("FindItemByType.log", e.Mobile, false);

					string name = e.GetString(0);

					foreach (Item item in World.Items.Values)
					{
						if (item != null && item.GetType().ToString().ToLower().IndexOf(name.ToLower()) >= 0)
						{
							Logger.Log(LogType.Item, item);
						}
					}
					Logger.Finish();
				}
				else
				{
					e.Mobile.SendMessage("Format: FindItemByType <type>");
				}
			}
			catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
		}
예제 #9
0
        private static void LagReport_OnCommand(CommandEventArgs arg)
        {
            Mobile from = arg.Mobile;

            if (from is PlayerMobile)
            {
                PlayerMobile pm = (PlayerMobile)from;

                // Limit to 5 minutes between lag reports
                if ((pm.LastLagTime + TimeSpan.FromMinutes(5.0)) < DateTime.Now)
                {
                    // Let them log again
                    LogHelper lh = new LogHelper("lagreports.log", false, true);
                    lh.Log(LogType.Mobile, from, Server.Engines.CronScheduler.Cron.GetRecentTasks());                     //adam: added schduled tasks!

                    //Requested by Adam:
                    Console.WriteLine("Lag at: {0}", DateTime.Now.ToShortTimeString());

                    // Update LastLagTime on PlayerMobile
                    pm.LastLagTime = DateTime.Now;

                    lh.Finish();

                    from.SendMessage("The fact that you are experiencing lag has been logged. We will review this with other data to try and determine the cause of this lag. Thank you for your help.");
                }
                else
                {
                    from.SendMessage("It has been less than five minutes since you last reported lag. Please wait five minutes between submitting lag reports.");
                }
            }
        }
예제 #10
0
        public static void RehydrateWorld_OnCommand(CommandEventArgs e)
        {
            // make it known
            Server.World.Broadcast(0x35, true, "The world is rehydrating, please wait.");
            Console.WriteLine("World: rehydrating...");
            DateTime startTime = DateTime.Now;

            LogHelper Logger = new LogHelper("RehydrateWorld.log", e.Mobile, true);

            // Extract property & value from command parameters
            ArrayList containers = new ArrayList();

            // Loop items and check vs. types
            foreach (Item item in World.Items.Values)
            {
                if (item is Container)
                {
                    if ((item as Container).CanFreezeDry == true)
                    {
                        containers.Add(item);
                    }
                }
            }

            Logger.Log(LogType.Text,
                       string.Format("{0} containers scheduled for Rehydration...",
                                     containers.Count));

            int count = 0;

            for (int ix = 0; ix < containers.Count; ix++)
            {
                Container cont = containers[ix] as Container;

                if (cont != null)
                {
                    // Rehydrate it if necessary
                    if (cont.CanFreezeDry && cont.IsFreezeDried == true)
                    {
                        cont.Rehydrate();
                    }
                    count++;
                }
            }

            Logger.Log(LogType.Text,
                       string.Format("{0} containers actually Rehydrated", count));

            Logger.Finish();

            e.Mobile.SendMessage("{0} containers actually Rehydrated", count);

            DateTime endTime = DateTime.Now;

            Console.WriteLine("done in {0:F1} seconds.", (endTime - startTime).TotalSeconds);
            Server.World.Broadcast(0x35, true, "World rehydration complete. The entire process took {0:F1} seconds.", (endTime - startTime).TotalSeconds);
        }
예제 #11
0
        public static void DumpRares_OnCommand(CommandEventArgs e)
        {
            LogHelper Logger = new LogHelper("RaresDump.log", false);

            try
            {
                foreach (DODGroup dg in RareFactory.DODGroup)
                {
                    if (dg is DODGroup)
                    {
                        foreach (DODInstance di in dg.DODInst)
                        {
                            if (di is DODInstance)
                            {
                                if (di.RareTemplate == null)
                                {
                                    Logger.Log(LogType.Text, String.Format("DODInstance {0} has a null RareTemplate.", di.Name));
                                }
                                else
                                {
                                    Logger.Log(LogType.Item, di.RareTemplate, String.Format("DODInstance {0}: ({1}).", di.Name, di.RareTemplate.GetType().ToString()));
                                }
                            }
                        }
                    }
                }

                Logger.Log(LogType.Text, "------------- RareFactory.DODInst -------------");

                foreach (DODInstance di in  RareFactory.DODInst)
                {
                    if (di is DODInstance)
                    {
                        if (di.RareTemplate == null)
                        {
                            Logger.Log(LogType.Text, String.Format("DODInstance {0} has a null RareTemplate.", di.Name));
                        }
                        else
                        {
                            Logger.Log(LogType.Item, di.RareTemplate, String.Format("DODInstance {0}: ({1}).", di.Name, di.RareTemplate.GetType().ToString()));
                        }
                    }
                }

                e.Mobile.SendMessage("Done.");
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                e.Mobile.SendMessage(ex.Message);
            }
            finally
            {
                Logger.Finish();
            }
        }
예제 #12
0
        private static void MakeDeco_OnCommand(CommandEventArgs arg)
        {
            Mobile    from   = arg.Mobile;
            LogHelper Logger = new LogHelper("makedeco.log", from, true);

            // Loop through town regions and search out items
            // within

            foreach (Region reg in from.Map.Regions)
            {
                if (reg is FeluccaTown || reg is CustomRegion)
                {
                    for (int pos = 0; pos < reg.Coords.Count; pos++)
                    {
                        if (reg.Coords[pos] is Rectangle2D)
                        {
                            Rectangle2D       area  = (Rectangle2D)reg.Coords[pos];
                            IPooledEnumerable eable = from.Map.GetItemsInBounds(area);

                            foreach (object obj in eable)
                            {
                                if (obj is Container)
                                {
                                    Container cont = (Container)obj;

                                    if (cont.Movable == false &&
                                        cont.PlayerCrafted == false &&
                                        cont.Name != "Goodwill" &&
                                        !(cont.RootParent is Mobile) &&
                                        !(cont is TrashBarrel) &&
                                        cont.Deco == false &&
                                        !(cont.IsLockedDown) &&
                                        !(cont.IsSecure))
                                    {
                                        // Exclude ransom chests
                                        if (cont.Name != null && cont.Name.ToLower().IndexOf("ransom") >= 0)
                                        {
                                            continue;
                                        }

                                        // Found one
                                        cont.Deco = true;
                                        Logger.Log(LogType.Item, cont);
                                    }
                                }
                            }

                            eable.Free();
                        }
                    }
                }
            }

            Logger.Finish();
        }
예제 #13
0
        public static void FindItemByID_OnCommand(CommandEventArgs e)
        {
            try
            {
                if (e.Length == 1)
                {
                    //erl: LogHelper class handles generic logging functionality
                    LogHelper Logger = new LogHelper("FindItemByID.log", e.Mobile, false);

                    int    ItemId = 0;
                    string sx     = e.GetString(0).ToLower();

                    try
                    {
                        if (sx.StartsWith("0x"))
                        {                           // assume hex
                            sx     = sx.Substring(2);
                            ItemId = int.Parse(sx, System.Globalization.NumberStyles.AllowHexSpecifier);
                        }
                        else
                        {                           // assume decimal
                            ItemId = int.Parse(sx);
                        }
                    }
                    catch
                    {
                        e.Mobile.SendMessage("Format: FindItemByID <ItemID>");
                        return;
                    }

                    foreach (Item ix in World.Items.Values)
                    {
                        if (ix is Item)
                        {
                            if (ix.ItemID == ItemId)
                            {
                                Logger.Log(LogType.Item, ix);
                            }
                        }
                    }
                    Logger.Finish();
                }
                else
                {
                    e.Mobile.SendMessage("Format: FindItemByID <ItemID>");
                }
            }
            catch (Exception err)
            {
                e.Mobile.SendMessage("Exception: " + err.Message);
            }

            e.Mobile.SendMessage("Done.");
        }
예제 #14
0
 private static void EventSink_Shutdown(ShutdownEventArgs e)
 {
     for (int ix = 0; ix < LogHelper.OpenLogs.Count; ix++)
     {
         LogHelper lh = LogHelper.OpenLogs[ix] as LogHelper;
         if (lh != null)
         {
             lh.Finish();
         }
     }
 }
예제 #15
0
		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();
		}
예제 #16
0
        private static void FindSpawner_OnCommand(CommandEventArgs arg)
        {
            Mobile from = arg.Mobile;

            int X = from.Location.X;
            int Y = from.Location.Y;

            string SearchText = arg.GetString(0);
            int    TileRange  = arg.GetInt32(1);

            // Validate parameters

            if (SearchText == "")
            {
                from.SendMessage("To use : [findspawner <type> (<range>)");
                return;
            }

            Regex InvalidPatt = new Regex("[^-a-zA-Z0-9' ]");

            if (InvalidPatt.IsMatch(SearchText))
            {
                from.SendMessage("Invalid characters used in type or range specification.");
                return;
            }


            // Perform search and retrieve list of spawner matches

            LogHelper Logger = new LogHelper("findspawner.log", from, true);

            ArrayList SpawnerList = FindMobSpawners(SearchText, X, Y, TileRange);

            if (SpawnerList.Count > 0)
            {
                // Have results so sort, loop and display message for each match

                SpawnerList.Sort();

                foreach (SpawnerMatch ms in SpawnerList)
                {
                    if (ms.Item == false || from.AccessLevel == Server.AccessLevel.Administrator)
                    {
                        Logger.Log(LogType.Item, ms.Sp, string.Format("{0}:{1}:{2}",
                                                                      ms.Matched,
                                                                      ms.Distance,
                                                                      ms.Status));
                    }
                }
            }

            Logger.Finish();
        }
예제 #17
0
        // Does search... returns ArrayList reference for mobiles that matched

        public static ArrayList FindSkillMobs(SkillName skill, int elapsed)
        {
            if (elapsed == 0)
            {
                elapsed = 2;                            // Default
            }
            //ArrayList MobStates = NetState.Instances;
            List <NetState> MobStates  = NetState.Instances;
            ArrayList       MobMatches = new ArrayList(NetState.Instances.Count);

            LogHelper Logger = new LogHelper("findskill.log", false, true);

            // Loop through active connections' mobiles and check conditions

            for (int i = 0; i < MobStates.Count; ++i)
            {
                Mobile m = MobStates[i].Mobile;

                // If m defined & PlayerMobile, get involved (not explicit)

                if (m != null)
                {
                    if (m is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)m;

                        SkillName LastSkill = pm.LastSkillUsed;
                        DateTime  LastTime  = pm.LastSkillTime;

                        // Check time & skill, display if match

                        if (LastSkill == skill && DateTime.Now <= (LastTime + TimeSpan.FromSeconds(elapsed * 60)))
                        {
                            MobMatches.Add(pm);
                        }
                    }
                }
            }

            if (MobMatches.Count > 0)
            {
                // Loop through matches and log before returning

                foreach (PlayerMobile pm in MobMatches)
                {
                    Logger.Log(LogType.Mobile, pm, skill.ToString());
                }

                Logger.Finish();
            }

            return(MobMatches);
        }
예제 #18
0
 public static void LogException(Exception ex, string additionalMessage)
 {
     try
     {
         LogHelper Logger = new LogHelper("Exception.log", false);
         string    text   = String.Format("{0}\r\n{1}\r\n{2}", additionalMessage, ex.Message, ex.StackTrace);
         Logger.Log(LogType.Text, text);
         Logger.Finish();
         Console.WriteLine(text);
     }
     catch
     {
         // do nothing here as we do not want to enter a "cycle of doom!"
         //  Basically, we do not want the caller to catch an exception here, and call
         //  LogException() again, where it throws another exception, and so forth
     }
 }
예제 #19
0
        public static void TrackIt(Mobile from, string text, bool accomplice)
        {
            LogHelper Logger = new LogHelper("Cheater.log", false);

            Logger.Log(LogType.Mobile, from, text);
            if (accomplice == true)
            {
                IPooledEnumerable eable = from.GetMobilesInRange(24);
                foreach (Mobile m in eable)
                {
                    if (m is PlayerMobile && m != from)
                    {
                        Logger.Log(LogType.Mobile, m, "Possible accomplice.");
                    }
                }
                eable.Free();
            }
            Logger.Finish();
        }
예제 #20
0
        public static void ComLogger_OnCommand(CommandEventArgs e)
        {
            LogHelper Logger = new LogHelper("Commoditydeed.log", true);

            foreach (Item m in World.Items.Values)
            {
                if (m != null)
                {
                    if (m is CommodityDeed && ((CommodityDeed)m).Commodity != null)
                    {
                        string output = string.Format("{0}\t{1,-25}\t{2,-25}",
                                                      m.Serial + ",", ((CommodityDeed)m).Commodity + ",", ((CommodityDeed)m).Commodity.Amount);

                        Logger.Log(LogType.Text, output);
                    }
                }
            }
            Logger.Finish();
        }
예제 #21
0
		public static void ComLogger_OnCommand(CommandEventArgs e)
		{
			LogHelper Logger = new LogHelper("Commoditydeed.log", true);

			foreach (Item m in World.Items.Values)
			{

				if (m != null)
				{
					if (m is CommodityDeed && ((CommodityDeed)m).Commodity != null)
					{
						string output = string.Format("{0}\t{1,-25}\t{2,-25}",
							m.Serial + ",", ((CommodityDeed)m).Commodity + ",", ((CommodityDeed)m).Commodity.Amount);

						Logger.Log(LogType.Text, output);
					}
				}
			}
			Logger.Finish();
		}
예제 #22
0
		public static void FindItemByName_OnCommand(CommandEventArgs e)
		{
			if (e.Length == 1)
			{
				LogHelper Logger = new LogHelper("FindItemByName.log", e.Mobile, false);

				string name = e.GetString(0).ToLower();

				foreach (Item item in World.Items.Values)
					if (item.Name != null && item.Name.ToLower().IndexOf(name) >= 0)
						Logger.Log(LogType.Item, item);

				Logger.Finish();


			}
			else
			{
				e.Mobile.SendMessage("Format: FindItemByName <name>");
			}
		}
예제 #23
0
        public static void FindItemByName_OnCommand(CommandEventArgs e)
        {
            if (e.Length == 1)
            {
                LogHelper Logger = new LogHelper("FindItemByName.log", e.Mobile, false);

                string name = e.GetString(0).ToLower();

                foreach (Item item in World.Items.Values)
                {
                    if (item.Name != null && item.Name.ToLower().IndexOf(name) >= 0)
                    {
                        Logger.Log(LogType.Item, item);
                    }
                }

                Logger.Finish();
            }
            else
            {
                e.Mobile.SendMessage("Format: FindItemByName <name>");
            }
        }
예제 #24
0
		private static void EventSink_AddItem(AddItemEventArgs e)
		{
			LogHelper lh = new LogHelper("AddItem.log", false, true);
			lh.Log(LogType.Mobile, e.from, String.Format("Used [Add Item to create ItemID:{0}, Serial:{1}", e.item.ItemID.ToString(), e.item.Serial.ToString()));
			lh.Finish();
		}
예제 #25
0
		public static void On_RHFile(CommandEventArgs e)
		{
			if (e.Arguments.Length != 1)
			{
				e.Mobile.SendMessage("Usage: [LoadCont <filename>");
				return;
			}

			try
			{
				int loaded = 0;
				int count;
				LogHelper log = new LogHelper(e.Arguments[0] + " LoadCont.log");
				log.Log(LogType.Text, String.Format("Reload process initiated by {0}, with {1} as backup data.", e.Mobile, e.Arguments[0]));

				using (FileStream idxfs = new FileStream(e.Arguments[0] + ".idx", FileMode.Open, FileAccess.Read))
				{
					using (FileStream binfs = new FileStream(e.Arguments[0] + ".bin", FileMode.Open, FileAccess.Read))
					{
						GenericReader bin = new BinaryFileReader(new BinaryReader(binfs));
						GenericReader idx = new BinaryFileReader(new BinaryReader(idxfs));

						count = idx.ReadInt();
						if (count == -1)
							log.Log(LogType.Text, "No item data to reload."); // do nothing
						else
						{
							ArrayList items = new ArrayList(count);
							log.Log(LogType.Text, String.Format("Attempting to reload {0} items.", count));

							Type[] ctortypes = new Type[] { typeof(Serial) };
							object[] ctorargs = new object[1];

							for (int i = 0; i < count; i++)
							{
								string type = idx.ReadString();
								Serial serial = (Serial)idx.ReadInt();
								long position = idx.ReadLong();
								int length = idx.ReadInt();

								Type t = ScriptCompiler.FindTypeByFullName(type);
								if (t == null)
								{
									Console.WriteLine("Warning: Tried to load nonexistent type {0}. Ignoring item.", type);
									log.Log(String.Format("Warning: Tried to load nonexistent type {0}. Ignoring item.", type));
									continue;
								}

								ConstructorInfo ctor = t.GetConstructor(ctortypes);
								if (ctor == null)
								{
									Console.WriteLine("Warning: Tried to load type {0} which has no serialization constructor. Ignoring item.", type);
									log.Log(String.Format("Warning: Tried to load type {0} which has no serialization constructor. Ignoring item.", type));
									continue;
								}

								Item item = null;
								try
								{
									if (World.FindItem(serial) != null)
									{
										log.Log(LogType.Item, World.FindItem(serial), "Serial already in use!! Loading of saved item failed.");
									}
									else if (!World.IsReserved(serial))
									{
										log.Log(String.Format("Serial {0} is not reserved!! Loading of saved item failed.", serial));
									}
									else
									{
										ctorargs[0] = serial;
										item = (Item)(ctor.Invoke(ctorargs));
									}
								}
								catch (Exception ex)
								{
									LogHelper.LogException(ex);
									Console.WriteLine("An exception occurred while trying to invoke {0}'s serialization constructor.", t.FullName);
									Console.WriteLine(ex.ToString());
									log.Log(String.Format("An exception occurred while trying to invoke {0}'s serialization constructor.", t.FullName));
									log.Log(ex.ToString());
								}

								if (item != null)
								{
									World.FreeSerial(serial);

									World.AddItem(item);
									items.Add(new object[] { item, position, length });
									log.Log(String.Format("Successfully created item {0}", item));
								}
							}

							for (int i = 0; i < items.Count; i++)
							{
								object[] entry = (object[])items[i];
								Item item = entry[0] as Item;
								long position = (long)entry[1];
								int length = (int)entry[2];

								if (item != null)
								{
									bin.Seek(position, SeekOrigin.Begin);

									try
									{
										item.Deserialize(bin);

										// take care of parent hierarchy
										object p = item.Parent;
										if (p is Item)
										{
											((Item)p).RemoveItem(item);
											item.Parent = null;
											((Item)p).AddItem(item);
										}
										else if (p is Mobile)
										{
											((Mobile)p).RemoveItem(item);
											item.Parent = null;
											((Mobile)p).AddItem(item);
										}
										else
										{
											item.Delta(ItemDelta.Update);
										}

										item.ClearProperties();

										object rp = item.RootParent;
										if (rp is Item)
											((Item)rp).UpdateTotals();
										else if (rp is Mobile)
											((Mobile)rp).UpdateTotals();
										else
											item.UpdateTotals();

										if (bin.Position != (position + length))
											throw new Exception(String.Format("Bad serialize on {0}", item));

										log.Log(LogType.Item, item, "Successfully loaded.");
										loaded++;
									}
									catch (Exception ex)
									{
										LogHelper.LogException(ex);
										Console.WriteLine("Caught exception while deserializing {0}:", item);
										Console.WriteLine(ex.ToString());
										Console.WriteLine("Deleting item.");
										log.Log(String.Format("Caught exception while deserializing {0}:", item));
										log.Log(ex.ToString());
										log.Log("Deleting item.");
										item.Delete();
									}
								}
							}

						}
						idx.Close();
						bin.Close();
					}
				}

				Console.WriteLine("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded);
				log.Log(String.Format("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded));
				e.Mobile.SendMessage("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded);
				log.Finish();
			}
			catch (Exception ex)
			{
				LogHelper.LogException(ex);
				Console.WriteLine(ex.ToString());
				e.Mobile.SendMessage("Exception: {0}", ex.Message);
			}
		}
예제 #26
0
		public static void FindItem_OnCommand(CommandEventArgs e)
		{
			if (e.Length > 1)
			{

				LogHelper Logger = new LogHelper("finditem.log", e.Mobile, false);

				// Extract property & value from command parameters

				string sProp = e.GetString(0);
				string sVal = "";

				if (e.Length > 2)
				{

					sVal = e.GetString(1);

					// Concatenate the strings
					for (int argi = 2; argi < e.Length; argi++)
						sVal += " " + e.GetString(argi);
				}
				else
					sVal = e.GetString(1);

				Regex PattMatch = new Regex("= \"*" + sVal, RegexOptions.IgnoreCase);

				// Loop through assemblies and add type if has property

				Type[] types;
				Assembly[] asms = ScriptCompiler.Assemblies;

				ArrayList MatchTypes = new ArrayList();

				for (int i = 0; i < asms.Length; ++i)
				{
					types = ScriptCompiler.GetTypeCache(asms[i]).Types;

					foreach (Type t in types)
					{

						if (typeof(Item).IsAssignableFrom(t))
						{

							// Reflect type
							PropertyInfo[] allProps = t.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);

							foreach (PropertyInfo prop in allProps)
								if (prop.Name.ToLower() == sProp.ToLower())
									MatchTypes.Add(t);
						}
					}
				}

				// Loop items and check vs. types

				foreach (Item item in World.Items.Values)
				{
					Type t = item.GetType();
					bool match = false;

					foreach (Type MatchType in MatchTypes)
					{
						if (t == MatchType)
						{
							match = true;
							break;
						}
					}

					if (match == false)
						continue;

					// Reflect instance of type (matched)

					if (PattMatch.IsMatch(Properties.GetValue(e.Mobile, item, sProp)))
						Logger.Log(LogType.ItemSerial, item);

				}

				Logger.Finish();
			}
			else
			{
				// Badly formatted
				e.Mobile.SendMessage("Format: FindItem <property> <value>");
			}
		}
예제 #27
0
		public static void LogException(Exception ex, string additionalMessage)
		{
			try
			{
				LogHelper Logger = new LogHelper("Exception.log", false);
				string text = String.Format("{0}\r\n{1}\r\n{2}", additionalMessage, ex.Message, ex.StackTrace);
				Logger.Log(LogType.Text, text);
				Logger.Finish();
				Console.WriteLine(text);
			}
			catch
			{
				// do nothing here as we do not want to enter a "cycle of doom!"
				//  Basically, we do not want the caller to catch an exception here, and call
				//  LogException() again, where it throws another exception, and so forth
			}
		}
예제 #28
0
        public static void AddressDump_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            // check arguments
            if (e.Length < 1)
            {
                Usage(from);
                return;
            }

            int iChecked  = 0;
            int Reminders = 0;

            try
            {
                // loop through the accouints looking for current users
                ArrayList results = new ArrayList();

                // assume DaysActive
                if (e.Length == 1 && LooksLikeInt(e.GetString(0)))
                {
                    int days = 0;
                    try { days = Convert.ToInt32(e.GetString(0)); }
                    catch { Usage(from); return; }
                    foreach (Account acct in Accounts.Table.Values)
                    {
                        iChecked++;
                        // logged in the last n days.
                        if (Server.Engines.CronScheduler.EmailHelpers.RecentLogin(acct, days) == true)
                        {
                            if (ValidEmail(acct.EmailAddress))
                            {
                                Reminders++;
                                results.Add(acct.EmailAddress);
                            }
                        }
                    }
                }
                // assume activations since date
                else
                {
                    string buff = null;
                    for (int ix = 0; ix < e.Length; ix++)
                    {
                        buff += e.GetString(ix) + " ";
                    }

                    DateTime Since;
                    try { Since = DateTime.Parse(buff); }
                    catch { Usage(from); return; }

                    foreach (Account acct in Accounts.Table.Values)
                    {
                        iChecked++;
                        // account created since...
                        if (acct.Created >= Since && acct.EmailAddress != null)
                        {
                            if (ValidEmail(acct.EmailAddress))
                            {
                                Reminders++;
                                results.Add(acct.EmailAddress);
                            }
                        }
                    }
                }

                if (Reminders > 0)
                {
                    from.SendMessage("Logging {0} email address(es).", Reminders);
                    LogHelper Logger = new LogHelper("accountEmails.log", true);

                    foreach (object ox in results)
                    {
                        string address = ox as string;
                        if (address == null)
                        {
                            continue;
                        }
                        Logger.Log(LogType.Text, address);
                    }
                    Logger.Finish();
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                System.Console.WriteLine("Exception Caught in generic emailer: " + ex.Message);
                System.Console.WriteLine(ex.StackTrace);
            }

            return;
        }
예제 #29
0
            protected override void OnTarget(Mobile from, object targ)
            {
                PlayerMobile pm = targ as PlayerMobile;

                if (pm == null)
                {
                    from.SendMessage("Only players can be sent to jail.");
                    return;
                }

                Account acct = pm.Account as Account;

                int sentence = 12;                 // 12 hour minimum sentence

                if (Trouble == true)
                {
                    sentence = 2;                    // two hour sentance for troublemakets
                }
                else
                {
                    foreach (AccountComment comm in acct.Comments)
                    {
                        if (comm.Content.IndexOf("Jailed for ") != -1 && comm.Content.IndexOf("Tag count: ") != -1)
                        {
                            sentence += 12;                             // 12 hours for each previous [jail'ing
                        }
                        else if (comm.Content.IndexOf(" : reported using the [macroer command") != -1)
                        {
                            sentence += 12;                             // 12 hours for every time they were caught resource botting
                        }
                    }
                }

                // stable the players pets
                StablePets(from, pm);

                // handle jailing of logged out players
                Point3D destPoint = Jail.GetCell(m_Cell);

                pm.MoveToWorld(destPoint, Map.Felucca);
                if (pm.NetState == null)
                {
                    pm.LogoutLocation = destPoint;
                    pm.Map            = Map.Internal;
                }

                JailExitGate.AddInmate(pm, sentence);
                pm.SendMessage("You have been jailed for {0} hours.", sentence);
                from.SendMessage("{0} has been jailed for {1} hours.", pm.Name, sentence);

                LogHelper Logger = new LogHelper("jail.log", false, true);

                Logger.Log(LogType.Mobile, pm, string.Format("{0}:{1}:{2}:{3}",
                                                             from.Name,
                                                             m_Cell,
                                                             m_Comment,
                                                             sentence));
                Logger.Finish();

                Commands.CommandLogging.WriteLine(from, "{0} jailed {1}(Username: {2}) into cell {3} for {5} hours with reason: {4}.",
                                                  from.Name, pm.Name, acct.Username, m_Cell, m_Comment, sentence);
                if (Trouble == true)
                {
                    acct.Comments.Add(new AccountComment(from.Name, DateTime.Now + "\nTag count: " + (acct.Comments.Count + 1) + "\nJailedTroubleMaker for " + sentence + " hours. Reason: " + m_Comment));
                }
                else
                {
                    acct.Comments.Add(new AccountComment(from.Name, DateTime.Now + "\nTag count: " + (acct.Comments.Count + 1) + "\nJailed for " + sentence + " hours. Reason: " + m_Comment));
                }
            }
예제 #30
0
		public virtual void EndPickTarget(Mobile from, Mobile target, OrderType order)
		{
			// adam: sanity
			if (from == null)
			{
				Console.WriteLine("(from == null) in BaseAI::EndPickTarget");
				//return;
			}

			if (m_Mobile.Deleted || !m_Mobile.Controlled || from != m_Mobile.ControlMaster || !from.InRange(m_Mobile, 14) || from.Map != m_Mobile.Map || !from.CheckAlive())
				return;

			//Special case for if it's an iob follower!
			if (m_Mobile.IOBFollower && m_Mobile.IOBLeader == from)
			{
				if (target is BaseCreature)
				{
					BaseCreature bc = (BaseCreature)target;
					if (bc.IOBAlignment != IOBAlignment.None)
					{
						if (bc.IOBAlignment == m_Mobile.IOBAlignment)
						{
							//Won't attack same IOBAlignment
						}
						else
						{
							m_Mobile.ControlTarget = target;
							m_Mobile.ControlOrder = order;
						}
					}
					else
					{
						m_Mobile.SayTo(from, "Your follower refuses to attack that creature");
					}
				}
				else if (target is PlayerMobile)
				{
					if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.IOBShardWide)
						|| (Server.Engines.IOBSystem.IOBRegions.IsInIOBRegion(from)
						&& Server.Engines.IOBSystem.IOBRegions.IsInIOBRegion(target)))
					{
						PlayerMobile pm = (PlayerMobile)target;
						if (pm.IOBAlignment == m_Mobile.IOBAlignment || pm.IOBAlignment == IOBAlignment.None)
						{
							//Won't attack same IOBAlignment
						}
						else
						{
							m_Mobile.ControlTarget = target;
							m_Mobile.ControlOrder = order;
						}
					}
					else
					{
						m_Mobile.SayTo(from, "Your follower refuses to attack that here.");
					}
				}
				return;
			}

			if (order == OrderType.Attack && target is BaseCreature && (((BaseCreature)target).IsScaryToPets && ((BaseCreature)target).IsScaryCondition()) && m_Mobile.IsScaredOfScaryThings)
			{
				m_Mobile.SayTo(from, "Your pet refuses to attack this creature!");
				return;
			}

			if (m_Mobile.CheckControlChance(from))
			{
				// wea: targetted mobile and fixed control destination
				// 
				if (CoreAI.TempInt == 2 && order == OrderType.Attack)
				{
					bool success = false;

					if (target is BaseCreature)
					{
						// Is the controlmaster the same?
						if (m_Mobile.ControlMaster == ((BaseCreature)target).ControlMaster)
							success = true;
					}
					else if (target is PlayerMobile)
					{
						// Are we targetting the controlmaster?
						if (m_Mobile.ControlMaster == target)
							success = true;

					}

					if (success)
					{
						// Log this
						LogHelper Logger = new LogHelper("allguardbug.log", false, true);
						Logger.Log(LogType.Text, string.Format("{0}:{1}:{2}:{3}", from, m_Mobile, order, target));
						Logger.Finish();

						// Send a message to all staff in range
						IPooledEnumerable eable = m_Mobile.GetClientsInRange(75);
						foreach (NetState state in eable)
						{
							if (state.Mobile.AccessLevel >= AccessLevel.Counselor)
								m_Mobile.PrivateOverheadMessage(MessageType.Regular, 123, true, string.Format("My master just ordered me ({0}) to {1} the mobile ({2})", m_Mobile, order, target), state);
						}
					}
				}

				m_Mobile.ControlTarget = target;
				m_Mobile.ControlOrder = order;
			}

		}
예제 #31
0
		public bool IsRestrictedSkill(int skill, Mobile m)
		{
			bool bReturn = false;

			try
			{
				bool Invalid = false;

				if (skill < 0)
					Invalid = true;

				if (skill >= m_RestrictedSkills.Length)
					Invalid = true;

				if (Invalid && m is PlayerMobile)
				{
					try
					{
						Account a = m.Account as Account;
						LogHelper Logger = new LogHelper("InvalidPacket.log", false, true);
						Logger.Log(LogType.Text, "--------New Invalid Packet Entry---------");
						Logger.Log(LogType.Text,
									 string.Format("Skill Registered Number: {0} From Player: {1} Account: {2}, IP: {3}, Version: {4}",
												 skill,
												 m.Name,
												 ((a != null) ? a.Username : "******"),
													((m.NetState != null) ? m.NetState.ToString() : ""),
													m.NetState.Version == null ? "(null)" :
													m.NetState.Version.ToString()));
						Logger.Finish();
					}
					catch (Exception e)
					{
						LogHelper.LogException(e, "Caught error in Invalid packet handling.");
					}
					return false;
				}
				if (!Invalid)
					bReturn = m_RestrictedSkills[skill];
			}
			catch (Exception e)
			{
				LogHelper.LogException(e);
			}

			return bReturn;
		}
예제 #32
0
		public override void OnResponse( NetState state, int index )
		{
            //pla, 03/10/07
            // Log help stuck attempt
            if (index != 2)
            {
                LogHelper log = new LogHelper("HelpStuck.log");
                if (log != null)
                {
                    log.Log(LogType.Mobile, state.Mobile);
                    log.Finish();
                }
            }
			if ( index == 0 )
			{
				bool bGood = false;
				if (m_From.Alive == false) //dead: always allow to transport
				{
					bGood = true;
				}
				else if (m_From.Region is Regions.FeluccaDungeon) //alive and in dungeon
				{
					m_From.SendMessage("You have chosen to die.");
					m_From.Kill();
					bGood = true;
				}
				else if (m_From.TotalWeight < StuckMenu.MAXHELPSTUCKALIVEWEIGHT) //alive and out of dungeon and not over weight limit
				{
					bGood = true;
				}
				else // alive, out of dungeon, over weight limit
				{
					m_From.SendMessage("You are too encumbered to be moved, drop most of your stuff and help-stuck again.");
				}

				if (bGood)
				{
					//auto-choose destination now, so don't give them this message
					//m_From.SendMessage("You will now be given the standard help-stuck menu.");

					StuckMenu menu = new StuckMenu(m_From, m_From, true, true);
					//menu.BeginClose();
					//m_From.SendGump(menu);
					menu.AutoSelect();
				}
			}
			else if ( index == 1 )
			{
				if (!HelpGump.TryMoveStuckPlayer(m_From, 4))
				{
					int staffonline = 0;
					foreach (NetState ns in NetState.Instances)
					{
						Mobile m = ns.Mobile;
						if (m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify)
							staffonline++;
					}

					if (staffonline == 0)
					{
						StuckMenu menu = new StuckMenu(m_From, m_From, true);
						//menu.BeginClose();
						//m_From.SendGump(menu);
						menu.AutoSelect();
					}
				}
			}
			else if (index == 2)
			{
				m_From.SendMessage("Help Stuck request cancelled.");
			}
		}
예제 #33
0
		private int AccountCleanupWorker (out int AcctsDeleted)
		{
			int iChecked = 0;
			AcctsDeleted = 0;

			if (CoreAI.TCAcctCleanupEnable == false)
				return 0;

			try
			{
				ArrayList results = new ArrayList();

				foreach (Account acct in Accounts.Table.Values)
				{
					iChecked++;
					if (AccountCleanupRule(acct) != 0)
					{
						results.Add(acct);
					}
				}

				if (results.Count > 0)
				{
					LogHelper Logger = new LogHelper("accountDeletion.log", false);
					for (int i = 0; i < results.Count; i++)
					{
						AcctsDeleted++;
						Account acct = (Account)results[i];

						// log it
						string temp = string.Format("Rule:{3}, Username:{0}, Created:{1}, Last Login:{4}, Email:{2}",
							acct.Username,
							acct.Created,
							acct.EmailAddress,
							AccountCleanupRule(acct),
							acct.LastLogin);
						Logger.Log(LogType.Text, temp);

						// delete it!
						acct.Delete();
					}
					Logger.Finish();
				}
			}
			catch (Exception e)
			{
				LogHelper.LogException(e);
				System.Console.WriteLine("Exception Caught in Account Cleanup code: " + e.Message);
				System.Console.WriteLine(e.StackTrace);
			}
			return iChecked;
		}
예제 #34
0
		private int GuildstoneCleanupWorker (out int NumberDeleted)
		{
			int iChecked = 0;
			NumberDeleted = 0;
			try
			{
				LogHelper Logger = new LogHelper("GuildstoneCleanup.log", false);

				// first time we see something we think we should delete, we simply mark it 
				//	as something to delete. If we see it again and we still think we should
				//	delete it, we delete it.
				ArrayList list = new ArrayList();
				foreach (Item i in World.Items.Values)
				{
					// only look at guildstones
					if (!(i is Guildstone)) continue;

					iChecked++;
					if (i.Map != Map.Internal)		// not internal (internal cleanup done elsewhere)
					{
						if (i.Parent == null		// not being carried
							&& !i.SpawnerTempItem	// spawner template item no deleteing!
							&& !i.IsIntMapStorage	// int storage item no deleteing!
							&& !i.Deleted			// duh
							&& !InHouse(i))			// not in a house
						{

							// if already marked, add to delete list
							if (i.ToDelete == true)
							{
								list.Add(i);
								Logger.Log(LogType.Item, i, "(Deleted)");
							}

								// mark to delete
							else
							{
								i.ToDelete = true;
								Logger.Log(LogType.Item, i, "(Marked For Deletion)");
							}
						}
						else
						{
							if (i.ToDelete == true)
								Logger.Log(LogType.Item, i, "(Unmarked For Deletion)");
							i.ToDelete = false;
						}
					}
				}

				// Cleanup
				foreach (Item item in list)
				{
					NumberDeleted++;
					item.Delete();
				}

				Logger.Finish();
			}
			catch (Exception e)
			{
				LogHelper.LogException(e);
				System.Console.WriteLine("Exception Caught in GuildstoneCleanup removal code: " + e.Message);
				System.Console.WriteLine(e.StackTrace);
			}

			return iChecked;
		}
예제 #35
0
		// Expire the rare
		public void Expire()
		{
			// Log this deletion before we lose all the associated data :P
			LogHelper lh = new LogHelper("RareExpiration.log", false, true );
			lh.Log(LogType.Item, this.RareTemplate,string.Format("{0}", this.Name));
			lh.Finish();
						
			
			// Delete the "in storage" rare 
			this.RareTemplate.Delete();
			
			// Find it in the group lists + remove
			for (int i = 0; i < RareFactory.DODGroup.Count; i++)
			{
				DODGroup dg = (DODGroup)RareFactory.DODGroup[i];
				for (int ir = 0; ir < dg.DODInst.Count; ir++)
                    if (((DODInstance)dg.DODInst[ir]) == this)
                    {   // There should never be more than one of these right?
                        dg.DODInst.RemoveAt(ir);
                        break; 
                    }
			}

			// Find it in the main rare list + remove
			for (int i = 0; i < RareFactory.DODInst.Count; i++)
			{
				DODInstance di = (DODInstance)RareFactory.DODInst[i];
                if (di == this)
                {   // There should never be more than one of these right?
                    RareFactory.DODInst.RemoveAt(i);
                    break;  
                }
			}
		}
예제 #36
0
		private int PlayerNPCCleanupWorker(out int NumberDeleted)
		{
			int iChecked = 0;
			NumberDeleted = 0;
			try
			{
				LogHelper Logger = new LogHelper("PlayerNPCCleanup.log", false);

				// first time we see something we think we should delete, we simply mark it 
				//	as something to delete. If we see it again and we still think we should
				//	delete it, we delete it.
				ArrayList list = new ArrayList();
				foreach (Mobile i in World.Mobiles.Values)
				{
					// only look at Player owned NPCs
					bool PlayerNPC =
						i is PlayerBarkeeper ||
						i is PlayerVendor ||
						i is RentedVendor ||
						i is HouseSitter;

					if (!PlayerNPC) continue;

					iChecked++;
					if (i.Map != Map.Internal)		// not internal (internal cleanup done elsewhere)
					{
						if (!i.SpawnerTempMob		// spawner template Mobile no deleteing!
							&& !InHouse(i)			// not in a house (not with a mouse)
							&& !i.Deleted			// duh
							&& !GmPlaced(i))		// not GM placed
						{

							// if already marked, add to delete list
							if (i.ToDelete == true)
							{
								list.Add(i);
								Logger.Log(LogType.Mobile, i, "(Deleted)");
							}

								// mark to delete
							else
							{
								i.ToDelete = true;
								Logger.Log(LogType.Mobile, i, "(Marked For Deletion)");
							}
						}
						else
						{
							if (i.ToDelete == true)
								Logger.Log(LogType.Mobile, i, "(Unmarked For Deletion)");
							i.ToDelete = false;
						}
					}
				}

				// Cleanup
				foreach (Mobile m in list)
				{
					NumberDeleted++;
					m.Delete();
				}

				Logger.Finish();
			}
			catch (Exception e)
			{
				LogHelper.LogException(e);
				System.Console.WriteLine("Exception Caught in PlayerNPCCleanup removal code: " + e.Message);
				System.Console.WriteLine(e.StackTrace);
			}

			return iChecked;
		}
예제 #37
0
		private static void DoCommand(CommandEventArgs e)
		{
			Dictionary<Serial, Serial> dict = new Dictionary<Serial, Serial>();
			string logname = "IntMapOrphan.log";

			if (e.ArgString.ToLower() == "list")
			{
				LoadDict(dict);

				LogHelper Logger = new LogHelper(logname, e.Mobile, true);
				int orphans = 0;
				foreach (Serial serial in dict.Keys)
				{
					Item item = World.FindItem(serial);
					Mobile mob = World.FindMobile(serial);
					if (item != null)
						Logger.Log(LogType.Item, item, String.Format("Managed by Spawner {0}", dict[serial]));
					if (mob != null)
						Logger.Log(LogType.Mobile, mob, String.Format("Managed by Spawner {0}", dict[serial]));
					if (dict[serial] == Serial.MinusOne)
						orphans++;
				}

				e.Mobile.SendMessage(String.Format("{0} template objects found with {1} orphans.", dict.Count, orphans));
				e.Mobile.SendMessage(String.Format("Please see {0} for a list of template/spawner pairs. ", logname));

				Logger.Finish();
			}
			else if (e.ArgString.ToLower() == "mark")
			{
				LoadDict(dict);
				LogHelper Logger = new LogHelper(logname, e.Mobile, true);

				int orphans = 0;
				foreach (Serial serial in dict.Keys)
				{
					Item item = World.FindItem(serial);
					Mobile mob = World.FindMobile(serial);
					if (item != null && dict[serial] == Serial.MinusOne)
					{
						item.IsIntMapStorage = false;
						item.SpawnerTempItem = false;
						Logger.Log(LogType.Item, item, "Set to decay.");
					}
					if (mob != null && dict[serial] == Serial.MinusOne)
					{
						mob.SpawnerTempMob = false;
						Logger.Log(LogType.Mobile, mob, "Set to decay.");
					}
					if (dict[serial] == Serial.MinusOne)
						orphans++;
				}

				e.Mobile.SendMessage(String.Format("{0} template objects found with {1} orphans.", dict.Count, orphans));
				e.Mobile.SendMessage(String.Format("Please see {0} for a list cleared templates. ", logname));

				Logger.Finish();
			}
			else
				e.Mobile.SendMessage("Usage: IntMapOrphan List | Mark(for cleanup)");
		}
예제 #38
0
        public static void RetargetRunes_OnCommand(CommandEventArgs e)
        {
            ArrayList regionList = new ArrayList();

            if (HaveRegions(e, regionList))
            {
                try
                {
                    LogHelper Logger = new LogHelper("retarget.log", e.Mobile, true);

                    foreach (Item item in World.Items.Values)
                    {
                        if (item is RecallRune)
                        {
                            RecallRune rune = (RecallRune)item;

                            for (int ix = 0; ix < regionList.Count; ix++)
                            {
                                if (rune.Marked && rune.TargetMap != null && (regionList[ix] as Region).Contains(rune.Target))
                                {
                                    object root = item.RootParent;

                                    if (root is Mobile)
                                    {
                                        if (((Mobile)root).AccessLevel < AccessLevel.GameMaster)
                                        {
                                            Logger.Log(LogType.Item, rune, rune.Description);
                                            rune.Target = new Point3D(0, 0, 0);
                                        }
                                    }
                                    else
                                    {
                                        Logger.Log(LogType.Item, rune, rune.Description);
                                        rune.Target = new Point3D(0, 0, 0);
                                    }
                                }
                            }
                        }
                        else if (item is Moonstone)
                        {
                            Moonstone stone = (Moonstone)item;

                            for (int ix = 0; ix < regionList.Count; ix++)
                            {
                                if (stone.Marked && (regionList[ix] as Region).Contains(stone.Destination))
                                {
                                    object root = item.RootParent;

                                    if (root is Mobile)
                                    {
                                        if (((Mobile)root).AccessLevel < AccessLevel.GameMaster)
                                        {
                                            Logger.Log(LogType.Item, stone, stone.Description);
                                            stone.Destination = new Point3D(0, 0, 0);
                                        }
                                    }
                                    else
                                    {
                                        Logger.Log(LogType.Item, stone, stone.Description);
                                        stone.Destination = new Point3D(0, 0, 0);
                                    }
                                }
                            }
                        }
                        else if (item is Runebook)
                        {
                            Runebook book = (Runebook)item;

                            for (int ix = 0; ix < regionList.Count; ix++)
                            {
                                for (int i = 0; i < book.Entries.Count; ++i)
                                {
                                    RunebookEntry entry = (RunebookEntry)book.Entries[i];

                                    if (entry.Map != null && (regionList[ix] as Region).Contains(entry.Location))
                                    {
                                        object root = item.RootParent;

                                        if (root is Mobile)
                                        {
                                            if (((Mobile)root).AccessLevel < AccessLevel.GameMaster)
                                            {
                                                Logger.Log(LogType.Item, item, string.Format("{0}:{1}:{2}",
                                                                                             i,
                                                                                             entry.Description,
                                                                                             book.Description));

                                                entry.Location = new Point3D(0, 0, 0);
                                            }
                                        }
                                        else
                                        {
                                            Logger.Log(LogType.Item, item, string.Format("{0}:{1}:{2}",
                                                                                         i,
                                                                                         entry.Description,
                                                                                         book.Description));

                                            entry.Location = new Point3D(0, 0, 0);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    Logger.Finish();
                    e.Mobile.SendMessage("DONE search for runes.");

                    return;
                }
                catch (Exception exc)
                {
                    LogHelper.LogException(exc);
                    e.Mobile.SendMessage("Exception in [Retarget -- see console.");
                    System.Console.WriteLine("Exception in [Retarget: {0}", exc.Message);
                    System.Console.WriteLine(exc.StackTrace);
                    return;
                }
            }
            else
            {
                e.Mobile.SendMessage("Usage: [Retarget <-regionName|-type|-point|-RegionUID> <name|type|point|uid>");
            }
        }
예제 #39
0
		private void DebugDump()
		{
			LogHelper logger = new LogHelper("champSpawner.log", false);
			try
			{
					logger.Log(LogType.Text, String.Format("this = {0}", this));
					logger.Log(LogType.Text, String.Format("m_LevelCounter = {0}", m_LevelCounter));
					logger.Log(LogType.Text, String.Format("SpawnLevels.Count = {0}", SpawnLevels.Count));
					logger.Log(LogType.Text, String.Format("((ChampLevelData)SpawnLevels [m_LevelCounter]).Monsters.Length = {0}", ((ChampLevelData)SpawnLevels[m_LevelCounter]).Monsters.Length));
					//logger.Log(LogType.Text, "X = {0}", X);
			}
			catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
			finally
			{
					logger.Finish();
			}
		}
예제 #40
0
        private static void InvBox_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            LogHelper Logger = new LogHelper("inventory.log", true);

            Logger.Log(LogType.Text, string.Format("{0}\t{1,-25}\t{7,-25}\t{2,-25}\t{3,-20}\t{4,-20}\t{5,-20}\t{6,-20}",
                                                   "Qty ---",
                                                   "Item ------------",
                                                   "Damage / Protection --",
                                                   "Durability -----",
                                                   "Accuracy -----",
                                                   "Exceptional",
                                                   "Slayer ----",
                                                   "Serial ----"));

            // Create rec and retrieve items within from bounding box callback
            // result
            Rectangle2D       rect  = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);
            IPooledEnumerable eable = map.GetItemsInBounds(rect);

            // Loop through and add objects returned
            foreach (object obj in eable)
            {
                if (m_ItemType == null || obj is BaseContainer)
                {
                    AddInv(obj);
                }
                else
                {
                    Type ot = obj.GetType();

                    if (ot.IsSubclassOf(m_ItemType) || ot == m_ItemType)
                    {
                        AddInv(obj);
                    }
                }
            }

            eable.Free();

            m_Inv.Sort();               // Sort results

            // Loop and log
            foreach (InvItem ir in m_Inv)
            {
                // ir.m_description += String.Format(" ({0})", it.Serial.ToString());
                string output = string.Format("{0}\t{1,-25}\t{7,-25}\t{2,-25}\t{3,-20}\t{4,-20}\t{5,-20}\t{6,-20}",
                                              ir.m_count + ",",
                                              (ir.GetDescription()) + ",",
                                              (ir.m_damage != null ? ir.m_damage : "N/A") + ",",
                                              (ir.m_durability != null ? ir.m_durability : "N/A") + ",",
                                              (ir.m_accuracy != null ? ir.m_accuracy : "N/A") + ",",
                                              (ir.m_quality != null ? ir.m_quality : "N/A") + ",",
                                              (ir.m_slayer != null ? ir.m_slayer : "N/A") + ",",
                                              ir.m_serial.ToString()
                                              );

                Logger.Log(LogType.Text, output);

                if (m_verbose)
                {
                    output = string.Format("{0}{1}{7}{2}{3}{4}{5}{6}",
                                           ir.m_count + ",",
                                           (ir.GetDescription()) + ",",
                                           (ir.m_damage != null ? ir.m_damage : "N/A") + ",",
                                           (ir.m_durability != null ? ir.m_durability : "N/A") + ",",
                                           (ir.m_accuracy != null ? ir.m_accuracy : "N/A") + ",",
                                           (ir.m_quality != null ? ir.m_quality : "N/A") + ",",
                                           (ir.m_slayer != null ? ir.m_slayer : "N/A") + ",",
                                           ir.m_serial.ToString()
                                           );

                    from.SendMessage(output);
                }
            }

            Logger.Count--;             // count-1 for header
            Logger.Finish();
        }
예제 #41
0
        // log non frineds marking in a house
        public void LogMark(Mobile m)
        {
            // log non frineds marking in a house
            try
            {
                ArrayList regions = Region.FindAll(m.Location, m.Map);
                for (int ix = 0; ix < regions.Count; ix++)
                {
                    if (regions[ix] is Regions.HouseRegion == false)
                        continue;

                    Regions.HouseRegion hr = regions[ix] as Regions.HouseRegion;
                    BaseHouse bh = hr.House;

                    if (bh != null)
                    {
                        if (bh.IsFriend(m) == false)
                        {
                            LogHelper Logger = new LogHelper("mark.log", false, true);
                            Logger.Log(LogType.Mobile, m);
                            Logger.Log(LogType.Item, this);
                            Logger.Finish();
                        }
                    }
                }
            }
            catch (Exception ex) { LogHelper.LogException(ex); }
        }
예제 #42
0
            public override void Execute(CommandEventArgs e, object obj)
            {
                try
                {
                    Item item = obj as Item;

                    if (!RareFactory.InUse)
                    {
                        if (e.Arguments.Length == 4)
                        {
                            int iRarity = 0;
                            if (int.TryParse(e.Arguments[1], out iRarity) == true && iRarity >= 0 && iRarity <= 10)
                            {
                                DODGroup match;
                                if ((match = FindGroup(e.Arguments[0], iRarity)) != null)
                                {
                                    int iStartIndex = 0;
                                    if (int.TryParse(e.Arguments[2], out iStartIndex) == true && iStartIndex > 0 && iStartIndex <= 255)
                                    {
                                        int iLastIndex = 0;
                                        if (int.TryParse(e.Arguments[3], out iLastIndex) == true && iLastIndex > 0 && iLastIndex <= 255)
                                        {
                                            if (item != null)
                                            {
                                                LogHelper Logger = null;
                                                try
                                                {
                                                    DODInstance di = RareFactory.AddRare(match, item);    // rarity is defined by the group
                                                    di.LastIndex  = (short)iLastIndex;
                                                    di.StartIndex = (short)iStartIndex;
                                                    di.StartDate  = DateTime.MinValue;  // valid now
                                                    di.EndDate    = DateTime.MaxValue;  // valid forever

                                                    // default the name to the name of the item
                                                    if (item.Name != null && item.Name != "")
                                                    {
                                                        di.Name = item.Name;
                                                    }
                                                    else
                                                    {
                                                        di.Name = item.GetType().Name;
                                                    }

                                                    AddResponse("Sucessfully defined new rare '" + di.Name + "'!");
                                                }
                                                catch (Exception ex)
                                                {
                                                    LogHelper.LogException(ex);
                                                    e.Mobile.SendMessage(ex.Message);
                                                }
                                                finally
                                                {
                                                    if (Logger != null)
                                                    {
                                                        Logger.Finish();
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                LogFailure("Only an item may be converted into a rare.");
                                            }
                                        }
                                        else
                                        {
                                            LogFailure("The LastIndex must be a numeric value between 1 and 255 inclusive.");
                                        }
                                    }
                                    else
                                    {
                                        LogFailure("The StartIndex must be a numeric value between 1 and 255 inclusive.");
                                    }
                                }
                                else
                                {
                                    LogFailure(String.Format("Could not find the group \"{0}\" with a rarity of {1}", e.Arguments[0], iRarity));
                                }
                            }
                            else
                            {
                                LogFailure("The rarity must be a numeric value between 0 and 10 inclusive.");
                            }
                        }
                        else
                        {
                            LogFailure("AddRare sGroup iRarity iStartIndex iLastIndex");
                        }
                    }
                    else
                    {
                        LogFailure("Rare Factory is currently being configured by another administrator! Please wait. ");
                    }
                }
                catch (Exception exe)
                {
                    LogHelper.LogException(exe);
                    e.Mobile.SendMessage(exe.Message);
                }
            }
예제 #43
0
        public static void On_RHFile(CommandEventArgs e)
        {
            if (e.Arguments.Length != 1)
            {
                e.Mobile.SendMessage("Usage: [LoadCont <filename>");
                return;
            }

            try
            {
                int       loaded = 0;
                int       count;
                LogHelper log = new LogHelper(e.Arguments[0] + " LoadCont.log");
                log.Log(LogType.Text, String.Format("Reload process initiated by {0}, with {1} as backup data.", e.Mobile, e.Arguments[0]));

                using (FileStream idxfs = new FileStream(e.Arguments[0] + ".idx", FileMode.Open, FileAccess.Read))
                {
                    using (FileStream binfs = new FileStream(e.Arguments[0] + ".bin", FileMode.Open, FileAccess.Read))
                    {
                        GenericReader bin = new BinaryFileReader(new BinaryReader(binfs));
                        GenericReader idx = new BinaryFileReader(new BinaryReader(idxfs));

                        count = idx.ReadInt();
                        if (count == -1)
                        {
                            log.Log(LogType.Text, "No item data to reload.");                             // do nothing
                        }
                        else
                        {
                            ArrayList items = new ArrayList(count);
                            log.Log(LogType.Text, String.Format("Attempting to reload {0} items.", count));

                            Type[]   ctortypes = new Type[] { typeof(Serial) };
                            object[] ctorargs  = new object[1];

                            for (int i = 0; i < count; i++)
                            {
                                string type     = idx.ReadString();
                                Serial serial   = (Serial)idx.ReadInt();
                                long   position = idx.ReadLong();
                                int    length   = idx.ReadInt();

                                Type t = ScriptCompiler.FindTypeByFullName(type);
                                if (t == null)
                                {
                                    Console.WriteLine("Warning: Tried to load nonexistent type {0}. Ignoring item.", type);
                                    log.Log(String.Format("Warning: Tried to load nonexistent type {0}. Ignoring item.", type));
                                    continue;
                                }

                                ConstructorInfo ctor = t.GetConstructor(ctortypes);
                                if (ctor == null)
                                {
                                    Console.WriteLine("Warning: Tried to load type {0} which has no serialization constructor. Ignoring item.", type);
                                    log.Log(String.Format("Warning: Tried to load type {0} which has no serialization constructor. Ignoring item.", type));
                                    continue;
                                }

                                Item item = null;
                                try
                                {
                                    if (World.FindItem(serial) != null)
                                    {
                                        log.Log(LogType.Item, World.FindItem(serial), "Serial already in use!! Loading of saved item failed.");
                                    }
                                    else if (!World.IsReserved(serial))
                                    {
                                        log.Log(String.Format("Serial {0} is not reserved!! Loading of saved item failed.", serial));
                                    }
                                    else
                                    {
                                        ctorargs[0] = serial;
                                        item        = (Item)(ctor.Invoke(ctorargs));
                                    }
                                }
                                catch (Exception ex)
                                {
                                    LogHelper.LogException(ex);
                                    Console.WriteLine("An exception occurred while trying to invoke {0}'s serialization constructor.", t.FullName);
                                    Console.WriteLine(ex.ToString());
                                    log.Log(String.Format("An exception occurred while trying to invoke {0}'s serialization constructor.", t.FullName));
                                    log.Log(ex.ToString());
                                }

                                if (item != null)
                                {
                                    World.FreeSerial(serial);

                                    World.AddItem(item);
                                    items.Add(new object[] { item, position, length });
                                    log.Log(String.Format("Successfully created item {0}", item));
                                }
                            }

                            for (int i = 0; i < items.Count; i++)
                            {
                                object[] entry    = (object[])items[i];
                                Item     item     = entry[0] as Item;
                                long     position = (long)entry[1];
                                int      length   = (int)entry[2];

                                if (item != null)
                                {
                                    bin.Seek(position, SeekOrigin.Begin);

                                    try
                                    {
                                        item.Deserialize(bin);

                                        // take care of parent hierarchy
                                        object p = item.Parent;
                                        if (p is Item)
                                        {
                                            ((Item)p).RemoveItem(item);
                                            item.Parent = null;
                                            ((Item)p).AddItem(item);
                                        }
                                        else if (p is Mobile)
                                        {
                                            ((Mobile)p).RemoveItem(item);
                                            item.Parent = null;
                                            ((Mobile)p).AddItem(item);
                                        }
                                        else
                                        {
                                            item.Delta(ItemDelta.Update);
                                        }

                                        item.ClearProperties();

                                        object rp = item.RootParent;
                                        if (rp is Item)
                                        {
                                            ((Item)rp).UpdateTotals();
                                        }
                                        else if (rp is Mobile)
                                        {
                                            ((Mobile)rp).UpdateTotals();
                                        }
                                        else
                                        {
                                            item.UpdateTotals();
                                        }

                                        if (bin.Position != (position + length))
                                        {
                                            throw new Exception(String.Format("Bad serialize on {0}", item));
                                        }

                                        log.Log(LogType.Item, item, "Successfully loaded.");
                                        loaded++;
                                    }
                                    catch (Exception ex)
                                    {
                                        LogHelper.LogException(ex);
                                        Console.WriteLine("Caught exception while deserializing {0}:", item);
                                        Console.WriteLine(ex.ToString());
                                        Console.WriteLine("Deleting item.");
                                        log.Log(String.Format("Caught exception while deserializing {0}:", item));
                                        log.Log(ex.ToString());
                                        log.Log("Deleting item.");
                                        item.Delete();
                                    }
                                }
                            }
                        }
                        idx.Close();
                        bin.Close();
                    }
                }

                Console.WriteLine("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded);
                log.Log(String.Format("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded));
                e.Mobile.SendMessage("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded);
                log.Finish();
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                Console.WriteLine(ex.ToString());
                e.Mobile.SendMessage("Exception: {0}", ex.Message);
            }
        }
예제 #44
0
		private void ConsumerPriceIndexWorker()
		{
			try
			{
				LogHelper Logger1 = new LogHelper("ConsumerPriceIndexNightly.log", true);	// this one gets emailed each night
				LogHelper Logger2 = new LogHelper("ConsumerPriceIndex.log", false);			// this is a running account

				string s1, s2;
				Scripts.Commands.Diagnostics.CPI_Worker(out s1, out s2);
				Logger1.Log(LogType.Text, s1);
				Logger1.Log(LogType.Text, s2);
				Logger2.Log(LogType.Text, s1);
				Logger2.Log(LogType.Text, s2);

				Logger1.Finish();
				Logger2.Finish();
			}
			catch (Exception e)
			{
				LogHelper.LogException(e);
				System.Console.WriteLine("ConsumerPriceIndex code: " + e.Message);
				System.Console.WriteLine(e.StackTrace);
			}
		}
예제 #45
0
        public static void FindMobile_OnCommand(CommandEventArgs e)
        {
            if (e.Length > 1)
            {
                LogHelper Logger = new LogHelper("findMobile.log", e.Mobile, false);

                // Extract property & value from command parameters

                string sProp = e.GetString(0);
                string sVal  = "";

                if (e.Length > 2)
                {
                    sVal = e.GetString(1);

                    // Concatenate the strings
                    for (int argi = 2; argi < e.Length; argi++)
                    {
                        sVal += " " + e.GetString(argi);
                    }
                }
                else
                {
                    sVal = e.GetString(1);
                }

                Regex PattMatch = new Regex("= \"*" + sVal, RegexOptions.IgnoreCase);

                // Loop through assemblies and add type if has property

                Type[]     types;
                Assembly[] asms = ScriptCompiler.Assemblies;

                ArrayList MatchTypes = new ArrayList();

                for (int i = 0; i < asms.Length; ++i)
                {
                    types = ScriptCompiler.GetTypeCache(asms[i]).Types;

                    foreach (Type t in types)
                    {
                        if (typeof(Mobile).IsAssignableFrom(t))
                        {
                            // Reflect type
                            PropertyInfo[] allProps = t.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);

                            foreach (PropertyInfo prop in allProps)
                            {
                                if (prop.Name.ToLower() == sProp.ToLower())
                                {
                                    MatchTypes.Add(t);
                                }
                            }
                        }
                    }
                }

                // Loop items and check vs. types

                foreach (Mobile m in World.Mobiles.Values)
                {
                    Type t     = m.GetType();
                    bool match = false;

                    foreach (Type MatchType in MatchTypes)
                    {
                        if (t == MatchType)
                        {
                            match = true;
                            break;
                        }
                    }

                    if (match == false)
                    {
                        continue;
                    }

                    // Reflect instance of type (matched)

                    if (PattMatch.IsMatch(Properties.GetValue(e.Mobile, m, sProp)))
                    {
                        Logger.Log(LogType.Mobile, m);
                    }
                }

                Logger.Finish();
            }
            else
            {
                // Badly formatted
                e.Mobile.SendMessage("Format: FindMobile <property> <value>");
            }
        }
예제 #46
0
		private void WealthTrackerWorker()
		{
			try
			{
				int limit = 10;     // top 10 farmers
				int timeout = 90;   // active within the last 90 minutes

				// compile the constrained list
				Server.Engines.WealthTracker.IPDomain[] list = Server.Engines.WealthTracker.ReportCompiler(limit, timeout);

				LogHelper Logger1 = new LogHelper("WealthTrackerNightly.log", true);	// this one gets emailed each night
				LogHelper Logger2 = new LogHelper("WealthTracker.log", false);			// this is a running account

				// write a super minimal report
				for (int ix = 0; ix < list.Length; ix++)
				{
					Server.Engines.WealthTracker.IPDomain node = list[ix] as Server.Engines.WealthTracker.IPDomain;
					Server.Engines.WealthTracker.AccountDomain ad = Server.Engines.WealthTracker.GetFirst(node.accountList) as Server.Engines.WealthTracker.AccountDomain; // just first account
					Mobile m = Server.Engines.WealthTracker.GetFirst(ad.mobileList) as Mobile;                   // just first mobile
					string sx = String.Format("mob:{2}, gold:{0}, loc:{1}", node.gold, node.location, m);
					Logger1.Log(LogType.Text, sx);
					Logger2.Log(LogType.Text, sx);
				}

				Logger1.Finish();
				Logger2.Finish();
			}
			catch (Exception e)
			{
				LogHelper.LogException(e);
				System.Console.WriteLine("WealthTracker code: " + e.Message);
				System.Console.WriteLine(e.StackTrace);
			}
		}
예제 #47
0
		private static void MakeDeco_OnCommand(CommandEventArgs arg)
		{
			Mobile from = arg.Mobile;
			LogHelper Logger = new LogHelper("makedeco.log", from, true);

			// Loop through town regions and search out items
			// within

			foreach (Region reg in from.Map.Regions)
			{
				if (reg is FeluccaTown || reg is CustomRegion)
				{
					for (int pos = 0; pos < reg.Coords.Count; pos++)
					{
						if (reg.Coords[pos] is Rectangle2D)
						{

							Rectangle2D area = (Rectangle2D)reg.Coords[pos];
							IPooledEnumerable eable = from.Map.GetItemsInBounds(area);

							foreach (object obj in eable)
							{
								if (obj is Container)
								{
									Container cont = (Container)obj;

									if (cont.Movable == false &&
										cont.PlayerCrafted == false &&
										cont.Name != "Goodwill" &&
										!(cont.RootParent is Mobile) &&
										!(cont is TrashBarrel) &&
										cont.Deco == false &&
										!(cont.IsLockedDown) &&
										!(cont.IsSecure))
									{

										// Exclude ransom chests
										if (cont.Name != null && cont.Name.ToLower().IndexOf("ransom") >= 0)
											continue;

										// Found one
										cont.Deco = true;
										Logger.Log(LogType.Item, cont);
									}
								}
							}

							eable.Free();
						}
					}
				}
			}

			Logger.Finish();
		}
예제 #48
0
		private static void InvBox_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
		{

			LogHelper Logger = new LogHelper("inventory.log", true);

			Logger.Log(LogType.Text, string.Format("{0}\t{1,-25}\t{7,-25}\t{2,-25}\t{3,-20}\t{4,-20}\t{5,-20}\t{6,-20}",
				"Qty ---",
				"Item ------------",
				"Damage / Protection --",
				"Durability -----",
				"Accuracy -----",
				"Exceptional",
				"Slayer ----",
				"Serial ----"));

			// Create rec and retrieve items within from bounding box callback
			// result
			Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);
			IPooledEnumerable eable = map.GetItemsInBounds(rect);

			// Loop through and add objects returned
			foreach (object obj in eable)
			{

				if (m_ItemType == null || obj is BaseContainer)
					AddInv(obj);
				else
				{
					Type ot = obj.GetType();

					if (ot.IsSubclassOf(m_ItemType) || ot == m_ItemType)
						AddInv(obj);
				}
			}

			eable.Free();

			m_Inv.Sort();	// Sort results

			// Loop and log
			foreach (InvItem ir in m_Inv)
			{
				// ir.m_description += String.Format(" ({0})", it.Serial.ToString());
				string output = string.Format("{0}\t{1,-25}\t{7,-25}\t{2,-25}\t{3,-20}\t{4,-20}\t{5,-20}\t{6,-20}",
					ir.m_count + ",",
					(ir.GetDescription()) + ",",
					(ir.m_damage != null ? ir.m_damage : "N/A") + ",",
					(ir.m_durability != null ? ir.m_durability : "N/A") + ",",
					(ir.m_accuracy != null ? ir.m_accuracy : "N/A") + ",",
					(ir.m_quality != null ? ir.m_quality : "N/A") + ",",
					(ir.m_slayer != null ? ir.m_slayer : "N/A") + ",",
					ir.m_serial.ToString()
					);

				Logger.Log(LogType.Text, output);

				if (m_verbose)
				{
					output = string.Format("{0}{1}{7}{2}{3}{4}{5}{6}",
						ir.m_count + ",",
						(ir.GetDescription()) + ",",
						(ir.m_damage != null ? ir.m_damage : "N/A") + ",",
						(ir.m_durability != null ? ir.m_durability : "N/A") + ",",
						(ir.m_accuracy != null ? ir.m_accuracy : "N/A") + ",",
						(ir.m_quality != null ? ir.m_quality : "N/A") + ",",
						(ir.m_slayer != null ? ir.m_slayer : "N/A") + ",",
						ir.m_serial.ToString()
						);

					from.SendMessage(output);
				}
			}

			Logger.Count--; // count-1 for header
			Logger.Finish();
		}
예제 #49
0
		public static void TrackIt(Mobile from, string text, bool accomplice)
		{
			LogHelper Logger = new LogHelper("Cheater.log", false);
			Logger.Log(LogType.Mobile, from, text);
			if (accomplice == true)
			{
				IPooledEnumerable eable = from.GetMobilesInRange(24);
				foreach (Mobile m in eable)
				{
					if (m is PlayerMobile && m != from)
						Logger.Log(LogType.Mobile, m, "Possible accomplice.");
				}
				eable.Free();
			}
			Logger.Finish();
		}
예제 #50
0
			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));
					}
				}
			}
예제 #51
0
            public void GoToJail()
            {
                if (m_Player == null || m_Player.Deleted)
                {
                    return;
                }

                Account acct = m_Player.Account as Account;

                int sentence = 12;                 // 12 hour minimum sentence

                if (Trouble == true)
                {
                    sentence = 2;                    // two hour sentance for troublemakets
                }
                else
                {
                    foreach (AccountComment comm in acct.Comments)
                    {
                        if (comm.Content.IndexOf("Jailed for ") != -1 && comm.Content.IndexOf("Tag count: ") != -1)
                        {
                            sentence += 12;                             // 12 hours for each previous [jail'ing
                        }
                        else if (comm.Content.IndexOf(" : reported using the [macroer command") != -1)
                        {
                            sentence += 12;                             // 12 hours for every time they were caught resource botting
                        }
                    }
                }

                // stable the players pets
                StablePets(m_Player);

                // move to jail
                Point3D destPoint = Jail.GetCell(m_Cell);

                m_Player.MoveToWorld(destPoint, Map.Felucca);

                // handle jailing of logged out players
                if (m_Player.NetState == null)
                {
                    m_Player.LogoutLocation = destPoint;
                    m_Player.Map            = Map.Internal;
                }

                JailExitGate.AddInmate(m_Player, sentence);
                m_Player.SendMessage("You have been jailed for {0} hours.", sentence);

                LogHelper Logger = new LogHelper("jail.log", false, true);

                Logger.Log(LogType.Mobile, m_Player, string.Format("{0}:{1}:{2}:{3}", "SYSTEM", m_Cell, m_Comment, sentence));
                Logger.Finish();

                if (Trouble == true)
                {
                    acct.Comments.Add(new AccountComment("SYSTEM", DateTime.Now + "\nTag count: " + (acct.Comments.Count + 1) + "\nJailedTroubleMaker for " + sentence + " hours. Reason: " + m_Comment));
                }
                else
                {
                    acct.Comments.Add(new AccountComment("SYSTEM", DateTime.Now + "\nTag count: " + (acct.Comments.Count + 1) + "\nJailed for " + sentence + " hours. Reason: " + m_Comment));
                }
            }
예제 #52
0
		private int StrongboxCleanupWorker(out int NumberDeleted)
		{
			int iChecked = 0;
			NumberDeleted = 0;
			try
			{
				LogHelper Logger = new LogHelper("StrongboxCleanup.log", false);

				// first time we see something we think we should delete, we simply mark it 
				//	as something to delete. If we see it again and we still think we should
				//	delete it, we delete it.
				ArrayList list = new ArrayList();
				foreach (Item i in World.Items.Values)
				{
					// only look at guildstones
					if (!(i is StrongBox)) continue;
					StrongBox sb = i as StrongBox;

					iChecked++;
					if (i.Map != Map.Internal)			// not internal (internal cleanup done elsewhere)
					{
						if (sb.Owner != null					// it is owned
							&& sb.House != null					// in a house
														&& !sb.Deleted                          // duh
							&& !sb.House.IsCoOwner(sb.Owner))	// yet owner is not a co owner of the house
						{

							// if already marked, add to delete list
							if (i.ToDelete == true)
							{
								list.Add(i);
								Logger.Log(LogType.Item, i, "(Deleted)");
							}

							// mark to delete
							else
							{
								i.ToDelete = true;
								Logger.Log(LogType.Item, i, "(Marked For Deletion)");
							}
						}
						else
						{
							if (i.ToDelete == true)
								Logger.Log(LogType.Item, i, "(Unmarked For Deletion)");
							i.ToDelete = false;
						}
					}
				}

				// Cleanup
				foreach (Item item in list)
				{
					NumberDeleted++;
					item.Delete();
				}

				Logger.Finish();
			}
			catch (Exception e)
			{
				LogHelper.LogException(e);
				System.Console.WriteLine("Exception Caught in StrongboxCleanup removal code: " + e.Message);
				System.Console.WriteLine(e.StackTrace);
			}

			return iChecked;
		}
예제 #53
0
        private void FillChest()
        {
            int RaresDropped = 0;
            LogHelper Logger = new LogHelper("PirateChampChest.log", false);

            // 25 piles * 1200 = 30K gold
            for (int ix = 0; ix < 25; ix++)
            {   // force the separate piles
                Gold gold = new Gold(800, 1200);
                gold.Stackable = false;
                m_MetalChest.DropItem(gold);
                gold.Stackable = true;
            }

            // "a smelly old mackerel"
            if (Utility.RandomChance(10))
            {
                Item ii;
                ii = new BigFish();
                ii.Name = "a smelly old mackerel";
                ii.Weight = 5;
                m_MetalChest.DropItem(ii);
                RaresDropped++;
                Logger.Log(LogType.Item, ii);
            }

            // single gold ingot weight 12
            if (Utility.RandomChance(10 * 2))
            {
                Item ii;
                if (Utility.RandomBool())
                    ii = new Item(7145);
                else
                    ii = new Item(7148);

                ii.Weight = 12;
                m_MetalChest.DropItem(ii);
                RaresDropped++;
                Logger.Log(LogType.Item, ii);
            }

            // 3 gold ingots 12*3
            if (Utility.RandomChance(5 * 2))
            {
                Item ii;
                if (Utility.RandomBool())
                    ii = new Item(7146);
                else
                    ii = new Item(7149);

                ii.Weight = 12 * 3;
                m_MetalChest.DropItem(ii);
                RaresDropped++;
                Logger.Log(LogType.Item, ii);
            }

            // 5 gold ingots 12*5
            if (Utility.RandomChance(1 * 2))
            {
                Item ii;
                if (Utility.RandomBool())
                    ii = new Item(7147);
                else
                    ii = new Item(7150);

                ii.Weight = 12 * 5;
                m_MetalChest.DropItem(ii);
                RaresDropped++;
                Logger.Log(LogType.Item, ii);
            }

            // single silver ingot weight 6
            if (Utility.RandomChance(10 * 2))
            {
                Item ii;
                if (Utility.RandomBool())
                    ii = new Item(7157);
                else
                    ii = new Item(7160);

                ii.Weight = 6;
                m_MetalChest.DropItem(ii);
                RaresDropped++;
                Logger.Log(LogType.Item, ii);
            }

            // 3 silver ingots 6*3
            if (Utility.RandomChance(5 * 2))
            {
                Item ii;
                if (Utility.RandomBool())
                    ii = new Item(7158);
                else
                    ii = new Item(7161);

                ii.Weight = 6 * 3;
                m_MetalChest.DropItem(ii);
                RaresDropped++;
                Logger.Log(LogType.Item, ii);
            }

            // 5 silver ingots 6*5
            if (Utility.RandomChance(1 * 2))
            {
                Item ii;
                if (Utility.RandomBool())
                    ii = new Item(7159);
                else
                    ii = new Item(7162);

                ii.Weight = 6 * 5;
                m_MetalChest.DropItem(ii);
                RaresDropped++;
                Logger.Log(LogType.Item, ii);
            }

            // rolled map w1
            if (Utility.RandomChance(20 * 2))
            {
                Item ii;
                if (Utility.RandomBool())
                    ii = new Item(5357);
                else
                    ii = new Item(5358);

                ii.Weight = 1;
                m_MetalChest.DropItem(ii);
                RaresDropped++;
                Logger.Log(LogType.Item, ii);
            }

            // ship plans
            if (Utility.RandomChance(10 * 2))
            {
                Item ii;
                if (Utility.RandomBool())
                    ii = new Item(5361);
                else
                    ii = new Item(5362);

                ii.Weight = 1;
                m_MetalChest.DropItem(ii);
                RaresDropped++;
                Logger.Log(LogType.Item, ii);
            }

            // ship model
            if (Utility.RandomChance(5 * 2))
            {
                Item ii;
                if (Utility.RandomBool())
                    ii = new Item(5363);
                else
                    ii = new Item(5364);

                ii.Weight = 3;
                m_MetalChest.DropItem(ii);
                RaresDropped++;
                Logger.Log(LogType.Item, ii);
            }

            // "scale shield" w6
            if (Utility.RandomChance(1))
            {
                Item ii;
                if (Utility.RandomBool())
                    ii = new Item(7110);
                else
                    ii = new Item(7111);

                ii.Name = "scale shield";
                ii.Weight = 6;
                m_MetalChest.DropItem(ii);
                RaresDropped++;
                Logger.Log(LogType.Item, ii);
            }

            // level 5 chest regs & gems
            TreasureMapChest.PackRegs(m_MetalChest, 5 * 10);
            TreasureMapChest.PackGems(m_MetalChest, 5 * 5);

            // level 5 magic items
            DungeonTreasureChest.PackMagicItem(m_MetalChest, 3, 3, 0.20);
            DungeonTreasureChest.PackMagicItem(m_MetalChest, 3, 3, 0.10);
            DungeonTreasureChest.PackMagicItem(m_MetalChest, 3, 3, 0.05);

            // an a level 5 treasure map
            m_MetalChest.DropItem(new TreasureMap(5, Map.Felucca));

            Logger.Finish();
        }
예제 #54
0
		public static void RehydrateWorld_OnCommand(CommandEventArgs e)
		{
			// make it known			
			Server.World.Broadcast(0x35, true, "The world is rehydrating, please wait.");
			Console.WriteLine("World: rehydrating...");
			DateTime startTime = DateTime.Now;

			LogHelper Logger = new LogHelper("RehydrateWorld.log", e.Mobile, true);

			// Extract property & value from command parameters
			ArrayList containers = new ArrayList();

			// Loop items and check vs. types
			foreach (Item item in World.Items.Values)
			{
				if (item is Container)
				{
					if ((item as Container).CanFreezeDry == true)
						containers.Add(item);
				}
			}

			Logger.Log(LogType.Text,
				string.Format("{0} containers scheduled for Rehydration...",
					containers.Count));

			int count = 0;
			for (int ix = 0; ix < containers.Count; ix++)
			{
				Container cont = containers[ix] as Container;

				if (cont != null)
				{
					// Rehydrate it if necessary
					if (cont.CanFreezeDry && cont.IsFreezeDried == true)
						cont.Rehydrate();
					count++;
				}
			}

			Logger.Log(LogType.Text,
				string.Format("{0} containers actually Rehydrated", count));

			Logger.Finish();

			e.Mobile.SendMessage("{0} containers actually Rehydrated", count);

			DateTime endTime = DateTime.Now;
			Console.WriteLine("done in {0:F1} seconds.", (endTime - startTime).TotalSeconds);
			Server.World.Broadcast(0x35, true, "World rehydration complete. The entire process took {0:F1} seconds.", (endTime - startTime).TotalSeconds);
		}
예제 #55
0
		public static void FindItemByID_OnCommand(CommandEventArgs e)
		{
			try
			{
				if (e.Length == 1)
				{
					//erl: LogHelper class handles generic logging functionality
					LogHelper Logger = new LogHelper("FindItemByID.log", e.Mobile, false);

					int ItemId = 0;
					string sx = e.GetString(0).ToLower();

					try
					{
						if (sx.StartsWith("0x"))
						{   // assume hex
							sx = sx.Substring(2);
							ItemId = int.Parse(sx, System.Globalization.NumberStyles.AllowHexSpecifier);
						}
						else
						{   // assume decimal
							ItemId = int.Parse(sx);
						}
					}
					catch
					{
						e.Mobile.SendMessage("Format: FindItemByID <ItemID>");
						return;
					}

					foreach (Item ix in World.Items.Values)
					{
						if (ix is Item)
							if (ix.ItemID == ItemId)
							{
								Logger.Log(LogType.Item, ix);
							}
					}
					Logger.Finish();
				}
				else
					e.Mobile.SendMessage("Format: FindItemByID <ItemID>");
			}
			catch (Exception err)
			{

				e.Mobile.SendMessage("Exception: " + err.Message);
			}

			e.Mobile.SendMessage("Done.");
		}
예제 #56
0
        private static void DoCommand(CommandEventArgs e)
        {
            Dictionary <Serial, Serial> dict = new Dictionary <Serial, Serial>();
            string logname = "IntMapOrphan.log";

            if (e.ArgString.ToLower() == "list")
            {
                LoadDict(dict);

                LogHelper Logger  = new LogHelper(logname, e.Mobile, true);
                int       orphans = 0;
                foreach (Serial serial in dict.Keys)
                {
                    Item   item = World.FindItem(serial);
                    Mobile mob  = World.FindMobile(serial);
                    if (item != null)
                    {
                        Logger.Log(LogType.Item, item, String.Format("Managed by Spawner {0}", dict[serial]));
                    }
                    if (mob != null)
                    {
                        Logger.Log(LogType.Mobile, mob, String.Format("Managed by Spawner {0}", dict[serial]));
                    }
                    if (dict[serial] == Serial.MinusOne)
                    {
                        orphans++;
                    }
                }

                e.Mobile.SendMessage(String.Format("{0} template objects found with {1} orphans.", dict.Count, orphans));
                e.Mobile.SendMessage(String.Format("Please see {0} for a list of template/spawner pairs. ", logname));

                Logger.Finish();
            }
            else if (e.ArgString.ToLower() == "mark")
            {
                LoadDict(dict);
                LogHelper Logger = new LogHelper(logname, e.Mobile, true);

                int orphans = 0;
                foreach (Serial serial in dict.Keys)
                {
                    Item   item = World.FindItem(serial);
                    Mobile mob  = World.FindMobile(serial);
                    if (item != null && dict[serial] == Serial.MinusOne)
                    {
                        item.IsIntMapStorage = false;
                        item.SpawnerTempItem = false;
                        Logger.Log(LogType.Item, item, "Set to decay.");
                    }
                    if (mob != null && dict[serial] == Serial.MinusOne)
                    {
                        mob.SpawnerTempMob = false;
                        Logger.Log(LogType.Mobile, mob, "Set to decay.");
                    }
                    if (dict[serial] == Serial.MinusOne)
                    {
                        orphans++;
                    }
                }

                e.Mobile.SendMessage(String.Format("{0} template objects found with {1} orphans.", dict.Count, orphans));
                e.Mobile.SendMessage(String.Format("Please see {0} for a list cleared templates. ", logname));

                Logger.Finish();
            }
            else
            {
                e.Mobile.SendMessage("Usage: IntMapOrphan List | Mark(for cleanup)");
            }
        }