From 12e935e4f49cec7d766c24ac902125ab5672e212 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 26 Sep 2020 22:38:50 -0700 Subject: [PATCH] Adds property sorting for json output (#266) --- .../Configuration/ServerConfiguration.cs | 21 +- Projects/Server/Items/Container.cs | 12 +- .../Converters/IPEndPointConverter.cs | 0 .../Converters/IPEndPointConverterFactory.cs | 0 .../Converters/MapConverter.cs | 0 .../Converters/MapConverterFactory.cs | 0 .../Converters/NullableStructSerializer.cs | 0 .../NullableStructSerializerFactory.cs | 0 .../Converters/Point2DConverter.cs | 0 .../Converters/Point2DConverterFactory.cs | 0 .../Converters/Point3DConverter.cs | 0 .../Converters/Point3DConverterFactory.cs | 0 .../Converters/Rectangle3DConverter.cs | 0 .../Converters/Rectangle3DConverterFactory.cs | 0 .../Converters/TimeSpanConverter.cs | 0 .../Converters/TimeSpanConverterFactory.cs | 0 .../Converters/TypeConverter.cs | 0 .../Converters/TypeConverterFactory.cs | 0 .../Converters/WorldLocationConverter.cs | 0 .../WorldLocationConverterFactory.cs | 0 .../DynamicJson.cs | 0 .../{JsonConfiguration => Json}/JsonConfig.cs | 11 +- Projects/Server/Json/JsonUtilities.cs | 100 ++++++++++ Projects/Server/Regions/Region.cs | 4 +- .../Configuration/EmailConfiguration.cs | 12 +- .../UOContent/Engines/BulkOrders/Rewards.cs | 2 +- .../UOContent/Engines/Craft/Core/CraftGump.cs | 4 +- .../New Guild System/GuildRosterGump.cs | 2 +- Projects/UOContent/Gumps/SkillsGump.cs | 186 +++++++++--------- .../UOContent/Mobiles/AI/OppositionGroup.cs | 2 +- .../Spells/Necromancy/AnimateDeadSpell.cs | 2 +- 31 files changed, 228 insertions(+), 130 deletions(-) rename Projects/Server/{JsonConfiguration => Json}/Converters/IPEndPointConverter.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/IPEndPointConverterFactory.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/MapConverter.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/MapConverterFactory.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/NullableStructSerializer.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/NullableStructSerializerFactory.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/Point2DConverter.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/Point2DConverterFactory.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/Point3DConverter.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/Point3DConverterFactory.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/Rectangle3DConverter.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/Rectangle3DConverterFactory.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/TimeSpanConverter.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/TimeSpanConverterFactory.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/TypeConverter.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/TypeConverterFactory.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/WorldLocationConverter.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/Converters/WorldLocationConverterFactory.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/DynamicJson.cs (100%) rename Projects/Server/{JsonConfiguration => Json}/JsonConfig.cs (90%) create mode 100644 Projects/Server/Json/JsonUtilities.cs diff --git a/Projects/Server/Configuration/ServerConfiguration.cs b/Projects/Server/Configuration/ServerConfiguration.cs index 5b78cecc3..4f31709d1 100644 --- a/Projects/Server/Configuration/ServerConfiguration.cs +++ b/Projects/Server/Configuration/ServerConfiguration.cs @@ -138,17 +138,6 @@ namespace Server Save(); } - public static T GetMetadata(string key) where T : class - { - m_Settings.metadata.TryGetValue(key, out var value); - return value as T; - } - - public static void SetMetadata(string key, object value) - { - m_Settings.metadata[key] = value; - } - // If mock is enabled we skip the console readline. public static void Load(bool mocked = false) { @@ -291,14 +280,14 @@ namespace Server internal class ServerSettings { - [JsonPropertyName("dataDirectories")] public List dataDirectories { get; set; } = new List(); + [JsonPropertyName("dataDirectories")] + public List dataDirectories { get; set; } = new List(); - [JsonPropertyName("listeners")] public List listeners { get; set; } = new List(); + [JsonPropertyName("listeners")] + public List listeners { get; set; } = new List(); [JsonPropertyName("settings")] - public Dictionary settings { get; set; } = new Dictionary(); - - [JsonExtensionData] public Dictionary metadata { get; set; } = new Dictionary(); + public SortedDictionary settings { get; set; } = new SortedDictionary(); } } } diff --git a/Projects/Server/Items/Container.cs b/Projects/Server/Items/Container.cs index fb51d3967..89e6848d8 100644 --- a/Projects/Server/Items/Container.cs +++ b/Projects/Server/Items/Container.cs @@ -859,7 +859,7 @@ namespace Server.Items if (v == 0) { - @group.Add(b); + group.Add(b); } else { @@ -971,7 +971,7 @@ namespace Server.Items if (v == 0) { - @group.Add(b); + group.Add(b); } else { @@ -1087,7 +1087,7 @@ namespace Server.Items if (v == 0) { - @group.Add(b); + group.Add(b); } else { @@ -1404,7 +1404,7 @@ namespace Server.Items if (v == 0) { - @group.Add(b); + group.Add(b); } else { @@ -1465,7 +1465,7 @@ namespace Server.Items if (v == 0) { - @group.Add(b); + group.Add(b); } else { @@ -1522,7 +1522,7 @@ namespace Server.Items if (v == 0) { - @group.Add(b); + group.Add(b); } else { diff --git a/Projects/Server/JsonConfiguration/Converters/IPEndPointConverter.cs b/Projects/Server/Json/Converters/IPEndPointConverter.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/IPEndPointConverter.cs rename to Projects/Server/Json/Converters/IPEndPointConverter.cs diff --git a/Projects/Server/JsonConfiguration/Converters/IPEndPointConverterFactory.cs b/Projects/Server/Json/Converters/IPEndPointConverterFactory.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/IPEndPointConverterFactory.cs rename to Projects/Server/Json/Converters/IPEndPointConverterFactory.cs diff --git a/Projects/Server/JsonConfiguration/Converters/MapConverter.cs b/Projects/Server/Json/Converters/MapConverter.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/MapConverter.cs rename to Projects/Server/Json/Converters/MapConverter.cs diff --git a/Projects/Server/JsonConfiguration/Converters/MapConverterFactory.cs b/Projects/Server/Json/Converters/MapConverterFactory.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/MapConverterFactory.cs rename to Projects/Server/Json/Converters/MapConverterFactory.cs diff --git a/Projects/Server/JsonConfiguration/Converters/NullableStructSerializer.cs b/Projects/Server/Json/Converters/NullableStructSerializer.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/NullableStructSerializer.cs rename to Projects/Server/Json/Converters/NullableStructSerializer.cs diff --git a/Projects/Server/JsonConfiguration/Converters/NullableStructSerializerFactory.cs b/Projects/Server/Json/Converters/NullableStructSerializerFactory.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/NullableStructSerializerFactory.cs rename to Projects/Server/Json/Converters/NullableStructSerializerFactory.cs diff --git a/Projects/Server/JsonConfiguration/Converters/Point2DConverter.cs b/Projects/Server/Json/Converters/Point2DConverter.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/Point2DConverter.cs rename to Projects/Server/Json/Converters/Point2DConverter.cs diff --git a/Projects/Server/JsonConfiguration/Converters/Point2DConverterFactory.cs b/Projects/Server/Json/Converters/Point2DConverterFactory.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/Point2DConverterFactory.cs rename to Projects/Server/Json/Converters/Point2DConverterFactory.cs diff --git a/Projects/Server/JsonConfiguration/Converters/Point3DConverter.cs b/Projects/Server/Json/Converters/Point3DConverter.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/Point3DConverter.cs rename to Projects/Server/Json/Converters/Point3DConverter.cs diff --git a/Projects/Server/JsonConfiguration/Converters/Point3DConverterFactory.cs b/Projects/Server/Json/Converters/Point3DConverterFactory.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/Point3DConverterFactory.cs rename to Projects/Server/Json/Converters/Point3DConverterFactory.cs diff --git a/Projects/Server/JsonConfiguration/Converters/Rectangle3DConverter.cs b/Projects/Server/Json/Converters/Rectangle3DConverter.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/Rectangle3DConverter.cs rename to Projects/Server/Json/Converters/Rectangle3DConverter.cs diff --git a/Projects/Server/JsonConfiguration/Converters/Rectangle3DConverterFactory.cs b/Projects/Server/Json/Converters/Rectangle3DConverterFactory.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/Rectangle3DConverterFactory.cs rename to Projects/Server/Json/Converters/Rectangle3DConverterFactory.cs diff --git a/Projects/Server/JsonConfiguration/Converters/TimeSpanConverter.cs b/Projects/Server/Json/Converters/TimeSpanConverter.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/TimeSpanConverter.cs rename to Projects/Server/Json/Converters/TimeSpanConverter.cs diff --git a/Projects/Server/JsonConfiguration/Converters/TimeSpanConverterFactory.cs b/Projects/Server/Json/Converters/TimeSpanConverterFactory.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/TimeSpanConverterFactory.cs rename to Projects/Server/Json/Converters/TimeSpanConverterFactory.cs diff --git a/Projects/Server/JsonConfiguration/Converters/TypeConverter.cs b/Projects/Server/Json/Converters/TypeConverter.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/TypeConverter.cs rename to Projects/Server/Json/Converters/TypeConverter.cs diff --git a/Projects/Server/JsonConfiguration/Converters/TypeConverterFactory.cs b/Projects/Server/Json/Converters/TypeConverterFactory.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/TypeConverterFactory.cs rename to Projects/Server/Json/Converters/TypeConverterFactory.cs diff --git a/Projects/Server/JsonConfiguration/Converters/WorldLocationConverter.cs b/Projects/Server/Json/Converters/WorldLocationConverter.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/WorldLocationConverter.cs rename to Projects/Server/Json/Converters/WorldLocationConverter.cs diff --git a/Projects/Server/JsonConfiguration/Converters/WorldLocationConverterFactory.cs b/Projects/Server/Json/Converters/WorldLocationConverterFactory.cs similarity index 100% rename from Projects/Server/JsonConfiguration/Converters/WorldLocationConverterFactory.cs rename to Projects/Server/Json/Converters/WorldLocationConverterFactory.cs diff --git a/Projects/Server/JsonConfiguration/DynamicJson.cs b/Projects/Server/Json/DynamicJson.cs similarity index 100% rename from Projects/Server/JsonConfiguration/DynamicJson.cs rename to Projects/Server/Json/DynamicJson.cs diff --git a/Projects/Server/JsonConfiguration/JsonConfig.cs b/Projects/Server/Json/JsonConfig.cs similarity index 90% rename from Projects/Server/JsonConfiguration/JsonConfig.cs rename to Projects/Server/Json/JsonConfig.cs index bfd8c70a8..9a1614e29 100644 --- a/Projects/Server/JsonConfiguration/JsonConfig.cs +++ b/Projects/Server/Json/JsonConfig.cs @@ -16,6 +16,7 @@ using System; using System.Buffers; using System.IO; +using System.Text.Encodings.Web; using System.Text.Json; using System.Text.Json.Serialization; @@ -33,7 +34,8 @@ namespace Server.Json WriteIndented = true, AllowTrailingCommas = true, IgnoreNullValues = true, - ReadCommentHandling = JsonCommentHandling.Skip + ReadCommentHandling = JsonCommentHandling.Skip, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping }; options.Converters.Add(new MapConverterFactory()); @@ -64,8 +66,13 @@ namespace Server.Json return JsonSerializer.Deserialize(text, options ?? DefaultOptions); } + public static string Serialize(object value, JsonSerializerOptions options = null) => + JsonSerializer.Serialize(value, options ?? DefaultOptions); + public static void Serialize(string filePath, object value, JsonSerializerOptions options = null) { + var contents = Serialize(value, options); + if (File.Exists(filePath)) { File.Delete(filePath); @@ -73,7 +80,7 @@ namespace Server.Json Directory.CreateDirectory(Path.GetDirectoryName(filePath)); - File.WriteAllText(filePath, JsonSerializer.Serialize(value, options ?? DefaultOptions)); + File.WriteAllText(filePath, contents); } public static T ToObject(this ref Utf8JsonReader reader, JsonSerializerOptions options = null) => diff --git a/Projects/Server/Json/JsonUtilities.cs b/Projects/Server/Json/JsonUtilities.cs new file mode 100644 index 000000000..b4976c9e5 --- /dev/null +++ b/Projects/Server/Json/JsonUtilities.cs @@ -0,0 +1,100 @@ +/************************************************************************* + * ModernUO * + * Copyright 2019-2020 - ModernUO Development Team * + * Email: hi@modernuo.com * + * File: JsonPropertySorter.cs * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + *************************************************************************/ + +using System; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.Encodings.Web; +using System.Text.Json; + +namespace Server.Json +{ + public static class JsonUtilities + { + public static string SortByPropertyName(string jsonStr) + { + using JsonDocument doc = JsonDocument.Parse(jsonStr); + return SortByPropertyName(doc.RootElement); + } + + public static string SortByPropertyName(JsonElement je) + { + // TODO: Better way to do this than a stream? + using var ms = new MemoryStream(); + JsonWriterOptions opts = new JsonWriterOptions + { + Indented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }; + + using (var writer = new Utf8JsonWriter(ms, opts)) + { + WriteJsonElementSorted(je, writer); + } + + ms.TryGetBuffer(out var buffer); + return Encoding.UTF8.GetString(buffer); + } + + private static void WriteJsonElementSorted(JsonElement je, Utf8JsonWriter writer) + { + switch(je.ValueKind) + { + case JsonValueKind.Object: + writer.WriteStartObject(); + + // TODO: This is slow, can make it faster? + foreach (JsonProperty x in je.EnumerateObject().OrderBy(prop => prop.Name)) + { + writer.WritePropertyName(x.Name); + WriteJsonElementSorted(x.Value, writer); + } + + writer.WriteEndObject(); + break; + case JsonValueKind.Array: + writer.WriteStartArray(); + foreach(JsonElement x in je.EnumerateArray()) + { + WriteJsonElementSorted(x, writer); + } + writer.WriteEndArray(); + break; + case JsonValueKind.Number: + writer.WriteNumberValue(je.GetDouble()); + break; + case JsonValueKind.String: + // Escape the string + writer.WriteStringValue(je.GetString()); + break; + case JsonValueKind.Null: + writer.WriteNullValue(); + break; + case JsonValueKind.True: + writer.WriteBooleanValue(true); + break; + case JsonValueKind.False: + writer.WriteBooleanValue(false); + break; + case JsonValueKind.Undefined: // Don't write anything + break; + default: + throw new NotImplementedException($"Kind: {je.ValueKind}"); + + } + } + } +} diff --git a/Projects/Server/Regions/Region.cs b/Projects/Server/Regions/Region.cs index 163aba550..aed457b33 100644 --- a/Projects/Server/Regions/Region.cs +++ b/Projects/Server/Regions/Region.cs @@ -649,8 +649,8 @@ namespace Server public virtual bool OnTarget(Mobile m, Target t, object o) => Parent?.OnTarget(m, t, o) != false; - public virtual bool OnCombatantChange(Mobile m, Mobile old, Mobile @new) => - Parent?.OnCombatantChange(m, old, @new) != false; + public virtual bool OnCombatantChange(Mobile m, Mobile old, Mobile newMobile) => + Parent?.OnCombatantChange(m, old, newMobile) != false; public virtual bool AllowHousing(Mobile from, Point3D p) => Parent?.AllowHousing(from, p) != false; diff --git a/Projects/UOContent/Configuration/EmailConfiguration.cs b/Projects/UOContent/Configuration/EmailConfiguration.cs index 2a852c3d9..05d715823 100644 --- a/Projects/UOContent/Configuration/EmailConfiguration.cs +++ b/Projects/UOContent/Configuration/EmailConfiguration.cs @@ -25,16 +25,16 @@ namespace Server.Configurations { private const string m_RelPath = "Configuration/email-settings.json"; - public static bool EmailEnabled { get; private set; } - public static MailboxAddress FromAddress { get; private set; } public static MailboxAddress CrashAddress { get; private set; } - public static MailboxAddress SpeechLogPageAddress { get; private set; } - public static string EmailServer { get; private set; } + public static bool EmailEnabled { get; private set; } public static int EmailPort { get; private set; } - public static string EmailServerUsername { get; private set; } - public static string EmailServerPassword { get; private set; } public static int EmailSendRetryCount { get; private set; } // seconds public static int EmailSendRetryDelay { get; private set; } // seconds + public static string EmailServer { get; private set; } + public static string EmailServerUsername { get; private set; } + public static string EmailServerPassword { get; private set; } + public static MailboxAddress FromAddress { get; private set; } + public static MailboxAddress SpeechLogPageAddress { get; private set; } public static void Configure() { diff --git a/Projects/UOContent/Engines/BulkOrders/Rewards.cs b/Projects/UOContent/Engines/BulkOrders/Rewards.cs index 77eb67ec1..9a367868b 100644 --- a/Projects/UOContent/Engines/BulkOrders/Rewards.cs +++ b/Projects/UOContent/Engines/BulkOrders/Rewards.cs @@ -173,7 +173,7 @@ namespace Server.Engines.BulkOrders if (points >= group.Points) { - return @group; + return group; } } diff --git a/Projects/UOContent/Engines/Craft/Core/CraftGump.cs b/Projects/UOContent/Engines/Craft/Core/CraftGump.cs index d40dc963b..9feeadb5a 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftGump.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftGump.cs @@ -498,7 +498,7 @@ namespace Server.Engines.Craft if (index >= 0 && index < group.CraftItems.Count) { - CraftItem(@group.CraftItems[index]); + CraftItem(group.CraftItems[index]); } } @@ -519,7 +519,7 @@ namespace Server.Engines.Craft if (index >= 0 && index < group.CraftItems.Count) { - m_From.SendGump(new CraftGumpItem(m_From, system, @group.CraftItems[index], m_Tool)); + m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems[index], m_Tool)); } } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs index 6cc5db868..98f31995f 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs @@ -133,7 +133,7 @@ namespace Server.Guilds if (pm == null || !IsMember(pm, guild) || !pm.GuildRank.GetFlag(RankFlags.CanInvitePlayer)) { - pm.SendLocalizedMessage(503301); // You don't have permission to do that. + from.SendLocalizedMessage(503301); // You don't have permission to do that. } else if (targ == null) { diff --git a/Projects/UOContent/Gumps/SkillsGump.cs b/Projects/UOContent/Gumps/SkillsGump.cs index 075f97754..3882a7abc 100644 --- a/Projects/UOContent/Gumps/SkillsGump.cs +++ b/Projects/UOContent/Gumps/SkillsGump.cs @@ -179,11 +179,11 @@ namespace Server.Gumps /* private static bool PrevLabel = OldStyle, NextLabel = OldStyle; - + private static readonly int PrevLabelOffsetX = PrevWidth + 1; - + private static readonly int PrevLabelOffsetY = 0; - + private static readonly int NextLabelOffsetX = -29; private static readonly int NextLabelOffsetY = 0; * */ @@ -306,108 +306,110 @@ namespace Server.Gumps AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); } - if (group == selected) + if (group != selected) { - var indentMaskX = BorderSize; - var indentMaskY = y + EntryHeight + OffsetSize; + continue; + } - for (var j = 0; j < group.Skills.Length; ++j) - { - var sk = target.Skills[group.Skills[j]]; + var indentMaskX = BorderSize; + var indentMaskY = y + EntryHeight + OffsetSize; - x = BorderSize + OffsetSize; - y += EntryHeight + OffsetSize; + for (var j = 0; j < group!.Skills.Length; ++j) + { + var sk = target.Skills[group.Skills[j]]; - x += OffsetSize; - x += IndentWidth; + x = BorderSize + OffsetSize; + y += EntryHeight + OffsetSize; - AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); + x += OffsetSize; + x += IndentWidth; - AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E1, 0x15E5, GetButtonID(1, j)); + AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); - x += PrevWidth + OffsetSize; + AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E1, 0x15E5, GetButtonID(1, j)); - x -= OldStyle ? OffsetSize : 0; + x += PrevWidth + OffsetSize; - AddImageTiled( - x, - y, - emptyWidth + (OldStyle ? OffsetSize * 2 : 0) - OffsetSize - IndentWidth, - EntryHeight, - EntryGumpID - ); - AddLabel(x + TextOffsetX, y, TextHue, sk == null ? "(null)" : sk.Name); - - x += emptyWidth + (OldStyle ? OffsetSize * 2 : 0) - OffsetSize - IndentWidth; - x += OffsetSize; - - if (SetGumpID != 0) - { - AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - } - - if (sk != null) - { - int buttonID1, buttonID2; - int xOffset, yOffset; - - switch (sk.Lock) - { - default: - buttonID1 = 0x983; - buttonID2 = 0x983; - xOffset = 6; - yOffset = 4; - break; - case SkillLock.Down: - buttonID1 = 0x985; - buttonID2 = 0x985; - xOffset = 6; - yOffset = 4; - break; - case SkillLock.Locked: - buttonID1 = 0x82C; - buttonID2 = 0x82C; - xOffset = 5; - yOffset = 2; - break; - } - - AddButton(x + xOffset, y + yOffset, buttonID1, buttonID2, GetButtonID(2, j)); - - y += 1; - x -= OffsetSize; - x -= 1; - x -= 50; - - AddImageTiled(x, y, 50, EntryHeight - 2, OffsetGumpID); - - x += 1; - y += 1; - - AddImageTiled(x, y, 48, EntryHeight - 4, EntryGumpID); - - AddLabelCropped( - x + TextOffsetX, - y - 1, - 48 - TextOffsetX, - EntryHeight - 3, - TextHue, - sk.Base.ToString("F1") - ); - - y -= 2; - } - } + x -= OldStyle ? OffsetSize : 0; AddImageTiled( - indentMaskX, - indentMaskY, - IndentWidth + OffsetSize, - group.Skills.Length * (EntryHeight + OffsetSize) - (i < m_Groups.Length - 1 ? OffsetSize : 0), - BackGumpID + 4 + x, + y, + emptyWidth + (OldStyle ? OffsetSize * 2 : 0) - OffsetSize - IndentWidth, + EntryHeight, + EntryGumpID ); + AddLabel(x + TextOffsetX, y, TextHue, sk == null ? "(null)" : sk.Name); + + x += emptyWidth + (OldStyle ? OffsetSize * 2 : 0) - OffsetSize - IndentWidth; + x += OffsetSize; + + if (SetGumpID != 0) + { + AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } + + if (sk != null) + { + int buttonID1, buttonID2; + int xOffset, yOffset; + + switch (sk.Lock) + { + default: + buttonID1 = 0x983; + buttonID2 = 0x983; + xOffset = 6; + yOffset = 4; + break; + case SkillLock.Down: + buttonID1 = 0x985; + buttonID2 = 0x985; + xOffset = 6; + yOffset = 4; + break; + case SkillLock.Locked: + buttonID1 = 0x82C; + buttonID2 = 0x82C; + xOffset = 5; + yOffset = 2; + break; + } + + AddButton(x + xOffset, y + yOffset, buttonID1, buttonID2, GetButtonID(2, j)); + + y += 1; + x -= OffsetSize; + x -= 1; + x -= 50; + + AddImageTiled(x, y, 50, EntryHeight - 2, OffsetGumpID); + + x += 1; + y += 1; + + AddImageTiled(x, y, 48, EntryHeight - 4, EntryGumpID); + + AddLabelCropped( + x + TextOffsetX, + y - 1, + 48 - TextOffsetX, + EntryHeight - 3, + TextHue, + sk.Base.ToString("F1") + ); + + y -= 2; + } } + + AddImageTiled( + indentMaskX, + indentMaskY, + IndentWidth + OffsetSize, + group.Skills.Length * (EntryHeight + OffsetSize) - (i < m_Groups.Length - 1 ? OffsetSize : 0), + BackGumpID + 4 + ); } } diff --git a/Projects/UOContent/Mobiles/AI/OppositionGroup.cs b/Projects/UOContent/Mobiles/AI/OppositionGroup.cs index ccabc7f39..7af0d48b2 100644 --- a/Projects/UOContent/Mobiles/AI/OppositionGroup.cs +++ b/Projects/UOContent/Mobiles/AI/OppositionGroup.cs @@ -120,7 +120,7 @@ namespace Server for (var j = 0; !contains && j < group.Length; ++j) { - contains = @group[j].IsAssignableFrom(type); + contains = group[j].IsAssignableFrom(type); } if (contains) diff --git a/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs b/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs index 61c73edfe..f71cb8992 100644 --- a/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs +++ b/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs @@ -226,7 +226,7 @@ namespace Server.Spells.Necromancy if (contains) { - return @group; + return group; } }