Ejemplo n.º 1
1
		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();
			}
		}
Ejemplo n.º 2
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)); }
		}
Ejemplo n.º 3
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.");
				}

			}

		}
Ejemplo n.º 4
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)); }
		}
Ejemplo n.º 5
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();
		}
Ejemplo n.º 6
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);
		}
Ejemplo n.º 7
0
		public PlayerQuestDeed(BaseContainer c) : base( 0x14F0 )
		{
			base.Weight = 1.0;
			base.Name = "a quest ticket";
			m_container = c;										// the prize
			m_expires = DateTime.Now + TimeSpan.FromHours(24.0);	// Heartbeat has it's own hadrcoded notion of 24 hours not tied to this value
			m_PrizeID = (int)m_container.Serial;					// identifies the prize
			PlayerQuestManager.Deeds.Add(this);						// add to our managers list
			PlayerQuestManager.Announce();							// force an announcement now
			LogHelper Logger = new LogHelper("PlayerQuest.log", false);
			string temp = String.Format("A Player Quest Deed({0}) has been created.", this.Serial);
			Logger.Log(LogType.Item, m_container, temp);
			Logger.Finish();
		}
Ejemplo n.º 8
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();
		}
Ejemplo n.º 9
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>");
			}
		}
Ejemplo n.º 10
0
		public static List<Spawner> GetSpawnersByRegion(Region region)
		{
			if (region == null) return null;
			List<Spawner> spawners = new List<Spawner>();
			//time this search, log if it takes longer than .30 seconds
			Utility.TimeCheck tc = new Utility.TimeCheck();
			tc.Start();
			foreach (Spawner s in m_Spawners)
				if (Region.Find(s.Location, s.Map) == region)
					spawners.Add(s);
			tc.End();
			if (tc.Elapsed() > 30)
			{
				LogHelper logger = new LogHelper("SpawnerCache");
				logger.Log("Warning:  Spawner search by region for " + region.Name + " took " + tc.Elapsed().ToString() + "ms");
			}
			return spawners;
		}
Ejemplo n.º 11
0
		public static Spawner GetRandomSpawner(SpawnerType type)
		{
			// if still empty, fail
			if (m_Spawners.Count == 0)
				return null;

			Spawner spawner = null;
			Utility.TimeCheck tc = new Utility.TimeCheck();
			tc.Start();
			//try to find an appropriate spawner
			for (int count = 0; count < m_Spawners.Count * 2; ++count)
			{
				// pick one at random..
				Spawner random = m_Spawners[Utility.Random(m_Spawners.Count)] as Spawner;
				Region region = Server.Region.Find(random.Location, Map.Felucca);

				// test if this spawner satisfies type required
				switch (type)
				{
					case SpawnerType.Overland:
						{
							// Must be running
							if (!random.Running)
								continue;

							if (region != null)
							{	// No Towns
								if (IsTown(region.Name))
									continue;

								// no green acres, inside houses, etc..
								if (IsValidRegion(random.Location, region) == false)
									continue;
							}

							break;
						}

					default:
						{
							if (region != null)
							{
								// no green acres, inside houses, etc..
								if (IsValidRegion(random.Location, region) == false)
									continue;
							}

							break;
						}
				}

				//this is a good candidate!
				spawner = random;
				break;
			}
			tc.End();
			if (tc.Elapsed() > 30)
			{
				LogHelper logger = new LogHelper("SpawnerCache");
				logger.Log("Warning:  Spawner overland search took " + tc.Elapsed().ToString() + "ms");
			}

			return spawner;

		}
Ejemplo n.º 12
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.");
			}
		}
Ejemplo n.º 13
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>");
            }
        }
Ejemplo n.º 14
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();
		}
Ejemplo n.º 15
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);
			}
		}
Ejemplo n.º 16
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>");
			}
		}
Ejemplo n.º 17
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);
			}
		}
Ejemplo n.º 18
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));
                }
            }
Ejemplo n.º 19
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)");
		}
Ejemplo n.º 20
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;
		}
Ejemplo n.º 21
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;
		}
Ejemplo n.º 22
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;
		}
Ejemplo n.º 23
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));
					}
				}
			}
Ejemplo n.º 24
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
			}
		}
Ejemplo n.º 25
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;  
                }
			}
		}
Ejemplo n.º 26
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));
                }
            }
Ejemplo n.º 27
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();
		}
Ejemplo n.º 28
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.");
		}
Ejemplo n.º 29
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();
		}
Ejemplo n.º 30
0
        public static void Remap_Process()
        {
            RCDCaller.SendMessage(string.Format("Processing next {0} containers...", RCDProcRate));

            // Loop through the next load of serial numbers, unfreezing each container in
            // turn and matching it against out stored list

            int idone  = 0;
            int itotal = RCDConlist.Count;
            int endpos = RCDProcessed + RCDProcRate;

            while (RCDProcessed < endpos && RCDProcessed < itotal)
            {
                RCDProcessed++;
                idone++;

                RCDEnum.MoveNext();

                // Use the serial number to find the item in the world
                Item item = World.FindItem((Serial)RCDEnum.Current);

                // Make sure it still exists
                if (item == null)
                {
                    continue;
                }

                if (item is Container)
                {
                    // It's still there!
                    Container cont = (Container)item;

                    // Rehydrate it if necessary
                    if (cont.CanFreezeDry)
                    {
                        cont.Rehydrate();
                    }

                    ArrayList ContQueue = new ArrayList();

                    foreach (Item content in cont.Items)
                    {
                        ContQueue.Add(content);
                    }

                    while (ContQueue.Count > 0)
                    {
                        Item content;

                        // Make sure the object in the queue is still an item

                        if (ContQueue[0] is Item)
                        {
                            content = (Item)ContQueue[0];
                            ContQueue.RemoveAt(0);
                        }
                        else
                        {
                            ContQueue.RemoveAt(0);
                            continue;
                        }

                        if (content is CommodityDeed)
                        {
                            // Check it against the ones we loaded into memory on init

                            bool match = false;
                            int  ipos;

                            for (ipos = 0; ipos < RCDData.Count; ipos++)
                            {
                                if (RCDData[ipos].ToString().IndexOf(content.Serial.ToString()) > -1)
                                {
                                    // We have a match, so break the loop

                                    match = true;
                                    break;
                                }
                            }
                            if (match)
                            {
                                if (RCDEncode(((CommodityDeed)content), RCDData[ipos].ToString()))
                                {
                                    // We were successfully able to encode the deed
                                    RCDData.Remove(RCDData[ipos]);
                                }
                                else
                                {
                                    // We failed to encode the deed
                                    continue;
                                }
                            }
                        }
                        else if (content is Container)
                        {
                            foreach (Item ci in ((Container)content).Items)
                            {
                                // Queue it up!
                                ContQueue.Add(ci);
                            }
                        }
                    }
                }
            }

            // Re-process any left in the RCDData list to ensure that they
            // cannot be located outside of rehydrated containers

            for (int ipos = 0; ipos < RCDData.Count; ipos++)
            {
                string sbase = RCDData[ipos].ToString().Substring(2, 8);
                int    iserial;

                // Try and convert serial string into a value

                try
                {
                    iserial = Int32.Parse(sbase, System.Globalization.NumberStyles.HexNumber);
                }
                catch
                {
                    Console.WriteLine("Failed to convert serial into a value!");

                    RCDLogger.Log(LogType.Text,
                                  string.Format("INVALID SERIAL DETECTED - :{0}:", sbase));

                    RCDCaller.SendMessage("Warning! Invalid serial detected... see logfile!");

                    // Loop to next data entry
                    continue;
                }

                Item item = World.FindItem(iserial);

                // Make sure it still exists
                if (item == null)
                {
                    continue;
                }

                // If it's a commodity deed, try and encode
                if (item is CommodityDeed)
                {
                    if (RCDEncode(((CommodityDeed)item), RCDData[ipos].ToString()))
                    {
                        RCDData.Remove(RCDData[ipos]);
                    }
                }
            }

            // Adam: tell the caller this run has completed
            RCDCaller.SendMessage(string.Format("Finished processing {0} containers.", RCDProcRate));

            if (RCDProcessed == itotal)
            {
                Remap_Finish();

                // Adam: tell the caller we are done.
                RCDCaller.SendMessage("Commodity deed processing complete.");
            }
            else
            {
                // Set up another timer to re-call another process run
                RCDTimer = new Remap_Timer();
                RCDTimer.Start();
            }
        }
Ejemplo n.º 31
0
		public void Report(Mobile from)
		{
			if (m_ReportLogger != null)
			{
				m_ReportLogger.Log(LogType.Text, "\n**** Reported again by " + from.Name + " ****\n");
				m_ReportLogger.Finish();
				if (m_ReportLogStopper != null)
					m_ReportLogStopper.Stop();
			}
		
			m_Reported = DateTime.Now;
			m_ReportLogger = new LogHelper( GetReportLogName(m_Reported.ToString("MM-dd-yyyy HH-mm-ss")) );
			m_ReportLogger.Log(LogType.Text, String.Format("{0} (acct {1}, SN {2}, IP {3}) reported by {4} (acct {5}, SN {6}) at {7}, at {8}.\r\n\r\n",
				this.Name, ((Account)this.Account).Username, this.Serial, ((this.NetState != null) ? this.NetState.ToString() : ""), from.Name, ((Account)from.Account).Username, from.Serial, DateTime.Now, from.Location));
            //Console.WriteLine("{0} (acct {1}, SN {2}, IP {3}) reported by {4} (acct {5}, SN {6}) at {7}, at {8}.\r\n\r\n",
            //    this.Name, ((Account)this.Account).Username, this.Serial, this.NetState.ToString(), from.Name, ((Account)from.Account).Username, from.Serial, DateTime.Now, from.Location);

			while (m_SpeechRecord.Count > 0)
				m_ReportLogger.Log(LogType.Text, ((SpeechRecordEntry)m_SpeechRecord.Dequeue()).Speech);

			m_ReportLogStopper = Timer.DelayCall(ReportTime, new TimerCallback(EndReport));
		}
Ejemplo n.º 32
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;
			}

		}
Ejemplo n.º 33
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();
        }
Ejemplo n.º 34
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();
		}
Ejemplo n.º 35
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)");
            }
        }
Ejemplo n.º 36
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);
            }
        }