diff --git a/Projects/Server/Main.cs b/Projects/Server/Main.cs index d17c45108..43fa92fae 100644 --- a/Projects/Server/Main.cs +++ b/Projects/Server/Main.cs @@ -164,7 +164,7 @@ public static class Core { // See notes above for _now and why this is a volatile variable. var now = _now; - return now == DateTime.MinValue ? DateTime.UtcNow : now; + return now == DateTime.MinValue ? Core.Now : now; } } @@ -557,7 +557,7 @@ public static class Core while (!Closing) { _tickCount = TickCount; - _now = DateTime.UtcNow; + _now = Core.Now; Mobile.ProcessDeltaQueue(); Item.ProcessDeltaQueue(); diff --git a/Projects/Server/Serialization/GenericEntityPersistence.cs b/Projects/Server/Serialization/GenericEntityPersistence.cs index 49e53979a..005838b51 100644 --- a/Projects/Server/Serialization/GenericEntityPersistence.cs +++ b/Projects/Server/Serialization/GenericEntityPersistence.cs @@ -255,7 +255,7 @@ public class GenericEntityPersistence : Persistence, IGenericEntityPersistenc try { using var op = new StreamWriter("world-save-errors.log", true); - op.WriteLine("{0}\t{1}", DateTime.UtcNow, message); + op.WriteLine("{0}\t{1}", Core.Now, message); op.WriteLine(new StackTrace(2).ToString()); op.WriteLine(); } diff --git a/Projects/Server/Serialization/IGenericReader.cs b/Projects/Server/Serialization/IGenericReader.cs index 31f5c4a7e..815b9f54c 100644 --- a/Projects/Server/Serialization/IGenericReader.cs +++ b/Projects/Server/Serialization/IGenericReader.cs @@ -51,7 +51,7 @@ public interface IGenericReader { long.MinValue => DateTime.MinValue, long.MaxValue => DateTime.MaxValue, - var delta => new DateTime(delta + DateTime.UtcNow.Ticks, DateTimeKind.Utc) + var delta => new DateTime(delta + Core.Now.Ticks, DateTimeKind.Utc) }; } decimal ReadDecimal() => new(stackalloc int[4] { ReadInt(), ReadInt(), ReadInt(), ReadInt() }); diff --git a/Projects/Server/Serialization/IGenericWriter.cs b/Projects/Server/Serialization/IGenericWriter.cs index 6595cb0fa..d512996da 100644 --- a/Projects/Server/Serialization/IGenericWriter.cs +++ b/Projects/Server/Serialization/IGenericWriter.cs @@ -70,7 +70,7 @@ public interface IGenericWriter } // Technically supports negative deltas for times in the past - Write(value.Ticks - DateTime.UtcNow.Ticks); + Write(value.Ticks - Core.Now.Ticks); } void Write(IPAddress value) { diff --git a/Projects/Server/World/EntityPersistence.cs b/Projects/Server/World/EntityPersistence.cs index 8564f0bd0..25e9fe16b 100644 --- a/Projects/Server/World/EntityPersistence.cs +++ b/Projects/Server/World/EntityPersistence.cs @@ -119,7 +119,7 @@ public static class EntityPersistence return map; } - var now = DateTime.UtcNow; + var now = Core.Now; for (int i = 0; i < count; ++i) { diff --git a/Projects/UOContent/Engines/XMLSpawner/BaseXmlSpawner.cs b/Projects/UOContent/Engines/XMLSpawner/BaseXmlSpawner.cs index 9866f8f57..e7a33b48e 100644 --- a/Projects/UOContent/Engines/XMLSpawner/BaseXmlSpawner.cs +++ b/Projects/UOContent/Engines/XMLSpawner/BaseXmlSpawner.cs @@ -28,11 +28,8 @@ public class BaseXmlSpawner } private static readonly Type typeofTimeSpan = typeof(TimeSpan); - private static readonly Type typeofParsable = typeof(ParsableAttribute); private static readonly Type typeofCustomEnum = typeof(CustomEnumAttribute); - private static bool IsParsable(Type t) => t == typeofTimeSpan || t.IsDefined(typeofParsable, false); - private static readonly Type[] m_ParseTypes = { typeof(string) }; private static readonly object[] m_ParseParams = new object[1]; @@ -204,7 +201,7 @@ public class BaseXmlSpawner Type = type; m_Delay = delay; m_Timeout = timeout; - m_TimeoutEnd = DateTime.UtcNow + timeout; + m_TimeoutEnd = Core.Now + timeout; m_Spawner = spawner; m_Condition = condition; m_Goto = gotogroup; @@ -280,7 +277,7 @@ public class BaseXmlSpawner private void DoTimer(TimeSpan delay, TimeSpan repeatdelay, string condition, int gotogroup) { - m_End = DateTime.UtcNow + delay; + m_End = Core.Now + delay; if (m_Timer != null) { @@ -303,11 +300,11 @@ public class BaseXmlSpawner if (Type == 0) { // save any timer information - writer.Write(m_End - DateTime.UtcNow); + writer.Write(m_End - Core.Now); writer.Write(m_Delay); writer.Write(m_Condition); writer.Write(m_Goto); - writer.Write(m_TimeoutEnd - DateTime.UtcNow); + writer.Write(m_TimeoutEnd - Core.Now); writer.Write(m_Timeout); writer.Write(m_TrigMob); } @@ -337,7 +334,7 @@ public class BaseXmlSpawner m_Goto = reader.ReadInt(); TimeSpan timeoutdelay = reader.ReadTimeSpan(); - m_TimeoutEnd = DateTime.UtcNow + timeoutdelay; + m_TimeoutEnd = Core.Now + timeoutdelay; m_Timeout = reader.ReadTimeSpan(); m_TrigMob = reader.ReadEntity(); @@ -373,9 +370,8 @@ public class BaseXmlSpawner if (!string.IsNullOrEmpty(m_Condition) && m_Spawner != null && m_Spawner.Running) { // if the test is valid then terminate the timer - string status_str; - if (TestItemProperty(m_Spawner, m_Spawner, m_Condition, out status_str)) + if (TestItemProperty(m_Spawner, m_Spawner, m_Condition, out _)) { // spawn the designated subgroup if specified if (m_Goto >= 0 && m_Spawner != null && !m_Spawner.Deleted) @@ -403,7 +399,7 @@ public class BaseXmlSpawner if (m_Tag != null && !m_Tag.Deleted) { // check the timeout if applicable - if (m_Tag.m_Timeout > TimeSpan.Zero && m_Tag.m_TimeoutEnd < DateTime.UtcNow) + if (m_Tag.m_Timeout > TimeSpan.Zero && m_Tag.m_TimeoutEnd < Core.Now) { // release the hold on spawning and delete the tag m_Tag.Delete(); @@ -578,17 +574,6 @@ public class BaseXmlSpawner return "No type with that name was found."; } } - else if (IsParsable(type)) - { - try - { - toSet = Parse(obj, type, value); - } - catch - { - return "That is not properly formatted."; - } - } else if (value == null) { toSet = null; @@ -2553,11 +2538,6 @@ public class BaseXmlSpawner } catch { } } - // try to find the attachment on the mob - if (XmlAttach.FindAttachmentOnMobile(m, atype, aname) != null) - { - return true; - } return false; } @@ -2603,87 +2583,13 @@ public class BaseXmlSpawner // found the item if (testitem != null) { - // check to see if it is a quest token item. If so, then check validity, otherwise just finding it is enough - if (testitem is IXmlQuest token) + // is the equippedonly flag set? If so then see if the item is equipped + if (equippedonly && testitem.Parent == m || !equippedonly) { - if (token.IsValid) - { - if (objstr.Length > objoffset) - { - has_valid_item = true; - // get any objectives and test for them. If any of the required conditions are false, then dont trigger - for (int n = objoffset; n < objstr.Length; n++) - { - try - { - switch (int.Parse(objstr[n]) - objoffset + 1) - { - case 1: - { - if (!token.Completed1) - { - has_valid_item = false; - } - - break; - } - case 2: - { - if (!token.Completed2) - { - has_valid_item = false; - } - - break; - } - case 3: - { - if (!token.Completed3) - { - has_valid_item = false; - } - - break; - } - case 4: - { - if (!token.Completed4) - { - has_valid_item = false; - } - - break; - } - case 5: - { - if (!token.Completed5) - { - has_valid_item = false; - } - - break; - } - } - } - catch { } - } - } - else - // if an objective list has not been specified then just a valid item is enough - { - has_valid_item = true; - } - } - } - else - { - // is the equippedonly flag set? If so then see if the item is equipped - if (equippedonly && testitem.Parent == m || !equippedonly) - { - has_valid_item = true; - } + has_valid_item = true; } } + return has_valid_item; } public static bool CheckForNotCarried(Mobile m, string objectivestr) @@ -2767,12 +2673,6 @@ public class BaseXmlSpawner catch { } } - // try to find the attachment on the mob - if (XmlAttach.FindAttachmentOnMobile(m, atype, aname) != null) - { - return false; - } - return true; } @@ -2818,81 +2718,10 @@ public class BaseXmlSpawner // found the item if (testitem != null) { - // check to see if it is a quest token item. If so, then check validity, otherwise just finding it is enough - if (testitem is IXmlQuest token && token.IsValid) + // is the equippedonly flag set? If so then see if the item is equipped + if (equippedonly && testitem.Parent == m || !equippedonly) { - if (objstr.Length > objoffset) - { - has_no_such_item = true; - // get any objectives and test for them. If any of the required conditions are true, then block trigger - for (int n = objoffset; n < objstr.Length; n++) - { - try - { - switch (int.Parse(objstr[n]) - objoffset + 1) - { - case 1: - { - if (token.Completed1) - { - has_no_such_item = false; - } - - break; - } - case 2: - { - if (token.Completed2) - { - has_no_such_item = false; - } - - break; - } - case 3: - { - if (token.Completed3) - { - has_no_such_item = false; - } - - break; - } - case 4: - { - if (token.Completed4) - { - has_no_such_item = false; - } - - break; - } - case 5: - { - if (token.Completed5) - { - has_no_such_item = false; - } - - break; - } - } - } - catch { } - } - } - else - { - has_no_such_item = false; - } - } - else - { - // is the equippedonly flag set? If so then see if the item is equipped - if (equippedonly && testitem.Parent == m || !equippedonly) - { - has_no_such_item = false; - } + has_no_such_item = false; } } return has_no_such_item; @@ -3296,9 +3125,8 @@ public class BaseXmlSpawner string keypart = remaining.Substring(startindex + 1, endindex); // try to evaluate and then substitute the arg - Type ptype; - string value = ParseForKeywords(spawner, o, keypart.Trim(), true, out ptype); + string value = ParseForKeywords(spawner, o, keypart.Trim(), true, out _); // trim off the " from strings if (value != null) diff --git a/Projects/UOContent/Engines/XMLSpawner/ItemFlags.cs b/Projects/UOContent/Engines/XMLSpawner/ItemFlags.cs index ce893bfcf..0ed76c387 100644 --- a/Projects/UOContent/Engines/XMLSpawner/ItemFlags.cs +++ b/Projects/UOContent/Engines/XMLSpawner/ItemFlags.cs @@ -64,7 +64,7 @@ public partial class ItemFlags { bool state = item.GetSavedFlag(m_flag); - from.SendMessage("Flag (0x{0:X}) = {1}",m_flag,state); + from.SendMessage($"Flag (0x{m_flag:X}) = {state}"); } else { from.SendMessage("Must target an Item"); @@ -123,7 +123,7 @@ public partial class ItemFlags bool state = GetStealable(item); - from.SendMessage("Stealable = {0}",state); + from.SendMessage($"Stealable = {state}"); } else { diff --git a/Projects/UOContent/Engines/XMLSpawner/SpawnerExporter.cs b/Projects/UOContent/Engines/XMLSpawner/SpawnerExporter.cs index d5fa8d955..d8df61e43 100644 --- a/Projects/UOContent/Engines/XMLSpawner/SpawnerExporter.cs +++ b/Projects/UOContent/Engines/XMLSpawner/SpawnerExporter.cs @@ -206,11 +206,11 @@ public class SpawnerExporter } } - e.Mobile.SendMessage("{0} spawners loaded successfully from {1}, {2} failures.", successes, filePath, failures); + e.Mobile.SendMessage($"{successes} spawners loaded successfully from {filePath}, {failures} failures."); } else { - e.Mobile.SendMessage("File {0} does not exist.", filePath); + e.Mobile.SendMessage($"File {filePath} does not exist."); } } else diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlPropsGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlPropsGump.cs index 29e451244..053386ae3 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlPropsGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlPropsGump.cs @@ -608,10 +608,10 @@ public class XmlPropertiesGump : Gump { if (t == typeof(ulong) || t == typeof(uint) || t == typeof(ushort) || t == typeof(byte)) { - return Convert.ChangeType(Convert.ToUInt64(s.Substring(2), 16), t); + return Convert.ChangeType(Convert.ToUInt64(s[2..], 16), t); } - return Convert.ChangeType(Convert.ToInt64(s.Substring(2), 16), t); + return Convert.ChangeType(Convert.ToInt64(s[2..], 16), t); } return Convert.ChangeType(s, t); @@ -621,12 +621,6 @@ public class XmlPropertiesGump : Gump { return Convert.ChangeType(s, t); } - if (t.IsDefined(typeof(ParsableAttribute), false)) - { - MethodInfo parseMethod = t.GetMethod("Parse", new[] { typeof(string) }); - - return parseMethod.Invoke(null, new object[] { s }); - } throw new Exception("bad"); } diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectGump.cs index d0230e414..b69949db6 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectGump.cs @@ -181,7 +181,7 @@ public class XmlSetObjectGump : Gump { toSet = null; shouldSet = false; - m_Mobile.SendMessage("The object with that serial could not be assigned to a property of type : {0}", m_Type.Name); + m_Mobile.SendMessage($"The object with that serial could not be assigned to a property of type : {m_Type.Name}"); } else { diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectTarget.cs b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectTarget.cs index 9c6393b40..303c03d69 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectTarget.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectTarget.cs @@ -49,7 +49,7 @@ public class XmlSetObjectTarget : Target } else { - m_Mobile.SendMessage("That cannot be assigned to a property of type : {0}", m_Type.Name); + m_Mobile.SendMessage($"That cannot be assigned to a property of type : {m_Type.Name}"); } } catch diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlSpawner.cs b/Projects/UOContent/Engines/XMLSpawner/XmlSpawner.cs index abb16a41c..d0c629154 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlSpawner.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlSpawner.cs @@ -231,11 +231,11 @@ public class XmlSpawner : Item, ISpawner // is not counted in the normal item count public override bool IsVirtualItem => true; - private bool m_skillTriggerActivated; - private SkillName m_SkillTriggerName; - private double m_SkillTriggerMin; - private double m_SkillTriggerMax; - private int m_SkillTriggerSuccess; + // private bool m_skillTriggerActivated; + // private SkillName m_SkillTriggerName; + // private double m_SkillTriggerMin; + // private double m_SkillTriggerMax; + // private int m_SkillTriggerSuccess; public bool DebugThis { get; set; } = false; @@ -279,17 +279,17 @@ public class XmlSpawner : Item, ISpawner int minutes; Clock.GetTime(Map, Location.X, Location.Y, out hours, out minutes); - return new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, hours, minutes, 0).TimeOfDay; + return new DateTime(Core.Now.Year, Core.Now.Month, Core.Now.Day, hours, minutes, 0).TimeOfDay; } } - public TimeSpan RealTOD => DateTime.UtcNow.TimeOfDay; + public TimeSpan RealTOD => Core.Now.TimeOfDay; - public int RealDay => DateTime.UtcNow.Day; + public int RealDay => Core.Now.Day; - public int RealMonth => DateTime.UtcNow.Month; + public int RealMonth => Core.Now.Month; - public DayOfWeek RealDayOfWeek => DateTime.UtcNow.DayOfWeek; + public DayOfWeek RealDayOfWeek => Core.Now.DayOfWeek; public MoonPhase MoonPhase => Clock.GetMoonPhase(Map, Location.X, Location.Y); @@ -532,7 +532,7 @@ public class XmlSpawner : Item, ISpawner using (StreamWriter op = new StreamWriter("badspawn.log", true)) { - op.WriteLine("{0} SmartSpawning disabled at {1} {2} : Range too large.", DateTime.UtcNow, loc, Map); + op.WriteLine("{0} SmartSpawning disabled at {1} {2} : Range too large.", Core.Now, loc, Map); op.WriteLine(); } } @@ -656,7 +656,7 @@ public class XmlSpawner : Item, ISpawner } else { - status_str = string.Format("{0} is not a valid type name.", str); + status_str = $"{str} is not a valid type name."; } } InvalidateProperties(); @@ -1304,7 +1304,7 @@ public class XmlSpawner : Item, ISpawner { if (m_refractActivated) { - return m_RefractEnd - DateTime.UtcNow; + return m_RefractEnd - Core.Now; } return TimeSpan.FromSeconds(0); @@ -1402,10 +1402,10 @@ public class XmlSpawner : Item, ISpawner int hours; int minutes; Clock.GetTime(Map, Location.X, Location.Y, out hours, out minutes); - return new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, hours, minutes, 0).TimeOfDay; + return new DateTime(Core.Now.Year, Core.Now.Month, Core.Now.Day, hours, minutes, 0).TimeOfDay; } - return DateTime.UtcNow.TimeOfDay; + return Core.Now.TimeOfDay; } } @@ -1434,12 +1434,12 @@ public class XmlSpawner : Item, ISpawner int hours; int minutes; Clock.GetTime(Map, Location.X, Location.Y, out hours, out minutes); - now = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, hours, minutes, 0); + now = new DateTime(Core.Now.Year, Core.Now.Month, Core.Now.Day, hours, minutes, 0); } else { // calculate the time window - now = DateTime.UtcNow; + now = Core.Now; } var day_start = new DateTime(now.Year, now.Month, now.Day); // calculate the starting TOD window by adding the TODStart to day_start @@ -1491,7 +1491,7 @@ public class XmlSpawner : Item, ISpawner { if (m_durActivated) { - return m_DurEnd - DateTime.UtcNow; + return m_DurEnd - Core.Now; } return TimeSpan.FromSeconds(0); @@ -1565,7 +1565,7 @@ public class XmlSpawner : Item, ISpawner { if (m_Running) { - return m_End - DateTime.UtcNow; + return m_End - Core.Now; } return TimeSpan.FromSeconds(0); @@ -1610,14 +1610,14 @@ public class XmlSpawner : Item, ISpawner { get { - if (m_Running && m_SeqEnd - DateTime.UtcNow > TimeSpan.Zero) + if (m_Running && m_SeqEnd - Core.Now > TimeSpan.Zero) { - return m_SeqEnd - DateTime.UtcNow; + return m_SeqEnd - Core.Now; } return TimeSpan.FromSeconds(0); } - set => m_SeqEnd = DateTime.UtcNow + value; + set => m_SeqEnd = Core.Now + value; } [CommandProperty(AccessLevel.GameMaster)] @@ -2149,7 +2149,7 @@ public class XmlSpawner : Item, ISpawner if (fs == null) { - status_str = string.Format("Unable to open {0} for loading", filename); + status_str = $"Unable to open {filename} for loading"; return; } @@ -2558,14 +2558,14 @@ public class XmlSpawner : Item, ISpawner public static TimeSpan[] _traceTotal = new TimeSpan[MaxTraces]; public static string[] _traceName = new string[MaxTraces]; public static int[] _traceCount = new int[MaxTraces]; - private static DateTime _traceStartTime = DateTime.UtcNow; + private static DateTime _traceStartTime = Core.Now; private static double _startProcessTime; public static void _TraceStart(int index) { if (index < MaxTraces) { - _traceStart[index] = DateTime.UtcNow; + _traceStart[index] = Core.Now; //_traceStart[index] = Process.GetCurrentProcess().UserProcessorTime; } } @@ -2573,7 +2573,7 @@ public class XmlSpawner : Item, ISpawner { if (index < MaxTraces) { - _traceTotal[index] = _traceTotal[index].Add(DateTime.UtcNow - _traceStart[index]); + _traceTotal[index] = _traceTotal[index].Add(Core.Now - _traceStart[index]); //XmlSpawner._traceTotal[index] = XmlSpawner._traceTotal[index].Add(Process.GetCurrentProcess().UserProcessorTime - _traceStart[index]); _traceCount[index]++; } @@ -2725,19 +2725,19 @@ public class XmlSpawner : Item, ISpawner return; } - m_skillTriggerActivated = false; + // m_skillTriggerActivated = false; // check the skill trigger conditions, Skillname[+/-][,min,max] - if (m_SkillTrigger != null && skill.SkillName == m_SkillTriggerName && - (m_SkillTriggerMin < 0 || skill.Value >= m_SkillTriggerMin) && - (m_SkillTriggerMax < 0 || skill.Value <= m_SkillTriggerMax) && - (m_SkillTriggerSuccess == 3 || m_SkillTriggerSuccess == 1 && success || m_SkillTriggerSuccess == 2 && !success)) - { - // have a skill trigger so flag it and test it - m_skillTriggerActivated = true; - - CheckTriggers(m, skill, true); - } + // if (m_SkillTrigger != null && skill.SkillName == m_SkillTriggerName && + // (m_SkillTriggerMin < 0 || skill.Value >= m_SkillTriggerMin) && + // (m_SkillTriggerMax < 0 || skill.Value <= m_SkillTriggerMax) && + // (m_SkillTriggerSuccess == 3 || m_SkillTriggerSuccess == 1 && success || m_SkillTriggerSuccess == 2 && !success)) + // { + // // have a skill trigger so flag it and test it + // m_skillTriggerActivated = true; + // + // CheckTriggers(m, skill, true); + // } } } public override bool HandlesOnSpeech => m_Running && !string.IsNullOrEmpty(m_SpeechTrigger); @@ -3326,7 +3326,7 @@ public class XmlSpawner : Item, ISpawner { return; } - from.SendMessage("{0}", result); + from.SendMessage($"{result}"); } } @@ -3448,7 +3448,7 @@ public class XmlSpawner : Item, ISpawner if (o == targeted) { - from.SendMessage("{0}, {1}, {2}", spawner.X, spawner.Y, spawner.Z); + from.SendMessage($"{spawner.Location}"); if (m_e.GetString(0) == "go") { @@ -3581,7 +3581,7 @@ public class XmlSpawner : Item, ISpawner xml.Close(); } - m.SendMessage("defaults saved to {0}", filePath); + m.SendMessage($"defaults saved to {filePath}"); } public static void XmlLoadDefaults(string filePath, Mobile m) @@ -3601,11 +3601,11 @@ public class XmlSpawner : Item, ISpawner XmlElement root = doc["XmlDefaults"]; LoadDefaults(root); - m.SendMessage("defaults loaded successfully from {0}", filePath); + m.SendMessage($"defaults loaded successfully from {filePath}"); } else { - m.SendMessage("File {0} does not exist.", filePath); + m.SendMessage($"File {filePath} does not exist."); } } } @@ -3742,126 +3742,126 @@ public class XmlSpawner : Item, ISpawner try { defMaxDelay = TimeSpan.FromMinutes(Convert.ToDouble(e.Arguments[1])); - m.SendMessage("MaxDelay = {0}", defMaxDelay); + m.SendMessage($"MaxDelay = {defMaxDelay}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "mindelay") { try { defMinDelay = TimeSpan.FromMinutes(Convert.ToDouble(e.Arguments[1])); - m.SendMessage("MinDelay = {0}", defMinDelay); + m.SendMessage($"MinDelay = {defMinDelay}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "spawnrange") { try { defSpawnRange = Convert.ToInt32(e.Arguments[1]); - m.SendMessage("SpawnRange = {0}", defSpawnRange); + m.SendMessage($"SpawnRange = {defSpawnRange}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "homerange") { try { defHomeRange = Convert.ToInt32(e.Arguments[1]); - m.SendMessage("HomeRange = {0}", defHomeRange); + m.SendMessage($"HomeRange = {defHomeRange}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "relativehome") { try { defRelativeHome = Convert.ToBoolean(e.Arguments[1]); - m.SendMessage("RelativeHome = {0}", defRelativeHome); + m.SendMessage($"RelativeHome = {defRelativeHome}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "proximitytriggersound") { try { defProximityTriggerSound = Convert.ToInt32(e.Arguments[1]); - m.SendMessage("ProximityTriggerSound = {0}", defProximityTriggerSound); + m.SendMessage($"ProximityTriggerSound = {defProximityTriggerSound}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "proximityrange") { try { defProximityRange = Convert.ToInt32(e.Arguments[1]); - m.SendMessage("ProximityRange = {0}", defProximityRange); + m.SendMessage($"ProximityRange = {defProximityRange}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "triggerprobability") { try { defTriggerProbability = Convert.ToDouble(e.Arguments[1]); - m.SendMessage("TriggerProbability = {0}", defTriggerProbability); + m.SendMessage($"TriggerProbability = {defTriggerProbability}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "todstart") { try { defTODStart = TimeSpan.FromMinutes(Convert.ToDouble(e.Arguments[1])); - m.SendMessage("TODStart = {0}", defTODStart); + m.SendMessage($"TODStart = {defTODStart}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "todend") { try { defTODEnd = TimeSpan.FromMinutes(Convert.ToDouble(e.Arguments[1])); - m.SendMessage("TODEnd = {0}", defTODEnd); + m.SendMessage($"TODEnd = {defTODEnd}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "stackamount") { try { defAmount = Convert.ToInt32(e.Arguments[1]); - m.SendMessage("StackAmount = {0}", defAmount); + m.SendMessage($"StackAmount = {defAmount}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "duration") { try { defDuration = TimeSpan.FromMinutes(Convert.ToDouble(e.Arguments[1])); - m.SendMessage("Duration = {0}", defDuration); + m.SendMessage($"Duration = {defDuration}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "group") { try { defIsGroup = Convert.ToBoolean(e.Arguments[1]); - m.SendMessage("Group = {0}", defIsGroup); + m.SendMessage($"Group = {defIsGroup}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "team") { try { defTeam = Convert.ToInt32(e.Arguments[1]); - m.SendMessage("Team = {0}", defTeam); + m.SendMessage($"Team = {defTeam}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "todmode") { @@ -3881,31 +3881,31 @@ public class XmlSpawner : Item, ISpawner break; } } - m.SendMessage("TODMode = {0}", defTODMode); + m.SendMessage($"TODMode = {defTODMode}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "maxrefractory") { try { defMaxRefractory = TimeSpan.FromMinutes(Convert.ToDouble(e.Arguments[1])); - m.SendMessage("MaxRefractory = {0}", defMaxRefractory); + m.SendMessage($"MaxRefractory = {defMaxRefractory}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else if (e.Arguments[0].ToLower() == "minrefractory") { try { defMinRefractory = TimeSpan.FromMinutes(Convert.ToDouble(e.Arguments[1])); - m.SendMessage("MinRefractory = {0}", defMinRefractory); + m.SendMessage($"MinRefractory = {defMinRefractory}"); } - catch { m.SendMessage("invalid value : {0}", e.Arguments[1]); } + catch { m.SendMessage($"invalid value : {e.Arguments[1]}"); } } else { - m.SendMessage("{0} : no such default value.", e.Arguments[0]); + m.SendMessage($"{e.Arguments[0]} : no such default value."); } } @@ -3913,23 +3913,23 @@ public class XmlSpawner : Item, ISpawner else { // just display the values - m.SendMessage("TriggerProbability = {0}", defTriggerProbability); - m.SendMessage("ProximityRange = {0}", defProximityRange); - m.SendMessage("ProximityTriggerSound = {0}", defProximityTriggerSound); - m.SendMessage("MinRefractory = {0}", defMinRefractory); - m.SendMessage("MaxRefractory = {0}", defMaxRefractory); - m.SendMessage("TODStart = {0}", defTODStart); - m.SendMessage("TODEnd = {0}", defTODEnd); - m.SendMessage("TODMode = {0}", defTODMode); - m.SendMessage("StackAmount = {0}", defAmount); - m.SendMessage("Duration = {0}", defDuration); - m.SendMessage("Group = {0}", defIsGroup); - m.SendMessage("Team = {0}", defTeam); - m.SendMessage("RelativeHome = {0}", defRelativeHome); - m.SendMessage("SpawnRange = {0}", defSpawnRange); - m.SendMessage("HomeRange = {0}", defHomeRange); - m.SendMessage("MinDelay = {0}", defMinDelay); - m.SendMessage("MaxDelay = {0}", defMaxDelay); + m.SendMessage($"TriggerProbability = {defTriggerProbability}"); + m.SendMessage($"ProximityRange = {defProximityRange}"); + m.SendMessage($"ProximityTriggerSound = {defProximityTriggerSound}"); + m.SendMessage($"MinRefractory = {defMinRefractory}"); + m.SendMessage($"MaxRefractory = {defMaxRefractory}"); + m.SendMessage($"TODStart = {defTODStart}"); + m.SendMessage($"TODEnd = {defTODEnd}"); + m.SendMessage($"TODMode = {defTODMode}"); + m.SendMessage($"StackAmount = {defAmount}"); + m.SendMessage($"Duration = {defDuration}"); + m.SendMessage($"Group = {defIsGroup}"); + m.SendMessage($"Team = {defTeam}"); + m.SendMessage($"RelativeHome = {defRelativeHome}"); + m.SendMessage($"SpawnRange = {defSpawnRange}"); + m.SendMessage($"HomeRange = {defHomeRange}"); + m.SendMessage($"MinDelay = {defMinDelay}"); + m.SendMessage($"MaxDelay = {defMaxDelay}"); } } @@ -4054,7 +4054,7 @@ public class XmlSpawner : Item, ISpawner } else { - from.SendMessage("Map '{0}' does not exist!", MapName); + from.SendMessage($"Map '{MapName}' does not exist!"); return; } @@ -4157,21 +4157,18 @@ public class XmlSpawner : Item, ISpawner maxpercent = 100 * maxcount / totalcount; } - e.Mobile.SendMessage( - "Smartspawning access level is {10}\n" + - "--------------------------------\n" + - "{0} XmlSpawners\n" + - "{1} are configured for SmartSpawning\n" + - "{2} are currently inactivated\n" + - "{9} sectors being monitored\n" + - "Maximum possible spawn count is {3}\n" + - "Maximum possible spawn reduction is {4}\n" + - "Current spawn count is {5}\n" + - "Current spawn reduction is {6}\n" + - "Maximum possible savings is {7}%\n" + - "Current savings is {8}%", - count, smartcount, inactivecount, totalcount, maxcount, currentcount, savings, maxpercent, - percent, totalSectorsMonitored, SmartSpawnAccessLevel); + e.Mobile.SendMessage($"Smartspawning access level is {SmartSpawnAccessLevel}"); + e.Mobile.SendMessage($"--------------------------------"); + e.Mobile.SendMessage($"{count} XmlSpawners"); + e.Mobile.SendMessage($"{smartcount} are configured for SmartSpawning\n"); + e.Mobile.SendMessage($"{inactivecount} are currently inactivated"); + e.Mobile.SendMessage($"{totalSectorsMonitored} sectors being monitored\n"); + e.Mobile.SendMessage($"Maximum possible spawn count is {totalcount}"); + e.Mobile.SendMessage($"Maximum possible spawn reduction is {maxcount}\n"); + e.Mobile.SendMessage($"Current spawn count is {currentcount}"); + e.Mobile.SendMessage($"Current spawn reduction is {savings}"); + e.Mobile.SendMessage($"Maximum possible savings is {maxpercent}%"); + e.Mobile.SendMessage($"Current savings is {percent}%"); } [Usage("OptimalSmartSpawning [max spawn/homerange diff]")] @@ -4268,8 +4265,8 @@ public class XmlSpawner : Item, ISpawner } } - e.Mobile.SendMessage("Configured {0} XmlSpawners for SmartSpawning using maxdiff of {1}", count, maxdiff); - e.Mobile.SendMessage("Estimated item/mob reduction is {0}", maxcount); + e.Mobile.SendMessage($"Configured {count} XmlSpawners for SmartSpawning using maxdiff of {maxdiff}"); + e.Mobile.SendMessage($"Estimated item/mob reduction is {maxcount}"); } [Usage("XmlSpawnerWipe [SpawnerPrefixFilter]")] @@ -4313,7 +4310,7 @@ public class XmlSpawner : Item, ISpawner { if (from != null) { - from.SendMessage("Unable to open {0} for unloading", filename); + from.SendMessage($"Unable to open {filename} for unloading"); } return; @@ -4337,7 +4334,7 @@ public class XmlSpawner : Item, ISpawner { if (from != null) { - from.SendMessage("UnLoading {0} .xml files from directory {1}", files.Length, filename); + from.SendMessage($"UnLoading {files.Length} .xml files from directory {filename}"); } foreach (string file in files) @@ -4365,7 +4362,7 @@ public class XmlSpawner : Item, ISpawner } if (from != null) { - from.SendMessage("UnLoaded a total of {0} .xml files and {2} spawners from directory {1}", total_processed_maps, filename, total_processed_spawners); + from.SendMessage($"UnLoaded a total of {total_processed_maps} .xml files and {total_processed_spawners} spawners from directory {filename}"); } processedmaps = total_processed_maps; @@ -4375,7 +4372,7 @@ public class XmlSpawner : Item, ISpawner { if (from != null) { - from.SendMessage("{0} does not exist", filename); + from.SendMessage($"{filename} does not exist"); } } @@ -4403,8 +4400,9 @@ public class XmlSpawner : Item, ISpawner if (from != null) { - from.SendMessage(string.Format("UnLoading {0} objects{1} from file {2}.", - "XmlSpawner", !string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" : string.Empty, filename)); + from.SendMessage( + $"UnLoading {"XmlSpawner"} objects{(!string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" : string.Empty)} from file {filename}." + ); } // Create the data set @@ -4421,7 +4419,7 @@ public class XmlSpawner : Item, ISpawner { if (from != null) { - from.SendMessage(33, "Error reading xml file {0}", filename); + from.SendMessage(33, $"Error reading xml file {filename}"); } fileerror = true; @@ -4544,15 +4542,16 @@ public class XmlSpawner : Item, ISpawner if (from != null) { - from.SendMessage("{0}/{8} spawner(s) were unloaded using file {1} [Trammel={2}, Felucca={3}, Ilshenar={4}, Malas={5}, Tokuno={6}, Other={7}].", - spawners_deleted, filename, TrammelCount, FeluccaCount, IlshenarCount, MalasCount, TokunoCount, OtherCount, TotalCount); + from.SendMessage( + $"{spawners_deleted}/{TotalCount} spawner(s) were unloaded using file {filename} [Trammel={TrammelCount}, Felucca={FeluccaCount}, Ilshenar={IlshenarCount}, Malas={MalasCount}, Tokuno={TokunoCount}, Other={OtherCount}]." + ); } if (bad_spawner_count > 0) { if (from != null) { - from.SendMessage(33, "{0} bad spawners detected.", bad_spawner_count); + from.SendMessage(33, $"{bad_spawner_count} bad spawners detected."); } } @@ -4579,13 +4578,11 @@ public class XmlSpawner : Item, ISpawner } string filename = LocateFile(e.Arguments[0]); - int processedmaps; - int processedspawners; - XmlUnLoadFromFile(filename, SpawnerPrefix, e.Mobile, out processedmaps, out processedspawners); + XmlUnLoadFromFile(filename, SpawnerPrefix, e.Mobile, out _, out _); } else { - e.Mobile.SendMessage("Usage: {0} ", e.Command); + e.Mobile.SendMessage($"Usage: {e.Command} "); } } else @@ -4604,13 +4601,11 @@ public class XmlSpawner : Item, ISpawner { string filename = e.Arguments[0]; - int processedmaps; - int processedspawners; - XmlImportMap(filename, e.Mobile, out processedmaps, out processedspawners); + XmlImportMap(filename, e.Mobile, out _, out _); } else { - e.Mobile.SendMessage("Usage: {0} ", e.Command); + e.Mobile.SendMessage($"Usage: {e.Command} "); } } else @@ -4688,10 +4683,10 @@ public class XmlSpawner : Item, ISpawner catch (Exception e) { // Let the user know what went wrong. - from.SendMessage("The file could not be read: {0}", e.Message); + from.SendMessage($"The file could not be read: {e.Message}"); } - from.SendMessage("Imported {0} spawners from {1}", spawnercount, filename); - from.SendMessage("{0} bad spawners detected", badspawnercount); + from.SendMessage($"Imported {spawnercount} spawners from {filename}"); + from.SendMessage($"{badspawnercount} bad spawners detected"); processedmaps = 1; processedspawners = spawnercount; } @@ -4708,7 +4703,7 @@ public class XmlSpawner : Item, ISpawner catch { } if (files != null && files.Length > 0) { - from.SendMessage("Importing {0} .map files from directory {1}", files.Length, filename); + from.SendMessage($"Importing {files.Length} .map files from directory {filename}"); foreach (string file in files) { XmlImportMap(file, from, out processedmaps, out processedspawners); @@ -4732,13 +4727,15 @@ public class XmlSpawner : Item, ISpawner total_processed_spawners += processedspawners; } } - from.SendMessage("Imported a total of {0} .map files and {2} spawners from directory {1}", total_processed_maps, filename, total_processed_spawners); + from.SendMessage( + $"Imported a total of {total_processed_maps} .map files and {filename} spawners from directory {total_processed_spawners}" + ); processedmaps = total_processed_maps; processedspawners = total_processed_spawners; } else { - from.SendMessage("{0} does not exist", filename); + from.SendMessage($"{filename} does not exist"); } } @@ -4835,7 +4832,7 @@ public class XmlSpawner : Item, ISpawner maxcount[k] = int.Parse(args[k + 16]); } } - catch { from.SendMessage("Parsing error at line {0}", linenumber); badspawn = true; } + catch { from.SendMessage($"Parsing error at line {linenumber}"); badspawn = true; } // compute the total number of spawns int totalspawns = 0; @@ -4924,8 +4921,8 @@ public class XmlSpawner : Item, ISpawner { // invalid so dont spawn it badspawnercount++; - from.SendMessage("Invalid map/location at line {0}", linenumber); - from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber); + from.SendMessage($"Invalid map/location at line {linenumber}"); + from.SendMessage($"Bad spawn at line {line}: {line}"); return; } @@ -4966,7 +4963,7 @@ public class XmlSpawner : Item, ISpawner Guid SpawnId = Guid.NewGuid(); // and give it a name based on the spawner count and file - string spawnername = string.Format("{0}#{1}", Path.GetFileNameWithoutExtension(filename), spawnercount); + string spawnername = $"{Path.GetFileNameWithoutExtension(filename)}#{spawnercount}"; // Create the new xml spawner XmlSpawner spawner = new XmlSpawner(SpawnId, x, y, 0, 0, spawnername, totalmaxcount, @@ -4985,8 +4982,8 @@ public class XmlSpawner : Item, ISpawner { badspawnercount++; spawner.Delete(); - from.SendMessage("Invalid map at line {0}", linenumber); - from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber); + from.SendMessage($"Invalid map at line {linenumber}"); + from.SendMessage($"Bad spawn at line {linenumber}: {line}"); return; } spawnercount++; @@ -5013,7 +5010,7 @@ public class XmlSpawner : Item, ISpawner { badspawnercount++; spawner.Delete(); - from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber); + from.SendMessage($"Bad spawn at line {linenumber}: {line}"); return; } spawnercount++; @@ -5022,7 +5019,7 @@ public class XmlSpawner : Item, ISpawner else { badspawnercount++; - from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber); + from.SendMessage($"Bad spawn at line {linenumber}: {line}"); } } } @@ -5095,7 +5092,7 @@ public class XmlSpawner : Item, ISpawner if (args.Length != 11 && args.Length != 12) { badspawn = true; - from.SendMessage("Invalid arg count {1} at line {0}", linenumber, args.Length); + from.SendMessage($"Invalid arg count {args.Length} at line {linenumber}"); } else { @@ -5119,7 +5116,7 @@ public class XmlSpawner : Item, ISpawner maxcount = int.Parse(args[10]); } - catch { from.SendMessage("Parsing error at line {0}", linenumber); badspawn = true; } + catch { from.SendMessage($"Parsing error at line {linenumber}"); badspawn = true; } } else if (args.Length == 12) @@ -5139,7 +5136,7 @@ public class XmlSpawner : Item, ISpawner maxcount = int.Parse(args[11]); } - catch { from.SendMessage("Parsing error at line {0}", linenumber); badspawn = true; } + catch { from.SendMessage($"Parsing error at line {linenumber}"); badspawn = true; } } } @@ -5207,8 +5204,8 @@ public class XmlSpawner : Item, ISpawner { // invalid so dont spawn it badspawnercount++; - from.SendMessage("Invalid map/location at line {0}", linenumber); - from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber); + from.SendMessage($"Invalid map/location at line {linenumber}"); + from.SendMessage($"Bad spawn at line {linenumber}: {line}"); return; } @@ -5236,7 +5233,7 @@ public class XmlSpawner : Item, ISpawner Guid SpawnId = Guid.NewGuid(); // and give it a name based on the spawner count and file - string spawnername = string.Format("{0}#{1}", Path.GetFileNameWithoutExtension(filename), spawnercount); + string spawnername = $"{Path.GetFileNameWithoutExtension(filename)}#{spawnercount}"; // Create the new xml spawner XmlSpawner spawner = new XmlSpawner(SpawnId, x, y, 0, 0, spawnername, maxcount, @@ -5255,8 +5252,8 @@ public class XmlSpawner : Item, ISpawner { badspawnercount++; spawner.Delete(); - from.SendMessage("Invalid map at line {0}", linenumber); - from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber); + from.SendMessage($"Invalid map at line {linenumber}"); + from.SendMessage($"Bad spawn at line {linenumber}: {line}"); return; } spawnercount++; @@ -5283,7 +5280,7 @@ public class XmlSpawner : Item, ISpawner { badspawnercount++; spawner.Delete(); - from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber); + from.SendMessage($"Bad spawn at line {linenumber}: {line}"); return; } spawnercount++; @@ -5292,7 +5289,7 @@ public class XmlSpawner : Item, ISpawner else { badspawnercount++; - from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber); + from.SendMessage($"Bad spawn at line {linenumber}: {line}"); } } } @@ -5314,7 +5311,7 @@ public class XmlSpawner : Item, ISpawner } catch { - e.Mobile.SendMessage("unable to load file {0}.", filePath); + e.Mobile.SendMessage($"unable to load file {filePath}."); return; } @@ -5329,14 +5326,14 @@ public class XmlSpawner : Item, ISpawner ImportSpawner(spawner, e.Mobile); successes++; } - catch (Exception ex) { e.Mobile.SendMessage(33, "{0} {1}", ex.Message, spawner.InnerText); failures++; } + catch (Exception ex) { e.Mobile.SendMessage(33, $"{ex.Message} {spawner.InnerText}"); failures++; } } } - e.Mobile.SendMessage("{0} spawners loaded successfully from {1}, {2} failures.", successes, filePath, failures); + e.Mobile.SendMessage($"{successes} spawners loaded successfully from {filePath}, {failures} failures."); } else { - e.Mobile.SendMessage("File {0} does not exist.", filePath); + e.Mobile.SendMessage($"File {filePath} does not exist."); } } else @@ -5461,9 +5458,9 @@ public class XmlSpawner : Item, ISpawner ImportMegaSpawner(e.Mobile, spawner); successes++; } - catch (Exception ex) { e.Mobile.SendMessage(33, "{0} {1}", ex.Message, spawner.InnerText); failures++; } + catch (Exception ex) { e.Mobile.SendMessage(33, $"{ex.Message} {spawner.InnerText}"); failures++; } } - e.Mobile.SendMessage("{0} megaspawners loaded successfully from {1}, {2} failures.", successes, filePath, failures); + e.Mobile.SendMessage($"{successes} megaspawners loaded successfully from {filePath}, {failures} failures."); } else { @@ -5472,7 +5469,7 @@ public class XmlSpawner : Item, ISpawner } else { - e.Mobile.SendMessage("File {0} does not exist.", filePath); + e.Mobile.SendMessage($"File {filePath} does not exist."); } } else @@ -5631,12 +5628,12 @@ public class XmlSpawner : Item, ISpawner { using (StreamWriter op = new StreamWriter("badimport.log", true)) { - op.WriteLine("{0} MSFImport Error; inconsistent entry count {1} {2}", DateTime.UtcNow, location, map); + op.WriteLine($"{Core.Now} MSFImport Error; inconsistent entry count {location} {map}"); op.WriteLine(); } } catch { } - from.SendMessage("Inconsistent entry count detected at {0} {1}.", location, map); + from.SendMessage($"Inconsistent entry count detected at {location} {map}."); break; } @@ -5644,13 +5641,13 @@ public class XmlSpawner : Item, ISpawner } if (diff) { - from.SendMessage("Individual entry setting detected at {0} {1}.", location, map); + from.SendMessage($"Individual entry setting detected at {location} {map}."); // log it try { using (StreamWriter op = new StreamWriter("badimport.log", true)) { - op.WriteLine("{0} MSFImport: Individual entry setting differences listed above from spawner at {1} {2}", DateTime.UtcNow, location, map); + op.WriteLine($"{Core.Now} MSFImport: Individual entry setting differences listed above from spawner at {location} {map}"); op.WriteLine(); } } @@ -5729,7 +5726,7 @@ public class XmlSpawner : Item, ISpawner { if (from != null) { - from.SendMessage("Unable to open {0} for loading", filename); + from.SendMessage($"Unable to open {filename} for loading"); } return; @@ -5752,7 +5749,7 @@ public class XmlSpawner : Item, ISpawner { if (from != null) { - from.SendMessage("Loading {0} .xml files from directory {1}", files.Length, filename); + from.SendMessage($"Loading {files.Length} .xml files from directory {filename}"); } foreach (string file in files) @@ -5780,7 +5777,7 @@ public class XmlSpawner : Item, ISpawner } if (from != null) { - from.SendMessage("Loaded a total of {0} .xml files and {2} spawners from directory {1}", total_processed_maps, filename, total_processed_spawners); + from.SendMessage($"Loaded a total of {total_processed_maps} .xml files and {filename} spawners from directory {total_processed_spawners}"); } processedmaps = total_processed_maps; @@ -5790,7 +5787,7 @@ public class XmlSpawner : Item, ISpawner { if (from != null) { - from.SendMessage("{0} does not exist", filename); + from.SendMessage($"{filename} does not exist"); } } @@ -5877,7 +5874,7 @@ public class XmlSpawner : Item, ISpawner { if (from != null) { - from.SendMessage(33, "Error reading xml file {0}", filename); + from.SendMessage(33, $"Error reading xml file {filename}"); } fileerror = true; @@ -5908,7 +5905,7 @@ public class XmlSpawner : Item, ISpawner if (loadnew) { // append the new id to the name - SpawnName = string.Format("{0}-{1}", SpawnName, newloadid); + SpawnName = $"{SpawnName}-{newloadid}"; } // Check if there is any spawner name criteria specified on the load @@ -6272,8 +6269,7 @@ public class XmlSpawner : Item, ISpawner { if (from != null) { - from.SendMessage(33, "Invalid location '{0}' at [{1} {2}] in {3}", - SpawnName, SpawnCentreX, SpawnCentreY, XmlMapName); + from.SendMessage(33, $"Invalid location '{SpawnName}' at [{SpawnCentreX} {SpawnCentreY}] in {XmlMapName}"); } bad_spawner = true; @@ -6333,7 +6329,7 @@ public class XmlSpawner : Item, ISpawner { using (StreamWriter op = new StreamWriter("badxml.log", true)) { - op.WriteLine("# Invalid spawner : {0}: Fileposition {1} {2}", DateTime.UtcNow, fileposition, filename); + op.WriteLine("# Invalid spawner : {0}: Fileposition {1} {2}", Core.Now, fileposition, filename); op.WriteLine(); } } @@ -6345,8 +6341,7 @@ public class XmlSpawner : Item, ISpawner questionablecount++; if (from != null) { - from.SendMessage(33, "Questionable spawner '{0}' at [{1} {2}] in {3}", - SpawnName, SpawnCentreX, SpawnCentreY, XmlMapName); + from.SendMessage(33, $"Questionable spawner '{SpawnName}' at [{SpawnCentreX} {SpawnCentreY}] in {XmlMapName}"); } // log it @@ -6357,7 +6352,7 @@ public class XmlSpawner : Item, ISpawner { using (StreamWriter op = new StreamWriter("badxml.log", true)) { - op.WriteLine("# Questionable spawner : {0}: Format: X Y Z Map SpawnerName Fileposition Xmlfile", DateTime.UtcNow); + op.WriteLine("# Questionable spawner : {0}: Format: X Y Z Map SpawnerName Fileposition Xmlfile", Core.Now); op.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}", SpawnCentreX, SpawnCentreY, SpawnCentreZ, XmlMapName, SpawnName, fileposition, filename); op.WriteLine(); } @@ -6441,7 +6436,7 @@ public class XmlSpawner : Item, ISpawner // Send a message to the client that the spawner is created if (from != null && verbose) { - from.SendMessage(188, "Created '{0}' in {1} at {2}", TheSpawn.Name, TheSpawn.Map.Name, TheSpawn.Location.ToString()); + from.SendMessage(188, $"Created '{TheSpawn.Name}' in {TheSpawn.Map.Name} at {TheSpawn.Location}"); } // Do a total respawn @@ -6536,7 +6531,7 @@ public class XmlSpawner : Item, ISpawner // if this is a new load then assume that it will be referring to another newly loaded object so append the newloadid if (loadnew) { - string tmpsetObjectName = string.Format("{0}-{1}", namestr, newloadid); + string tmpsetObjectName = $"{namestr}-{newloadid}"; OldSpawner.m_SetPropertyItem = BaseXmlSpawner.FindItemByName(null, tmpsetObjectName, typestr); } // if this fails then try the original @@ -6549,8 +6544,7 @@ public class XmlSpawner : Item, ISpawner failedsetitemcount++; if (from != null) { - from.SendMessage(33, "Failed to initialize SetItemProperty Object '{0}' on ' '{1}' at [{2} {3}] in {4}", - setObjectName, OldSpawner.Name, OldSpawner.Location.X, OldSpawner.Location.Y, OldSpawner.Map); + from.SendMessage(33, $"Failed to initialize SetItemProperty Object '{setObjectName}' on ' '{OldSpawner.Name}' at [{OldSpawner.Location.X} {OldSpawner.Location.Y}] in {OldSpawner.Map}"); } // log it @@ -6559,7 +6553,7 @@ public class XmlSpawner : Item, ISpawner using (StreamWriter op = new StreamWriter("badxml.log", true)) { op.WriteLine("# Failed SetItemProperty Object initialization : {0}: Format: ObjectName X Y Z Map SpawnerName Xmlfile", - DateTime.UtcNow); + Core.Now); op.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}", setObjectName, OldSpawner.Location.X, OldSpawner.Location.Y, OldSpawner.Location.Z, OldSpawner.Map, OldSpawner.Name, filename); op.WriteLine(); @@ -6588,7 +6582,7 @@ public class XmlSpawner : Item, ISpawner // if this is a new load then assume that it will be referring to another newly loaded object so append the newloadid if (loadnew) { - string tmptriggerObjectName = string.Format("{0}-{1}", namestr, newloadid); + string tmptriggerObjectName = $"{namestr}-{newloadid}"; OldSpawner.m_ObjectPropertyItem = BaseXmlSpawner.FindItemByName(null, tmptriggerObjectName, typestr); } // if this fails then try the original @@ -6601,8 +6595,7 @@ public class XmlSpawner : Item, ISpawner failedobjectitemcount++; if (from != null) { - from.SendMessage(33, "Failed to initialize TriggerObject '{0}' on ' '{1}' at [{2} {3}] in {4}", - triggerObjectName, OldSpawner.Name, OldSpawner.Location.X, OldSpawner.Location.Y, OldSpawner.Map); + from.SendMessage(33, $"Failed to initialize TriggerObject '{triggerObjectName}' on ' '{OldSpawner.Name}' at [{OldSpawner.Location.X} {OldSpawner.Location.Y}] in {OldSpawner.Map}"); } // log it @@ -6611,7 +6604,7 @@ public class XmlSpawner : Item, ISpawner using (StreamWriter op = new StreamWriter("badxml.log", true)) { op.WriteLine("# Failed TriggerObject initialization : {0}: Format: ObjectName X Y Z Map SpawnerName Xmlfile", - DateTime.UtcNow); + Core.Now); op.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}", triggerObjectName, OldSpawner.Location.X, OldSpawner.Location.Y, OldSpawner.Location.Z, OldSpawner.Map, OldSpawner.Name, filename); op.WriteLine(); @@ -6634,36 +6627,35 @@ public class XmlSpawner : Item, ISpawner if (from != null) { - from.SendMessage("{0} spawner(s) were created from file {1} [Trammel={2}, Felucca={3}, Ilshenar={4}, Malas={5}, Tokuno={6} Other={7}].", - TotalCount, filename, TrammelCount, FeluccaCount, IlshenarCount, MalasCount, TokunoCount, OtherCount); + from.SendMessage($"{TotalCount} spawner(s) were created from file {filename} [Trammel={TrammelCount}, Felucca={FeluccaCount}, Ilshenar={IlshenarCount}, Malas={MalasCount}, Tokuno={TokunoCount} Other={OtherCount}]."); } if (failedobjectitemcount > 0) { if (from != null) { - from.SendMessage(33, "Failed to initialize TriggerObjects in {0} spawners. Saved to 'badxml.log'", failedobjectitemcount); + from.SendMessage(33, $"Failed to initialize TriggerObjects in {failedobjectitemcount} spawners. Saved to 'badxml.log'"); } } if (failedsetitemcount > 0) { if (from != null) { - from.SendMessage(33, "Failed to initialize SetItemProperty Objects in {0} spawners. Saved to 'badxml.log'", failedsetitemcount); + from.SendMessage(33, $"Failed to initialize SetItemProperty Objects in {failedsetitemcount} spawners. Saved to 'badxml.log'"); } } if (badcount > 0) { if (from != null) { - from.SendMessage(33, "{0} bad spawners detected. Saved to 'badxml.log'", badcount); + from.SendMessage(33, $"{badcount} bad spawners detected. Saved to 'badxml.log'"); } } if (questionablecount > 0) { if (from != null) { - from.SendMessage(33, "{0} questionable spawners detected. Saved to 'badxml.log'", questionablecount); + from.SendMessage(33, $"{questionablecount} questionable spawners detected. Saved to 'badxml.log'"); } } processedmaps = 1; @@ -6680,7 +6672,7 @@ public class XmlSpawner : Item, ISpawner if (Directory.Exists(XmlSpawnDir)) { // get it from the defaults directory if it exists - dirname = string.Format("{0}/{1}", XmlSpawnDir, filename); + dirname = $"{XmlSpawnDir}/{filename}"; found = File.Exists(dirname) || Directory.Exists(dirname); } @@ -6712,14 +6704,11 @@ public class XmlSpawner : Item, ISpawner SpawnerPrefix = e.Arguments[1]; } - int processedmaps; - int processedspawners; - - XmlLoadFromFile(filename, SpawnerPrefix, e.Mobile, false, 0, true, out processedmaps, out processedspawners); + XmlLoadFromFile(filename, SpawnerPrefix, e.Mobile, false, 0, true, out _, out _); } else { - e.Mobile.SendMessage("Usage: {0} [SpawnerPrefixFilter]", e.Command); + e.Mobile.SendMessage($"Usage: {e.Command} [SpawnerPrefixFilter]"); } } else @@ -6749,14 +6738,11 @@ public class XmlSpawner : Item, ISpawner SpawnerPrefix = e.Arguments[1]; } - int processedmaps; - int processedspawners; - - XmlLoadFromFile(filename, SpawnerPrefix, m, false, 0, false, out processedmaps, out processedspawners); + XmlLoadFromFile(filename, SpawnerPrefix, m, false, 0, false, out _, out _); } else if (m != null) { - e.Mobile.SendMessage("Usage: {0} [SpawnerPrefixFilter]", e.Command); + e.Mobile.SendMessage($"Usage: {e.Command} [SpawnerPrefixFilter]"); } } else @@ -6797,19 +6783,16 @@ public class XmlSpawner : Item, ISpawner } } } - catch { e.Mobile.SendMessage("Usage: {0} [SpawnerPrefixFilter][-maxrange range]", e.Command); badargs = true; } + catch { e.Mobile.SendMessage($"Usage: {e.Command} [SpawnerPrefixFilter][-maxrange range]"); badargs = true; } if (!badargs) { - int processedmaps; - int processedspawners; - - XmlLoadFromFile(filename, SpawnerPrefix, e.Mobile, true, maxrange, true, out processedmaps, out processedspawners); + XmlLoadFromFile(filename, SpawnerPrefix, e.Mobile, true, maxrange, true, out _, out _); } } else { - e.Mobile.SendMessage("Usage: {0} [SpawnerPrefixFilter][-maxrange range]", e.Command); + e.Mobile.SendMessage($"Usage: {e.Command} [SpawnerPrefixFilter][-maxrange range]"); } } else @@ -6849,19 +6832,16 @@ public class XmlSpawner : Item, ISpawner } } } - catch { e.Mobile.SendMessage("Usage: {0} [SpawnerPrefixFilter][-maxrange range]", e.Command); badargs = true; } + catch { e.Mobile.SendMessage($"Usage: {e.Command} [SpawnerPrefixFilter][-maxrange range]"); badargs = true; } if (!badargs) { - int processedmaps; - int processedspawners; - - XmlLoadFromFile(filename, SpawnerPrefix, e.Mobile, true, maxrange, false, out processedmaps, out processedspawners); + XmlLoadFromFile(filename, SpawnerPrefix, e.Mobile, true, maxrange, false, out _, out _); } } else { - e.Mobile.SendMessage("Usage: {0} [SpawnerPrefixFilter][-maxrange range]", e.Command); + e.Mobile.SendMessage($"Usage: {e.Command} [SpawnerPrefixFilter][-maxrange range]"); } } else @@ -6912,7 +6892,7 @@ public class XmlSpawner : Item, ISpawner if (e.Arguments.Length < 1) { - e.Mobile.SendMessage("Usage: {0} (without spaces!!)", e.Command); + e.Mobile.SendMessage($"Usage: {e.Command} (without spaces!!)"); return; } @@ -6928,7 +6908,7 @@ public class XmlSpawner : Item, ISpawner Mobile m = e.Mobile; - CommandLogging.WriteLine(m, "{0} {1} Saving XmlSpawner {2} on file {3}", m.AccessLevel, CommandLogging.Format(m), CommandLogging.Format(xmlspawner), CommandLogging.Format(filename)); + CommandLogging.WriteLine(m, $"{m.AccessLevel} {CommandLogging.Format(m)} Saving XmlSpawner {CommandLogging.Format(xmlspawner)} on file {CommandLogging.Format(filename)}"); SaveSpawns(m, xmlspawner, filename); } } @@ -6946,7 +6926,7 @@ public class XmlSpawner : Item, ISpawner if (Directory.Exists(XmlSpawnDir) && filename != null && !filename.StartsWith("/") && !filename.StartsWith("\\")) { // put it in the defaults directory if it exists - dirname = string.Format("{0}/{1}", XmlSpawnDir, filename); + dirname = $"{XmlSpawnDir}/{filename}"; } else { @@ -6954,7 +6934,7 @@ public class XmlSpawner : Item, ISpawner dirname = filename; } - m.SendMessage("Saving object in folder {0} - file {1} - spawner {2}.", dirname, filename, xmlspawner); + m.SendMessage($"Saving object in folder {dirname} - file {filename} - spawner {xmlspawner}."); List saveslist = new List(1); saveslist.Add(xmlspawner); @@ -6976,7 +6956,7 @@ public class XmlSpawner : Item, ISpawner if (e.Arguments != null && e.Arguments.Length < 1) { - e.Mobile.SendMessage("Usage: {0} [SpawnerPrefixFilter]", e.Command); + e.Mobile.SendMessage($"Usage: {e.Command} [SpawnerPrefixFilter]"); return; } @@ -6995,7 +6975,7 @@ public class XmlSpawner : Item, ISpawner if (Directory.Exists(XmlSpawnDir) && filename != null && !filename.StartsWith("/") && !filename.StartsWith("\\")) { // put it in the defaults directory if it exists - dirname = string.Format("{0}/{1}", XmlSpawnDir, filename); + dirname = $"{XmlSpawnDir}/{filename}"; } else { @@ -7005,13 +6985,15 @@ public class XmlSpawner : Item, ISpawner if (SaveAllMaps) { - e.Mobile.SendMessage(string.Format("Saving {0} objects{1} to file {2} from {3}.", "XmlSpawner", - !string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" : string.Empty, dirname, e.Mobile.Map)); + e.Mobile.SendMessage( + $"Saving XmlSpawner objects{(!string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" : string.Empty)} to file {dirname} from {e.Mobile.Map}." + ); } else { - e.Mobile.SendMessage(string.Format("Saving {0} obejcts{1} to file {2} from the entire world.", "XmlSpawner", - !string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" : string.Empty, dirname)); + e.Mobile.SendMessage( + $"Saving XmlSpawner obejcts{(!string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" : string.Empty)} to file {dirname} from the entire world." + ); } @@ -7055,7 +7037,7 @@ public class XmlSpawner : Item, ISpawner { if (from != null) { - from.SendMessage("Error creating file {0}", dirname); + from.SendMessage($"Error creating file {dirname}"); } save_ok = false; @@ -7181,7 +7163,7 @@ public class XmlSpawner : Item, ISpawner if (verbose && from != null) // Send a message to the client that the spawner is being saved { - from.SendMessage(68, "Saving '{0}' in {1} at {2}", sp.Name, sp.Map.Name, sp.Location.ToString()); + from.SendMessage(68, $"Saving '{sp.Name}' in {sp.Map.Name} at {sp.Location}"); } // Create a new data row @@ -7285,8 +7267,7 @@ public class XmlSpawner : Item, ISpawner dr["ProximityTriggerMessage"] = sp.m_ProximityTriggerMessage; if (sp.m_ObjectPropertyItem != null && !sp.m_ObjectPropertyItem.Deleted) { - dr["ObjectPropertyItemName"] = string.Format("{0},{1}", sp.m_ObjectPropertyItem.Name, - sp.m_ObjectPropertyItem.GetType().Name); + dr["ObjectPropertyItemName"] = $"{sp.m_ObjectPropertyItem.Name},{sp.m_ObjectPropertyItem.GetType().Name}"; } else { @@ -7296,8 +7277,7 @@ public class XmlSpawner : Item, ISpawner dr["ObjectPropertyName"] = sp.m_ObjectPropertyName; if (sp.m_SetPropertyItem != null && !sp.m_SetPropertyItem.Deleted) { - dr["SetPropertyItemName"] = string.Format("{0},{1}", sp.m_SetPropertyItem.Name, - sp.m_SetPropertyItem.GetType().Name); + dr["SetPropertyItemName"] = $"{sp.m_SetPropertyItem.Name},{sp.m_SetPropertyItem.GetType().Name}"; } else { @@ -7334,7 +7314,7 @@ public class XmlSpawner : Item, ISpawner } else { - waystr = string.Format("SERIAL,{0}", sp.m_WayPoint.Serial); + waystr = $"SERIAL,{sp.m_WayPoint.Serial}"; } } dr["WayPoint"] = waystr; @@ -7382,8 +7362,7 @@ public class XmlSpawner : Item, ISpawner // Indicate how many spawners were written if (from != null) { - from.SendMessage("{0} spawner(s) were saved to file {1} [Trammel={2}, Felucca={3}, Ilshenar={4}, Malas={5}, Tokuno={6}, Other={7}].", - TotalCount, dirname, TrammelCount, FeluccaCount, IlshenarCount, MalasCount, TokunoCount, OtherCount); + from.SendMessage($"{TotalCount} spawner(s) were saved to file {dirname} [Trammel={TrammelCount}, Felucca={FeluccaCount}, Ilshenar={IlshenarCount}, Malas={MalasCount}, Tokuno={TokunoCount}, Other={OtherCount}]."); } return true; @@ -7409,13 +7388,11 @@ public class XmlSpawner : Item, ISpawner if (WipeAll) { - e.Mobile.SendMessage("Removing ALL XmlSpawner objects from the world{0}.", !string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" - : string.Empty); + e.Mobile.SendMessage($"Removing ALL XmlSpawner objects from the world{(!string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" : string.Empty)}."); } else { - e.Mobile.SendMessage("Removing ALL XmlSpawner objects from {0}{1}.", e.Mobile.Map, !string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" - : string.Empty); + e.Mobile.SendMessage($"Removing ALL XmlSpawner objects from {e.Mobile.Map}{(!string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" : string.Empty)}."); } // Delete Xml spawner's in the world based on the mobiles current map @@ -7445,11 +7422,11 @@ public class XmlSpawner : Item, ISpawner if (WipeAll) { - e.Mobile.SendMessage("Removed {0} XmlSpawner objects from the world.", Count); + e.Mobile.SendMessage($"Removed {Count} XmlSpawner objects from the world."); } else { - e.Mobile.SendMessage("Removed {0} XmlSpawner objects from {1}.", Count, e.Mobile.Map); + e.Mobile.SendMessage($"Removed {Count} XmlSpawner objects from {e.Mobile.Map}."); } } else @@ -7493,13 +7470,11 @@ public class XmlSpawner : Item, ISpawner if (RespawnAll) { - e.Mobile.SendMessage("Respawning ALL XmlSpawner objects from the world{0}.", !string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" - : string.Empty); + e.Mobile.SendMessage($"Respawning ALL XmlSpawner objects from the world{(!string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" : string.Empty)}."); } else { - e.Mobile.SendMessage("Respawning ALL XmlSpawner objects from {0}{1}.", e.Mobile.Map, !string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" - : string.Empty); + e.Mobile.SendMessage($"Respawning ALL XmlSpawner objects from {e.Mobile.Map}{(!string.IsNullOrEmpty(SpawnerPrefix) ? $" beginning with {SpawnerPrefix}" : string.Empty)}."); } // Respawn Xml spawner's in the world based on the mobiles current map @@ -7509,7 +7484,6 @@ public class XmlSpawner : Item, ISpawner { try { - if (i is XmlSpawner && (RespawnAll || i.Map == e.Mobile.Map) && i.Deleted == false) { // Check if there is a respawn condition @@ -7527,18 +7501,18 @@ public class XmlSpawner : Item, ISpawner { // Send a message to the client that the spawner is being respawned - e.Mobile.SendMessage(33, "Respawning '{0}' in {1} at {2}", i.Name, i.Map.Name, i.Location.ToString()); + e.Mobile.SendMessage(33, $"Respawning '{i.Name}' in {i.Map.Name} at {i.Location}"); XmlSpawner CheckXmlSpawner = (XmlSpawner)i; CheckXmlSpawner.TryRespawn(); } if (RespawnAll) { - e.Mobile.SendMessage("Respawned {0} XmlSpawner objects from the world.", Count); + e.Mobile.SendMessage($"Respawned {Count} XmlSpawner objects from the world."); } else { - e.Mobile.SendMessage("Respawned {0} XmlSpawner objects from {1}.", Count, e.Mobile.Map); + e.Mobile.SendMessage($"Respawned {Count} XmlSpawner objects from {e.Mobile.Map}."); } } else @@ -7581,11 +7555,11 @@ public class XmlSpawner : Item, ISpawner } if (e.Arguments.Length > 2) { - e.Mobile.SendMessage("Created {0} Spawner objects.", count); + e.Mobile.SendMessage($"Created {count} Spawner objects."); } else { - e.Mobile.SendMessage("Created {0} XmlSpawner objects.", count); + e.Mobile.SendMessage($"Created {count} XmlSpawner objects."); } @@ -7600,7 +7574,7 @@ public class XmlSpawner : Item, ISpawner public static void XmlTrace_OnCommand(CommandEventArgs e) { Process currentprocess = Process.GetCurrentProcess(); - TimeSpan runningtime = DateTime.UtcNow - _traceStartTime; + TimeSpan runningtime = Core.Now - _traceStartTime; double processtime = currentprocess.UserProcessorTime.TotalMilliseconds - _startProcessTime; double sysload = 0; @@ -7641,7 +7615,7 @@ public class XmlSpawner : Item, ISpawner _traceCount[i] = 0; _traceTotal[i] = TimeSpan.Zero; } - _traceStartTime = DateTime.UtcNow; + _traceStartTime = Core.Now; Process currentprocess = Process.GetCurrentProcess(); _startProcessTime = currentprocess.UserProcessorTime.TotalMilliseconds; @@ -7846,7 +7820,7 @@ public class XmlSpawner : Item, ISpawner { bool despawned = false; // check to see if the despawn time has elapsed. If so, then delete it if it hasnt been picked up or stolen. - if (DespawnTime.TotalHours > 0 && !item.Deleted && item.LastMoved < DateTime.UtcNow - DespawnTime && item.Parent == Parent + if (DespawnTime.TotalHours > 0 && !item.Deleted && item.LastMoved < Core.Now - DespawnTime && item.Parent == Parent && (!ItemFlags.GetTaken(item) || item.Parent != null && item.Parent == Parent)) // can despawn if just moved within the same container { //item.Delete(); @@ -7886,7 +7860,7 @@ public class XmlSpawner : Item, ISpawner { bool despawned = false; // check to see if the despawn time has elapsed. If so, and the sector is not active then delete it. - if (DespawnTime.TotalHours > 0 && !mobile.Deleted && mobile.Created < DateTime.UtcNow - DespawnTime + if (DespawnTime.TotalHours > 0 && !mobile.Deleted && mobile.Created < Core.Now - DespawnTime && mobile.Map != null && mobile.Map != Map.Internal && !mobile.Map.GetSector(mobile.Location).Active) { //m.Delete(); @@ -8986,7 +8960,7 @@ public class XmlSpawner : Item, ISpawner } // check the nextspawn time to see if it is available - if (TheSpawn.NextSpawn > DateTime.UtcNow) + if (TheSpawn.NextSpawn > Core.Now) { return false; } @@ -9738,7 +9712,7 @@ public class XmlSpawner : Item, ISpawner { SpawnObject so = m_SpawnObjects[i]; - so.NextSpawn = DateTime.UtcNow; + so.NextSpawn = Core.Now; } } } @@ -9754,14 +9728,14 @@ public class XmlSpawner : Item, ISpawner int maxd = (int)(so.MaxDelay * 60); if (mind < 0 || maxd < 0) { - so.NextSpawn = DateTime.UtcNow; + so.NextSpawn = Core.Now; } else { TimeSpan delay = TimeSpan.FromSeconds(Utility.RandomMinMax(mind, maxd)); - so.NextSpawn = DateTime.UtcNow + delay; + so.NextSpawn = Core.Now + delay; } } @@ -11258,7 +11232,8 @@ public class XmlSpawner : Item, ISpawner m_SpawnObjects.Remove(TheSpawn); if (from != null) { - CommandLogging.WriteLine(from, "{0} {1} removed from XmlSpawner {2} '{3}' [{4}, {5}] ({6}) : {7}", from.AccessLevel, CommandLogging.Format(from), Serial, Name, GetWorldLocation().X, GetWorldLocation().Y, Map, SpawnObjectName); + var loc = GetWorldLocation(); + CommandLogging.WriteLine(from, $"{from.AccessLevel} {CommandLogging.Format(from)} removed from XmlSpawner {Serial} '{Name}' [{loc.X}, {loc.Y}] ({Map}) : {SpawnObjectName}"); } } } @@ -11518,7 +11493,7 @@ public class XmlSpawner : Item, ISpawner using (StreamWriter op = new StreamWriter("badspawn.log", true)) { - op.WriteLine("# Bad spawns : {0}", DateTime.UtcNow); + op.WriteLine("# Bad spawns : {0}", Core.Now); op.WriteLine("# Format: X Y Z F Name"); op.WriteLine(); @@ -11557,7 +11532,7 @@ public class XmlSpawner : Item, ISpawner return; } - m_End = DateTime.UtcNow + delay; + m_End = Core.Now + delay; if (m_Timer != null) { @@ -11570,7 +11545,7 @@ public class XmlSpawner : Item, ISpawner public void DoTimer2(TimeSpan delay) { - m_DurEnd = DateTime.UtcNow + delay; + m_DurEnd = Core.Now + delay; if (m_Duration > TimeSpan.FromMinutes(0) || m_durActivated) { if (m_DurTimer != null) @@ -11586,7 +11561,7 @@ public class XmlSpawner : Item, ISpawner public void DoTimer3(TimeSpan delay) { - m_RefractEnd = DateTime.UtcNow + delay; + m_RefractEnd = Core.Now + delay; m_refractActivated = true; if (m_RefractoryTimer != null) @@ -11850,12 +11825,12 @@ public class XmlSpawner : Item, ISpawner writer.Write(m_MaxRefractory); if (m_refractActivated) { - writer.Write(m_RefractEnd - DateTime.UtcNow); + writer.Write(m_RefractEnd - Core.Now); } if (m_durActivated) { - writer.Write(m_DurEnd - DateTime.UtcNow); + writer.Write(m_DurEnd - Core.Now); } // Version 3 @@ -11884,7 +11859,7 @@ public class XmlSpawner : Item, ISpawner if (m_Running) { - writer.Write(m_End - DateTime.UtcNow); + writer.Write(m_End - Core.Now); } // Write the spawn object list @@ -12119,7 +12094,7 @@ public class XmlSpawner : Item, ISpawner hasnewobjectinfo = true; m_SequentialSpawning = reader.ReadInt(); TimeSpan seqdelay = reader.ReadTimeSpan(); - m_SeqEnd = DateTime.UtcNow + seqdelay; + m_SeqEnd = Core.Now + seqdelay; tmpSubGroup = new List(tmpSpawnListSize); tmpSequentialResetTime = new List(tmpSpawnListSize); @@ -12535,7 +12510,8 @@ public class XmlSpawner : Item, ISpawner if (!found) { - CommandLogging.WriteLine(from, "{0} {1} added to XmlSpawner {2} '{3}' [{4}, {5}] ({6}) : {7}", from.AccessLevel, CommandLogging.Format(from), spawner.Serial, spawner.Name, spawner.GetWorldLocation().X, spawner.GetWorldLocation().Y, spawner.Map, name); + var loc = spawner.GetWorldLocation(); + CommandLogging.WriteLine(from, $"{from.AccessLevel} {CommandLogging.Format(from)} added to XmlSpawner {spawner.Serial} '{spawner.Name}' [{loc.X}, {loc.Y}] ({spawner.Map}) : {name}"); } } diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerGumps.cs b/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerGumps.cs index 832509a37..a708f2c22 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerGumps.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerGumps.cs @@ -510,18 +510,18 @@ public class XmlSpawnerGump : Gump } string strnext; - if (m_Spawner.SpawnObjects[i].NextSpawn > DateTime.UtcNow) + if (m_Spawner.SpawnObjects[i].NextSpawn > Core.Now) { // if the next spawn tick of the spawner will occur after the subgroup is available for spawning // then report the next spawn tick since that is the earliest that the subgroup can actually be spawned - if (DateTime.UtcNow + m_Spawner.NextSpawn > m_Spawner.SpawnObjects[i].NextSpawn) + if (Core.Now + m_Spawner.NextSpawn > m_Spawner.SpawnObjects[i].NextSpawn) { strnext = m_Spawner.NextSpawn.ToString(); } else { // estimate the earliest the next spawn could occur as the first spawn tick after reaching the subgroup nextspawn - strnext = (m_Spawner.SpawnObjects[i].NextSpawn - DateTime.UtcNow + m_Spawner.NextSpawn).ToString(); + strnext = (m_Spawner.SpawnObjects[i].NextSpawn - Core.Now + m_Spawner.NextSpawn).ToString(); } } else @@ -665,16 +665,7 @@ public class XmlSpawnerGump : Gump { CommandLogging.WriteLine( from, - "{0} {1} changed XmlSpawner {2} '{3}' [{4}, {5}] ({6}) : {7} to {8}", - from.AccessLevel, - CommandLogging.Format(from), - m_Spawner.Serial, - m_Spawner.Name, - m_Spawner.GetWorldLocation().X, - m_Spawner.GetWorldLocation().Y, - m_Spawner.Map, - m_Spawner.SpawnObjects[i].TypeName, - str + $"{from.AccessLevel} {CommandLogging.Format(from)} changed XmlSpawner {m_Spawner.Serial} '{m_Spawner.Name}' [{m_Spawner.GetWorldLocation().X}, {m_Spawner.GetWorldLocation().Y}] ({m_Spawner.Map}) : {m_Spawner.SpawnObjects[i].TypeName} to {str}" ); } @@ -740,7 +731,7 @@ public class XmlSpawnerGump : Gump if (from != null && !from.Deleted) { - from.SendMessage("{0} is not available", i); + from.SendMessage($"{i} is not available"); } } else if (o is Mobile m) @@ -752,7 +743,7 @@ public class XmlSpawnerGump : Gump if (from != null && !from.Deleted) { - from.SendMessage("{0} is not available", m); + from.SendMessage($"{m} is not available"); } } diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerSkillCheck.cs b/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerSkillCheck.cs index 314551e44..fa1b2b6ed 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerSkillCheck.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerSkillCheck.cs @@ -270,25 +270,11 @@ public class XmlSpawnerSkillCheck // determine whether there are any registered objects for this skill foreach(RegisteredSkill rs in skilllist) { - if (rs.sid == skill.SkillName) + // if so then invoke their skill handlers + // call the spawner handler + if (rs.sid == skill.SkillName && rs.target is XmlSpawner spawner && spawner.HandlesOnSkillUse) { - // if so then invoke their skill handlers - if (rs.target is XmlSpawner spawner) - { - if (spawner.HandlesOnSkillUse) - { - // call the spawner handler - spawner.OnSkillUse(m, skill, success); - } - } else - if (rs.target is IXmlQuest quest) - { - if (quest.HandlesOnSkillUse) - { - // call the xmlquest handler - quest.OnSkillUse(m, skill, success); - } - } + spawner.OnSkillUse(m, skill, success); } } } diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/WriteMulti.cs b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/WriteMulti.cs index 8992ed537..ce083ed65 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/WriteMulti.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/WriteMulti.cs @@ -46,7 +46,7 @@ public class WriteMulti if (e.Arguments != null && e.Arguments.Length < 1) { - e.Mobile.SendMessage("Usage: {0} [zmin zmax][-noitems][-nostatics][-nomultis][-noaddons][-invisible]", e.Command); + e.Mobile.SendMessage($"Usage: {e.Command} [zmin zmax][-noitems][-nostatics][-nomultis][-noaddons][-invisible]"); return; } @@ -99,7 +99,7 @@ public class WriteMulti } catch { - e.Mobile.SendMessage("{0} : Invalid zmin zmax arguments", e.Command); + e.Mobile.SendMessage($"{e.Command} : Invalid zmin zmax arguments"); return; } } @@ -126,13 +126,6 @@ public class WriteMulti try { StreamReader op = new StreamReader(dirname, false); - - if (op == null) - { - e.Mobile.SendMessage("Cannot access file {0}", dirname); - return; - } - string line = op.ReadLine(); op.Close(); @@ -142,28 +135,28 @@ public class WriteMulti { string[] args = line.Split(" ".ToCharArray(), 3); - if (args == null || args.Length < 3) + if (args.Length < 3) { - e.Mobile.SendMessage("Cannot overwrite file {0} : not owner", dirname); + e.Mobile.SendMessage($"Cannot overwrite file {dirname} : not owner"); return; } if (args[2] != e.Mobile.Name) { - e.Mobile.SendMessage("Cannot overwrite file {0} : not owner", dirname); + e.Mobile.SendMessage($"Cannot overwrite file {dirname} : not owner"); return; } } else { - e.Mobile.SendMessage("Cannot overwrite file {0} : not owner", dirname); + e.Mobile.SendMessage($"Cannot overwrite file {dirname} : not owner"); return; } } catch { - e.Mobile.SendMessage("Cannot overwrite file {0}", dirname); + e.Mobile.SendMessage($"Cannot overwrite file {dirname}"); return; } @@ -410,7 +403,7 @@ public class WriteMulti } catch { - from.SendMessage("Error writing multi file {0}", dirname); + from.SendMessage($"Error writing multi file {dirname}"); return; } @@ -418,11 +411,11 @@ public class WriteMulti if (includeitems) { - from.SendMessage(66, "Included {0} items", nitems); + from.SendMessage(66, $"Included {nitems} items"); if (includemultis) { - from.SendMessage("{0} multis", nmultis); + from.SendMessage($"{nmultis} multis"); } else { @@ -431,7 +424,7 @@ public class WriteMulti if (includeinvisible) { - from.SendMessage("{0} invisible", ninvisible); + from.SendMessage($"{ninvisible} invisible"); } else { @@ -440,7 +433,7 @@ public class WriteMulti if (includeaddons) { - from.SendMessage("{0} addons", naddons); + from.SendMessage($"{naddons} addons"); } else { @@ -455,14 +448,14 @@ public class WriteMulti if (includestatics) { - from.SendMessage(66, "Included {0} statics", nstatics); + from.SendMessage(66, $"Included {nstatics} statics"); } else { from.SendMessage(33, "Ignored statics"); } - from.SendMessage(66, "Saved {0} components to {1}", ntotal, dirname); + from.SendMessage(66, $"Saved {ntotal} components to {dirname}"); } } } diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlAdd.cs b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlAdd.cs index eac9420f2..c74c2fa30 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlAdd.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlAdd.cs @@ -378,7 +378,7 @@ public class XmlAddGump : Gump { if (from != null && !from.Deleted) { - from.SendMessage("Error trying to save to file {0}", dirname); + from.SendMessage($"Error trying to save to file {dirname}"); } return; @@ -386,7 +386,7 @@ public class XmlAddGump : Gump if (from != null && !from.Deleted) { - from.SendMessage("Saved defs to file {0}", dirname); + from.SendMessage($"Saved defs to file {dirname}"); } } @@ -426,7 +426,7 @@ public class XmlAddGump : Gump if (fs == null) { - from.SendMessage("Unable to open {0} for loading", dirname); + from.SendMessage($"Unable to open {dirname} for loading"); return; } @@ -447,7 +447,7 @@ public class XmlAddGump : Gump { if (from != null && !from.Deleted) { - from.SendMessage(33, "Error reading defs file {0}", dirname); + from.SendMessage(33, $"Error reading defs file {dirname}"); } return; @@ -590,7 +590,7 @@ public class XmlAddGump : Gump if (from != null && !from.Deleted) { - from.SendMessage("Loaded defs from file {0}", dirname); + from.SendMessage($"Loaded defs from file {dirname}"); } } } @@ -599,7 +599,7 @@ public class XmlAddGump : Gump { if (from != null && !from.Deleted) { - from.SendMessage(33, "File not found: {0}", dirname); + from.SendMessage(33, $"File not found: {dirname}"); } } } diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlEdit.cs b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlEdit.cs deleted file mode 100644 index e61f7113c..000000000 --- a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlEdit.cs +++ /dev/null @@ -1,1420 +0,0 @@ -using System; -using System.Collections; -using Server.Items; -using Server.Network; -using Server.Gumps; -using Server.Targeting; -using CPA = Server.CommandPropertyAttribute; -using Server.Mobiles; - -/* -** XmlEditNPC -** Version 1.00 -** updated 5/24/05 -** ArteGordon -** -** -*/ - -namespace Server.Engines.XmlSpawner2; - -public class XmlEditDialogGump : Gump -{ - private const int MaxEntries = 8; - private const int MaxEntriesPerPage = 8; - - private Mobile m_From; - private string Name; - private int Selected; - private int DisplayFrom; - private string SaveFilename; - private bool [] m_SelectionList; - private XmlDialog m_Dialog; - - private bool SelectAll; - - private ArrayList m_SearchList; - - public static void Initialize() - { - CommandSystem.Register("XmlEdit", AccessLevel.GameMaster, XmlEditDialog_OnCommand); - } - - [Usage("XmlEdit")] - [Description("Edits XmlDialog entries on an object")] - public static void XmlEditDialog_OnCommand(CommandEventArgs e) - { - if (e == null || e.Mobile == null) - { - return; - } - - // target an object with the xmldialog attachment - e.Mobile.Target = new EditDialogTarget(); - - - } - - private class EditDialogTarget : Target - { - - public EditDialogTarget() : base (30, true, TargetFlags.None) - { - - } - - protected override void OnTarget(Mobile from, object targeted) - { - if (from == null) - { - return; - } - - // does it have an xmldialog attachment? - XmlDialog xd = XmlAttach.FindAttachment(targeted, typeof(XmlDialog)) as XmlDialog; - - if (xd == null) - { - from.SendMessage("Target has no XmlDialog attachment"); - - // TODO: ask whether they would like to add one - from.SendGump(new XmlConfirmAddGump(from, targeted)); - - return; - } - - from.SendGump(new XmlEditDialogGump(from, true, xd, -1, 0, null, false, null, 0, 0)); - } - } - - public class XmlConfirmAddGump : Gump - { - private Mobile m_From; - private object m_Targeted; - - public XmlConfirmAddGump(Mobile from, object targeted) : base (0, 0) - { - if (from == null || targeted == null) - { - return; - } - - m_Targeted = targeted; - m_From = from; - - Closable = false; - Draggable = true; - AddPage(0); - AddBackground(10, 200, 200, 130, 5054); - - AddLabel(20, 210, 68, "Add an XmlDialog to target?"); - - string name = null; - if (targeted is Item item) - { - name = item.Name; - } - else - if (targeted is Mobile mobile) - { - name = mobile.Name; - } - - if (name == null) - { - name = targeted.GetType().Name; - } - AddLabel(20, 230, 0, $"{name}"); - - AddRadio(35, 255, 9721, 9724, false, 1); // accept/yes radio - AddRadio(135, 255, 9721, 9724, true, 2); // decline/no radio - AddHtmlLocalized(72, 255, 200, 30, 1049016, 0x7fff); // Yes - AddHtmlLocalized(172, 255, 200, 30, 1049017, 0x7fff); // No - AddButton(80, 289, 2130, 2129, 3); // Okay button - - } - public override void OnResponse(NetState state, RelayInfo info) - { - if (info == null || state == null || state.Mobile == null) - { - return; - } - - int radiostate = -1; - if (info.Switches.Length > 0) - { - radiostate = info.Switches[0]; - } - switch (info.ButtonID) - { - - default: - { - if (radiostate == 1) - { // accept - - // add the attachment - XmlDialog xd = new XmlDialog(); - XmlAttach.AttachTo(state.Mobile, m_Targeted, xd); - - // open the editing gump - state.Mobile.SendGump(new XmlEditDialogGump(state.Mobile, true, xd, -1, 0, null, false, null, 0, 0)); - } - break; - } - } - } - } - - public const int MaxLabelLength = 200; - public string TruncateLabel(string s) - { - if (s == null || s.Length < MaxLabelLength) - { - return s; - } - - return s.Substring(0,MaxLabelLength); - } - - public XmlEditDialogGump(Mobile from, bool firststart, - XmlDialog dialog, int selected, int displayfrom, string savefilename, - bool selectall, bool [] selectionlist, int X, int Y) : base(X,Y) - { - - if (from == null || dialog == null) - { - return; - } - - m_Dialog = dialog; - m_From = from; - - m_SelectionList = selectionlist; - if (m_SelectionList == null) - { - m_SelectionList = new bool[MaxEntries]; - } - SaveFilename = savefilename; - - DisplayFrom = displayfrom; - Selected = selected; - - // fill the list with the XmlDialog entries - m_SearchList = dialog.SpeechEntries; - - // prepare the page - int height = 500; - - - AddPage(0); - - AddBackground(0, 0, 755, height, 5054); - AddAlphaRegion(0, 0, 755, height); - - // add the separators - AddImageTiled(10, 80, 735, 4, 0xBB9); - AddImageTiled(10, height -212, 735, 4, 0xBB9); - AddImageTiled(10, height -60, 735, 4, 0xBB9); - - // add the xmldialog properties - int y = 5; - int w = 140; - int x = 5; - int lw = 0; - // the dialog name - AddImageTiled(x, y, w, 21, 0x23F4); - // get the name of the object this is attached to - - if (m_Dialog.AttachedTo is Item item) - { - Name = item.Name; - } - else - if (m_Dialog.AttachedTo is Mobile mobile) - { - Name = mobile.Name; - } - if (Name == null && m_Dialog.AttachedTo != null) - { - Name = m_Dialog.AttachedTo.GetType().Name; - } - AddLabelCropped(x, y, w, 21, 0, Name); - - - x += w + lw + 20; - w = 40; - lw = 90; - // add the proximity range - AddLabel(x, y, 0x384, "ProximityRange"); - AddImageTiled(x+lw, y, w, 21, 0xBBC); - AddTextEntry(x+lw, y, w, 21, 0, 140, m_Dialog.ProximityRange.ToString()); - - x += w + lw + 20; - w = 100; - lw = 60; - // reset time - AddLabel(x, y, 0x384, "ResetTime"); - AddImageTiled(x+lw, y, w, 21, 0xBBC); - AddTextEntry(x+lw, y, w, 21, 0, 141, m_Dialog.ResetTime.ToString()); - - x += w + lw + 20; - w = 40; - lw = 65; - // speech pace - AddLabel(x, y, 0x384, "SpeechPace"); - AddImageTiled(x+lw, y, w, 21, 0xBBC); - AddTextEntry(x+lw, y, w, 21, 0, 142, m_Dialog.SpeechPace.ToString()); - - x += w + lw + 20; - w = 30; - lw = 55; - // allow ghost triggering - AddLabel(x, y, 0x384, "GhostTrig"); - AddCheck(x+lw, y, 0xD2, 0xD3, m_Dialog.AllowGhostTrig, 260); - - // add the triggeroncarried - y += 27; - w = 600; - x = 10; - lw = 100; - AddLabel(10, y, 0x384, "TrigOnCarried"); - AddImageTiled(x + lw, y, w, 21, 0xBBC); - AddTextEntry(x+lw, y, w, 21, 0, 150, TruncateLabel(m_Dialog.TriggerOnCarried)); - AddButton(720, y, 0xFAB, 0xFAD, 5005); - - // add the notriggeroncarried - y += 22; - w = 600; - x = 10; - lw = 100; - AddLabel(x, y, 0x384, "NoTrigOnCarried"); - AddImageTiled(x+lw, y, w, 21, 0xBBC); - AddTextEntry(x + lw, y, w, 21, 0, 151, TruncateLabel(m_Dialog.NoTriggerOnCarried)); - AddButton(720, y, 0xFAB, 0xFAD, 5006); - - y = 88; - // column labels - AddLabel(10, y, 0x384, "Edit"); - AddLabel(45, y, 0x384, "#"); - AddLabel(95, y, 0x384, "ID"); - AddLabel(145, y, 0x384, "Depends"); - AddLabel(195, y, 0x384, "Keywords"); - AddLabel(295, y, 0x384, "Text"); - AddLabel(540, y, 0x384, "Action"); - AddLabel(602, y, 0x384, "Condition"); - AddLabel(664, y, 0x384, "Gump"); - - // display the select-all-displayed toggle - AddButton(730, y, 0xD2, 0xD3, 3999); - - y -= 10; - for (int i = 0; i < MaxEntries; i++) - { - int index = i + DisplayFrom; - if (m_SearchList == null || index >= m_SearchList.Count) - { - break; - } - - int page = i/MaxEntriesPerPage; - if (i%MaxEntriesPerPage == 0) - { - AddPage(page+1); - // add highlighted page button - //AddImageTiled(235+page*25, 448, 25, 25, 0xBBC); - //AddImage(238+page*25, 450, 0x8B1+page); - } - - // background for search results area - AddImageTiled(235, y + 22 * (i%MaxEntriesPerPage) + 30, 386, 23, 0x52); - AddImageTiled(236, y + 22 * (i%MaxEntriesPerPage) + 31, 384, 21, 0xBBC); - - - XmlDialog.SpeechEntry s = (XmlDialog.SpeechEntry)m_SearchList[index]; - - if (s == null) - { - continue; - } - - int texthue = 0; - - bool sel=false; - - if (m_SelectionList != null && i < m_SelectionList.Length) - { - sel = m_SelectionList[i]; - } - - // entries with the selection box checked are highlighted in red - if (sel) - { - texthue = 33; - } - - // the selected entry is highlighted in green - if (i == Selected) - { - texthue = 68; - } - - x = 10; - w = 35; - // add the Edit button for each entry - AddButton(10, y + 22 * (i%MaxEntriesPerPage) + 30, 0xFAE, 0xFAF, 1000+i); - - x += w; - w = 50; - // display the entry number - AddImageTiled(x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0xBBC); - AddLabel(x, y + 22 * (i%MaxEntriesPerPage) + 31, texthue, s.EntryNumber.ToString()); - - x += w; - w = 50; - // display the entry ID - AddImageTiled(x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0x23F4); - AddLabel(x, y + 22 * (i%MaxEntriesPerPage) + 31, texthue, s.ID.ToString()); - - x += w; - w = 50; - // display the entry dependson - AddImageTiled(x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0xBBC ); - AddLabel(x, y + 22 * (i%MaxEntriesPerPage) + 31, texthue, s.DependsOn); - - x += w; - w = 100; - // display the entry keywords - AddImageTiled(x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0x23F4); - AddLabelCropped(x, y + 22 * (i%MaxEntriesPerPage) + 31, w-5, 21, texthue, TruncateLabel(s.Keywords)); - - x += w; - w = 245; - // display the entry text - AddImageTiled(x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0xBBC); - AddLabelCropped(x, y + 22 * (i%MaxEntriesPerPage) + 31, w-5, 21, texthue, TruncateLabel(s.Text)); - - x += w; - w = 62; - // display the action text - AddImageTiled(x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0x23F4); - AddLabelCropped(x, y + 22 * (i%MaxEntriesPerPage) + 31, w-5, 21, texthue, TruncateLabel(s.Action)); - - x += w; - w = 62; - // display the condition text - AddImageTiled(x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0xBBC); - AddLabelCropped(x, y + 22 * (i%MaxEntriesPerPage) + 31, w-5, 21, texthue, TruncateLabel(s.Condition)); - - x += w; - w = 62; - // display the gump text - AddImageTiled(x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0x23F4); - AddLabelCropped(x, y + 22 * (i%MaxEntriesPerPage) + 31, w-5, 21, texthue, TruncateLabel(s.Gump)); - - // display the selection button - AddButton(730, y + 22 * (i%MaxEntriesPerPage) + 32, sel? 0xD3:0xD2, sel? 0xD2:0xD3, 4000+i); - - } - - - // display the selected entry information for editing - XmlDialog.SpeechEntry sentry = null; - if (Selected >= 0 && Selected + DisplayFrom >= 0 && Selected + DisplayFrom < m_SearchList.Count) - { - sentry = (XmlDialog.SpeechEntry)m_SearchList[Selected+ DisplayFrom]; - } - - if (sentry != null) - { - - y = height - 200; - - // add the entry parameters - lw = 15; - w = 40; - x = 10; - int spacing = 11; - - // entry number - AddLabel(x, y, 0x384, "#"); - AddImageTiled(x+lw, y, w, 21, 0xBBC); - AddTextEntry(x+lw, y, w, 21, 0, 200, sentry.EntryNumber.ToString()); - - x += w + lw + spacing; - w = 40; - lw = 17; - // ID number - AddLabel(x, y, 0x384, "ID"); - AddImageTiled(x+lw, y, w, 21, 0xBBC); - AddTextEntry(x+lw, y, w, 21, 0, 201, sentry.ID.ToString()); - - x += w + lw + spacing; - w = 40; - lw = 65; - // depends on - AddLabel(x, y, 0x384, "DependsOn"); - AddImageTiled(x+lw, y, w, 21, 0xBBC); - AddTextEntry(x+lw, y, w, 21, 0, 202, sentry.DependsOn); - - x += w + lw + spacing; - w = 35; - lw = 57; - // prepause - AddLabel(x, y, 0x384, "PrePause"); - AddImageTiled(x+lw, y, w, 21, 0xBBC); - AddTextEntry(x+lw, y, w, 21, 0, 203, sentry.PrePause.ToString()); - - x += w + lw + spacing; - w = 35; - lw = 37; - // pause - AddLabel(x, y, 0x384, "Pause"); - AddImageTiled(x+lw, y, w, 21, 0xBBC); - AddTextEntry(x+lw, y, w, 21, 0, 204, sentry.Pause.ToString()); - - x += w + lw + spacing; - w = 37; - lw = 26; - // speech hue - AddLabel(x, y, 0x384, "Hue"); - AddImageTiled(x+lw, y, w, 21, 0xBBC); - AddTextEntry(x+lw, y, w, 21, 0, 205, sentry.SpeechHue.ToString()); - - x += w + lw + spacing; - w = 20; - lw = 52; - // lock conversation - AddLabel(x, y, 0x384, "IgnoreCar"); - AddCheck(x + lw, y, 0xD2, 0xD3, sentry.IgnoreCarried, 252); - - x += w + lw + spacing; - w = 20; - lw = 42; - // lock conversation - AddLabel(x, y, 0x384, "LockOn"); - AddCheck(x+lw, y, 0xD2, 0xD3, sentry.LockConversation, 250); - - x += w + lw + spacing; - w = 20; - lw = 54; - // npctrigger - AddLabel(x, y, 0x384, "AllowNPC"); - AddCheck(x+lw, y, 0xD2, 0xD3, sentry.AllowNPCTrigger, 251); - - - w = 650; - x = 70; - - y += 27; - // add the keyword entry - AddLabel(10, y, 0x384, "Keywords"); - AddImageTiled(x, y, w, 21, 0xBBC); - AddTextEntry(x+1, y, w, 21, 0, 101, sentry.Keywords); - AddButton(720, y, 0xFAB, 0xFAD, 5001); - - y += 22; - // add the text entry - AddLabel(10, y, 0x384, "Text"); - AddImageTiled(x, y, w, 21, 0xBBC); - AddTextEntry(x+1, y, w, 21, 0, 100, sentry.Text); - AddButton(720, y, 0xFAB, 0xFAD, 5000); - - - y += 22; - // add the condition string entry - AddLabel(10, y, 0x384, "Condition"); - AddImageTiled(x, y, w, 21, 0xBBC); - AddTextEntry(x+1, y, w, 21, 0, 102, sentry.Condition); - AddButton(720, y, 0xFAB, 0xFAD, 5002); - - y += 22; - // add the action string entry - AddLabel(10, y, 0x384, "Action"); - AddImageTiled(x, y, w, 21, 0xBBC); - AddTextEntry(x+1, y, w, 21, 0, 103, sentry.Action); - AddButton(720, y, 0xFAB, 0xFAD, 5003); - - y += 22; - // add the gump string entry - AddLabel(10, y, 0x384, "Gump"); - AddImageTiled(x, y, w, 21, 0xBBC); - AddTextEntry(x+1, y, w, 21, 0, 104, sentry.Gump); - AddButton(720, y, 0xFAB, 0xFAD, 5004); - } - - y = height - 50; - - AddLabel(10, y, 0x384, "Config:"); - AddImageTiled(50, y , 120, 19, 0x23F4); - AddLabel(50, y, 0, m_Dialog.ConfigFile); - - if (from.AccessLevel >= XmlSpawner.DiskAccessLevel) - { - - // add the save entry - AddButton(185, y , 0xFA8, 0xFAA, 159); - AddLabel(218, y , 0x384, "Save to file:"); - AddImageTiled(300, y , 180, 19, 0xBBC); - AddTextEntry(300, y, 180, 19, 0, 300, SaveFilename); - } - - // display the item list - if (m_SearchList != null) - { - AddLabel(495, y, 68, $"{m_SearchList.Count} Entries"); - int last = DisplayFrom + MaxEntries < m_SearchList.Count ? DisplayFrom + MaxEntries : m_SearchList.Count; - if (last > 0) - { - AddLabel(595, y, 68, $"Displaying {DisplayFrom}-{last - 1}"); - } - } - - y = height - 25; - - // add run status display - if (m_Dialog.Running) - { - AddButton(10, y-5, 0x2A4E, 0x2A3A, 100); - AddLabel(43, y, 0x384, "On"); - } - else - { - AddButton(10, y-5, 0x2A62, 0x2A3A, 100); - AddLabel(43, y, 0x384, "Off"); - } - - // add the Refresh/Sort button - AddButton(80, y, 0xFAB, 0xFAD, 700); - AddLabel(113, y, 0x384, "Refresh"); - - // add the Add button - AddButton(185, y, 0xFAB, 0xFAD, 155); - AddLabel(218, y, 0x384, "Add"); - - // add the Delete button - AddButton(255, y, 0xFB1, 0xFB3, 156); - AddLabel(283, y, 0x384, "Delete"); - - // add the page buttons - for(int i = 0;i 0) - { - - m_SearchList.Sort(new ListSorter(false)); - - } - } - - private class ListSorter : IComparer - { - private bool Dsort; - public ListSorter(bool descend) => Dsort = descend; - - public int Compare(object x, object y) - { - int xn = 0; - int yn = 0; - - - xn = ((XmlDialog.SpeechEntry)x).EntryNumber; - - yn = ((XmlDialog.SpeechEntry)y).EntryNumber; - - - if (Dsort) - { - return yn - xn; - } - - return xn- yn; - } - } - - - - private void SaveList(Mobile from, string filename) - { - if (m_SearchList == null || m_SelectionList == null) - { - return; - } - - string dirname; - if (System.IO.Directory.Exists(XmlDialog.DefsDir) && filename != null && !filename.StartsWith("/") && !filename.StartsWith("\\")) - { - // put it in the defaults directory if it exists - dirname = $"{XmlDialog.DefsDir}/{filename}"; - } - else - { - // otherwise just put it in the main installation dir - dirname = filename; - } - - // save it to the file - } - - private XmlEditDialogGump Refresh(NetState state) - { - XmlEditDialogGump g = new XmlEditDialogGump(m_From, false, m_Dialog, Selected, - DisplayFrom, SaveFilename, SelectAll, m_SelectionList, X, Y); - state.Mobile.SendGump(g); - return g; - } - - public static void ProcessXmlEditBookEntry(Mobile from, object[] args, string text) - { - - if (from == null || args == null || args.Length < 6) - { - return; - } - - XmlDialog dialog = (XmlDialog)args[0]; - XmlDialog.SpeechEntry entry = (XmlDialog.SpeechEntry)args[1]; - int textid = (int)args[2]; - int selected = (int)args[3]; - int displayfrom = (int)args[4]; - string savefile = (string)args[5]; - - // place the book text into the entry by type - switch (textid) - { - case 0: // text - { - if (entry != null) - { - entry.Text = text; - } - - break; - } - case 1: // keywords - { - if (entry != null) - { - entry.Keywords = text; - } - - break; - } - case 2: // condition - { - if (entry != null) - { - entry.Condition = text; - } - - break; - } - case 3: // action - { - if (entry != null) - { - entry.Action = text; - } - - break; - } - case 4: // gump - { - if (entry != null) - { - entry.Gump = text; - } - - break; - } - case 5: // trigoncarried - { - if (dialog != null) - { - dialog.TriggerOnCarried = text; - } - - break; - } - case 6: // notrigoncarried - { - if (dialog != null) - { - dialog.NoTriggerOnCarried = text; - } - - break; - } - } - - - from.CloseGump(); - - //from.SendGump(new XmlEditDialogGump(from, false, m_Dialog, selected, displayfrom, savefilename, false, null, X, Y)); - from.SendGump(new XmlEditDialogGump(from, true, dialog, selected, displayfrom, savefile, false, null, 0, 0)); - } - - - public override void OnResponse(NetState state, RelayInfo info) - { - if (info == null || state == null || state.Mobile == null || m_Dialog == null) - { - return; - } - - int radiostate = -1; - if (info.Switches.Length > 0) - { - radiostate = info.Switches[0]; - } - - - - TextRelay tr = info.GetTextEntry(400); // displayfrom info - try - { - DisplayFrom = int.Parse(tr.Text); - } - catch{} - - - tr = info.GetTextEntry(300); // savefilename info - if (tr != null) - { - SaveFilename = tr.Text; - } - - if (m_Dialog != null) - { - tr = info.GetTextEntry(140); // proximity range - if (tr != null) - { - try - { - m_Dialog.ProximityRange = int.Parse(tr.Text); - } - catch{} - } - tr = info.GetTextEntry(141); // reset time - if (tr != null) - { - try - { - m_Dialog.ResetTime = TimeSpan.Parse(tr.Text); - } - catch{} - } - tr = info.GetTextEntry(142); // speech pace - if (tr != null) - { - try - { - m_Dialog.SpeechPace = int.Parse(tr.Text); - } - catch{} - } - - tr = info.GetTextEntry(150); // trig on carried - if (tr != null && (m_Dialog.TriggerOnCarried == null || m_Dialog.TriggerOnCarried.Length < 230)) - { - if (tr.Text != null && tr.Text.Trim().Length > 0) - { - m_Dialog.TriggerOnCarried = tr.Text; - } - else - { - m_Dialog.TriggerOnCarried = null; - } - } - - tr = info.GetTextEntry(151); // notrig on carried - if (tr != null && (m_Dialog.NoTriggerOnCarried == null || m_Dialog.NoTriggerOnCarried.Length < 230)) - { - if (tr.Text != null && tr.Text.Trim().Length > 0) - { - m_Dialog.NoTriggerOnCarried = tr.Text; - } - else - { - m_Dialog.NoTriggerOnCarried = null; - } - } - - m_Dialog.AllowGhostTrig = info.IsSwitched(260); // allow ghost triggering - } - - if (m_SearchList != null && Selected >= 0 && Selected + DisplayFrom >= 0 && Selected + DisplayFrom < m_SearchList.Count) - { - // entry information - XmlDialog.SpeechEntry entry = (XmlDialog.SpeechEntry)m_SearchList[Selected + DisplayFrom]; - - tr = info.GetTextEntry(200); // entry number - if (tr != null) - { - try - { - entry.EntryNumber = int.Parse(tr.Text); - } - catch {} - } - - tr = info.GetTextEntry(201); // entry id - if (tr != null) - { - try - { - entry.ID = int.Parse(tr.Text); - } - catch {} - } - - tr = info.GetTextEntry(202); // depends on - if (tr != null) - { - try - { - entry.DependsOn = tr.Text; - } - catch {} - } - - tr = info.GetTextEntry(203); // prepause - if (tr != null) - { - try - { - entry.PrePause = int.Parse(tr.Text); - } - catch {} - } - - tr = info.GetTextEntry(204); // pause - if (tr != null) - { - try - { - entry.Pause = int.Parse(tr.Text); - } - catch {} - } - - tr = info.GetTextEntry(205); // hue - if (tr != null) - { - try - { - entry.SpeechHue = int.Parse(tr.Text); - } - catch {} - } - - tr = info.GetTextEntry(101); // keywords - if (tr != null && (entry.Keywords == null || entry.Keywords.Length < 230)) - { - if (tr.Text != null && tr.Text.Trim().Length > 0) - { - entry.Keywords = tr.Text; - } - else - { - entry.Keywords = null; - } - - } - - tr = info.GetTextEntry(100); // text - if (tr != null && (entry.Text == null || entry.Text.Length < 230)) - { - if (tr.Text != null && tr.Text.Trim().Length > 0) - { - entry.Text = tr.Text; - } - else - { - entry.Text = null; - } - } - - tr = info.GetTextEntry(102); // condition - if (tr != null && (entry.Condition == null || entry.Condition.Length < 230)) - { - if (tr.Text != null && tr.Text.Trim().Length > 0) - { - entry.Condition = tr.Text; - } - else - { - entry.Condition = null; - } - } - - tr = info.GetTextEntry(103); // action - if (tr != null && (entry.Action == null || entry.Action.Length < 230)) - { - if (tr.Text != null && tr.Text.Trim().Length > 0) - { - entry.Action = tr.Text; - } - else - { - entry.Action = null; - } - } - - tr = info.GetTextEntry(104); // gump - if (tr != null && (entry.Gump == null || entry.Gump.Length < 230)) - { - if (tr.Text != null && tr.Text.Trim().Length > 0) - { - entry.Gump = tr.Text; - } - else - { - entry.Gump = null; - } - } - - entry.LockConversation = info.IsSwitched(250); // lock conversation - entry.AllowNPCTrigger = info.IsSwitched(251); // allow npc - entry.IgnoreCarried = info.IsSwitched(252); // ignorecarried - } - - - - switch (info.ButtonID) - { - - case 0: // Close - { - - m_Dialog.DeleteTextEntryBook(); - - return; - } - case 100: // toggle running status - { - - m_Dialog.Running = !m_Dialog.Running; - - break; - } - case 155: // add new entry - { - - if (m_SearchList != null) - { - // find the last entry - int lastentry = 0; - foreach(XmlDialog.SpeechEntry e in m_SearchList) - { - if (e.EntryNumber > lastentry) - { - lastentry = e.EntryNumber; - } - } - lastentry += 10; - XmlDialog.SpeechEntry se = new XmlDialog.SpeechEntry(); - se.EntryNumber = lastentry; - se.ID = lastentry; - m_SearchList.Add(se); - Selected = m_SearchList.Count -1; - } - break; - } - - case 156: // Delete selected entries - { - XmlEditDialogGump g = Refresh(state); - int allcount = 0; - if (m_SearchList != null) - { - allcount = m_SearchList.Count; - } - - state.Mobile.SendGump(new XmlConfirmDeleteGump(state.Mobile, g, m_SearchList, m_SelectionList, DisplayFrom, SelectAll, allcount)); - return; - } - - case 159: // save to a .npc file - { - - // Create a new gump - Refresh(state); - // try to save - m_Dialog.DoSaveNPC(state.Mobile, SaveFilename, true); - - return; - } - - case 201: // forward block - { - // clear the selections - if (m_SelectionList != null && !SelectAll) - { - Array.Clear(m_SelectionList,0,m_SelectionList.Length); - } - - if (m_SearchList != null && DisplayFrom + MaxEntries < m_SearchList.Count) - { - DisplayFrom += MaxEntries; - // clear any selection - Selected = -1; - } - break; - } - case 202: // backward block - { - // clear the selections - if (m_SelectionList != null && !SelectAll) - { - Array.Clear(m_SelectionList,0,m_SelectionList.Length); - } - - DisplayFrom -= MaxEntries; - if (DisplayFrom < 0) - { - DisplayFrom = 0; - } - - // clear any selection - Selected = -1; - break; - } - - case 700: // Sort - { - // clear any selection - Selected = -1; - // clear the selections - if (m_SelectionList != null && !SelectAll) - { - Array.Clear(m_SelectionList,0,m_SelectionList.Length); - } - - SortFindList(); - break; - } - - case 9998: // refresh the gump - { - // clear any selection - Selected = -1; - break; - } - default: - { - - if (info.ButtonID >= 1000 && info.ButtonID < 1000+ MaxEntries) - { - // flag the entry selected - Selected = info.ButtonID - 1000; - } - else - if (info.ButtonID == 3998) - { - - SelectAll = !SelectAll; - - // dont allow individual selection with the selectall button selected - if (m_SelectionList != null) - { - for(int i = 0; i < MaxEntries;i++) - { - if (i < m_SelectionList.Length) - { - // only toggle the selection list entries for things that actually have entries - m_SelectionList[i] = SelectAll; - } - else - { - break; - } - } - } - } - else - if (info.ButtonID == 3999) - { - - // dont allow individual selection with the selectall button selected - if (m_SelectionList != null && m_SearchList != null && !SelectAll) - { - for(int i = 0; i < MaxEntries;i++) - { - if (i < m_SelectionList.Length) - { - // only toggle the selection list entries for things that actually have entries - if (m_SearchList.Count - DisplayFrom > i) - { - m_SelectionList[i] = !m_SelectionList[i]; - } - } - else - { - break; - } - } - } - } - else - if (info.ButtonID >= 4000 && info.ButtonID < 4000+ MaxEntries) - { - int i = info.ButtonID - 4000; - // dont allow individual selection with the selectall button selected - if (m_SelectionList != null && i >= 0 && i < m_SelectionList.Length && !SelectAll) - { - // only toggle the selection list entries for things that actually have entries - if (m_SearchList != null && m_SearchList.Count - DisplayFrom > i) - { - m_SelectionList[i] = !m_SelectionList[i]; - } - } - } - else - if (info.ButtonID >= 5000 && info.ButtonID < 5100) - { - - - // text entry book buttons - int textid = info.ButtonID - 5000; - - // entry information - XmlDialog.SpeechEntry entry = null; - - if (m_SearchList != null && Selected >= 0 && Selected + DisplayFrom >= 0 && Selected + DisplayFrom < m_SearchList.Count) - { - entry = (XmlDialog.SpeechEntry)m_SearchList[Selected + DisplayFrom]; - } - - string text = String.Empty; - string title = String.Empty; - switch (textid) - { - case 0: // text - { - if (entry != null) - { - text = entry.Text; - } - - title = "Text"; - break; - } - case 1: // keywords - { - if (entry != null) - { - text = entry.Keywords; - } - - title = "Keywords"; - break; - } - case 2: // condition - { - if (entry != null) - { - text = entry.Condition; - } - - title = "Condition"; - break; - } - case 3: // action - { - if (entry != null) - { - text = entry.Action; - } - - title = "Action"; - break; - } - case 4: // gump - { - if (entry != null) - { - text = entry.Gump; - } - - title = "Gump"; - break; - } - case 5: // trigoncarried - { - text = m_Dialog.TriggerOnCarried; - title = "TrigOnCarried"; - break; - } - case 6: // notrigoncarried - { - text = m_Dialog.NoTriggerOnCarried; - title = "NoTrigOnCarried"; - break; - } - } - - object [] args = new object[6]; - - args[0] = m_Dialog; - args[1] = entry; - args[2] = textid; - args[3] = Selected; - args[4] = DisplayFrom; - args[5] = SaveFilename; - - XmlTextEntryBook book = new XmlTextEntryBook(0, String.Empty, m_Dialog.Name, 20, true); - //XmlTextEntryBook book = new XmlTextEntryBook(0, String.Empty, m_Dialog.Name, 20, true, new XmlTextEntryBookCallback(ProcessXmlEditBookEntry), args); - if (m_Dialog.m_TextEntryBook == null) - { - m_Dialog.m_TextEntryBook = new ArrayList(); - } - m_Dialog.m_TextEntryBook.Add(book); - - book.Title = title; - book.Author = Name; - - // fill the contents of the book with the current text entry data - book.FillTextEntryBook(text); - - // put the book at the location of the player so that it can be opened, but drop it below visible range - book.Visible = false; - book.Movable = false; - book.MoveToWorld(new Point3D(state.Mobile.Location.X,state.Mobile.Location.Y,state.Mobile.Location.Z-100), state.Mobile.Map); - - // Create a new gump - Refresh(state); - - // and open it - book.OnDoubleClick(state.Mobile); - - return; - - } - break; - } - } - // Create a new gump - Refresh(state); - } - - - public class XmlConfirmDeleteGump : Gump - { - private ArrayList SearchList; - private bool [] SelectedList; - private Mobile From; - private int DisplayFrom; - private bool selectAll; - XmlEditDialogGump m_Gump; - - public XmlConfirmDeleteGump(Mobile from, XmlEditDialogGump gump, ArrayList searchlist, bool [] selectedlist, int displayfrom, bool selectall, int allcount) : base (0, 0) - { - SearchList = searchlist; - SelectedList = selectedlist; - DisplayFrom = displayfrom; - selectAll = selectall; - m_Gump = gump; - From = from; - Closable = false; - Draggable = true; - AddPage(0); - AddBackground(10, 200, 200, 130, 5054); - int count = 0; - if (selectall) - { - count = allcount; - } - else - { - for(int i =0;i 0) - { - radiostate = info.Switches[0]; - } - switch (info.ButtonID) - { - - default: - { - if (radiostate == 1 && SearchList != null && SelectedList != null) - { // accept - ArrayList dlist = new ArrayList(); - for(int i = 0;i < SearchList.Count;i++) - { - int index = i-DisplayFrom; - if (index >= 0 && index < SelectedList.Length && SelectedList[index] || selectAll) - { - object o = SearchList[i]; - // delete the entry; - dlist.Add(o); - } - } - - foreach(object o in dlist) - { - SearchList.Remove(o); - } - - // clear the selections - Array.Clear(SelectedList,0,SelectedList.Length); - - if (m_Gump != null) - { - state.Mobile.CloseGump(); - m_Gump.Refresh(state); - } - } - break; - } - } - } - } -} diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlFind.cs b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlFind.cs index 7ad581eba..34ea93a2e 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlFind.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlFind.cs @@ -59,7 +59,7 @@ public class XmlFindGump : Gump from.SendGump(gump); if (status_str != null) { - from.SendMessage(33, "XmlFind: {0}", status_str); + from.SendMessage(33, $"XmlFind: {status_str}"); } } } @@ -280,7 +280,7 @@ public class XmlFindGump : Gump if (direction) { // true means allow only mobs greater than the age - if (DateTime.UtcNow - mob.Created > TimeSpan.FromHours(age)) + if (Core.Now - mob.Created > TimeSpan.FromHours(age)) { return true; } @@ -288,7 +288,7 @@ public class XmlFindGump : Gump else { // false means allow only mobs less than the age - if (DateTime.UtcNow - mob.Created < TimeSpan.FromHours(age)) + if (Core.Now - mob.Created < TimeSpan.FromHours(age)) { return true; } @@ -843,7 +843,7 @@ public class XmlFindGump : Gump catch { dorange = false; - e.Mobile.SendMessage("Invalid range argument {0}", e.Arguments[1]); + e.Mobile.SendMessage($"Invalid range argument {e.Arguments[1]}"); } } @@ -1844,7 +1844,7 @@ public class XmlFindGump : Gump return; } } - from.SendMessage("Invalid command: {0}", args[0]); + from.SendMessage($"Invalid command: {args[0]}"); } } } @@ -1987,8 +1987,7 @@ public class XmlFindGump : Gump case 4: // SubSearch { // do the search - string status_str; - m_SearchList = Search(m_SearchCriteria, out status_str); + m_SearchList = Search(m_SearchCriteria, out _); break; } case 150: // Open the map gump